Quantcast
Channel: Objective Development Forums
Viewing all articles
Browse latest Browse all 4524

Re: hid-keys key repetition....

$
0
0
I define a new variable in main, lastSendKey.
int   main(void)
{
   uchar   key, keyDidChange = 0, lastKey = 0, lastSendKey = 0;

Then I change a little bit in the usbSetInterrupt part
if(keyDidChange && usbInterruptIsReady() && lastSendKey != lastKey){ //added: check so we dont send same key again :)
         keyDidChange = 0;
         /* use last key and not current key status in order to avoid lost
         changes in key status. */
         buildReport(lastKey);
         usbSetInterrupt(reportBuffer, sizeof(reportBuffer));
         lastSendKey = lastKey; // save last sended key to avoid repetions
      }
      else if (usbInterruptIsReady()) { // Usb interrupt Is ready but we haven't change key. Send no key (0)
         buildReport(0);
         usbSetInterrupt(reportBuffer, sizeof(reportBuffer));
      }


Maybee not the best way. But it works for me :)

Viewing all articles
Browse latest Browse all 4524

Trending Articles