diff --git a/src/userland/hid/Makefile b/src/userland/hid/Makefile index 462034d..81bcd9d 100644 --- a/src/userland/hid/Makefile +++ b/src/userland/hid/Makefile @@ -7,7 +7,7 @@ BUILD_FOLDER = build -SOURCE_FILES := $(shell find . -name *.c -or -name *.asm -or -name *.s) +SOURCE_FILES := $(shell find . -name "*.c" -or -name "*.asm" -or -name "*.s") OBJS := $(SOURCE_FILES:%=$(BUILD_FOLDER)/%.o) NAME = hid diff --git a/src/userland/hid/Makefile b/src/userland/hid/Makefile index 462034d..81bcd9d 100644 --- a/src/userland/hid/Makefile +++ b/src/userland/hid/Makefile @@ -7,7 +7,7 @@ BUILD_FOLDER = build -SOURCE_FILES := $(shell find . -name *.c -or -name *.asm -or -name *.s) +SOURCE_FILES := $(shell find . -name "*.c" -or -name "*.asm" -or -name "*.s") OBJS := $(SOURCE_FILES:%=$(BUILD_FOLDER)/%.o) NAME = hid diff --git a/src/userland/hid/compile_flags.txt b/src/userland/hid/compile_flags.txt new file mode 100644 index 0000000..a432e7b --- /dev/null +++ b/src/userland/hid/compile_flags.txt @@ -0,0 +1,6 @@ +-I./include +-I../../include +clang +-fms-extensions +-Wno-microsoft-anon-tag +-Wno-incompatible-library-redeclaration diff --git a/src/userland/hid/Makefile b/src/userland/hid/Makefile index 462034d..81bcd9d 100644 --- a/src/userland/hid/Makefile +++ b/src/userland/hid/Makefile @@ -7,7 +7,7 @@ BUILD_FOLDER = build -SOURCE_FILES := $(shell find . -name *.c -or -name *.asm -or -name *.s) +SOURCE_FILES := $(shell find . -name "*.c" -or -name "*.asm" -or -name "*.s") OBJS := $(SOURCE_FILES:%=$(BUILD_FOLDER)/%.o) NAME = hid diff --git a/src/userland/hid/compile_flags.txt b/src/userland/hid/compile_flags.txt new file mode 100644 index 0000000..a432e7b --- /dev/null +++ b/src/userland/hid/compile_flags.txt @@ -0,0 +1,6 @@ +-I./include +-I../../include +clang +-fms-extensions +-Wno-microsoft-anon-tag +-Wno-incompatible-library-redeclaration diff --git a/src/userland/hid/hid.h b/src/userland/hid/hid.h deleted file mode 100644 index 329fcc9..0000000 --- a/src/userland/hid/hid.h +++ /dev/null @@ -1,44 +0,0 @@ -#ifndef HID_H -#define HID_H - -#include - -typedef struct { - uint32_t serviceId; - uint32_t deviceId; - uint32_t normalFunction; - void *buffer; - ListElement *inputReaders; -} HIDDevice; - -typedef struct { - uint8_t buttons; - int8_t x, y; -} __attribute__((packed)) MouseReport; - -typedef struct { - char *name; - uint32_t id; -} UsagePage; - -extern UsagePage *getUsagePage(uint32_t id); - -typedef struct { - uint32_t padding; - uint32_t reportSize, reportCount; - uint32_t totalBits; - uint32_t usageMin, usageMax; - uint32_t logicalMin, logicalMax; - UsagePage *usagePage; - ListElement *usages; -} ReportParserState; - -typedef struct { - uint8_t usage; - uint8_t size; - int32_t min, max; - UsagePage *usagePage; - bool discard, relative, isSigned; -} InputReader; - -#endif diff --git a/src/userland/hid/Makefile b/src/userland/hid/Makefile index 462034d..81bcd9d 100644 --- a/src/userland/hid/Makefile +++ b/src/userland/hid/Makefile @@ -7,7 +7,7 @@ BUILD_FOLDER = build -SOURCE_FILES := $(shell find . -name *.c -or -name *.asm -or -name *.s) +SOURCE_FILES := $(shell find . -name "*.c" -or -name "*.asm" -or -name "*.s") OBJS := $(SOURCE_FILES:%=$(BUILD_FOLDER)/%.o) NAME = hid diff --git a/src/userland/hid/compile_flags.txt b/src/userland/hid/compile_flags.txt new file mode 100644 index 0000000..a432e7b --- /dev/null +++ b/src/userland/hid/compile_flags.txt @@ -0,0 +1,6 @@ +-I./include +-I../../include +clang +-fms-extensions +-Wno-microsoft-anon-tag +-Wno-incompatible-library-redeclaration diff --git a/src/userland/hid/hid.h b/src/userland/hid/hid.h deleted file mode 100644 index 329fcc9..0000000 --- a/src/userland/hid/hid.h +++ /dev/null @@ -1,44 +0,0 @@ -#ifndef HID_H -#define HID_H - -#include - -typedef struct { - uint32_t serviceId; - uint32_t deviceId; - uint32_t normalFunction; - void *buffer; - ListElement *inputReaders; -} HIDDevice; - -typedef struct { - uint8_t buttons; - int8_t x, y; -} __attribute__((packed)) MouseReport; - -typedef struct { - char *name; - uint32_t id; -} UsagePage; - -extern UsagePage *getUsagePage(uint32_t id); - -typedef struct { - uint32_t padding; - uint32_t reportSize, reportCount; - uint32_t totalBits; - uint32_t usageMin, usageMax; - uint32_t logicalMin, logicalMax; - UsagePage *usagePage; - ListElement *usages; -} ReportParserState; - -typedef struct { - uint8_t usage; - uint8_t size; - int32_t min, max; - UsagePage *usagePage; - bool discard, relative, isSigned; -} InputReader; - -#endif diff --git a/src/userland/hid/include/hid.h b/src/userland/hid/include/hid.h new file mode 100644 index 0000000..7b177fa --- /dev/null +++ b/src/userland/hid/include/hid.h @@ -0,0 +1,45 @@ +#ifndef HID_H +#define HID_H + +#include + +typedef struct { + uint32_t serviceId; + uint32_t deviceId; + uint32_t normalFunction; + void *buffer; + ListElement *inputReaders; +} HIDDevice; + +typedef struct { + uint8_t buttons; + int8_t x, y; +} __attribute__((packed)) MouseReport; + +typedef struct { + char *name; + uint32_t id; +} UsagePage; + +extern UsagePage *getUsagePage(uint32_t id); +extern void initializeUsagePages(); + +typedef struct { + uint32_t padding; + uint32_t reportSize, reportCount; + uint32_t totalBits; + uint32_t usageMin, usageMax; + uint32_t logicalMin, logicalMax; + UsagePage *usagePage; + ListElement *usages; +} ReportParserState; + +typedef struct { + uint8_t usage; + uint8_t size; + int32_t min, max; + UsagePage *usagePage; + bool discard, relative, isSigned; +} InputReader; + +#endif diff --git a/src/userland/hid/Makefile b/src/userland/hid/Makefile index 462034d..81bcd9d 100644 --- a/src/userland/hid/Makefile +++ b/src/userland/hid/Makefile @@ -7,7 +7,7 @@ BUILD_FOLDER = build -SOURCE_FILES := $(shell find . -name *.c -or -name *.asm -or -name *.s) +SOURCE_FILES := $(shell find . -name "*.c" -or -name "*.asm" -or -name "*.s") OBJS := $(SOURCE_FILES:%=$(BUILD_FOLDER)/%.o) NAME = hid diff --git a/src/userland/hid/compile_flags.txt b/src/userland/hid/compile_flags.txt new file mode 100644 index 0000000..a432e7b --- /dev/null +++ b/src/userland/hid/compile_flags.txt @@ -0,0 +1,6 @@ +-I./include +-I../../include +clang +-fms-extensions +-Wno-microsoft-anon-tag +-Wno-incompatible-library-redeclaration diff --git a/src/userland/hid/hid.h b/src/userland/hid/hid.h deleted file mode 100644 index 329fcc9..0000000 --- a/src/userland/hid/hid.h +++ /dev/null @@ -1,44 +0,0 @@ -#ifndef HID_H -#define HID_H - -#include - -typedef struct { - uint32_t serviceId; - uint32_t deviceId; - uint32_t normalFunction; - void *buffer; - ListElement *inputReaders; -} HIDDevice; - -typedef struct { - uint8_t buttons; - int8_t x, y; -} __attribute__((packed)) MouseReport; - -typedef struct { - char *name; - uint32_t id; -} UsagePage; - -extern UsagePage *getUsagePage(uint32_t id); - -typedef struct { - uint32_t padding; - uint32_t reportSize, reportCount; - uint32_t totalBits; - uint32_t usageMin, usageMax; - uint32_t logicalMin, logicalMax; - UsagePage *usagePage; - ListElement *usages; -} ReportParserState; - -typedef struct { - uint8_t usage; - uint8_t size; - int32_t min, max; - UsagePage *usagePage; - bool discard, relative, isSigned; -} InputReader; - -#endif diff --git a/src/userland/hid/include/hid.h b/src/userland/hid/include/hid.h new file mode 100644 index 0000000..7b177fa --- /dev/null +++ b/src/userland/hid/include/hid.h @@ -0,0 +1,45 @@ +#ifndef HID_H +#define HID_H + +#include + +typedef struct { + uint32_t serviceId; + uint32_t deviceId; + uint32_t normalFunction; + void *buffer; + ListElement *inputReaders; +} HIDDevice; + +typedef struct { + uint8_t buttons; + int8_t x, y; +} __attribute__((packed)) MouseReport; + +typedef struct { + char *name; + uint32_t id; +} UsagePage; + +extern UsagePage *getUsagePage(uint32_t id); +extern void initializeUsagePages(); + +typedef struct { + uint32_t padding; + uint32_t reportSize, reportCount; + uint32_t totalBits; + uint32_t usageMin, usageMax; + uint32_t logicalMin, logicalMax; + UsagePage *usagePage; + ListElement *usages; +} ReportParserState; + +typedef struct { + uint8_t usage; + uint8_t size; + int32_t min, max; + UsagePage *usagePage; + bool discard, relative, isSigned; +} InputReader; + +#endif diff --git a/src/userland/hid/main.c b/src/userland/hid/main.c index 6d8246d..2244f95 100644 --- a/src/userland/hid/main.c +++ b/src/userland/hid/main.c @@ -1,7 +1,7 @@ #define ALLOC_MAIN #include -#include "hid.h" +#include REQUEST(checkFocus, "ioManager", "checkFocus"); REQUEST(moveRelative, "mouse", "moveRelative"); @@ -31,7 +31,7 @@ char *usage(UsagePage *usagePage, uint32_t data) { if (usagePage->id != 1) { // Generic Desktop Page - return "Unknown"; + return "Unknown: unimplemented usage page"; } switch (data) { case 0: return "Undefined"; @@ -263,6 +263,7 @@ void initialize() { createFunction("registerHID", (void *)registerHID); + initializeUsagePages(); } int32_t main() { diff --git a/src/userland/hid/Makefile b/src/userland/hid/Makefile index 462034d..81bcd9d 100644 --- a/src/userland/hid/Makefile +++ b/src/userland/hid/Makefile @@ -7,7 +7,7 @@ BUILD_FOLDER = build -SOURCE_FILES := $(shell find . -name *.c -or -name *.asm -or -name *.s) +SOURCE_FILES := $(shell find . -name "*.c" -or -name "*.asm" -or -name "*.s") OBJS := $(SOURCE_FILES:%=$(BUILD_FOLDER)/%.o) NAME = hid diff --git a/src/userland/hid/compile_flags.txt b/src/userland/hid/compile_flags.txt new file mode 100644 index 0000000..a432e7b --- /dev/null +++ b/src/userland/hid/compile_flags.txt @@ -0,0 +1,6 @@ +-I./include +-I../../include +clang +-fms-extensions +-Wno-microsoft-anon-tag +-Wno-incompatible-library-redeclaration diff --git a/src/userland/hid/hid.h b/src/userland/hid/hid.h deleted file mode 100644 index 329fcc9..0000000 --- a/src/userland/hid/hid.h +++ /dev/null @@ -1,44 +0,0 @@ -#ifndef HID_H -#define HID_H - -#include - -typedef struct { - uint32_t serviceId; - uint32_t deviceId; - uint32_t normalFunction; - void *buffer; - ListElement *inputReaders; -} HIDDevice; - -typedef struct { - uint8_t buttons; - int8_t x, y; -} __attribute__((packed)) MouseReport; - -typedef struct { - char *name; - uint32_t id; -} UsagePage; - -extern UsagePage *getUsagePage(uint32_t id); - -typedef struct { - uint32_t padding; - uint32_t reportSize, reportCount; - uint32_t totalBits; - uint32_t usageMin, usageMax; - uint32_t logicalMin, logicalMax; - UsagePage *usagePage; - ListElement *usages; -} ReportParserState; - -typedef struct { - uint8_t usage; - uint8_t size; - int32_t min, max; - UsagePage *usagePage; - bool discard, relative, isSigned; -} InputReader; - -#endif diff --git a/src/userland/hid/include/hid.h b/src/userland/hid/include/hid.h new file mode 100644 index 0000000..7b177fa --- /dev/null +++ b/src/userland/hid/include/hid.h @@ -0,0 +1,45 @@ +#ifndef HID_H +#define HID_H + +#include + +typedef struct { + uint32_t serviceId; + uint32_t deviceId; + uint32_t normalFunction; + void *buffer; + ListElement *inputReaders; +} HIDDevice; + +typedef struct { + uint8_t buttons; + int8_t x, y; +} __attribute__((packed)) MouseReport; + +typedef struct { + char *name; + uint32_t id; +} UsagePage; + +extern UsagePage *getUsagePage(uint32_t id); +extern void initializeUsagePages(); + +typedef struct { + uint32_t padding; + uint32_t reportSize, reportCount; + uint32_t totalBits; + uint32_t usageMin, usageMax; + uint32_t logicalMin, logicalMax; + UsagePage *usagePage; + ListElement *usages; +} ReportParserState; + +typedef struct { + uint8_t usage; + uint8_t size; + int32_t min, max; + UsagePage *usagePage; + bool discard, relative, isSigned; +} InputReader; + +#endif diff --git a/src/userland/hid/main.c b/src/userland/hid/main.c index 6d8246d..2244f95 100644 --- a/src/userland/hid/main.c +++ b/src/userland/hid/main.c @@ -1,7 +1,7 @@ #define ALLOC_MAIN #include -#include "hid.h" +#include REQUEST(checkFocus, "ioManager", "checkFocus"); REQUEST(moveRelative, "mouse", "moveRelative"); @@ -31,7 +31,7 @@ char *usage(UsagePage *usagePage, uint32_t data) { if (usagePage->id != 1) { // Generic Desktop Page - return "Unknown"; + return "Unknown: unimplemented usage page"; } switch (data) { case 0: return "Undefined"; @@ -263,6 +263,7 @@ void initialize() { createFunction("registerHID", (void *)registerHID); + initializeUsagePages(); } int32_t main() { diff --git a/src/userland/hid/usagePages.c b/src/userland/hid/usagePages.c deleted file mode 100644 index 6c21ec3..0000000 --- a/src/userland/hid/usagePages.c +++ /dev/null @@ -1,44 +0,0 @@ -#include "hid.h" - -// https://www.usb.org/sites/default/files/documents/hut1_12v2.pdf -// page 14, section 3, table 1: Usage Page Summary -UsagePage usagePages[] = { - { - .name = "Undefined", - }, { - .name = "Generic Desktop Controls", - }, { - .name = "Simulation Controls", - }, { - .name = "VR Controls", - }, { - .name = "Sport Controls", - }, { - .name = "Game Controls", - }, { - .name = "Generic Device Controls", - }, { - .name = "Keyboard/Keypad", - }, { - .name = "LEDs", - }, { - .name = "Button", - }, { - .name = "Ordinal", - }, { - .name = "Telephony", - }, { - .name = "Consumer", - }, { - .name = "Digitizer", - }, { - .name = "PID Page", - }, -}; - -UsagePage *getUsagePage(uint32_t id) { - if (id >= sizeof(usagePages) / sizeof(usagePages[0])) { - return &usagePages[0]; - } - return &usagePages[id]; -} diff --git a/src/userland/hid/Makefile b/src/userland/hid/Makefile index 462034d..81bcd9d 100644 --- a/src/userland/hid/Makefile +++ b/src/userland/hid/Makefile @@ -7,7 +7,7 @@ BUILD_FOLDER = build -SOURCE_FILES := $(shell find . -name *.c -or -name *.asm -or -name *.s) +SOURCE_FILES := $(shell find . -name "*.c" -or -name "*.asm" -or -name "*.s") OBJS := $(SOURCE_FILES:%=$(BUILD_FOLDER)/%.o) NAME = hid diff --git a/src/userland/hid/compile_flags.txt b/src/userland/hid/compile_flags.txt new file mode 100644 index 0000000..a432e7b --- /dev/null +++ b/src/userland/hid/compile_flags.txt @@ -0,0 +1,6 @@ +-I./include +-I../../include +clang +-fms-extensions +-Wno-microsoft-anon-tag +-Wno-incompatible-library-redeclaration diff --git a/src/userland/hid/hid.h b/src/userland/hid/hid.h deleted file mode 100644 index 329fcc9..0000000 --- a/src/userland/hid/hid.h +++ /dev/null @@ -1,44 +0,0 @@ -#ifndef HID_H -#define HID_H - -#include - -typedef struct { - uint32_t serviceId; - uint32_t deviceId; - uint32_t normalFunction; - void *buffer; - ListElement *inputReaders; -} HIDDevice; - -typedef struct { - uint8_t buttons; - int8_t x, y; -} __attribute__((packed)) MouseReport; - -typedef struct { - char *name; - uint32_t id; -} UsagePage; - -extern UsagePage *getUsagePage(uint32_t id); - -typedef struct { - uint32_t padding; - uint32_t reportSize, reportCount; - uint32_t totalBits; - uint32_t usageMin, usageMax; - uint32_t logicalMin, logicalMax; - UsagePage *usagePage; - ListElement *usages; -} ReportParserState; - -typedef struct { - uint8_t usage; - uint8_t size; - int32_t min, max; - UsagePage *usagePage; - bool discard, relative, isSigned; -} InputReader; - -#endif diff --git a/src/userland/hid/include/hid.h b/src/userland/hid/include/hid.h new file mode 100644 index 0000000..7b177fa --- /dev/null +++ b/src/userland/hid/include/hid.h @@ -0,0 +1,45 @@ +#ifndef HID_H +#define HID_H + +#include + +typedef struct { + uint32_t serviceId; + uint32_t deviceId; + uint32_t normalFunction; + void *buffer; + ListElement *inputReaders; +} HIDDevice; + +typedef struct { + uint8_t buttons; + int8_t x, y; +} __attribute__((packed)) MouseReport; + +typedef struct { + char *name; + uint32_t id; +} UsagePage; + +extern UsagePage *getUsagePage(uint32_t id); +extern void initializeUsagePages(); + +typedef struct { + uint32_t padding; + uint32_t reportSize, reportCount; + uint32_t totalBits; + uint32_t usageMin, usageMax; + uint32_t logicalMin, logicalMax; + UsagePage *usagePage; + ListElement *usages; +} ReportParserState; + +typedef struct { + uint8_t usage; + uint8_t size; + int32_t min, max; + UsagePage *usagePage; + bool discard, relative, isSigned; +} InputReader; + +#endif diff --git a/src/userland/hid/main.c b/src/userland/hid/main.c index 6d8246d..2244f95 100644 --- a/src/userland/hid/main.c +++ b/src/userland/hid/main.c @@ -1,7 +1,7 @@ #define ALLOC_MAIN #include -#include "hid.h" +#include REQUEST(checkFocus, "ioManager", "checkFocus"); REQUEST(moveRelative, "mouse", "moveRelative"); @@ -31,7 +31,7 @@ char *usage(UsagePage *usagePage, uint32_t data) { if (usagePage->id != 1) { // Generic Desktop Page - return "Unknown"; + return "Unknown: unimplemented usage page"; } switch (data) { case 0: return "Undefined"; @@ -263,6 +263,7 @@ void initialize() { createFunction("registerHID", (void *)registerHID); + initializeUsagePages(); } int32_t main() { diff --git a/src/userland/hid/usagePages.c b/src/userland/hid/usagePages.c deleted file mode 100644 index 6c21ec3..0000000 --- a/src/userland/hid/usagePages.c +++ /dev/null @@ -1,44 +0,0 @@ -#include "hid.h" - -// https://www.usb.org/sites/default/files/documents/hut1_12v2.pdf -// page 14, section 3, table 1: Usage Page Summary -UsagePage usagePages[] = { - { - .name = "Undefined", - }, { - .name = "Generic Desktop Controls", - }, { - .name = "Simulation Controls", - }, { - .name = "VR Controls", - }, { - .name = "Sport Controls", - }, { - .name = "Game Controls", - }, { - .name = "Generic Device Controls", - }, { - .name = "Keyboard/Keypad", - }, { - .name = "LEDs", - }, { - .name = "Button", - }, { - .name = "Ordinal", - }, { - .name = "Telephony", - }, { - .name = "Consumer", - }, { - .name = "Digitizer", - }, { - .name = "PID Page", - }, -}; - -UsagePage *getUsagePage(uint32_t id) { - if (id >= sizeof(usagePages) / sizeof(usagePages[0])) { - return &usagePages[0]; - } - return &usagePages[id]; -} diff --git a/src/userland/hid/usagePages/usagePages.c b/src/userland/hid/usagePages/usagePages.c new file mode 100644 index 0000000..c70df3a --- /dev/null +++ b/src/userland/hid/usagePages/usagePages.c @@ -0,0 +1,50 @@ +#include + +// https://www.usb.org/sites/default/files/documents/hut1_12v2.pdf +// page 14, section 3, table 1: Usage Page Summary +UsagePage usagePages[] = { + { + .name = "Undefined", + }, { + .name = "Generic Desktop Controls", + }, { + .name = "Simulation Controls", + }, { + .name = "VR Controls", + }, { + .name = "Sport Controls", + }, { + .name = "Game Controls", + }, { + .name = "Generic Device Controls", + }, { + .name = "Keyboard/Keypad", + }, { + .name = "LEDs", + }, { + .name = "Button", + }, { + .name = "Ordinal", + }, { + .name = "Telephony", + }, { + .name = "Consumer", + }, { + .name = "Digitizer", + }, { + .name = "PID Page", + }, +}; + +void initializeUsagePages() { + for (uint32_t i = 0; i < sizeof(usagePages) / sizeof(usagePages[0]); i++) { + usagePages[i].id = i; + } +} + +UsagePage *getUsagePage(uint32_t id) { + if (id >= sizeof(usagePages) / sizeof(usagePages[0])) { + return &usagePages[0]; + } + return &usagePages[id]; +}