M .gitignore => .gitignore +2 -0
@@ 5,3 5,5 @@
/pointerd
/motion-control
/buttonc
+/evdev/codes.ha
+/event-codes
M Makefile => Makefile +9 -3
@@ 1,17 1,23 @@
SENSORS ?= gy801
+HEADERS_PREFIX ?= /usr/include
BINARIES = evdev-dump-events uinput-pointer sensors-dump pointerd pointerc motion-control buttonc
-evdev-dump-events uinput-pointer:
+event-codes:
+ hare build -o $@ aux/$@/
+evdev/codes.ha: event-codes
+ ./event-codes <$(HEADERS_PREFIX)/linux/input-event-codes.h >$@
+
+evdev-dump-events uinput-pointer: evdev/codes.ha
hare build -levdev -o $@ tools/$@/
sensors-dump pointerc:
hare build -T +$(SENSORS) -o $@ tools/$@/
buttonc:
hare build -o $@ tools/$@/
-pointerd:
+pointerd: evdev/codes.ha
hare build -levdev -o $@ cmd/$@/
motion-control:
hare build -T +$(SENSORS) -o $@ cmd/$@/
.PHONY: $(BINARIES)
all: $(BINARIES)
clean:
- rm -f $(BINARIES)
+ rm -f event-codes evdev/codes.ha $(BINARIES)
A aux/event-codes/main.ha => aux/event-codes/main.ha +38 -0
@@ 0,0 1,38 @@
+use bufio;
+use fmt;
+use io;
+use os;
+use strings;
+
+export fn main() void = {
+ for (true) {
+ const line = match (bufio::scanline(os::stdin)!) {
+ case let s: []u8 =>
+ yield strings::fromutf8(s);
+ case io::EOF =>
+ return;
+ };
+
+ if (!strings::hasprefix(line, "#define")) {
+ free(line);
+ continue;
+ };
+ const iend = match (strings::index(strings::sub(line, 8, strings::end), '\t')) {
+ case void =>
+ free(line);
+ continue;
+ case let s: size =>
+ yield s + 8;
+ };
+ const val = strings::trim(strings::sub(line, iend, strings::end), '\t');
+ const val = match (strings::index(val, "/*")) {
+ case void =>
+ yield val;
+ case let s: size =>
+ yield strings::sub(val, 0, s);
+ };
+ fmt::printfln("export def {}: u16\t= {};", strings::sub(line, 8, iend), val)!;
+
+ free(line);
+ };
+};
D evdev/codes.ha => evdev/codes.ha +0 -29
@@ 1,29 0,0 @@
-export def EV_SYN: u16 = 0x00;
-export def EV_KEY: u16 = 0x01;
-export def EV_REL: u16 = 0x02;
-export def EV_ABS: u16 = 0x03;
-export def EV_MSC: u16 = 0x04;
-export def EV_SW: u16 = 0x05;
-export def EV_LED: u16 = 0x11;
-export def EV_SND: u16 = 0x12;
-export def EV_REP: u16 = 0x14;
-export def EV_FF: u16 = 0x15;
-export def EV_PWR: u16 = 0x16;
-export def EV_FF_STATUS: u16 = 0x17;
-export def EV_MAX: u16 = 0x1f;
-export def EV_CNT: u16 = EV_MAX + 1;
-
-export def SYN_REPORT: u16 = 0;
-export def SYN_CONFIG: u16 = 1;
-export def SYN_MT_REPORT: u16 = 2;
-export def SYN_DROPPED: u16 = 3;
-export def SYN_MAX: u16 = 0xf;
-export def SYN_CNT: u16 = SYN_MAX + 1;
-
-export def BTN_LEFT: u16 = 0x110;
-export def BTN_RIGHT: u16 = 0x111;
-export def BTN_MIDDLE: u16 = 0x112;
-
-export def REL_X: u16 = 0x00;
-export def REL_Y: u16 = 0x01;
-export def REL_Z: u16 = 0x02;