Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add /dev/input/eventN number to event struct #14

Closed
wants to merge 1 commit into from

Conversation

tomlankhorst
Copy link

@tomlankhorst tomlankhorst commented Sep 19, 2019

Fixes #13

Corresponds to libspnav PR FreeSpacenav/libspnav#5

Copy link
Contributor

@jtsiomb jtsiomb left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

First of all this can't possibly be merged due to breaking changes in the protocol. But I don't get what it tries to achieve on a deeper level. Just adding an id to the device and the events, doesn't do anything if spacenavd is only able to use a single device to begin with.

Multi-device support requires pretty much a rewrite of much of spacenavd, and a new more extensive protocol for communication with the clients.

struct {
int type;
int dev;
};
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nameless structs are not valid C89. Also why make a struct here instead of just adding a dev field in the existing struct?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is just to be consistent with the spnav_event union such that both type and dev become accessible without using a nested struct.

float motion_mul;

if(lsock == -1) return;

switch(ev->type) {
case EVENT_MOTION:
data[0] = UEV_TYPE_MOTION;
data[1] = ev->dev;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can't do this. Shuffling the data fields, and increasing the length of the data, breaks the protocol.

src/dev.c Show resolved Hide resolved
@@ -44,6 +56,7 @@ int init_devices(void)
if(!dev_path_in_use(cfg.serial_dev)) {
dev = add_device();
strcpy(dev->path, cfg.serial_dev);
dev->evt_num = device_evt_num(cfg.serial_dev);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A serial device will certainly not have a /dev/input/eventN number.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would there be another identifier, such as /dev/ttyX?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, typically it would be something like /dev/ttySX or /dev/ttyUSBX.

@jtsiomb jtsiomb closed this Sep 19, 2019
@tomlankhorst
Copy link
Author

tomlankhorst commented Sep 19, 2019

@jtsiomb I totally understand that you cannot suddenly break the protocol. Thanks for taking a look anyway.
What do you mean by

spacenavd is only able to use a single device to begin with

When connecting multiple devices, spacenavd retrieves events from both of them.
I just achieved what I wanted: to be able to differentiate two connected devices by taking a look at the dev identifier in the spnav_event.

@jtsiomb
Copy link
Contributor

jtsiomb commented Sep 19, 2019

When connecting multiple devices, spacenavd retrieves events from both of them.

Nice, I must have added that feature at some point, and forgot about it. So I as long as I include a device identifier in the events of the new protocol, it'll be easy to support multiple devices. I thought I needed to restructure the code to handle input from multiple physical devices, but I guess I've done that already...

Edit: Ah that's why I don't remember doing this. I didn't write that code, it was implemented in a patch someone else sent me.

@tomlankhorst
Copy link
Author

That's great. It works flawlessly in my situation. Hope you find some time soon to work on a slightly revised protocol, if I can help you out, let me know.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Differentiate multiple devices
2 participants