summaryrefslogtreecommitdiff
path: root/docs/src/hid.js
blob: 583ce7a5356f7def41f791d5af625cba45c92bcb (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
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]], []);
}