From b1d8db2c96ed457437464c0ade3f67f8cf2d30fa Mon Sep 17 00:00:00 2001 From: zilmar Date: Thu, 9 Feb 2017 06:08:06 +1100 Subject: [PATCH] [[Glide64] Add ability to set screen resolution --- Android/jni/Glide64/Glide64.mk | 1 + Android/res/values/strings.xml | 4 +- Android/res/xml/setting_video.xml | 6 + Android/src/emu/project64/AndroidDevice.java | 77 +++++++++---- .../src/emu/project64/GalleryActivity.java | 2 +- .../project64/game/GameLifecycleHandler.java | 105 +++++++++++------- .../emu/project64/jni/LanguageStringID.java | 3 + .../src/emu/project64/jni/NativeVideo.java | 31 ++++++ .../src/emu/project64/jni/VideoSettingID.java | 63 +++++++++++ .../settings/GamepadScreenFragment.java | 22 ---- .../project64/settings/SettingsActivity.java | 3 + ...nesListPreferenceDialogFragmentCompat.java | 52 ++++----- .../emu/project64/settings/VideoFragment.java | 43 ++++++- Source/Glide64/Android.cpp | 37 ++++++ Source/Glide64/Glide64.vcxproj | 1 + Source/Glide64/Glide64.vcxproj.filters | 1 + Source/Glide64/Main.cpp | 28 ++--- Source/Glide64/ScreenResolution.cpp | 16 +++ Source/Glide64/Settings.cpp | 47 +++++--- Source/Glide64/Settings.h | 8 +- Source/Project64-core/Multilanguage.h | 3 + .../Multilanguage/LanguageClass.cpp | 3 + changes.txt | 2 + 23 files changed, 409 insertions(+), 149 deletions(-) create mode 100644 Android/src/emu/project64/jni/NativeVideo.java create mode 100644 Android/src/emu/project64/jni/VideoSettingID.java create mode 100644 Source/Glide64/Android.cpp create mode 100644 changes.txt diff --git a/Android/jni/Glide64/Glide64.mk b/Android/jni/Glide64/Glide64.mk index 16a1951a6..b99467c58 100644 --- a/Android/jni/Glide64/Glide64.mk +++ b/Android/jni/Glide64/Glide64.mk @@ -22,6 +22,7 @@ LOCAL_SRC_FILES := \ $(SRCDIR)/Glitch64/OGLEStextures.cpp \ $(SRCDIR)/Glitch64/OGLESwrappers.cpp \ $(SRCDIR)/Glide64/3dmath.cpp \ + $(SRCDIR)/Glide64/Android.cpp \ $(SRCDIR)/Glide64/Combine.cpp \ $(SRCDIR)/Glide64/Config.cpp \ $(SRCDIR)/Glide64/CRC.cpp \ diff --git a/Android/res/values/strings.xml b/Android/res/values/strings.xml index 024a939dd..3d3c5fa18 100644 --- a/Android/res/values/strings.xml +++ b/Android/res/values/strings.xml @@ -100,9 +100,11 @@ Advanced CPU Usage Show the cpu used by different components - Display Speed Limit the max speed executed Limit FPS + Rendered Resolution + should show value??? + Display Speed Show the speed of the emulation Display Speed Display Display lists per second diff --git a/Android/res/xml/setting_video.xml b/Android/res/xml/setting_video.xml index 0c7ab6470..f8cf1cbba 100644 --- a/Android/res/xml/setting_video.xml +++ b/Android/res/xml/setting_video.xml @@ -1,6 +1,12 @@ + = Build.VERSION_CODES.GINGERBREAD; - + /** True if device is running Honeycomb or later (11 - Android 3.0.x) */ public static final boolean IS_HONEYCOMB = Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB; - + /** True if device is running Honeycomb MR1 or later (12 - Android 3.1.x) */ public static final boolean IS_HONEYCOMB_MR1 = Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB_MR1; - + /** True if device is running Ice Cream Sandwich or later (14 - Android 4.0.x) */ public static final boolean IS_ICE_CREAM_SANDWICH = Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH; - + /** True if device is running Jellybean or later (16 - Android 4.1.x) */ public static final boolean IS_JELLY_BEAN = Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN; - + /** True if device is running KitKat or later (19 - Android 4.4.x) */ public static final boolean IS_KITKAT = Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT; - + /** True if device is running Lollipop or later (21 - Android 5.0.x) */ public static final boolean IS_LOLLIPOP = Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP; /** True if device is an OUYA. */ public static final boolean IS_OUYA_HARDWARE = OuyaFacade.getInstance().isRunningOnOUYAHardware(); - + public final static String EXTERNAL_PUBLIC_DIRECTORY = Environment.getExternalStorageDirectory().getPath(); public final static String PACKAGE_DIRECTORY = EXTERNAL_PUBLIC_DIRECTORY + "/Android/data/" + AndroidDevice.class.getPackage().getName(); public static final boolean IS_ACTION_BAR_AVAILABLE = AndroidDevice.IS_HONEYCOMB && !AndroidDevice.IS_OUYA_HARDWARE; final static boolean isTv; - + public final static int nativeWidth, nativeWidthOriginal; + public final static int nativeHeight, nativeHeightOriginal; + public static boolean MapVolumeKeys = false; - - static + + static { isTv = Project64Application.getAppContext().getPackageManager().hasSystemFeature("android.software.leanback"); + DisplayMetrics metrics = Project64Application.getAppContext().getResources().getDisplayMetrics(); + int _nativeWidth = metrics.widthPixels < metrics.heightPixels ? metrics.heightPixels : metrics.widthPixels; + int _nativeHeight = metrics.widthPixels < metrics.heightPixels ? metrics.widthPixels: metrics.heightPixels; + + if (IS_KITKAT) + { + Point size = new Point(); + try + { + ((WindowManager) Project64Application.getAppContext().getSystemService(Project64Application.getAppContext().WINDOW_SERVICE)).getDefaultDisplay().getRealSize(size); + _nativeWidth = size.x < size.y ? size.y : size.x; + _nativeHeight = size.x < size.y ? size.x: size.y; + } + catch (NoSuchMethodError e) + { + } + } + nativeWidth = _nativeWidth; + nativeHeight = _nativeHeight; + + final float aspect = 0.75f; + final boolean isLetterboxed = ( (float) nativeHeight / (float) nativeWidth ) > aspect; + nativeWidthOriginal = isLetterboxed ? nativeWidth : Math.round( nativeHeight / aspect ); + nativeHeightOriginal = isLetterboxed ? Math.round( nativeWidth * aspect ) : nativeHeight; } - - public static boolean isAndroidTv() + + public static boolean isAndroidTv() { return isTv; } - + public static List getUnmappableKeyCodes () { List unmappables = new ArrayList(); @@ -89,8 +120,8 @@ public class AndroidDevice } return unmappables; } - - public static ArrayList getStorageDirectories() + + public static ArrayList getStorageDirectories() { BufferedReader bufReader = null; ArrayList list = new ArrayList(); @@ -99,7 +130,7 @@ public class AndroidDevice List typeWL = Arrays.asList("vfat", "exfat", "sdcardfs", "fuse", "ntfs", "fat32", "ext3", "ext4", "esdfs"); List typeBL = Arrays.asList("tmpfs"); String[] mountWL = {"/mnt", "/Removable", "/storage"}; - String[] mountBL = + String[] mountBL = { "/mnt/secure", "/mnt/shell", @@ -109,18 +140,18 @@ public class AndroidDevice "/mnt/media_rw/sdcard", "/storage/emulated" }; - String[] deviceWL = + String[] deviceWL = { "/dev/block/vold", "/dev/fuse", "/mnt/media_rw" }; - try + try { bufReader = new BufferedReader(new FileReader("/proc/mounts")); String line; - while ((line = bufReader.readLine()) != null) + while ((line = bufReader.readLine()) != null) { StringTokenizer tokens = new StringTokenizer(line, " "); String device = tokens.nextToken(); @@ -134,7 +165,7 @@ public class AndroidDevice } // check that device is in whitelist, and either type or mountpoint is in a whitelist - if (Strings.startsWith(deviceWL, device) && (typeWL.contains(type) || Strings.startsWith(mountWL, mountpoint))) + if (Strings.startsWith(deviceWL, device) && (typeWL.contains(type) || Strings.startsWith(mountWL, mountpoint))) { int position = Strings.containsName(list, FileUtil.getFileNameFromPath(mountpoint)); if (position > -1) @@ -145,13 +176,13 @@ public class AndroidDevice } } } - catch (FileNotFoundException e) + catch (FileNotFoundException e) { } - catch (IOException e) + catch (IOException e) { } - finally + finally { Utility.close(bufReader); } diff --git a/Android/src/emu/project64/GalleryActivity.java b/Android/src/emu/project64/GalleryActivity.java index 25e4dece2..5c5c73bde 100644 --- a/Android/src/emu/project64/GalleryActivity.java +++ b/Android/src/emu/project64/GalleryActivity.java @@ -843,7 +843,7 @@ public class GalleryActivity extends AppCompatActivity implements IabBroadcastLi { return false; } - + int RunCount = NativeExports.UISettingsLoadDword(UISettingID.SupportWindow_RunCount.getValue()); Log.d("GalleryActivity", "ShowSupportWindow RunCount = " + RunCount); if (RunCount == -1) diff --git a/Android/src/emu/project64/game/GameLifecycleHandler.java b/Android/src/emu/project64/game/GameLifecycleHandler.java index 21e755ba8..9a3a228b5 100644 --- a/Android/src/emu/project64/game/GameLifecycleHandler.java +++ b/Android/src/emu/project64/game/GameLifecycleHandler.java @@ -21,6 +21,7 @@ import java.util.ArrayList; import java.util.Set; import emu.project64.AndroidDevice; +import emu.project64.Project64Application; import emu.project64.R; import emu.project64.hack.MogaHack; import emu.project64.input.AbstractController; @@ -34,10 +35,12 @@ import emu.project64.input.provider.KeyProvider; import emu.project64.input.provider.KeyProvider.ImeFormula; import emu.project64.input.provider.MogaProvider; import emu.project64.jni.NativeExports; +import emu.project64.jni.NativeVideo; import emu.project64.jni.NativeXperiaTouchpad; import emu.project64.jni.SettingsID; import emu.project64.jni.SystemEvent; import emu.project64.jni.UISettingID; +import emu.project64.jni.VideoSettingID; import emu.project64.persistent.ConfigFile; import emu.project64.persistent.ConfigFile.ConfigSection; import emu.project64.profile.Profile; @@ -52,11 +55,15 @@ import android.graphics.drawable.ColorDrawable; import android.os.Bundle; import android.os.Vibrator; import android.util.Log; +import android.view.Display; +import android.view.Gravity; import android.view.KeyEvent; import android.view.SurfaceHolder; import android.view.View; import android.view.Window; +import android.view.WindowManager; import android.view.WindowManager.LayoutParams; +import android.widget.FrameLayout; public class GameLifecycleHandler implements View.OnKeyListener, SurfaceHolder.Callback, GameSurface.SurfaceInfo { @@ -92,7 +99,7 @@ public class GameLifecycleHandler implements View.OnKeyListener, SurfaceHolder.C mActivity = activity; mControllers = new ArrayList(); mIsXperiaPlay = !(activity instanceof GameActivity); - mMogaController = Controller.getInstance( mActivity ); + mMogaController = Controller.getInstance(mActivity); } @TargetApi(11) @@ -105,8 +112,7 @@ public class GameLifecycleHandler implements View.OnKeyListener, SurfaceHolder.C // Initialize MOGA controller API // TODO: Remove hack after MOGA SDK is fixed // mMogaController.init(); - MogaHack.init( mMogaController, mActivity ); - + MogaHack.init(mMogaController, mActivity); // For Honeycomb, let the action bar overlay the rendered view (rather // than squeezing it) @@ -140,19 +146,34 @@ public class GameLifecycleHandler implements View.OnKeyListener, SurfaceHolder.C // Lay out content and get the views mActivity.setContentView(R.layout.game_activity); - mSurface = (GameSurface) mActivity.findViewById( R.id.gameSurface ); + mSurface = (GameSurface) mActivity.findViewById(R.id.gameSurface); mOverlay = (GameOverlay) mActivity.findViewById(R.id.gameOverlay); + float widthRatio = (float)AndroidDevice.nativeWidth/(float)AndroidDevice.nativeWidthOriginal; + float heightRatio = (float)AndroidDevice.nativeHeight/(float)AndroidDevice.nativeHeightOriginal; + int ScreenRes = NativeExports.SettingsLoadDword(SettingsID.FirstGfxSettings.getValue() + VideoSettingID.Set_Resolution.getValue()); + + int videoRenderWidth = Math.round(NativeVideo.GetScreenResWidth(ScreenRes) * (ScreenRes == 0 ? 1 : widthRatio)); + int videoRenderHeight = Math.round(NativeVideo.GetScreenResHeight(ScreenRes) * (ScreenRes == 0 ? 1 : heightRatio)); + + // Update screen res + mSurface.getHolder().setFixedSize(videoRenderWidth, videoRenderHeight); + final FrameLayout.LayoutParams params = (FrameLayout.LayoutParams) mSurface.getLayoutParams(); + params.width = AndroidDevice.nativeWidth; + params.height = AndroidDevice.nativeHeight; + params.gravity = Gravity.CENTER_HORIZONTAL | Gravity.CENTER_VERTICAL; + mSurface.setLayoutParams(params); + // Listen to game surface events (created, changed, destroyed) - mSurface.getHolder().addCallback( this ); - mSurface.createGLContext((ActivityManager)mActivity.getSystemService(Context.ACTIVITY_SERVICE)); + mSurface.getHolder().addCallback(this); + mSurface.createGLContext((ActivityManager) mActivity.getSystemService(Context.ACTIVITY_SERVICE)); // Configure the action bar introduced in higher Android versions if (AndroidDevice.IS_ACTION_BAR_AVAILABLE) { mActivity.getActionBar().hide(); ColorDrawable color = new ColorDrawable(Color.parseColor("#303030")); - color.setAlpha(50 /*mGlobalPrefs.displayActionBarTransparency*/); + color.setAlpha(50 /* mGlobalPrefs.displayActionBarTransparency */); mActivity.getActionBar().setBackgroundDrawable(color); } @@ -162,8 +183,9 @@ public class GameLifecycleHandler implements View.OnKeyListener, SurfaceHolder.C View inputSource = mIsXperiaPlay ? new NativeXperiaTouchpad(mActivity) : mOverlay; initControllers(inputSource); - // Override the peripheral controllers' key provider, to add some extra functionality - inputSource.setOnKeyListener( this ); + // Override the peripheral controllers' key provider, to add some extra + // functionality + inputSource.setOnKeyListener(this); } public void onStart() @@ -235,7 +257,7 @@ public class GameLifecycleHandler implements View.OnKeyListener, SurfaceHolder.C { pause = true; PauseType = NativeExports.SettingsLoadDword(SettingsID.GameRunning_CPU_PausedType.getValue()); - NativeExports.ExternalEvent( SystemEvent.SysEvent_ResumeCPU_FromMenu.getValue()); + NativeExports.ExternalEvent(SystemEvent.SysEvent_ResumeCPU_FromMenu.getValue()); } int CurrentSaveState = NativeExports.SettingsLoadDword(SettingsID.Game_CurrentSaveState.getValue()); int OriginalSaveTime = NativeExports.SettingsLoadDword(SettingsID.Game_LastSaveTime.getValue()); @@ -256,7 +278,7 @@ public class GameLifecycleHandler implements View.OnKeyListener, SurfaceHolder.C { Thread.sleep(100); } - catch(InterruptedException ex) + catch (InterruptedException ex) { Thread.currentThread().interrupt(); } @@ -264,7 +286,7 @@ public class GameLifecycleHandler implements View.OnKeyListener, SurfaceHolder.C NativeExports.SettingsSaveDword(SettingsID.Game_CurrentSaveState.getValue(), CurrentSaveState); if (pause) { - NativeExports.ExternalEvent( SystemEvent.SysEvent_PauseCPU_FromMenu.getValue()); + NativeExports.ExternalEvent(SystemEvent.SysEvent_PauseCPU_FromMenu.getValue()); NativeExports.SettingsSaveDword(SettingsID.GameRunning_CPU_PausedType.getValue(), PauseType); } } @@ -324,9 +346,9 @@ public class GameLifecycleHandler implements View.OnKeyListener, SurfaceHolder.C mMogaController.exit(); } - public void onSettingDone () + public void onSettingDone() { - mtouchscreenScale = ((float)NativeExports.UISettingsLoadDword(UISettingID.TouchScreen_ButtonScale.getValue())) / 100.0f; + mtouchscreenScale = ((float) NativeExports.UISettingsLoadDword(UISettingID.TouchScreen_ButtonScale.getValue())) / 100.0f; mlayout = NativeExports.UISettingsLoadString(UISettingID.TouchScreen_Layout.getValue()); mControllers = new ArrayList(); CreateTouchScreenControls(); @@ -339,37 +361,40 @@ public class GameLifecycleHandler implements View.OnKeyListener, SurfaceHolder.C private void CreateTouchScreenControls() { - boolean isTouchscreenAnimated = false; //mGlobalPrefs.isTouchscreenAnimated - boolean isTouchscreenHidden = false; //!isTouchscreenEnabled || globalPrefs.touchscreenTransparency == 0; + boolean isTouchscreenAnimated = false; // mGlobalPrefs.isTouchscreenAnimated + boolean isTouchscreenHidden = false; // !isTouchscreenEnabled || + // globalPrefs.touchscreenTransparency + // == 0; String profilesDir = AndroidDevice.PACKAGE_DIRECTORY + "/profiles"; String touchscreenProfiles_cfg = profilesDir + "/touchscreen.cfg"; - ConfigFile touchscreenConfigFile = new ConfigFile( touchscreenProfiles_cfg ); + ConfigFile touchscreenConfigFile = new ConfigFile(touchscreenProfiles_cfg); ConfigSection section = touchscreenConfigFile.get(mlayout); if (section == null) { mlayout = "Analog"; section = touchscreenConfigFile.get(mlayout); } - Profile touchscreenProfile = new Profile( true, section); + Profile touchscreenProfile = new Profile(true, section); int touchscreenTransparency = 100; String touchscreenSkinsDir = AndroidDevice.PACKAGE_DIRECTORY + "/skins/touchscreen"; String touchscreenSkin = touchscreenSkinsDir + "/Outline"; - // The touch map and overlay are needed to display frame rate and/or controls - mTouchscreenMap = new VisibleTouchMap( mActivity.getResources() ); - mTouchscreenMap.load(touchscreenSkin, touchscreenProfile, isTouchscreenAnimated, mtouchscreenScale, touchscreenTransparency ); - mOverlay.initialize( mTouchscreenMap, !isTouchscreenHidden, isTouchscreenAnimated ); - } + // The touch map and overlay are needed to display frame rate and/or + // controls + mTouchscreenMap = new VisibleTouchMap(mActivity.getResources()); + mTouchscreenMap.load(touchscreenSkin, touchscreenProfile, isTouchscreenAnimated, mtouchscreenScale, touchscreenTransparency); + mOverlay.initialize(mTouchscreenMap, !isTouchscreenHidden, isTouchscreenAnimated); + } @Override - public boolean onKey( View view, int keyCode, KeyEvent event ) + public boolean onKey(View view, int keyCode, KeyEvent event) { // If PeripheralControllers exist and handle the event, // they return true. Else they return false, signaling // Android to handle the event (menu button, vol keys). - if( mKeyProvider != null ) + if (mKeyProvider != null) { - return mKeyProvider.onKey( view, keyCode, event ); + return mKeyProvider.onKey(view, keyCode, event); } return false; } @@ -378,32 +403,32 @@ public class GameLifecycleHandler implements View.OnKeyListener, SurfaceHolder.C private void initControllers(View inputSource) { // By default, send Player 1 rumbles through phone vibrator - Vibrator vibrator = (Vibrator) mActivity.getSystemService( Context.VIBRATOR_SERVICE ); + Vibrator vibrator = (Vibrator) mActivity.getSystemService(Context.VIBRATOR_SERVICE); int touchscreenAutoHold = 0; boolean isTouchscreenFeedbackEnabled = false; Set autoHoldableButtons = null; // Create the touchscreen controller - TouchController touchscreenController = new TouchController( mTouchscreenMap, - inputSource, mOverlay, vibrator, touchscreenAutoHold, - isTouchscreenFeedbackEnabled, autoHoldableButtons ); - mControllers.add( touchscreenController ); + TouchController touchscreenController = new TouchController(mTouchscreenMap, inputSource, mOverlay, vibrator, + touchscreenAutoHold, isTouchscreenFeedbackEnabled, autoHoldableButtons); + mControllers.add(touchscreenController); // Create the input providers shared among all peripheral controllers String profile_name = NativeExports.UISettingsLoadString(UISettingID.Controller_CurrentProfile.getValue()); - ConfigFile ControllerConfigFile = new ConfigFile(NativeExports.UISettingsLoadString(UISettingID.Controller_ConfigFile.getValue())); - ConfigSection section = ControllerConfigFile.get( profile_name ); + ConfigFile ControllerConfigFile = new ConfigFile( + NativeExports.UISettingsLoadString(UISettingID.Controller_ConfigFile.getValue())); + ConfigSection section = ControllerConfigFile.get(profile_name); if (section != null) { - Profile ControllerProfile = new Profile( false, section ); - InputMap map = new InputMap( ControllerProfile.get( "map" ) ); + Profile ControllerProfile = new Profile(false, section); + InputMap map = new InputMap(ControllerProfile.get("map")); - mKeyProvider = new KeyProvider( inputSource, ImeFormula.DEFAULT, AndroidDevice.getUnmappableKeyCodes() ); - MogaProvider mogaProvider = new MogaProvider( mMogaController ); - AbstractProvider axisProvider = AndroidDevice.IS_HONEYCOMB_MR1 ? new AxisProvider( inputSource ) : null; + mKeyProvider = new KeyProvider(inputSource, ImeFormula.DEFAULT, AndroidDevice.getUnmappableKeyCodes()); + MogaProvider mogaProvider = new MogaProvider(mMogaController); + AbstractProvider axisProvider = AndroidDevice.IS_HONEYCOMB_MR1 ? new AxisProvider(inputSource) : null; int Deadzone = NativeExports.UISettingsLoadDword(UISettingID.Controller_Deadzone.getValue()); int Sensitivity = NativeExports.UISettingsLoadDword(UISettingID.Controller_Sensitivity.getValue()); - mControllers.add( new PeripheralController( 1, map, Deadzone, Sensitivity, mKeyProvider, axisProvider, mogaProvider ) ); + mControllers.add(new PeripheralController(1, map, Deadzone, Sensitivity, mKeyProvider, axisProvider, mogaProvider)); } } @@ -442,4 +467,4 @@ public class GameLifecycleHandler implements View.OnKeyListener, SurfaceHolder.C } NativeExports.onSurfaceChanged(width, height); } -} +} \ No newline at end of file diff --git a/Android/src/emu/project64/jni/LanguageStringID.java b/Android/src/emu/project64/jni/LanguageStringID.java index e3be953eb..40354211b 100644 --- a/Android/src/emu/project64/jni/LanguageStringID.java +++ b/Android/src/emu/project64/jni/LanguageStringID.java @@ -589,6 +589,9 @@ public enum LanguageStringID ANDROID_MENU_DEBUGGINGOPTIONS(3111), ANDROID_MENU_RESETFUNCTIONTIMES(3112), ANDROID_MENU_DUMPFUNCTIONTIMES(3113), + + //Video plugin + ANDROID_VIDEO_NATIVE_RES(3200), ; private int value; diff --git a/Android/src/emu/project64/jni/NativeVideo.java b/Android/src/emu/project64/jni/NativeVideo.java new file mode 100644 index 000000000..39432d44a --- /dev/null +++ b/Android/src/emu/project64/jni/NativeVideo.java @@ -0,0 +1,31 @@ +/**************************************************************************** +* * +* Project 64 - A Nintendo 64 emulator. * +* http://www.pj64-emu.com/ * +* Copyright (C) 2012 Project64. All rights reserved. * +* * +* License: * +* GNU/GPLv2 http://www.gnu.org/licenses/gpl-2.0.html * +* * +****************************************************************************/ +package emu.project64.jni; + +/** + * Calls made between the native input-android library and Java. Any function names changed here + * should also be changed in the corresponding C code, and vice versa. + * + * @see /Source/Android/PluginInput/Main.cpp + * @see CoreInterface + */ +public class NativeVideo +{ + static + { + System.loadLibrary( "Project64-gfx-glide64" ); + } + + public static native int getResolutionCount(); + public static native String getResolutionName(int Index); + public static native int GetScreenResWidth(int Index); + public static native int GetScreenResHeight(int Index); +} diff --git a/Android/src/emu/project64/jni/VideoSettingID.java b/Android/src/emu/project64/jni/VideoSettingID.java new file mode 100644 index 000000000..71d505ea6 --- /dev/null +++ b/Android/src/emu/project64/jni/VideoSettingID.java @@ -0,0 +1,63 @@ +/**************************************************************************** +* * +* Project 64 - A Nintendo 64 emulator. * +* http://www.pj64-emu.com/ * +* Copyright (C) 2012 Project64. All rights reserved. * +* * +* License: * +* GNU/GPLv2 http://www.gnu.org/licenses/gpl-2.0.html * +* * +****************************************************************************/ +package emu.project64.jni; + +public enum VideoSettingID +{ + // General Settings + Set_vsync, Set_Rotate, Set_texenh_options, Set_wrpVRAM, + Set_wrpFBO, Set_wrpAnisotropic, Set_autodetect_ucode, Set_ucode, Set_wireframe, + Set_wfmode, Set_unk_as_red, Set_unk_clear, Set_ghq_fltr, + Set_ghq_cmpr, Set_ghq_enht, Set_ghq_hirs, Set_ghq_enht_cmpr, Set_ghq_enht_tile, + Set_ghq_enht_f16bpp, Set_ghq_enht_gz, Set_ghq_enht_nobg, Set_ghq_hirs_cmpr, + Set_ghq_hirs_tile, Set_ghq_hirs_f16bpp, Set_ghq_hirs_gz, Set_ghq_hirs_altcrc, + Set_ghq_cache_save, Set_ghq_cache_size, Set_ghq_hirs_let_texartists_fly, + Set_ghq_hirs_dump, Set_Resolution, + + // Default Game Settings + Set_optimize_texrect_default, Set_filtering_default, Set_lodmode_default, + Set_fog_default, Set_buff_clear_default, Set_swapmode_default, + Set_aspect_default, Set_fb_smart_default, Set_fb_hires_default, + Set_fb_read_always_default, Set_read_back_to_screen_default, Set_detect_cpu_write_default, + Set_fb_get_info_default, Set_fb_render_default, + + //Game Settings + Set_alt_tex_size, Set_use_sts1_only, Set_force_calc_sphere, Set_correct_viewport, + Set_increase_texrect_edge, Set_decrease_fillrect_edge, Set_texture_correction, + Set_pal230, Set_stipple_mode, Set_stipple_pattern, Set_force_microcheck, Set_force_quad3d, + Set_clip_zmin, Set_clip_zmax, Set_fast_crc, Set_adjust_aspect, Set_zmode_compare_less, + Set_old_style_adither, Set_n64_z_scale, Set_optimize_texrect, Set_ignore_aux_copy, + Set_hires_buf_clear, Set_fb_read_alpha, Set_useless_is_useless, Set_fb_crc_mode, + Set_filtering, Set_fog, Set_buff_clear, Set_swapmode, Set_aspect, Set_lodmode, + Set_fb_smart, Set_fb_hires, Set_fb_read_always, Set_read_back_to_screen, + Set_detect_cpu_write, Set_fb_get_info, Set_fb_render, + + //RDB Setting + Set_ucodeLookup, + ; + + private int value; + + public int getValue() + { + return this.value; + } + private static final class StaticFields + { + public static int Counter = 0; + } + + private VideoSettingID() + { + this.value = StaticFields.Counter; + StaticFields.Counter += 1; + } +} diff --git a/Android/src/emu/project64/settings/GamepadScreenFragment.java b/Android/src/emu/project64/settings/GamepadScreenFragment.java index d134bfec8..c1b8fb8f2 100644 --- a/Android/src/emu/project64/settings/GamepadScreenFragment.java +++ b/Android/src/emu/project64/settings/GamepadScreenFragment.java @@ -31,27 +31,5 @@ public class GamepadScreenFragment extends BaseSettingsFragment public void onCreatePreferences(Bundle bundle, String s) { super.onCreatePreferences(bundle, s); - - /*String profilesDir = AndroidDevice.PACKAGE_DIRECTORY + "/profiles"; - String touchscreenProfiles_cfg = profilesDir + "/touchscreen.cfg"; - ConfigFile touchscreenProfiles = new ConfigFile( touchscreenProfiles_cfg ); - Set layoutsKeySet = touchscreenProfiles.keySet(); - String[] layouts = layoutsKeySet.toArray(new String[layoutsKeySet.size()]); - - CharSequence[] entries = new CharSequence[layouts.length]; - String[] entryValues = new String[layouts.length]; - String[] entrySubtitles = new String[layouts.length]; - - for( int i = 0; i < layouts.length; i++ ) - { - entries[i] = layouts[i]; - entryValues[i] = layouts[i]; - entrySubtitles[i] = touchscreenProfiles.get(layouts[i]).get("comment"); - } - - final TwoLinesListPreference listPreference = (TwoLinesListPreference) findPreference("touchscreenLayout"); - listPreference.setEntries(entries); - listPreference.setEntryValues(entryValues); - listPreference.setEntriesSubtitles(entrySubtitles);*/ } } diff --git a/Android/src/emu/project64/settings/SettingsActivity.java b/Android/src/emu/project64/settings/SettingsActivity.java index 554d9787e..41378c9c7 100644 --- a/Android/src/emu/project64/settings/SettingsActivity.java +++ b/Android/src/emu/project64/settings/SettingsActivity.java @@ -18,6 +18,7 @@ import emu.project64.jni.NativeExports; import emu.project64.jni.SettingsID; import emu.project64.jni.SystemEvent; import emu.project64.jni.UISettingID; +import emu.project64.jni.VideoSettingID; import android.content.SharedPreferences; import android.os.Bundle; import android.preference.PreferenceManager; @@ -92,6 +93,7 @@ public class SettingsActivity extends AppCompatActivity implements SharedPrefere .putString("Debugger_TraceExceptionHandler",String.valueOf(NativeExports.SettingsLoadDword(SettingsID.Debugger_TraceExceptionHandler.getValue()))) .putString("Debugger_TraceAudioInitShutdown",String.valueOf(NativeExports.SettingsLoadDword(SettingsID.FirstAudioSettings.getValue() + AudioSettingID.Logging_LogAudioInitShutdown.getValue()))) .putString("Debugger_TraceAudioAudioInterface",String.valueOf(NativeExports.SettingsLoadDword(SettingsID.FirstAudioSettings.getValue() + AudioSettingID.Logging_LogAudioInterface.getValue()))) + .putString("video_screenResolution",String.valueOf(NativeExports.SettingsLoadDword(SettingsID.FirstGfxSettings.getValue() + VideoSettingID.Set_Resolution.getValue()))) .putInt("MaxRomsRemembered",NativeExports.UISettingsLoadDword(UISettingID.File_RecentGameFileCount.getValue())) .apply(); @@ -175,6 +177,7 @@ public class SettingsActivity extends AppCompatActivity implements SharedPrefere else if (key.equals("Debugger_TraceExceptionHandler")) { NativeExports.SettingsSaveDword(SettingsID.Debugger_TraceExceptionHandler.getValue(), Integer.valueOf(sharedPreferences.getString(key, "1"))); } else if (key.equals("Debugger_TraceAudioInitShutdown")) { NativeExports.SettingsSaveDword(SettingsID.FirstAudioSettings.getValue() + AudioSettingID.Logging_LogAudioInitShutdown.getValue(), Integer.valueOf(sharedPreferences.getString(key, "1"))); } else if (key.equals("Debugger_TraceAudioAudioInterface")) { NativeExports.SettingsSaveDword(SettingsID.FirstAudioSettings.getValue() + AudioSettingID.Logging_LogAudioInterface.getValue(), Integer.valueOf(sharedPreferences.getString(key, "1"))); } + else if (key.equals("video_screenResolution")) { NativeExports.SettingsSaveDword(SettingsID.FirstGfxSettings.getValue() + VideoSettingID.Set_Resolution.getValue(), Integer.valueOf(sharedPreferences.getString(key, "1"))); } else if (key.equals("MaxRomsRemembered")) { NativeExports.UISettingsSaveDword(UISettingID.File_RecentGameFileCount.getValue(), sharedPreferences.getInt(key, 10)); } } } diff --git a/Android/src/emu/project64/settings/TwoLinesListPreferenceDialogFragmentCompat.java b/Android/src/emu/project64/settings/TwoLinesListPreferenceDialogFragmentCompat.java index f69d47c3a..a23cf0f01 100644 --- a/Android/src/emu/project64/settings/TwoLinesListPreferenceDialogFragmentCompat.java +++ b/Android/src/emu/project64/settings/TwoLinesListPreferenceDialogFragmentCompat.java @@ -32,18 +32,15 @@ public class TwoLinesListPreferenceDialogFragmentCompat extends PreferenceDialog return (TwoLinesListPreference)this.getPreference(); } - class YourAdapter extends ArrayAdapter + class TwoLinesListPreferenceAdapter extends ArrayAdapter { - public YourAdapter(Context context, String[] values) + public TwoLinesListPreferenceAdapter(Context context, String[] values) { super(context, R.layout.two_lines_list_preference_row, values); } class ViewHolder { - TextView title; - TextView subTitle; - RadioButton radioBtn; } ViewHolder holder; @@ -52,33 +49,32 @@ public class TwoLinesListPreferenceDialogFragmentCompat extends PreferenceDialog @Override public View getView(int position, View convertView, ViewGroup parent) { - final LayoutInflater inflater = (LayoutInflater) getContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE); - if (convertView == null) - { - convertView = inflater.inflate(R.layout.two_lines_list_preference_row, null); - holder = new ViewHolder(); - holder.title = (TextView) convertView.findViewById(R.id.two_lines_list_view_row_text); - holder.subTitle = (TextView) convertView.findViewById(R.id.two_lines_list_view_row_subtext); - holder.radioBtn = (RadioButton) convertView.findViewById(R.id.two_lines_list_view_row_radiobtn); - convertView.setTag(holder); + final TwoLinesListPreference preference = getTwoLinesListPreference(); - holder.title.setOnClickListener(listener); - holder.subTitle.setOnClickListener(listener); - holder.radioBtn.setOnClickListener(listener); + final LayoutInflater inflater = (LayoutInflater) getContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE); + convertView = inflater.inflate(R.layout.two_lines_list_preference_row, null); + + TextView title = (TextView) convertView.findViewById(R.id.two_lines_list_view_row_text); + title.setOnClickListener(listener); + title.setText(preference.getEntries()[position]); + title.setTag(position); + + TextView subTitle = (TextView) convertView.findViewById(R.id.two_lines_list_view_row_subtext); + if (preference.getEntriesSubtitles()[position].length() == 0) + { + subTitle.setVisibility(View.GONE); } else { - holder = (ViewHolder) convertView.getTag(); + subTitle.setOnClickListener(listener); + subTitle.setText(preference.getEntriesSubtitles()[position]); + subTitle.setTag(position); } - final TwoLinesListPreference preference = getTwoLinesListPreference(); - holder.title.setText(preference.getEntries()[position]); - holder.title.setTag(position); - holder.subTitle.setText(preference.getEntriesSubtitles()[position]); - holder.subTitle.setTag(position); - - holder.radioBtn.setChecked(preference.getValueIndex() == position); - holder.radioBtn.setTag(position); + RadioButton radioBtn = (RadioButton) convertView.findViewById(R.id.two_lines_list_view_row_radiobtn); + radioBtn.setOnClickListener(listener); + radioBtn.setChecked(preference.getValueIndex() == position); + radioBtn.setTag(position); return convertView; } @@ -96,7 +92,7 @@ public class TwoLinesListPreferenceDialogFragmentCompat extends PreferenceDialog values[i] = entries[i].toString(); } - ListAdapter adapter = new YourAdapter(builder.getContext(), values); + ListAdapter adapter = new TwoLinesListPreferenceAdapter(builder.getContext(), values); builder.setAdapter(adapter, new DialogInterface.OnClickListener() { @Override @@ -126,7 +122,7 @@ public class TwoLinesListPreferenceDialogFragmentCompat extends PreferenceDialog { final TwoLinesListPreference preference = getTwoLinesListPreference(); int EntryIndex = (Integer) v.getTag(); - preference.setValue(preference.getEntries()[EntryIndex].toString()); + preference.setValue(preference.getEntryValues()[EntryIndex].toString()); TwoLinesListPreferenceDialogFragmentCompat.this.getDialog().dismiss(); } } diff --git a/Android/src/emu/project64/settings/VideoFragment.java b/Android/src/emu/project64/settings/VideoFragment.java index 4db06a5f4..c1e5426cb 100644 --- a/Android/src/emu/project64/settings/VideoFragment.java +++ b/Android/src/emu/project64/settings/VideoFragment.java @@ -10,19 +10,58 @@ ****************************************************************************/ package emu.project64.settings; +import android.content.Context; +import android.graphics.Point; +import android.os.Build; +import android.os.Bundle; +import android.util.DisplayMetrics; +import android.util.Log; +import android.view.WindowManager; +import emu.project64.AndroidDevice; import emu.project64.R; +import emu.project64.jni.LanguageStringID; +import emu.project64.jni.NativeVideo; +import emu.project64.util.Strings; public class VideoFragment extends BaseSettingsFragment { @Override - protected int getXml() + protected int getXml() { return R.xml.setting_video; } @Override - protected int getTitleId() + protected int getTitleId() { return R.string.video_screen_title; } + + @Override + public void onCreatePreferences(Bundle bundle, String s) + { + super.onCreatePreferences(bundle, s); + + int ResCount = NativeVideo.getResolutionCount(); + CharSequence[] ResEntries = new CharSequence[ResCount]; + String[] ResEntryValues = new String[ResCount]; + String[] ResEntrySubtitles = new String[ResCount]; + + for( int i = 0; i < ResCount; i++ ) + { + ResEntries[i] = NativeVideo.getResolutionName(i); + ResEntryValues[i] = Integer.toString(i); + ResEntrySubtitles[i] = ""; + if (ResEntries[i].equals("#3200#")) + { + ResEntries[i] = Strings.GetString(LanguageStringID.ANDROID_VIDEO_NATIVE_RES); + ResEntrySubtitles[i] = AndroidDevice.nativeWidth+"x"+AndroidDevice.nativeHeight; + } + } + + final TwoLinesListPreference listPreference = (TwoLinesListPreference) findPreference("video_screenResolution"); + listPreference.setEntries(ResEntries); + listPreference.setEntryValues(ResEntryValues); + listPreference.setEntriesSubtitles(ResEntrySubtitles); + } } diff --git a/Source/Glide64/Android.cpp b/Source/Glide64/Android.cpp new file mode 100644 index 000000000..d73ed3000 --- /dev/null +++ b/Source/Glide64/Android.cpp @@ -0,0 +1,37 @@ +/**************************************************************************** +* * +* Project 64 - A Nintendo 64 emulator. * +* http://www.pj64-emu.com/ * +* Copyright (C) 2012 Project64. All rights reserved. * +* * +* License: * +* GNU/GPLv2 http://www.gnu.org/licenses/gpl-2.0.html * +* * +****************************************************************************/ +#ifdef ANDROID +#include +#include "ScreenResolution.h" + +#define EXPORT extern "C" __attribute__((visibility("default"))) +#define CALL + +EXPORT jint CALL Java_emu_project64_jni_NativeVideo_getResolutionCount(JNIEnv* env, jclass cls) +{ + return GetScreenResolutionCount(); +} + +EXPORT jstring CALL Java_emu_project64_jni_NativeVideo_getResolutionName(JNIEnv* env, jclass cls, int index) +{ + return env->NewStringUTF(GetScreenResolutionName(index)); +} + +EXPORT jint CALL Java_emu_project64_jni_NativeVideo_GetScreenResWidth(JNIEnv* env, jclass cls, int index) +{ + return GetScreenResWidth(index); +} + +EXPORT jint CALL Java_emu_project64_jni_NativeVideo_GetScreenResHeight(JNIEnv* env, jclass cls, int index) +{ + return GetScreenResHeight(index); +} +#endif \ No newline at end of file diff --git a/Source/Glide64/Glide64.vcxproj b/Source/Glide64/Glide64.vcxproj index b3d63cfd6..f2c287f73 100644 --- a/Source/Glide64/Glide64.vcxproj +++ b/Source/Glide64/Glide64.vcxproj @@ -96,6 +96,7 @@ + diff --git a/Source/Glide64/Glide64.vcxproj.filters b/Source/Glide64/Glide64.vcxproj.filters index f7b5970df..451d50bfa 100644 --- a/Source/Glide64/Glide64.vcxproj.filters +++ b/Source/Glide64/Glide64.vcxproj.filters @@ -155,6 +155,7 @@ + diff --git a/Source/Glide64/Main.cpp b/Source/Glide64/Main.cpp index 991b81b68..22f052e49 100644 --- a/Source/Glide64/Main.cpp +++ b/Source/Glide64/Main.cpp @@ -67,6 +67,10 @@ #include +#ifdef ANDROID +uint32_t g_NativeWidth, g_NativeHeight; +#endif + GFX_INFO gfx; int to_fullscreen = FALSE; @@ -79,6 +83,8 @@ int evoodoo = 0; int ev_fullscreen = 0; extern int viewport_offset; +extern int g_width, g_height; + #ifdef _WIN32 HINSTANCE hinstDLL = NULL; @@ -410,7 +416,6 @@ void SetWindowDisplaySize(HWND hWnd) else { RECT clientRect = { 0 }, toolbarRect = { 0 }, statusbarRect = { 0 }, windowedRect = { 0 }; - ZeroMemory(&g_windowedRect, sizeof(RECT)); HWND hToolBar = FindWindowEx(hWnd, NULL, REBARCLASSNAME, NULL); HWND hStatusBar = FindWindowEx(hWnd, NULL, STATUSCLASSNAME, NULL); if (hStatusBar == NULL) @@ -503,18 +508,18 @@ int InitGfx() voodoo.has_2mb_tex_boundary = (SST_type < GR_SSTTYPE_Banshee) && !evoodoo; // use UMA if available voodoo.tex_UMA = FALSE; - //* - if (strstr(extensions, " TEXUMA ")) { + if (strstr(extensions, " TEXUMA ")) + { // we get better texture cache hits with UMA on grEnable(GR_TEXTURE_UMA_EXT); voodoo.tex_UMA = TRUE; WriteTrace(TraceGlide64, TraceDebug, "Using TEXUMA extension"); } - //*/ -#ifndef ANDROID g_settings->UpdateScreenSize(ev_fullscreen); +#ifndef ANDROID SetWindowDisplaySize(gfx.hWnd); +#endif gfx_context = grSstWinOpen(GR_COLORFORMAT_RGBA, GR_ORIGIN_UPPER_LEFT, 2, 1); if (!gfx_context) { @@ -526,11 +531,6 @@ int InitGfx() grGlideShutdown(); return FALSE; } -#else - gfx_context = grSstWinOpen(GR_COLORFORMAT_RGBA, GR_ORIGIN_UPPER_LEFT, 2, 1); - g_settings->scr_res_x = g_settings->res_x = g_width; - g_settings->scr_res_y = g_settings->res_y = g_height; -#endif GfxInitDone = TRUE; to_fullscreen = FALSE; @@ -1614,16 +1614,12 @@ Purpose: this function is called when the surface is has changed. input: none output: none *******************************************************************/ -void init_combiner(); - void CALL SurfaceChanged(int width, int height) { - g_width = width; - g_height = height; + g_NativeWidth = width; + g_NativeHeight = height; } -#endif -#ifdef ANDROID void Android_JNI_SwapWindow() { gfx.SwapBuffers(); diff --git a/Source/Glide64/ScreenResolution.cpp b/Source/Glide64/ScreenResolution.cpp index 2f95fb7ba..7326ce3f0 100644 --- a/Source/Glide64/ScreenResolution.cpp +++ b/Source/Glide64/ScreenResolution.cpp @@ -12,6 +12,10 @@ #include "settings.h" #include "trace.h" +#ifdef ANDROID +extern uint32_t g_NativeWidth, g_NativeHeight; +#endif + struct ResolutionInfo { ResolutionInfo(const char * name = NULL, uint32_t width = 0, uint32_t height = 0, uint32_t frequency = 0, bool default_res = false) : @@ -114,6 +118,12 @@ uint32_t GetScreenResWidth(uint32_t index) { if (index < GetScreenResolutionCount()) { +#ifdef ANDROID + if (g_resolutions[index].width() == 0) + { + return g_NativeWidth; + } +#endif return g_resolutions[index].width(); } return 0; @@ -123,6 +133,12 @@ uint32_t GetScreenResHeight(uint32_t index) { if (index < GetScreenResolutionCount()) { +#ifdef ANDROID + if (g_resolutions[index].height() == 0) + { + return g_NativeHeight; + } +#endif return g_resolutions[index].height(); } return 0; diff --git a/Source/Glide64/Settings.cpp b/Source/Glide64/Settings.cpp index a16b9c5e2..125c9e40f 100644 --- a/Source/Glide64/Settings.cpp +++ b/Source/Glide64/Settings.cpp @@ -7,16 +7,20 @@ int GetCurrentResIndex(void); #endif +#ifdef ANDROID +extern uint32_t g_NativeWidth, g_NativeHeight; +#endif + short Set_basic_mode = 0, Set_texture_dir = 0, Set_log_dir = 0, Set_log_flush = 0; extern int g_width, g_height; CSettings::CSettings() : m_dirty(false), - m_res_x(640), - m_scr_res_x(640), - m_res_y(480), - m_scr_res_y(480), - m_ScreenRes(7), + m_res_x(GetScreenResWidth(GetDefaultScreenRes())), + m_scr_res_x(GetScreenResWidth(GetDefaultScreenRes())), + m_res_y(GetScreenResHeight(GetDefaultScreenRes())), + m_scr_res_y(GetScreenResHeight(GetDefaultScreenRes())), + m_ScreenRes(GetDefaultScreenRes()), advanced_options(0), texenh_options(0), vsync(0), @@ -29,6 +33,7 @@ buff_clear(0), m_lodmode(LOD_Off), m_aspectmode(Aspect_4x3), m_frame_buffer(0), + m_fb_crc_mode(fbcrcFast), //Texture filtering options texture_dir(""), m_ghq_fltr(TextureFilter_None), @@ -99,6 +104,10 @@ m_FlushLogs(false) ReadSettings(); } +CSettings::~CSettings() +{ +} + void CSettings::RegisterSettings(void) { SetModuleName("default"); @@ -108,7 +117,7 @@ void CSettings::RegisterSettings(void) Set_log_dir = FindSystemSettingId("Dir:Log"); SetModuleName("Glide64"); - general_setting(Set_Resolution, "resolution", 7); + general_setting(Set_Resolution, "resolution", GetDefaultScreenRes()); #ifdef _WIN32 general_setting(Set_FullScreenRes, "FullScreenRes", GetCurrentResIndex()); #endif @@ -203,6 +212,9 @@ void CSettings::RegisterSettings(void) game_setting_default(Set_detect_cpu_write, "detect_cpu_write", Set_detect_cpu_write_default); game_setting_default(Set_fb_get_info, "fb_get_info", Set_fb_get_info_default); game_setting_default(Set_fb_render, "fb_render", Set_fb_render_default); + + SettingsRegisterChange(false, Set_Resolution, this, stSettingsChanged); + } void CSettings::SetScreenRes(uint32_t value) @@ -234,6 +246,11 @@ void CSettings::UpdateScreenSize(bool fullscreen) } m_scr_res_x = m_res_x = g_width; m_scr_res_y = m_res_y = g_height; +#else + g_width = GetScreenResWidth(m_ScreenRes); + g_height = GetScreenResHeight(m_ScreenRes); + m_scr_res_x = m_res_x = g_width; + m_scr_res_y = m_res_y = g_height; #endif UpdateAspectRatio(); } @@ -363,11 +380,8 @@ void CSettings::UpdateAspectRatio(void) void CSettings::ReadSettings() { -#ifdef ANDROID - this->scr_res_x = this->res_x = g_width; - this->scr_res_y = this->res_y = g_height; -#else SetScreenRes(GetSetting(Set_Resolution)); +#ifndef ANDROID this->wrpResolution = GetSetting(Set_FullScreenRes); #endif this->vsync = GetSetting(Set_vsync); @@ -582,10 +596,8 @@ void CSettings::ReadGameSettings(const char * name) g_settings->fog = GetSetting(g_romopen ? Set_fog : Set_fog_default); g_settings->buff_clear = GetSetting(g_romopen ? Set_buff_clear : Set_buff_clear_default); -#ifdef _WIN32 - g_settings->m_ScreenRes = GetSetting(Set_Resolution); - if (g_settings->m_ScreenRes < 0 || g_settings->m_ScreenRes >= 0x18) g_settings->m_ScreenRes = 12; -#endif + m_ScreenRes = GetSetting(Set_Resolution); + if (m_ScreenRes >= GetScreenResolutionCount()) { m_ScreenRes = GetDefaultScreenRes(); } //frame buffer short fb_Settings[] = @@ -649,8 +661,8 @@ void CSettings::ReadGameSettings(const char * name) void CSettings::WriteSettings(void) { -#ifdef _WIN32 SetSetting(Set_Resolution, g_settings->m_ScreenRes); +#ifdef _WIN32 SetSetting(Set_FullScreenRes, g_settings->wrpResolution); #endif SetSetting(Set_vsync, g_settings->vsync); @@ -717,3 +729,8 @@ void CSettings::WriteSettings(void) FlushSettings(); } + +void CSettings::SettingsChanged(void) +{ + m_ScreenRes = GetSetting(Set_Resolution); +} diff --git a/Source/Glide64/Settings.h b/Source/Glide64/Settings.h index 5d7cb0725..82c3c27c5 100644 --- a/Source/Glide64/Settings.h +++ b/Source/Glide64/Settings.h @@ -5,6 +5,7 @@ class CSettings { public: CSettings(); + ~CSettings(); //Frame buffer emulation options enum fb_bits_t @@ -272,10 +273,15 @@ public: void UpdateAspectRatio(void); void UpdateScreenSize(bool fullscreen); - private: void ReadSettings(); void RegisterSettings(void); + void SettingsChanged(void); + + static void stSettingsChanged(void * _this) + { + ((CSettings *)_this)->SettingsChanged(); + } bool m_dirty; bool m_FlushLogs; diff --git a/Source/Project64-core/Multilanguage.h b/Source/Project64-core/Multilanguage.h index b178e20ec..5d7066c2c 100644 --- a/Source/Project64-core/Multilanguage.h +++ b/Source/Project64-core/Multilanguage.h @@ -589,6 +589,9 @@ enum LanguageStringID ANDROID_MENU_DEBUGGINGOPTIONS = 3111, ANDROID_MENU_RESETFUNCTIONTIMES = 3112, ANDROID_MENU_DUMPFUNCTIONTIMES = 3113, + + //Video plugin + ANDROID_VIDEO_NATIVE_RES = 3200, }; #include "Multilanguage/LanguageClass.h" diff --git a/Source/Project64-core/Multilanguage/LanguageClass.cpp b/Source/Project64-core/Multilanguage/LanguageClass.cpp index b2a4a2d91..57f42f880 100644 --- a/Source/Project64-core/Multilanguage/LanguageClass.cpp +++ b/Source/Project64-core/Multilanguage/LanguageClass.cpp @@ -557,6 +557,9 @@ void CLanguage::LoadDefaultStrings(void) DEF_STR(ANDROID_MENU_DEBUGGINGOPTIONS, "Debugging Options"); DEF_STR(ANDROID_MENU_RESETFUNCTIONTIMES, "Reset Function Times"); DEF_STR(ANDROID_MENU_DUMPFUNCTIONTIMES, "Dump Function Times"); + + //Video plugin + DEF_STR(ANDROID_VIDEO_NATIVE_RES, "Native"); } CLanguage::CLanguage() : diff --git a/changes.txt b/changes.txt new file mode 100644 index 000000000..9bb048312 --- /dev/null +++ b/changes.txt @@ -0,0 +1,2 @@ +Android Release 9: +- Add ability to change screen res \ No newline at end of file