mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-07-21 05:09:34 -06:00
InputCommon/SDL: Code style fixes.
This commit is contained in:
@ -338,7 +338,7 @@ GameController::GameController(SDL_GameController* const gamecontroller,
|
|||||||
name = SDL_GameControllerName(gamecontroller);
|
name = SDL_GameControllerName(gamecontroller);
|
||||||
else
|
else
|
||||||
name = SDL_JoystickName(joystick);
|
name = SDL_JoystickName(joystick);
|
||||||
m_name = name != NULL ? name : "Unknown";
|
m_name = name != nullptr ? name : "Unknown";
|
||||||
|
|
||||||
// If a Joystick Button has a GameController equivalent, don't detect it
|
// If a Joystick Button has a GameController equivalent, don't detect it
|
||||||
int n_legacy_buttons = SDL_JoystickNumButtons(joystick);
|
int n_legacy_buttons = SDL_JoystickNumButtons(joystick);
|
||||||
@ -362,11 +362,11 @@ GameController::GameController(SDL_GameController* const gamecontroller,
|
|||||||
n_legacy_hats = 0;
|
n_legacy_hats = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::vector<bool> is_button_mapped(n_legacy_buttons);
|
std::vector<bool> is_button_mapped(static_cast<size_t>(n_legacy_buttons), false);
|
||||||
std::vector<bool> is_axis_mapped(n_legacy_axes);
|
std::vector<bool> is_axis_mapped(static_cast<size_t>(n_legacy_axes), false);
|
||||||
std::vector<bool> is_hat_mapped(n_legacy_hats);
|
std::vector<bool> is_hat_mapped(static_cast<size_t>(n_legacy_hats), false);
|
||||||
|
|
||||||
auto RegisterMapping = [&](SDL_GameControllerButtonBind bind) {
|
const auto register_mapping = [&](const SDL_GameControllerButtonBind& bind) {
|
||||||
switch (bind.bindType)
|
switch (bind.bindType)
|
||||||
{
|
{
|
||||||
case SDL_CONTROLLER_BINDTYPE_NONE:
|
case SDL_CONTROLLER_BINDTYPE_NONE:
|
||||||
@ -397,7 +397,7 @@ GameController::GameController(SDL_GameController* const gamecontroller,
|
|||||||
if (SDL_GameControllerHasButton(m_gamecontroller, button))
|
if (SDL_GameControllerHasButton(m_gamecontroller, button))
|
||||||
{
|
{
|
||||||
AddInput(new Button(gamecontroller, button));
|
AddInput(new Button(gamecontroller, button));
|
||||||
RegisterMapping(SDL_GameControllerGetBindForButton(gamecontroller, button));
|
register_mapping(SDL_GameControllerGetBindForButton(gamecontroller, button));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -418,7 +418,7 @@ GameController::GameController(SDL_GameController* const gamecontroller,
|
|||||||
{
|
{
|
||||||
AddInput(new Axis(m_gamecontroller, 32767, axis));
|
AddInput(new Axis(m_gamecontroller, 32767, axis));
|
||||||
}
|
}
|
||||||
RegisterMapping(SDL_GameControllerGetBindForAxis(gamecontroller, axis));
|
register_mapping(SDL_GameControllerGetBindForAxis(gamecontroller, axis));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// Rumble
|
// Rumble
|
||||||
@ -430,7 +430,7 @@ GameController::GameController(SDL_GameController* const gamecontroller,
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Motion
|
// Motion
|
||||||
auto AddSensor = [this](SDL_SensorType type, std::string_view name,
|
const auto add_sensor = [this](SDL_SensorType type, std::string_view name,
|
||||||
const SDLMotionAxisList& axes) {
|
const SDLMotionAxisList& axes) {
|
||||||
if (SDL_GameControllerSetSensorEnabled(m_gamecontroller, type, SDL_TRUE) == 0)
|
if (SDL_GameControllerSetSensorEnabled(m_gamecontroller, type, SDL_TRUE) == 0)
|
||||||
{
|
{
|
||||||
@ -442,12 +442,12 @@ GameController::GameController(SDL_GameController* const gamecontroller,
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
AddSensor(SDL_SENSOR_ACCEL, "Accel", SDL_AXES_ACCELEROMETER);
|
add_sensor(SDL_SENSOR_ACCEL, "Accel", SDL_AXES_ACCELEROMETER);
|
||||||
AddSensor(SDL_SENSOR_GYRO, "Gyro", SDL_AXES_GYRO);
|
add_sensor(SDL_SENSOR_GYRO, "Gyro", SDL_AXES_GYRO);
|
||||||
AddSensor(SDL_SENSOR_ACCEL_L, "Accel L", SDL_AXES_ACCELEROMETER);
|
add_sensor(SDL_SENSOR_ACCEL_L, "Accel L", SDL_AXES_ACCELEROMETER);
|
||||||
AddSensor(SDL_SENSOR_GYRO_L, "Gyro L", SDL_AXES_GYRO);
|
add_sensor(SDL_SENSOR_GYRO_L, "Gyro L", SDL_AXES_GYRO);
|
||||||
AddSensor(SDL_SENSOR_ACCEL_R, "Accel R", SDL_AXES_ACCELEROMETER);
|
add_sensor(SDL_SENSOR_ACCEL_R, "Accel R", SDL_AXES_ACCELEROMETER);
|
||||||
AddSensor(SDL_SENSOR_GYRO_R, "Gyro R", SDL_AXES_GYRO);
|
add_sensor(SDL_SENSOR_GYRO_R, "Gyro R", SDL_AXES_GYRO);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Legacy inputs
|
// Legacy inputs
|
||||||
|
@ -103,7 +103,7 @@ private:
|
|||||||
class Motor : public Output
|
class Motor : public Output
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
explicit Motor(SDL_GameController* gc) : m_gc(gc){};
|
explicit Motor(SDL_GameController* gc) : m_gc(gc) {}
|
||||||
std::string GetName() const override;
|
std::string GetName() const override;
|
||||||
void SetState(ControlState state) override;
|
void SetState(ControlState state) override;
|
||||||
|
|
||||||
@ -114,7 +114,7 @@ private:
|
|||||||
class MotorL : public Output
|
class MotorL : public Output
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
explicit MotorL(SDL_GameController* gc) : m_gc(gc){};
|
explicit MotorL(SDL_GameController* gc) : m_gc(gc) {}
|
||||||
std::string GetName() const override;
|
std::string GetName() const override;
|
||||||
void SetState(ControlState state) override;
|
void SetState(ControlState state) override;
|
||||||
|
|
||||||
@ -122,11 +122,10 @@ private:
|
|||||||
SDL_GameController* const m_gc;
|
SDL_GameController* const m_gc;
|
||||||
};
|
};
|
||||||
|
|
||||||
// Rumble
|
|
||||||
class MotorR : public Output
|
class MotorR : public Output
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
explicit MotorR(SDL_GameController* gc) : m_gc(gc){};
|
explicit MotorR(SDL_GameController* gc) : m_gc(gc) {}
|
||||||
std::string GetName() const override;
|
std::string GetName() const override;
|
||||||
void SetState(ControlState state) override;
|
void SetState(ControlState state) override;
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user