summaryrefslogtreecommitdiffstats
path: root/src/common
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--src/common/CMakeLists.txt4
-rw-r--r--src/common/demangle.cpp35
-rw-r--r--src/common/demangle.h12
-rw-r--r--src/common/input.h68
-rw-r--r--src/common/polyfill_thread.h36
-rw-r--r--src/common/settings.h1
6 files changed, 128 insertions, 28 deletions
diff --git a/src/common/CMakeLists.txt b/src/common/CMakeLists.txt
index 45332cf95..9884a4a0b 100644
--- a/src/common/CMakeLists.txt
+++ b/src/common/CMakeLists.txt
@@ -38,6 +38,8 @@ add_library(common STATIC
common_precompiled_headers.h
common_types.h
concepts.h
+ demangle.cpp
+ demangle.h
div_ceil.h
dynamic_library.cpp
dynamic_library.h
@@ -175,7 +177,7 @@ endif()
create_target_directory_groups(common)
target_link_libraries(common PUBLIC ${Boost_LIBRARIES} fmt::fmt microprofile Threads::Threads)
-target_link_libraries(common PRIVATE lz4::lz4 zstd::zstd)
+target_link_libraries(common PRIVATE lz4::lz4 zstd::zstd LLVM::Demangle)
if (YUZU_USE_PRECOMPILED_HEADERS)
target_precompile_headers(common PRIVATE precompiled_headers.h)
diff --git a/src/common/demangle.cpp b/src/common/demangle.cpp
new file mode 100644
index 000000000..3310faf86
--- /dev/null
+++ b/src/common/demangle.cpp
@@ -0,0 +1,35 @@
+// SPDX-FileCopyrightText: Copyright 2020 yuzu Emulator Project
+// SPDX-License-Identifier: GPL-2.0-or-later
+
+#include <llvm/Demangle/Demangle.h>
+
+#include "common/demangle.h"
+#include "common/scope_exit.h"
+
+namespace Common {
+
+std::string DemangleSymbol(const std::string& mangled) {
+ auto is_itanium = [](const std::string& name) -> bool {
+ // A valid Itanium encoding requires 1-4 leading underscores, followed by 'Z'.
+ auto pos = name.find_first_not_of('_');
+ return pos > 0 && pos <= 4 && pos < name.size() && name[pos] == 'Z';
+ };
+
+ if (mangled.empty()) {
+ return mangled;
+ }
+
+ char* demangled = nullptr;
+ SCOPE_EXIT({ std::free(demangled); });
+
+ if (is_itanium(mangled)) {
+ demangled = llvm::itaniumDemangle(mangled.c_str(), nullptr, nullptr, nullptr);
+ }
+
+ if (!demangled) {
+ return mangled;
+ }
+ return demangled;
+}
+
+} // namespace Common
diff --git a/src/common/demangle.h b/src/common/demangle.h
new file mode 100644
index 000000000..f072d22f3
--- /dev/null
+++ b/src/common/demangle.h
@@ -0,0 +1,12 @@
+// SPDX-FileCopyrightText: Copyright 2020 yuzu Emulator Project
+// SPDX-License-Identifier: GPL-2.0-or-later
+
+#pragma once
+
+#include <string>
+
+namespace Common {
+
+std::string DemangleSymbol(const std::string& mangled);
+
+} // namespace Common
diff --git a/src/common/input.h b/src/common/input.h
index d27b1d772..d61cd7ca8 100644
--- a/src/common/input.h
+++ b/src/common/input.h
@@ -51,6 +51,8 @@ enum class PollingMode {
NFC,
// Enable infrared camera polling
IR,
+ // Enable ring controller polling
+ Ring,
};
enum class CameraFormat {
@@ -62,21 +64,22 @@ enum class CameraFormat {
None,
};
-// Vibration reply from the controller
-enum class VibrationError {
- None,
+// Different results that can happen from a device request
+enum class DriverResult {
+ Success,
+ WrongReply,
+ Timeout,
+ UnsupportedControllerType,
+ HandleInUse,
+ ErrorReadingData,
+ ErrorWritingData,
+ NoDeviceDetected,
+ InvalidHandle,
NotSupported,
Disabled,
Unknown,
};
-// Polling mode reply from the controller
-enum class PollingError {
- None,
- NotSupported,
- Unknown,
-};
-
// Nfc reply from the controller
enum class NfcState {
Success,
@@ -90,13 +93,6 @@ enum class NfcState {
Unknown,
};
-// Ir camera reply from the controller
-enum class CameraError {
- None,
- NotSupported,
- Unknown,
-};
-
// Hint for amplification curve to be used
enum class VibrationAmplificationType {
Linear,
@@ -190,6 +186,8 @@ struct TouchStatus {
struct BodyColorStatus {
u32 body{};
u32 buttons{};
+ u32 left_grip{};
+ u32 right_grip{};
};
// HD rumble data
@@ -228,17 +226,31 @@ enum class ButtonNames {
Engine,
// This will display the button by value instead of the button name
Value,
+
+ // Joycon button names
ButtonLeft,
ButtonRight,
ButtonDown,
ButtonUp,
- TriggerZ,
- TriggerR,
- TriggerL,
ButtonA,
ButtonB,
ButtonX,
ButtonY,
+ ButtonPlus,
+ ButtonMinus,
+ ButtonHome,
+ ButtonCapture,
+ ButtonStickL,
+ ButtonStickR,
+ TriggerL,
+ TriggerZL,
+ TriggerSL,
+ TriggerR,
+ TriggerZR,
+ TriggerSR,
+
+ // GC button names
+ TriggerZ,
ButtonStart,
// DS4 button names
@@ -316,22 +328,24 @@ class OutputDevice {
public:
virtual ~OutputDevice() = default;
- virtual void SetLED([[maybe_unused]] const LedStatus& led_status) {}
+ virtual DriverResult SetLED([[maybe_unused]] const LedStatus& led_status) {
+ return DriverResult::NotSupported;
+ }
- virtual VibrationError SetVibration([[maybe_unused]] const VibrationStatus& vibration_status) {
- return VibrationError::NotSupported;
+ virtual DriverResult SetVibration([[maybe_unused]] const VibrationStatus& vibration_status) {
+ return DriverResult::NotSupported;
}
virtual bool IsVibrationEnabled() {
return false;
}
- virtual PollingError SetPollingMode([[maybe_unused]] PollingMode polling_mode) {
- return PollingError::NotSupported;
+ virtual DriverResult SetPollingMode([[maybe_unused]] PollingMode polling_mode) {
+ return DriverResult::NotSupported;
}
- virtual CameraError SetCameraFormat([[maybe_unused]] CameraFormat camera_format) {
- return CameraError::NotSupported;
+ virtual DriverResult SetCameraFormat([[maybe_unused]] CameraFormat camera_format) {
+ return DriverResult::NotSupported;
}
virtual NfcState SupportsNfc() const {
diff --git a/src/common/polyfill_thread.h b/src/common/polyfill_thread.h
index 5a8d1ce08..b2c929d2f 100644
--- a/src/common/polyfill_thread.h
+++ b/src/common/polyfill_thread.h
@@ -11,6 +11,8 @@
#ifdef __cpp_lib_jthread
+#include <chrono>
+#include <condition_variable>
#include <stop_token>
#include <thread>
@@ -21,11 +23,23 @@ void CondvarWait(Condvar& cv, Lock& lock, std::stop_token token, Pred&& pred) {
cv.wait(lock, token, std::move(pred));
}
+template <typename Rep, typename Period>
+bool StoppableTimedWait(std::stop_token token, const std::chrono::duration<Rep, Period>& rel_time) {
+ std::condition_variable_any cv;
+ std::mutex m;
+
+ // Perform the timed wait.
+ std::unique_lock lk{m};
+ return !cv.wait_for(lk, token, rel_time, [&] { return token.stop_requested(); });
+}
+
} // namespace Common
#else
#include <atomic>
+#include <chrono>
+#include <condition_variable>
#include <functional>
#include <list>
#include <memory>
@@ -318,6 +332,28 @@ void CondvarWait(Condvar& cv, Lock& lock, std::stop_token token, Pred pred) {
cv.wait(lock, [&] { return pred() || token.stop_requested(); });
}
+template <typename Rep, typename Period>
+bool StoppableTimedWait(std::stop_token token, const std::chrono::duration<Rep, Period>& rel_time) {
+ if (token.stop_requested()) {
+ return false;
+ }
+
+ bool stop_requested = false;
+ std::condition_variable cv;
+ std::mutex m;
+
+ std::stop_callback cb(token, [&] {
+ // Wake up the waiting thread.
+ std::unique_lock lk{m};
+ stop_requested = true;
+ cv.notify_one();
+ });
+
+ // Perform the timed wait.
+ std::unique_lock lk{m};
+ return !cv.wait_for(lk, rel_time, [&] { return stop_requested; });
+}
+
} // namespace Common
#endif
diff --git a/src/common/settings.h b/src/common/settings.h
index 80b2eeabc..4b4da4da2 100644
--- a/src/common/settings.h
+++ b/src/common/settings.h
@@ -483,6 +483,7 @@ struct Values {
Setting<bool> enable_raw_input{false, "enable_raw_input"};
Setting<bool> controller_navigation{true, "controller_navigation"};
+ Setting<bool> enable_joycon_driver{true, "enable_joycon_driver"};
SwitchableSetting<bool> vibration_enabled{true, "vibration_enabled"};
SwitchableSetting<bool> enable_accurate_vibrations{false, "enable_accurate_vibrations"};