Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to assign key press as a button #15

Open
Altitechlab opened this issue Dec 28, 2020 · 4 comments
Open

How to assign key press as a button #15

Altitechlab opened this issue Dec 28, 2020 · 4 comments

Comments

@Altitechlab
Copy link

Dear all,
Thank you so much for sharing this project. It is very useful for me.
I want to add more feature such as add Volume up or down when press a button.
But I don't understand how to assign report descriptor to a button.
Does anyone help or show me any example?
Really appreciate your help!

@AchimStuy
Copy link

Hi Mathiew,

you should add the buttons to the UI and in the listener add the code to send the report. See KeyboardSender.kt, Line 22 for an example on how to send the keyboard report and its function keyEventHandler on how to create such a keyboard report.

According to HID Usage Tables, Page 85 Volume Up and Down keys have ids 0x80 and 0x81.

Tell, if you need further assistance.

@aldrinjoemathew
Copy link

@AchimStuy Do you have any idea on how to implement long press, I mean what should be the values for the sendreport in that case?

@AchimStuy
Copy link

@aldrinjoemathew, from what I'm reading in RelativeMouseSender.kt, methods sendTestClick(), sendDoubleTapClick() as well as sendLeftClickOn() and sendLeftClickOff(), you basically send a report with key down, wait the time you want and send a report with key up.

@AchimStuy
Copy link

Hi @aldrinjoemathew, I just thought about it: I guess, you were talking of keyboard key long press and not mouse key long press? Let me cite the USB Device Class Definition for HID 1.11, Appendix C: Keyboard Implementation:

“Repeat Rate” and “Delay Before First Repeat” are implemented by the host and not in the keyboard (this means the BIOS in legacy mode). The host may use the device report rate and the number of reports to determine how long a key is being held down. Alternatively, the host may use its own clock or the idle request for the timing of thesefeatures.

So have you tried just sending the same key in a short intervall? I have read somewhere, that Windows interprets from 500ms on as repeated click, So maybe try to send the report every 100ms?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants