diff --git a/Common/CommonTypes.h b/Common/CommonTypes.h index 41045019ae..84e7d2dcd9 100644 --- a/Common/CommonTypes.h +++ b/Common/CommonTypes.h @@ -41,9 +41,6 @@ typedef signed __int64 s64; #define NO_INLINE __attribute__((noinline)) #ifdef __SWITCH__ -// Some HID conflicts -#define KEY_UP PKEY_UP -#define KEY_DOWN PKEY_DOWN // Other conflicts #define Event _Event #define Framebuffer _Framebuffer @@ -51,8 +48,8 @@ typedef signed __int64 s64; #define ThreadContext _ThreadContext #include // Cleanup -#undef KEY_UP -#undef KEY_DOWN +#undef KeyInputFlags::UP +#undef KeyInputFlags::DOWN #undef Event #undef Framebuffer #undef Waitable diff --git a/Common/Input/InputState.h b/Common/Input/InputState.h index dc9a03a5f8..b41a28d0ea 100644 --- a/Common/Input/InputState.h +++ b/Common/Input/InputState.h @@ -164,27 +164,25 @@ struct TouchInput { double timestamp; }; -#undef KEY_DOWN -#undef KEY_UP - -enum KeyInputFlags { - KEY_DOWN = 1 << 0, - KEY_UP = 1 << 1, - KEY_HASWHEELDELTA = 1 << 2, - KEY_IS_REPEAT = 1 << 3, - KEY_CHAR = 1 << 4, // Unicode character input. Cannot detect keyups of these so KEY_DOWN and KEY_UP are zero when this is set. +enum class KeyInputFlags { + DOWN = 1 << 0, + UP = 1 << 1, + HAS_WHEEL_DELTA = 1 << 2, + IS_REPEAT = 1 << 3, + CHAR = 1 << 4, // Unicode character input. Cannot detect keyups of these so KeyInputFlags::DOWN and KeyInputFlags::UP are zero when this is set. }; +ENUM_CLASS_BITOPS(KeyInputFlags); struct KeyInput { KeyInput() {} - KeyInput(InputDeviceID devId, InputKeyCode code, int fl) : deviceId(devId), keyCode(code), flags(fl) {} - KeyInput(InputDeviceID devId, int unicode) : deviceId(devId), unicodeChar(unicode), flags(KEY_CHAR) {} + KeyInput(InputDeviceID devId, InputKeyCode code, KeyInputFlags fl) : deviceId(devId), keyCode(code), flags(fl) {} + KeyInput(InputDeviceID devId, int unicode) : deviceId(devId), unicodeChar(unicode), flags(KeyInputFlags::CHAR) {} InputDeviceID deviceId; union { InputKeyCode keyCode; // Android keycodes are the canonical keycodes, everyone else map to them. - int unicodeChar; // for KEY_CHAR + int unicodeChar; // for KeyInputFlags::CHAR }; - int flags; + KeyInputFlags flags; // Used by mousewheel events. The delta is packed in the upper 16 bits of flags. // TODO: Move mousewheel events to TouchInput? diff --git a/Common/UI/PopupScreens.cpp b/Common/UI/PopupScreens.cpp index 0af8e186ed..3f70c8a0da 100644 --- a/Common/UI/PopupScreens.cpp +++ b/Common/UI/PopupScreens.cpp @@ -46,7 +46,7 @@ void PopupScreen::touch(const TouchInput &touch) { } bool PopupScreen::key(const KeyInput &key) { - if (key.flags & KEY_DOWN) { + if (key.flags & KeyInputFlags::DOWN) { if ((key.keyCode == NKCODE_ENTER || key.keyCode == NKCODE_NUMPAD_ENTER) && defaultButton_) { UI::EventParams e{}; defaultButton_->OnClick.Trigger(e); diff --git a/Common/UI/Root.cpp b/Common/UI/Root.cpp index a067a7a750..81b492b2b7 100644 --- a/Common/UI/Root.cpp +++ b/Common/UI/Root.cpp @@ -186,7 +186,7 @@ bool IsScrollKey(const KeyInput &input) { static KeyEventResult KeyEventToFocusMoves(const KeyInput &key) { KeyEventResult retval = KeyEventResult::PASS_THROUGH; // Ignore repeats for focus moves. - if ((key.flags & (KEY_DOWN | KEY_IS_REPEAT)) == KEY_DOWN) { + if ((key.flags & KeyInputFlags::DOWN) && !(key.flags & KeyInputFlags::IS_REPEAT)) { if (IsDPadKey(key) || IsScrollKey(key)) { // Let's only repeat DPAD initially. HeldKey hk; @@ -205,7 +205,7 @@ static KeyEventResult KeyEventToFocusMoves(const KeyInput &key) { retval = KeyEventResult::ACCEPT; } } - if (key.flags & KEY_UP) { + if (key.flags & KeyInputFlags::UP) { // We ignore the device ID here (in the comparator for HeldKey), due to the Ouya quirk mentioned above. if (!heldKeys.empty()) { HeldKey hk; @@ -232,7 +232,7 @@ KeyEventResult UnsyncKeyEvent(const KeyInput &key, ViewGroup *root) { retval = KeyEventResult::PASS_THROUGH; break; default: - if (!(key.flags & KEY_IS_REPEAT)) { + if (!(key.flags & KeyInputFlags::IS_REPEAT)) { // If a repeat, we follow what KeyEventToFocusMoves set it to. // Otherwise we signal that we used the key, always. retval = KeyEventResult::ACCEPT; @@ -289,14 +289,14 @@ void AxisEvent(const AxisInput &axis, ViewGroup *root) { if (old == cur) return; if (old == DirState::POS) { - FakeKeyEvent(KeyInput{ DEVICE_ID_KEYBOARD, pos_key, KEY_UP }, root); + FakeKeyEvent(KeyInput{ DEVICE_ID_KEYBOARD, pos_key, KeyInputFlags::UP }, root); } else if (old == DirState::NEG) { - FakeKeyEvent(KeyInput{ DEVICE_ID_KEYBOARD, neg_key, KEY_UP }, root); + FakeKeyEvent(KeyInput{ DEVICE_ID_KEYBOARD, neg_key, KeyInputFlags::UP }, root); } if (cur == DirState::POS) { - FakeKeyEvent(KeyInput{ DEVICE_ID_KEYBOARD, pos_key, KEY_DOWN }, root); + FakeKeyEvent(KeyInput{ DEVICE_ID_KEYBOARD, pos_key, KeyInputFlags::DOWN }, root); } else if (cur == DirState::NEG) { - FakeKeyEvent(KeyInput{ DEVICE_ID_KEYBOARD, neg_key, KEY_DOWN }, root); + FakeKeyEvent(KeyInput{ DEVICE_ID_KEYBOARD, neg_key, KeyInputFlags::DOWN }, root); } }; @@ -357,7 +357,7 @@ restart: KeyInput key; key.keyCode = iter->key; key.deviceId = iter->deviceId; - key.flags = KEY_DOWN; + key.flags = KeyInputFlags::DOWN; KeyEvent(key, root); focusMoves.push_back(key.keyCode); diff --git a/Common/UI/Screen.cpp b/Common/UI/Screen.cpp index f865821224..2c4407009f 100644 --- a/Common/UI/Screen.cpp +++ b/Common/UI/Screen.cpp @@ -170,7 +170,7 @@ bool ScreenManager::key(const KeyInput &key) { std::lock_guard guard(inputLock_); bool result = false; // Send key up to every screen layer, to avoid stuck keys. - if (key.flags & KEY_UP) { + if (key.flags & KeyInputFlags::UP) { for (auto &layer : stack_) { result = layer.screen->UnsyncKey(key); } diff --git a/Common/UI/ScrollView.cpp b/Common/UI/ScrollView.cpp index 63972768a9..16b1a08900 100644 --- a/Common/UI/ScrollView.cpp +++ b/Common/UI/ScrollView.cpp @@ -118,10 +118,10 @@ bool ScrollView::Key(const KeyInput &input) { break; } - if ((input.flags & KEY_DOWN) && mouseHover_) { + if ((input.flags & KeyInputFlags::DOWN) && mouseHover_) { if ((input.keyCode == NKCODE_EXT_MOUSEWHEEL_UP || input.keyCode == NKCODE_EXT_MOUSEWHEEL_DOWN) && - (input.flags & KEY_HASWHEELDELTA)) { - scrollSpeed = (float)(short)(input.flags >> 16) * 1.25f; // Fudge factor. TODO: Should be moved to the backends. + (input.flags & KeyInputFlags::HAS_WHEEL_DELTA)) { + scrollSpeed = (float)((s32)input.flags >> 16) * 1.25f; // Fudge factor. TODO: Should be moved to the backends. } switch (input.keyCode) { diff --git a/Common/UI/TabHolder.cpp b/Common/UI/TabHolder.cpp index 86a30437ab..04a8776521 100644 --- a/Common/UI/TabHolder.cpp +++ b/Common/UI/TabHolder.cpp @@ -316,7 +316,7 @@ void ChoiceStrip::EnableChoice(int choice, bool enabled) { bool ChoiceStrip::Key(const KeyInput &input) { bool ret = false; - if (topTabs_ && (input.flags & KEY_DOWN)) { + if (topTabs_ && (input.flags & KeyInputFlags::DOWN)) { if (IsTabLeftKey(input)) { if (selected_ > 0) { SetSelection(selected_ - 1, true); diff --git a/Common/UI/UIScreen.cpp b/Common/UI/UIScreen.cpp index 196bb52a35..a9d7c983b9 100644 --- a/Common/UI/UIScreen.cpp +++ b/Common/UI/UIScreen.cpp @@ -267,7 +267,7 @@ void UIScreen::TriggerFinish(DialogResult result) { bool UIDialogScreen::key(const KeyInput &key) { bool retval = UIScreen::key(key); - if (!retval && (key.flags & KEY_DOWN) && UI::IsEscapeKey(key)) { + if (!retval && (key.flags & KeyInputFlags::DOWN) && UI::IsEscapeKey(key)) { if (finished_) { ERROR_LOG(Log::System, "Screen already finished"); } else { diff --git a/Common/UI/View.cpp b/Common/UI/View.cpp index 8da1f60a9b..e0e3891d0a 100644 --- a/Common/UI/View.cpp +++ b/Common/UI/View.cpp @@ -361,13 +361,13 @@ bool Clickable::Key(const KeyInput &key) { // TODO: Replace most of Update with this. bool ret = false; - if (key.flags & KEY_DOWN) { + if (key.flags & KeyInputFlags::DOWN) { if (IsAcceptKey(key)) { down_ = true; ret = true; } } - if (key.flags & KEY_UP) { + if (key.flags & KeyInputFlags::UP) { if (IsAcceptKey(key)) { if (down_) { ClickInternal(); @@ -407,7 +407,7 @@ bool StickyChoice::Key(const KeyInput &key) { } // TODO: Replace most of Update with this. - if (key.flags & KEY_DOWN) { + if (key.flags & KeyInputFlags::DOWN) { if (IsAcceptKey(key)) { down_ = true; UI::PlayUISound(UI::UISound::TOGGLE_ON); @@ -475,7 +475,9 @@ void Choice::GetContentDimensionsBySpec(const UIContext &dc, MeasureSpec horiz, int paddingLeft = 12; int paddingRight = 12; if (rightIconImage_.isValid()) { - paddingRight = ITEM_HEIGHT; + float imgW, imgH; + dc.Draw()->GetAtlas()->measureImage(rightIconImage_, &imgW, &imgH); + paddingRight = std::max(ITEM_HEIGHT, imgW); } float availWidth = horiz.size - paddingLeft - paddingRight - textPadding_.horiz() - totalW; @@ -540,7 +542,9 @@ void Choice::Draw(UIContext &dc) { } if (rightIconImage_.isValid()) { - paddingRight = bounds_.h; + float imgW, imgH; + dc.Draw()->GetAtlas()->measureImage(rightIconImage_, &imgW, &imgH); + paddingRight = std::max(ITEM_HEIGHT, imgW); } float availWidth = bounds_.w - (paddingLeft + paddingRight + textPadding_.horiz()); @@ -616,7 +620,7 @@ void ItemHeader::Draw(UIContext &dc) { const UI::Style &style = popupStyle_ ? dc.GetTheme().popupStyle : dc.GetTheme().headerStyle; dc.FillRect(style.background, bounds_); - dc.DrawText(text_, bounds_.x + 4, bounds_.centerY(), style.fgColor, ALIGN_LEFT | ALIGN_VCENTER); + dc.DrawText(text_, bounds_.x + 8, bounds_.centerY(), style.fgColor, ALIGN_LEFT | ALIGN_VCENTER); dc.Draw()->DrawImageCenterTexel(dc.GetTheme().whiteImage, bounds_.x, bounds_.y2()-2, bounds_.x2(), bounds_.y2(), style.fgColor); } @@ -1293,7 +1297,7 @@ bool TextEdit::Key(const KeyInput &input) { return false; bool textChanged = false; // Process hardcoded navigation keys. These aren't chars. - if (input.flags & KEY_DOWN) { + if (input.flags & KeyInputFlags::DOWN) { switch (input.keyCode) { case NKCODE_CTRL_LEFT: case NKCODE_CTRL_RIGHT: @@ -1396,7 +1400,7 @@ bool TextEdit::Key(const KeyInput &input) { } } - if (input.flags & KEY_UP) { + if (input.flags & KeyInputFlags::UP) { switch (input.keyCode) { case NKCODE_CTRL_LEFT: case NKCODE_CTRL_RIGHT: @@ -1408,7 +1412,7 @@ bool TextEdit::Key(const KeyInput &input) { } // Process chars. - if (input.flags & KEY_CHAR) { + if (input.flags & KeyInputFlags::CHAR) { const int unichar = input.keyCode; if (unichar >= 0x20 && !ctrlDown_) { // Ignore control characters. // Insert it! (todo: do it with a string insert) @@ -1521,7 +1525,7 @@ void TriggerButton::GetContentDimensions(const UIContext &dc, float &w, float &h } bool Slider::Key(const KeyInput &input) { - if (HasFocus() && (input.flags & (KEY_DOWN | KEY_IS_REPEAT)) == KEY_DOWN) { + if (HasFocus() && (input.flags & KeyInputFlags::DOWN) && !(input.flags & KeyInputFlags::IS_REPEAT)) { if (ApplyKey(input.keyCode)) { Clamp(); repeat_ = 0; @@ -1529,7 +1533,7 @@ bool Slider::Key(const KeyInput &input) { return true; } return false; - } else if ((input.flags & KEY_UP) && input.keyCode == repeatCode_) { + } else if ((input.flags & KeyInputFlags::UP) && input.keyCode == repeatCode_) { repeat_ = -1; return false; } else { @@ -1722,7 +1726,7 @@ void Slider::GetContentDimensions(const UIContext &dc, float &w, float &h) const } bool SliderFloat::Key(const KeyInput &input) { - if (HasFocus() && (input.flags & (KEY_DOWN | KEY_IS_REPEAT)) == KEY_DOWN) { + if (HasFocus() && (input.flags & KeyInputFlags::DOWN) && !(input.flags & KeyInputFlags::IS_REPEAT)) { if (ApplyKey(input.keyCode)) { Clamp(); repeat_ = 0; @@ -1730,7 +1734,7 @@ bool SliderFloat::Key(const KeyInput &input) { return true; } return false; - } else if ((input.flags & KEY_UP) && input.keyCode == repeatCode_) { + } else if ((input.flags & KeyInputFlags::UP) && input.keyCode == repeatCode_) { repeat_ = -1; return false; } else { diff --git a/Common/VR/PPSSPPVR.cpp b/Common/VR/PPSSPPVR.cpp index db971301c4..ef4fd3cf68 100644 --- a/Common/VR/PPSSPPVR.cpp +++ b/Common/VR/PPSSPPVR.cpp @@ -236,7 +236,7 @@ void UpdateVRInput(bool haptics, float dp_xscale, float dp_yscale) { //fill KeyInput structure bool pressed = status & m.ovr; - keyInput.flags = pressed ? KEY_DOWN : KEY_UP; + keyInput.flags = pressed ? KeyInputFlags::DOWN : KeyInputFlags::UP; keyInput.keyCode = m.keycode; keyInput.deviceId = controllerIds[j]; @@ -250,7 +250,7 @@ void UpdateVRInput(bool haptics, float dp_xscale, float dp_yscale) { m.pressed = pressed; m.repeat = 0; } else if (pressed && (m.repeat > 30)) { - keyInput.flags |= KEY_IS_REPEAT; + keyInput.flags |= KeyInputFlags::IS_REPEAT; cbNativeKey(keyInput); m.repeat = 0; } else { @@ -345,10 +345,10 @@ void UpdateVRInput(bool haptics, float dp_xscale, float dp_yscale) { for (int j = 0; j < 2; j++) { keyInput.deviceId = controllerIds[j]; float scroll = -IN_VRGetJoystickState(j).y; - keyInput.flags = scroll < -0.5f ? KEY_DOWN : KEY_UP; + keyInput.flags = scroll < -0.5f ? KeyInputFlags::DOWN : KeyInputFlags::UP; keyInput.keyCode = NKCODE_EXT_MOUSEWHEEL_UP; cbNativeKey(keyInput); - keyInput.flags = scroll > 0.5f ? KEY_DOWN : KEY_UP; + keyInput.flags = scroll > 0.5f ? KeyInputFlags::DOWN : KeyInputFlags::UP; keyInput.keyCode = NKCODE_EXT_MOUSEWHEEL_DOWN; cbNativeKey(keyInput); } @@ -375,7 +375,7 @@ bool UpdateVRKeys(const KeyInput &key) { bool wasCameraAdjustOn = pspKeys[VIRTKEY_VR_CAMERA_ADJUST]; if (KeyMap::InputMappingToPspButton(InputMapping(key.deviceId, key.keyCode), &nativeKeys)) { for (int& nativeKey : nativeKeys) { - pspKeys[nativeKey] = key.flags & KEY_DOWN; + pspKeys[nativeKey] = key.flags & KeyInputFlags::DOWN; } } @@ -406,7 +406,7 @@ bool UpdateVRKeys(const KeyInput &key) { if (!wasCameraAdjustOn && pspKeys[VIRTKEY_VR_CAMERA_ADJUST]) { KeyInput keyUp; keyUp.deviceId = key.deviceId; - keyUp.flags = KEY_UP; + keyUp.flags = KeyInputFlags::UP; pspKeys[VIRTKEY_VR_CAMERA_ADJUST] = false; for (auto& pspKey : pspKeys) { diff --git a/Core/ControlMapper.cpp b/Core/ControlMapper.cpp index d1f875d63a..b14f9dafe4 100644 --- a/Core/ControlMapper.cpp +++ b/Core/ControlMapper.cpp @@ -250,7 +250,7 @@ void ControlMapper::ReleaseAll() { if (input.second.value != 0.0) { KeyInput key; key.deviceId = input.first.deviceId; - key.flags = KEY_UP; + key.flags = KeyInputFlags::UP; key.keyCode = (InputKeyCode)input.first.keyCode; keys.push_back(key); } @@ -538,7 +538,7 @@ bool ControlMapper::UpdatePSPState(const InputMapping &changedMapping, double no } bool ControlMapper::Key(const KeyInput &key, bool *pauseTrigger) { - if (key.flags & KEY_IS_REPEAT) { + if (key.flags & KeyInputFlags::IS_REPEAT) { // Claim that we handled this. Prevents volume key repeats from popping up the volume control on Android. return true; } @@ -552,14 +552,14 @@ bool ControlMapper::Key(const KeyInput &key, bool *pauseTrigger) { deviceTimestamps_[(int)key.deviceId] = now; } - if (key.flags & KEY_DOWN) { + if (key.flags & KeyInputFlags::DOWN) { curInput_[mapping] = { 1.0f, now }; - } else if (key.flags & KEY_UP) { + } else if (key.flags & KeyInputFlags::UP) { curInput_[mapping] = { 0.0f, now}; } // TODO: See if this can be simplified further somehow. - if ((key.flags & KEY_DOWN) && key.keyCode == NKCODE_BACK) { + if ((key.flags & KeyInputFlags::DOWN) && key.keyCode == NKCODE_BACK) { bool mappingFound = KeyMap::InputMappingToPspButton(mapping, nullptr); DEBUG_LOG(Log::System, "Key: %d DeviceId: %d", key.keyCode, key.deviceId); if (!mappingFound || key.deviceId == DEVICE_ID_DEFAULT) { @@ -666,25 +666,25 @@ void ControlMapper::Update(const DisplayLayoutConfig &config, double now) { } } -void ControlMapper::PSPKey(int deviceId, int pspKeyCode, int flags) { +void ControlMapper::PSPKey(int deviceId, int pspKeyCode, KeyInputFlags flags) { std::lock_guard guard(mutex_); if (pspKeyCode >= VIRTKEY_FIRST) { int vk = pspKeyCode - VIRTKEY_FIRST; - if (flags & KEY_DOWN) { + if (flags & KeyInputFlags::DOWN) { virtKeys_[vk] = 1.0f; onVKey((VirtKey)pspKeyCode, true); onVKeyAnalog(deviceId, (VirtKey)pspKeyCode, 1.0f); } - if (flags & KEY_UP) { + if (flags & KeyInputFlags::UP) { virtKeys_[vk] = 0.0f; onVKey((VirtKey)pspKeyCode, false); onVKeyAnalog(deviceId, (VirtKey)pspKeyCode, 0.0f); } } else { // INFO_LOG(Log::System, "pspKey %d %d", pspKeyCode, flags); - if (flags & KEY_DOWN) + if (flags & KeyInputFlags::DOWN) updatePSPButtons_(pspKeyCode, 0); - if (flags & KEY_UP) + if (flags & KeyInputFlags::UP) updatePSPButtons_(0, pspKeyCode); } } diff --git a/Core/ControlMapper.h b/Core/ControlMapper.h index 36c06193fc..b3772e07af 100644 --- a/Core/ControlMapper.h +++ b/Core/ControlMapper.h @@ -31,7 +31,7 @@ public: // Inject raw PSP key input directly, such as from touch screen controls. // Combined with the mapped input. Unlike __Ctrl APIs, this supports // virtual key codes, including analog mappings. - void PSPKey(int deviceId, int pspKeyCode, int flags); + void PSPKey(int deviceId, int pspKeyCode, KeyInputFlags flags); // Toggle swapping DPAD and Analog. Useful on some input devices with few buttons. void ToggleSwapAxes(); diff --git a/Qt/QtMain.cpp b/Qt/QtMain.cpp index c82e0895da..6997a1f0e4 100644 --- a/Qt/QtMain.cpp +++ b/Qt/QtMain.cpp @@ -630,16 +630,16 @@ bool MainUI::event(QEvent *e) { NativeTouch(input); break; case Qt::RightButton: - NativeKey(KeyInput(DEVICE_ID_MOUSE, NKCODE_EXT_MOUSEBUTTON_2, (e->type() == QEvent::MouseButtonPress) ? KEY_DOWN : KEY_UP)); + NativeKey(KeyInput(DEVICE_ID_MOUSE, NKCODE_EXT_MOUSEBUTTON_2, (e->type() == QEvent::MouseButtonPress) ? KeyInputFlags::DOWN : KeyInputFlags::UP)); break; case Qt::MiddleButton: - NativeKey(KeyInput(DEVICE_ID_MOUSE, NKCODE_EXT_MOUSEBUTTON_3, (e->type() == QEvent::MouseButtonPress) ? KEY_DOWN : KEY_UP)); + NativeKey(KeyInput(DEVICE_ID_MOUSE, NKCODE_EXT_MOUSEBUTTON_3, (e->type() == QEvent::MouseButtonPress) ? KeyInputFlags::DOWN : KeyInputFlags::UP)); break; case Qt::ExtraButton1: - NativeKey(KeyInput(DEVICE_ID_MOUSE, NKCODE_EXT_MOUSEBUTTON_4, (e->type() == QEvent::MouseButtonPress) ? KEY_DOWN : KEY_UP)); + NativeKey(KeyInput(DEVICE_ID_MOUSE, NKCODE_EXT_MOUSEBUTTON_4, (e->type() == QEvent::MouseButtonPress) ? KeyInputFlags::DOWN : KeyInputFlags::UP)); break; case Qt::ExtraButton2: - NativeKey(KeyInput(DEVICE_ID_MOUSE, NKCODE_EXT_MOUSEBUTTON_5, (e->type() == QEvent::MouseButtonPress) ? KEY_DOWN : KEY_UP)); + NativeKey(KeyInput(DEVICE_ID_MOUSE, NKCODE_EXT_MOUSEBUTTON_5, (e->type() == QEvent::MouseButtonPress) ? KeyInputFlags::DOWN : KeyInputFlags::UP)); break; default: break; @@ -653,7 +653,7 @@ bool MainUI::event(QEvent *e) { NativeTouch(input); break; case QEvent::Wheel: - NativeKey(KeyInput(DEVICE_ID_MOUSE, ((QWheelEvent*)e)->delta()<0 ? NKCODE_EXT_MOUSEWHEEL_DOWN : NKCODE_EXT_MOUSEWHEEL_UP, KEY_DOWN)); + NativeKey(KeyInput(DEVICE_ID_MOUSE, ((QWheelEvent*)e)->delta()<0 ? NKCODE_EXT_MOUSEWHEEL_DOWN : NKCODE_EXT_MOUSEWHEEL_UP, KeyInputFlags::DOWN)); break; case QEvent::KeyPress: { @@ -662,7 +662,7 @@ bool MainUI::event(QEvent *e) { InputKeyCode nativeKeycode = NKCODE_UNKNOWN; if (iter != KeyMapRawQttoNative.end()) { nativeKeycode = iter->second; - NativeKey(KeyInput(DEVICE_ID_KEYBOARD, nativeKeycode, KEY_DOWN)); + NativeKey(KeyInput(DEVICE_ID_KEYBOARD, nativeKeycode, KeyInputFlags::DOWN)); } // Also get the unicode value. @@ -686,7 +686,7 @@ bool MainUI::event(QEvent *e) { } break; case QEvent::KeyRelease: - NativeKey(KeyInput(DEVICE_ID_KEYBOARD, KeyMapRawQttoNative.find(((QKeyEvent*)e)->key())->second, KEY_UP)); + NativeKey(KeyInput(DEVICE_ID_KEYBOARD, KeyMapRawQttoNative.find(((QKeyEvent*)e)->key())->second, KeyInputFlags::UP)); break; default: diff --git a/SDL/SDLJoystick.cpp b/SDL/SDLJoystick.cpp index 94a6f481ba..290cf57ce1 100644 --- a/SDL/SDLJoystick.cpp +++ b/SDL/SDLJoystick.cpp @@ -179,7 +179,7 @@ void SDLJoystick::ProcessInput(const SDL_Event &event){ auto code = getKeycodeForButton((SDL_GameControllerButton)event.cbutton.button); if (code != NKCODE_UNKNOWN) { KeyInput key; - key.flags = KEY_DOWN; + key.flags = KeyInputFlags::DOWN; key.keyCode = code; key.deviceId = DEVICE_ID_PAD_0 + getDeviceIndex(event.cbutton.which); NativeKey(key); @@ -191,7 +191,7 @@ void SDLJoystick::ProcessInput(const SDL_Event &event){ auto code = getKeycodeForButton((SDL_GameControllerButton)event.cbutton.button); if (code != NKCODE_UNKNOWN) { KeyInput key; - key.flags = KEY_UP; + key.flags = KeyInputFlags::UP; key.keyCode = code; key.deviceId = DEVICE_ID_PAD_0 + getDeviceIndex(event.cbutton.which); NativeKey(key); diff --git a/SDL/SDLMain.cpp b/SDL/SDLMain.cpp index c31efac077..599080cac1 100644 --- a/SDL/SDLMain.cpp +++ b/SDL/SDLMain.cpp @@ -1016,7 +1016,7 @@ static void ProcessSDLEvent(SDL_Window *window, const SDL_Event &event, InputSta if (event.key.repeat > 0) { break;} int k = event.key.keysym.sym; KeyInput key; - key.flags = KEY_DOWN; + key.flags = KeyInputFlags::DOWN; auto mapped = KeyMapRawSDLtoNative.find(k); if (mapped == KeyMapRawSDLtoNative.end() || mapped->second == NKCODE_UNKNOWN) { break; @@ -1065,7 +1065,7 @@ static void ProcessSDLEvent(SDL_Window *window, const SDL_Event &event, InputSta if (event.key.repeat > 0) { break;} int k = event.key.keysym.sym; KeyInput key; - key.flags = KEY_UP; + key.flags = KeyInputFlags::UP; auto mapped = KeyMapRawSDLtoNative.find(k); if (mapped == KeyMapRawSDLtoNative.end() || mapped->second == NKCODE_UNKNOWN) { break; @@ -1080,7 +1080,7 @@ static void ProcessSDLEvent(SDL_Window *window, const SDL_Event &event, InputSta int pos = 0; int c = u8_nextchar(event.text.text, &pos, strlen(event.text.text)); KeyInput key; - key.flags = KEY_CHAR; + key.flags = KeyInputFlags::CHAR; key.unicodeChar = c; key.deviceId = DEVICE_ID_KEYBOARD; NativeKey(key); @@ -1116,7 +1116,7 @@ static void ProcessSDLEvent(SDL_Window *window, const SDL_Event &event, InputSta KeyInput key{}; key.deviceId = DEVICE_ID_MOUSE; key.keyCode = NKCODE_EXT_MOUSEBUTTON_1; - key.flags = KEY_DOWN; + key.flags = KeyInputFlags::DOWN; NativeKey(key); break; } @@ -1135,7 +1135,7 @@ static void ProcessSDLEvent(SDL_Window *window, const SDL_Event &event, InputSta KeyInput key; key.deviceId = DEVICE_ID_MOUSE; key.keyCode = NKCODE_EXT_MOUSEBUTTON_1; - key.flags = KEY_UP; + key.flags = KeyInputFlags::UP; NativeKey(key); break; } @@ -1152,7 +1152,7 @@ static void ProcessSDLEvent(SDL_Window *window, const SDL_Event &event, InputSta input.buttons = 1; input.id = 0; NativeTouch(input); - KeyInput key(DEVICE_ID_MOUSE, NKCODE_EXT_MOUSEBUTTON_1, KEY_DOWN); + KeyInput key(DEVICE_ID_MOUSE, NKCODE_EXT_MOUSEBUTTON_1, KeyInputFlags::DOWN); NativeKey(key); } break; @@ -1166,25 +1166,25 @@ static void ProcessSDLEvent(SDL_Window *window, const SDL_Event &event, InputSta input.buttons = 2; input.id = 0; NativeTouch(input); - KeyInput key(DEVICE_ID_MOUSE, NKCODE_EXT_MOUSEBUTTON_2, KEY_DOWN); + KeyInput key(DEVICE_ID_MOUSE, NKCODE_EXT_MOUSEBUTTON_2, KeyInputFlags::DOWN); NativeKey(key); } break; case SDL_BUTTON_MIDDLE: { - KeyInput key(DEVICE_ID_MOUSE, NKCODE_EXT_MOUSEBUTTON_3, KEY_DOWN); + KeyInput key(DEVICE_ID_MOUSE, NKCODE_EXT_MOUSEBUTTON_3, KeyInputFlags::DOWN); NativeKey(key); } break; case SDL_BUTTON_X1: { - KeyInput key(DEVICE_ID_MOUSE, NKCODE_EXT_MOUSEBUTTON_4, KEY_DOWN); + KeyInput key(DEVICE_ID_MOUSE, NKCODE_EXT_MOUSEBUTTON_4, KeyInputFlags::DOWN); NativeKey(key); } break; case SDL_BUTTON_X2: { - KeyInput key(DEVICE_ID_MOUSE, NKCODE_EXT_MOUSEBUTTON_5, KEY_DOWN); + KeyInput key(DEVICE_ID_MOUSE, NKCODE_EXT_MOUSEBUTTON_5, KeyInputFlags::DOWN); NativeKey(key); } break; @@ -1194,18 +1194,18 @@ static void ProcessSDLEvent(SDL_Window *window, const SDL_Event &event, InputSta { KeyInput key{}; key.deviceId = DEVICE_ID_MOUSE; - key.flags = KEY_DOWN; + key.flags = KeyInputFlags::DOWN; #if SDL_VERSION_ATLEAST(2, 0, 18) if (event.wheel.preciseY != 0.0f) { // Should the scale be DPI-driven? const float scale = 30.0f; key.keyCode = event.wheel.preciseY > 0 ? NKCODE_EXT_MOUSEWHEEL_UP : NKCODE_EXT_MOUSEWHEEL_DOWN; - key.flags |= KEY_HASWHEELDELTA; + key.flags |= KeyInputFlags::HAS_WHEEL_DELTA; int wheelDelta = event.wheel.preciseY * scale; if (event.wheel.preciseY < 0) { wheelDelta = -wheelDelta; } - key.flags |= wheelDelta << 16; + key.flags = (KeyInputFlags)((u32)key.flags | (wheelDelta << 16)); NativeKey(key); break; } @@ -1244,7 +1244,7 @@ static void ProcessSDLEvent(SDL_Window *window, const SDL_Event &event, InputSta input.flags = TouchInputFlags::UP | TouchInputFlags::MOUSE; input.buttons = 1; NativeTouch(input); - KeyInput key(DEVICE_ID_MOUSE, NKCODE_EXT_MOUSEBUTTON_1, KEY_UP); + KeyInput key(DEVICE_ID_MOUSE, NKCODE_EXT_MOUSEBUTTON_1, KeyInputFlags::UP); NativeKey(key); } break; @@ -1259,25 +1259,25 @@ static void ProcessSDLEvent(SDL_Window *window, const SDL_Event &event, InputSta input.flags = TouchInputFlags::UP | TouchInputFlags::MOUSE; input.buttons = 2; NativeTouch(input); - KeyInput key(DEVICE_ID_MOUSE, NKCODE_EXT_MOUSEBUTTON_2, KEY_UP); + KeyInput key(DEVICE_ID_MOUSE, NKCODE_EXT_MOUSEBUTTON_2, KeyInputFlags::UP); NativeKey(key); } break; case SDL_BUTTON_MIDDLE: { - KeyInput key(DEVICE_ID_MOUSE, NKCODE_EXT_MOUSEBUTTON_3, KEY_UP); + KeyInput key(DEVICE_ID_MOUSE, NKCODE_EXT_MOUSEBUTTON_3, KeyInputFlags::UP); NativeKey(key); } break; case SDL_BUTTON_X1: { - KeyInput key(DEVICE_ID_MOUSE, NKCODE_EXT_MOUSEBUTTON_4, KEY_UP); + KeyInput key(DEVICE_ID_MOUSE, NKCODE_EXT_MOUSEBUTTON_4, KeyInputFlags::UP); NativeKey(key); } break; case SDL_BUTTON_X2: { - KeyInput key(DEVICE_ID_MOUSE, NKCODE_EXT_MOUSEBUTTON_5, KEY_UP); + KeyInput key(DEVICE_ID_MOUSE, NKCODE_EXT_MOUSEBUTTON_5, KeyInputFlags::UP); NativeKey(key); } break; @@ -1755,7 +1755,7 @@ int main(int argc, char *argv[]) { // Avoid the IME popup when holding keys. This doesn't affect all versions of SDL. // Note: We re-enable it in text input fields! This is necessary otherwise we don't receive - // KEY_CHAR events. + // KeyInputFlags::CHAR events. SDL_StopTextInput(); InitSDLAudioDevice(); diff --git a/UI/ControlMappingScreen.cpp b/UI/ControlMappingScreen.cpp index b887abeca1..83a5a5789e 100644 --- a/UI/ControlMappingScreen.cpp +++ b/UI/ControlMappingScreen.cpp @@ -346,7 +346,7 @@ bool KeyMappingNewKeyDialog::key(const KeyInput &key) { if (time_now_d() < delayUntil_) return true; - if (key.flags & KEY_DOWN) { + if (key.flags & KeyInputFlags::DOWN) { if (key.keyCode == NKCODE_EXT_MOUSEBUTTON_1) { // Don't map return true; @@ -359,7 +359,7 @@ bool KeyMappingNewKeyDialog::key(const KeyInput &key) { InputMapping newMapping(key.deviceId, key.keyCode); - if (!(key.flags & KEY_IS_REPEAT)) { + if (!(key.flags & KeyInputFlags::IS_REPEAT)) { if (!g_Config.bAllowMappingCombos && !mapping_.mappings.empty()) { comboMappingsNotEnabled_->SetVisibility(UI::V_VISIBLE); } else if (!mapping_.mappings.contains(newMapping)) { @@ -368,7 +368,7 @@ bool KeyMappingNewKeyDialog::key(const KeyInput &key) { } } } - if (key.flags & KEY_UP) { + if (key.flags & KeyInputFlags::UP) { // If the key released wasn't part of the mapping, ignore it here. Some device can cause // stray key-up events. InputMapping upMapping(key.deviceId, key.keyCode); @@ -401,7 +401,7 @@ bool KeyMappingNewMouseKeyDialog::key(const KeyInput &key) { return false; if (ignoreInput_) return true; - if (key.flags & KEY_DOWN) { + if (key.flags & KeyInputFlags::DOWN) { if (key.keyCode == NKCODE_ESCAPE) { TriggerFinish(DR_OK); g_IsMappingMouseInput = false; @@ -913,7 +913,7 @@ void VisualMappingScreen::CreateViews() { } bool VisualMappingScreen::key(const KeyInput &key) { - if (key.flags & KEY_DOWN) { + if (key.flags & KeyInputFlags::DOWN) { std::vector pspKeys; KeyMap::InputMappingToPspButton(InputMapping(key.deviceId, key.keyCode), &pspKeys); for (int pspKey : pspKeys) { diff --git a/UI/DevScreens.cpp b/UI/DevScreens.cpp index cefae777c3..5a3049e992 100644 --- a/UI/DevScreens.cpp +++ b/UI/DevScreens.cpp @@ -521,7 +521,7 @@ void ShaderViewScreen::CreateViews() { } bool ShaderViewScreen::key(const KeyInput &ki) { - if (ki.flags & KEY_CHAR) { + if (ki.flags & KeyInputFlags::CHAR) { if (ki.unicodeChar == 'C' || ki.unicodeChar == 'c') { System_CopyStringToClipboard(gpu->DebugGetShaderString(id_, type_, SHADER_STRING_SHORT_DESC)); } @@ -707,10 +707,10 @@ bool TouchTestScreen::key(const KeyInput &key) { UIScreen::key(key); char buf[512]; snprintf(buf, sizeof(buf), "%s (%d) Device ID: %d [%s%s%s%s]", KeyMap::GetKeyName(key.keyCode).c_str(), key.keyCode, key.deviceId, - (key.flags & KEY_IS_REPEAT) ? "REP" : "", - (key.flags & KEY_UP) ? "UP" : "", - (key.flags & KEY_DOWN) ? "DOWN" : "", - (key.flags & KEY_CHAR) ? "CHAR" : ""); + (key.flags & KeyInputFlags::IS_REPEAT) ? "REP" : "", + (key.flags & KeyInputFlags::UP) ? "UP" : "", + (key.flags & KeyInputFlags::DOWN) ? "DOWN" : "", + (key.flags & KeyInputFlags::CHAR) ? "CHAR" : ""); keyEventLog_.push_back(buf); UpdateLogView(); return true; diff --git a/UI/EmuScreen.cpp b/UI/EmuScreen.cpp index 370546e78f..ba74075b78 100644 --- a/UI/EmuScreen.cpp +++ b/UI/EmuScreen.cpp @@ -1071,8 +1071,8 @@ bool EmuScreen::UnsyncKey(const KeyInput &key) { System_Notify(SystemNotification::ACTIVITY); // Update imgui modifier flags - if (key.flags & (KEY_DOWN | KEY_UP)) { - bool down = (key.flags & KEY_DOWN) != 0; + if (key.flags & (KeyInputFlags::DOWN | KeyInputFlags::UP)) { + bool down = (key.flags & KeyInputFlags::DOWN) != 0; switch (key.keyCode) { case NKCODE_CTRL_LEFT: keyCtrlLeft_ = down; break; case NKCODE_CTRL_RIGHT: keyCtrlRight_ = down; break; @@ -1090,7 +1090,7 @@ bool EmuScreen::UnsyncKey(const KeyInput &key) { // Note: Allow some Vkeys through, so we can toggle the imgui for example (since we actually block the control mapper otherwise in imgui mode). // We need to manually implement it here :/ if (g_Config.bShowImDebugger && imguiInited_) { - if (key.flags & (KEY_UP | KEY_DOWN)) { + if (key.flags & (KeyInputFlags::UP | KeyInputFlags::DOWN)) { InputMapping mapping(key.deviceId, key.keyCode); std::vector pspButtons; bool mappingFound = KeyMap::InputMappingToPspButton(mapping, &pspButtons); @@ -1121,7 +1121,7 @@ bool EmuScreen::UnsyncKey(const KeyInput &key) { } } else { // Let up-events through to the controlMapper_ so input doesn't get stuck. - if (key.flags & KEY_UP) { + if (key.flags & KeyInputFlags::UP) { controlMapper_.Key(key, &pauseTrigger_); } } @@ -1148,7 +1148,7 @@ bool EmuScreen::key(const KeyInput &key) { ImGui_ImplPlatform_KeyEvent(key); } - if (!retval && (key.flags & KEY_DOWN) != 0 && UI::IsEscapeKey(key)) { + if (!retval && (key.flags & KeyInputFlags::DOWN) != 0 && UI::IsEscapeKey(key)) { if (chatMenu_) chatMenu_->Close(); if (chatButton_) diff --git a/UI/GameSettingsScreen.cpp b/UI/GameSettingsScreen.cpp index 3b473ad8cf..a5cc0850ca 100644 --- a/UI/GameSettingsScreen.cpp +++ b/UI/GameSettingsScreen.cpp @@ -998,7 +998,8 @@ void GameSettingsScreen::CreateNetworkingSettings(UI::ViewGroup *networkingSetti networkingSettings->Add(new ItemHeader(ms->T("Networking"))); - networkingSettings->Add(new Choice(n->T("Open PPSSPP Multiplayer Wiki Page")))->OnClick.Handle(this, &GameSettingsScreen::OnAdhocGuides); + Choice *wiki = networkingSettings->Add(new Choice(n->T("Open PPSSPP Multiplayer Wiki Page"), ImageID("I_LINK_OUT"))); + wiki->OnClick.Handle(this, &GameSettingsScreen::OnAdhocGuides); networkingSettings->Add(new CheckBox(&g_Config.bEnableWlan, n->T("Enable networking", "Enable networking/wlan (beta)"))); networkingSettings->Add(new MacAddressChooser(GetRequesterToken(), gamePath_, &g_Config.sMACAddress, n->T("Change Mac Address"), screenManager())); @@ -1053,7 +1054,7 @@ void GameSettingsScreen::CreateNetworkingSettings(UI::ViewGroup *networkingSetti qc->SetEnabledPtr(&g_Config.bEnableNetworkChat); #endif -#if !defined(MOBILE_DEVICE) && !defined(USING_QT_UI) // TODO: Add all platforms where KEY_CHAR support is added +#if !defined(MOBILE_DEVICE) && !defined(USING_QT_UI) // TODO: Add all platforms where KeyInputFlags::CHAR support is added PopupTextInputChoice *qc1 = networkingSettings->Add(new PopupTextInputChoice(GetRequesterToken(), &g_Config.sQuickChat0, n->T("Quick Chat 1"), "", 32, screenManager())); PopupTextInputChoice *qc2 = networkingSettings->Add(new PopupTextInputChoice(GetRequesterToken(), &g_Config.sQuickChat1, n->T("Quick Chat 2"), "", 32, screenManager())); PopupTextInputChoice *qc3 = networkingSettings->Add(new PopupTextInputChoice(GetRequesterToken(), &g_Config.sQuickChat2, n->T("Quick Chat 3"), "", 32, screenManager())); @@ -1868,10 +1869,10 @@ void HostnameSelectScreen::CreatePopupContents(UI::ViewGroup *parent) { progressView_->SetVisibility(UI::V_GONE); } -void HostnameSelectScreen::SendEditKey(InputKeyCode keyCode, int flags) { +void HostnameSelectScreen::SendEditKey(InputKeyCode keyCode, KeyInputFlags flags) { auto oldView = UI::GetFocusedView(); UI::SetFocusedView(addrView_); - KeyInput fakeKey{ DEVICE_ID_KEYBOARD, keyCode, KEY_DOWN | flags }; + KeyInput fakeKey{ DEVICE_ID_KEYBOARD, keyCode, KeyInputFlags::DOWN | flags }; addrView_->Key(fakeKey); UI::SetFocusedView(oldView); } @@ -1879,12 +1880,12 @@ void HostnameSelectScreen::SendEditKey(InputKeyCode keyCode, int flags) { void HostnameSelectScreen::OnNumberClick(UI::EventParams &e) { std::string text = e.v ? e.v->Tag() : ""; if (text.length() == 1 && text[0] >= '0' && text[0] <= '9') { - SendEditKey((InputKeyCode)text[0], KEY_CHAR); // ASCII for digits match keycodes. + SendEditKey((InputKeyCode)text[0], KeyInputFlags::CHAR); // ASCII for digits match keycodes. } } void HostnameSelectScreen::OnPointClick(UI::EventParams &e) { - SendEditKey((InputKeyCode)'.', KEY_CHAR); + SendEditKey((InputKeyCode)'.', KeyInputFlags::CHAR); } void HostnameSelectScreen::OnDeleteClick(UI::EventParams &e) { diff --git a/UI/GameSettingsScreen.h b/UI/GameSettingsScreen.h index 0bf5e63fbe..458bd1244d 100644 --- a/UI/GameSettingsScreen.h +++ b/UI/GameSettingsScreen.h @@ -150,7 +150,7 @@ protected: private: void ResolverThread(); - void SendEditKey(InputKeyCode keyCode, int flags = 0); + void SendEditKey(InputKeyCode keyCode, KeyInputFlags flags = (KeyInputFlags)0); void OnNumberClick(UI::EventParams &e); void OnPointClick(UI::EventParams &e); diff --git a/UI/GamepadEmu.cpp b/UI/GamepadEmu.cpp index 5ace55d35f..d83765b44b 100644 --- a/UI/GamepadEmu.cpp +++ b/UI/GamepadEmu.cpp @@ -233,7 +233,7 @@ bool CustomButton::Touch(const TouchInput &input) { if (!repeat_) { for (int i = 0; i < ARRAY_SIZE(g_customKeyList); i++) { if (pspButtonBit_ & (1ULL << i)) { - controlMapper_->PSPKey(DEVICE_ID_TOUCH, g_customKeyList[i].c, (on_ && toggle_) ? KEY_UP : KEY_DOWN); + controlMapper_->PSPKey(DEVICE_ID_TOUCH, g_customKeyList[i].c, (on_ && toggle_) ? KeyInputFlags::UP : KeyInputFlags::DOWN); } } } @@ -242,7 +242,7 @@ bool CustomButton::Touch(const TouchInput &input) { if (!repeat_) { for (int i = 0; i < ARRAY_SIZE(g_customKeyList); i++) { if (pspButtonBit_ & (1ULL << i)) { - controlMapper_->PSPKey(DEVICE_ID_TOUCH, g_customKeyList[i].c, KEY_UP); + controlMapper_->PSPKey(DEVICE_ID_TOUCH, g_customKeyList[i].c, KeyInputFlags::UP); } } } @@ -264,13 +264,13 @@ void CustomButton::Update() { } else if (pressedFrames_ == DOWN_FRAME) { for (int i = 0; i < ARRAY_SIZE(g_customKeyList); i++) { if (pspButtonBit_ & (1ULL << i)) { - controlMapper_->PSPKey(DEVICE_ID_TOUCH, g_customKeyList[i].c, KEY_UP); + controlMapper_->PSPKey(DEVICE_ID_TOUCH, g_customKeyList[i].c, KeyInputFlags::UP); } } } else if (on_ && pressedFrames_ == 0) { for (int i = 0; i < ARRAY_SIZE(g_customKeyList); i++) { if (pspButtonBit_ & (1ULL << i)) { - controlMapper_->PSPKey(DEVICE_ID_TOUCH, g_customKeyList[i].c, KEY_DOWN); + controlMapper_->PSPKey(DEVICE_ID_TOUCH, g_customKeyList[i].c, KeyInputFlags::DOWN); } } pressedFrames_ = 1; @@ -1049,7 +1049,7 @@ bool GestureGamepad::Touch(const TouchInput &input) { const float now = time_now_d(); if (now - lastTapRelease_ < 0.3f && !haveDoubleTapped_) { if (g_Config.iDoubleTapGesture != 0 ) - controlMapper_->PSPKey(DEVICE_ID_TOUCH, GestureKey::keyList[g_Config.iDoubleTapGesture-1], KEY_DOWN); + controlMapper_->PSPKey(DEVICE_ID_TOUCH, GestureKey::keyList[g_Config.iDoubleTapGesture-1], KeyInputFlags::DOWN); haveDoubleTapped_ = true; } @@ -1081,7 +1081,7 @@ bool GestureGamepad::Touch(const TouchInput &input) { if (haveDoubleTapped_) { if (g_Config.iDoubleTapGesture != 0) - controlMapper_->PSPKey(DEVICE_ID_TOUCH, GestureKey::keyList[g_Config.iDoubleTapGesture-1], KEY_UP); + controlMapper_->PSPKey(DEVICE_ID_TOUCH, GestureKey::keyList[g_Config.iDoubleTapGesture-1], KeyInputFlags::UP); haveDoubleTapped_ = false; } @@ -1110,37 +1110,37 @@ void GestureGamepad::Update() { float dy = deltaY_ * g_display.dpi_scale_y * g_Config.fSwipeSensitivity; if (g_Config.iSwipeRight != 0) { if (dx > th) { - controlMapper_->PSPKey(DEVICE_ID_TOUCH, GestureKey::keyList[g_Config.iSwipeRight-1], KEY_DOWN); + controlMapper_->PSPKey(DEVICE_ID_TOUCH, GestureKey::keyList[g_Config.iSwipeRight-1], KeyInputFlags::DOWN); swipeRightReleased_ = false; } else if (!swipeRightReleased_) { - controlMapper_->PSPKey(DEVICE_ID_TOUCH, GestureKey::keyList[g_Config.iSwipeRight-1], KEY_UP); + controlMapper_->PSPKey(DEVICE_ID_TOUCH, GestureKey::keyList[g_Config.iSwipeRight-1], KeyInputFlags::UP); swipeRightReleased_ = true; } } if (g_Config.iSwipeLeft != 0) { if (dx < -th) { - controlMapper_->PSPKey(DEVICE_ID_TOUCH, GestureKey::keyList[g_Config.iSwipeLeft-1], KEY_DOWN); + controlMapper_->PSPKey(DEVICE_ID_TOUCH, GestureKey::keyList[g_Config.iSwipeLeft-1], KeyInputFlags::DOWN); swipeLeftReleased_ = false; } else if (!swipeLeftReleased_) { - controlMapper_->PSPKey(DEVICE_ID_TOUCH, GestureKey::keyList[g_Config.iSwipeLeft-1], KEY_UP); + controlMapper_->PSPKey(DEVICE_ID_TOUCH, GestureKey::keyList[g_Config.iSwipeLeft-1], KeyInputFlags::UP); swipeLeftReleased_ = true; } } if (g_Config.iSwipeUp != 0) { if (dy < -th) { - controlMapper_->PSPKey(DEVICE_ID_TOUCH, GestureKey::keyList[g_Config.iSwipeUp-1], KEY_DOWN); + controlMapper_->PSPKey(DEVICE_ID_TOUCH, GestureKey::keyList[g_Config.iSwipeUp-1], KeyInputFlags::DOWN); swipeUpReleased_ = false; } else if (!swipeUpReleased_) { - controlMapper_->PSPKey(DEVICE_ID_TOUCH, GestureKey::keyList[g_Config.iSwipeUp-1], KEY_UP); + controlMapper_->PSPKey(DEVICE_ID_TOUCH, GestureKey::keyList[g_Config.iSwipeUp-1], KeyInputFlags::UP); swipeUpReleased_ = true; } } if (g_Config.iSwipeDown != 0) { if (dy > th) { - controlMapper_->PSPKey(DEVICE_ID_TOUCH, GestureKey::keyList[g_Config.iSwipeDown-1], KEY_DOWN); + controlMapper_->PSPKey(DEVICE_ID_TOUCH, GestureKey::keyList[g_Config.iSwipeDown-1], KeyInputFlags::DOWN); swipeDownReleased_ = false; } else if (!swipeDownReleased_) { - controlMapper_->PSPKey(DEVICE_ID_TOUCH, GestureKey::keyList[g_Config.iSwipeDown-1], KEY_UP); + controlMapper_->PSPKey(DEVICE_ID_TOUCH, GestureKey::keyList[g_Config.iSwipeDown-1], KeyInputFlags::UP); swipeDownReleased_ = true; } } diff --git a/UI/JitCompareScreen.cpp b/UI/JitCompareScreen.cpp index 2060abdf7e..d223a1f760 100644 --- a/UI/JitCompareScreen.cpp +++ b/UI/JitCompareScreen.cpp @@ -485,7 +485,7 @@ void AddressPromptScreen::UpdatePreviewDigits() { } bool AddressPromptScreen::key(const KeyInput &key) { - if (key.flags & KEY_DOWN) { + if (key.flags & KeyInputFlags::DOWN) { if (key.keyCode >= NKCODE_0 && key.keyCode <= NKCODE_9) { AddDigit(key.keyCode - NKCODE_0); } else if (key.keyCode >= NKCODE_A && key.keyCode <= NKCODE_F) { diff --git a/UI/MainScreen.cpp b/UI/MainScreen.cpp index 2c82140a91..bc036db171 100644 --- a/UI/MainScreen.cpp +++ b/UI/MainScreen.cpp @@ -153,15 +153,15 @@ public: if (HasFocus() && UI::IsInfoKey(key)) { // If the button mapped to triangle, then show the info. - if (key.flags & KEY_UP) { + if (key.flags & KeyInputFlags::UP) { showInfo = true; } } else if (hovering_ && key.deviceId == DEVICE_ID_MOUSE && key.keyCode == NKCODE_EXT_MOUSEBUTTON_2) { // If it's the right mouse button, and it's not otherwise mapped, show the info also. - if (key.flags & KEY_DOWN) { + if (key.flags & KeyInputFlags::DOWN) { showInfoPressed_ = true; } - if ((key.flags & KEY_UP) && showInfoPressed_) { + if ((key.flags & KeyInputFlags::UP) && showInfoPressed_) { showInfo = true; showInfoPressed_ = false; } @@ -1369,7 +1369,7 @@ void MainScreen::CreateViews() { } bool MainScreen::key(const KeyInput &touch) { - if (touch.flags & KEY_DOWN) { + if (touch.flags & KeyInputFlags::DOWN) { if (touch.keyCode == NKCODE_CTRL_LEFT || touch.keyCode == NKCODE_CTRL_RIGHT) searchKeyModifier_ = true; if (touch.keyCode == NKCODE_F && searchKeyModifier_ && System_GetPropertyBool(SYSPROP_HAS_TEXT_INPUT_DIALOG)) { @@ -1379,7 +1379,7 @@ bool MainScreen::key(const KeyInput &touch) { searchChanged_ = true; }); } - } else if (touch.flags & KEY_UP) { + } else if (touch.flags & KeyInputFlags::UP) { if (touch.keyCode == NKCODE_CTRL_LEFT || touch.keyCode == NKCODE_CTRL_RIGHT) searchKeyModifier_ = false; } diff --git a/UI/MiscScreens.cpp b/UI/MiscScreens.cpp index 1ab57c9d61..843acc016d 100644 --- a/UI/MiscScreens.cpp +++ b/UI/MiscScreens.cpp @@ -409,7 +409,7 @@ void LogoScreen::sendMessage(UIMessage message, const char *value) { } bool LogoScreen::key(const KeyInput &key) { - if (key.deviceId != DEVICE_ID_MOUSE && (key.flags & KEY_DOWN)) { + if (key.deviceId != DEVICE_ID_MOUSE && (key.flags & KeyInputFlags::DOWN)) { Next(); return true; } diff --git a/UI/MiscViews.cpp b/UI/MiscViews.cpp index d4230957f8..5b10ab1ebc 100644 --- a/UI/MiscViews.cpp +++ b/UI/MiscViews.cpp @@ -134,7 +134,7 @@ PaneTitleBar::PaneTitleBar(const Path &gamePath, std::string_view title, const s auto dlg = GetI18NCategory(I18NCat::DIALOG); if (!title.empty()) { - SimpleTextView *titleView = Add(new SimpleTextView(title, new LinearLayoutParams(0.0f, Gravity::G_VCENTER, Margins(10, 0, 20, 0)))); + SimpleTextView *titleView = Add(new SimpleTextView(title, new LinearLayoutParams(0.0f, Gravity::G_VCENTER, Margins(8, 0, 20, 0)))); titleView->SetBig(true); // If using HCENTER, to balance the centering, add a spacer on the right. } diff --git a/UI/NativeApp.cpp b/UI/NativeApp.cpp index af874315da..73d79d67a4 100644 --- a/UI/NativeApp.cpp +++ b/UI/NativeApp.cpp @@ -1335,7 +1335,7 @@ static void ProcessWheelRelease(InputKeyCode keyCode, double now, bool keyPress) KeyInput key{}; key.deviceId = DEVICE_ID_MOUSE; key.keyCode = keyCode; - key.flags = KEY_UP; + key.flags = KeyInputFlags::UP; NativeKey(key); } @@ -1356,7 +1356,7 @@ bool NativeKey(const KeyInput &key) { #if PPSSPP_PLATFORM(UWP) // Ignore if key sent from OnKeyDown/OnKeyUp/XInput while text edit active // it's already handled by `OnCharacterReceived` - if (IgnoreInput(key.keyCode) && !(key.flags & KEY_CHAR)) { + if (IgnoreInput(key.keyCode) && !(key.flags & KeyInputFlags::CHAR)) { return false; } #endif @@ -1377,7 +1377,7 @@ bool NativeKey(const KeyInput &key) { #ifdef _DEBUG // Debug hack: Randomize the language with F9! - if (false && (key.keyCode == NKCODE_F9 && (key.flags & KEY_DOWN))) { + if (false && (key.keyCode == NKCODE_F9 && (key.flags & KeyInputFlags::DOWN))) { std::vector tempLangs; g_VFS.GetFileListing("lang", &tempLangs, "ini"); int x = rand() % tempLangs.size(); @@ -1398,11 +1398,11 @@ bool NativeKey(const KeyInput &key) { } // Handle releases of mousewheel keys. - if ((key.flags & KEY_DOWN) && key.deviceId == DEVICE_ID_MOUSE && (key.keyCode == NKCODE_EXT_MOUSEWHEEL_UP || key.keyCode == NKCODE_EXT_MOUSEWHEEL_DOWN)) { + if ((key.flags & KeyInputFlags::DOWN) && key.deviceId == DEVICE_ID_MOUSE && (key.keyCode == NKCODE_EXT_MOUSEWHEEL_UP || key.keyCode == NKCODE_EXT_MOUSEWHEEL_DOWN)) { ProcessWheelRelease(key.keyCode, now, true); } - HLEPlugins::SetKey(key.keyCode, (key.flags & KEY_DOWN) ? 1 : 0); + HLEPlugins::SetKey(key.keyCode, (key.flags & KeyInputFlags::DOWN) ? 1 : 0); // Dispatch the key event. bool retval = g_screenManager->key(key); diff --git a/UI/PauseScreen.cpp b/UI/PauseScreen.cpp index 73341f1a60..736c7882d3 100644 --- a/UI/PauseScreen.cpp +++ b/UI/PauseScreen.cpp @@ -342,7 +342,7 @@ GamePauseScreen::~GamePauseScreen() { } bool GamePauseScreen::key(const KeyInput &key) { - if (!UIScreen::key(key) && (key.flags & KEY_DOWN)) { + if (!UIScreen::key(key) && (key.flags & KeyInputFlags::DOWN)) { // Special case to be able to unpause with a bound pause key. // Normally we can't bind keys used in the UI. InputMapping mapping(key.deviceId, key.keyCode); diff --git a/UI/SystemInfoScreen.cpp b/UI/SystemInfoScreen.cpp index 9c8576edee..50c8080b4d 100644 --- a/UI/SystemInfoScreen.cpp +++ b/UI/SystemInfoScreen.cpp @@ -111,7 +111,8 @@ void SystemInfoScreen::CreateDeviceInfoTab(UI::LinearLayout *deviceSpecs) { auto si = GetI18NCategory(I18NCat::SYSINFO); auto gr = GetI18NCategory(I18NCat::GRAPHICS); - deviceSpecs->Add(new TopBar(*screenManager()->getUIContext(), TopBarFlags::Default, si->T("Device Info"))); + // bool portrait = GetDeviceOrientation() == DeviceOrientation::Portrait; + // deviceSpecs->Add(new TopBar(*screenManager()->getUIContext(), portrait ? TopBarFlags::Portrait : TopBarFlags::Default, si->T("Device Info"))); UI::CollapsibleSection *systemInfo = deviceSpecs->Add(new UI::CollapsibleSection(si->T("System Information"))); diff --git a/UWP/PPSSPP_UWPMain.cpp b/UWP/PPSSPP_UWPMain.cpp index 48ae35fd58..5621a6c51b 100644 --- a/UWP/PPSSPP_UWPMain.cpp +++ b/UWP/PPSSPP_UWPMain.cpp @@ -204,7 +204,7 @@ void PPSSPP_UWPMain::OnKeyDown(int scanCode, Windows::System::VirtualKey virtual KeyInput key{}; key.deviceId = DEVICE_ID_KEYBOARD; key.keyCode = iter->second; - key.flags = KEY_DOWN | (repeatCount > 1 ? KEY_IS_REPEAT : 0); + key.flags = KeyInputFlags::DOWN | (repeatCount > 1 ? KeyInputFlags::IS_REPEAT : 0); NativeKey(key); } } @@ -215,7 +215,7 @@ void PPSSPP_UWPMain::OnKeyUp(int scanCode, Windows::System::VirtualKey virtualKe KeyInput key{}; key.deviceId = DEVICE_ID_KEYBOARD; key.keyCode = iter->second; - key.flags = KEY_UP; + key.flags = KeyInputFlags::UP; NativeKey(key); } } @@ -227,9 +227,9 @@ void PPSSPP_UWPMain::OnCharacterReceived(int scanCode, unsigned int keyCode) { KeyInput key{}; key.deviceId = DEVICE_ID_KEYBOARD; key.keyCode = (InputKeyCode)keyCode; - // After many tests turns out for char just add `KEY_CHAR` for the flags - // any other flag like `KEY_DOWN` will cause conflict and trigger something else - key.flags = KEY_CHAR; + // After many tests turns out for char just add `KeyInputFlags::CHAR` for the flags + // any other flag like `KeyInputFlags::DOWN` will cause conflict and trigger something else + key.flags = KeyInputFlags::CHAR; NativeKey(key); } } @@ -245,16 +245,16 @@ void PPSSPP_UWPMain::OnMouseWheel(float delta) { KeyInput keyInput{}; keyInput.keyCode = key; keyInput.deviceId = DEVICE_ID_MOUSE; - keyInput.flags = KEY_DOWN; + keyInput.flags = KeyInputFlags::DOWN; NativeKey(keyInput); - // KEY_UP is now sent automatically afterwards for mouse wheel events, see NativeKey. + // KeyInputFlags::UP is now sent automatically afterwards for mouse wheel events, see NativeKey. } bool PPSSPP_UWPMain::OnHardwareButton(HardwareButton button) { KeyInput keyInput{}; keyInput.deviceId = DEVICE_ID_KEYBOARD; - keyInput.flags = KEY_DOWN | KEY_UP; + keyInput.flags = KeyInputFlags::DOWN | KeyInputFlags::UP; switch (button) { case HardwareButton::BACK: keyInput.keyCode = NKCODE_BACK; @@ -284,12 +284,12 @@ void PPSSPP_UWPMain::OnTouchEvent(int touchEvent, int touchId, float x, float y, key.deviceId = DEVICE_ID_MOUSE; if (touchEvent & TouchInputFlags::DOWN) { key.keyCode = NKCODE_EXT_MOUSEBUTTON_1; - key.flags = KEY_DOWN; + key.flags = KeyInputFlags::DOWN; NativeKey(key); } if (touchEvent & TouchInputFlags::UP) { key.keyCode = NKCODE_EXT_MOUSEBUTTON_1; - key.flags = KEY_UP; + key.flags = KeyInputFlags::UP; NativeKey(key); } } diff --git a/Windows/DinputDevice.cpp b/Windows/DinputDevice.cpp index 0c3775fb73..393d0a4bdc 100644 --- a/Windows/DinputDevice.cpp +++ b/Windows/DinputDevice.cpp @@ -261,7 +261,7 @@ void DinputDevice::ApplyButtons(DIJOYSTATE2 &state) { bool down = (state.rgbButtons[i] & downMask) == downMask; KeyInput key; key.deviceId = DEVICE_ID_PAD_0 + pDevNum; - key.flags = down ? KEY_DOWN : KEY_UP; + key.flags = down ? KeyInputFlags::DOWN : KeyInputFlags::UP; key.keyCode = dinput_buttons[i]; NativeKey(key); @@ -273,7 +273,7 @@ void DinputDevice::ApplyButtons(DIJOYSTATE2 &state) { KeyInput dpad[4]{}; for (int i = 0; i < 4; ++i) { dpad[i].deviceId = DEVICE_ID_PAD_0 + pDevNum; - dpad[i].flags = KEY_UP; + dpad[i].flags = KeyInputFlags::UP; } dpad[0].keyCode = NKCODE_DPAD_UP; dpad[1].keyCode = NKCODE_DPAD_LEFT; @@ -283,16 +283,16 @@ void DinputDevice::ApplyButtons(DIJOYSTATE2 &state) { if (LOWORD(state.rgdwPOV[0]) != JOY_POVCENTERED) { // These are the edges, so we use or. if (state.rgdwPOV[0] >= JOY_POVLEFT_FORWARD || state.rgdwPOV[0] <= JOY_POVFORWARD_RIGHT) { - dpad[0].flags = KEY_DOWN; + dpad[0].flags = KeyInputFlags::DOWN; } if (state.rgdwPOV[0] >= JOY_POVBACKWARD_LEFT && state.rgdwPOV[0] <= JOY_POVLEFT_FORWARD) { - dpad[1].flags = KEY_DOWN; + dpad[1].flags = KeyInputFlags::DOWN; } if (state.rgdwPOV[0] >= JOY_POVRIGHT_BACKWARD && state.rgdwPOV[0] <= JOY_POVBACKWARD_LEFT) { - dpad[2].flags = KEY_DOWN; + dpad[2].flags = KeyInputFlags::DOWN; } if (state.rgdwPOV[0] >= JOY_POVFORWARD_RIGHT && state.rgdwPOV[0] <= JOY_POVRIGHT_BACKWARD) { - dpad[3].flags = KEY_DOWN; + dpad[3].flags = KeyInputFlags::DOWN; } } diff --git a/Windows/HidInputDevice.cpp b/Windows/HidInputDevice.cpp index cee349b3d9..09665bf1c2 100644 --- a/Windows/HidInputDevice.cpp +++ b/Windows/HidInputDevice.cpp @@ -649,7 +649,7 @@ void HidInputDevice::ReleaseAllKeys(const ButtonInputMapping *buttonMappings, in const auto &mapping = buttonMappings[i]; KeyInput key; key.deviceId = DEVICE_ID_XINPUT_0 + pad_; - key.flags = KEY_UP; + key.flags = KeyInputFlags::UP; key.keyCode = mapping.keyCode; NativeKey(key); } @@ -716,14 +716,14 @@ int HidInputDevice::UpdateState() { if (downMask & mapping.button) { KeyInput key; key.deviceId = deviceID; - key.flags = KEY_DOWN; + key.flags = KeyInputFlags::DOWN; key.keyCode = mapping.keyCode; NativeKey(key); } if (upMask & mapping.button) { KeyInput key; key.deviceId = deviceID; - key.flags = KEY_UP; + key.flags = KeyInputFlags::UP; key.keyCode = mapping.keyCode; NativeKey(key); } diff --git a/Windows/MainWindow.cpp b/Windows/MainWindow.cpp index afe6dffabc..30bfe7c0ce 100644 --- a/Windows/MainWindow.cpp +++ b/Windows/MainWindow.cpp @@ -890,7 +890,7 @@ namespace MainWindow key.keyCode = NKCODE_EXT_MOUSEWHEEL_UP; } // There's no release event, but we simulate it in NativeKey/NativeFrame. - key.flags = KEY_DOWN | KEY_HASWHEELDELTA | (wheelDelta << 16); + key.flags = (KeyInputFlags)((u32)KeyInputFlags::DOWN | (u32)KeyInputFlags::HAS_WHEEL_DELTA | (wheelDelta << 16)); NativeKey(key); } break; diff --git a/Windows/RawInput.cpp b/Windows/RawInput.cpp index 2105e4123a..479366f2cd 100644 --- a/Windows/RawInput.cpp +++ b/Windows/RawInput.cpp @@ -260,7 +260,7 @@ namespace WindowsRawInput { key.deviceId = DEVICE_ID_KEYBOARD; if (raw->data.keyboard.Message == WM_KEYDOWN || raw->data.keyboard.Message == WM_SYSKEYDOWN) { - key.flags = KEY_DOWN; + key.flags = KeyInputFlags::DOWN; key.keyCode = GetTrueVKey(raw->data.keyboard); if (key.keyCode) { @@ -268,7 +268,7 @@ namespace WindowsRawInput { keyboardKeysDown.insert(key.keyCode); } } else if (raw->data.keyboard.Message == WM_KEYUP) { - key.flags = KEY_UP; + key.flags = KeyInputFlags::UP; key.keyCode = GetTrueVKey(raw->data.keyboard); if (key.keyCode) { @@ -283,7 +283,7 @@ namespace WindowsRawInput { LRESULT ProcessChar(HWND hWnd, WPARAM wParam, LPARAM lParam) { KeyInput key; key.unicodeChar = (int)wParam; // Note that this is NOT a NKCODE but a Unicode character! - key.flags = KEY_CHAR; + key.flags = KeyInputFlags::CHAR; key.deviceId = DEVICE_ID_KEYBOARD; NativeKey(key); return 0; @@ -342,7 +342,7 @@ namespace WindowsRawInput { for (int i = 0; i < 5; i++) { if (i > 0 || (g_Config.bMouseControl && (GetUIState() == UISTATE_INGAME || g_IsMappingMouseInput))) { if (raw->data.mouse.usButtonFlags & rawInputDownID[i]) { - key.flags = KEY_DOWN; + key.flags = KeyInputFlags::DOWN; key.keyCode = windowsTransTable[vkInputID[i]]; NativeTouch(touch); if (MouseInWindow(hWnd)) { @@ -350,16 +350,16 @@ namespace WindowsRawInput { } mouseDown[i] = true; } else if (raw->data.mouse.usButtonFlags & rawInputUpID[i]) { - key.flags = KEY_UP; + key.flags = KeyInputFlags::UP; key.keyCode = windowsTransTable[vkInputID[i]]; NativeTouch(touch); if (MouseInWindow(hWnd)) { if (!mouseDown[i]) { // This means they were focused outside, and clicked inside. // Seems intentional, so send a down first. - key.flags = KEY_DOWN; + key.flags = KeyInputFlags::DOWN; NativeKey(key); - key.flags = KEY_UP; + key.flags = KeyInputFlags::UP; NativeKey(key); } else { NativeKey(key); @@ -428,7 +428,7 @@ namespace WindowsRawInput { // Force-release all held keys on the keyboard to prevent annoying stray inputs. KeyInput key; key.deviceId = DEVICE_ID_KEYBOARD; - key.flags = KEY_UP; + key.flags = KeyInputFlags::UP; for (auto i = keyboardKeysDown.begin(); i != keyboardKeysDown.end(); ++i) { key.keyCode = *i; NativeKey(key); diff --git a/Windows/XinputDevice.cpp b/Windows/XinputDevice.cpp index a38c4fd91b..9579e125d7 100644 --- a/Windows/XinputDevice.cpp +++ b/Windows/XinputDevice.cpp @@ -243,14 +243,14 @@ void XinputDevice::ApplyButtons(int pad, const XINPUT_STATE &state) { if (downMask & xinput_ctrl_map[i].from) { KeyInput key; key.deviceId = DEVICE_ID_XINPUT_0 + pad; - key.flags = KEY_DOWN; + key.flags = KeyInputFlags::DOWN; key.keyCode = xinput_ctrl_map[i].to; NativeKey(key); } if (upMask & xinput_ctrl_map[i].from) { KeyInput key; key.deviceId = DEVICE_ID_XINPUT_0 + pad; - key.flags = KEY_UP; + key.flags = KeyInputFlags::UP; key.keyCode = xinput_ctrl_map[i].to; NativeKey(key); } diff --git a/android/jni/app-android.cpp b/android/jni/app-android.cpp index 3de9661722..89c9a6fb39 100644 --- a/android/jni/app-android.cpp +++ b/android/jni/app-android.cpp @@ -1248,9 +1248,9 @@ extern "C" jboolean Java_org_ppsspp_ppsspp_NativeApp_keyDown(JNIEnv *, jclass, j KeyInput keyInput; keyInput.deviceId = (InputDeviceID)deviceId; keyInput.keyCode = (InputKeyCode)key; - keyInput.flags = KEY_DOWN; + keyInput.flags = KeyInputFlags::DOWN; if (isRepeat) { - keyInput.flags |= KEY_IS_REPEAT; + keyInput.flags |= KeyInputFlags::IS_REPEAT; } return NativeKey(keyInput); } @@ -1267,7 +1267,7 @@ extern "C" jboolean Java_org_ppsspp_ppsspp_NativeApp_keyUp(JNIEnv *, jclass, jin KeyInput keyInput; keyInput.deviceId = (InputDeviceID)deviceId; keyInput.keyCode = (InputKeyCode)key; - keyInput.flags = KEY_UP; + keyInput.flags = KeyInputFlags::UP; return NativeKey(keyInput); } @@ -1350,7 +1350,7 @@ extern "C" jboolean Java_org_ppsspp_ppsspp_NativeApp_mouse( case 3: input.keyCode = NKCODE_EXT_MOUSEBUTTON_3; break; default: WARN_LOG(Log::System, "Unexpected mouse button %d", button); } - input.flags = action == 1 ? KEY_DOWN : KEY_UP; + input.flags = action == 1 ? KeyInputFlags::DOWN : KeyInputFlags::UP; if (input.keyCode != 0) { NativeKey(input); } @@ -1377,7 +1377,7 @@ extern "C" jboolean Java_org_ppsspp_ppsspp_NativeApp_mouseWheelEvent( } // There's no separate keyup event for mousewheel events, // so we release it with a slight delay. - key.flags = KEY_DOWN | KEY_HASWHEELDELTA | (wheelDelta << 16); + key.flags = (KeyInputFlags)((u32)KeyInputFlags::DOWN | (u32)KeyInputFlags::HAS_WHEEL_DELTA | (wheelDelta << 16)); NativeKey(key); return true; } diff --git a/ext/imgui/imgui_impl_platform.cpp b/ext/imgui/imgui_impl_platform.cpp index dfeb7fae33..b07e377216 100644 --- a/ext/imgui/imgui_impl_platform.cpp +++ b/ext/imgui/imgui_impl_platform.cpp @@ -15,7 +15,7 @@ Bounds g_imguiCentralNodeBounds; void ImGui_ImplPlatform_KeyEvent(const KeyInput &key) { ImGuiIO &io = ImGui::GetIO(); - if (key.flags & KEY_DOWN) { + if (key.flags & KeyInputFlags::DOWN) { // Specially handle scroll events and any other special keys. switch (key.keyCode) { case NKCODE_EXT_MOUSEWHEEL_UP: @@ -34,13 +34,13 @@ void ImGui_ImplPlatform_KeyEvent(const KeyInput &key) { } } } - if (key.flags & KEY_UP) { + if (key.flags & KeyInputFlags::UP) { ImGuiKey keyCode = KeyCodeToImGui(key.keyCode); if (keyCode != ImGuiKey_None) { io.AddKeyEvent(keyCode, false); } } - if (key.flags & KEY_CHAR) { + if (key.flags & KeyInputFlags::CHAR) { const int unichar = key.unicodeChar; if (unichar >= 0x20) { diff --git a/ios/PPSSPPUIApplication.mm b/ios/PPSSPPUIApplication.mm index aabb3695d6..be3c76e444 100644 --- a/ios/PPSSPPUIApplication.mm +++ b/ios/PPSSPPUIApplication.mm @@ -77,13 +77,13 @@ if (eventType == GSEVENT_TYPE_KEYUP) { struct KeyInput key; - key.flags = KEY_UP; + key.flags = KeyInputFlags::UP; key.keyCode = getSmartKeyboardMap((int)eventScanCode); key.deviceId = DEVICE_ID_KEYBOARD; NativeKey(key); } else if (GSEVENT_TYPE_KEYDOWN) { struct KeyInput key; - key.flags = KEY_DOWN; + key.flags = KeyInputFlags::DOWN; key.keyCode = getSmartKeyboardMap((int)eventScanCode); key.deviceId = DEVICE_ID_KEYBOARD; NativeKey(key);