XInputGetKeystroke/Ex.
This commit is contained in:
@@ -32,6 +32,9 @@ public:
|
||||
uint32_t user_index, X_INPUT_STATE& out_state) = 0;
|
||||
virtual X_RESULT SetState(
|
||||
uint32_t user_index, X_INPUT_VIBRATION& vibration) = 0;
|
||||
virtual X_RESULT GetKeystroke(
|
||||
uint32_t user_index, uint32_t flags,
|
||||
X_INPUT_KEYSTROKE& out_keystroke) = 0;
|
||||
|
||||
protected:
|
||||
InputDriver(InputSystem* input_system);
|
||||
|
||||
@@ -23,7 +23,7 @@ InputSystem::InputSystem(Emulator* emulator) :
|
||||
}
|
||||
|
||||
InputSystem::~InputSystem() {
|
||||
for (std::vector<InputDriver*>::iterator it = drivers_.begin();
|
||||
for (auto it = drivers_.begin();
|
||||
it != drivers_.end(); ++it) {
|
||||
InputDriver* driver = *it;
|
||||
delete driver;
|
||||
@@ -42,8 +42,7 @@ void InputSystem::AddDriver(InputDriver* driver) {
|
||||
|
||||
X_RESULT InputSystem::GetCapabilities(
|
||||
uint32_t user_index, uint32_t flags, X_INPUT_CAPABILITIES& out_caps) {
|
||||
for (std::vector<InputDriver*>::iterator it = drivers_.begin();
|
||||
it != drivers_.end(); ++it) {
|
||||
for (auto it = drivers_.begin(); it != drivers_.end(); ++it) {
|
||||
InputDriver* driver = *it;
|
||||
if (XSUCCEEDED(driver->GetCapabilities(user_index, flags, out_caps))) {
|
||||
return X_ERROR_SUCCESS;
|
||||
@@ -53,8 +52,7 @@ X_RESULT InputSystem::GetCapabilities(
|
||||
}
|
||||
|
||||
X_RESULT InputSystem::GetState(uint32_t user_index, X_INPUT_STATE& out_state) {
|
||||
for (std::vector<InputDriver*>::iterator it = drivers_.begin();
|
||||
it != drivers_.end(); ++it) {
|
||||
for (auto it = drivers_.begin(); it != drivers_.end(); ++it) {
|
||||
InputDriver* driver = *it;
|
||||
if (driver->GetState(user_index, out_state) == X_ERROR_SUCCESS) {
|
||||
return X_ERROR_SUCCESS;
|
||||
@@ -65,8 +63,7 @@ X_RESULT InputSystem::GetState(uint32_t user_index, X_INPUT_STATE& out_state) {
|
||||
|
||||
X_RESULT InputSystem::SetState(
|
||||
uint32_t user_index, X_INPUT_VIBRATION& vibration) {
|
||||
for (std::vector<InputDriver*>::iterator it = drivers_.begin();
|
||||
it != drivers_.end(); ++it) {
|
||||
for (auto it = drivers_.begin(); it != drivers_.end(); ++it) {
|
||||
InputDriver* driver = *it;
|
||||
if (XSUCCEEDED(driver->SetState(user_index, vibration))) {
|
||||
return X_ERROR_SUCCESS;
|
||||
@@ -74,3 +71,14 @@ X_RESULT InputSystem::SetState(
|
||||
}
|
||||
return X_ERROR_DEVICE_NOT_CONNECTED;
|
||||
}
|
||||
|
||||
X_RESULT InputSystem::GetKeystroke(
|
||||
uint32_t user_index, uint32_t flags, X_INPUT_KEYSTROKE& out_keystroke) {
|
||||
for (auto it = drivers_.begin(); it != drivers_.end(); ++it) {
|
||||
InputDriver* driver = *it;
|
||||
if (XSUCCEEDED(driver->GetKeystroke(user_index, flags, out_keystroke))) {
|
||||
return X_ERROR_SUCCESS;
|
||||
}
|
||||
}
|
||||
return X_ERROR_DEVICE_NOT_CONNECTED;
|
||||
}
|
||||
@@ -41,6 +41,8 @@ public:
|
||||
uint32_t user_index, uint32_t flags, X_INPUT_CAPABILITIES& out_caps);
|
||||
X_RESULT GetState(uint32_t user_index, X_INPUT_STATE& out_state);
|
||||
X_RESULT SetState(uint32_t user_index, X_INPUT_VIBRATION& vibration);
|
||||
X_RESULT GetKeystroke(uint32_t user_index, uint32_t flags,
|
||||
X_INPUT_KEYSTROKE& out_keystroke);
|
||||
|
||||
private:
|
||||
Emulator* emulator_;
|
||||
|
||||
@@ -45,3 +45,8 @@ X_RESULT NopInputDriver::SetState(
|
||||
uint32_t user_index, X_INPUT_VIBRATION& vibration) {
|
||||
return X_ERROR_DEVICE_NOT_CONNECTED;
|
||||
}
|
||||
|
||||
X_RESULT NopInputDriver::GetKeystroke(
|
||||
uint32_t user_index, uint32_t flags, X_INPUT_KEYSTROKE& out_keystroke) {
|
||||
return X_ERROR_DEVICE_NOT_CONNECTED;
|
||||
}
|
||||
|
||||
@@ -34,6 +34,8 @@ public:
|
||||
uint32_t user_index, X_INPUT_STATE& out_state);
|
||||
virtual X_RESULT SetState(
|
||||
uint32_t user_index, X_INPUT_VIBRATION& vibration);
|
||||
virtual X_RESULT GetKeystroke(
|
||||
uint32_t user_index, uint32_t flags, X_INPUT_KEYSTROKE& out_keystroke);
|
||||
|
||||
protected:
|
||||
};
|
||||
|
||||
@@ -86,3 +86,22 @@ X_RESULT XInputInputDriver::SetState(
|
||||
DWORD result = XInputSetState(user_index, &native_vibration);
|
||||
return result;
|
||||
}
|
||||
|
||||
X_RESULT XInputInputDriver::GetKeystroke(
|
||||
uint32_t user_index, uint32_t flags, X_INPUT_KEYSTROKE& out_keystroke) {
|
||||
// We may want to filter flags/user_index before sending to native.
|
||||
// flags is reserved on desktop.
|
||||
XINPUT_KEYSTROKE native_keystroke;
|
||||
DWORD result = XInputGetKeystroke(user_index, flags, &native_keystroke);
|
||||
if (result == ERROR_SUCCESS) {
|
||||
out_keystroke.virtual_key = native_keystroke.VirtualKey;
|
||||
out_keystroke.unicode = native_keystroke.Unicode;
|
||||
out_keystroke.flags = native_keystroke.Flags;
|
||||
out_keystroke.user_index = native_keystroke.UserIndex;
|
||||
out_keystroke.hid_code = native_keystroke.HidCode;
|
||||
}
|
||||
// X_ERROR_EMPTY if no new keys
|
||||
// X_ERROR_DEVICE_NOT_CONNECTED if no device
|
||||
// X_ERROR_SUCCESS if key
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -34,6 +34,8 @@ public:
|
||||
uint32_t user_index, X_INPUT_STATE& out_state);
|
||||
virtual X_RESULT SetState(
|
||||
uint32_t user_index, X_INPUT_VIBRATION& vibration);
|
||||
virtual X_RESULT GetKeystroke(
|
||||
uint32_t user_index, uint32_t flags, X_INPUT_KEYSTROKE& out_keystroke);
|
||||
|
||||
protected:
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user