EventGhost icon indicating copy to clipboard operation
EventGhost copied to clipboard

[Keyboard plugin] Media keys do not generate events

Open maffe opened this issue 4 years ago • 10 comments

Describe the bug Media keys (Play, Pause, Mute etc.) don’t generate events.

To Reproduce

  1. Press Play or any other media key on the keyboard
  2. EventGhost does not show any keyboard event

Expected behavior Media keys should generate events like other keys, and they should support combined key presses (for example, it should be possible to assign Shift+Mute, Windows+Play or VolumeDown+VolumeUp to a macro).

Plugin version 1.1.1

EventGhost version 0.5.0-rc6

maffe avatar Jul 16 '20 17:07 maffe

I will see what I can do about writing a better keyboard hook that will support the extended keys and also key combinations properly.

kdschlosser avatar Jul 18 '20 23:07 kdschlosser

in the keyboard plugin there is an option in the config dialog. check off the option and see if the plugin starts working the way you want.

kdschlosser avatar Jul 23 '20 07:07 kdschlosser

I tried that, but it doesn’t affect the media keys. It toggles between specific and more generic events for some keys, for example, left Ctrl key generates Keyboard.LCtrl or Keyboard.Ctrl depending on the setting.

maffe avatar Jul 23 '20 09:07 maffe

Just for some background information: Media keys are not part of the keyboard layout and therefore not "normal" keys, that's why you don't get an event for them in Eventghost with the keyboard plugin. I never tried it, but maybe you can get an event for them using the HID plugin.

ThomasBott avatar Jul 23 '20 13:07 ThomasBott

No they are supposed to work. If you look at the code for cFunctions/keyhook.c you will see them listed. I am not sure why they are not working.

https://github.com/EventGhost/EventGhost/blob/master/_build/extensions/cFunctions/keyhook.c

starts at line 291.

The universal mods is supposed to load a whole different key mapping.

kdschlosser avatar Jul 23 '20 15:07 kdschlosser

I never tried it, but maybe you can get an event for them using the HID plugin.

Interesting, with the HID plugin I get events for the media keys. But:

  • I have to add each keyboard individually (I have multiple keyboards/remotes)
  • A single device is displayed as multiple HID devices, for example, a Corsair K68 RGB is displayed as 4 HID devices, in total the plugin shows 26 devices
  • Default action is triggered even if the event is assigned to a macro
  • It’s not possible to add triggers for key combinations, for example, for Shift+VolumeUp I get two separate events: Keyboard.Shift and HID.Button.233. Keys recognized by the keyboard plugin do not seem to generate HID events at all.

maffe avatar Jul 24 '20 21:07 maffe

Jep, that's how I expected it. Well, I'm happy it works! :) That you can't do key Kombinations with the media keys is kinda logical, as you're using two plugins that generate events by two different methods. With the HID plugin you can't get events for keyboard keys, as they are exclusively processed by the OS. The media keys are actually a different device/controller in the same box as your keyboard. However, you can maybe work around it with two macros; macro one is triggered my the shift key and enables macro two, macro two is triggered by your volume key and executes whatever you like it to ;) (just an example there are more ways to get there)

ThomasBott avatar Jul 24 '20 22:07 ThomasBott

However, you can maybe work around it with two macros; macro one is triggered my the shift key and enables macro two, macro two is triggered by your volume key and executes whatever you like it to ;) (just an example there are more ways to get there)

I thought about that, but there are no key release events, so there’s no clean way disable the second macro. I could start a timer with Shift, but that’s quite ugly and makes an unreliable input method. Also the keyboard plugin would completely block the Shift key :(

maffe avatar Jul 24 '20 22:07 maffe

That's right!!! depending on who makes the keyboard they may or may not use the OS key codes. Alot of time they have apecial handling of those keys and they do not let the OS handle them. I completely forgot about that. Thanks @ThomasBott for helping out with this. It would have sent me on a wild goose chase for a while before my brain finally kicked in. You also see this exact same kind of a thing with hooking the mouse as well.

kdschlosser avatar Jul 25 '20 01:07 kdschlosser

@maffe I have to put some thought into it to see if there is a clean way to go about doing what you are trying to do. I know there is a clean way I just have to think about it for a bit. give me a day I am sure I can come up with something.

kdschlosser avatar Jul 25 '20 01:07 kdschlosser