diff --git a/input/overlay.c b/input/overlay.c index 1e2a1c3089..c7d6b3d2f5 100644 --- a/input/overlay.c +++ b/input/overlay.c @@ -22,6 +22,7 @@ #include #include "input_common.h" #include +#include #include #include @@ -695,15 +696,6 @@ static bool inside_hitbox(const struct overlay_desc *desc, float x, float y) return false; } -static inline float clamp(float val, float lower, float upper) -{ - if (val < lower) - return lower; - else if (val > upper) - return upper; - return val; -} - void input_overlay_poll(input_overlay_t *ol, input_overlay_state_t *out, int16_t norm_x, int16_t norm_y) { @@ -757,17 +749,17 @@ void input_overlay_poll(input_overlay_t *ol, input_overlay_state_t *out, float y_val_sat = y_val / desc->analog_saturate_pct; unsigned int base = (desc->type == OVERLAY_TYPE_ANALOG_RIGHT) ? 2 : 0; - out->analog[base + 0] = clamp(x_val_sat, -1.0f, 1.0f) * 32767.0f; - out->analog[base + 1] = clamp(y_val_sat, -1.0f, 1.0f) * 32767.0f; + out->analog[base + 0] = clamp_float(x_val_sat, -1.0f, 1.0f) * 32767.0f; + out->analog[base + 1] = clamp_float(y_val_sat, -1.0f, 1.0f) * 32767.0f; } if (desc->movable) { float x_dist = x - desc->x; float y_dist = y - desc->y; - desc->delta_x = clamp(x_dist, -desc->range_x, desc->range_x) + desc->delta_x = clamp_float(x_dist, -desc->range_x, desc->range_x) * ol->active->mod_w; - desc->delta_y = clamp(y_dist, -desc->range_y, desc->range_y) + desc->delta_y = clamp_float(y_dist, -desc->range_y, desc->range_y) * ol->active->mod_h; } } diff --git a/libretro-sdk/include/clamping.h b/libretro-sdk/include/clamping.h new file mode 100644 index 0000000000..c066c11b43 --- /dev/null +++ b/libretro-sdk/include/clamping.h @@ -0,0 +1,24 @@ +#ifndef _LIBRETRO_SDK_CLAMPING_H +#define _LIBRETRO_SDK_CLAMPING_H + +#include + +static inline float clamp_float(float val, float lower, float upper) +{ + if (val < lower) + return lower; + if (val > upper) + return upper; + return val; +} + +static inline uint8_t clamp_8bit(int val) +{ + if (val > 255) + return 255; + if (val < 0) + return 0; + return (uint8_t)val; +} + +#endif diff --git a/libretro-sdk/include/gfx/scaler/pixconv.h b/libretro-sdk/include/gfx/scaler/pixconv.h index 9078a92fb8..f7189e7ded 100644 --- a/libretro-sdk/include/gfx/scaler/pixconv.h +++ b/libretro-sdk/include/gfx/scaler/pixconv.h @@ -23,7 +23,7 @@ #ifndef __LIBRETRO_SDK_SCALER_PIXCONV_H__ #define __LIBRETRO_SDK_SCALER_PIXCONV_H__ -#include +#include void conv_0rgb1555_argb8888(void *output, const void *input, int width, int height, diff --git a/libretro-sdk/include/gfx/scaler/scaler.h b/libretro-sdk/include/gfx/scaler/scaler.h index ead54069e0..97014afcf0 100644 --- a/libretro-sdk/include/gfx/scaler/scaler.h +++ b/libretro-sdk/include/gfx/scaler/scaler.h @@ -26,7 +26,7 @@ #include #include #include -#include "scaler_common.h" +#include #define FILTER_UNITY (1 << 14) diff --git a/libretro-sdk/include/gfx/scaler/scaler_common.h b/libretro-sdk/include/gfx/scaler/scaler_common.h deleted file mode 100644 index d73555d6ec..0000000000 --- a/libretro-sdk/include/gfx/scaler/scaler_common.h +++ /dev/null @@ -1,37 +0,0 @@ -/* Copyright (C) 2010-2014 The RetroArch team - * - * --------------------------------------------------------------------------------------- - * The following license statement only applies to this file (scaler_common.h). - * --------------------------------------------------------------------------------------- - * - * Permission is hereby granted, free of charge, - * to any person obtaining a copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation the rights to - * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, - * and to permit persons to whom the Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, - * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. - * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, - * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - -#ifndef __LIBRETRO_SDK_SCALER_COMMON_H__ -#define __LIBRETRO_SDK_SCALER_COMMON_H__ - -#include - -static inline uint8_t clamp_8bit(int val) -{ - if (val > 255) - return 255; - if (val < 0) - return 0; - return (uint8_t)val; -} - -#endif