mirror of
https://github.com/izzy2lost/WeeU.git
synced 2026-07-06 00:19:59 -07:00
Refactor code
This commit is contained in:
@@ -19,20 +19,20 @@
|
||||
android:theme="@style/Theme.Cemu"
|
||||
tools:targetApi="31">
|
||||
<activity
|
||||
android:name=".EmulationActivity"
|
||||
android:name=".emulation.EmulationActivity"
|
||||
android:launchMode="singleTop"
|
||||
android:parentActivityName=".MainActivity"
|
||||
android:screenOrientation="userLandscape"
|
||||
tools:ignore="DiscouragedApi" />
|
||||
<activity
|
||||
android:name=".InputOverlayConfigureActivity"
|
||||
android:name=".inputoverlay.InputOverlayConfigureActivity"
|
||||
android:launchMode="singleTop"
|
||||
android:parentActivityName=".SettingsActivity"
|
||||
android:parentActivityName=".settings.SettingsActivity"
|
||||
android:screenOrientation="userLandscape"
|
||||
tools:ignore="DiscouragedApi" />
|
||||
|
||||
<activity
|
||||
android:name=".SettingsActivity"
|
||||
android:name=".settings.SettingsActivity"
|
||||
android:exported="false"
|
||||
android:parentActivityName=".MainActivity" />
|
||||
<activity
|
||||
|
||||
@@ -27,7 +27,7 @@ class AndroidFilesystemCallbacks : public FilesystemAndroid::FilesystemCallbacks
|
||||
AndroidFilesystemCallbacks()
|
||||
{
|
||||
JNIUtils::ScopedJNIENV env;
|
||||
m_fileUtilClass = JNIUtils::Scopedjclass("info/cemu/Cemu/FileUtil");
|
||||
m_fileUtilClass = JNIUtils::Scopedjclass("info/cemu/Cemu/utils/FileUtil");
|
||||
m_openContentUriMid = env->GetStaticMethodID(*m_fileUtilClass, "openContentUri", "(Ljava/lang/String;)I");
|
||||
m_listFilesMid = env->GetStaticMethodID(*m_fileUtilClass, "listFiles", "(Ljava/lang/String;)[Ljava/lang/String;");
|
||||
m_isDirectoryMid = env->GetStaticMethodID(*m_fileUtilClass, "isDirectory", "(Ljava/lang/String;)Z");
|
||||
|
||||
@@ -3,6 +3,9 @@ package info.cemu.Cemu;
|
||||
import android.app.Application;
|
||||
import android.util.DisplayMetrics;
|
||||
|
||||
import info.cemu.Cemu.NativeLibrary;
|
||||
import info.cemu.Cemu.utils.FileUtil;
|
||||
|
||||
public class CemuApplication extends Application {
|
||||
@Override
|
||||
public void onCreate() {
|
||||
|
||||
@@ -1,6 +0,0 @@
|
||||
package info.cemu.Cemu;
|
||||
|
||||
public class CemuPreferences {
|
||||
public static final String PREFERENCES_NAME = "CEMU_PREFERENCES";
|
||||
public static final String GAMES_PATH_KEY = "GAME_PATHS_KEY";
|
||||
}
|
||||
@@ -2,33 +2,16 @@ package info.cemu.Cemu;
|
||||
|
||||
import android.view.Surface;
|
||||
|
||||
import androidx.annotation.Nullable;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
import java.util.function.Predicate;
|
||||
|
||||
public class NativeLibrary {
|
||||
static {
|
||||
System.loadLibrary("CemuAndroid");
|
||||
}
|
||||
|
||||
public interface FileSystemCallbacks {
|
||||
int openContentUri(String uri);
|
||||
|
||||
String[] listFiles(String uri);
|
||||
|
||||
boolean isDirectory(String uri);
|
||||
|
||||
boolean isFile(String uri);
|
||||
|
||||
boolean exists(String uri);
|
||||
}
|
||||
|
||||
public static native void setDPI(float dpi);
|
||||
|
||||
public static native void setSurface(Surface surface, boolean isMainCanvas);
|
||||
@@ -72,145 +55,134 @@ public class NativeLibrary {
|
||||
|
||||
public static native void onNativeAxis(String deviceDescriptor, String deviceName, int axis, float value);
|
||||
|
||||
static final int VPAD_BUTTON_NONE = 0;
|
||||
static final int VPAD_BUTTON_A = 1;
|
||||
static final int VPAD_BUTTON_B = 2;
|
||||
static final int VPAD_BUTTON_X = 3;
|
||||
static final int VPAD_BUTTON_Y = 4;
|
||||
static final int VPAD_BUTTON_L = 5;
|
||||
static final int VPAD_BUTTON_R = 6;
|
||||
static final int VPAD_BUTTON_ZL = 7;
|
||||
static final int VPAD_BUTTON_ZR = 8;
|
||||
static final int VPAD_BUTTON_PLUS = 9;
|
||||
static final int VPAD_BUTTON_MINUS = 10;
|
||||
static final int VPAD_BUTTON_UP = 11;
|
||||
static final int VPAD_BUTTON_DOWN = 12;
|
||||
static final int VPAD_BUTTON_LEFT = 13;
|
||||
static final int VPAD_BUTTON_RIGHT = 14;
|
||||
static final int VPAD_BUTTON_STICKL = 15;
|
||||
static final int VPAD_BUTTON_STICKR = 16;
|
||||
static final int VPAD_BUTTON_STICKL_UP = 17;
|
||||
static final int VPAD_BUTTON_STICKL_DOWN = 18;
|
||||
static final int VPAD_BUTTON_STICKL_LEFT = 19;
|
||||
static final int VPAD_BUTTON_STICKL_RIGHT = 20;
|
||||
static final int VPAD_BUTTON_STICKR_UP = 21;
|
||||
static final int VPAD_BUTTON_STICKR_DOWN = 22;
|
||||
static final int VPAD_BUTTON_STICKR_LEFT = 23;
|
||||
static final int VPAD_BUTTON_STICKR_RIGHT = 24;
|
||||
static final int VPAD_BUTTON_MIC = 25;
|
||||
static final int VPAD_BUTTON_SCREEN = 26;
|
||||
static final int VPAD_BUTTON_HOME = 27;
|
||||
static final int VPAD_BUTTON_MAX = 28;
|
||||
public static final int VPAD_BUTTON_NONE = 0;
|
||||
public static final int VPAD_BUTTON_A = 1;
|
||||
public static final int VPAD_BUTTON_B = 2;
|
||||
public static final int VPAD_BUTTON_X = 3;
|
||||
public static final int VPAD_BUTTON_Y = 4;
|
||||
public static final int VPAD_BUTTON_L = 5;
|
||||
public static final int VPAD_BUTTON_R = 6;
|
||||
public static final int VPAD_BUTTON_ZL = 7;
|
||||
public static final int VPAD_BUTTON_ZR = 8;
|
||||
public static final int VPAD_BUTTON_PLUS = 9;
|
||||
public static final int VPAD_BUTTON_MINUS = 10;
|
||||
public static final int VPAD_BUTTON_UP = 11;
|
||||
public static final int VPAD_BUTTON_DOWN = 12;
|
||||
public static final int VPAD_BUTTON_LEFT = 13;
|
||||
public static final int VPAD_BUTTON_RIGHT = 14;
|
||||
public static final int VPAD_BUTTON_STICKL = 15;
|
||||
public static final int VPAD_BUTTON_STICKR = 16;
|
||||
public static final int VPAD_BUTTON_STICKL_UP = 17;
|
||||
public static final int VPAD_BUTTON_STICKL_DOWN = 18;
|
||||
public static final int VPAD_BUTTON_STICKL_LEFT = 19;
|
||||
public static final int VPAD_BUTTON_STICKL_RIGHT = 20;
|
||||
public static final int VPAD_BUTTON_STICKR_UP = 21;
|
||||
public static final int VPAD_BUTTON_STICKR_DOWN = 22;
|
||||
public static final int VPAD_BUTTON_STICKR_LEFT = 23;
|
||||
public static final int VPAD_BUTTON_STICKR_RIGHT = 24;
|
||||
public static final int VPAD_BUTTON_MIC = 25;
|
||||
public static final int VPAD_BUTTON_SCREEN = 26;
|
||||
public static final int VPAD_BUTTON_HOME = 27;
|
||||
public static final int VPAD_BUTTON_MAX = 28;
|
||||
|
||||
static final int PRO_BUTTON_NONE = 0;
|
||||
static final int PRO_BUTTON_A = 1;
|
||||
static final int PRO_BUTTON_B = 2;
|
||||
static final int PRO_BUTTON_X = 3;
|
||||
static final int PRO_BUTTON_Y = 4;
|
||||
static final int PRO_BUTTON_L = 5;
|
||||
static final int PRO_BUTTON_R = 6;
|
||||
static final int PRO_BUTTON_ZL = 7;
|
||||
static final int PRO_BUTTON_ZR = 8;
|
||||
static final int PRO_BUTTON_PLUS = 9;
|
||||
static final int PRO_BUTTON_MINUS = 10;
|
||||
static final int PRO_BUTTON_HOME = 11;
|
||||
static final int PRO_BUTTON_UP = 12;
|
||||
static final int PRO_BUTTON_DOWN = 13;
|
||||
static final int PRO_BUTTON_LEFT = 14;
|
||||
static final int PRO_BUTTON_RIGHT = 15;
|
||||
static final int PRO_BUTTON_STICKL = 16;
|
||||
static final int PRO_BUTTON_STICKR = 17;
|
||||
static final int PRO_BUTTON_STICKL_UP = 18;
|
||||
static final int PRO_BUTTON_STICKL_DOWN = 19;
|
||||
static final int PRO_BUTTON_STICKL_LEFT = 20;
|
||||
static final int PRO_BUTTON_STICKL_RIGHT = 21;
|
||||
static final int PRO_BUTTON_STICKR_UP = 22;
|
||||
static final int PRO_BUTTON_STICKR_DOWN = 23;
|
||||
static final int PRO_BUTTON_STICKR_LEFT = 24;
|
||||
static final int PRO_BUTTON_STICKR_RIGHT = 25;
|
||||
static final int PRO_BUTTON_MAX = 26;
|
||||
public static final int PRO_BUTTON_NONE = 0;
|
||||
public static final int PRO_BUTTON_A = 1;
|
||||
public static final int PRO_BUTTON_B = 2;
|
||||
public static final int PRO_BUTTON_X = 3;
|
||||
public static final int PRO_BUTTON_Y = 4;
|
||||
public static final int PRO_BUTTON_L = 5;
|
||||
public static final int PRO_BUTTON_R = 6;
|
||||
public static final int PRO_BUTTON_ZL = 7;
|
||||
public static final int PRO_BUTTON_ZR = 8;
|
||||
public static final int PRO_BUTTON_PLUS = 9;
|
||||
public static final int PRO_BUTTON_MINUS = 10;
|
||||
public static final int PRO_BUTTON_HOME = 11;
|
||||
public static final int PRO_BUTTON_UP = 12;
|
||||
public static final int PRO_BUTTON_DOWN = 13;
|
||||
public static final int PRO_BUTTON_LEFT = 14;
|
||||
public static final int PRO_BUTTON_RIGHT = 15;
|
||||
public static final int PRO_BUTTON_STICKL = 16;
|
||||
public static final int PRO_BUTTON_STICKR = 17;
|
||||
public static final int PRO_BUTTON_STICKL_UP = 18;
|
||||
public static final int PRO_BUTTON_STICKL_DOWN = 19;
|
||||
public static final int PRO_BUTTON_STICKL_LEFT = 20;
|
||||
public static final int PRO_BUTTON_STICKL_RIGHT = 21;
|
||||
public static final int PRO_BUTTON_STICKR_UP = 22;
|
||||
public static final int PRO_BUTTON_STICKR_DOWN = 23;
|
||||
public static final int PRO_BUTTON_STICKR_LEFT = 24;
|
||||
public static final int PRO_BUTTON_STICKR_RIGHT = 25;
|
||||
public static final int PRO_BUTTON_MAX = 26;
|
||||
|
||||
static final int CLASSIC_BUTTON_NONE = 0;
|
||||
static final int CLASSIC_BUTTON_A = 1;
|
||||
static final int CLASSIC_BUTTON_B = 2;
|
||||
static final int CLASSIC_BUTTON_X = 3;
|
||||
static final int CLASSIC_BUTTON_Y = 4;
|
||||
static final int CLASSIC_BUTTON_L = 5;
|
||||
static final int CLASSIC_BUTTON_R = 6;
|
||||
static final int CLASSIC_BUTTON_ZL = 7;
|
||||
static final int CLASSIC_BUTTON_ZR = 8;
|
||||
static final int CLASSIC_BUTTON_PLUS = 9;
|
||||
static final int CLASSIC_BUTTON_MINUS = 10;
|
||||
static final int CLASSIC_BUTTON_HOME = 11;
|
||||
static final int CLASSIC_BUTTON_UP = 12;
|
||||
static final int CLASSIC_BUTTON_DOWN = 13;
|
||||
static final int CLASSIC_BUTTON_LEFT = 14;
|
||||
static final int CLASSIC_BUTTON_RIGHT = 15;
|
||||
static final int CLASSIC_BUTTON_STICKL_UP = 16;
|
||||
static final int CLASSIC_BUTTON_STICKL_DOWN = 17;
|
||||
static final int CLASSIC_BUTTON_STICKL_LEFT = 18;
|
||||
static final int CLASSIC_BUTTON_STICKL_RIGHT = 19;
|
||||
static final int CLASSIC_BUTTON_STICKR_UP = 20;
|
||||
static final int CLASSIC_BUTTON_STICKR_DOWN = 21;
|
||||
static final int CLASSIC_BUTTON_STICKR_LEFT = 22;
|
||||
static final int CLASSIC_BUTTON_STICKR_RIGHT = 23;
|
||||
static final int CLASSIC_BUTTON_MAX = 24;
|
||||
public static final int CLASSIC_BUTTON_NONE = 0;
|
||||
public static final int CLASSIC_BUTTON_A = 1;
|
||||
public static final int CLASSIC_BUTTON_B = 2;
|
||||
public static final int CLASSIC_BUTTON_X = 3;
|
||||
public static final int CLASSIC_BUTTON_Y = 4;
|
||||
public static final int CLASSIC_BUTTON_L = 5;
|
||||
public static final int CLASSIC_BUTTON_R = 6;
|
||||
public static final int CLASSIC_BUTTON_ZL = 7;
|
||||
public static final int CLASSIC_BUTTON_ZR = 8;
|
||||
public static final int CLASSIC_BUTTON_PLUS = 9;
|
||||
public static final int CLASSIC_BUTTON_MINUS = 10;
|
||||
public static final int CLASSIC_BUTTON_HOME = 11;
|
||||
public static final int CLASSIC_BUTTON_UP = 12;
|
||||
public static final int CLASSIC_BUTTON_DOWN = 13;
|
||||
public static final int CLASSIC_BUTTON_LEFT = 14;
|
||||
public static final int CLASSIC_BUTTON_RIGHT = 15;
|
||||
public static final int CLASSIC_BUTTON_STICKL_UP = 16;
|
||||
public static final int CLASSIC_BUTTON_STICKL_DOWN = 17;
|
||||
public static final int CLASSIC_BUTTON_STICKL_LEFT = 18;
|
||||
public static final int CLASSIC_BUTTON_STICKL_RIGHT = 19;
|
||||
public static final int CLASSIC_BUTTON_STICKR_UP = 20;
|
||||
public static final int CLASSIC_BUTTON_STICKR_DOWN = 21;
|
||||
public static final int CLASSIC_BUTTON_STICKR_LEFT = 22;
|
||||
public static final int CLASSIC_BUTTON_STICKR_RIGHT = 23;
|
||||
public static final int CLASSIC_BUTTON_MAX = 24;
|
||||
|
||||
static final int WIIMOTE_BUTTON_NONE = 0;
|
||||
static final int WIIMOTE_BUTTON_A = 1;
|
||||
static final int WIIMOTE_BUTTON_B = 2;
|
||||
static final int WIIMOTE_BUTTON_1 = 3;
|
||||
static final int WIIMOTE_BUTTON_2 = 4;
|
||||
static final int WIIMOTE_BUTTON_NUNCHUCK_Z = 5;
|
||||
static final int WIIMOTE_BUTTON_NUNCHUCK_C = 6;
|
||||
static final int WIIMOTE_BUTTON_PLUS = 7;
|
||||
static final int WIIMOTE_BUTTON_MINUS = 8;
|
||||
static final int WIIMOTE_BUTTON_UP = 9;
|
||||
static final int WIIMOTE_BUTTON_DOWN = 10;
|
||||
static final int WIIMOTE_BUTTON_LEFT = 11;
|
||||
static final int WIIMOTE_BUTTON_RIGHT = 12;
|
||||
static final int WIIMOTE_BUTTON_NUNCHUCK_UP = 13;
|
||||
static final int WIIMOTE_BUTTON_NUNCHUCK_DOWN = 14;
|
||||
static final int WIIMOTE_BUTTON_NUNCHUCK_LEFT = 15;
|
||||
static final int WIIMOTE_BUTTON_NUNCHUCK_RIGHT = 16;
|
||||
static final int WIIMOTE_BUTTON_HOME = 17;
|
||||
static final int WIIMOTE_BUTTON_MAX = 18;
|
||||
public static final int WIIMOTE_BUTTON_NONE = 0;
|
||||
public static final int WIIMOTE_BUTTON_A = 1;
|
||||
public static final int WIIMOTE_BUTTON_B = 2;
|
||||
public static final int WIIMOTE_BUTTON_1 = 3;
|
||||
public static final int WIIMOTE_BUTTON_2 = 4;
|
||||
public static final int WIIMOTE_BUTTON_NUNCHUCK_Z = 5;
|
||||
public static final int WIIMOTE_BUTTON_NUNCHUCK_C = 6;
|
||||
public static final int WIIMOTE_BUTTON_PLUS = 7;
|
||||
public static final int WIIMOTE_BUTTON_MINUS = 8;
|
||||
public static final int WIIMOTE_BUTTON_UP = 9;
|
||||
public static final int WIIMOTE_BUTTON_DOWN = 10;
|
||||
public static final int WIIMOTE_BUTTON_LEFT = 11;
|
||||
public static final int WIIMOTE_BUTTON_RIGHT = 12;
|
||||
public static final int WIIMOTE_BUTTON_NUNCHUCK_UP = 13;
|
||||
public static final int WIIMOTE_BUTTON_NUNCHUCK_DOWN = 14;
|
||||
public static final int WIIMOTE_BUTTON_NUNCHUCK_LEFT = 15;
|
||||
public static final int WIIMOTE_BUTTON_NUNCHUCK_RIGHT = 16;
|
||||
public static final int WIIMOTE_BUTTON_HOME = 17;
|
||||
public static final int WIIMOTE_BUTTON_MAX = 18;
|
||||
|
||||
static final int EMULATED_CONTROLLER_TYPE_VPAD = 0;
|
||||
static final int EMULATED_CONTROLLER_TYPE_PRO = 1;
|
||||
static final int EMULATED_CONTROLLER_TYPE_CLASSIC = 2;
|
||||
static final int EMULATED_CONTROLLER_TYPE_WIIMOTE = 3;
|
||||
static final int EMULATED_CONTROLLER_TYPE_DISABLED = -1;
|
||||
public static final int EMULATED_CONTROLLER_TYPE_VPAD = 0;
|
||||
public static final int EMULATED_CONTROLLER_TYPE_PRO = 1;
|
||||
public static final int EMULATED_CONTROLLER_TYPE_CLASSIC = 2;
|
||||
public static final int EMULATED_CONTROLLER_TYPE_WIIMOTE = 3;
|
||||
public static final int EMULATED_CONTROLLER_TYPE_DISABLED = -1;
|
||||
|
||||
static final int DPAD_UP = 34;
|
||||
static final int DPAD_DOWN = 35;
|
||||
static final int DPAD_LEFT = 36;
|
||||
static final int DPAD_RIGHT = 37;
|
||||
static final int AXIS_X_POS = 38;
|
||||
static final int AXIS_Y_POS = 39;
|
||||
static final int ROTATION_X_POS = 40;
|
||||
static final int ROTATION_Y_POS = 41;
|
||||
static final int TRIGGER_X_POS = 42;
|
||||
static final int TRIGGER_Y_POS = 43;
|
||||
static final int AXIS_X_NEG = 44;
|
||||
static final int AXIS_Y_NEG = 45;
|
||||
static final int ROTATION_X_NEG = 46;
|
||||
static final int ROTATION_Y_NEG = 47;
|
||||
public static final int DPAD_UP = 34;
|
||||
public static final int DPAD_DOWN = 35;
|
||||
public static final int DPAD_LEFT = 36;
|
||||
public static final int DPAD_RIGHT = 37;
|
||||
public static final int AXIS_X_POS = 38;
|
||||
public static final int AXIS_Y_POS = 39;
|
||||
public static final int ROTATION_X_POS = 40;
|
||||
public static final int ROTATION_Y_POS = 41;
|
||||
public static final int TRIGGER_X_POS = 42;
|
||||
public static final int TRIGGER_Y_POS = 43;
|
||||
public static final int AXIS_X_NEG = 44;
|
||||
public static final int AXIS_Y_NEG = 45;
|
||||
public static final int ROTATION_X_NEG = 46;
|
||||
public static final int ROTATION_Y_NEG = 47;
|
||||
|
||||
static final int MAX_CONTROLLERS = 8;
|
||||
static final int MAX_VPAD_CONTROLLERS = 2;
|
||||
static final int MAX_WPAD_CONTROLLERS = 7;
|
||||
|
||||
public static int controllerTypeToResourceNameId(int type) {
|
||||
return switch (type) {
|
||||
case EMULATED_CONTROLLER_TYPE_DISABLED -> R.string.disabled;
|
||||
case EMULATED_CONTROLLER_TYPE_VPAD -> R.string.vpad_controller;
|
||||
case EMULATED_CONTROLLER_TYPE_PRO -> R.string.pro_controller;
|
||||
case EMULATED_CONTROLLER_TYPE_WIIMOTE -> R.string.wiimote_controller;
|
||||
case EMULATED_CONTROLLER_TYPE_CLASSIC -> R.string.classic_controller;
|
||||
default -> throw new RuntimeException("Invalid controller type: " + type);
|
||||
};
|
||||
}
|
||||
public static final int MAX_CONTROLLERS = 8;
|
||||
public static final int MAX_VPAD_CONTROLLERS = 2;
|
||||
public static final int MAX_WPAD_CONTROLLERS = 7;
|
||||
|
||||
public static native void setControllerType(int index, int emulatedControllerType);
|
||||
|
||||
@@ -238,18 +210,9 @@ public class NativeLibrary {
|
||||
|
||||
public static native void setAsyncShaderCompile(boolean enabled);
|
||||
|
||||
static final int VSYNC_MODE_OFF = 0;
|
||||
static final int VSYNC_MODE_DOUBLE_BUFFERING = 1;
|
||||
static final int VSYNC_MODE_TRIPLE_BUFFERING = 2;
|
||||
|
||||
public static int vsyncModeToResourceNameId(int vsyncMode) {
|
||||
return switch (vsyncMode) {
|
||||
case VSYNC_MODE_OFF -> R.string.off;
|
||||
case VSYNC_MODE_DOUBLE_BUFFERING -> R.string.double_buffering;
|
||||
case VSYNC_MODE_TRIPLE_BUFFERING -> R.string.triple_buffering;
|
||||
default -> throw new RuntimeException("Invalid vsync mode: " + vsyncMode);
|
||||
};
|
||||
}
|
||||
public static final int VSYNC_MODE_OFF = 0;
|
||||
public static final int VSYNC_MODE_DOUBLE_BUFFERING = 1;
|
||||
public static final int VSYNC_MODE_TRIPLE_BUFFERING = 2;
|
||||
|
||||
public static native int getVSyncMode();
|
||||
|
||||
@@ -263,25 +226,16 @@ public class NativeLibrary {
|
||||
|
||||
public static native void setAudioDeviceEnabled(boolean enabled, boolean tv);
|
||||
|
||||
static final int AUDIO_CHANNELS_MONO = 0;
|
||||
static final int AUDIO_CHANNELS_STEREO = 1;
|
||||
static final int AUDIO_CHANNELS_SURROUND = 2;
|
||||
|
||||
public static int channelsToResourceNameId(int channels) {
|
||||
return switch (channels) {
|
||||
case AUDIO_CHANNELS_MONO -> R.string.mono;
|
||||
case AUDIO_CHANNELS_STEREO -> R.string.stereo;
|
||||
case AUDIO_CHANNELS_SURROUND -> R.string.surround;
|
||||
default -> throw new RuntimeException("Invalid channels type: " + channels);
|
||||
};
|
||||
}
|
||||
public static final int AUDIO_CHANNELS_MONO = 0;
|
||||
public static final int AUDIO_CHANNELS_STEREO = 1;
|
||||
public static final int AUDIO_CHANNELS_SURROUND = 2;
|
||||
|
||||
public static native void setAudioDeviceChannels(int channels, boolean tv);
|
||||
|
||||
public static native int getAudioDeviceChannels(boolean tv);
|
||||
|
||||
static final int AUDIO_MIN_VOLUME = 0;
|
||||
static final int AUDIO_MAX_VOLUME = 100;
|
||||
public static final int AUDIO_MIN_VOLUME = 0;
|
||||
public static final int AUDIO_MAX_VOLUME = 100;
|
||||
|
||||
public static native void setAudioDeviceVolume(int volume, boolean tv);
|
||||
|
||||
@@ -325,7 +279,7 @@ public class NativeLibrary {
|
||||
|
||||
public void setActivePreset(String activePreset) {
|
||||
if (presets.stream().noneMatch(s -> s.equals(activePreset)))
|
||||
throw new RuntimeException("Trying to set an invalid preset: " + activePreset);
|
||||
throw new IllegalArgumentException ("Trying to set an invalid preset: " + activePreset);
|
||||
setGraphicPackActivePreset(graphicPackId, category, activePreset);
|
||||
this.activePreset = activePreset;
|
||||
}
|
||||
@@ -382,27 +336,13 @@ public class NativeLibrary {
|
||||
|
||||
public static native void onOverlayAxis(int controllerIndex, int mappingId, float value);
|
||||
|
||||
static final int OVERLAY_SCREEN_POSITION_DISABLED = 0;
|
||||
static final int OVERLAY_SCREEN_POSITION_TOP_LEFT = 1;
|
||||
static final int OVERLAY_SCREEN_POSITION_TOP_CENTER = 2;
|
||||
static final int OVERLAY_SCREEN_POSITION_TOP_RIGHT = 3;
|
||||
static final int OVERLAY_SCREEN_POSITION_BOTTOM_LEFT = 4;
|
||||
static final int OVERLAY_SCREEN_POSITION_BOTTOM_CENTER = 5;
|
||||
static final int OVERLAY_SCREEN_POSITION_BOTTOM_RIGHT = 6;
|
||||
|
||||
public static int overlayScreenPositionToResourceNameId(int overlayScreenPosition) {
|
||||
return switch (overlayScreenPosition) {
|
||||
case OVERLAY_SCREEN_POSITION_DISABLED -> R.string.overlay_position_disabled;
|
||||
case OVERLAY_SCREEN_POSITION_TOP_LEFT -> R.string.overlay_position_top_left;
|
||||
case OVERLAY_SCREEN_POSITION_TOP_CENTER -> R.string.overlay_position_top_center;
|
||||
case OVERLAY_SCREEN_POSITION_TOP_RIGHT -> R.string.overlay_position_top_right;
|
||||
case OVERLAY_SCREEN_POSITION_BOTTOM_LEFT -> R.string.overlay_position_bottom_left;
|
||||
case OVERLAY_SCREEN_POSITION_BOTTOM_CENTER -> R.string.overlay_position_bottom_center;
|
||||
case OVERLAY_SCREEN_POSITION_BOTTOM_RIGHT -> R.string.overlay_position_bottom_right;
|
||||
default ->
|
||||
throw new RuntimeException("Invalid overlay position: " + overlayScreenPosition);
|
||||
};
|
||||
}
|
||||
public static final int OVERLAY_SCREEN_POSITION_DISABLED = 0;
|
||||
public static final int OVERLAY_SCREEN_POSITION_TOP_LEFT = 1;
|
||||
public static final int OVERLAY_SCREEN_POSITION_TOP_CENTER = 2;
|
||||
public static final int OVERLAY_SCREEN_POSITION_TOP_RIGHT = 3;
|
||||
public static final int OVERLAY_SCREEN_POSITION_BOTTOM_LEFT = 4;
|
||||
public static final int OVERLAY_SCREEN_POSITION_BOTTOM_CENTER = 5;
|
||||
public static final int OVERLAY_SCREEN_POSITION_BOTTOM_RIGHT = 6;
|
||||
|
||||
public static native int getOverlayPosition();
|
||||
|
||||
|
||||
+8
-10
@@ -1,21 +1,19 @@
|
||||
package info.cemu.Cemu;
|
||||
package info.cemu.Cemu.emulation;
|
||||
|
||||
import androidx.appcompat.app.AlertDialog;
|
||||
import androidx.appcompat.app.AppCompatActivity;
|
||||
import androidx.core.view.WindowCompat;
|
||||
import androidx.core.view.WindowInsetsAnimationCompat;
|
||||
import androidx.core.view.WindowInsetsCompat;
|
||||
import androidx.core.view.WindowInsetsControllerCompat;
|
||||
|
||||
import android.content.DialogInterface;
|
||||
import android.os.Bundle;
|
||||
import android.view.KeyEvent;
|
||||
import android.view.MotionEvent;
|
||||
|
||||
import androidx.appcompat.app.AppCompatActivity;
|
||||
import androidx.core.view.WindowCompat;
|
||||
import androidx.core.view.WindowInsetsCompat;
|
||||
import androidx.core.view.WindowInsetsControllerCompat;
|
||||
|
||||
import com.google.android.material.dialog.MaterialAlertDialogBuilder;
|
||||
|
||||
import info.cemu.Cemu.R;
|
||||
import info.cemu.Cemu.databinding.ActivityEmulationBinding;
|
||||
import info.cemu.Cemu.databinding.ActivityMainBinding;
|
||||
import info.cemu.Cemu.input.InputManager;
|
||||
|
||||
public class EmulationActivity extends AppCompatActivity {
|
||||
|
||||
+16
-6
@@ -1,4 +1,4 @@
|
||||
package info.cemu.Cemu;
|
||||
package info.cemu.Cemu.emulation;
|
||||
|
||||
import android.content.Context;
|
||||
import android.os.Bundle;
|
||||
@@ -10,9 +10,14 @@ import android.view.ViewGroup;
|
||||
import android.widget.Toast;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.fragment.app.Fragment;
|
||||
|
||||
import info.cemu.Cemu.R;
|
||||
import info.cemu.Cemu.databinding.FragmentEmulationBinding;
|
||||
import info.cemu.Cemu.inputoverlay.InputOverlaySettingsProvider;
|
||||
import info.cemu.Cemu.inputoverlay.InputOverlaySurfaceView;
|
||||
import info.cemu.Cemu.NativeLibrary;
|
||||
|
||||
public class EmulationFragment extends Fragment implements SurfaceHolder.Callback {
|
||||
private final long gameTitleId;
|
||||
@@ -24,14 +29,19 @@ public class EmulationFragment extends Fragment implements SurfaceHolder.Callbac
|
||||
this.gameTitleId = gameTitleId;
|
||||
}
|
||||
|
||||
InputOverlaySettingsProvider.OverlaySettings overlaySettings;
|
||||
|
||||
@Override
|
||||
public void onCreate(@Nullable Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
var inputOverlaySettingsProvider = new InputOverlaySettingsProvider(requireContext());
|
||||
overlaySettings = inputOverlaySettingsProvider.getOverlaySettings();
|
||||
}
|
||||
|
||||
@Override
|
||||
public View onCreateView(@NonNull LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
|
||||
FragmentEmulationBinding binding = FragmentEmulationBinding.inflate(inflater, container, false);
|
||||
var context = requireContext();
|
||||
var sharedPref = context.getSharedPreferences(
|
||||
context.getString(R.string.inputoverlaysettings_shared_preferences_name), Context.MODE_PRIVATE);
|
||||
var inputOverlaySettingsProvider = new InputOverlaySettingsProvider(sharedPref);
|
||||
var overlaySettings = inputOverlaySettingsProvider.getOverlaySettings();
|
||||
|
||||
InputOverlaySurfaceView surfaceView = binding.inputOverlay;
|
||||
binding.inputModeButton.setOnClickListener(v -> {
|
||||
InputOverlaySurfaceView.InputMode nextMode = InputOverlaySurfaceView.InputMode.DEFAULT;
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
package info.cemu.Cemu;
|
||||
package info.cemu.Cemu.gameview;
|
||||
|
||||
import android.graphics.Bitmap;
|
||||
|
||||
+3
-1
@@ -1,4 +1,4 @@
|
||||
package info.cemu.Cemu;
|
||||
package info.cemu.Cemu.gameview;
|
||||
|
||||
import android.graphics.Bitmap;
|
||||
import android.view.LayoutInflater;
|
||||
@@ -18,6 +18,8 @@ import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import info.cemu.Cemu.R;
|
||||
|
||||
public class GameAdapter extends RecyclerView.Adapter<GameAdapter.ViewHolder> implements Filterable {
|
||||
private final Map<Long, Game> gameInfoMap;
|
||||
private final List<Long> gameTitleIds;
|
||||
+11
-8
@@ -1,8 +1,6 @@
|
||||
package info.cemu.Cemu;
|
||||
package info.cemu.Cemu.gameview;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.SharedPreferences;
|
||||
import android.graphics.Bitmap;
|
||||
import android.os.Bundle;
|
||||
import android.text.Editable;
|
||||
@@ -17,23 +15,28 @@ import androidx.fragment.app.Fragment;
|
||||
import androidx.recyclerview.widget.LinearLayoutManager;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
|
||||
import info.cemu.Cemu.R;
|
||||
import info.cemu.Cemu.databinding.FragmentGamesBinding;
|
||||
import info.cemu.Cemu.emulation.EmulationActivity;
|
||||
import info.cemu.Cemu.NativeLibrary;
|
||||
import info.cemu.Cemu.settings.SettingsActivity;
|
||||
import info.cemu.Cemu.settings.SettingsManager;
|
||||
|
||||
public class GamesFragment extends Fragment {
|
||||
FragmentGamesBinding binding;
|
||||
GameAdapter gameAdapter;
|
||||
private FragmentGamesBinding binding;
|
||||
private GameAdapter gameAdapter;
|
||||
private SettingsManager settingsManager;
|
||||
|
||||
@Override
|
||||
public void onCreate(@Nullable Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
settingsManager = new SettingsManager(requireContext());
|
||||
}
|
||||
|
||||
@Override
|
||||
public View onCreateView(@NonNull LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
|
||||
binding = FragmentGamesBinding.inflate(inflater, container, false);
|
||||
|
||||
SharedPreferences cemuPreferences = requireActivity().getSharedPreferences(CemuPreferences.PREFERENCES_NAME, Context.MODE_PRIVATE);
|
||||
String gamesPath = cemuPreferences.getString(CemuPreferences.GAMES_PATH_KEY, null);
|
||||
String gamesPath = settingsManager.getGamesPath();
|
||||
if (gamesPath != null)
|
||||
NativeLibrary.addGamePath(gamesPath);
|
||||
RecyclerView recyclerView = binding.gamesRecyclerView;
|
||||
+2
-5
@@ -1,4 +1,4 @@
|
||||
package info.cemu.Cemu;
|
||||
package info.cemu.Cemu.guibasecomponents;
|
||||
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
@@ -7,10 +7,7 @@ import android.widget.BaseAdapter;
|
||||
|
||||
import com.google.android.material.radiobutton.MaterialRadioButton;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.OptionalInt;
|
||||
import java.util.stream.IntStream;
|
||||
import info.cemu.Cemu.R;
|
||||
|
||||
public abstract class BaseSelectionAdapter<T> extends BaseAdapter {
|
||||
|
||||
+3
-1
@@ -1,4 +1,4 @@
|
||||
package info.cemu.Cemu;
|
||||
package info.cemu.Cemu.guibasecomponents;
|
||||
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
@@ -9,6 +9,8 @@ import androidx.recyclerview.widget.RecyclerView;
|
||||
|
||||
import com.google.android.material.dialog.MaterialAlertDialogBuilder;
|
||||
|
||||
import info.cemu.Cemu.R;
|
||||
|
||||
public abstract class BaseSingleSelectionRecyclerViewItem<T> implements RecyclerViewItem {
|
||||
private static class SingleSelectionViewHolder extends RecyclerView.ViewHolder {
|
||||
TextView label;
|
||||
+3
-1
@@ -1,4 +1,4 @@
|
||||
package info.cemu.Cemu;
|
||||
package info.cemu.Cemu.guibasecomponents;
|
||||
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
@@ -7,6 +7,8 @@ import android.widget.TextView;
|
||||
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
|
||||
import info.cemu.Cemu.R;
|
||||
|
||||
public class ButtonRecyclerViewItem implements RecyclerViewItem {
|
||||
public interface OnButtonClickListener {
|
||||
void onButtonClick();
|
||||
+3
-1
@@ -1,4 +1,4 @@
|
||||
package info.cemu.Cemu;
|
||||
package info.cemu.Cemu.guibasecomponents;
|
||||
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
@@ -9,6 +9,8 @@ import androidx.recyclerview.widget.RecyclerView;
|
||||
|
||||
import com.google.android.material.checkbox.MaterialCheckBox;
|
||||
|
||||
import info.cemu.Cemu.R;
|
||||
|
||||
public class CheckboxRecyclerViewItem implements RecyclerViewItem {
|
||||
public interface OnCheckedChangeListener {
|
||||
void onCheckChanged(boolean checked);
|
||||
+1
-2
@@ -1,4 +1,4 @@
|
||||
package info.cemu.Cemu;
|
||||
package info.cemu.Cemu.guibasecomponents;
|
||||
|
||||
import android.view.ViewGroup;
|
||||
|
||||
@@ -7,7 +7,6 @@ import androidx.recyclerview.widget.RecyclerView;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.function.Predicate;
|
||||
|
||||
public class GenericRecyclerViewAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> {
|
||||
|
||||
+3
-1
@@ -1,4 +1,4 @@
|
||||
package info.cemu.Cemu;
|
||||
package info.cemu.Cemu.guibasecomponents;
|
||||
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
@@ -7,6 +7,8 @@ import android.widget.TextView;
|
||||
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
|
||||
import info.cemu.Cemu.R;
|
||||
|
||||
public class HeaderRecyclerViewItem implements RecyclerViewItem {
|
||||
|
||||
private static class HeaderViewHolder extends RecyclerView.ViewHolder {
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
package info.cemu.Cemu;
|
||||
package info.cemu.Cemu.guibasecomponents;
|
||||
|
||||
import android.view.ViewGroup;
|
||||
|
||||
+2
-9
@@ -1,20 +1,13 @@
|
||||
package info.cemu.Cemu;
|
||||
package info.cemu.Cemu.guibasecomponents;
|
||||
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.BaseAdapter;
|
||||
import android.widget.TextView;
|
||||
|
||||
import androidx.annotation.StringRes;
|
||||
|
||||
import com.google.android.material.radiobutton.MaterialRadioButton;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.OptionalInt;
|
||||
import java.util.function.Consumer;
|
||||
import java.util.function.Function;
|
||||
import java.util.stream.IntStream;
|
||||
|
||||
public class SelectionAdapter<T> extends BaseSelectionAdapter<T> {
|
||||
@@ -49,7 +42,7 @@ public class SelectionAdapter<T> extends BaseSelectionAdapter<T> {
|
||||
public int getPositionOf(T value) {
|
||||
OptionalInt optionalInt = IntStream.range(0, choiceItems.size()).filter(position -> choiceItems.get(position).choiceValue.equals(value)).findFirst();
|
||||
if (!optionalInt.isPresent())
|
||||
throw new RuntimeException("value " + value + " was not found in the list of choiceItems");
|
||||
throw new IllegalArgumentException("value " + value + " was not found in the list of choiceItems");
|
||||
return optionalInt.getAsInt();
|
||||
}
|
||||
|
||||
+3
-1
@@ -1,4 +1,4 @@
|
||||
package info.cemu.Cemu;
|
||||
package info.cemu.Cemu.guibasecomponents;
|
||||
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
@@ -7,6 +7,8 @@ import android.widget.TextView;
|
||||
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
|
||||
import info.cemu.Cemu.R;
|
||||
|
||||
public class SimpleButtonRecyclerViewItem implements RecyclerViewItem {
|
||||
public interface OnButtonClickListener {
|
||||
void onButtonClick();
|
||||
+3
-1
@@ -1,4 +1,4 @@
|
||||
package info.cemu.Cemu;
|
||||
package info.cemu.Cemu.guibasecomponents;
|
||||
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
@@ -10,6 +10,8 @@ import androidx.recyclerview.widget.RecyclerView;
|
||||
|
||||
import com.google.android.material.dialog.MaterialAlertDialogBuilder;
|
||||
|
||||
import info.cemu.Cemu.R;
|
||||
|
||||
public class SingleSelectionRecyclerViewItem<T> implements RecyclerViewItem {
|
||||
private static class SingleSelectionViewHolder extends RecyclerView.ViewHolder {
|
||||
TextView label;
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user