-
Notifications
You must be signed in to change notification settings - Fork 5
Broader handling of architectures; WITH-EVENT-DEVICES macro #8
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
base: master
Are you sure you want to change the base?
Changes from all commits
e4f4678
66fc39b
6838e1b
2cef42c
0fe425b
62fa757
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -175,11 +175,8 @@ linux/include/uapi/linux/input.h.") | |
| :test #'equal | ||
| :documentation "Relative motion types.") | ||
|
|
||
| (cond ((member (machine-type) '("X86" "armv7l") :test #'equal) | ||
| (define-unsigned unsigned-long-int 4)) | ||
| ((member (machine-type) '("X86-64" "x86_64") :test #'equal) | ||
| (define-unsigned unsigned-long-int 8)) | ||
| (t 4)) | ||
| #+32-bit(define-unsigned unsigned-long-int 4) | ||
| #+64-bit(define-unsigned unsigned-long-int 8) | ||
|
|
||
| (define-unsigned unsigned-short 2) | ||
| (define-unsigned unsigned-int 4) | ||
|
|
@@ -346,3 +343,24 @@ condition is signaled." | |
| for ,event-var = (read-event ,stream) | ||
| while ,event-var | ||
| do (progn ,@body))))) | ||
|
|
||
| (defmacro with-evdev-devices ((event-var &rest device-paths) | ||
| &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." | ||
|
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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.
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 |
||
| (let ((concatenated (gensym)) | ||
| (inputs (gensym))) | ||
| `(let* ((,inputs (loop for device-path in ',device-paths | ||
| collecting (open device-path | ||
| :element-type '(unsigned-byte 8) | ||
| :direction :input | ||
| :if-does-not-exist :error))) | ||
| (,concatenated (apply #'make-concatenated-stream ,inputs))) | ||
| (unwind-protect | ||
| (loop | ||
| for ,event-var = (read-event ,concatenated) | ||
| while ,event-var | ||
| do (progn ,@body)) | ||
| (dolist (s (concatenated-stream-streams ,concatenated)) | ||
| (close s)))))) | ||
There was a problem hiding this comment.
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.