|
@@ -13,34 +13,20 @@ UsbRawHidDevice UsbRawHid = UsbRawHidDevice();
|
13
|
13
|
* Redundant entries (such as LOGICAL_MINIMUM and USAGE_PAGE) have been omitted
|
14
|
14
|
* for the second INPUT item.
|
15
|
15
|
*/
|
16
|
|
-PROGMEM const char usbHidReportDescriptor[52] = { /* USB report descriptor, size must match usbconfig.h */
|
17
|
|
- 0x05, 0x01, // USAGE_PAGE (Generic Desktop)
|
18
|
|
- 0x09, 0x02, // USAGE (Mouse)
|
19
|
|
- 0xa1, 0x01, // COLLECTION (Application)
|
20
|
|
- 0x09, 0x01, // USAGE (Pointer)
|
21
|
|
- 0xA1, 0x00, // COLLECTION (Physical)
|
22
|
|
- 0x05, 0x09, // USAGE_PAGE (Button)
|
23
|
|
- 0x19, 0x01, // USAGE_MINIMUM
|
24
|
|
- 0x29, 0x03, // USAGE_MAXIMUM
|
25
|
|
- 0x15, 0x00, // LOGICAL_MINIMUM (0)
|
26
|
|
- 0x25, 0x01, // LOGICAL_MAXIMUM (1)
|
27
|
|
- 0x95, 0x03, // REPORT_COUNT (3)
|
28
|
|
- 0x75, 0x01, // REPORT_SIZE (1)
|
29
|
|
- 0x81, 0x02, // INPUT (Data,Var,Abs)
|
30
|
|
- 0x95, 0x01, // REPORT_COUNT (1)
|
31
|
|
- 0x75, 0x05, // REPORT_SIZE (5)
|
32
|
|
- 0x81, 0x03, // INPUT (Const,Var,Abs)
|
33
|
|
- 0x05, 0x01, // USAGE_PAGE (Generic Desktop)
|
34
|
|
- 0x09, 0x30, // USAGE (X)
|
35
|
|
- 0x09, 0x31, // USAGE (Y)
|
36
|
|
- 0x09, 0x38, // USAGE (Wheel)
|
37
|
|
- 0x15, 0x81, // LOGICAL_MINIMUM (-127)
|
38
|
|
- 0x25, 0x7F, // LOGICAL_MAXIMUM (127)
|
39
|
|
- 0x75, 0x08, // REPORT_SIZE (8)
|
40
|
|
- 0x95, 0x03, // REPORT_COUNT (3)
|
41
|
|
- 0x81, 0x06, // INPUT (Data,Var,Rel)
|
42
|
|
- 0xC0, // END_COLLECTION
|
43
|
|
- 0xC0, // END COLLECTION
|
|
16
|
+PROGMEM const char usbHidReportDescriptor[32] = {
|
|
17
|
+ 0x06, 0x42, 0xff,
|
|
18
|
+ 0x0A, 0x42, 0xff,
|
|
19
|
+ 0xA1, 0x01, // Collection 0x01
|
|
20
|
+ 0x75, 0x08, // report size = 8 bits
|
|
21
|
+ 0x15, 0x00, // logical minimum = 0
|
|
22
|
+ 0x26, 0xFF, 0x00, // logical maximum = 255
|
|
23
|
+ 0x95, RAWHID_TX_SIZE, // report count
|
|
24
|
+ 0x09, 0x01, // usage
|
|
25
|
+ 0x81, 0x02, // Input (array)
|
|
26
|
+ 0x95, RAWHID_RX_SIZE, // report count
|
|
27
|
+ 0x09, 0x02, // usage
|
|
28
|
+ 0x91, 0x02, // Output (array)
|
|
29
|
+ 0xC0 // end collection
|
44
|
30
|
};
|
45
|
31
|
|
46
|
32
|
UsbRawHidDevice::UsbRawHidDevice()
|
|
@@ -53,6 +39,7 @@ UsbRawHidDevice::UsbRawHidDevice()
|
53
|
39
|
usbDeviceConnect();
|
54
|
40
|
usbInit();
|
55
|
41
|
sei();
|
|
42
|
+ //sendData("", 0);
|
56
|
43
|
}
|
57
|
44
|
|
58
|
45
|
bool UsbRawHidDevice::isUsbReady()
|
|
@@ -61,6 +48,18 @@ bool UsbRawHidDevice::isUsbReady()
|
61
|
48
|
return usbInterruptIsReady();
|
62
|
49
|
}
|
63
|
50
|
|
|
51
|
+void UsbRawHidDevice::sendData(const char* data, unsigned size)
|
|
52
|
+{
|
|
53
|
+ if (size > RAWHID_TX_SIZE || size == 0)
|
|
54
|
+ {
|
|
55
|
+ size = RAWHID_TX_SIZE;
|
|
56
|
+ }
|
|
57
|
+ memcpy(reportBuffer, data, size);
|
|
58
|
+ memset(reportBuffer + size, 0, RAWHID_TX_SIZE - size);
|
|
59
|
+
|
|
60
|
+ usbSetInterrupt((unsigned char*)(void *)&reportBuffer, sizeof(reportBuffer));
|
|
61
|
+}
|
|
62
|
+
|
64
|
63
|
usbMsgLen_t usbFunctionSetup(uchar data[8])
|
65
|
64
|
{
|
66
|
65
|
usbRequest_t *rq = (usbRequest_t*)(void*)data;
|