diff options
Diffstat (limited to 'tmk_core')
| -rw-r--r-- | tmk_core/common/action.c | 34 | ||||
| -rw-r--r-- | tmk_core/protocol/ps2_mouse.c | 29 |
2 files changed, 45 insertions, 18 deletions
diff --git a/tmk_core/common/action.c b/tmk_core/common/action.c index a534f818e..f73b0fe80 100644 --- a/tmk_core/common/action.c +++ b/tmk_core/common/action.c | |||
| @@ -34,6 +34,8 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. | |||
| 34 | #include "nodebug.h" | 34 | #include "nodebug.h" |
| 35 | #endif | 35 | #endif |
| 36 | 36 | ||
| 37 | int tp_buttons; | ||
| 38 | |||
| 37 | #ifdef FAUXCLICKY_ENABLE | 39 | #ifdef FAUXCLICKY_ENABLE |
| 38 | #include <fauxclicky.h> | 40 | #include <fauxclicky.h> |
| 39 | #endif | 41 | #endif |
| @@ -311,11 +313,35 @@ void process_action(keyrecord_t *record, action_t action) | |||
| 311 | /* Mouse key */ | 313 | /* Mouse key */ |
| 312 | case ACT_MOUSEKEY: | 314 | case ACT_MOUSEKEY: |
| 313 | if (event.pressed) { | 315 | if (event.pressed) { |
| 314 | mousekey_on(action.key.code); | 316 | switch (action.key.code) { |
| 315 | 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 | } | ||
| 316 | } else { | 330 | } else { |
| 317 | mousekey_off(action.key.code); | 331 | switch (action.key.code) { |
| 318 | 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 | } | ||
| 319 | } | 345 | } |
| 320 | break; | 346 | break; |
| 321 | #endif | 347 | #endif |
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); |
