Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
qsb_scan.cpp@0:2a3d940c3621, 2016-02-25 (annotated)
- Committer:
- ThomasSonderDesign
- Date:
- Thu Feb 25 00:44:58 2016 +0000
- Revision:
- 0:2a3d940c3621
Test Sending scancodes over usb
Who changed what in which revision?
| User | Revision | Line number | New contents of line |
|---|---|---|---|
| ThomasSonderDesign | 0:2a3d940c3621 | 1 | /* |
| ThomasSonderDesign | 0:2a3d940c3621 | 2 | Sends a scan code to the PC over usb HID |
| ThomasSonderDesign | 0:2a3d940c3621 | 3 | */ |
| ThomasSonderDesign | 0:2a3d940c3621 | 4 | #include "mbed.h" |
| ThomasSonderDesign | 0:2a3d940c3621 | 5 | #include "USBHID.h" |
| ThomasSonderDesign | 0:2a3d940c3621 | 6 | #include "VKCodes.h" |
| ThomasSonderDesign | 0:2a3d940c3621 | 7 | |
| ThomasSonderDesign | 0:2a3d940c3621 | 8 | DigitalOut led (P0_7); |
| ThomasSonderDesign | 0:2a3d940c3621 | 9 | USBHID hid(8, 8,0x1234,0x3241); //Create a HID conection with and 8 byte input and output report, PID0x1234 VID 3241 |
| ThomasSonderDesign | 0:2a3d940c3621 | 10 | HID_REPORT send_report; |
| ThomasSonderDesign | 0:2a3d940c3621 | 11 | HID_REPORT recv_report; |
| ThomasSonderDesign | 0:2a3d940c3621 | 12 | |
| ThomasSonderDesign | 0:2a3d940c3621 | 13 | |
| ThomasSonderDesign | 0:2a3d940c3621 | 14 | int main(void){ |
| ThomasSonderDesign | 0:2a3d940c3621 | 15 | send_report.length = 8; |
| ThomasSonderDesign | 0:2a3d940c3621 | 16 | while(1){ |
| ThomasSonderDesign | 0:2a3d940c3621 | 17 | if(hid.readNB(&recv_report)){ |
| ThomasSonderDesign | 0:2a3d940c3621 | 18 | if(recv_report.data[1]==0xaa){ //reciev 0xaa puts the device into keyboard mode |
| ThomasSonderDesign | 0:2a3d940c3621 | 19 | for (int i = 0; i<10;i++){ |
| ThomasSonderDesign | 0:2a3d940c3621 | 20 | send_report.data[0] = 0; |
| ThomasSonderDesign | 0:2a3d940c3621 | 21 | send_report.data[1] = 99; //send code for mod key comibination |
| ThomasSonderDesign | 0:2a3d940c3621 | 22 | send_report.data[2] = 55; //send code for specific key |
| ThomasSonderDesign | 0:2a3d940c3621 | 23 | send_report.data[3] = 0; |
| ThomasSonderDesign | 0:2a3d940c3621 | 24 | send_report.data[4] = 0; |
| ThomasSonderDesign | 0:2a3d940c3621 | 25 | send_report.data[5] = 0; |
| ThomasSonderDesign | 0:2a3d940c3621 | 26 | send_report.data[6] = 0; |
| ThomasSonderDesign | 0:2a3d940c3621 | 27 | send_report.data[7] = 0; |
| ThomasSonderDesign | 0:2a3d940c3621 | 28 | wait_ms(58); |
| ThomasSonderDesign | 0:2a3d940c3621 | 29 | hid.send(&send_report); |
| ThomasSonderDesign | 0:2a3d940c3621 | 30 | } |
| ThomasSonderDesign | 0:2a3d940c3621 | 31 | } |
| ThomasSonderDesign | 0:2a3d940c3621 | 32 | } |
| ThomasSonderDesign | 0:2a3d940c3621 | 33 | } |
| ThomasSonderDesign | 0:2a3d940c3621 | 34 | } |