Go Down

Topic: Trouble with USB keyboard using Leonardo (Read 170 times) previous topic - next topic

jski3

Mar 14, 2019, 09:10 pm Last Edit: Mar 14, 2019, 10:26 pm by jski3
I have a "mystery box" that I know very little about. I need to get the Leonardo to function with the box while it's in BIOS setup. I downloaded the USBSerPassThruLine project from GitHub (https://github.com/gdsports/usb-metamorph/tree/master/USBSerPassThruLine) and that appears to work with every BIOS setup known to mankind except for my special box.

Every keystroke is accompanied by an implicit SHIFT. So if I call Keyboard.press('a') I get 'A'.
Or for Keyboard.press('3') I get '#'.

I've tried being as direct as possible with my own simple press() routine:

Code: [Select]
void sendReport(KeyReport* keys)
{
   HID().SendReport(2,keys,sizeof(KeyReport));
}

KeyReport rawdata;
size_t press()
{
   uint8_t i;
         
   memset(&rawdata, 0, sizeof(KeyReport));
       
//#define KEY_MOD_LCTRL  0x01
//#define KEY_MOD_LSHIFT 0x02
//#define KEY_MOD_LALT   0x04
//#define KEY_MOD_LMETA  0x08
//#define KEY_MOD_RCTRL  0x10
//#define KEY_MOD_RSHIFT 0x20
//#define KEY_MOD_RALT   0x40
//#define KEY_MOD_RMETA  0x80

//   rawdata.modifiers = KEY_MOD_RSHIFT;

   for (i=0; i<6; i++) {
      rawdata.keys[i] = KEY_1+i;
   }

  sendReport(&rawdata);
}

All to no avail.

I still get: '!@#$%^' (instead of '123456')

Any ideas?

BTW, the strangle thing is that this BIOS setup works with any USB keyboard I plug into the box. Is there some older standard this box could be using?

jski3

#1
Mar 18, 2019, 02:52 pm Last Edit: Mar 18, 2019, 02:54 pm by jski3
Had to add this to get it to work:
Code: [Select]
if (first_time) {

     first_time = 0;

     memset(&rawdata, 0x0, sizeof(KeyReport));

     rawdata.keys[0] = KEY_CAPSLOCK;
     sendReport(&rawdata);
     releaseAll();
     delay(100);

     rawdata.keys[0] = KEY_CAPSLOCK;
     sendReport(&rawdata);
     releaseAll();
     delay(100);

     rawdata.keys[0] = KEY_LEFTSHIFT;
     sendReport(&rawdata);
     releaseAll();
     delay(100);
   }

As to why this works? Who knows?

BTW, this has ZERO to do the Arduino board and everything to do with that p.o.s. box.


ieee488

BTW, this has ZERO to do the Arduino board and everything to do with that p.o.s. box.


I disagree. It has EVERYTHING to do with the Arduino board!

The fact that all other USB keyboards work and the Leonardo does not indicate that the Leonardo is not like the other USB keyboards.


.

Go Up