Black Lives Matter - Action and Equality. ... Adafruit is open and shipping.
0

Modifying Trinket USB Keyboard code: Not compling
Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.

Modifying Trinket USB Keyboard code: Not compling

by 77slevin on Sun May 10, 2020 8:57 am

I am using a Amiga Emulator with an original Amiga 1200 Case. This keyboard only goes from F1-F10 function keys, but what do you know... FS-UAE needs F12 to get into preferences/configuration.

So my idea was to modify the code from https://learn.adafruit.com/trinket-usb-keyboard/code and make the key press F12.
this line in the code says press shift and press A to print a capital A.

TrinketKeyboard.pressKey(KEYCODE_MOD_LEFT_SHIFT, KEYCODE_A);

So with my limited knowledge, I thought adapting the code to:

TrinketKeyboard.pressKey(KEYCODE_F12);

Would do the trick seeing I don't need the shift modifier for F12...alas no joy.
the code fails to compile and trows a

exit status 1
no matching function for call to 'Trinket_Keyboard::pressKey(int)'

What am I doing wrong?

77slevin
 
Posts: 2
Joined: Sun May 10, 2020 8:47 am

Re: Modifying Trinket USB Keyboard code: Not compling

by dastels on Sun May 10, 2020 10:12 am

The pressKey methods all take the modifiers as an initial argument. There is not one that takes just a keycode. Looking at the header will give you all the method signatures which documents what can be called, and with what arguments. See https://github.com/adafruit/Adafruit-Trinket-USB/blob/master/TrinketKeyboard/TrinketKeyboard.h.

If you don't want modifiers pressed, pass a 0 as the first argument.

The modifier constants consititute an 8-bit value with each modifier key represented by one of the bits. You binary-or together the ones you want. E.g. For left-control and left-shift:
Code: Select all | TOGGLE FULL SIZE
KEYCODE_MOD_LEFT_CONTROL   |  KEYCODE_MOD_LEFT_SHIFT


Dave

dastels
 
Posts: 2987
Joined: Tue Oct 20, 2015 3:22 pm

Re: Modifying Trinket USB Keyboard code: Not compling

by 77slevin on Sun May 10, 2020 10:21 am

Thanks Dave, that did the trick! I can now access my config interface.

77slevin
 
Posts: 2
Joined: Sun May 10, 2020 8:47 am

Please be positive and constructive with your questions and comments.