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

hid_keyboard: Add HID keyboard example #17

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

WallaceIT
Copy link

In this example, the device is seen as an HID keyboard.
When a pin (in this case RA3) is sensed low, a CTRL+SHIFT+1 keypress is sent to the OS.

Code comes from the hid_mouse example.

Signed-off-by: Francesco Valla [email protected]

In this example, the device is seen as an HID keyboard.
When a pin (in this case RA3) is sensed low, a CTRL+SHIFT+1 keypress is sent to the OS.

Signed-off-by: Francesco Valla <[email protected]>

if(PORTAbits.RA3 != button){
button = PORTAbits.RA3;
buf[0] = (!button?0x03:0x00); // modifier (shift+ctrl)
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

0x03 is error undefined , isn't it?

@WallaceIT
Copy link
Author

Hi,
It's ctrl+shift modifier, see https://gist.github.com/MightyPork/6da26e382a7ad91b5496ee55fdc73db2

@sergimn
Copy link

sergimn commented Jan 7, 2018

Hi!
I don't know if I'm blind or I don't have the sufficient coding skills but I'm still unable to see anything that confirms your statement. In the line 39 of the code you provided there is a commented line which says:

0x03 // Keyboard Error Undefined

And no other 0x03 is found in the whole file. Am I missing something?

@WallaceIT
Copy link
Author

Hi!
Byte 0 is reserved for modifier mask. In my code, 0x01 (lctrl) is OR'ed with 0x02 (lshift) to provide ctrl+shift modifier (0x03).
The 0x03 you are referring to is related to scan codes (bytes 2 to 7).

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

Successfully merging this pull request may close these issues.

2 participants