Closed Laivindur closed 3 years ago
Hi @Laivindur
Good spot! The HidService
code was starting before any listeners were added leading to missed events on startup. However since this has been the default behaviour for a long time I've decided to keep it in place and have an autoStart
flag in HidSpecification
to drive a manual start process.
I've updated the examples (and added some ANSI colour) to reflect various customisations with a manual start being one of them.
Can you review the changes and see if it fixes this issue for you?
Platform architecture: x86-64
Resource prefix: linux-x86-64
Libusb activation: true
[32mManually starting HID services.[0m
[32mEnumerating attached devices...[0m
[34mDevice attached: HidServicesEvent{hidDevice=HidDevice [path=0001:0014:00, vendorId=0x483, productId=0x5750, serialNumber=STM3210, releaseNumber=0x200, manufacturer=STMicroelectronics, product=STM32 Custm HID, usagePage=0x0, usage=0x0, interfaceNumber=0]}[0m
HidDevice [path=0001:0014:00, vendorId=0x483, productId=0x5750, serialNumber=STM3210, releaseNumber=0x200, manufacturer=STMicroelectronics, product=STM32 Custm HID, usagePage=0x0, usage=0x0, interfaceNumber=0]
[32mWaiting 30s to demonstrate attach/detach handling. Watch for slow response after write if configured.
[0m
Worked like a charm!
I will upgrade to the new version as soon as it's released.
Thank you for the quick response and fix. It allows me to get rid of ugly walkaround :-)
Thanks for testing it @Laivindur. I'll merge it into develop
which should mean that a 0.7.0 release can be done.
Hi @gary-rowe
I have realised that, for some reason, when we call
hidService.start()
by the first time, noHidServiceEvent
is handled by the listener.Here the code I use to start
HidService
. It's very similar to the one in the project's exampleNote that, the listener, has not been implemented in the class itself. It's defined on-the-fly by an anonymous class
In production, it's a first-citizen class with its own file.
I was expecting that, during the
HidService
initialization, any HID device already attached will cause aHidServiceEvent
. Inspecting hid4java classes, I have found that, somehow, I'm right.HidService.start()
callsHidDeviceManager.start()
and ...The method
scan()
The first time any device is mapped into
attachedDevices
should result in a new call tostenerList.fireHidDeviceAttached(attachedDevice);
Given the code above, I should see something like this in the console
Note the output after
Starting HID services.
starting withDevice attached: HidServicesEvent{
.At the moment, the output is
What am I doing wrong? I'm missing something, but I don't know what
Thank you in advance.