annotate Output/pjrcUSB/arm/usb_keyboard.c @ 449:45feb80a2ad1

Major USB update, fixes most (if not all) known issues USB - General - Refactored descriptors - Enabled/Disable USB endpoints - Added debug flags for special features - Code cleanup - Interface count calculation based off of enabled endpoints - Delayed wTotalLength calculation to simplify descriptor offsets - Re-ordered endpoints and interfaces - Added more debug output - Added usbInitTime to show how long keyboard initialization took (Useful when debugging bad init sequences) - Added function for usb_resume() which takes care of the resume sequence * Resume is now only called if packets are starting to timeout USB - Special Options - Added enableDeviceRestartOnUSBTimeout * A last resort hammer for bad USB Chipsets/OSs, don't use if you can help it * Disabled - Added enableUSBResume * Enables host resume wake-up signalling, required to wake a computer from sleep * Enabled - Added enableUSBLowPowerNegotiation * Enables power negotiation hack * Required to use firmware with an IPad and other hard-limit low-power USB hosts * Hasn't been tested with the recent changes * Disabled - Added enableUSBSuspend * Enables power down events on host USB bus suspend * Enabled USB - Keyboard - Attempted to cleanup HID SET_REPORT * Works much better * Still has an issue under Linux which generates *a lot* of NAKs (initializes quickly regardless) + Not present on other keyboards + SETUP -> OUT -> IN : This sequence is the problem + Specifically during the OUT phase - Enabled USB - CDC Virtual Serial Port - Code cleanup - Added convenience struct USBCDCLineCoding for easier debugging - Attempted to cleanup CDC_SET_LING_CODING * Works much better * Still has an issue under Linux which generates *a lot* of NAKs (initializes quickly regardless) + SETUP -> OUT -> IN : This sequence is the problem + Specifically during the OUT phase + Likely the same issues as HID SET_REPORT - Enabled USB - Mouse - Enabled USB - Joystick - Disabled USB - RawIO - Initial code, API not used yet - Disabled DFU - Updated load script, now faster
author Jacob Alexander <haata@kiibohd.com>
date Tue, 31 May 2016 00:19:45 -0700
parents 56237ba5da6f
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
117
5ffefdf89b37 Adding in USB module updates from Teensyduino 1.18rc2.
Jacob Alexander <haata@kiibohd.com>
parents: 104
diff changeset
1 /* Teensyduino Core Library
5ffefdf89b37 Adding in USB module updates from Teensyduino 1.18rc2.
Jacob Alexander <haata@kiibohd.com>
parents: 104
diff changeset
2 * http://www.pjrc.com/teensy/
5ffefdf89b37 Adding in USB module updates from Teensyduino 1.18rc2.
Jacob Alexander <haata@kiibohd.com>
parents: 104
diff changeset
3 * Copyright (c) 2013 PJRC.COM, LLC.
449
45feb80a2ad1 Major USB update, fixes most (if not all) known issues
Jacob Alexander <haata@kiibohd.com>
parents: 447
diff changeset
4 * Modifications by Jacob Alexander 2013-2016
117
5ffefdf89b37 Adding in USB module updates from Teensyduino 1.18rc2.
Jacob Alexander <haata@kiibohd.com>
parents: 104
diff changeset
5 *
5ffefdf89b37 Adding in USB module updates from Teensyduino 1.18rc2.
Jacob Alexander <haata@kiibohd.com>
parents: 104
diff changeset
6 * Permission is hereby granted, free of charge, to any person obtaining
5ffefdf89b37 Adding in USB module updates from Teensyduino 1.18rc2.
Jacob Alexander <haata@kiibohd.com>
parents: 104
diff changeset
7 * a copy of this software and associated documentation files (the
5ffefdf89b37 Adding in USB module updates from Teensyduino 1.18rc2.
Jacob Alexander <haata@kiibohd.com>
parents: 104
diff changeset
8 * "Software"), to deal in the Software without restriction, including
5ffefdf89b37 Adding in USB module updates from Teensyduino 1.18rc2.
Jacob Alexander <haata@kiibohd.com>
parents: 104
diff changeset
9 * without limitation the rights to use, copy, modify, merge, publish,
5ffefdf89b37 Adding in USB module updates from Teensyduino 1.18rc2.
Jacob Alexander <haata@kiibohd.com>
parents: 104
diff changeset
10 * distribute, sublicense, and/or sell copies of the Software, and to
5ffefdf89b37 Adding in USB module updates from Teensyduino 1.18rc2.
Jacob Alexander <haata@kiibohd.com>
parents: 104
diff changeset
11 * permit persons to whom the Software is furnished to do so, subject to
5ffefdf89b37 Adding in USB module updates from Teensyduino 1.18rc2.
Jacob Alexander <haata@kiibohd.com>
parents: 104
diff changeset
12 * the following conditions:
5ffefdf89b37 Adding in USB module updates from Teensyduino 1.18rc2.
Jacob Alexander <haata@kiibohd.com>
parents: 104
diff changeset
13 *
224
138e5ca7f8e4 Preparing ARM for USB NKRO
Jacob Alexander <haata@kiibohd.com>
parents: 118
diff changeset
14 * 1. The above copyright notice and this permission notice shall be
117
5ffefdf89b37 Adding in USB module updates from Teensyduino 1.18rc2.
Jacob Alexander <haata@kiibohd.com>
parents: 104
diff changeset
15 * included in all copies or substantial portions of the Software.
5ffefdf89b37 Adding in USB module updates from Teensyduino 1.18rc2.
Jacob Alexander <haata@kiibohd.com>
parents: 104
diff changeset
16 *
224
138e5ca7f8e4 Preparing ARM for USB NKRO
Jacob Alexander <haata@kiibohd.com>
parents: 118
diff changeset
17 * 2. If the Software is incorporated into a build system that allows
117
5ffefdf89b37 Adding in USB module updates from Teensyduino 1.18rc2.
Jacob Alexander <haata@kiibohd.com>
parents: 104
diff changeset
18 * selection among a list of target devices, then similar target
5ffefdf89b37 Adding in USB module updates from Teensyduino 1.18rc2.
Jacob Alexander <haata@kiibohd.com>
parents: 104
diff changeset
19 * devices manufactured by PJRC.COM must be included in the list of
5ffefdf89b37 Adding in USB module updates from Teensyduino 1.18rc2.
Jacob Alexander <haata@kiibohd.com>
parents: 104
diff changeset
20 * target devices and selectable in the same manner.
5ffefdf89b37 Adding in USB module updates from Teensyduino 1.18rc2.
Jacob Alexander <haata@kiibohd.com>
parents: 104
diff changeset
21 *
5ffefdf89b37 Adding in USB module updates from Teensyduino 1.18rc2.
Jacob Alexander <haata@kiibohd.com>
parents: 104
diff changeset
22 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
5ffefdf89b37 Adding in USB module updates from Teensyduino 1.18rc2.
Jacob Alexander <haata@kiibohd.com>
parents: 104
diff changeset
23 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
5ffefdf89b37 Adding in USB module updates from Teensyduino 1.18rc2.
Jacob Alexander <haata@kiibohd.com>
parents: 104
diff changeset
24 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
5ffefdf89b37 Adding in USB module updates from Teensyduino 1.18rc2.
Jacob Alexander <haata@kiibohd.com>
parents: 104
diff changeset
25 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
5ffefdf89b37 Adding in USB module updates from Teensyduino 1.18rc2.
Jacob Alexander <haata@kiibohd.com>
parents: 104
diff changeset
26 * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
5ffefdf89b37 Adding in USB module updates from Teensyduino 1.18rc2.
Jacob Alexander <haata@kiibohd.com>
parents: 104
diff changeset
27 * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
5ffefdf89b37 Adding in USB module updates from Teensyduino 1.18rc2.
Jacob Alexander <haata@kiibohd.com>
parents: 104
diff changeset
28 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
5ffefdf89b37 Adding in USB module updates from Teensyduino 1.18rc2.
Jacob Alexander <haata@kiibohd.com>
parents: 104
diff changeset
29 * SOFTWARE.
5ffefdf89b37 Adding in USB module updates from Teensyduino 1.18rc2.
Jacob Alexander <haata@kiibohd.com>
parents: 104
diff changeset
30 */
5ffefdf89b37 Adding in USB module updates from Teensyduino 1.18rc2.
Jacob Alexander <haata@kiibohd.com>
parents: 104
diff changeset
31
449
45feb80a2ad1 Major USB update, fixes most (if not all) known issues
Jacob Alexander <haata@kiibohd.com>
parents: 447
diff changeset
32 #include <kll_defs.h>
45feb80a2ad1 Major USB update, fixes most (if not all) known issues
Jacob Alexander <haata@kiibohd.com>
parents: 447
diff changeset
33 #if enableKeyboard_define == 1
45feb80a2ad1 Major USB update, fixes most (if not all) known issues
Jacob Alexander <haata@kiibohd.com>
parents: 447
diff changeset
34
224
138e5ca7f8e4 Preparing ARM for USB NKRO
Jacob Alexander <haata@kiibohd.com>
parents: 118
diff changeset
35 // ----- Includes -----
138e5ca7f8e4 Preparing ARM for USB NKRO
Jacob Alexander <haata@kiibohd.com>
parents: 118
diff changeset
36
138e5ca7f8e4 Preparing ARM for USB NKRO
Jacob Alexander <haata@kiibohd.com>
parents: 118
diff changeset
37 // Compiler Includes
138e5ca7f8e4 Preparing ARM for USB NKRO
Jacob Alexander <haata@kiibohd.com>
parents: 118
diff changeset
38 #include <string.h> // for memcpy()
138e5ca7f8e4 Preparing ARM for USB NKRO
Jacob Alexander <haata@kiibohd.com>
parents: 118
diff changeset
39
138e5ca7f8e4 Preparing ARM for USB NKRO
Jacob Alexander <haata@kiibohd.com>
parents: 118
diff changeset
40 // Project Includes
138e5ca7f8e4 Preparing ARM for USB NKRO
Jacob Alexander <haata@kiibohd.com>
parents: 118
diff changeset
41 #include <Lib/OutputLib.h>
138e5ca7f8e4 Preparing ARM for USB NKRO
Jacob Alexander <haata@kiibohd.com>
parents: 118
diff changeset
42 #include <print.h>
138e5ca7f8e4 Preparing ARM for USB NKRO
Jacob Alexander <haata@kiibohd.com>
parents: 118
diff changeset
43
138e5ca7f8e4 Preparing ARM for USB NKRO
Jacob Alexander <haata@kiibohd.com>
parents: 118
diff changeset
44 // Local Includes
104
e84738d174bc Moving USB to Output in preparation for additional Output types.
Jacob Alexander <haata@kiibohd.com>
parents:
diff changeset
45 #include "usb_dev.h"
e84738d174bc Moving USB to Output in preparation for additional Output types.
Jacob Alexander <haata@kiibohd.com>
parents:
diff changeset
46 #include "usb_keyboard.h"
224
138e5ca7f8e4 Preparing ARM for USB NKRO
Jacob Alexander <haata@kiibohd.com>
parents: 118
diff changeset
47
104
e84738d174bc Moving USB to Output in preparation for additional Output types.
Jacob Alexander <haata@kiibohd.com>
parents:
diff changeset
48
e84738d174bc Moving USB to Output in preparation for additional Output types.
Jacob Alexander <haata@kiibohd.com>
parents:
diff changeset
49
224
138e5ca7f8e4 Preparing ARM for USB NKRO
Jacob Alexander <haata@kiibohd.com>
parents: 118
diff changeset
50 // ----- Defines -----
138e5ca7f8e4 Preparing ARM for USB NKRO
Jacob Alexander <haata@kiibohd.com>
parents: 118
diff changeset
51
104
e84738d174bc Moving USB to Output in preparation for additional Output types.
Jacob Alexander <haata@kiibohd.com>
parents:
diff changeset
52 // Maximum number of transmit packets to queue so we don't starve other endpoints for memory
e84738d174bc Moving USB to Output in preparation for additional Output types.
Jacob Alexander <haata@kiibohd.com>
parents:
diff changeset
53 #define TX_PACKET_LIMIT 4
e84738d174bc Moving USB to Output in preparation for additional Output types.
Jacob Alexander <haata@kiibohd.com>
parents:
diff changeset
54
e84738d174bc Moving USB to Output in preparation for additional Output types.
Jacob Alexander <haata@kiibohd.com>
parents:
diff changeset
55 // When the PC isn't listening, how long do we wait before discarding data?
e84738d174bc Moving USB to Output in preparation for additional Output types.
Jacob Alexander <haata@kiibohd.com>
parents:
diff changeset
56 #define TX_TIMEOUT_MSEC 50
e84738d174bc Moving USB to Output in preparation for additional Output types.
Jacob Alexander <haata@kiibohd.com>
parents:
diff changeset
57
368
06a54d582bf8 FIxing Media Keys and general USB compatibilty
Jacob Alexander <haata@kiibohd.com>
parents: 346
diff changeset
58 #if F_CPU == 168000000
06a54d582bf8 FIxing Media Keys and general USB compatibilty
Jacob Alexander <haata@kiibohd.com>
parents: 346
diff changeset
59 #define TX_TIMEOUT (TX_TIMEOUT_MSEC * 1100)
06a54d582bf8 FIxing Media Keys and general USB compatibilty
Jacob Alexander <haata@kiibohd.com>
parents: 346
diff changeset
60 #elif F_CPU == 144000000
06a54d582bf8 FIxing Media Keys and general USB compatibilty
Jacob Alexander <haata@kiibohd.com>
parents: 346
diff changeset
61 #define TX_TIMEOUT (TX_TIMEOUT_MSEC * 932)
06a54d582bf8 FIxing Media Keys and general USB compatibilty
Jacob Alexander <haata@kiibohd.com>
parents: 346
diff changeset
62 #elif F_CPU == 120000000
06a54d582bf8 FIxing Media Keys and general USB compatibilty
Jacob Alexander <haata@kiibohd.com>
parents: 346
diff changeset
63 #define TX_TIMEOUT (TX_TIMEOUT_MSEC * 764)
06a54d582bf8 FIxing Media Keys and general USB compatibilty
Jacob Alexander <haata@kiibohd.com>
parents: 346
diff changeset
64 #elif F_CPU == 96000000
334
9ac304aa1ab5 Adding initial dfu-upload code and debugging for Bootloader.
Jacob Alexander <haata@kiibohd.com>
parents: 326
diff changeset
65 #define TX_TIMEOUT (TX_TIMEOUT_MSEC * 596)
9ac304aa1ab5 Adding initial dfu-upload code and debugging for Bootloader.
Jacob Alexander <haata@kiibohd.com>
parents: 326
diff changeset
66 #elif F_CPU == 72000000
368
06a54d582bf8 FIxing Media Keys and general USB compatibilty
Jacob Alexander <haata@kiibohd.com>
parents: 346
diff changeset
67 #define TX_TIMEOUT (TX_TIMEOUT_MSEC * 512)
104
e84738d174bc Moving USB to Output in preparation for additional Output types.
Jacob Alexander <haata@kiibohd.com>
parents:
diff changeset
68 #elif F_CPU == 48000000
334
9ac304aa1ab5 Adding initial dfu-upload code and debugging for Bootloader.
Jacob Alexander <haata@kiibohd.com>
parents: 326
diff changeset
69 #define TX_TIMEOUT (TX_TIMEOUT_MSEC * 428)
104
e84738d174bc Moving USB to Output in preparation for additional Output types.
Jacob Alexander <haata@kiibohd.com>
parents:
diff changeset
70 #elif F_CPU == 24000000
334
9ac304aa1ab5 Adding initial dfu-upload code and debugging for Bootloader.
Jacob Alexander <haata@kiibohd.com>
parents: 326
diff changeset
71 #define TX_TIMEOUT (TX_TIMEOUT_MSEC * 262)
104
e84738d174bc Moving USB to Output in preparation for additional Output types.
Jacob Alexander <haata@kiibohd.com>
parents:
diff changeset
72 #endif
e84738d174bc Moving USB to Output in preparation for additional Output types.
Jacob Alexander <haata@kiibohd.com>
parents:
diff changeset
73
e84738d174bc Moving USB to Output in preparation for additional Output types.
Jacob Alexander <haata@kiibohd.com>
parents:
diff changeset
74
224
138e5ca7f8e4 Preparing ARM for USB NKRO
Jacob Alexander <haata@kiibohd.com>
parents: 118
diff changeset
75
138e5ca7f8e4 Preparing ARM for USB NKRO
Jacob Alexander <haata@kiibohd.com>
parents: 118
diff changeset
76 // ----- Variables -----
138e5ca7f8e4 Preparing ARM for USB NKRO
Jacob Alexander <haata@kiibohd.com>
parents: 118
diff changeset
77
138e5ca7f8e4 Preparing ARM for USB NKRO
Jacob Alexander <haata@kiibohd.com>
parents: 118
diff changeset
78 static uint8_t transmit_previous_timeout = 0;
138e5ca7f8e4 Preparing ARM for USB NKRO
Jacob Alexander <haata@kiibohd.com>
parents: 118
diff changeset
79
138e5ca7f8e4 Preparing ARM for USB NKRO
Jacob Alexander <haata@kiibohd.com>
parents: 118
diff changeset
80
138e5ca7f8e4 Preparing ARM for USB NKRO
Jacob Alexander <haata@kiibohd.com>
parents: 118
diff changeset
81
138e5ca7f8e4 Preparing ARM for USB NKRO
Jacob Alexander <haata@kiibohd.com>
parents: 118
diff changeset
82 // ----- Functions -----
138e5ca7f8e4 Preparing ARM for USB NKRO
Jacob Alexander <haata@kiibohd.com>
parents: 118
diff changeset
83
104
e84738d174bc Moving USB to Output in preparation for additional Output types.
Jacob Alexander <haata@kiibohd.com>
parents:
diff changeset
84 // send the contents of keyboard_keys and keyboard_modifier_keys
224
138e5ca7f8e4 Preparing ARM for USB NKRO
Jacob Alexander <haata@kiibohd.com>
parents: 118
diff changeset
85 void usb_keyboard_send()
104
e84738d174bc Moving USB to Output in preparation for additional Output types.
Jacob Alexander <haata@kiibohd.com>
parents:
diff changeset
86 {
224
138e5ca7f8e4 Preparing ARM for USB NKRO
Jacob Alexander <haata@kiibohd.com>
parents: 118
diff changeset
87 uint32_t wait_count = 0;
104
e84738d174bc Moving USB to Output in preparation for additional Output types.
Jacob Alexander <haata@kiibohd.com>
parents:
diff changeset
88 usb_packet_t *tx_packet;
e84738d174bc Moving USB to Output in preparation for additional Output types.
Jacob Alexander <haata@kiibohd.com>
parents:
diff changeset
89
232
9a3c9f6f4866 USB NKRO working for ARM!
Jacob Alexander <haata@kiibohd.com>
parents: 224
diff changeset
90 // Wait till ready
224
138e5ca7f8e4 Preparing ARM for USB NKRO
Jacob Alexander <haata@kiibohd.com>
parents: 118
diff changeset
91 while ( 1 )
138e5ca7f8e4 Preparing ARM for USB NKRO
Jacob Alexander <haata@kiibohd.com>
parents: 118
diff changeset
92 {
138e5ca7f8e4 Preparing ARM for USB NKRO
Jacob Alexander <haata@kiibohd.com>
parents: 118
diff changeset
93 if ( !usb_configuration )
138e5ca7f8e4 Preparing ARM for USB NKRO
Jacob Alexander <haata@kiibohd.com>
parents: 118
diff changeset
94 {
138e5ca7f8e4 Preparing ARM for USB NKRO
Jacob Alexander <haata@kiibohd.com>
parents: 118
diff changeset
95 erro_print("USB not configured...");
138e5ca7f8e4 Preparing ARM for USB NKRO
Jacob Alexander <haata@kiibohd.com>
parents: 118
diff changeset
96 return;
104
e84738d174bc Moving USB to Output in preparation for additional Output types.
Jacob Alexander <haata@kiibohd.com>
parents:
diff changeset
97 }
232
9a3c9f6f4866 USB NKRO working for ARM!
Jacob Alexander <haata@kiibohd.com>
parents: 224
diff changeset
98
9a3c9f6f4866 USB NKRO working for ARM!
Jacob Alexander <haata@kiibohd.com>
parents: 224
diff changeset
99 if ( USBKeys_Protocol == 0 ) // Boot Mode
224
138e5ca7f8e4 Preparing ARM for USB NKRO
Jacob Alexander <haata@kiibohd.com>
parents: 118
diff changeset
100 {
368
06a54d582bf8 FIxing Media Keys and general USB compatibilty
Jacob Alexander <haata@kiibohd.com>
parents: 346
diff changeset
101 if ( usb_tx_packet_count( KEYBOARD_ENDPOINT ) < TX_PACKET_LIMIT )
232
9a3c9f6f4866 USB NKRO working for ARM!
Jacob Alexander <haata@kiibohd.com>
parents: 224
diff changeset
102 {
9a3c9f6f4866 USB NKRO working for ARM!
Jacob Alexander <haata@kiibohd.com>
parents: 224
diff changeset
103 tx_packet = usb_malloc();
9a3c9f6f4866 USB NKRO working for ARM!
Jacob Alexander <haata@kiibohd.com>
parents: 224
diff changeset
104 if ( tx_packet )
9a3c9f6f4866 USB NKRO working for ARM!
Jacob Alexander <haata@kiibohd.com>
parents: 224
diff changeset
105 break;
9a3c9f6f4866 USB NKRO working for ARM!
Jacob Alexander <haata@kiibohd.com>
parents: 224
diff changeset
106 }
104
e84738d174bc Moving USB to Output in preparation for additional Output types.
Jacob Alexander <haata@kiibohd.com>
parents:
diff changeset
107 }
232
9a3c9f6f4866 USB NKRO working for ARM!
Jacob Alexander <haata@kiibohd.com>
parents: 224
diff changeset
108 else if ( USBKeys_Protocol == 1 ) // NKRO Mode
9a3c9f6f4866 USB NKRO working for ARM!
Jacob Alexander <haata@kiibohd.com>
parents: 224
diff changeset
109 {
368
06a54d582bf8 FIxing Media Keys and general USB compatibilty
Jacob Alexander <haata@kiibohd.com>
parents: 346
diff changeset
110 if ( usb_tx_packet_count( NKRO_KEYBOARD_ENDPOINT ) < TX_PACKET_LIMIT )
06a54d582bf8 FIxing Media Keys and general USB compatibilty
Jacob Alexander <haata@kiibohd.com>
parents: 346
diff changeset
111 {
06a54d582bf8 FIxing Media Keys and general USB compatibilty
Jacob Alexander <haata@kiibohd.com>
parents: 346
diff changeset
112 tx_packet = usb_malloc();
06a54d582bf8 FIxing Media Keys and general USB compatibilty
Jacob Alexander <haata@kiibohd.com>
parents: 346
diff changeset
113 if ( tx_packet )
06a54d582bf8 FIxing Media Keys and general USB compatibilty
Jacob Alexander <haata@kiibohd.com>
parents: 346
diff changeset
114 break;
06a54d582bf8 FIxing Media Keys and general USB compatibilty
Jacob Alexander <haata@kiibohd.com>
parents: 346
diff changeset
115 }
06a54d582bf8 FIxing Media Keys and general USB compatibilty
Jacob Alexander <haata@kiibohd.com>
parents: 346
diff changeset
116 }
06a54d582bf8 FIxing Media Keys and general USB compatibilty
Jacob Alexander <haata@kiibohd.com>
parents: 346
diff changeset
117 else if ( USBKeys_Changed &
06a54d582bf8 FIxing Media Keys and general USB compatibilty
Jacob Alexander <haata@kiibohd.com>
parents: 346
diff changeset
118 ( USBKeyChangeState_System | USBKeyChangeState_Consumer )
06a54d582bf8 FIxing Media Keys and general USB compatibilty
Jacob Alexander <haata@kiibohd.com>
parents: 346
diff changeset
119 )
06a54d582bf8 FIxing Media Keys and general USB compatibilty
Jacob Alexander <haata@kiibohd.com>
parents: 346
diff changeset
120 {
06a54d582bf8 FIxing Media Keys and general USB compatibilty
Jacob Alexander <haata@kiibohd.com>
parents: 346
diff changeset
121 if ( usb_tx_packet_count( SYS_CTRL_ENDPOINT ) < TX_PACKET_LIMIT )
232
9a3c9f6f4866 USB NKRO working for ARM!
Jacob Alexander <haata@kiibohd.com>
parents: 224
diff changeset
122 {
9a3c9f6f4866 USB NKRO working for ARM!
Jacob Alexander <haata@kiibohd.com>
parents: 224
diff changeset
123 tx_packet = usb_malloc();
9a3c9f6f4866 USB NKRO working for ARM!
Jacob Alexander <haata@kiibohd.com>
parents: 224
diff changeset
124 if ( tx_packet )
9a3c9f6f4866 USB NKRO working for ARM!
Jacob Alexander <haata@kiibohd.com>
parents: 224
diff changeset
125 break;
9a3c9f6f4866 USB NKRO working for ARM!
Jacob Alexander <haata@kiibohd.com>
parents: 224
diff changeset
126 }
9a3c9f6f4866 USB NKRO working for ARM!
Jacob Alexander <haata@kiibohd.com>
parents: 224
diff changeset
127 }
9a3c9f6f4866 USB NKRO working for ARM!
Jacob Alexander <haata@kiibohd.com>
parents: 224
diff changeset
128
449
45feb80a2ad1 Major USB update, fixes most (if not all) known issues
Jacob Alexander <haata@kiibohd.com>
parents: 447
diff changeset
129 // USB Timeout, drop the packet, and potentially try something more drastic to re-enable the bus
224
138e5ca7f8e4 Preparing ARM for USB NKRO
Jacob Alexander <haata@kiibohd.com>
parents: 118
diff changeset
130 if ( ++wait_count > TX_TIMEOUT || transmit_previous_timeout )
138e5ca7f8e4 Preparing ARM for USB NKRO
Jacob Alexander <haata@kiibohd.com>
parents: 118
diff changeset
131 {
104
e84738d174bc Moving USB to Output in preparation for additional Output types.
Jacob Alexander <haata@kiibohd.com>
parents:
diff changeset
132 transmit_previous_timeout = 1;
449
45feb80a2ad1 Major USB update, fixes most (if not all) known issues
Jacob Alexander <haata@kiibohd.com>
parents: 447
diff changeset
133 USBKeys_Changed = USBKeyChangeState_None; // Indicate packet lost
45feb80a2ad1 Major USB update, fixes most (if not all) known issues
Jacob Alexander <haata@kiibohd.com>
parents: 447
diff changeset
134 #if enableDeviceRestartOnUSBTimeout == 1
447
56237ba5da6f Adding auto-restart support whenever USB gets into an odd state
Jacob Alexander <haata@kiibohd.com>
parents: 439
diff changeset
135 warn_print("USB Transmit Timeout...restarting device");
56237ba5da6f Adding auto-restart support whenever USB gets into an odd state
Jacob Alexander <haata@kiibohd.com>
parents: 439
diff changeset
136 usb_device_software_reset();
449
45feb80a2ad1 Major USB update, fixes most (if not all) known issues
Jacob Alexander <haata@kiibohd.com>
parents: 447
diff changeset
137 #else
45feb80a2ad1 Major USB update, fixes most (if not all) known issues
Jacob Alexander <haata@kiibohd.com>
parents: 447
diff changeset
138 warn_print("USB Transmit Timeout...auto-restart disabled");
45feb80a2ad1 Major USB update, fixes most (if not all) known issues
Jacob Alexander <haata@kiibohd.com>
parents: 447
diff changeset
139 #endif
45feb80a2ad1 Major USB update, fixes most (if not all) known issues
Jacob Alexander <haata@kiibohd.com>
parents: 447
diff changeset
140 // Try to wakeup
224
138e5ca7f8e4 Preparing ARM for USB NKRO
Jacob Alexander <haata@kiibohd.com>
parents: 118
diff changeset
141 return;
104
e84738d174bc Moving USB to Output in preparation for additional Output types.
Jacob Alexander <haata@kiibohd.com>
parents:
diff changeset
142 }
449
45feb80a2ad1 Major USB update, fixes most (if not all) known issues
Jacob Alexander <haata@kiibohd.com>
parents: 447
diff changeset
143
45feb80a2ad1 Major USB update, fixes most (if not all) known issues
Jacob Alexander <haata@kiibohd.com>
parents: 447
diff changeset
144 // Try to wake up the device if we can't allocate a packet for some reason
45feb80a2ad1 Major USB update, fixes most (if not all) known issues
Jacob Alexander <haata@kiibohd.com>
parents: 447
diff changeset
145 // XXX This is a bit aggressive, but seems to work well. Unfortunately, not as quick as I'd like it -HaaTa
45feb80a2ad1 Major USB update, fixes most (if not all) known issues
Jacob Alexander <haata@kiibohd.com>
parents: 447
diff changeset
146 usb_resume();
45feb80a2ad1 Major USB update, fixes most (if not all) known issues
Jacob Alexander <haata@kiibohd.com>
parents: 447
diff changeset
147
104
e84738d174bc Moving USB to Output in preparation for additional Output types.
Jacob Alexander <haata@kiibohd.com>
parents:
diff changeset
148 yield();
e84738d174bc Moving USB to Output in preparation for additional Output types.
Jacob Alexander <haata@kiibohd.com>
parents:
diff changeset
149 }
224
138e5ca7f8e4 Preparing ARM for USB NKRO
Jacob Alexander <haata@kiibohd.com>
parents: 118
diff changeset
150
447
56237ba5da6f Adding auto-restart support whenever USB gets into an odd state
Jacob Alexander <haata@kiibohd.com>
parents: 439
diff changeset
151 transmit_previous_timeout = 0;
56237ba5da6f Adding auto-restart support whenever USB gets into an odd state
Jacob Alexander <haata@kiibohd.com>
parents: 439
diff changeset
152
232
9a3c9f6f4866 USB NKRO working for ARM!
Jacob Alexander <haata@kiibohd.com>
parents: 224
diff changeset
153 // Pointer to USB tx packet buffer
9a3c9f6f4866 USB NKRO working for ARM!
Jacob Alexander <haata@kiibohd.com>
parents: 224
diff changeset
154 uint8_t *tx_buf = tx_packet->buf;
9a3c9f6f4866 USB NKRO working for ARM!
Jacob Alexander <haata@kiibohd.com>
parents: 224
diff changeset
155
368
06a54d582bf8 FIxing Media Keys and general USB compatibilty
Jacob Alexander <haata@kiibohd.com>
parents: 346
diff changeset
156 // Check system control keys
06a54d582bf8 FIxing Media Keys and general USB compatibilty
Jacob Alexander <haata@kiibohd.com>
parents: 346
diff changeset
157 if ( USBKeys_Changed & USBKeyChangeState_System )
06a54d582bf8 FIxing Media Keys and general USB compatibilty
Jacob Alexander <haata@kiibohd.com>
parents: 346
diff changeset
158 {
06a54d582bf8 FIxing Media Keys and general USB compatibilty
Jacob Alexander <haata@kiibohd.com>
parents: 346
diff changeset
159 if ( Output_DebugMode )
06a54d582bf8 FIxing Media Keys and general USB compatibilty
Jacob Alexander <haata@kiibohd.com>
parents: 346
diff changeset
160 {
06a54d582bf8 FIxing Media Keys and general USB compatibilty
Jacob Alexander <haata@kiibohd.com>
parents: 346
diff changeset
161 print("SysCtrl[");
06a54d582bf8 FIxing Media Keys and general USB compatibilty
Jacob Alexander <haata@kiibohd.com>
parents: 346
diff changeset
162 printHex_op( USBKeys_SysCtrl, 2 );
06a54d582bf8 FIxing Media Keys and general USB compatibilty
Jacob Alexander <haata@kiibohd.com>
parents: 346
diff changeset
163 print( "] " NL );
06a54d582bf8 FIxing Media Keys and general USB compatibilty
Jacob Alexander <haata@kiibohd.com>
parents: 346
diff changeset
164 }
06a54d582bf8 FIxing Media Keys and general USB compatibilty
Jacob Alexander <haata@kiibohd.com>
parents: 346
diff changeset
165
06a54d582bf8 FIxing Media Keys and general USB compatibilty
Jacob Alexander <haata@kiibohd.com>
parents: 346
diff changeset
166 *tx_buf++ = 0x02; // ID
06a54d582bf8 FIxing Media Keys and general USB compatibilty
Jacob Alexander <haata@kiibohd.com>
parents: 346
diff changeset
167 *tx_buf = USBKeys_SysCtrl;
06a54d582bf8 FIxing Media Keys and general USB compatibilty
Jacob Alexander <haata@kiibohd.com>
parents: 346
diff changeset
168 tx_packet->len = 2;
06a54d582bf8 FIxing Media Keys and general USB compatibilty
Jacob Alexander <haata@kiibohd.com>
parents: 346
diff changeset
169
06a54d582bf8 FIxing Media Keys and general USB compatibilty
Jacob Alexander <haata@kiibohd.com>
parents: 346
diff changeset
170 // Send USB Packet
06a54d582bf8 FIxing Media Keys and general USB compatibilty
Jacob Alexander <haata@kiibohd.com>
parents: 346
diff changeset
171 usb_tx( SYS_CTRL_ENDPOINT, tx_packet );
06a54d582bf8 FIxing Media Keys and general USB compatibilty
Jacob Alexander <haata@kiibohd.com>
parents: 346
diff changeset
172 USBKeys_Changed &= ~USBKeyChangeState_System; // Mark sent
06a54d582bf8 FIxing Media Keys and general USB compatibilty
Jacob Alexander <haata@kiibohd.com>
parents: 346
diff changeset
173 return;
06a54d582bf8 FIxing Media Keys and general USB compatibilty
Jacob Alexander <haata@kiibohd.com>
parents: 346
diff changeset
174 }
06a54d582bf8 FIxing Media Keys and general USB compatibilty
Jacob Alexander <haata@kiibohd.com>
parents: 346
diff changeset
175
06a54d582bf8 FIxing Media Keys and general USB compatibilty
Jacob Alexander <haata@kiibohd.com>
parents: 346
diff changeset
176 // Check consumer control keys
06a54d582bf8 FIxing Media Keys and general USB compatibilty
Jacob Alexander <haata@kiibohd.com>
parents: 346
diff changeset
177 if ( USBKeys_Changed & USBKeyChangeState_Consumer )
06a54d582bf8 FIxing Media Keys and general USB compatibilty
Jacob Alexander <haata@kiibohd.com>
parents: 346
diff changeset
178 {
06a54d582bf8 FIxing Media Keys and general USB compatibilty
Jacob Alexander <haata@kiibohd.com>
parents: 346
diff changeset
179 if ( Output_DebugMode )
06a54d582bf8 FIxing Media Keys and general USB compatibilty
Jacob Alexander <haata@kiibohd.com>
parents: 346
diff changeset
180 {
06a54d582bf8 FIxing Media Keys and general USB compatibilty
Jacob Alexander <haata@kiibohd.com>
parents: 346
diff changeset
181 print("ConsCtrl[");
06a54d582bf8 FIxing Media Keys and general USB compatibilty
Jacob Alexander <haata@kiibohd.com>
parents: 346
diff changeset
182 printHex_op( USBKeys_ConsCtrl, 2 );
06a54d582bf8 FIxing Media Keys and general USB compatibilty
Jacob Alexander <haata@kiibohd.com>
parents: 346
diff changeset
183 print( "] " NL );
06a54d582bf8 FIxing Media Keys and general USB compatibilty
Jacob Alexander <haata@kiibohd.com>
parents: 346
diff changeset
184 }
06a54d582bf8 FIxing Media Keys and general USB compatibilty
Jacob Alexander <haata@kiibohd.com>
parents: 346
diff changeset
185
06a54d582bf8 FIxing Media Keys and general USB compatibilty
Jacob Alexander <haata@kiibohd.com>
parents: 346
diff changeset
186 *tx_buf++ = 0x03; // ID
06a54d582bf8 FIxing Media Keys and general USB compatibilty
Jacob Alexander <haata@kiibohd.com>
parents: 346
diff changeset
187 *tx_buf++ = (uint8_t)(USBKeys_ConsCtrl & 0x00FF);
06a54d582bf8 FIxing Media Keys and general USB compatibilty
Jacob Alexander <haata@kiibohd.com>
parents: 346
diff changeset
188 *tx_buf = (uint8_t)(USBKeys_ConsCtrl >> 8);
06a54d582bf8 FIxing Media Keys and general USB compatibilty
Jacob Alexander <haata@kiibohd.com>
parents: 346
diff changeset
189 tx_packet->len = 3;
06a54d582bf8 FIxing Media Keys and general USB compatibilty
Jacob Alexander <haata@kiibohd.com>
parents: 346
diff changeset
190
06a54d582bf8 FIxing Media Keys and general USB compatibilty
Jacob Alexander <haata@kiibohd.com>
parents: 346
diff changeset
191 // Send USB Packet
06a54d582bf8 FIxing Media Keys and general USB compatibilty
Jacob Alexander <haata@kiibohd.com>
parents: 346
diff changeset
192 usb_tx( SYS_CTRL_ENDPOINT, tx_packet );
06a54d582bf8 FIxing Media Keys and general USB compatibilty
Jacob Alexander <haata@kiibohd.com>
parents: 346
diff changeset
193 USBKeys_Changed &= ~USBKeyChangeState_Consumer; // Mark sent
06a54d582bf8 FIxing Media Keys and general USB compatibilty
Jacob Alexander <haata@kiibohd.com>
parents: 346
diff changeset
194 return;
06a54d582bf8 FIxing Media Keys and general USB compatibilty
Jacob Alexander <haata@kiibohd.com>
parents: 346
diff changeset
195 }
06a54d582bf8 FIxing Media Keys and general USB compatibilty
Jacob Alexander <haata@kiibohd.com>
parents: 346
diff changeset
196
232
9a3c9f6f4866 USB NKRO working for ARM!
Jacob Alexander <haata@kiibohd.com>
parents: 224
diff changeset
197 switch ( USBKeys_Protocol )
9a3c9f6f4866 USB NKRO working for ARM!
Jacob Alexander <haata@kiibohd.com>
parents: 224
diff changeset
198 {
9a3c9f6f4866 USB NKRO working for ARM!
Jacob Alexander <haata@kiibohd.com>
parents: 224
diff changeset
199 // Send boot keyboard interrupt packet(s)
9a3c9f6f4866 USB NKRO working for ARM!
Jacob Alexander <haata@kiibohd.com>
parents: 224
diff changeset
200 case 0:
285
1495b4504a59 Adding outputDebug command
Jacob Alexander <haata@kiibohd.com>
parents: 251
diff changeset
201 // USB Boot Mode debug output
1495b4504a59 Adding outputDebug command
Jacob Alexander <haata@kiibohd.com>
parents: 251
diff changeset
202 if ( Output_DebugMode )
1495b4504a59 Adding outputDebug command
Jacob Alexander <haata@kiibohd.com>
parents: 251
diff changeset
203 {
1495b4504a59 Adding outputDebug command
Jacob Alexander <haata@kiibohd.com>
parents: 251
diff changeset
204 dbug_msg("Boot USB: ");
1495b4504a59 Adding outputDebug command
Jacob Alexander <haata@kiibohd.com>
parents: 251
diff changeset
205 printHex_op( USBKeys_Modifiers, 2 );
1495b4504a59 Adding outputDebug command
Jacob Alexander <haata@kiibohd.com>
parents: 251
diff changeset
206 print(" ");
1495b4504a59 Adding outputDebug command
Jacob Alexander <haata@kiibohd.com>
parents: 251
diff changeset
207 printHex( 0 );
1495b4504a59 Adding outputDebug command
Jacob Alexander <haata@kiibohd.com>
parents: 251
diff changeset
208 print(" ");
1495b4504a59 Adding outputDebug command
Jacob Alexander <haata@kiibohd.com>
parents: 251
diff changeset
209 printHex_op( USBKeys_Keys[0], 2 );
1495b4504a59 Adding outputDebug command
Jacob Alexander <haata@kiibohd.com>
parents: 251
diff changeset
210 printHex_op( USBKeys_Keys[1], 2 );
1495b4504a59 Adding outputDebug command
Jacob Alexander <haata@kiibohd.com>
parents: 251
diff changeset
211 printHex_op( USBKeys_Keys[2], 2 );
1495b4504a59 Adding outputDebug command
Jacob Alexander <haata@kiibohd.com>
parents: 251
diff changeset
212 printHex_op( USBKeys_Keys[3], 2 );
1495b4504a59 Adding outputDebug command
Jacob Alexander <haata@kiibohd.com>
parents: 251
diff changeset
213 printHex_op( USBKeys_Keys[4], 2 );
1495b4504a59 Adding outputDebug command
Jacob Alexander <haata@kiibohd.com>
parents: 251
diff changeset
214 printHex_op( USBKeys_Keys[5], 2 );
1495b4504a59 Adding outputDebug command
Jacob Alexander <haata@kiibohd.com>
parents: 251
diff changeset
215 print( NL );
1495b4504a59 Adding outputDebug command
Jacob Alexander <haata@kiibohd.com>
parents: 251
diff changeset
216 }
1495b4504a59 Adding outputDebug command
Jacob Alexander <haata@kiibohd.com>
parents: 251
diff changeset
217
232
9a3c9f6f4866 USB NKRO working for ARM!
Jacob Alexander <haata@kiibohd.com>
parents: 224
diff changeset
218 // Boot Mode
9a3c9f6f4866 USB NKRO working for ARM!
Jacob Alexander <haata@kiibohd.com>
parents: 224
diff changeset
219 *tx_buf++ = USBKeys_Modifiers;
9a3c9f6f4866 USB NKRO working for ARM!
Jacob Alexander <haata@kiibohd.com>
parents: 224
diff changeset
220 *tx_buf++ = 0;
9a3c9f6f4866 USB NKRO working for ARM!
Jacob Alexander <haata@kiibohd.com>
parents: 224
diff changeset
221 memcpy( tx_buf, USBKeys_Keys, USB_BOOT_MAX_KEYS );
9a3c9f6f4866 USB NKRO working for ARM!
Jacob Alexander <haata@kiibohd.com>
parents: 224
diff changeset
222 tx_packet->len = 8;
9a3c9f6f4866 USB NKRO working for ARM!
Jacob Alexander <haata@kiibohd.com>
parents: 224
diff changeset
223
9a3c9f6f4866 USB NKRO working for ARM!
Jacob Alexander <haata@kiibohd.com>
parents: 224
diff changeset
224 // Send USB Packet
9a3c9f6f4866 USB NKRO working for ARM!
Jacob Alexander <haata@kiibohd.com>
parents: 224
diff changeset
225 usb_tx( KEYBOARD_ENDPOINT, tx_packet );
9a3c9f6f4866 USB NKRO working for ARM!
Jacob Alexander <haata@kiibohd.com>
parents: 224
diff changeset
226 USBKeys_Changed = USBKeyChangeState_None;
9a3c9f6f4866 USB NKRO working for ARM!
Jacob Alexander <haata@kiibohd.com>
parents: 224
diff changeset
227 break;
9a3c9f6f4866 USB NKRO working for ARM!
Jacob Alexander <haata@kiibohd.com>
parents: 224
diff changeset
228
9a3c9f6f4866 USB NKRO working for ARM!
Jacob Alexander <haata@kiibohd.com>
parents: 224
diff changeset
229 // Send NKRO keyboard interrupts packet(s)
9a3c9f6f4866 USB NKRO working for ARM!
Jacob Alexander <haata@kiibohd.com>
parents: 224
diff changeset
230 case 1:
285
1495b4504a59 Adding outputDebug command
Jacob Alexander <haata@kiibohd.com>
parents: 251
diff changeset
231 if ( Output_DebugMode )
1495b4504a59 Adding outputDebug command
Jacob Alexander <haata@kiibohd.com>
parents: 251
diff changeset
232 {
1495b4504a59 Adding outputDebug command
Jacob Alexander <haata@kiibohd.com>
parents: 251
diff changeset
233 dbug_msg("NKRO USB: ");
1495b4504a59 Adding outputDebug command
Jacob Alexander <haata@kiibohd.com>
parents: 251
diff changeset
234 }
1495b4504a59 Adding outputDebug command
Jacob Alexander <haata@kiibohd.com>
parents: 251
diff changeset
235
251
d3ac199593d6 Fixing NKRO on Windows 8.1
Jacob Alexander <haata@kiibohd.com>
parents: 248
diff changeset
236 // Standard HID Keyboard
d3ac199593d6 Fixing NKRO on Windows 8.1
Jacob Alexander <haata@kiibohd.com>
parents: 248
diff changeset
237 if ( USBKeys_Changed )
d3ac199593d6 Fixing NKRO on Windows 8.1
Jacob Alexander <haata@kiibohd.com>
parents: 248
diff changeset
238 {
285
1495b4504a59 Adding outputDebug command
Jacob Alexander <haata@kiibohd.com>
parents: 251
diff changeset
239 // USB NKRO Debug output
1495b4504a59 Adding outputDebug command
Jacob Alexander <haata@kiibohd.com>
parents: 251
diff changeset
240 if ( Output_DebugMode )
1495b4504a59 Adding outputDebug command
Jacob Alexander <haata@kiibohd.com>
parents: 251
diff changeset
241 {
1495b4504a59 Adding outputDebug command
Jacob Alexander <haata@kiibohd.com>
parents: 251
diff changeset
242 printHex_op( USBKeys_Modifiers, 2 );
1495b4504a59 Adding outputDebug command
Jacob Alexander <haata@kiibohd.com>
parents: 251
diff changeset
243 print(" ");
1495b4504a59 Adding outputDebug command
Jacob Alexander <haata@kiibohd.com>
parents: 251
diff changeset
244 for ( uint8_t c = 0; c < 6; c++ )
1495b4504a59 Adding outputDebug command
Jacob Alexander <haata@kiibohd.com>
parents: 251
diff changeset
245 printHex_op( USBKeys_Keys[ c ], 2 );
1495b4504a59 Adding outputDebug command
Jacob Alexander <haata@kiibohd.com>
parents: 251
diff changeset
246 print(" ");
1495b4504a59 Adding outputDebug command
Jacob Alexander <haata@kiibohd.com>
parents: 251
diff changeset
247 for ( uint8_t c = 6; c < 20; c++ )
1495b4504a59 Adding outputDebug command
Jacob Alexander <haata@kiibohd.com>
parents: 251
diff changeset
248 printHex_op( USBKeys_Keys[ c ], 2 );
1495b4504a59 Adding outputDebug command
Jacob Alexander <haata@kiibohd.com>
parents: 251
diff changeset
249 print(" ");
1495b4504a59 Adding outputDebug command
Jacob Alexander <haata@kiibohd.com>
parents: 251
diff changeset
250 printHex_op( USBKeys_Keys[20], 2 );
1495b4504a59 Adding outputDebug command
Jacob Alexander <haata@kiibohd.com>
parents: 251
diff changeset
251 print(" ");
1495b4504a59 Adding outputDebug command
Jacob Alexander <haata@kiibohd.com>
parents: 251
diff changeset
252 for ( uint8_t c = 21; c < 27; c++ )
1495b4504a59 Adding outputDebug command
Jacob Alexander <haata@kiibohd.com>
parents: 251
diff changeset
253 printHex_op( USBKeys_Keys[ c ], 2 );
1495b4504a59 Adding outputDebug command
Jacob Alexander <haata@kiibohd.com>
parents: 251
diff changeset
254 print( NL );
1495b4504a59 Adding outputDebug command
Jacob Alexander <haata@kiibohd.com>
parents: 251
diff changeset
255 }
1495b4504a59 Adding outputDebug command
Jacob Alexander <haata@kiibohd.com>
parents: 251
diff changeset
256
251
d3ac199593d6 Fixing NKRO on Windows 8.1
Jacob Alexander <haata@kiibohd.com>
parents: 248
diff changeset
257 tx_packet->len = 0;
d3ac199593d6 Fixing NKRO on Windows 8.1
Jacob Alexander <haata@kiibohd.com>
parents: 248
diff changeset
258
d3ac199593d6 Fixing NKRO on Windows 8.1
Jacob Alexander <haata@kiibohd.com>
parents: 248
diff changeset
259 // Modifiers
d3ac199593d6 Fixing NKRO on Windows 8.1
Jacob Alexander <haata@kiibohd.com>
parents: 248
diff changeset
260 *tx_buf++ = 0x01; // ID
d3ac199593d6 Fixing NKRO on Windows 8.1
Jacob Alexander <haata@kiibohd.com>
parents: 248
diff changeset
261 *tx_buf++ = USBKeys_Modifiers;
d3ac199593d6 Fixing NKRO on Windows 8.1
Jacob Alexander <haata@kiibohd.com>
parents: 248
diff changeset
262 tx_packet->len += 2;
d3ac199593d6 Fixing NKRO on Windows 8.1
Jacob Alexander <haata@kiibohd.com>
parents: 248
diff changeset
263
d3ac199593d6 Fixing NKRO on Windows 8.1
Jacob Alexander <haata@kiibohd.com>
parents: 248
diff changeset
264 // 4-49 (first 6 bytes)
d3ac199593d6 Fixing NKRO on Windows 8.1
Jacob Alexander <haata@kiibohd.com>
parents: 248
diff changeset
265 memcpy( tx_buf, USBKeys_Keys, 6 );
d3ac199593d6 Fixing NKRO on Windows 8.1
Jacob Alexander <haata@kiibohd.com>
parents: 248
diff changeset
266 tx_buf += 6;
d3ac199593d6 Fixing NKRO on Windows 8.1
Jacob Alexander <haata@kiibohd.com>
parents: 248
diff changeset
267 tx_packet->len += 6;
d3ac199593d6 Fixing NKRO on Windows 8.1
Jacob Alexander <haata@kiibohd.com>
parents: 248
diff changeset
268
d3ac199593d6 Fixing NKRO on Windows 8.1
Jacob Alexander <haata@kiibohd.com>
parents: 248
diff changeset
269 // 51-155 (Middle 14 bytes)
d3ac199593d6 Fixing NKRO on Windows 8.1
Jacob Alexander <haata@kiibohd.com>
parents: 248
diff changeset
270 memcpy( tx_buf, USBKeys_Keys + 6, 14 );
d3ac199593d6 Fixing NKRO on Windows 8.1
Jacob Alexander <haata@kiibohd.com>
parents: 248
diff changeset
271 tx_buf += 14;
d3ac199593d6 Fixing NKRO on Windows 8.1
Jacob Alexander <haata@kiibohd.com>
parents: 248
diff changeset
272 tx_packet->len += 14;
d3ac199593d6 Fixing NKRO on Windows 8.1
Jacob Alexander <haata@kiibohd.com>
parents: 248
diff changeset
273
d3ac199593d6 Fixing NKRO on Windows 8.1
Jacob Alexander <haata@kiibohd.com>
parents: 248
diff changeset
274 // 157-164 (Next byte)
d3ac199593d6 Fixing NKRO on Windows 8.1
Jacob Alexander <haata@kiibohd.com>
parents: 248
diff changeset
275 memcpy( tx_buf, USBKeys_Keys + 20, 1 );
d3ac199593d6 Fixing NKRO on Windows 8.1
Jacob Alexander <haata@kiibohd.com>
parents: 248
diff changeset
276 tx_buf += 1;
d3ac199593d6 Fixing NKRO on Windows 8.1
Jacob Alexander <haata@kiibohd.com>
parents: 248
diff changeset
277 tx_packet->len += 1;
d3ac199593d6 Fixing NKRO on Windows 8.1
Jacob Alexander <haata@kiibohd.com>
parents: 248
diff changeset
278
d3ac199593d6 Fixing NKRO on Windows 8.1
Jacob Alexander <haata@kiibohd.com>
parents: 248
diff changeset
279 // 176-221 (last 6 bytes)
d3ac199593d6 Fixing NKRO on Windows 8.1
Jacob Alexander <haata@kiibohd.com>
parents: 248
diff changeset
280 memcpy( tx_buf, USBKeys_Keys + 21, 6 );
d3ac199593d6 Fixing NKRO on Windows 8.1
Jacob Alexander <haata@kiibohd.com>
parents: 248
diff changeset
281 tx_packet->len += 6;
d3ac199593d6 Fixing NKRO on Windows 8.1
Jacob Alexander <haata@kiibohd.com>
parents: 248
diff changeset
282
d3ac199593d6 Fixing NKRO on Windows 8.1
Jacob Alexander <haata@kiibohd.com>
parents: 248
diff changeset
283 // Send USB Packet
d3ac199593d6 Fixing NKRO on Windows 8.1
Jacob Alexander <haata@kiibohd.com>
parents: 248
diff changeset
284 usb_tx( NKRO_KEYBOARD_ENDPOINT, tx_packet );
d3ac199593d6 Fixing NKRO on Windows 8.1
Jacob Alexander <haata@kiibohd.com>
parents: 248
diff changeset
285 USBKeys_Changed = USBKeyChangeState_None; // Mark sent
d3ac199593d6 Fixing NKRO on Windows 8.1
Jacob Alexander <haata@kiibohd.com>
parents: 248
diff changeset
286 }
d3ac199593d6 Fixing NKRO on Windows 8.1
Jacob Alexander <haata@kiibohd.com>
parents: 248
diff changeset
287
232
9a3c9f6f4866 USB NKRO working for ARM!
Jacob Alexander <haata@kiibohd.com>
parents: 224
diff changeset
288 break;
9a3c9f6f4866 USB NKRO working for ARM!
Jacob Alexander <haata@kiibohd.com>
parents: 224
diff changeset
289 }
224
138e5ca7f8e4 Preparing ARM for USB NKRO
Jacob Alexander <haata@kiibohd.com>
parents: 118
diff changeset
290
138e5ca7f8e4 Preparing ARM for USB NKRO
Jacob Alexander <haata@kiibohd.com>
parents: 118
diff changeset
291 return;
104
e84738d174bc Moving USB to Output in preparation for additional Output types.
Jacob Alexander <haata@kiibohd.com>
parents:
diff changeset
292 }
e84738d174bc Moving USB to Output in preparation for additional Output types.
Jacob Alexander <haata@kiibohd.com>
parents:
diff changeset
293
449
45feb80a2ad1 Major USB update, fixes most (if not all) known issues
Jacob Alexander <haata@kiibohd.com>
parents: 447
diff changeset
294 #endif
45feb80a2ad1 Major USB update, fixes most (if not all) known issues
Jacob Alexander <haata@kiibohd.com>
parents: 447
diff changeset
295