summaryrefslogtreecommitdiffstats
path: root/app/consumer.c
diff options
context:
space:
mode:
Diffstat (limited to 'app/consumer.c')
-rw-r--r--app/consumer.c33
1 files changed, 32 insertions, 1 deletions
diff --git a/app/consumer.c b/app/consumer.c
index 044c15b..c61c4cc 100644
--- a/app/consumer.c
+++ b/app/consumer.c
@@ -58,7 +58,7 @@ static const struct
const struct usb_endpoint_descriptor consumer_endpoint = {
.bLength = USB_DT_ENDPOINT_SIZE,
.bDescriptorType = USB_DT_ENDPOINT,
- .bEndpointAddress = 0x82,
+ .bEndpointAddress = CONSUMER_EP,
.bmAttributes = USB_ENDPOINT_ATTR_INTERRUPT,
.wMaxPacketSize = 2,
.bInterval = 0x1 //0x20,
@@ -91,3 +91,34 @@ consumer_get_descriptor (uint8_t ** buf, uint16_t * len)
*len = sizeof (consumer_report_descriptor);
}
+
+
+static void
+consumer_send (uint16_t keys)
+{
+ /*Last byte is the power wakeup stuff that we don't yet support */
+ uint8_t buf[CONSUMER_EP_TXN_SIZE] = { keys & 0xff, keys >> 8 };
+
+ usbd_ep_write_packet (usbd_dev, CONSUMER_EP, buf, sizeof(buf));
+}
+
+void consumer_dispatch(int bit,int updown)
+{
+static uint16_t keys;
+
+if (updown)
+ keys|=bit;
+else
+ keys &= ~bit;
+
+
+#ifdef DEBUG
+printf("CNS> %02x %02x\r\n",keys & 0xff, keys >>8 );
+#endif
+
+consumer_send(keys);
+
+
+}
+
+