summaryrefslogtreecommitdiff
path: root/src/input_common/drivers
diff options
context:
space:
mode:
authorGravatar arades792023-02-11 13:28:03 -0500
committerGravatar arades792023-02-14 12:33:11 -0500
commit45e13b03f372230dbf780f3fa87dd88f388af605 (patch)
tree555593e7e5016b6ba2a777d7417ada244abce458 /src/input_common/drivers
parentMerge pull request #9795 from Kelebek1/biquad_fix (diff)
downloadyuzu-45e13b03f372230dbf780f3fa87dd88f388af605.tar.gz
yuzu-45e13b03f372230dbf780f3fa87dd88f388af605.tar.xz
yuzu-45e13b03f372230dbf780f3fa87dd88f388af605.zip
add static lifetime to constexpr values to force compile time evaluation where possible
Signed-off-by: arades79 <scravers@protonmail.com>
Diffstat (limited to 'src/input_common/drivers')
-rw-r--r--src/input_common/drivers/gc_adapter.cpp8
-rw-r--r--src/input_common/drivers/joycon.cpp4
-rw-r--r--src/input_common/drivers/mouse.cpp2
-rw-r--r--src/input_common/drivers/sdl_driver.cpp8
-rw-r--r--src/input_common/drivers/udp_client.cpp2
5 files changed, 12 insertions, 12 deletions
diff --git a/src/input_common/drivers/gc_adapter.cpp b/src/input_common/drivers/gc_adapter.cpp
index d09ff178b..a4faab15e 100644
--- a/src/input_common/drivers/gc_adapter.cpp
+++ b/src/input_common/drivers/gc_adapter.cpp
@@ -223,8 +223,8 @@ void GCAdapter::AdapterScanThread(std::stop_token stop_token) {
223} 223}
224 224
225bool GCAdapter::Setup() { 225bool GCAdapter::Setup() {
226 constexpr u16 nintendo_vid = 0x057e; 226 constexpr static u16 nintendo_vid = 0x057e;
227 constexpr u16 gc_adapter_pid = 0x0337; 227 constexpr static u16 gc_adapter_pid = 0x0337;
228 usb_adapter_handle = 228 usb_adapter_handle =
229 std::make_unique<LibUSBDeviceHandle>(libusb_ctx->get(), nintendo_vid, gc_adapter_pid); 229 std::make_unique<LibUSBDeviceHandle>(libusb_ctx->get(), nintendo_vid, gc_adapter_pid);
230 if (!usb_adapter_handle->get()) { 230 if (!usb_adapter_handle->get()) {
@@ -346,7 +346,7 @@ void GCAdapter::UpdateVibrations() {
346 // Use 8 states to keep the switching between on/off fast enough for 346 // Use 8 states to keep the switching between on/off fast enough for
347 // a human to feel different vibration strenght 347 // a human to feel different vibration strenght
348 // More states == more rumble strengths == slower update time 348 // More states == more rumble strengths == slower update time
349 constexpr u8 vibration_states = 8; 349 constexpr static u8 vibration_states = 8;
350 350
351 vibration_counter = (vibration_counter + 1) % vibration_states; 351 vibration_counter = (vibration_counter + 1) % vibration_states;
352 352
@@ -363,7 +363,7 @@ void GCAdapter::SendVibrations() {
363 return; 363 return;
364 } 364 }
365 s32 size{}; 365 s32 size{};
366 constexpr u8 rumble_command = 0x11; 366 constexpr static u8 rumble_command = 0x11;
367 const u8 p1 = pads[0].enable_vibration; 367 const u8 p1 = pads[0].enable_vibration;
368 const u8 p2 = pads[1].enable_vibration; 368 const u8 p2 = pads[1].enable_vibration;
369 const u8 p3 = pads[2].enable_vibration; 369 const u8 p3 = pads[2].enable_vibration;
diff --git a/src/input_common/drivers/joycon.cpp b/src/input_common/drivers/joycon.cpp
index afc33db57..a93bb5c25 100644
--- a/src/input_common/drivers/joycon.cpp
+++ b/src/input_common/drivers/joycon.cpp
@@ -77,7 +77,7 @@ void Joycons::Setup() {
77} 77}
78 78
79void Joycons::ScanThread(std::stop_token stop_token) { 79void Joycons::ScanThread(std::stop_token stop_token) {
80 constexpr u16 nintendo_vendor_id = 0x057e; 80 constexpr static u16 nintendo_vendor_id = 0x057e;
81 Common::SetCurrentThreadName("JoyconScanThread"); 81 Common::SetCurrentThreadName("JoyconScanThread");
82 82
83 do { 83 do {
@@ -390,7 +390,7 @@ void Joycons::OnMotionUpdate(std::size_t port, Joycon::ControllerType type, int
390void Joycons::OnRingConUpdate(f32 ring_data) { 390void Joycons::OnRingConUpdate(f32 ring_data) {
391 // To simplify ring detection it will always be mapped to an empty identifier for all 391 // To simplify ring detection it will always be mapped to an empty identifier for all
392 // controllers 392 // controllers
393 constexpr PadIdentifier identifier = { 393 constexpr static PadIdentifier identifier = {
394 .guid = Common::UUID{}, 394 .guid = Common::UUID{},
395 .port = 0, 395 .port = 0,
396 .pad = 0, 396 .pad = 0,
diff --git a/src/input_common/drivers/mouse.cpp b/src/input_common/drivers/mouse.cpp
index faf9cbdc3..dfa93d58a 100644
--- a/src/input_common/drivers/mouse.cpp
+++ b/src/input_common/drivers/mouse.cpp
@@ -37,7 +37,7 @@ Mouse::Mouse(std::string input_engine_) : InputEngine(std::move(input_engine_))
37 37
38void Mouse::UpdateThread(std::stop_token stop_token) { 38void Mouse::UpdateThread(std::stop_token stop_token) {
39 Common::SetCurrentThreadName("Mouse"); 39 Common::SetCurrentThreadName("Mouse");
40 constexpr int update_time = 10; 40 constexpr static int update_time = 10;
41 while (!stop_token.stop_requested()) { 41 while (!stop_token.stop_requested()) {
42 if (Settings::values.mouse_panning && !Settings::values.mouse_enabled) { 42 if (Settings::values.mouse_panning && !Settings::values.mouse_enabled) {
43 // Slow movement by 4% 43 // Slow movement by 4%
diff --git a/src/input_common/drivers/sdl_driver.cpp b/src/input_common/drivers/sdl_driver.cpp
index 88cacd615..53ebae2d6 100644
--- a/src/input_common/drivers/sdl_driver.cpp
+++ b/src/input_common/drivers/sdl_driver.cpp
@@ -63,7 +63,7 @@ public:
63 } 63 }
64 64
65 bool UpdateMotion(SDL_ControllerSensorEvent event) { 65 bool UpdateMotion(SDL_ControllerSensorEvent event) {
66 constexpr float gravity_constant = 9.80665f; 66 constexpr static float gravity_constant = 9.80665f;
67 std::scoped_lock lock{mutex}; 67 std::scoped_lock lock{mutex};
68 const u64 time_difference = event.timestamp - last_motion_update; 68 const u64 time_difference = event.timestamp - last_motion_update;
69 last_motion_update = event.timestamp; 69 last_motion_update = event.timestamp;
@@ -109,7 +109,7 @@ public:
109 } 109 }
110 110
111 bool RumblePlay(const Common::Input::VibrationStatus vibration) { 111 bool RumblePlay(const Common::Input::VibrationStatus vibration) {
112 constexpr u32 rumble_max_duration_ms = 1000; 112 constexpr static u32 rumble_max_duration_ms = 1000;
113 if (sdl_controller) { 113 if (sdl_controller) {
114 return SDL_GameControllerRumble( 114 return SDL_GameControllerRumble(
115 sdl_controller.get(), static_cast<u16>(vibration.low_amplitude), 115 sdl_controller.get(), static_cast<u16>(vibration.low_amplitude),
@@ -616,7 +616,7 @@ bool SDLDriver::IsVibrationEnabled(const PadIdentifier& identifier) {
616 const auto joystick = 616 const auto joystick =
617 GetSDLJoystickByGUID(identifier.guid.RawString(), static_cast<int>(identifier.port)); 617 GetSDLJoystickByGUID(identifier.guid.RawString(), static_cast<int>(identifier.port));
618 618
619 constexpr Common::Input::VibrationStatus test_vibration{ 619 constexpr static Common::Input::VibrationStatus test_vibration{
620 .low_amplitude = 1, 620 .low_amplitude = 1,
621 .low_frequency = 160.0f, 621 .low_frequency = 160.0f,
622 .high_amplitude = 1, 622 .high_amplitude = 1,
@@ -624,7 +624,7 @@ bool SDLDriver::IsVibrationEnabled(const PadIdentifier& identifier) {
624 .type = Common::Input::VibrationAmplificationType::Exponential, 624 .type = Common::Input::VibrationAmplificationType::Exponential,
625 }; 625 };
626 626
627 constexpr Common::Input::VibrationStatus zero_vibration{ 627 constexpr static Common::Input::VibrationStatus zero_vibration{
628 .low_amplitude = 0, 628 .low_amplitude = 0,
629 .low_frequency = 160.0f, 629 .low_frequency = 160.0f,
630 .high_amplitude = 0, 630 .high_amplitude = 0,
diff --git a/src/input_common/drivers/udp_client.cpp b/src/input_common/drivers/udp_client.cpp
index 808b21069..ae49f0478 100644
--- a/src/input_common/drivers/udp_client.cpp
+++ b/src/input_common/drivers/udp_client.cpp
@@ -599,7 +599,7 @@ CalibrationConfigurationJob::CalibrationConfigurationJob(
599 Status current_status{Status::Initialized}; 599 Status current_status{Status::Initialized};
600 SocketCallback callback{[](Response::Version) {}, [](Response::PortInfo) {}, 600 SocketCallback callback{[](Response::Version) {}, [](Response::PortInfo) {},
601 [&](Response::PadData data) { 601 [&](Response::PadData data) {
602 constexpr u16 CALIBRATION_THRESHOLD = 100; 602 constexpr static u16 CALIBRATION_THRESHOLD = 100;
603 603
604 if (current_status == Status::Initialized) { 604 if (current_status == Status::Initialized) {
605 // Receiving data means the communication is ready now 605 // Receiving data means the communication is ready now