summaryrefslogtreecommitdiff
path: root/src/android
diff options
context:
space:
mode:
authorGravatar Charles Lombardo2023-04-02 23:46:22 -0400
committerGravatar bunnei2023-06-03 00:05:49 -0700
commit4d9011a8f0f7b64de23a27babffb533ebeb2075b (patch)
treeec7e6d8623fc6e8fc889fe9ecc164663fdd28ac3 /src/android
parentandroid: Remove LocalBroadcastManager (diff)
downloadyuzu-4d9011a8f0f7b64de23a27babffb533ebeb2075b.tar.gz
yuzu-4d9011a8f0f7b64de23a27babffb533ebeb2075b.tar.xz
yuzu-4d9011a8f0f7b64de23a27babffb533ebeb2075b.zip
android: Convert NativeLibrary to Kotlin
Diffstat (limited to 'src/android')
-rw-r--r--src/android/app/src/main/java/org/yuzu/yuzu_emu/NativeLibrary.java698
-rw-r--r--src/android/app/src/main/java/org/yuzu/yuzu_emu/NativeLibrary.kt463
-rw-r--r--src/android/app/src/main/java/org/yuzu/yuzu_emu/YuzuApplication.kt2
-rw-r--r--src/android/app/src/main/java/org/yuzu/yuzu_emu/activities/EmulationActivity.kt7
-rw-r--r--src/android/app/src/main/java/org/yuzu/yuzu_emu/adapters/GameAdapter.kt2
-rw-r--r--src/android/app/src/main/java/org/yuzu/yuzu_emu/applets/keyboard/SoftwareKeyboard.kt2
-rw-r--r--src/android/app/src/main/java/org/yuzu/yuzu_emu/features/settings/ui/SettingsActivity.kt2
-rw-r--r--src/android/app/src/main/java/org/yuzu/yuzu_emu/features/settings/ui/SettingsActivityPresenter.kt2
-rw-r--r--src/android/app/src/main/java/org/yuzu/yuzu_emu/features/settings/utils/SettingsFile.kt2
-rw-r--r--src/android/app/src/main/java/org/yuzu/yuzu_emu/fragments/EmulationFragment.kt20
-rw-r--r--src/android/app/src/main/java/org/yuzu/yuzu_emu/ui/main/MainActivity.kt6
-rw-r--r--src/android/app/src/main/java/org/yuzu/yuzu_emu/utils/DirectoryInitialization.kt4
-rw-r--r--src/android/app/src/main/java/org/yuzu/yuzu_emu/utils/GameHelper.kt12
-rw-r--r--src/android/app/src/main/java/org/yuzu/yuzu_emu/utils/GpuDriverHelper.kt2
-rw-r--r--src/android/app/src/main/jni/native.cpp65
15 files changed, 523 insertions, 766 deletions
diff --git a/src/android/app/src/main/java/org/yuzu/yuzu_emu/NativeLibrary.java b/src/android/app/src/main/java/org/yuzu/yuzu_emu/NativeLibrary.java
deleted file mode 100644
index 50ec34e22..000000000
--- a/src/android/app/src/main/java/org/yuzu/yuzu_emu/NativeLibrary.java
+++ /dev/null
@@ -1,698 +0,0 @@
1/*
2 * Copyright 2013 Dolphin Emulator Project
3 * Licensed under GPLv2+
4 * Refer to the license.txt file included.
5 */
6
7package org.yuzu.yuzu_emu;
8
9import android.app.Activity;
10import android.app.Dialog;
11import android.content.pm.PackageManager;
12import android.content.res.Configuration;
13import android.os.Bundle;
14import android.text.Html;
15import android.text.method.LinkMovementMethod;
16import android.view.Surface;
17import android.view.ViewGroup;
18import android.widget.EditText;
19import android.widget.FrameLayout;
20import android.widget.TextView;
21
22import androidx.annotation.NonNull;
23import androidx.appcompat.app.AlertDialog;
24import androidx.core.content.ContextCompat;
25import androidx.fragment.app.DialogFragment;
26
27import com.google.android.material.dialog.MaterialAlertDialogBuilder;
28
29import org.yuzu.yuzu_emu.activities.EmulationActivity;
30import org.yuzu.yuzu_emu.utils.DocumentsTree;
31import org.yuzu.yuzu_emu.utils.EmulationMenuSettings;
32import org.yuzu.yuzu_emu.utils.FileUtil;
33import org.yuzu.yuzu_emu.utils.Log;
34
35import java.lang.ref.WeakReference;
36import java.util.Objects;
37
38import static android.Manifest.permission.CAMERA;
39import static android.Manifest.permission.RECORD_AUDIO;
40
41/**
42 * Class which contains methods that interact
43 * with the native side of the Citra code.
44 */
45public final class NativeLibrary {
46 /**
47 * Default controller id for each device
48 */
49 public static final int Player1Device = 0;
50 public static final int Player2Device = 1;
51 public static final int Player3Device = 2;
52 public static final int Player4Device = 3;
53 public static final int Player5Device = 4;
54 public static final int Player6Device = 5;
55 public static final int Player7Device = 6;
56 public static final int Player8Device = 7;
57 public static final int ConsoleDevice = 8;
58 public static WeakReference<EmulationActivity> sEmulationActivity = new WeakReference<>(null);
59
60 private static boolean alertResult = false;
61 private static String alertPromptResult = "";
62 private static int alertPromptButton = 0;
63 private static final Object alertPromptLock = new Object();
64 private static boolean alertPromptInProgress = false;
65 private static String alertPromptCaption = "";
66 private static int alertPromptButtonConfig = 0;
67 private static EditText alertPromptEditText = null;
68
69 static {
70 try {
71 System.loadLibrary("yuzu-android");
72 } catch (UnsatisfiedLinkError ex) {
73 Log.error("[NativeLibrary] " + ex.toString());
74 }
75 }
76
77 private NativeLibrary() {
78 // Disallows instantiation.
79 }
80
81 public static int openContentUri(String path, String openmode) {
82 if (DocumentsTree.isNativePath(path)) {
83 return YuzuApplication.documentsTree.openContentUri(path, openmode);
84 }
85 return FileUtil.openContentUri(YuzuApplication.getAppContext(), path, openmode);
86 }
87
88 public static long getSize(String path) {
89 if (DocumentsTree.isNativePath(path)) {
90 return YuzuApplication.documentsTree.getFileSize(path);
91 }
92 return FileUtil.getFileSize(YuzuApplication.getAppContext(), path);
93 }
94
95 /**
96 * Handles button press events for a gamepad.
97 *
98 * @param Device The input descriptor of the gamepad.
99 * @param Button Key code identifying which button was pressed.
100 * @param Action Mask identifying which action is happening (button pressed down, or button released).
101 * @return If we handled the button press.
102 */
103 public static native boolean onGamePadButtonEvent(int Device, int Button, int Action);
104
105 /**
106 * Handles joystick movement events.
107 *
108 * @param Device The device ID of the gamepad.
109 * @param Axis The axis ID
110 * @param x_axis The value of the x-axis represented by the given ID.
111 * @param y_axis The value of the y-axis represented by the given ID.
112 */
113 public static native boolean onGamePadJoystickEvent(int Device, int Axis, float x_axis, float y_axis);
114
115 /**
116 * Handles motion events.
117 *
118 * @param delta_timestamp The finger id corresponding to this event
119 * @param gyro_x,gyro_y,gyro_z The value of the accelerometer sensor.
120 * @param accel_x,accel_y,accel_z The value of the y-axis
121 */
122
123 public static native boolean onGamePadMotionEvent(int Device, long delta_timestamp, float gyro_x, float gyro_y,
124 float gyro_z, float accel_x, float accel_y, float accel_z);
125
126 /**
127 * Signals and load a nfc tag
128 *
129 * @param data Byte array containing all the data from a nfc tag
130 */
131 public static native boolean onReadNfcTag(byte[] data);
132
133 /**
134 * Removes current loaded nfc tag
135 */
136 public static native boolean onRemoveNfcTag();
137
138 /**
139 * Handles touch press events.
140 *
141 * @param finger_id The finger id corresponding to this event
142 * @param x_axis The value of the x-axis.
143 * @param y_axis The value of the y-axis.
144 */
145 public static native void onTouchPressed(int finger_id, float x_axis, float y_axis);
146
147 /**
148 * Handles touch movement.
149 *
150 * @param x_axis The value of the instantaneous x-axis.
151 * @param y_axis The value of the instantaneous y-axis.
152 */
153 public static native void onTouchMoved(int finger_id, float x_axis, float y_axis);
154
155 /**
156 * Handles touch release events.
157 *
158 * @param finger_id The finger id corresponding to this event
159 */
160 public static native void onTouchReleased(int finger_id);
161
162 public static native void ReloadSettings();
163
164 public static native String GetUserSetting(String gameID, String Section, String Key);
165
166 public static native void SetUserSetting(String gameID, String Section, String Key, String Value);
167
168 public static native void InitGameIni(String gameID);
169
170 /**
171 * Gets the embedded icon within the given ROM.
172 *
173 * @param filename the file path to the ROM.
174 * @return a byte array containing the JPEG data for the icon.
175 */
176 public static native byte[] GetIcon(String filename);
177
178 /**
179 * Gets the embedded title of the given ISO/ROM.
180 *
181 * @param filename The file path to the ISO/ROM.
182 * @return the embedded title of the ISO/ROM.
183 */
184 public static native String GetTitle(String filename);
185
186 public static native String GetDescription(String filename);
187
188 public static native String GetGameId(String filename);
189
190 public static native String GetRegions(String filename);
191
192 public static native String GetCompany(String filename);
193
194 public static native String GetGitRevision();
195
196 public static native void SetAppDirectory(String directory);
197
198 public static native void InitializeGpuDriver(String hookLibDir, String customDriverDir, String customDriverName, String fileRedirectDir);
199
200 public static native boolean ReloadKeys();
201
202 public static native void InitializeEmulation();
203
204 public static native int DefaultCPUCore();
205
206 /**
207 * Begins emulation.
208 */
209 public static native void Run(String path);
210
211 /**
212 * Begins emulation from the specified savestate.
213 */
214 public static native void Run(String path, String savestatePath, boolean deleteSavestate);
215
216 // Surface Handling
217 public static native void SurfaceChanged(Surface surf);
218
219 public static native void SurfaceDestroyed();
220
221 /**
222 * Unpauses emulation from a paused state.
223 */
224 public static native void UnPauseEmulation();
225
226 /**
227 * Pauses emulation.
228 */
229 public static native void PauseEmulation();
230
231 /**
232 * Stops emulation.
233 */
234 public static native void StopEmulation();
235
236 /**
237 * Resets the in-memory ROM metadata cache.
238 */
239 public static native void ResetRomMetadata();
240
241 /**
242 * Returns true if emulation is running (or is paused).
243 */
244 public static native boolean IsRunning();
245
246 /**
247 * Returns the performance stats for the current game
248 **/
249 public static native double[] GetPerfStats();
250
251 /**
252 * Notifies the core emulation that the orientation has changed.
253 */
254 public static native void NotifyOrientationChange(int layout_option, int rotation);
255
256 public enum CoreError {
257 ErrorSystemFiles,
258 ErrorSavestate,
259 ErrorUnknown,
260 }
261
262 private static boolean coreErrorAlertResult = false;
263 private static final Object coreErrorAlertLock = new Object();
264
265 public static class CoreErrorDialogFragment extends DialogFragment {
266 static CoreErrorDialogFragment newInstance(String title, String message) {
267 CoreErrorDialogFragment frag = new CoreErrorDialogFragment();
268 Bundle args = new Bundle();
269 args.putString("title", title);
270 args.putString("message", message);
271 frag.setArguments(args);
272 return frag;
273 }
274
275 @NonNull
276 @Override
277 public Dialog onCreateDialog(Bundle savedInstanceState) {
278 final Activity emulationActivity = Objects.requireNonNull(getActivity());
279
280 final String title = Objects.requireNonNull(Objects.requireNonNull(getArguments()).getString("title"));
281 final String message = Objects.requireNonNull(Objects.requireNonNull(getArguments()).getString("message"));
282
283 return new MaterialAlertDialogBuilder(emulationActivity)
284 .setTitle(title)
285 .setMessage(message)
286 .setPositiveButton(R.string.continue_button, (dialog, which) -> {
287 coreErrorAlertResult = true;
288 synchronized (coreErrorAlertLock) {
289 coreErrorAlertLock.notify();
290 }
291 })
292 .setNegativeButton(R.string.abort_button, (dialog, which) -> {
293 coreErrorAlertResult = false;
294 synchronized (coreErrorAlertLock) {
295 coreErrorAlertLock.notify();
296 }
297 }).setOnDismissListener(dialog -> {
298 coreErrorAlertResult = true;
299 synchronized (coreErrorAlertLock) {
300 coreErrorAlertLock.notify();
301 }
302 }).create();
303 }
304 }
305
306 private static void OnCoreErrorImpl(String title, String message) {
307 final EmulationActivity emulationActivity = sEmulationActivity.get();
308 if (emulationActivity == null) {
309 Log.error("[NativeLibrary] EmulationActivity not present");
310 return;
311 }
312
313 CoreErrorDialogFragment fragment = CoreErrorDialogFragment.newInstance(title, message);
314 fragment.show(emulationActivity.getSupportFragmentManager(), "coreError");
315 }
316
317 /**
318 * Handles a core error.
319 *
320 * @return true: continue; false: abort
321 */
322 public static boolean OnCoreError(CoreError error, String details) {
323 final EmulationActivity emulationActivity = sEmulationActivity.get();
324 if (emulationActivity == null) {
325 Log.error("[NativeLibrary] EmulationActivity not present");
326 return false;
327 }
328
329 String title, message;
330 switch (error) {
331 case ErrorSystemFiles: {
332 title = emulationActivity.getString(R.string.system_archive_not_found);
333 message = emulationActivity.getString(R.string.system_archive_not_found_message, details.isEmpty() ? emulationActivity.getString(R.string.system_archive_general) : details);
334 break;
335 }
336 case ErrorSavestate: {
337 title = emulationActivity.getString(R.string.save_load_error);
338 message = details;
339 break;
340 }
341 case ErrorUnknown: {
342 title = emulationActivity.getString(R.string.fatal_error);
343 message = emulationActivity.getString(R.string.fatal_error_message);
344 break;
345 }
346 default: {
347 return true;
348 }
349 }
350
351 // Show the AlertDialog on the main thread.
352 emulationActivity.runOnUiThread(() -> OnCoreErrorImpl(title, message));
353
354 // Wait for the lock to notify that it is complete.
355 synchronized (coreErrorAlertLock) {
356 try {
357 coreErrorAlertLock.wait();
358 } catch (Exception ignored) {
359 }
360 }
361
362 return coreErrorAlertResult;
363 }
364
365 public static boolean isPortraitMode() {
366 return YuzuApplication.getAppContext().getResources().getConfiguration().orientation ==
367 Configuration.ORIENTATION_PORTRAIT;
368 }
369
370 public static int landscapeScreenLayout() {
371 return EmulationMenuSettings.getLandscapeScreenLayout();
372 }
373
374 public static boolean displayAlertMsg(final String caption, final String text,
375 final boolean yesNo) {
376 Log.error("[NativeLibrary] Alert: " + text);
377 final EmulationActivity emulationActivity = sEmulationActivity.get();
378 boolean result = false;
379 if (emulationActivity == null) {
380 Log.warning("[NativeLibrary] EmulationActivity is null, can't do panic alert.");
381 } else {
382 // Create object used for waiting.
383 final Object lock = new Object();
384 MaterialAlertDialogBuilder builder = new MaterialAlertDialogBuilder(emulationActivity)
385 .setTitle(caption)
386 .setMessage(text);
387
388 // If not yes/no dialog just have one button that dismisses modal,
389 // otherwise have a yes and no button that sets alertResult accordingly.
390 if (!yesNo) {
391 builder
392 .setCancelable(false)
393 .setPositiveButton(android.R.string.ok, (dialog, whichButton) ->
394 {
395 dialog.dismiss();
396 synchronized (lock) {
397 lock.notify();
398 }
399 });
400 } else {
401 alertResult = false;
402
403 builder
404 .setPositiveButton(android.R.string.yes, (dialog, whichButton) ->
405 {
406 alertResult = true;
407 dialog.dismiss();
408 synchronized (lock) {
409 lock.notify();
410 }
411 })
412 .setNegativeButton(android.R.string.no, (dialog, whichButton) ->
413 {
414 alertResult = false;
415 dialog.dismiss();
416 synchronized (lock) {
417 lock.notify();
418 }
419 });
420 }
421
422 // Show the AlertDialog on the main thread.
423 emulationActivity.runOnUiThread(builder::show);
424
425 // Wait for the lock to notify that it is complete.
426 synchronized (lock) {
427 try {
428 lock.wait();
429 } catch (Exception e) {
430 }
431 }
432
433 if (yesNo)
434 result = alertResult;
435 }
436 return result;
437 }
438
439 public static void retryDisplayAlertPrompt() {
440 if (!alertPromptInProgress) {
441 return;
442 }
443 displayAlertPromptImpl(alertPromptCaption, alertPromptEditText.getText().toString(), alertPromptButtonConfig).show();
444 }
445
446 public static String displayAlertPrompt(String caption, String text, int buttonConfig) {
447 alertPromptCaption = caption;
448 alertPromptButtonConfig = buttonConfig;
449 alertPromptInProgress = true;
450
451 // Show the AlertDialog on the main thread
452 sEmulationActivity.get().runOnUiThread(() -> displayAlertPromptImpl(alertPromptCaption, text, alertPromptButtonConfig).show());
453
454 // Wait for the lock to notify that it is complete
455 synchronized (alertPromptLock) {
456 try {
457 alertPromptLock.wait();
458 } catch (Exception e) {
459 }
460 }
461 alertPromptInProgress = false;
462
463 return alertPromptResult;
464 }
465
466 public static MaterialAlertDialogBuilder displayAlertPromptImpl(String caption, String text, int buttonConfig) {
467 final EmulationActivity emulationActivity = sEmulationActivity.get();
468 alertPromptResult = "";
469 alertPromptButton = 0;
470
471 FrameLayout.LayoutParams params = new FrameLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT);
472 params.leftMargin = params.rightMargin = YuzuApplication.getAppContext().getResources().getDimensionPixelSize(R.dimen.dialog_margin);
473
474 // Set up the input
475 alertPromptEditText = new EditText(YuzuApplication.getAppContext());
476 alertPromptEditText.setText(text);
477 alertPromptEditText.setSingleLine();
478 alertPromptEditText.setLayoutParams(params);
479
480 FrameLayout container = new FrameLayout(emulationActivity);
481 container.addView(alertPromptEditText);
482
483 MaterialAlertDialogBuilder builder = new MaterialAlertDialogBuilder(emulationActivity)
484 .setTitle(caption)
485 .setView(container)
486 .setPositiveButton(android.R.string.ok, (dialogInterface, i) ->
487 {
488 alertPromptButton = buttonConfig;
489 alertPromptResult = alertPromptEditText.getText().toString();
490 synchronized (alertPromptLock) {
491 alertPromptLock.notifyAll();
492 }
493 })
494 .setOnDismissListener(dialogInterface ->
495 {
496 alertPromptResult = "";
497 synchronized (alertPromptLock) {
498 alertPromptLock.notifyAll();
499 }
500 });
501
502 if (buttonConfig > 0) {
503 builder.setNegativeButton(android.R.string.cancel, (dialogInterface, i) ->
504 {
505 alertPromptResult = "";
506 synchronized (alertPromptLock) {
507 alertPromptLock.notifyAll();
508 }
509 });
510 }
511
512 return builder;
513 }
514
515 public static int alertPromptButton() {
516 return alertPromptButton;
517 }
518
519 public static void exitEmulationActivity(int resultCode) {
520 final int Success = 0;
521 final int ErrorNotInitialized = 1;
522 final int ErrorGetLoader = 2;
523 final int ErrorSystemFiles = 3;
524 final int ErrorSharedFont = 4;
525 final int ErrorVideoCore = 5;
526 final int ErrorUnknown = 6;
527 final int ErrorLoader = 7;
528
529 int captionId;
530 int descriptionId;
531 switch (resultCode) {
532 case ErrorVideoCore:
533 captionId = R.string.loader_error_video_core;
534 descriptionId = R.string.loader_error_video_core_description;
535 break;
536 default:
537 captionId = R.string.loader_error_encrypted;
538 descriptionId = R.string.loader_error_encrypted_roms_description;
539 if (!ReloadKeys()) {
540 descriptionId = R.string.loader_error_encrypted_keys_description;
541 }
542 break;
543 }
544
545 final EmulationActivity emulationActivity = sEmulationActivity.get();
546 if (emulationActivity == null) {
547 Log.warning("[NativeLibrary] EmulationActivity is null, can't exit.");
548 return;
549 }
550
551 MaterialAlertDialogBuilder builder = new MaterialAlertDialogBuilder(emulationActivity)
552 .setTitle(captionId)
553 .setMessage(Html.fromHtml(emulationActivity.getString(descriptionId), Html.FROM_HTML_MODE_LEGACY))
554 .setPositiveButton(android.R.string.ok, (dialog, whichButton) -> emulationActivity.finish())
555 .setOnDismissListener(dialogInterface -> emulationActivity.finish());
556 emulationActivity.runOnUiThread(() -> {
557 AlertDialog alert = builder.create();
558 alert.show();
559 ((TextView) alert.findViewById(android.R.id.message)).setMovementMethod(LinkMovementMethod.getInstance());
560 });
561 }
562
563 public static void setEmulationActivity(EmulationActivity emulationActivity) {
564 Log.verbose("[NativeLibrary] Registering EmulationActivity.");
565 sEmulationActivity = new WeakReference<>(emulationActivity);
566 }
567
568 public static void clearEmulationActivity() {
569 Log.verbose("[NativeLibrary] Unregistering EmulationActivity.");
570
571 sEmulationActivity.clear();
572 }
573
574 private static final Object cameraPermissionLock = new Object();
575 private static boolean cameraPermissionGranted = false;
576 public static final int REQUEST_CODE_NATIVE_CAMERA = 800;
577
578 public static boolean RequestCameraPermission() {
579 final EmulationActivity emulationActivity = sEmulationActivity.get();
580 if (emulationActivity == null) {
581 Log.error("[NativeLibrary] EmulationActivity not present");
582 return false;
583 }
584 if (ContextCompat.checkSelfPermission(emulationActivity, CAMERA) == PackageManager.PERMISSION_GRANTED) {
585 // Permission already granted
586 return true;
587 }
588 emulationActivity.requestPermissions(new String[]{CAMERA}, REQUEST_CODE_NATIVE_CAMERA);
589
590 // Wait until result is returned
591 synchronized (cameraPermissionLock) {
592 try {
593 cameraPermissionLock.wait();
594 } catch (InterruptedException ignored) {
595 }
596 }
597 return cameraPermissionGranted;
598 }
599
600 public static void CameraPermissionResult(boolean granted) {
601 cameraPermissionGranted = granted;
602 synchronized (cameraPermissionLock) {
603 cameraPermissionLock.notify();
604 }
605 }
606
607 private static final Object micPermissionLock = new Object();
608 private static boolean micPermissionGranted = false;
609 public static final int REQUEST_CODE_NATIVE_MIC = 900;
610
611 public static boolean RequestMicPermission() {
612 final EmulationActivity emulationActivity = sEmulationActivity.get();
613 if (emulationActivity == null) {
614 Log.error("[NativeLibrary] EmulationActivity not present");
615 return false;
616 }
617 if (ContextCompat.checkSelfPermission(emulationActivity, RECORD_AUDIO) == PackageManager.PERMISSION_GRANTED) {
618 // Permission already granted
619 return true;
620 }
621 emulationActivity.requestPermissions(new String[]{RECORD_AUDIO}, REQUEST_CODE_NATIVE_MIC);
622
623 // Wait until result is returned
624 synchronized (micPermissionLock) {
625 try {
626 micPermissionLock.wait();
627 } catch (InterruptedException ignored) {
628 }
629 }
630 return micPermissionGranted;
631 }
632
633 public static void MicPermissionResult(boolean granted) {
634 micPermissionGranted = granted;
635 synchronized (micPermissionLock) {
636 micPermissionLock.notify();
637 }
638 }
639
640 /**
641 * Logs the Citra version, Android version and, CPU.
642 */
643 public static native void LogDeviceInfo();
644
645 /**
646 * Submits inline keyboard text. Called on input for buttons that result text.
647 * @param text Text to submit to the inline software keyboard implementation.
648 */
649 public static native void SubmitInlineKeyboardText(String text);
650
651 /**
652 * Submits inline keyboard input. Used to indicate keys pressed that are not text.
653 * @param key_code Android Key Code associated with the keyboard input.
654 */
655 public static native void SubmitInlineKeyboardInput(int key_code);
656
657 /**
658 * Button type for use in onTouchEvent
659 */
660 public static final class ButtonType {
661 public static final int BUTTON_A = 0;
662 public static final int BUTTON_B = 1;
663 public static final int BUTTON_X = 2;
664 public static final int BUTTON_Y = 3;
665 public static final int STICK_L = 4;
666 public static final int STICK_R = 5;
667 public static final int TRIGGER_L = 6;
668 public static final int TRIGGER_R = 7;
669 public static final int TRIGGER_ZL = 8;
670 public static final int TRIGGER_ZR = 9;
671 public static final int BUTTON_PLUS = 10;
672 public static final int BUTTON_MINUS = 11;
673 public static final int DPAD_LEFT = 12;
674 public static final int DPAD_UP = 13;
675 public static final int DPAD_RIGHT = 14;
676 public static final int DPAD_DOWN = 15;
677 public static final int BUTTON_SL = 16;
678 public static final int BUTTON_SR = 17;
679 public static final int BUTTON_HOME = 18;
680 public static final int BUTTON_CAPTURE = 19;
681 }
682
683 /**
684 * Stick type for use in onTouchEvent
685 */
686 public static final class StickType {
687 public static final int STICK_L = 0;
688 public static final int STICK_R = 1;
689 }
690
691 /**
692 * Button states
693 */
694 public static final class ButtonState {
695 public static final int RELEASED = 0;
696 public static final int PRESSED = 1;
697 }
698}
diff --git a/src/android/app/src/main/java/org/yuzu/yuzu_emu/NativeLibrary.kt b/src/android/app/src/main/java/org/yuzu/yuzu_emu/NativeLibrary.kt
new file mode 100644
index 000000000..725917ace
--- /dev/null
+++ b/src/android/app/src/main/java/org/yuzu/yuzu_emu/NativeLibrary.kt
@@ -0,0 +1,463 @@
1// SPDX-FileCopyrightText: 2023 yuzu Emulator Project
2// SPDX-License-Identifier: GPL-2.0-or-later
3
4package org.yuzu.yuzu_emu
5
6import android.app.Dialog
7import android.content.DialogInterface
8import android.os.Bundle
9import android.text.Html
10import android.text.method.LinkMovementMethod
11import android.view.Surface
12import android.view.View
13import android.widget.TextView
14import androidx.fragment.app.DialogFragment
15import com.google.android.material.dialog.MaterialAlertDialogBuilder
16import org.yuzu.yuzu_emu.YuzuApplication.Companion.appContext
17import org.yuzu.yuzu_emu.activities.EmulationActivity
18import org.yuzu.yuzu_emu.utils.DocumentsTree.Companion.isNativePath
19import org.yuzu.yuzu_emu.utils.FileUtil.getFileSize
20import org.yuzu.yuzu_emu.utils.FileUtil.openContentUri
21import org.yuzu.yuzu_emu.utils.Log.error
22import org.yuzu.yuzu_emu.utils.Log.verbose
23import org.yuzu.yuzu_emu.utils.Log.warning
24import org.yuzu.yuzu_emu.utils.SerializableHelper.serializable
25import java.lang.ref.WeakReference
26
27/**
28 * Class which contains methods that interact
29 * with the native side of the Yuzu code.
30 */
31object NativeLibrary {
32 /**
33 * Default controller id for each device
34 */
35 const val Player1Device = 0
36 const val Player2Device = 1
37 const val Player3Device = 2
38 const val Player4Device = 3
39 const val Player5Device = 4
40 const val Player6Device = 5
41 const val Player7Device = 6
42 const val Player8Device = 7
43 const val ConsoleDevice = 8
44
45 var sEmulationActivity = WeakReference<EmulationActivity?>(null)
46
47 init {
48 try {
49 System.loadLibrary("yuzu-android")
50 } catch (ex: UnsatisfiedLinkError) {
51 error("[NativeLibrary] $ex")
52 }
53 }
54
55 @JvmStatic
56 fun openContentUri(path: String?, openmode: String?): Int {
57 return if (isNativePath(path!!)) {
58 YuzuApplication.documentsTree!!.openContentUri(path, openmode)
59 } else openContentUri(appContext, path, openmode)
60 }
61
62 @JvmStatic
63 fun getSize(path: String?): Long {
64 return if (isNativePath(path!!)) {
65 YuzuApplication.documentsTree!!.getFileSize(path)
66 } else getFileSize(appContext, path)
67 }
68
69 /**
70 * Handles button press events for a gamepad.
71 *
72 * @param Device The input descriptor of the gamepad.
73 * @param Button Key code identifying which button was pressed.
74 * @param Action Mask identifying which action is happening (button pressed down, or button released).
75 * @return If we handled the button press.
76 */
77 external fun onGamePadButtonEvent(Device: Int, Button: Int, Action: Int): Boolean
78
79 /**
80 * Handles joystick movement events.
81 *
82 * @param Device The device ID of the gamepad.
83 * @param Axis The axis ID
84 * @param x_axis The value of the x-axis represented by the given ID.
85 * @param y_axis The value of the y-axis represented by the given ID.
86 */
87 external fun onGamePadJoystickEvent(
88 Device: Int,
89 Axis: Int,
90 x_axis: Float,
91 y_axis: Float
92 ): Boolean
93
94 /**
95 * Handles motion events.
96 *
97 * @param delta_timestamp The finger id corresponding to this event
98 * @param gyro_x,gyro_y,gyro_z The value of the accelerometer sensor.
99 * @param accel_x,accel_y,accel_z The value of the y-axis
100 */
101 external fun onGamePadMotionEvent(
102 Device: Int,
103 delta_timestamp: Long,
104 gyro_x: Float,
105 gyro_y: Float,
106 gyro_z: Float,
107 accel_x: Float,
108 accel_y: Float,
109 accel_z: Float
110 ): Boolean
111
112 /**
113 * Signals and load a nfc tag
114 *
115 * @param data Byte array containing all the data from a nfc tag
116 */
117 external fun onReadNfcTag(data: ByteArray?): Boolean
118
119 /**
120 * Removes current loaded nfc tag
121 */
122 external fun onRemoveNfcTag(): Boolean
123
124 /**
125 * Handles touch press events.
126 *
127 * @param finger_id The finger id corresponding to this event
128 * @param x_axis The value of the x-axis.
129 * @param y_axis The value of the y-axis.
130 */
131 external fun onTouchPressed(finger_id: Int, x_axis: Float, y_axis: Float)
132
133 /**
134 * Handles touch movement.
135 *
136 * @param x_axis The value of the instantaneous x-axis.
137 * @param y_axis The value of the instantaneous y-axis.
138 */
139 external fun onTouchMoved(finger_id: Int, x_axis: Float, y_axis: Float)
140
141 /**
142 * Handles touch release events.
143 *
144 * @param finger_id The finger id corresponding to this event
145 */
146 external fun onTouchReleased(finger_id: Int)
147
148 external fun reloadSettings()
149
150 external fun getUserSetting(gameID: String?, Section: String?, Key: String?): String?
151
152 external fun setUserSetting(gameID: String?, Section: String?, Key: String?, Value: String?)
153
154 external fun initGameIni(gameID: String?)
155
156 /**
157 * Gets the embedded icon within the given ROM.
158 *
159 * @param filename the file path to the ROM.
160 * @return a byte array containing the JPEG data for the icon.
161 */
162 external fun getIcon(filename: String): ByteArray
163
164 /**
165 * Gets the embedded title of the given ISO/ROM.
166 *
167 * @param filename The file path to the ISO/ROM.
168 * @return the embedded title of the ISO/ROM.
169 */
170 external fun getTitle(filename: String): String
171
172 external fun getDescription(filename: String): String
173
174 external fun getGameId(filename: String): String
175
176 external fun getRegions(filename: String): String
177
178 external fun getCompany(filename: String): String
179
180 external fun setAppDirectory(directory: String)
181
182 external fun initializeGpuDriver(
183 hookLibDir: String?,
184 customDriverDir: String?,
185 customDriverName: String?,
186 fileRedirectDir: String?
187 )
188
189 external fun reloadKeys(): Boolean
190
191 external fun initializeEmulation()
192
193 external fun defaultCPUCore(): Int
194
195 /**
196 * Begins emulation.
197 */
198 external fun run(path: String?)
199
200 /**
201 * Begins emulation from the specified savestate.
202 */
203 external fun run(path: String?, savestatePath: String?, deleteSavestate: Boolean)
204
205 // Surface Handling
206 external fun surfaceChanged(surf: Surface?)
207
208 external fun surfaceDestroyed()
209
210 external fun doFrame()
211
212 /**
213 * Unpauses emulation from a paused state.
214 */
215 external fun unPauseEmulation()
216
217 /**
218 * Pauses emulation.
219 */
220 external fun pauseEmulation()
221
222 /**
223 * Stops emulation.
224 */
225 external fun stopEmulation()
226
227 /**
228 * Resets the in-memory ROM metadata cache.
229 */
230 external fun resetRomMetadata()
231
232 /**
233 * Returns true if emulation is running (or is paused).
234 */
235 external fun isRunning(): Boolean
236
237 /**
238 * Returns the performance stats for the current game
239 */
240 external fun getPerfStats(): DoubleArray
241
242 /**
243 * Notifies the core emulation that the orientation has changed.
244 */
245 external fun notifyOrientationChange(layout_option: Int, rotation: Int)
246
247 enum class CoreError {
248 ErrorSystemFiles,
249 ErrorSavestate,
250 ErrorUnknown
251 }
252
253 private var coreErrorAlertResult = false
254 private val coreErrorAlertLock = Object()
255
256 class CoreErrorDialogFragment : DialogFragment() {
257 override fun onCreateDialog(savedInstanceState: Bundle?): Dialog {
258 val title = requireArguments().serializable<String>("title")
259 val message = requireArguments().serializable<String>("message")
260
261 return MaterialAlertDialogBuilder(requireActivity())
262 .setTitle(title)
263 .setMessage(message)
264 .setPositiveButton(R.string.continue_button, null)
265 .setNegativeButton(R.string.abort_button) { _: DialogInterface?, _: Int ->
266 coreErrorAlertResult = false
267 synchronized(coreErrorAlertLock) { coreErrorAlertLock.notify() }
268 }
269 .create()
270 }
271
272 override fun onDismiss(dialog: DialogInterface) {
273 coreErrorAlertResult = true
274 synchronized(coreErrorAlertLock) { coreErrorAlertLock.notify() }
275 }
276
277 companion object {
278 fun newInstance(title: String?, message: String?): CoreErrorDialogFragment {
279 val frag = CoreErrorDialogFragment()
280 val args = Bundle()
281 args.putString("title", title)
282 args.putString("message", message)
283 frag.arguments = args
284 return frag
285 }
286 }
287 }
288
289 private fun onCoreErrorImpl(title: String, message: String) {
290 val emulationActivity = sEmulationActivity.get()
291 if (emulationActivity == null) {
292 error("[NativeLibrary] EmulationActivity not present")
293 return
294 }
295
296 val fragment = CoreErrorDialogFragment.newInstance(title, message)
297 fragment.show(emulationActivity.supportFragmentManager, "coreError")
298 }
299
300 /**
301 * Handles a core error.
302 *
303 * @return true: continue; false: abort
304 */
305 fun onCoreError(error: CoreError?, details: String): Boolean {
306 val emulationActivity = sEmulationActivity.get()
307 if (emulationActivity == null) {
308 error("[NativeLibrary] EmulationActivity not present")
309 return false
310 }
311
312 val title: String
313 val message: String
314 when (error) {
315 CoreError.ErrorSystemFiles -> {
316 title = emulationActivity.getString(R.string.system_archive_not_found)
317 message = emulationActivity.getString(
318 R.string.system_archive_not_found_message,
319 details.ifEmpty { emulationActivity.getString(R.string.system_archive_general) }
320 )
321 }
322 CoreError.ErrorSavestate -> {
323 title = emulationActivity.getString(R.string.save_load_error)
324 message = details
325 }
326 CoreError.ErrorUnknown -> {
327 title = emulationActivity.getString(R.string.fatal_error)
328 message = emulationActivity.getString(R.string.fatal_error_message)
329 }
330 else -> {
331 return true
332 }
333 }
334
335 // Show the AlertDialog on the main thread.
336 emulationActivity.runOnUiThread(Runnable { onCoreErrorImpl(title, message) })
337
338 // Wait for the lock to notify that it is complete.
339 synchronized(coreErrorAlertLock) { coreErrorAlertLock.wait() }
340
341 return coreErrorAlertResult
342 }
343
344 @JvmStatic
345 fun exitEmulationActivity(resultCode: Int) {
346 val Success = 0
347 val ErrorNotInitialized = 1
348 val ErrorGetLoader = 2
349 val ErrorSystemFiles = 3
350 val ErrorSharedFont = 4
351 val ErrorVideoCore = 5
352 val ErrorUnknown = 6
353 val ErrorLoader = 7
354
355 val captionId: Int
356 var descriptionId: Int
357 when (resultCode) {
358 ErrorVideoCore -> {
359 captionId = R.string.loader_error_video_core
360 descriptionId = R.string.loader_error_video_core_description
361 }
362 else -> {
363 captionId = R.string.loader_error_encrypted
364 descriptionId = R.string.loader_error_encrypted_roms_description
365 if (!reloadKeys()) {
366 descriptionId = R.string.loader_error_encrypted_keys_description
367 }
368 }
369 }
370
371 val emulationActivity = sEmulationActivity.get()
372 if (emulationActivity == null) {
373 warning("[NativeLibrary] EmulationActivity is null, can't exit.")
374 return
375 }
376
377 val builder = MaterialAlertDialogBuilder(emulationActivity)
378 .setTitle(captionId)
379 .setMessage(
380 Html.fromHtml(
381 emulationActivity.getString(descriptionId),
382 Html.FROM_HTML_MODE_LEGACY
383 )
384 )
385 .setPositiveButton(android.R.string.ok) { _: DialogInterface?, _: Int -> emulationActivity.finish() }
386 .setOnDismissListener { emulationActivity.finish() }
387 emulationActivity.runOnUiThread {
388 val alert = builder.create()
389 alert.show()
390 (alert.findViewById<View>(android.R.id.message) as TextView).movementMethod =
391 LinkMovementMethod.getInstance()
392 }
393 }
394
395 fun setEmulationActivity(emulationActivity: EmulationActivity?) {
396 verbose("[NativeLibrary] Registering EmulationActivity.")
397 sEmulationActivity = WeakReference(emulationActivity)
398 }
399
400 fun clearEmulationActivity() {
401 verbose("[NativeLibrary] Unregistering EmulationActivity.")
402 sEmulationActivity.clear()
403 }
404
405 /**
406 * Logs the Yuzu version, Android version and, CPU.
407 */
408 external fun logDeviceInfo()
409
410 /**
411 * Submits inline keyboard text. Called on input for buttons that result text.
412 * @param text Text to submit to the inline software keyboard implementation.
413 */
414 external fun submitInlineKeyboardText(text: String?)
415
416 /**
417 * Submits inline keyboard input. Used to indicate keys pressed that are not text.
418 * @param key_code Android Key Code associated with the keyboard input.
419 */
420 external fun submitInlineKeyboardInput(key_code: Int)
421
422 /**
423 * Button type for use in onTouchEvent
424 */
425 object ButtonType {
426 const val BUTTON_A = 0
427 const val BUTTON_B = 1
428 const val BUTTON_X = 2
429 const val BUTTON_Y = 3
430 const val STICK_L = 4
431 const val STICK_R = 5
432 const val TRIGGER_L = 6
433 const val TRIGGER_R = 7
434 const val TRIGGER_ZL = 8
435 const val TRIGGER_ZR = 9
436 const val BUTTON_PLUS = 10
437 const val BUTTON_MINUS = 11
438 const val DPAD_LEFT = 12
439 const val DPAD_UP = 13
440 const val DPAD_RIGHT = 14
441 const val DPAD_DOWN = 15
442 const val BUTTON_SL = 16
443 const val BUTTON_SR = 17
444 const val BUTTON_HOME = 18
445 const val BUTTON_CAPTURE = 19
446 }
447
448 /**
449 * Stick type for use in onTouchEvent
450 */
451 object StickType {
452 const val STICK_L = 0
453 const val STICK_R = 1
454 }
455
456 /**
457 * Button states
458 */
459 object ButtonState {
460 const val RELEASED = 0
461 const val PRESSED = 1
462 }
463}
diff --git a/src/android/app/src/main/java/org/yuzu/yuzu_emu/YuzuApplication.kt b/src/android/app/src/main/java/org/yuzu/yuzu_emu/YuzuApplication.kt
index f81b4da40..f987c6b7b 100644
--- a/src/android/app/src/main/java/org/yuzu/yuzu_emu/YuzuApplication.kt
+++ b/src/android/app/src/main/java/org/yuzu/yuzu_emu/YuzuApplication.kt
@@ -40,7 +40,7 @@ class YuzuApplication : Application() {
40 documentsTree = DocumentsTree() 40 documentsTree = DocumentsTree()
41 DirectoryInitialization.start(applicationContext) 41 DirectoryInitialization.start(applicationContext)
42 GpuDriverHelper.initializeDriverParameters(applicationContext) 42 GpuDriverHelper.initializeDriverParameters(applicationContext)
43 NativeLibrary.LogDeviceInfo() 43 NativeLibrary.logDeviceInfo()
44 44
45 // TODO(bunnei): Disable notifications until we support app suspension. 45 // TODO(bunnei): Disable notifications until we support app suspension.
46 //createNotificationChannel(); 46 //createNotificationChannel();
diff --git a/src/android/app/src/main/java/org/yuzu/yuzu_emu/activities/EmulationActivity.kt b/src/android/app/src/main/java/org/yuzu/yuzu_emu/activities/EmulationActivity.kt
index 32d04ef31..f1f92841c 100644
--- a/src/android/app/src/main/java/org/yuzu/yuzu_emu/activities/EmulationActivity.kt
+++ b/src/android/app/src/main/java/org/yuzu/yuzu_emu/activities/EmulationActivity.kt
@@ -100,10 +100,10 @@ open class EmulationActivity : AppCompatActivity() {
100 val textChar = event.unicodeChar 100 val textChar = event.unicodeChar
101 if (textChar == 0) { 101 if (textChar == 0) {
102 // No text, button input. 102 // No text, button input.
103 NativeLibrary.SubmitInlineKeyboardInput(keyCode) 103 NativeLibrary.submitInlineKeyboardInput(keyCode)
104 } else { 104 } else {
105 // Text submitted. 105 // Text submitted.
106 NativeLibrary.SubmitInlineKeyboardText(textChar.toChar().toString()) 106 NativeLibrary.submitInlineKeyboardText(textChar.toChar().toString())
107 } 107 }
108 } 108 }
109 } 109 }
@@ -132,9 +132,6 @@ open class EmulationActivity : AppCompatActivity() {
132 132
133 private fun restoreState(savedInstanceState: Bundle) { 133 private fun restoreState(savedInstanceState: Bundle) {
134 game = savedInstanceState.parcelable(EXTRA_SELECTED_GAME)!! 134 game = savedInstanceState.parcelable(EXTRA_SELECTED_GAME)!!
135
136 // If an alert prompt was in progress when state was restored, retry displaying it
137 NativeLibrary.retryDisplayAlertPrompt()
138 } 135 }
139 136
140 private fun enableFullscreenImmersive() { 137 private fun enableFullscreenImmersive() {
diff --git a/src/android/app/src/main/java/org/yuzu/yuzu_emu/adapters/GameAdapter.kt b/src/android/app/src/main/java/org/yuzu/yuzu_emu/adapters/GameAdapter.kt
index 024676185..af83f05c1 100644
--- a/src/android/app/src/main/java/org/yuzu/yuzu_emu/adapters/GameAdapter.kt
+++ b/src/android/app/src/main/java/org/yuzu/yuzu_emu/adapters/GameAdapter.kt
@@ -93,7 +93,7 @@ class GameAdapter(private val activity: AppCompatActivity, var games: ArrayList<
93 } 93 }
94 94
95 private fun decodeGameIcon(uri: String): Bitmap? { 95 private fun decodeGameIcon(uri: String): Bitmap? {
96 val data = NativeLibrary.GetIcon(uri) 96 val data = NativeLibrary.getIcon(uri)
97 return BitmapFactory.decodeByteArray( 97 return BitmapFactory.decodeByteArray(
98 data, 98 data,
99 0, 99 0,
diff --git a/src/android/app/src/main/java/org/yuzu/yuzu_emu/applets/keyboard/SoftwareKeyboard.kt b/src/android/app/src/main/java/org/yuzu/yuzu_emu/applets/keyboard/SoftwareKeyboard.kt
index 704109ec0..e6485d039 100644
--- a/src/android/app/src/main/java/org/yuzu/yuzu_emu/applets/keyboard/SoftwareKeyboard.kt
+++ b/src/android/app/src/main/java/org/yuzu/yuzu_emu/applets/keyboard/SoftwareKeyboard.kt
@@ -48,7 +48,7 @@ object SoftwareKeyboard {
48 } 48 }
49 49
50 // No longer visible, submit the result. 50 // No longer visible, submit the result.
51 NativeLibrary.SubmitInlineKeyboardInput(KeyEvent.KEYCODE_ENTER) 51 NativeLibrary.submitInlineKeyboardInput(KeyEvent.KEYCODE_ENTER)
52 } 52 }
53 }, delayMs.toLong()) 53 }, delayMs.toLong())
54 } 54 }
diff --git a/src/android/app/src/main/java/org/yuzu/yuzu_emu/features/settings/ui/SettingsActivity.kt b/src/android/app/src/main/java/org/yuzu/yuzu_emu/features/settings/ui/SettingsActivity.kt
index a655500f8..0f2c23827 100644
--- a/src/android/app/src/main/java/org/yuzu/yuzu_emu/features/settings/ui/SettingsActivity.kt
+++ b/src/android/app/src/main/java/org/yuzu/yuzu_emu/features/settings/ui/SettingsActivity.kt
@@ -85,7 +85,7 @@ class SettingsActivity : AppCompatActivity(), SettingsActivityView {
85 presenter.onStop(isFinishing) 85 presenter.onStop(isFinishing)
86 86
87 // Update framebuffer layout when closing the settings 87 // Update framebuffer layout when closing the settings
88 NativeLibrary.NotifyOrientationChange( 88 NativeLibrary.notifyOrientationChange(
89 EmulationMenuSettings.landscapeScreenLayout, 89 EmulationMenuSettings.landscapeScreenLayout,
90 windowManager.defaultDisplay.rotation 90 windowManager.defaultDisplay.rotation
91 ) 91 )
diff --git a/src/android/app/src/main/java/org/yuzu/yuzu_emu/features/settings/ui/SettingsActivityPresenter.kt b/src/android/app/src/main/java/org/yuzu/yuzu_emu/features/settings/ui/SettingsActivityPresenter.kt
index 8c90156e3..e435c6d58 100644
--- a/src/android/app/src/main/java/org/yuzu/yuzu_emu/features/settings/ui/SettingsActivityPresenter.kt
+++ b/src/android/app/src/main/java/org/yuzu/yuzu_emu/features/settings/ui/SettingsActivityPresenter.kt
@@ -63,7 +63,7 @@ class SettingsActivityPresenter(private val activityView: SettingsActivityView)
63 Log.debug("[SettingsActivity] Settings activity stopping. Saving settings to INI...") 63 Log.debug("[SettingsActivity] Settings activity stopping. Saving settings to INI...")
64 settings.saveSettings(activityView) 64 settings.saveSettings(activityView)
65 } 65 }
66 NativeLibrary.ReloadSettings() 66 NativeLibrary.reloadSettings()
67 } 67 }
68 68
69 fun onSettingChanged() { 69 fun onSettingChanged() {
diff --git a/src/android/app/src/main/java/org/yuzu/yuzu_emu/features/settings/utils/SettingsFile.kt b/src/android/app/src/main/java/org/yuzu/yuzu_emu/features/settings/utils/SettingsFile.kt
index 87ad64142..37ae39fe6 100644
--- a/src/android/app/src/main/java/org/yuzu/yuzu_emu/features/settings/utils/SettingsFile.kt
+++ b/src/android/app/src/main/java/org/yuzu/yuzu_emu/features/settings/utils/SettingsFile.kt
@@ -155,7 +155,7 @@ object SettingsFile {
155 val sortedKeySet: Set<String> = TreeSet(settings.keys) 155 val sortedKeySet: Set<String> = TreeSet(settings.keys)
156 for (settingKey in sortedKeySet) { 156 for (settingKey in sortedKeySet) {
157 val setting = settings[settingKey] 157 val setting = settings[settingKey]
158 NativeLibrary.SetUserSetting( 158 NativeLibrary.setUserSetting(
159 gameId, mapSectionNameFromIni( 159 gameId, mapSectionNameFromIni(
160 section.name 160 section.name
161 ), setting!!.key, setting.valueAsString 161 ), setting!!.key, setting.valueAsString
diff --git a/src/android/app/src/main/java/org/yuzu/yuzu_emu/fragments/EmulationFragment.kt b/src/android/app/src/main/java/org/yuzu/yuzu_emu/fragments/EmulationFragment.kt
index daee937ca..1d4641d5c 100644
--- a/src/android/app/src/main/java/org/yuzu/yuzu_emu/fragments/EmulationFragment.kt
+++ b/src/android/app/src/main/java/org/yuzu/yuzu_emu/fragments/EmulationFragment.kt
@@ -182,7 +182,7 @@ class EmulationFragment : Fragment(), SurfaceHolder.Callback {
182 val FRAMETIME = 2 182 val FRAMETIME = 2
183 val SPEED = 3 183 val SPEED = 3
184 perfStatsUpdater = { 184 perfStatsUpdater = {
185 val perfStats = NativeLibrary.GetPerfStats() 185 val perfStats = NativeLibrary.getPerfStats()
186 if (perfStats[FPS] > 0 && _binding != null) { 186 if (perfStats[FPS] > 0 && _binding != null) {
187 binding.showFpsText.text = String.format("FPS: %.1f", perfStats[FPS]) 187 binding.showFpsText.text = String.format("FPS: %.1f", perfStats[FPS])
188 } 188 }
@@ -333,7 +333,7 @@ class EmulationFragment : Fragment(), SurfaceHolder.Callback {
333 if (state != State.STOPPED) { 333 if (state != State.STOPPED) {
334 Log.debug("[EmulationFragment] Stopping emulation.") 334 Log.debug("[EmulationFragment] Stopping emulation.")
335 state = State.STOPPED 335 state = State.STOPPED
336 NativeLibrary.StopEmulation() 336 NativeLibrary.stopEmulation()
337 } else { 337 } else {
338 Log.warning("[EmulationFragment] Stop called while already stopped.") 338 Log.warning("[EmulationFragment] Stop called while already stopped.")
339 } 339 }
@@ -347,8 +347,8 @@ class EmulationFragment : Fragment(), SurfaceHolder.Callback {
347 Log.debug("[EmulationFragment] Pausing emulation.") 347 Log.debug("[EmulationFragment] Pausing emulation.")
348 348
349 // Release the surface before pausing, since emulation has to be running for that. 349 // Release the surface before pausing, since emulation has to be running for that.
350 NativeLibrary.SurfaceDestroyed() 350 NativeLibrary.surfaceDestroyed()
351 NativeLibrary.PauseEmulation() 351 NativeLibrary.pauseEmulation()
352 } else { 352 } else {
353 Log.warning("[EmulationFragment] Pause called while already paused.") 353 Log.warning("[EmulationFragment] Pause called while already paused.")
354 } 354 }
@@ -357,7 +357,7 @@ class EmulationFragment : Fragment(), SurfaceHolder.Callback {
357 @Synchronized 357 @Synchronized
358 fun run(isActivityRecreated: Boolean) { 358 fun run(isActivityRecreated: Boolean) {
359 if (isActivityRecreated) { 359 if (isActivityRecreated) {
360 if (NativeLibrary.IsRunning()) { 360 if (NativeLibrary.isRunning()) {
361 state = State.PAUSED 361 state = State.PAUSED
362 } 362 }
363 } else { 363 } else {
@@ -390,7 +390,7 @@ class EmulationFragment : Fragment(), SurfaceHolder.Callback {
390 Log.debug("[EmulationFragment] Surface destroyed.") 390 Log.debug("[EmulationFragment] Surface destroyed.")
391 when (state) { 391 when (state) {
392 State.RUNNING -> { 392 State.RUNNING -> {
393 NativeLibrary.SurfaceDestroyed() 393 NativeLibrary.surfaceDestroyed()
394 state = State.PAUSED 394 state = State.PAUSED
395 } 395 }
396 State.PAUSED -> Log.warning("[EmulationFragment] Surface cleared while emulation paused.") 396 State.PAUSED -> Log.warning("[EmulationFragment] Surface cleared while emulation paused.")
@@ -403,17 +403,17 @@ class EmulationFragment : Fragment(), SurfaceHolder.Callback {
403 runWhenSurfaceIsValid = false 403 runWhenSurfaceIsValid = false
404 when (state) { 404 when (state) {
405 State.STOPPED -> { 405 State.STOPPED -> {
406 NativeLibrary.SurfaceChanged(surface) 406 NativeLibrary.surfaceChanged(surface)
407 val mEmulationThread = Thread({ 407 val mEmulationThread = Thread({
408 Log.debug("[EmulationFragment] Starting emulation thread.") 408 Log.debug("[EmulationFragment] Starting emulation thread.")
409 NativeLibrary.Run(mGamePath) 409 NativeLibrary.run(mGamePath)
410 }, "NativeEmulation") 410 }, "NativeEmulation")
411 mEmulationThread.start() 411 mEmulationThread.start()
412 } 412 }
413 State.PAUSED -> { 413 State.PAUSED -> {
414 Log.debug("[EmulationFragment] Resuming emulation.") 414 Log.debug("[EmulationFragment] Resuming emulation.")
415 NativeLibrary.SurfaceChanged(surface) 415 NativeLibrary.surfaceChanged(surface)
416 NativeLibrary.UnPauseEmulation() 416 NativeLibrary.unPauseEmulation()
417 } 417 }
418 else -> Log.debug("[EmulationFragment] Bug, run called while already running.") 418 else -> Log.debug("[EmulationFragment] Bug, run called while already running.")
419 } 419 }
diff --git a/src/android/app/src/main/java/org/yuzu/yuzu_emu/ui/main/MainActivity.kt b/src/android/app/src/main/java/org/yuzu/yuzu_emu/ui/main/MainActivity.kt
index b6ad72591..69a371947 100644
--- a/src/android/app/src/main/java/org/yuzu/yuzu_emu/ui/main/MainActivity.kt
+++ b/src/android/app/src/main/java/org/yuzu/yuzu_emu/ui/main/MainActivity.kt
@@ -142,7 +142,7 @@ class MainActivity : AppCompatActivity(), MainView {
142 142
143 private fun refreshFragment() { 143 private fun refreshFragment() {
144 if (platformGamesFragment != null) { 144 if (platformGamesFragment != null) {
145 NativeLibrary.ResetRomMetadata() 145 NativeLibrary.resetRomMetadata()
146 platformGamesFragment!!.refresh() 146 platformGamesFragment!!.refresh()
147 } 147 }
148 } 148 }
@@ -194,7 +194,7 @@ class MainActivity : AppCompatActivity(), MainView {
194 194
195 val dstPath = DirectoryInitialization.userDirectory + "/keys/" 195 val dstPath = DirectoryInitialization.userDirectory + "/keys/"
196 if (FileUtil.copyUriToInternalStorage(this, result, dstPath, "prod.keys")) { 196 if (FileUtil.copyUriToInternalStorage(this, result, dstPath, "prod.keys")) {
197 if (NativeLibrary.ReloadKeys()) { 197 if (NativeLibrary.reloadKeys()) {
198 Toast.makeText( 198 Toast.makeText(
199 this, 199 this,
200 R.string.install_keys_success, 200 R.string.install_keys_success,
@@ -225,7 +225,7 @@ class MainActivity : AppCompatActivity(), MainView {
225 225
226 val dstPath = DirectoryInitialization.userDirectory + "/keys/" 226 val dstPath = DirectoryInitialization.userDirectory + "/keys/"
227 if (FileUtil.copyUriToInternalStorage(this, result, dstPath, "key_retail.bin")) { 227 if (FileUtil.copyUriToInternalStorage(this, result, dstPath, "key_retail.bin")) {
228 if (NativeLibrary.ReloadKeys()) { 228 if (NativeLibrary.reloadKeys()) {
229 Toast.makeText( 229 Toast.makeText(
230 this, 230 this,
231 R.string.install_keys_success, 231 R.string.install_keys_success,
diff --git a/src/android/app/src/main/java/org/yuzu/yuzu_emu/utils/DirectoryInitialization.kt b/src/android/app/src/main/java/org/yuzu/yuzu_emu/utils/DirectoryInitialization.kt
index 7b66bf220..6cd0e9d1d 100644
--- a/src/android/app/src/main/java/org/yuzu/yuzu_emu/utils/DirectoryInitialization.kt
+++ b/src/android/app/src/main/java/org/yuzu/yuzu_emu/utils/DirectoryInitialization.kt
@@ -16,7 +16,7 @@ object DirectoryInitialization {
16 fun start(context: Context) { 16 fun start(context: Context) {
17 if (!areDirectoriesReady) { 17 if (!areDirectoriesReady) {
18 initializeInternalStorage(context) 18 initializeInternalStorage(context)
19 NativeLibrary.InitializeEmulation() 19 NativeLibrary.initializeEmulation()
20 areDirectoriesReady = true 20 areDirectoriesReady = true
21 } 21 }
22 } 22 }
@@ -30,7 +30,7 @@ object DirectoryInitialization {
30 private fun initializeInternalStorage(context: Context) { 30 private fun initializeInternalStorage(context: Context) {
31 try { 31 try {
32 userPath = context.getExternalFilesDir(null)!!.canonicalPath 32 userPath = context.getExternalFilesDir(null)!!.canonicalPath
33 NativeLibrary.SetAppDirectory(userPath) 33 NativeLibrary.setAppDirectory(userPath!!)
34 } catch (e: IOException) { 34 } catch (e: IOException) {
35 e.printStackTrace() 35 e.printStackTrace()
36 } 36 }
diff --git a/src/android/app/src/main/java/org/yuzu/yuzu_emu/utils/GameHelper.kt b/src/android/app/src/main/java/org/yuzu/yuzu_emu/utils/GameHelper.kt
index 6dfd8b7f8..c463a66d8 100644
--- a/src/android/app/src/main/java/org/yuzu/yuzu_emu/utils/GameHelper.kt
+++ b/src/android/app/src/main/java/org/yuzu/yuzu_emu/utils/GameHelper.kt
@@ -22,7 +22,7 @@ object GameHelper {
22 val gamesUri = Uri.parse(gamesDir) 22 val gamesUri = Uri.parse(gamesDir)
23 23
24 // Ensure keys are loaded so that ROM metadata can be decrypted. 24 // Ensure keys are loaded so that ROM metadata can be decrypted.
25 NativeLibrary.ReloadKeys() 25 NativeLibrary.reloadKeys()
26 26
27 val children = FileUtil.listFiles(context, gamesUri) 27 val children = FileUtil.listFiles(context, gamesUri)
28 for (file in children) { 28 for (file in children) {
@@ -44,13 +44,13 @@ object GameHelper {
44 } 44 }
45 45
46 private fun getGame(filePath: String): Game { 46 private fun getGame(filePath: String): Game {
47 var name = NativeLibrary.GetTitle(filePath) 47 var name = NativeLibrary.getTitle(filePath)
48 48
49 // If the game's title field is empty, use the filename. 49 // If the game's title field is empty, use the filename.
50 if (name.isEmpty()) { 50 if (name.isEmpty()) {
51 name = filePath.substring(filePath.lastIndexOf("/") + 1) 51 name = filePath.substring(filePath.lastIndexOf("/") + 1)
52 } 52 }
53 var gameId = NativeLibrary.GetGameId(filePath) 53 var gameId = NativeLibrary.getGameId(filePath)
54 54
55 // If the game's ID field is empty, use the filename without extension. 55 // If the game's ID field is empty, use the filename without extension.
56 if (gameId.isEmpty()) { 56 if (gameId.isEmpty()) {
@@ -62,11 +62,11 @@ object GameHelper {
62 62
63 return Game( 63 return Game(
64 name, 64 name,
65 NativeLibrary.GetDescription(filePath).replace("\n", " "), 65 NativeLibrary.getDescription(filePath).replace("\n", " "),
66 NativeLibrary.GetRegions(filePath), 66 NativeLibrary.getRegions(filePath),
67 filePath, 67 filePath,
68 gameId, 68 gameId,
69 NativeLibrary.GetCompany(filePath) 69 NativeLibrary.getCompany(filePath)
70 ) 70 )
71 } 71 }
72} 72}
diff --git a/src/android/app/src/main/java/org/yuzu/yuzu_emu/utils/GpuDriverHelper.kt b/src/android/app/src/main/java/org/yuzu/yuzu_emu/utils/GpuDriverHelper.kt
index 598c6808b..236c7bc23 100644
--- a/src/android/app/src/main/java/org/yuzu/yuzu_emu/utils/GpuDriverHelper.kt
+++ b/src/android/app/src/main/java/org/yuzu/yuzu_emu/utils/GpuDriverHelper.kt
@@ -67,7 +67,7 @@ object GpuDriverHelper {
67 hookLibPath = context.applicationInfo.nativeLibraryDir + "/" 67 hookLibPath = context.applicationInfo.nativeLibraryDir + "/"
68 68
69 // Initialize GPU driver. 69 // Initialize GPU driver.
70 NativeLibrary.InitializeGpuDriver( 70 NativeLibrary.initializeGpuDriver(
71 hookLibPath, 71 hookLibPath,
72 driverInstallationPath, 72 driverInstallationPath,
73 customDriverLibraryName, 73 customDriverLibraryName,
diff --git a/src/android/app/src/main/jni/native.cpp b/src/android/app/src/main/jni/native.cpp
index ce713b80f..a170b57aa 100644
--- a/src/android/app/src/main/jni/native.cpp
+++ b/src/android/app/src/main/jni/native.cpp
@@ -353,32 +353,32 @@ static Core::SystemResultStatus RunEmulation(const std::string& filepath) {
353 353
354extern "C" { 354extern "C" {
355 355
356void Java_org_yuzu_yuzu_1emu_NativeLibrary_SurfaceChanged(JNIEnv* env, 356void Java_org_yuzu_yuzu_1emu_NativeLibrary_surfaceChanged(JNIEnv* env,
357 [[maybe_unused]] jclass clazz, 357 [[maybe_unused]] jclass clazz,
358 jobject surf) { 358 jobject surf) {
359 EmulationSession::GetInstance().SetNativeWindow(ANativeWindow_fromSurface(env, surf)); 359 EmulationSession::GetInstance().SetNativeWindow(ANativeWindow_fromSurface(env, surf));
360 EmulationSession::GetInstance().SurfaceChanged(); 360 EmulationSession::GetInstance().SurfaceChanged();
361} 361}
362 362
363void Java_org_yuzu_yuzu_1emu_NativeLibrary_SurfaceDestroyed(JNIEnv* env, 363void Java_org_yuzu_yuzu_1emu_NativeLibrary_surfaceDestroyed(JNIEnv* env,
364 [[maybe_unused]] jclass clazz) { 364 [[maybe_unused]] jclass clazz) {
365 ANativeWindow_release(EmulationSession::GetInstance().NativeWindow()); 365 ANativeWindow_release(EmulationSession::GetInstance().NativeWindow());
366 EmulationSession::GetInstance().SetNativeWindow(nullptr); 366 EmulationSession::GetInstance().SetNativeWindow(nullptr);
367 EmulationSession::GetInstance().SurfaceChanged(); 367 EmulationSession::GetInstance().SurfaceChanged();
368} 368}
369 369
370void Java_org_yuzu_yuzu_1emu_NativeLibrary_NotifyOrientationChange(JNIEnv* env, 370void Java_org_yuzu_yuzu_1emu_NativeLibrary_notifyOrientationChange(JNIEnv* env,
371 [[maybe_unused]] jclass clazz, 371 [[maybe_unused]] jclass clazz,
372 jint layout_option, 372 jint layout_option,
373 jint rotation) {} 373 jint rotation) {}
374 374
375void Java_org_yuzu_yuzu_1emu_NativeLibrary_SetAppDirectory(JNIEnv* env, 375void Java_org_yuzu_yuzu_1emu_NativeLibrary_setAppDirectory(JNIEnv* env,
376 [[maybe_unused]] jclass clazz, 376 [[maybe_unused]] jclass clazz,
377 jstring j_directory) { 377 jstring j_directory) {
378 Common::FS::SetAppDirectory(GetJString(env, j_directory)); 378 Common::FS::SetAppDirectory(GetJString(env, j_directory));
379} 379}
380 380
381void JNICALL Java_org_yuzu_yuzu_1emu_NativeLibrary_InitializeGpuDriver( 381void JNICALL Java_org_yuzu_yuzu_1emu_NativeLibrary_initializeGpuDriver(
382 JNIEnv* env, [[maybe_unused]] jclass clazz, jstring hook_lib_dir, jstring custom_driver_dir, 382 JNIEnv* env, [[maybe_unused]] jclass clazz, jstring hook_lib_dir, jstring custom_driver_dir,
383 jstring custom_driver_name, jstring file_redirect_dir) { 383 jstring custom_driver_name, jstring file_redirect_dir) {
384 EmulationSession::GetInstance().InitializeGpuDriver( 384 EmulationSession::GetInstance().InitializeGpuDriver(
@@ -386,33 +386,33 @@ void JNICALL Java_org_yuzu_yuzu_1emu_NativeLibrary_InitializeGpuDriver(
386 GetJString(env, custom_driver_name), GetJString(env, file_redirect_dir)); 386 GetJString(env, custom_driver_name), GetJString(env, file_redirect_dir));
387} 387}
388 388
389jboolean Java_org_yuzu_yuzu_1emu_NativeLibrary_ReloadKeys(JNIEnv* env, 389jboolean Java_org_yuzu_yuzu_1emu_NativeLibrary_reloadKeys(JNIEnv* env,
390 [[maybe_unused]] jclass clazz) { 390 [[maybe_unused]] jclass clazz) {
391 Core::Crypto::KeyManager::Instance().ReloadKeys(); 391 Core::Crypto::KeyManager::Instance().ReloadKeys();
392 return static_cast<jboolean>(Core::Crypto::KeyManager::Instance().AreKeysLoaded()); 392 return static_cast<jboolean>(Core::Crypto::KeyManager::Instance().AreKeysLoaded());
393} 393}
394 394
395void Java_org_yuzu_yuzu_1emu_NativeLibrary_UnPauseEmulation([[maybe_unused]] JNIEnv* env, 395void Java_org_yuzu_yuzu_1emu_NativeLibrary_unPauseEmulation([[maybe_unused]] JNIEnv* env,
396 [[maybe_unused]] jclass clazz) { 396 [[maybe_unused]] jclass clazz) {
397 EmulationSession::GetInstance().UnPauseEmulation(); 397 EmulationSession::GetInstance().UnPauseEmulation();
398} 398}
399 399
400void Java_org_yuzu_yuzu_1emu_NativeLibrary_PauseEmulation([[maybe_unused]] JNIEnv* env, 400void Java_org_yuzu_yuzu_1emu_NativeLibrary_pauseEmulation([[maybe_unused]] JNIEnv* env,
401 [[maybe_unused]] jclass clazz) { 401 [[maybe_unused]] jclass clazz) {
402 EmulationSession::GetInstance().PauseEmulation(); 402 EmulationSession::GetInstance().PauseEmulation();
403} 403}
404 404
405void Java_org_yuzu_yuzu_1emu_NativeLibrary_StopEmulation([[maybe_unused]] JNIEnv* env, 405void Java_org_yuzu_yuzu_1emu_NativeLibrary_stopEmulation([[maybe_unused]] JNIEnv* env,
406 [[maybe_unused]] jclass clazz) { 406 [[maybe_unused]] jclass clazz) {
407 EmulationSession::GetInstance().HaltEmulation(); 407 EmulationSession::GetInstance().HaltEmulation();
408} 408}
409 409
410void Java_org_yuzu_yuzu_1emu_NativeLibrary_ResetRomMetadata([[maybe_unused]] JNIEnv* env, 410void Java_org_yuzu_yuzu_1emu_NativeLibrary_resetRomMetadata([[maybe_unused]] JNIEnv* env,
411 [[maybe_unused]] jclass clazz) { 411 [[maybe_unused]] jclass clazz) {
412 EmulationSession::GetInstance().ResetRomMetadata(); 412 EmulationSession::GetInstance().ResetRomMetadata();
413} 413}
414 414
415jboolean Java_org_yuzu_yuzu_1emu_NativeLibrary_IsRunning([[maybe_unused]] JNIEnv* env, 415jboolean Java_org_yuzu_yuzu_1emu_NativeLibrary_isRunning([[maybe_unused]] JNIEnv* env,
416 [[maybe_unused]] jclass clazz) { 416 [[maybe_unused]] jclass clazz) {
417 return static_cast<jboolean>(EmulationSession::GetInstance().IsRunning()); 417 return static_cast<jboolean>(EmulationSession::GetInstance().IsRunning());
418} 418}
@@ -492,7 +492,7 @@ void Java_org_yuzu_yuzu_1emu_NativeLibrary_onTouchReleased([[maybe_unused]] JNIE
492 } 492 }
493} 493}
494 494
495jbyteArray Java_org_yuzu_yuzu_1emu_NativeLibrary_GetIcon([[maybe_unused]] JNIEnv* env, 495jbyteArray Java_org_yuzu_yuzu_1emu_NativeLibrary_getIcon([[maybe_unused]] JNIEnv* env,
496 [[maybe_unused]] jclass clazz, 496 [[maybe_unused]] jclass clazz,
497 [[maybe_unused]] jstring j_filename) { 497 [[maybe_unused]] jstring j_filename) {
498 auto icon_data = EmulationSession::GetInstance().GetRomIcon(GetJString(env, j_filename)); 498 auto icon_data = EmulationSession::GetInstance().GetRomIcon(GetJString(env, j_filename));
@@ -502,43 +502,38 @@ jbyteArray Java_org_yuzu_yuzu_1emu_NativeLibrary_GetIcon([[maybe_unused]] JNIEnv
502 return icon; 502 return icon;
503} 503}
504 504
505jstring Java_org_yuzu_yuzu_1emu_NativeLibrary_GetTitle([[maybe_unused]] JNIEnv* env, 505jstring Java_org_yuzu_yuzu_1emu_NativeLibrary_getTitle([[maybe_unused]] JNIEnv* env,
506 [[maybe_unused]] jclass clazz, 506 [[maybe_unused]] jclass clazz,
507 [[maybe_unused]] jstring j_filename) { 507 [[maybe_unused]] jstring j_filename) {
508 auto title = EmulationSession::GetInstance().GetRomTitle(GetJString(env, j_filename)); 508 auto title = EmulationSession::GetInstance().GetRomTitle(GetJString(env, j_filename));
509 return env->NewStringUTF(title.c_str()); 509 return env->NewStringUTF(title.c_str());
510} 510}
511 511
512jstring Java_org_yuzu_yuzu_1emu_NativeLibrary_GetDescription([[maybe_unused]] JNIEnv* env, 512jstring Java_org_yuzu_yuzu_1emu_NativeLibrary_getDescription([[maybe_unused]] JNIEnv* env,
513 [[maybe_unused]] jclass clazz, 513 [[maybe_unused]] jclass clazz,
514 jstring j_filename) { 514 jstring j_filename) {
515 return j_filename; 515 return j_filename;
516} 516}
517 517
518jstring Java_org_yuzu_yuzu_1emu_NativeLibrary_GetGameId([[maybe_unused]] JNIEnv* env, 518jstring Java_org_yuzu_yuzu_1emu_NativeLibrary_getGameId([[maybe_unused]] JNIEnv* env,
519 [[maybe_unused]] jclass clazz, 519 [[maybe_unused]] jclass clazz,
520 jstring j_filename) { 520 jstring j_filename) {
521 return j_filename; 521 return j_filename;
522} 522}
523 523
524jstring Java_org_yuzu_yuzu_1emu_NativeLibrary_GetRegions([[maybe_unused]] JNIEnv* env, 524jstring Java_org_yuzu_yuzu_1emu_NativeLibrary_getRegions([[maybe_unused]] JNIEnv* env,
525 [[maybe_unused]] jclass clazz, 525 [[maybe_unused]] jclass clazz,
526 [[maybe_unused]] jstring j_filename) { 526 [[maybe_unused]] jstring j_filename) {
527 return env->NewStringUTF(""); 527 return env->NewStringUTF("");
528} 528}
529 529
530jstring Java_org_yuzu_yuzu_1emu_NativeLibrary_GetCompany([[maybe_unused]] JNIEnv* env, 530jstring Java_org_yuzu_yuzu_1emu_NativeLibrary_getCompany([[maybe_unused]] JNIEnv* env,
531 [[maybe_unused]] jclass clazz, 531 [[maybe_unused]] jclass clazz,
532 [[maybe_unused]] jstring j_filename) { 532 [[maybe_unused]] jstring j_filename) {
533 return env->NewStringUTF(""); 533 return env->NewStringUTF("");
534} 534}
535 535
536jstring Java_org_yuzu_yuzu_1emu_NativeLibrary_GetGitRevision([[maybe_unused]] JNIEnv* env, 536void Java_org_yuzu_yuzu_1emu_NativeLibrary_initializeEmulation
537 [[maybe_unused]] jclass clazz) {
538 return {};
539}
540
541void Java_org_yuzu_yuzu_1emu_NativeLibrary_InitializeEmulation
542 [[maybe_unused]] (JNIEnv* env, [[maybe_unused]] jclass clazz) { 537 [[maybe_unused]] (JNIEnv* env, [[maybe_unused]] jclass clazz) {
543 // Create the default config.ini. 538 // Create the default config.ini.
544 Config{}; 539 Config{};
@@ -546,21 +541,21 @@ void Java_org_yuzu_yuzu_1emu_NativeLibrary_InitializeEmulation
546 EmulationSession::GetInstance().System().Initialize(); 541 EmulationSession::GetInstance().System().Initialize();
547} 542}
548 543
549jint Java_org_yuzu_yuzu_1emu_NativeLibrary_DefaultCPUCore([[maybe_unused]] JNIEnv* env, 544jint Java_org_yuzu_yuzu_1emu_NativeLibrary_defaultCPUCore([[maybe_unused]] JNIEnv* env,
550 [[maybe_unused]] jclass clazz) { 545 [[maybe_unused]] jclass clazz) {
551 return {}; 546 return {};
552} 547}
553 548
554void Java_org_yuzu_yuzu_1emu_NativeLibrary_Run__Ljava_lang_String_2Ljava_lang_String_2Z( 549void Java_org_yuzu_yuzu_1emu_NativeLibrary_run__Ljava_lang_String_2Ljava_lang_String_2Z(
555 [[maybe_unused]] JNIEnv* env, [[maybe_unused]] jclass clazz, [[maybe_unused]] jstring j_file, 550 [[maybe_unused]] JNIEnv* env, [[maybe_unused]] jclass clazz, [[maybe_unused]] jstring j_file,
556 [[maybe_unused]] jstring j_savestate, [[maybe_unused]] jboolean j_delete_savestate) {} 551 [[maybe_unused]] jstring j_savestate, [[maybe_unused]] jboolean j_delete_savestate) {}
557 552
558void Java_org_yuzu_yuzu_1emu_NativeLibrary_ReloadSettings([[maybe_unused]] JNIEnv* env, 553void Java_org_yuzu_yuzu_1emu_NativeLibrary_reloadSettings([[maybe_unused]] JNIEnv* env,
559 [[maybe_unused]] jclass clazz) { 554 [[maybe_unused]] jclass clazz) {
560 Config{}; 555 Config{};
561} 556}
562 557
563jstring Java_org_yuzu_yuzu_1emu_NativeLibrary_GetUserSetting([[maybe_unused]] JNIEnv* env, 558jstring Java_org_yuzu_yuzu_1emu_NativeLibrary_getUserSetting([[maybe_unused]] JNIEnv* env,
564 [[maybe_unused]] jclass clazz, 559 [[maybe_unused]] jclass clazz,
565 jstring j_game_id, jstring j_section, 560 jstring j_game_id, jstring j_section,
566 jstring j_key) { 561 jstring j_key) {
@@ -575,7 +570,7 @@ jstring Java_org_yuzu_yuzu_1emu_NativeLibrary_GetUserSetting([[maybe_unused]] JN
575 return env->NewStringUTF(""); 570 return env->NewStringUTF("");
576} 571}
577 572
578void Java_org_yuzu_yuzu_1emu_NativeLibrary_SetUserSetting([[maybe_unused]] JNIEnv* env, 573void Java_org_yuzu_yuzu_1emu_NativeLibrary_setUserSetting([[maybe_unused]] JNIEnv* env,
579 [[maybe_unused]] jclass clazz, 574 [[maybe_unused]] jclass clazz,
580 jstring j_game_id, jstring j_section, 575 jstring j_game_id, jstring j_section,
581 jstring j_key, jstring j_value) { 576 jstring j_key, jstring j_value) {
@@ -590,7 +585,7 @@ void Java_org_yuzu_yuzu_1emu_NativeLibrary_SetUserSetting([[maybe_unused]] JNIEn
590 env->ReleaseStringUTFChars(j_value, value.data()); 585 env->ReleaseStringUTFChars(j_value, value.data());
591} 586}
592 587
593void Java_org_yuzu_yuzu_1emu_NativeLibrary_InitGameIni([[maybe_unused]] JNIEnv* env, 588void Java_org_yuzu_yuzu_1emu_NativeLibrary_initGameIni([[maybe_unused]] JNIEnv* env,
594 [[maybe_unused]] jclass clazz, 589 [[maybe_unused]] jclass clazz,
595 jstring j_game_id) { 590 jstring j_game_id) {
596 std::string_view game_id = env->GetStringUTFChars(j_game_id, 0); 591 std::string_view game_id = env->GetStringUTFChars(j_game_id, 0);
@@ -598,7 +593,7 @@ void Java_org_yuzu_yuzu_1emu_NativeLibrary_InitGameIni([[maybe_unused]] JNIEnv*
598 env->ReleaseStringUTFChars(j_game_id, game_id.data()); 593 env->ReleaseStringUTFChars(j_game_id, game_id.data());
599} 594}
600 595
601jdoubleArray Java_org_yuzu_yuzu_1emu_NativeLibrary_GetPerfStats([[maybe_unused]] JNIEnv* env, 596jdoubleArray Java_org_yuzu_yuzu_1emu_NativeLibrary_getPerfStats([[maybe_unused]] JNIEnv* env,
602 [[maybe_unused]] jclass clazz) { 597 [[maybe_unused]] jclass clazz) {
603 jdoubleArray j_stats = env->NewDoubleArray(4); 598 jdoubleArray j_stats = env->NewDoubleArray(4);
604 599
@@ -615,10 +610,10 @@ jdoubleArray Java_org_yuzu_yuzu_1emu_NativeLibrary_GetPerfStats([[maybe_unused]]
615 return j_stats; 610 return j_stats;
616} 611}
617 612
618void Java_org_yuzu_yuzu_1emu_utils_DirectoryInitialization_SetSysDirectory( 613void Java_org_yuzu_yuzu_1emu_utils_DirectoryInitialization_setSysDirectory(
619 [[maybe_unused]] JNIEnv* env, [[maybe_unused]] jclass clazz, jstring j_path) {} 614 [[maybe_unused]] JNIEnv* env, [[maybe_unused]] jclass clazz, jstring j_path) {}
620 615
621void Java_org_yuzu_yuzu_1emu_NativeLibrary_Run__Ljava_lang_String_2([[maybe_unused]] JNIEnv* env, 616void Java_org_yuzu_yuzu_1emu_NativeLibrary_run__Ljava_lang_String_2([[maybe_unused]] JNIEnv* env,
622 [[maybe_unused]] jclass clazz, 617 [[maybe_unused]] jclass clazz,
623 jstring j_path) { 618 jstring j_path) {
624 const std::string path = GetJString(env, j_path); 619 const std::string path = GetJString(env, j_path);
@@ -630,19 +625,19 @@ void Java_org_yuzu_yuzu_1emu_NativeLibrary_Run__Ljava_lang_String_2([[maybe_unus
630 } 625 }
631} 626}
632 627
633void Java_org_yuzu_yuzu_1emu_NativeLibrary_LogDeviceInfo([[maybe_unused]] JNIEnv* env, 628void Java_org_yuzu_yuzu_1emu_NativeLibrary_logDeviceInfo([[maybe_unused]] JNIEnv* env,
634 [[maybe_unused]] jclass clazz) { 629 [[maybe_unused]] jclass clazz) {
635 LOG_INFO(Frontend, "yuzu Version: {}-{}", Common::g_scm_branch, Common::g_scm_desc); 630 LOG_INFO(Frontend, "yuzu Version: {}-{}", Common::g_scm_branch, Common::g_scm_desc);
636 LOG_INFO(Frontend, "Host OS: Android API level {}", android_get_device_api_level()); 631 LOG_INFO(Frontend, "Host OS: Android API level {}", android_get_device_api_level());
637} 632}
638 633
639void Java_org_yuzu_yuzu_1emu_NativeLibrary_SubmitInlineKeyboardText(JNIEnv* env, jclass clazz, 634void Java_org_yuzu_yuzu_1emu_NativeLibrary_submitInlineKeyboardText(JNIEnv* env, jclass clazz,
640 jstring j_text) { 635 jstring j_text) {
641 const std::u16string input = Common::UTF8ToUTF16(GetJString(env, j_text)); 636 const std::u16string input = Common::UTF8ToUTF16(GetJString(env, j_text));
642 EmulationSession::GetInstance().SoftwareKeyboard()->SubmitInlineKeyboardText(input); 637 EmulationSession::GetInstance().SoftwareKeyboard()->SubmitInlineKeyboardText(input);
643} 638}
644 639
645void Java_org_yuzu_yuzu_1emu_NativeLibrary_SubmitInlineKeyboardInput(JNIEnv* env, jclass clazz, 640void Java_org_yuzu_yuzu_1emu_NativeLibrary_submitInlineKeyboardInput(JNIEnv* env, jclass clazz,
646 jint j_key_code) { 641 jint j_key_code) {
647 EmulationSession::GetInstance().SoftwareKeyboard()->SubmitInlineKeyboardInput(j_key_code); 642 EmulationSession::GetInstance().SoftwareKeyboard()->SubmitInlineKeyboardInput(j_key_code);
648} 643}