parameter cleanup

This commit is contained in:
kalaposfos13 2026-02-12 22:35:17 +01:00
parent 9b8c15276a
commit baa766857d
5 changed files with 27 additions and 27 deletions

View File

@ -93,12 +93,12 @@ int GameController::ReadStates(State* states, int states_num, bool* isConnected,
return ret_num;
}
void GameController::Button(int id, OrbisPadButtonDataOffset button, bool is_pressed) {
void GameController::Button(OrbisPadButtonDataOffset button, bool is_pressed) {
m_state.OnButton(button, is_pressed);
PushState();
}
void GameController::Axis(int id, Input::Axis axis, int value) {
void GameController::Axis(Input::Axis axis, int value) {
m_state.OnAxis(axis, value);
PushState();
}
@ -113,12 +113,12 @@ void GameController::Acceleration(int id) {
PushState();
}
void GameController::UpdateGyro(int id, const float gyro[3]) {
void GameController::UpdateGyro(const float gyro[3]) {
std::lock_guard lg(m_states_queue_mutex);
std::memcpy(gyro_buf, gyro, sizeof(gyro));
}
void GameController::UpdateAcceleration(int id, const float acceleration[3]) {
void GameController::UpdateAcceleration(const float acceleration[3]) {
std::lock_guard lg(m_states_queue_mutex);
std::memcpy(accel_buf, acceleration, sizeof(acceleration));
}

View File

@ -96,12 +96,12 @@ public:
void ReadState(State* state, bool* isConnected, int* connectedCount);
int ReadStates(State* states, int states_num, bool* isConnected, int* connectedCount);
void Button(int id, Libraries::Pad::OrbisPadButtonDataOffset button, bool isPressed);
void Axis(int id, Input::Axis axis, int value);
void Button(Libraries::Pad::OrbisPadButtonDataOffset button, bool isPressed);
void Axis(Input::Axis axis, int value);
void Gyro(int id);
void Acceleration(int id);
void UpdateGyro(int id, const float gyro[3]);
void UpdateAcceleration(int id, const float acceleration[3]);
void UpdateGyro(const float gyro[3]);
void UpdateAcceleration(const float acceleration[3]);
void SetLightBarRGB(u8 r, u8 g, u8 b);
bool SetVibration(u8 smallMotor, u8 largeMotor);
void SetTouchpadState(int touchIndex, bool touchDown, float x, float y);

View File

@ -571,15 +571,15 @@ void ControllerOutput::FinalizeUpdate(u8 gamepad_index) {
switch (button) {
case SDL_GAMEPAD_BUTTON_TOUCHPAD_LEFT:
controller->SetTouchpadState(0, new_button_state, 0.25f, 0.5f);
controller->Button(0, SDLGamepadToOrbisButton(button), new_button_state);
controller->Button(SDLGamepadToOrbisButton(button), new_button_state);
break;
case SDL_GAMEPAD_BUTTON_TOUCHPAD_CENTER:
controller->SetTouchpadState(0, new_button_state, 0.50f, 0.5f);
controller->Button(0, SDLGamepadToOrbisButton(button), new_button_state);
controller->Button(SDLGamepadToOrbisButton(button), new_button_state);
break;
case SDL_GAMEPAD_BUTTON_TOUCHPAD_RIGHT:
controller->SetTouchpadState(0, new_button_state, 0.75f, 0.5f);
controller->Button(0, SDLGamepadToOrbisButton(button), new_button_state);
controller->Button(SDLGamepadToOrbisButton(button), new_button_state);
break;
case LEFTJOYSTICK_HALFMODE:
leftjoystick_halfmode = new_button_state;
@ -636,7 +636,7 @@ void ControllerOutput::FinalizeUpdate(u8 gamepad_index) {
SetMouseGyroRollMode(new_button_state);
break;
default: // is a normal key (hopefully)
controller->Button(0, SDLGamepadToOrbisButton(button), new_button_state);
controller->Button(SDLGamepadToOrbisButton(button), new_button_state);
break;
}
} else if (axis != SDL_GAMEPAD_AXIS_INVALID && positive_axis) {
@ -666,18 +666,18 @@ void ControllerOutput::FinalizeUpdate(u8 gamepad_index) {
break;
case Axis::TriggerLeft:
ApplyDeadzone(new_param, lefttrigger_deadzone);
controllers[gamepad_index]->Axis(0, c_axis, GetAxis(0x0, 0x7f, *new_param));
controllers[gamepad_index]->Button(0, OrbisPadButtonDataOffset::L2, *new_param > 0x20);
controllers[gamepad_index]->Axis(c_axis, GetAxis(0x0, 0x7f, *new_param));
controllers[gamepad_index]->Button(OrbisPadButtonDataOffset::L2, *new_param > 0x20);
return;
case Axis::TriggerRight:
ApplyDeadzone(new_param, righttrigger_deadzone);
controllers[gamepad_index]->Axis(0, c_axis, GetAxis(0x0, 0x7f, *new_param));
controllers[gamepad_index]->Button(0, OrbisPadButtonDataOffset::R2, *new_param > 0x20);
controllers[gamepad_index]->Axis(c_axis, GetAxis(0x0, 0x7f, *new_param));
controllers[gamepad_index]->Button(OrbisPadButtonDataOffset::R2, *new_param > 0x20);
return;
default:
break;
}
controllers[gamepad_index]->Axis(0, c_axis, GetAxis(-0x80, 0x7f, *new_param * multiplier));
controllers[gamepad_index]->Axis(c_axis, GetAxis(-0x80, 0x7f, *new_param * multiplier));
}
}

View File

@ -77,11 +77,11 @@ void EmulateJoystick(GameController* controller, u32 interval) {
float a_x = cos(angle) * output_speed, a_y = sin(angle) * output_speed;
if (d_x != 0 || d_y != 0) {
controller->Axis(0, axis_x, GetAxis(-0x80, 0x7f, a_x));
controller->Axis(0, axis_y, GetAxis(-0x80, 0x7f, a_y));
controller->Axis(axis_x, GetAxis(-0x80, 0x7f, a_x));
controller->Axis(axis_y, GetAxis(-0x80, 0x7f, a_y));
} else {
controller->Axis(0, axis_x, GetAxis(-0x80, 0x7f, 0));
controller->Axis(0, axis_y, GetAxis(-0x80, 0x7f, 0));
controller->Axis(axis_x, GetAxis(-0x80, 0x7f, 0));
controller->Axis(axis_y, GetAxis(-0x80, 0x7f, 0));
}
}
@ -89,13 +89,13 @@ constexpr float constant_down_accel[3] = {0.0f, -9.81, 0.0f};
void EmulateGyro(GameController* controller, u32 interval) {
float d_x = 0, d_y = 0;
SDL_GetRelativeMouseState(&d_x, &d_y);
controller->UpdateAcceleration(1, constant_down_accel);
controller->UpdateAcceleration(constant_down_accel);
float gyro_from_mouse[3] = {-d_y / 100, -d_x / 100, 0.0f};
if (mouse_gyro_roll_mode) {
gyro_from_mouse[1] = 0.0f;
gyro_from_mouse[2] = -d_x / 100;
}
controller->UpdateGyro(1, gyro_from_mouse);
controller->UpdateGyro(gyro_from_mouse);
}
void EmulateTouchpad(GameController* controller, u32 interval) {
@ -104,7 +104,7 @@ void EmulateTouchpad(GameController* controller, u32 interval) {
controller->SetTouchpadState(0, (mouse_buttons & SDL_BUTTON_LMASK) != 0,
std::clamp(x / g_window->GetWidth(), 0.0f, 1.0f),
std::clamp(y / g_window->GetHeight(), 0.0f, 1.0f));
controller->Button(0, Libraries::Pad::OrbisPadButtonDataOffset::TouchPad,
controller->Button(Libraries::Pad::OrbisPadButtonDataOffset::TouchPad,
(mouse_buttons & SDL_BUTTON_RMASK) != 0);
}

View File

@ -351,7 +351,7 @@ void WindowSDL::OnGamepadEvent(const SDL_Event* event) {
// You can still bind other things to it though
if (event->gbutton.button == SDL_GAMEPAD_BUTTON_TOUCHPAD) {
controllers[Input::GameControllers::GetGamepadIndexFromJoystickId(event->gbutton.which)]
->Button(0, OrbisPadButtonDataOffset::TouchPad, input_down);
->Button(OrbisPadButtonDataOffset::TouchPad, input_down);
return;
}
@ -360,11 +360,11 @@ void WindowSDL::OnGamepadEvent(const SDL_Event* event) {
switch ((SDL_SensorType)event->gsensor.sensor) {
case SDL_SENSOR_GYRO:
controllers[Input::GameControllers::GetGamepadIndexFromJoystickId(event->gsensor.which)]
->UpdateGyro(0, event->gsensor.data);
->UpdateGyro(event->gsensor.data);
break;
case SDL_SENSOR_ACCEL:
controllers[Input::GameControllers::GetGamepadIndexFromJoystickId(event->gsensor.which)]
->UpdateAcceleration(0, event->gsensor.data);
->UpdateAcceleration(event->gsensor.data);
break;
default:
break;