summaryrefslogtreecommitdiff
path: root/src/common
diff options
context:
space:
mode:
Diffstat (limited to 'src/common')
-rw-r--r--src/common/android/id_cache.cpp163
-rw-r--r--src/common/android/id_cache.h24
-rw-r--r--src/common/demangle.cpp4
-rw-r--r--src/common/host_memory.cpp4
-rw-r--r--src/common/page_table.cpp4
-rw-r--r--src/common/scope_exit.h66
-rw-r--r--src/common/settings.cpp3
-rw-r--r--src/common/settings.h32
-rw-r--r--src/common/settings_common.h1
-rw-r--r--src/common/settings_enums.h2
-rw-r--r--src/common/settings_input.h4
11 files changed, 282 insertions, 25 deletions
diff --git a/src/common/android/id_cache.cpp b/src/common/android/id_cache.cpp
index f39262db9..1145cbdf2 100644
--- a/src/common/android/id_cache.cpp
+++ b/src/common/android/id_cache.cpp
@@ -65,6 +65,30 @@ static jclass s_boolean_class;
static jmethodID s_boolean_constructor;
static jfieldID s_boolean_value_field;
+static jclass s_player_input_class;
+static jmethodID s_player_input_constructor;
+static jfieldID s_player_input_connected_field;
+static jfieldID s_player_input_buttons_field;
+static jfieldID s_player_input_analogs_field;
+static jfieldID s_player_input_motions_field;
+static jfieldID s_player_input_vibration_enabled_field;
+static jfieldID s_player_input_vibration_strength_field;
+static jfieldID s_player_input_body_color_left_field;
+static jfieldID s_player_input_body_color_right_field;
+static jfieldID s_player_input_button_color_left_field;
+static jfieldID s_player_input_button_color_right_field;
+static jfieldID s_player_input_profile_name_field;
+static jfieldID s_player_input_use_system_vibrator_field;
+
+static jclass s_yuzu_input_device_interface;
+static jmethodID s_yuzu_input_device_get_name;
+static jmethodID s_yuzu_input_device_get_guid;
+static jmethodID s_yuzu_input_device_get_port;
+static jmethodID s_yuzu_input_device_get_supports_vibration;
+static jmethodID s_yuzu_input_device_vibrate;
+static jmethodID s_yuzu_input_device_get_axes;
+static jmethodID s_yuzu_input_device_has_keys;
+
static constexpr jint JNI_VERSION = JNI_VERSION_1_6;
namespace Common::Android {
@@ -276,6 +300,94 @@ jfieldID GetBooleanValueField() {
return s_boolean_value_field;
}
+jclass GetPlayerInputClass() {
+ return s_player_input_class;
+}
+
+jmethodID GetPlayerInputConstructor() {
+ return s_player_input_constructor;
+}
+
+jfieldID GetPlayerInputConnectedField() {
+ return s_player_input_connected_field;
+}
+
+jfieldID GetPlayerInputButtonsField() {
+ return s_player_input_buttons_field;
+}
+
+jfieldID GetPlayerInputAnalogsField() {
+ return s_player_input_analogs_field;
+}
+
+jfieldID GetPlayerInputMotionsField() {
+ return s_player_input_motions_field;
+}
+
+jfieldID GetPlayerInputVibrationEnabledField() {
+ return s_player_input_vibration_enabled_field;
+}
+
+jfieldID GetPlayerInputVibrationStrengthField() {
+ return s_player_input_vibration_strength_field;
+}
+
+jfieldID GetPlayerInputBodyColorLeftField() {
+ return s_player_input_body_color_left_field;
+}
+
+jfieldID GetPlayerInputBodyColorRightField() {
+ return s_player_input_body_color_right_field;
+}
+
+jfieldID GetPlayerInputButtonColorLeftField() {
+ return s_player_input_button_color_left_field;
+}
+
+jfieldID GetPlayerInputButtonColorRightField() {
+ return s_player_input_button_color_right_field;
+}
+
+jfieldID GetPlayerInputProfileNameField() {
+ return s_player_input_profile_name_field;
+}
+
+jfieldID GetPlayerInputUseSystemVibratorField() {
+ return s_player_input_use_system_vibrator_field;
+}
+
+jclass GetYuzuInputDeviceInterface() {
+ return s_yuzu_input_device_interface;
+}
+
+jmethodID GetYuzuDeviceGetName() {
+ return s_yuzu_input_device_get_name;
+}
+
+jmethodID GetYuzuDeviceGetGUID() {
+ return s_yuzu_input_device_get_guid;
+}
+
+jmethodID GetYuzuDeviceGetPort() {
+ return s_yuzu_input_device_get_port;
+}
+
+jmethodID GetYuzuDeviceGetSupportsVibration() {
+ return s_yuzu_input_device_get_supports_vibration;
+}
+
+jmethodID GetYuzuDeviceVibrate() {
+ return s_yuzu_input_device_vibrate;
+}
+
+jmethodID GetYuzuDeviceGetAxes() {
+ return s_yuzu_input_device_get_axes;
+}
+
+jmethodID GetYuzuDeviceHasKeys() {
+ return s_yuzu_input_device_has_keys;
+}
+
#ifdef __cplusplus
extern "C" {
#endif
@@ -387,6 +499,55 @@ jint JNI_OnLoad(JavaVM* vm, void* reserved) {
s_boolean_value_field = env->GetFieldID(boolean_class, "value", "Z");
env->DeleteLocalRef(boolean_class);
+ const jclass player_input_class =
+ env->FindClass("org/yuzu/yuzu_emu/features/input/model/PlayerInput");
+ s_player_input_class = reinterpret_cast<jclass>(env->NewGlobalRef(player_input_class));
+ s_player_input_constructor = env->GetMethodID(
+ player_input_class, "<init>",
+ "(Z[Ljava/lang/String;[Ljava/lang/String;[Ljava/lang/String;ZIJJJJLjava/lang/String;Z)V");
+ s_player_input_connected_field = env->GetFieldID(player_input_class, "connected", "Z");
+ s_player_input_buttons_field =
+ env->GetFieldID(player_input_class, "buttons", "[Ljava/lang/String;");
+ s_player_input_analogs_field =
+ env->GetFieldID(player_input_class, "analogs", "[Ljava/lang/String;");
+ s_player_input_motions_field =
+ env->GetFieldID(player_input_class, "motions", "[Ljava/lang/String;");
+ s_player_input_vibration_enabled_field =
+ env->GetFieldID(player_input_class, "vibrationEnabled", "Z");
+ s_player_input_vibration_strength_field =
+ env->GetFieldID(player_input_class, "vibrationStrength", "I");
+ s_player_input_body_color_left_field =
+ env->GetFieldID(player_input_class, "bodyColorLeft", "J");
+ s_player_input_body_color_right_field =
+ env->GetFieldID(player_input_class, "bodyColorRight", "J");
+ s_player_input_button_color_left_field =
+ env->GetFieldID(player_input_class, "buttonColorLeft", "J");
+ s_player_input_button_color_right_field =
+ env->GetFieldID(player_input_class, "buttonColorRight", "J");
+ s_player_input_profile_name_field =
+ env->GetFieldID(player_input_class, "profileName", "Ljava/lang/String;");
+ s_player_input_use_system_vibrator_field =
+ env->GetFieldID(player_input_class, "useSystemVibrator", "Z");
+ env->DeleteLocalRef(player_input_class);
+
+ const jclass yuzu_input_device_interface =
+ env->FindClass("org/yuzu/yuzu_emu/features/input/YuzuInputDevice");
+ s_yuzu_input_device_interface =
+ reinterpret_cast<jclass>(env->NewGlobalRef(yuzu_input_device_interface));
+ s_yuzu_input_device_get_name =
+ env->GetMethodID(yuzu_input_device_interface, "getName", "()Ljava/lang/String;");
+ s_yuzu_input_device_get_guid =
+ env->GetMethodID(yuzu_input_device_interface, "getGUID", "()Ljava/lang/String;");
+ s_yuzu_input_device_get_port = env->GetMethodID(yuzu_input_device_interface, "getPort", "()I");
+ s_yuzu_input_device_get_supports_vibration =
+ env->GetMethodID(yuzu_input_device_interface, "getSupportsVibration", "()Z");
+ s_yuzu_input_device_vibrate = env->GetMethodID(yuzu_input_device_interface, "vibrate", "(F)V");
+ s_yuzu_input_device_get_axes =
+ env->GetMethodID(yuzu_input_device_interface, "getAxes", "()[Ljava/lang/Integer;");
+ s_yuzu_input_device_has_keys =
+ env->GetMethodID(yuzu_input_device_interface, "hasKeys", "([I)[Z");
+ env->DeleteLocalRef(yuzu_input_device_interface);
+
// Initialize Android Storage
Common::FS::Android::RegisterCallbacks(env, s_native_library_class);
@@ -416,6 +577,8 @@ void JNI_OnUnload(JavaVM* vm, void* reserved) {
env->DeleteGlobalRef(s_double_class);
env->DeleteGlobalRef(s_integer_class);
env->DeleteGlobalRef(s_boolean_class);
+ env->DeleteGlobalRef(s_player_input_class);
+ env->DeleteGlobalRef(s_yuzu_input_device_interface);
// UnInitialize applets
SoftwareKeyboard::CleanupJNI(env);
diff --git a/src/common/android/id_cache.h b/src/common/android/id_cache.h
index 47802f96c..cd2844dcc 100644
--- a/src/common/android/id_cache.h
+++ b/src/common/android/id_cache.h
@@ -85,4 +85,28 @@ jclass GetBooleanClass();
jmethodID GetBooleanConstructor();
jfieldID GetBooleanValueField();
+jclass GetPlayerInputClass();
+jmethodID GetPlayerInputConstructor();
+jfieldID GetPlayerInputConnectedField();
+jfieldID GetPlayerInputButtonsField();
+jfieldID GetPlayerInputAnalogsField();
+jfieldID GetPlayerInputMotionsField();
+jfieldID GetPlayerInputVibrationEnabledField();
+jfieldID GetPlayerInputVibrationStrengthField();
+jfieldID GetPlayerInputBodyColorLeftField();
+jfieldID GetPlayerInputBodyColorRightField();
+jfieldID GetPlayerInputButtonColorLeftField();
+jfieldID GetPlayerInputButtonColorRightField();
+jfieldID GetPlayerInputProfileNameField();
+jfieldID GetPlayerInputUseSystemVibratorField();
+
+jclass GetYuzuInputDeviceInterface();
+jmethodID GetYuzuDeviceGetName();
+jmethodID GetYuzuDeviceGetGUID();
+jmethodID GetYuzuDeviceGetPort();
+jmethodID GetYuzuDeviceGetSupportsVibration();
+jmethodID GetYuzuDeviceVibrate();
+jmethodID GetYuzuDeviceGetAxes();
+jmethodID GetYuzuDeviceHasKeys();
+
} // namespace Common::Android
diff --git a/src/common/demangle.cpp b/src/common/demangle.cpp
index 6e117cb41..b2c9d126a 100644
--- a/src/common/demangle.cpp
+++ b/src/common/demangle.cpp
@@ -20,7 +20,9 @@ std::string DemangleSymbol(const std::string& mangled) {
}
char* demangled = nullptr;
- SCOPE_EXIT({ std::free(demangled); });
+ SCOPE_EXIT {
+ std::free(demangled);
+ };
if (is_itanium(mangled)) {
demangled = llvm::itaniumDemangle(mangled.c_str());
diff --git a/src/common/host_memory.cpp b/src/common/host_memory.cpp
index 860c39e6a..e0b5a6a67 100644
--- a/src/common/host_memory.cpp
+++ b/src/common/host_memory.cpp
@@ -430,11 +430,11 @@ public:
explicit Impl(size_t backing_size_, size_t virtual_size_)
: backing_size{backing_size_}, virtual_size{virtual_size_} {
bool good = false;
- SCOPE_EXIT({
+ SCOPE_EXIT {
if (!good) {
Release();
}
- });
+ };
long page_size = sysconf(_SC_PAGESIZE);
if (page_size != 0x1000) {
diff --git a/src/common/page_table.cpp b/src/common/page_table.cpp
index 85dc18c11..3205eb7da 100644
--- a/src/common/page_table.cpp
+++ b/src/common/page_table.cpp
@@ -24,10 +24,10 @@ bool PageTable::ContinueTraversal(TraversalEntry* out_entry, TraversalContext* c
out_entry->block_size = page_size;
// Regardless of whether the page was mapped, advance on exit.
- SCOPE_EXIT({
+ SCOPE_EXIT {
context->next_page += 1;
context->next_offset += page_size;
- });
+ };
// Validate that we can read the actual entry.
const auto page = context->next_page;
diff --git a/src/common/scope_exit.h b/src/common/scope_exit.h
index e9c789c88..f3e88cde9 100644
--- a/src/common/scope_exit.h
+++ b/src/common/scope_exit.h
@@ -7,29 +7,61 @@
#include "common/common_funcs.h"
namespace detail {
-template <typename Func>
-struct ScopeExitHelper {
- explicit ScopeExitHelper(Func&& func_) : func(std::move(func_)) {}
- ~ScopeExitHelper() {
+template <class F>
+class ScopeGuard {
+ YUZU_NON_COPYABLE(ScopeGuard);
+
+private:
+ F f;
+ bool active;
+
+public:
+ constexpr ScopeGuard(F f_) : f(std::move(f_)), active(true) {}
+ constexpr ~ScopeGuard() {
if (active) {
- func();
+ f();
}
}
-
- void Cancel() {
+ constexpr void Cancel() {
active = false;
}
- Func func;
- bool active{true};
+ constexpr ScopeGuard(ScopeGuard&& rhs) : f(std::move(rhs.f)), active(rhs.active) {
+ rhs.Cancel();
+ }
+
+ ScopeGuard& operator=(ScopeGuard&& rhs) = delete;
};
-template <typename Func>
-ScopeExitHelper<Func> ScopeExit(Func&& func) {
- return ScopeExitHelper<Func>(std::forward<Func>(func));
+template <class F>
+constexpr ScopeGuard<F> MakeScopeGuard(F f) {
+ return ScopeGuard<F>(std::move(f));
}
+
+enum class ScopeGuardOnExit {};
+
+template <typename F>
+constexpr ScopeGuard<F> operator+(ScopeGuardOnExit, F&& f) {
+ return ScopeGuard<F>(std::forward<F>(f));
+}
+
} // namespace detail
+#define CONCATENATE_IMPL(s1, s2) s1##s2
+#define CONCATENATE(s1, s2) CONCATENATE_IMPL(s1, s2)
+
+#ifdef __COUNTER__
+#define ANONYMOUS_VARIABLE(pref) CONCATENATE(pref, __COUNTER__)
+#else
+#define ANONYMOUS_VARIABLE(pref) CONCATENATE(pref, __LINE__)
+#endif
+
+/**
+ * This macro is similar to SCOPE_EXIT, except the object is caller managed. This is intended to be
+ * used when the caller might want to cancel the ScopeExit.
+ */
+#define SCOPE_GUARD detail::ScopeGuardOnExit() + [&]()
+
/**
* This macro allows you to conveniently specify a block of code that will run on scope exit. Handy
* for doing ad-hoc clean-up tasks in a function with multiple returns.
@@ -38,7 +70,7 @@ ScopeExitHelper<Func> ScopeExit(Func&& func) {
* \code
* const int saved_val = g_foo;
* g_foo = 55;
- * SCOPE_EXIT({ g_foo = saved_val; });
+ * SCOPE_EXIT{ g_foo = saved_val; };
*
* if (Bar()) {
* return 0;
@@ -47,10 +79,4 @@ ScopeExitHelper<Func> ScopeExit(Func&& func) {
* }
* \endcode
*/
-#define SCOPE_EXIT(body) auto CONCAT2(scope_exit_helper_, __LINE__) = detail::ScopeExit([&]() body)
-
-/**
- * This macro is similar to SCOPE_EXIT, except the object is caller managed. This is intended to be
- * used when the caller might want to cancel the ScopeExit.
- */
-#define SCOPE_GUARD(body) detail::ScopeExit([&]() body)
+#define SCOPE_EXIT auto ANONYMOUS_VARIABLE(SCOPE_EXIT_STATE_) = SCOPE_GUARD
diff --git a/src/common/settings.cpp b/src/common/settings.cpp
index 07709d4e5..80d388fe8 100644
--- a/src/common/settings.cpp
+++ b/src/common/settings.cpp
@@ -30,6 +30,7 @@ namespace Settings {
#define SETTING(TYPE, RANGED) template class Setting<TYPE, RANGED>
#define SWITCHABLE(TYPE, RANGED) template class SwitchableSetting<TYPE, RANGED>
+SETTING(AppletMode, false);
SETTING(AudioEngine, false);
SETTING(bool, false);
SETTING(int, false);
@@ -215,6 +216,8 @@ const char* TranslateCategory(Category category) {
return "Debugging";
case Category::GpuDriver:
return "GpuDriver";
+ case Category::LibraryApplet:
+ return "LibraryApplet";
case Category::Miscellaneous:
return "Miscellaneous";
case Category::Network:
diff --git a/src/common/settings.h b/src/common/settings.h
index f1b1add56..aa054dc24 100644
--- a/src/common/settings.h
+++ b/src/common/settings.h
@@ -133,6 +133,38 @@ struct TouchFromButtonMap {
struct Values {
Linkage linkage{};
+ // Applet
+ Setting<AppletMode> cabinet_applet_mode{linkage, AppletMode::LLE, "cabinet_applet_mode",
+ Category::LibraryApplet};
+ Setting<AppletMode> controller_applet_mode{linkage, AppletMode::HLE, "controller_applet_mode",
+ Category::LibraryApplet};
+ Setting<AppletMode> data_erase_applet_mode{linkage, AppletMode::HLE, "data_erase_applet_mode",
+ Category::LibraryApplet};
+ Setting<AppletMode> error_applet_mode{linkage, AppletMode::HLE, "error_applet_mode",
+ Category::LibraryApplet};
+ Setting<AppletMode> net_connect_applet_mode{linkage, AppletMode::HLE, "net_connect_applet_mode",
+ Category::LibraryApplet};
+ Setting<AppletMode> player_select_applet_mode{
+ linkage, AppletMode::HLE, "player_select_applet_mode", Category::LibraryApplet};
+ Setting<AppletMode> swkbd_applet_mode{linkage, AppletMode::LLE, "swkbd_applet_mode",
+ Category::LibraryApplet};
+ Setting<AppletMode> mii_edit_applet_mode{linkage, AppletMode::LLE, "mii_edit_applet_mode",
+ Category::LibraryApplet};
+ Setting<AppletMode> web_applet_mode{linkage, AppletMode::HLE, "web_applet_mode",
+ Category::LibraryApplet};
+ Setting<AppletMode> shop_applet_mode{linkage, AppletMode::HLE, "shop_applet_mode",
+ Category::LibraryApplet};
+ Setting<AppletMode> photo_viewer_applet_mode{
+ linkage, AppletMode::LLE, "photo_viewer_applet_mode", Category::LibraryApplet};
+ Setting<AppletMode> offline_web_applet_mode{linkage, AppletMode::LLE, "offline_web_applet_mode",
+ Category::LibraryApplet};
+ Setting<AppletMode> login_share_applet_mode{linkage, AppletMode::HLE, "login_share_applet_mode",
+ Category::LibraryApplet};
+ Setting<AppletMode> wifi_web_auth_applet_mode{
+ linkage, AppletMode::HLE, "wifi_web_auth_applet_mode", Category::LibraryApplet};
+ Setting<AppletMode> my_page_applet_mode{linkage, AppletMode::LLE, "my_page_applet_mode",
+ Category::LibraryApplet};
+
// Audio
SwitchableSetting<AudioEngine> sink_id{linkage, AudioEngine::Auto, "output_engine",
Category::Audio, Specialization::RuntimeList};
diff --git a/src/common/settings_common.h b/src/common/settings_common.h
index 987489e8a..2df3f0809 100644
--- a/src/common/settings_common.h
+++ b/src/common/settings_common.h
@@ -44,6 +44,7 @@ enum class Category : u32 {
Services,
Paths,
Linux,
+ LibraryApplet,
MaxEnum,
};
diff --git a/src/common/settings_enums.h b/src/common/settings_enums.h
index 617036588..f42367e67 100644
--- a/src/common/settings_enums.h
+++ b/src/common/settings_enums.h
@@ -151,6 +151,8 @@ ENUM(AspectRatio, R16_9, R4_3, R21_9, R16_10, Stretch);
ENUM(ConsoleMode, Handheld, Docked);
+ENUM(AppletMode, HLE, LLE);
+
template <typename Type>
inline std::string CanonicalizeEnum(Type id) {
const auto group = EnumMetadata<Type>::Canonicalizations();
diff --git a/src/common/settings_input.h b/src/common/settings_input.h
index 53a95ef8f..a99bb0892 100644
--- a/src/common/settings_input.h
+++ b/src/common/settings_input.h
@@ -395,6 +395,10 @@ struct PlayerInput {
u32 button_color_left;
u32 button_color_right;
std::string profile_name;
+
+ // This is meant to tell the Android frontend whether to use a device's built-in vibration
+ // motor or a controller's vibrations.
+ bool use_system_vibrator;
};
struct TouchscreenInput {