Skip to content

Commit

Permalink
refactor moudle
Browse files Browse the repository at this point in the history
  • Loading branch information
tokyo2006 committed Dec 14, 2024
1 parent 2d0b6a2 commit fa530ee
Show file tree
Hide file tree
Showing 16 changed files with 177 additions and 441 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ name: Build ZMK firmware
on:
workflow_dispatch:
push:
paths:
- "config/**"
paths-ignore:
- "keymap-drawer/**"

jobs:
build:
Expand Down
18 changes: 18 additions & 0 deletions .github/workflows/draw.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
name: Draw Keymap
on:
workflow_dispatch:
push:
paths:
- "config/**"
- .github/workflows/draw.yml
- keymap_drawer.config.yaml

jobs:
draw:
uses: caksoylar/keymap-drawer/.github/workflows/draw-zmk.yml@main
permissions:
contents: write
with:
commit_message: "[Draw] ${{ github.event.head_commit.message }}"
destination: "commit"
fail_on_error: ${{ fromJSON(true) }} of extra args to pass to `keymap draw`, e.g. "corne:'-k corne_rotated' cradio:'-k paroxysm'"
25 changes: 0 additions & 25 deletions .github/workflows/keymap_drawer.yml

This file was deleted.

11 changes: 9 additions & 2 deletions build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,15 @@ include:
shield: oddball_central_dongle dongle_display
artifact-name: oddball_central_dongle
- board: nice_nano_v2
shield: oddball_central_left
artifact-name: oddball_central_left
shield: oddball_central_dongle dongle_display
snippet: studio-rpc-usb-uart
cmake-args: -DCONFIG_ZMK_STUDIO=y -DCONFIG_ZMK_STUDIO_LOCKING=n
artifact-name: corne_studio_dongle
- board: nice_nano_v2
shield: oddball_central_dongle prospector_adapter
snippet: studio-rpc-usb-uart
cmake-args: -DCONFIG_ZMK_STUDIO=y -DCONFIG_ZMK_STUDIO_LOCKING=n
artifact-name: corne_studio_dongle_prospector
- board: nice_nano_v2
shield: oddball_peripheral_left
artifact-name: oddball_peripheral_left
Expand Down
52 changes: 52 additions & 0 deletions config/boards/shields/oddball/oddball-layouts.dtsi
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
#include <physical_layouts.dtsi>

/ {
oddball_layout: oddball_layout {
compatible = "zmk,physical-layout";
display-name = "default";
transform = <&default_transform>;

keys // w h x y rot rx ry
= <&key_physical_attrs 100 100 0 38 0 0 0>
, <&key_physical_attrs 100 100 100 38 0 0 0>
, <&key_physical_attrs 100 100 200 12 0 0 0>
, <&key_physical_attrs 100 100 300 0 0 0 0>
, <&key_physical_attrs 100 100 400 12 0 0 0>
, <&key_physical_attrs 100 100 500 25 0 0 0>
, <&key_physical_attrs 100 100 900 25 0 0 0>
, <&key_physical_attrs 100 100 1000 12 0 0 0>
, <&key_physical_attrs 100 100 1100 0 0 0 0>
, <&key_physical_attrs 100 100 1200 12 0 0 0>
, <&key_physical_attrs 100 100 1300 38 0 0 0>
, <&key_physical_attrs 100 100 1400 38 0 0 0>
, <&key_physical_attrs 100 100 0 138 0 0 0>
, <&key_physical_attrs 100 100 100 138 0 0 0>
, <&key_physical_attrs 100 100 200 112 0 0 0>
, <&key_physical_attrs 100 100 300 100 0 0 0>
, <&key_physical_attrs 100 100 400 112 0 0 0>
, <&key_physical_attrs 100 100 500 125 0 0 0>
, <&key_physical_attrs 100 100 900 125 0 0 0>
, <&key_physical_attrs 100 100 1000 112 0 0 0>
, <&key_physical_attrs 100 100 1100 100 0 0 0>
, <&key_physical_attrs 100 100 1200 112 0 0 0>
, <&key_physical_attrs 100 100 1300 138 0 0 0>
, <&key_physical_attrs 100 100 1400 138 0 0 0>
, <&key_physical_attrs 100 100 0 238 0 0 0>
, <&key_physical_attrs 100 100 100 238 0 0 0>
, <&key_physical_attrs 100 100 200 212 0 0 0>
, <&key_physical_attrs 100 100 300 200 0 0 0>
, <&key_physical_attrs 100 100 400 212 0 0 0>
, <&key_physical_attrs 100 100 500 225 0 0 0>
, <&key_physical_attrs 100 100 900 225 0 0 0>
, <&key_physical_attrs 100 100 1000 212 0 0 0>
, <&key_physical_attrs 100 100 1100 200 0 0 0>
, <&key_physical_attrs 100 100 1200 212 0 0 0>
, <&key_physical_attrs 100 100 1300 238 0 0 0>
, <&key_physical_attrs 100 100 1400 238 0 0 0>
, <&key_physical_attrs 100 100 348 314 0 0 0>
, <&key_physical_attrs 100 100 348 314 1500 398 764>
, <&key_physical_attrs 100 100 348 312 3000 398 764>
, <&key_physical_attrs 100 100 1052 314 (-1500) 1102 764>
;
};
};
7 changes: 6 additions & 1 deletion config/boards/shields/oddball/oddball.dtsi
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
#include <dt-bindings/zmk/matrix_transform.h>
#include "oddball-layouts.dtsi"

