forked from kofal.net/zmk
Merge remote-tracking branch 'upstream/main' into CrossR/Sofle
This commit is contained in:
@@ -56,3 +56,5 @@ target_sources_ifdef(CONFIG_ZMK_RGB_UNDERGLOW app PRIVATE src/rgb_underglow.c)
|
||||
target_sources(app PRIVATE src/endpoints.c)
|
||||
target_sources(app PRIVATE src/hid_listener.c)
|
||||
target_sources(app PRIVATE src/main.c)
|
||||
|
||||
zephyr_cc_option(-Wfatal-errors)
|
||||
@@ -1,2 +1,6 @@
|
||||
# Uncomment to enable encoder
|
||||
# CONFIG_EC11=y
|
||||
# CONFIG_EC11_TRIGGER_GLOBAL_THREAD=y
|
||||
|
||||
# Uncomment the following line to enable the Lily58 OLED Display
|
||||
# CONFIG_ZMK_DISPLAY=y
|
||||
|
||||
@@ -45,6 +45,19 @@ RC(3,0) RC(3,1) RC(3,2) RC(3,3) RC(3,4) RC(3,5) RC(4,5) RC(4,6) RC(3,6) RC(3,7)
|
||||
|
||||
};
|
||||
|
||||
left_encoder: encoder_left {
|
||||
compatible = "alps,ec11";
|
||||
label = "LEFT_ENCODER";
|
||||
a-gpios = <&pro_micro_a 3 (GPIO_ACTIVE_HIGH | GPIO_PULL_UP)>;
|
||||
b-gpios = <&pro_micro_a 2 (GPIO_ACTIVE_HIGH | GPIO_PULL_UP)>;
|
||||
resolution = <4>;
|
||||
};
|
||||
|
||||
sensors {
|
||||
compatible = "zmk,keymap-sensors";
|
||||
sensors = <&left_encoder>;
|
||||
};
|
||||
|
||||
bt_unpair_combo: bt_unpair_combo {
|
||||
compatible = "zmk,bt-unpair-combo";
|
||||
};
|
||||
|
||||
@@ -19,6 +19,8 @@
|
||||
&kp LSFT &kp Z &kp X &kp C &kp V &kp B &kp LBKT &kp RBKT &kp N &kp M &kp CMMA &kp DOT &kp FSLH &kp RSFT
|
||||
&kp LALT &kp LGUI &mo 1 &kp SPC &kp RET &mo 2 &kp BKSP &kp RGUI
|
||||
>;
|
||||
|
||||
sensor-bindings = <&inc_dec_cp M_VOLU M_VOLD>;
|
||||
};
|
||||
|
||||
lower_layer {
|
||||
@@ -35,6 +37,8 @@
|
||||
&trans &trans &trans &trans &trans &trans &trans &trans &trans &kp MINUS &kp KPLS &kp LCUR &kp RCUR &kp PIPE
|
||||
&trans &trans &trans &trans &trans &trans &trans &trans
|
||||
>;
|
||||
|
||||
sensor-bindings = <&inc_dec_cp M_VOLU M_VOLD>;
|
||||
};
|
||||
|
||||
raise_layer {
|
||||
@@ -51,6 +55,8 @@
|
||||
&kp F7 &kp F8 &kp F9 &kp F10 &kp F11 &kp F12 &trans &trans &kp KPLS &kp MINUS &kp EQL &kp LBKT &kp RBKT &kp BSLH
|
||||
&trans &trans &trans &trans &trans &trans &trans &trans
|
||||
>;
|
||||
|
||||
sensor-bindings = <&inc_dec_cp M_VOLU M_VOLD>;
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
@@ -1,2 +1,6 @@
|
||||
# Uncomment to enable encoder
|
||||
# CONFIG_EC11=y
|
||||
# CONFIG_EC11_TRIGGER_GLOBAL_THREAD=y
|
||||
|
||||
CONFIG_ZMK_SPLIT=y
|
||||
CONFIG_ZMK_SPLIT_BLE_ROLE_CENTRAL=y
|
||||
CONFIG_ZMK_SPLIT_BLE_ROLE_CENTRAL=y
|
||||
@@ -17,6 +17,10 @@
|
||||
;
|
||||
};
|
||||
|
||||
&bt_unpair_combo {
|
||||
key-positions = <0 42>;
|
||||
&left_encoder {
|
||||
status = "okay";
|
||||
};
|
||||
|
||||
&bt_unpair_combo {
|
||||
key-positions = <0 53>;
|
||||
};
|
||||
|
||||
@@ -22,5 +22,5 @@
|
||||
};
|
||||
|
||||
&bt_unpair_combo {
|
||||
key-positions = <11 43>;
|
||||
key-positions = <11 54>;
|
||||
};
|
||||
|
||||
@@ -156,7 +156,6 @@ static int kscan_gpio_read(struct device *dev)
|
||||
struct kscan_gpio_data *data = dev->driver_data;
|
||||
const struct kscan_gpio_config *cfg = dev->config_info;
|
||||
u32_t read_state = data->pin_state;
|
||||
LOG_DBG("Scanning the pins for updated state");
|
||||
for (int i = 0; i < cfg->num_of_inputs; i++)
|
||||
{
|
||||
struct device *in_dev = kscan_gpio_input_devices(dev)[i];
|
||||
@@ -165,8 +164,9 @@ static int kscan_gpio_read(struct device *dev)
|
||||
}
|
||||
for (int i = 0; i < cfg->num_of_inputs; i++)
|
||||
{
|
||||
bool prev_pressed = BIT(i) & data->pin_state;
|
||||
bool pressed = BIT(i) & read_state;
|
||||
if (pressed != (BIT(i) & data->pin_state))
|
||||
if (pressed != prev_pressed)
|
||||
{
|
||||
LOG_DBG("Sending event at %d,%d state %s",
|
||||
0, i, (pressed ? "on" : "off"));
|
||||
|
||||
@@ -51,10 +51,10 @@ static u8_t zmk_keymap_layer_default = 0;
|
||||
|
||||
// State
|
||||
|
||||
// When a behavior handles a key position "down" event, we record that layer
|
||||
// When a behavior handles a key position "down" event, we record the layer state
|
||||
// here so that even if that layer is deactivated before the "up", event, we
|
||||
// still send the release event to the behavior in that layer also.
|
||||
static u8_t zmk_keymap_active_behavior_layer[ZMK_KEYMAP_LEN];
|
||||
static u32_t zmk_keymap_active_behavior_layer[ZMK_KEYMAP_LEN];
|
||||
|
||||
static struct zmk_behavior_binding zmk_keymap[ZMK_KEYMAP_LAYERS_LEN][ZMK_KEYMAP_LEN] = {
|
||||
DT_INST_FOREACH_CHILD(0, TRANSFORMED_LAYER)
|
||||
@@ -101,47 +101,51 @@ int zmk_keymap_layer_toggle(u8_t layer)
|
||||
return zmk_keymap_layer_activate(layer);
|
||||
};
|
||||
|
||||
bool is_active_position(u32_t position, u8_t layer)
|
||||
bool is_active_layer(u8_t layer, u32_t layer_state)
|
||||
{
|
||||
return (zmk_keymap_layer_state & BIT(layer)) == BIT(layer)
|
||||
|| layer == zmk_keymap_layer_default
|
||||
|| zmk_keymap_active_behavior_layer[position] == layer;
|
||||
return (layer_state & BIT(layer)) == BIT(layer)
|
||||
|| layer == zmk_keymap_layer_default;
|
||||
}
|
||||
|
||||
int zmk_keymap_apply_position_state(int layer, u32_t position, bool pressed)
|
||||
{
|
||||
struct zmk_behavior_binding *binding = &zmk_keymap[layer][position];
|
||||
struct device *behavior;
|
||||
|
||||
LOG_DBG("layer: %d position: %d, binding name: %s", layer, position, log_strdup(binding->behavior_dev));
|
||||
|
||||
behavior = device_get_binding(binding->behavior_dev);
|
||||
|
||||
if (!behavior) {
|
||||
LOG_DBG("No behavior assigned to %d on layer %d", position, layer);
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (pressed) {
|
||||
return behavior_keymap_binding_pressed(behavior, position, binding->param1, binding->param2);
|
||||
} else {
|
||||
return behavior_keymap_binding_released(behavior, position, binding->param1, binding->param2);
|
||||
}
|
||||
}
|
||||
|
||||
int zmk_keymap_position_state_changed(u32_t position, bool pressed)
|
||||
{
|
||||
for (int layer = ZMK_KEYMAP_LAYERS_LEN - 1; layer >= zmk_keymap_layer_default; layer--)
|
||||
{
|
||||
if (is_active_position(position, layer))
|
||||
u32_t layer_state = pressed ? zmk_keymap_layer_state : zmk_keymap_active_behavior_layer[position];
|
||||
if (is_active_layer(layer, layer_state))
|
||||
{
|
||||
struct zmk_behavior_binding *binding = &zmk_keymap[layer][position];
|
||||
struct device *behavior;
|
||||
int ret;
|
||||
int ret = zmk_keymap_apply_position_state(layer, position, pressed);
|
||||
|
||||
LOG_DBG("layer: %d position: %d, binding name: %s", layer, position, log_strdup(binding->behavior_dev));
|
||||
|
||||
behavior = device_get_binding(binding->behavior_dev);
|
||||
|
||||
if (!behavior) {
|
||||
LOG_DBG("No behavior assigned to %d on layer %d", position, layer);
|
||||
continue;
|
||||
}
|
||||
if (pressed) {
|
||||
ret = behavior_keymap_binding_pressed(behavior, position, binding->param1, binding->param2);
|
||||
} else {
|
||||
ret = behavior_keymap_binding_released(behavior, position, binding->param1, binding->param2);
|
||||
}
|
||||
|
||||
zmk_keymap_active_behavior_layer[position] = zmk_keymap_layer_state;
|
||||
|
||||
if (ret > 0) {
|
||||
LOG_DBG("behavior processing to continue to next layer");
|
||||
continue;
|
||||
} else if (ret < 0) {
|
||||
LOG_DBG("Behavior returned error: %d", ret);
|
||||
zmk_keymap_active_behavior_layer[position] = 0;
|
||||
return ret;
|
||||
} else {
|
||||
zmk_keymap_active_behavior_layer[position] = pressed ? layer : 0;
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user