From f460151f39b123af6fc102b582275e3b4054a04b Mon Sep 17 00:00:00 2001 From: iota97 Date: Thu, 5 Mar 2020 18:29:35 +0100 Subject: [PATCH] u8_clamp clean up --- UI/GamepadEmu.cpp | 19 ++++++++----------- UI/GamepadEmu.h | 4 ++-- 2 files changed, 10 insertions(+), 13 deletions(-) diff --git a/UI/GamepadEmu.cpp b/UI/GamepadEmu.cpp index 90e45f6a1b..355475908a 100644 --- a/UI/GamepadEmu.cpp +++ b/UI/GamepadEmu.cpp @@ -29,7 +29,6 @@ #include "gfx/texture_atlas.h" #include "math/math_util.h" #include "ui/ui_context.h" -#include "Core/Util/AudioFormat.h" // for clamp_u8 static u32 GetButtonColor() { return g_Config.iTouchButtonStyle != 0 ? 0xFFFFFF : 0xc0b080; @@ -464,8 +463,6 @@ void PSPStick::ProcessTouch(float x, float y, bool down) { PSPCustomStick::PSPCustomStick(ImageID bgImg, ImageID stickImg, ImageID stickDownImg, float scale, UI::LayoutParams *layoutParams) : PSPStick(bgImg, stickImg, stickDownImg, -1, scale, layoutParams) { - posX_ = clamp_u8((int)ceilf(127.5f)); - posY_ = clamp_u8((int)ceilf(127.5f)); } void PSPCustomStick::Draw(UIContext &dc) { @@ -490,8 +487,8 @@ void PSPCustomStick::Draw(UIContext &dc) { float stickY = centerY_; float dx, dy; - dx = (posX_ - 127.5f) / 127.5f; - dy = -(posY_ - 127.5f) / 127.5f; + dx = posX_; + dy = -posY_; dc.Draw()->DrawImage(bgImg_, stickX, stickY, 1.0f * scale_, colorBg, ALIGN_CENTER); if (dragPointerId_ != -1 && g_Config.iTouchButtonStyle == 2 && stickDownImg_ != stickImageIndex_) @@ -505,8 +502,8 @@ void PSPCustomStick::Touch(const TouchInput &input) { dragPointerId_ = -1; centerX_ = bounds_.centerX(); centerY_ = bounds_.centerY(); - posX_ = clamp_u8((int)ceilf(127.5f)); - posY_ = clamp_u8((int)ceilf(127.5f)); + posX_ = 0.0f; + posY_ = 0.0f; return; } if (input.flags & TOUCH_DOWN) { @@ -576,8 +573,8 @@ void PSPCustomStick::ProcessTouch(float x, float y, bool down) { if (g_Config.iRightAnalogPress != 0) __CtrlButtonDown(button[g_Config.iRightAnalogPress-1]); - posX_ = clamp_u8((int)ceilf(dx * 127.5f + 127.5f)); - posY_ = clamp_u8((int)ceilf(dy * 127.5f + 127.5f)); + posX_ = dx; + posY_ = dy; } else { if (g_Config.iRightAnalogUp != 0) @@ -591,8 +588,8 @@ void PSPCustomStick::ProcessTouch(float x, float y, bool down) { if (g_Config.iRightAnalogPress != 0) __CtrlButtonUp(button[g_Config.iRightAnalogPress-1]); - posX_ = clamp_u8((int)ceilf(127.5f)); - posY_ = clamp_u8((int)ceilf(127.5f)); + posX_ = 0.0f; + posY_ = 0.0f; } } diff --git a/UI/GamepadEmu.h b/UI/GamepadEmu.h index 50aef8f526..f306c09163 100644 --- a/UI/GamepadEmu.h +++ b/UI/GamepadEmu.h @@ -174,8 +174,8 @@ public: private: void ProcessTouch(float x, float y, bool down); - u8 posX_; - u8 posY_; + float posX_ = 0.0f; + float posY_ = 0.0f; }; //initializes the layout from Config. if a default layout does not exist,