summary refs log tree commit diff stats
path: root/rust/qmk-hid-com/src_c/src/main.c
blob: 48d490eac485409be0809395bafe6bf7a867a848 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
#include <stdlib.h>

#include "error.h"
#include "hid/hid.h"
#include "keyboard/keyboard.h"

int main(int argc, const char *argv[]) {
  if (argc != 3) {
    fail("Usage: %s <usage> <usage_page>", argv[0]);
  }

  char *ep;
  uint32_t usage = (uint32_t)strtoul(argv[1], &ep, 0);
  if (*ep != 0) {
    fail("Invalid usage: %x", usage);
  }

  uint32_t usage_page = (uint32_t)strtoul(argv[2], &ep, 0);
  if (*ep != 0) {
    fail("Invalid usage: %x", usage_page);
  }

  uint32_t key_value = read_next(usage, usage_page);

  struct qmk_unicode_type qmk_unicode_type = init_qmk_unicode();
  type_keycode(&qmk_unicode_type, key_value);
  destroy_qmk_unicode(qmk_unicode_type);
}