chiark / gitweb /
hostside: hidrawconv: rename various variables and functions to be more sensible...
[trains.git] / hostside / hidrawconv.h
index 9e34f780997fed5f3e684d79ddec8a45a6bcbcdf..8bf12be9961429b4de2e167ca76c8b0f51894f75 100644 (file)
@@ -4,33 +4,49 @@
 #include <stdio.h>
 #include <stdint.h>
 
+#include <sys/ioctl.h>
+#include <sys/types.h>
+
+#include <linux/types.h>
+
+#include "hidraw.h"
+
 #include "common.h"
 
 #define MAXREPORTLEN 256
 #define MAXREPORTS 256
 
-typedef void ProcessReport(uint8_t msg[MAXREPORTLEN], int msglen,
-                          const uint8_t last[MAXREPORTLEN]);
+typedef struct { int len; uint8_t *msg; } Last;
+typedef struct { Last lasts[MAXREPORTS]; } LastReports;
+typedef void ProcessReport(const uint8_t *msg, int msglen, const uint8_t *last);
 
 extern const char *const descriptor;
 extern ProcessReport *const report_processors[MAXREPORTS];
 
+void dispatch(LastReports *lasts, const char *message_prefix,
+             ProcessReport *const report_processors[MAXREPORTS],
+             const uint8_t *msg, int l);
+
+/*---------- specific reporters ----------*/
+
 typedef struct {
   const char *str;
   int pos;
   uint8_t mask;
 } KeyBit;
 
+void reportbits(const uint8_t msg[], const uint8_t last[],
+               int len, const KeyBit keybits[]);
+
+
 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 reportvals(const uint8_t msg[], const uint8_t last[],
+               int len, const ValLoc vallocs[]);
 
-void reportlocs(const uint8_t msg[], const uint8_t last[],
-               int len, const ValLoc locs[]);
 
 #endif /*HIDRAWCONV_H*/