mirror of
https://github.com/shadps4-emu/shadPS4.git
synced 2025-08-04 08:22:32 +00:00
General code cleanup
This commit is contained in:
parent
cd4d3c59cf
commit
9958033d05
@ -32,7 +32,6 @@
|
|||||||
Uint32 getMouseWheelEvent(const SDL_Event* event) {
|
Uint32 getMouseWheelEvent(const SDL_Event* event) {
|
||||||
if (event->type != SDL_EVENT_MOUSE_WHEEL)
|
if (event->type != SDL_EVENT_MOUSE_WHEEL)
|
||||||
return 0;
|
return 0;
|
||||||
// std::cout << "We got a wheel event! ";
|
|
||||||
if (event->wheel.y > 0) {
|
if (event->wheel.y > 0) {
|
||||||
return SDL_MOUSE_WHEEL_UP;
|
return SDL_MOUSE_WHEEL_UP;
|
||||||
} else if (event->wheel.y < 0) {
|
} else if (event->wheel.y < 0) {
|
||||||
@ -145,7 +144,6 @@ std::vector<DelayedAction> delayedActions;
|
|||||||
KeyBinding::KeyBinding(const SDL_Event* event) {
|
KeyBinding::KeyBinding(const SDL_Event* event) {
|
||||||
modifier = getCustomModState();
|
modifier = getCustomModState();
|
||||||
key = 0;
|
key = 0;
|
||||||
// std::cout << "Someone called the new binding ctor!\n";
|
|
||||||
if (event->type == SDL_EVENT_KEY_DOWN || event->type == SDL_EVENT_KEY_UP) {
|
if (event->type == SDL_EVENT_KEY_DOWN || event->type == SDL_EVENT_KEY_UP) {
|
||||||
key = event->key.key;
|
key = event->key.key;
|
||||||
} else if (event->type == SDL_EVENT_MOUSE_BUTTON_DOWN ||
|
} else if (event->type == SDL_EVENT_MOUSE_BUTTON_DOWN ||
|
||||||
@ -367,29 +365,9 @@ typename std::map<KeyBinding, T>::const_iterator FindKeyAllowingOnlyNoModifiers(
|
|||||||
return map.end(); // Return end if no match is found
|
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() {
|
void WindowSDL::handleDelayedActions() {
|
||||||
// Uncomment at your own terminal's risk
|
// Uncomment at your own terminal's risk
|
||||||
// std::cout << "I fear the amount of spam this line will generate\n";
|
// std::cout << "I fear the amount of spam this line will generate\n";
|
||||||
std::this_thread::sleep_for(std::chrono::milliseconds(1));
|
std::this_thread::sleep_for(std::chrono::milliseconds(1));
|
||||||
Uint32 currentTime = SDL_GetTicks();
|
Uint32 currentTime = SDL_GetTicks();
|
||||||
for (auto it = delayedActions.begin(); it != delayedActions.end();) {
|
for (auto it = delayedActions.begin(); it != delayedActions.end();) {
|
||||||
@ -420,7 +398,7 @@ void WindowSDL::handleDelayedActions() {
|
|||||||
Uint32 WindowSDL::mousePolling(void* param, Uint32 id, Uint32 interval) {
|
Uint32 WindowSDL::mousePolling(void* param, Uint32 id, Uint32 interval) {
|
||||||
auto* data = (WindowSDL*)param;
|
auto* data = (WindowSDL*)param;
|
||||||
data->updateMouse();
|
data->updateMouse();
|
||||||
return 33; // Return 0 to stop the timer after firing once
|
return 33;
|
||||||
}
|
}
|
||||||
|
|
||||||
void WindowSDL::updateMouse() {
|
void WindowSDL::updateMouse() {
|
||||||
@ -447,7 +425,6 @@ void WindowSDL::updateMouse() {
|
|||||||
float output_speed =
|
float output_speed =
|
||||||
SDL_clamp((sqrt(d_x * d_x + d_y * d_y) + mouse_speed_offset * 128) * mouse_speed,
|
SDL_clamp((sqrt(d_x * d_x + d_y * d_y) + mouse_speed_offset * 128) * mouse_speed,
|
||||||
mouse_deadzone_offset * 128, 128.0);
|
mouse_deadzone_offset * 128, 128.0);
|
||||||
// std::cout << "speed: " << mouse_speed << "\n";
|
|
||||||
|
|
||||||
float angle = atan2(d_y, d_x);
|
float angle = atan2(d_y, d_x);
|
||||||
float a_x = cos(angle) * output_speed, a_y = sin(angle) * output_speed;
|
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:
|
case OrbisPadButtonDataOffset::ORBIS_PAD_BUTTON_R2:
|
||||||
axis = (button == OrbisPadButtonDataOffset::ORBIS_PAD_BUTTON_R2) ? Input::Axis::TriggerRight
|
axis = (button == OrbisPadButtonDataOffset::ORBIS_PAD_BUTTON_R2) ? Input::Axis::TriggerRight
|
||||||
: Input::Axis::TriggerLeft;
|
: 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));
|
controller->Axis(0, axis, Input::GetAxis(0, 0x80, is_pressed ? 255 : 0));
|
||||||
break;
|
break;
|
||||||
case OrbisPadButtonDataOffset::ORBIS_PAD_BUTTON_TOUCH_PAD:
|
case OrbisPadButtonDataOffset::ORBIS_PAD_BUTTON_TOUCH_PAD:
|
||||||
|
@ -274,7 +274,6 @@ private:
|
|||||||
|
|
||||||
void updateModKeyedInputsManually(KBMConfig::KeyBinding& binding);
|
void updateModKeyedInputsManually(KBMConfig::KeyBinding& binding);
|
||||||
void updateButton(KBMConfig::KeyBinding& binding, u32 button, bool isPressed);
|
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);
|
static Uint32 mousePolling(void* param, Uint32 id, Uint32 interval);
|
||||||
void handleDelayedActions();
|
void handleDelayedActions();
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user