Kiibohd Controller
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
This repo is archived. You can view files and clone it, but cannot push or open issues/pull-requests.

output_com.c 17KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672
  1. /* Copyright (C) 2014-2015 by Jacob Alexander
  2. *
  3. * Permission is hereby granted, free of charge, to any person obtaining a copy
  4. * of this software and associated documentation files (the "Software"), to deal
  5. * in the Software without restriction, including without limitation the rights
  6. * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  7. * copies of the Software, and to permit persons to whom the Software is
  8. * furnished to do so, subject to the following conditions:
  9. *
  10. * The above copyright notice and this permission notice shall be included in
  11. * all copies or substantial portions of the Software.
  12. *
  13. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  14. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  15. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  16. * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  17. * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  18. * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  19. * THE SOFTWARE.
  20. */
  21. // ----- Includes -----
  22. // Compiler Includes
  23. #include <Lib/OutputLib.h>
  24. // Project Includes
  25. #include <cli.h>
  26. #include <led.h>
  27. #include <print.h>
  28. #include <scan_loop.h>
  29. // USB Includes
  30. #if defined(_at90usb162_) || defined(_atmega32u4_) || defined(_at90usb646_) || defined(_at90usb1286_)
  31. #elif defined(_mk20dx128_) || defined(_mk20dx128vlf5_) || defined(_mk20dx256_) || defined(_mk20dx256vlh7_)
  32. #include <arm/uart_serial.h>
  33. #include <arm/usb_dev.h>
  34. #include <arm/usb_keyboard.h>
  35. #include <arm/usb_serial.h>
  36. #endif
  37. // Local Includes
  38. #include "output_com.h"
  39. // ----- Macros -----
  40. // Used to build a bitmap lookup table from a byte addressable array
  41. #define byteLookup( byte ) case (( byte ) * ( 8 )): bytePosition = byte; byteShift = 0; break; \
  42. case (( byte ) * ( 8 ) + ( 1 )): bytePosition = byte; byteShift = 1; break; \
  43. case (( byte ) * ( 8 ) + ( 2 )): bytePosition = byte; byteShift = 2; break; \
  44. case (( byte ) * ( 8 ) + ( 3 )): bytePosition = byte; byteShift = 3; break; \
  45. case (( byte ) * ( 8 ) + ( 4 )): bytePosition = byte; byteShift = 4; break; \
  46. case (( byte ) * ( 8 ) + ( 5 )): bytePosition = byte; byteShift = 5; break; \
  47. case (( byte ) * ( 8 ) + ( 6 )): bytePosition = byte; byteShift = 6; break; \
  48. case (( byte ) * ( 8 ) + ( 7 )): bytePosition = byte; byteShift = 7; break
  49. // ----- Function Declarations -----
  50. void cliFunc_kbdProtocol( char* args );
  51. void cliFunc_readLEDs ( char* args );
  52. void cliFunc_readUART ( char* args );
  53. void cliFunc_sendKeys ( char* args );
  54. void cliFunc_sendUART ( char* args );
  55. void cliFunc_setKeys ( char* args );
  56. void cliFunc_setMod ( char* args );
  57. // ----- Variables -----
  58. // Output Module command dictionary
  59. CLIDict_Entry( kbdProtocol, "Keyboard Protocol Mode: 0 - Boot, 1 - OS/NKRO Mode" );
  60. CLIDict_Entry( readLEDs, "Read LED byte:" NL "\t\t1 NumLck, 2 CapsLck, 4 ScrlLck, 16 Kana, etc." );
  61. CLIDict_Entry( readUART, "Read UART buffer until empty." );
  62. CLIDict_Entry( sendKeys, "Send the prepared list of USB codes and modifier byte." );
  63. CLIDict_Entry( sendUART, "Send characters over UART0." );
  64. CLIDict_Entry( setKeys, "Prepare a space separated list of USB codes (decimal). Waits until \033[35msendKeys\033[0m." );
  65. 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" );
  66. CLIDict_Def( outputCLIDict, "USB Module Commands" ) = {
  67. CLIDict_Item( kbdProtocol ),
  68. CLIDict_Item( readLEDs ),
  69. CLIDict_Item( readUART ),
  70. CLIDict_Item( sendKeys ),
  71. CLIDict_Item( sendUART ),
  72. CLIDict_Item( setKeys ),
  73. CLIDict_Item( setMod ),
  74. { 0, 0, 0 } // Null entry for dictionary end
  75. };
  76. // Which modifier keys are currently pressed
  77. // 1=left ctrl, 2=left shift, 4=left alt, 8=left gui
  78. // 16=right ctrl, 32=right shift, 64=right alt, 128=right gui
  79. uint8_t USBKeys_Modifiers = 0;
  80. uint8_t USBKeys_ModifiersCLI = 0; // Separate CLI send buffer
  81. // Currently pressed keys, max is defined by USB_MAX_KEY_SEND
  82. uint8_t USBKeys_Keys [USB_NKRO_BITFIELD_SIZE_KEYS];
  83. uint8_t USBKeys_KeysCLI[USB_NKRO_BITFIELD_SIZE_KEYS]; // Separate CLI send buffer
  84. // System Control and Consumer Control 1KRO containers
  85. uint8_t USBKeys_SysCtrl;
  86. uint16_t USBKeys_ConsCtrl;
  87. // The number of keys sent to the usb in the array
  88. uint8_t USBKeys_Sent = 0;
  89. uint8_t USBKeys_SentCLI = 0;
  90. // 1=num lock, 2=caps lock, 4=scroll lock, 8=compose, 16=kana
  91. volatile uint8_t USBKeys_LEDs = 0;
  92. // Protocol setting from the host.
  93. // 0 - Boot Mode
  94. // 1 - NKRO Mode (Default, unless set by a BIOS or boot interface)
  95. volatile uint8_t USBKeys_Protocol = 0;
  96. // Indicate if USB should send update
  97. // OS only needs update if there has been a change in state
  98. USBKeyChangeState USBKeys_Changed = USBKeyChangeState_None;
  99. // the idle configuration, how often we send the report to the
  100. // host (ms * 4) even when it hasn't changed
  101. uint8_t USBKeys_Idle_Config = 125;
  102. // count until idle timeout
  103. uint8_t USBKeys_Idle_Count = 0;
  104. // Indicates whether the Output module is fully functional
  105. // 0 - Not fully functional, 1 - Fully functional
  106. // 0 is often used to show that a USB cable is not plugged in (but has power)
  107. uint8_t Output_Available = 0;
  108. // Debug control variable for Output modules
  109. // 0 - Debug disabled (default)
  110. // 1 - Debug enabled
  111. uint8_t Output_DebugMode = 0;
  112. // ----- Capabilities -----
  113. // Set Boot Keyboard Protocol
  114. void Output_kbdProtocolBoot_capability( uint8_t state, uint8_t stateType, uint8_t *args )
  115. {
  116. // Display capability name
  117. if ( stateType == 0xFF && state == 0xFF )
  118. {
  119. print("Output_kbdProtocolBoot()");
  120. return;
  121. }
  122. // Only set if necessary
  123. if ( USBKeys_Protocol == 0 )
  124. return;
  125. // TODO Analog inputs
  126. // Only set on key press
  127. if ( stateType != 0x01 )
  128. return;
  129. // Flush the key buffers
  130. Output_flushBuffers();
  131. // Set the keyboard protocol to Boot Mode
  132. USBKeys_Protocol = 0;
  133. }
  134. // Set NKRO Keyboard Protocol
  135. void Output_kbdProtocolNKRO_capability( uint8_t state, uint8_t stateType, uint8_t *args )
  136. {
  137. // Display capability name
  138. if ( stateType == 0xFF && state == 0xFF )
  139. {
  140. print("Output_kbdProtocolNKRO()");
  141. return;
  142. }
  143. // Only set if necessary
  144. if ( USBKeys_Protocol == 1 )
  145. return;
  146. // TODO Analog inputs
  147. // Only set on key press
  148. if ( stateType != 0x01 )
  149. return;
  150. // Flush the key buffers
  151. Output_flushBuffers();
  152. // Set the keyboard protocol to NKRO Mode
  153. USBKeys_Protocol = 1;
  154. }
  155. // Sends a Consumer Control code to the USB Output buffer
  156. void Output_consCtrlSend_capability( uint8_t state, uint8_t stateType, uint8_t *args )
  157. {
  158. // Display capability name
  159. if ( stateType == 0xFF && state == 0xFF )
  160. {
  161. print("Output_consCtrlSend(consCode)");
  162. return;
  163. }
  164. // Not implemented in Boot Mode
  165. if ( USBKeys_Protocol == 0 )
  166. {
  167. warn_print("Consumer Control is not implemented for Boot Mode");
  168. return;
  169. }
  170. // TODO Analog inputs
  171. // Only indicate USB has changed if either a press or release has occured
  172. if ( state == 0x01 || state == 0x03 )
  173. USBKeys_Changed |= USBKeyChangeState_Consumer;
  174. // Only send keypresses if press or hold state
  175. if ( stateType == 0x00 && state == 0x03 ) // Release state
  176. return;
  177. // Set consumer control code
  178. USBKeys_ConsCtrl = *(uint16_t*)(&args[0]);
  179. }
  180. // Ignores the given key status update
  181. // Used to prevent fall-through, this is the None keyword in KLL
  182. void Output_noneSend_capability( uint8_t state, uint8_t stateType, uint8_t *args )
  183. {
  184. // Display capability name
  185. if ( stateType == 0xFF && state == 0xFF )
  186. {
  187. print("Output_noneSend()");
  188. return;
  189. }
  190. // Nothing to do, because that's the point :P
  191. }
  192. // Sends a System Control code to the USB Output buffer
  193. void Output_sysCtrlSend_capability( uint8_t state, uint8_t stateType, uint8_t *args )
  194. {
  195. // Display capability name
  196. if ( stateType == 0xFF && state == 0xFF )
  197. {
  198. print("Output_sysCtrlSend(sysCode)");
  199. return;
  200. }
  201. // Not implemented in Boot Mode
  202. if ( USBKeys_Protocol == 0 )
  203. {
  204. warn_print("System Control is not implemented for Boot Mode");
  205. return;
  206. }
  207. // TODO Analog inputs
  208. // Only indicate USB has changed if either a press or release has occured
  209. if ( state == 0x01 || state == 0x03 )
  210. USBKeys_Changed |= USBKeyChangeState_System;
  211. // Only send keypresses if press or hold state
  212. if ( stateType == 0x00 && state == 0x03 ) // Release state
  213. return;
  214. // Set system control code
  215. USBKeys_SysCtrl = args[0];
  216. }
  217. // Adds a single USB Code to the USB Output buffer
  218. // Argument #1: USB Code
  219. void Output_usbCodeSend_capability( uint8_t state, uint8_t stateType, uint8_t *args )
  220. {
  221. // Display capability name
  222. if ( stateType == 0xFF && state == 0xFF )
  223. {
  224. print("Output_usbCodeSend(usbCode)");
  225. return;
  226. }
  227. // Depending on which mode the keyboard is in the USB needs Press/Hold/Release events
  228. uint8_t keyPress = 0; // Default to key release, only used for NKRO
  229. switch ( USBKeys_Protocol )
  230. {
  231. case 0: // Boot Mode
  232. // TODO Analog inputs
  233. // Only indicate USB has changed if either a press or release has occured
  234. if ( state == 0x01 || state == 0x03 )
  235. USBKeys_Changed = USBKeyChangeState_MainKeys;
  236. // Only send keypresses if press or hold state
  237. if ( stateType == 0x00 && state == 0x03 ) // Release state
  238. return;
  239. break;
  240. case 1: // NKRO Mode
  241. // Only send press and release events
  242. if ( stateType == 0x00 && state == 0x02 ) // Hold state
  243. return;
  244. // Determine if setting or unsetting the bitfield (press == set)
  245. if ( stateType == 0x00 && state == 0x01 ) // Press state
  246. keyPress = 1;
  247. break;
  248. }
  249. // Get the keycode from arguments
  250. uint8_t key = args[0];
  251. // Depending on which mode the keyboard is in, USBKeys_Keys array is used differently
  252. // Boot mode - Maximum of 6 byte codes
  253. // NKRO mode - Each bit of the 26 byte corresponds to a key
  254. // Bits 0 - 160 (first 20 bytes) correspond to USB Codes 4 - 164
  255. // Bits 161 - 205 (last 6 bytes) correspond to USB Codes 176 - 221
  256. // Bits 206 - 208 (last byte) correspond to the 3 padded bits in USB (unused)
  257. uint8_t bytePosition = 0;
  258. uint8_t byteShift = 0;
  259. switch ( USBKeys_Protocol )
  260. {
  261. case 0: // Boot Mode
  262. // Set the modifier bit if this key is a modifier
  263. if ( (key & 0xE0) == 0xE0 ) // AND with 0xE0 (Left Ctrl, first modifier)
  264. {
  265. USBKeys_Modifiers |= 1 << (key ^ 0xE0); // Left shift 1 by key XOR 0xE0
  266. }
  267. // Normal USB Code
  268. else
  269. {
  270. // USB Key limit reached
  271. if ( USBKeys_Sent >= USB_BOOT_MAX_KEYS )
  272. {
  273. warn_print("USB Key limit reached");
  274. return;
  275. }
  276. // Make sure key is within the USB HID range
  277. if ( key <= 104 )
  278. {
  279. USBKeys_Keys[USBKeys_Sent++] = key;
  280. }
  281. // Invalid key
  282. else
  283. {
  284. warn_msg("USB Code above 104/0x68 in Boot Mode: ");
  285. printHex( key );
  286. print( NL );
  287. }
  288. }
  289. break;
  290. case 1: // NKRO Mode
  291. // Set the modifier bit if this key is a modifier
  292. if ( (key & 0xE0) == 0xE0 ) // AND with 0xE0 (Left Ctrl, first modifier)
  293. {
  294. if ( keyPress )
  295. {
  296. USBKeys_Modifiers |= 1 << (key ^ 0xE0); // Left shift 1 by key XOR 0xE0
  297. }
  298. else // Release
  299. {
  300. USBKeys_Modifiers &= ~(1 << (key ^ 0xE0)); // Left shift 1 by key XOR 0xE0
  301. }
  302. USBKeys_Changed |= USBKeyChangeState_Modifiers;
  303. break;
  304. }
  305. // First 20 bytes
  306. else if ( key >= 4 && key <= 164 )
  307. {
  308. // Lookup (otherwise division or multiple checks are needed to do alignment)
  309. uint8_t keyPos = key - 4; // Starting position in array
  310. switch ( keyPos )
  311. {
  312. byteLookup( 0 );
  313. byteLookup( 1 );
  314. byteLookup( 2 );
  315. byteLookup( 3 );
  316. byteLookup( 4 );
  317. byteLookup( 5 );
  318. byteLookup( 6 );
  319. byteLookup( 7 );
  320. byteLookup( 8 );
  321. byteLookup( 9 );
  322. byteLookup( 10 );
  323. byteLookup( 11 );
  324. byteLookup( 12 );
  325. byteLookup( 13 );
  326. byteLookup( 14 );
  327. byteLookup( 15 );
  328. byteLookup( 16 );
  329. byteLookup( 17 );
  330. byteLookup( 18 );
  331. byteLookup( 19 );
  332. }
  333. USBKeys_Changed |= USBKeyChangeState_MainKeys;
  334. }
  335. // Last 6 bytes
  336. else if ( key >= 176 && key <= 221 )
  337. {
  338. // Lookup (otherwise division or multiple checks are needed to do alignment)
  339. uint8_t keyPos = key - 176; // Starting position in array
  340. switch ( keyPos )
  341. {
  342. byteLookup( 20 );
  343. byteLookup( 21 );
  344. byteLookup( 22 );
  345. byteLookup( 23 );
  346. byteLookup( 24 );
  347. byteLookup( 25 );
  348. }
  349. USBKeys_Changed |= USBKeyChangeState_SecondaryKeys;
  350. }
  351. // Invalid key
  352. else
  353. {
  354. warn_msg("USB Code not within 4-164 (0x4-0xA4) or 176-221 (0xB0-0xDD) NKRO Mode: ");
  355. printHex( key );
  356. print( NL );
  357. break;
  358. }
  359. // Set/Unset
  360. if ( keyPress )
  361. {
  362. USBKeys_Keys[bytePosition] |= (1 << byteShift);
  363. USBKeys_Sent++;
  364. }
  365. else // Release
  366. {
  367. USBKeys_Keys[bytePosition] &= ~(1 << byteShift);
  368. USBKeys_Sent++;
  369. }
  370. break;
  371. }
  372. }
  373. // ----- Functions -----
  374. // Flush Key buffers
  375. void Output_flushBuffers()
  376. {
  377. // Zero out USBKeys_Keys array
  378. for ( uint8_t c = 0; c < USB_NKRO_BITFIELD_SIZE_KEYS; c++ )
  379. USBKeys_Keys[ c ] = 0;
  380. // Zero out other key buffers
  381. USBKeys_ConsCtrl = 0;
  382. USBKeys_Modifiers = 0;
  383. USBKeys_SysCtrl = 0;
  384. }
  385. // USB Module Setup
  386. inline void Output_setup()
  387. {
  388. // Setup UART
  389. uart_serial_setup();
  390. print("\033[2J"); // Clear screen
  391. // Initialize the USB, and then wait for the host to set configuration.
  392. // This will hang forever if USB does not initialize
  393. usb_init();
  394. while ( !usb_configured() );
  395. // Register USB Output CLI dictionary
  396. CLI_registerDictionary( outputCLIDict, outputCLIDictName );
  397. // Zero out USBKeys_Keys array
  398. for ( uint8_t c = 0; c < USB_NKRO_BITFIELD_SIZE_KEYS; c++ )
  399. USBKeys_Keys[ c ] = 0;
  400. }
  401. // USB Data Send
  402. inline void Output_send()
  403. {
  404. // Boot Mode Only, unset stale keys
  405. if ( USBKeys_Protocol == 0 )
  406. for ( uint8_t c = USBKeys_Sent; c < USB_BOOT_MAX_KEYS; c++ )
  407. USBKeys_Keys[c] = 0;
  408. // Send keypresses while there are pending changes
  409. while ( USBKeys_Changed )
  410. usb_keyboard_send();
  411. // Clear modifiers and keys
  412. USBKeys_Modifiers = 0;
  413. USBKeys_Sent = 0;
  414. // Signal Scan Module we are finished
  415. switch ( USBKeys_Protocol )
  416. {
  417. case 0: // Boot Mode
  418. Scan_finishedWithOutput( USBKeys_Sent <= USB_BOOT_MAX_KEYS ? USBKeys_Sent : USB_BOOT_MAX_KEYS );
  419. break;
  420. case 1: // NKRO Mode
  421. Scan_finishedWithOutput( USBKeys_Sent );
  422. break;
  423. }
  424. }
  425. // Sets the device into firmware reload mode
  426. inline void Output_firmwareReload()
  427. {
  428. uart_device_reload();
  429. }
  430. // USB Input buffer available
  431. inline unsigned int Output_availablechar()
  432. {
  433. return usb_serial_available() + uart_serial_available();
  434. }
  435. // USB Get Character from input buffer
  436. inline int Output_getchar()
  437. {
  438. // XXX Make sure to check output_availablechar() first! Information is lost with the cast (error codes) (AVR)
  439. if ( usb_serial_available() > 0 )
  440. {
  441. return (int)usb_serial_getchar();
  442. }
  443. if ( uart_serial_available() > 0 )
  444. {
  445. return (int)uart_serial_getchar();
  446. }
  447. return -1;
  448. }
  449. // USB Send Character to output buffer
  450. inline int Output_putchar( char c )
  451. {
  452. // First send to UART
  453. uart_serial_putchar( c );
  454. // Then send to USB
  455. return usb_serial_putchar( c );
  456. }
  457. // USB Send String to output buffer, null terminated
  458. inline int Output_putstr( char* str )
  459. {
  460. #if defined(_at90usb162_) || defined(_atmega32u4_) || defined(_at90usb646_) || defined(_at90usb1286_) // AVR
  461. uint16_t count = 0;
  462. #elif defined(_mk20dx128_) || defined(_mk20dx128vlf5_) || defined(_mk20dx256_) || defined(_mk20dx256vlh7_) // ARM
  463. uint32_t count = 0;
  464. #endif
  465. // Count characters until NULL character, then send the amount counted
  466. while ( str[count] != '\0' )
  467. count++;
  468. // First send to UART
  469. uart_serial_write( str, count );
  470. // Then send to USB
  471. return usb_serial_write( str, count );
  472. }
  473. // Soft Chip Reset
  474. inline void Output_softReset()
  475. {
  476. usb_device_software_reset();
  477. }
  478. // ----- CLI Command Functions -----
  479. void cliFunc_kbdProtocol( char* args )
  480. {
  481. print( NL );
  482. info_msg("Keyboard Protocol: ");
  483. printInt8( USBKeys_Protocol );
  484. }
  485. void cliFunc_readLEDs( char* args )
  486. {
  487. print( NL );
  488. info_msg("LED State: ");
  489. printInt8( USBKeys_LEDs );
  490. }
  491. void cliFunc_readUART( char* args )
  492. {
  493. print( NL );
  494. // Read UART buffer until empty
  495. while ( uart_serial_available() > 0 )
  496. {
  497. char out[] = { (char)uart_serial_getchar(), '\0' };
  498. dPrint( out );
  499. }
  500. }
  501. void cliFunc_sendKeys( char* args )
  502. {
  503. // Copy USBKeys_KeysCLI to USBKeys_Keys
  504. for ( uint8_t key = 0; key < USBKeys_SentCLI; ++key )
  505. {
  506. // TODO
  507. //USBKeys_Keys[key] = USBKeys_KeysCLI[key];
  508. }
  509. USBKeys_Sent = USBKeys_SentCLI;
  510. // Set modifier byte
  511. USBKeys_Modifiers = USBKeys_ModifiersCLI;
  512. }
  513. void cliFunc_sendUART( char* args )
  514. {
  515. // Write all args to UART
  516. uart_serial_write( args, lenStr( args ) );
  517. }
  518. void cliFunc_setKeys( char* args )
  519. {
  520. char* curArgs;
  521. char* arg1Ptr;
  522. char* arg2Ptr = args;
  523. // Parse up to USBKeys_MaxSize args (whichever is least)
  524. for ( USBKeys_SentCLI = 0; USBKeys_SentCLI < USB_BOOT_MAX_KEYS; ++USBKeys_SentCLI )
  525. {
  526. curArgs = arg2Ptr;
  527. CLI_argumentIsolation( curArgs, &arg1Ptr, &arg2Ptr );
  528. // Stop processing args if no more are found
  529. if ( *arg1Ptr == '\0' )
  530. break;
  531. // Add the USB code to be sent
  532. // TODO
  533. //USBKeys_KeysCLI[USBKeys_SentCLI] = numToInt( arg1Ptr );
  534. }
  535. }
  536. void cliFunc_setMod( char* args )
  537. {
  538. // Parse number from argument
  539. // NOTE: Only first argument is used
  540. char* arg1Ptr;
  541. char* arg2Ptr;
  542. CLI_argumentIsolation( args, &arg1Ptr, &arg2Ptr );
  543. USBKeys_ModifiersCLI = numToInt( arg1Ptr );
  544. }