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

Multiplexing input devices #171

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

triclops200
Copy link

This can now gracefully handle multiple input devices

Copy link
Owner

@kernc kernc left a comment

Choose a reason for hiding this comment

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

Save the indentation hodgepodge, which is absolutely not your fault, it looks good to me, thanks! Just a few comments.

}
else { // event device supplied as -d argument
std::string::size_type i = args.device.find_last_of('/');
args.device = (std::string(INPUT_EVENT_PATH) + args.device.substr(i == std::string::npos ? 0 : i + 1));
results.push_back((std::string(INPUT_EVENT_PATH) + args.device.substr(i == std::string::npos ? 0 : i + 1)));
Copy link
Owner

Choose a reason for hiding this comment

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

Could this be made to support multiple -d switches?
Or perhaps comma-separated -d device1,device2,device3?

Copy link
Author

Choose a reason for hiding this comment

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

Also will take care of in the next week or so.

for(unsigned long i = 0; i < input_fds.size() && x > 0; i++){
int fd = input_fds[i];
FD_SET(fd, &read_fds);
}
Copy link
Owner

Choose a reason for hiding this comment

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

Could this re-setting snippet be put up, above select() call?

Copy link
Author

Choose a reason for hiding this comment

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

Yes, should be, but it needs the FD_ZERO line as well. That would also allow de-complecting the initial set setup above the while loop as well.


void signal_handler(int signal)
{
if (input_fd != -1)
close(input_fd); // closing input file will break the infinite while loop
for(int i = 0; i < input_fds.size(); i++){
Copy link
Owner

Choose a reason for hiding this comment

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

Signed int here raises a compilation warning.

Copy link
Author

Choose a reason for hiding this comment

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

Oops, I'll change that sometime in the afternoon in the next week or so. If you want to make the change, it should be an unsigned long i.

@triclops200
Copy link
Author

triclops200 commented Nov 30, 2017

I haven't forgotten about this, I just got extremly busy. I'll get the other changes in later.

@rightaway
Copy link

Would this PR solve this issue for logging from all keyboards or it's something different? #38

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.

None yet

4 participants