Changes in USB keyboard support on Teensy 2.0

Status
Not open for further replies.
Hi,

I'm trying to tweak some code written five years ago for the Teensy 2.0. Back then, KEYCODE_TYPE and the KEY_xxx codes were an unsigned chars, and the code worked fine.

Now, with the changes to enable media keys on Teensy 2.0, the KEY_xxx keys are either unsigned char or unsigned int (for unicode) and I cannot see what I have to define to make it unsigned char. It is defaulting to unsigned int (for unicode) rather than unsigned chart (for ASCII).

I just want to compile my code and make an unrelated tweak (this code is reading an Infra-red remote control and generating USB keyboard keypresses).

Does anyone know how I can ask the USB keyboard support to either make KEYCODE_TYPE be a 16 bit int or that the KEY_xxx codes generate an 8 bit char?

Thanks,

Paul
 
Last edited:
Code is trivially simple:

typedef struct
{
unsigned char ir_code;
KEYCODE_TYPE keyboard_code;
KEYCODE_TYPE keyboard_modifier;
} keyboard_entry_t;

keyboard_entry_t nec_key_translation[] = {
{ 0x15, KEY_ENTER, 0 }, /*OK*/
{ 0x1B, KEY_LEFT, 0 }, /*LEFT*/
{ 0x1C, KEY_RIGHT, 0 }, /*RIGHT*/
{ 0x0B, KEY_UP, 0 }, /*UP*/

and the error is (repeated umpteen times for all the keys):
IR_Keyboard:114: error: narrowing conversion of '61480' from 'unsigned int' to 'uint8_t {aka unsigned char}' inside { } [-Wnarrowing]
};
 
So it looks like KEYBOARD_TYPE is being defined somewhere as 8 bit, but the KEY_xxx codes are generating 16 bit values...

I'm running the latest teensyduino and Arduino 1.8.10
 
Last edited:
I suppose I could make it compile by simply changing the struct to use unsigned int instead of KEYCODE_TYPE but that feels like the sort of hack that will bite me later.
 
Status
Not open for further replies.
Back
Top