0

error in <ProTrinketKeyboard.h>
Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.

error in <ProTrinketKeyboard.h>

by muellermario on Sat Feb 02, 2019 5:33 am

Hi,

could anybody please doulecheck (I am using ProTrinket 5 V)?
When I use:

TrinketKeyboard.pressKey(KEYCODE_MOD_LEFT_SHIFT, KEYCODE_MOD_RIGHT_SHIFT, MODIFIER_NONE);

the sign § gets send!!! (As I got a german keyboard it could be that you see a different sign)

As I need the above coding statement for a pinball, I would be glad if you could check!

Thanks
Regards
Mario

muellermario
 
Posts: 46
Joined: Wed Jan 27, 2016 11:53 am

Re: error in <ProTrinketKeyboard.h>

by adafruit_support_mike on Sun Feb 03, 2019 4:19 am

The values you're sending don't make sense.

KEYCODE_MOD_LEFT_SHIFT and KEYCODE_MOD_RIGHT_SHIFT are modifiers that get encoded in the first byte of a HID packet. MODIFIER_NONE contradicts the other two.

The function above also sends KEYCODE_MOD_RIGHT_SHIFT and MODIFIER_NONE as keypresses rather than modifiers.

The expression:

Code: Select all | TOGGLE FULL SIZE
    TrinketKeyboard.pressKey(KEYCODE_MOD_LEFT_SHIFT, KEYCODE_MOD_RIGHT_SHIFT, MODIFIER_NONE);
creates a HID packet that says, "press the left shift key and the key with code 0x20". 0x20 happens to be the HID key code for '3', so the packet means "shift-3". That matches the § symbol on a German keyboard.

If you want to use the left and right shift keys as modifers, do it like this:

Code: Select all | TOGGLE FULL SIZE
    TrinketKeyboard.pressKey( KEYCODE_MOD_LEFT_SHIFT + KEYCODE_MOD_RIGHT_SHIFT, KEYCODE_SPACE );
or whatever keypress you want the shift keys to modify.

If you want to use the left and right shift keys as keypresses by themselves, do this:

Code: Select all | TOGGLE FULL SIZE
    TrinketKeyboard.pressKey( 0, KEYCODE_LEFT_SHIFT, KEYCODE_RIGHT_SHIFT );

adafruit_support_mike
 
Posts: 58825
Joined: Thu Feb 11, 2010 2:51 pm

Re: error in <ProTrinketKeyboard.h>

by muellermario on Sun Feb 03, 2019 7:07 am

Hi Mike,

many many thanks!
Regards
Mario

muellermario
 
Posts: 46
Joined: Wed Jan 27, 2016 11:53 am

Please be positive and constructive with your questions and comments.