chiark / gitweb /
hostside/hidrawconv*: tools for converting hidraw according to our own idea of how...
[trains.git] / hostside / hidrawconv.h
diff --git a/hostside/hidrawconv.h b/hostside/hidrawconv.h
new file mode 100644 (file)
index 0000000..9e34f78
--- /dev/null
@@ -0,0 +1,36 @@
+#ifndef HIDRAWCONV_H
+#define HIDRAWCONV_H
+
+#include <stdio.h>
+#include <stdint.h>
+
+#include "common.h"
+
+#define MAXREPORTLEN 256
+#define MAXREPORTS 256
+
+typedef void ProcessReport(uint8_t msg[MAXREPORTLEN], int msglen,
+                          const uint8_t last[MAXREPORTLEN]);
+
+extern const char *const descriptor;
+extern ProcessReport *const report_processors[MAXREPORTS];
+
+typedef struct {
+  const char *str;
+  int pos;
+  uint8_t mask;
+} KeyBit;
+
+typedef struct {
+  const char *str;
+  int pos, rshift, sign; /* mask is applied before rshift */
+  uint8_t mask, zero;
+} ValLoc;
+
+void reportbits(const uint8_t msg[], const uint8_t last[],
+               int len, const KeyBit bits[]);
+
+void reportlocs(const uint8_t msg[], const uint8_t last[],
+               int len, const ValLoc locs[]);
+
+#endif /*HIDRAWCONV_H*/