+// Sends a mouse command over the USB Output buffer
+// XXX This function *will* be changing in the future
+// If you use it, be prepared that your .kll files will break in the future (post KLL 0.5)
+// Argument #1: USB Mouse Button #
+void Output_usbMouse_capability( uint8_t state, uint8_t stateType, uint8_t *args )
+{
+ // Display capability name
+ if ( stateType == 0xFF && state == 0xFF )
+ {
+ print("Output_usbMouse(mouseButton)");
+ return;
+ }
+
+ // Determine which mouse button was sent
+ // The USB spec defines up to a max of 0xFFFF buttons
+ // The usual are:
+ // 1 - Button 1 - (Primary)
+ // 2 - Button 2 - (Secondary)
+ // 3 - Button 3 - (Tertiary)
+ uint16_t mouse_button = *(uint16_t*)(&args[0]);
+
+ // If set to zero, ignore
+ if ( mouse_button == 0 )
+ return;
+
+ // Adjust for bit shift
+ mouse_button -= 1;
+
+ // Only send mouse button if in press or hold state
+ if ( stateType == 0x00 && state == 0x03 ) // Release state
+ {
+ USBMouse_Buttons &= ~(1 << mouse_button);
+ }
+ else
+ {
+ USBMouse_Buttons |= (1 << mouse_button);
+ }
+
+ // TODO Add more states when adding full support
+ USBMouse_Changed = 1;
+}
+