InputCommon/SDL: Avoid potential infinite loops from integer truncation.
This commit is contained in:
parent
d657ad5932
commit
5e6e61c723
|
@ -453,11 +453,11 @@ GameController::GameController(SDL_GameController* const gamecontroller,
|
||||||
// Legacy inputs
|
// Legacy inputs
|
||||||
|
|
||||||
// Buttons
|
// Buttons
|
||||||
for (u8 i = 0; i != n_legacy_buttons; ++i)
|
for (int i = 0; i != n_legacy_buttons; ++i)
|
||||||
AddInput(new LegacyButton(m_joystick, i, !is_button_mapped[i]));
|
AddInput(new LegacyButton(m_joystick, i, !is_button_mapped[i]));
|
||||||
|
|
||||||
// Axes
|
// Axes
|
||||||
for (u8 i = 0; i != n_legacy_axes; ++i)
|
for (int i = 0; i != n_legacy_axes; ++i)
|
||||||
{
|
{
|
||||||
// each axis gets a negative and a positive input instance associated with it
|
// each axis gets a negative and a positive input instance associated with it
|
||||||
AddAnalogInputs(new LegacyAxis(m_joystick, i, -32768, !is_axis_mapped[i]),
|
AddAnalogInputs(new LegacyAxis(m_joystick, i, -32768, !is_axis_mapped[i]),
|
||||||
|
@ -465,7 +465,7 @@ GameController::GameController(SDL_GameController* const gamecontroller,
|
||||||
}
|
}
|
||||||
|
|
||||||
// Hats
|
// Hats
|
||||||
for (u8 i = 0; i != n_legacy_hats; ++i)
|
for (int i = 0; i != n_legacy_hats; ++i)
|
||||||
{
|
{
|
||||||
// each hat gets 4 input instances associated with it, (up down left right)
|
// each hat gets 4 input instances associated with it, (up down left right)
|
||||||
for (u8 d = 0; d != 4; ++d)
|
for (u8 d = 0; d != 4; ++d)
|
||||||
|
|
|
@ -50,7 +50,7 @@ private:
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
std::string GetName() const override;
|
std::string GetName() const override;
|
||||||
LegacyButton(SDL_Joystick* js, u8 index, bool is_detectable)
|
LegacyButton(SDL_Joystick* js, int index, bool is_detectable)
|
||||||
: m_js(js), m_index(index), m_is_detectable(is_detectable)
|
: m_js(js), m_index(index), m_is_detectable(is_detectable)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
@ -67,8 +67,8 @@ private:
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
std::string GetName() const override;
|
std::string GetName() const override;
|
||||||
LegacyAxis(SDL_Joystick* js, u8 index, Sint16 range, bool is_detectable)
|
LegacyAxis(SDL_Joystick* js, int index, s16 range, bool is_detectable)
|
||||||
: m_js(js), m_range(range), m_index(index), m_is_detectable(is_detectable)
|
: m_js(js), m_index(index), m_range(range), m_is_detectable(is_detectable)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
bool IsDetectable() const override { return m_is_detectable; }
|
bool IsDetectable() const override { return m_is_detectable; }
|
||||||
|
@ -76,8 +76,8 @@ private:
|
||||||
|
|
||||||
private:
|
private:
|
||||||
SDL_Joystick* const m_js;
|
SDL_Joystick* const m_js;
|
||||||
const Sint16 m_range;
|
const int m_index;
|
||||||
const u8 m_index;
|
const s16 m_range;
|
||||||
const bool m_is_detectable;
|
const bool m_is_detectable;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -85,8 +85,8 @@ private:
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
std::string GetName() const override;
|
std::string GetName() const override;
|
||||||
LegacyHat(SDL_Joystick* js, u8 index, u8 direction, bool is_detectable)
|
LegacyHat(SDL_Joystick* js, int index, u8 direction, bool is_detectable)
|
||||||
: m_js(js), m_direction(direction), m_index(index), m_is_detectable(is_detectable)
|
: m_js(js), m_index(index), m_direction(direction), m_is_detectable(is_detectable)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
bool IsDetectable() const override { return m_is_detectable; }
|
bool IsDetectable() const override { return m_is_detectable; }
|
||||||
|
@ -94,8 +94,8 @@ private:
|
||||||
|
|
||||||
private:
|
private:
|
||||||
SDL_Joystick* const m_js;
|
SDL_Joystick* const m_js;
|
||||||
|
const int m_index;
|
||||||
const u8 m_direction;
|
const u8 m_direction;
|
||||||
const u8 m_index;
|
|
||||||
const bool m_is_detectable;
|
const bool m_is_detectable;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue