diff options
Diffstat (limited to 'docs/src/hid.js')
-rw-r--r-- | docs/src/hid.js | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/docs/src/hid.js b/docs/src/hid.js new file mode 100644 index 0000000..583ce7a --- /dev/null +++ b/docs/src/hid.js @@ -0,0 +1,20 @@ +/* + * Copyright (c) 2020 The ZMK Contributors + * + * SPDX-License-Identifier: CC-BY-NC-SA-4.0 + */ + +import codes from "./data/hid"; + +export const map = codes.reduce((map, item) => { + item.names.forEach((name) => (map[name] = item)); + return map; +}, {}); + +export function getCode(id) { + return map[id] ?? null; +} + +export function getCodes(ids) { + return ids.reduce((result, id) => [...result, map[id]], []); +} |