Skip to content

Conversation

@varjagg
Copy link
Contributor

@varjagg varjagg commented Jan 6, 2025

Please consider the following changes:

  • Add trivial-features dependency to determine the word size across architectures/compilers
  • WITH-EVDEV-DEVICES allowing handling of several input event devices as the same blocking operation

Copy link
Owner

@jtgans jtgans left a comment

Choose a reason for hiding this comment

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

I'd prefer to not merge this as-is. We need to solve the nonblocking problem in a better way.

Also, I'd like to see the int size problem solved in a better way. Can you split these two things into two different PRs?

(define-unsigned unsigned-long-int 8))
(t 4))
#+32-bit(define-unsigned unsigned-long-int 4)
#+64-bit(define-unsigned unsigned-long-int 8)
Copy link
Owner

Choose a reason for hiding this comment

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

This has always stuck in my craw, and while using these flags seem to work okay, I worry it's the wrong approach.

The more I think about it, the more I think the host CL compiler is the wrong place to put this: it's possible this library could be running in a 32-bit compiler with a 64-bit host kernel, which means these values are entirely wrong for the evdev interface.

We really need a way to identify what the host kernel's word size is, rather than the host compiler's architecture.

&body body)
"Opens DEVICE-PATHS for reading, combine individual stream events into
EVENT-VAR and calls BODY for each event passed in. DEVICE-PATHS must
exist, otherwise an error condition is signaled."
Copy link
Owner

Choose a reason for hiding this comment

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

It's also worth noting here that the event orders may be out of order, kernel depending, since you're only using a read syscall here instead of poll or otherwise. It's possible that the other devices may be ready, but you're blocked on one earlier in the list.

read-raw-event should probably at the very least be made to work in nonblocking mode for this to work correctly, or these file descriptors should be passed out in a threaded manner, or otherwise poll/select should be setup to do this, otherwise, this function isn't really what you want. I know I'm speaking C here, but that's the underlying interface we have to think about in this case.

When I designed this library, the concept was to keep it focused on doing one thing well (parse out evdev data into something useful for CL), ideally in a reentrant way. That's why I never put in anything relating to nonblocking, threading or anything else.

This meant that I was actually letting threading and nonblocking behavior exist outside of this library in the outer silica project's inputmanager handler, which felt more appropriate. In there, I was using chanl as a means to dispatch events from multiple threads into a producer/consumer setup to solve the blocking problem in a more managed way. See also handler.lisp in cl-event-handler. Effectively, while the code is currently written to only handle one evdev device, the manager could be altered to manage events from multiple handler instances, each running their own with-evdev-device loop.

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.

2 participants