diff options
Diffstat (limited to 'tmk_core')
| -rw-r--r-- | tmk_core/avr.mk | 42 | ||||
| -rw-r--r-- | tmk_core/chibios.mk | 4 | ||||
| -rw-r--r-- | tmk_core/common/action.c | 53 | ||||
| -rw-r--r-- | tmk_core/common/keyboard.c | 58 | ||||
| -rw-r--r-- | tmk_core/common/keyboard.h | 1 | ||||
| -rw-r--r-- | tmk_core/protocol/ps2_mouse.c | 29 |
6 files changed, 133 insertions, 54 deletions
diff --git a/tmk_core/avr.mk b/tmk_core/avr.mk index 5df539def..ccecdb192 100644 --- a/tmk_core/avr.mk +++ b/tmk_core/avr.mk | |||
| @@ -89,9 +89,9 @@ DEBUG_HOST = localhost | |||
| 89 | #============================================================================ | 89 | #============================================================================ |
| 90 | # Autodecct teensy loader | 90 | # Autodecct teensy loader |
| 91 | ifneq (, $(shell which teensy-loader-cli 2>/dev/null)) | 91 | ifneq (, $(shell which teensy-loader-cli 2>/dev/null)) |
| 92 | TEENSY_LOADER_CLI = teensy-loader-cli | 92 | TEENSY_LOADER_CLI ?= teensy-loader-cli |
| 93 | else | 93 | else |
| 94 | TEENSY_LOADER_CLI = teensy_loader_cli | 94 | TEENSY_LOADER_CLI ?= teensy_loader_cli |
| 95 | endif | 95 | endif |
| 96 | 96 | ||
| 97 | # Program the device. | 97 | # Program the device. |
| @@ -100,43 +100,47 @@ program: $(BUILD_DIR)/$(TARGET).hex $(BUILD_DIR)/$(TARGET).eep | |||
| 100 | 100 | ||
| 101 | teensy: $(BUILD_DIR)/$(TARGET).hex | 101 | teensy: $(BUILD_DIR)/$(TARGET).hex |
| 102 | $(TEENSY_LOADER_CLI) -mmcu=$(MCU) -w -v $(BUILD_DIR)/$(TARGET).hex | 102 | $(TEENSY_LOADER_CLI) -mmcu=$(MCU) -w -v $(BUILD_DIR)/$(TARGET).hex |
| 103 | |||
| 104 | BATCHISP ?= batchisp | ||
| 103 | 105 | ||
| 104 | flip: $(BUILD_DIR)/$(TARGET).hex | 106 | flip: $(BUILD_DIR)/$(TARGET).hex |
| 105 | batchisp -hardware usb -device $(MCU) -operation erase f | 107 | $(BATCHISP) -hardware usb -device $(MCU) -operation erase f |
| 106 | batchisp -hardware usb -device $(MCU) -operation loadbuffer $(BUILD_DIR)/$(TARGET).hex program | 108 | $(BATCHISP) -hardware usb -device $(MCU) -operation loadbuffer $(BUILD_DIR)/$(TARGET).hex program |
| 107 | batchisp -hardware usb -device $(MCU) -operation start reset 0 | 109 | $(BATCHISP) -hardware usb -device $(MCU) -operation start reset 0 |
| 110 | |||
| 111 | DFU_PROGRAMMER ?= dfu-programmer | ||
| 108 | 112 | ||
| 109 | dfu: $(BUILD_DIR)/$(TARGET).hex sizeafter | 113 | dfu: $(BUILD_DIR)/$(TARGET).hex sizeafter |
| 110 | until dfu-programmer $(MCU) get bootloader-version; do\ | 114 | until $(DFU_PROGRAMMER) $(MCU) get bootloader-version; do\ |
| 111 | echo "Error: Bootloader not found. Trying again in 5s." ;\ | 115 | echo "Error: Bootloader not found. Trying again in 5s." ;\ |
| 112 | sleep 5 ;\ | 116 | sleep 5 ;\ |
| 113 | done | 117 | done |
| 114 | ifneq (, $(findstring 0.7, $(shell dfu-programmer --version 2>&1))) | 118 | ifneq (, $(findstring 0.7, $(shell $(DFU_PROGRAMMER) --version 2>&1))) |
| 115 | dfu-programmer $(MCU) erase --force | 119 | $(DFU_PROGRAMMER) $(MCU) erase --force |
| 116 | else | 120 | else |
| 117 | dfu-programmer $(MCU) erase | 121 | $(DFU_PROGRAMMER) $(MCU) erase |
| 118 | endif | 122 | endif |
| 119 | dfu-programmer $(MCU) flash $(BUILD_DIR)/$(TARGET).hex | 123 | $(DFU_PROGRAMMER) $(MCU) flash $(BUILD_DIR)/$(TARGET).hex |
| 120 | dfu-programmer $(MCU) reset | 124 | $(DFU_PROGRAMMER) $(MCU) reset |
| 121 | 125 | ||
| 122 | dfu-start: | 126 | dfu-start: |
| 123 | dfu-programmer $(MCU) reset | 127 | $(DFU_PROGRAMMER) $(MCU) reset |
| 124 | dfu-programmer $(MCU) start | 128 | $(DFU_PROGRAMMER) $(MCU) start |
| 125 | 129 | ||
| 126 | flip-ee: $(BUILD_DIR)/$(TARGET).hex $(BUILD_DIR)/$(TARGET).eep | 130 | flip-ee: $(BUILD_DIR)/$(TARGET).hex $(BUILD_DIR)/$(TARGET).eep |
| 127 | $(COPY) $(BUILD_DIR)/$(TARGET).eep $(BUILD_DIR)/$(TARGET)eep.hex | 131 | $(COPY) $(BUILD_DIR)/$(TARGET).eep $(BUILD_DIR)/$(TARGET)eep.hex |
| 128 | batchisp -hardware usb -device $(MCU) -operation memory EEPROM erase | 132 | $(BATCHISP) -hardware usb -device $(MCU) -operation memory EEPROM erase |
| 129 | batchisp -hardware usb -device $(MCU) -operation memory EEPROM loadbuffer $(BUILD_DIR)/$(TARGET)eep.hex program | 133 | $(BATCHISP) -hardware usb -device $(MCU) -operation memory EEPROM loadbuffer $(BUILD_DIR)/$(TARGET)eep.hex program |
| 130 | batchisp -hardware usb -device $(MCU) -operation start reset 0 | 134 | $(BATCHISP) -hardware usb -device $(MCU) -operation start reset 0 |
| 131 | $(REMOVE) $(BUILD_DIR)/$(TARGET)eep.hex | 135 | $(REMOVE) $(BUILD_DIR)/$(TARGET)eep.hex |
| 132 | 136 | ||
| 133 | dfu-ee: $(BUILD_DIR)/$(TARGET).hex $(BUILD_DIR)/$(TARGET).eep | 137 | dfu-ee: $(BUILD_DIR)/$(TARGET).hex $(BUILD_DIR)/$(TARGET).eep |
| 134 | ifneq (, $(findstring 0.7, $(shell dfu-programmer --version 2>&1))) | 138 | ifneq (, $(findstring 0.7, $(shell dfu-programmer --version 2>&1))) |
| 135 | dfu-programmer $(MCU) flash --eeprom $(BUILD_DIR)/$(TARGET).eep | 139 | $(DFU_PROGRAMMER) $(MCU) flash --eeprom $(BUILD_DIR)/$(TARGET).eep |
| 136 | else | 140 | else |
| 137 | dfu-programmer $(MCU) flash-eeprom $(BUILD_DIR)/$(TARGET).eep | 141 | $(DFU_PROGRAMMER) $(MCU) flash-eeprom $(BUILD_DIR)/$(TARGET).eep |
| 138 | endif | 142 | endif |
| 139 | dfu-programmer $(MCU) reset | 143 | $(DFU_PROGRAMMER) $(MCU) reset |
| 140 | 144 | ||
| 141 | # Convert hex to bin. | 145 | # Convert hex to bin. |
| 142 | flashbin: $(BUILD_DIR)/$(TARGET).hex | 146 | flashbin: $(BUILD_DIR)/$(TARGET).hex |
diff --git a/tmk_core/chibios.mk b/tmk_core/chibios.mk index eb0c40138..2a8d32fb9 100644 --- a/tmk_core/chibios.mk +++ b/tmk_core/chibios.mk | |||
| @@ -151,5 +151,7 @@ endif | |||
| 151 | # List any extra directories to look for libraries here. | 151 | # List any extra directories to look for libraries here. |
| 152 | EXTRALIBDIRS = $(RULESPATH)/ld | 152 | EXTRALIBDIRS = $(RULESPATH)/ld |
| 153 | 153 | ||
| 154 | DFU_UTIL ?= dfu-util | ||
| 155 | |||
| 154 | dfu-util: $(BUILD_DIR)/$(TARGET).bin sizeafter | 156 | dfu-util: $(BUILD_DIR)/$(TARGET).bin sizeafter |
| 155 | dfu-util $(DFU_ARGS) -D $(BUILD_DIR)/$(TARGET).bin | 157 | $(DFU_UTIL) $(DFU_ARGS) -D $(BUILD_DIR)/$(TARGET).bin |
diff --git a/tmk_core/common/action.c b/tmk_core/common/action.c index 4ba1cc251..f73b0fe80 100644 --- a/tmk_core/common/action.c +++ b/tmk_core/common/action.c | |||
| @@ -26,6 +26,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. | |||
| 26 | #include "action_macro.h" | 26 | #include "action_macro.h" |
| 27 | #include "action_util.h" | 27 | #include "action_util.h" |
| 28 | #include "action.h" | 28 | #include "action.h" |
| 29 | #include "wait.h" | ||
| 29 | 30 | ||
| 30 | #ifdef DEBUG_ACTION | 31 | #ifdef DEBUG_ACTION |
| 31 | #include "debug.h" | 32 | #include "debug.h" |
| @@ -33,6 +34,8 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. | |||
| 33 | #include "nodebug.h" | 34 | #include "nodebug.h" |
| 34 | #endif | 35 | #endif |
| 35 | 36 | ||
| 37 | int tp_buttons; | ||
| 38 | |||
| 36 | #ifdef FAUXCLICKY_ENABLE | 39 | #ifdef FAUXCLICKY_ENABLE |
| 37 | #include <fauxclicky.h> | 40 | #include <fauxclicky.h> |
| 38 | #endif | 41 | #endif |
| @@ -310,11 +313,35 @@ void process_action(keyrecord_t *record, action_t action) | |||
| 310 | /* Mouse key */ | 313 | /* Mouse key */ |
| 311 | case ACT_MOUSEKEY: | 314 | case ACT_MOUSEKEY: |
| 312 | if (event.pressed) { | 315 | if (event.pressed) { |
| 313 | mousekey_on(action.key.code); | 316 | switch (action.key.code) { |
| 314 | mousekey_send(); | 317 | case KC_MS_BTN1: |
| 318 | tp_buttons |= (1<<0); | ||
| 319 | break; | ||
| 320 | case KC_MS_BTN2: | ||
| 321 | tp_buttons |= (1<<1); | ||
| 322 | break; | ||
| 323 | case KC_MS_BTN3: | ||
| 324 | tp_buttons |= (1<<2); | ||
| 325 | break; | ||
| 326 | default: | ||
| 327 | mousekey_on(action.key.code); | ||
| 328 | mousekey_send(); | ||
| 329 | } | ||
| 315 | } else { | 330 | } else { |
| 316 | mousekey_off(action.key.code); | 331 | switch (action.key.code) { |
| 317 | mousekey_send(); | 332 | case KC_MS_BTN1: |
| 333 | tp_buttons &= ~(1<<0); | ||
| 334 | break; | ||
| 335 | case KC_MS_BTN2: | ||
| 336 | tp_buttons &= ~(1<<1); | ||
| 337 | break; | ||
| 338 | case KC_MS_BTN3: | ||
| 339 | tp_buttons &= ~(1<<2); | ||
| 340 | break; | ||
| 341 | default: | ||
| 342 | mousekey_off(action.key.code); | ||
| 343 | mousekey_send(); | ||
| 344 | } | ||
| 318 | } | 345 | } |
| 319 | break; | 346 | break; |
| 320 | #endif | 347 | #endif |
| @@ -438,6 +465,9 @@ void process_action(keyrecord_t *record, action_t action) | |||
| 438 | } else { | 465 | } else { |
| 439 | if (tap_count > 0) { | 466 | if (tap_count > 0) { |
| 440 | dprint("KEYMAP_TAP_KEY: Tap: unregister_code\n"); | 467 | dprint("KEYMAP_TAP_KEY: Tap: unregister_code\n"); |
| 468 | if (action.layer_tap.code == KC_CAPS) { | ||
| 469 | wait_ms(80); | ||
| 470 | } | ||
| 441 | unregister_code(action.layer_tap.code); | 471 | unregister_code(action.layer_tap.code); |
| 442 | } else { | 472 | } else { |
| 443 | dprint("KEYMAP_TAP_KEY: No tap: Off on release\n"); | 473 | dprint("KEYMAP_TAP_KEY: No tap: Off on release\n"); |
| @@ -537,6 +567,21 @@ void process_action(keyrecord_t *record, action_t action) | |||
| 537 | break; | 567 | break; |
| 538 | } | 568 | } |
| 539 | 569 | ||
| 570 | #ifndef NO_ACTION_LAYER | ||
| 571 | // if this event is a layer action, update the leds | ||
| 572 | switch (action.kind.id) { | ||
| 573 | case ACT_LAYER: | ||
| 574 | #ifndef NO_ACTION_TAPPING | ||
| 575 | case ACT_LAYER_TAP: | ||
| 576 | case ACT_LAYER_TAP_EXT: | ||
| 577 | #endif | ||
| 578 | led_set(host_keyboard_leds()); | ||
| 579 | break; | ||
| 580 | default: | ||
| 581 | break; | ||
| 582 | } | ||
| 583 | #endif | ||
| 584 | |||
| 540 | #ifndef NO_ACTION_ONESHOT | 585 | #ifndef NO_ACTION_ONESHOT |
| 541 | /* Because we switch layers after a oneshot event, we need to release the | 586 | /* Because we switch layers after a oneshot event, we need to release the |
| 542 | * key before we leave the layer or no key up event will be generated. | 587 | * key before we leave the layer or no key up event will be generated. |
diff --git a/tmk_core/common/keyboard.c b/tmk_core/common/keyboard.c index eac1f1dd8..97a8f1cd8 100644 --- a/tmk_core/common/keyboard.c +++ b/tmk_core/common/keyboard.c | |||
| @@ -61,23 +61,51 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. | |||
| 61 | # include "visualizer/visualizer.h" | 61 | # include "visualizer/visualizer.h" |
| 62 | #endif | 62 | #endif |
| 63 | 63 | ||
| 64 | #ifdef MATRIX_HAS_GHOST | ||
| 65 | extern const uint16_t keymaps[][MATRIX_ROWS][MATRIX_COLS]; | ||
| 66 | static matrix_row_t get_real_keys(uint8_t row, matrix_row_t rowdata){ | ||
| 67 | matrix_row_t out = 0; | ||
| 68 | for (uint8_t col = 0; col < MATRIX_COLS; col++) { | ||
| 69 | //read each key in the row data and check if the keymap defines it as a real key | ||
| 70 | if (pgm_read_byte(&keymaps[0][row][col]) && (rowdata & (1<<col))){ | ||
| 71 | //this creates new row data, if a key is defined in the keymap, it will be set here | ||
| 72 | out |= 1<<col; | ||
| 73 | } | ||
| 74 | } | ||
| 75 | return out; | ||
| 76 | } | ||
| 64 | 77 | ||
| 78 | static inline bool popcount_more_than_one(matrix_row_t rowdata) | ||
| 79 | { | ||
| 80 | rowdata &= rowdata-1; //if there are less than two bits (keys) set, rowdata will become zero | ||
| 81 | return rowdata; | ||
| 82 | } | ||
| 65 | 83 | ||
| 66 | #ifdef MATRIX_HAS_GHOST | 84 | static inline bool has_ghost_in_row(uint8_t row, matrix_row_t rowdata) |
| 67 | static bool has_ghost_in_row(uint8_t row) | ||
| 68 | { | 85 | { |
| 69 | matrix_row_t matrix_row = matrix_get_row(row); | 86 | /* No ghost exists when less than 2 keys are down on the row. |
| 70 | // No ghost exists when less than 2 keys are down on the row | 87 | If there are "active" blanks in the matrix, the key can't be pressed by the user, |
| 71 | if (((matrix_row - 1) & matrix_row) == 0) | 88 | there is no doubt as to which keys are really being pressed. |
| 89 | The ghosts will be ignored, they are KC_NO. */ | ||
| 90 | rowdata = get_real_keys(row, rowdata); | ||
| 91 | if ((popcount_more_than_one(rowdata)) == 0){ | ||
| 72 | return false; | 92 | return false; |
| 73 | 93 | } | |
| 74 | // Ghost occurs when the row shares column line with other row | 94 | /* Ghost occurs when the row shares a column line with other row, |
| 95 | and two columns are read on each row. Blanks in the matrix don't matter, | ||
| 96 | so they are filtered out. | ||
| 97 | If there are two or more real keys pressed and they match columns with | ||
| 98 | at least two of another row's real keys, the row will be ignored. Keep in mind, | ||
| 99 | we are checking one row at a time, not all of them at once. | ||
| 100 | */ | ||
| 75 | for (uint8_t i=0; i < MATRIX_ROWS; i++) { | 101 | for (uint8_t i=0; i < MATRIX_ROWS; i++) { |
| 76 | if (i != row && (matrix_get_row(i) & matrix_row)) | 102 | if (i != row && popcount_more_than_one(get_real_keys(i, matrix_get_row(i)) & rowdata)){ |
| 77 | return true; | 103 | return true; |
| 104 | } | ||
| 78 | } | 105 | } |
| 79 | return false; | 106 | return false; |
| 80 | } | 107 | } |
| 108 | |||
| 81 | #endif | 109 | #endif |
| 82 | 110 | ||
| 83 | __attribute__ ((weak)) | 111 | __attribute__ ((weak)) |
| @@ -127,7 +155,7 @@ void keyboard_task(void) | |||
| 127 | { | 155 | { |
| 128 | static matrix_row_t matrix_prev[MATRIX_ROWS]; | 156 | static matrix_row_t matrix_prev[MATRIX_ROWS]; |
| 129 | #ifdef MATRIX_HAS_GHOST | 157 | #ifdef MATRIX_HAS_GHOST |
| 130 | static matrix_row_t matrix_ghost[MATRIX_ROWS]; | 158 | // static matrix_row_t matrix_ghost[MATRIX_ROWS]; |
| 131 | #endif | 159 | #endif |
| 132 | static uint8_t led_status = 0; | 160 | static uint8_t led_status = 0; |
| 133 | matrix_row_t matrix_row = 0; | 161 | matrix_row_t matrix_row = 0; |
| @@ -139,18 +167,18 @@ void keyboard_task(void) | |||
| 139 | matrix_change = matrix_row ^ matrix_prev[r]; | 167 | matrix_change = matrix_row ^ matrix_prev[r]; |
| 140 | if (matrix_change) { | 168 | if (matrix_change) { |
| 141 | #ifdef MATRIX_HAS_GHOST | 169 | #ifdef MATRIX_HAS_GHOST |
| 142 | if (has_ghost_in_row(r)) { | 170 | if (has_ghost_in_row(r, matrix_row)) { |
| 143 | /* Keep track of whether ghosted status has changed for | 171 | /* Keep track of whether ghosted status has changed for |
| 144 | * debugging. But don't update matrix_prev until un-ghosted, or | 172 | * debugging. But don't update matrix_prev until un-ghosted, or |
| 145 | * the last key would be lost. | 173 | * the last key would be lost. |
| 146 | */ | 174 | */ |
| 147 | if (debug_matrix && matrix_ghost[r] != matrix_row) { | 175 | //if (debug_matrix && matrix_ghost[r] != matrix_row) { |
| 148 | matrix_print(); | 176 | // matrix_print(); |
| 149 | } | 177 | //} |
| 150 | matrix_ghost[r] = matrix_row; | 178 | //matrix_ghost[r] = matrix_row; |
| 151 | continue; | 179 | continue; |
| 152 | } | 180 | } |
| 153 | matrix_ghost[r] = matrix_row; | 181 | //matrix_ghost[r] = matrix_row; |
| 154 | #endif | 182 | #endif |
| 155 | if (debug_matrix) matrix_print(); | 183 | if (debug_matrix) matrix_print(); |
| 156 | for (uint8_t c = 0; c < MATRIX_COLS; c++) { | 184 | for (uint8_t c = 0; c < MATRIX_COLS; c++) { |
diff --git a/tmk_core/common/keyboard.h b/tmk_core/common/keyboard.h index 7738251b6..f17003c2f 100644 --- a/tmk_core/common/keyboard.h +++ b/tmk_core/common/keyboard.h | |||
| @@ -57,7 +57,6 @@ static inline bool IS_RELEASED(keyevent_t event) { return (!IS_NOEVENT(event) && | |||
| 57 | .time = (timer_read() | 1) \ | 57 | .time = (timer_read() | 1) \ |
| 58 | } | 58 | } |
| 59 | 59 | ||
| 60 | |||
| 61 | /* it runs once at early stage of startup before keyboard_init. */ | 60 | /* it runs once at early stage of startup before keyboard_init. */ |
| 62 | void keyboard_setup(void); | 61 | void keyboard_setup(void); |
| 63 | /* it runs once after initializing host side protocol, debug and MCU peripherals. */ | 62 | /* it runs once after initializing host side protocol, debug and MCU peripherals. */ |
diff --git a/tmk_core/protocol/ps2_mouse.c b/tmk_core/protocol/ps2_mouse.c index d9ccbecb4..4ed3cae1f 100644 --- a/tmk_core/protocol/ps2_mouse.c +++ b/tmk_core/protocol/ps2_mouse.c | |||
| @@ -72,12 +72,13 @@ void ps2_mouse_init_user(void) { | |||
| 72 | 72 | ||
| 73 | void ps2_mouse_task(void) { | 73 | void ps2_mouse_task(void) { |
| 74 | static uint8_t buttons_prev = 0; | 74 | static uint8_t buttons_prev = 0; |
| 75 | extern int tp_buttons; | ||
| 75 | 76 | ||
| 76 | /* receives packet from mouse */ | 77 | /* receives packet from mouse */ |
| 77 | uint8_t rcv; | 78 | uint8_t rcv; |
| 78 | rcv = ps2_host_send(PS2_MOUSE_READ_DATA); | 79 | rcv = ps2_host_send(PS2_MOUSE_READ_DATA); |
| 79 | if (rcv == PS2_ACK) { | 80 | if (rcv == PS2_ACK) { |
| 80 | mouse_report.buttons = ps2_host_recv_response(); | 81 | mouse_report.buttons = ps2_host_recv_response() | tp_buttons; |
| 81 | mouse_report.x = ps2_host_recv_response() * PS2_MOUSE_X_MULTIPLIER; | 82 | mouse_report.x = ps2_host_recv_response() * PS2_MOUSE_X_MULTIPLIER; |
| 82 | mouse_report.y = ps2_host_recv_response() * PS2_MOUSE_Y_MULTIPLIER; | 83 | mouse_report.y = ps2_host_recv_response() * PS2_MOUSE_Y_MULTIPLIER; |
| 83 | #ifdef PS2_MOUSE_ENABLE_SCROLLING | 84 | #ifdef PS2_MOUSE_ENABLE_SCROLLING |
| @@ -106,34 +107,34 @@ void ps2_mouse_task(void) { | |||
| 106 | #endif | 107 | #endif |
| 107 | host_mouse_send(&mouse_report); | 108 | host_mouse_send(&mouse_report); |
| 108 | } | 109 | } |
| 109 | 110 | ||
| 110 | ps2_mouse_clear_report(&mouse_report); | 111 | ps2_mouse_clear_report(&mouse_report); |
| 111 | } | 112 | } |
| 112 | 113 | ||
| 113 | void ps2_mouse_disable_data_reporting(void) { | 114 | void ps2_mouse_disable_data_reporting(void) { |
| 114 | PS2_MOUSE_SEND(PS2_MOUSE_DISABLE_DATA_REPORTING, "ps2 mouse disable data reporting"); | 115 | PS2_MOUSE_SEND(PS2_MOUSE_DISABLE_DATA_REPORTING, "ps2 mouse disable data reporting"); |
| 115 | } | 116 | } |
| 116 | 117 | ||
| 117 | void ps2_mouse_enable_data_reporting(void) { | 118 | void ps2_mouse_enable_data_reporting(void) { |
| 118 | PS2_MOUSE_SEND(PS2_MOUSE_ENABLE_DATA_REPORTING, "ps2 mouse enable data reporting"); | 119 | PS2_MOUSE_SEND(PS2_MOUSE_ENABLE_DATA_REPORTING, "ps2 mouse enable data reporting"); |
| 119 | } | 120 | } |
| 120 | 121 | ||
| 121 | void ps2_mouse_set_remote_mode(void) { | 122 | void ps2_mouse_set_remote_mode(void) { |
| 122 | PS2_MOUSE_SEND_SAFE(PS2_MOUSE_SET_REMOTE_MODE, "ps2 mouse set remote mode"); | 123 | PS2_MOUSE_SEND_SAFE(PS2_MOUSE_SET_REMOTE_MODE, "ps2 mouse set remote mode"); |
| 123 | ps2_mouse_mode = PS2_MOUSE_REMOTE_MODE; | 124 | ps2_mouse_mode = PS2_MOUSE_REMOTE_MODE; |
| 124 | } | 125 | } |
| 125 | 126 | ||
| 126 | void ps2_mouse_set_stream_mode(void) { | 127 | void ps2_mouse_set_stream_mode(void) { |
| 127 | PS2_MOUSE_SEND_SAFE(PS2_MOUSE_SET_STREAM_MODE, "ps2 mouse set stream mode"); | 128 | PS2_MOUSE_SEND_SAFE(PS2_MOUSE_SET_STREAM_MODE, "ps2 mouse set stream mode"); |
| 128 | ps2_mouse_mode = PS2_MOUSE_STREAM_MODE; | 129 | ps2_mouse_mode = PS2_MOUSE_STREAM_MODE; |
| 129 | } | 130 | } |
| 130 | 131 | ||
| 131 | void ps2_mouse_set_scaling_2_1(void) { | 132 | void ps2_mouse_set_scaling_2_1(void) { |
| 132 | PS2_MOUSE_SEND_SAFE(PS2_MOUSE_SET_SCALING_2_1, "ps2 mouse set scaling 2:1"); | 133 | PS2_MOUSE_SEND_SAFE(PS2_MOUSE_SET_SCALING_2_1, "ps2 mouse set scaling 2:1"); |
| 133 | } | 134 | } |
| 134 | 135 | ||
| 135 | void ps2_mouse_set_scaling_1_1(void) { | 136 | void ps2_mouse_set_scaling_1_1(void) { |
| 136 | PS2_MOUSE_SEND_SAFE(PS2_MOUSE_SET_SCALING_1_1, "ps2 mouse set scaling 1:1"); | 137 | PS2_MOUSE_SEND_SAFE(PS2_MOUSE_SET_SCALING_1_1, "ps2 mouse set scaling 1:1"); |
| 137 | } | 138 | } |
| 138 | 139 | ||
| 139 | void ps2_mouse_set_resolution(ps2_mouse_resolution_t resolution) { | 140 | void ps2_mouse_set_resolution(ps2_mouse_resolution_t resolution) { |
| @@ -204,9 +205,9 @@ static inline void ps2_mouse_enable_scrolling(void) { | |||
| 204 | #define PRESS_SCROLL_BUTTONS mouse_report->buttons |= (PS2_MOUSE_SCROLL_BTN_MASK) | 205 | #define PRESS_SCROLL_BUTTONS mouse_report->buttons |= (PS2_MOUSE_SCROLL_BTN_MASK) |
| 205 | #define RELEASE_SCROLL_BUTTONS mouse_report->buttons &= ~(PS2_MOUSE_SCROLL_BTN_MASK) | 206 | #define RELEASE_SCROLL_BUTTONS mouse_report->buttons &= ~(PS2_MOUSE_SCROLL_BTN_MASK) |
| 206 | static inline void ps2_mouse_scroll_button_task(report_mouse_t *mouse_report) { | 207 | static inline void ps2_mouse_scroll_button_task(report_mouse_t *mouse_report) { |
| 207 | static enum { | 208 | static enum { |
| 208 | SCROLL_NONE, | 209 | SCROLL_NONE, |
| 209 | SCROLL_BTN, | 210 | SCROLL_BTN, |
| 210 | SCROLL_SENT, | 211 | SCROLL_SENT, |
| 211 | } scroll_state = SCROLL_NONE; | 212 | } scroll_state = SCROLL_NONE; |
| 212 | static uint16_t scroll_button_time = 0; | 213 | static uint16_t scroll_button_time = 0; |
| @@ -228,10 +229,10 @@ static inline void ps2_mouse_scroll_button_task(report_mouse_t *mouse_report) { | |||
| 228 | mouse_report->y = 0; | 229 | mouse_report->y = 0; |
| 229 | } | 230 | } |
| 230 | } else if (0 == (PS2_MOUSE_SCROLL_BTN_MASK & mouse_report->buttons)) { | 231 | } else if (0 == (PS2_MOUSE_SCROLL_BTN_MASK & mouse_report->buttons)) { |
| 231 | // None of the scroll buttons are pressed | 232 | // None of the scroll buttons are pressed |
| 232 | 233 | ||
| 233 | #if PS2_MOUSE_SCROLL_BTN_SEND | 234 | #if PS2_MOUSE_SCROLL_BTN_SEND |
| 234 | if (scroll_state == SCROLL_BTN | 235 | if (scroll_state == SCROLL_BTN |
| 235 | && timer_elapsed(scroll_button_time) < PS2_MOUSE_SCROLL_BTN_SEND) { | 236 | && timer_elapsed(scroll_button_time) < PS2_MOUSE_SCROLL_BTN_SEND) { |
| 236 | PRESS_SCROLL_BUTTONS; | 237 | PRESS_SCROLL_BUTTONS; |
| 237 | host_mouse_send(mouse_report); | 238 | host_mouse_send(mouse_report); |
