From 81e85a1a4e4b1b7c5bbf1fcffe967a60639778c0 Mon Sep 17 00:00:00 2001 From: dbroqua Date: Fri, 26 May 2017 20:35:31 +0200 Subject: - Added integration of IBM Trackpoint --- tmk_core/common/action.c | 34 ++++++++++++++++++++++++++++++---- tmk_core/protocol/ps2_mouse.c | 29 +++++++++++++++-------------- 2 files changed, 45 insertions(+), 18 deletions(-) (limited to 'tmk_core') diff --git a/tmk_core/common/action.c b/tmk_core/common/action.c index a534f818ec..f73b0fe807 100644 --- a/tmk_core/common/action.c +++ b/tmk_core/common/action.c @@ -34,6 +34,8 @@ along with this program. If not, see . #include "nodebug.h" #endif +int tp_buttons; + #ifdef FAUXCLICKY_ENABLE #include #endif @@ -311,11 +313,35 @@ void process_action(keyrecord_t *record, action_t action) /* Mouse key */ case ACT_MOUSEKEY: if (event.pressed) { - mousekey_on(action.key.code); - mousekey_send(); + 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: + mousekey_on(action.key.code); + mousekey_send(); + } } else { - mousekey_off(action.key.code); - mousekey_send(); + 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: + mousekey_off(action.key.code); + mousekey_send(); + } } break; #endif 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); -- cgit v1.2.1 From fa1b92fbb10ecf423d0c611ee2a39fca59376a1d Mon Sep 17 00:00:00 2001 From: yiancar Date: Fri, 26 May 2017 21:58:43 +0100 Subject: Use variable to disable usb check at startup Adds a define variable which when defined disables the usb startup check. Modified the makefile to separate above define from bluetooth dependancy --- tmk_core/common.mk | 20 ++++++++++++++------ tmk_core/protocol/lufa/lufa.c | 2 +- 2 files changed, 15 insertions(+), 7 deletions(-) (limited to 'tmk_core') 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/protocol/lufa/lufa.c b/tmk_core/protocol/lufa/lufa.c index ae6129d1a2..3c4ad4b4d2 100644 --- a/tmk_core/protocol/lufa/lufa.c +++ b/tmk_core/protocol/lufa/lufa.c @@ -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(); -- cgit v1.2.1 From f0fc2db4e291dc7584c3cb81994ae14b9749fc62 Mon Sep 17 00:00:00 2001 From: Priyadi Iman Nurcahyo Date: Mon, 29 May 2017 18:17:21 +0700 Subject: Adafruit Feather BLE / BLE Friend mouse buttons support --- tmk_core/protocol/lufa/adafruit_ble.cpp | 20 +++++++++++++++++++- tmk_core/protocol/lufa/adafruit_ble.h | 2 +- tmk_core/protocol/lufa/lufa.c | 2 +- 3 files changed, 21 insertions(+), 3 deletions(-) (limited to 'tmk_core') 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 3c4ad4b4d2..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); -- cgit v1.2.1 From b6c60333e48e3ed77d5e8a21a139ce9955977559 Mon Sep 17 00:00:00 2001 From: Jack Humbert Date: Mon, 29 May 2017 13:21:38 -0400 Subject: Re-enable mouse buttons --- tmk_core/common/action.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) (limited to 'tmk_core') diff --git a/tmk_core/common/action.c b/tmk_core/common/action.c index f73b0fe807..cffc0b9ebe 100644 --- a/tmk_core/common/action.c +++ b/tmk_core/common/action.c @@ -324,9 +324,10 @@ void process_action(keyrecord_t *record, action_t action) tp_buttons |= (1<<2); break; default: - mousekey_on(action.key.code); - mousekey_send(); + break; } + mousekey_on(action.key.code); + mousekey_send(); } else { switch (action.key.code) { case KC_MS_BTN1: @@ -339,9 +340,10 @@ void process_action(keyrecord_t *record, action_t action) tp_buttons &= ~(1<<2); break; default: - mousekey_off(action.key.code); - mousekey_send(); + break; } + mousekey_off(action.key.code); + mousekey_send(); } break; #endif -- cgit v1.2.1