From e078f61baddc6b4c6c7346e0d8892a34a507676a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Henrik=20Rydg=C3=A5rd?= Date: Mon, 8 May 2023 10:13:16 +0200 Subject: [PATCH 1/3] Rename class CustomKey to CustomButton --- UI/CustomButtonMappingScreen.h | 2 +- UI/GamepadEmu.cpp | 12 ++++++------ UI/GamepadEmu.h | 4 ++-- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/UI/CustomButtonMappingScreen.h b/UI/CustomButtonMappingScreen.h index 2fda9162687e..66fbf869ea63 100644 --- a/UI/CustomButtonMappingScreen.h +++ b/UI/CustomButtonMappingScreen.h @@ -28,7 +28,7 @@ class CustomButtonMappingScreen : public UIDialogScreenWithGameBackground { public: CustomButtonMappingScreen(const Path &gamePath, int id) : UIDialogScreenWithGameBackground(gamePath), id_(id) {} - const char *tag() const override { return "CustomKey"; } + const char *tag() const override { return "CustomButton"; } void CreateViews() override; void onFinish(DialogResult result) override; diff --git a/UI/GamepadEmu.cpp b/UI/GamepadEmu.cpp index d9c66dc7e721..53b6412ce5a4 100644 --- a/UI/GamepadEmu.cpp +++ b/UI/GamepadEmu.cpp @@ -189,11 +189,11 @@ bool PSPButton::Touch(const TouchInput &input) { return retval; } -bool CustomKey::IsDown() { +bool CustomButton::IsDown() { return (toggle_ && on_) || (!toggle_ && pointerDownMask_ != 0); } -void CustomKey::GetContentDimensions(const UIContext &dc, float &w, float &h) const { +void CustomButton::GetContentDimensions(const UIContext &dc, float &w, float &h) const { MultiTouchButton::GetContentDimensions(dc, w, h); if (invertedContextDimension_) { float tmp = w; @@ -202,7 +202,7 @@ void CustomKey::GetContentDimensions(const UIContext &dc, float &w, float &h) co } } -bool CustomKey::Touch(const TouchInput &input) { +bool CustomButton::Touch(const TouchInput &input) { using namespace CustomKeyData; bool lastDown = pointerDownMask_ != 0; bool retval = MultiTouchButton::Touch(input); @@ -233,7 +233,7 @@ bool CustomKey::Touch(const TouchInput &input) { return retval; } -void CustomKey::Update() { +void CustomButton::Update() { MultiTouchButton::Update(); using namespace CustomKeyData; @@ -825,10 +825,10 @@ UI::ViewGroup *CreatePadLayout(float xres, float yres, bool *pause, bool showPau } return nullptr; }; - auto addCustomButton = [=](const ConfigCustomButton& cfg, const char *key, const ConfigTouchPos &touch) -> CustomKey * { + auto addCustomButton = [=](const ConfigCustomButton& cfg, const char *key, const ConfigTouchPos &touch) -> CustomButton * { using namespace CustomKeyData; if (touch.show) { - auto aux = root->Add(new CustomKey(cfg.key, key, cfg.toggle, cfg.repeat, controllMapper, + auto aux = root->Add(new CustomButton(cfg.key, key, cfg.toggle, cfg.repeat, controllMapper, g_Config.iTouchButtonStyle == 0 ? customKeyShapes[cfg.shape].i : customKeyShapes[cfg.shape].l, customKeyShapes[cfg.shape].i, customKeyImages[cfg.image].i, touch.scale, customKeyShapes[cfg.shape].d, buttonLayoutParams(touch))); aux->SetAngle(customKeyImages[cfg.image].r, customKeyShapes[cfg.shape].r); diff --git a/UI/GamepadEmu.h b/UI/GamepadEmu.h index 9236038a6838..3779088b7f4a 100644 --- a/UI/GamepadEmu.h +++ b/UI/GamepadEmu.h @@ -173,9 +173,9 @@ UI::ViewGroup *CreatePadLayout(float xres, float yres, bool *pause, bool showPau const int D_pad_Radius = 50; const int baseActionButtonSpacing = 60; -class CustomKey : public MultiTouchButton { +class CustomButton : public MultiTouchButton { public: - CustomKey(uint64_t pspButtonBit, const char *key, bool toggle, bool repeat, ControlMapper* controllMapper, ImageID bgImg, ImageID bgDownImg, ImageID img, float scale, bool invertedContextDimension, UI::LayoutParams *layoutParams) + CustomButton(uint64_t pspButtonBit, const char *key, bool toggle, bool repeat, ControlMapper* controllMapper, ImageID bgImg, ImageID bgDownImg, ImageID img, float scale, bool invertedContextDimension, UI::LayoutParams *layoutParams) : MultiTouchButton(key, bgImg, bgDownImg, img, scale, layoutParams), pspButtonBit_(pspButtonBit), toggle_(toggle), repeat_(repeat), controlMapper_(controllMapper), on_(false), invertedContextDimension_(invertedContextDimension) { } bool Touch(const TouchInput &input) override; From 9623f515e735cfa546ed067ea7a6c0087b47aadc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Henrik=20Rydg=C3=A5rd?= Date: Mon, 8 May 2023 10:46:28 +0200 Subject: [PATCH 2/3] Add back support for custom buttons to control analog inputs --- Core/ControlMapper.cpp | 2 ++ Core/ControlMapper.h | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/Core/ControlMapper.cpp b/Core/ControlMapper.cpp index 49f3d0c3e387..07945a02c5b9 100644 --- a/Core/ControlMapper.cpp +++ b/Core/ControlMapper.cpp @@ -504,10 +504,12 @@ void ControlMapper::PSPKey(int deviceId, int pspKeyCode, int flags) { if (flags & KEY_DOWN) { virtKeys_[vk] = 1.0f; onVKey(pspKeyCode, true); + onVKeyAnalog(deviceId, pspKeyCode, 1.0f); } if (flags & KEY_UP) { virtKeys_[vk] = 0.0f; onVKey(pspKeyCode, false); + onVKeyAnalog(deviceId, pspKeyCode, 0.0f); } } else { // INFO_LOG(SYSTEM, "pspKey %d %d", pspKeyCode, flags); diff --git a/Core/ControlMapper.h b/Core/ControlMapper.h index 6ebef3a76f98..bca32ff0e8f5 100644 --- a/Core/ControlMapper.h +++ b/Core/ControlMapper.h @@ -29,7 +29,7 @@ class ControlMapper { // 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, though not analog mappings. + // virtual key codes, including analog mappings. void PSPKey(int deviceId, int pspKeyCode, int flags); // Toggle swapping DPAD and Analog. Useful on some input devices with few buttons. From ce632ec079509ced43eac2430097ab66ffd3bac4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Henrik=20Rydg=C3=A5rd?= Date: Mon, 8 May 2023 10:47:03 +0200 Subject: [PATCH 3/3] IniFile: Fix writing 64-bit hex values. --- Common/Data/Format/IniFile.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Common/Data/Format/IniFile.cpp b/Common/Data/Format/IniFile.cpp index 91c042d5b4be..79ff0aebee78 100644 --- a/Common/Data/Format/IniFile.cpp +++ b/Common/Data/Format/IniFile.cpp @@ -5,6 +5,8 @@ #include #include +#include + #ifndef _MSC_VER #include #endif @@ -192,7 +194,7 @@ void Section::Set(const char* key, uint32_t newValue) { } void Section::Set(const char* key, uint64_t newValue) { - Set(key, StringFromFormat("0x%016lx", newValue).c_str()); + Set(key, StringFromFormat("0x%016" PRIx64, newValue).c_str()); } void Section::Set(const char* key, float newValue) {