split keyboard input logic into platform specific code
This commit is contained in:
+37
-32
@@ -13,42 +13,47 @@ TEMPLATE = app
|
|||||||
|
|
||||||
|
|
||||||
SOURCES += src/main.cpp\
|
SOURCES += src/main.cpp\
|
||||||
src/overlaycontroller.cpp \
|
src/overlaycontroller.cpp \
|
||||||
src/tabcontrollers/AudioTabController.cpp \
|
src/tabcontrollers/AudioTabController.cpp \
|
||||||
src/tabcontrollers/ChaperoneTabController.cpp \
|
src/tabcontrollers/ChaperoneTabController.cpp \
|
||||||
src/tabcontrollers/FixFloorTabController.cpp \
|
src/tabcontrollers/FixFloorTabController.cpp \
|
||||||
src/tabcontrollers/MoveCenterTabController.cpp \
|
src/tabcontrollers/MoveCenterTabController.cpp \
|
||||||
src/tabcontrollers/SettingsTabController.cpp \
|
src/tabcontrollers/SettingsTabController.cpp \
|
||||||
src/tabcontrollers/StatisticsTabController.cpp \
|
src/tabcontrollers/StatisticsTabController.cpp \
|
||||||
src/tabcontrollers/SteamVRTabController.cpp \
|
src/tabcontrollers/SteamVRTabController.cpp \
|
||||||
src/tabcontrollers/ReviveTabController.cpp \
|
src/tabcontrollers/ReviveTabController.cpp \
|
||||||
src/tabcontrollers/UtilitiesTabController.cpp \
|
src/tabcontrollers/UtilitiesTabController.cpp \
|
||||||
src/tabcontrollers/PttController.cpp \
|
src/tabcontrollers/PttController.cpp \
|
||||||
src/tabcontrollers/AccessibilityTabController.cpp \
|
src/tabcontrollers/AccessibilityTabController.cpp \
|
||||||
src/utils/ChaperoneUtils.cpp \
|
src/utils/ChaperoneUtils.cpp \
|
||||||
src/tabcontrollers/audiomanager/AudioManagerDummy.cpp
|
src/tabcontrollers/audiomanager/AudioManagerDummy.cpp \
|
||||||
|
src/tabcontrollers/keyboardinput/KeyboardInputDummy.cpp
|
||||||
|
|
||||||
HEADERS += src/overlaycontroller.h \
|
HEADERS += src/overlaycontroller.h \
|
||||||
src/logging.h \
|
src/logging.h \
|
||||||
src/tabcontrollers/AudioTabController.h \
|
src/tabcontrollers/AudioTabController.h \
|
||||||
src/tabcontrollers/ChaperoneTabController.h \
|
src/tabcontrollers/ChaperoneTabController.h \
|
||||||
src/tabcontrollers/FixFloorTabController.h \
|
src/tabcontrollers/FixFloorTabController.h \
|
||||||
src/tabcontrollers/MoveCenterTabController.h \
|
src/tabcontrollers/MoveCenterTabController.h \
|
||||||
src/tabcontrollers/SettingsTabController.h \
|
src/tabcontrollers/SettingsTabController.h \
|
||||||
src/tabcontrollers/StatisticsTabController.h \
|
src/tabcontrollers/StatisticsTabController.h \
|
||||||
src/tabcontrollers/SteamVRTabController.h \
|
src/tabcontrollers/SteamVRTabController.h \
|
||||||
src/tabcontrollers/ReviveTabController.h \
|
src/tabcontrollers/ReviveTabController.h \
|
||||||
src/tabcontrollers/UtilitiesTabController.h \
|
src/tabcontrollers/UtilitiesTabController.h \
|
||||||
src/tabcontrollers/AudioManager.h \
|
src/tabcontrollers/AudioManager.h \
|
||||||
src/tabcontrollers/PttController.h \
|
src/tabcontrollers/PttController.h \
|
||||||
src/tabcontrollers/AccessibilityTabController.h \
|
src/tabcontrollers/AccessibilityTabController.h \
|
||||||
src/utils/Matrix.h \
|
src/tabcontrollers/KeyboardInput.h \
|
||||||
src/utils/ChaperoneUtils.h \
|
src/utils/Matrix.h \
|
||||||
src/tabcontrollers/audiomanager/AudioManagerDummy.h
|
src/utils/ChaperoneUtils.h \
|
||||||
|
src/tabcontrollers/audiomanager/AudioManagerDummy.h \
|
||||||
|
src/tabcontrollers/keyboardinput/KeyboardInputDummy.h
|
||||||
|
|
||||||
win32 {
|
win32 {
|
||||||
SOURCES += src/tabcontrollers/audiomanager/AudioManagerWindows.h
|
SOURCES += src/tabcontrollers/audiomanager/AudioManagerWindows.cpp \
|
||||||
HEADERS += src/tabcontrollers/audiomanager/AudioManagerWindows.h
|
src/tabcontrollers/keyboardinput/KeyboardInputWindows.cpp
|
||||||
|
HEADERS += src/tabcontrollers/audiomanager/AudioManagerWindows.h \
|
||||||
|
src/tabcontrollers/keyboardinput/KeyboardInputWindows.h
|
||||||
}
|
}
|
||||||
|
|
||||||
INCLUDEPATH += third-party/openvr/headers \
|
INCLUDEPATH += third-party/openvr/headers \
|
||||||
|
|||||||
@@ -0,0 +1,22 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include <vector>
|
||||||
|
#include <QString>
|
||||||
|
|
||||||
|
// application namespace
|
||||||
|
namespace advsettings {
|
||||||
|
|
||||||
|
class AudioTabController;
|
||||||
|
|
||||||
|
class KeyboardInput
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
virtual ~KeyboardInput() {};
|
||||||
|
|
||||||
|
virtual void sendKeyboardInput(QString input) = 0;
|
||||||
|
virtual void sendKeyboardEnter() = 0;
|
||||||
|
virtual void sendKeyboardBackspace(int count) = 0;
|
||||||
|
};
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
@@ -2,8 +2,12 @@
|
|||||||
#include <QQuickWindow>
|
#include <QQuickWindow>
|
||||||
#include <QApplication>
|
#include <QApplication>
|
||||||
#include "../overlaycontroller.h"
|
#include "../overlaycontroller.h"
|
||||||
#include <Windows.h>
|
|
||||||
#include <thread>
|
#include <thread>
|
||||||
|
#ifdef _WIN32
|
||||||
|
#include "keyboardinput/KeyboardInputWindows.h"
|
||||||
|
#else
|
||||||
|
#include "keyboardinput/KeyboardInputDummy.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
// application namespace
|
// application namespace
|
||||||
namespace advsettings {
|
namespace advsettings {
|
||||||
@@ -11,6 +15,11 @@ namespace advsettings {
|
|||||||
const char* steamDesktopOverlaykey = "valve.steam.desktop";
|
const char* steamDesktopOverlaykey = "valve.steam.desktop";
|
||||||
|
|
||||||
void UtilitiesTabController::initStage1() {
|
void UtilitiesTabController::initStage1() {
|
||||||
|
#ifdef _WIN32
|
||||||
|
keyboardInput.reset(new KeyboardInputWindows());
|
||||||
|
#else
|
||||||
|
keyboardInput.reset(new KeyboardInputDummy());
|
||||||
|
#endif
|
||||||
auto settings = OverlayController::appSettings();
|
auto settings = OverlayController::appSettings();
|
||||||
settings->beginGroup("utilitiesSettings");
|
settings->beginGroup("utilitiesSettings");
|
||||||
auto qAlarmEnabled = settings->value("alarmEnabled", m_alarmEnabled);
|
auto qAlarmEnabled = settings->value("alarmEnabled", m_alarmEnabled);
|
||||||
@@ -44,135 +53,16 @@ namespace advsettings {
|
|||||||
this->widget = widget;
|
this->widget = widget;
|
||||||
}
|
}
|
||||||
|
|
||||||
void fillKiStruct(INPUT& ip, WORD scanCode, bool keyup) {
|
|
||||||
ip.type = INPUT_KEYBOARD;
|
|
||||||
ip.ki.wVk = scanCode;
|
|
||||||
if (keyup) {
|
|
||||||
ip.ki.dwFlags = KEYEVENTF_KEYUP;
|
|
||||||
} else {
|
|
||||||
ip.ki.dwFlags = 0;
|
|
||||||
}
|
|
||||||
ip.ki.wScan = 0;
|
|
||||||
ip.ki.dwExtraInfo = 0;
|
|
||||||
ip.ki.time = 0;
|
|
||||||
};
|
|
||||||
|
|
||||||
void UtilitiesTabController::sendKeyboardInput(QString input) {
|
void UtilitiesTabController::sendKeyboardInput(QString input) {
|
||||||
int len = input.length();
|
keyboardInput->sendKeyboardInput(input);
|
||||||
if (len > 0) {
|
|
||||||
LPINPUT ips = new INPUT[len * 5 + 3];
|
|
||||||
unsigned ii = 0;
|
|
||||||
bool shiftPressed = false;
|
|
||||||
bool ctrlPressed = false;
|
|
||||||
bool altPressed = false;
|
|
||||||
for (int i = 0; i < len; i++) {
|
|
||||||
short tmp = VkKeyScan(input.at(i).toLatin1());
|
|
||||||
WORD c = tmp & 0xFF;
|
|
||||||
short shiftState = tmp >> 8;
|
|
||||||
bool isShift = shiftState & 1;
|
|
||||||
bool isCtrl = shiftState & 2;
|
|
||||||
bool isAlt = shiftState & 4;
|
|
||||||
if (isShift && !shiftPressed) {
|
|
||||||
fillKiStruct(ips[ii++], VK_SHIFT, false);
|
|
||||||
shiftPressed = true;
|
|
||||||
} else if (!isShift && shiftPressed) {
|
|
||||||
fillKiStruct(ips[ii++], VK_SHIFT, true);
|
|
||||||
shiftPressed = false;
|
|
||||||
}
|
|
||||||
if (isCtrl && !ctrlPressed) {
|
|
||||||
fillKiStruct(ips[ii++], VK_CONTROL, false);
|
|
||||||
ctrlPressed = true;
|
|
||||||
} else if (!isCtrl && ctrlPressed) {
|
|
||||||
fillKiStruct(ips[ii++], VK_CONTROL, true);
|
|
||||||
ctrlPressed = false;
|
|
||||||
}
|
|
||||||
if (isAlt && !altPressed) {
|
|
||||||
fillKiStruct(ips[ii++], VK_MENU, false);
|
|
||||||
altPressed = true;
|
|
||||||
} else if (!isAlt && altPressed) {
|
|
||||||
fillKiStruct(ips[ii++], VK_MENU, true);
|
|
||||||
altPressed = false;
|
|
||||||
}
|
|
||||||
fillKiStruct(ips[ii++], c, false);
|
|
||||||
fillKiStruct(ips[ii++], c, true);
|
|
||||||
}
|
|
||||||
if (shiftPressed) {
|
|
||||||
fillKiStruct(ips[ii++], VK_SHIFT, true);
|
|
||||||
shiftPressed = false;
|
|
||||||
}
|
|
||||||
if (ctrlPressed) {
|
|
||||||
fillKiStruct(ips[ii++], VK_CONTROL, true);
|
|
||||||
ctrlPressed = false;
|
|
||||||
}
|
|
||||||
if (altPressed) {
|
|
||||||
fillKiStruct(ips[ii++], VK_MENU, true);
|
|
||||||
altPressed = false;
|
|
||||||
}
|
|
||||||
if (!SendInput(ii, ips, sizeof(INPUT))) {
|
|
||||||
char *err;
|
|
||||||
auto errCode = GetLastError();
|
|
||||||
if (!FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM,
|
|
||||||
NULL,
|
|
||||||
errCode,
|
|
||||||
MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), // default language
|
|
||||||
(LPTSTR)&err,
|
|
||||||
0,
|
|
||||||
NULL)){
|
|
||||||
LOG(ERROR) << "Error calling SendInput(): Could not get error message (" << errCode << ")";
|
|
||||||
} else {
|
|
||||||
LOG(ERROR) << "Error calling SendInput(): " << err;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
delete ips;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void UtilitiesTabController::sendKeyboardEnter() {
|
void UtilitiesTabController::sendKeyboardEnter() {
|
||||||
LPINPUT ips = new INPUT[2];
|
keyboardInput->sendKeyboardEnter();
|
||||||
fillKiStruct(ips[0], VK_RETURN, false);
|
|
||||||
fillKiStruct(ips[1], VK_RETURN, true);
|
|
||||||
if (!SendInput(2, ips, sizeof(INPUT))) {
|
|
||||||
char *err;
|
|
||||||
auto errCode = GetLastError();
|
|
||||||
if (!FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM,
|
|
||||||
NULL,
|
|
||||||
errCode,
|
|
||||||
MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), // default language
|
|
||||||
(LPTSTR)&err,
|
|
||||||
0,
|
|
||||||
NULL)) {
|
|
||||||
LOG(ERROR) << "Error calling SendInput(): Could not get error message (" << errCode << ")";
|
|
||||||
} else {
|
|
||||||
LOG(ERROR) << "Error calling SendInput(): " << err;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
delete ips;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void UtilitiesTabController::sendKeyboardBackspace(int count) {
|
void UtilitiesTabController::sendKeyboardBackspace(int count) {
|
||||||
if (count > 0) {
|
keyboardInput->sendKeyboardBackspace(count);
|
||||||
LPINPUT ips = new INPUT[count * 2];
|
|
||||||
for (int i = 0; i < count; i++) {
|
|
||||||
fillKiStruct(ips[2 * i], VK_BACK, false);
|
|
||||||
fillKiStruct(ips[2 * i + 1], VK_BACK, true);
|
|
||||||
}
|
|
||||||
if (!SendInput(2 * count, ips, sizeof(INPUT))) {
|
|
||||||
char *err;
|
|
||||||
auto errCode = GetLastError();
|
|
||||||
if (!FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM,
|
|
||||||
NULL,
|
|
||||||
errCode,
|
|
||||||
MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), // default language
|
|
||||||
(LPTSTR)&err,
|
|
||||||
0,
|
|
||||||
NULL)) {
|
|
||||||
LOG(ERROR) << "Error calling SendInput(): Could not get error message (" << errCode << ")";
|
|
||||||
} else {
|
|
||||||
LOG(ERROR) << "Error calling SendInput(): " << err;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
delete ips;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -4,6 +4,8 @@
|
|||||||
#include <QObject>
|
#include <QObject>
|
||||||
#include <QTime>
|
#include <QTime>
|
||||||
#include <openvr.h>
|
#include <openvr.h>
|
||||||
|
#include <memory>
|
||||||
|
#include "KeyboardInput.h"
|
||||||
|
|
||||||
class QQuickWindow;
|
class QQuickWindow;
|
||||||
// application namespace
|
// application namespace
|
||||||
@@ -38,6 +40,8 @@ namespace advsettings {
|
|||||||
int m_batteryState[vr::k_unMaxTrackedDeviceCount];
|
int m_batteryState[vr::k_unMaxTrackedDeviceCount];
|
||||||
bool m_batteryVisible[vr::k_unMaxTrackedDeviceCount];
|
bool m_batteryVisible[vr::k_unMaxTrackedDeviceCount];
|
||||||
|
|
||||||
|
std::unique_ptr<KeyboardInput> keyboardInput;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
void initStage1();
|
void initStage1();
|
||||||
void initStage2(OverlayController* parent, QQuickWindow* widget);
|
void initStage2(OverlayController* parent, QQuickWindow* widget);
|
||||||
|
|||||||
@@ -0,0 +1,20 @@
|
|||||||
|
#include "KeyboardInputDummy.h"
|
||||||
|
|
||||||
|
namespace advsettings {
|
||||||
|
|
||||||
|
void KeyboardInputDummy::sendKeyboardInput(QString input)
|
||||||
|
{
|
||||||
|
// noop
|
||||||
|
}
|
||||||
|
|
||||||
|
void KeyboardInputDummy::sendKeyboardEnter()
|
||||||
|
{
|
||||||
|
// noop
|
||||||
|
}
|
||||||
|
|
||||||
|
void KeyboardInputDummy::sendKeyboardBackspace(int count)
|
||||||
|
{
|
||||||
|
// noop
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,19 @@
|
|||||||
|
#ifndef KEYBOARDINPUTDUMMY_H
|
||||||
|
#define KEYBOARDINPUTDUMMY_H
|
||||||
|
|
||||||
|
#include "../KeyboardInput.h"
|
||||||
|
|
||||||
|
// application namespace
|
||||||
|
namespace advsettings {
|
||||||
|
|
||||||
|
class KeyboardInputDummy : public KeyboardInput
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
virtual void sendKeyboardInput(QString input) override;
|
||||||
|
virtual void sendKeyboardEnter() override;
|
||||||
|
virtual void sendKeyboardBackspace(int count) override;
|
||||||
|
};
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif // KEYBOARDINPUTDUMMY_H
|
||||||
@@ -0,0 +1,140 @@
|
|||||||
|
#include "KeyboardInputWindows.h"
|
||||||
|
#include <Windows.h>
|
||||||
|
|
||||||
|
namespace advsettings {
|
||||||
|
|
||||||
|
void fillKiStruct(INPUT& ip, WORD scanCode, bool keyup) {
|
||||||
|
ip.type = INPUT_KEYBOARD;
|
||||||
|
ip.ki.wVk = scanCode;
|
||||||
|
if (keyup) {
|
||||||
|
ip.ki.dwFlags = KEYEVENTF_KEYUP;
|
||||||
|
} else {
|
||||||
|
ip.ki.dwFlags = 0;
|
||||||
|
}
|
||||||
|
ip.ki.wScan = 0;
|
||||||
|
ip.ki.dwExtraInfo = 0;
|
||||||
|
ip.ki.time = 0;
|
||||||
|
};
|
||||||
|
|
||||||
|
void KeyboardInputWindows::sendKeyboardInput(QString input)
|
||||||
|
{
|
||||||
|
int len = input.length();
|
||||||
|
if (len > 0) {
|
||||||
|
LPINPUT ips = new INPUT[len * 5 + 3];
|
||||||
|
unsigned ii = 0;
|
||||||
|
bool shiftPressed = false;
|
||||||
|
bool ctrlPressed = false;
|
||||||
|
bool altPressed = false;
|
||||||
|
for (int i = 0; i < len; i++) {
|
||||||
|
short tmp = VkKeyScan(input.at(i).toLatin1());
|
||||||
|
WORD c = tmp & 0xFF;
|
||||||
|
short shiftState = tmp >> 8;
|
||||||
|
bool isShift = shiftState & 1;
|
||||||
|
bool isCtrl = shiftState & 2;
|
||||||
|
bool isAlt = shiftState & 4;
|
||||||
|
if (isShift && !shiftPressed) {
|
||||||
|
fillKiStruct(ips[ii++], VK_SHIFT, false);
|
||||||
|
shiftPressed = true;
|
||||||
|
} else if (!isShift && shiftPressed) {
|
||||||
|
fillKiStruct(ips[ii++], VK_SHIFT, true);
|
||||||
|
shiftPressed = false;
|
||||||
|
}
|
||||||
|
if (isCtrl && !ctrlPressed) {
|
||||||
|
fillKiStruct(ips[ii++], VK_CONTROL, false);
|
||||||
|
ctrlPressed = true;
|
||||||
|
} else if (!isCtrl && ctrlPressed) {
|
||||||
|
fillKiStruct(ips[ii++], VK_CONTROL, true);
|
||||||
|
ctrlPressed = false;
|
||||||
|
}
|
||||||
|
if (isAlt && !altPressed) {
|
||||||
|
fillKiStruct(ips[ii++], VK_MENU, false);
|
||||||
|
altPressed = true;
|
||||||
|
} else if (!isAlt && altPressed) {
|
||||||
|
fillKiStruct(ips[ii++], VK_MENU, true);
|
||||||
|
altPressed = false;
|
||||||
|
}
|
||||||
|
fillKiStruct(ips[ii++], c, false);
|
||||||
|
fillKiStruct(ips[ii++], c, true);
|
||||||
|
}
|
||||||
|
if (shiftPressed) {
|
||||||
|
fillKiStruct(ips[ii++], VK_SHIFT, true);
|
||||||
|
shiftPressed = false;
|
||||||
|
}
|
||||||
|
if (ctrlPressed) {
|
||||||
|
fillKiStruct(ips[ii++], VK_CONTROL, true);
|
||||||
|
ctrlPressed = false;
|
||||||
|
}
|
||||||
|
if (altPressed) {
|
||||||
|
fillKiStruct(ips[ii++], VK_MENU, true);
|
||||||
|
altPressed = false;
|
||||||
|
}
|
||||||
|
if (!SendInput(ii, ips, sizeof(INPUT))) {
|
||||||
|
char *err;
|
||||||
|
auto errCode = GetLastError();
|
||||||
|
if (!FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM,
|
||||||
|
NULL,
|
||||||
|
errCode,
|
||||||
|
MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), // default language
|
||||||
|
(LPTSTR)&err,
|
||||||
|
0,
|
||||||
|
NULL)){
|
||||||
|
LOG(ERROR) << "Error calling SendInput(): Could not get error message (" << errCode << ")";
|
||||||
|
} else {
|
||||||
|
LOG(ERROR) << "Error calling SendInput(): " << err;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
delete ips;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void KeyboardInputWindows::sendKeyboardEnter()
|
||||||
|
{
|
||||||
|
LPINPUT ips = new INPUT[2];
|
||||||
|
fillKiStruct(ips[0], VK_RETURN, false);
|
||||||
|
fillKiStruct(ips[1], VK_RETURN, true);
|
||||||
|
if (!SendInput(2, ips, sizeof(INPUT))) {
|
||||||
|
char *err;
|
||||||
|
auto errCode = GetLastError();
|
||||||
|
if (!FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM,
|
||||||
|
NULL,
|
||||||
|
errCode,
|
||||||
|
MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), // default language
|
||||||
|
(LPTSTR)&err,
|
||||||
|
0,
|
||||||
|
NULL)) {
|
||||||
|
LOG(ERROR) << "Error calling SendInput(): Could not get error message (" << errCode << ")";
|
||||||
|
} else {
|
||||||
|
LOG(ERROR) << "Error calling SendInput(): " << err;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
delete ips;
|
||||||
|
}
|
||||||
|
|
||||||
|
void KeyboardInputWindows::sendKeyboardBackspace(int count)
|
||||||
|
{
|
||||||
|
if (count > 0) {
|
||||||
|
LPINPUT ips = new INPUT[count * 2];
|
||||||
|
for (int i = 0; i < count; i++) {
|
||||||
|
fillKiStruct(ips[2 * i], VK_BACK, false);
|
||||||
|
fillKiStruct(ips[2 * i + 1], VK_BACK, true);
|
||||||
|
}
|
||||||
|
if (!SendInput(2 * count, ips, sizeof(INPUT))) {
|
||||||
|
char *err;
|
||||||
|
auto errCode = GetLastError();
|
||||||
|
if (!FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM,
|
||||||
|
NULL,
|
||||||
|
errCode,
|
||||||
|
MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), // default language
|
||||||
|
(LPTSTR)&err,
|
||||||
|
0,
|
||||||
|
NULL)) {
|
||||||
|
LOG(ERROR) << "Error calling SendInput(): Could not get error message (" << errCode << ")";
|
||||||
|
} else {
|
||||||
|
LOG(ERROR) << "Error calling SendInput(): " << err;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
delete ips;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,19 @@
|
|||||||
|
#ifndef KEYBOARDINPUTWINDOWS_H
|
||||||
|
#define KEYBOARDINPUTWINDOWS_H
|
||||||
|
|
||||||
|
#include "../KeyboardInput.h"
|
||||||
|
|
||||||
|
// application namespace
|
||||||
|
namespace advsettings {
|
||||||
|
|
||||||
|
class KeyboardInputWindows : public KeyboardInput
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
virtual void sendKeyboardInput(QString input) override;
|
||||||
|
virtual void sendKeyboardEnter() override;
|
||||||
|
virtual void sendKeyboardBackspace(int count) override;
|
||||||
|
};
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif // KEYBOARDINPUTWINDOWS_H
|
||||||
Reference in New Issue
Block a user