mirror of
https://github.com/hrydgard/ppsspp.git
synced 2024-11-26 23:10:38 +00:00
libretro: Add a local clamp() instead of using the color conv one
This commit is contained in:
parent
5c23305e09
commit
6763ace946
@ -1,7 +1,7 @@
|
||||
#include "Common/Data/Color/RGBAUtil.h"
|
||||
|
||||
template <typename T>
|
||||
T clamp(T f, T low, T high) {
|
||||
static T clamp(T f, T low, T high) {
|
||||
if (f < low)
|
||||
return low;
|
||||
if (f > high)
|
||||
|
@ -2,8 +2,6 @@
|
||||
|
||||
#include <cstdint>
|
||||
|
||||
template <typename T>
|
||||
T clamp(T f, T low, T high);
|
||||
uint32_t whiteAlpha(float alpha);
|
||||
uint32_t blackAlpha(float alpha);
|
||||
uint32_t colorAlpha(uint32_t color, float alpha);
|
||||
|
@ -8,7 +8,6 @@
|
||||
#include <mutex>
|
||||
|
||||
#include "Common/CPUDetect.h"
|
||||
#include "Common/Data/Color/RGBAUtil.h"
|
||||
#include "Common/Log.h"
|
||||
#include "Common/LogManager.h"
|
||||
#include "Common/System/Display.h"
|
||||
@ -111,6 +110,25 @@ namespace Libretro
|
||||
static float runSpeed = 0.0f;
|
||||
static s64 runTicksLast = 0;
|
||||
|
||||
/**
|
||||
* Clamp a value to a given range.
|
||||
*
|
||||
* This implementation was taken from `RGBAUtil.cpp` to allow building when `std::clamp()` is unavailable.
|
||||
*
|
||||
* @param f The value to clamp.
|
||||
* @param low The lower bound of the range.
|
||||
* @param high The upper bound of the range.
|
||||
* @return The clamped value.
|
||||
*/
|
||||
template <typename T>
|
||||
static T clamp(T f, T low, T high) {
|
||||
if (f < low)
|
||||
return low;
|
||||
if (f > high)
|
||||
return high;
|
||||
return f;
|
||||
}
|
||||
|
||||
static void VsyncSwapIntervalReset()
|
||||
{
|
||||
expectedTimeUsPerRun = (s64)(1000000.0f / (60.0f / 1.001f));
|
||||
@ -1431,8 +1449,8 @@ static void retro_input(void)
|
||||
}
|
||||
|
||||
float mappedNorm = norm;
|
||||
x_left = clamp(x_left / norm * mappedNorm, -1.0f, 1.0f);
|
||||
y_left = clamp(y_left / norm * mappedNorm, -1.0f, 1.0f);
|
||||
x_left = Libretro::clamp(x_left / norm * mappedNorm, -1.0f, 1.0f);
|
||||
y_left = Libretro::clamp(y_left / norm * mappedNorm, -1.0f, 1.0f);
|
||||
|
||||
__CtrlSetAnalogXY(CTRL_STICK_LEFT, x_left, y_left);
|
||||
__CtrlSetAnalogXY(CTRL_STICK_RIGHT, x_right, y_right);
|
||||
|
Loading…
Reference in New Issue
Block a user