Hallo! Ich möchte eins der V-USB-Beispiele (z.B. HIDKeys (http://www.obdev.at/products/vusb/hidkeys.html) oder hid-data (http://www.obdev.at/products/vusb/download.html)) so umbauen, dass sich ein ATmega oder ATtiny als USB-Tastatur am Computer anmeldet und Tastendrücke senden kann, man ihm aber auch per SetFeature Daten senden kann. Ich habe schon einen Feature-Report in den Report-Descriptor der HIDKeys-Firmware geschrieben, aber Windows erkennt die "Tastatur" dann nicht (statt dem "Gerät angesteckt"-Sound wird der "Hardwarefehler"-Sound abgespielt). Was muss ich in den Report-Descriptor und die V-USB-Funktionen schreiben, damit der µC Tastendrücke senden und Daten empfangen kann?
Keine Ahnung, ob dir das hier was hilft, aber:
1 | PROGMEM char usbHidReportDescriptor[USB_CFG_HID_REPORT_DESCRIPTOR_LENGTH] = { /* USB report descriptor */ |
2 | 0x05, 0x01, // USAGE_PAGE (Generic Desktop) |
3 | 0x09, 0x06, // USAGE (Keyboard) |
4 | 0xa1, 0x01, // COLLECTION (Application) |
5 | 0x05, 0x07, // USAGE_PAGE (Keyboard) |
6 | 0x19, 0xe0, // USAGE_MINIMUM (Keyboard LeftControl) |
7 | 0x29, 0xe7, // USAGE_MAXIMUM (Keyboard Right GUI) |
8 | 0x15, 0x00, // LOGICAL_MINIMUM (0) |
9 | 0x25, 0x01, // LOGICAL_MAXIMUM (1) |
10 | 0x75, 0x01, // REPORT_SIZE (1) |
11 | 0x95, 0x08, // REPORT_COUNT (8) |
12 | 0x81, 0x02, // INPUT (Data,Var,Abs) |
13 | 0x95, 0x01, // REPORT_COUNT (1) |
14 | 0x75, 0x08, // REPORT_SIZE (8) |
15 | 0x25, 0x65, // LOGICAL_MAXIMUM (101) |
16 | 0x19, 0x00, // USAGE_MINIMUM (Reserved (no event indicated)) |
17 | 0x29, 0x65, // USAGE_MAXIMUM (Keyboard Application) |
18 | 0x81, 0x00, // INPUT (Data,Ary,Abs) |
19 | 0xc0 // END_COLLECTION |
20 | };
|
Hatte ich mal hier (http://macetech.com/blog/?q=node/46) her genommen und lief problemlos...
Das ist der minimalistische Tastatur-Descriptor (nur einzelne Tastendrücke, keine LEDs), der auch bei HIDKeys verwendet wird. Ich brauch aber einen, der auch Feature-Requests unterstützt - nur meldet mir Windows einen Hardwarefehler, wenn ich einfach "USAGE (Undefined)" (0x09, 0x00) und "Feature (Data,Var,Abs,Buf)" (Hexwerte habe ich gerade nicht im Kopf) dazuschreibe. Hat irgendjemand einen Beispielquelltext, wo beides (Tastatur-Implementierung und Feature-Requests) zusammen funktioniert oder kann mir erklären, was ich dazu an HIDKeys verändern muss?
Ich habs mir jetzt nicht genau angesehen, aber ggf. hilfts dir weiter: http://www.schatenseite.de/dulcimer.html?L=2 >This coincidence proves how popular the Model M still is: Another >replacement electronics to give USB connectivity to IBM’s old keyboard, >developed at the same time as rump (see above) and without knowing about >the parallel effort. *This version supports the keyboard’s LEDs as well.*
1 | char PROGMEM usbHidReportDescriptor[USB_CFG_HID_REPORT_DESCRIPTOR_LENGTH] = { |
2 | 0x05, 0x01, // USAGE_PAGE (Generic Desktop) |
3 | 0x09, 0x06, // USAGE (Keyboard) |
4 | 0xa1, 0x01, // COLLECTION (Application) |
5 | 0x05, 0x07, // USAGE_PAGE (Keyboard) |
6 | 0x19, 0xe0, // USAGE_MINIMUM (Keyboard LeftControl) |
7 | 0x29, 0xe7, // USAGE_MAXIMUM (Keyboard Right GUI) |
8 | 0x15, 0x00, // LOGICAL_MINIMUM (0) |
9 | 0x25, 0x01, // LOGICAL_MAXIMUM (1) |
10 | 0x75, 0x01, // REPORT_SIZE (1) |
11 | 0x95, 0x08, // REPORT_COUNT (8) |
12 | 0x81, 0x02, // INPUT (Data,Var,Abs) |
13 | 0x95, 0x01, // REPORT_COUNT (1) |
14 | 0x75, 0x08, // REPORT_SIZE (8) |
15 | 0x81, 0x03, // INPUT (Cnst,Var,Abs) |
16 | 0x95, 0x05, // REPORT_COUNT (5) |
17 | 0x75, 0x01, // REPORT_SIZE (1) |
18 | 0x05, 0x08, // USAGE_PAGE (LEDs) |
19 | 0x19, 0x01, // USAGE_MINIMUM (Num Lock) |
20 | 0x29, 0x05, // USAGE_MAXIMUM (Kana) |
21 | 0x91, 0x02, // OUTPUT (Data,Var,Abs) |
22 | 0x95, 0x01, // REPORT_COUNT (1) |
23 | 0x75, 0x03, // REPORT_SIZE (3) |
24 | 0x91, 0x03, // OUTPUT (Cnst,Var,Abs) |
25 | 0x95, 0x06, // REPORT_COUNT (6) |
26 | 0x75, 0x08, // REPORT_SIZE (8) |
27 | 0x15, 0x00, // LOGICAL_MINIMUM (0) |
28 | 0x25, 0x65, // LOGICAL_MAXIMUM (101) |
29 | 0x05, 0x07, // USAGE_PAGE (Keyboard) |
30 | 0x19, 0x00, // USAGE_MINIMUM (Reserved (no event indicated)) |
31 | 0x29, 0x65, // USAGE_MAXIMUM (Keyboard Application) |
32 | 0x81, 0x00, // INPUT (Data,Ary,Abs) |
33 | 0xc0 // END_COLLECTION |
34 | };
|
mfg Andreas
Bitte melde dich an um einen Beitrag zu schreiben. Anmeldung ist kostenlos und dauert nur eine Minute.
Bestehender Account
Schon ein Account bei Google/GoogleMail? Keine Anmeldung erforderlich!
Mit Google-Account einloggen
Mit Google-Account einloggen
Noch kein Account? Hier anmelden.