diff Output/usbMuxUart/output_com.c @ 447:56237ba5da6f

Adding auto-restart support whenever USB gets into an odd state - Somewhat aggresive, may cause restarts if the keyboard/OS hasn't fully intialized the keyboard - Added GET_IDLE handling and correct usage of SET_IDLE - Initial implementation of idle send, commented out as it causes issues on Mac OSX for sleeping (keyboard has been working without it) - MacOSX seems to have some sort of data corruption on the USB link, not sure why (other OSs have no issues) - Cleaned up some code - Added a longer sleep after the resume sequence to prevent possible issues sending keys too soon (may need to be increased more) Ipad support now seems flaky, though Mac, Windows seems solid. Init sequence on Linux seems slow, even though there are no errors.
author Jacob Alexander <haata@kiibohd.com>
date Fri, 27 May 2016 01:21:57 -0700
parents 380e1f0123d0
children 45feb80a2ad1
line wrap: on
line diff
--- a/Output/usbMuxUart/output_com.c	Thu May 26 11:13:35 2016 -0700
+++ b/Output/usbMuxUart/output_com.c	Fri May 27 01:21:57 2016 -0700
@@ -37,6 +37,7 @@
 #include <arm/usb_dev.h>
 #include <arm/usb_keyboard.h>
 #include <arm/usb_serial.h>
+#include "arm/usb_mouse.h"
 #endif
 
 // KLL
@@ -141,9 +142,11 @@
 
 // the idle configuration, how often we send the report to the
 // host (ms * 4) even when it hasn't changed
-uint8_t  USBKeys_Idle_Config = 125;
+// 0 - Disables
+uint8_t  USBKeys_Idle_Config = 0;
 
-// count until idle timeout
+// Count until idle timeout
+uint32_t USBKeys_Idle_Expiry = 0;
 uint8_t  USBKeys_Idle_Count = 0;
 
 // Indicates whether the Output module is fully functional
@@ -653,6 +656,23 @@
 		for ( uint8_t c = USBKeys_Sent; c < USB_BOOT_MAX_KEYS; c++ )
 			USBKeys_Keys[c] = 0;
 
+	// XXX - Behaves oddly on Mac OSX, might help with corrupted packets specific to OSX? -HaaTa
+	/*
+	// Check if idle count has been exceed, this forces usb_keyboard_send and usb_mouse_send to update
+	// TODO Add joystick as well (may be endpoint specific, currently not kept track of)
+	if ( usb_configuration && USBKeys_Idle_Config && (
+		USBKeys_Idle_Expiry < systick_millis_count ||
+		USBKeys_Idle_Expiry + USBKeys_Idle_Config * 4 >= systick_millis_count ) )
+	{
+		USBKeys_Changed = USBKeyChangeState_All;
+		USBMouse_Changed = USBMouseChangeState_All;
+	}
+	*/
+
+	// Process mouse actions
+	while ( USBMouse_Changed )
+		usb_mouse_send();
+
 	// Send keypresses while there are pending changes
 	while ( USBKeys_Changed )
 		usb_keyboard_send();