diff --git a/PHYレイヤー.md b/PHYレイヤー.md index 66aec14..affae5e 100644 --- a/PHYレイヤー.md +++ b/PHYレイヤー.md @@ -153,8 +153,6 @@ Transform は回転と平行移動だけを持つ剛体変換であり、合成 各ノードは親から見た変換を持つ。キー・クラスター・部品ノードを混在させた木構造として保持する。 各ノードはIDを持つ。木の中のノードを一意に指すために持ち、キーのIDは他レイヤーからの参照にも使う。 -`phase1-json-schema.md` のPHYスキーマは、この節の Key 型(x2〜h2, decal, ghost, labels, switchOffset, partGroup, orientation, perKeyLED)と Component 型にまだ追従していない。 - ```ts type Transform = { x: number, // 親座標系での位置 diff --git a/phase1-json-schema.md b/phase1-json-schema.md index 87364bf..f9ab281 100644 --- a/phase1-json-schema.md +++ b/phase1-json-schema.md @@ -10,7 +10,7 @@ PHY (物理配置) → IDX (キー識別) → ELC (電気配線) + MAP (キー ## 1. PHYレイヤー JSON Schema -座標・回転・サイズの意味は `PHYレイヤー.md` を正とする。 +各フィールドの意味は `PHYレイヤー.md` を正とする。 ### 基本構造 @@ -68,7 +68,8 @@ PHY (物理配置) → IDX (キー識別) → ELC (電気配線) + MAP (キー "items": { "oneOf": [ { "$ref": "#/$defs/key" }, - { "$ref": "#/$defs/cluster" } + { "$ref": "#/$defs/cluster" }, + { "$ref": "#/$defs/component" } ] } } @@ -131,25 +132,65 @@ PHY (物理配置) → IDX (キー識別) → ELC (電気配線) + MAP (キー "required": ["w", "h"], "properties": { "w": { "type": "number", "minimum": 0 }, - "h": { "type": "number", "minimum": 0 } + "h": { "type": "number", "minimum": 0 }, + "x2": { "type": "number", "description": "Second rectangle for non-rectangular keys, relative to the local origin" }, + "y2": { "type": "number" }, + "w2": { "type": "number", "minimum": 0 }, + "h2": { "type": "number", "minimum": 0 } } }, - "metadata": { + "switchOffset": { "type": "object", + "description": "Switch position, offset from the center of the (w, h) rectangle. Key local coordinates, unit U. Defaults to 0", + "required": ["x", "y"], "properties": { - "label": { "type": "string" }, - "color": { "type": "string" }, - "textColor": { "type": "string" }, - "kleCompatibility": { - "type": "object", - "description": "Original KLE fields for round-trip compatibility", - "properties": { - "labels": { "type": "array", "items": { "type": "string" } }, - "textSizes": { "type": "array", "items": { "type": "number" } }, - "decalData": { "type": "object" } - } - } + "x": { "type": "number" }, + "y": { "type": "number" } } + }, + "partGroup": { + "type": "string", + "description": "Label grouping keys that use the same part. Not interpreted by Beyond KLE" + }, + "orientation": { + "type": "integer", + "enum": [0, 90, 180, 270], + "default": 0, + "description": "Switch orientation in the key local coordinates" + }, + "perKeyLED": { + "type": "boolean", + "default": false, + "description": "Whether a per-key LED is mounted" + }, + "decal": { "type": "boolean", "default": false }, + "ghost": { "type": "boolean", "default": false }, + "labels": { + "type": "array", + "items": { "type": "string" }, + "description": "Reference information. Used for matching on KLE JSON import" + }, + "kleCompatibility": { + "type": "object", + "description": "Opaque KLE fields kept for round-trip output (c, t, p, a, f, f2, fa, l, n, sm, sb, st). The owning layer is undecided; see P-6 in PHYレイヤー.md", + "additionalProperties": true + } + } + }, + "component": { + "type": "object", + "description": "Non-key part placed by the designer (LED, OLED, encoder, screw hole, ...)", + "required": ["type", "id", "transform"], + "properties": { + "type": { + "type": "string", + "const": "component" + }, + "id": { "type": "string" }, + "transform": { "$ref": "#/$defs/transform" }, + "partGroup": { + "type": "string", + "description": "Names starting with @ are reserved for editor rendering" } } }, @@ -169,7 +210,8 @@ PHY (物理配置) → IDX (キー識別) → ELC (電気配線) + MAP (キー "items": { "oneOf": [ { "$ref": "#/$defs/key" }, - { "$ref": "#/$defs/cluster" } + { "$ref": "#/$defs/cluster" }, + { "$ref": "#/$defs/component" } ] } } @@ -211,22 +253,26 @@ PHY (物理配置) → IDX (キー識別) → ELC (電気配線) + MAP (キー "profile": "standard", "transform": { "x": 0, "y": 0, "rotation": 0 }, "size": { "w": 1, "h": 1 }, - "metadata": { "label": "Q" } + "partGroup": "main", + "perKeyLED": true, + "labels": ["Q"] }, { - "type": "key", + "type": "key", "id": "k01", "profile": "standard", "transform": { "x": 1, "y": 0, "rotation": 0 }, "size": { "w": 1, "h": 1 }, - "metadata": { "label": "W" } + "partGroup": "main", + "perKeyLED": true, + "labels": ["W"] } ] }, { "type": "cluster", "id": "left_thumb", - "name": "Left Thumb Cluster", + "name": "Left Thumb Cluster", "transform": { "x": 2, "y": 3, "rotation": 15 }, "children": [ { @@ -235,17 +281,42 @@ PHY (物理配置) → IDX (キー識別) → ELC (電気配線) + MAP (キー "profile": "standard", "transform": { "x": 0, "y": 0, "rotation": 0 }, "size": { "w": 1.25, "h": 1 }, - "metadata": { "label": "Space" } + "partGroup": "thumb", + "orientation": 180, + "labels": ["Space"] }, { "type": "key", - "id": "k31", + "id": "k31", "profile": "standard", "transform": { "x": 1.25, "y": 0, "rotation": 0 }, "size": { "w": 1, "h": 1 }, - "metadata": { "label": "Enter" } + "partGroup": "thumb", + "orientation": 180, + "labels": ["Enter"] + }, + { + "type": "component", + "id": "enc0", + "transform": { "x": 2.25, "y": 0.5, "rotation": 0 }, + "partGroup": "encoder" } ] + }, + { + "type": "key", + "id": "k_iso_enter", + "profile": "standard", + "transform": { "x": 6, "y": 1, "rotation": 0 }, + "size": { "w": 1.5, "h": 1, "x2": 0.25, "y2": 1, "w2": 1.25, "h2": 1 }, + "switchOffset": { "x": 0, "y": 0.5 }, + "labels": ["Enter"] + }, + { + "type": "component", + "id": "screw0", + "transform": { "x": 0, "y": 4.5, "rotation": 0 }, + "partGroup": "screw-m2" } ] }