Mercurial > louis > kiibohd-controller
annotate Output/usbMuxUart/output_com.c @ 453:98bbee08f005 default tip louis
Setup hgignore, volume/brightness up/down, sysreq still not working
author | Louis Opter <kalessin@kalessin.fr> |
---|---|
date | Wed, 13 Jul 2016 23:16:49 -0700 |
parents | 45feb80a2ad1 |
children |
rev | line source |
---|---|
420
23a1868b4ac2
Adding dynamic USB power support
Jacob Alexander <haata@kiibohd.com>
parents:
385
diff
changeset
|
1 /* Copyright (C) 2014-2016 by Jacob Alexander |
172
a30bddad4115
Adding UART and UART + USB muxed CLI output.
Jacob Alexander <haata@kiibohd.com>
parents:
diff
changeset
|
2 * |
a30bddad4115
Adding UART and UART + USB muxed CLI output.
Jacob Alexander <haata@kiibohd.com>
parents:
diff
changeset
|
3 * Permission is hereby granted, free of charge, to any person obtaining a copy |
a30bddad4115
Adding UART and UART + USB muxed CLI output.
Jacob Alexander <haata@kiibohd.com>
parents:
diff
changeset
|
4 * of this software and associated documentation files (the "Software"), to deal |
a30bddad4115
Adding UART and UART + USB muxed CLI output.
Jacob Alexander <haata@kiibohd.com>
parents:
diff
changeset
|
5 * in the Software without restriction, including without limitation the rights |
a30bddad4115
Adding UART and UART + USB muxed CLI output.
Jacob Alexander <haata@kiibohd.com>
parents:
diff
changeset
|
6 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell |
a30bddad4115
Adding UART and UART + USB muxed CLI output.
Jacob Alexander <haata@kiibohd.com>
parents:
diff
changeset
|
7 * copies of the Software, and to permit persons to whom the Software is |
a30bddad4115
Adding UART and UART + USB muxed CLI output.
Jacob Alexander <haata@kiibohd.com>
parents:
diff
changeset
|
8 * furnished to do so, subject to the following conditions: |
a30bddad4115
Adding UART and UART + USB muxed CLI output.
Jacob Alexander <haata@kiibohd.com>
parents:
diff
changeset
|
9 * |
a30bddad4115
Adding UART and UART + USB muxed CLI output.
Jacob Alexander <haata@kiibohd.com>
parents:
diff
changeset
|
10 * The above copyright notice and this permission notice shall be included in |
a30bddad4115
Adding UART and UART + USB muxed CLI output.
Jacob Alexander <haata@kiibohd.com>
parents:
diff
changeset
|
11 * all copies or substantial portions of the Software. |
a30bddad4115
Adding UART and UART + USB muxed CLI output.
Jacob Alexander <haata@kiibohd.com>
parents:
diff
changeset
|
12 * |
a30bddad4115
Adding UART and UART + USB muxed CLI output.
Jacob Alexander <haata@kiibohd.com>
parents:
diff
changeset
|
13 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
a30bddad4115
Adding UART and UART + USB muxed CLI output.
Jacob Alexander <haata@kiibohd.com>
parents:
diff
changeset
|
14 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
a30bddad4115
Adding UART and UART + USB muxed CLI output.
Jacob Alexander <haata@kiibohd.com>
parents:
diff
changeset
|
15 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE |
a30bddad4115
Adding UART and UART + USB muxed CLI output.
Jacob Alexander <haata@kiibohd.com>
parents:
diff
changeset
|
16 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
a30bddad4115
Adding UART and UART + USB muxed CLI output.
Jacob Alexander <haata@kiibohd.com>
parents:
diff
changeset
|
17 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
a30bddad4115
Adding UART and UART + USB muxed CLI output.
Jacob Alexander <haata@kiibohd.com>
parents:
diff
changeset
|
18 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN |
a30bddad4115
Adding UART and UART + USB muxed CLI output.
Jacob Alexander <haata@kiibohd.com>
parents:
diff
changeset
|
19 * THE SOFTWARE. |
a30bddad4115
Adding UART and UART + USB muxed CLI output.
Jacob Alexander <haata@kiibohd.com>
parents:
diff
changeset
|
20 */ |
a30bddad4115
Adding UART and UART + USB muxed CLI output.
Jacob Alexander <haata@kiibohd.com>
parents:
diff
changeset
|
21 |
a30bddad4115
Adding UART and UART + USB muxed CLI output.
Jacob Alexander <haata@kiibohd.com>
parents:
diff
changeset
|
22 // ----- Includes ----- |
a30bddad4115
Adding UART and UART + USB muxed CLI output.
Jacob Alexander <haata@kiibohd.com>
parents:
diff
changeset
|
23 |
a30bddad4115
Adding UART and UART + USB muxed CLI output.
Jacob Alexander <haata@kiibohd.com>
parents:
diff
changeset
|
24 // Compiler Includes |
a30bddad4115
Adding UART and UART + USB muxed CLI output.
Jacob Alexander <haata@kiibohd.com>
parents:
diff
changeset
|
25 #include <Lib/OutputLib.h> |
a30bddad4115
Adding UART and UART + USB muxed CLI output.
Jacob Alexander <haata@kiibohd.com>
parents:
diff
changeset
|
26 |
a30bddad4115
Adding UART and UART + USB muxed CLI output.
Jacob Alexander <haata@kiibohd.com>
parents:
diff
changeset
|
27 // Project Includes |
a30bddad4115
Adding UART and UART + USB muxed CLI output.
Jacob Alexander <haata@kiibohd.com>
parents:
diff
changeset
|
28 #include <cli.h> |
227
ed05fa3555d4
Updating usbMuxUart for NKRO
Jacob Alexander <haata@kiibohd.com>
parents:
195
diff
changeset
|
29 #include <led.h> |
172
a30bddad4115
Adding UART and UART + USB muxed CLI output.
Jacob Alexander <haata@kiibohd.com>
parents:
diff
changeset
|
30 #include <print.h> |
a30bddad4115
Adding UART and UART + USB muxed CLI output.
Jacob Alexander <haata@kiibohd.com>
parents:
diff
changeset
|
31 #include <scan_loop.h> |
a30bddad4115
Adding UART and UART + USB muxed CLI output.
Jacob Alexander <haata@kiibohd.com>
parents:
diff
changeset
|
32 |
a30bddad4115
Adding UART and UART + USB muxed CLI output.
Jacob Alexander <haata@kiibohd.com>
parents:
diff
changeset
|
33 // USB Includes |
a30bddad4115
Adding UART and UART + USB muxed CLI output.
Jacob Alexander <haata@kiibohd.com>
parents:
diff
changeset
|
34 #if defined(_at90usb162_) || defined(_atmega32u4_) || defined(_at90usb646_) || defined(_at90usb1286_) |
263
9afed592bcb5
Preparing for mk20dx256vlh7
Jacob Alexander <haata@kiibohd.com>
parents:
239
diff
changeset
|
35 #elif defined(_mk20dx128_) || defined(_mk20dx128vlf5_) || defined(_mk20dx256_) || defined(_mk20dx256vlh7_) |
300
7119c2149abb
Fixing compiler errors for usbMuxUart Output module
Jacob Alexander <haata@kiibohd.com>
parents:
275
diff
changeset
|
36 #include <arm/uart_serial.h> |
7119c2149abb
Fixing compiler errors for usbMuxUart Output module
Jacob Alexander <haata@kiibohd.com>
parents:
275
diff
changeset
|
37 #include <arm/usb_dev.h> |
7119c2149abb
Fixing compiler errors for usbMuxUart Output module
Jacob Alexander <haata@kiibohd.com>
parents:
275
diff
changeset
|
38 #include <arm/usb_keyboard.h> |
7119c2149abb
Fixing compiler errors for usbMuxUart Output module
Jacob Alexander <haata@kiibohd.com>
parents:
275
diff
changeset
|
39 #include <arm/usb_serial.h> |
447
56237ba5da6f
Adding auto-restart support whenever USB gets into an odd state
Jacob Alexander <haata@kiibohd.com>
parents:
445
diff
changeset
|
40 #include "arm/usb_mouse.h" |
172
a30bddad4115
Adding UART and UART + USB muxed CLI output.
Jacob Alexander <haata@kiibohd.com>
parents:
diff
changeset
|
41 #endif |
a30bddad4115
Adding UART and UART + USB muxed CLI output.
Jacob Alexander <haata@kiibohd.com>
parents:
diff
changeset
|
42 |
438
f10c2dad7f55
Adding missing GET_PROTOCOL handling
Jacob Alexander <haata@kiibohd.com>
parents:
420
diff
changeset
|
43 // KLL |
f10c2dad7f55
Adding missing GET_PROTOCOL handling
Jacob Alexander <haata@kiibohd.com>
parents:
420
diff
changeset
|
44 #include <kll_defs.h> |
f10c2dad7f55
Adding missing GET_PROTOCOL handling
Jacob Alexander <haata@kiibohd.com>
parents:
420
diff
changeset
|
45 |
172
a30bddad4115
Adding UART and UART + USB muxed CLI output.
Jacob Alexander <haata@kiibohd.com>
parents:
diff
changeset
|
46 // Local Includes |
a30bddad4115
Adding UART and UART + USB muxed CLI output.
Jacob Alexander <haata@kiibohd.com>
parents:
diff
changeset
|
47 #include "output_com.h" |
a30bddad4115
Adding UART and UART + USB muxed CLI output.
Jacob Alexander <haata@kiibohd.com>
parents:
diff
changeset
|
48 |
a30bddad4115
Adding UART and UART + USB muxed CLI output.
Jacob Alexander <haata@kiibohd.com>
parents:
diff
changeset
|
49 |
a30bddad4115
Adding UART and UART + USB muxed CLI output.
Jacob Alexander <haata@kiibohd.com>
parents:
diff
changeset
|
50 |
227
ed05fa3555d4
Updating usbMuxUart for NKRO
Jacob Alexander <haata@kiibohd.com>
parents:
195
diff
changeset
|
51 // ----- Macros ----- |
ed05fa3555d4
Updating usbMuxUart for NKRO
Jacob Alexander <haata@kiibohd.com>
parents:
195
diff
changeset
|
52 |
ed05fa3555d4
Updating usbMuxUart for NKRO
Jacob Alexander <haata@kiibohd.com>
parents:
195
diff
changeset
|
53 // Used to build a bitmap lookup table from a byte addressable array |
449
45feb80a2ad1
Major USB update, fixes most (if not all) known issues
Jacob Alexander <haata@kiibohd.com>
parents:
447
diff
changeset
|
54 #define byteLookup( byte ) \ |
45feb80a2ad1
Major USB update, fixes most (if not all) known issues
Jacob Alexander <haata@kiibohd.com>
parents:
447
diff
changeset
|
55 case (( byte ) * ( 8 )): bytePosition = byte; byteShift = 0; break; \ |
45feb80a2ad1
Major USB update, fixes most (if not all) known issues
Jacob Alexander <haata@kiibohd.com>
parents:
447
diff
changeset
|
56 case (( byte ) * ( 8 ) + ( 1 )): bytePosition = byte; byteShift = 1; break; \ |
45feb80a2ad1
Major USB update, fixes most (if not all) known issues
Jacob Alexander <haata@kiibohd.com>
parents:
447
diff
changeset
|
57 case (( byte ) * ( 8 ) + ( 2 )): bytePosition = byte; byteShift = 2; break; \ |
45feb80a2ad1
Major USB update, fixes most (if not all) known issues
Jacob Alexander <haata@kiibohd.com>
parents:
447
diff
changeset
|
58 case (( byte ) * ( 8 ) + ( 3 )): bytePosition = byte; byteShift = 3; break; \ |
45feb80a2ad1
Major USB update, fixes most (if not all) known issues
Jacob Alexander <haata@kiibohd.com>
parents:
447
diff
changeset
|
59 case (( byte ) * ( 8 ) + ( 4 )): bytePosition = byte; byteShift = 4; break; \ |
45feb80a2ad1
Major USB update, fixes most (if not all) known issues
Jacob Alexander <haata@kiibohd.com>
parents:
447
diff
changeset
|
60 case (( byte ) * ( 8 ) + ( 5 )): bytePosition = byte; byteShift = 5; break; \ |
45feb80a2ad1
Major USB update, fixes most (if not all) known issues
Jacob Alexander <haata@kiibohd.com>
parents:
447
diff
changeset
|
61 case (( byte ) * ( 8 ) + ( 6 )): bytePosition = byte; byteShift = 6; break; \ |
45feb80a2ad1
Major USB update, fixes most (if not all) known issues
Jacob Alexander <haata@kiibohd.com>
parents:
447
diff
changeset
|
62 case (( byte ) * ( 8 ) + ( 7 )): bytePosition = byte; byteShift = 7; break |
227
ed05fa3555d4
Updating usbMuxUart for NKRO
Jacob Alexander <haata@kiibohd.com>
parents:
195
diff
changeset
|
63 |
ed05fa3555d4
Updating usbMuxUart for NKRO
Jacob Alexander <haata@kiibohd.com>
parents:
195
diff
changeset
|
64 |
ed05fa3555d4
Updating usbMuxUart for NKRO
Jacob Alexander <haata@kiibohd.com>
parents:
195
diff
changeset
|
65 |
172
a30bddad4115
Adding UART and UART + USB muxed CLI output.
Jacob Alexander <haata@kiibohd.com>
parents:
diff
changeset
|
66 // ----- Function Declarations ----- |
a30bddad4115
Adding UART and UART + USB muxed CLI output.
Jacob Alexander <haata@kiibohd.com>
parents:
diff
changeset
|
67 |
a30bddad4115
Adding UART and UART + USB muxed CLI output.
Jacob Alexander <haata@kiibohd.com>
parents:
diff
changeset
|
68 void cliFunc_kbdProtocol( char* args ); |
347
136e47478441
UARTConnect enumeration working!
Jacob Alexander <haata@kiibohd.com>
parents:
340
diff
changeset
|
69 void cliFunc_outputDebug( char* args ); |
172
a30bddad4115
Adding UART and UART + USB muxed CLI output.
Jacob Alexander <haata@kiibohd.com>
parents:
diff
changeset
|
70 void cliFunc_readLEDs ( char* args ); |
a30bddad4115
Adding UART and UART + USB muxed CLI output.
Jacob Alexander <haata@kiibohd.com>
parents:
diff
changeset
|
71 void cliFunc_readUART ( char* args ); |
a30bddad4115
Adding UART and UART + USB muxed CLI output.
Jacob Alexander <haata@kiibohd.com>
parents:
diff
changeset
|
72 void cliFunc_sendKeys ( char* args ); |
a30bddad4115
Adding UART and UART + USB muxed CLI output.
Jacob Alexander <haata@kiibohd.com>
parents:
diff
changeset
|
73 void cliFunc_sendUART ( char* args ); |
a30bddad4115
Adding UART and UART + USB muxed CLI output.
Jacob Alexander <haata@kiibohd.com>
parents:
diff
changeset
|
74 void cliFunc_setKeys ( char* args ); |
a30bddad4115
Adding UART and UART + USB muxed CLI output.
Jacob Alexander <haata@kiibohd.com>
parents:
diff
changeset
|
75 void cliFunc_setMod ( char* args ); |
449
45feb80a2ad1
Major USB update, fixes most (if not all) known issues
Jacob Alexander <haata@kiibohd.com>
parents:
447
diff
changeset
|
76 void cliFunc_usbInitTime( char* args ); |
172
a30bddad4115
Adding UART and UART + USB muxed CLI output.
Jacob Alexander <haata@kiibohd.com>
parents:
diff
changeset
|
77 |
a30bddad4115
Adding UART and UART + USB muxed CLI output.
Jacob Alexander <haata@kiibohd.com>
parents:
diff
changeset
|
78 |
227
ed05fa3555d4
Updating usbMuxUart for NKRO
Jacob Alexander <haata@kiibohd.com>
parents:
195
diff
changeset
|
79 |
172
a30bddad4115
Adding UART and UART + USB muxed CLI output.
Jacob Alexander <haata@kiibohd.com>
parents:
diff
changeset
|
80 // ----- Variables ----- |
a30bddad4115
Adding UART and UART + USB muxed CLI output.
Jacob Alexander <haata@kiibohd.com>
parents:
diff
changeset
|
81 |
a30bddad4115
Adding UART and UART + USB muxed CLI output.
Jacob Alexander <haata@kiibohd.com>
parents:
diff
changeset
|
82 // Output Module command dictionary |
239
2a4c99da1276
HUGE AVR RAM optimization (~28%).
Jacob Alexander <haata@kiibohd.com>
parents:
230
diff
changeset
|
83 CLIDict_Entry( kbdProtocol, "Keyboard Protocol Mode: 0 - Boot, 1 - OS/NKRO Mode" ); |
347
136e47478441
UARTConnect enumeration working!
Jacob Alexander <haata@kiibohd.com>
parents:
340
diff
changeset
|
84 CLIDict_Entry( outputDebug, "Toggle Output Debug mode." ); |
239
2a4c99da1276
HUGE AVR RAM optimization (~28%).
Jacob Alexander <haata@kiibohd.com>
parents:
230
diff
changeset
|
85 CLIDict_Entry( readLEDs, "Read LED byte:" NL "\t\t1 NumLck, 2 CapsLck, 4 ScrlLck, 16 Kana, etc." ); |
2a4c99da1276
HUGE AVR RAM optimization (~28%).
Jacob Alexander <haata@kiibohd.com>
parents:
230
diff
changeset
|
86 CLIDict_Entry( readUART, "Read UART buffer until empty." ); |
2a4c99da1276
HUGE AVR RAM optimization (~28%).
Jacob Alexander <haata@kiibohd.com>
parents:
230
diff
changeset
|
87 CLIDict_Entry( sendKeys, "Send the prepared list of USB codes and modifier byte." ); |
2a4c99da1276
HUGE AVR RAM optimization (~28%).
Jacob Alexander <haata@kiibohd.com>
parents:
230
diff
changeset
|
88 CLIDict_Entry( sendUART, "Send characters over UART0." ); |
2a4c99da1276
HUGE AVR RAM optimization (~28%).
Jacob Alexander <haata@kiibohd.com>
parents:
230
diff
changeset
|
89 CLIDict_Entry( setKeys, "Prepare a space separated list of USB codes (decimal). Waits until \033[35msendKeys\033[0m." ); |
2a4c99da1276
HUGE AVR RAM optimization (~28%).
Jacob Alexander <haata@kiibohd.com>
parents:
230
diff
changeset
|
90 CLIDict_Entry( setMod, "Set the modfier byte:" NL "\t\t1 LCtrl, 2 LShft, 4 LAlt, 8 LGUI, 16 RCtrl, 32 RShft, 64 RAlt, 128 RGUI" ); |
449
45feb80a2ad1
Major USB update, fixes most (if not all) known issues
Jacob Alexander <haata@kiibohd.com>
parents:
447
diff
changeset
|
91 CLIDict_Entry( usbInitTime, "Displays the time in ms from usb_init() till the last setup call." ); |
239
2a4c99da1276
HUGE AVR RAM optimization (~28%).
Jacob Alexander <haata@kiibohd.com>
parents:
230
diff
changeset
|
92 |
2a4c99da1276
HUGE AVR RAM optimization (~28%).
Jacob Alexander <haata@kiibohd.com>
parents:
230
diff
changeset
|
93 CLIDict_Def( outputCLIDict, "USB Module Commands" ) = { |
2a4c99da1276
HUGE AVR RAM optimization (~28%).
Jacob Alexander <haata@kiibohd.com>
parents:
230
diff
changeset
|
94 CLIDict_Item( kbdProtocol ), |
347
136e47478441
UARTConnect enumeration working!
Jacob Alexander <haata@kiibohd.com>
parents:
340
diff
changeset
|
95 CLIDict_Item( outputDebug ), |
239
2a4c99da1276
HUGE AVR RAM optimization (~28%).
Jacob Alexander <haata@kiibohd.com>
parents:
230
diff
changeset
|
96 CLIDict_Item( readLEDs ), |
2a4c99da1276
HUGE AVR RAM optimization (~28%).
Jacob Alexander <haata@kiibohd.com>
parents:
230
diff
changeset
|
97 CLIDict_Item( readUART ), |
2a4c99da1276
HUGE AVR RAM optimization (~28%).
Jacob Alexander <haata@kiibohd.com>
parents:
230
diff
changeset
|
98 CLIDict_Item( sendKeys ), |
2a4c99da1276
HUGE AVR RAM optimization (~28%).
Jacob Alexander <haata@kiibohd.com>
parents:
230
diff
changeset
|
99 CLIDict_Item( sendUART ), |
2a4c99da1276
HUGE AVR RAM optimization (~28%).
Jacob Alexander <haata@kiibohd.com>
parents:
230
diff
changeset
|
100 CLIDict_Item( setKeys ), |
2a4c99da1276
HUGE AVR RAM optimization (~28%).
Jacob Alexander <haata@kiibohd.com>
parents:
230
diff
changeset
|
101 CLIDict_Item( setMod ), |
449
45feb80a2ad1
Major USB update, fixes most (if not all) known issues
Jacob Alexander <haata@kiibohd.com>
parents:
447
diff
changeset
|
102 CLIDict_Item( usbInitTime ), |
172
a30bddad4115
Adding UART and UART + USB muxed CLI output.
Jacob Alexander <haata@kiibohd.com>
parents:
diff
changeset
|
103 { 0, 0, 0 } // Null entry for dictionary end |
a30bddad4115
Adding UART and UART + USB muxed CLI output.
Jacob Alexander <haata@kiibohd.com>
parents:
diff
changeset
|
104 }; |
a30bddad4115
Adding UART and UART + USB muxed CLI output.
Jacob Alexander <haata@kiibohd.com>
parents:
diff
changeset
|
105 |
a30bddad4115
Adding UART and UART + USB muxed CLI output.
Jacob Alexander <haata@kiibohd.com>
parents:
diff
changeset
|
106 |
a30bddad4115
Adding UART and UART + USB muxed CLI output.
Jacob Alexander <haata@kiibohd.com>
parents:
diff
changeset
|
107 // Which modifier keys are currently pressed |
a30bddad4115
Adding UART and UART + USB muxed CLI output.
Jacob Alexander <haata@kiibohd.com>
parents:
diff
changeset
|
108 // 1=left ctrl, 2=left shift, 4=left alt, 8=left gui |
a30bddad4115
Adding UART and UART + USB muxed CLI output.
Jacob Alexander <haata@kiibohd.com>
parents:
diff
changeset
|
109 // 16=right ctrl, 32=right shift, 64=right alt, 128=right gui |
347
136e47478441
UARTConnect enumeration working!
Jacob Alexander <haata@kiibohd.com>
parents:
340
diff
changeset
|
110 uint8_t USBKeys_Modifiers = 0; |
136e47478441
UARTConnect enumeration working!
Jacob Alexander <haata@kiibohd.com>
parents:
340
diff
changeset
|
111 uint8_t USBKeys_ModifiersCLI = 0; // Separate CLI send buffer |
172
a30bddad4115
Adding UART and UART + USB muxed CLI output.
Jacob Alexander <haata@kiibohd.com>
parents:
diff
changeset
|
112 |
a30bddad4115
Adding UART and UART + USB muxed CLI output.
Jacob Alexander <haata@kiibohd.com>
parents:
diff
changeset
|
113 // Currently pressed keys, max is defined by USB_MAX_KEY_SEND |
347
136e47478441
UARTConnect enumeration working!
Jacob Alexander <haata@kiibohd.com>
parents:
340
diff
changeset
|
114 uint8_t USBKeys_Keys [USB_NKRO_BITFIELD_SIZE_KEYS]; |
136e47478441
UARTConnect enumeration working!
Jacob Alexander <haata@kiibohd.com>
parents:
340
diff
changeset
|
115 uint8_t USBKeys_KeysCLI[USB_NKRO_BITFIELD_SIZE_KEYS]; // Separate CLI send buffer |
227
ed05fa3555d4
Updating usbMuxUart for NKRO
Jacob Alexander <haata@kiibohd.com>
parents:
195
diff
changeset
|
116 |
ed05fa3555d4
Updating usbMuxUart for NKRO
Jacob Alexander <haata@kiibohd.com>
parents:
195
diff
changeset
|
117 // System Control and Consumer Control 1KRO containers |
347
136e47478441
UARTConnect enumeration working!
Jacob Alexander <haata@kiibohd.com>
parents:
340
diff
changeset
|
118 uint8_t USBKeys_SysCtrl; |
136e47478441
UARTConnect enumeration working!
Jacob Alexander <haata@kiibohd.com>
parents:
340
diff
changeset
|
119 uint16_t USBKeys_ConsCtrl; |
172
a30bddad4115
Adding UART and UART + USB muxed CLI output.
Jacob Alexander <haata@kiibohd.com>
parents:
diff
changeset
|
120 |
a30bddad4115
Adding UART and UART + USB muxed CLI output.
Jacob Alexander <haata@kiibohd.com>
parents:
diff
changeset
|
121 // The number of keys sent to the usb in the array |
347
136e47478441
UARTConnect enumeration working!
Jacob Alexander <haata@kiibohd.com>
parents:
340
diff
changeset
|
122 uint8_t USBKeys_Sent = 0; |
136e47478441
UARTConnect enumeration working!
Jacob Alexander <haata@kiibohd.com>
parents:
340
diff
changeset
|
123 uint8_t USBKeys_SentCLI = 0; |
172
a30bddad4115
Adding UART and UART + USB muxed CLI output.
Jacob Alexander <haata@kiibohd.com>
parents:
diff
changeset
|
124 |
a30bddad4115
Adding UART and UART + USB muxed CLI output.
Jacob Alexander <haata@kiibohd.com>
parents:
diff
changeset
|
125 // 1=num lock, 2=caps lock, 4=scroll lock, 8=compose, 16=kana |
227
ed05fa3555d4
Updating usbMuxUart for NKRO
Jacob Alexander <haata@kiibohd.com>
parents:
195
diff
changeset
|
126 volatile uint8_t USBKeys_LEDs = 0; |
172
a30bddad4115
Adding UART and UART + USB muxed CLI output.
Jacob Alexander <haata@kiibohd.com>
parents:
diff
changeset
|
127 |
438
f10c2dad7f55
Adding missing GET_PROTOCOL handling
Jacob Alexander <haata@kiibohd.com>
parents:
420
diff
changeset
|
128 // Currently pressed mouse buttons, bitmask, 0 represents no buttons pressed |
f10c2dad7f55
Adding missing GET_PROTOCOL handling
Jacob Alexander <haata@kiibohd.com>
parents:
420
diff
changeset
|
129 volatile uint16_t USBMouse_Buttons = 0; |
f10c2dad7f55
Adding missing GET_PROTOCOL handling
Jacob Alexander <haata@kiibohd.com>
parents:
420
diff
changeset
|
130 |
f10c2dad7f55
Adding missing GET_PROTOCOL handling
Jacob Alexander <haata@kiibohd.com>
parents:
420
diff
changeset
|
131 // Relative mouse axis movement, stores pending movement |
f10c2dad7f55
Adding missing GET_PROTOCOL handling
Jacob Alexander <haata@kiibohd.com>
parents:
420
diff
changeset
|
132 volatile uint16_t USBMouse_Relative_x = 0; |
f10c2dad7f55
Adding missing GET_PROTOCOL handling
Jacob Alexander <haata@kiibohd.com>
parents:
420
diff
changeset
|
133 volatile uint16_t USBMouse_Relative_y = 0; |
f10c2dad7f55
Adding missing GET_PROTOCOL handling
Jacob Alexander <haata@kiibohd.com>
parents:
420
diff
changeset
|
134 |
172
a30bddad4115
Adding UART and UART + USB muxed CLI output.
Jacob Alexander <haata@kiibohd.com>
parents:
diff
changeset
|
135 // Protocol setting from the host. |
227
ed05fa3555d4
Updating usbMuxUart for NKRO
Jacob Alexander <haata@kiibohd.com>
parents:
195
diff
changeset
|
136 // 0 - Boot Mode |
ed05fa3555d4
Updating usbMuxUart for NKRO
Jacob Alexander <haata@kiibohd.com>
parents:
195
diff
changeset
|
137 // 1 - NKRO Mode (Default, unless set by a BIOS or boot interface) |
438
f10c2dad7f55
Adding missing GET_PROTOCOL handling
Jacob Alexander <haata@kiibohd.com>
parents:
420
diff
changeset
|
138 volatile uint8_t USBKeys_Protocol = USBProtocol_define; |
227
ed05fa3555d4
Updating usbMuxUart for NKRO
Jacob Alexander <haata@kiibohd.com>
parents:
195
diff
changeset
|
139 |
ed05fa3555d4
Updating usbMuxUart for NKRO
Jacob Alexander <haata@kiibohd.com>
parents:
195
diff
changeset
|
140 // Indicate if USB should send update |
ed05fa3555d4
Updating usbMuxUart for NKRO
Jacob Alexander <haata@kiibohd.com>
parents:
195
diff
changeset
|
141 // OS only needs update if there has been a change in state |
ed05fa3555d4
Updating usbMuxUart for NKRO
Jacob Alexander <haata@kiibohd.com>
parents:
195
diff
changeset
|
142 USBKeyChangeState USBKeys_Changed = USBKeyChangeState_None; |
172
a30bddad4115
Adding UART and UART + USB muxed CLI output.
Jacob Alexander <haata@kiibohd.com>
parents:
diff
changeset
|
143 |
438
f10c2dad7f55
Adding missing GET_PROTOCOL handling
Jacob Alexander <haata@kiibohd.com>
parents:
420
diff
changeset
|
144 // Indicate if USB should send update |
f10c2dad7f55
Adding missing GET_PROTOCOL handling
Jacob Alexander <haata@kiibohd.com>
parents:
420
diff
changeset
|
145 USBMouseChangeState USBMouse_Changed = 0; |
f10c2dad7f55
Adding missing GET_PROTOCOL handling
Jacob Alexander <haata@kiibohd.com>
parents:
420
diff
changeset
|
146 |
172
a30bddad4115
Adding UART and UART + USB muxed CLI output.
Jacob Alexander <haata@kiibohd.com>
parents:
diff
changeset
|
147 // the idle configuration, how often we send the report to the |
a30bddad4115
Adding UART and UART + USB muxed CLI output.
Jacob Alexander <haata@kiibohd.com>
parents:
diff
changeset
|
148 // host (ms * 4) even when it hasn't changed |
447
56237ba5da6f
Adding auto-restart support whenever USB gets into an odd state
Jacob Alexander <haata@kiibohd.com>
parents:
445
diff
changeset
|
149 // 0 - Disables |
56237ba5da6f
Adding auto-restart support whenever USB gets into an odd state
Jacob Alexander <haata@kiibohd.com>
parents:
445
diff
changeset
|
150 uint8_t USBKeys_Idle_Config = 0; |
172
a30bddad4115
Adding UART and UART + USB muxed CLI output.
Jacob Alexander <haata@kiibohd.com>
parents:
diff
changeset
|
151 |
447
56237ba5da6f
Adding auto-restart support whenever USB gets into an odd state
Jacob Alexander <haata@kiibohd.com>
parents:
445
diff
changeset
|
152 // Count until idle timeout |
56237ba5da6f
Adding auto-restart support whenever USB gets into an odd state
Jacob Alexander <haata@kiibohd.com>
parents:
445
diff
changeset
|
153 uint32_t USBKeys_Idle_Expiry = 0; |
347
136e47478441
UARTConnect enumeration working!
Jacob Alexander <haata@kiibohd.com>
parents:
340
diff
changeset
|
154 uint8_t USBKeys_Idle_Count = 0; |
227
ed05fa3555d4
Updating usbMuxUart for NKRO
Jacob Alexander <haata@kiibohd.com>
parents:
195
diff
changeset
|
155 |
275
d5bf41d7f7ef
Initial code for USB cable detection
Jacob Alexander <haata@kiibohd.com>
parents:
263
diff
changeset
|
156 // Indicates whether the Output module is fully functional |
d5bf41d7f7ef
Initial code for USB cable detection
Jacob Alexander <haata@kiibohd.com>
parents:
263
diff
changeset
|
157 // 0 - Not fully functional, 1 - Fully functional |
d5bf41d7f7ef
Initial code for USB cable detection
Jacob Alexander <haata@kiibohd.com>
parents:
263
diff
changeset
|
158 // 0 is often used to show that a USB cable is not plugged in (but has power) |
347
136e47478441
UARTConnect enumeration working!
Jacob Alexander <haata@kiibohd.com>
parents:
340
diff
changeset
|
159 volatile uint8_t Output_Available = 0; |
275
d5bf41d7f7ef
Initial code for USB cable detection
Jacob Alexander <haata@kiibohd.com>
parents:
263
diff
changeset
|
160 |
300
7119c2149abb
Fixing compiler errors for usbMuxUart Output module
Jacob Alexander <haata@kiibohd.com>
parents:
275
diff
changeset
|
161 // Debug control variable for Output modules |
7119c2149abb
Fixing compiler errors for usbMuxUart Output module
Jacob Alexander <haata@kiibohd.com>
parents:
275
diff
changeset
|
162 // 0 - Debug disabled (default) |
7119c2149abb
Fixing compiler errors for usbMuxUart Output module
Jacob Alexander <haata@kiibohd.com>
parents:
275
diff
changeset
|
163 // 1 - Debug enabled |
347
136e47478441
UARTConnect enumeration working!
Jacob Alexander <haata@kiibohd.com>
parents:
340
diff
changeset
|
164 uint8_t Output_DebugMode = 0; |
300
7119c2149abb
Fixing compiler errors for usbMuxUart Output module
Jacob Alexander <haata@kiibohd.com>
parents:
275
diff
changeset
|
165 |
420
23a1868b4ac2
Adding dynamic USB power support
Jacob Alexander <haata@kiibohd.com>
parents:
385
diff
changeset
|
166 // mA - Set by outside module if not using USB (i.e. Interconnect) |
23a1868b4ac2
Adding dynamic USB power support
Jacob Alexander <haata@kiibohd.com>
parents:
385
diff
changeset
|
167 // Generally set to 100 mA (low power) or 500 mA (high power) |
23a1868b4ac2
Adding dynamic USB power support
Jacob Alexander <haata@kiibohd.com>
parents:
385
diff
changeset
|
168 uint16_t Output_ExtCurrent_Available = 0; |
23a1868b4ac2
Adding dynamic USB power support
Jacob Alexander <haata@kiibohd.com>
parents:
385
diff
changeset
|
169 |
23a1868b4ac2
Adding dynamic USB power support
Jacob Alexander <haata@kiibohd.com>
parents:
385
diff
changeset
|
170 // mA - Set by USB module (if exists) |
23a1868b4ac2
Adding dynamic USB power support
Jacob Alexander <haata@kiibohd.com>
parents:
385
diff
changeset
|
171 // Initially 100 mA, but may be negotiated higher (e.g. 500 mA) |
23a1868b4ac2
Adding dynamic USB power support
Jacob Alexander <haata@kiibohd.com>
parents:
385
diff
changeset
|
172 uint16_t Output_USBCurrent_Available = 0; |
23a1868b4ac2
Adding dynamic USB power support
Jacob Alexander <haata@kiibohd.com>
parents:
385
diff
changeset
|
173 |
449
45feb80a2ad1
Major USB update, fixes most (if not all) known issues
Jacob Alexander <haata@kiibohd.com>
parents:
447
diff
changeset
|
174 // USB Init Time (ms) |
45feb80a2ad1
Major USB update, fixes most (if not all) known issues
Jacob Alexander <haata@kiibohd.com>
parents:
447
diff
changeset
|
175 volatile uint32_t USBInit_TimeStart; |
45feb80a2ad1
Major USB update, fixes most (if not all) known issues
Jacob Alexander <haata@kiibohd.com>
parents:
447
diff
changeset
|
176 volatile uint32_t USBInit_TimeEnd; |
45feb80a2ad1
Major USB update, fixes most (if not all) known issues
Jacob Alexander <haata@kiibohd.com>
parents:
447
diff
changeset
|
177 volatile uint16_t USBInit_Ticks; |
45feb80a2ad1
Major USB update, fixes most (if not all) known issues
Jacob Alexander <haata@kiibohd.com>
parents:
447
diff
changeset
|
178 |
227
ed05fa3555d4
Updating usbMuxUart for NKRO
Jacob Alexander <haata@kiibohd.com>
parents:
195
diff
changeset
|
179 |
ed05fa3555d4
Updating usbMuxUart for NKRO
Jacob Alexander <haata@kiibohd.com>
parents:
195
diff
changeset
|
180 |
ed05fa3555d4
Updating usbMuxUart for NKRO
Jacob Alexander <haata@kiibohd.com>
parents:
195
diff
changeset
|
181 // ----- Capabilities ----- |
ed05fa3555d4
Updating usbMuxUart for NKRO
Jacob Alexander <haata@kiibohd.com>
parents:
195
diff
changeset
|
182 |
300
7119c2149abb
Fixing compiler errors for usbMuxUart Output module
Jacob Alexander <haata@kiibohd.com>
parents:
275
diff
changeset
|
183 // Set Boot Keyboard Protocol |
7119c2149abb
Fixing compiler errors for usbMuxUart Output module
Jacob Alexander <haata@kiibohd.com>
parents:
275
diff
changeset
|
184 void Output_kbdProtocolBoot_capability( uint8_t state, uint8_t stateType, uint8_t *args ) |
7119c2149abb
Fixing compiler errors for usbMuxUart Output module
Jacob Alexander <haata@kiibohd.com>
parents:
275
diff
changeset
|
185 { |
449
45feb80a2ad1
Major USB update, fixes most (if not all) known issues
Jacob Alexander <haata@kiibohd.com>
parents:
447
diff
changeset
|
186 #if enableKeyboard_define == 1 |
300
7119c2149abb
Fixing compiler errors for usbMuxUart Output module
Jacob Alexander <haata@kiibohd.com>
parents:
275
diff
changeset
|
187 // Display capability name |
7119c2149abb
Fixing compiler errors for usbMuxUart Output module
Jacob Alexander <haata@kiibohd.com>
parents:
275
diff
changeset
|
188 if ( stateType == 0xFF && state == 0xFF ) |
7119c2149abb
Fixing compiler errors for usbMuxUart Output module
Jacob Alexander <haata@kiibohd.com>
parents:
275
diff
changeset
|
189 { |
7119c2149abb
Fixing compiler errors for usbMuxUart Output module
Jacob Alexander <haata@kiibohd.com>
parents:
275
diff
changeset
|
190 print("Output_kbdProtocolBoot()"); |
7119c2149abb
Fixing compiler errors for usbMuxUart Output module
Jacob Alexander <haata@kiibohd.com>
parents:
275
diff
changeset
|
191 return; |
7119c2149abb
Fixing compiler errors for usbMuxUart Output module
Jacob Alexander <haata@kiibohd.com>
parents:
275
diff
changeset
|
192 } |
7119c2149abb
Fixing compiler errors for usbMuxUart Output module
Jacob Alexander <haata@kiibohd.com>
parents:
275
diff
changeset
|
193 |
7119c2149abb
Fixing compiler errors for usbMuxUart Output module
Jacob Alexander <haata@kiibohd.com>
parents:
275
diff
changeset
|
194 // Only set if necessary |
7119c2149abb
Fixing compiler errors for usbMuxUart Output module
Jacob Alexander <haata@kiibohd.com>
parents:
275
diff
changeset
|
195 if ( USBKeys_Protocol == 0 ) |
7119c2149abb
Fixing compiler errors for usbMuxUart Output module
Jacob Alexander <haata@kiibohd.com>
parents:
275
diff
changeset
|
196 return; |
7119c2149abb
Fixing compiler errors for usbMuxUart Output module
Jacob Alexander <haata@kiibohd.com>
parents:
275
diff
changeset
|
197 |
7119c2149abb
Fixing compiler errors for usbMuxUart Output module
Jacob Alexander <haata@kiibohd.com>
parents:
275
diff
changeset
|
198 // TODO Analog inputs |
7119c2149abb
Fixing compiler errors for usbMuxUart Output module
Jacob Alexander <haata@kiibohd.com>
parents:
275
diff
changeset
|
199 // Only set on key press |
7119c2149abb
Fixing compiler errors for usbMuxUart Output module
Jacob Alexander <haata@kiibohd.com>
parents:
275
diff
changeset
|
200 if ( stateType != 0x01 ) |
7119c2149abb
Fixing compiler errors for usbMuxUart Output module
Jacob Alexander <haata@kiibohd.com>
parents:
275
diff
changeset
|
201 return; |
7119c2149abb
Fixing compiler errors for usbMuxUart Output module
Jacob Alexander <haata@kiibohd.com>
parents:
275
diff
changeset
|
202 |
7119c2149abb
Fixing compiler errors for usbMuxUart Output module
Jacob Alexander <haata@kiibohd.com>
parents:
275
diff
changeset
|
203 // Flush the key buffers |
7119c2149abb
Fixing compiler errors for usbMuxUart Output module
Jacob Alexander <haata@kiibohd.com>
parents:
275
diff
changeset
|
204 Output_flushBuffers(); |
7119c2149abb
Fixing compiler errors for usbMuxUart Output module
Jacob Alexander <haata@kiibohd.com>
parents:
275
diff
changeset
|
205 |
7119c2149abb
Fixing compiler errors for usbMuxUart Output module
Jacob Alexander <haata@kiibohd.com>
parents:
275
diff
changeset
|
206 // Set the keyboard protocol to Boot Mode |
7119c2149abb
Fixing compiler errors for usbMuxUart Output module
Jacob Alexander <haata@kiibohd.com>
parents:
275
diff
changeset
|
207 USBKeys_Protocol = 0; |
449
45feb80a2ad1
Major USB update, fixes most (if not all) known issues
Jacob Alexander <haata@kiibohd.com>
parents:
447
diff
changeset
|
208 #endif |
300
7119c2149abb
Fixing compiler errors for usbMuxUart Output module
Jacob Alexander <haata@kiibohd.com>
parents:
275
diff
changeset
|
209 } |
7119c2149abb
Fixing compiler errors for usbMuxUart Output module
Jacob Alexander <haata@kiibohd.com>
parents:
275
diff
changeset
|
210 |
7119c2149abb
Fixing compiler errors for usbMuxUart Output module
Jacob Alexander <haata@kiibohd.com>
parents:
275
diff
changeset
|
211 |
7119c2149abb
Fixing compiler errors for usbMuxUart Output module
Jacob Alexander <haata@kiibohd.com>
parents:
275
diff
changeset
|
212 // Set NKRO Keyboard Protocol |
7119c2149abb
Fixing compiler errors for usbMuxUart Output module
Jacob Alexander <haata@kiibohd.com>
parents:
275
diff
changeset
|
213 void Output_kbdProtocolNKRO_capability( uint8_t state, uint8_t stateType, uint8_t *args ) |
7119c2149abb
Fixing compiler errors for usbMuxUart Output module
Jacob Alexander <haata@kiibohd.com>
parents:
275
diff
changeset
|
214 { |
449
45feb80a2ad1
Major USB update, fixes most (if not all) known issues
Jacob Alexander <haata@kiibohd.com>
parents:
447
diff
changeset
|
215 #if enableKeyboard_define == 1 |
300
7119c2149abb
Fixing compiler errors for usbMuxUart Output module
Jacob Alexander <haata@kiibohd.com>
parents:
275
diff
changeset
|
216 // Display capability name |
7119c2149abb
Fixing compiler errors for usbMuxUart Output module
Jacob Alexander <haata@kiibohd.com>
parents:
275
diff
changeset
|
217 if ( stateType == 0xFF && state == 0xFF ) |
7119c2149abb
Fixing compiler errors for usbMuxUart Output module
Jacob Alexander <haata@kiibohd.com>
parents:
275
diff
changeset
|
218 { |
7119c2149abb
Fixing compiler errors for usbMuxUart Output module
Jacob Alexander <haata@kiibohd.com>
parents:
275
diff
changeset
|
219 print("Output_kbdProtocolNKRO()"); |
7119c2149abb
Fixing compiler errors for usbMuxUart Output module
Jacob Alexander <haata@kiibohd.com>
parents:
275
diff
changeset
|
220 return; |
7119c2149abb
Fixing compiler errors for usbMuxUart Output module
Jacob Alexander <haata@kiibohd.com>
parents:
275
diff
changeset
|
221 } |
7119c2149abb
Fixing compiler errors for usbMuxUart Output module
Jacob Alexander <haata@kiibohd.com>
parents:
275
diff
changeset
|
222 |
7119c2149abb
Fixing compiler errors for usbMuxUart Output module
Jacob Alexander <haata@kiibohd.com>
parents:
275
diff
changeset
|
223 // Only set if necessary |
7119c2149abb
Fixing compiler errors for usbMuxUart Output module
Jacob Alexander <haata@kiibohd.com>
parents:
275
diff
changeset
|
224 if ( USBKeys_Protocol == 1 ) |
7119c2149abb
Fixing compiler errors for usbMuxUart Output module
Jacob Alexander <haata@kiibohd.com>
parents:
275
diff
changeset
|
225 return; |
7119c2149abb
Fixing compiler errors for usbMuxUart Output module
Jacob Alexander <haata@kiibohd.com>
parents:
275
diff
changeset
|
226 |
7119c2149abb
Fixing compiler errors for usbMuxUart Output module
Jacob Alexander <haata@kiibohd.com>
parents:
275
diff
changeset
|
227 // TODO Analog inputs |
7119c2149abb
Fixing compiler errors for usbMuxUart Output module
Jacob Alexander <haata@kiibohd.com>
parents:
275
diff
changeset
|
228 // Only set on key press |
7119c2149abb
Fixing compiler errors for usbMuxUart Output module
Jacob Alexander <haata@kiibohd.com>
parents:
275
diff
changeset
|
229 if ( stateType != 0x01 ) |
7119c2149abb
Fixing compiler errors for usbMuxUart Output module
Jacob Alexander <haata@kiibohd.com>
parents:
275
diff
changeset
|
230 return; |
7119c2149abb
Fixing compiler errors for usbMuxUart Output module
Jacob Alexander <haata@kiibohd.com>
parents:
275
diff
changeset
|
231 |
7119c2149abb
Fixing compiler errors for usbMuxUart Output module
Jacob Alexander <haata@kiibohd.com>
parents:
275
diff
changeset
|
232 // Flush the key buffers |
7119c2149abb
Fixing compiler errors for usbMuxUart Output module
Jacob Alexander <haata@kiibohd.com>
parents:
275
diff
changeset
|
233 Output_flushBuffers(); |
7119c2149abb
Fixing compiler errors for usbMuxUart Output module
Jacob Alexander <haata@kiibohd.com>
parents:
275
diff
changeset
|
234 |
7119c2149abb
Fixing compiler errors for usbMuxUart Output module
Jacob Alexander <haata@kiibohd.com>
parents:
275
diff
changeset
|
235 // Set the keyboard protocol to NKRO Mode |
7119c2149abb
Fixing compiler errors for usbMuxUart Output module
Jacob Alexander <haata@kiibohd.com>
parents:
275
diff
changeset
|
236 USBKeys_Protocol = 1; |
449
45feb80a2ad1
Major USB update, fixes most (if not all) known issues
Jacob Alexander <haata@kiibohd.com>
parents:
447
diff
changeset
|
237 #endif |
300
7119c2149abb
Fixing compiler errors for usbMuxUart Output module
Jacob Alexander <haata@kiibohd.com>
parents:
275
diff
changeset
|
238 } |
7119c2149abb
Fixing compiler errors for usbMuxUart Output module
Jacob Alexander <haata@kiibohd.com>
parents:
275
diff
changeset
|
239 |
7119c2149abb
Fixing compiler errors for usbMuxUart Output module
Jacob Alexander <haata@kiibohd.com>
parents:
275
diff
changeset
|
240 |
445
380e1f0123d0
Adding toggleKbdProtocol capability
José Luis Salvador Rufo <salvador.joseluis@gmail.com>
parents:
439
diff
changeset
|
241 // Toggle Keyboard Protocol |
380e1f0123d0
Adding toggleKbdProtocol capability
José Luis Salvador Rufo <salvador.joseluis@gmail.com>
parents:
439
diff
changeset
|
242 void Output_toggleKbdProtocol_capability( uint8_t state, uint8_t stateType, uint8_t *args ) |
380e1f0123d0
Adding toggleKbdProtocol capability
José Luis Salvador Rufo <salvador.joseluis@gmail.com>
parents:
439
diff
changeset
|
243 { |
449
45feb80a2ad1
Major USB update, fixes most (if not all) known issues
Jacob Alexander <haata@kiibohd.com>
parents:
447
diff
changeset
|
244 #if enableKeyboard_define == 1 |
445
380e1f0123d0
Adding toggleKbdProtocol capability
José Luis Salvador Rufo <salvador.joseluis@gmail.com>
parents:
439
diff
changeset
|
245 // Display capability name |
380e1f0123d0
Adding toggleKbdProtocol capability
José Luis Salvador Rufo <salvador.joseluis@gmail.com>
parents:
439
diff
changeset
|
246 if ( stateType == 0xFF && state == 0xFF ) |
380e1f0123d0
Adding toggleKbdProtocol capability
José Luis Salvador Rufo <salvador.joseluis@gmail.com>
parents:
439
diff
changeset
|
247 { |
380e1f0123d0
Adding toggleKbdProtocol capability
José Luis Salvador Rufo <salvador.joseluis@gmail.com>
parents:
439
diff
changeset
|
248 print("Output_toggleKbdProtocol()"); |
380e1f0123d0
Adding toggleKbdProtocol capability
José Luis Salvador Rufo <salvador.joseluis@gmail.com>
parents:
439
diff
changeset
|
249 return; |
380e1f0123d0
Adding toggleKbdProtocol capability
José Luis Salvador Rufo <salvador.joseluis@gmail.com>
parents:
439
diff
changeset
|
250 } |
380e1f0123d0
Adding toggleKbdProtocol capability
José Luis Salvador Rufo <salvador.joseluis@gmail.com>
parents:
439
diff
changeset
|
251 |
380e1f0123d0
Adding toggleKbdProtocol capability
José Luis Salvador Rufo <salvador.joseluis@gmail.com>
parents:
439
diff
changeset
|
252 // Only toggle protocol if release state |
380e1f0123d0
Adding toggleKbdProtocol capability
José Luis Salvador Rufo <salvador.joseluis@gmail.com>
parents:
439
diff
changeset
|
253 if ( stateType == 0x00 && state == 0x03 ) |
380e1f0123d0
Adding toggleKbdProtocol capability
José Luis Salvador Rufo <salvador.joseluis@gmail.com>
parents:
439
diff
changeset
|
254 { |
380e1f0123d0
Adding toggleKbdProtocol capability
José Luis Salvador Rufo <salvador.joseluis@gmail.com>
parents:
439
diff
changeset
|
255 // Flush the key buffers |
380e1f0123d0
Adding toggleKbdProtocol capability
José Luis Salvador Rufo <salvador.joseluis@gmail.com>
parents:
439
diff
changeset
|
256 Output_flushBuffers(); |
380e1f0123d0
Adding toggleKbdProtocol capability
José Luis Salvador Rufo <salvador.joseluis@gmail.com>
parents:
439
diff
changeset
|
257 |
380e1f0123d0
Adding toggleKbdProtocol capability
José Luis Salvador Rufo <salvador.joseluis@gmail.com>
parents:
439
diff
changeset
|
258 // Toggle the keyboard protocol Mode |
380e1f0123d0
Adding toggleKbdProtocol capability
José Luis Salvador Rufo <salvador.joseluis@gmail.com>
parents:
439
diff
changeset
|
259 USBKeys_Protocol = !USBKeys_Protocol; |
380e1f0123d0
Adding toggleKbdProtocol capability
José Luis Salvador Rufo <salvador.joseluis@gmail.com>
parents:
439
diff
changeset
|
260 } |
449
45feb80a2ad1
Major USB update, fixes most (if not all) known issues
Jacob Alexander <haata@kiibohd.com>
parents:
447
diff
changeset
|
261 #endif |
445
380e1f0123d0
Adding toggleKbdProtocol capability
José Luis Salvador Rufo <salvador.joseluis@gmail.com>
parents:
439
diff
changeset
|
262 } |
380e1f0123d0
Adding toggleKbdProtocol capability
José Luis Salvador Rufo <salvador.joseluis@gmail.com>
parents:
439
diff
changeset
|
263 |
380e1f0123d0
Adding toggleKbdProtocol capability
José Luis Salvador Rufo <salvador.joseluis@gmail.com>
parents:
439
diff
changeset
|
264 |
227
ed05fa3555d4
Updating usbMuxUart for NKRO
Jacob Alexander <haata@kiibohd.com>
parents:
195
diff
changeset
|
265 // Sends a Consumer Control code to the USB Output buffer |
ed05fa3555d4
Updating usbMuxUart for NKRO
Jacob Alexander <haata@kiibohd.com>
parents:
195
diff
changeset
|
266 void Output_consCtrlSend_capability( uint8_t state, uint8_t stateType, uint8_t *args ) |
ed05fa3555d4
Updating usbMuxUart for NKRO
Jacob Alexander <haata@kiibohd.com>
parents:
195
diff
changeset
|
267 { |
449
45feb80a2ad1
Major USB update, fixes most (if not all) known issues
Jacob Alexander <haata@kiibohd.com>
parents:
447
diff
changeset
|
268 #if enableKeyboard_define == 1 |
227
ed05fa3555d4
Updating usbMuxUart for NKRO
Jacob Alexander <haata@kiibohd.com>
parents:
195
diff
changeset
|
269 // Display capability name |
ed05fa3555d4
Updating usbMuxUart for NKRO
Jacob Alexander <haata@kiibohd.com>
parents:
195
diff
changeset
|
270 if ( stateType == 0xFF && state == 0xFF ) |
ed05fa3555d4
Updating usbMuxUart for NKRO
Jacob Alexander <haata@kiibohd.com>
parents:
195
diff
changeset
|
271 { |
ed05fa3555d4
Updating usbMuxUart for NKRO
Jacob Alexander <haata@kiibohd.com>
parents:
195
diff
changeset
|
272 print("Output_consCtrlSend(consCode)"); |
ed05fa3555d4
Updating usbMuxUart for NKRO
Jacob Alexander <haata@kiibohd.com>
parents:
195
diff
changeset
|
273 return; |
ed05fa3555d4
Updating usbMuxUart for NKRO
Jacob Alexander <haata@kiibohd.com>
parents:
195
diff
changeset
|
274 } |
ed05fa3555d4
Updating usbMuxUart for NKRO
Jacob Alexander <haata@kiibohd.com>
parents:
195
diff
changeset
|
275 |
ed05fa3555d4
Updating usbMuxUart for NKRO
Jacob Alexander <haata@kiibohd.com>
parents:
195
diff
changeset
|
276 // Not implemented in Boot Mode |
ed05fa3555d4
Updating usbMuxUart for NKRO
Jacob Alexander <haata@kiibohd.com>
parents:
195
diff
changeset
|
277 if ( USBKeys_Protocol == 0 ) |
ed05fa3555d4
Updating usbMuxUart for NKRO
Jacob Alexander <haata@kiibohd.com>
parents:
195
diff
changeset
|
278 { |
ed05fa3555d4
Updating usbMuxUart for NKRO
Jacob Alexander <haata@kiibohd.com>
parents:
195
diff
changeset
|
279 warn_print("Consumer Control is not implemented for Boot Mode"); |
ed05fa3555d4
Updating usbMuxUart for NKRO
Jacob Alexander <haata@kiibohd.com>
parents:
195
diff
changeset
|
280 return; |
ed05fa3555d4
Updating usbMuxUart for NKRO
Jacob Alexander <haata@kiibohd.com>
parents:
195
diff
changeset
|
281 } |
ed05fa3555d4
Updating usbMuxUart for NKRO
Jacob Alexander <haata@kiibohd.com>
parents:
195
diff
changeset
|
282 |
ed05fa3555d4
Updating usbMuxUart for NKRO
Jacob Alexander <haata@kiibohd.com>
parents:
195
diff
changeset
|
283 // TODO Analog inputs |
ed05fa3555d4
Updating usbMuxUart for NKRO
Jacob Alexander <haata@kiibohd.com>
parents:
195
diff
changeset
|
284 // Only indicate USB has changed if either a press or release has occured |
ed05fa3555d4
Updating usbMuxUart for NKRO
Jacob Alexander <haata@kiibohd.com>
parents:
195
diff
changeset
|
285 if ( state == 0x01 || state == 0x03 ) |
ed05fa3555d4
Updating usbMuxUart for NKRO
Jacob Alexander <haata@kiibohd.com>
parents:
195
diff
changeset
|
286 USBKeys_Changed |= USBKeyChangeState_Consumer; |
ed05fa3555d4
Updating usbMuxUart for NKRO
Jacob Alexander <haata@kiibohd.com>
parents:
195
diff
changeset
|
287 |
ed05fa3555d4
Updating usbMuxUart for NKRO
Jacob Alexander <haata@kiibohd.com>
parents:
195
diff
changeset
|
288 // Only send keypresses if press or hold state |
ed05fa3555d4
Updating usbMuxUart for NKRO
Jacob Alexander <haata@kiibohd.com>
parents:
195
diff
changeset
|
289 if ( stateType == 0x00 && state == 0x03 ) // Release state |
347
136e47478441
UARTConnect enumeration working!
Jacob Alexander <haata@kiibohd.com>
parents:
340
diff
changeset
|
290 { |
136e47478441
UARTConnect enumeration working!
Jacob Alexander <haata@kiibohd.com>
parents:
340
diff
changeset
|
291 USBKeys_ConsCtrl = 0; |
227
ed05fa3555d4
Updating usbMuxUart for NKRO
Jacob Alexander <haata@kiibohd.com>
parents:
195
diff
changeset
|
292 return; |
347
136e47478441
UARTConnect enumeration working!
Jacob Alexander <haata@kiibohd.com>
parents:
340
diff
changeset
|
293 } |
227
ed05fa3555d4
Updating usbMuxUart for NKRO
Jacob Alexander <haata@kiibohd.com>
parents:
195
diff
changeset
|
294 |
ed05fa3555d4
Updating usbMuxUart for NKRO
Jacob Alexander <haata@kiibohd.com>
parents:
195
diff
changeset
|
295 // Set consumer control code |
ed05fa3555d4
Updating usbMuxUart for NKRO
Jacob Alexander <haata@kiibohd.com>
parents:
195
diff
changeset
|
296 USBKeys_ConsCtrl = *(uint16_t*)(&args[0]); |
449
45feb80a2ad1
Major USB update, fixes most (if not all) known issues
Jacob Alexander <haata@kiibohd.com>
parents:
447
diff
changeset
|
297 #endif |
227
ed05fa3555d4
Updating usbMuxUart for NKRO
Jacob Alexander <haata@kiibohd.com>
parents:
195
diff
changeset
|
298 } |
ed05fa3555d4
Updating usbMuxUart for NKRO
Jacob Alexander <haata@kiibohd.com>
parents:
195
diff
changeset
|
299 |
ed05fa3555d4
Updating usbMuxUart for NKRO
Jacob Alexander <haata@kiibohd.com>
parents:
195
diff
changeset
|
300 |
340 | 301 // Ignores the given key status update |
302 // Used to prevent fall-through, this is the None keyword in KLL | |
303 void Output_noneSend_capability( uint8_t state, uint8_t stateType, uint8_t *args ) | |
304 { | |
305 // Display capability name | |
306 if ( stateType == 0xFF && state == 0xFF ) | |
307 { | |
308 print("Output_noneSend()"); | |
309 return; | |
310 } | |
311 | |
312 // Nothing to do, because that's the point :P | |
313 } | |
314 | |
315 | |
227
ed05fa3555d4
Updating usbMuxUart for NKRO
Jacob Alexander <haata@kiibohd.com>
parents:
195
diff
changeset
|
316 // Sends a System Control code to the USB Output buffer |
ed05fa3555d4
Updating usbMuxUart for NKRO
Jacob Alexander <haata@kiibohd.com>
parents:
195
diff
changeset
|
317 void Output_sysCtrlSend_capability( uint8_t state, uint8_t stateType, uint8_t *args ) |
ed05fa3555d4
Updating usbMuxUart for NKRO
Jacob Alexander <haata@kiibohd.com>
parents:
195
diff
changeset
|
318 { |
449
45feb80a2ad1
Major USB update, fixes most (if not all) known issues
Jacob Alexander <haata@kiibohd.com>
parents:
447
diff
changeset
|
319 #if enableKeyboard_define == 1 |
227
ed05fa3555d4
Updating usbMuxUart for NKRO
Jacob Alexander <haata@kiibohd.com>
parents:
195
diff
changeset
|
320 // Display capability name |
ed05fa3555d4
Updating usbMuxUart for NKRO
Jacob Alexander <haata@kiibohd.com>
parents:
195
diff
changeset
|
321 if ( stateType == 0xFF && state == 0xFF ) |
ed05fa3555d4
Updating usbMuxUart for NKRO
Jacob Alexander <haata@kiibohd.com>
parents:
195
diff
changeset
|
322 { |
ed05fa3555d4
Updating usbMuxUart for NKRO
Jacob Alexander <haata@kiibohd.com>
parents:
195
diff
changeset
|
323 print("Output_sysCtrlSend(sysCode)"); |
ed05fa3555d4
Updating usbMuxUart for NKRO
Jacob Alexander <haata@kiibohd.com>
parents:
195
diff
changeset
|
324 return; |
ed05fa3555d4
Updating usbMuxUart for NKRO
Jacob Alexander <haata@kiibohd.com>
parents:
195
diff
changeset
|
325 } |
ed05fa3555d4
Updating usbMuxUart for NKRO
Jacob Alexander <haata@kiibohd.com>
parents:
195
diff
changeset
|
326 |
ed05fa3555d4
Updating usbMuxUart for NKRO
Jacob Alexander <haata@kiibohd.com>
parents:
195
diff
changeset
|
327 // Not implemented in Boot Mode |
ed05fa3555d4
Updating usbMuxUart for NKRO
Jacob Alexander <haata@kiibohd.com>
parents:
195
diff
changeset
|
328 if ( USBKeys_Protocol == 0 ) |
ed05fa3555d4
Updating usbMuxUart for NKRO
Jacob Alexander <haata@kiibohd.com>
parents:
195
diff
changeset
|
329 { |
ed05fa3555d4
Updating usbMuxUart for NKRO
Jacob Alexander <haata@kiibohd.com>
parents:
195
diff
changeset
|
330 warn_print("System Control is not implemented for Boot Mode"); |
ed05fa3555d4
Updating usbMuxUart for NKRO
Jacob Alexander <haata@kiibohd.com>
parents:
195
diff
changeset
|
331 return; |
ed05fa3555d4
Updating usbMuxUart for NKRO
Jacob Alexander <haata@kiibohd.com>
parents:
195
diff
changeset
|
332 } |
ed05fa3555d4
Updating usbMuxUart for NKRO
Jacob Alexander <haata@kiibohd.com>
parents:
195
diff
changeset
|
333 |
ed05fa3555d4
Updating usbMuxUart for NKRO
Jacob Alexander <haata@kiibohd.com>
parents:
195
diff
changeset
|
334 // TODO Analog inputs |
ed05fa3555d4
Updating usbMuxUart for NKRO
Jacob Alexander <haata@kiibohd.com>
parents:
195
diff
changeset
|
335 // Only indicate USB has changed if either a press or release has occured |
ed05fa3555d4
Updating usbMuxUart for NKRO
Jacob Alexander <haata@kiibohd.com>
parents:
195
diff
changeset
|
336 if ( state == 0x01 || state == 0x03 ) |
ed05fa3555d4
Updating usbMuxUart for NKRO
Jacob Alexander <haata@kiibohd.com>
parents:
195
diff
changeset
|
337 USBKeys_Changed |= USBKeyChangeState_System; |
ed05fa3555d4
Updating usbMuxUart for NKRO
Jacob Alexander <haata@kiibohd.com>
parents:
195
diff
changeset
|
338 |
ed05fa3555d4
Updating usbMuxUart for NKRO
Jacob Alexander <haata@kiibohd.com>
parents:
195
diff
changeset
|
339 // Only send keypresses if press or hold state |
ed05fa3555d4
Updating usbMuxUart for NKRO
Jacob Alexander <haata@kiibohd.com>
parents:
195
diff
changeset
|
340 if ( stateType == 0x00 && state == 0x03 ) // Release state |
347
136e47478441
UARTConnect enumeration working!
Jacob Alexander <haata@kiibohd.com>
parents:
340
diff
changeset
|
341 { |
136e47478441
UARTConnect enumeration working!
Jacob Alexander <haata@kiibohd.com>
parents:
340
diff
changeset
|
342 USBKeys_SysCtrl = 0; |
227
ed05fa3555d4
Updating usbMuxUart for NKRO
Jacob Alexander <haata@kiibohd.com>
parents:
195
diff
changeset
|
343 return; |
347
136e47478441
UARTConnect enumeration working!
Jacob Alexander <haata@kiibohd.com>
parents:
340
diff
changeset
|
344 } |
227
ed05fa3555d4
Updating usbMuxUart for NKRO
Jacob Alexander <haata@kiibohd.com>
parents:
195
diff
changeset
|
345 |
ed05fa3555d4
Updating usbMuxUart for NKRO
Jacob Alexander <haata@kiibohd.com>
parents:
195
diff
changeset
|
346 // Set system control code |
ed05fa3555d4
Updating usbMuxUart for NKRO
Jacob Alexander <haata@kiibohd.com>
parents:
195
diff
changeset
|
347 USBKeys_SysCtrl = args[0]; |
449
45feb80a2ad1
Major USB update, fixes most (if not all) known issues
Jacob Alexander <haata@kiibohd.com>
parents:
447
diff
changeset
|
348 #endif |
227
ed05fa3555d4
Updating usbMuxUart for NKRO
Jacob Alexander <haata@kiibohd.com>
parents:
195
diff
changeset
|
349 } |
ed05fa3555d4
Updating usbMuxUart for NKRO
Jacob Alexander <haata@kiibohd.com>
parents:
195
diff
changeset
|
350 |
ed05fa3555d4
Updating usbMuxUart for NKRO
Jacob Alexander <haata@kiibohd.com>
parents:
195
diff
changeset
|
351 |
ed05fa3555d4
Updating usbMuxUart for NKRO
Jacob Alexander <haata@kiibohd.com>
parents:
195
diff
changeset
|
352 // Adds a single USB Code to the USB Output buffer |
ed05fa3555d4
Updating usbMuxUart for NKRO
Jacob Alexander <haata@kiibohd.com>
parents:
195
diff
changeset
|
353 // Argument #1: USB Code |
ed05fa3555d4
Updating usbMuxUart for NKRO
Jacob Alexander <haata@kiibohd.com>
parents:
195
diff
changeset
|
354 void Output_usbCodeSend_capability( uint8_t state, uint8_t stateType, uint8_t *args ) |
ed05fa3555d4
Updating usbMuxUart for NKRO
Jacob Alexander <haata@kiibohd.com>
parents:
195
diff
changeset
|
355 { |
449
45feb80a2ad1
Major USB update, fixes most (if not all) known issues
Jacob Alexander <haata@kiibohd.com>
parents:
447
diff
changeset
|
356 #if enableKeyboard_define == 1 |
227
ed05fa3555d4
Updating usbMuxUart for NKRO
Jacob Alexander <haata@kiibohd.com>
parents:
195
diff
changeset
|
357 // Display capability name |
ed05fa3555d4
Updating usbMuxUart for NKRO
Jacob Alexander <haata@kiibohd.com>
parents:
195
diff
changeset
|
358 if ( stateType == 0xFF && state == 0xFF ) |
ed05fa3555d4
Updating usbMuxUart for NKRO
Jacob Alexander <haata@kiibohd.com>
parents:
195
diff
changeset
|
359 { |
ed05fa3555d4
Updating usbMuxUart for NKRO
Jacob Alexander <haata@kiibohd.com>
parents:
195
diff
changeset
|
360 print("Output_usbCodeSend(usbCode)"); |
ed05fa3555d4
Updating usbMuxUart for NKRO
Jacob Alexander <haata@kiibohd.com>
parents:
195
diff
changeset
|
361 return; |
ed05fa3555d4
Updating usbMuxUart for NKRO
Jacob Alexander <haata@kiibohd.com>
parents:
195
diff
changeset
|
362 } |
ed05fa3555d4
Updating usbMuxUart for NKRO
Jacob Alexander <haata@kiibohd.com>
parents:
195
diff
changeset
|
363 |
ed05fa3555d4
Updating usbMuxUart for NKRO
Jacob Alexander <haata@kiibohd.com>
parents:
195
diff
changeset
|
364 // Depending on which mode the keyboard is in the USB needs Press/Hold/Release events |
ed05fa3555d4
Updating usbMuxUart for NKRO
Jacob Alexander <haata@kiibohd.com>
parents:
195
diff
changeset
|
365 uint8_t keyPress = 0; // Default to key release, only used for NKRO |
ed05fa3555d4
Updating usbMuxUart for NKRO
Jacob Alexander <haata@kiibohd.com>
parents:
195
diff
changeset
|
366 switch ( USBKeys_Protocol ) |
ed05fa3555d4
Updating usbMuxUart for NKRO
Jacob Alexander <haata@kiibohd.com>
parents:
195
diff
changeset
|
367 { |
ed05fa3555d4
Updating usbMuxUart for NKRO
Jacob Alexander <haata@kiibohd.com>
parents:
195
diff
changeset
|
368 case 0: // Boot Mode |
ed05fa3555d4
Updating usbMuxUart for NKRO
Jacob Alexander <haata@kiibohd.com>
parents:
195
diff
changeset
|
369 // TODO Analog inputs |
ed05fa3555d4
Updating usbMuxUart for NKRO
Jacob Alexander <haata@kiibohd.com>
parents:
195
diff
changeset
|
370 // Only indicate USB has changed if either a press or release has occured |
ed05fa3555d4
Updating usbMuxUart for NKRO
Jacob Alexander <haata@kiibohd.com>
parents:
195
diff
changeset
|
371 if ( state == 0x01 || state == 0x03 ) |
ed05fa3555d4
Updating usbMuxUart for NKRO
Jacob Alexander <haata@kiibohd.com>
parents:
195
diff
changeset
|
372 USBKeys_Changed = USBKeyChangeState_MainKeys; |
ed05fa3555d4
Updating usbMuxUart for NKRO
Jacob Alexander <haata@kiibohd.com>
parents:
195
diff
changeset
|
373 |
ed05fa3555d4
Updating usbMuxUart for NKRO
Jacob Alexander <haata@kiibohd.com>
parents:
195
diff
changeset
|
374 // Only send keypresses if press or hold state |
ed05fa3555d4
Updating usbMuxUart for NKRO
Jacob Alexander <haata@kiibohd.com>
parents:
195
diff
changeset
|
375 if ( stateType == 0x00 && state == 0x03 ) // Release state |
ed05fa3555d4
Updating usbMuxUart for NKRO
Jacob Alexander <haata@kiibohd.com>
parents:
195
diff
changeset
|
376 return; |
ed05fa3555d4
Updating usbMuxUart for NKRO
Jacob Alexander <haata@kiibohd.com>
parents:
195
diff
changeset
|
377 break; |
ed05fa3555d4
Updating usbMuxUart for NKRO
Jacob Alexander <haata@kiibohd.com>
parents:
195
diff
changeset
|
378 case 1: // NKRO Mode |
ed05fa3555d4
Updating usbMuxUart for NKRO
Jacob Alexander <haata@kiibohd.com>
parents:
195
diff
changeset
|
379 // Only send press and release events |
ed05fa3555d4
Updating usbMuxUart for NKRO
Jacob Alexander <haata@kiibohd.com>
parents:
195
diff
changeset
|
380 if ( stateType == 0x00 && state == 0x02 ) // Hold state |
ed05fa3555d4
Updating usbMuxUart for NKRO
Jacob Alexander <haata@kiibohd.com>
parents:
195
diff
changeset
|
381 return; |
ed05fa3555d4
Updating usbMuxUart for NKRO
Jacob Alexander <haata@kiibohd.com>
parents:
195
diff
changeset
|
382 |
ed05fa3555d4
Updating usbMuxUart for NKRO
Jacob Alexander <haata@kiibohd.com>
parents:
195
diff
changeset
|
383 // Determine if setting or unsetting the bitfield (press == set) |
ed05fa3555d4
Updating usbMuxUart for NKRO
Jacob Alexander <haata@kiibohd.com>
parents:
195
diff
changeset
|
384 if ( stateType == 0x00 && state == 0x01 ) // Press state |
ed05fa3555d4
Updating usbMuxUart for NKRO
Jacob Alexander <haata@kiibohd.com>
parents:
195
diff
changeset
|
385 keyPress = 1; |
ed05fa3555d4
Updating usbMuxUart for NKRO
Jacob Alexander <haata@kiibohd.com>
parents:
195
diff
changeset
|
386 break; |
ed05fa3555d4
Updating usbMuxUart for NKRO
Jacob Alexander <haata@kiibohd.com>
parents:
195
diff
changeset
|
387 } |
ed05fa3555d4
Updating usbMuxUart for NKRO
Jacob Alexander <haata@kiibohd.com>
parents:
195
diff
changeset
|
388 |
ed05fa3555d4
Updating usbMuxUart for NKRO
Jacob Alexander <haata@kiibohd.com>
parents:
195
diff
changeset
|
389 // Get the keycode from arguments |
ed05fa3555d4
Updating usbMuxUart for NKRO
Jacob Alexander <haata@kiibohd.com>
parents:
195
diff
changeset
|
390 uint8_t key = args[0]; |
ed05fa3555d4
Updating usbMuxUart for NKRO
Jacob Alexander <haata@kiibohd.com>
parents:
195
diff
changeset
|
391 |
ed05fa3555d4
Updating usbMuxUart for NKRO
Jacob Alexander <haata@kiibohd.com>
parents:
195
diff
changeset
|
392 // Depending on which mode the keyboard is in, USBKeys_Keys array is used differently |
ed05fa3555d4
Updating usbMuxUart for NKRO
Jacob Alexander <haata@kiibohd.com>
parents:
195
diff
changeset
|
393 // Boot mode - Maximum of 6 byte codes |
ed05fa3555d4
Updating usbMuxUart for NKRO
Jacob Alexander <haata@kiibohd.com>
parents:
195
diff
changeset
|
394 // NKRO mode - Each bit of the 26 byte corresponds to a key |
347
136e47478441
UARTConnect enumeration working!
Jacob Alexander <haata@kiibohd.com>
parents:
340
diff
changeset
|
395 // Bits 0 - 45 (bytes 0 - 5) correspond to USB Codes 4 - 49 (Main) |
136e47478441
UARTConnect enumeration working!
Jacob Alexander <haata@kiibohd.com>
parents:
340
diff
changeset
|
396 // Bits 48 - 161 (bytes 6 - 20) correspond to USB Codes 51 - 164 (Secondary) |
136e47478441
UARTConnect enumeration working!
Jacob Alexander <haata@kiibohd.com>
parents:
340
diff
changeset
|
397 // Bits 168 - 213 (bytes 21 - 26) correspond to USB Codes 176 - 221 (Tertiary) |
136e47478441
UARTConnect enumeration working!
Jacob Alexander <haata@kiibohd.com>
parents:
340
diff
changeset
|
398 // Bits 214 - 216 unused |
227
ed05fa3555d4
Updating usbMuxUart for NKRO
Jacob Alexander <haata@kiibohd.com>
parents:
195
diff
changeset
|
399 uint8_t bytePosition = 0; |
ed05fa3555d4
Updating usbMuxUart for NKRO
Jacob Alexander <haata@kiibohd.com>
parents:
195
diff
changeset
|
400 uint8_t byteShift = 0; |
ed05fa3555d4
Updating usbMuxUart for NKRO
Jacob Alexander <haata@kiibohd.com>
parents:
195
diff
changeset
|
401 switch ( USBKeys_Protocol ) |
ed05fa3555d4
Updating usbMuxUart for NKRO
Jacob Alexander <haata@kiibohd.com>
parents:
195
diff
changeset
|
402 { |
ed05fa3555d4
Updating usbMuxUart for NKRO
Jacob Alexander <haata@kiibohd.com>
parents:
195
diff
changeset
|
403 case 0: // Boot Mode |
ed05fa3555d4
Updating usbMuxUart for NKRO
Jacob Alexander <haata@kiibohd.com>
parents:
195
diff
changeset
|
404 // Set the modifier bit if this key is a modifier |
ed05fa3555d4
Updating usbMuxUart for NKRO
Jacob Alexander <haata@kiibohd.com>
parents:
195
diff
changeset
|
405 if ( (key & 0xE0) == 0xE0 ) // AND with 0xE0 (Left Ctrl, first modifier) |
ed05fa3555d4
Updating usbMuxUart for NKRO
Jacob Alexander <haata@kiibohd.com>
parents:
195
diff
changeset
|
406 { |
ed05fa3555d4
Updating usbMuxUart for NKRO
Jacob Alexander <haata@kiibohd.com>
parents:
195
diff
changeset
|
407 USBKeys_Modifiers |= 1 << (key ^ 0xE0); // Left shift 1 by key XOR 0xE0 |
ed05fa3555d4
Updating usbMuxUart for NKRO
Jacob Alexander <haata@kiibohd.com>
parents:
195
diff
changeset
|
408 } |
ed05fa3555d4
Updating usbMuxUart for NKRO
Jacob Alexander <haata@kiibohd.com>
parents:
195
diff
changeset
|
409 // Normal USB Code |
ed05fa3555d4
Updating usbMuxUart for NKRO
Jacob Alexander <haata@kiibohd.com>
parents:
195
diff
changeset
|
410 else |
ed05fa3555d4
Updating usbMuxUart for NKRO
Jacob Alexander <haata@kiibohd.com>
parents:
195
diff
changeset
|
411 { |
ed05fa3555d4
Updating usbMuxUart for NKRO
Jacob Alexander <haata@kiibohd.com>
parents:
195
diff
changeset
|
412 // USB Key limit reached |
ed05fa3555d4
Updating usbMuxUart for NKRO
Jacob Alexander <haata@kiibohd.com>
parents:
195
diff
changeset
|
413 if ( USBKeys_Sent >= USB_BOOT_MAX_KEYS ) |
ed05fa3555d4
Updating usbMuxUart for NKRO
Jacob Alexander <haata@kiibohd.com>
parents:
195
diff
changeset
|
414 { |
ed05fa3555d4
Updating usbMuxUart for NKRO
Jacob Alexander <haata@kiibohd.com>
parents:
195
diff
changeset
|
415 warn_print("USB Key limit reached"); |
ed05fa3555d4
Updating usbMuxUart for NKRO
Jacob Alexander <haata@kiibohd.com>
parents:
195
diff
changeset
|
416 return; |
ed05fa3555d4
Updating usbMuxUart for NKRO
Jacob Alexander <haata@kiibohd.com>
parents:
195
diff
changeset
|
417 } |
ed05fa3555d4
Updating usbMuxUart for NKRO
Jacob Alexander <haata@kiibohd.com>
parents:
195
diff
changeset
|
418 |
ed05fa3555d4
Updating usbMuxUart for NKRO
Jacob Alexander <haata@kiibohd.com>
parents:
195
diff
changeset
|
419 // Make sure key is within the USB HID range |
ed05fa3555d4
Updating usbMuxUart for NKRO
Jacob Alexander <haata@kiibohd.com>
parents:
195
diff
changeset
|
420 if ( key <= 104 ) |
ed05fa3555d4
Updating usbMuxUart for NKRO
Jacob Alexander <haata@kiibohd.com>
parents:
195
diff
changeset
|
421 { |
ed05fa3555d4
Updating usbMuxUart for NKRO
Jacob Alexander <haata@kiibohd.com>
parents:
195
diff
changeset
|
422 USBKeys_Keys[USBKeys_Sent++] = key; |
ed05fa3555d4
Updating usbMuxUart for NKRO
Jacob Alexander <haata@kiibohd.com>
parents:
195
diff
changeset
|
423 } |
ed05fa3555d4
Updating usbMuxUart for NKRO
Jacob Alexander <haata@kiibohd.com>
parents:
195
diff
changeset
|
424 // Invalid key |
ed05fa3555d4
Updating usbMuxUart for NKRO
Jacob Alexander <haata@kiibohd.com>
parents:
195
diff
changeset
|
425 else |
ed05fa3555d4
Updating usbMuxUart for NKRO
Jacob Alexander <haata@kiibohd.com>
parents:
195
diff
changeset
|
426 { |
ed05fa3555d4
Updating usbMuxUart for NKRO
Jacob Alexander <haata@kiibohd.com>
parents:
195
diff
changeset
|
427 warn_msg("USB Code above 104/0x68 in Boot Mode: "); |
ed05fa3555d4
Updating usbMuxUart for NKRO
Jacob Alexander <haata@kiibohd.com>
parents:
195
diff
changeset
|
428 printHex( key ); |
ed05fa3555d4
Updating usbMuxUart for NKRO
Jacob Alexander <haata@kiibohd.com>
parents:
195
diff
changeset
|
429 print( NL ); |
ed05fa3555d4
Updating usbMuxUart for NKRO
Jacob Alexander <haata@kiibohd.com>
parents:
195
diff
changeset
|
430 } |
ed05fa3555d4
Updating usbMuxUart for NKRO
Jacob Alexander <haata@kiibohd.com>
parents:
195
diff
changeset
|
431 } |
ed05fa3555d4
Updating usbMuxUart for NKRO
Jacob Alexander <haata@kiibohd.com>
parents:
195
diff
changeset
|
432 break; |
ed05fa3555d4
Updating usbMuxUart for NKRO
Jacob Alexander <haata@kiibohd.com>
parents:
195
diff
changeset
|
433 |
ed05fa3555d4
Updating usbMuxUart for NKRO
Jacob Alexander <haata@kiibohd.com>
parents:
195
diff
changeset
|
434 case 1: // NKRO Mode |
ed05fa3555d4
Updating usbMuxUart for NKRO
Jacob Alexander <haata@kiibohd.com>
parents:
195
diff
changeset
|
435 // Set the modifier bit if this key is a modifier |
ed05fa3555d4
Updating usbMuxUart for NKRO
Jacob Alexander <haata@kiibohd.com>
parents:
195
diff
changeset
|
436 if ( (key & 0xE0) == 0xE0 ) // AND with 0xE0 (Left Ctrl, first modifier) |
ed05fa3555d4
Updating usbMuxUart for NKRO
Jacob Alexander <haata@kiibohd.com>
parents:
195
diff
changeset
|
437 { |
ed05fa3555d4
Updating usbMuxUart for NKRO
Jacob Alexander <haata@kiibohd.com>
parents:
195
diff
changeset
|
438 if ( keyPress ) |
ed05fa3555d4
Updating usbMuxUart for NKRO
Jacob Alexander <haata@kiibohd.com>
parents:
195
diff
changeset
|
439 { |
ed05fa3555d4
Updating usbMuxUart for NKRO
Jacob Alexander <haata@kiibohd.com>
parents:
195
diff
changeset
|
440 USBKeys_Modifiers |= 1 << (key ^ 0xE0); // Left shift 1 by key XOR 0xE0 |
ed05fa3555d4
Updating usbMuxUart for NKRO
Jacob Alexander <haata@kiibohd.com>
parents:
195
diff
changeset
|
441 } |
ed05fa3555d4
Updating usbMuxUart for NKRO
Jacob Alexander <haata@kiibohd.com>
parents:
195
diff
changeset
|
442 else // Release |
ed05fa3555d4
Updating usbMuxUart for NKRO
Jacob Alexander <haata@kiibohd.com>
parents:
195
diff
changeset
|
443 { |
ed05fa3555d4
Updating usbMuxUart for NKRO
Jacob Alexander <haata@kiibohd.com>
parents:
195
diff
changeset
|
444 USBKeys_Modifiers &= ~(1 << (key ^ 0xE0)); // Left shift 1 by key XOR 0xE0 |
ed05fa3555d4
Updating usbMuxUart for NKRO
Jacob Alexander <haata@kiibohd.com>
parents:
195
diff
changeset
|
445 } |
ed05fa3555d4
Updating usbMuxUart for NKRO
Jacob Alexander <haata@kiibohd.com>
parents:
195
diff
changeset
|
446 |
ed05fa3555d4
Updating usbMuxUart for NKRO
Jacob Alexander <haata@kiibohd.com>
parents:
195
diff
changeset
|
447 USBKeys_Changed |= USBKeyChangeState_Modifiers; |
ed05fa3555d4
Updating usbMuxUart for NKRO
Jacob Alexander <haata@kiibohd.com>
parents:
195
diff
changeset
|
448 break; |
ed05fa3555d4
Updating usbMuxUart for NKRO
Jacob Alexander <haata@kiibohd.com>
parents:
195
diff
changeset
|
449 } |
347
136e47478441
UARTConnect enumeration working!
Jacob Alexander <haata@kiibohd.com>
parents:
340
diff
changeset
|
450 // First 6 bytes |
136e47478441
UARTConnect enumeration working!
Jacob Alexander <haata@kiibohd.com>
parents:
340
diff
changeset
|
451 else if ( key >= 4 && key <= 49 ) |
227
ed05fa3555d4
Updating usbMuxUart for NKRO
Jacob Alexander <haata@kiibohd.com>
parents:
195
diff
changeset
|
452 { |
ed05fa3555d4
Updating usbMuxUart for NKRO
Jacob Alexander <haata@kiibohd.com>
parents:
195
diff
changeset
|
453 // Lookup (otherwise division or multiple checks are needed to do alignment) |
347
136e47478441
UARTConnect enumeration working!
Jacob Alexander <haata@kiibohd.com>
parents:
340
diff
changeset
|
454 // Starting at 0th position, each byte has 8 bits, starting at 4th bit |
136e47478441
UARTConnect enumeration working!
Jacob Alexander <haata@kiibohd.com>
parents:
340
diff
changeset
|
455 uint8_t keyPos = key + (0 * 8 - 4); // Starting position in array, Ignoring 4 keys |
227
ed05fa3555d4
Updating usbMuxUart for NKRO
Jacob Alexander <haata@kiibohd.com>
parents:
195
diff
changeset
|
456 switch ( keyPos ) |
ed05fa3555d4
Updating usbMuxUart for NKRO
Jacob Alexander <haata@kiibohd.com>
parents:
195
diff
changeset
|
457 { |
ed05fa3555d4
Updating usbMuxUart for NKRO
Jacob Alexander <haata@kiibohd.com>
parents:
195
diff
changeset
|
458 byteLookup( 0 ); |
ed05fa3555d4
Updating usbMuxUart for NKRO
Jacob Alexander <haata@kiibohd.com>
parents:
195
diff
changeset
|
459 byteLookup( 1 ); |
ed05fa3555d4
Updating usbMuxUart for NKRO
Jacob Alexander <haata@kiibohd.com>
parents:
195
diff
changeset
|
460 byteLookup( 2 ); |
ed05fa3555d4
Updating usbMuxUart for NKRO
Jacob Alexander <haata@kiibohd.com>
parents:
195
diff
changeset
|
461 byteLookup( 3 ); |
ed05fa3555d4
Updating usbMuxUart for NKRO
Jacob Alexander <haata@kiibohd.com>
parents:
195
diff
changeset
|
462 byteLookup( 4 ); |
ed05fa3555d4
Updating usbMuxUart for NKRO
Jacob Alexander <haata@kiibohd.com>
parents:
195
diff
changeset
|
463 byteLookup( 5 ); |
347
136e47478441
UARTConnect enumeration working!
Jacob Alexander <haata@kiibohd.com>
parents:
340
diff
changeset
|
464 } |
136e47478441
UARTConnect enumeration working!
Jacob Alexander <haata@kiibohd.com>
parents:
340
diff
changeset
|
465 |
136e47478441
UARTConnect enumeration working!
Jacob Alexander <haata@kiibohd.com>
parents:
340
diff
changeset
|
466 USBKeys_Changed |= USBKeyChangeState_MainKeys; |
136e47478441
UARTConnect enumeration working!
Jacob Alexander <haata@kiibohd.com>
parents:
340
diff
changeset
|
467 } |
136e47478441
UARTConnect enumeration working!
Jacob Alexander <haata@kiibohd.com>
parents:
340
diff
changeset
|
468 // Next 14 bytes |
136e47478441
UARTConnect enumeration working!
Jacob Alexander <haata@kiibohd.com>
parents:
340
diff
changeset
|
469 else if ( key >= 51 && key <= 155 ) |
136e47478441
UARTConnect enumeration working!
Jacob Alexander <haata@kiibohd.com>
parents:
340
diff
changeset
|
470 { |
136e47478441
UARTConnect enumeration working!
Jacob Alexander <haata@kiibohd.com>
parents:
340
diff
changeset
|
471 // Lookup (otherwise division or multiple checks are needed to do alignment) |
136e47478441
UARTConnect enumeration working!
Jacob Alexander <haata@kiibohd.com>
parents:
340
diff
changeset
|
472 // Starting at 6th byte position, each byte has 8 bits, starting at 51st bit |
136e47478441
UARTConnect enumeration working!
Jacob Alexander <haata@kiibohd.com>
parents:
340
diff
changeset
|
473 uint8_t keyPos = key + (6 * 8 - 51); // Starting position in array |
136e47478441
UARTConnect enumeration working!
Jacob Alexander <haata@kiibohd.com>
parents:
340
diff
changeset
|
474 switch ( keyPos ) |
136e47478441
UARTConnect enumeration working!
Jacob Alexander <haata@kiibohd.com>
parents:
340
diff
changeset
|
475 { |
227
ed05fa3555d4
Updating usbMuxUart for NKRO
Jacob Alexander <haata@kiibohd.com>
parents:
195
diff
changeset
|
476 byteLookup( 6 ); |
ed05fa3555d4
Updating usbMuxUart for NKRO
Jacob Alexander <haata@kiibohd.com>
parents:
195
diff
changeset
|
477 byteLookup( 7 ); |
ed05fa3555d4
Updating usbMuxUart for NKRO
Jacob Alexander <haata@kiibohd.com>
parents:
195
diff
changeset
|
478 byteLookup( 8 ); |
ed05fa3555d4
Updating usbMuxUart for NKRO
Jacob Alexander <haata@kiibohd.com>
parents:
195
diff
changeset
|
479 byteLookup( 9 ); |
ed05fa3555d4
Updating usbMuxUart for NKRO
Jacob Alexander <haata@kiibohd.com>
parents:
195
diff
changeset
|
480 byteLookup( 10 ); |
ed05fa3555d4
Updating usbMuxUart for NKRO
Jacob Alexander <haata@kiibohd.com>
parents:
195
diff
changeset
|
481 byteLookup( 11 ); |
ed05fa3555d4
Updating usbMuxUart for NKRO
Jacob Alexander <haata@kiibohd.com>
parents:
195
diff
changeset
|
482 byteLookup( 12 ); |
ed05fa3555d4
Updating usbMuxUart for NKRO
Jacob Alexander <haata@kiibohd.com>
parents:
195
diff
changeset
|
483 byteLookup( 13 ); |
ed05fa3555d4
Updating usbMuxUart for NKRO
Jacob Alexander <haata@kiibohd.com>
parents:
195
diff
changeset
|
484 byteLookup( 14 ); |
ed05fa3555d4
Updating usbMuxUart for NKRO
Jacob Alexander <haata@kiibohd.com>
parents:
195
diff
changeset
|
485 byteLookup( 15 ); |
ed05fa3555d4
Updating usbMuxUart for NKRO
Jacob Alexander <haata@kiibohd.com>
parents:
195
diff
changeset
|
486 byteLookup( 16 ); |
ed05fa3555d4
Updating usbMuxUart for NKRO
Jacob Alexander <haata@kiibohd.com>
parents:
195
diff
changeset
|
487 byteLookup( 17 ); |
ed05fa3555d4
Updating usbMuxUart for NKRO
Jacob Alexander <haata@kiibohd.com>
parents:
195
diff
changeset
|
488 byteLookup( 18 ); |
ed05fa3555d4
Updating usbMuxUart for NKRO
Jacob Alexander <haata@kiibohd.com>
parents:
195
diff
changeset
|
489 byteLookup( 19 ); |
ed05fa3555d4
Updating usbMuxUart for NKRO
Jacob Alexander <haata@kiibohd.com>
parents:
195
diff
changeset
|
490 } |
ed05fa3555d4
Updating usbMuxUart for NKRO
Jacob Alexander <haata@kiibohd.com>
parents:
195
diff
changeset
|
491 |
347
136e47478441
UARTConnect enumeration working!
Jacob Alexander <haata@kiibohd.com>
parents:
340
diff
changeset
|
492 USBKeys_Changed |= USBKeyChangeState_SecondaryKeys; |
136e47478441
UARTConnect enumeration working!
Jacob Alexander <haata@kiibohd.com>
parents:
340
diff
changeset
|
493 } |
136e47478441
UARTConnect enumeration working!
Jacob Alexander <haata@kiibohd.com>
parents:
340
diff
changeset
|
494 // Next byte |
136e47478441
UARTConnect enumeration working!
Jacob Alexander <haata@kiibohd.com>
parents:
340
diff
changeset
|
495 else if ( key >= 157 && key <= 164 ) |
136e47478441
UARTConnect enumeration working!
Jacob Alexander <haata@kiibohd.com>
parents:
340
diff
changeset
|
496 { |
136e47478441
UARTConnect enumeration working!
Jacob Alexander <haata@kiibohd.com>
parents:
340
diff
changeset
|
497 // Lookup (otherwise division or multiple checks are needed to do alignment) |
136e47478441
UARTConnect enumeration working!
Jacob Alexander <haata@kiibohd.com>
parents:
340
diff
changeset
|
498 uint8_t keyPos = key + (20 * 8 - 157); // Starting position in array, Ignoring 6 keys |
136e47478441
UARTConnect enumeration working!
Jacob Alexander <haata@kiibohd.com>
parents:
340
diff
changeset
|
499 switch ( keyPos ) |
136e47478441
UARTConnect enumeration working!
Jacob Alexander <haata@kiibohd.com>
parents:
340
diff
changeset
|
500 { |
136e47478441
UARTConnect enumeration working!
Jacob Alexander <haata@kiibohd.com>
parents:
340
diff
changeset
|
501 byteLookup( 20 ); |
136e47478441
UARTConnect enumeration working!
Jacob Alexander <haata@kiibohd.com>
parents:
340
diff
changeset
|
502 } |
136e47478441
UARTConnect enumeration working!
Jacob Alexander <haata@kiibohd.com>
parents:
340
diff
changeset
|
503 |
136e47478441
UARTConnect enumeration working!
Jacob Alexander <haata@kiibohd.com>
parents:
340
diff
changeset
|
504 USBKeys_Changed |= USBKeyChangeState_TertiaryKeys; |
227
ed05fa3555d4
Updating usbMuxUart for NKRO
Jacob Alexander <haata@kiibohd.com>
parents:
195
diff
changeset
|
505 } |
ed05fa3555d4
Updating usbMuxUart for NKRO
Jacob Alexander <haata@kiibohd.com>
parents:
195
diff
changeset
|
506 // Last 6 bytes |
ed05fa3555d4
Updating usbMuxUart for NKRO
Jacob Alexander <haata@kiibohd.com>
parents:
195
diff
changeset
|
507 else if ( key >= 176 && key <= 221 ) |
ed05fa3555d4
Updating usbMuxUart for NKRO
Jacob Alexander <haata@kiibohd.com>
parents:
195
diff
changeset
|
508 { |
ed05fa3555d4
Updating usbMuxUart for NKRO
Jacob Alexander <haata@kiibohd.com>
parents:
195
diff
changeset
|
509 // Lookup (otherwise division or multiple checks are needed to do alignment) |
347
136e47478441
UARTConnect enumeration working!
Jacob Alexander <haata@kiibohd.com>
parents:
340
diff
changeset
|
510 uint8_t keyPos = key + (21 * 8 - 176); // Starting position in array |
227
ed05fa3555d4
Updating usbMuxUart for NKRO
Jacob Alexander <haata@kiibohd.com>
parents:
195
diff
changeset
|
511 switch ( keyPos ) |
ed05fa3555d4
Updating usbMuxUart for NKRO
Jacob Alexander <haata@kiibohd.com>
parents:
195
diff
changeset
|
512 { |
ed05fa3555d4
Updating usbMuxUart for NKRO
Jacob Alexander <haata@kiibohd.com>
parents:
195
diff
changeset
|
513 byteLookup( 21 ); |
ed05fa3555d4
Updating usbMuxUart for NKRO
Jacob Alexander <haata@kiibohd.com>
parents:
195
diff
changeset
|
514 byteLookup( 22 ); |
ed05fa3555d4
Updating usbMuxUart for NKRO
Jacob Alexander <haata@kiibohd.com>
parents:
195
diff
changeset
|
515 byteLookup( 23 ); |
ed05fa3555d4
Updating usbMuxUart for NKRO
Jacob Alexander <haata@kiibohd.com>
parents:
195
diff
changeset
|
516 byteLookup( 24 ); |
ed05fa3555d4
Updating usbMuxUart for NKRO
Jacob Alexander <haata@kiibohd.com>
parents:
195
diff
changeset
|
517 byteLookup( 25 ); |
347
136e47478441
UARTConnect enumeration working!
Jacob Alexander <haata@kiibohd.com>
parents:
340
diff
changeset
|
518 byteLookup( 26 ); |
227
ed05fa3555d4
Updating usbMuxUart for NKRO
Jacob Alexander <haata@kiibohd.com>
parents:
195
diff
changeset
|
519 } |
ed05fa3555d4
Updating usbMuxUart for NKRO
Jacob Alexander <haata@kiibohd.com>
parents:
195
diff
changeset
|
520 |
347
136e47478441
UARTConnect enumeration working!
Jacob Alexander <haata@kiibohd.com>
parents:
340
diff
changeset
|
521 USBKeys_Changed |= USBKeyChangeState_QuartiaryKeys; |
136e47478441
UARTConnect enumeration working!
Jacob Alexander <haata@kiibohd.com>
parents:
340
diff
changeset
|
522 } |
136e47478441
UARTConnect enumeration working!
Jacob Alexander <haata@kiibohd.com>
parents:
340
diff
changeset
|
523 // Received 0x00 |
136e47478441
UARTConnect enumeration working!
Jacob Alexander <haata@kiibohd.com>
parents:
340
diff
changeset
|
524 // This is a special USB Code that internally indicates a "break" |
136e47478441
UARTConnect enumeration working!
Jacob Alexander <haata@kiibohd.com>
parents:
340
diff
changeset
|
525 // It is used to send "nothing" in order to break up sequences of USB Codes |
136e47478441
UARTConnect enumeration working!
Jacob Alexander <haata@kiibohd.com>
parents:
340
diff
changeset
|
526 else if ( key == 0x00 ) |
136e47478441
UARTConnect enumeration working!
Jacob Alexander <haata@kiibohd.com>
parents:
340
diff
changeset
|
527 { |
136e47478441
UARTConnect enumeration working!
Jacob Alexander <haata@kiibohd.com>
parents:
340
diff
changeset
|
528 USBKeys_Changed |= USBKeyChangeState_MainKeys; |
136e47478441
UARTConnect enumeration working!
Jacob Alexander <haata@kiibohd.com>
parents:
340
diff
changeset
|
529 |
136e47478441
UARTConnect enumeration working!
Jacob Alexander <haata@kiibohd.com>
parents:
340
diff
changeset
|
530 // Also flush out buffers just in case |
136e47478441
UARTConnect enumeration working!
Jacob Alexander <haata@kiibohd.com>
parents:
340
diff
changeset
|
531 Output_flushBuffers(); |
136e47478441
UARTConnect enumeration working!
Jacob Alexander <haata@kiibohd.com>
parents:
340
diff
changeset
|
532 break; |
227
ed05fa3555d4
Updating usbMuxUart for NKRO
Jacob Alexander <haata@kiibohd.com>
parents:
195
diff
changeset
|
533 } |
ed05fa3555d4
Updating usbMuxUart for NKRO
Jacob Alexander <haata@kiibohd.com>
parents:
195
diff
changeset
|
534 // Invalid key |
ed05fa3555d4
Updating usbMuxUart for NKRO
Jacob Alexander <haata@kiibohd.com>
parents:
195
diff
changeset
|
535 else |
ed05fa3555d4
Updating usbMuxUart for NKRO
Jacob Alexander <haata@kiibohd.com>
parents:
195
diff
changeset
|
536 { |
347
136e47478441
UARTConnect enumeration working!
Jacob Alexander <haata@kiibohd.com>
parents:
340
diff
changeset
|
537 warn_msg("USB Code not within 4-49 (0x4-0x31), 51-155 (0x33-0x9B), 157-164 (0x9D-0xA4), 176-221 (0xB0-0xDD) or 224-231 (0xE0-0xE7) NKRO Mode: "); |
227
ed05fa3555d4
Updating usbMuxUart for NKRO
Jacob Alexander <haata@kiibohd.com>
parents:
195
diff
changeset
|
538 printHex( key ); |
ed05fa3555d4
Updating usbMuxUart for NKRO
Jacob Alexander <haata@kiibohd.com>
parents:
195
diff
changeset
|
539 print( NL ); |
ed05fa3555d4
Updating usbMuxUart for NKRO
Jacob Alexander <haata@kiibohd.com>
parents:
195
diff
changeset
|
540 break; |
ed05fa3555d4
Updating usbMuxUart for NKRO
Jacob Alexander <haata@kiibohd.com>
parents:
195
diff
changeset
|
541 } |
ed05fa3555d4
Updating usbMuxUart for NKRO
Jacob Alexander <haata@kiibohd.com>
parents:
195
diff
changeset
|
542 |
ed05fa3555d4
Updating usbMuxUart for NKRO
Jacob Alexander <haata@kiibohd.com>
parents:
195
diff
changeset
|
543 // Set/Unset |
ed05fa3555d4
Updating usbMuxUart for NKRO
Jacob Alexander <haata@kiibohd.com>
parents:
195
diff
changeset
|
544 if ( keyPress ) |
ed05fa3555d4
Updating usbMuxUart for NKRO
Jacob Alexander <haata@kiibohd.com>
parents:
195
diff
changeset
|
545 { |
ed05fa3555d4
Updating usbMuxUart for NKRO
Jacob Alexander <haata@kiibohd.com>
parents:
195
diff
changeset
|
546 USBKeys_Keys[bytePosition] |= (1 << byteShift); |
ed05fa3555d4
Updating usbMuxUart for NKRO
Jacob Alexander <haata@kiibohd.com>
parents:
195
diff
changeset
|
547 USBKeys_Sent++; |
ed05fa3555d4
Updating usbMuxUart for NKRO
Jacob Alexander <haata@kiibohd.com>
parents:
195
diff
changeset
|
548 } |
ed05fa3555d4
Updating usbMuxUart for NKRO
Jacob Alexander <haata@kiibohd.com>
parents:
195
diff
changeset
|
549 else // Release |
ed05fa3555d4
Updating usbMuxUart for NKRO
Jacob Alexander <haata@kiibohd.com>
parents:
195
diff
changeset
|
550 { |
ed05fa3555d4
Updating usbMuxUart for NKRO
Jacob Alexander <haata@kiibohd.com>
parents:
195
diff
changeset
|
551 USBKeys_Keys[bytePosition] &= ~(1 << byteShift); |
ed05fa3555d4
Updating usbMuxUart for NKRO
Jacob Alexander <haata@kiibohd.com>
parents:
195
diff
changeset
|
552 USBKeys_Sent++; |
ed05fa3555d4
Updating usbMuxUart for NKRO
Jacob Alexander <haata@kiibohd.com>
parents:
195
diff
changeset
|
553 } |
ed05fa3555d4
Updating usbMuxUart for NKRO
Jacob Alexander <haata@kiibohd.com>
parents:
195
diff
changeset
|
554 |
ed05fa3555d4
Updating usbMuxUart for NKRO
Jacob Alexander <haata@kiibohd.com>
parents:
195
diff
changeset
|
555 break; |
ed05fa3555d4
Updating usbMuxUart for NKRO
Jacob Alexander <haata@kiibohd.com>
parents:
195
diff
changeset
|
556 } |
449
45feb80a2ad1
Major USB update, fixes most (if not all) known issues
Jacob Alexander <haata@kiibohd.com>
parents:
447
diff
changeset
|
557 #endif |
227
ed05fa3555d4
Updating usbMuxUart for NKRO
Jacob Alexander <haata@kiibohd.com>
parents:
195
diff
changeset
|
558 } |
ed05fa3555d4
Updating usbMuxUart for NKRO
Jacob Alexander <haata@kiibohd.com>
parents:
195
diff
changeset
|
559 |
370
39e338a6733d
Fixing default ErgoDox layout and adding FlashMode button
Jacob Alexander <haata@kiibohd.com>
parents:
347
diff
changeset
|
560 void Output_flashMode_capability( uint8_t state, uint8_t stateType, uint8_t *args ) |
39e338a6733d
Fixing default ErgoDox layout and adding FlashMode button
Jacob Alexander <haata@kiibohd.com>
parents:
347
diff
changeset
|
561 { |
39e338a6733d
Fixing default ErgoDox layout and adding FlashMode button
Jacob Alexander <haata@kiibohd.com>
parents:
347
diff
changeset
|
562 // Display capability name |
39e338a6733d
Fixing default ErgoDox layout and adding FlashMode button
Jacob Alexander <haata@kiibohd.com>
parents:
347
diff
changeset
|
563 if ( stateType == 0xFF && state == 0xFF ) |
39e338a6733d
Fixing default ErgoDox layout and adding FlashMode button
Jacob Alexander <haata@kiibohd.com>
parents:
347
diff
changeset
|
564 { |
385
d8f61e15aca1
Adding jump to bootloader key
Jacob Alexander <haata@kiibohd.com>
parents:
370
diff
changeset
|
565 print("Output_flashMode()"); |
370
39e338a6733d
Fixing default ErgoDox layout and adding FlashMode button
Jacob Alexander <haata@kiibohd.com>
parents:
347
diff
changeset
|
566 return; |
39e338a6733d
Fixing default ErgoDox layout and adding FlashMode button
Jacob Alexander <haata@kiibohd.com>
parents:
347
diff
changeset
|
567 } |
39e338a6733d
Fixing default ErgoDox layout and adding FlashMode button
Jacob Alexander <haata@kiibohd.com>
parents:
347
diff
changeset
|
568 |
39e338a6733d
Fixing default ErgoDox layout and adding FlashMode button
Jacob Alexander <haata@kiibohd.com>
parents:
347
diff
changeset
|
569 // Start flash mode |
39e338a6733d
Fixing default ErgoDox layout and adding FlashMode button
Jacob Alexander <haata@kiibohd.com>
parents:
347
diff
changeset
|
570 Output_firmwareReload(); |
39e338a6733d
Fixing default ErgoDox layout and adding FlashMode button
Jacob Alexander <haata@kiibohd.com>
parents:
347
diff
changeset
|
571 } |
39e338a6733d
Fixing default ErgoDox layout and adding FlashMode button
Jacob Alexander <haata@kiibohd.com>
parents:
347
diff
changeset
|
572 |
438
f10c2dad7f55
Adding missing GET_PROTOCOL handling
Jacob Alexander <haata@kiibohd.com>
parents:
420
diff
changeset
|
573 // Sends a mouse command over the USB Output buffer |
f10c2dad7f55
Adding missing GET_PROTOCOL handling
Jacob Alexander <haata@kiibohd.com>
parents:
420
diff
changeset
|
574 // XXX This function *will* be changing in the future |
f10c2dad7f55
Adding missing GET_PROTOCOL handling
Jacob Alexander <haata@kiibohd.com>
parents:
420
diff
changeset
|
575 // If you use it, be prepared that your .kll files will break in the future (post KLL 0.5) |
f10c2dad7f55
Adding missing GET_PROTOCOL handling
Jacob Alexander <haata@kiibohd.com>
parents:
420
diff
changeset
|
576 // Argument #1: USB Mouse Button (16 bit) |
f10c2dad7f55
Adding missing GET_PROTOCOL handling
Jacob Alexander <haata@kiibohd.com>
parents:
420
diff
changeset
|
577 // Argument #2: USB X Axis (16 bit) relative |
f10c2dad7f55
Adding missing GET_PROTOCOL handling
Jacob Alexander <haata@kiibohd.com>
parents:
420
diff
changeset
|
578 // Argument #3: USB Y Axis (16 bit) relative |
f10c2dad7f55
Adding missing GET_PROTOCOL handling
Jacob Alexander <haata@kiibohd.com>
parents:
420
diff
changeset
|
579 void Output_usbMouse_capability( uint8_t state, uint8_t stateType, uint8_t *args ) |
f10c2dad7f55
Adding missing GET_PROTOCOL handling
Jacob Alexander <haata@kiibohd.com>
parents:
420
diff
changeset
|
580 { |
449
45feb80a2ad1
Major USB update, fixes most (if not all) known issues
Jacob Alexander <haata@kiibohd.com>
parents:
447
diff
changeset
|
581 #if enableMouse_define == 1 |
438
f10c2dad7f55
Adding missing GET_PROTOCOL handling
Jacob Alexander <haata@kiibohd.com>
parents:
420
diff
changeset
|
582 // Display capability name |
f10c2dad7f55
Adding missing GET_PROTOCOL handling
Jacob Alexander <haata@kiibohd.com>
parents:
420
diff
changeset
|
583 if ( stateType == 0xFF && state == 0xFF ) |
f10c2dad7f55
Adding missing GET_PROTOCOL handling
Jacob Alexander <haata@kiibohd.com>
parents:
420
diff
changeset
|
584 { |
f10c2dad7f55
Adding missing GET_PROTOCOL handling
Jacob Alexander <haata@kiibohd.com>
parents:
420
diff
changeset
|
585 print("Output_usbMouse(mouseButton,relX,relY)"); |
f10c2dad7f55
Adding missing GET_PROTOCOL handling
Jacob Alexander <haata@kiibohd.com>
parents:
420
diff
changeset
|
586 return; |
f10c2dad7f55
Adding missing GET_PROTOCOL handling
Jacob Alexander <haata@kiibohd.com>
parents:
420
diff
changeset
|
587 } |
f10c2dad7f55
Adding missing GET_PROTOCOL handling
Jacob Alexander <haata@kiibohd.com>
parents:
420
diff
changeset
|
588 |
f10c2dad7f55
Adding missing GET_PROTOCOL handling
Jacob Alexander <haata@kiibohd.com>
parents:
420
diff
changeset
|
589 // Determine which mouse button was sent |
f10c2dad7f55
Adding missing GET_PROTOCOL handling
Jacob Alexander <haata@kiibohd.com>
parents:
420
diff
changeset
|
590 // The USB spec defines up to a max of 0xFFFF buttons |
f10c2dad7f55
Adding missing GET_PROTOCOL handling
Jacob Alexander <haata@kiibohd.com>
parents:
420
diff
changeset
|
591 // The usual are: |
f10c2dad7f55
Adding missing GET_PROTOCOL handling
Jacob Alexander <haata@kiibohd.com>
parents:
420
diff
changeset
|
592 // 1 - Button 1 - (Primary) |
f10c2dad7f55
Adding missing GET_PROTOCOL handling
Jacob Alexander <haata@kiibohd.com>
parents:
420
diff
changeset
|
593 // 2 - Button 2 - (Secondary) |
f10c2dad7f55
Adding missing GET_PROTOCOL handling
Jacob Alexander <haata@kiibohd.com>
parents:
420
diff
changeset
|
594 // 3 - Button 3 - (Tertiary) |
f10c2dad7f55
Adding missing GET_PROTOCOL handling
Jacob Alexander <haata@kiibohd.com>
parents:
420
diff
changeset
|
595 uint16_t mouse_button = *(uint16_t*)(&args[0]); |
f10c2dad7f55
Adding missing GET_PROTOCOL handling
Jacob Alexander <haata@kiibohd.com>
parents:
420
diff
changeset
|
596 |
f10c2dad7f55
Adding missing GET_PROTOCOL handling
Jacob Alexander <haata@kiibohd.com>
parents:
420
diff
changeset
|
597 // X/Y Relative Axis |
f10c2dad7f55
Adding missing GET_PROTOCOL handling
Jacob Alexander <haata@kiibohd.com>
parents:
420
diff
changeset
|
598 uint16_t mouse_x = *(uint16_t*)(&args[2]); |
f10c2dad7f55
Adding missing GET_PROTOCOL handling
Jacob Alexander <haata@kiibohd.com>
parents:
420
diff
changeset
|
599 uint16_t mouse_y = *(uint16_t*)(&args[4]); |
f10c2dad7f55
Adding missing GET_PROTOCOL handling
Jacob Alexander <haata@kiibohd.com>
parents:
420
diff
changeset
|
600 |
f10c2dad7f55
Adding missing GET_PROTOCOL handling
Jacob Alexander <haata@kiibohd.com>
parents:
420
diff
changeset
|
601 // Adjust for bit shift |
f10c2dad7f55
Adding missing GET_PROTOCOL handling
Jacob Alexander <haata@kiibohd.com>
parents:
420
diff
changeset
|
602 uint16_t mouse_button_shift = mouse_button - 1; |
f10c2dad7f55
Adding missing GET_PROTOCOL handling
Jacob Alexander <haata@kiibohd.com>
parents:
420
diff
changeset
|
603 |
f10c2dad7f55
Adding missing GET_PROTOCOL handling
Jacob Alexander <haata@kiibohd.com>
parents:
420
diff
changeset
|
604 // Only send mouse button if in press or hold state |
f10c2dad7f55
Adding missing GET_PROTOCOL handling
Jacob Alexander <haata@kiibohd.com>
parents:
420
diff
changeset
|
605 if ( stateType == 0x00 && state == 0x03 ) // Release state |
f10c2dad7f55
Adding missing GET_PROTOCOL handling
Jacob Alexander <haata@kiibohd.com>
parents:
420
diff
changeset
|
606 { |
f10c2dad7f55
Adding missing GET_PROTOCOL handling
Jacob Alexander <haata@kiibohd.com>
parents:
420
diff
changeset
|
607 // Release |
f10c2dad7f55
Adding missing GET_PROTOCOL handling
Jacob Alexander <haata@kiibohd.com>
parents:
420
diff
changeset
|
608 if ( mouse_button ) |
f10c2dad7f55
Adding missing GET_PROTOCOL handling
Jacob Alexander <haata@kiibohd.com>
parents:
420
diff
changeset
|
609 USBMouse_Buttons &= ~(1 << mouse_button_shift); |
f10c2dad7f55
Adding missing GET_PROTOCOL handling
Jacob Alexander <haata@kiibohd.com>
parents:
420
diff
changeset
|
610 } |
f10c2dad7f55
Adding missing GET_PROTOCOL handling
Jacob Alexander <haata@kiibohd.com>
parents:
420
diff
changeset
|
611 else |
f10c2dad7f55
Adding missing GET_PROTOCOL handling
Jacob Alexander <haata@kiibohd.com>
parents:
420
diff
changeset
|
612 { |
f10c2dad7f55
Adding missing GET_PROTOCOL handling
Jacob Alexander <haata@kiibohd.com>
parents:
420
diff
changeset
|
613 // Press or hold |
f10c2dad7f55
Adding missing GET_PROTOCOL handling
Jacob Alexander <haata@kiibohd.com>
parents:
420
diff
changeset
|
614 if ( mouse_button ) |
f10c2dad7f55
Adding missing GET_PROTOCOL handling
Jacob Alexander <haata@kiibohd.com>
parents:
420
diff
changeset
|
615 USBMouse_Buttons |= (1 << mouse_button_shift); |
f10c2dad7f55
Adding missing GET_PROTOCOL handling
Jacob Alexander <haata@kiibohd.com>
parents:
420
diff
changeset
|
616 |
f10c2dad7f55
Adding missing GET_PROTOCOL handling
Jacob Alexander <haata@kiibohd.com>
parents:
420
diff
changeset
|
617 if ( mouse_x ) |
f10c2dad7f55
Adding missing GET_PROTOCOL handling
Jacob Alexander <haata@kiibohd.com>
parents:
420
diff
changeset
|
618 USBMouse_Relative_x = mouse_x; |
f10c2dad7f55
Adding missing GET_PROTOCOL handling
Jacob Alexander <haata@kiibohd.com>
parents:
420
diff
changeset
|
619 if ( mouse_y ) |
f10c2dad7f55
Adding missing GET_PROTOCOL handling
Jacob Alexander <haata@kiibohd.com>
parents:
420
diff
changeset
|
620 USBMouse_Relative_y = mouse_y; |
f10c2dad7f55
Adding missing GET_PROTOCOL handling
Jacob Alexander <haata@kiibohd.com>
parents:
420
diff
changeset
|
621 } |
f10c2dad7f55
Adding missing GET_PROTOCOL handling
Jacob Alexander <haata@kiibohd.com>
parents:
420
diff
changeset
|
622 |
f10c2dad7f55
Adding missing GET_PROTOCOL handling
Jacob Alexander <haata@kiibohd.com>
parents:
420
diff
changeset
|
623 // Trigger updates |
f10c2dad7f55
Adding missing GET_PROTOCOL handling
Jacob Alexander <haata@kiibohd.com>
parents:
420
diff
changeset
|
624 if ( mouse_button ) |
f10c2dad7f55
Adding missing GET_PROTOCOL handling
Jacob Alexander <haata@kiibohd.com>
parents:
420
diff
changeset
|
625 USBMouse_Changed |= USBMouseChangeState_Buttons; |
f10c2dad7f55
Adding missing GET_PROTOCOL handling
Jacob Alexander <haata@kiibohd.com>
parents:
420
diff
changeset
|
626 |
f10c2dad7f55
Adding missing GET_PROTOCOL handling
Jacob Alexander <haata@kiibohd.com>
parents:
420
diff
changeset
|
627 if ( mouse_x || mouse_y ) |
f10c2dad7f55
Adding missing GET_PROTOCOL handling
Jacob Alexander <haata@kiibohd.com>
parents:
420
diff
changeset
|
628 USBMouse_Changed |= USBMouseChangeState_Relative; |
449
45feb80a2ad1
Major USB update, fixes most (if not all) known issues
Jacob Alexander <haata@kiibohd.com>
parents:
447
diff
changeset
|
629 #endif |
438
f10c2dad7f55
Adding missing GET_PROTOCOL handling
Jacob Alexander <haata@kiibohd.com>
parents:
420
diff
changeset
|
630 } |
f10c2dad7f55
Adding missing GET_PROTOCOL handling
Jacob Alexander <haata@kiibohd.com>
parents:
420
diff
changeset
|
631 |
172
a30bddad4115
Adding UART and UART + USB muxed CLI output.
Jacob Alexander <haata@kiibohd.com>
parents:
diff
changeset
|
632 |
a30bddad4115
Adding UART and UART + USB muxed CLI output.
Jacob Alexander <haata@kiibohd.com>
parents:
diff
changeset
|
633 |
a30bddad4115
Adding UART and UART + USB muxed CLI output.
Jacob Alexander <haata@kiibohd.com>
parents:
diff
changeset
|
634 // ----- Functions ----- |
a30bddad4115
Adding UART and UART + USB muxed CLI output.
Jacob Alexander <haata@kiibohd.com>
parents:
diff
changeset
|
635 |
300
7119c2149abb
Fixing compiler errors for usbMuxUart Output module
Jacob Alexander <haata@kiibohd.com>
parents:
275
diff
changeset
|
636 // Flush Key buffers |
7119c2149abb
Fixing compiler errors for usbMuxUart Output module
Jacob Alexander <haata@kiibohd.com>
parents:
275
diff
changeset
|
637 void Output_flushBuffers() |
7119c2149abb
Fixing compiler errors for usbMuxUart Output module
Jacob Alexander <haata@kiibohd.com>
parents:
275
diff
changeset
|
638 { |
7119c2149abb
Fixing compiler errors for usbMuxUart Output module
Jacob Alexander <haata@kiibohd.com>
parents:
275
diff
changeset
|
639 // Zero out USBKeys_Keys array |
7119c2149abb
Fixing compiler errors for usbMuxUart Output module
Jacob Alexander <haata@kiibohd.com>
parents:
275
diff
changeset
|
640 for ( uint8_t c = 0; c < USB_NKRO_BITFIELD_SIZE_KEYS; c++ ) |
7119c2149abb
Fixing compiler errors for usbMuxUart Output module
Jacob Alexander <haata@kiibohd.com>
parents:
275
diff
changeset
|
641 USBKeys_Keys[ c ] = 0; |
7119c2149abb
Fixing compiler errors for usbMuxUart Output module
Jacob Alexander <haata@kiibohd.com>
parents:
275
diff
changeset
|
642 |
7119c2149abb
Fixing compiler errors for usbMuxUart Output module
Jacob Alexander <haata@kiibohd.com>
parents:
275
diff
changeset
|
643 // Zero out other key buffers |
7119c2149abb
Fixing compiler errors for usbMuxUart Output module
Jacob Alexander <haata@kiibohd.com>
parents:
275
diff
changeset
|
644 USBKeys_ConsCtrl = 0; |
7119c2149abb
Fixing compiler errors for usbMuxUart Output module
Jacob Alexander <haata@kiibohd.com>
parents:
275
diff
changeset
|
645 USBKeys_Modifiers = 0; |
7119c2149abb
Fixing compiler errors for usbMuxUart Output module
Jacob Alexander <haata@kiibohd.com>
parents:
275
diff
changeset
|
646 USBKeys_SysCtrl = 0; |
7119c2149abb
Fixing compiler errors for usbMuxUart Output module
Jacob Alexander <haata@kiibohd.com>
parents:
275
diff
changeset
|
647 } |
7119c2149abb
Fixing compiler errors for usbMuxUart Output module
Jacob Alexander <haata@kiibohd.com>
parents:
275
diff
changeset
|
648 |
7119c2149abb
Fixing compiler errors for usbMuxUart Output module
Jacob Alexander <haata@kiibohd.com>
parents:
275
diff
changeset
|
649 |
172
a30bddad4115
Adding UART and UART + USB muxed CLI output.
Jacob Alexander <haata@kiibohd.com>
parents:
diff
changeset
|
650 // USB Module Setup |
a30bddad4115
Adding UART and UART + USB muxed CLI output.
Jacob Alexander <haata@kiibohd.com>
parents:
diff
changeset
|
651 inline void Output_setup() |
a30bddad4115
Adding UART and UART + USB muxed CLI output.
Jacob Alexander <haata@kiibohd.com>
parents:
diff
changeset
|
652 { |
230
d81ad399c14f
Adding clear screen before usb initializes
Jacob Alexander <haata@kiibohd.com>
parents:
227
diff
changeset
|
653 // Setup UART |
d81ad399c14f
Adding clear screen before usb initializes
Jacob Alexander <haata@kiibohd.com>
parents:
227
diff
changeset
|
654 uart_serial_setup(); |
d81ad399c14f
Adding clear screen before usb initializes
Jacob Alexander <haata@kiibohd.com>
parents:
227
diff
changeset
|
655 |
347
136e47478441
UARTConnect enumeration working!
Jacob Alexander <haata@kiibohd.com>
parents:
340
diff
changeset
|
656 // Initialize the USB |
136e47478441
UARTConnect enumeration working!
Jacob Alexander <haata@kiibohd.com>
parents:
340
diff
changeset
|
657 // If a USB connection does not exist, just ignore it |
136e47478441
UARTConnect enumeration working!
Jacob Alexander <haata@kiibohd.com>
parents:
340
diff
changeset
|
658 // All usb related functions will non-fatally fail if called |
136e47478441
UARTConnect enumeration working!
Jacob Alexander <haata@kiibohd.com>
parents:
340
diff
changeset
|
659 // If the USB initialization is delayed, then functionality will just be delayed |
172
a30bddad4115
Adding UART and UART + USB muxed CLI output.
Jacob Alexander <haata@kiibohd.com>
parents:
diff
changeset
|
660 usb_init(); |
175 | 661 |
172
a30bddad4115
Adding UART and UART + USB muxed CLI output.
Jacob Alexander <haata@kiibohd.com>
parents:
diff
changeset
|
662 // Register USB Output CLI dictionary |
a30bddad4115
Adding UART and UART + USB muxed CLI output.
Jacob Alexander <haata@kiibohd.com>
parents:
diff
changeset
|
663 CLI_registerDictionary( outputCLIDict, outputCLIDictName ); |
227
ed05fa3555d4
Updating usbMuxUart for NKRO
Jacob Alexander <haata@kiibohd.com>
parents:
195
diff
changeset
|
664 |
347
136e47478441
UARTConnect enumeration working!
Jacob Alexander <haata@kiibohd.com>
parents:
340
diff
changeset
|
665 // Flush key buffers |
136e47478441
UARTConnect enumeration working!
Jacob Alexander <haata@kiibohd.com>
parents:
340
diff
changeset
|
666 Output_flushBuffers(); |
172
a30bddad4115
Adding UART and UART + USB muxed CLI output.
Jacob Alexander <haata@kiibohd.com>
parents:
diff
changeset
|
667 } |
a30bddad4115
Adding UART and UART + USB muxed CLI output.
Jacob Alexander <haata@kiibohd.com>
parents:
diff
changeset
|
668 |
a30bddad4115
Adding UART and UART + USB muxed CLI output.
Jacob Alexander <haata@kiibohd.com>
parents:
diff
changeset
|
669 |
a30bddad4115
Adding UART and UART + USB muxed CLI output.
Jacob Alexander <haata@kiibohd.com>
parents:
diff
changeset
|
670 // USB Data Send |
227
ed05fa3555d4
Updating usbMuxUart for NKRO
Jacob Alexander <haata@kiibohd.com>
parents:
195
diff
changeset
|
671 inline void Output_send() |
172
a30bddad4115
Adding UART and UART + USB muxed CLI output.
Jacob Alexander <haata@kiibohd.com>
parents:
diff
changeset
|
672 { |
420
23a1868b4ac2
Adding dynamic USB power support
Jacob Alexander <haata@kiibohd.com>
parents:
385
diff
changeset
|
673 // USB status checks |
23a1868b4ac2
Adding dynamic USB power support
Jacob Alexander <haata@kiibohd.com>
parents:
385
diff
changeset
|
674 // Non-standard USB state manipulation, usually does nothing |
23a1868b4ac2
Adding dynamic USB power support
Jacob Alexander <haata@kiibohd.com>
parents:
385
diff
changeset
|
675 usb_device_check(); |
23a1868b4ac2
Adding dynamic USB power support
Jacob Alexander <haata@kiibohd.com>
parents:
385
diff
changeset
|
676 |
227
ed05fa3555d4
Updating usbMuxUart for NKRO
Jacob Alexander <haata@kiibohd.com>
parents:
195
diff
changeset
|
677 // Boot Mode Only, unset stale keys |
447
56237ba5da6f
Adding auto-restart support whenever USB gets into an odd state
Jacob Alexander <haata@kiibohd.com>
parents:
445
diff
changeset
|
678 // XXX - Behaves oddly on Mac OSX, might help with corrupted packets specific to OSX? -HaaTa |
56237ba5da6f
Adding auto-restart support whenever USB gets into an odd state
Jacob Alexander <haata@kiibohd.com>
parents:
445
diff
changeset
|
679 /* |
56237ba5da6f
Adding auto-restart support whenever USB gets into an odd state
Jacob Alexander <haata@kiibohd.com>
parents:
445
diff
changeset
|
680 // Check if idle count has been exceed, this forces usb_keyboard_send and usb_mouse_send to update |
56237ba5da6f
Adding auto-restart support whenever USB gets into an odd state
Jacob Alexander <haata@kiibohd.com>
parents:
445
diff
changeset
|
681 // TODO Add joystick as well (may be endpoint specific, currently not kept track of) |
56237ba5da6f
Adding auto-restart support whenever USB gets into an odd state
Jacob Alexander <haata@kiibohd.com>
parents:
445
diff
changeset
|
682 if ( usb_configuration && USBKeys_Idle_Config && ( |
56237ba5da6f
Adding auto-restart support whenever USB gets into an odd state
Jacob Alexander <haata@kiibohd.com>
parents:
445
diff
changeset
|
683 USBKeys_Idle_Expiry < systick_millis_count || |
56237ba5da6f
Adding auto-restart support whenever USB gets into an odd state
Jacob Alexander <haata@kiibohd.com>
parents:
445
diff
changeset
|
684 USBKeys_Idle_Expiry + USBKeys_Idle_Config * 4 >= systick_millis_count ) ) |
56237ba5da6f
Adding auto-restart support whenever USB gets into an odd state
Jacob Alexander <haata@kiibohd.com>
parents:
445
diff
changeset
|
685 { |
56237ba5da6f
Adding auto-restart support whenever USB gets into an odd state
Jacob Alexander <haata@kiibohd.com>
parents:
445
diff
changeset
|
686 USBKeys_Changed = USBKeyChangeState_All; |
56237ba5da6f
Adding auto-restart support whenever USB gets into an odd state
Jacob Alexander <haata@kiibohd.com>
parents:
445
diff
changeset
|
687 USBMouse_Changed = USBMouseChangeState_All; |
56237ba5da6f
Adding auto-restart support whenever USB gets into an odd state
Jacob Alexander <haata@kiibohd.com>
parents:
445
diff
changeset
|
688 } |
56237ba5da6f
Adding auto-restart support whenever USB gets into an odd state
Jacob Alexander <haata@kiibohd.com>
parents:
445
diff
changeset
|
689 */ |
56237ba5da6f
Adding auto-restart support whenever USB gets into an odd state
Jacob Alexander <haata@kiibohd.com>
parents:
445
diff
changeset
|
690 |
449
45feb80a2ad1
Major USB update, fixes most (if not all) known issues
Jacob Alexander <haata@kiibohd.com>
parents:
447
diff
changeset
|
691 #if enableMouse_define == 1 |
447
56237ba5da6f
Adding auto-restart support whenever USB gets into an odd state
Jacob Alexander <haata@kiibohd.com>
parents:
445
diff
changeset
|
692 // Process mouse actions |
56237ba5da6f
Adding auto-restart support whenever USB gets into an odd state
Jacob Alexander <haata@kiibohd.com>
parents:
445
diff
changeset
|
693 while ( USBMouse_Changed ) |
56237ba5da6f
Adding auto-restart support whenever USB gets into an odd state
Jacob Alexander <haata@kiibohd.com>
parents:
445
diff
changeset
|
694 usb_mouse_send(); |
449
45feb80a2ad1
Major USB update, fixes most (if not all) known issues
Jacob Alexander <haata@kiibohd.com>
parents:
447
diff
changeset
|
695 #endif |
45feb80a2ad1
Major USB update, fixes most (if not all) known issues
Jacob Alexander <haata@kiibohd.com>
parents:
447
diff
changeset
|
696 |
45feb80a2ad1
Major USB update, fixes most (if not all) known issues
Jacob Alexander <haata@kiibohd.com>
parents:
447
diff
changeset
|
697 #if enableKeyboard_define == 1 |
45feb80a2ad1
Major USB update, fixes most (if not all) known issues
Jacob Alexander <haata@kiibohd.com>
parents:
447
diff
changeset
|
698 if ( USBKeys_Protocol == 0 ) |
45feb80a2ad1
Major USB update, fixes most (if not all) known issues
Jacob Alexander <haata@kiibohd.com>
parents:
447
diff
changeset
|
699 for ( uint8_t c = USBKeys_Sent; c < USB_BOOT_MAX_KEYS; c++ ) |
45feb80a2ad1
Major USB update, fixes most (if not all) known issues
Jacob Alexander <haata@kiibohd.com>
parents:
447
diff
changeset
|
700 USBKeys_Keys[c] = 0; |
447
56237ba5da6f
Adding auto-restart support whenever USB gets into an odd state
Jacob Alexander <haata@kiibohd.com>
parents:
445
diff
changeset
|
701 |
227
ed05fa3555d4
Updating usbMuxUart for NKRO
Jacob Alexander <haata@kiibohd.com>
parents:
195
diff
changeset
|
702 // Send keypresses while there are pending changes |
ed05fa3555d4
Updating usbMuxUart for NKRO
Jacob Alexander <haata@kiibohd.com>
parents:
195
diff
changeset
|
703 while ( USBKeys_Changed ) |
ed05fa3555d4
Updating usbMuxUart for NKRO
Jacob Alexander <haata@kiibohd.com>
parents:
195
diff
changeset
|
704 usb_keyboard_send(); |
172
a30bddad4115
Adding UART and UART + USB muxed CLI output.
Jacob Alexander <haata@kiibohd.com>
parents:
diff
changeset
|
705 |
347
136e47478441
UARTConnect enumeration working!
Jacob Alexander <haata@kiibohd.com>
parents:
340
diff
changeset
|
706 // Clear keys sent |
136e47478441
UARTConnect enumeration working!
Jacob Alexander <haata@kiibohd.com>
parents:
340
diff
changeset
|
707 USBKeys_Sent = 0; |
172
a30bddad4115
Adding UART and UART + USB muxed CLI output.
Jacob Alexander <haata@kiibohd.com>
parents:
diff
changeset
|
708 |
186
50702debf278
Initial MatrixARM implementation
Jacob Alexander <haata@kiibohd.com>
parents:
178
diff
changeset
|
709 // Signal Scan Module we are finished |
227
ed05fa3555d4
Updating usbMuxUart for NKRO
Jacob Alexander <haata@kiibohd.com>
parents:
195
diff
changeset
|
710 switch ( USBKeys_Protocol ) |
ed05fa3555d4
Updating usbMuxUart for NKRO
Jacob Alexander <haata@kiibohd.com>
parents:
195
diff
changeset
|
711 { |
ed05fa3555d4
Updating usbMuxUart for NKRO
Jacob Alexander <haata@kiibohd.com>
parents:
195
diff
changeset
|
712 case 0: // Boot Mode |
347
136e47478441
UARTConnect enumeration working!
Jacob Alexander <haata@kiibohd.com>
parents:
340
diff
changeset
|
713 // Clear modifiers only in boot mode |
136e47478441
UARTConnect enumeration working!
Jacob Alexander <haata@kiibohd.com>
parents:
340
diff
changeset
|
714 USBKeys_Modifiers = 0; |
227
ed05fa3555d4
Updating usbMuxUart for NKRO
Jacob Alexander <haata@kiibohd.com>
parents:
195
diff
changeset
|
715 Scan_finishedWithOutput( USBKeys_Sent <= USB_BOOT_MAX_KEYS ? USBKeys_Sent : USB_BOOT_MAX_KEYS ); |
ed05fa3555d4
Updating usbMuxUart for NKRO
Jacob Alexander <haata@kiibohd.com>
parents:
195
diff
changeset
|
716 break; |
ed05fa3555d4
Updating usbMuxUart for NKRO
Jacob Alexander <haata@kiibohd.com>
parents:
195
diff
changeset
|
717 case 1: // NKRO Mode |
ed05fa3555d4
Updating usbMuxUart for NKRO
Jacob Alexander <haata@kiibohd.com>
parents:
195
diff
changeset
|
718 Scan_finishedWithOutput( USBKeys_Sent ); |
ed05fa3555d4
Updating usbMuxUart for NKRO
Jacob Alexander <haata@kiibohd.com>
parents:
195
diff
changeset
|
719 break; |
ed05fa3555d4
Updating usbMuxUart for NKRO
Jacob Alexander <haata@kiibohd.com>
parents:
195
diff
changeset
|
720 } |
449
45feb80a2ad1
Major USB update, fixes most (if not all) known issues
Jacob Alexander <haata@kiibohd.com>
parents:
447
diff
changeset
|
721 #endif |
172
a30bddad4115
Adding UART and UART + USB muxed CLI output.
Jacob Alexander <haata@kiibohd.com>
parents:
diff
changeset
|
722 } |
a30bddad4115
Adding UART and UART + USB muxed CLI output.
Jacob Alexander <haata@kiibohd.com>
parents:
diff
changeset
|
723 |
a30bddad4115
Adding UART and UART + USB muxed CLI output.
Jacob Alexander <haata@kiibohd.com>
parents:
diff
changeset
|
724 |
a30bddad4115
Adding UART and UART + USB muxed CLI output.
Jacob Alexander <haata@kiibohd.com>
parents:
diff
changeset
|
725 // Sets the device into firmware reload mode |
347
136e47478441
UARTConnect enumeration working!
Jacob Alexander <haata@kiibohd.com>
parents:
340
diff
changeset
|
726 void Output_firmwareReload() |
172
a30bddad4115
Adding UART and UART + USB muxed CLI output.
Jacob Alexander <haata@kiibohd.com>
parents:
diff
changeset
|
727 { |
347
136e47478441
UARTConnect enumeration working!
Jacob Alexander <haata@kiibohd.com>
parents:
340
diff
changeset
|
728 usb_device_reload(); |
172
a30bddad4115
Adding UART and UART + USB muxed CLI output.
Jacob Alexander <haata@kiibohd.com>
parents:
diff
changeset
|
729 } |
a30bddad4115
Adding UART and UART + USB muxed CLI output.
Jacob Alexander <haata@kiibohd.com>
parents:
diff
changeset
|
730 |
a30bddad4115
Adding UART and UART + USB muxed CLI output.
Jacob Alexander <haata@kiibohd.com>
parents:
diff
changeset
|
731 |
a30bddad4115
Adding UART and UART + USB muxed CLI output.
Jacob Alexander <haata@kiibohd.com>
parents:
diff
changeset
|
732 // USB Input buffer available |
a30bddad4115
Adding UART and UART + USB muxed CLI output.
Jacob Alexander <haata@kiibohd.com>
parents:
diff
changeset
|
733 inline unsigned int Output_availablechar() |
a30bddad4115
Adding UART and UART + USB muxed CLI output.
Jacob Alexander <haata@kiibohd.com>
parents:
diff
changeset
|
734 { |
449
45feb80a2ad1
Major USB update, fixes most (if not all) known issues
Jacob Alexander <haata@kiibohd.com>
parents:
447
diff
changeset
|
735 #if enableVirtualSerialPort_define == 1 |
172
a30bddad4115
Adding UART and UART + USB muxed CLI output.
Jacob Alexander <haata@kiibohd.com>
parents:
diff
changeset
|
736 return usb_serial_available() + uart_serial_available(); |
449
45feb80a2ad1
Major USB update, fixes most (if not all) known issues
Jacob Alexander <haata@kiibohd.com>
parents:
447
diff
changeset
|
737 #else |
45feb80a2ad1
Major USB update, fixes most (if not all) known issues
Jacob Alexander <haata@kiibohd.com>
parents:
447
diff
changeset
|
738 return uart_serial_available(); |
45feb80a2ad1
Major USB update, fixes most (if not all) known issues
Jacob Alexander <haata@kiibohd.com>
parents:
447
diff
changeset
|
739 #endif |
172
a30bddad4115
Adding UART and UART + USB muxed CLI output.
Jacob Alexander <haata@kiibohd.com>
parents:
diff
changeset
|
740 } |
a30bddad4115
Adding UART and UART + USB muxed CLI output.
Jacob Alexander <haata@kiibohd.com>
parents:
diff
changeset
|
741 |
a30bddad4115
Adding UART and UART + USB muxed CLI output.
Jacob Alexander <haata@kiibohd.com>
parents:
diff
changeset
|
742 |
a30bddad4115
Adding UART and UART + USB muxed CLI output.
Jacob Alexander <haata@kiibohd.com>
parents:
diff
changeset
|
743 // USB Get Character from input buffer |
a30bddad4115
Adding UART and UART + USB muxed CLI output.
Jacob Alexander <haata@kiibohd.com>
parents:
diff
changeset
|
744 inline int Output_getchar() |
a30bddad4115
Adding UART and UART + USB muxed CLI output.
Jacob Alexander <haata@kiibohd.com>
parents:
diff
changeset
|
745 { |
449
45feb80a2ad1
Major USB update, fixes most (if not all) known issues
Jacob Alexander <haata@kiibohd.com>
parents:
447
diff
changeset
|
746 #if enableVirtualSerialPort_define == 1 |
178
555d70c6764d
Removing unnecessary ifdefs
Jacob Alexander <haata@kiibohd.com>
parents:
175
diff
changeset
|
747 // XXX Make sure to check output_availablechar() first! Information is lost with the cast (error codes) (AVR) |
172
a30bddad4115
Adding UART and UART + USB muxed CLI output.
Jacob Alexander <haata@kiibohd.com>
parents:
diff
changeset
|
748 if ( usb_serial_available() > 0 ) |
a30bddad4115
Adding UART and UART + USB muxed CLI output.
Jacob Alexander <haata@kiibohd.com>
parents:
diff
changeset
|
749 { |
178
555d70c6764d
Removing unnecessary ifdefs
Jacob Alexander <haata@kiibohd.com>
parents:
175
diff
changeset
|
750 return (int)usb_serial_getchar(); |
172
a30bddad4115
Adding UART and UART + USB muxed CLI output.
Jacob Alexander <haata@kiibohd.com>
parents:
diff
changeset
|
751 } |
449
45feb80a2ad1
Major USB update, fixes most (if not all) known issues
Jacob Alexander <haata@kiibohd.com>
parents:
447
diff
changeset
|
752 #endif |
172
a30bddad4115
Adding UART and UART + USB muxed CLI output.
Jacob Alexander <haata@kiibohd.com>
parents:
diff
changeset
|
753 |
a30bddad4115
Adding UART and UART + USB muxed CLI output.
Jacob Alexander <haata@kiibohd.com>
parents:
diff
changeset
|
754 if ( uart_serial_available() > 0 ) |
a30bddad4115
Adding UART and UART + USB muxed CLI output.
Jacob Alexander <haata@kiibohd.com>
parents:
diff
changeset
|
755 { |
178
555d70c6764d
Removing unnecessary ifdefs
Jacob Alexander <haata@kiibohd.com>
parents:
175
diff
changeset
|
756 return (int)uart_serial_getchar(); |
172
a30bddad4115
Adding UART and UART + USB muxed CLI output.
Jacob Alexander <haata@kiibohd.com>
parents:
diff
changeset
|
757 } |
a30bddad4115
Adding UART and UART + USB muxed CLI output.
Jacob Alexander <haata@kiibohd.com>
parents:
diff
changeset
|
758 |
a30bddad4115
Adding UART and UART + USB muxed CLI output.
Jacob Alexander <haata@kiibohd.com>
parents:
diff
changeset
|
759 return -1; |
a30bddad4115
Adding UART and UART + USB muxed CLI output.
Jacob Alexander <haata@kiibohd.com>
parents:
diff
changeset
|
760 } |
a30bddad4115
Adding UART and UART + USB muxed CLI output.
Jacob Alexander <haata@kiibohd.com>
parents:
diff
changeset
|
761 |
a30bddad4115
Adding UART and UART + USB muxed CLI output.
Jacob Alexander <haata@kiibohd.com>
parents:
diff
changeset
|
762 |
a30bddad4115
Adding UART and UART + USB muxed CLI output.
Jacob Alexander <haata@kiibohd.com>
parents:
diff
changeset
|
763 // USB Send Character to output buffer |
a30bddad4115
Adding UART and UART + USB muxed CLI output.
Jacob Alexander <haata@kiibohd.com>
parents:
diff
changeset
|
764 inline int Output_putchar( char c ) |
a30bddad4115
Adding UART and UART + USB muxed CLI output.
Jacob Alexander <haata@kiibohd.com>
parents:
diff
changeset
|
765 { |
449
45feb80a2ad1
Major USB update, fixes most (if not all) known issues
Jacob Alexander <haata@kiibohd.com>
parents:
447
diff
changeset
|
766 #if enableVirtualSerialPort_define == 1 |
172
a30bddad4115
Adding UART and UART + USB muxed CLI output.
Jacob Alexander <haata@kiibohd.com>
parents:
diff
changeset
|
767 // First send to UART |
a30bddad4115
Adding UART and UART + USB muxed CLI output.
Jacob Alexander <haata@kiibohd.com>
parents:
diff
changeset
|
768 uart_serial_putchar( c ); |
a30bddad4115
Adding UART and UART + USB muxed CLI output.
Jacob Alexander <haata@kiibohd.com>
parents:
diff
changeset
|
769 |
a30bddad4115
Adding UART and UART + USB muxed CLI output.
Jacob Alexander <haata@kiibohd.com>
parents:
diff
changeset
|
770 // Then send to USB |
a30bddad4115
Adding UART and UART + USB muxed CLI output.
Jacob Alexander <haata@kiibohd.com>
parents:
diff
changeset
|
771 return usb_serial_putchar( c ); |
449
45feb80a2ad1
Major USB update, fixes most (if not all) known issues
Jacob Alexander <haata@kiibohd.com>
parents:
447
diff
changeset
|
772 #else |
45feb80a2ad1
Major USB update, fixes most (if not all) known issues
Jacob Alexander <haata@kiibohd.com>
parents:
447
diff
changeset
|
773 return uart_serial_putchar( c ); |
45feb80a2ad1
Major USB update, fixes most (if not all) known issues
Jacob Alexander <haata@kiibohd.com>
parents:
447
diff
changeset
|
774 #endif |
172
a30bddad4115
Adding UART and UART + USB muxed CLI output.
Jacob Alexander <haata@kiibohd.com>
parents:
diff
changeset
|
775 } |
a30bddad4115
Adding UART and UART + USB muxed CLI output.
Jacob Alexander <haata@kiibohd.com>
parents:
diff
changeset
|
776 |
a30bddad4115
Adding UART and UART + USB muxed CLI output.
Jacob Alexander <haata@kiibohd.com>
parents:
diff
changeset
|
777 |
a30bddad4115
Adding UART and UART + USB muxed CLI output.
Jacob Alexander <haata@kiibohd.com>
parents:
diff
changeset
|
778 // USB Send String to output buffer, null terminated |
a30bddad4115
Adding UART and UART + USB muxed CLI output.
Jacob Alexander <haata@kiibohd.com>
parents:
diff
changeset
|
779 inline int Output_putstr( char* str ) |
a30bddad4115
Adding UART and UART + USB muxed CLI output.
Jacob Alexander <haata@kiibohd.com>
parents:
diff
changeset
|
780 { |
a30bddad4115
Adding UART and UART + USB muxed CLI output.
Jacob Alexander <haata@kiibohd.com>
parents:
diff
changeset
|
781 #if defined(_at90usb162_) || defined(_atmega32u4_) || defined(_at90usb646_) || defined(_at90usb1286_) // AVR |
178
555d70c6764d
Removing unnecessary ifdefs
Jacob Alexander <haata@kiibohd.com>
parents:
175
diff
changeset
|
782 uint16_t count = 0; |
263
9afed592bcb5
Preparing for mk20dx256vlh7
Jacob Alexander <haata@kiibohd.com>
parents:
239
diff
changeset
|
783 #elif defined(_mk20dx128_) || defined(_mk20dx128vlf5_) || defined(_mk20dx256_) || defined(_mk20dx256vlh7_) // ARM |
172
a30bddad4115
Adding UART and UART + USB muxed CLI output.
Jacob Alexander <haata@kiibohd.com>
parents:
diff
changeset
|
784 uint32_t count = 0; |
a30bddad4115
Adding UART and UART + USB muxed CLI output.
Jacob Alexander <haata@kiibohd.com>
parents:
diff
changeset
|
785 #endif |
a30bddad4115
Adding UART and UART + USB muxed CLI output.
Jacob Alexander <haata@kiibohd.com>
parents:
diff
changeset
|
786 // Count characters until NULL character, then send the amount counted |
a30bddad4115
Adding UART and UART + USB muxed CLI output.
Jacob Alexander <haata@kiibohd.com>
parents:
diff
changeset
|
787 while ( str[count] != '\0' ) |
a30bddad4115
Adding UART and UART + USB muxed CLI output.
Jacob Alexander <haata@kiibohd.com>
parents:
diff
changeset
|
788 count++; |
a30bddad4115
Adding UART and UART + USB muxed CLI output.
Jacob Alexander <haata@kiibohd.com>
parents:
diff
changeset
|
789 |
449
45feb80a2ad1
Major USB update, fixes most (if not all) known issues
Jacob Alexander <haata@kiibohd.com>
parents:
447
diff
changeset
|
790 #if enableVirtualSerialPort_define == 1 |
173
afd0f94023ff
Fixed bug with standalone UART CLI
Jacob Alexander <haata@kiibohd.com>
parents:
172
diff
changeset
|
791 // First send to UART |
afd0f94023ff
Fixed bug with standalone UART CLI
Jacob Alexander <haata@kiibohd.com>
parents:
172
diff
changeset
|
792 uart_serial_write( str, count ); |
172
a30bddad4115
Adding UART and UART + USB muxed CLI output.
Jacob Alexander <haata@kiibohd.com>
parents:
diff
changeset
|
793 |
a30bddad4115
Adding UART and UART + USB muxed CLI output.
Jacob Alexander <haata@kiibohd.com>
parents:
diff
changeset
|
794 // Then send to USB |
a30bddad4115
Adding UART and UART + USB muxed CLI output.
Jacob Alexander <haata@kiibohd.com>
parents:
diff
changeset
|
795 return usb_serial_write( str, count ); |
449
45feb80a2ad1
Major USB update, fixes most (if not all) known issues
Jacob Alexander <haata@kiibohd.com>
parents:
447
diff
changeset
|
796 #else |
45feb80a2ad1
Major USB update, fixes most (if not all) known issues
Jacob Alexander <haata@kiibohd.com>
parents:
447
diff
changeset
|
797 return uart_serial_write( str, count ); |
45feb80a2ad1
Major USB update, fixes most (if not all) known issues
Jacob Alexander <haata@kiibohd.com>
parents:
447
diff
changeset
|
798 #endif |
172
a30bddad4115
Adding UART and UART + USB muxed CLI output.
Jacob Alexander <haata@kiibohd.com>
parents:
diff
changeset
|
799 } |
a30bddad4115
Adding UART and UART + USB muxed CLI output.
Jacob Alexander <haata@kiibohd.com>
parents:
diff
changeset
|
800 |
a30bddad4115
Adding UART and UART + USB muxed CLI output.
Jacob Alexander <haata@kiibohd.com>
parents:
diff
changeset
|
801 |
a30bddad4115
Adding UART and UART + USB muxed CLI output.
Jacob Alexander <haata@kiibohd.com>
parents:
diff
changeset
|
802 // Soft Chip Reset |
a30bddad4115
Adding UART and UART + USB muxed CLI output.
Jacob Alexander <haata@kiibohd.com>
parents:
diff
changeset
|
803 inline void Output_softReset() |
a30bddad4115
Adding UART and UART + USB muxed CLI output.
Jacob Alexander <haata@kiibohd.com>
parents:
diff
changeset
|
804 { |
178
555d70c6764d
Removing unnecessary ifdefs
Jacob Alexander <haata@kiibohd.com>
parents:
175
diff
changeset
|
805 usb_device_software_reset(); |
172
a30bddad4115
Adding UART and UART + USB muxed CLI output.
Jacob Alexander <haata@kiibohd.com>
parents:
diff
changeset
|
806 } |
a30bddad4115
Adding UART and UART + USB muxed CLI output.
Jacob Alexander <haata@kiibohd.com>
parents:
diff
changeset
|
807 |
a30bddad4115
Adding UART and UART + USB muxed CLI output.
Jacob Alexander <haata@kiibohd.com>
parents:
diff
changeset
|
808 |
420
23a1868b4ac2
Adding dynamic USB power support
Jacob Alexander <haata@kiibohd.com>
parents:
385
diff
changeset
|
809 // Update USB current (mA) |
23a1868b4ac2
Adding dynamic USB power support
Jacob Alexander <haata@kiibohd.com>
parents:
385
diff
changeset
|
810 // Triggers power change event |
23a1868b4ac2
Adding dynamic USB power support
Jacob Alexander <haata@kiibohd.com>
parents:
385
diff
changeset
|
811 void Output_update_usb_current( unsigned int current ) |
23a1868b4ac2
Adding dynamic USB power support
Jacob Alexander <haata@kiibohd.com>
parents:
385
diff
changeset
|
812 { |
23a1868b4ac2
Adding dynamic USB power support
Jacob Alexander <haata@kiibohd.com>
parents:
385
diff
changeset
|
813 // Only signal if changed |
23a1868b4ac2
Adding dynamic USB power support
Jacob Alexander <haata@kiibohd.com>
parents:
385
diff
changeset
|
814 if ( current == Output_USBCurrent_Available ) |
23a1868b4ac2
Adding dynamic USB power support
Jacob Alexander <haata@kiibohd.com>
parents:
385
diff
changeset
|
815 return; |
23a1868b4ac2
Adding dynamic USB power support
Jacob Alexander <haata@kiibohd.com>
parents:
385
diff
changeset
|
816 |
23a1868b4ac2
Adding dynamic USB power support
Jacob Alexander <haata@kiibohd.com>
parents:
385
diff
changeset
|
817 // Update USB current |
23a1868b4ac2
Adding dynamic USB power support
Jacob Alexander <haata@kiibohd.com>
parents:
385
diff
changeset
|
818 Output_USBCurrent_Available = current; |
23a1868b4ac2
Adding dynamic USB power support
Jacob Alexander <haata@kiibohd.com>
parents:
385
diff
changeset
|
819 |
439
68e19d7c953e
Adding proper remote wake-up support
Jacob Alexander <haata@kiibohd.com>
parents:
438
diff
changeset
|
820 /* XXX Affects sleep states due to USB messages |
420
23a1868b4ac2
Adding dynamic USB power support
Jacob Alexander <haata@kiibohd.com>
parents:
385
diff
changeset
|
821 unsigned int total_current = Output_current_available(); |
23a1868b4ac2
Adding dynamic USB power support
Jacob Alexander <haata@kiibohd.com>
parents:
385
diff
changeset
|
822 info_msg("USB Available Current Changed. Total Available: "); |
23a1868b4ac2
Adding dynamic USB power support
Jacob Alexander <haata@kiibohd.com>
parents:
385
diff
changeset
|
823 printInt32( total_current ); |
23a1868b4ac2
Adding dynamic USB power support
Jacob Alexander <haata@kiibohd.com>
parents:
385
diff
changeset
|
824 print(" mA" NL); |
439
68e19d7c953e
Adding proper remote wake-up support
Jacob Alexander <haata@kiibohd.com>
parents:
438
diff
changeset
|
825 */ |
420
23a1868b4ac2
Adding dynamic USB power support
Jacob Alexander <haata@kiibohd.com>
parents:
385
diff
changeset
|
826 |
23a1868b4ac2
Adding dynamic USB power support
Jacob Alexander <haata@kiibohd.com>
parents:
385
diff
changeset
|
827 // Send new total current to the Scan Modules |
23a1868b4ac2
Adding dynamic USB power support
Jacob Alexander <haata@kiibohd.com>
parents:
385
diff
changeset
|
828 Scan_currentChange( Output_current_available() ); |
23a1868b4ac2
Adding dynamic USB power support
Jacob Alexander <haata@kiibohd.com>
parents:
385
diff
changeset
|
829 } |
23a1868b4ac2
Adding dynamic USB power support
Jacob Alexander <haata@kiibohd.com>
parents:
385
diff
changeset
|
830 |
23a1868b4ac2
Adding dynamic USB power support
Jacob Alexander <haata@kiibohd.com>
parents:
385
diff
changeset
|
831 |
23a1868b4ac2
Adding dynamic USB power support
Jacob Alexander <haata@kiibohd.com>
parents:
385
diff
changeset
|
832 // Update external current (mA) |
23a1868b4ac2
Adding dynamic USB power support
Jacob Alexander <haata@kiibohd.com>
parents:
385
diff
changeset
|
833 // Triggers power change event |
23a1868b4ac2
Adding dynamic USB power support
Jacob Alexander <haata@kiibohd.com>
parents:
385
diff
changeset
|
834 void Output_update_external_current( unsigned int current ) |
23a1868b4ac2
Adding dynamic USB power support
Jacob Alexander <haata@kiibohd.com>
parents:
385
diff
changeset
|
835 { |
23a1868b4ac2
Adding dynamic USB power support
Jacob Alexander <haata@kiibohd.com>
parents:
385
diff
changeset
|
836 // Only signal if changed |
23a1868b4ac2
Adding dynamic USB power support
Jacob Alexander <haata@kiibohd.com>
parents:
385
diff
changeset
|
837 if ( current == Output_ExtCurrent_Available ) |
23a1868b4ac2
Adding dynamic USB power support
Jacob Alexander <haata@kiibohd.com>
parents:
385
diff
changeset
|
838 return; |
23a1868b4ac2
Adding dynamic USB power support
Jacob Alexander <haata@kiibohd.com>
parents:
385
diff
changeset
|
839 |
23a1868b4ac2
Adding dynamic USB power support
Jacob Alexander <haata@kiibohd.com>
parents:
385
diff
changeset
|
840 // Update external current |
23a1868b4ac2
Adding dynamic USB power support
Jacob Alexander <haata@kiibohd.com>
parents:
385
diff
changeset
|
841 Output_ExtCurrent_Available = current; |
23a1868b4ac2
Adding dynamic USB power support
Jacob Alexander <haata@kiibohd.com>
parents:
385
diff
changeset
|
842 |
23a1868b4ac2
Adding dynamic USB power support
Jacob Alexander <haata@kiibohd.com>
parents:
385
diff
changeset
|
843 unsigned int total_current = Output_current_available(); |
23a1868b4ac2
Adding dynamic USB power support
Jacob Alexander <haata@kiibohd.com>
parents:
385
diff
changeset
|
844 info_msg("External Available Current Changed. Total Available: "); |
23a1868b4ac2
Adding dynamic USB power support
Jacob Alexander <haata@kiibohd.com>
parents:
385
diff
changeset
|
845 printInt32( total_current ); |
23a1868b4ac2
Adding dynamic USB power support
Jacob Alexander <haata@kiibohd.com>
parents:
385
diff
changeset
|
846 print(" mA" NL); |
23a1868b4ac2
Adding dynamic USB power support
Jacob Alexander <haata@kiibohd.com>
parents:
385
diff
changeset
|
847 |
23a1868b4ac2
Adding dynamic USB power support
Jacob Alexander <haata@kiibohd.com>
parents:
385
diff
changeset
|
848 // Send new total current to the Scan Modules |
23a1868b4ac2
Adding dynamic USB power support
Jacob Alexander <haata@kiibohd.com>
parents:
385
diff
changeset
|
849 Scan_currentChange( Output_current_available() ); |
23a1868b4ac2
Adding dynamic USB power support
Jacob Alexander <haata@kiibohd.com>
parents:
385
diff
changeset
|
850 } |
23a1868b4ac2
Adding dynamic USB power support
Jacob Alexander <haata@kiibohd.com>
parents:
385
diff
changeset
|
851 |
23a1868b4ac2
Adding dynamic USB power support
Jacob Alexander <haata@kiibohd.com>
parents:
385
diff
changeset
|
852 |
23a1868b4ac2
Adding dynamic USB power support
Jacob Alexander <haata@kiibohd.com>
parents:
385
diff
changeset
|
853 // Power/Current Available |
23a1868b4ac2
Adding dynamic USB power support
Jacob Alexander <haata@kiibohd.com>
parents:
385
diff
changeset
|
854 unsigned int Output_current_available() |
23a1868b4ac2
Adding dynamic USB power support
Jacob Alexander <haata@kiibohd.com>
parents:
385
diff
changeset
|
855 { |
23a1868b4ac2
Adding dynamic USB power support
Jacob Alexander <haata@kiibohd.com>
parents:
385
diff
changeset
|
856 unsigned int total_current = 0; |
23a1868b4ac2
Adding dynamic USB power support
Jacob Alexander <haata@kiibohd.com>
parents:
385
diff
changeset
|
857 |
23a1868b4ac2
Adding dynamic USB power support
Jacob Alexander <haata@kiibohd.com>
parents:
385
diff
changeset
|
858 // Check for USB current source |
23a1868b4ac2
Adding dynamic USB power support
Jacob Alexander <haata@kiibohd.com>
parents:
385
diff
changeset
|
859 total_current += Output_USBCurrent_Available; |
23a1868b4ac2
Adding dynamic USB power support
Jacob Alexander <haata@kiibohd.com>
parents:
385
diff
changeset
|
860 |
23a1868b4ac2
Adding dynamic USB power support
Jacob Alexander <haata@kiibohd.com>
parents:
385
diff
changeset
|
861 // Check for external current source |
23a1868b4ac2
Adding dynamic USB power support
Jacob Alexander <haata@kiibohd.com>
parents:
385
diff
changeset
|
862 total_current += Output_ExtCurrent_Available; |
23a1868b4ac2
Adding dynamic USB power support
Jacob Alexander <haata@kiibohd.com>
parents:
385
diff
changeset
|
863 |
23a1868b4ac2
Adding dynamic USB power support
Jacob Alexander <haata@kiibohd.com>
parents:
385
diff
changeset
|
864 // XXX If the total available current is still 0 |
23a1868b4ac2
Adding dynamic USB power support
Jacob Alexander <haata@kiibohd.com>
parents:
385
diff
changeset
|
865 // Set to 100 mA, which is generally a safe assumption at startup |
23a1868b4ac2
Adding dynamic USB power support
Jacob Alexander <haata@kiibohd.com>
parents:
385
diff
changeset
|
866 // before we've been able to determine actual available current |
23a1868b4ac2
Adding dynamic USB power support
Jacob Alexander <haata@kiibohd.com>
parents:
385
diff
changeset
|
867 if ( total_current == 0 ) |
23a1868b4ac2
Adding dynamic USB power support
Jacob Alexander <haata@kiibohd.com>
parents:
385
diff
changeset
|
868 { |
23a1868b4ac2
Adding dynamic USB power support
Jacob Alexander <haata@kiibohd.com>
parents:
385
diff
changeset
|
869 total_current = 100; |
23a1868b4ac2
Adding dynamic USB power support
Jacob Alexander <haata@kiibohd.com>
parents:
385
diff
changeset
|
870 } |
23a1868b4ac2
Adding dynamic USB power support
Jacob Alexander <haata@kiibohd.com>
parents:
385
diff
changeset
|
871 |
23a1868b4ac2
Adding dynamic USB power support
Jacob Alexander <haata@kiibohd.com>
parents:
385
diff
changeset
|
872 return total_current; |
23a1868b4ac2
Adding dynamic USB power support
Jacob Alexander <haata@kiibohd.com>
parents:
385
diff
changeset
|
873 } |
23a1868b4ac2
Adding dynamic USB power support
Jacob Alexander <haata@kiibohd.com>
parents:
385
diff
changeset
|
874 |
23a1868b4ac2
Adding dynamic USB power support
Jacob Alexander <haata@kiibohd.com>
parents:
385
diff
changeset
|
875 |
23a1868b4ac2
Adding dynamic USB power support
Jacob Alexander <haata@kiibohd.com>
parents:
385
diff
changeset
|
876 |
172
a30bddad4115
Adding UART and UART + USB muxed CLI output.
Jacob Alexander <haata@kiibohd.com>
parents:
diff
changeset
|
877 // ----- CLI Command Functions ----- |
a30bddad4115
Adding UART and UART + USB muxed CLI output.
Jacob Alexander <haata@kiibohd.com>
parents:
diff
changeset
|
878 |
a30bddad4115
Adding UART and UART + USB muxed CLI output.
Jacob Alexander <haata@kiibohd.com>
parents:
diff
changeset
|
879 void cliFunc_kbdProtocol( char* args ) |
a30bddad4115
Adding UART and UART + USB muxed CLI output.
Jacob Alexander <haata@kiibohd.com>
parents:
diff
changeset
|
880 { |
a30bddad4115
Adding UART and UART + USB muxed CLI output.
Jacob Alexander <haata@kiibohd.com>
parents:
diff
changeset
|
881 print( NL ); |
a30bddad4115
Adding UART and UART + USB muxed CLI output.
Jacob Alexander <haata@kiibohd.com>
parents:
diff
changeset
|
882 info_msg("Keyboard Protocol: "); |
a30bddad4115
Adding UART and UART + USB muxed CLI output.
Jacob Alexander <haata@kiibohd.com>
parents:
diff
changeset
|
883 printInt8( USBKeys_Protocol ); |
a30bddad4115
Adding UART and UART + USB muxed CLI output.
Jacob Alexander <haata@kiibohd.com>
parents:
diff
changeset
|
884 } |
a30bddad4115
Adding UART and UART + USB muxed CLI output.
Jacob Alexander <haata@kiibohd.com>
parents:
diff
changeset
|
885 |
a30bddad4115
Adding UART and UART + USB muxed CLI output.
Jacob Alexander <haata@kiibohd.com>
parents:
diff
changeset
|
886 |
347
136e47478441
UARTConnect enumeration working!
Jacob Alexander <haata@kiibohd.com>
parents:
340
diff
changeset
|
887 void cliFunc_outputDebug( char* args ) |
136e47478441
UARTConnect enumeration working!
Jacob Alexander <haata@kiibohd.com>
parents:
340
diff
changeset
|
888 { |
136e47478441
UARTConnect enumeration working!
Jacob Alexander <haata@kiibohd.com>
parents:
340
diff
changeset
|
889 // Parse number from argument |
136e47478441
UARTConnect enumeration working!
Jacob Alexander <haata@kiibohd.com>
parents:
340
diff
changeset
|
890 // NOTE: Only first argument is used |
136e47478441
UARTConnect enumeration working!
Jacob Alexander <haata@kiibohd.com>
parents:
340
diff
changeset
|
891 char* arg1Ptr; |
136e47478441
UARTConnect enumeration working!
Jacob Alexander <haata@kiibohd.com>
parents:
340
diff
changeset
|
892 char* arg2Ptr; |
136e47478441
UARTConnect enumeration working!
Jacob Alexander <haata@kiibohd.com>
parents:
340
diff
changeset
|
893 CLI_argumentIsolation( args, &arg1Ptr, &arg2Ptr ); |
136e47478441
UARTConnect enumeration working!
Jacob Alexander <haata@kiibohd.com>
parents:
340
diff
changeset
|
894 |
136e47478441
UARTConnect enumeration working!
Jacob Alexander <haata@kiibohd.com>
parents:
340
diff
changeset
|
895 // Default to 1 if no argument is given |
136e47478441
UARTConnect enumeration working!
Jacob Alexander <haata@kiibohd.com>
parents:
340
diff
changeset
|
896 Output_DebugMode = 1; |
136e47478441
UARTConnect enumeration working!
Jacob Alexander <haata@kiibohd.com>
parents:
340
diff
changeset
|
897 |
136e47478441
UARTConnect enumeration working!
Jacob Alexander <haata@kiibohd.com>
parents:
340
diff
changeset
|
898 if ( arg1Ptr[0] != '\0' ) |
136e47478441
UARTConnect enumeration working!
Jacob Alexander <haata@kiibohd.com>
parents:
340
diff
changeset
|
899 { |
136e47478441
UARTConnect enumeration working!
Jacob Alexander <haata@kiibohd.com>
parents:
340
diff
changeset
|
900 Output_DebugMode = (uint16_t)numToInt( arg1Ptr ); |
136e47478441
UARTConnect enumeration working!
Jacob Alexander <haata@kiibohd.com>
parents:
340
diff
changeset
|
901 } |
136e47478441
UARTConnect enumeration working!
Jacob Alexander <haata@kiibohd.com>
parents:
340
diff
changeset
|
902 } |
136e47478441
UARTConnect enumeration working!
Jacob Alexander <haata@kiibohd.com>
parents:
340
diff
changeset
|
903 |
136e47478441
UARTConnect enumeration working!
Jacob Alexander <haata@kiibohd.com>
parents:
340
diff
changeset
|
904 |
172
a30bddad4115
Adding UART and UART + USB muxed CLI output.
Jacob Alexander <haata@kiibohd.com>
parents:
diff
changeset
|
905 void cliFunc_readLEDs( char* args ) |
a30bddad4115
Adding UART and UART + USB muxed CLI output.
Jacob Alexander <haata@kiibohd.com>
parents:
diff
changeset
|
906 { |
a30bddad4115
Adding UART and UART + USB muxed CLI output.
Jacob Alexander <haata@kiibohd.com>
parents:
diff
changeset
|
907 print( NL ); |
227
ed05fa3555d4
Updating usbMuxUart for NKRO
Jacob Alexander <haata@kiibohd.com>
parents:
195
diff
changeset
|
908 info_msg("LED State: "); |
172
a30bddad4115
Adding UART and UART + USB muxed CLI output.
Jacob Alexander <haata@kiibohd.com>
parents:
diff
changeset
|
909 printInt8( USBKeys_LEDs ); |
a30bddad4115
Adding UART and UART + USB muxed CLI output.
Jacob Alexander <haata@kiibohd.com>
parents:
diff
changeset
|
910 } |
a30bddad4115
Adding UART and UART + USB muxed CLI output.
Jacob Alexander <haata@kiibohd.com>
parents:
diff
changeset
|
911 |
a30bddad4115
Adding UART and UART + USB muxed CLI output.
Jacob Alexander <haata@kiibohd.com>
parents:
diff
changeset
|
912 |
a30bddad4115
Adding UART and UART + USB muxed CLI output.
Jacob Alexander <haata@kiibohd.com>
parents:
diff
changeset
|
913 void cliFunc_readUART( char* args ) |
a30bddad4115
Adding UART and UART + USB muxed CLI output.
Jacob Alexander <haata@kiibohd.com>
parents:
diff
changeset
|
914 { |
a30bddad4115
Adding UART and UART + USB muxed CLI output.
Jacob Alexander <haata@kiibohd.com>
parents:
diff
changeset
|
915 print( NL ); |
a30bddad4115
Adding UART and UART + USB muxed CLI output.
Jacob Alexander <haata@kiibohd.com>
parents:
diff
changeset
|
916 |
a30bddad4115
Adding UART and UART + USB muxed CLI output.
Jacob Alexander <haata@kiibohd.com>
parents:
diff
changeset
|
917 // Read UART buffer until empty |
a30bddad4115
Adding UART and UART + USB muxed CLI output.
Jacob Alexander <haata@kiibohd.com>
parents:
diff
changeset
|
918 while ( uart_serial_available() > 0 ) |
a30bddad4115
Adding UART and UART + USB muxed CLI output.
Jacob Alexander <haata@kiibohd.com>
parents:
diff
changeset
|
919 { |
a30bddad4115
Adding UART and UART + USB muxed CLI output.
Jacob Alexander <haata@kiibohd.com>
parents:
diff
changeset
|
920 char out[] = { (char)uart_serial_getchar(), '\0' }; |
a30bddad4115
Adding UART and UART + USB muxed CLI output.
Jacob Alexander <haata@kiibohd.com>
parents:
diff
changeset
|
921 dPrint( out ); |
a30bddad4115
Adding UART and UART + USB muxed CLI output.
Jacob Alexander <haata@kiibohd.com>
parents:
diff
changeset
|
922 } |
a30bddad4115
Adding UART and UART + USB muxed CLI output.
Jacob Alexander <haata@kiibohd.com>
parents:
diff
changeset
|
923 } |
a30bddad4115
Adding UART and UART + USB muxed CLI output.
Jacob Alexander <haata@kiibohd.com>
parents:
diff
changeset
|
924 |
a30bddad4115
Adding UART and UART + USB muxed CLI output.
Jacob Alexander <haata@kiibohd.com>
parents:
diff
changeset
|
925 |
a30bddad4115
Adding UART and UART + USB muxed CLI output.
Jacob Alexander <haata@kiibohd.com>
parents:
diff
changeset
|
926 void cliFunc_sendKeys( char* args ) |
a30bddad4115
Adding UART and UART + USB muxed CLI output.
Jacob Alexander <haata@kiibohd.com>
parents:
diff
changeset
|
927 { |
227
ed05fa3555d4
Updating usbMuxUart for NKRO
Jacob Alexander <haata@kiibohd.com>
parents:
195
diff
changeset
|
928 // Copy USBKeys_KeysCLI to USBKeys_Keys |
172
a30bddad4115
Adding UART and UART + USB muxed CLI output.
Jacob Alexander <haata@kiibohd.com>
parents:
diff
changeset
|
929 for ( uint8_t key = 0; key < USBKeys_SentCLI; ++key ) |
a30bddad4115
Adding UART and UART + USB muxed CLI output.
Jacob Alexander <haata@kiibohd.com>
parents:
diff
changeset
|
930 { |
227
ed05fa3555d4
Updating usbMuxUart for NKRO
Jacob Alexander <haata@kiibohd.com>
parents:
195
diff
changeset
|
931 // TODO |
ed05fa3555d4
Updating usbMuxUart for NKRO
Jacob Alexander <haata@kiibohd.com>
parents:
195
diff
changeset
|
932 //USBKeys_Keys[key] = USBKeys_KeysCLI[key]; |
172
a30bddad4115
Adding UART and UART + USB muxed CLI output.
Jacob Alexander <haata@kiibohd.com>
parents:
diff
changeset
|
933 } |
a30bddad4115
Adding UART and UART + USB muxed CLI output.
Jacob Alexander <haata@kiibohd.com>
parents:
diff
changeset
|
934 USBKeys_Sent = USBKeys_SentCLI; |
a30bddad4115
Adding UART and UART + USB muxed CLI output.
Jacob Alexander <haata@kiibohd.com>
parents:
diff
changeset
|
935 |
a30bddad4115
Adding UART and UART + USB muxed CLI output.
Jacob Alexander <haata@kiibohd.com>
parents:
diff
changeset
|
936 // Set modifier byte |
a30bddad4115
Adding UART and UART + USB muxed CLI output.
Jacob Alexander <haata@kiibohd.com>
parents:
diff
changeset
|
937 USBKeys_Modifiers = USBKeys_ModifiersCLI; |
a30bddad4115
Adding UART and UART + USB muxed CLI output.
Jacob Alexander <haata@kiibohd.com>
parents:
diff
changeset
|
938 } |
a30bddad4115
Adding UART and UART + USB muxed CLI output.
Jacob Alexander <haata@kiibohd.com>
parents:
diff
changeset
|
939 |
a30bddad4115
Adding UART and UART + USB muxed CLI output.
Jacob Alexander <haata@kiibohd.com>
parents:
diff
changeset
|
940 |
a30bddad4115
Adding UART and UART + USB muxed CLI output.
Jacob Alexander <haata@kiibohd.com>
parents:
diff
changeset
|
941 void cliFunc_sendUART( char* args ) |
a30bddad4115
Adding UART and UART + USB muxed CLI output.
Jacob Alexander <haata@kiibohd.com>
parents:
diff
changeset
|
942 { |
a30bddad4115
Adding UART and UART + USB muxed CLI output.
Jacob Alexander <haata@kiibohd.com>
parents:
diff
changeset
|
943 // Write all args to UART |
a30bddad4115
Adding UART and UART + USB muxed CLI output.
Jacob Alexander <haata@kiibohd.com>
parents:
diff
changeset
|
944 uart_serial_write( args, lenStr( args ) ); |
a30bddad4115
Adding UART and UART + USB muxed CLI output.
Jacob Alexander <haata@kiibohd.com>
parents:
diff
changeset
|
945 } |
a30bddad4115
Adding UART and UART + USB muxed CLI output.
Jacob Alexander <haata@kiibohd.com>
parents:
diff
changeset
|
946 |
a30bddad4115
Adding UART and UART + USB muxed CLI output.
Jacob Alexander <haata@kiibohd.com>
parents:
diff
changeset
|
947 |
a30bddad4115
Adding UART and UART + USB muxed CLI output.
Jacob Alexander <haata@kiibohd.com>
parents:
diff
changeset
|
948 void cliFunc_setKeys( char* args ) |
a30bddad4115
Adding UART and UART + USB muxed CLI output.
Jacob Alexander <haata@kiibohd.com>
parents:
diff
changeset
|
949 { |
a30bddad4115
Adding UART and UART + USB muxed CLI output.
Jacob Alexander <haata@kiibohd.com>
parents:
diff
changeset
|
950 char* curArgs; |
a30bddad4115
Adding UART and UART + USB muxed CLI output.
Jacob Alexander <haata@kiibohd.com>
parents:
diff
changeset
|
951 char* arg1Ptr; |
a30bddad4115
Adding UART and UART + USB muxed CLI output.
Jacob Alexander <haata@kiibohd.com>
parents:
diff
changeset
|
952 char* arg2Ptr = args; |
a30bddad4115
Adding UART and UART + USB muxed CLI output.
Jacob Alexander <haata@kiibohd.com>
parents:
diff
changeset
|
953 |
a30bddad4115
Adding UART and UART + USB muxed CLI output.
Jacob Alexander <haata@kiibohd.com>
parents:
diff
changeset
|
954 // Parse up to USBKeys_MaxSize args (whichever is least) |
227
ed05fa3555d4
Updating usbMuxUart for NKRO
Jacob Alexander <haata@kiibohd.com>
parents:
195
diff
changeset
|
955 for ( USBKeys_SentCLI = 0; USBKeys_SentCLI < USB_BOOT_MAX_KEYS; ++USBKeys_SentCLI ) |
172
a30bddad4115
Adding UART and UART + USB muxed CLI output.
Jacob Alexander <haata@kiibohd.com>
parents:
diff
changeset
|
956 { |
a30bddad4115
Adding UART and UART + USB muxed CLI output.
Jacob Alexander <haata@kiibohd.com>
parents:
diff
changeset
|
957 curArgs = arg2Ptr; |
a30bddad4115
Adding UART and UART + USB muxed CLI output.
Jacob Alexander <haata@kiibohd.com>
parents:
diff
changeset
|
958 CLI_argumentIsolation( curArgs, &arg1Ptr, &arg2Ptr ); |
a30bddad4115
Adding UART and UART + USB muxed CLI output.
Jacob Alexander <haata@kiibohd.com>
parents:
diff
changeset
|
959 |
a30bddad4115
Adding UART and UART + USB muxed CLI output.
Jacob Alexander <haata@kiibohd.com>
parents:
diff
changeset
|
960 // Stop processing args if no more are found |
a30bddad4115
Adding UART and UART + USB muxed CLI output.
Jacob Alexander <haata@kiibohd.com>
parents:
diff
changeset
|
961 if ( *arg1Ptr == '\0' ) |
a30bddad4115
Adding UART and UART + USB muxed CLI output.
Jacob Alexander <haata@kiibohd.com>
parents:
diff
changeset
|
962 break; |
a30bddad4115
Adding UART and UART + USB muxed CLI output.
Jacob Alexander <haata@kiibohd.com>
parents:
diff
changeset
|
963 |
a30bddad4115
Adding UART and UART + USB muxed CLI output.
Jacob Alexander <haata@kiibohd.com>
parents:
diff
changeset
|
964 // Add the USB code to be sent |
227
ed05fa3555d4
Updating usbMuxUart for NKRO
Jacob Alexander <haata@kiibohd.com>
parents:
195
diff
changeset
|
965 // TODO |
ed05fa3555d4
Updating usbMuxUart for NKRO
Jacob Alexander <haata@kiibohd.com>
parents:
195
diff
changeset
|
966 //USBKeys_KeysCLI[USBKeys_SentCLI] = numToInt( arg1Ptr ); |
172
a30bddad4115
Adding UART and UART + USB muxed CLI output.
Jacob Alexander <haata@kiibohd.com>
parents:
diff
changeset
|
967 } |
a30bddad4115
Adding UART and UART + USB muxed CLI output.
Jacob Alexander <haata@kiibohd.com>
parents:
diff
changeset
|
968 } |
a30bddad4115
Adding UART and UART + USB muxed CLI output.
Jacob Alexander <haata@kiibohd.com>
parents:
diff
changeset
|
969 |
a30bddad4115
Adding UART and UART + USB muxed CLI output.
Jacob Alexander <haata@kiibohd.com>
parents:
diff
changeset
|
970 |
a30bddad4115
Adding UART and UART + USB muxed CLI output.
Jacob Alexander <haata@kiibohd.com>
parents:
diff
changeset
|
971 void cliFunc_setMod( char* args ) |
a30bddad4115
Adding UART and UART + USB muxed CLI output.
Jacob Alexander <haata@kiibohd.com>
parents:
diff
changeset
|
972 { |
a30bddad4115
Adding UART and UART + USB muxed CLI output.
Jacob Alexander <haata@kiibohd.com>
parents:
diff
changeset
|
973 // Parse number from argument |
a30bddad4115
Adding UART and UART + USB muxed CLI output.
Jacob Alexander <haata@kiibohd.com>
parents:
diff
changeset
|
974 // NOTE: Only first argument is used |
a30bddad4115
Adding UART and UART + USB muxed CLI output.
Jacob Alexander <haata@kiibohd.com>
parents:
diff
changeset
|
975 char* arg1Ptr; |
a30bddad4115
Adding UART and UART + USB muxed CLI output.
Jacob Alexander <haata@kiibohd.com>
parents:
diff
changeset
|
976 char* arg2Ptr; |
a30bddad4115
Adding UART and UART + USB muxed CLI output.
Jacob Alexander <haata@kiibohd.com>
parents:
diff
changeset
|
977 CLI_argumentIsolation( args, &arg1Ptr, &arg2Ptr ); |
a30bddad4115
Adding UART and UART + USB muxed CLI output.
Jacob Alexander <haata@kiibohd.com>
parents:
diff
changeset
|
978 |
195
58cfcb7bac88
Changing decToInt to numToInt (adds support for Hex number interpreter)
Jacob Alexander <haata@kiibohd.com>
parents:
192
diff
changeset
|
979 USBKeys_ModifiersCLI = numToInt( arg1Ptr ); |
172
a30bddad4115
Adding UART and UART + USB muxed CLI output.
Jacob Alexander <haata@kiibohd.com>
parents:
diff
changeset
|
980 } |
a30bddad4115
Adding UART and UART + USB muxed CLI output.
Jacob Alexander <haata@kiibohd.com>
parents:
diff
changeset
|
981 |
449
45feb80a2ad1
Major USB update, fixes most (if not all) known issues
Jacob Alexander <haata@kiibohd.com>
parents:
447
diff
changeset
|
982 void cliFunc_usbInitTime( char* args ) |
45feb80a2ad1
Major USB update, fixes most (if not all) known issues
Jacob Alexander <haata@kiibohd.com>
parents:
447
diff
changeset
|
983 { |
45feb80a2ad1
Major USB update, fixes most (if not all) known issues
Jacob Alexander <haata@kiibohd.com>
parents:
447
diff
changeset
|
984 // Calculate overall USB initialization time |
45feb80a2ad1
Major USB update, fixes most (if not all) known issues
Jacob Alexander <haata@kiibohd.com>
parents:
447
diff
changeset
|
985 // XXX A protocol analyzer will be more accurate, however, this is built-in and easier to collect data |
45feb80a2ad1
Major USB update, fixes most (if not all) known issues
Jacob Alexander <haata@kiibohd.com>
parents:
447
diff
changeset
|
986 print(NL); |
45feb80a2ad1
Major USB update, fixes most (if not all) known issues
Jacob Alexander <haata@kiibohd.com>
parents:
447
diff
changeset
|
987 info_msg("USB Init Time: "); |
45feb80a2ad1
Major USB update, fixes most (if not all) known issues
Jacob Alexander <haata@kiibohd.com>
parents:
447
diff
changeset
|
988 printInt32( USBInit_TimeEnd - USBInit_TimeStart ); |
45feb80a2ad1
Major USB update, fixes most (if not all) known issues
Jacob Alexander <haata@kiibohd.com>
parents:
447
diff
changeset
|
989 print(" ms - "); |
45feb80a2ad1
Major USB update, fixes most (if not all) known issues
Jacob Alexander <haata@kiibohd.com>
parents:
447
diff
changeset
|
990 printInt16( USBInit_Ticks ); |
45feb80a2ad1
Major USB update, fixes most (if not all) known issues
Jacob Alexander <haata@kiibohd.com>
parents:
447
diff
changeset
|
991 print(" ticks"); |
45feb80a2ad1
Major USB update, fixes most (if not all) known issues
Jacob Alexander <haata@kiibohd.com>
parents:
447
diff
changeset
|
992 } |
45feb80a2ad1
Major USB update, fixes most (if not all) known issues
Jacob Alexander <haata@kiibohd.com>
parents:
447
diff
changeset
|
993 |