summaryrefslogtreecommitdiffstats
path: root/src/tablet.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/tablet.c')
-rw-r--r--src/tablet.c109
1 files changed, 55 insertions, 54 deletions
diff --git a/src/tablet.c b/src/tablet.c
index 87d2f2a..1073b37 100644
--- a/src/tablet.c
+++ b/src/tablet.c
@@ -1,50 +1,50 @@
#include "project.h"
static const uint8_t tablet_report_descriptor[] = {
- 0x05, 0x01, // USAGE_PAGE (Generic Desktop)
- 0x09, 0x02, // USAGE (Mouse)
- 0xa1, 0x01, // COLLECTION (Application)
- 0x09, 0x01, // USAGE (Pointer)
- 0xa1, 0x00, // COLLECTION (Physical)
- 0x05, 0x01, // USAGE_PAGE (Generic Desktop)
- 0x09, 0x30, // USAGE (X)
- 0x09, 0x31, // USAGE (Y)
- 0x15, 0x00, // LOGICAL_MINIMUM (0)
- 0x26, 0xff, 0x7f, // LOGICAL_MAXIMUM (32767)
- 0x75, 0x10, // REPORT_SIZE (16)
- 0x95, 0x02, // REPORT_COUNT (2)
- 0x81, 0x02, // INPUT (Data,Var,Abs)
- 0x05, 0x01, // USAGE_PAGE (Generic Desktop)
- 0x09, 0x38, // USAGE (Wheel)
- 0x15, 0x81, // LOGICAL_MINIMUM (-127)
- 0x25, 0x7f, // LOGICAL_MAXIMUM (127)
- 0x75, 0x08, // REPORT_SIZE (8)
- 0x95, 0x01, // REPORT_COUNT (1)
- 0x81, 0x06, // INPUT (Data,Var,Rel)
- 0x05, 0x09, // USAGE_PAGE (Button)
- 0x19, 0x01, // USAGE_MINIMUM (Button 1)
- 0x29, 0x03, // USAGE_MAXIMUM (Button 3)
- 0x15, 0x00, // LOGICAL_MINIMUM (0)
- 0x25, 0x01, // LOGICAL_MAXIMUM (1)
- 0x95, 0x03, // REPORT_COUNT (3)
- 0x75, 0x01, // REPORT_SIZE (1)
- 0x81, 0x02, // INPUT (Data,Var,Abs)
- 0x95, 0x01, // REPORT_COUNT (1)
- 0x75, 0x05, // REPORT_SIZE (5)
- 0x81, 0x01, // INPUT (Cnst,Ary,Abs)
- 0xc0, // END_COLLECTION
- 0x09, 0x3c, // USAGE (Button 60)
- 0x06, 0x00, 0xff, // USAGE_PAGE (Vendor Defined Page 1)
- 0x09, 0x01, // USAGE (Vendor Usage 1)
- 0x15, 0x00, // LOGICAL_MINIMUM (0)
- 0x25, 0x01, // LOGICAL_MAXIMUM (1)
- 0x75, 0x01, // REPORT_SIZE (1)
- 0x95, 0x02, // REPORT_COUNT (2)
- 0xb1, 0x22, // FEATURE (Data,Var,Abs,NPrf)
- 0x75, 0x06, // REPORT_SIZE (6)
- 0x95, 0x01, // REPORT_COUNT (1)
- 0xb1, 0x01, // FEATURE (Cnst,Ary,Abs)
- 0xc0 // END_COLLECTION
+ 0x05, 0x01, // USAGE_PAGE (Generic Desktop)
+ 0x09, 0x02, // USAGE (Mouse)
+ 0xa1, 0x01, // COLLECTION (Application)
+ 0x09, 0x01, // USAGE (Pointer)
+ 0xa1, 0x00, // COLLECTION (Physical)
+ 0x05, 0x01, // USAGE_PAGE (Generic Desktop)
+ 0x09, 0x30, // USAGE (X)
+ 0x09, 0x31, // USAGE (Y)
+ 0x15, 0x00, // LOGICAL_MINIMUM (0)
+ 0x26, 0xff, 0x7f, // LOGICAL_MAXIMUM (32767)
+ 0x75, 0x10, // REPORT_SIZE (16)
+ 0x95, 0x02, // REPORT_COUNT (2)
+ 0x81, 0x02, // INPUT (Data,Var,Abs)
+ 0x05, 0x01, // USAGE_PAGE (Generic Desktop)
+ 0x09, 0x38, // USAGE (Wheel)
+ 0x15, 0x81, // LOGICAL_MINIMUM (-127)
+ 0x25, 0x7f, // LOGICAL_MAXIMUM (127)
+ 0x75, 0x08, // REPORT_SIZE (8)
+ 0x95, 0x01, // REPORT_COUNT (1)
+ 0x81, 0x06, // INPUT (Data,Var,Rel)
+ 0x05, 0x09, // USAGE_PAGE (Button)
+ 0x19, 0x01, // USAGE_MINIMUM (Button 1)
+ 0x29, 0x03, // USAGE_MAXIMUM (Button 3)
+ 0x15, 0x00, // LOGICAL_MINIMUM (0)
+ 0x25, 0x01, // LOGICAL_MAXIMUM (1)
+ 0x95, 0x03, // REPORT_COUNT (3)
+ 0x75, 0x01, // REPORT_SIZE (1)
+ 0x81, 0x02, // INPUT (Data,Var,Abs)
+ 0x95, 0x01, // REPORT_COUNT (1)
+ 0x75, 0x05, // REPORT_SIZE (5)
+ 0x81, 0x01, // INPUT (Cnst,Ary,Abs)
+ 0xc0, // END_COLLECTION
+ 0x09, 0x3c, // USAGE (Button 60)
+ 0x06, 0x00, 0xff, // USAGE_PAGE (Vendor Defined Page 1)
+ 0x09, 0x01, // USAGE (Vendor Usage 1)
+ 0x15, 0x00, // LOGICAL_MINIMUM (0)
+ 0x25, 0x01, // LOGICAL_MAXIMUM (1)
+ 0x75, 0x01, // REPORT_SIZE (1)
+ 0x95, 0x02, // REPORT_COUNT (2)
+ 0xb1, 0x22, // FEATURE (Data,Var,Abs,NPrf)
+ 0x75, 0x06, // REPORT_SIZE (6)
+ 0x95, 0x01, // REPORT_COUNT (1)
+ 0xb1, 0x01, // FEATURE (Cnst,Ary,Abs)
+ 0xc0 // END_COLLECTION
};
static const struct
@@ -59,8 +59,8 @@ static const struct
{
.hid_descriptor =
{
- .bLength = sizeof (tablet_function),.bDescriptorType = USB_DT_HID,.bcdHID =
- 0x0100,.bCountryCode = 0,.bNumDescriptors = 1,}
+ .bLength = sizeof (tablet_function),.bDescriptorType =
+ USB_DT_HID,.bcdHID = 0x0100,.bCountryCode = 0,.bNumDescriptors = 1,}
,.hid_report =
{
.bReportDescriptorType = USB_DT_REPORT,.wDescriptorLength =
@@ -94,7 +94,8 @@ const struct usb_interface_descriptor tablet_iface = {
};
-void tablet_get_descriptor(uint8_t **buf,uint16_t *len)
+void
+tablet_get_descriptor (uint8_t ** buf, uint16_t * len)
{
/* Handle the HID report descriptor. */
@@ -106,14 +107,14 @@ void
tablet_test (void)
{
static int c = 0;
- uint8_t buf[6] = { 0, 0, 0, 0,0 };
+ uint8_t buf[6] = { 0, 0, 0, 0, 0 };
- buf[0]=c & 0xff;
- buf[1]=(c &0x7fff) >> 8;
- buf[2]=(32767 -(c &0x7fff)) & 0xff;
- buf[3]=(32767 -(c & 0x7fff)) >> 8;
- buf[4]=(c&8 ) ? -1:1;
- buf[5]=c;
+ buf[0] = c & 0xff;
+ buf[1] = (c & 0x7fff) >> 8;
+ buf[2] = (32767 - (c & 0x7fff)) & 0xff;
+ buf[3] = (32767 - (c & 0x7fff)) >> 8;
+ buf[4] = (c & 8) ? -1 : 1;
+ buf[5] = c;
c++;