Mercurial > louis > kiibohd-controller
comparison Output/pjrcUSB/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 |
comparison
equal
deleted
inserted
replaced
446:f570ab7c861a | 447:56237ba5da6f |
---|---|
135 // Indicate if USB should send update | 135 // Indicate if USB should send update |
136 USBMouseChangeState USBMouse_Changed = 0; | 136 USBMouseChangeState USBMouse_Changed = 0; |
137 | 137 |
138 // the idle configuration, how often we send the report to the | 138 // the idle configuration, how often we send the report to the |
139 // host (ms * 4) even when it hasn't changed | 139 // host (ms * 4) even when it hasn't changed |
140 uint8_t USBKeys_Idle_Config = 125; | 140 // 0 - Disables |
141 | 141 uint8_t USBKeys_Idle_Config = 0; |
142 // count until idle timeout | 142 |
143 // Count until idle timeout | |
144 uint32_t USBKeys_Idle_Expiry = 0; | |
143 uint8_t USBKeys_Idle_Count = 0; | 145 uint8_t USBKeys_Idle_Count = 0; |
144 | 146 |
145 // Indicates whether the Output module is fully functional | 147 // Indicates whether the Output module is fully functional |
146 // 0 - Not fully functional, 1 - Fully functional | 148 // 0 - Not fully functional, 1 - Fully functional |
147 // 0 is often used to show that a USB cable is not plugged in (but has power) | 149 // 0 is often used to show that a USB cable is not plugged in (but has power) |
644 // Boot Mode Only, unset stale keys | 646 // Boot Mode Only, unset stale keys |
645 if ( USBKeys_Protocol == 0 ) | 647 if ( USBKeys_Protocol == 0 ) |
646 for ( uint8_t c = USBKeys_Sent; c < USB_BOOT_MAX_KEYS; c++ ) | 648 for ( uint8_t c = USBKeys_Sent; c < USB_BOOT_MAX_KEYS; c++ ) |
647 USBKeys_Keys[c] = 0; | 649 USBKeys_Keys[c] = 0; |
648 | 650 |
651 // XXX - Behaves oddly on Mac OSX, might help with corrupted packets specific to OSX? -HaaTa | |
652 /* | |
653 // Check if idle count has been exceed, this forces usb_keyboard_send and usb_mouse_send to update | |
654 // TODO Add joystick as well (may be endpoint specific, currently not kept track of) | |
655 if ( usb_configuration && USBKeys_Idle_Config && ( | |
656 USBKeys_Idle_Expiry < systick_millis_count || | |
657 USBKeys_Idle_Expiry + USBKeys_Idle_Config * 4 >= systick_millis_count ) ) | |
658 { | |
659 USBKeys_Changed = USBKeyChangeState_All; | |
660 USBMouse_Changed = USBMouseChangeState_All; | |
661 } | |
662 */ | |
663 | |
649 // Process mouse actions | 664 // Process mouse actions |
650 while ( USBMouse_Changed ) | 665 while ( USBMouse_Changed ) |
651 usb_mouse_send(); | 666 usb_mouse_send(); |
652 | 667 |
653 // Send keypresses while there are pending changes | 668 // Send keypresses while there are pending changes |