Skip to content

Commit

Permalink
test badjeff's driver
Browse files Browse the repository at this point in the history
  • Loading branch information
280Zo committed Aug 22, 2024
1 parent 95e05f6 commit 30a4dbc
Show file tree
Hide file tree
Showing 4 changed files with 118 additions and 42 deletions.
32 changes: 13 additions & 19 deletions config/boards/shields/charybdis-mini-wireless/charybdis_right.conf
Original file line number Diff line number Diff line change
Expand Up @@ -7,23 +7,17 @@ CONFIG_INPUT=y
CONFIG_ZMK_MOUSE=y
CONFIG_PMW3610=y

# https://github.com/inorichi/zmk-pmw3610-driver/blob/main/Kconfig
# https://github.com/badjeff/zmk-pmw3610-driver
CONFIG_SPI=y
CONFIG_INPUT=y
CONFIG_ZMK_MOUSE=y
CONFIG_PMW3610=y
# CONFIG_PMW3610_SWAP_XY=y
# CONFIG_PMW3610_INVERT_X=y
# CONFIG_PMW3610_INVERT_Y=y
# CONFIG_PMW3610_REPORT_INTERVAL_MIN=12
# CONFIG_PMW3610_LOG_LEVEL_DBG=y
CONFIG_PMW3610_SMART_ALGORITHM=y
CONFIG_PMW3610_CPI=1200
CONFIG_PMW3610_CPI_DIVIDOR=3
CONFIG_PMW3610_SNIPE_CPI=200
CONFIG_PMW3610_SNIPE_CPI_DIVIDOR=1
CONFIG_PMW3610_SCROLL_TICK=20

CONFIG_PMW3610_POLLING_RATE_125_SW=y
# CONFIG_PMW3610_POLLING_RATE_125=y
# CONFIG_PMW3610_POLLING_RATE_250=y

CONFIG_PMW3610_FORCE_AWAKE=y
# CONFIG_PMW3610_RUN_DOWNSHIFT_TIME_MS=2500
# CONFIG_PMW3610_REST1_SAMPLE_TIME_MS=10

CONFIG_PMW3610_ORIENTATION_90=y
CONFIG_PMW3610_INVERT_X=y
CONFIG_PMW3610_INVERT_SCROLL_Y=n
CONFIG_PMW3610_AUTOMOUSE_TIMEOUT_MS=450
CONFIG_PMW3610_RUN_DOWNSHIFT_TIME_MS=128
CONFIG_PMW3610_REST1_DOWNSHIFT_TIME_MS=5000
CONFIG_PMW3610_REST1_SAMPLE_TIME_MS=40
Original file line number Diff line number Diff line change
Expand Up @@ -16,21 +16,21 @@
;
};

// https://github.com/inorichi/zmk-pmw3610-driver
// https://github.com/badjeff/zmk-pmw3610-driver
&pinctrl {
spi0_default: spi0_default {
group1 {
psels = <NRF_PSEL(SPIM_SCK, 0, 8)>,
<NRF_PSEL(SPIM_MOSI, 0, 17)>,
<NRF_PSEL(SPIM_MISO, 0, 17)>;
psels = <NRF_PSEL(SPIM_SCK, 0, 8)>,
<NRF_PSEL(SPIM_MOSI, 0, 17)>,
<NRF_PSEL(SPIM_MISO, 0, 17)>;
};
};

spi0_sleep: spi0_sleep {
group1 {
psels = <NRF_PSEL(SPIM_SCK, 0, 8)>,
<NRF_PSEL(SPIM_MOSI, 0, 17)>,
<NRF_PSEL(SPIM_MISO, 0, 17)>;
psels = <NRF_PSEL(SPIM_SCK, 0, 8)>,
<NRF_PSEL(SPIM_MOSI, 0, 17)>,
<NRF_PSEL(SPIM_MISO, 0, 17)>;
low-power-enable;
};
};
Expand All @@ -50,10 +50,10 @@
reg = <0>;
spi-max-frequency = <2000000>;
irq-gpios = <&gpio0 6 (GPIO_ACTIVE_LOW | GPIO_PULL_UP)>;
/* optional features */
snipe-layers = <8>;
scroll-layers = <1 2 3 9>;
// automouse-layer = <7>;
cpi = <600>;
evt-type = <INPUT_EV_REL>;
x-input-code = <INPUT_REL_X>;
y-input-code = <INPUT_REL_Y>;
};
};

