forked from zmkfirmware/zmk
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
slicemk: caksoylar feat/mouse-keys branch (squashed 2023-11-23)
- Loading branch information
1 parent
2ac47cb
commit 6381f65
Showing
47 changed files
with
1,376 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
/ { | ||
behaviors { | ||
/omit-if-no-ref/ mkp: behavior_mouse_key_press { | ||
compatible = "zmk,behavior-mouse-key-press"; | ||
label = "MOUSE_KEY_PRESS"; | ||
#binding-cells = <1>; | ||
}; | ||
}; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
/ { | ||
behaviors { | ||
/omit-if-no-ref/ mmv: behavior_mouse_move { | ||
compatible = "zmk,behavior-mouse-move"; | ||
label = "MOUSE_MOVE"; | ||
#binding-cells = <1>; | ||
delay-ms = <0>; | ||
time-to-max-speed-ms = <300>; | ||
acceleration-exponent = <1>; | ||
}; | ||
}; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
/ { | ||
behaviors { | ||
/omit-if-no-ref/ mwh: msc: behavior_mouse_scroll { | ||
compatible = "zmk,behavior-mouse-scroll"; | ||
label = "MOUSE_SCROLL"; | ||
#binding-cells = <1>; | ||
delay-ms = <0>; | ||
time-to-max-speed-ms = <300>; | ||
acceleration-exponent = <0>; | ||
}; | ||
}; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
description: Mouse key press/release behavior | ||
|
||
compatible: "zmk,behavior-mouse-key-press" | ||
|
||
include: one_param.yaml |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
description: Mouse move | ||
|
||
compatible: "zmk,behavior-mouse-move" | ||
|
||
include: one_param.yaml | ||
|
||
properties: | ||
delay-ms: | ||
type: int | ||
time-to-max-speed-ms: | ||
type: int | ||
acceleration-exponent: | ||
type: int |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
description: Mouse scroll | ||
|
||
compatible: "zmk,behavior-mouse-scroll" | ||
|
||
include: one_param.yaml | ||
|
||
properties: | ||
delay-ms: | ||
type: int | ||
time-to-max-speed-ms: | ||
type: int | ||
acceleration-exponent: | ||
type: int |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
/* | ||
* Copyright (c) 2023 The ZMK Contributors | ||
* | ||
* SPDX-License-Identifier: MIT | ||
*/ | ||
#pragma once | ||
|
||
#include <zephyr/dt-bindings/dt-util.h> | ||
|
||
/* Mouse press behavior */ | ||
/* Left click */ | ||
#define MB1 BIT(0) | ||
#define LCLK (MB1) | ||
|
||
/* Right click */ | ||
#define MB2 BIT(1) | ||
#define RCLK (MB2) | ||
|
||
/* Middle click */ | ||
#define MB3 BIT(2) | ||
#define MCLK (MB3) | ||
|
||
#define MB4 BIT(3) | ||
#define MB5 BIT(4) | ||
|
||
/* 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) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
|
||
/* | ||
* Copyright (c) 2020 The ZMK Contributors | ||
* | ||
* SPDX-License-Identifier: MIT | ||
*/ | ||
|
||
#pragma once | ||
|
||
#include <zmk/hid.h> | ||
#include <zmk/event_manager.h> | ||
#include <zmk/mouse.h> | ||
|
||
struct zmk_mouse_button_state_changed { | ||
zmk_mouse_button_t buttons; | ||
bool state; | ||
int64_t timestamp; | ||
}; | ||
|
||
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 = ZMK_HID_USAGE_ID(encoded), .state = pressed, .timestamp = timestamp}); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
|
||
/* | ||
* Copyright (c) 2020 The ZMK Contributors | ||
* | ||
* SPDX-License-Identifier: MIT | ||
*/ | ||
|
||
#pragma once | ||
|
||
#include <zephyr/kernel.h> | ||
#include <zmk/event_manager.h> | ||
#include <zmk/mouse.h> | ||
|
||
struct zmk_mouse_move_state_changed { | ||
struct vector2d max_speed; | ||
struct mouse_config config; | ||
bool state; | ||
int64_t timestamp; | ||
}; | ||
|
||
ZMK_EVENT_DECLARE(zmk_mouse_move_state_changed); | ||
|
||
static inline struct zmk_mouse_move_state_changed_event * | ||
zmk_mouse_move_state_changed_from_encoded(uint32_t encoded, struct mouse_config config, | ||
bool pressed, int64_t timestamp) { | ||
struct vector2d max_speed = (struct vector2d){ | ||
.x = MOVE_HOR_DECODE(encoded), | ||
.y = MOVE_VERT_DECODE(encoded), | ||
}; | ||
|
||
return new_zmk_mouse_move_state_changed((struct zmk_mouse_move_state_changed){ | ||
.max_speed = max_speed, .config = config, .state = pressed, .timestamp = timestamp}); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
|
||
/* | ||
* Copyright (c) 2020 The ZMK Contributors | ||
* | ||
* SPDX-License-Identifier: MIT | ||
*/ | ||
|
||
#pragma once | ||
|
||
#include <zephyr/kernel.h> | ||
#include <zmk/event_manager.h> | ||
#include <zmk/mouse.h> | ||
#include <dt-bindings/zmk/mouse.h> | ||
|
||
struct zmk_mouse_scroll_state_changed { | ||
struct vector2d max_speed; | ||
struct mouse_config config; | ||
bool state; | ||
int64_t timestamp; | ||
}; | ||
|
||
ZMK_EVENT_DECLARE(zmk_mouse_scroll_state_changed); | ||
|
||
static inline struct zmk_mouse_scroll_state_changed_event * | ||
zmk_mouse_scroll_state_changed_from_encoded(uint32_t encoded, struct mouse_config config, | ||
bool pressed, int64_t timestamp) { | ||
struct vector2d max_speed = (struct vector2d){ | ||
.x = SCROLL_HOR_DECODE(encoded), | ||
.y = SCROLL_VERT_DECODE(encoded), | ||
}; | ||
|
||
return new_zmk_mouse_scroll_state_changed((struct zmk_mouse_scroll_state_changed){ | ||
.max_speed = max_speed, .config = config, .state = pressed, .timestamp = timestamp}); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
|
||
/* | ||
* Copyright (c) 2020 The ZMK Contributors | ||
* | ||
* SPDX-License-Identifier: MIT | ||
*/ | ||
|
||
#pragma once | ||
|
||
#include <dt-bindings/zmk/mouse.h> | ||
#include <zephyr/kernel.h> | ||
#include <zmk/event_manager.h> | ||
#include <zmk/mouse.h> | ||
|
||
struct zmk_mouse_tick { | ||
struct vector2d max_move; | ||
struct vector2d max_scroll; | ||
struct mouse_config move_config; | ||
struct mouse_config scroll_config; | ||
struct mouse_times start_times; | ||
int64_t timestamp; | ||
}; | ||
|
||
ZMK_EVENT_DECLARE(zmk_mouse_tick); | ||
|
||
static inline struct zmk_mouse_tick_event *zmk_mouse_tick(struct vector2d max_move, | ||
struct vector2d max_scroll, | ||
struct mouse_config move_config, | ||
struct mouse_config scroll_config, | ||
struct mouse_times movement_start) { | ||
return new_zmk_mouse_tick((struct zmk_mouse_tick){ | ||
.max_move = max_move, | ||
.max_scroll = max_scroll, | ||
.move_config = move_config, | ||
.scroll_config = scroll_config, | ||
.start_times = movement_start, | ||
.timestamp = k_uptime_get(), | ||
}); | ||
} |
Oops, something went wrong.