-
Notifications
You must be signed in to change notification settings - Fork 404
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
Event Device Support (evdev
)
#1943
Event Device Support (evdev
)
#1943
Conversation
@pabera @ChisSoc |
f06fcb5
to
4bd118d
Compare
Nice addition! Regarding the documentation: The best way to go would be to write a Ueer Guide Page. The live in The user guide needs
Ah, yes, |
Thanks for the feedback+
Top, I will look into adding the documentation.
@Dereference: i already have put the plugin last, but the only way to get
it to run was to add the listeners only when adding them as a "finalize"
step.
Is the performance hit without dereference really bad enough to worry about
this optimization?
Cheers!
…On Fri, Dec 30, 2022, 21:06 Chris ***@***.***> wrote:
Nice addition!
Regarding the documentation: The best way to go would be to write a Ueer
Guide Page. The live in docs/sphinx/userguide. Just create a new .rst
file and add to in the index.rst. See the bluetooth doc as an example
<https://rpi-jukebox-rfid.readthedocs.io/en/latest/userguide/bluetooth_audio_buttons.html>
.
The user guide needs
- How to activate this plugin
- How to find out the device_name that is needed for the configuration
- How to find out the button id
- And a complete configuration example, please
Ah, yes, dereference. If I remember correctly this has to do with the
order of the loading of the plugins. Try loading your plugin last.
—
Reply to this email directly, view it on GitHub
<#1943 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AA4R2KB5276MQANQHKX3PLTWP46C5ANCNFSM6AAAAAATM5NKVI>
.
You are receiving this because you authored the thread.Message ID:
***@***.***>
|
Ah yes, finalize it was. Don't worry about the performance impact. It is negligible. |
I added now a documentation. |
ef0b487
to
fde2478
Compare
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.
I read through your documentation. I found a few typos which I corrected myself rather than calling them out. I committed them to the same branch. I'd like @ChisSoc to do a last check on the Python code.
Great addition. (all though I wonder how my 3 year old would use a USB mouse to rule their Phoniebox 🤔)
Thanks for the comments, I will address them! "(all though I wonder how my 3 year old would use a USB mouse to rule their Phoniebox thinking)" The USB mouse was more a very general illustration that this works with any USB device, not necessarily an endorsement :) |
It seems that flake8 is failing due to flake8 violations in code not touched by this PR. |
A separate PR would be ok. Would you still be interested in merging this? |
For the fixes see #1989 |
b17d531
to
a01c6f0
Compare
Hi @pabera , Sorry for being unresponsive, I had quite lot of personal events that diminished my free time. I rebased the PR to the latest dev branch, so the flake8 should be fixed and the cosmetic issues should be addressed. |
I have fixed the flake8 issue in another PR (#2057). If you pull all changes again, you should be able to pass flake8 properly |
This implements an "event device" listener plugin, that enables the user to configure the phoniebox to respond to events from an "event device" (device under /dev/input). This incluces eg button presses from an USB controller or keyboard.
Includes a detailed how-to as well as example config
This is an actual usecase in case someone wants to setup a device and figure out the button ids by looking at the logs
- Remove duplicated section as suggested - Add Zero Delay Arcade USB Encoder usecase
a01c6f0
to
a93104b
Compare
Hi there, |
I also found by chance that in the old Jukebox there was already an implementation/reference about this: https://github.com/MiczFlor/RPi-Jukebox-RFID/blob/develop/components/controls/buttons_usb_encoder/README.md?plain=1 |
@votti would you mind rebasing latest changes from I think then we could merge this PR |
@pabera I am away for holidays so no access to a pi. However I just managed to get the docker dev environment (including evdev devices) runing, so I may be able to work on it till the end of the week. No hard feelings if this does not make the next release. I think having the configuration file in a final form before merging it is really important. |
This is tighly modeled after gpio. In contrast to GPIO, this is a list of devices containing each one or more input/output devices. Eg a Joystick has keys but potentially also rumble or leds. Currently only very simply input devices (buttons) are supported. This structer should enable to extend this easily.
As suggested this should be a separate file, similar to the gpioz config
Now the config for evdev is akin to GPIO. The big difference is that multiple devices with each multiple input/output devices are supported. Note that the backend is still the old event device listener backend. Thus to support more features, the backend would need to be quite drastically overhauled.
I now aligned the configuration structure with While extending the config to such new functionalities is now easy, this code is still relying on the pre-existing This functionality has been tested now in the Docker environment as I currently dont have access to my raspi. However due to the generic nature of the matter, I would expect no issues. " Investigate why I indicated that the evdev module should be listed last." - I did not find a good reason after trying also different orders. Maybe I just meant that while it looks in the provided example that it should be the first entry, it actually just should be appended. |
The attribute 'device_request' of EvDevKeyListener is now called 'device_name_request'
Fails if there is no device_name and setts proper default for 'exact'
This is required for some tests. Following the instructions from issue MiczFlor#2050 Specifically: MiczFlor#2050 (comment)
This reverts commit 75161b5. As this was not working
Currently it is hard to install zmq (MiczFlor#2050) and for CI pytest `zmq` is not available. As the test do not really require `jukebox.publishing` running, mocking it in the test avoids it being imported. Thus the tests do not require `zmq` to be installed.
I now also added some tests and fixed some bugs/edge cases found during testing. One issue I encountered is that I will add an issue that it would be nice to eventually have |
@@ -0,0 +1,59 @@ | |||
devices: # A list of evdev devices each containing one or multiple input/output devices | |||
joystick: # A nickname for a device | |||
device_name: DragonRise Inc. Generic USB # Device name |
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.
Is this just a pretty name or actually relevant to access/call the device?
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.
The 'device_name' is relevant as it is used to get the device number (in contrast to the nickname line 2 which is cosmetic).
The docs contain a section how to look it up: https://github.com/MiczFlor/RPi-Jukebox-RFID/blob/49839adb01019cb296d67dc29c06cd9a6af0bc62/documentation/builders/event-devices.md#identifying-the-device_name
@@ -0,0 +1,185 @@ | |||
""" Tests for the evdev __init__ module |
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.
I like the fact that you have put effort into tests as well. It keeps pushing the bar. It's something we haven't pushed for in the past but indeed allows to be more confident when others make changes in the future.
Could be merged? |
Let me know if there is anything still required from my side! |
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.
Approved.
Last question @votti .. How do you execute the tests in this scenario?
The tests are executed as part of the standard "pytest" call.
|
Background
As described in #1942, a plugin to support to setup listeners to event devices such as USB controller, joysticks or keyboards would be useful.
Implementation
This implementation builds on the
EvDevKeyListener
and is based on thebluetooth_audio_buttons
plugin.The following details differ from the
bluetooth_audio_buttons
plugin:deference=False
. Otherwise plugins, eg next_song, may not be initialized yet upon initialization. Is there a better way?