/ {
chosen {
zmk,kscan = &kscan0;
zmk,matrix_transform = &default_transform;
zmk,physical-layout = &oddball_layout;
};

default_transform: keymap_transform_0 {
Expand Down Expand Up @@ -32,3 +33,7 @@
;
};
};

zephyr_udc0: &usbd {
status = "okay";
};
2 changes: 2 additions & 0 deletions config/boards/shields/oddball/oddball_central_dongle.conf
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ CONFIG_ZMK_MOUSE=y
CONFIG_PINCTRL=y
CONFIG_SPI=y
CONFIG_INPUT=y
CONFIG_ZMK_POINTING=y
CONFIG_ZMK_POINTING_SMOOTH_SCROLLING=y
CONFIG_ZMK_EXT_POWER=y
CONFIG_PMW3610=y
CONFIG_PMW3610_SWAP_XY=y
Expand Down
150 changes: 2 additions & 148 deletions config/boards/shields/oddball/oddball_central_dongle.overlay
Original file line number Diff line number Diff line change
Expand Up @@ -3,41 +3,14 @@
*
* SPDX-License-Identifier: MIT
*/
#include <dt-bindings/zmk/matrix_transform.h>

#define INPUT_EV_KEY 0x01 /**< Key event */
#define INPUT_EV_REL 0x02 /**< Relative coordinate event */
#define INPUT_EV_ABS 0x03 /**< Absolute coordinate event */
#define INPUT_EV_MSC 0x04 /**< Miscellaneous event */
#define INPUT_EV_VENDOR_START 0xf0 /**< Vendor specific event start */
#define INPUT_EV_VENDOR_STOP 0xff /**< Vendor specific event stop */

#define INPUT_REL_X 0x00 /**< Relative X coordinate */
#define INPUT_REL_Y 0x01 /**< Relative Y coordinate */
#define INPUT_REL_WHEEL 0x08 /**< Relative wheel coordinate */
#define INPUT_REL_HWHEEL 0x06 /**< Relative horizontal wheel coordinate */
#define INPUT_REL_MISC 0x09 /**< Relative misc coordinate */

#include "oddball.dtsi"
#include "oddball_trackball.dtsi"

