MCPcopy Create free account
hub / github.com/Zalafina/QKeyMapper / FakerInputClient_sendKeyboardInput

Method FakerInputClient_sendKeyboardInput

QKeyMapper/qkeymapper_worker.cpp:5863–5970  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

5861}
5862
5863bool QKeyMapper_Worker::FakerInputClient_sendKeyboardInput(quint8 vkeycode, bool extendedFlag, int keyupdown, ULONG_PTR extraInfo)
5864{
5865 Q_UNUSED(extendedFlag);
5866
5867 QMutexLocker locker(&s_FakerInputClient_Mutex);
5868
5869 if (s_FakerInputClient == Q_NULLPTR || s_FakerInputClient_ConnectState != FAKERINPUT_CONNECT_SUCCESS) {
5870#ifdef DEBUG_LOGOUT_ON
5871 qWarning() << "[FakerInputClient_sendKeyboardInput] FakerInput not connected!";
5872#endif
5873 return false;
5874 }
5875
5876 // Check if this is a modifier key
5877 BYTE modifierFlag = VirtualKeyCodeToHIDModifierFlag(vkeycode);
5878 if (modifierFlag != 0) {
5879 // Handle modifier key
5880 if (keyupdown == KEY_DOWN) {
5881 s_FakerInputKeyboardReport_ShiftFlags |= modifierFlag;
5882 } else {
5883 s_FakerInputKeyboardReport_ShiftFlags &= ~modifierFlag;
5884 }
5885 } else {
5886 // Handle normal key
5887 BYTE hidCode = VirtualKeyCodeToHIDUsageCode(vkeycode);
5888 if (hidCode == 0) {
5889#ifdef DEBUG_LOGOUT_ON
5890 qWarning("[FakerInputClient_sendKeyboardInput] No HID mapping for VK: 0x%02X", vkeycode);
5891#endif
5892 return false;
5893 }
5894
5895 if (keyupdown == KEY_DOWN) {
5896 // Add key to the report (find empty slot)
5897 bool added = false;
5898 for (int i = 0; i < KBD_KEY_CODES; i++) {
5899 if (s_FakerInputKeyboardReport_KeyCodes[i] == 0) {
5900 s_FakerInputKeyboardReport_KeyCodes[i] = hidCode;
5901 added = true;
5902 break;
5903 } else if (s_FakerInputKeyboardReport_KeyCodes[i] == hidCode) {
5904 // Key already in report
5905 added = true;
5906 break;
5907 }
5908 }
5909 if (!added) {
5910#ifdef DEBUG_LOGOUT_ON
5911 qWarning("[FakerInputClient_sendKeyboardInput] Keyboard report full, cannot add HID: 0x%02X", hidCode);
5912#endif
5913 }
5914 } else {
5915 // Remove key from the report
5916 for (int i = 0; i < KBD_KEY_CODES; i++) {
5917 if (s_FakerInputKeyboardReport_KeyCodes[i] == hidCode) {
5918 s_FakerInputKeyboardReport_KeyCodes[i] = 0;
5919 break;
5920 }

Callers

nothing calls this directly

Calls 3

sizeMethod · 0.80
isEmptyMethod · 0.80

Tested by

no test coverage detected