forked from zmkfirmware/zmk
-
Notifications
You must be signed in to change notification settings - Fork 42
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
12 changed files
with
229 additions
and
2 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
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,9 @@ | ||
/ { | ||
behaviors { | ||
/omit-if-no-ref/ mmv: behavior_mouse_move { | ||
compatible = "zmk,behavior-mouse-move"; | ||
label = "MOUSE_MOVE"; | ||
#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,9 @@ | ||
/ { | ||
behaviors { | ||
/omit-if-no-ref/ mwh: behavior_mouse_wheel { | ||
compatible = "zmk,behavior-mouse-wheel"; | ||
label = "MOUSE_WHEEL"; | ||
#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,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,5 @@ | ||
description: Mouse move | ||
|
||
compatible: "zmk,behavior-mouse-move" | ||
|
||
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,5 @@ | ||
description: Mouse wheel | ||
|
||
compatible: "zmk,behavior-mouse-wheel" | ||
|
||
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
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,45 @@ | ||
/* | ||
* Copyright (c) 2021 The ZMK Contributors | ||
* | ||
* SPDX-License-Identifier: MIT | ||
*/ | ||
|
||
#define DT_DRV_COMPAT zmk_behavior_mouse_key_press | ||
|
||
#include <device.h> | ||
#include <drivers/behavior.h> | ||
#include <logging/log.h> | ||
|
||
#include <zmk/event_manager.h> | ||
#include <zmk/events/keycode_state_changed.h> | ||
#include <zmk/behavior.h> | ||
#include <zmk/hid.h> | ||
#include <zmk/endpoints.h> | ||
|
||
LOG_MODULE_DECLARE(zmk, CONFIG_ZMK_LOG_LEVEL); | ||
|
||
static int behavior_mouse_key_press_init(const struct device *dev) { return 0; }; | ||
|
||
static int on_keymap_binding_pressed(struct zmk_behavior_binding *binding, | ||
struct zmk_behavior_binding_event event) { | ||
LOG_DBG("position %d keycode 0x%02X", event.position, binding->param1); | ||
zmk_hid_mouse_buttons_press(HID_USAGE_ID(binding->param1)); | ||
return zmk_endpoints_send_mouse_report(); | ||
} | ||
|
||
static int on_keymap_binding_released(struct zmk_behavior_binding *binding, | ||
struct zmk_behavior_binding_event event) { | ||
LOG_DBG("position %d keycode 0x%02X", event.position, binding->param1); | ||
zmk_hid_mouse_buttons_release(HID_USAGE_ID(binding->param1)); | ||
return zmk_endpoints_send_mouse_report(); | ||
} | ||
|
||
static const struct behavior_driver_api behavior_mouse_key_press_driver_api = { | ||
.binding_pressed = on_keymap_binding_pressed, .binding_released = on_keymap_binding_released}; | ||
|
||
#define KP_INST(n) \ | ||
DEVICE_AND_API_INIT(behavior_mouse_key_press_##n, DT_INST_LABEL(n), behavior_mouse_key_press_init, NULL, \ | ||
NULL, APPLICATION, CONFIG_KERNEL_INIT_PRIORITY_DEFAULT, \ | ||
&behavior_mouse_key_press_driver_api); | ||
|
||
DT_INST_FOREACH_STATUS_OKAY(KP_INST) |
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,49 @@ | ||
/* | ||
* Copyright (c) 2021 The ZMK Contributors | ||
* | ||
* SPDX-License-Identifier: MIT | ||
*/ | ||
|
||
#define DT_DRV_COMPAT zmk_behavior_mouse_move | ||
|
||
#include <device.h> | ||
#include <drivers/behavior.h> | ||
#include <logging/log.h> | ||
|
||
#include <zmk/event_manager.h> | ||
#include <zmk/events/keycode_state_changed.h> | ||
#include <zmk/behavior.h> | ||
#include <zmk/hid.h> | ||
#include <zmk/endpoints.h> | ||
|
||
LOG_MODULE_DECLARE(zmk, CONFIG_ZMK_LOG_LEVEL); | ||
|
||
static int behavior_mouse_move_init(const struct device *dev) { return 0; }; | ||
|
||
static int on_keymap_binding_pressed(struct zmk_behavior_binding *binding, | ||
struct zmk_behavior_binding_event event) { | ||
LOG_DBG("position %d keycode 0x%02X", event.position, binding->param1); | ||
uint32_t x = (binding->param1 & 0xFFFF0000) >> 16; | ||
uint32_t y = binding->param1 & 0x0000FFFF; | ||
zmk_hid_mouse_movement_press(x, y); | ||
return zmk_endpoints_send_mouse_report(); | ||
} | ||
|
||
static int on_keymap_binding_released(struct zmk_behavior_binding *binding, | ||
struct zmk_behavior_binding_event event) { | ||
LOG_DBG("position %d keycode 0x%02X", event.position, binding->param1); | ||
uint32_t x = (binding->param1 & 0xFFFF0000) >> 16; | ||
uint32_t y = binding->param1 & 0x0000FFFF; | ||
zmk_hid_mouse_movement_release(x, y); | ||
return zmk_endpoints_send_mouse_report(); | ||
} | ||
|
||
static const struct behavior_driver_api behavior_mouse_move_driver_api = { | ||
.binding_pressed = on_keymap_binding_pressed, .binding_released = on_keymap_binding_released}; | ||
|
||
#define KP_INST(n) \ | ||
DEVICE_AND_API_INIT(behavior_mouse_move_##n, DT_INST_LABEL(n), behavior_mouse_move_init, NULL, \ | ||
NULL, APPLICATION, CONFIG_KERNEL_INIT_PRIORITY_DEFAULT, \ | ||
&behavior_mouse_move_driver_api); | ||
|
||
DT_INST_FOREACH_STATUS_OKAY(KP_INST) |
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) 2021 The ZMK Contributors | ||
* | ||
* SPDX-License-Identifier: MIT | ||
*/ | ||
|
||
#define DT_DRV_COMPAT zmk_behavior_mouse_wheel | ||
|
||
#include <device.h> | ||
#include <drivers/behavior.h> | ||
#include <logging/log.h> | ||
|
||
#include <zmk/event_manager.h> | ||
#include <zmk/events/keycode_state_changed.h> | ||
#include <zmk/behavior.h> | ||
#include <zmk/hid.h> | ||
#include <zmk/endpoints.h> | ||
|
||
LOG_MODULE_DECLARE(zmk, CONFIG_ZMK_LOG_LEVEL); | ||
|
||
static int behavior_mouse_wheel_init(const struct device *dev) { return 0; }; | ||
|
||
static int on_keymap_binding_pressed(struct zmk_behavior_binding *binding, | ||
struct zmk_behavior_binding_event event) { | ||
LOG_DBG("position %d keycode 0x%02X", event.position, binding->param1); | ||
int32_t x = (binding->param1 & 0xFF00) >> 8; | ||
int32_t y = binding->param1 & 0x00FF; | ||
zmk_hid_mouse_wheel_press(x, y); | ||
return zmk_endpoints_send_mouse_report(); | ||
} | ||
|
||
static int on_keymap_binding_released(struct zmk_behavior_binding *binding, | ||
struct zmk_behavior_binding_event event) { | ||
LOG_DBG("position %d keycode 0x%02X", event.position, binding->param1); | ||
int32_t x = (binding->param1 & 0xFF00) >> 8; | ||
int32_t y = binding->param1 & 0x00FF; | ||
zmk_hid_mouse_wheel_release(x, y); | ||
return zmk_endpoints_send_mouse_report(); | ||
} | ||
|
||
static const struct behavior_driver_api behavior_mouse_wheel_driver_api = { | ||
.binding_pressed = on_keymap_binding_pressed, .binding_released = on_keymap_binding_released}; | ||
|
||
|
||
#define KP_INST(n) \ | ||
DEVICE_AND_API_INIT(behavior_mouse_wheel_##n, DT_INST_LABEL(n), behavior_mouse_wheel_init, NULL, \ | ||
NULL, APPLICATION, CONFIG_KERNEL_INIT_PRIORITY_DEFAULT, \ | ||
&behavior_mouse_wheel_driver_api); | ||
|
||
DT_INST_FOREACH_STATUS_OKAY(KP_INST) |