/ {
chosen {
zmk,kscan = &mock_kscan;
zmk,matrix-transform = &default_transform;
zephyr,display = &oled;
};

default_transform: keymap_transform_0 {
compatible = "zmk,matrix-transform";
columns = <12>;
rows = <4>;
map = <
RC(0,0) RC(0,1) RC(0,2) RC(0,3) RC(0,4) RC(0,5) RC(0,6) RC(0,7) RC(0,8) RC(0,9) RC(0,10) RC(0,11)
RC(1,0) RC(1,1) RC(1,2) RC(1,3) RC(1,4) RC(1,5) RC(1,6) RC(1,7) RC(1,8) RC(1,9) RC(1,10) RC(1,11)
RC(2,0) RC(2,1) RC(2,2) RC(2,3) RC(2,4) RC(2,5) RC(2,6) RC(2,7) RC(2,8) RC(2,9) RC(2,10) RC(2,11)
RC(3,2) RC(3,3) RC(3,4) RC(3,10)
>;
};

mock_kscan: kscan_0 {
compatible = "zmk,kscan-mock";
columns = <0>;
Expand All @@ -46,125 +19,6 @@
};
};

#include "oddball_trackball.dtsi"

/ {
/* define virtual input, will be resurrected for emitting input event */
/* NOTE: set `device = <&pd1>` in `zmk,input-listener` */
pd1: virtual_input {
compatible = "zmk,virtual-input";
};
};

/ {
/* for central side, define (relay-channel)-to-(virtual-input) mapping */
input_relay_config_102 {
compatible = "zmk,split-peripheral-input-relay";

/* channel id, used to filter incoming annotated input event from split peripheral */
/* NOTE: should matching relay-channel on peripheral overlay */
relay-channel = <102>;

/* virtual input device on central, which used to emit input event as an agent device */
device = <&pd1>;
};
};

/{
trackball_listener {
compatible = "zmk,input-listener";
device = <&pd1>;
};
};

/{
/* auto toggle mouse key layer */
trackball_peripheral_auto_mouse_listener {
compatible = "zmk,input-behavior-listener";
device = <&pd1>;
layers = <0>;
rotate-deg = <315>;
evt-type = <INPUT_EV_REL>;
x-input-code = <INPUT_REL_X>;
y-input-code = <INPUT_REL_WHEEL>;
scale-multiplier = <1>;
scale-divisor = <1>;
bindings = <&ib_tog_layer 5>;
};

/* input config for mouse scroll mode on momentary mouse scoll layer */
trackball_peripheral_scroll_listener {
compatible = "zmk,input-behavior-listener";
device = <&pd1>;
layers = <1 2 3 4>;
evt-type = <INPUT_EV_REL>;
/* slienting x-axis with alt event code */
x-input-code = <INPUT_REL_HWHEEL>;
y-input-code = <INPUT_REL_WHEEL>;
/* invent scrolling direction */
y-invert;
/* align to CCW 45 degree */
rotate-deg = <180>;
/* 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_x 1 8 &ib_wheel_scaler_y 1 10>;
};

trackball_peripheral_snipe_listener {
compatible = "zmk,input-behavior-listener";
device = <&pd1>;
layers = <6>;
evt-type = <INPUT_EV_REL>;
x-input-code = <INPUT_REL_X>;
y-input-code = <INPUT_REL_Y>;
scale-multiplier = <1>;
scale-divisor = <1>;
rotate-deg = <315>;
bindings = <&ib_snipe_scaler_x 1 8 &ib_snipe_scaler_y 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 = <2000>;
};

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

ib_wheel_scaler_y: ib_wheel_scaler_y {
compatible = "zmk,input-behavior-scaler";
#binding-cells = <2>;
evt-type = <INPUT_EV_REL>;
input-code = <INPUT_REL_HWHEEL>;
};

ib_snipe_scaler_x: ib_snipe_scaler_x {
compatible = "zmk,input-behavior-scaler";
#binding-cells = <2>;
evt-type = <INPUT_EV_REL>;
input-code = <INPUT_REL_X>;
};

ib_snipe_scaler_y: ib_snipe_scaler_y {
compatible = "zmk,input-behavior-scaler";
#binding-cells = <2>;
evt-type = <INPUT_EV_REL>;
input-code = <INPUT_REL_Y>;
};
};

&pinctrl {
i2c0_default: i2c0_default {
group1 {
Expand Down
43 changes: 0 additions & 43 deletions config/boards/shields/oddball/oddball_central_left.conf

This file was deleted.

Loading

0 comments on commit fa530ee

Please sign in to comment.