Commit Graph

41 Commits

Author SHA1 Message Date
Peter Johanson fa110488b0 fix(split): Add define for local source.
* Add `ZMK_POSITION_STATE_CHANGE_SOURCE_LOCAL` and use
  it consinstently to fix bug w/ local `&reset`, `&bootloader`, etc.
2022-01-31 23:03:34 -05:00
Peter Johanson 9297c5f2b4 refactor(splits): Use index for event source.
* Track peripherals by indexes slot, with all appropiate peripheral
  state stored in the slot.
* Event sources tracked by peripheral slot index.
2022-01-31 23:03:34 -05:00
Pete Johanson 47f873b038 feature(split): behavior locality support.
* GATT characteristic allowing passng data + behavior
  label to invoke the behavior on the peripheral side.
* Behaviors have a locality setting to specify where they run.
* Build reset/power/RGB on peripheral.
2022-01-31 23:03:34 -05:00
Pete Johanson e6f168d6df refactor(behaviors): Convert state dependent params.
* Allow each behavior to map a relative binding, e.g. "toggle",
  to an absolute one, e.g. "on", before being invoked.
2021-02-09 01:27:50 -05:00
Okke Formsma 84d19fe79b refactor(behaviors): factor out multiple uses of _TRANSFORM_ENTRY 2021-02-02 00:43:26 -05:00
Pete Johanson 3368a81057 refactor(core): Combine `is_` and `cast_` event functions.
* Use a single `as_foo` generated function to conditionally
  return a certain event type from a generic `zmk_event_t*`
  pointer.
2021-01-20 07:06:11 -05:00
Pete Johanson 3fe2acc2d1 refactor(core): Extra event payloads to own types, refactor API.
* Make it easier to use *just* event payloads by defining the data,
  and then having event manager macros generate "wrapper structs"
