I have tried replacing the usbdrv with the latest version, but that did not help (nor break) anything.
The hardware is EXACTLY the same as the HIDkeys project. That means mega8 connected with a supply voltage of ~3.5V. If I compile the original HIDkeys program and flash it, it works flawlessly:
[ 9819.345390] usb 2-2.1: new low speed USB device using uhci_hcd and address 15
[ 9819.500539] usb 2-2.1: configuration #1 chosen from 1 choice
[ 9819.525534] input: obdev.at HIDKeys as /devices/pci0000:00/0000:00:1d.0/usb2/2-2/2-2.1/2-2.1:1.0/input/input7
[ 9819.525650] generic-usb 0003:4242:E131.0007: input,hidraw1: USB HID v1.01 Keyboard [obdev.at HIDKeys] on usb-0000:00:1d.0-2.1/input0
However as soon as I replace the report descriptor (and change the report size), it just refuses to work and I get this:
[ 9777.097659] usb 2-2.1: new low speed USB device using uhci_hcd and address 14
[ 9777.249654] usb 2-2.1: configuration #1 chosen from 1 choice
[ 9777.264061] generic-usb: probe of 0003:4242:E131.0006 failed with error -22
Here is the diff -urN between the two files:
Code: Select all
--- main.c 2009-11-20 16:13:40.000000000 +0100
+++ minimal_not_working.c 2009-11-20 15:30:49.000000000 +0100
@@ -107,26 +107,110 @@
static uchar reportBuffer[2]; /* buffer for HID reports */
static uchar idleRate; /* in 4 ms units */
-PROGMEM char usbHidReportDescriptor[35] = { /* USB report descriptor */
- 0x05, 0x01, // USAGE_PAGE (Generic Desktop)
- 0x09, 0x06, // USAGE (Keyboard)
- 0xa1, 0x01, // COLLECTION (Application)
- 0x05, 0x07, // USAGE_PAGE (Keyboard)
- 0x19, 0xe0, // USAGE_MINIMUM (Keyboard LeftControl)
- 0x29, 0xe7, // USAGE_MAXIMUM (Keyboard Right GUI)
- 0x15, 0x00, // LOGICAL_MINIMUM (0)
- 0x25, 0x01, // LOGICAL_MAXIMUM (1)
- 0x75, 0x01, // REPORT_SIZE (1)
- 0x95, 0x08, // REPORT_COUNT (8)
- 0x81, 0x02, // INPUT (Data,Var,Abs)
- 0x95, 0x01, // REPORT_COUNT (1)
- 0x75, 0x08, // REPORT_SIZE (8)
- 0x25, 0x65, // LOGICAL_MAXIMUM (101)
- 0x19, 0x00, // USAGE_MINIMUM (Reserved (no event indicated))
- 0x29, 0x65, // USAGE_MAXIMUM (Keyboard Application)
- 0x81, 0x00, // INPUT (Data,Ary,Abs)
- 0xc0 // END_COLLECTION
+PROGMEM char usbHidReportDescriptor[121] = { /* USB report descriptor */
+ 0x05, 0x01, // USAGE_PAGE (Generic Desktop)
+ 0x09, 0x06, // USAGE (Keyboard)
+ 0xa1, 0x01, // COLLECTION (Application)
+ 0x05, 0x07, // USAGE_PAGE (Keyboard)
+ 0x15, 0x00, // LOGICAL_MINIMUM (0)
+ 0x25, 0x01, // LOGICAL_MAXIMUM (1)
+/*
+ Player 1
+ Right, Left, Down, Up
+ Left Ctrl
+ Left Alt
+ Space
+ 1
+*/
+ 0x19, 0x4f, // USAGE_MINIMUM (Keyboard Right Arrow)
+ 0x29, 0x52, // USAGE_MAXIMUM (Keyboard Up Arrow)
+ 0x75, 0x01, // REPORT_SIZE (1) 1-bit value
+ 0x95, 0x04, // REPORT_COUNT (4) 4 keys
+ 0x81, 0x02, // INPUT (Data,Var,Abs) add report
+ 0x95, 0x01, // REPORT_COUNT (1) 1 key
+
+ 0x19, 0xe0, // USAGE_MINIMUM (Keyboard LeftControl)
+ 0x29, 0xe0, // USAGE_MAXIMUM (Keyboard LeftControl)
+ 0x81, 0x02, // INPUT (Data,Var,Abs) add report
+
+ 0x19, 0xe2, // USAGE_MINIMUM (Keyboard LeftAlt)
+ 0x29, 0xe2, // USAGE_MAXIMUM (Keyboard LeftAlt)
+ 0x81, 0x02, // INPUT (Data,Var,Abs) add report
+
+ 0x19, 0x2c, // USAGE_MINIMUM (Keyboard Space)
+ 0x29, 0x2c, // USAGE_MAXIMUM (Keyboard Space)
+ 0x81, 0x02, // INPUT (Data,Var,Abs) add report
+
+ 0x19, 0x1e, // USAGE_MINIMUM (Keyboard LeftAlt)
+ 0x29, 0x1e, // USAGE_MAXIMUM (Keyboard LeftAlt)
+ 0x81, 0x02, // INPUT (Data,Var,Abs) add report
+
+/*
+ Player 2
+ G, D, F, R
+ A
+ S
+ Q
+ 2
+*/
+ 0x19, 0x0a, // USAGE_MINIMUM (Keyboard G)
+ 0x29, 0x0a, // USAGE_MAXIMUM (Keyboard G)
+ 0x81, 0x02, // INPUT (Data,Var,Abs) add report
+
+ 0x19, 0x07, // USAGE_MINIMUM (Keyboard D)
+ 0x29, 0x07, // USAGE_MAXIMUM (Keyboard D)
+ 0x81, 0x02, // INPUT (Data,Var,Abs) add report
+
+ 0x19, 0x09, // USAGE_MINIMUM (Keyboard F)
+ 0x29, 0x09, // USAGE_MAXIMUM (Keyboard F)
+ 0x81, 0x02, // INPUT (Data,Var,Abs) add report
+
+ 0x19, 0x15, // USAGE_MINIMUM (Keyboard R)
+ 0x29, 0x15, // USAGE_MAXIMUM (Keyboard R)
+ 0x81, 0x02, // INPUT (Data,Var,Abs) add report
+
+ 0x19, 0x04, // USAGE_MINIMUM (Keyboard A)
+ 0x29, 0x04, // USAGE_MAXIMUM (Keyboard A)
+ 0x81, 0x02, // INPUT (Data,Var,Abs) add report
+
+ 0x19, 0x16, // USAGE_MINIMUM (Keyboard S)
+ 0x29, 0x16, // USAGE_MAXIMUM (Keyboard S)
+ 0x81, 0x02, // INPUT (Data,Var,Abs) add report
+
+ 0x19, 0x14, // usage_minimum (keyboard Q)
+ 0x29, 0x14, // usage_maximum (keyboard Q)
+ 0x81, 0x02, // input (data,var,abs) add report
+
+ 0x19, 0x1f, // usage_minimum (keyboard 2)
+ 0x29, 0x1f, // usage_maximum (keyboard 2)
+ 0x81, 0x02, // input (data,var,abs) add report
+
+/*
+ Extra
+ 5, 6 - Coin in
+ ESC - Quit game
+*/
+
+ 0x19, 0x22, // usage_minimum (keyboard 5)
+ 0x29, 0x22, // usage_maximum (keyboard 5)
+ 0x81, 0x02, // input (data,var,abs) add report
+
+ 0x19, 0x23, // usage_minimum (keyboard 6)
+ 0x29, 0x23, // usage_maximum (keyboard 6)
+ 0x81, 0x02, // input (data,var,abs) add report
+
+ 0x19, 0x29, // usage_minimum (keyboard ESC)
+ 0x29, 0x29, // usage_maximum (keyboard ESC)
+ 0x81, 0x02, // input (data,var,abs) add report
+
+ 0x75, 0x05, // REPORT_SIZE (5) 5-bit padding
+ 0x81, 0x03, // INPUT (Const,Var,Abs) add report
+ 0xc0 // END_COLLECTION
};
+
+
+
+
/* We use a simplifed keyboard report descriptor which does not support the
* boot protocol. We don't allow setting status LEDs and we only allow one
* simultaneous key press (except modifiers). We can therefore use short
@@ -223,7 +307,10 @@
static void buildReport(uchar key)
{
/* This (not so elegant) cast saves us 10 bytes of program memory */
- *(int *)reportBuffer = pgm_read_word(keyReport[key]);
+ //*(int *)reportBuffer = pgm_read_word(keyReport[key]);
+ reportBuffer[0] = 0;
+ reportBuffer[1] = 0;
+ reportBuffer[2] = 0;
}
uchar usbFunctionSetup(uchar data[8])