Skip to content

Commit

Permalink
Remove everything not required for buttons
Browse files Browse the repository at this point in the history
I've stripped out everything not strictly required for mouse button HID
support. This include dropping the worker thread completely, shaving
down the USB HID descriptor. Flattening the mouse/ source directory
structure and removing a bunch of event handling.

I have kept the mouse event handling separate from the other HID event
handling since I figured that was a pretty neat split. If that's a bad
idea, do tell.

I've also added a test case for mouse button emulation, since that was
untested before.

The changes have been tested on a corne (split) in usb mode. Bindings on
both the left and the right side works (with the left side as master).
  • Loading branch information
DelusionalLogic authored and petejohanson committed Nov 6, 2023
1 parent 2c519f1 commit b965f57
Show file tree
Hide file tree
Showing 36 changed files with 120 additions and 944 deletions.
9 changes: 1 addition & 8 deletions app/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,6 @@ target_sources(app PRIVATE src/stdlib.c)
target_sources(app PRIVATE src/activity.c)
target_sources(app PRIVATE src/kscan.c)
target_sources(app PRIVATE src/matrix_transform.c)
target_sources(app PRIVATE src/mouse/key_listener.c)
target_sources(app PRIVATE src/mouse/main.c)
target_sources(app PRIVATE src/mouse/tick_listener.c)
target_sources(app PRIVATE src/sensors.c)
target_sources_ifdef(CONFIG_ZMK_WPM app PRIVATE src/wpm.c)
target_sources(app PRIVATE src/event_manager.c)
Expand All @@ -35,15 +32,13 @@ target_sources(app PRIVATE src/events/activity_state_changed.c)
target_sources(app PRIVATE src/events/position_state_changed.c)
target_sources(app PRIVATE src/events/sensor_event.c)
target_sources(app PRIVATE src/events/mouse_button_state_changed.c)
target_sources(app PRIVATE src/events/mouse_move_state_changed.c)
target_sources(app PRIVATE src/events/mouse_tick.c)
target_sources(app PRIVATE src/events/mouse_scroll_state_changed.c)
target_sources_ifdef(CONFIG_ZMK_WPM app PRIVATE src/events/wpm_state_changed.c)
target_sources_ifdef(CONFIG_USB_DEVICE_STACK app PRIVATE src/events/usb_conn_state_changed.c)
target_sources(app PRIVATE src/behaviors/behavior_reset.c)
target_sources_ifdef(CONFIG_ZMK_EXT_POWER app PRIVATE src/behaviors/behavior_ext_power.c)
if ((NOT CONFIG_ZMK_SPLIT) OR CONFIG_ZMK_SPLIT_ROLE_CENTRAL)
target_sources(app PRIVATE src/hid.c)
target_sources(app PRIVATE src/mouse.c)
target_sources(app PRIVATE src/behaviors/behavior_key_press.c)
target_sources_ifdef(CONFIG_ZMK_BEHAVIOR_KEY_TOGGLE app PRIVATE src/behaviors/behavior_key_toggle.c)
target_sources(app PRIVATE src/behaviors/behavior_hold_tap.c)
Expand All @@ -62,8 +57,6 @@ if ((NOT CONFIG_ZMK_SPLIT) OR CONFIG_ZMK_SPLIT_ROLE_CENTRAL)
target_sources_ifdef(CONFIG_ZMK_BEHAVIOR_SENSOR_ROTATE_VAR app PRIVATE src/behaviors/behavior_sensor_rotate_var.c)
target_sources_ifdef(CONFIG_ZMK_BEHAVIOR_SENSOR_ROTATE_COMMON app PRIVATE src/behaviors/behavior_sensor_rotate_common.c)
target_sources(app PRIVATE src/behaviors/behavior_mouse_key_press.c)
target_sources(app PRIVATE src/behaviors/behavior_mouse_move.c)
target_sources(app PRIVATE src/behaviors/behavior_mouse_scroll.c)
target_sources(app PRIVATE src/combo.c)
target_sources(app PRIVATE src/behaviors/behavior_tap_dance.c)
target_sources(app PRIVATE src/behavior_queue.c)
Expand Down
4 changes: 3 additions & 1 deletion app/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -314,7 +314,9 @@ endmenu

