Convert check_warn_joy_support_limit to non-template

This commit is contained in:
Kp 2016-10-29 23:16:15 +00:00
parent 9cb24b0d4a
commit 538b6e23fd

View file

@ -255,8 +255,7 @@ int joy_axis_handler(SDL_JoyAxisEvent *jae)
/* ----------------------------------------------- */
template <unsigned MAX, typename T>
static T check_warn_joy_support_limit(const T n, const char *const desc)
static unsigned check_warn_joy_support_limit(const unsigned n, const char *const desc, const unsigned MAX)
{
if (n <= MAX)
{
@ -282,7 +281,7 @@ void joy_init()
joybutton_text.clear();
#endif
const auto n = check_warn_joy_support_limit<DXX_MAX_JOYSTICKS>(SDL_NumJoysticks(), "joystick");
const auto n = check_warn_joy_support_limit(SDL_NumJoysticks(), "joystick", DXX_MAX_JOYSTICKS);
unsigned joystick_n_buttons = 0, joystick_n_axes = 0;
for (int i = 0; i < n; i++) {
auto &joystick = SDL_Joysticks[num_joysticks];
@ -296,7 +295,7 @@ void joy_init()
if (handle)
{
#if DXX_MAX_AXES_PER_JOYSTICK
const auto n_axes = check_warn_joy_support_limit<DXX_MAX_AXES_PER_JOYSTICK>(SDL_JoystickNumAxes(handle), "axe");
const auto n_axes = check_warn_joy_support_limit(SDL_JoystickNumAxes(handle), "axe", DXX_MAX_AXES_PER_JOYSTICK);
joyaxis_text.resize(joyaxis_text.size() + n_axes);
for (int j=0; j < n_axes; j++)
@ -308,8 +307,8 @@ void joy_init()
#endif
#if DXX_MAX_BUTTONS_PER_JOYSTICK || DXX_MAX_HATS_PER_JOYSTICK
const auto n_buttons = check_warn_joy_support_limit<DXX_MAX_BUTTONS_PER_JOYSTICK>(SDL_JoystickNumButtons(handle), "button");
const auto n_hats = check_warn_joy_support_limit<DXX_MAX_HATS_PER_JOYSTICK>(SDL_JoystickNumHats(handle), "hat");
const auto n_buttons = check_warn_joy_support_limit(SDL_JoystickNumButtons(handle), "button", DXX_MAX_BUTTONS_PER_JOYSTICK);
const auto n_hats = check_warn_joy_support_limit(SDL_JoystickNumHats(handle), "hat", DXX_MAX_HATS_PER_JOYSTICK);
joybutton_text.resize(joybutton_text.size() + n_buttons + (4 * n_hats));
#if DXX_MAX_BUTTONS_PER_JOYSTICK