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

Keyboard LED indicators don't work when grab device #10

Closed
ellysh opened this issue Jun 5, 2013 · 4 comments
Closed

Keyboard LED indicators don't work when grab device #10

ellysh opened this issue Jun 5, 2013 · 4 comments

Comments

@ellysh
Copy link

ellysh commented Jun 5, 2013

Hi,

I have a question about your code sample from this issue:
link

This is source code:

dev = InputDevice(...)
dev.grab()

for ev in dev.read_loop():
    if ev.code not in (KEY_LEFTCTRL, KEY_RIGHTCTRL, KEY_Q):
        ui.write_event(ev)
        continue

    # lots of messy checks for when Q is pressed/depressed while a
    # Ctrl key is pressed (ev.value == 1)

The LED indicators don't work when device is grabbed and events are resended by ui.write_event function. Is it possible to fix the LEDs work?

@gvalkov
Copy link
Owner

gvalkov commented Jun 5, 2013

Hello,

I must admit I don't know how to fix this at the moment. My initial idea was to add EV_LED and EV_MSC to the UInput constructor (by default, the uinput device can inject only EV_KEY + EV_BTN events).

from evdev import *

cap = {
   ecodes.EV_KEY: list(ecodes.keys.keys()),
   ecodes.EV_LED: list(ecodes.LED.keys())[:-2],
   ecodes.EV_MSC: list(ecodes.MSC.keys())[:-2],
}

dev = InputDevice('/dev/input/event3')
ui = UInput(cap)
dev.grab()

for ev in dev.read_loop():
   ui.write_event(ev)

The events emitted through UInput and those that my keyboard typically emits when NUM_LOCK is pressed apprear to be the same.

I'll look in to it. Thank you for reporting this.

@ellysh
Copy link
Author

ellysh commented Jun 6, 2013

Thank you very much for your answer!

I will be wait a solution. This is very usefull feature for the keys mapping applications.

@gvalkov
Copy link
Owner

gvalkov commented Jul 1, 2013

Hello @ellysh . Pull request #13 introduced a viable workaround to this problem. Leds can now be set through dev.set_led(...).

I'm still not sure why this happens, but I have a feeling it's not entirely related to python-evdev.

@ellysh
Copy link
Author

ellysh commented Jul 1, 2013

Thank you very much!

Now it works well.

@ellysh ellysh closed this as completed Jul 1, 2013
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

No branches or pull requests

2 participants