diff options
author | Nick Choi <nikchi@users.noreply.github.com> | 2017-05-30 14:17:48 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-05-30 14:17:48 -0400 |
commit | 2c9f846608cbf91ce936071372634194745994d0 (patch) | |
tree | 7fc260baa3bca7ba748117e07fca8aaa186943dd /tmk_core | |
parent | 5393bc6f4eee3d3cb83997e5b03d8e5a5cea85d8 (diff) | |
parent | cb791cf6cdbcd9fd1291f36f6b1a6840753db97f (diff) |
Merge pull request #2 from qmk/master
pull in new qmk changes
Diffstat (limited to 'tmk_core')
-rw-r--r-- | tmk_core/common.mk | 20 | ||||
-rw-r--r-- | tmk_core/common/action.c | 28 | ||||
-rw-r--r-- | tmk_core/protocol/lufa/adafruit_ble.cpp | 20 | ||||
-rw-r--r-- | tmk_core/protocol/lufa/adafruit_ble.h | 2 | ||||
-rw-r--r-- | tmk_core/protocol/lufa/lufa.c | 4 | ||||
-rw-r--r-- | tmk_core/protocol/ps2_mouse.c | 29 |
6 files changed, 79 insertions, 24 deletions
diff --git a/tmk_core/common.mk b/tmk_core/common.mk index 3e0bd7dbc8..edec2acb4a 100644 --- a/tmk_core/common.mk +++ b/tmk_core/common.mk @@ -95,27 +95,35 @@ endif ifeq ($(strip $(BLUETOOTH_ENABLE)), yes) TMK_COMMON_DEFS += -DBLUETOOTH_ENABLE + TMK_COMMON_DEFS += -DNO_USB_STARTUP_CHECK endif ifeq ($(strip $(BLUETOOTH)), AdafruitBLE) - TMK_COMMON_DEFS += -DBLUETOOTH_ENABLE - TMK_COMMON_DEFS += -DMODULE_ADAFRUIT_BLE + TMK_COMMON_DEFS += -DBLUETOOTH_ENABLE + TMK_COMMON_DEFS += -DMODULE_ADAFRUIT_BLE + TMK_COMMON_DEFS += -DNO_USB_STARTUP_CHECK endif ifeq ($(strip $(BLUETOOTH)), AdafruitEZKey) - TMK_COMMON_DEFS += -DBLUETOOTH_ENABLE - TMK_COMMON_DEFS += -DMODULE_ADAFRUIT_EZKEY + TMK_COMMON_DEFS += -DBLUETOOTH_ENABLE + TMK_COMMON_DEFS += -DMODULE_ADAFRUIT_EZKEY + TMK_COMMON_DEFS += -DNO_USB_STARTUP_CHECK endif ifeq ($(strip $(BLUETOOTH)), RN42) - TMK_COMMON_DEFS += -DBLUETOOTH_ENABLE - TMK_COMMON_DEFS += -DMODULE_RN42 + TMK_COMMON_DEFS += -DBLUETOOTH_ENABLE + TMK_COMMON_DEFS += -DMODULE_RN42 + TMK_COMMON_DEFS += -DNO_USB_STARTUP_CHECK endif ifeq ($(strip $(ONEHAND_ENABLE)), yes) TMK_COMMON_DEFS += -DONEHAND_ENABLE endif +ifeq ($(strip $(NO_USB_STARTUP_CHECK)), yes) + TMK_COMMON_DEFS += -DNO_USB_STARTUP_CHECK +endif + ifeq ($(strip $(KEYMAP_SECTION_ENABLE)), yes) TMK_COMMON_DEFS += -DKEYMAP_SECTION_ENABLE diff --git a/tmk_core/common/action.c b/tmk_core/common/action.c index a534f818ec..cffc0b9ebe 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/>. #include "nodebug.h" #endif +int tp_buttons; + #ifdef FAUXCLICKY_ENABLE #include <fauxclicky.h> #endif @@ -311,9 +313,35 @@ void process_action(keyrecord_t *record, action_t action) /* Mouse key */ case ACT_MOUSEKEY: if (event.pressed) { + switch (action.key.code) { + case KC_MS_BTN1: + tp_buttons |= (1<<0); + break; + case KC_MS_BTN2: + tp_buttons |= (1<<1); + break; + case KC_MS_BTN3: + tp_buttons |= (1<<2); + break; + default: + break; + } mousekey_on(action.key.code); mousekey_send(); } else { + switch (action.key.code) { + case KC_MS_BTN1: + tp_buttons &= ~(1<<0); + break; + case KC_MS_BTN2: + tp_buttons &= ~(1<<1); + break; + case KC_MS_BTN3: + tp_buttons &= ~(1<<2); + break; + default: + break; + } mousekey_off(action.key.code); mousekey_send(); } diff --git a/tmk_core/protocol/lufa/adafruit_ble.cpp b/tmk_core/protocol/lufa/adafruit_ble.cpp index fd6edd42cf..bee6bb2c19 100644 --- a/tmk_core/protocol/lufa/adafruit_ble.cpp +++ b/tmk_core/protocol/lufa/adafruit_ble.cpp @@ -87,6 +87,7 @@ struct queue_item { uint16_t consumer; struct __attribute__((packed)) { int8_t x, y, scroll, pan; + uint8_t buttons; } mousemove; }; }; @@ -699,6 +700,22 @@ static bool process_queue_item(struct queue_item *item, uint16_t timeout) { strcpy_P(fmtbuf, PSTR("AT+BLEHIDMOUSEMOVE=%d,%d,%d,%d")); snprintf(cmdbuf, sizeof(cmdbuf), fmtbuf, item->mousemove.x, item->mousemove.y, item->mousemove.scroll, item->mousemove.pan); + if (!at_command(cmdbuf, NULL, 0, true, timeout)) { + return false; + } + strcpy_P(cmdbuf, PSTR("AT+BLEHIDMOUSEBUTTON=")); + if (item->mousemove.buttons & MOUSE_BTN1) { + strcat(cmdbuf, "L"); + } + if (item->mousemove.buttons & MOUSE_BTN2) { + strcat(cmdbuf, "R"); + } + if (item->mousemove.buttons & MOUSE_BTN3) { + strcat(cmdbuf, "M"); + } + if (item->mousemove.buttons == 0) { + strcat(cmdbuf, "0"); + } return at_command(cmdbuf, NULL, 0, true, timeout); #endif default: @@ -757,7 +774,7 @@ bool adafruit_ble_send_consumer_key(uint16_t keycode, int hold_duration) { #ifdef MOUSE_ENABLE bool adafruit_ble_send_mouse_move(int8_t x, int8_t y, int8_t scroll, - int8_t pan) { + int8_t pan, uint8_t buttons) { struct queue_item item; item.queue_type = QTMouseMove; @@ -765,6 +782,7 @@ bool adafruit_ble_send_mouse_move(int8_t x, int8_t y, int8_t scroll, item.mousemove.y = y; item.mousemove.scroll = scroll; item.mousemove.pan = pan; + item.mousemove.buttons = buttons; while (!send_buf.enqueue(item)) { send_buf_send_one(); diff --git a/tmk_core/protocol/lufa/adafruit_ble.h b/tmk_core/protocol/lufa/adafruit_ble.h index b3bab3ca09..036b7d14ea 100644 --- a/tmk_core/protocol/lufa/adafruit_ble.h +++ b/tmk_core/protocol/lufa/adafruit_ble.h @@ -43,7 +43,7 @@ extern bool adafruit_ble_send_consumer_key(uint16_t keycode, int hold_duration); * The parameters are signed and indicate positive of negative direction * change. */ extern bool adafruit_ble_send_mouse_move(int8_t x, int8_t y, int8_t scroll, - int8_t pan); + int8_t pan, uint8_t buttons); #endif /* Compute battery voltage by reading an analog pin. diff --git a/tmk_core/protocol/lufa/lufa.c b/tmk_core/protocol/lufa/lufa.c index ae6129d1a2..e3f8724e81 100644 --- a/tmk_core/protocol/lufa/lufa.c +++ b/tmk_core/protocol/lufa/lufa.c @@ -669,7 +669,7 @@ static void send_mouse(report_mouse_t *report) if (where == OUTPUT_BLUETOOTH || where == OUTPUT_USB_AND_BT) { #ifdef MODULE_ADAFRUIT_BLE // FIXME: mouse buttons - adafruit_ble_send_mouse_move(report->x, report->y, report->v, report->h); + adafruit_ble_send_mouse_move(report->x, report->y, report->v, report->h, report->buttons); #else bluefruit_serial_send(0xFD); bluefruit_serial_send(0x00); @@ -1180,7 +1180,7 @@ int main(void) print("Keyboard start.\n"); while (1) { - #if !defined(BLUETOOTH_ENABLE) + #if !defined(NO_USB_STARTUP_CHECK) while (USB_DeviceState == DEVICE_STATE_Suspended) { print("[s]"); suspend_power_down(); diff --git a/tmk_core/protocol/ps2_mouse.c b/tmk_core/protocol/ps2_mouse.c index d9ccbecb43..4ed3cae1fd 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) { @@ -204,9 +205,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; @@ -228,10 +229,10 @@ static inline void ps2_mouse_scroll_button_task(report_mouse_t *mouse_report) { mouse_report->y = 0; } } 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); |