For our thesis we are working with an Arduino Due. We bought it especially for the 2nd USB port which can emulate a keyboard.The intention was to take over the characters sent by a keyboard towards a game on PC. Instead of playing the game on the keyboardthe Arduino should collect data from other devices (like potmeters and switches) and sent the proper characters towards the game.

Unfortunally our game does not recognize the Native USB interface as a full compliant keyboard.However other programs are accepting fine the characters sent by the Arduino Due.

I don't know that much of an USB interface but with USBlyzer I managed to detect some differences.My keyboard has 2 interfaces (keyboard and Mouse) The binterfaceClass/binterfaceSubClass/binterfaceProtocol is keyboard: 03_01_01 and mouse 03_01_02

For the native USB interface however, I see it is defined as a CDC device with 4 pipes. (??)The last "Interface Descriptor" has a similar binterfaceClass/binterfaceSubClass/binterfaceProtocol : 03_00_00.The others are CDC descriptors.(Communication Device Class)

The Point is, not to send a Key but an condition (pressed or not pressed, that's the question XD )In the Tutorial a delay ist used, for the game use Keyboard.press when it's pressed and then Keyboard.releaseAll when it's no longer pressed.

Yes, yes, yes. It works!!!We are very grateful. TransWarp, you saved the project!!!

But please explain what the exact difference is between sending a characterand keep it pressed for the game.I can imaging that, when the game is just polling every x miliseconds thatit is missing characters which are sent at 9600baud (~1ms)

So I tried to determ x. And below a delay(25); it started to fail once a while (the lower the more of course)tnx againYougo

The Interrupt-Logic waits till a key is pressed, then --> Interrupts the Main Program, tell a Key is pressed (Send a Signal) and the Main Program does something and continue at that point when the interrupt came (maybe with changed Values).

The Interrupt-Logic waits till the key is released, then --> Interrupts the Main Program again, send the Key Released-Signal and the Main Program does something and continue at that point when the interrupt came.

The Main Program does not waste time with waiting (there is no x), the Interrupt-Controller waits independent and sends only Signals to the Main Program.Then it depends on the programmer, how he want to deal with those Signals.

Working with Interrupts is a complete different way of programing, due the separation from the code sequence into Hardeware (it can happen at any time), the Compiler can't test all possibilities.If you know what you're doing, it's fast and cool.

I know that polling is a very inefficient way of programming and reacting.(Always the polling delay)But in this case it is the game on the PC which is doing it in the polling way. I was not expecting that. So therefore I was puzzled and came not to the idea to use the pressed key functionalityin the Arduino Due.

I will take your advice into account when I got to program someything similar on the Arduino.