General code cleanup

This commit is contained in:
kalaposfos13 2024-10-31 21:40:15 +01:00
parent cd4d3c59cf
commit 9958033d05
2 changed files with 2 additions and 28 deletions

View File

@ -32,7 +32,6 @@
Uint32 getMouseWheelEvent(const SDL_Event* event) {
if (event->type != SDL_EVENT_MOUSE_WHEEL)
return 0;
// std::cout << "We got a wheel event! ";
if (event->wheel.y > 0) {
return SDL_MOUSE_WHEEL_UP;
} else if (event->wheel.y < 0) {
@ -145,7 +144,6 @@ std::vector<DelayedAction> delayedActions;
KeyBinding::KeyBinding(const SDL_Event* event) {
modifier = getCustomModState();
key = 0;
// std::cout << "Someone called the new binding ctor!\n";
if (event->type == SDL_EVENT_KEY_DOWN || event->type == SDL_EVENT_KEY_UP) {
key = event->key.key;
} else if (event->type == SDL_EVENT_MOUSE_BUTTON_DOWN ||
@ -367,26 +365,6 @@ typename std::map<KeyBinding, T>::const_iterator FindKeyAllowingOnlyNoModifiers(
return map.end(); // Return end if no match is found
}
Uint32 WindowSDL::keyRepeatCallback(void* param, Uint32 id, Uint32 interval) {
auto* data = (std::pair<WindowSDL*, SDL_Event*>*)param;
KeyBinding binding(data->second);
if (data->second->type == SDL_EVENT_MOUSE_WHEEL) {
// send an off signal a frame later
auto button_it = button_map.find(binding);
auto axis_it = axis_map.find(binding);
if (button_it != button_map.end()) {
data->first->updateButton(binding, button_it->second, false);
} else if (axis_it != axis_map.end()) {
data->first->controller->Axis(0, axis_it->second.axis, Input::GetAxis(-0x80, 0x80, 0));
}
return 0;
}
data->first->updateModKeyedInputsManually(binding);
delete data->second;
delete data;
return 0; // Return 0 to stop the timer after firing once
}
void WindowSDL::handleDelayedActions() {
// Uncomment at your own terminal's risk
// std::cout << "I fear the amount of spam this line will generate\n";
@ -420,7 +398,7 @@ void WindowSDL::handleDelayedActions() {
Uint32 WindowSDL::mousePolling(void* param, Uint32 id, Uint32 interval) {
auto* data = (WindowSDL*)param;
data->updateMouse();
return 33; // Return 0 to stop the timer after firing once
return 33;
}
void WindowSDL::updateMouse() {
@ -447,7 +425,6 @@ void WindowSDL::updateMouse() {
float output_speed =
SDL_clamp((sqrt(d_x * d_x + d_y * d_y) + mouse_speed_offset * 128) * mouse_speed,
mouse_deadzone_offset * 128, 128.0);
// std::cout << "speed: " << mouse_speed << "\n";
float angle = atan2(d_y, d_x);
float a_x = cos(angle) * output_speed, a_y = sin(angle) * output_speed;
@ -599,8 +576,6 @@ void WindowSDL::updateButton(KeyBinding& binding, u32 button, bool is_pressed) {
case OrbisPadButtonDataOffset::ORBIS_PAD_BUTTON_R2:
axis = (button == OrbisPadButtonDataOffset::ORBIS_PAD_BUTTON_R2) ? Input::Axis::TriggerRight
: Input::Axis::TriggerLeft;
// int axis_value = is_pressed ? 255 : 0;
// int ax = Input::GetAxis(0, 0x80, is_pressed ? 255 : 0);
controller->Axis(0, axis, Input::GetAxis(0, 0x80, is_pressed ? 255 : 0));
break;
case OrbisPadButtonDataOffset::ORBIS_PAD_BUTTON_TOUCH_PAD:

View File

@ -274,7 +274,6 @@ private:
void updateModKeyedInputsManually(KBMConfig::KeyBinding& binding);
void updateButton(KBMConfig::KeyBinding& binding, u32 button, bool isPressed);
static Uint32 keyRepeatCallback(void* param, Uint32 id, Uint32 interval);
static Uint32 mousePolling(void* param, Uint32 id, Uint32 interval);
void handleDelayedActions();