From a331de779686029da924c28393badf99b1bb61bb Mon Sep 17 00:00:00 2001 From: Peter Johanson Date: Mon, 24 Jun 2024 15:10:38 -0600 Subject: [PATCH] feat: Initial message definitions. --- LICENSE | 21 +++++++++++ README.md | 8 +++++ protos/zmk/.gitignore | 2 ++ protos/zmk/behaviors.options.in | 0 protos/zmk/behaviors.proto | 64 +++++++++++++++++++++++++++++++++ protos/zmk/core.proto | 29 +++++++++++++++ protos/zmk/keymap.proto | 9 +++++ protos/zmk/meta.proto | 18 ++++++++++ protos/zmk/studio.options.in | 0 protos/zmk/studio.proto | 41 +++++++++++++++++++++ zephyr/module.yml | 1 + 11 files changed, 193 insertions(+) create mode 100644 LICENSE create mode 100644 README.md create mode 100644 protos/zmk/.gitignore create mode 100644 protos/zmk/behaviors.options.in create mode 100644 protos/zmk/behaviors.proto create mode 100644 protos/zmk/core.proto create mode 100644 protos/zmk/keymap.proto create mode 100644 protos/zmk/meta.proto create mode 100644 protos/zmk/studio.options.in create mode 100644 protos/zmk/studio.proto create mode 100644 zephyr/module.yml diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..186ff6a --- /dev/null +++ b/LICENSE @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2024 The ZMK Contributors + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/README.md b/README.md new file mode 100644 index 0000000..0db5241 --- /dev/null +++ b/README.md @@ -0,0 +1,8 @@ +# ZMK Studio Messages + +This repository contains the message definitions used to interract with ZMK Studio enabled devices. + +## TODO + +* Document transport protocol used with these messages +* Release/versioning strategy diff --git a/protos/zmk/.gitignore b/protos/zmk/.gitignore new file mode 100644 index 0000000..2dd31c3 --- /dev/null +++ b/protos/zmk/.gitignore @@ -0,0 +1,2 @@ +include/ +src/ \ No newline at end of file diff --git a/protos/zmk/behaviors.options.in b/protos/zmk/behaviors.options.in new file mode 100644 index 0000000..e69de29 diff --git a/protos/zmk/behaviors.proto b/protos/zmk/behaviors.proto new file mode 100644 index 0000000..576f992 --- /dev/null +++ b/protos/zmk/behaviors.proto @@ -0,0 +1,64 @@ +syntax = "proto3"; + +package zmk.behaviors; + +message Request { + oneof request_type { + bool list_all_behaviors = 1; + GetBehaviorDetailsRequest get_behavior_details = 2; + } +} + +message GetBehaviorDetailsRequest { + uint32 behavior_id = 1; +} + +message Response { + oneof response_type { + ListAllBehaviorsResponse list_all_behaviors = 1; + GetBehaviorDetailsResponse get_behavior_details = 2; + } +} + +message ListAllBehaviorsResponse { + repeated uint32 behaviors = 1; +} + +message GetBehaviorDetailsResponse { + uint32 id = 1; + string display_name = 2; + repeated BehaviorBindingParametersSet metadata = 3; +} + +enum BehaviorBindingParameterStandardDomain { + NIL = 0; + HID_USAGE = 1; + LAYER_INDEX = 2; + // HSV_VALUE = 3; +} + +message BehaviorBindingParametersSet { + repeated BehaviorParameterValueDescription param1 = 1; + repeated BehaviorParameterValueDescription param2 = 2; +} + +message BehaviorParameterValueDescriptionRange { + int32 min = 1; + int32 max = 2; +} + +message BehaviorParameterNil {} +message BehaviorParameterLayerIndex {} +message BehaviorParameterHidUsage {} + +message BehaviorParameterValueDescription { + string name = 1; + + oneof value_type { + BehaviorParameterNil nil = 2; + uint32 constant = 3; + BehaviorParameterValueDescriptionRange range = 4; + BehaviorParameterHidUsage hid_usage = 5; + BehaviorParameterLayerIndex layer_index = 6; + } +} diff --git a/protos/zmk/core.proto b/protos/zmk/core.proto new file mode 100644 index 0000000..3901569 --- /dev/null +++ b/protos/zmk/core.proto @@ -0,0 +1,29 @@ +syntax = "proto3"; + +package zmk.core; + +enum LockState { + ZMK_STUDIO_CORE_LOCK_STATE_LOCKED = 0; + ZMK_STUDIO_CORE_LOCK_STATE_UNLOCKING = 1; + ZMK_STUDIO_CORE_LOCK_STATE_UNLOCKED = 2; +} + +message Request { + oneof request_type { + bool get_lock_state = 1; + bool request_unlock = 2; + bool lock = 3; + } +} + +message Response { + oneof response_type { + LockState get_lock_state = 1; + } +} + +message Notification { + oneof notification_type { + LockState lock_state_changed = 1; + } +} \ No newline at end of file diff --git a/protos/zmk/keymap.proto b/protos/zmk/keymap.proto new file mode 100644 index 0000000..6ec2c99 --- /dev/null +++ b/protos/zmk/keymap.proto @@ -0,0 +1,9 @@ +syntax = "proto3"; + +package zmk.keymap; + +message Request { + oneof request_type { + bool get_layer_summaries = 1; + } +} \ No newline at end of file diff --git a/protos/zmk/meta.proto b/protos/zmk/meta.proto new file mode 100644 index 0000000..c3dc0bf --- /dev/null +++ b/protos/zmk/meta.proto @@ -0,0 +1,18 @@ +syntax = "proto3"; + +package zmk.meta; + +enum ErrorConditions { + GENERIC = 0; + UNLOCK_REQUIRED = 1; + RPC_NOT_FOUND = 2; + MSG_DECODE_FAILED = 3; + MSG_ENCODE_FAILED = 4; +} + +message Response { + oneof response_type { + bool no_response = 1; + ErrorConditions simple_error = 2; + } +} \ No newline at end of file diff --git a/protos/zmk/studio.options.in b/protos/zmk/studio.options.in new file mode 100644 index 0000000..e69de29 diff --git a/protos/zmk/studio.proto b/protos/zmk/studio.proto new file mode 100644 index 0000000..fd9e98a --- /dev/null +++ b/protos/zmk/studio.proto @@ -0,0 +1,41 @@ +// Requests +syntax = "proto3"; + +package zmk; + +import "meta.proto"; +import "core.proto"; +import "behaviors.proto"; +import "keymap.proto"; + +message Request { + uint32 request_id = 1; + + oneof subsystem { + zmk.core.Request core = 2; + zmk.keymap.Request keymap = 3; + zmk.behaviors.Request behaviors = 4; + } +} + +message Response { + oneof type { + RequestResponse request_response = 1; + Notification notification = 2; + } +} + +message RequestResponse { + uint32 request_id = 1; + oneof subsystem { + zmk.meta.Response meta = 2; + zmk.core.Response core = 3; + zmk.behaviors.Response behaviors = 4; + } +} + +message Notification { + oneof subsystem { + zmk.core.Notification core = 2; + } +} diff --git a/zephyr/module.yml b/zephyr/module.yml new file mode 100644 index 0000000..841c339 --- /dev/null +++ b/zephyr/module.yml @@ -0,0 +1 @@ +name: zmk-studio-messages