2#include "pedigree/kernel/LockGuard.h"
3#include "pedigree/kernel/Log.h"
4#include "pedigree/kernel/machine/InputManager.h"
5#include "pedigree/kernel/process/Mutex.h"
6#include "pedigree/kernel/process/Semaphore.h"
8#include "modules/drivers/common/hid/HidReport.h"
9#include "modules/drivers/common/hid/HidUtils.h"
19 auto* capture =
static_cast<Capture*
>(notification.meta);
21 if (notification.type == InputManager::RawKey &&
22 (notification.data.rawkey.
scancode == 4 || notification.data.rawkey.
scancode == 5))
23 value = notification.data.rawkey.
scancode * (notification.data.rawkey.
keyUp ? -1 : 1);
24 else if (notification.type == InputManager::Mouse && notification.data.pointy.relx == -1)
29 if (capture->count < 8)
30 capture->values[capture->count++] = value;
31 capture->received.release();
35EXPORTED_PUBLIC
bool runHostedHidReportRegressions() {
36 uint8_t descriptor[] = {0x05, 1, 0x09, 6, 0xa1, 1, 0x85, 1, 0x05, 7, 0x09, 4,
37 0x15, 0, 0x25, 1, 0x75, 1, 0x95, 1, 0x81, 2, 0x75, 7,
38 0x81, 3, 0xc0, 0x05, 1, 0x09, 6, 0xa1, 1, 0x85, 2, 0x05,
39 7, 0x09, 5, 0x15, 0, 0x25, 1, 0x75, 1, 0x95, 1, 0x81,
40 2, 0x75, 7, 0x81, 3, 0xc0, 0x05, 1, 0x09, 2, 0xa1, 1,
41 0x85, 3, 0x09, 0x30, 0x16, 0, 0xf8, 0x26, 0xff, 7, 0x75, 12,
42 0x95, 1, 0x81, 6, 0x75, 4, 0x81, 3, 0xc0};
50 uint8_t packets[][3] = {{1, 1}, {2, 1}, {1}, {1, 0}, {2, 0}, {3, 0xff, 0x0f}};
51 const size_t lengths[] = {2, 2, 1, 2, 2, 3};
52 for (
size_t i = 0; i < 6; ++i)
53 report.
feedInput(packets[i],
nullptr, lengths[i]);
54 const bool delivered = capture.received.acquireForCompletion(5, 2);
56 const int expected[] = {4, 5, -4, -5, 100};
57 bool valid = delivered && capture.count == 5;
58 for (
size_t i = 0; valid && i < 5; ++i)
59 valid = capture.values[i] == expected[i];
60 uint8_t truncated[] = {0x27, 0};
63 valid &= !malformed.valid();
65 for (
size_t i = 0; i < 34; i += 2) {
71 valid &= !deep.valid();
72 uint8_t field[] = {0xf0, 0x3f};
75 NOTICE(
"HOSTED-WAIT-TEST: PASS hid-report-ids-short-signed-and-bounds");
77 ERROR(
"HOSTED-WAIT-TEST: FAIL hid-report-ids-short-signed-and-bounds");
void parseDescriptor(uint8_t *pDescriptor, size_t nDescriptorLength)
Parses a HID report descriptor and stores the resulted data.
void feedInput(uint8_t *pBuffer, uint8_t *pOldBuffer, size_t nBufferSize)
Feeds the input interpreter with a new input buffer.
uint64_t getBufferField(uint8_t *pBuffer, size_t nStart, size_t nLength)
Retrieves a field in a buffer.