20 #include "modules/drivers/common/hid/HidUtils.h" 21 #include "modules/drivers/common/hid/HidUsages.h" 22 #include "pedigree/kernel/machine/HidInputManager.h" 23 #include "pedigree/kernel/machine/InputManager.h" 33 ((nStart % 8) + nLength - i) < 8 ? nLength % 8 : 8 - (nStart % 8);
34 nValue |= ((pBuffer[nStart / 8] >> (nStart % 8)) & ((1 << nBits) - 1))
51 if (nMin < (1LL << 8) && nMin & (1LL << 7))
53 else if (nMin < (1LL << 16) && nMin & (1LL << 15))
55 else if (nMin < (1LL << 32) && nMin & (1LL << 31))
70 if (nMin > -(1LL << 8) && nValue < (1LL << 8) &&
74 nMin > -(1LL << 16) && nValue < (1LL << 16) &&
78 nMin > -(1LL << 32) && nValue < (1LL << 32) &&
84 HidDeviceType deviceType, uint16_t nUsagePage, uint16_t nUsage,
85 int64_t nRelativeValue)
89 static uint32_t mouseButtons = 0;
90 static uint32_t joystickButtons = 0;
93 if ((deviceType ==
Keyboard) && (nUsagePage == HidUsagePages::Keyboard))
95 if (nRelativeValue > 0)
102 if ((deviceType == Mouse) && (nUsagePage == HidUsagePages::GenericDesktop))
104 if (nUsage == HidUsages::X)
106 nRelativeValue, 0, 0, mouseButtons);
107 if (nUsage == HidUsages::Y)
109 0, nRelativeValue, 0, mouseButtons);
110 if (nUsage == HidUsages::Wheel)
112 0, 0, nRelativeValue, mouseButtons);
116 if ((deviceType == Joystick) &&
117 (nUsagePage == HidUsagePages::GenericDesktop))
119 if (nUsage == HidUsages::X)
121 nRelativeValue, 0, 0, joystickButtons);
122 if (nUsage == HidUsages::Y)
124 0, nRelativeValue, 0, joystickButtons);
125 if (nUsage == HidUsages::Z)
127 0, 0, nRelativeValue, joystickButtons);
131 if ((deviceType == Mouse) && (nUsagePage == HidUsagePages::Button))
134 if (nRelativeValue > 0)
135 mouseButtons |= 1 << (nUsage - 1);
137 mouseButtons &= ~(1 << (nUsage - 1));
144 if ((deviceType == Joystick) && (nUsagePage == HidUsagePages::Button))
147 if (nRelativeValue > 0)
148 joystickButtons |= 1 << (nUsage - 1);
150 joystickButtons &= ~(1 << (nUsage - 1));
void sendInputToManager(HidDeviceType deviceType, uint16_t nUsagePage, uint16_t nUsage, int64_t nRelativeValue)
Sends the input to the right handler in HidInputManager or InputManager.
void fixNegativeMinimum(int64_t &nMin, int64_t nMax)
Converts.
uint64_t getBufferField(uint8_t *pBuffer, size_t nStart, size_t nLength)
Retrieves a field in a buffer.
void fixNegativeValue(int64_t nMin, int64_t nMax, int64_t &nValue)
Converts.