Skip to content

Commit

Permalink
feat: Initial message definitions.
Browse files Browse the repository at this point in the history
  • Loading branch information
petejohanson committed Jun 24, 2024
0 parents commit a331de7
Show file tree
Hide file tree
Showing 11 changed files with 193 additions and 0 deletions.
21 changes: 21 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -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.
8 changes: 8 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -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
2 changes: 2 additions & 0 deletions protos/zmk/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
include/
src/
Empty file added protos/zmk/behaviors.options.in
Empty file.
64 changes: 64 additions & 0 deletions protos/zmk/behaviors.proto
Original file line number Diff line number Diff line change
@@ -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;
}
}
29 changes: 29 additions & 0 deletions protos/zmk/core.proto
Original file line number Diff line number Diff line change
@@ -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;
}
}
9 changes: 9 additions & 0 deletions protos/zmk/keymap.proto
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
syntax = "proto3";

package zmk.keymap;

message Request {
oneof request_type {
bool get_layer_summaries = 1;
}
}
18 changes: 18 additions & 0 deletions protos/zmk/meta.proto
Original file line number Diff line number Diff line change
@@ -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;
}
}
Empty file added protos/zmk/studio.options.in
Empty file.
41 changes: 41 additions & 0 deletions protos/zmk/studio.proto
Original file line number Diff line number Diff line change
@@ -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;
}
}
1 change: 1 addition & 0 deletions zephyr/module.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
name: zmk-studio-messages

0 comments on commit a331de7

Please sign in to comment.