Mercurial > louis > kiibohd-controller
comparison Output/usbMuxUart/output_com.c @ 438:f10c2dad7f55
Adding missing GET_PROTOCOL handling
- Odd that this went unnoticed for sooooo long
- Fixes Mac OSX issue where keyboard freezes/hangs on a reboot
- Also adding missing code for usbMuxUart
author | Jacob Alexander <haata@kiibohd.com> |
---|---|
date | Mon, 16 May 2016 23:25:08 -0700 |
parents | 23a1868b4ac2 |
children | 68e19d7c953e |
comparison
equal
deleted
inserted
replaced
437:da28cecc0b5b | 438:f10c2dad7f55 |
---|---|
37 #include <arm/usb_dev.h> | 37 #include <arm/usb_dev.h> |
38 #include <arm/usb_keyboard.h> | 38 #include <arm/usb_keyboard.h> |
39 #include <arm/usb_serial.h> | 39 #include <arm/usb_serial.h> |
40 #endif | 40 #endif |
41 | 41 |
42 // KLL | |
43 #include <kll_defs.h> | |
44 | |
42 // Local Includes | 45 // Local Includes |
43 #include "output_com.h" | 46 #include "output_com.h" |
44 | 47 |
45 | 48 |
46 | 49 |
115 uint8_t USBKeys_SentCLI = 0; | 118 uint8_t USBKeys_SentCLI = 0; |
116 | 119 |
117 // 1=num lock, 2=caps lock, 4=scroll lock, 8=compose, 16=kana | 120 // 1=num lock, 2=caps lock, 4=scroll lock, 8=compose, 16=kana |
118 volatile uint8_t USBKeys_LEDs = 0; | 121 volatile uint8_t USBKeys_LEDs = 0; |
119 | 122 |
123 // Currently pressed mouse buttons, bitmask, 0 represents no buttons pressed | |
124 volatile uint16_t USBMouse_Buttons = 0; | |
125 | |
126 // Relative mouse axis movement, stores pending movement | |
127 volatile uint16_t USBMouse_Relative_x = 0; | |
128 volatile uint16_t USBMouse_Relative_y = 0; | |
129 | |
120 // Protocol setting from the host. | 130 // Protocol setting from the host. |
121 // 0 - Boot Mode | 131 // 0 - Boot Mode |
122 // 1 - NKRO Mode (Default, unless set by a BIOS or boot interface) | 132 // 1 - NKRO Mode (Default, unless set by a BIOS or boot interface) |
123 volatile uint8_t USBKeys_Protocol = 1; | 133 volatile uint8_t USBKeys_Protocol = USBProtocol_define; |
124 | 134 |
125 // Indicate if USB should send update | 135 // Indicate if USB should send update |
126 // OS only needs update if there has been a change in state | 136 // OS only needs update if there has been a change in state |
127 USBKeyChangeState USBKeys_Changed = USBKeyChangeState_None; | 137 USBKeyChangeState USBKeys_Changed = USBKeyChangeState_None; |
138 | |
139 // Indicate if USB should send update | |
140 USBMouseChangeState USBMouse_Changed = 0; | |
128 | 141 |
129 // the idle configuration, how often we send the report to the | 142 // the idle configuration, how often we send the report to the |
130 // host (ms * 4) even when it hasn't changed | 143 // host (ms * 4) even when it hasn't changed |
131 uint8_t USBKeys_Idle_Config = 125; | 144 uint8_t USBKeys_Idle_Config = 125; |
132 | 145 |
509 | 522 |
510 // Start flash mode | 523 // Start flash mode |
511 Output_firmwareReload(); | 524 Output_firmwareReload(); |
512 } | 525 } |
513 | 526 |
527 // Sends a mouse command over the USB Output buffer | |
528 // XXX This function *will* be changing in the future | |
529 // If you use it, be prepared that your .kll files will break in the future (post KLL 0.5) | |
530 // Argument #1: USB Mouse Button (16 bit) | |
531 // Argument #2: USB X Axis (16 bit) relative | |
532 // Argument #3: USB Y Axis (16 bit) relative | |
533 void Output_usbMouse_capability( uint8_t state, uint8_t stateType, uint8_t *args ) | |
534 { | |
535 // Display capability name | |
536 if ( stateType == 0xFF && state == 0xFF ) | |
537 { | |
538 print("Output_usbMouse(mouseButton,relX,relY)"); | |
539 return; | |
540 } | |
541 | |
542 // Determine which mouse button was sent | |
543 // The USB spec defines up to a max of 0xFFFF buttons | |
544 // The usual are: | |
545 // 1 - Button 1 - (Primary) | |
546 // 2 - Button 2 - (Secondary) | |
547 // 3 - Button 3 - (Tertiary) | |
548 uint16_t mouse_button = *(uint16_t*)(&args[0]); | |
549 | |
550 // X/Y Relative Axis | |
551 uint16_t mouse_x = *(uint16_t*)(&args[2]); | |
552 uint16_t mouse_y = *(uint16_t*)(&args[4]); | |
553 | |
554 // Adjust for bit shift | |
555 uint16_t mouse_button_shift = mouse_button - 1; | |
556 | |
557 // Only send mouse button if in press or hold state | |
558 if ( stateType == 0x00 && state == 0x03 ) // Release state | |
559 { | |
560 // Release | |
561 if ( mouse_button ) | |
562 USBMouse_Buttons &= ~(1 << mouse_button_shift); | |
563 } | |
564 else | |
565 { | |
566 // Press or hold | |
567 if ( mouse_button ) | |
568 USBMouse_Buttons |= (1 << mouse_button_shift); | |
569 | |
570 if ( mouse_x ) | |
571 USBMouse_Relative_x = mouse_x; | |
572 if ( mouse_y ) | |
573 USBMouse_Relative_y = mouse_y; | |
574 } | |
575 | |
576 // Trigger updates | |
577 if ( mouse_button ) | |
578 USBMouse_Changed |= USBMouseChangeState_Buttons; | |
579 | |
580 if ( mouse_x || mouse_y ) | |
581 USBMouse_Changed |= USBMouseChangeState_Relative; | |
582 } | |
583 | |
514 | 584 |
515 | 585 |
516 // ----- Functions ----- | 586 // ----- Functions ----- |
517 | 587 |
518 // Flush Key buffers | 588 // Flush Key buffers |