Need your help with testing new cool addon

Updated addon too.
Still need keycodes from you, guys.

All binaries are there — https://bitbucket.org/ArmanHayots/mediakeyshandler/downloads

Вообще отдельная клава - Logitech K330
Вот коды что выдаёт та утилитка :slight_smile:

Левый верх клавы
Верхняя строка 93 первая левая кнопка
Верхняя строка 786827 почтовый клиент
Верхняя строка 786980 кнопка домик
Верхняя строка 786820 кнопка музыкальный значок - плеер
Верхняя строка 102, нижняя 62 кнопка - свернуть окна

Правый верх клавы
Верхняя строка 786615 предыдущая дорожка
Верхняя строка 786638 пауза\играть
Верхняя строка 786614 следуйщая дорожка
Верхняя строка 786659 полностью выключить кромкость
Верхняя строка 786667 - громкость
Верхняя строка 786666 + громкость

Верхняя строка 786835 кнопка калькулятор над нампадом

FN + F5 = верхняя строка 786978
FN + F6 = верхняя строка 102, нижняя строка 68
FN + F7 = верхняя строка 102, нижняя строка 41
FN + F8 = не меняется, на ней значок выключить пк
FN + PrintScreen = верхняя строка 104 меню нарисовано, открывается кнопка на Deskbar
FN + Pause Break = нижняя строка 15 стрелочка скачать, или загрузки

1 Like

Thank you BeRUS for keycodes. Currently I need only volume control ones.
Looks like no one uses USB-HID standard codes — 127-129. MS (for my MS 2000) uses 786658, 786665 and 786666, while your keyboard using 786659, 786666 and 786667.
I can’t simply put them all into code, a switcher needed.

That’s strange. Under Windows all keyboards works same even under generic drivers — but how it can be if codes are different?
Maybe bug inside Haiku input_server?

If I have enough time I’ll give this a try tomorrow but I have a laptop and I don’t know what my keyboard model is, can I send you my laptop model instead? It also has other media keys: previous, play/pause, stop and next. Will information about those be useful too? Oops, I just saw your previous comment, you don’t need those.

I could not test it today, sorry but I want to test it as soon as possible, I need to make my media keys work.

1 Like

Laptop brand and keycodes are enough.

Please check the USB specification: http://www.usb.org/developers/hidpage/Hut1_12v2.pdf
Mute for instance is available in pages 0x7 and 0xC, which means that both codes 0x0C E2 and 0x07 7F can be used.

Pages and codes happen to be defined in our headers:
http://cgit.haiku-os.org/haiku/tree/headers/os/drivers/usb/USB_hid.h#n86
http://cgit.haiku-os.org/haiku/tree/headers/os/drivers/usb/USB_hid_page_keyboard.h#n152
http://cgit.haiku-os.org/haiku/tree/headers/os/drivers/usb/USB_hid_page_consumer.h#n126

I’d kindly recommend to implement things at a lower level though:
At the moment, media keys in the Keyboard page are left unmapped (http://cgit.haiku-os.org/haiku/tree/src/add-ons/kernel/drivers/input/usb_hid/KeyboardProtocolHandler.cpp#n661)
I’d nonetheless add definitions to InterfaceDefs.h « interface « os « headers - haiku - Haiku's main repository, ie B_MEDIA_MUTE_KEY, and use this in usb_hid. ps2_hid could then be patched for PS/2 keyboards.

Side note: as already stated by others, the input filter addon is in this case superfluous, media apps can catch the new key codes, or users can use Shortcuts.

from usb_hid/KeyboardProtocolHandler.cpp

static const uint32 kKeyTable[] = {
		0x00,	// ERROR
		0x00,	// ERROR
		0x00,	// ERROR
		0x00,	// ERROR
		0x3c,	// A
		0x50,	// B
		0x4e,	// C
		0x3e,	// D

from USB HID datasheet

0 00 Reserved (no event indicated)
1 01 Keyboard   ErrorRollOver
2 02 Keyboard   POSTFail
...
4 04 a and A
5 05 b and B
6 06 c and C
7 07 D and D

What kind of magic is this?

Well, it’s a mapping table:
kKeyTable[4] => 0x3c
0x3c is the Haiku raw key code for the key A.
You can check numbers at the top of any keymap file in src/data/keymaps/.

HP Mini 210-1140 (I am not sure about the 1140 part but the keyboard is exactly the same).

The media keys produce these numbers (in the mapped section):

  • Volume down: 10
  • Volume up: 11
  • Mute/unmute: 12

That’s strange. Looks like korli was right, we need to work with low-level keys handling first.
That «zoo of keys» is completely unmaintainable.

I have a lenovo Z580 I downloaded the binary of GetPressedKeyCodeUtility and put it in.

/boot/home/config/non-packaged/add-ons/input_server/filters (it has a created date of Oct 9th)

reboted and tested. I am getting no responce. What information, if any, can I get you so that my system may be supported?

David

Also I have the same problem another user had, I have to press fn+media keys to get F9, F10, etc. but they don’t produce any codes.

You can put GetPressedKeyCodeUtility everywhere — it’s simple utility which you must run to get codes for your mediakeys.
The actual addon is called MediaKeysHandler and it must be put in /boot/home/config/non-packaged/add-ons/input_server/filters (or /boot/home/config/non-packaged/add-ons/input_server/filters for single-user with ability to disable at boot).

At this time we had troubles 'cause Haiku handles mediakeys on different devices with different codes. So more experienced devs in this thread suggests to add mediakeys support to Haiku instead of making this input filter addon.

If you want, I can add smth like configuration so you’ll able to use your keys, but it will not solve troubles with some keyboards like them which guys reported.

The problem is deep inside the Haiku.

Looks like you too. At this point there’s no help.
This requires deep changes as korli and guys suggests.

If you want working mediakeys now and your keyboard produces codes — so I’ve updated addon and now you can just write your codes to config file.
Please read complete guide here — https://bitbucket.org/ArmanHayots/mediakeyshandler

I shall not do anything more just 'cause it’s a temporary solution. We must think how to add mediakeys handling directly into Haiku.

Thank you for your help and your patience, I will wait until there is a more permanent solution.

1 Like

Hello! I have tried your addon, but couldn’t get the keycodes too.
However, there is a nice shell command setvolume, which does the job.
One can simply write a shell script and bind it to standard Haiku shortcut.
Here is a quick example of a script which increases the volume:


#!/bin/sh current=````setvolume | sed -e 's/Current volume: \(.*\) (min = -60, max = 18)/\1/'``\
step=${1-6} setvolume $((current+step))


Accordingly, “$((current-step))” can be used for decreasing the volume, as well as different volume levels can be set (I guess it depends on the sound card, mine has -60 to 18 db).
For muting/un-muting, current volume can be stored in some file. Here is an example:


#!/bin/sh current=````setvolume | sed -e 's/Current volume: \(.*\) (min = -60, max = 18)/\1/'``\

if [ $current = -60 ]; then setvolume ```cat ‘/boot/home/.current_volume’```
else echo "$current" > '/boot/home/.current_volume' setvolume -60 fi


For me it works fine as a quick fix. I hope Haiku will have a better ACPI support in the future =)

2 Likes