comparison 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
comparison
equal deleted inserted replaced
429:970dab727f47 430:d3cef419c849
169 } 169 }
170 170
171 transmit_previous_timeout = 0; 171 transmit_previous_timeout = 0;
172 172
173 // Prepare USB Mouse Packet 173 // Prepare USB Mouse Packet
174 // TODO Document each byte
175 // TODO Dynamically generate this code based on KLL requirements 174 // TODO Dynamically generate this code based on KLL requirements
176 *(tx_packet->buf + 0) = USBMouse_Buttons; 175 uint16_t *packet_data = (uint16_t*)(&tx_packet->buf[0]);
177 *(tx_packet->buf + 1) = 0; 176 packet_data[0] = USBMouse_Buttons;
178 *(tx_packet->buf + 2) = 0; 177 packet_data[1] = USBMouse_Relative_x;
179 *(tx_packet->buf + 3) = 0; 178 packet_data[2] = USBMouse_Relative_y;
180 *(tx_packet->buf + 4) = 0; 179 tx_packet->len = 6;
181 tx_packet->len = 5;
182 usb_tx( MOUSE_ENDPOINT, tx_packet ); 180 usb_tx( MOUSE_ENDPOINT, tx_packet );
183 181
184 // Clear status and state 182 // Clear status and state
185 USBMouse_Buttons = 0; 183 USBMouse_Buttons = 0;
184 USBMouse_Relative_x = 0;
185 USBMouse_Relative_y = 0;
186 USBMouse_Changed = 0; 186 USBMouse_Changed = 0;
187 } 187 }
188 188
189 189
190 // Move the mouse. x, y and wheel are -127 to 127. Use 0 for no movement. 190 // Move the mouse. x, y and wheel are -127 to 127. Use 0 for no movement.