Need your help with testing new cool addon

I am sorry.
At this point I have no idea why another addon works with your KB on BeOS and why on Haiku you can’t even get keycodes.
Maybe an error hidden deep in Haiku, who knows…

Hi Arman,

I update Haiku at least once a week, so I always run one of the latest nightly; on BeOS I use the same keyboard, and there ,thanks to another addon, I have working media keys; I tried again, on Haiku, with the latest version of your addon but again no luck :frowning:

1 Like

I think your KB simulates at least two KBs at same time — that’s can be reason why Haiku can’t detect your mediakeys. I see somewhere that BeOS can work with multiple KBs and Haiku can’t.
Anyway, thank you.

Multiple keyboards work just fine (for example you can use your laptop keyboard + an external USB one). The “problem” is they all share the same keybaord layout, so you can’t have french azerty on the laptop + spanish qwerty on the external keyboard, for example.

The problem with media keys is simply that the keycodes are not mapped to anything and I think they are not accessible at all in our keymap files. We should add this, and it should not be a very difficult change.

Nope. I mean situation when one physical KB represented as multiple KBs.
Currently addon works just fine, 'cause I’m using B_UNMAPPED_KEY_DOWN .
The trouble of Giova is that on his KB this event not raises nor returns nothing — see testing utility on same repo.

I think I’ve done my best with addon and if we want something better, we must start with desklink — at least it need command line args to change volume level.
I’ve tried, but got fail. When I’ll have another free time, I’ll start again.

This seems like a really cool addon, but for me it crashes the media_addon_server on boot (it didn’t work before boot either)

In syslog I have a traceback:

KERN: malloc() of 1841829962 bytes asked KERN: vm_soft_fault: va 0x85dc9000 not covered by area in address space KERN: vm_page_fault: vm_soft_fault returned error 'Bad address' on fault at 0x85dc905a, ip 0x1ad6f1f, write 0, user 1, thread 0x376 KERN: vm_page_fault: thread "media_addon_server" (886) in team "media_addon_server" (886) tried to read address 0x85dc905a, ip 0x1ad6f1f ("???" +0x1ad6f1f) KERN: debug_server: Thread 886 entered the debugger: Segment violation KERN: stack trace, current PC 0x1ad6f1f _PrintToStream__C8BMessagePCc + 0x1bb: KERN: (0x727b0318) 0x1ad72d2 _PrintToStream__C8BMessagePCc + 0x56e KERN: (0x727b07d8) 0x1ad6d4e PrintToStream__C8BMessage + 0x26 KERN: (0x727b0808) 0x5774f5 _LoadSettings__15MultiAudioAddOn + 0xed KERN: (0x727b08c8) 0x576a49 __15MultiAudioAddOnl + 0x71 KERN: (0x727b08f8) 0x57698d make_media_addon + 0x31 KERN: (0x727b0938) 0x13fc20d _LoadAddOn__Q38BPrivate5media18DormantNodeManagerPCclPP11BMediaAddOnPl + 0xad KERN: (0x727b0968) 0x13fb3f5 GetAddOn__Q38BPrivate5media18DormantNodeManagerl + 0xa9 KERN: (0x727b0a08) 0x15e40dc _AddOnAdded__16MediaAddonServerPCcx + 0x64 KERN: (0x727b0ac8) 0x15e2d55 AddOnEnabled__Q216MediaAddonServer14MonitorHandlerPCQ38BPrivate7Storage17add_on_entry_info + 0xd9 KERN: (0x727b0b58) 0x15ea532 _EntryCreated__Q38BPrivate7Storage19AddOnMonitorHandlerRQ38BPrivate7Storage17add_on_entry_info + 0x14a KERN: (0x727b0b98) 0x15ea373 _HandlePendingEntries__Q38BPrivate7Storage19AddOnMonitorHandler + 0x227 KERN: (0x727b0dc8) 0x15e8658 MessageReceived__Q38BPrivate7Storage19AddOnMonitorHandlerP8BMessage + 0x2c KERN: (0x727b0df8) 0x1ad34b7 DispatchMessage__7BLooperP8BMessageP8BHandler + 0x5b KERN: (0x727b0e28) 0x1ac8e45 DispatchMessage__12BApplicationP8BMessageP8BHandler + 0x4e9 KERN: (0x727b1028) 0x1ad4d39 task_looper__7BLooper + 0x205 KERN: (0x727b1068) 0x1ac77be Run__12BApplication + 0x6e KERN: (0x727b10a8) 0x15e5b36 main + 0x7e KERN: (0x727b10d8) 0x15e2b23 _start + 0x5b KERN: (0x727b1108) 0x22c5b98 runtime_loader + 0x134 KERN: debug_server: Killing team 886 (/system/servers/media_addon_server)

If I try to run the server manually after boot I get:

MediaAddonServer::InstantiatePhysialInputsAndOutputs GetFlavorAt failed for index 0! started node 0 fSettings BMessage('mfil') { type items = BMessage(0x0) { type = string("Sounds", 7 bytes) item[0] = string("Beep", 5 bytes) item[1] = string("Error notification", 19 bytes) item[2] = string("Important notification", 23 bytes) item[3] = string("Information notification", 25 bytes) item[4] = string("Key down", 9 bytes) item[5] = string("Key repeat", 11 bytes) item[6] = string("Key up", 7 bytes) item[7] = string("Mouse down", 11 bytes) item[8] = string("Mouse up", 9 bytes) item[9] = string("Progress notification", 22 bytes) item[10] = string("Startup", 8 bytes) item[11] = string("Window activated", 17 bytes) item[12] = string("Window close", 13 bytes) item[13] = string("Window minimized", 17 bytes) item[14] = string("Window open", 12 bytes) item[15] = string("Window restored", 16 bytes) item[16] = string("Window zoomed", 14 bytes) Kill Thread

This turned out to be a completely different issue that just happened to appear at the same time.

However, the utility doesn’t work for me. When I use the utilty to get key presses, nothing happens when I press the volume up/down keys (accessed through fn+F3/F4 on my laptop)

Thank you guys, when I’ll find a little time, I’ll dig into it.
In other hand, I’m C++ (and Haiku API too) newbie, so errors can be caused by me.
Currently all works on my PC with Microsoft Keyboard 2000, so it’s little hard to find fault point.

I updated utility for getting keycodes, so please try anain.
Just run it (after dowload or fetching+compilation), press media keys and write codes there.
I hope this will help us with addon, 'cause without right keycodes for your KBs I was unable to make it working.

https://bitbucket.org/ArmanHayots/mediakeyshandler/ - hg repo
https://bitbucket.org/ArmanHayots/mediakeyshandler/downloads/GetPressedKeyCodeUtility.zip - binary

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