diff Output/pjrcUSB/arm/usb_mouse.c @ 430:d3cef419c849

Adding relative movement mouse key support - Still very basic (lots of room for improvement) - Capability format will likely change at some point - 16 bit movement control, however repeat rate limits usability (will need KLL 0.4 to make better)
author Jacob Alexander <haata@kiibohd.com>
date Mon, 21 Mar 2016 22:23:57 -0700
parents 970dab727f47
children 68e19d7c953e
line wrap: on
line diff
--- a/Output/pjrcUSB/arm/usb_mouse.c	Mon Mar 21 00:43:19 2016 -0700
+++ b/Output/pjrcUSB/arm/usb_mouse.c	Mon Mar 21 22:23:57 2016 -0700
@@ -171,18 +171,18 @@
         transmit_previous_timeout = 0;
 
         // Prepare USB Mouse Packet
-        // TODO Document each byte
         // TODO Dynamically generate this code based on KLL requirements
-        *(tx_packet->buf + 0) = USBMouse_Buttons;
-        *(tx_packet->buf + 1) = 0;
-        *(tx_packet->buf + 2) = 0;
-        *(tx_packet->buf + 3) = 0;
-        *(tx_packet->buf + 4) = 0;
-        tx_packet->len = 5;
+        uint16_t *packet_data = (uint16_t*)(&tx_packet->buf[0]);
+        packet_data[0] = USBMouse_Buttons;
+        packet_data[1] = USBMouse_Relative_x;
+        packet_data[2] = USBMouse_Relative_y;
+        tx_packet->len = 6;
         usb_tx( MOUSE_ENDPOINT, tx_packet );
 
         // Clear status and state
         USBMouse_Buttons = 0;
+        USBMouse_Relative_x = 0;
+        USBMouse_Relative_y = 0;
         USBMouse_Changed = 0;
 }