diff --git a/src/userland/hid/hid.h b/src/userland/hid/hid.h index f1463e7..03cacd1 100644 --- a/src/userland/hid/hid.h +++ b/src/userland/hid/hid.h @@ -27,7 +27,7 @@ uint32_t padding; uint32_t currentUsagePage, reportSize, reportCount; uint32_t totalBits; - uint32_t usageMinimum, usageMaximum; + uint32_t usageMin, usageMax; uint32_t logicalMin, logicalMax; ListElement *usages; } ReportParserState; diff --git a/src/userland/hid/hid.h b/src/userland/hid/hid.h index f1463e7..03cacd1 100644 --- a/src/userland/hid/hid.h +++ b/src/userland/hid/hid.h @@ -27,7 +27,7 @@ uint32_t padding; uint32_t currentUsagePage, reportSize, reportCount; uint32_t totalBits; - uint32_t usageMinimum, usageMaximum; + uint32_t usageMin, usageMax; uint32_t logicalMin, logicalMax; ListElement *usages; } ReportParserState; diff --git a/src/userland/hid/main.c b/src/userland/hid/main.c index bf6ede7..f7c585c 100644 --- a/src/userland/hid/main.c +++ b/src/userland/hid/main.c @@ -128,13 +128,6 @@ for (uint32_t i = 0; i < state->reportCount; i++) { insertInputReader(state, i, data, inputReaders); } - } else if (state->currentUsagePage == 0x09) { - printf("%p New input parser has BUTTON usage for all entries\n", state->padding); - // TODO: research exact implementation for this - for (uint32_t i = 0; i < state->reportCount; i++) { - printf("%p Interpreting report %i as button %i\n", state->padding, i, i + 1); - insertInputReader(state, i, data, inputReaders); - } } else if (usageCount == 1) { uint8_t currentUsage = U32(listGet(state->usages, 0)); printf("%p New input parser has usage %s for all entries\n", @@ -155,6 +148,10 @@ ); insertInputReader(state, U32(currentUsage), data, inputReaders); }); + } else if (usageCount == 0 && (state->usageMax - state->usageMin + 1 == state->reportCount)) { + for (uint32_t currentUsage = state->usageMin; currentUsage <= state->usageMax; currentUsage++) { + insertInputReader(state, currentUsage, data, inputReaders); + } } else { printf("%p Input parser cannot deduce the usage of the reports, having %i reports and %i usages\n", state->padding, @@ -196,11 +193,11 @@ break; case 0x06: printf("%pUsageMinimum(%x)\n", state.padding, data); - state.usageMinimum = data; + state.usageMin = data; break; case 0x0A: printf("%pUsageMaximum(%x)\n", state.padding, data); - state.usageMaximum = data; + state.usageMax = data; break; case 0x1D: printf("%pReportSize(%x)\n", state.padding, data);