How to Send USB HID Keyboard Keystrokes to PC using uTasker??

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

How to Send USB HID Keyboard Keystrokes to PC using uTasker??

1,189 Views
alresarena
Contributor III

How to Send USB HID Keyboard Keystrokes to PC using uTasker??

I tried to send keystrokes to pc using fnwrite(keybHandle, keyData, sizeof(keyData); but it crashes the Teensy 3.5 with Kinetis mk64fxvmd12 chip..

2 Replies

845 Views
mjbcswitzerland
Specialist V

Hi Alres

1. As you know, the Teensy 3.5 doesn't support debugging so you need to build up a project in small steps to ensure that each thing you add if functional. You can however use the simulator in Visual Studio to test the operation and identify most errors before needing to load to the board.

2. Are you sure that the line of code that you show is the problem (eg. does it run without it but enumerate as keyboard)? If you are not sure start with the BLINKY configuration to check the boards LED flashes, then add functions (like USB-MSD) to verify that each step operates.

3. The line of code that you show has been added by yourself since it is not code from the reference application, which uses a keyboard handle named "USBPortID_HID_kb". Therefore, make sure that the handle is valid before using it:
- it needs to be opened before use [USBPortID_HID_kb = fnOpen(TYPE_USB, 0, &tInterfaceParameters);]
- check the handle using
if (NO_ID_ALLOCATED != keybHandle) {
    fnwrite(keybHandle, keyData, sizeof(keyData));

}
before writing since writing to a non-allocated handle will cause a crash.

4. Note that you can use the HID Keyboard reference directly too - it allows queue driven keystroke operation for speeds up to 1'000 keystrokes a second, plus includes keyboard HW interface. You can modify the routine fnKeyboardInput() if you need to customise it rather than build a new method.

Regards

Mark

P.S. I strongly recommend using VS and the simulator for Teensy work since it will allow you to exercise the code and simulate the USB operation. If the code has errors it will also fail but will allow simple debugging in VS.

845 Views
alresarena
Contributor III

THANK YOU FOR THE ADVISE SIR MARK!! :smileygrin:  I APPRECIATED YOUR REPLY :smileygrin:

0 Kudos