Expand Down
97 changes: 88 additions & 9 deletions config/charybdis.keymap
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,86 @@
chosen { zmk,matrix_transform = &default_transform; };
};

// index of keymap layers
#define DEF 0 // default layer
#define MSK 7 // mouse key layer
#define MSC 9 // mouse scoll layer

/ {
/* input config for mouse move mode on default layer (DEF & MSK) */
tb0_mmv_ibl {
/* new forked compatible name */
compatible = "zmk,input-behavior-listener";

/* the input point device alias */
device = <&pd0>;

/* only enable in default layer (DEF) & mouse key layer (MSK) */
layers = <DEF MSK>;

/* event code value to override raw input event */
/* designed for switching to mouse scroll, xy-swap, precise-mode+, etc */
/* NOTE: only apply input-code overriding for INPUT_EV_REL */
evt-type = <INPUT_EV_REL>;
x-input-code = <INPUT_REL_X>;
y-input-code = <INPUT_REL_Y>;
scale-multiplier = <1>;
scale-divisor = <1>;

/* bind a behavior to auto activate MSK layer for &mkp */
bindings = <&ib_tog_layer MSK>;

/* align to CCW 45 degree */
rotate-deg = <315>;
/* NOTE 1: This settings do not compitable with y-invert and x-invert */
/* NOTE 2: Floating point computation requires alot of ram. */
/* This feature will cuase stackove flow with CONFIG_ZMK_USB_LOGGING=y */
};

/* input config for mouse scroll mode on momentary mouse scoll layer (MSC) */
tb0_msl_ibl {
compatible = "zmk,input-behavior-listener";
device = <&pd0>;
layers = <MSC>;
evt-type = <INPUT_EV_REL>;

/* slienting x-axis with alt event code */
x-input-code = <INPUT_REL_MISC>;
y-input-code = <INPUT_REL_WHEEL>;

/* invent scrolling direction */
y-invert;

/* align to CCW 45 degree */
rotate-deg = <315>;
/* NOTE 1: This settings do not compitable with y-invert and x-invert */
/* NOTE 2: Floating point computation requires alot of ram. */
/* This feature will cuase stackove flow with CONFIG_ZMK_USB_LOGGING=y */

/* bind a behavior to down scaling input value to (1/8) */
/* NOTE: This behavior is different to scale-divisor. */
/* The delta value is accumlated until result >= 1 after cast. */
/* The scrolling is preented in hi-res and allow precise scrolling */
bindings = <&ib_wheel_scaler 1 8>;
};

/* adjust cooldown waiting period for mouse key layer (MSK) after activated */
ib_tog_layer: ib_tog_layer {
compatible = "zmk,input-behavior-tog-layer";
#binding-cells = <1>;
time-to-live-ms = <1000>;
};

/* define a resolution down scaler only for INPUT_REL_WHEEL */
ib_wheel_scaler: ib_wheel_scaler {
compatible = "zmk,input-behavior-scaler";
#binding-cells = <2>;
evt-type = <INPUT_EV_REL>;
input-code = <INPUT_REL_WHEEL>;
};



behaviors {
hm: homerow_mod {
compatible = "zmk,behavior-hold-tap";
Expand Down Expand Up @@ -95,15 +174,15 @@

BASE {
bindings = <
// ╭────────────────┬──────────────┬─────────────────────────┬─────────────────────────────┬──────────────────┬─────────╮ ╭──────────────┬─────────────────┬─────────────────────────────────┬──────────────────────────────┬────────────────────────┬───────╮
&kp C_AC_SEARCH &kp Q &kp W &kp E &kp R &kp T &kp Y &kp U &kp I &kp O &kp P &to 4
// ├────────────────┼──────────────┼─────────────────────────┼─────────────────────────────┼──────────────────┼─────────┤ ├──────────────┼─────────────────┼─────────────────────────────────┼──────────────────────────────┼────────────────────────┼───────┤
&hm LG(E) TAB &hm LEFT_GUI A &hm LEFT_ALT S &hm LCTRL D &hm LEFT_SHIFT F &kp G &kp H &hm LEFT_SHIFT J &hm RCTRL K &hm RIGHT_ALT L &hm LEFT_META SEMICOLON &kp DEL
// ├────────────────┼──────────────┼─────────────────────────┼─────────────────────────────┼──────────────────┼─────────┤ ├──────────────┼─────────────────┼─────────────────────────────────┼──────────────────────────────┼────────────────────────┼───────┤
&kp LA(LC(T)) &kp Z &hm LC(LA(LEFT_SHIFT)) X &hm LA(LC(LG(LEFT_SHIFT))) C &kp V &kp B &kp N &kp M &hm LA(LC(LG(LEFT_SHIFT))) COMMA &hm LC(LA(LEFT_SHIFT)) PERIOD &kp FSLH &to 5
// ╰────────────────┴──────────────┴─────────────────────────┼─────────────────────────────┼──────────────────┼─────────┤ ├──────────────┼─────────────────┼─────────────────────────────────┴──────────────────────────────┴────────────────────────┴───────╯
&lt 1 BACKSPACE &lt 2 ESCAPE &tdbt &lt 7 RETURN &lt 3 SPACE
// ╰─────────────────────────────┴──────────────────┴─────────╯ ╰──────────────┴───────────╯
// ╭────────────────┬──────────────┬─────────────────────────┬─────────────────────────────┬──────────────────┬──────────────╮ ╭──────────────┬─────────────────┬─────────────────────────────────┬──────────────────────────────┬────────────────────────┬───────╮
&kp C_AC_SEARCH &kp Q &kp W &kp E &kp R &kp T &kp Y &kp U &kp I &kp O &kp P &to 4
// ├────────────────┼──────────────┼─────────────────────────┼─────────────────────────────┼──────────────────┼──────────────┤ ├──────────────┼─────────────────┼─────────────────────────────────┼──────────────────────────────┼────────────────────────┼───────┤
&hm LG(E) TAB &hm LEFT_GUI A &hm LEFT_ALT S &hm LCTRL D &hm LEFT_SHIFT F &kp G &kp H &hm LEFT_SHIFT J &hm RCTRL K &hm RIGHT_ALT L &hm LEFT_META SEMICOLON &kp DEL
// ├────────────────┼──────────────┼─────────────────────────┼─────────────────────────────┼──────────────────┼──────────────┤ ├──────────────┼─────────────────┼─────────────────────────────────┼──────────────────────────────┼────────────────────────┼───────┤
&kp LA(LC(T)) &kp Z &hm LC(LA(LEFT_SHIFT)) X &hm LA(LC(LG(LEFT_SHIFT))) C &kp V &kp B &kp N &kp M &hm LA(LC(LG(LEFT_SHIFT))) COMMA &hm LC(LA(LEFT_SHIFT)) PERIOD &kp FSLH &to 5
// ╰────────────────┴──────────────┴─────────────────────────┼─────────────────────────────┼──────────────────┼──────────────┤ ├──────────────┼─────────────────┼─────────────────────────────────┴──────────────────────────────┴────────────────────────┴───────╯
&tdtb &lt 1 BACKSPACE &lt 2 ESCAPE &lt 7 RETURN &lt 3 SPACE
// ╰─────────────────────────────┴──────────────────┴──────────────╯ ╰──────────────┴───────────╯
>;
};

Expand Down
9 changes: 6 additions & 3 deletions config/west.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,18 @@ manifest:
remotes:
- name: zmkfirmware
url-base: https://github.com/petejohanson
- name: pmw3610k-driver
url-base: https://github.com/inorichi
- name: badjeff
url-base: https://github.com/badjeff
projects:
- name: zmk
remote: zmkfirmware
revision: feat/pointers-move-scroll
import: app/west.yml
- name: zmk-pmw3610-driver
remote: pmw3610k-driver
remote: badjeff
revision: main
- name: zmk-input-behavior-listener
remote: badjeff
revision: main
self:
path: config
Expand Down

0 comments on commit 30a4dbc

Please sign in to comment.