[HID] Add 'is active' checks to winkey input.
[HID] Add 'is active' checks to winkey input driver.
This commit is contained in:
parent
dd25e69e66
commit
6c073d3c84
|
@ -22,6 +22,10 @@ WinKeyInputDriver::WinKeyInputDriver(xe::ui::Window* window)
|
|||
: InputDriver(window), packet_number_(1) {
|
||||
// Register a key listener.
|
||||
window->on_key_down.AddListener([this](ui::KeyEvent* evt) {
|
||||
if (!is_active()) {
|
||||
return;
|
||||
}
|
||||
|
||||
auto global_lock = global_critical_region_.Acquire();
|
||||
|
||||
KeyEvent key;
|
||||
|
@ -32,6 +36,10 @@ WinKeyInputDriver::WinKeyInputDriver(xe::ui::Window* window)
|
|||
key_events_.push(key);
|
||||
});
|
||||
window->on_key_up.AddListener([this](ui::KeyEvent* evt) {
|
||||
if (!is_active()) {
|
||||
return;
|
||||
}
|
||||
|
||||
auto global_lock = global_critical_region_.Acquire();
|
||||
|
||||
KeyEvent key;
|
||||
|
@ -88,7 +96,7 @@ X_RESULT WinKeyInputDriver::GetState(uint32_t user_index,
|
|||
int16_t thumb_rx = 0;
|
||||
int16_t thumb_ry = 0;
|
||||
|
||||
if (window()->has_focus()) {
|
||||
if (window()->has_focus() && is_active()) {
|
||||
if (IS_KEY_TOGGLED(VK_CAPITAL) || IS_KEY_DOWN(VK_SHIFT)) {
|
||||
// dpad toggled
|
||||
if (IS_KEY_DOWN('A')) {
|
||||
|
@ -227,6 +235,10 @@ X_RESULT WinKeyInputDriver::GetKeystroke(uint32_t user_index, uint32_t flags,
|
|||
return X_ERROR_DEVICE_NOT_CONNECTED;
|
||||
}
|
||||
|
||||
if (!is_active()) {
|
||||
return X_ERROR_EMPTY;
|
||||
}
|
||||
|
||||
X_RESULT result = X_ERROR_EMPTY;
|
||||
|
||||
uint16_t virtual_key = 0;
|
||||
|
|
Loading…
Reference in New Issue