menu "Mouse Options"

rsource "src/mouse/Kconfig"
config ZMK_MOUSE
bool "Enable ZMK mouse emulation"
default n

#Mouse Options
endmenu
Expand Down
2 changes: 0 additions & 2 deletions app/dts/behaviors.dtsi
Original file line number Diff line number Diff line change
Expand Up @@ -20,5 +20,3 @@
#include <behaviors/backlight.dtsi>
#include <behaviors/macros.dtsi>
#include <behaviors/mouse_key_press.dtsi>
#include <behaviors/mouse_move.dtsi>
#include <behaviors/mouse_scroll.dtsi>
12 changes: 0 additions & 12 deletions app/dts/behaviors/mouse_move.dtsi

This file was deleted.

12 changes: 0 additions & 12 deletions app/dts/behaviors/mouse_scroll.dtsi

This file was deleted.

13 changes: 0 additions & 13 deletions app/dts/bindings/behaviors/zmk,behavior-mouse-move.yaml

This file was deleted.

13 changes: 0 additions & 13 deletions app/dts/bindings/behaviors/zmk,behavior-mouse-scroll.yaml

This file was deleted.

26 changes: 0 additions & 26 deletions app/include/dt-bindings/zmk/mouse.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,29 +27,3 @@
#define MB7 (0x40)

#define MB8 (0x80)

/* Mouse move behavior */
#define MOVE_VERT(vert) ((vert)&0xFFFF)
#define MOVE_VERT_DECODE(encoded) (int16_t)((encoded)&0x0000FFFF)
#define MOVE_HOR(hor) (((hor)&0xFFFF) << 16)
#define MOVE_HOR_DECODE(encoded) (int16_t)(((encoded)&0xFFFF0000) >> 16)

#define MOVE(hor, vert) (MOVE_HOR(hor) + MOVE_VERT(vert))

#define MOVE_UP MOVE_VERT(-600)
#define MOVE_DOWN MOVE_VERT(600)
#define MOVE_LEFT MOVE_HOR(-600)
#define MOVE_RIGHT MOVE_HOR(600)

/* Mouse scroll behavior */
#define SCROLL_VERT(vert) ((vert)&0xFFFF)
#define SCROLL_VERT_DECODE(encoded) (int16_t)((encoded)&0x0000FFFF)
#define SCROLL_HOR(hor) (((hor)&0xFFFF) << 16)
#define SCROLL_HOR_DECODE(encoded) (int16_t)(((encoded)&0xFFFF0000) >> 16)

#define SCROLL(hor, vert) (SCROLL_HOR(hor) + SCROLL_VERT(vert))

#define SCROLL_UP SCROLL_VERT(10)
#define SCROLL_DOWN SCROLL_VERT(-10)
#define SCROLL_LEFT SCROLL_HOR(-10)
#define SCROLL_RIGHT SCROLL_HOR(10)
2 changes: 1 addition & 1 deletion app/include/zmk/events/mouse_button_state_changed.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,5 +23,5 @@ ZMK_EVENT_DECLARE(zmk_mouse_button_state_changed);
static inline struct zmk_mouse_button_state_changed_event *
zmk_mouse_button_state_changed_from_encoded(uint32_t encoded, bool pressed, int64_t timestamp) {
return new_zmk_mouse_button_state_changed((struct zmk_mouse_button_state_changed){
.buttons = HID_USAGE_ID(encoded), .state = pressed, .timestamp = timestamp});
.buttons = ZMK_HID_USAGE_ID(encoded), .state = pressed, .timestamp = timestamp});
}
33 changes: 0 additions & 33 deletions app/include/zmk/events/mouse_move_state_changed.h

This file was deleted.

34 changes: 0 additions & 34 deletions app/include/zmk/events/mouse_scroll_state_changed.h

This file was deleted.

39 changes: 0 additions & 39 deletions app/include/zmk/events/mouse_tick.h

This file was deleted.

Loading

0 comments on commit b965f57

Please sign in to comment.