X-Git-Url: https://git.donarmstrong.com/?a=blobdiff_plain;f=tmk_core%2Fprotocol%2Fps2_mouse.c;h=cf1055eb802c30f3f434df6ba55aeb50c8c466b2;hb=91683d56fa5c9cf9893219b3dac269e20a2c7251;hp=d9ccbecb43a3f7f1848daed5e1093628db51c326;hpb=a28f6893878f60509a7796637192fedb4be38d45;p=qmk_firmware.git diff --git a/tmk_core/protocol/ps2_mouse.c b/tmk_core/protocol/ps2_mouse.c index d9ccbecb4..cf1055eb8 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) { void ps2_mouse_task(void) { static uint8_t buttons_prev = 0; + extern int tp_buttons; /* receives packet from mouse */ uint8_t rcv; rcv = ps2_host_send(PS2_MOUSE_READ_DATA); if (rcv == PS2_ACK) { - mouse_report.buttons = ps2_host_recv_response(); + mouse_report.buttons = ps2_host_recv_response() | tp_buttons; mouse_report.x = ps2_host_recv_response() * PS2_MOUSE_X_MULTIPLIER; mouse_report.y = ps2_host_recv_response() * PS2_MOUSE_Y_MULTIPLIER; #ifdef PS2_MOUSE_ENABLE_SCROLLING @@ -106,34 +107,34 @@ void ps2_mouse_task(void) { #endif host_mouse_send(&mouse_report); } - + ps2_mouse_clear_report(&mouse_report); } void ps2_mouse_disable_data_reporting(void) { - PS2_MOUSE_SEND(PS2_MOUSE_DISABLE_DATA_REPORTING, "ps2 mouse disable data reporting"); + PS2_MOUSE_SEND(PS2_MOUSE_DISABLE_DATA_REPORTING, "ps2 mouse disable data reporting"); } void ps2_mouse_enable_data_reporting(void) { PS2_MOUSE_SEND(PS2_MOUSE_ENABLE_DATA_REPORTING, "ps2 mouse enable data reporting"); } -void ps2_mouse_set_remote_mode(void) { - PS2_MOUSE_SEND_SAFE(PS2_MOUSE_SET_REMOTE_MODE, "ps2 mouse set remote mode"); +void ps2_mouse_set_remote_mode(void) { + PS2_MOUSE_SEND_SAFE(PS2_MOUSE_SET_REMOTE_MODE, "ps2 mouse set remote mode"); ps2_mouse_mode = PS2_MOUSE_REMOTE_MODE; } -void ps2_mouse_set_stream_mode(void) { - PS2_MOUSE_SEND_SAFE(PS2_MOUSE_SET_STREAM_MODE, "ps2 mouse set stream mode"); +void ps2_mouse_set_stream_mode(void) { + PS2_MOUSE_SEND_SAFE(PS2_MOUSE_SET_STREAM_MODE, "ps2 mouse set stream mode"); ps2_mouse_mode = PS2_MOUSE_STREAM_MODE; } void ps2_mouse_set_scaling_2_1(void) { - PS2_MOUSE_SEND_SAFE(PS2_MOUSE_SET_SCALING_2_1, "ps2 mouse set scaling 2:1"); + PS2_MOUSE_SEND_SAFE(PS2_MOUSE_SET_SCALING_2_1, "ps2 mouse set scaling 2:1"); } void ps2_mouse_set_scaling_1_1(void) { - PS2_MOUSE_SEND_SAFE(PS2_MOUSE_SET_SCALING_1_1, "ps2 mouse set scaling 1:1"); + PS2_MOUSE_SEND_SAFE(PS2_MOUSE_SET_SCALING_1_1, "ps2 mouse set scaling 1:1"); } void ps2_mouse_set_resolution(ps2_mouse_resolution_t resolution) { @@ -168,8 +169,14 @@ static inline void ps2_mouse_convert_report_to_hid(report_mouse_t *mouse_report) // remove sign and overflow flags mouse_report->buttons &= PS2_MOUSE_BTN_MASK; +#ifdef PS2_MOUSE_INVERT_X + mouse_report->x = -mouse_report->x; +#endif +#ifndef PS2_MOUSE_INVERT_Y // NOTE if not! // invert coordinate of y to conform to USB HID mouse mouse_report->y = -mouse_report->y; +#endif + } static inline void ps2_mouse_clear_report(report_mouse_t *mouse_report) { @@ -204,9 +211,9 @@ static inline void ps2_mouse_enable_scrolling(void) { #define PRESS_SCROLL_BUTTONS mouse_report->buttons |= (PS2_MOUSE_SCROLL_BTN_MASK) #define RELEASE_SCROLL_BUTTONS mouse_report->buttons &= ~(PS2_MOUSE_SCROLL_BTN_MASK) static inline void ps2_mouse_scroll_button_task(report_mouse_t *mouse_report) { - static enum { - SCROLL_NONE, - SCROLL_BTN, + static enum { + SCROLL_NONE, + SCROLL_BTN, SCROLL_SENT, } scroll_state = SCROLL_NONE; static uint16_t scroll_button_time = 0; @@ -226,12 +233,18 @@ static inline void ps2_mouse_scroll_button_task(report_mouse_t *mouse_report) { mouse_report->h = mouse_report->x/(PS2_MOUSE_SCROLL_DIVISOR_H); mouse_report->x = 0; mouse_report->y = 0; +#ifdef PS2_MOUSE_INVERT_H + mouse_report->h = -mouse_report->h; +#endif +#ifdef PS2_MOUSE_INVERT_V + mouse_report->v = -mouse_report->v; +#endif } } else if (0 == (PS2_MOUSE_SCROLL_BTN_MASK & mouse_report->buttons)) { - // None of the scroll buttons are pressed + // None of the scroll buttons are pressed #if PS2_MOUSE_SCROLL_BTN_SEND - if (scroll_state == SCROLL_BTN + if (scroll_state == SCROLL_BTN && timer_elapsed(scroll_button_time) < PS2_MOUSE_SCROLL_BTN_SEND) { PRESS_SCROLL_BUTTONS; host_mouse_send(mouse_report);