* Improve is_*/cast_* APIs to hide details of full event struct.
* Create `zmk_event_t` typedef to pass to event handlers.
* Bring event names inline w/ consistent `zmk_` prefix.
2021-01-20 07:06:11 -05:00
Pete Johanson 003db892ad refactor(core): Extra position state change data struct.
* Separate header and data struct for the event.
* Remove duplicate struct in split code.
2021-01-20 07:06:11 -05:00
Pete Johanson a55b1397c9 feat(keymap): API for retrieving label for a layer 2021-01-04 13:02:38 -05:00
KemoNine d207c3c30f
(feature) Add &to keycode/behavior (#489)
feat(behaviors): Add `&to` behavior to switch to a layer.
2020-12-29 11:57:49 -05:00
innovaker 0e71dbc860 refactor(app): replace zmk_keymap_layers_state with zmk_keymap_layers_state_t
Aligns with typedef _t convention.

PR: #531
2020-12-28 10:20:12 -05:00
innovaker 842aa5a842 refactor: replace filename hyphens with underscores
Aligns *.h and *.c to underscore naming convention.

These were kept (with warnings) for backwards compatibility with external boards/shields:
- kscan-mock.h
- matrix-transform.h
They should be removed in the future.

PR: #523
2020-12-28 01:15:35 -05:00
innovaker 00ca0d2f1c refactor(app): replace `struct device *` with `const struct device *`
Replaced with RegExp: /(?<!const )(struct device \*)/g

See: https://docs.zephyrproject.org/latest/releases/release-notes-2.4.html
PR: #467
2020-12-14 12:41:25 -05:00
innovaker bac1f17cf6 refactor(app): replace Zephyr integer types with C99 integer types
u8_t → uint8_t
u16_t → uint16_t
u32_t → uint32_t
u64_t → uint64_t
s8_t → int8_t
s16_t → int16_t
s32_t → int32_t
s64_t → int64_t

Prerequisite for #223
See: https://github.com/zephyrproject-rtos/zephyr/releases/tag/zephyr-v2.4.0
PR: #467
2020-12-14 12:41:25 -05:00
KemoNine 2427a4ab33
feature(keymaps): Keymap layer state event, highest layer API
* Fire an event w/ layer number, state, and timestamp
  when a layer is activated/deactivated.
* Add `zmk_keymap_highest_layer_active()` query.

Co-authored-by: KemoNine <mcrosson@kemonine.info>
2020-12-09 09:35:57 -05:00
Okke Formsma bee45f9b3a feat(events): add timestamp to keycode_state_changed and sensor_event
These timestamps are necessary to correctly deal with delayed events due to hold-tap shenanigans.
2020-11-28 00:58:24 -05:00
Okke Formsma e48a6b659c fix momentary layer bug when top layer is not &trans
Key release events released keys on the wrong layer if the 'top layer'
was not &trans above the &mo key.

base    <&mo 1>
layer 1 <&kp B>

This was caused by overwriting
`zmk_keymap_active_behavior_layer[position]` after the &mo key was
handled.
2020-11-16 17:19:27 -05:00
Okke Formsma 4f258efbf1 initial implementation for modifiers
https://github.com/zmkfirmware/zmk/issues/86
2020-11-03 00:19:37 -05:00
Okke Formsma d38740cebf
Add timestamps to position and behavior events (#147)
* Add timestamps to position events and behaviors.

- Take original event timestamps into consideration so nested tap-holds have proper timing.
- Add position and timestamp to keycode state changed event so the one-shot behavior can properly identify other keypresses and timings.
- Add timestamp to position events received from peripheral

* reduce number of arguments to behaviors
2020-10-10 17:32:53 -04:00
Pete Johanson 191a2d755a chore: clang-format the codebase.
* Use the LLVM style
* Override indent width (8) and column limit (100)
* Fixes #142.
2020-09-14 00:10:34 -04:00
Pete Johanson 68e72f9275 fix: Switch to single AUTHORS file.* Closes #164 2020-09-10 10:24:23 -04:00
Cody McGinnis 639a338c2d fix(core): track layer state with keypress 2020-09-01 09:49:21 -04:00
Cody McGinnis 50643b2c56 fix(keymap): add brackets around if statement body 2020-08-18 14:21:39 -04:00
Cody McGinnis 7facb6eee8 fix(keymap): move the toggle layer logic to keymap.c 2020-08-18 14:02:25 -04:00
Cody McGinnis a82f990d4c feat(keymap): allow users to toggle layers 2020-08-18 14:02:24 -04:00
Pete Johanson 3127192720 Invoke called behavior after layer change.
* If you press a key with a layer active, then
  deactivate the layer (e.g. releasing a `&mo`,
  then release the key, we currently may send
  the wrong key release event.
* Fixes #67.
2020-08-09 12:30:47 -04:00
Pete Johanson 01b8b724c1 Remove debugging line that snuck in. 2020-08-06 23:54:18 -04:00
Pete Johanson 0460631729 Refactor to simpler keymaps. 2020-08-06 23:28:34 -04:00
Pete Johanson 34ff6190bd Initial behavior for key presses on encoder rotate 2020-07-22 14:54:18 -04:00
Pete Johanson 4d73938cb5 More sensor keymap work. 2020-07-22 10:10:04 -04:00
Pete Johanson adfa1b5443 Initial work on sensor bindings. 2020-07-22 02:13:52 -04:00
Pete Johanson 7bf8621d5b Whitespace fix. 2020-06-30 16:39:29 -04:00
Pete Johanson 9a991bf019 Initial event manager work, and two first events.
* Add initial event manager implementation,
  roughly mimicking Nordic's API.
* Add `position_state_changed` and
  `keycode_state_changed` events.
* Hook up HID and keymap to new events
  instead of using behaviour global event
  crazy.
2020-06-30 00:31:09 -04:00
Pete Johanson 5ffd95694f Kyria left/right overlays, matrix transform fixes
* Refactor Kyria into separate left/right "revisions"
  of the Kyria shield, and include central
  kyria.dtsi file with common definition.
* Fixes for keymaps to work fully with matrix
  transforms that override effective rows/columns.
* Add ability for matrix transform to do row/col
  offsets, which is needed for split keyboards.
2020-06-27 00:16:15 -04:00
Pete Johanson 55cf9db564 Fix consumer keys w/ refactored behaviors. 2020-06-22 11:06:01 -04:00
Pete Johanson 223edf05ad Refactor global bindings, implement mod-tap.
* Use extra comptible = "zmk,behavior-global" to add
   behaviors to global bindings for event notification.
* Implement mod-tap, as a keymap binding and global one
  to skip tap if other keycode pressed while held.
2020-06-21 21:43:44 -04:00
Pete Johanson 7e659851c8 Refactor matrix transform, positions pervasively
* Do mapping to positions right in kscan handler, and then
  surface positions throughout the API.
2020-06-20 17:54:52 -04:00
Pete Johanson c23d752917 Some initial work on behavior bindings for keymaps 2020-06-19 15:32:33 -04:00
Pete Johanson 1659562bb7 Rename keymap-transform to matrix-transform.
* Clearer name to capture essence of the role of the
  transform.
2020-06-16 21:35:44 -04:00
Pete Johanson 1751470785 Initial work on keymap transforms for non-standard matrixes.
* Allows "gaps" for keyboards like Kyra.
* Allows keyboards with matrixes that don't map the logical key
  locations to have normal looking keymaps when defined.
2020-06-15 17:03:34 -04:00
Pete Johanson 38f1dbd984 Move Zephyr app into subdirectory. 2020-06-08 21:07:16 -04:00
Renamed from src/keymap.c (Browse further)