Author Topic: Keyboard Example is dropping characters on OSX  (Read 6412 times)

dublo7

  • Newbie
  • *
  • Posts: 5
Keyboard Example is dropping characters on OSX
« on: December 28, 2012, 08:40:58 pm »
I'm having some troubles using the USB Keyboard example.  It seems to be dropping characters.  I've tried adding more "DigiKeyboard.update();" commands into the example, and manipulating the delay, but nothing seems to be working.

This is the output I tend to get - the initial H is missing.

Hello digispark
Hello digispark
Hello digispark
ello digispark
ello digispark
Hello digispark
Hello digispark
ello digispark
ello digispark
ello digispark

Does anyone have any tips to make things output be more reliable?

I've tried adding a delay after the update, before the first H but that hasn't worked.  Not sure what else to try.
« Last Edit: December 28, 2012, 08:40:58 pm by dublo7 »

bart

  • Newbie
  • *
  • Posts: 9
Keyboard Example is dropping characters on OSX
« Reply #1 on: December 29, 2012, 08:11:50 am »
Hello digispark
Hello digispark
Hello digispark
Hello digispark
Hello digispark
Hello digispark
Hello digispark
Hello digispark
Hello digispark
Hello digispark
Hello digispark
with OS X 10.8.2, I did not see any issues with the demo program...

dublo7

  • Newbie
  • *
  • Posts: 5
Keyboard Example is dropping characters on OSX
« Reply #2 on: December 29, 2012, 07:58:16 pm »
Mine is OSX 10.6.2... a 2009 Macbook Pro.  Maybe it\'s just too old.

dublo7

  • Newbie
  • *
  • Posts: 5
Keyboard Example is dropping characters on OSX
« Reply #3 on: December 29, 2012, 08:28:09 pm »
Appears to be a known bug - found this in the source of DigiKeyboard.h


    // TODO: Remove the next two lines once we fix
    //       missing first keystroke bug properly.
    memset(reportBuffer, 0, sizeof(reportBuffer));      
    usbSetInterrupt(reportBuffer, sizeof(reportBuffer));

digistump

  • Administrator
  • Hero Member
  • *****
  • Posts: 1465
Keyboard Example is dropping characters on OSX
« Reply #4 on: December 29, 2012, 10:21:29 pm »
I sometimes experience and issue on older machines with the first key not registering after a long pause - my work around for this (until I have time to chase issues like this - meaning after shipping is done) - is to send

DigiKeyboard.sendKeyStroke(0);

which is a keyboard event with no keystroke, to essentially wake things up after a delay, before sending more keystrokes - I only see this issue on one of my many test machines, and it is an old Atom based file server that runs the shipping program.

dublo7

  • Newbie
  • *
  • Posts: 5
Keyboard Example is dropping characters on OSX
« Reply #5 on: December 30, 2012, 08:19:08 pm »
Thanks digistump, That fixed it for me.  Maybe you could update the example program with that line and a comment so it just works out of the box.  

The only issue now is OSX doing its identify this new keyboard thing every time I plug it in.  Any idea of work arounds for that issue?

digistump

  • Administrator
  • Hero Member
  • *****
  • Posts: 1465
Keyboard Example is dropping characters on OSX
« Reply #6 on: December 30, 2012, 10:17:00 pm »
I\'ve added the line and a note to the newest release of the software package.

kcbudd

  • Newbie
  • *
  • Posts: 11
Keyboard Example is dropping characters on OSX
« Reply #7 on: December 31, 2012, 08:08:52 am »
@dublo7 - I haven\'t played with the Macs, but could it be because OSX is seeing a VendorID (VID) and ProductID (PID) combination it hasn\'t seen before?  

If so, maybe changing the USB VID and USB PID to match those of the regular apple keyboard would prevent the invocation?  I believe they\'re just defined in usbconfig.h under the DigisparkKeyboard/ library.  (Pay careful attention to the comments regarding the byte order.)  I\'d experiment with that and see if it helps.

dublo7

  • Newbie
  • *
  • Posts: 5
Keyboard Example is dropping characters on OSX
« Reply #8 on: January 02, 2013, 08:20:47 pm »
@kcbudd - Good Call, I found the following codes worked to make OSX not try to detect the keyboard.  

05ac  Apple, Inc.
0201  USB Keyboard [Alps or Logitech, M2452]

The actual lines of code I used in usbconfig.h were...

#define USB_CFG_VENDOR_ID 0xac, 0x05
#define USB_CFG_DEVICE_ID 0x01, 0x02

I left the vendor name alone so technically it\'s still reporting to be an apple keyboard with the vendor name digistump, but it will work for my purposes.

I used the list of USB vendor/product ids from the linux usb project.
http://www.linux-usb.org/usb.ids

Hopefully this helps someone in the future.

digistump

  • Administrator
  • Hero Member
  • *****
  • Posts: 1465
Keyboard Example is dropping characters on OSX
« Reply #9 on: January 02, 2013, 09:09:14 pm »
thanks for sharing that - that will definitely come in handy!