schema: IDX/ELCスキーマを確定した仕様に追従させる

ELCをELCレイヤー.mdの保存形式で書き直した。microcontrollerとmatrixの列挙は
捨てたモデルなので削除し、提供者・端子・LEDチェーンに置き換え。参照先もIDXからPHYへ。
IDXからはrow/colとラベルを外し、キーIDとキー番号の対応だけにした。
PHYはcompatibilityブロックを、キー側と同じ形のファイル単位kleCompatibilityに置換。
clusterのnameは保存形式に無いため必須から外した。

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
2026-09-20 21:56:32 +09:00
co-authored by Claude Opus 5
parent 8c47e547b4
commit d858361586
+156 -78
View File
@@ -2,11 +2,16 @@
## レイヤー間データフロー ## レイヤー間データフロー
```txt
PHY (物理配置)
├─→ ELC (電気配線)
└─→ IDX (キー識別)
└─→ MAP (キーマップ)
``` ```
PHY (物理配置) → IDX (キー識別) → ELC (電気配線) + MAP (キーマップ)
↓ ↓ ELCとIDXはどちらもPHYを参照する。ELCはIDXを参照しない。
ファームウェア生成 VIA/Remap出力 ファームウェアやVIA/Remap向けの出力は、各レイヤーの情報を統合して生成する。
``` 他レイヤーからキーや部品を指す参照には、PHYのノードIDを使う。
## 1. PHYレイヤー JSON Schema ## 1. PHYレイヤー JSON Schema
@@ -38,23 +43,10 @@ PHY (物理配置) → IDX (キー識別) → ELC (電気配線) + MAP (キー
"modified": { "type": "string", "format": "date-time" } "modified": { "type": "string", "format": "date-time" }
} }
}, },
"compatibility": { "kleCompatibility": {
"type": "object", "type": "object",
"description": "Information for external tool compatibility", "description": "File-level opaque KLE fields kept for round-trip output (switchMount, switchBrand, switchType, backcolor, radii, background, css). The owning layer is undecided; see P-6 in PHYレイヤー.md",
"properties": { "additionalProperties": true
"kleJson": {
"type": "object",
"properties": {
"source": { "type": "string" },
"checksum": { "type": "string" },
"preservedFields": { "type": "array", "items": { "type": "string" } }
}
},
"originalFormat": {
"type": "string",
"enum": ["kle", "via", "qmk", "native"]
}
}
}, },
"profiles": { "profiles": {
"type": "array", "type": "array",
@@ -196,7 +188,7 @@ PHY (物理配置) → IDX (キー識別) → ELC (電気配線) + MAP (キー
}, },
"cluster": { "cluster": {
"type": "object", "type": "object",
"required": ["type", "id", "name", "transform", "children"], "required": ["type", "id", "transform", "children"],
"properties": { "properties": {
"type": { "type": {
"type": "string", "type": "string",
@@ -324,6 +316,10 @@ PHY (物理配置) → IDX (キー識別) → ELC (電気配線) + MAP (キー
## 2. IDXレイヤー JSON Schema ## 2. IDXレイヤー JSON Schema
IDXが持つのは、PHYのキーとキー番号の対応だけとする [推測:P-1]。
マトリックス座標(row/col)とLEDの識別番号はここに置かない。どちらも配線で決まる情報で、
row/col はELCの配線から導く派生情報、LEDの番号はELCが正本を持つ。
### 基本構造 ### 基本構造
```json ```json
@@ -331,7 +327,7 @@ PHY (物理配置) → IDX (キー識別) → ELC (電気配線) + MAP (キー
"$schema": "https://json-schema.org/draft/2020-12/schema", "$schema": "https://json-schema.org/draft/2020-12/schema",
"$id": "https://beyond-kle.org/schemas/idx-layer.json", "$id": "https://beyond-kle.org/schemas/idx-layer.json",
"title": "IDX Layer - Key Identification", "title": "IDX Layer - Key Identification",
"description": "Mapping between physical keys and logical identifiers", "description": "Mapping between PHY keys and key numbers",
"type": "object", "type": "object",
"required": ["version", "phyReference", "keyMap"], "required": ["version", "phyReference", "keyMap"],
"properties": { "properties": {
@@ -354,26 +350,16 @@ PHY (物理配置) → IDX (キー識別) → ELC (電気配線) + MAP (キー
"$defs": { "$defs": {
"keyMapping": { "keyMapping": {
"type": "object", "type": "object",
"required": ["physicalId", "logicalId"], "required": ["keyId", "index"],
"properties": { "properties": {
"physicalId": { "keyId": {
"type": "string", "type": "string",
"description": "Reference to PHY layer key ID" "description": "Reference to PHY layer key ID"
}, },
"logicalId": { "index": {
"type": "object", "type": "integer",
"required": ["index"], "minimum": 0,
"properties": { "description": "Key number"
"index": { "type": "integer", "minimum": 0 },
"matrix": {
"type": "object",
"properties": {
"row": { "type": "integer", "minimum": 0 },
"col": { "type": "integer", "minimum": 0 }
}
},
"label": { "type": "string" }
}
} }
} }
} }
@@ -383,19 +369,21 @@ PHY (物理配置) → IDX (キー識別) → ELC (電気配線) + MAP (キー
## 3. ELCレイヤー JSON Schema ## 3. ELCレイヤー JSON Schema
各フィールドの意味は `ELCレイヤー.md` を正とする。
### 基本構造 ### 基本構造
```json ```json
{ {
"$schema": "https://json-schema.org/draft/2020-12/schema", "$schema": "https://json-schema.org/draft/2020-12/schema",
"$id": "https://beyond-kle.org/schemas/elc-layer.json", "$id": "https://beyond-kle.org/schemas/elc-layer.json",
"title": "ELC Layer - Electrical Configuration", "title": "ELC Layer - Electrical Wiring",
"description": "Electrical wiring and pin mapping", "description": "Wiring between provider pins and key terminals",
"type": "object", "type": "object",
"required": ["version", "idxReference", "microcontroller", "matrix"], "required": ["version", "phyReference", "providers", "keys"],
"properties": { "properties": {
"version": { "type": "string" }, "version": { "type": "string" },
"idxReference": { "phyReference": {
"type": "object", "type": "object",
"required": ["source", "checksum"], "required": ["source", "checksum"],
"properties": { "properties": {
@@ -403,42 +391,125 @@ PHY (物理配置) → IDX (キー識別) → ELC (電気配線) + MAP (キー
"checksum": { "type": "string" } "checksum": { "type": "string" }
} }
}, },
"microcontroller": { "providers": {
"type": "object",
"required": ["type", "pinMapping"],
"properties": {
"type": { "type": "string" },
"pinMapping": {
"type": "object",
"properties": {
"rows": {
"type": "array", "type": "array",
"items": { "type": "string" } "items": { "$ref": "#/$defs/provider" }
}, },
"cols": { "keys": {
"type": "array", "type": "array",
"items": { "type": "string" } "items": { "$ref": "#/$defs/keyWiring" }
} },
} "ledChains": {
} "type": "array",
"items": { "$ref": "#/$defs/ledChain" }
} }
}, },
"matrix": { "$defs": {
"type": "object", "pinRef": {
"required": ["type", "dimensions"],
"properties": {
"type": {
"type": "string", "type": "string",
"enum": ["standard", "charlieplexing", "direct"] "pattern": "^(VCC|GND|[^.]+\\.[^.]+)$",
"description": "\"<provider id>.<pin name>\", or the reserved power rails VCC / GND"
}, },
"dimensions": { "provider": {
"oneOf": [
{ "$ref": "#/$defs/mcuProvider" },
{ "$ref": "#/$defs/analogMuxProvider" }
]
},
"mcuProvider": {
"type": "object", "type": "object",
"required": ["rows", "cols"], "required": ["id", "kind", "part"],
"properties": { "properties": {
"rows": { "type": "integer", "minimum": 1 }, "id": { "type": "string" },
"cols": { "type": "integer", "minimum": 1 } "kind": { "const": "mcu" },
"part": {
"type": "string",
"description": "Part number. Used to interpret pin names"
} }
} }
},
"analogMuxProvider": {
"type": "object",
"required": ["id", "kind", "channels", "select", "common"],
"properties": {
"id": { "type": "string" },
"kind": { "const": "analog-mux" },
"channels": {
"type": "integer",
"minimum": 1,
"description": "Number of logical pins provided. Pin names are \"0\"..\"channels-1\""
},
"select": {
"type": "array",
"items": { "$ref": "#/$defs/pinRef" },
"description": "Select pins, least significant bit first"
},
"common": { "$ref": "#/$defs/pinRef" },
"enable": { "$ref": "#/$defs/pinRef" }
}
},
"keyWiring": {
"oneOf": [
{ "$ref": "#/$defs/contactKey" },
{ "$ref": "#/$defs/analogKey" }
]
},
"contactKey": {
"type": "object",
"required": ["key", "detect", "terminals"],
"properties": {
"key": {
"type": "string",
"description": "Reference to PHY layer key ID"
},
"detect": { "const": "contact" },
"terminals": {
"type": "object",
"description": "Non-polar. a and b carry no ordering meaning",
"required": ["a", "b"],
"properties": {
"a": { "$ref": "#/$defs/pinRef" },
"b": { "$ref": "#/$defs/pinRef" }
}
},
"diode": {
"type": "string",
"enum": ["a-to-b", "b-to-a"],
"description": "Anode side comes first. Omitted means no diode"
}
}
},
"analogKey": {
"type": "object",
"required": ["key", "detect", "terminals"],
"properties": {
"key": {
"type": "string",
"description": "Reference to PHY layer key ID"
},
"detect": { "const": "analog" },
"terminals": {
"type": "object",
"required": ["out", "vcc", "gnd"],
"properties": {
"out": { "$ref": "#/$defs/pinRef" },
"vcc": { "$ref": "#/$defs/pinRef" },
"gnd": { "$ref": "#/$defs/pinRef" }
}
}
}
},
"ledChain": {
"type": "object",
"required": ["id", "data", "order"],
"properties": {
"id": { "type": "string" },
"data": { "$ref": "#/$defs/pinRef" },
"order": {
"type": "array",
"items": { "type": "string" },
"description": "PHY node IDs. The position in the array is the LED number"
}
} }
} }
} }
@@ -505,25 +576,32 @@ PHY (物理配置) → IDX (キー識別) → ELC (電気配線) + MAP (キー
### PHY → IDX変換 ### PHY → IDX変換
1. PHYレイヤーから物理キーリストを取得 1. PHYレイヤーからキーのリストを取得
2. 各キーに論理IDを割り当て 2. 各キーにキー番号を割り当て
3. マトリックス座標の自動生成(行列最適化)
### IDX → ELC変換 ### PHY → ELC変換
1. マトリックス次元を算出 1. ピン提供者を置き、各提供者が消費する上位ピンを指定
2. ピン配置の最適化提案 2. 各キーの端子の接続先を指定
3. 配線効率の検証 3. LEDチェーンの並びを指定
### IDX + ELC → MAP変換 ### IDX + ELC + MAP → ファームウェア出力
1. キーインデックス配列の生成 1. ELCの配線から、ターゲットが要求する row / col を割り当て
2. デフォルトキーマップの提案 2. キー番号の配列とキーマップ配列の生成
3. VIA/QMK形式への出力 3. VIA/QMK形式への出力
## 次のステップ ## 次のステップ
1. **TypeScriptでの型定義作成** 1. **型定義の作成**(言語は `implementation-plan.md` で選定)
2. **変換ロジックのプロトタイプ実装** 2. **変換ロジックのプロトタイプ実装**
3. **テストケース(60%、Split等)での検証** 3. **テストケース(60%、Split等)での検証**
4. **既存KLE JSONからの変換機能** 4. **既存KLE JSONからの変換機能**
## 未確認事項
### P-1 IDXがキー番号以外に持つものがあるか
- 位置づけ: 本文「2. IDXレイヤー JSON Schema」が前提にしている。IDXには仕様ドキュメントがなく、
決定済みの情報(row/col と LEDの番号はELC)から引き算した最小形として書いている
- 格上げ条件: IDXレイヤーの仕様をユーザーと決め、`IDXレイヤー.md` に書く