Durgod K320 USB Keyboard
Salvatore Insalaco (8688) 7 posts |
I’m an Italian newcomer in the RISC OS world, with a brand new 4té. BUT (and that’s the interesting part) it works perfectly if I:
If I connect the keyboard without the USBHID module loaded, or I load the module after connecting the keyboard, everything crashes. There’s something I can do to help debug the issue? I’m a developer, but I’m not very familiar (yet) with RISC OS. I noticed a lot of dprintf on the USBDriver source, but I suspect there’s no way to see the messages without recompiling the ROM, is it correct? |
David Feugey (2125) 2709 posts |
Stupid question: does it works OK without USBHID? |
Salvatore Insalaco (8688) 7 posts |
That’s the interesting detail, it doesn’t work without USBHID. If I connect the keyboard without loading USBHID, it just doesn’t work or creates strange side effects (usb drive not recognised, whole operating system crash). |
David Feugey (2125) 2709 posts |
Ho ho… Is it plugged on an internal or external hub or directly to the Pi? |
David J. Ruck (33) 1636 posts |
It’s not one of these keyboards covered in RGB lighting, so it shouldn’t be that power hungry. It might be worth looking at what !USBInfo has to say about it. |
Salvatore Insalaco (8688) 7 posts |
Thank you to both David(s) for help! I’m attaching the USBInfo report for the device, if it can help:
|
Colin (478) 2433 posts |
The USBDriver just uses Interface 0, Alternate 0. It doesn’t do anything fancy so can’t see why your keyboard would fail. It sounds like the crash is in detach_keyboard as it happens When HID loads which presumably would make riscos detach the keyboard. If HID is already loaded when you plug in the keyboard you won’t get the keyboard detach. but keyboard_detach doesn’t do much. It may be that HID is using the other interfaces.
yes |
Richard Walker (2090) 431 posts |
Probably time to get the RISC OS sources set up locally, so you can build your own USBDriver (the keyboard and mouse driver). Then you can try making various tweaks, perhaps in the HID parsing, which will hopefully bring your keyboard to life. You should be able to soft-load a new USBDriver without faffing on building an entire ROM. |
Colin (478) 2433 posts |
There is no HID parsing. RISC OS uses the keyboard boot protocol – it just reads a simplified standard structure from an interrupt endpoint and sets leds when necessary – as simple as it gets really. It’s likely that HID is not using the boot protocol as I presume that HID can use any multimedia keys and that wouldn’t be possible with the boot protocol. That may explain why hid works and usbdriver doesn’t, there may be something quirky about the keyboard’s boot protocol. Edit: Here’s the usbkboard file |
Richard Walker (2090) 431 posts |
Ah… Don’t know what I was thinking of there! It has been a while, but I did once read through the keyboard and mouse drivers. I had this vague recollection that there were some areas that were a bit simple. I am probably thinking of something else entirely! I have never built an OS module with debug enabled, nor explored where the debug will appear. I imagine that you would need to do that to make any serious headway with something like USBDriver. |
Jon Abbott (1421) 2651 posts |
Is it sending multimedia key events? Unless RO now supports them, they certainly used to cause issues for the OS as it didn’t acknowledge them. You might need to code a bespoke HID driver for it, as I did for the pi-top keyboard in which case you could use my HID handler Module as a starting point. I cheated somewhat though as I didn’t code a USB attach/detach handler – something I do plan to add soon. If you want to attempt to read the HID data from the various endpoints, there’s some example BASIC code in this |
Salvatore Insalaco (8688) 7 posts |
Good news: I’ve solved the issue. The problems with this particular keyboard (but may be applicable to other non-working keyboards as well) were twofold:
Now I’ve solved the issue softloading a patched USBDriver that ignores the keyboard on the mouse driver, and ignores the STALL on the keyboard one. I don’t know if it could be useful for other people. In the meantime, I’ve learned how to compile the kernel, how to compile a specific module in debug mode, how to use DADebug, and that the file and printf backends of the debug library cause the funniest effects when used on a driver that operates in interrupt mode: if it’s useful I could write a short note on the wiki about it. Thanks to everybody for the insights and support! |
Colin (478) 2433 posts |
can be useful as it redirects the output to a Reporter window and you can see the debug output in real time. |
Richard Walker (2090) 431 posts |
Well done! Delighted that you solved your problem, and impressed you have gone from zero to kernel/USBDriver developer! :) In my opinion, this would be most welcome on the wiki. |