diff --git a/Android/app/src/main/java/emu/project64/AboutActivity.java b/Android/app/src/main/java/emu/project64/AboutActivity.java index bc2afe9a6..ad76d017d 100644 --- a/Android/app/src/main/java/emu/project64/AboutActivity.java +++ b/Android/app/src/main/java/emu/project64/AboutActivity.java @@ -68,9 +68,6 @@ public class AboutActivity extends AppCompatActivity TextView about_text = (TextView)findViewById(R.id.about_text); about_text.setText(Strings.GetString(LanguageStringID.ANDROID_ABOUT_TEXT)); - TextView Project64_authors = (TextView)findViewById(R.id.Project64_authors); - Project64_authors.setText(Strings.GetString(LanguageStringID.ANDROID_ABOUT_PJ64_AUTHORS)); - webView.loadData(Utility.readAsset("licence.htm", ""), "text/html", "UTF8"); } @@ -91,7 +88,7 @@ public class AboutActivity extends AppCompatActivity m_title_clicks += 1; if (m_title_clicks == 6) { - NativeExports.SettingsSaveBool(SettingsID.UserInterface_BasicMode.getValue(), false); + NativeExports.SettingsSaveBool(SettingsID.UserInterface_BasicMode.toString(), false); Toast.makeText(this, "Advanced Mode Enabled", Toast.LENGTH_SHORT).show(); } } diff --git a/Android/app/src/main/java/emu/project64/AndroidDevice.java b/Android/app/src/main/java/emu/project64/AndroidDevice.java index 09551bac0..1828f2947 100644 --- a/Android/app/src/main/java/emu/project64/AndroidDevice.java +++ b/Android/app/src/main/java/emu/project64/AndroidDevice.java @@ -8,17 +8,14 @@ import java.util.ArrayList; import java.util.Arrays; import java.util.List; import java.util.StringTokenizer; - import emu.project64.util.Strings; import emu.project64.util.FileUtil; import emu.project64.util.Utility; -import tv.ouya.console.api.OuyaFacade; import android.annotation.SuppressLint; import android.graphics.Point; import android.os.Build; import android.os.Environment; import android.util.DisplayMetrics; -import android.view.KeyEvent; import android.view.WindowManager; @SuppressLint("NewApi") @@ -45,23 +42,15 @@ public class AndroidDevice /** 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; + public static final boolean IS_ACTION_BAR_AVAILABLE = AndroidDevice.IS_HONEYCOMB; - final static boolean isTv; public final static int nativeWidth; public final static int nativeHeight; - - public static boolean MapVolumeKeys = false; - 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; @@ -83,29 +72,6 @@ public class AndroidDevice nativeHeight = _nativeHeight; } - public static boolean isAndroidTv() - { - return isTv; - } - - public static List getUnmappableKeyCodes () - { - List unmappables = new ArrayList(); - unmappables.add( KeyEvent.KEYCODE_MENU ); - if( IS_HONEYCOMB ) - { - // Back key is needed to show/hide the action bar in HC+ - unmappables.add( KeyEvent.KEYCODE_BACK ); - } - if( !MapVolumeKeys ) - { - unmappables.add( KeyEvent.KEYCODE_VOLUME_UP ); - unmappables.add( KeyEvent.KEYCODE_VOLUME_DOWN ); - unmappables.add( KeyEvent.KEYCODE_VOLUME_MUTE ); - } - return unmappables; - } - public static ArrayList getStorageDirectories() { BufferedReader bufReader = null; diff --git a/Android/app/src/main/java/emu/project64/GalleryActivity.java b/Android/app/src/main/java/emu/project64/GalleryActivity.java index 714086f87..738d46566 100644 --- a/Android/app/src/main/java/emu/project64/GalleryActivity.java +++ b/Android/app/src/main/java/emu/project64/GalleryActivity.java @@ -15,16 +15,13 @@ import java.util.regex.Pattern; import emu.project64.R; import emu.project64.dialog.ProgressDialog; import emu.project64.game.GameActivity; -import emu.project64.game.GameActivityXperiaPlay; import emu.project64.jni.LanguageStringID; import emu.project64.jni.NativeExports; import emu.project64.jni.SettingsID; -import emu.project64.jni.SystemEvent; import emu.project64.jni.UISettingID; import emu.project64.settings.GameSettingsActivity; import emu.project64.settings.SettingsActivity; import emu.project64.util.Strings; -import emu.project64.util.Utility; import android.annotation.TargetApi; import android.app.Activity; import androidx.appcompat.app.AlertDialog; @@ -57,6 +54,7 @@ import android.widget.ListAdapter; import android.widget.TextView; import android.widget.TextView.BufferType; +import androidx.appcompat.view.menu.MenuBuilder; import androidx.appcompat.app.ActionBar; import androidx.appcompat.app.ActionBarDrawerToggle; import androidx.appcompat.app.AppCompatActivity; @@ -89,6 +87,7 @@ public class GalleryActivity extends AppCompatActivity private static List mRecentItems = new ArrayList(); private static GalleryActivity mActiveGalleryActivity = null; + public static final int GAME_DIR_REQUEST_CODE = 1; static final int RC_SETTINGS = 10002; @Override @@ -114,7 +113,6 @@ public class GalleryActivity extends AppCompatActivity super.onCreate( savedInstanceState ); mActiveGalleryActivity = this; - Log.d("GalleryActivity", "Starting setup."); // Lay out the content setContentView( R.layout.gallery_activity ); @@ -142,39 +140,20 @@ public class GalleryActivity extends AppCompatActivity Toolbar toolbar = (Toolbar) findViewById( R.id.toolbar ); toolbar.setTitle( R.string.app_name ); setSupportActionBar( toolbar ); - - // Configure the navigation drawer - mDrawerLayout = (DrawerLayout) findViewById( R.id.drawerLayout ); - mDrawerToggle = new ActionBarDrawerToggle( this, mDrawerLayout, toolbar, 0, 0 ); - mDrawerLayout.addDrawerListener( mDrawerToggle ); - - // Configure the list in the navigation drawer - mDrawerList = (MenuListView) findViewById( R.id.drawerNavigation ); - mDrawerList.setMenuResource( R.menu.gallery_drawer ); - // Handle menu item selections - mDrawerList.setOnClickListener( new MenuListView.OnClickListener() - { - @Override - public void onClick( MenuItem menuItem ) - { - GalleryActivity.this.onOptionsItemSelected( menuItem ); - } - }); - UpdateLanguage(); - + ActionBar actionBar = getSupportActionBar(); + actionBar.setDisplayHomeAsUpEnabled(false); + actionBar.setHomeButtonEnabled(false); + actionBar.setDisplayShowTitleEnabled(false); } - void UpdateLanguage() + void UpdateMenuLanguage(Menu menu) { - Strings.SetMenuTitle(mDrawerList.getMenu(), R.id.menuItem_settings, LanguageStringID.ANDROID_SETTINGS); - Strings.SetMenuTitle(mDrawerList.getMenu(), R.id.menuItem_discord, LanguageStringID.ANDROID_DISCORD); - Strings.SetMenuTitle(mDrawerList.getMenu(), R.id.menuItem_reportBug, LanguageStringID.ANDROID_REPORT_BUG); - Strings.SetMenuTitle(mDrawerList.getMenu(), R.id.menuItem_review, LanguageStringID.ANDROID_REVIEW_PJ64); - Strings.SetMenuTitle(mDrawerList.getMenu(), R.id.menuItem_support, LanguageStringID.ANDROID_SUPPORT_PJ64); - Strings.SetMenuTitle(mDrawerList.getMenu(), R.id.menuItem_about, LanguageStringID.ANDROID_ABOUT); + Strings.SetMenuTitle(menu, R.id.menuItem_GameDir, LanguageStringID.ANDROID_GAMEDIR); + Strings.SetMenuTitle(menu, R.id.menuItem_settings, LanguageStringID.ANDROID_SETTINGS); + Strings.SetMenuTitle(menu, R.id.menuItem_discord, LanguageStringID.ANDROID_DISCORD); + Strings.SetMenuTitle(menu, R.id.menuItem_about, LanguageStringID.ANDROID_ABOUT); } - void alert(String message) { AlertDialog.Builder bld = new AlertDialog.Builder(this); @@ -184,28 +163,30 @@ public class GalleryActivity extends AppCompatActivity bld.create().show(); } - @Override protected void onPostCreate( Bundle savedInstanceState ) { super.onPostCreate( savedInstanceState ); - mDrawerToggle.syncState(); } @Override public void onConfigurationChanged( Configuration newConfig ) { super.onConfigurationChanged( newConfig ); - mDrawerToggle.onConfigurationChanged( newConfig ); } @Override public boolean onCreateOptionsMenu( Menu menu ) { - getMenuInflater().inflate( R.menu.gallery_activity, menu ); - Strings.SetMenuTitle(menu, R.id.menuItem_gameDir, LanguageStringID.ANDROID_GAMEDIR); - - return super.onCreateOptionsMenu( menu ); + super.onCreateOptionsMenu( menu ); + getMenuInflater().inflate( R.menu.gallery, menu ); + UpdateMenuLanguage(menu); + if(menu instanceof MenuBuilder) + { + MenuBuilder menuBuilder = (MenuBuilder) menu; + menuBuilder.setOptionalIconsVisible(true); + } + return true; } @Override @@ -217,31 +198,20 @@ public class GalleryActivity extends AppCompatActivity Intent ScanRomsIntent = new Intent(this, ScanRomsActivity.class); startActivityForResult( ScanRomsIntent, GAME_DIR_REQUEST_CODE ); return true; - case R.id.menuItem_settings: - Intent SettingsIntent = new Intent(this, SettingsActivity.class); - startActivity( SettingsIntent ); - return true; - case R.id.menuItem_discord: - Intent ForumIntent = new Intent(Intent.ACTION_VIEW, Uri.parse("https://discord.gg/sbYbnda")); - startActivity(ForumIntent); - return true; - case R.id.menuItem_reportBug: - Intent IssueIntent = new Intent(Intent.ACTION_VIEW, Uri.parse("https://github.com/project64/project64/issues")); - startActivity(IssueIntent); - return true; - case R.id.menuItem_review: - ShowReviewOptions(); - return true; - case R.id.menuItem_support: - ShowPaymentOptions(); - return true; - case R.id.menuItem_about: - Intent AboutIntent = new Intent(this, AboutActivity.class); - startActivity( AboutIntent ); - return true; - default: - return super.onOptionsItemSelected( item ); + case R.id.menuItem_settings: + Intent SettingsIntent = new Intent(this, SettingsActivity.class); + startActivity( SettingsIntent ); + return true; + case R.id.menuItem_discord: + Intent DiscordIntent = new Intent(Intent.ACTION_VIEW, Uri.parse("https://discord.gg/Cg3zquF")); + startActivity(DiscordIntent); + return true; + case R.id.menuItem_about: + Intent AboutIntent = new Intent(this, AboutActivity.class); + startActivity( AboutIntent ); + return true; } + return super.onOptionsItemSelected( item ); } private boolean HasAutoSave(File GameSaveDir) @@ -280,8 +250,8 @@ public class GalleryActivity extends AppCompatActivity private void StartGameMenu (boolean ShowSettings) { - File InstantSaveDir = new File(NativeExports.SettingsLoadString(SettingsID.Directory_InstantSave.getValue())); - final File GameSaveDir = new File(InstantSaveDir,NativeExports.SettingsLoadString(SettingsID.Game_UniqueSaveDir.getValue())); + File InstantSaveDir = new File(NativeExports.SettingsLoadString(SettingsID.Directory_InstantSave.toString())); + final File GameSaveDir = new File(InstantSaveDir,NativeExports.SettingsLoadString(SettingsID.Game_UniqueSaveDir.toString())); class Item { @@ -303,7 +273,7 @@ public class GalleryActivity extends AppCompatActivity menuItemLst.add(new Item("Resume from Native save", R.drawable.ic_controller)); menuItemLst.add(new Item("Resume from Auto save", R.drawable.ic_play)); menuItemLst.add(new Item("Restart", R.drawable.ic_refresh)); - if (ShowSettings && !NativeExports.SettingsLoadBool(SettingsID.UserInterface_BasicMode.getValue())) + if (ShowSettings && !NativeExports.SettingsLoadBool(SettingsID.UserInterface_BasicMode.toString())) { menuItemLst.add(new Item("Settings", R.drawable.ic_sliders)); } @@ -370,7 +340,7 @@ public class GalleryActivity extends AppCompatActivity final Context finalContext = this; AlertDialog.Builder GameMenu = new AlertDialog.Builder(finalContext); - GameMenu.setTitle(NativeExports.SettingsLoadString(SettingsID.Rdb_GoodName.getValue())); + GameMenu.setTitle(NativeExports.SettingsLoadString(SettingsID.Rdb_GoodName.toString())); GameMenu.setAdapter(adapter, new DialogInterface.OnClickListener() { @Override @@ -420,8 +390,8 @@ public class GalleryActivity extends AppCompatActivity public void onGalleryItemClick( GalleryItem item ) { NativeExports.LoadGame(item.romFile.getAbsolutePath()); - File InstantSaveDir = new File(NativeExports.SettingsLoadString(SettingsID.Directory_InstantSave.getValue())); - File GameSaveDir = new File(InstantSaveDir,NativeExports.SettingsLoadString(SettingsID.Game_UniqueSaveDir.getValue())); + File InstantSaveDir = new File(NativeExports.SettingsLoadString(SettingsID.Directory_InstantSave.toString())); + File GameSaveDir = new File(InstantSaveDir,NativeExports.SettingsLoadString(SettingsID.Game_UniqueSaveDir.toString())); Boolean ResumeGame = HasAutoSave(GameSaveDir); launchGameActivity(ResumeGame); } @@ -438,11 +408,6 @@ public class GalleryActivity extends AppCompatActivity { Log.d("GalleryActivity", "onActivityResult(" + requestCode + "," + resultCode + "," + data); - if (requestCode == RC_SETTINGS) - { - StartGameMenu(true); - return; - } // Check which request we're responding to if (requestCode == GAME_DIR_REQUEST_CODE) { @@ -544,18 +509,14 @@ public class GalleryActivity extends AppCompatActivity } // Enables or disables the "please wait" screen. - public void launchGameActivity(boolean ResumeGame) { if (ResumeGame) { - NativeExports.SettingsSaveDword(SettingsID.Game_CurrentSaveState.getValue(), 0); + NativeExports.SettingsSaveDword(SettingsID.Game_CurrentSaveState.toString(), 0); } - NativeExports.SettingsSaveBool(SettingsID.Game_LoadSaveAtStart.getValue(), ResumeGame); - // Launch the game activity - boolean isXperiaPlay = false; - - Intent intent = isXperiaPlay ? new Intent( this, GameActivityXperiaPlay.class ) : new Intent( this, GameActivity.class ); + NativeExports.SettingsSaveBool(SettingsID.Game_LoadSaveAtStart.toString(), ResumeGame); + Intent intent = new Intent( this, GameActivity.class ); this.startActivity( intent ); } @@ -611,9 +572,9 @@ public class GalleryActivity extends AppCompatActivity { mRecentItems = new ArrayList(); - for (int i = 0, n = NativeExports.UISettingsLoadDword(UISettingID.File_RecentGameFileCount.getValue()); i < n; i++) + for (int i = 0, n = NativeExports.SettingsLoadDword(UISettingID.FileRecentGameFileCount.toString()); i < n; i++) { - String RecentFile = NativeExports.UISettingsLoadStringIndex(UISettingID.File_RecentGameFileIndex.getValue(), i); + String RecentFile = NativeExports.SettingsLoadStringIndex(UISettingID.FileRecentGameFileIndex.toString(), i); if (RecentFile.length() == 0) { break; diff --git a/Android/app/src/main/java/emu/project64/MenuListView.java b/Android/app/src/main/java/emu/project64/MenuListView.java index 69f872a7f..345e6c9a7 100644 --- a/Android/app/src/main/java/emu/project64/MenuListView.java +++ b/Android/app/src/main/java/emu/project64/MenuListView.java @@ -2,11 +2,12 @@ package emu.project64; import emu.project64.R; +import android.annotation.SuppressLint; import android.app.Activity; import android.content.Context; -import android.support.v7.view.menu.MenuBuilder; import android.util.AttributeSet; import android.util.DisplayMetrics; +import android.util.Log; import android.view.LayoutInflater; import android.view.Menu; import android.view.MenuItem; @@ -18,6 +19,7 @@ import android.widget.ExpandableListView; import android.widget.ImageView; import android.widget.ListView; import android.widget.TextView; +import androidx.appcompat.view.menu.MenuBuilder; /* ExpandableListView which stores its data set as a Menu hierarchy */ @@ -71,38 +73,39 @@ public class MenuListView extends ExpandableListView { reload(); } - } ); + }); setOnGroupClickListener( new OnGroupClickListener() { @Override - public boolean onGroupClick( ExpandableListView parent, View view, int groupPosition, - long itemId ) + public boolean onGroupClick( ExpandableListView parent, View view, int groupPosition, long itemId ) { MenuItem menuItem = mListData.getItem( groupPosition ); SubMenu submenu = menuItem.getSubMenu(); if( submenu == null ) { if( mListener != null ) + { mListener.onClick( menuItem ); + } } return false; } - } ); + }); setOnChildClickListener( new OnChildClickListener() { @Override - public boolean onChildClick( ExpandableListView parent, View view, int groupPosition, - int childPosition, long itemId ) + public boolean onChildClick( ExpandableListView parent, View view, int groupPosition, int childPosition, long itemId ) { - MenuItem menuItem = mListData.getItem( groupPosition ).getSubMenu() - .getItem( childPosition ); - if( mListener != null ) + MenuItem menuItem = mListData.getItem( groupPosition ).getSubMenu() .getItem( childPosition ); + if (mListener != null) + { mListener.onClick( menuItem ); + } return false; } - } ); + }); } public Menu getMenu() @@ -162,15 +165,15 @@ public class MenuListView extends ExpandableListView } @Override - public View getChildView( int groupPosition, final int childPosition, boolean isLastChild, - View convertView, ViewGroup parent ) + public View getChildView( int groupPosition, final int childPosition, boolean isLastChild, View convertView, ViewGroup parent ) { - LayoutInflater inflater = (LayoutInflater) mListView.getContext().getSystemService( - Context.LAYOUT_INFLATER_SERVICE ); + LayoutInflater inflater = (LayoutInflater) mListView.getContext().getSystemService( Context.LAYOUT_INFLATER_SERVICE ); View view = convertView; if( view == null ) + { view = inflater.inflate( R.layout.list_item_menu, null ); - + } + MenuItem item = getChild( groupPosition, childPosition ); if( item != null ) { @@ -187,11 +190,9 @@ public class MenuListView extends ExpandableListView // Indent child views by 15 points DisplayMetrics metrics = new DisplayMetrics(); - ( (Activity) mListView.getContext() ).getWindowManager().getDefaultDisplay() - .getMetrics( metrics ); + ( (Activity) mListView.getContext() ).getWindowManager().getDefaultDisplay().getMetrics( metrics ); - view.setPadding( (int) ( 15 * metrics.density ), view.getPaddingTop(), - view.getPaddingRight(), view.getPaddingBottom() ); + view.setPadding((int)(15 * metrics.density), view.getPaddingTop(), view.getPaddingRight(), view.getPaddingBottom() ); if( !item.isCheckable() ) indicator.setImageResource( 0x0 ); @@ -222,25 +223,23 @@ public class MenuListView extends ExpandableListView } @Override - public View getGroupView( int groupPosition, boolean isExpanded, View convertView, - ViewGroup parent ) + public View getGroupView( int groupPosition, boolean isExpanded, View convertView, ViewGroup parent ) { - LayoutInflater inflater = (LayoutInflater) mListView.getContext().getSystemService( - Context.LAYOUT_INFLATER_SERVICE ); + LayoutInflater inflater = (LayoutInflater) mListView.getContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE ); View view = convertView; if( view == null ) + { view = inflater.inflate( R.layout.list_item_menu, null ); - + } + MenuItem item = getGroup( groupPosition ); if( item != null ) { TextView text1 = (TextView) view.findViewById( R.id.text1 ); - TextView text2 = (TextView) view.findViewById( R.id.text2 ); ImageView icon = (ImageView) view.findViewById( R.id.icon ); ImageView indicator = (ImageView) view.findViewById( R.id.indicator ); - - text1.setText( item.getTitle() ); - text2.setVisibility( View.GONE ); + + text1.setText(item.getTitle()); icon.setImageDrawable( item.getIcon() ); if( item.isChecked() ) diff --git a/Android/app/src/main/java/emu/project64/Project64Application.java b/Android/app/src/main/java/emu/project64/Project64Application.java index f2cac2d56..0ed466985 100644 --- a/Android/app/src/main/java/emu/project64/Project64Application.java +++ b/Android/app/src/main/java/emu/project64/Project64Application.java @@ -2,8 +2,6 @@ package emu.project64; import android.content.Context; import android.content.res.Resources; -import com.google.android.gms.analytics.GoogleAnalytics; -import com.google.android.gms.analytics.Tracker; public class Project64Application extends android.app.Application { @@ -14,33 +12,15 @@ public class Project64Application extends android.app.Application { super.onCreate(); m_instance = this; - } - /** - * @return the main context of the Application - */ public static Context getAppContext() { return m_instance; } - /** - * @return the main resources from the Application - */ public static Resources getAppResources() { return m_instance.getResources(); } - - private Tracker tracker; - synchronized public Tracker getDefaultTracker() - { - if (tracker == null) - { - GoogleAnalytics analytics = GoogleAnalytics.getInstance(this); - tracker = analytics.newTracker(R.xml.analytics); - } - return tracker; - } } diff --git a/Android/app/src/main/java/emu/project64/ScanRomsActivity.java b/Android/app/src/main/java/emu/project64/ScanRomsActivity.java index 490e736ff..b03d36810 100644 --- a/Android/app/src/main/java/emu/project64/ScanRomsActivity.java +++ b/Android/app/src/main/java/emu/project64/ScanRomsActivity.java @@ -14,10 +14,10 @@ import android.content.Intent; import android.content.Context; import android.text.Html; import android.text.TextUtils; +import android.util.Log; import android.view.LayoutInflater; import android.os.Bundle; import android.os.Environment; -import android.support.v7.app.AppCompatActivity; import android.view.View; import android.view.ViewGroup; import android.widget.AdapterView; @@ -28,6 +28,7 @@ import android.widget.CheckBox; import android.widget.ListView; import android.widget.ImageView; import android.widget.TextView; +import androidx.appcompat.app.AppCompatActivity; public class ScanRomsActivity extends AppCompatActivity implements OnItemClickListener { @@ -49,9 +50,9 @@ public class ScanRomsActivity extends AppCompatActivity implements OnItemClickLi { super.onCreate(savedInstanceState); setContentView(R.layout.scan_roms_activity); - if (NativeExports.SettingsLoadBool(SettingsID.RomList_GameDirUseSelected.getValue())) + if (NativeExports.SettingsLoadBool(SettingsID.RomList_GameDirUseSelected.toString())) { - File CurrentPath = new File(NativeExports.SettingsLoadString(SettingsID.RomList_GameDir.getValue())); + File CurrentPath = new File(NativeExports.SettingsLoadString(SettingsID.RomList_GameDir.toString())); if (CurrentPath.exists() && CurrentPath.isDirectory()) { mCurrentPath = CurrentPath; @@ -62,7 +63,7 @@ public class ScanRomsActivity extends AppCompatActivity implements OnItemClickLi // Set check box state mScanRecursively = (CheckBox) findViewById( R.id.ScanRecursively ); - mScanRecursively.setChecked( NativeExports.SettingsLoadBool(SettingsID.RomList_GameDirRecursive.getValue()) ); + mScanRecursively.setChecked( NativeExports.SettingsLoadBool(SettingsID.RomList_GameDirRecursive.toString()) ); mScanRecursively.setText(Strings.GetString(LanguageStringID.ANDROID_INCLUDE_SUBDIRECTORIES)); mCancelButton = (Button) findViewById( R.id.buttonCancel ); diff --git a/Android/app/src/main/java/emu/project64/SplashActivity.java b/Android/app/src/main/java/emu/project64/SplashActivity.java index 30621ac93..ab9e9aff6 100644 --- a/Android/app/src/main/java/emu/project64/SplashActivity.java +++ b/Android/app/src/main/java/emu/project64/SplashActivity.java @@ -125,7 +125,7 @@ public class SplashActivity extends AppCompatActivity implements ExtractAssetsLi Log.i( "Splash", "extractAssetsTaskLauncher - startup"); final Handler handler = new Handler(); - if (!mAppInit || NativeExports.UISettingsLoadDword(UISettingID.Asserts_Version.getValue()) != ASSET_VERSION) + if (!mAppInit || NativeExports.SettingsLoadDword(UISettingID.AssertsVersion.toString()) != NativeExports.SettingsLoadDword(UISettingID.BuildVersion.toString())) { handler.post( extractAssetsTaskLauncher ); } @@ -207,35 +207,35 @@ public class SplashActivity extends AppCompatActivity implements ExtractAssetsLi } String SyncDir = this.getFilesDir().getParentFile().getAbsolutePath() + "/lib-sync/"; NativeExports.appInit(AndroidDevice.PACKAGE_DIRECTORY); - NativeExports.SettingsSaveString(SettingsID.Directory_PluginSelected.getValue(), LibsDir); - NativeExports.SettingsSaveBool(SettingsID.Directory_PluginUseSelected.getValue(), true); - NativeExports.SettingsSaveString(SettingsID.Directory_PluginSyncSelected.getValue(), SyncDir); - NativeExports.SettingsSaveBool(SettingsID.Directory_PluginSyncUseSelected.getValue(), true); + NativeExports.SettingsSaveString(SettingsID.Directory_PluginSelected.toString(), LibsDir); + NativeExports.SettingsSaveBool(SettingsID.Directory_PluginUseSelected.toString(), true); + NativeExports.SettingsSaveString(SettingsID.Directory_PluginSyncSelected.toString(), SyncDir); + NativeExports.SettingsSaveBool(SettingsID.Directory_PluginSyncUseSelected.toString(), true); String SaveDir = AndroidDevice.EXTERNAL_PUBLIC_DIRECTORY + "/Project64/Save"; - if (!NativeExports.IsSettingSet(SettingsID.Directory_NativeSave.getValue())) + if (!NativeExports.IsSettingSet(SettingsID.Directory_NativeSave.toString())) { - NativeExports.SettingsSaveString(SettingsID.Directory_NativeSaveSelected.getValue(), SaveDir); - NativeExports.SettingsSaveBool(SettingsID.Directory_NativeSaveUseSelected.getValue(), true); + NativeExports.SettingsSaveString(SettingsID.Directory_NativeSaveSelected.toString(), SaveDir); + NativeExports.SettingsSaveBool(SettingsID.Directory_NativeSaveUseSelected.toString(), true); } - if (!NativeExports.IsSettingSet(SettingsID.Directory_InstantSave.getValue())) + if (!NativeExports.IsSettingSet(SettingsID.Directory_InstantSave.toString())) { - NativeExports.SettingsSaveString(SettingsID.Directory_InstantSaveSelected.getValue(), SaveDir); - NativeExports.SettingsSaveBool(SettingsID.Directory_InstantSaveUseSelected.getValue(), true); + NativeExports.SettingsSaveString(SettingsID.Directory_InstantSaveSelected.toString(), SaveDir); + NativeExports.SettingsSaveBool(SettingsID.Directory_InstantSaveUseSelected.toString(), true); } - if (!NativeExports.IsSettingSet(SettingsID.Directory_Log.getValue())) + if (!NativeExports.IsSettingSet(SettingsID.Directory_Log.toString())) { String LogDir = AndroidDevice.EXTERNAL_PUBLIC_DIRECTORY + "/Project64/Logs"; - NativeExports.SettingsSaveString(SettingsID.Directory_LogSelected.getValue(), LogDir); - NativeExports.SettingsSaveBool(SettingsID.Directory_LogUseSelected.getValue(), true); + NativeExports.SettingsSaveString(SettingsID.Directory_LogSelected.toString(), LogDir); + NativeExports.SettingsSaveBool(SettingsID.Directory_LogUseSelected.toString(), true); } - if (!NativeExports.IsSettingSet(SettingsID.Directory_SnapShot.getValue())) + if (!NativeExports.IsSettingSet(SettingsID.Directory_SnapShot.toString())) { String SnapShotDir = AndroidDevice.EXTERNAL_PUBLIC_DIRECTORY + "/Project64/Screenshots"; - NativeExports.SettingsSaveString(SettingsID.Directory_SnapShotSelected.getValue(), SnapShotDir); - NativeExports.SettingsSaveBool(SettingsID.Directory_SnapShotUseSelected.getValue(), true); + NativeExports.SettingsSaveString(SettingsID.Directory_SnapShotSelected.toString(), SnapShotDir); + NativeExports.SettingsSaveBool(SettingsID.Directory_SnapShotUseSelected.toString(), true); } mAppInit = true; } @@ -311,7 +311,7 @@ public class SplashActivity extends AppCompatActivity implements ExtractAssetsLi InitProject64(); } mTextView.setText( R.string.assetExtractor_finished ); - NativeExports.UISettingsSaveDword(UISettingID.Asserts_Version.getValue(), ASSET_VERSION); + NativeExports.SettingsSaveDword(UISettingID.AssertsVersion.toString(), NativeExports.SettingsLoadDword(UISettingID.BuildVersion.toString())); Intent intent = new Intent( this, GalleryActivity.class ); this.startActivity( intent ); finish(); diff --git a/Android/app/src/main/java/emu/project64/compat/AppCompatPreferenceActivity.java b/Android/app/src/main/java/emu/project64/compat/AppCompatPreferenceActivity.java deleted file mode 100644 index f8624fd6a..000000000 --- a/Android/app/src/main/java/emu/project64/compat/AppCompatPreferenceActivity.java +++ /dev/null @@ -1,7 +0,0 @@ -package emu.project64.compat; - -import android.preference.PreferenceActivity; - -public class AppCompatPreferenceActivity extends PreferenceActivity -{ -} diff --git a/Android/app/src/main/java/emu/project64/game/GameActivityXperiaPlay.java b/Android/app/src/main/java/emu/project64/game/GameActivityXperiaPlay.java deleted file mode 100644 index ffb93ed98..000000000 --- a/Android/app/src/main/java/emu/project64/game/GameActivityXperiaPlay.java +++ /dev/null @@ -1,9 +0,0 @@ -package emu.project64.game; - -import android.annotation.TargetApi; -import android.app.NativeActivity; - -@TargetApi( 9 ) -public class GameActivityXperiaPlay extends NativeActivity -{ -} diff --git a/Android/app/src/main/java/emu/project64/game/GameLifecycleHandler.java b/Android/app/src/main/java/emu/project64/game/GameLifecycleHandler.java index 7708001e2..8583b0f60 100644 --- a/Android/app/src/main/java/emu/project64/game/GameLifecycleHandler.java +++ b/Android/app/src/main/java/emu/project64/game/GameLifecycleHandler.java @@ -72,7 +72,6 @@ public class GameLifecycleHandler implements View.OnKeyListener, SurfaceHolder.C private Controller mMogaController; // Internal flags - private final boolean mIsXperiaPlay; private boolean mStarted = false; private boolean mStopped = false; @@ -81,14 +80,13 @@ public class GameLifecycleHandler implements View.OnKeyListener, SurfaceHolder.C private boolean mIsResumed = false; // true if the activity is resumed private boolean mIsSurface = false; // true if the surface is available - private float mtouchscreenScale = ((float)NativeExports.UISettingsLoadDword(UISettingID.TouchScreen_ButtonScale.getValue())) / 100.0f; - private String mlayout = NativeExports.UISettingsLoadString(UISettingID.TouchScreen_Layout.getValue()); + private float mtouchscreenScale = ((float)NativeExports.SettingsLoadDword(UISettingID.TouchScreenButtonScale.toString())) / 100.0f; + private String mlayout = NativeExports.SettingsLoadString(UISettingID.TouchScreenLayout.toString()); public GameLifecycleHandler(Activity activity) { mActivity = activity; mControllers = new ArrayList(); - mIsXperiaPlay = !(activity instanceof GameActivity); mMogaController = Controller.getInstance(mActivity); } @@ -97,7 +95,7 @@ public class GameLifecycleHandler implements View.OnKeyListener, SurfaceHolder.C { if (LOG_GAMELIFECYCLEHANDLER) { - Log.i("GameLifecycleHandler", "onCreateBegin"); + Log.i("GameLifecycleHandler", "onCreateBegin - Start"); } // Initialize MOGA controller API // TODO: Remove hack after MOGA SDK is fixed @@ -117,7 +115,11 @@ public class GameLifecycleHandler implements View.OnKeyListener, SurfaceHolder.C window.setFlags(LayoutParams.FLAG_KEEP_SCREEN_ON, LayoutParams.FLAG_KEEP_SCREEN_ON); // Set the screen orientation - mActivity.setRequestedOrientation(NativeExports.UISettingsLoadDword(UISettingID.Screen_Orientation.getValue())); + mActivity.setRequestedOrientation(NativeExports.SettingsLoadDword(UISettingID.ScreenOrientation.toString())); + if (LOG_GAMELIFECYCLEHANDLER) + { + Log.i("GameLifecycleHandler", "onCreateBegin - end"); + } } @TargetApi(11) @@ -125,13 +127,7 @@ public class GameLifecycleHandler implements View.OnKeyListener, SurfaceHolder.C { if (LOG_GAMELIFECYCLEHANDLER) { - Log.i("GameLifecycleHandler", "onCreateEnd"); - } - - // Take control of the GameSurface if necessary - if (mIsXperiaPlay) - { - mActivity.getWindow().takeSurface(null); + Log.i("GameLifecycleHandler", "onCreateEnd start"); } // Lay out content and get the views @@ -139,8 +135,13 @@ public class GameLifecycleHandler implements View.OnKeyListener, SurfaceHolder.C mSurface = (GameSurface) mActivity.findViewById(R.id.gameSurface); mOverlay = (GameOverlay) mActivity.findViewById(R.id.gameOverlay); + if (NativeVideo.getResolutionCount() == 0) + { + NativeVideo.UpdateScreenRes(AndroidDevice.nativeWidth, AndroidDevice.nativeHeight); + } + float widthRatio = (float)AndroidDevice.nativeWidth/(float)AndroidDevice.nativeHeight; - int ScreenRes = NativeExports.SettingsLoadDword(SettingsID.FirstGfxSettings.getValue() + VideoSettingID.Set_Resolution.getValue()); + int ScreenRes = NativeExports.SettingsLoadDword(VideoSettingID.Set_Resolution.toString()); int videoRenderWidth = Math.round(NativeVideo.GetScreenResHeight(ScreenRes) * widthRatio); int videoRenderHeight = Math.round(NativeVideo.GetScreenResHeight(ScreenRes)); @@ -156,24 +157,17 @@ public class GameLifecycleHandler implements View.OnKeyListener, SurfaceHolder.C 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 */); - mActivity.getActionBar().setBackgroundDrawable(color); - } - - CreateTouchScreenControls(); - - // Initialize user interface devices - View inputSource = mIsXperiaPlay ? new NativeXperiaTouchpad(mActivity) : mOverlay; - initControllers(inputSource); + //CreateTouchScreenControls(); + //View inputSource = mOverlay; + //initControllers(inputSource); // Override the peripheral controllers' key provider, to add some extra // functionality - inputSource.setOnKeyListener(this); + //inputSource.setOnKeyListener(this); + if (LOG_GAMELIFECYCLEHANDLER) + { + Log.i("GameLifecycleHandler", "onCreateEnd done"); + } } public void onStart() @@ -237,7 +231,7 @@ public class GameLifecycleHandler implements View.OnKeyListener, SurfaceHolder.C { Log.i("GameLifecycleHandler", "OnAutoSave"); } - if (NativeExports.SettingsLoadBool(SettingsID.GameRunning_CPU_Running.getValue()) == true) + /*if (NativeExports.SettingsLoadBool(SettingsID.GameRunning_CPU_Running.getValue()) == true) { Boolean pause = false; int PauseType = 0; @@ -286,12 +280,12 @@ public class GameLifecycleHandler implements View.OnKeyListener, SurfaceHolder.C if (LOG_GAMELIFECYCLEHANDLER) { Log.i("GameLifecycleHandler", "OnAutoSave Done"); - } + }*/ } public void onPause() { - if (LOG_GAMELIFECYCLEHANDLER) + /*if (LOG_GAMELIFECYCLEHANDLER) { Log.i("GameLifecycleHandler", "onPause"); } @@ -304,7 +298,7 @@ public class GameLifecycleHandler implements View.OnKeyListener, SurfaceHolder.C if (LOG_GAMELIFECYCLEHANDLER) { Log.i("GameLifecycleHandler", "onPause - done"); - } + }*/ } @Override @@ -336,7 +330,7 @@ public class GameLifecycleHandler implements View.OnKeyListener, SurfaceHolder.C 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(); @@ -344,12 +338,12 @@ public class GameLifecycleHandler implements View.OnKeyListener, SurfaceHolder.C // Initialize user interface devices View inputSource = mIsXperiaPlay ? new NativeXperiaTouchpad(mActivity) : mOverlay; initControllers(inputSource); - +*/ } private void CreateTouchScreenControls() { - boolean isTouchscreenAnimated = false; // mGlobalPrefs.isTouchscreenAnimated + /*boolean isTouchscreenAnimated = false; // mGlobalPrefs.isTouchscreenAnimated boolean isTouchscreenHidden = false; // !isTouchscreenEnabled || // globalPrefs.touchscreenTransparency // == 0; @@ -371,7 +365,7 @@ public class GameLifecycleHandler implements View.OnKeyListener, SurfaceHolder.C // controls mTouchscreenMap = new VisibleTouchMap(mActivity.getResources()); mTouchscreenMap.load(touchscreenSkin, touchscreenProfile, isTouchscreenAnimated, mtouchscreenScale, touchscreenTransparency); - mOverlay.initialize(mTouchscreenMap, !isTouchscreenHidden, isTouchscreenAnimated); + mOverlay.initialize(mTouchscreenMap, !isTouchscreenHidden, isTouchscreenAnimated);*/ } @Override @@ -391,7 +385,7 @@ 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; @@ -417,7 +411,7 @@ public class GameLifecycleHandler implements View.OnKeyListener, SurfaceHolder.C 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)); - } + }*/ } private void tryRunning() diff --git a/Android/app/src/main/java/emu/project64/game/GameMenuHandler.java b/Android/app/src/main/java/emu/project64/game/GameMenuHandler.java index fab55f542..d8ca4c095 100644 --- a/Android/app/src/main/java/emu/project64/game/GameMenuHandler.java +++ b/Android/app/src/main/java/emu/project64/game/GameMenuHandler.java @@ -5,7 +5,7 @@ import java.sql.Date; import java.text.SimpleDateFormat; import emu.project64.R; -import emu.project64.jni.LanguageStringID; +//import emu.project64.jni.LanguageStringID; import emu.project64.jni.NativeExports; import emu.project64.jni.SettingsID; import emu.project64.jni.SystemEvent; @@ -32,7 +32,7 @@ public class GameMenuHandler implements PopupMenu.OnMenuItemClickListener, Popup public GameMenuHandler( Activity activity, GameLifecycleHandler LifecycleHandler ) { - mActivity = activity; + /*mActivity = activity; mLifecycleHandler = LifecycleHandler; final ImageButton MenuButton = (ImageButton)activity.findViewById( R.id.gameMenu ); @@ -43,7 +43,7 @@ public class GameMenuHandler implements PopupMenu.OnMenuItemClickListener, Popup @Override public void onClick(View view) { - Boolean GamePaused = NativeExports.SettingsLoadBool(SettingsID.GameRunning_CPU_Paused.getValue()); + /*Boolean GamePaused = NativeExports.SettingsLoadBool(SettingsID.GameRunning_CPU_Paused.getValue()); Boolean RecordExecutionTimes = NativeExports.SettingsLoadBool(SettingsID.Debugger_RecordExecutionTimes.getValue()); Boolean ShowDebugMenu = NativeExports.SettingsLoadBool(SettingsID.Debugger_Enabled.getValue()); @@ -99,9 +99,9 @@ public class GameMenuHandler implements PopupMenu.OnMenuItemClickListener, Popup FixSaveStateMenu(SaveDirectory, CurrentSaveState, menu, R.id.menuItem_CurrentSave8, 8); FixSaveStateMenu(SaveDirectory, CurrentSaveState, menu, R.id.menuItem_CurrentSave9, 9); FixSaveStateMenu(SaveDirectory, CurrentSaveState, menu, R.id.menuItem_CurrentSave10, 10); - popupMenu.show(); - } - }); + popupMenu.show();*/ + /*} + });*/ } public boolean onMenuItemClick(MenuItem item) @@ -122,7 +122,7 @@ public class GameMenuHandler implements PopupMenu.OnMenuItemClickListener, Popup case R.id.menuItem_LoadState: NativeExports.ExternalEvent(SystemEvent.SysEvent_LoadMachineState.getValue()); break; - case R.id.menuItem_CurrentSaveAuto: + /*case R.id.menuItem_CurrentSaveAuto: NativeExports.SettingsSaveDword(SettingsID.Game_CurrentSaveState.getValue(), 0); break; case R.id.menuItem_CurrentSave1: @@ -154,7 +154,7 @@ public class GameMenuHandler implements PopupMenu.OnMenuItemClickListener, Popup break; case R.id.menuItem_CurrentSave10: NativeExports.SettingsSaveDword(SettingsID.Game_CurrentSaveState.getValue(), 10); - break; + break;*/ case R.id.menuItem_pause: NativeExports.ExternalEvent( SystemEvent.SysEvent_PauseCPU_FromMenu.getValue()); break; @@ -195,7 +195,7 @@ public class GameMenuHandler implements PopupMenu.OnMenuItemClickListener, Popup @SuppressLint("SimpleDateFormat") private void FixSaveStateMenu(String SaveDirectory, int CurrentSaveState,Menu menu, int MenuId, int SaveSlot ) { - MenuItem item = menu.findItem(MenuId); + /*MenuItem item = menu.findItem(MenuId); if (CurrentSaveState == SaveSlot) { item.setChecked(true); @@ -219,12 +219,12 @@ public class GameMenuHandler implements PopupMenu.OnMenuItemClickListener, Popup } String SlotName = SaveSlot == 0 ? Strings.GetString(LanguageStringID.ANDROID_MENU_CURRENTSAVEAUTO) : Strings.GetString(LanguageStringID.ANDROID_MENU_CURRENTSAVESLOT) + " " + SaveSlot; - item.setTitle(SlotName + Timestamp); + item.setTitle(SlotName + Timestamp);*/ } private void SelectGameSpeed() { - NativeExports.ExternalEvent( SystemEvent.SysEvent_PauseCPU_AppLostActive.getValue()); + /*NativeExports.ExternalEvent( SystemEvent.SysEvent_PauseCPU_AppLostActive.getValue()); final int MAX_SPEED = 300; final int MIN_SPEED = 10; final int initial = (NativeExports.GetSpeed() * 100) / NativeExports.GetBaseSpeed(); @@ -291,6 +291,6 @@ public class GameMenuHandler implements PopupMenu.OnMenuItemClickListener, Popup dialog.dismiss(); NativeExports.ExternalEvent( SystemEvent.SysEvent_ResumeCPU_AppGainedActive.getValue()); } - }); + });*/ } } diff --git a/Android/app/src/main/java/emu/project64/inAppPurchase/IabBroadcastReceiver.java b/Android/app/src/main/java/emu/project64/inAppPurchase/IabBroadcastReceiver.java deleted file mode 100644 index 5cae146fb..000000000 --- a/Android/app/src/main/java/emu/project64/inAppPurchase/IabBroadcastReceiver.java +++ /dev/null @@ -1,60 +0,0 @@ -/* Copyright (c) 2014 Google Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package emu.project64.inAppPurchase; - -import android.content.BroadcastReceiver; -import android.content.Context; -import android.content.Intent; - -/** - * Receiver for the "com.android.vending.billing.PURCHASES_UPDATED" Action - * from the Play Store. - * - *

It is possible that an in-app item may be acquired without the - * application calling getBuyIntent(), for example if the item can be - * redeemed from inside the Play Store using a promotional code. If this - * application isn't running at the time, then when it is started a call - * to getPurchases() will be sufficient notification. However, if the - * application is already running in the background when the item is acquired, - * a message to this BroadcastReceiver will indicate that the an item - * has been acquired.

- */ -public class IabBroadcastReceiver extends BroadcastReceiver { - /** - * Listener interface for received broadcast messages. - */ - public interface IabBroadcastListener { - void receivedBroadcast(); - } - - /** - * The Intent action that this Receiver should filter for. - */ - public static final String ACTION = "com.android.vending.billing.PURCHASES_UPDATED"; - - private final IabBroadcastListener mListener; - - public IabBroadcastReceiver(IabBroadcastListener listener) { - mListener = listener; - } - - @Override - public void onReceive(Context context, Intent intent) { - if (mListener != null) { - mListener.receivedBroadcast(); - } - } -} diff --git a/Android/app/src/main/java/emu/project64/inAppPurchase/IabException.java b/Android/app/src/main/java/emu/project64/inAppPurchase/IabException.java deleted file mode 100644 index a7cc54e5f..000000000 --- a/Android/app/src/main/java/emu/project64/inAppPurchase/IabException.java +++ /dev/null @@ -1,43 +0,0 @@ -/* Copyright (c) 2012 Google Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package emu.project64.inAppPurchase; - -/** - * Exception thrown when something went wrong with in-app billing. - * An IabException has an associated IabResult (an error). - * To get the IAB result that caused this exception to be thrown, - * call {@link #getResult()}. - */ -public class IabException extends Exception { - IabResult mResult; - - public IabException(IabResult r) { - this(r, null); - } - public IabException(int response, String message) { - this(new IabResult(response, message)); - } - public IabException(IabResult r, Exception cause) { - super(r.getMessage(), cause); - mResult = r; - } - public IabException(int response, String message, Exception cause) { - this(new IabResult(response, message), cause); - } - - /** Returns the IAB result (error) that this exception signals. */ - public IabResult getResult() { return mResult; } -} \ No newline at end of file diff --git a/Android/app/src/main/java/emu/project64/inAppPurchase/IabHelper.java b/Android/app/src/main/java/emu/project64/inAppPurchase/IabHelper.java deleted file mode 100644 index c8dea07b9..000000000 --- a/Android/app/src/main/java/emu/project64/inAppPurchase/IabHelper.java +++ /dev/null @@ -1,1116 +0,0 @@ -/* Copyright (c) 2012 Google Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package emu.project64.inAppPurchase; - -import android.app.Activity; -import android.app.PendingIntent; -import android.content.ComponentName; -import android.content.Context; -import android.content.Intent; -import android.content.IntentSender.SendIntentException; -import android.content.ServiceConnection; -import android.content.pm.ResolveInfo; -import android.os.Bundle; -import android.os.Handler; -import android.os.IBinder; -import android.os.RemoteException; -import android.text.TextUtils; -import android.util.Log; - -import com.android.vending.billing.IInAppBillingService; - -import org.json.JSONException; - -import java.util.ArrayList; -import java.util.List; - - -/** - * Provides convenience methods for in-app billing. You can create one instance of this - * class for your application and use it to process in-app billing operations. - * It provides synchronous (blocking) and asynchronous (non-blocking) methods for - * many common in-app billing operations, as well as automatic signature - * verification. - * - * After instantiating, you must perform setup in order to start using the object. - * To perform setup, call the {@link #startSetup} method and provide a listener; - * that listener will be notified when setup is complete, after which (and not before) - * you may call other methods. - * - * After setup is complete, you will typically want to request an inventory of owned - * items and subscriptions. See {@link #queryInventory}, {@link #queryInventoryAsync} - * and related methods. - * - * When you are done with this object, don't forget to call {@link #dispose} - * to ensure proper cleanup. This object holds a binding to the in-app billing - * service, which will leak unless you dispose of it correctly. If you created - * the object on an Activity's onCreate method, then the recommended - * place to dispose of it is the Activity's onDestroy method. It is invalid to - * dispose the object while an asynchronous operation is in progress. You can - * call {@link #disposeWhenFinished()} to ensure that any in-progress operation - * completes before the object is disposed. - * - * A note about threading: When using this object from a background thread, you may - * call the blocking versions of methods; when using from a UI thread, call - * only the asynchronous versions and handle the results via callbacks. - * Also, notice that you can only call one asynchronous operation at a time; - * attempting to start a second asynchronous operation while the first one - * has not yet completed will result in an exception being thrown. - * - */ -public class IabHelper { - // Is debug logging enabled? - boolean mDebugLog = false; - String mDebugTag = "IabHelper"; - - // Is setup done? - boolean mSetupDone = false; - - // Has this object been disposed of? (If so, we should ignore callbacks, etc) - boolean mDisposed = false; - - // Do we need to dispose this object after an in-progress asynchronous operation? - boolean mDisposeAfterAsync = false; - - // Are subscriptions supported? - boolean mSubscriptionsSupported = false; - - // Is subscription update supported? - boolean mSubscriptionUpdateSupported = false; - - // Is an asynchronous operation in progress? - // (only one at a time can be in progress) - boolean mAsyncInProgress = false; - - // Ensure atomic access to mAsyncInProgress and mDisposeAfterAsync. - private final Object mAsyncInProgressLock = new Object(); - - // (for logging/debugging) - // if mAsyncInProgress == true, what asynchronous operation is in progress? - String mAsyncOperation = ""; - - // Context we were passed during initialization - Context mContext; - - // Connection to the service - IInAppBillingService mService; - ServiceConnection mServiceConn; - - // The request code used to launch purchase flow - int mRequestCode; - - // The item type of the current purchase flow - String mPurchasingItemType; - - // Public key for verifying signature, in base64 encoding - String mSignatureBase64 = null; - - // Billing response codes - public static final int BILLING_RESPONSE_RESULT_OK = 0; - public static final int BILLING_RESPONSE_RESULT_USER_CANCELED = 1; - public static final int BILLING_RESPONSE_RESULT_SERVICE_UNAVAILABLE = 2; - public static final int BILLING_RESPONSE_RESULT_BILLING_UNAVAILABLE = 3; - public static final int BILLING_RESPONSE_RESULT_ITEM_UNAVAILABLE = 4; - public static final int BILLING_RESPONSE_RESULT_DEVELOPER_ERROR = 5; - public static final int BILLING_RESPONSE_RESULT_ERROR = 6; - public static final int BILLING_RESPONSE_RESULT_ITEM_ALREADY_OWNED = 7; - public static final int BILLING_RESPONSE_RESULT_ITEM_NOT_OWNED = 8; - - // IAB Helper error codes - public static final int IABHELPER_ERROR_BASE = -1000; - public static final int IABHELPER_REMOTE_EXCEPTION = -1001; - public static final int IABHELPER_BAD_RESPONSE = -1002; - public static final int IABHELPER_VERIFICATION_FAILED = -1003; - public static final int IABHELPER_SEND_INTENT_FAILED = -1004; - public static final int IABHELPER_USER_CANCELLED = -1005; - public static final int IABHELPER_UNKNOWN_PURCHASE_RESPONSE = -1006; - public static final int IABHELPER_MISSING_TOKEN = -1007; - public static final int IABHELPER_UNKNOWN_ERROR = -1008; - public static final int IABHELPER_SUBSCRIPTIONS_NOT_AVAILABLE = -1009; - public static final int IABHELPER_INVALID_CONSUMPTION = -1010; - public static final int IABHELPER_SUBSCRIPTION_UPDATE_NOT_AVAILABLE = -1011; - - // Keys for the responses from InAppBillingService - public static final String RESPONSE_CODE = "RESPONSE_CODE"; - public static final String RESPONSE_GET_SKU_DETAILS_LIST = "DETAILS_LIST"; - public static final String RESPONSE_BUY_INTENT = "BUY_INTENT"; - public static final String RESPONSE_INAPP_PURCHASE_DATA = "INAPP_PURCHASE_DATA"; - public static final String RESPONSE_INAPP_SIGNATURE = "INAPP_DATA_SIGNATURE"; - public static final String RESPONSE_INAPP_ITEM_LIST = "INAPP_PURCHASE_ITEM_LIST"; - public static final String RESPONSE_INAPP_PURCHASE_DATA_LIST = "INAPP_PURCHASE_DATA_LIST"; - public static final String RESPONSE_INAPP_SIGNATURE_LIST = "INAPP_DATA_SIGNATURE_LIST"; - public static final String INAPP_CONTINUATION_TOKEN = "INAPP_CONTINUATION_TOKEN"; - - // Item types - public static final String ITEM_TYPE_INAPP = "inapp"; - public static final String ITEM_TYPE_SUBS = "subs"; - - // some fields on the getSkuDetails response bundle - public static final String GET_SKU_DETAILS_ITEM_LIST = "ITEM_ID_LIST"; - public static final String GET_SKU_DETAILS_ITEM_TYPE_LIST = "ITEM_TYPE_LIST"; - - /** - * Creates an instance. After creation, it will not yet be ready to use. You must perform - * setup by calling {@link #startSetup} and wait for setup to complete. This constructor does not - * block and is safe to call from a UI thread. - * - * @param ctx Your application or Activity context. Needed to bind to the in-app billing service. - * @param base64PublicKey Your application's public key, encoded in base64. - * This is used for verification of purchase signatures. You can find your app's base64-encoded - * public key in your application's page on Google Play Developer Console. Note that this - * is NOT your "developer public key". - */ - public IabHelper(Context ctx, String base64PublicKey) { - mContext = ctx.getApplicationContext(); - mSignatureBase64 = base64PublicKey; - logDebug("IAB helper created."); - } - - /** - * Enables or disable debug logging through LogCat. - */ - public void enableDebugLogging(boolean enable, String tag) { - checkNotDisposed(); - mDebugLog = enable; - mDebugTag = tag; - } - - public void enableDebugLogging(boolean enable) { - checkNotDisposed(); - mDebugLog = enable; - } - - /** - * Callback for setup process. This listener's {@link #onIabSetupFinished} method is called - * when the setup process is complete. - */ - public interface OnIabSetupFinishedListener { - /** - * Called to notify that setup is complete. - * - * @param result The result of the setup process. - */ - void onIabSetupFinished(IabResult result); - } - - /** - * Starts the setup process. This will start up the setup process asynchronously. - * You will be notified through the listener when the setup process is complete. - * This method is safe to call from a UI thread. - * - * @param listener The listener to notify when the setup process is complete. - */ - public void startSetup(final OnIabSetupFinishedListener listener) { - // If already set up, can't do it again. - checkNotDisposed(); - if (mSetupDone) throw new IllegalStateException("IAB helper is already set up."); - - // Connection to IAB service - logDebug("Starting in-app billing setup."); - mServiceConn = new ServiceConnection() { - @Override - public void onServiceDisconnected(ComponentName name) { - logDebug("Billing service disconnected."); - mService = null; - } - - @Override - public void onServiceConnected(ComponentName name, IBinder service) { - if (mDisposed) return; - logDebug("Billing service connected."); - mService = IInAppBillingService.Stub.asInterface(service); - String packageName = mContext.getPackageName(); - try { - logDebug("Checking for in-app billing 3 support."); - - // check for in-app billing v3 support - int response = mService.isBillingSupported(3, packageName, ITEM_TYPE_INAPP); - if (response != BILLING_RESPONSE_RESULT_OK) { - if (listener != null) listener.onIabSetupFinished(new IabResult(response, - "Error checking for billing v3 support.")); - - // if in-app purchases aren't supported, neither are subscriptions - mSubscriptionsSupported = false; - mSubscriptionUpdateSupported = false; - return; - } else { - logDebug("In-app billing version 3 supported for " + packageName); - } - - // Check for v5 subscriptions support. This is needed for - // getBuyIntentToReplaceSku which allows for subscription update - response = mService.isBillingSupported(5, packageName, ITEM_TYPE_SUBS); - if (response == BILLING_RESPONSE_RESULT_OK) { - logDebug("Subscription re-signup AVAILABLE."); - mSubscriptionUpdateSupported = true; - } else { - logDebug("Subscription re-signup not available."); - mSubscriptionUpdateSupported = false; - } - - if (mSubscriptionUpdateSupported) { - mSubscriptionsSupported = true; - } else { - // check for v3 subscriptions support - response = mService.isBillingSupported(3, packageName, ITEM_TYPE_SUBS); - if (response == BILLING_RESPONSE_RESULT_OK) { - logDebug("Subscriptions AVAILABLE."); - mSubscriptionsSupported = true; - } else { - logDebug("Subscriptions NOT AVAILABLE. Response: " + response); - mSubscriptionsSupported = false; - mSubscriptionUpdateSupported = false; - } - } - - mSetupDone = true; - } - catch (RemoteException e) { - if (listener != null) { - listener.onIabSetupFinished(new IabResult(IABHELPER_REMOTE_EXCEPTION, - "RemoteException while setting up in-app billing.")); - } - e.printStackTrace(); - return; - } - - if (listener != null) { - listener.onIabSetupFinished(new IabResult(BILLING_RESPONSE_RESULT_OK, "Setup successful.")); - } - } - }; - - Intent serviceIntent = new Intent("com.android.vending.billing.InAppBillingService.BIND"); - serviceIntent.setPackage("com.android.vending"); - List intentServices = mContext.getPackageManager().queryIntentServices(serviceIntent, 0); - if (intentServices != null && !intentServices.isEmpty()) { - // service available to handle that Intent - mContext.bindService(serviceIntent, mServiceConn, Context.BIND_AUTO_CREATE); - } - else { - // no service available to handle that Intent - if (listener != null) { - listener.onIabSetupFinished( - new IabResult(BILLING_RESPONSE_RESULT_BILLING_UNAVAILABLE, - "Billing service unavailable on device.")); - } - } - } - - /** - * Dispose of object, releasing resources. It's very important to call this - * method when you are done with this object. It will release any resources - * used by it such as service connections. Naturally, once the object is - * disposed of, it can't be used again. - */ - public void dispose() throws IabAsyncInProgressException { - synchronized (mAsyncInProgressLock) { - if (mAsyncInProgress) { - throw new IabAsyncInProgressException("Can't dispose because an async operation " + - "(" + mAsyncOperation + ") is in progress."); - } - } - logDebug("Disposing."); - mSetupDone = false; - if (mServiceConn != null) { - logDebug("Unbinding from service."); - if (mContext != null) mContext.unbindService(mServiceConn); - } - mDisposed = true; - mContext = null; - mServiceConn = null; - mService = null; - mPurchaseListener = null; - } - - /** - * Disposes of object, releasing resources. If there is an in-progress async operation, this - * method will queue the dispose to occur after the operation has finished. - */ - public void disposeWhenFinished() { - synchronized (mAsyncInProgressLock) { - if (mAsyncInProgress) { - logDebug("Will dispose after async operation finishes."); - mDisposeAfterAsync = true; - } else { - try { - dispose(); - } catch (IabAsyncInProgressException e) { - // Should never be thrown, because we call dispose() only after checking that - // there's not already an async operation in progress. - } - } - } - } - - private void checkNotDisposed() { - if (mDisposed) throw new IllegalStateException("IabHelper was disposed of, so it cannot be used."); - } - - /** Returns whether subscriptions are supported. */ - public boolean subscriptionsSupported() { - checkNotDisposed(); - return mSubscriptionsSupported; - } - - - /** - * Callback that notifies when a purchase is finished. - */ - public interface OnIabPurchaseFinishedListener { - /** - * Called to notify that an in-app purchase finished. If the purchase was successful, - * then the sku parameter specifies which item was purchased. If the purchase failed, - * the sku and extraData parameters may or may not be null, depending on how far the purchase - * process went. - * - * @param result The result of the purchase. - * @param info The purchase information (null if purchase failed) - */ - void onIabPurchaseFinished(IabResult result, Purchase info); - } - - // The listener registered on launchPurchaseFlow, which we have to call back when - // the purchase finishes - OnIabPurchaseFinishedListener mPurchaseListener; - - public void launchPurchaseFlow(Activity act, String sku, int requestCode, OnIabPurchaseFinishedListener listener) - throws IabAsyncInProgressException { - launchPurchaseFlow(act, sku, requestCode, listener, ""); - } - - public void launchPurchaseFlow(Activity act, String sku, int requestCode, - OnIabPurchaseFinishedListener listener, String extraData) - throws IabAsyncInProgressException { - launchPurchaseFlow(act, sku, ITEM_TYPE_INAPP, null, requestCode, listener, extraData); - } - - public void launchSubscriptionPurchaseFlow(Activity act, String sku, int requestCode, - OnIabPurchaseFinishedListener listener) throws IabAsyncInProgressException { - launchSubscriptionPurchaseFlow(act, sku, requestCode, listener, ""); - } - - public void launchSubscriptionPurchaseFlow(Activity act, String sku, int requestCode, - OnIabPurchaseFinishedListener listener, String extraData) - throws IabAsyncInProgressException { - launchPurchaseFlow(act, sku, ITEM_TYPE_SUBS, null, requestCode, listener, extraData); - } - - /** - * Initiate the UI flow for an in-app purchase. Call this method to initiate an in-app purchase, - * which will involve bringing up the Google Play screen. The calling activity will be paused - * while the user interacts with Google Play, and the result will be delivered via the - * activity's {@link android.app.Activity#onActivityResult} method, at which point you must call - * this object's {@link #handleActivityResult} method to continue the purchase flow. This method - * MUST be called from the UI thread of the Activity. - * - * @param act The calling activity. - * @param sku The sku of the item to purchase. - * @param itemType indicates if it's a product or a subscription (ITEM_TYPE_INAPP or - * ITEM_TYPE_SUBS) - * @param oldSkus A list of SKUs which the new SKU is replacing or null if there are none - * @param requestCode A request code (to differentiate from other responses -- as in - * {@link android.app.Activity#startActivityForResult}). - * @param listener The listener to notify when the purchase process finishes - * @param extraData Extra data (developer payload), which will be returned with the purchase - * data when the purchase completes. This extra data will be permanently bound to that - * purchase and will always be returned when the purchase is queried. - */ - public void launchPurchaseFlow(Activity act, String sku, String itemType, List oldSkus, - int requestCode, OnIabPurchaseFinishedListener listener, String extraData) - throws IabAsyncInProgressException { - checkNotDisposed(); - checkSetupDone("launchPurchaseFlow"); - flagStartAsync("launchPurchaseFlow"); - IabResult result; - - if (itemType.equals(ITEM_TYPE_SUBS) && !mSubscriptionsSupported) { - IabResult r = new IabResult(IABHELPER_SUBSCRIPTIONS_NOT_AVAILABLE, - "Subscriptions are not available."); - flagEndAsync(); - if (listener != null) listener.onIabPurchaseFinished(r, null); - return; - } - - try { - logDebug("Constructing buy intent for " + sku + ", item type: " + itemType); - Bundle buyIntentBundle; - if (oldSkus == null || oldSkus.isEmpty()) { - // Purchasing a new item or subscription re-signup - buyIntentBundle = mService.getBuyIntent(3, mContext.getPackageName(), sku, itemType, - extraData); - } else { - // Subscription upgrade/downgrade - if (!mSubscriptionUpdateSupported) { - IabResult r = new IabResult(IABHELPER_SUBSCRIPTION_UPDATE_NOT_AVAILABLE, - "Subscription updates are not available."); - flagEndAsync(); - if (listener != null) listener.onIabPurchaseFinished(r, null); - return; - } - buyIntentBundle = mService.getBuyIntentToReplaceSkus(5, mContext.getPackageName(), - oldSkus, sku, itemType, extraData); - } - int response = getResponseCodeFromBundle(buyIntentBundle); - if (response != BILLING_RESPONSE_RESULT_OK) { - logError("Unable to buy item, Error response: " + getResponseDesc(response)); - flagEndAsync(); - result = new IabResult(response, "Unable to buy item"); - if (listener != null) listener.onIabPurchaseFinished(result, null); - return; - } - - PendingIntent pendingIntent = buyIntentBundle.getParcelable(RESPONSE_BUY_INTENT); - logDebug("Launching buy intent for " + sku + ". Request code: " + requestCode); - mRequestCode = requestCode; - mPurchaseListener = listener; - mPurchasingItemType = itemType; - act.startIntentSenderForResult(pendingIntent.getIntentSender(), - requestCode, new Intent(), - Integer.valueOf(0), Integer.valueOf(0), - Integer.valueOf(0)); - } - catch (SendIntentException e) { - logError("SendIntentException while launching purchase flow for sku " + sku); - e.printStackTrace(); - flagEndAsync(); - - result = new IabResult(IABHELPER_SEND_INTENT_FAILED, "Failed to send intent."); - if (listener != null) listener.onIabPurchaseFinished(result, null); - } - catch (RemoteException e) { - logError("RemoteException while launching purchase flow for sku " + sku); - e.printStackTrace(); - flagEndAsync(); - - result = new IabResult(IABHELPER_REMOTE_EXCEPTION, "Remote exception while starting purchase flow"); - if (listener != null) listener.onIabPurchaseFinished(result, null); - } - } - - /** - * Handles an activity result that's part of the purchase flow in in-app billing. If you - * are calling {@link #launchPurchaseFlow}, then you must call this method from your - * Activity's {@link android.app.Activity@onActivityResult} method. This method - * MUST be called from the UI thread of the Activity. - * - * @param requestCode The requestCode as you received it. - * @param resultCode The resultCode as you received it. - * @param data The data (Intent) as you received it. - * @return Returns true if the result was related to a purchase flow and was handled; - * false if the result was not related to a purchase, in which case you should - * handle it normally. - */ - public boolean handleActivityResult(int requestCode, int resultCode, Intent data) { - IabResult result; - if (requestCode != mRequestCode) return false; - - checkNotDisposed(); - checkSetupDone("handleActivityResult"); - - // end of async purchase operation that started on launchPurchaseFlow - flagEndAsync(); - - if (data == null) { - logError("Null data in IAB activity result."); - result = new IabResult(IABHELPER_BAD_RESPONSE, "Null data in IAB result"); - if (mPurchaseListener != null) mPurchaseListener.onIabPurchaseFinished(result, null); - return true; - } - - int responseCode = getResponseCodeFromIntent(data); - String purchaseData = data.getStringExtra(RESPONSE_INAPP_PURCHASE_DATA); - String dataSignature = data.getStringExtra(RESPONSE_INAPP_SIGNATURE); - - if (resultCode == Activity.RESULT_OK && responseCode == BILLING_RESPONSE_RESULT_OK) { - logDebug("Successful resultcode from purchase activity."); - logDebug("Purchase data: " + purchaseData); - logDebug("Data signature: " + dataSignature); - logDebug("Extras: " + data.getExtras()); - logDebug("Expected item type: " + mPurchasingItemType); - - if (purchaseData == null || dataSignature == null) { - logError("BUG: either purchaseData or dataSignature is null."); - logDebug("Extras: " + data.getExtras().toString()); - result = new IabResult(IABHELPER_UNKNOWN_ERROR, "IAB returned null purchaseData or dataSignature"); - if (mPurchaseListener != null) mPurchaseListener.onIabPurchaseFinished(result, null); - return true; - } - - Purchase purchase = null; - try { - purchase = new Purchase(mPurchasingItemType, purchaseData, dataSignature); - String sku = purchase.getSku(); - - // Verify signature - if (!Security.verifyPurchase(mSignatureBase64, purchaseData, dataSignature)) { - logError("Purchase signature verification FAILED for sku " + sku); - result = new IabResult(IABHELPER_VERIFICATION_FAILED, "Signature verification failed for sku " + sku); - if (mPurchaseListener != null) mPurchaseListener.onIabPurchaseFinished(result, purchase); - return true; - } - logDebug("Purchase signature successfully verified."); - } - catch (JSONException e) { - logError("Failed to parse purchase data."); - e.printStackTrace(); - result = new IabResult(IABHELPER_BAD_RESPONSE, "Failed to parse purchase data."); - if (mPurchaseListener != null) mPurchaseListener.onIabPurchaseFinished(result, null); - return true; - } - - if (mPurchaseListener != null) { - mPurchaseListener.onIabPurchaseFinished(new IabResult(BILLING_RESPONSE_RESULT_OK, "Success"), purchase); - } - } - else if (resultCode == Activity.RESULT_OK) { - // result code was OK, but in-app billing response was not OK. - logDebug("Result code was OK but in-app billing response was not OK: " + getResponseDesc(responseCode)); - if (mPurchaseListener != null) { - result = new IabResult(responseCode, "Problem purchashing item."); - mPurchaseListener.onIabPurchaseFinished(result, null); - } - } - else if (resultCode == Activity.RESULT_CANCELED) { - logDebug("Purchase canceled - Response: " + getResponseDesc(responseCode)); - result = new IabResult(IABHELPER_USER_CANCELLED, "User canceled."); - if (mPurchaseListener != null) mPurchaseListener.onIabPurchaseFinished(result, null); - } - else { - logError("Purchase failed. Result code: " + Integer.toString(resultCode) - + ". Response: " + getResponseDesc(responseCode)); - result = new IabResult(IABHELPER_UNKNOWN_PURCHASE_RESPONSE, "Unknown purchase response."); - if (mPurchaseListener != null) mPurchaseListener.onIabPurchaseFinished(result, null); - } - return true; - } - - public Inventory queryInventory() throws IabException { - return queryInventory(false, null, null); - } - - /** - * Queries the inventory. This will query all owned items from the server, as well as - * information on additional skus, if specified. This method may block or take long to execute. - * Do not call from a UI thread. For that, use the non-blocking version {@link #queryInventoryAsync}. - * - * @param querySkuDetails if true, SKU details (price, description, etc) will be queried as well - * as purchase information. - * @param moreItemSkus additional PRODUCT skus to query information on, regardless of ownership. - * Ignored if null or if querySkuDetails is false. - * @param moreSubsSkus additional SUBSCRIPTIONS skus to query information on, regardless of ownership. - * Ignored if null or if querySkuDetails is false. - * @throws IabException if a problem occurs while refreshing the inventory. - */ - public Inventory queryInventory(boolean querySkuDetails, List moreItemSkus, - List moreSubsSkus) throws IabException { - checkNotDisposed(); - checkSetupDone("queryInventory"); - try { - Inventory inv = new Inventory(); - int r = queryPurchases(inv, ITEM_TYPE_INAPP); - if (r != BILLING_RESPONSE_RESULT_OK) { - throw new IabException(r, "Error refreshing inventory (querying owned items)."); - } - - if (querySkuDetails) { - r = querySkuDetails(ITEM_TYPE_INAPP, inv, moreItemSkus); - if (r != BILLING_RESPONSE_RESULT_OK) { - throw new IabException(r, "Error refreshing inventory (querying prices of items)."); - } - } - - // if subscriptions are supported, then also query for subscriptions - if (mSubscriptionsSupported) { - r = queryPurchases(inv, ITEM_TYPE_SUBS); - if (r != BILLING_RESPONSE_RESULT_OK) { - throw new IabException(r, "Error refreshing inventory (querying owned subscriptions)."); - } - - if (querySkuDetails) { - r = querySkuDetails(ITEM_TYPE_SUBS, inv, moreSubsSkus); - if (r != BILLING_RESPONSE_RESULT_OK) { - throw new IabException(r, "Error refreshing inventory (querying prices of subscriptions)."); - } - } - } - - return inv; - } - catch (RemoteException e) { - throw new IabException(IABHELPER_REMOTE_EXCEPTION, "Remote exception while refreshing inventory.", e); - } - catch (JSONException e) { - throw new IabException(IABHELPER_BAD_RESPONSE, "Error parsing JSON response while refreshing inventory.", e); - } - } - - /** - * Listener that notifies when an inventory query operation completes. - */ - public interface QueryInventoryFinishedListener { - /** - * Called to notify that an inventory query operation completed. - * - * @param result The result of the operation. - * @param inv The inventory. - */ - void onQueryInventoryFinished(IabResult result, Inventory inv); - } - - - /** - * Asynchronous wrapper for inventory query. This will perform an inventory - * query as described in {@link #queryInventory}, but will do so asynchronously - * and call back the specified listener upon completion. This method is safe to - * call from a UI thread. - * - * @param querySkuDetails as in {@link #queryInventory} - * @param moreItemSkus as in {@link #queryInventory} - * @param moreSubsSkus as in {@link #queryInventory} - * @param listener The listener to notify when the refresh operation completes. - */ - public void queryInventoryAsync(final boolean querySkuDetails, final List moreItemSkus, - final List moreSubsSkus, final QueryInventoryFinishedListener listener) - throws IabAsyncInProgressException { - final Handler handler = new Handler(); - checkNotDisposed(); - checkSetupDone("queryInventory"); - flagStartAsync("refresh inventory"); - (new Thread(new Runnable() { - public void run() { - IabResult result = new IabResult(BILLING_RESPONSE_RESULT_OK, "Inventory refresh successful."); - Inventory inv = null; - try { - inv = queryInventory(querySkuDetails, moreItemSkus, moreSubsSkus); - } - catch (IabException ex) { - result = ex.getResult(); - } - - flagEndAsync(); - - final IabResult result_f = result; - final Inventory inv_f = inv; - if (!mDisposed && listener != null) { - handler.post(new Runnable() { - public void run() { - listener.onQueryInventoryFinished(result_f, inv_f); - } - }); - } - } - })).start(); - } - - public void queryInventoryAsync(QueryInventoryFinishedListener listener) - throws IabAsyncInProgressException{ - queryInventoryAsync(false, null, null, listener); - } - - /** - * Consumes a given in-app product. Consuming can only be done on an item - * that's owned, and as a result of consumption, the user will no longer own it. - * This method may block or take long to return. Do not call from the UI thread. - * For that, see {@link #consumeAsync}. - * - * @param itemInfo The PurchaseInfo that represents the item to consume. - * @throws IabException if there is a problem during consumption. - */ - void consume(Purchase itemInfo) throws IabException { - checkNotDisposed(); - checkSetupDone("consume"); - - if (!itemInfo.mItemType.equals(ITEM_TYPE_INAPP)) { - throw new IabException(IABHELPER_INVALID_CONSUMPTION, - "Items of type '" + itemInfo.mItemType + "' can't be consumed."); - } - - try { - String token = itemInfo.getToken(); - String sku = itemInfo.getSku(); - if (token == null || token.equals("")) { - logError("Can't consume "+ sku + ". No token."); - throw new IabException(IABHELPER_MISSING_TOKEN, "PurchaseInfo is missing token for sku: " - + sku + " " + itemInfo); - } - - logDebug("Consuming sku: " + sku + ", token: " + token); - int response = mService.consumePurchase(3, mContext.getPackageName(), token); - if (response == BILLING_RESPONSE_RESULT_OK) { - logDebug("Successfully consumed sku: " + sku); - } - else { - logDebug("Error consuming consuming sku " + sku + ". " + getResponseDesc(response)); - throw new IabException(response, "Error consuming sku " + sku); - } - } - catch (RemoteException e) { - throw new IabException(IABHELPER_REMOTE_EXCEPTION, "Remote exception while consuming. PurchaseInfo: " + itemInfo, e); - } - } - - /** - * Callback that notifies when a consumption operation finishes. - */ - public interface OnConsumeFinishedListener { - /** - * Called to notify that a consumption has finished. - * - * @param purchase The purchase that was (or was to be) consumed. - * @param result The result of the consumption operation. - */ - void onConsumeFinished(Purchase purchase, IabResult result); - } - - /** - * Callback that notifies when a multi-item consumption operation finishes. - */ - public interface OnConsumeMultiFinishedListener { - /** - * Called to notify that a consumption of multiple items has finished. - * - * @param purchases The purchases that were (or were to be) consumed. - * @param results The results of each consumption operation, corresponding to each - * sku. - */ - void onConsumeMultiFinished(List purchases, List results); - } - - /** - * Asynchronous wrapper to item consumption. Works like {@link #consume}, but - * performs the consumption in the background and notifies completion through - * the provided listener. This method is safe to call from a UI thread. - * - * @param purchase The purchase to be consumed. - * @param listener The listener to notify when the consumption operation finishes. - */ - public void consumeAsync(Purchase purchase, OnConsumeFinishedListener listener) - throws IabAsyncInProgressException { - checkNotDisposed(); - checkSetupDone("consume"); - List purchases = new ArrayList(); - purchases.add(purchase); - consumeAsyncInternal(purchases, listener, null); - } - - /** - * Same as {@link #consumeAsync}, but for multiple items at once. - * @param purchases The list of PurchaseInfo objects representing the purchases to consume. - * @param listener The listener to notify when the consumption operation finishes. - */ - public void consumeAsync(List purchases, OnConsumeMultiFinishedListener listener) - throws IabAsyncInProgressException { - checkNotDisposed(); - checkSetupDone("consume"); - consumeAsyncInternal(purchases, null, listener); - } - - /** - * Returns a human-readable description for the given response code. - * - * @param code The response code - * @return A human-readable string explaining the result code. - * It also includes the result code numerically. - */ - public static String getResponseDesc(int code) { - String[] iab_msgs = ("0:OK/1:User Canceled/2:Unknown/" + - "3:Billing Unavailable/4:Item unavailable/" + - "5:Developer Error/6:Error/7:Item Already Owned/" + - "8:Item not owned").split("/"); - String[] iabhelper_msgs = ("0:OK/-1001:Remote exception during initialization/" + - "-1002:Bad response received/" + - "-1003:Purchase signature verification failed/" + - "-1004:Send intent failed/" + - "-1005:User cancelled/" + - "-1006:Unknown purchase response/" + - "-1007:Missing token/" + - "-1008:Unknown error/" + - "-1009:Subscriptions not available/" + - "-1010:Invalid consumption attempt").split("/"); - - if (code <= IABHELPER_ERROR_BASE) { - int index = IABHELPER_ERROR_BASE - code; - if (index >= 0 && index < iabhelper_msgs.length) return iabhelper_msgs[index]; - else return String.valueOf(code) + ":Unknown IAB Helper Error"; - } - else if (code < 0 || code >= iab_msgs.length) - return String.valueOf(code) + ":Unknown"; - else - return iab_msgs[code]; - } - - - // Checks that setup was done; if not, throws an exception. - void checkSetupDone(String operation) { - if (!mSetupDone) { - logError("Illegal state for operation (" + operation + "): IAB helper is not set up."); - throw new IllegalStateException("IAB helper is not set up. Can't perform operation: " + operation); - } - } - - // Workaround to bug where sometimes response codes come as Long instead of Integer - int getResponseCodeFromBundle(Bundle b) { - Object o = b.get(RESPONSE_CODE); - if (o == null) { - logDebug("Bundle with null response code, assuming OK (known issue)"); - return BILLING_RESPONSE_RESULT_OK; - } - else if (o instanceof Integer) return ((Integer)o).intValue(); - else if (o instanceof Long) return (int)((Long)o).longValue(); - else { - logError("Unexpected type for bundle response code."); - logError(o.getClass().getName()); - throw new RuntimeException("Unexpected type for bundle response code: " + o.getClass().getName()); - } - } - - // Workaround to bug where sometimes response codes come as Long instead of Integer - int getResponseCodeFromIntent(Intent i) { - Object o = i.getExtras().get(RESPONSE_CODE); - if (o == null) { - logError("Intent with no response code, assuming OK (known issue)"); - return BILLING_RESPONSE_RESULT_OK; - } - else if (o instanceof Integer) return ((Integer)o).intValue(); - else if (o instanceof Long) return (int)((Long)o).longValue(); - else { - logError("Unexpected type for intent response code."); - logError(o.getClass().getName()); - throw new RuntimeException("Unexpected type for intent response code: " + o.getClass().getName()); - } - } - - void flagStartAsync(String operation) throws IabAsyncInProgressException { - synchronized (mAsyncInProgressLock) { - if (mAsyncInProgress) { - throw new IabAsyncInProgressException("Can't start async operation (" + - operation + ") because another async operation (" + mAsyncOperation + - ") is in progress."); - } - mAsyncOperation = operation; - mAsyncInProgress = true; - logDebug("Starting async operation: " + operation); - } - } - - void flagEndAsync() { - synchronized (mAsyncInProgressLock) { - logDebug("Ending async operation: " + mAsyncOperation); - mAsyncOperation = ""; - mAsyncInProgress = false; - if (mDisposeAfterAsync) { - try { - dispose(); - } catch (IabAsyncInProgressException e) { - // Should not be thrown, because we reset mAsyncInProgress immediately before - // calling dispose(). - } - } - } - } - - /** - * Exception thrown when the requested operation cannot be started because an async operation - * is still in progress. - */ - public static class IabAsyncInProgressException extends Exception { - public IabAsyncInProgressException(String message) { - super(message); - } - } - - int queryPurchases(Inventory inv, String itemType) throws JSONException, RemoteException { - // Query purchases - logDebug("Querying owned items, item type: " + itemType); - logDebug("Package name: " + mContext.getPackageName()); - boolean verificationFailed = false; - String continueToken = null; - - do { - logDebug("Calling getPurchases with continuation token: " + continueToken); - Bundle ownedItems = mService.getPurchases(3, mContext.getPackageName(), - itemType, continueToken); - - int response = getResponseCodeFromBundle(ownedItems); - logDebug("Owned items response: " + String.valueOf(response)); - if (response != BILLING_RESPONSE_RESULT_OK) { - logDebug("getPurchases() failed: " + getResponseDesc(response)); - return response; - } - if (!ownedItems.containsKey(RESPONSE_INAPP_ITEM_LIST) - || !ownedItems.containsKey(RESPONSE_INAPP_PURCHASE_DATA_LIST) - || !ownedItems.containsKey(RESPONSE_INAPP_SIGNATURE_LIST)) { - logError("Bundle returned from getPurchases() doesn't contain required fields."); - return IABHELPER_BAD_RESPONSE; - } - - ArrayList ownedSkus = ownedItems.getStringArrayList( - RESPONSE_INAPP_ITEM_LIST); - ArrayList purchaseDataList = ownedItems.getStringArrayList( - RESPONSE_INAPP_PURCHASE_DATA_LIST); - ArrayList signatureList = ownedItems.getStringArrayList( - RESPONSE_INAPP_SIGNATURE_LIST); - - for (int i = 0; i < purchaseDataList.size(); ++i) { - String purchaseData = purchaseDataList.get(i); - String signature = signatureList.get(i); - String sku = ownedSkus.get(i); - if (Security.verifyPurchase(mSignatureBase64, purchaseData, signature)) { - logDebug("Sku is owned: " + sku); - Purchase purchase = new Purchase(itemType, purchaseData, signature); - - if (TextUtils.isEmpty(purchase.getToken())) { - logWarn("BUG: empty/null token!"); - logDebug("Purchase data: " + purchaseData); - } - - // Record ownership and token - inv.addPurchase(purchase); - } - else { - logWarn("Purchase signature verification **FAILED**. Not adding item."); - logDebug(" Purchase data: " + purchaseData); - logDebug(" Signature: " + signature); - verificationFailed = true; - } - } - - continueToken = ownedItems.getString(INAPP_CONTINUATION_TOKEN); - logDebug("Continuation token: " + continueToken); - } while (!TextUtils.isEmpty(continueToken)); - - return verificationFailed ? IABHELPER_VERIFICATION_FAILED : BILLING_RESPONSE_RESULT_OK; - } - - int querySkuDetails(String itemType, Inventory inv, List moreSkus) - throws RemoteException, JSONException { - logDebug("Querying SKU details."); - ArrayList skuList = new ArrayList(); - skuList.addAll(inv.getAllOwnedSkus(itemType)); - if (moreSkus != null) { - for (String sku : moreSkus) { - if (!skuList.contains(sku)) { - skuList.add(sku); - } - } - } - - if (skuList.size() == 0) { - logDebug("queryPrices: nothing to do because there are no SKUs."); - return BILLING_RESPONSE_RESULT_OK; - } - - // Split the sku list in blocks of no more than 20 elements. - ArrayList> packs = new ArrayList>(); - ArrayList tempList; - int n = skuList.size() / 20; - int mod = skuList.size() % 20; - for (int i = 0; i < n; i++) { - tempList = new ArrayList(); - for (String s : skuList.subList(i * 20, i * 20 + 20)) { - tempList.add(s); - } - packs.add(tempList); - } - if (mod != 0) { - tempList = new ArrayList(); - for (String s : skuList.subList(n * 20, n * 20 + mod)) { - tempList.add(s); - } - packs.add(tempList); - } - - for (ArrayList skuPartList : packs) { - Bundle querySkus = new Bundle(); - querySkus.putStringArrayList(GET_SKU_DETAILS_ITEM_LIST, skuPartList); - Bundle skuDetails = mService.getSkuDetails(3, mContext.getPackageName(), - itemType, querySkus); - - if (!skuDetails.containsKey(RESPONSE_GET_SKU_DETAILS_LIST)) { - int response = getResponseCodeFromBundle(skuDetails); - if (response != BILLING_RESPONSE_RESULT_OK) { - logDebug("getSkuDetails() failed: " + getResponseDesc(response)); - return response; - } else { - logError("getSkuDetails() returned a bundle with neither an error nor a detail list."); - return IABHELPER_BAD_RESPONSE; - } - } - - ArrayList responseList = skuDetails.getStringArrayList( - RESPONSE_GET_SKU_DETAILS_LIST); - - for (String thisResponse : responseList) { - SkuDetails d = new SkuDetails(itemType, thisResponse); - logDebug("Got sku details: " + d); - inv.addSkuDetails(d); - } - } - - return BILLING_RESPONSE_RESULT_OK; - } - - void consumeAsyncInternal(final List purchases, - final OnConsumeFinishedListener singleListener, - final OnConsumeMultiFinishedListener multiListener) - throws IabAsyncInProgressException { - final Handler handler = new Handler(); - flagStartAsync("consume"); - (new Thread(new Runnable() { - public void run() { - final List results = new ArrayList(); - for (Purchase purchase : purchases) { - try { - consume(purchase); - results.add(new IabResult(BILLING_RESPONSE_RESULT_OK, "Successful consume of sku " + purchase.getSku())); - } - catch (IabException ex) { - results.add(ex.getResult()); - } - } - - flagEndAsync(); - if (!mDisposed && singleListener != null) { - handler.post(new Runnable() { - public void run() { - singleListener.onConsumeFinished(purchases.get(0), results.get(0)); - } - }); - } - if (!mDisposed && multiListener != null) { - handler.post(new Runnable() { - public void run() { - multiListener.onConsumeMultiFinished(purchases, results); - } - }); - } - } - })).start(); - } - - void logDebug(String msg) { - if (mDebugLog) Log.d(mDebugTag, msg); - } - - void logError(String msg) { - Log.e(mDebugTag, "In-app billing error: " + msg); - } - - void logWarn(String msg) { - Log.w(mDebugTag, "In-app billing warning: " + msg); - } -} diff --git a/Android/app/src/main/java/emu/project64/inAppPurchase/IabResult.java b/Android/app/src/main/java/emu/project64/inAppPurchase/IabResult.java deleted file mode 100644 index c59df03f9..000000000 --- a/Android/app/src/main/java/emu/project64/inAppPurchase/IabResult.java +++ /dev/null @@ -1,45 +0,0 @@ -/* Copyright (c) 2012 Google Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package emu.project64.inAppPurchase; - -/** - * Represents the result of an in-app billing operation. - * A result is composed of a response code (an integer) and possibly a - * message (String). You can get those by calling - * {@link #getResponse} and {@link #getMessage()}, respectively. You - * can also inquire whether a result is a success or a failure by - * calling {@link #isSuccess()} and {@link #isFailure()}. - */ -public class IabResult { - int mResponse; - String mMessage; - - public IabResult(int response, String message) { - mResponse = response; - if (message == null || message.trim().length() == 0) { - mMessage = IabHelper.getResponseDesc(response); - } - else { - mMessage = message + " (response: " + IabHelper.getResponseDesc(response) + ")"; - } - } - public int getResponse() { return mResponse; } - public String getMessage() { return mMessage; } - public boolean isSuccess() { return mResponse == IabHelper.BILLING_RESPONSE_RESULT_OK; } - public boolean isFailure() { return !isSuccess(); } - public String toString() { return "IabResult: " + getMessage(); } -} - diff --git a/Android/app/src/main/java/emu/project64/inAppPurchase/Inventory.java b/Android/app/src/main/java/emu/project64/inAppPurchase/Inventory.java deleted file mode 100644 index ccd1c5d8e..000000000 --- a/Android/app/src/main/java/emu/project64/inAppPurchase/Inventory.java +++ /dev/null @@ -1,91 +0,0 @@ -/* Copyright (c) 2012 Google Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package emu.project64.inAppPurchase; - -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -/** - * Represents a block of information about in-app items. - * An Inventory is returned by such methods as {@link IabHelper#queryInventory}. - */ -public class Inventory { - Map mSkuMap = new HashMap(); - Map mPurchaseMap = new HashMap(); - - Inventory() { } - - /** Returns the listing details for an in-app product. */ - public SkuDetails getSkuDetails(String sku) { - return mSkuMap.get(sku); - } - - /** Returns purchase information for a given product, or null if there is no purchase. */ - public Purchase getPurchase(String sku) { - return mPurchaseMap.get(sku); - } - - /** Returns whether or not there exists a purchase of the given product. */ - public boolean hasPurchase(String sku) { - return mPurchaseMap.containsKey(sku); - } - - /** Return whether or not details about the given product are available. */ - public boolean hasDetails(String sku) { - return mSkuMap.containsKey(sku); - } - - /** - * Erase a purchase (locally) from the inventory, given its product ID. This just - * modifies the Inventory object locally and has no effect on the server! This is - * useful when you have an existing Inventory object which you know to be up to date, - * and you have just consumed an item successfully, which means that erasing its - * purchase data from the Inventory you already have is quicker than querying for - * a new Inventory. - */ - public void erasePurchase(String sku) { - if (mPurchaseMap.containsKey(sku)) mPurchaseMap.remove(sku); - } - - /** Returns a list of all owned product IDs. */ - List getAllOwnedSkus() { - return new ArrayList(mPurchaseMap.keySet()); - } - - /** Returns a list of all owned product IDs of a given type */ - List getAllOwnedSkus(String itemType) { - List result = new ArrayList(); - for (Purchase p : mPurchaseMap.values()) { - if (p.getItemType().equals(itemType)) result.add(p.getSku()); - } - return result; - } - - /** Returns a list of all purchases. */ - List getAllPurchases() { - return new ArrayList(mPurchaseMap.values()); - } - - void addSkuDetails(SkuDetails d) { - mSkuMap.put(d.getSku(), d); - } - - void addPurchase(Purchase p) { - mPurchaseMap.put(p.getSku(), p); - } -} diff --git a/Android/app/src/main/java/emu/project64/inAppPurchase/Purchase.java b/Android/app/src/main/java/emu/project64/inAppPurchase/Purchase.java deleted file mode 100644 index 62a087779..000000000 --- a/Android/app/src/main/java/emu/project64/inAppPurchase/Purchase.java +++ /dev/null @@ -1,66 +0,0 @@ -/* Copyright (c) 2012 Google Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package emu.project64.inAppPurchase; - -import org.json.JSONException; -import org.json.JSONObject; - -/** - * Represents an in-app billing purchase. - */ -public class Purchase { - String mItemType; // ITEM_TYPE_INAPP or ITEM_TYPE_SUBS - String mOrderId; - String mPackageName; - String mSku; - long mPurchaseTime; - int mPurchaseState; - String mDeveloperPayload; - String mToken; - String mOriginalJson; - String mSignature; - boolean mIsAutoRenewing; - - public Purchase(String itemType, String jsonPurchaseInfo, String signature) throws JSONException { - mItemType = itemType; - mOriginalJson = jsonPurchaseInfo; - JSONObject o = new JSONObject(mOriginalJson); - mOrderId = o.optString("orderId"); - mPackageName = o.optString("packageName"); - mSku = o.optString("productId"); - mPurchaseTime = o.optLong("purchaseTime"); - mPurchaseState = o.optInt("purchaseState"); - mDeveloperPayload = o.optString("developerPayload"); - mToken = o.optString("token", o.optString("purchaseToken")); - mIsAutoRenewing = o.optBoolean("autoRenewing"); - mSignature = signature; - } - - public String getItemType() { return mItemType; } - public String getOrderId() { return mOrderId; } - public String getPackageName() { return mPackageName; } - public String getSku() { return mSku; } - public long getPurchaseTime() { return mPurchaseTime; } - public int getPurchaseState() { return mPurchaseState; } - public String getDeveloperPayload() { return mDeveloperPayload; } - public String getToken() { return mToken; } - public String getOriginalJson() { return mOriginalJson; } - public String getSignature() { return mSignature; } - public boolean isAutoRenewing() { return mIsAutoRenewing; } - - @Override - public String toString() { return "PurchaseInfo(type:" + mItemType + "):" + mOriginalJson; } -} diff --git a/Android/app/src/main/java/emu/project64/inAppPurchase/Security.java b/Android/app/src/main/java/emu/project64/inAppPurchase/Security.java deleted file mode 100644 index 5e7c4b476..000000000 --- a/Android/app/src/main/java/emu/project64/inAppPurchase/Security.java +++ /dev/null @@ -1,121 +0,0 @@ -/* Copyright (c) 2012 Google Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package emu.project64.inAppPurchase; - -import android.text.TextUtils; -import android.util.Base64; -import android.util.Log; - -import java.security.InvalidKeyException; -import java.security.KeyFactory; -import java.security.NoSuchAlgorithmException; -import java.security.PublicKey; -import java.security.Signature; -import java.security.SignatureException; -import java.security.spec.InvalidKeySpecException; -import java.security.spec.X509EncodedKeySpec; - -/** - * Security-related methods. For a secure implementation, all of this code - * should be implemented on a server that communicates with the - * application on the device. For the sake of simplicity and clarity of this - * example, this code is included here and is executed on the device. If you - * must verify the purchases on the phone, you should obfuscate this code to - * make it harder for an attacker to replace the code with stubs that treat all - * purchases as verified. - */ -public class Security { - private static final String TAG = "IABUtil/Security"; - - private static final String KEY_FACTORY_ALGORITHM = "RSA"; - private static final String SIGNATURE_ALGORITHM = "SHA1withRSA"; - - /** - * Verifies that the data was signed with the given signature, and returns - * the verified purchase. The data is in JSON format and signed - * with a private key. The data also contains the {@link PurchaseState} - * and product ID of the purchase. - * @param base64PublicKey the base64-encoded public key to use for verifying. - * @param signedData the signed JSON string (signed, not encrypted) - * @param signature the signature for the data, signed with the private key - */ - public static boolean verifyPurchase(String base64PublicKey, String signedData, String signature) { - if (TextUtils.isEmpty(signedData) || TextUtils.isEmpty(base64PublicKey) || - TextUtils.isEmpty(signature)) { - Log.e(TAG, "Purchase verification failed: missing data."); - return false; - } - - PublicKey key = Security.generatePublicKey(base64PublicKey); - return Security.verify(key, signedData, signature); - } - - /** - * Generates a PublicKey instance from a string containing the - * Base64-encoded public key. - * - * @param encodedPublicKey Base64-encoded public key - * @throws IllegalArgumentException if encodedPublicKey is invalid - */ - public static PublicKey generatePublicKey(String encodedPublicKey) { - try { - byte[] decodedKey = Base64.decode(encodedPublicKey, Base64.DEFAULT); - KeyFactory keyFactory = KeyFactory.getInstance(KEY_FACTORY_ALGORITHM); - return keyFactory.generatePublic(new X509EncodedKeySpec(decodedKey)); - } catch (NoSuchAlgorithmException e) { - throw new RuntimeException(e); - } catch (InvalidKeySpecException e) { - Log.e(TAG, "Invalid key specification."); - throw new IllegalArgumentException(e); - } - } - - /** - * Verifies that the signature from the server matches the computed - * signature on the data. Returns true if the data is correctly signed. - * - * @param publicKey public key associated with the developer account - * @param signedData signed data from server - * @param signature server signature - * @return true if the data and signature match - */ - public static boolean verify(PublicKey publicKey, String signedData, String signature) { - byte[] signatureBytes; - try { - signatureBytes = Base64.decode(signature, Base64.DEFAULT); - } catch (IllegalArgumentException e) { - Log.e(TAG, "Base64 decoding failed."); - return false; - } - try { - Signature sig = Signature.getInstance(SIGNATURE_ALGORITHM); - sig.initVerify(publicKey); - sig.update(signedData.getBytes()); - if (!sig.verify(signatureBytes)) { - Log.e(TAG, "Signature verification failed."); - return false; - } - return true; - } catch (NoSuchAlgorithmException e) { - Log.e(TAG, "NoSuchAlgorithmException."); - } catch (InvalidKeyException e) { - Log.e(TAG, "Invalid key specification."); - } catch (SignatureException e) { - Log.e(TAG, "Signature exception."); - } - return false; - } -} diff --git a/Android/app/src/main/java/emu/project64/inAppPurchase/SkuDetails.java b/Android/app/src/main/java/emu/project64/inAppPurchase/SkuDetails.java deleted file mode 100644 index f9da64201..000000000 --- a/Android/app/src/main/java/emu/project64/inAppPurchase/SkuDetails.java +++ /dev/null @@ -1,64 +0,0 @@ -/* Copyright (c) 2012 Google Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package emu.project64.inAppPurchase; - -import org.json.JSONException; -import org.json.JSONObject; - -/** - * Represents an in-app product's listing details. - */ -public class SkuDetails { - private final String mItemType; - private final String mSku; - private final String mType; - private final String mPrice; - private final long mPriceAmountMicros; - private final String mPriceCurrencyCode; - private final String mTitle; - private final String mDescription; - private final String mJson; - - public SkuDetails(String jsonSkuDetails) throws JSONException { - this(IabHelper.ITEM_TYPE_INAPP, jsonSkuDetails); - } - - public SkuDetails(String itemType, String jsonSkuDetails) throws JSONException { - mItemType = itemType; - mJson = jsonSkuDetails; - JSONObject o = new JSONObject(mJson); - mSku = o.optString("productId"); - mType = o.optString("type"); - mPrice = o.optString("price"); - mPriceAmountMicros = o.optLong("price_amount_micros"); - mPriceCurrencyCode = o.optString("price_currency_code"); - mTitle = o.optString("title"); - mDescription = o.optString("description"); - } - - public String getSku() { return mSku; } - public String getType() { return mType; } - public String getPrice() { return mPrice; } - public long getPriceAmountMicros() { return mPriceAmountMicros; } - public String getPriceCurrencyCode() { return mPriceCurrencyCode; } - public String getTitle() { return mTitle; } - public String getDescription() { return mDescription; } - - @Override - public String toString() { - return "SkuDetails:" + mJson; - } -} diff --git a/Android/app/src/main/java/emu/project64/input/PeripheralController.java b/Android/app/src/main/java/emu/project64/input/PeripheralController.java index 13ecea245..ebfe47d74 100644 --- a/Android/app/src/main/java/emu/project64/input/PeripheralController.java +++ b/Android/app/src/main/java/emu/project64/input/PeripheralController.java @@ -141,14 +141,14 @@ public class PeripheralController extends AbstractController implements if( magnitude > mDeadzoneFraction ) { // Normalize the vector - float normalizedX = rawX / magnitude; + /*float normalizedX = rawX / magnitude; float normalizedY = rawY / magnitude; // Rescale strength to account for deadzone magnitude = ( magnitude - mDeadzoneFraction ) / ( 1f - mDeadzoneFraction ); magnitude = Utility.clamp( magnitude, 0f, 1f ); mState.axisFractionX = normalizedX * magnitude; - mState.axisFractionY = normalizedY * magnitude; + mState.axisFractionY = normalizedY * magnitude;*/ } else { diff --git a/Android/app/src/main/java/emu/project64/input/map/TouchMap.java b/Android/app/src/main/java/emu/project64/input/map/TouchMap.java index bd7233165..e423489c7 100644 --- a/Android/app/src/main/java/emu/project64/input/map/TouchMap.java +++ b/Android/app/src/main/java/emu/project64/input/map/TouchMap.java @@ -377,9 +377,10 @@ public class TouchMap */ public float getAnalogStrength( float displacement ) { - displacement /= scale; + /*displacement /= scale; float p = ( displacement - analogDeadzone ) / ( analogMaximum - analogDeadzone ); - return Utility.clamp( p, 0.0f, 1.0f ); + return Utility.clamp( p, 0.0f, 1.0f );*/ + return 0.0f; } /** diff --git a/Android/app/src/main/java/emu/project64/input/provider/AbstractProvider.java b/Android/app/src/main/java/emu/project64/input/provider/AbstractProvider.java index 003b3946c..4ac017d90 100644 --- a/Android/app/src/main/java/emu/project64/input/provider/AbstractProvider.java +++ b/Android/app/src/main/java/emu/project64/input/provider/AbstractProvider.java @@ -3,7 +3,6 @@ package emu.project64.input.provider; import java.util.ArrayList; import emu.project64.AndroidDevice; -import tv.ouya.console.api.OuyaController; import android.annotation.TargetApi; import android.view.InputDevice; import android.view.KeyEvent; @@ -214,7 +213,7 @@ public abstract class AbstractProvider { if( inputCode > 0 ) { - if( AndroidDevice.IS_HONEYCOMB_MR1 ) + /*if( AndroidDevice.IS_HONEYCOMB_MR1 ) { String name = null; if( inputCode != -1 && AndroidDevice.IS_OUYA_HARDWARE ) @@ -255,14 +254,14 @@ public abstract class AbstractProvider else return name + " (" + KeyEvent.keyCodeToString( inputCode ) + ")"; } - else + else*/ return "KEYCODE_" + inputCode; } else if( inputCode < 0 ) { int axis = inputToAxisCode( inputCode ); String direction = inputToAxisDirection( inputCode ) ? " (+)" : " (-)"; - if( AndroidDevice.IS_HONEYCOMB_MR1 ) + /*if( AndroidDevice.IS_HONEYCOMB_MR1 ) { String name = null; if( axis != -1 && AndroidDevice.IS_OUYA_HARDWARE ) @@ -285,7 +284,7 @@ public abstract class AbstractProvider else return name + " (" + MotionEvent.axisToString( axis ) + ")" + direction; } - else + else*/ return "AXIS_" + axis + direction; } else diff --git a/Android/app/src/main/java/emu/project64/jni/AudioSettingID.java b/Android/app/src/main/java/emu/project64/jni/AudioSettingID.java deleted file mode 100644 index a7079a5ab..000000000 --- a/Android/app/src/main/java/emu/project64/jni/AudioSettingID.java +++ /dev/null @@ -1,30 +0,0 @@ -package emu.project64.jni; - -public enum AudioSettingID -{ - Output_SwapChannels, - Output_DefaultFrequency, - Buffer_PrimarySize, - Buffer_SecondarySize, - Buffer_SecondaryNbr, - Logging_LogAudioInitShutdown, - Logging_LogAudioInterface, - ; - - private int value; - - public int getValue() - { - return this.value; - } - private static final class StaticFields - { - public static int Counter = 0; - } - - private AudioSettingID() - { - this.value = StaticFields.Counter; - StaticFields.Counter += 1; - } -} diff --git a/Android/app/src/main/java/emu/project64/jni/NativeConstants.java b/Android/app/src/main/java/emu/project64/jni/NativeConstants.java deleted file mode 100644 index 2d5df7583..000000000 --- a/Android/app/src/main/java/emu/project64/jni/NativeConstants.java +++ /dev/null @@ -1,11 +0,0 @@ -package emu.project64.jni; - -public class NativeConstants -{ - // @formatter:off - public static final int EMULATOR_STATE_UNKNOWN = 0; - public static final int EMULATOR_STATE_IDLE = 1; - public static final int EMULATOR_STATE_RUNNING = 2; - public static final int EMULATOR_STATE_PAUSED = 3; - // @formatter:on -} diff --git a/Android/app/src/main/java/emu/project64/jni/NativeExports.java b/Android/app/src/main/java/emu/project64/jni/NativeExports.java index f4be2a2a4..8480d1504 100644 --- a/Android/app/src/main/java/emu/project64/jni/NativeExports.java +++ b/Android/app/src/main/java/emu/project64/jni/NativeExports.java @@ -10,40 +10,27 @@ public class NativeExports System.loadLibrary( "Project64-bridge" ); } - public static native void appInit (String BaseDir ); + public static native boolean appInit (String BaseDir ); public static native String appVersion(); public static native void StopEmulation(); public static native void StartEmulation(); public static native void CloseSystem(); - public static native void SettingsSaveBool(int type, boolean value); - public static native void SettingsSaveDword(int type, int value); - public static native void SettingsSaveString(int type, String value); - public static native boolean SettingsLoadBool(int type); - public static native int SettingsLoadDword(int type); - public static native String SettingsLoadString(int type); - public static native boolean IsSettingSet(int type); + public static native void SettingsSaveBool(String Type, boolean Value); + public static native void SettingsSaveDword(String Type, int Value); + public static native void SettingsSaveString(String Type, String Value); + public static native boolean SettingsLoadBool(String Type); + public static native int SettingsLoadDword(String Type); + public static native String SettingsLoadString(String Type); + public static native String SettingsLoadStringIndex(String Type, int Index); + public static native boolean IsSettingSet(String Type); public static native void LoadGame(String FileLoc); public static native void StartGame(Activity activity, GameSurface.GLThread thread); public static native void LoadRomList(); public static native void RefreshRomDir(String RomDir, boolean Recursive); public static native void ExternalEvent(int Type); - public static native void ResetApplicationSettings(); public static native byte[] GetString(int StringId); - - public static native void SetSpeed(int Speed); - public static native int GetSpeed(); - public static native int GetBaseSpeed(); public static native void onSurfaceCreated(); public static native void onSurfaceChanged(int width, int height); public static native void onDrawFrame(); - - public static native void UISettingsSaveBool(int Type, boolean Value); - public static native void UISettingsSaveDword(int Type, int Value); - public static native void UISettingsSaveString(int type, String value); - - public static native boolean UISettingsLoadBool(int Type); - public static native int UISettingsLoadDword(int Type); - public static native String UISettingsLoadString(int type); - public static native String UISettingsLoadStringIndex(int Type, int Index); } diff --git a/Android/app/src/main/java/emu/project64/jni/SettingsID.java b/Android/app/src/main/java/emu/project64/jni/SettingsID.java index 1d05dc45d..02019f95d 100644 --- a/Android/app/src/main/java/emu/project64/jni/SettingsID.java +++ b/Android/app/src/main/java/emu/project64/jni/SettingsID.java @@ -330,36 +330,10 @@ public enum SettingsID Enhancement_Gameshark, Enhancement_GamesharkCode, Enhancement_Notes, - - FirstUISettings, LastUISettings(FirstUISettings.getValue() + 65535), - FirstRSPDefaultSet, LastRSPDefaultSet(FirstRSPDefaultSet.getValue() + 65535), - FirstRSPSettings, LastRSPSettings(FirstRSPSettings.getValue() + 65535), - FirstGfxDefaultSet, LastGfxDefaultSet(FirstGfxDefaultSet.getValue() + 65535), - FirstGfxSettings, LastGfxSettings(FirstGfxSettings.getValue() + 65535), - FirstAudioDefaultSet, LastAudioDefaultSet(FirstAudioDefaultSet.getValue() + 65535), - FirstAudioSettings, LastAudioSettings(FirstAudioSettings.getValue() + 65535), - FirstCtrlDefaultSet, LastCtrlDefaultSet(FirstCtrlDefaultSet.getValue() + 65535), - FirstCtrlSettings, LastCtrlSettings(FirstCtrlSettings.getValue() + 65535), ; - private int value; - - public int getValue() - { - return this.value; + + @Override + public String toString() { + return "Core." + super.toString(); } - private static final class StaticFields - { - public static int Counter = 0; - } - - private SettingsID() - { - this.value = StaticFields.Counter; - StaticFields.Counter += 1; - } - private SettingsID(int value) - { - this.value = value; - StaticFields.Counter = this.value + 1; - } } \ No newline at end of file diff --git a/Android/app/src/main/java/emu/project64/jni/UISettingID.java b/Android/app/src/main/java/emu/project64/jni/UISettingID.java index 1a2b8ad0e..08296ca4b 100644 --- a/Android/app/src/main/java/emu/project64/jni/UISettingID.java +++ b/Android/app/src/main/java/emu/project64/jni/UISettingID.java @@ -2,41 +2,30 @@ package emu.project64.jni; public enum UISettingID { - Asserts_Version, - Screen_Orientation, + AssertsVersion, + BuildVersion, + ScreenOrientation, //Recent Game - File_RecentGameFileCount, - File_RecentGameFileIndex, + FileRecentGameFileCount, + FileRecentGameFileIndex, //Touch Screen - TouchScreen_ButtonScale, - TouchScreen_Layout, + TouchScreenButtonScale, + TouchScreenLayout, //Controller Config - Controller_ConfigFile, - Controller_CurrentProfile, - Controller_Deadzone, - Controller_Sensitivity, + ControllerConfigFile, + ControllerCurrentProfile, + ControllerDeadzone, + ControllerSensitivity, //App Info - AppInfo_RunCount, + AppInfoRunCount, ; - - private int value; - - public int getValue() - { - return this.value; + + @Override + public String toString() { + return "UISettingID." + super.toString(); } - private static final class StaticFields - { - public static int Counter = 0; - } - - private UISettingID() - { - this.value = StaticFields.Counter; - StaticFields.Counter += 1; - } } diff --git a/Android/app/src/main/java/emu/project64/jni/VideoSettingID.java b/Android/app/src/main/java/emu/project64/jni/VideoSettingID.java index 0c4bbc3c8..320277bad 100644 --- a/Android/app/src/main/java/emu/project64/jni/VideoSettingID.java +++ b/Android/app/src/main/java/emu/project64/jni/VideoSettingID.java @@ -38,21 +38,10 @@ public enum VideoSettingID Set_Logging_Glitch, Set_Logging_VideoRDP, Set_Logging_TLUT, Set_Logging_PNG, Set_Logging_OGLWrapper, Set_Logging_RDPCommands, ; - - private int value; - - public int getValue() + + @Override + public String toString() { - return this.value; + return "VideoSettingID." + super.toString(); } - private static final class StaticFields - { - public static int Counter = 0; - } - - private VideoSettingID() - { - this.value = StaticFields.Counter; - StaticFields.Counter += 1; - } } diff --git a/Android/app/src/main/java/emu/project64/profile/ControllerProfileActivity.java b/Android/app/src/main/java/emu/project64/profile/ControllerProfileActivity.java deleted file mode 100644 index 6c0633744..000000000 --- a/Android/app/src/main/java/emu/project64/profile/ControllerProfileActivity.java +++ /dev/null @@ -1,500 +0,0 @@ -package emu.project64.profile; - -import java.util.ArrayList; -import java.util.List; - -import emu.project64.AndroidDevice; -import emu.project64.R; -import emu.project64.hack.MogaHack; -import emu.project64.input.AbstractController; -import emu.project64.input.map.InputMap; -import emu.project64.input.provider.AbstractProvider; -import emu.project64.input.provider.AbstractProvider.OnInputListener; -import emu.project64.input.provider.AxisProvider; -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.UISettingID; -import emu.project64.persistent.ConfigFile; -import emu.project64.persistent.ConfigFile.ConfigSection; -import android.app.AlertDialog; -import android.app.AlertDialog.Builder; -import android.annotation.TargetApi; -import android.content.Context; -import android.content.DialogInterface; -import android.graphics.PorterDuff; -import android.os.Bundle; -import android.support.v7.app.ActionBar; -import android.support.v7.app.AppCompatActivity; -import android.support.v7.widget.Toolbar; -import android.text.TextUtils; -import android.util.DisplayMetrics; -import android.util.Log; -import android.view.KeyEvent; -import android.view.MenuItem; -import android.view.MotionEvent; -import android.view.View; -import android.view.View.OnClickListener; -import android.view.WindowManager; -import android.widget.Button; -import android.widget.EditText; -import android.widget.FrameLayout; -import android.widget.TextView; - -import com.bda.controller.Controller; - -public class ControllerProfileActivity extends AppCompatActivity implements OnInputListener, - OnClickListener -{ - // Visual settings - private static final float UNMAPPED_BUTTON_ALPHA = 0.2f; - private static final int UNMAPPED_BUTTON_FILTER = 0x66FFFFFF; - private static final int MIN_LAYOUT_WIDTH_DP = 480; - - // Controller profile objects - private ConfigFile mConfigFile; - private Profile mProfile; - - // Input listening - private KeyProvider mKeyProvider; - private MogaProvider mMogaProvider; - private AxisProvider mAxisProvider; - private Controller mMogaController = Controller.getInstance( this ); - - // Widgets - private final Button[] mN64Buttons = new Button[InputMap.NUM_MAPPABLES]; - private TextView mFeedbackText; - - @Override - public void onCreate( Bundle savedInstanceState ) - { - super.onCreate( savedInstanceState ); - - // Initialize MOGA controller API - // TODO: Remove hack after MOGA SDK is fixed - // mMogaController.init(); - MogaHack.init( mMogaController, this ); - - // Load the profile; fail fast if there are any programmer usage errors - String name = NativeExports.UISettingsLoadString(UISettingID.Controller_CurrentProfile.getValue()); - if( TextUtils.isEmpty( name ) ) - throw new Error( "Invalid usage: profile name cannot be null or empty" ); - mConfigFile = new ConfigFile(NativeExports.UISettingsLoadString(UISettingID.Controller_ConfigFile.getValue())); - ConfigSection section = mConfigFile.get( name ); - if( section == null ) - { - //profile not found create it - mConfigFile.put(name, "map", "-"); - section = mConfigFile.get( name ); - if( section == null ) - { - throw new Error( "Invalid usage: profile name not found in config file" ); - } - } - mProfile = new Profile( false, section ); - - // Set up input listeners - mKeyProvider = new KeyProvider( ImeFormula.DEFAULT, AndroidDevice.getUnmappableKeyCodes() ); - mKeyProvider.registerListener( this ); - mMogaProvider = new MogaProvider( mMogaController ); - mMogaProvider.registerListener( this ); - if( AndroidDevice.IS_HONEYCOMB_MR1 ) - { - mAxisProvider = new AxisProvider(); - mAxisProvider.registerListener( this ); - } - - // Initialize the layout - initLayoutDefault(); - - // Refresh everything - refreshAllButtons(); - } - - @Override - public void onResume() - { - super.onResume(); - mMogaController.onResume(); - } - - @Override - public void onPause() - { - super.onPause(); - mMogaController.onPause(); - - // Lazily persist the profile data; only need to do it on pause - mProfile.writeTo( mConfigFile ); - mConfigFile.save(); - } - - @Override - public void onDestroy() - { - super.onDestroy(); - mMogaController.exit(); - } - - @Override - public boolean onOptionsItemSelected(MenuItem item) - { - switch (item.getItemId()) - { - case android.R.id.home: - finish(); - return true; - } - return super.onOptionsItemSelected(item); - } - - @Override - public void onBackPressed() - { - finish(); - } - - private void initLayoutDefault() - { - WindowManager manager = (WindowManager) getSystemService( Context.WINDOW_SERVICE ); - DisplayMetrics metrics = new DisplayMetrics(); - manager.getDefaultDisplay().getMetrics( metrics ); - float scalefactor = (float) DisplayMetrics.DENSITY_DEFAULT / (float) metrics.densityDpi; - int widthDp = Math.round( metrics.widthPixels * scalefactor ); - - // For narrow screens, use an alternate layout - if( widthDp < MIN_LAYOUT_WIDTH_DP ) - { - setContentView( R.layout.controller_profile_activity_port ); - } - else - { - setContentView( R.layout.controller_profile_activity ); - } - - // Add the tool bar to the activity (which supports the fancy menu/arrow animation) - Toolbar toolbar = (Toolbar) findViewById( R.id.toolbar ); - toolbar.setTitle( getString(R.string.gamepad_title) ); - setSupportActionBar( toolbar ); - ActionBar actionbar = getSupportActionBar(); - - if (AndroidDevice.IS_ICE_CREAM_SANDWICH) - { - actionbar.setHomeButtonEnabled(true); - actionbar.setDisplayHomeAsUpEnabled(true); - } - - // Initialize and refresh the widgets - initWidgets(); - } - - private void initWidgets() - { - // Get the text view object - mFeedbackText = (TextView) findViewById( R.id.textFeedback ); - mFeedbackText.setText( "" ); - - // Create a button list to simplify highlighting and mapping - setupButton( R.id.buttonDR, AbstractController.DPD_R ); - setupButton( R.id.buttonDL, AbstractController.DPD_L ); - setupButton( R.id.buttonDD, AbstractController.DPD_D ); - setupButton( R.id.buttonDU, AbstractController.DPD_U ); - setupButton( R.id.buttonS, AbstractController.START ); - setupButton( R.id.buttonZ, AbstractController.BTN_Z ); - setupButton( R.id.buttonB, AbstractController.BTN_B ); - setupButton( R.id.buttonA, AbstractController.BTN_A ); - setupButton( R.id.buttonCR, AbstractController.CPD_R ); - setupButton( R.id.buttonCL, AbstractController.CPD_L ); - setupButton( R.id.buttonCD, AbstractController.CPD_D ); - setupButton( R.id.buttonCU, AbstractController.CPD_U ); - setupButton( R.id.buttonR, AbstractController.BTN_R ); - setupButton( R.id.buttonL, AbstractController.BTN_L ); - setupButton( R.id.buttonAR, InputMap.AXIS_R ); - setupButton( R.id.buttonAL, InputMap.AXIS_L ); - setupButton( R.id.buttonAD, InputMap.AXIS_D ); - setupButton( R.id.buttonAU, InputMap.AXIS_U ); - } - - private void setupButton( int resId, int index ) - { - mN64Buttons[index] = (Button) findViewById( resId ); - if( mN64Buttons[index] != null ) - { - mN64Buttons[index].setOnClickListener( this ); - } - } - - @Override - public void onClick(View view) - { - // Handle button clicks in the mapping screen - for( int i = 0; i < mN64Buttons.length; i++ ) - { - // Find the button that was pressed - if( view.equals( mN64Buttons[i] ) ) - { - // Popup a dialog to listen to input codes from user - Button button = (Button) view; - popupListener( button.getText(), i ); - } - } - } - - private interface PromptInputCodeListener - { - public void onDialogClosed( int inputCode, int hardwareId, int which ); - } - - /** - * Open a dialog to prompt the user for an input code. - * - * @param context The activity context. - * @param moga The MOGA controller interface. - * @param title The title of the dialog. - * @param message The message to be shown inside the dialog. - * @param neutralButtonText The text to be shown on the neutral button, or null. - * @param ignoredKeyCodes The key codes to ignore. - * @param listener The listener to process the input code, when provided. - */ - public static void promptInputCode( Context context, Controller moga, CharSequence title, CharSequence message, - CharSequence neutralButtonText, final PromptInputCodeListener listener ) - { - final ArrayList providers = new ArrayList(); - - // Create a widget to dispatch key/motion event data - FrameLayout view = new FrameLayout( context ); - EditText dummyImeListener = new EditText( context ); - dummyImeListener.setVisibility( View.INVISIBLE ); - dummyImeListener.setHeight( 0 ); - view.addView( dummyImeListener ); - - // Set the focus parameters of the view so that it will dispatch events - view.setFocusable( true ); - view.setFocusableInTouchMode( true ); - view.requestFocus(); - - // Create the input event providers - providers.add( new KeyProvider( view, ImeFormula.DEFAULT, AndroidDevice.getUnmappableKeyCodes() ) ); - providers.add( new MogaProvider( moga ) ); - if( AndroidDevice.IS_HONEYCOMB_MR1 ) - { - providers.add( new AxisProvider( view ) ); - } - - // Notify the client when the user clicks the dialog's positive button - DialogInterface.OnClickListener clickListener = new DialogInterface.OnClickListener() - { - @Override - public void onClick( DialogInterface dialog, int which ) - { - for( AbstractProvider provider : providers ) - provider.unregisterAllListeners(); - listener.onDialogClosed( 0, 0, which ); - } - }; - - final AlertDialog dialog = new Builder( context ).setTitle( title ).setMessage( message ).setCancelable( false ) - .setNegativeButton( context.getString( android.R.string.cancel ), clickListener ) - .setPositiveButton( context.getString( android.R.string.ok ), clickListener ) - .setNeutralButton( neutralButtonText, clickListener ).setPositiveButton( null, null ) - .setView( view ).create(); - - OnInputListener inputListener = new OnInputListener() - { - @Override - public void onInput( int[] inputCodes, float[] strengths, int hardwareId ) - { - if( inputCodes == null || strengths == null ) - return; - - // Find the strongest input - float maxStrength = 0; - int strongestInputCode = 0; - for( int i = 0; i < inputCodes.length; i++ ) - { - // Identify the strongest input - float strength = strengths[i]; - if( strength > maxStrength ) - { - maxStrength = strength; - strongestInputCode = inputCodes[i]; - } - } - - // Call the overloaded method with the strongest found - onInput( strongestInputCode, maxStrength, hardwareId ); - } - - @Override - public void onInput( int inputCode, float strength, int hardwareId ) - { - if( inputCode != 0 && strength > AbstractProvider.STRENGTH_THRESHOLD ) - { - for( AbstractProvider provider : providers ) - provider.unregisterAllListeners(); - listener.onDialogClosed( inputCode, hardwareId, DialogInterface.BUTTON_POSITIVE ); - dialog.dismiss(); - } - } - }; - - // Connect the upstream event listeners - for( AbstractProvider provider : providers ) - { - provider.registerListener( inputListener ); - } - - // Launch the dialog - dialog.show(); - } - - private void popupListener( CharSequence title, final int index ) - { - final InputMap map = new InputMap( mProfile.get( "map" ) ); - String message = getString( R.string.inputMapActivity_popupMessage,map.getMappedCodeInfo( index ) ); - String btnText = getString( R.string.inputMapActivity_popupUnmap ); - - PromptInputCodeListener listener = new PromptInputCodeListener() - { - @Override - public void onDialogClosed( int inputCode, int hardwareId, int which ) - { - if( which != DialogInterface.BUTTON_NEGATIVE ) - { - if( which == DialogInterface.BUTTON_POSITIVE ) - { - map.map( inputCode, index ); - } - else - { - map.unmapCommand( index ); - } - mProfile.put( "map", map.serialize() ); - refreshAllButtons(); - } - - // Refresh our MOGA provider since the prompt disconnected it - mMogaProvider = new MogaProvider( mMogaController ); - mMogaProvider.registerListener( ControllerProfileActivity.this ); - } - }; - promptInputCode( this, mMogaController, title, message, btnText, listener); - } - - @Override - public boolean onKeyDown( int keyCode, KeyEvent event ) - { - return mKeyProvider.onKey( keyCode, event ) || super.onKeyDown( keyCode, event ); - } - - @Override - public boolean onKeyUp( int keyCode, KeyEvent event ) - { - return mKeyProvider.onKey( keyCode, event ) || super.onKeyUp( keyCode, event ); - } - - @TargetApi( 12 ) - @Override - public boolean onGenericMotionEvent( MotionEvent event ) - { - if( !AndroidDevice.IS_HONEYCOMB_MR1 ) - { - return false; - } - return mAxisProvider.onGenericMotion( event ) || super.onGenericMotionEvent( event ); - } - - @Override - public void onInput(int inputCode, float strength, int hardwareId) - { - refreshButton( inputCode, strength ); - refreshFeedbackText( inputCode, strength ); - } - - @Override - public void onInput(int[] inputCodes, float[] strengths, int hardwareId) - { - float maxStrength = AbstractProvider.STRENGTH_THRESHOLD; - int strongestInputCode = 0; - for( int i = 0; i < inputCodes.length; i++ ) - { - int inputCode = inputCodes[i]; - float strength = strengths[i]; - - // Cache the strongest input - if( strength > maxStrength ) - { - maxStrength = strength; - strongestInputCode = inputCode; - } - - refreshButton( inputCode, strength ); - } - refreshFeedbackText( strongestInputCode, maxStrength ); - } - - private void refreshFeedbackText( int inputCode, float strength ) - { - // Update the feedback text (not all layouts include this, so check null) - if( mFeedbackText != null ) - { - mFeedbackText.setText( strength > AbstractProvider.STRENGTH_THRESHOLD ? AbstractProvider.getInputName( inputCode ) : "" ); - } - } - - private void refreshButton( int inputCode, float strength ) - { - InputMap map = new InputMap( mProfile.get( "map" ) ); - int command = map.get( inputCode ); - if( command != InputMap.UNMAPPED ) - { - Button button = mN64Buttons[command]; - refreshButton( button, strength, true ); - } - } - - @TargetApi( 11 ) - private void refreshButton( Button button, float strength, boolean isMapped ) - { - if( button != null ) - { - button.setPressed( strength > AbstractProvider.STRENGTH_THRESHOLD ); - - // Fade any buttons that aren't mapped - if( AndroidDevice.IS_HONEYCOMB ) - { - if( isMapped ) - { - button.setAlpha( 1 ); - } - else - { - button.setAlpha( UNMAPPED_BUTTON_ALPHA ); - } - } - else - { - // For older APIs try something similar (not quite the same) - if( isMapped ) - { - button.getBackground().clearColorFilter(); - } - else - { - button.getBackground().setColorFilter( UNMAPPED_BUTTON_FILTER, PorterDuff.Mode.MULTIPLY ); - } - button.invalidate(); - } - } - } - - private void refreshAllButtons() - { - final InputMap map = new InputMap( mProfile.get( "map" ) ); - for( int i = 0; i < mN64Buttons.length; i++ ) - { - refreshButton( mN64Buttons[i], 0, map.isMapped( i ) ); - } - } -} diff --git a/Android/app/src/main/java/emu/project64/settings/BaseSettingsFragment.java b/Android/app/src/main/java/emu/project64/settings/BaseSettingsFragment.java index 33ff595a5..d0dc4c006 100644 --- a/Android/app/src/main/java/emu/project64/settings/BaseSettingsFragment.java +++ b/Android/app/src/main/java/emu/project64/settings/BaseSettingsFragment.java @@ -3,7 +3,6 @@ package emu.project64.settings; import emu.project64.R; import emu.project64.SplashActivity; import emu.project64.jni.NativeExports; -import emu.project64.profile.ControllerProfileActivity; import android.content.DialogInterface; import android.content.Intent; import android.os.Bundle; @@ -48,25 +47,6 @@ public abstract class BaseSettingsFragment extends PreferenceFragmentCompat @Override public void onDisplayPreferenceDialog(Preference preference) { - DialogFragment dialogFragment = null; - if (preference instanceof SeekBarPreference) - { - dialogFragment = SeekBarPreferencePreferenceDialogFragmentCompat.newInstance(preference.getKey()); - } - else if (preference instanceof TwoLinesListPreference) - { - dialogFragment = TwoLinesListPreferenceDialogFragmentCompat.newInstance(preference.getKey()); - } - else - { - super.onDisplayPreferenceDialog(preference); - } - - if (dialogFragment != null) - { - dialogFragment.setTargetFragment(this, 0); - dialogFragment.show(getFragmentManager(), DIALOG_FRAGMENT_TAG); - } } @Override @@ -84,9 +64,6 @@ public abstract class BaseSettingsFragment extends PreferenceFragmentCompat } else if (preference.getKey().equals("settings_gamepad_screen")) { - final AppCompatActivity activity = (AppCompatActivity)getActivity(); - Intent intent = new Intent( activity, ControllerProfileActivity.class ); - activity.startActivity( intent ); } else if (preference.getKey().equals("settings_video")) { @@ -125,7 +102,6 @@ public abstract class BaseSettingsFragment extends PreferenceFragmentCompat { if( which == DialogInterface.BUTTON_POSITIVE ) { - NativeExports.ResetApplicationSettings(); SplashActivity.Reset(); Intent SplashIntent = new Intent(getActivity(), SplashActivity.class); SplashIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK); @@ -133,14 +109,7 @@ public abstract class BaseSettingsFragment extends PreferenceFragmentCompat } } }; - - String title = getString( R.string.settings_reset_title ); - String message = getString( R.string.settings_reset_message ); - AlertDialog.Builder builder = new AlertDialog.Builder( getActivity() ).setTitle( title ).setMessage( message ).setCancelable( false ) - .setNegativeButton( getString( android.R.string.cancel ), internalListener ) - .setPositiveButton( getString( android.R.string.ok ), internalListener ); - builder.create().show(); - } + } else { return super.onPreferenceTreeClick(preference); diff --git a/Android/app/src/main/java/emu/project64/settings/GameSettingsActivity.java b/Android/app/src/main/java/emu/project64/settings/GameSettingsActivity.java index 8e7714fb9..f6bd6ce0a 100644 --- a/Android/app/src/main/java/emu/project64/settings/GameSettingsActivity.java +++ b/Android/app/src/main/java/emu/project64/settings/GameSettingsActivity.java @@ -35,8 +35,8 @@ public class GameSettingsActivity extends AppCompatActivity implements SharedPre SharedPreferences sharedPrefs = PreferenceManager.getDefaultSharedPreferences(this); sharedPrefs.edit().clear() - .putString("Game_CpuType",String.valueOf(NativeExports.SettingsLoadDword(SettingsID.Game_CpuType.getValue()))) - .putBoolean("Game_BlockLinking",NativeExports.SettingsLoadBool(SettingsID.Game_BlockLinking.getValue())) + .putString("Game_CpuType",String.valueOf(NativeExports.SettingsLoadDword(SettingsID.Game_CpuType.toString()))) + .putBoolean("Game_BlockLinking",NativeExports.SettingsLoadBool(SettingsID.Game_BlockLinking.toString())) .apply(); sharedPrefs.registerOnSharedPreferenceChangeListener(this); @@ -71,7 +71,7 @@ public class GameSettingsActivity extends AppCompatActivity implements SharedPre @Override public void onSharedPreferenceChanged(SharedPreferences sharedPreferences, String key) { - if (key.equals("Game_CpuType")) { NativeExports.SettingsSaveDword(SettingsID.Game_CpuType.getValue(), Integer.valueOf(sharedPreferences.getString(key, "1"))); } - else if (key.equals("Game_BlockLinking")) { NativeExports.SettingsSaveBool(SettingsID.Game_BlockLinking.getValue(), sharedPreferences.getBoolean(key,false)); } + if (key.equals("Game_CpuType")) { NativeExports.SettingsSaveDword(SettingsID.Game_CpuType.toString(), Integer.valueOf(sharedPreferences.getString(key, "1"))); } + else if (key.equals("Game_BlockLinking")) { NativeExports.SettingsSaveBool(SettingsID.Game_BlockLinking.toString(), sharedPreferences.getBoolean(key,false)); } } } diff --git a/Android/app/src/main/java/emu/project64/settings/LogLevelPreference.java b/Android/app/src/main/java/emu/project64/settings/LogLevelPreference.java index a1a072a0b..56063c8bd 100644 --- a/Android/app/src/main/java/emu/project64/settings/LogLevelPreference.java +++ b/Android/app/src/main/java/emu/project64/settings/LogLevelPreference.java @@ -3,95 +3,56 @@ package emu.project64.settings; import emu.project64.R; import android.content.Context; import android.content.res.TypedArray; -import android.support.v7.preference.ListPreference; import android.util.AttributeSet; +import android.util.TypedValue; +import android.text.TextUtils; +import androidx.appcompat.app.AlertDialog; +import androidx.core.content.res.TypedArrayUtils; +import androidx.preference.Preference; +import android.content.DialogInterface; +import android.content.DialogInterface.OnClickListener; -public class LogLevelPreference extends ListPreference -{ +public class LogLevelPreference extends Preference { + private CharSequence[] mEntries; + private CharSequence[] mEntryValues; private CharSequence[] mEntriesSubtitles; + private String mValue; private int mValueIndex; + private boolean mValueSet; public LogLevelPreference(Context context, AttributeSet attrs) { - super(context, attrs); + super(context, attrs, getAttr(context, R.attr.LogLevelPreferenceStyle, android.R.attr.preferenceStyle)); + TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.TwoLinesListPreference); mEntriesSubtitles = a.getTextArray(R.styleable.TwoLinesListPreference_entriesSubtitles); - - String[] TraceSeverityList=context.getResources().getStringArray(R.array.trace_severity_list); - setEntries(TraceSeverityList); - - String[] TraceSeverityValues=context.getResources().getStringArray(R.array.trace_severity_values); - setEntryValues(TraceSeverityValues); + mEntries = context.getResources().getStringArray(R.array.trace_severity_list); + mEntryValues = context.getResources().getStringArray(R.array.trace_severity_values); a.recycle(); - } - - @Override - protected void onSetInitialValue(boolean restoreValue, Object defaultValue) - { - super.onSetInitialValue(restoreValue, defaultValue); - mEntriesSubtitles = getEntriesSubtitles(); - mValueIndex = getValueIndex(); - } - - @Override - public void setValue(String value) - { - super.setValue(value); - mValueIndex = getValueIndex(); - updateSummary(); - } - /** - * Returns the index of the given value (in the entry values array). - * - * @param value The value whose index should be returned. - * @return The index of the value, or -1 if not found. - */ - public int findIndexOfValue(String value) - { - CharSequence[] EntryValues = getEntryValues(); - if (value != null && EntryValues != null) - { - for (int i = EntryValues.length - 1; i >= 0; i--) - { - if (EntryValues[i].equals(value)) - { - return i; - } - } - } - return -1; - } - - public int getValueIndex() - { - return findIndexOfValue(getValue()); - } - - public CharSequence[] getEntriesSubtitles() - { - return mEntriesSubtitles; - } - - @Override - public void setEntries(CharSequence[] Entries) - { - super.setEntries(Entries); updateSummary(); } @Override - public void setEntryValues(CharSequence[] EntryValues) - { - super.setEntryValues(EntryValues); - mValueIndex = getValueIndex(); - updateSummary(); - } - - public void setEntriesSubtitles(CharSequence[] mEntriesSubtitles) - { - this.mEntriesSubtitles = mEntriesSubtitles; - updateSummary(); + protected void onClick() { + AlertDialog.Builder builder = new AlertDialog.Builder(getContext()); + builder.setTitle(getTitle()) + .setSingleChoiceItems(mEntries, mValueIndex, new DialogInterface.OnClickListener() { + @Override + public void onClick(DialogInterface dialog, int index) { + setValueIndex(index); + dialog.dismiss(); + } + }) + .setPositiveButton("Go", new DialogInterface.OnClickListener() { + @Override + public void onClick(DialogInterface dialog, int index) { + setValueIndex(index); + dialog.dismiss(); + } + }); + AlertDialog dialog = builder.create(); + dialog.show(); } private void updateSummary() @@ -100,16 +61,50 @@ public class LogLevelPreference extends ListPreference { return; } - CharSequence[] Entries = getEntries(); - String summary = Entries[mValueIndex].toString(); - if (mEntriesSubtitles != null && mEntriesSubtitles.length > mValueIndex) - { - String subtitle = mEntriesSubtitles[mValueIndex].toString(); - if (summary.length() > 0 && subtitle.length() > 0) - { - summary += " - " + subtitle; - } + setSummary(mEntries[mValueIndex].toString()); + } + + private void setValueIndex(int index) + { + String value = mEntryValues[index].toString(); + final boolean changed = !TextUtils.equals(mValue, value); + if (changed || !mValueSet) { + mValueIndex = index; + mValue = value; + mValueSet = true; + persistString(value); + if (changed) { + notifyChanged(); + } + updateSummary(); + } + } + + private static int getAttr(Context context, int attr, int fallbackAttr) + { + TypedValue value = new TypedValue(); + context.getTheme().resolveAttribute(attr, value, true); + if (value.resourceId != 0) + { + return attr; + } + return fallbackAttr; + } + + @Override + protected void onSetInitialValue(Object defaultValue) + { + if (getSharedPreferences().contains(getKey())) + { + String Value = getPersistedString( Integer.toString(mValueIndex)); + for (int i = 0, n = mEntryValues.length; i < n; i++) + { + if (mEntryValues[i].equals(Value)) + { + mValueIndex = i; + updateSummary(); + } + } } - setSummary( summary ); } } \ No newline at end of file diff --git a/Android/app/src/main/java/emu/project64/settings/SeekBarPreference.java b/Android/app/src/main/java/emu/project64/settings/SeekBarPreference.java index b877cd2c7..2487d2ad2 100644 --- a/Android/app/src/main/java/emu/project64/settings/SeekBarPreference.java +++ b/Android/app/src/main/java/emu/project64/settings/SeekBarPreference.java @@ -172,7 +172,8 @@ public class SeekBarPreference extends DialogPreference */ public String getValueString( int value ) { - return getContext().getString( R.string.seekBarPreference_summary, value, mUnits ); + //return getContext().getString( R.string.seekBarPreference_summary, value, mUnits ); + return ""; } @Override diff --git a/Android/app/src/main/java/emu/project64/settings/SettingsActivity.java b/Android/app/src/main/java/emu/project64/settings/SettingsActivity.java index cce5b83cc..ae63009b1 100644 --- a/Android/app/src/main/java/emu/project64/settings/SettingsActivity.java +++ b/Android/app/src/main/java/emu/project64/settings/SettingsActivity.java @@ -1,20 +1,18 @@ package emu.project64.settings; import emu.project64.AndroidDevice; -import emu.project64.GalleryActivity; import emu.project64.R; -import emu.project64.jni.AudioSettingID; 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; -import android.support.v7.app.ActionBar; -import android.support.v7.app.AppCompatActivity; -import android.support.v7.widget.Toolbar; + +import androidx.appcompat.app.ActionBar; +import androidx.preference.PreferenceManager; +import androidx.appcompat.app.AppCompatActivity; +import androidx.fragment.app.Fragment; +import androidx.fragment.app.FragmentActivity; +import androidx.appcompat.widget.Toolbar; import android.view.MenuItem; public class SettingsActivity extends AppCompatActivity implements SharedPreferences.OnSharedPreferenceChangeListener @@ -24,61 +22,60 @@ public class SettingsActivity extends AppCompatActivity implements SharedPrefere { super.onCreate(savedInstanceState); - if (NativeExports.SettingsLoadBool(SettingsID.GameRunning_CPU_Running.getValue()) == true) + /*if (NativeExports.SettingsLoadBool(SettingsID.GameRunning_CPU_Running.getValue()) == true) { NativeExports.ExternalEvent( SystemEvent.SysEvent_ResumeCPU_FromMenu.getValue()); - } + }*/ setContentView(R.layout.settings_activity); - // Add the tool bar to the activity (which supports the fancy menu/arrow animation) Toolbar toolbar = (Toolbar) findViewById( R.id.toolbar ); - toolbar.setTitle( getString(R.string.settings_title) ); setSupportActionBar( toolbar ); - ActionBar actionbar = getSupportActionBar(); - + getSupportActionBar().setDisplayShowTitleEnabled(false); + toolbar.setTitle(getString(R.string.settings_title)); if (AndroidDevice.IS_ICE_CREAM_SANDWICH) { + ActionBar actionbar = getSupportActionBar(); actionbar.setHomeButtonEnabled(true); actionbar.setDisplayHomeAsUpEnabled(true); } SharedPreferences sharedPrefs = PreferenceManager.getDefaultSharedPreferences(this); sharedPrefs.edit().clear() - .putInt("touchscreenScale",NativeExports.UISettingsLoadDword(UISettingID.TouchScreen_ButtonScale.getValue())) + /*.putInt("touchscreenScale",NativeExports.UISettingsLoadDword(UISettingID.TouchScreen_ButtonScale.getValue())) .putString("touchscreenLayout",NativeExports.UISettingsLoadString(UISettingID.TouchScreen_Layout.getValue())) - .putBoolean("audio_Enabled",NativeExports.SettingsLoadBool(SettingsID.Plugin_EnableAudio.getValue())) - .putBoolean("UserInterface_BasicMode",NativeExports.SettingsLoadBool(SettingsID.UserInterface_BasicMode.getValue())) - .putBoolean("Debugger_Enabled",NativeExports.SettingsLoadBool(SettingsID.Debugger_Enabled.getValue())) - .putBoolean("Debugger_RecordRecompilerAsm",NativeExports.SettingsLoadBool(SettingsID.Debugger_RecordRecompilerAsm.getValue())) - .putBoolean("Debugger_LimitFPS",NativeExports.SettingsLoadBool(SettingsID.GameRunning_LimitFPS.getValue())) - .putBoolean("Debugger_DisplaySpeed",NativeExports.SettingsLoadBool(SettingsID.UserInterface_DisplayFrameRate.getValue())) - .putBoolean("Debugger_CpuUsage",NativeExports.SettingsLoadBool(SettingsID.UserInterface_ShowCPUPer.getValue())) - .putBoolean("Debugger_RecordExecutionTimes",NativeExports.SettingsLoadBool(SettingsID.Debugger_RecordExecutionTimes.getValue())) - .putBoolean("Debugger_DebugLanguage",NativeExports.SettingsLoadBool(SettingsID.Debugger_DebugLanguage.getValue())) - .putString("Debugger_DisplaySpeedType",String.valueOf(NativeExports.SettingsLoadDword(SettingsID.UserInterface_FrameDisplayType.getValue()))) - .putString("Debugger_TraceMD5",String.valueOf(NativeExports.SettingsLoadDword(SettingsID.Debugger_TraceMD5.getValue()))) - .putString("Debugger_TraceThread",String.valueOf(NativeExports.SettingsLoadDword(SettingsID.Debugger_TraceThread.getValue()))) - .putString("Debugger_TracePath",String.valueOf(NativeExports.SettingsLoadDword(SettingsID.Debugger_TracePath.getValue()))) - .putString("Debugger_TraceSettings",String.valueOf(NativeExports.SettingsLoadDword(SettingsID.Debugger_TraceSettings.getValue()))) - .putString("Debugger_TraceUnknown",String.valueOf(NativeExports.SettingsLoadDword(SettingsID.Debugger_TraceUnknown.getValue()))) - .putString("Debugger_TraceAppInit",String.valueOf(NativeExports.SettingsLoadDword(SettingsID.Debugger_TraceAppInit.getValue()))) - .putString("Debugger_TraceAppCleanup",String.valueOf(NativeExports.SettingsLoadDword(SettingsID.Debugger_TraceAppCleanup.getValue()))) - .putString("Debugger_TraceN64System",String.valueOf(NativeExports.SettingsLoadDword(SettingsID.Debugger_TraceN64System.getValue()))) - .putString("Debugger_TracePlugins",String.valueOf(NativeExports.SettingsLoadDword(SettingsID.Debugger_TracePlugins.getValue()))) - .putString("Debugger_TraceGFXPlugin",String.valueOf(NativeExports.SettingsLoadDword(SettingsID.Debugger_TraceGFXPlugin.getValue()))) - .putString("Debugger_TraceAudioPlugin",String.valueOf(NativeExports.SettingsLoadDword(SettingsID.Debugger_TraceAudioPlugin.getValue()))) - .putString("Debugger_TraceControllerPlugin",String.valueOf(NativeExports.SettingsLoadDword(SettingsID.Debugger_TraceControllerPlugin.getValue()))) - .putString("Debugger_TraceRSPPlugin",String.valueOf(NativeExports.SettingsLoadDword(SettingsID.Debugger_TraceRSPPlugin.getValue()))) - .putString("Debugger_TraceRSP",String.valueOf(NativeExports.SettingsLoadDword(SettingsID.Debugger_TraceRSP.getValue()))) - .putString("Debugger_TraceAudio",String.valueOf(NativeExports.SettingsLoadDword(SettingsID.Debugger_TraceAudio.getValue()))) - .putString("Debugger_TraceRegisterCache",String.valueOf(NativeExports.SettingsLoadDword(SettingsID.Debugger_TraceRegisterCache.getValue()))) - .putString("Debugger_TraceRecompiler",String.valueOf(NativeExports.SettingsLoadDword(SettingsID.Debugger_TraceRecompiler.getValue()))) - .putString("Debugger_TraceTLB",String.valueOf(NativeExports.SettingsLoadDword(SettingsID.Debugger_TraceTLB.getValue()))) - .putString("Debugger_TraceProtectedMEM",String.valueOf(NativeExports.SettingsLoadDword(SettingsID.Debugger_TraceProtectedMEM.getValue()))) - .putString("Debugger_TraceUserInterface",String.valueOf(NativeExports.SettingsLoadDword(SettingsID.Debugger_TraceUserInterface.getValue()))) - .putString("Debugger_TraceRomList",String.valueOf(NativeExports.SettingsLoadDword(SettingsID.Debugger_TraceRomList.getValue()))) - .putString("Debugger_TraceExceptionHandler",String.valueOf(NativeExports.SettingsLoadDword(SettingsID.Debugger_TraceExceptionHandler.getValue()))) - .putString("Debugger_TraceVideoMD5",String.valueOf(NativeExports.SettingsLoadDword(SettingsID.FirstGfxSettings.getValue() + VideoSettingID.Set_Logging_MD5.getValue()))) + .putBoolean("audio_Enabled",NativeExports.SettingsLoadBool(SettingsID.Plugin_EnableAudio.getValue()))*/ + .putBoolean("UserInterface_BasicMode",NativeExports.SettingsLoadBool(SettingsID.UserInterface_BasicMode.toString())) + .putBoolean("Debugger_Enabled",NativeExports.SettingsLoadBool(SettingsID.Debugger_Enabled.toString())) + .putBoolean("Debugger_RecordRecompilerAsm",NativeExports.SettingsLoadBool(SettingsID.Debugger_RecordRecompilerAsm.toString())) + .putBoolean("Debugger_LimitFPS",NativeExports.SettingsLoadBool(SettingsID.GameRunning_LimitFPS.toString())) + .putBoolean("Debugger_DisplaySpeed",NativeExports.SettingsLoadBool(SettingsID.UserInterface_DisplayFrameRate.toString())) + .putBoolean("Debugger_CpuUsage",NativeExports.SettingsLoadBool(SettingsID.UserInterface_ShowCPUPer.toString())) + .putBoolean("Debugger_RecordExecutionTimes",NativeExports.SettingsLoadBool(SettingsID.Debugger_RecordExecutionTimes.toString())) + .putBoolean("Debugger_DebugLanguage",NativeExports.SettingsLoadBool(SettingsID.Debugger_DebugLanguage.toString())) + .putString("Debugger_DisplaySpeedType",String.valueOf(NativeExports.SettingsLoadDword(SettingsID.UserInterface_FrameDisplayType.toString()))) + .putString("Debugger_TraceMD5",String.valueOf(NativeExports.SettingsLoadDword(SettingsID.Debugger_TraceMD5.toString()))) + .putString("Debugger_TraceThread",String.valueOf(NativeExports.SettingsLoadDword(SettingsID.Debugger_TraceThread.toString()))) + .putString("Debugger_TracePath",String.valueOf(NativeExports.SettingsLoadDword(SettingsID.Debugger_TracePath.toString()))) + .putString("Debugger_TraceSettings",String.valueOf(NativeExports.SettingsLoadDword(SettingsID.Debugger_TraceSettings.toString()))) + .putString("Debugger_TraceUnknown",String.valueOf(NativeExports.SettingsLoadDword(SettingsID.Debugger_TraceUnknown.toString()))) + .putString("Debugger_TraceAppInit",String.valueOf(NativeExports.SettingsLoadDword(SettingsID.Debugger_TraceAppInit.toString()))) + .putString("Debugger_TraceAppCleanup",String.valueOf(NativeExports.SettingsLoadDword(SettingsID.Debugger_TraceAppCleanup.toString()))) + .putString("Debugger_TraceN64System",String.valueOf(NativeExports.SettingsLoadDword(SettingsID.Debugger_TraceN64System.toString()))) + .putString("Debugger_TracePlugins",String.valueOf(NativeExports.SettingsLoadDword(SettingsID.Debugger_TracePlugins.toString()))) + .putString("Debugger_TraceGFXPlugin",String.valueOf(NativeExports.SettingsLoadDword(SettingsID.Debugger_TraceGFXPlugin.toString()))) + .putString("Debugger_TraceAudioPlugin",String.valueOf(NativeExports.SettingsLoadDword(SettingsID.Debugger_TraceAudioPlugin.toString()))) + .putString("Debugger_TraceControllerPlugin",String.valueOf(NativeExports.SettingsLoadDword(SettingsID.Debugger_TraceControllerPlugin.toString()))) + .putString("Debugger_TraceRSPPlugin",String.valueOf(NativeExports.SettingsLoadDword(SettingsID.Debugger_TraceRSPPlugin.toString()))) + .putString("Debugger_TraceRSP",String.valueOf(NativeExports.SettingsLoadDword(SettingsID.Debugger_TraceRSP.toString()))) + .putString("Debugger_TraceAudio",String.valueOf(NativeExports.SettingsLoadDword(SettingsID.Debugger_TraceAudio.toString()))) + .putString("Debugger_TraceRegisterCache",String.valueOf(NativeExports.SettingsLoadDword(SettingsID.Debugger_TraceRegisterCache.toString()))) + .putString("Debugger_TraceRecompiler",String.valueOf(NativeExports.SettingsLoadDword(SettingsID.Debugger_TraceRecompiler.toString()))) + .putString("Debugger_TraceTLB",String.valueOf(NativeExports.SettingsLoadDword(SettingsID.Debugger_TraceTLB.toString()))) + .putString("Debugger_TraceProtectedMEM",String.valueOf(NativeExports.SettingsLoadDword(SettingsID.Debugger_TraceProtectedMEM.toString()))) + .putString("Debugger_TraceUserInterface",String.valueOf(NativeExports.SettingsLoadDword(SettingsID.Debugger_TraceUserInterface.toString()))) + .putString("Debugger_TraceRomList",String.valueOf(NativeExports.SettingsLoadDword(SettingsID.Debugger_TraceRomList.toString()))) + .putString("Debugger_TraceExceptionHandler",String.valueOf(NativeExports.SettingsLoadDword(SettingsID.Debugger_TraceExceptionHandler.toString()))) + /*.putString("Debugger_TraceVideoMD5",String.valueOf(NativeExports.SettingsLoadDword(SettingsID.FirstGfxSettings.getValue() + VideoSettingID.Set_Logging_MD5.getValue()))) .putString("Debugger_TraceVideoThread",String.valueOf(NativeExports.SettingsLoadDword(SettingsID.FirstGfxSettings.getValue() + VideoSettingID.Set_Logging_Thread.getValue()))) .putString("Debugger_TraceVideoPath",String.valueOf(NativeExports.SettingsLoadDword(SettingsID.FirstGfxSettings.getValue() + VideoSettingID.Set_Logging_Path.getValue()))) .putString("Debugger_TraceVideoSettings",String.valueOf(NativeExports.SettingsLoadDword(SettingsID.FirstGfxSettings.getValue() + VideoSettingID.Set_Logging_Settings.getValue()))) @@ -95,7 +92,7 @@ public class SettingsActivity extends AppCompatActivity implements SharedPrefere .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()))) .putString("video_AspectRatio",String.valueOf(NativeExports.SettingsLoadDword(SettingsID.FirstGfxSettings.getValue() + VideoSettingID.Set_aspect.getValue()))) - .putInt("MaxRomsRemembered",NativeExports.UISettingsLoadDword(UISettingID.File_RecentGameFileCount.getValue())) + .putInt("MaxRomsRemembered",NativeExports.UISettingsLoadDword(UISettingID.File_RecentGameFileCount.getValue()))*/ .apply(); sharedPrefs.registerOnSharedPreferenceChangeListener(this); @@ -132,48 +129,48 @@ public class SettingsActivity extends AppCompatActivity implements SharedPrefere { if (key.equals("UserInterface_BasicMode")) { - NativeExports.SettingsSaveBool(SettingsID.UserInterface_BasicMode.getValue(), sharedPreferences.getBoolean(key,false)); + NativeExports.SettingsSaveBool(SettingsID.UserInterface_BasicMode.toString(), sharedPreferences.getBoolean(key,false)); getSupportFragmentManager().popBackStackImmediate(); getSupportFragmentManager().beginTransaction().replace(R.id.fragment_placeholder, new SettingsFragment()).commit(); } - else if (key.equals("Debugger_DebugLanguage")) + /*else if (key.equals("Debugger_DebugLanguage")) { NativeExports.SettingsSaveBool(SettingsID.Debugger_DebugLanguage.getValue(), sharedPreferences.getBoolean(key,false)); GalleryActivity.LanguageChanged(); } else if (key.equals("touchscreenScale")) { NativeExports.UISettingsSaveDword(UISettingID.TouchScreen_ButtonScale.getValue(), sharedPreferences.getInt(key, 100)); } else if (key.equals("touchscreenLayout")) { NativeExports.UISettingsSaveString(UISettingID.TouchScreen_Layout.getValue(), sharedPreferences.getString(key, "Analog")); } - else if (key.equals("audio_Enabled")) { NativeExports.SettingsSaveBool(SettingsID.Plugin_EnableAudio.getValue(), sharedPreferences.getBoolean(key,false)); } - else if (key.equals("Debugger_Enabled")) { NativeExports.SettingsSaveBool(SettingsID.Debugger_Enabled.getValue(), sharedPreferences.getBoolean(key,false)); } - else if (key.equals("Debugger_RecordRecompilerAsm")) { NativeExports.SettingsSaveBool(SettingsID.Debugger_RecordRecompilerAsm.getValue(), sharedPreferences.getBoolean(key,false)); } - else if (key.equals("Debugger_CpuUsage")) { NativeExports.SettingsSaveBool(SettingsID.UserInterface_ShowCPUPer.getValue(), sharedPreferences.getBoolean(key,false)); } - else if (key.equals("Debugger_RecordExecutionTimes")) { NativeExports.SettingsSaveBool(SettingsID.Debugger_RecordExecutionTimes.getValue(), sharedPreferences.getBoolean(key,false)); } - else if (key.equals("Debugger_LimitFPS")) { NativeExports.SettingsSaveBool(SettingsID.GameRunning_LimitFPS.getValue(), sharedPreferences.getBoolean(key,false)); } - else if (key.equals("Debugger_DisplaySpeed")) { NativeExports.SettingsSaveBool(SettingsID.UserInterface_DisplayFrameRate.getValue(), sharedPreferences.getBoolean(key,false)); } - else if (key.equals("Debugger_DisplaySpeedType")) { NativeExports.SettingsSaveDword(SettingsID.UserInterface_FrameDisplayType.getValue(), Integer.valueOf(sharedPreferences.getString(key, "0"))); } - else if (key.equals("Debugger_TraceMD5")) { NativeExports.SettingsSaveDword(SettingsID.Debugger_TraceMD5.getValue(), Integer.valueOf(sharedPreferences.getString(key, "1"))); } - else if (key.equals("Debugger_TraceThread")) { NativeExports.SettingsSaveDword(SettingsID.Debugger_TraceThread.getValue(), Integer.valueOf(sharedPreferences.getString(key, "1"))); } - else if (key.equals("Debugger_TracePath")) { NativeExports.SettingsSaveDword(SettingsID.Debugger_TracePath.getValue(), Integer.valueOf(sharedPreferences.getString(key, "1"))); } - else if (key.equals("Debugger_TraceSettings")) { NativeExports.SettingsSaveDword(SettingsID.Debugger_TraceSettings.getValue(), Integer.valueOf(sharedPreferences.getString(key, "1"))); } - else if (key.equals("Debugger_TraceUnknown")) { NativeExports.SettingsSaveDword(SettingsID.Debugger_TraceUnknown.getValue(), Integer.valueOf(sharedPreferences.getString(key, "1"))); } - else if (key.equals("Debugger_TraceAppInit")) { NativeExports.SettingsSaveDword(SettingsID.Debugger_TraceAppInit.getValue(), Integer.valueOf(sharedPreferences.getString(key, "1"))); } - else if (key.equals("Debugger_TraceAppCleanup")) { NativeExports.SettingsSaveDword(SettingsID.Debugger_TraceAppCleanup.getValue(), Integer.valueOf(sharedPreferences.getString(key, "1"))); } - else if (key.equals("Debugger_TraceN64System")) { NativeExports.SettingsSaveDword(SettingsID.Debugger_TraceN64System.getValue(), Integer.valueOf(sharedPreferences.getString(key, "1"))); } - else if (key.equals("Debugger_TracePlugins")) { NativeExports.SettingsSaveDword(SettingsID.Debugger_TracePlugins.getValue(), Integer.valueOf(sharedPreferences.getString(key, "1"))); } - else if (key.equals("Debugger_TraceGFXPlugin")) { NativeExports.SettingsSaveDword(SettingsID.Debugger_TraceGFXPlugin.getValue(), Integer.valueOf(sharedPreferences.getString(key, "1"))); } - else if (key.equals("Debugger_TraceAudioPlugin")) { NativeExports.SettingsSaveDword(SettingsID.Debugger_TraceAudioPlugin.getValue(), Integer.valueOf(sharedPreferences.getString(key, "1"))); } - else if (key.equals("Debugger_TraceControllerPlugin")) { NativeExports.SettingsSaveDword(SettingsID.Debugger_TraceControllerPlugin.getValue(), Integer.valueOf(sharedPreferences.getString(key, "1"))); } - else if (key.equals("Debugger_TraceRSPPlugin")) { NativeExports.SettingsSaveDword(SettingsID.Debugger_TraceRSPPlugin.getValue(), Integer.valueOf(sharedPreferences.getString(key, "1"))); } - else if (key.equals("Debugger_TraceRSP")) { NativeExports.SettingsSaveDword(SettingsID.Debugger_TraceRSP.getValue(), Integer.valueOf(sharedPreferences.getString(key, "1"))); } - else if (key.equals("Debugger_TraceAudio")) { NativeExports.SettingsSaveDword(SettingsID.Debugger_TraceAudio.getValue(), Integer.valueOf(sharedPreferences.getString(key, "1"))); } - else if (key.equals("Debugger_TraceRegisterCache")) { NativeExports.SettingsSaveDword(SettingsID.Debugger_TraceRegisterCache.getValue(), Integer.valueOf(sharedPreferences.getString(key, "1"))); } - else if (key.equals("Debugger_TraceRecompiler")) { NativeExports.SettingsSaveDword(SettingsID.Debugger_TraceRecompiler.getValue(), Integer.valueOf(sharedPreferences.getString(key, "1"))); } - else if (key.equals("Debugger_TraceTLB")) { NativeExports.SettingsSaveDword(SettingsID.Debugger_TraceTLB.getValue(), Integer.valueOf(sharedPreferences.getString(key, "1"))); } - else if (key.equals("Debugger_TraceProtectedMEM")) { NativeExports.SettingsSaveDword(SettingsID.Debugger_TraceProtectedMEM.getValue(), Integer.valueOf(sharedPreferences.getString(key, "1"))); } - else if (key.equals("Debugger_TraceUserInterface")) { NativeExports.SettingsSaveDword(SettingsID.Debugger_TraceUserInterface.getValue(), Integer.valueOf(sharedPreferences.getString(key, "1"))); } - else if (key.equals("Debugger_TraceRomList")) { NativeExports.SettingsSaveDword(SettingsID.Debugger_TraceRomList.getValue(), Integer.valueOf(sharedPreferences.getString(key, "1"))); } - else if (key.equals("Debugger_TraceExceptionHandler")) { NativeExports.SettingsSaveDword(SettingsID.Debugger_TraceExceptionHandler.getValue(), Integer.valueOf(sharedPreferences.getString(key, "1"))); } - else if (key.equals("Debugger_TraceVideoMD5")) { NativeExports.SettingsSaveDword(SettingsID.FirstGfxSettings.getValue() + VideoSettingID.Set_Logging_MD5.getValue(), Integer.valueOf(sharedPreferences.getString(key, "1"))); } + else if (key.equals("audio_Enabled")) { NativeExports.SettingsSaveBool(SettingsID.Plugin_EnableAudio.getValue(), sharedPreferences.getBoolean(key,false)); }*/ + else if (key.equals("Debugger_Enabled")) { NativeExports.SettingsSaveBool(SettingsID.Debugger_Enabled.toString(), sharedPreferences.getBoolean(key,false)); } + else if (key.equals("Debugger_RecordRecompilerAsm")) { NativeExports.SettingsSaveBool(SettingsID.Debugger_RecordRecompilerAsm.toString(), sharedPreferences.getBoolean(key,false)); } + else if (key.equals("Debugger_CpuUsage")) { NativeExports.SettingsSaveBool(SettingsID.UserInterface_ShowCPUPer.toString(), sharedPreferences.getBoolean(key,false)); } + else if (key.equals("Debugger_RecordExecutionTimes")) { NativeExports.SettingsSaveBool(SettingsID.Debugger_RecordExecutionTimes.toString(), sharedPreferences.getBoolean(key,false)); } + else if (key.equals("Debugger_LimitFPS")) { NativeExports.SettingsSaveBool(SettingsID.GameRunning_LimitFPS.toString(), sharedPreferences.getBoolean(key,false)); } + else if (key.equals("Debugger_DisplaySpeed")) { NativeExports.SettingsSaveBool(SettingsID.UserInterface_DisplayFrameRate.toString(), sharedPreferences.getBoolean(key,false)); } + else if (key.equals("Debugger_DisplaySpeedType")) { NativeExports.SettingsSaveDword(SettingsID.UserInterface_FrameDisplayType.toString(), Integer.valueOf(sharedPreferences.getString(key, "0"))); } + else if (key.equals("Debugger_TraceMD5")) { NativeExports.SettingsSaveDword(SettingsID.Debugger_TraceMD5.toString(), Integer.valueOf(sharedPreferences.getString(key, "1"))); } + else if (key.equals("Debugger_TraceThread")) { NativeExports.SettingsSaveDword(SettingsID.Debugger_TraceThread.toString(), Integer.valueOf(sharedPreferences.getString(key, "1"))); } + else if (key.equals("Debugger_TracePath")) { NativeExports.SettingsSaveDword(SettingsID.Debugger_TracePath.toString(), Integer.valueOf(sharedPreferences.getString(key, "1"))); } + else if (key.equals("Debugger_TraceSettings")) { NativeExports.SettingsSaveDword(SettingsID.Debugger_TraceSettings.toString(), Integer.valueOf(sharedPreferences.getString(key, "1"))); } + else if (key.equals("Debugger_TraceUnknown")) { NativeExports.SettingsSaveDword(SettingsID.Debugger_TraceUnknown.toString(), Integer.valueOf(sharedPreferences.getString(key, "1"))); } + else if (key.equals("Debugger_TraceAppInit")) { NativeExports.SettingsSaveDword(SettingsID.Debugger_TraceAppInit.toString(), Integer.valueOf(sharedPreferences.getString(key, "1"))); } + else if (key.equals("Debugger_TraceAppCleanup")) { NativeExports.SettingsSaveDword(SettingsID.Debugger_TraceAppCleanup.toString(), Integer.valueOf(sharedPreferences.getString(key, "1"))); } + else if (key.equals("Debugger_TraceN64System")) { NativeExports.SettingsSaveDword(SettingsID.Debugger_TraceN64System.toString(), Integer.valueOf(sharedPreferences.getString(key, "1"))); } + else if (key.equals("Debugger_TracePlugins")) { NativeExports.SettingsSaveDword(SettingsID.Debugger_TracePlugins.toString(), Integer.valueOf(sharedPreferences.getString(key, "1"))); } + else if (key.equals("Debugger_TraceGFXPlugin")) { NativeExports.SettingsSaveDword(SettingsID.Debugger_TraceGFXPlugin.toString(), Integer.valueOf(sharedPreferences.getString(key, "1"))); } + else if (key.equals("Debugger_TraceAudioPlugin")) { NativeExports.SettingsSaveDword(SettingsID.Debugger_TraceAudioPlugin.toString(), Integer.valueOf(sharedPreferences.getString(key, "1"))); } + else if (key.equals("Debugger_TraceControllerPlugin")) { NativeExports.SettingsSaveDword(SettingsID.Debugger_TraceControllerPlugin.toString(), Integer.valueOf(sharedPreferences.getString(key, "1"))); } + else if (key.equals("Debugger_TraceRSPPlugin")) { NativeExports.SettingsSaveDword(SettingsID.Debugger_TraceRSPPlugin.toString(), Integer.valueOf(sharedPreferences.getString(key, "1"))); } + else if (key.equals("Debugger_TraceRSP")) { NativeExports.SettingsSaveDword(SettingsID.Debugger_TraceRSP.toString(), Integer.valueOf(sharedPreferences.getString(key, "1"))); } + else if (key.equals("Debugger_TraceAudio")) { NativeExports.SettingsSaveDword(SettingsID.Debugger_TraceAudio.toString(), Integer.valueOf(sharedPreferences.getString(key, "1"))); } + else if (key.equals("Debugger_TraceRegisterCache")) { NativeExports.SettingsSaveDword(SettingsID.Debugger_TraceRegisterCache.toString(), Integer.valueOf(sharedPreferences.getString(key, "1"))); } + else if (key.equals("Debugger_TraceRecompiler")) { NativeExports.SettingsSaveDword(SettingsID.Debugger_TraceRecompiler.toString(), Integer.valueOf(sharedPreferences.getString(key, "1"))); } + else if (key.equals("Debugger_TraceTLB")) { NativeExports.SettingsSaveDword(SettingsID.Debugger_TraceTLB.toString(), Integer.valueOf(sharedPreferences.getString(key, "1"))); } + else if (key.equals("Debugger_TraceProtectedMEM")) { NativeExports.SettingsSaveDword(SettingsID.Debugger_TraceProtectedMEM.toString(), Integer.valueOf(sharedPreferences.getString(key, "1"))); } + else if (key.equals("Debugger_TraceUserInterface")) { NativeExports.SettingsSaveDword(SettingsID.Debugger_TraceUserInterface.toString(), Integer.valueOf(sharedPreferences.getString(key, "1"))); } + else if (key.equals("Debugger_TraceRomList")) { NativeExports.SettingsSaveDword(SettingsID.Debugger_TraceRomList.toString(), Integer.valueOf(sharedPreferences.getString(key, "1"))); } + else if (key.equals("Debugger_TraceExceptionHandler")) { NativeExports.SettingsSaveDword(SettingsID.Debugger_TraceExceptionHandler.toString(), Integer.valueOf(sharedPreferences.getString(key, "1"))); } + /*else if (key.equals("Debugger_TraceVideoMD5")) { NativeExports.SettingsSaveDword(SettingsID.FirstGfxSettings.getValue() + VideoSettingID.Set_Logging_MD5.getValue(), Integer.valueOf(sharedPreferences.getString(key, "1"))); } else if (key.equals("Debugger_TraceVideoThread")) { NativeExports.SettingsSaveDword(SettingsID.FirstGfxSettings.getValue() + VideoSettingID.Set_Logging_Thread.getValue(), Integer.valueOf(sharedPreferences.getString(key, "1"))); } else if (key.equals("Debugger_TraceVideoPath")) { NativeExports.SettingsSaveDword(SettingsID.FirstGfxSettings.getValue() + VideoSettingID.Set_Logging_Path.getValue(), Integer.valueOf(sharedPreferences.getString(key, "1"))); } else if (key.equals("Debugger_TraceVideoSettings")) { NativeExports.SettingsSaveDword(SettingsID.FirstGfxSettings.getValue() + VideoSettingID.Set_Logging_Settings.getValue(), Integer.valueOf(sharedPreferences.getString(key, "1"))); } @@ -188,13 +185,13 @@ public class SettingsActivity extends AppCompatActivity implements SharedPrefere else if (key.equals("Debugger_TraceVideoOGLWrapper")) { NativeExports.SettingsSaveDword(SettingsID.FirstGfxSettings.getValue() + VideoSettingID.Set_Logging_OGLWrapper.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("video_screenResolution")) { NativeExports.SettingsSaveDword(SettingsID.FirstGfxSettings.getValue() + VideoSettingID.Set_Resolution.getValue(), Integer.valueOf(sharedPreferences.getString(key, "1"))); } else if (key.equals("video_AspectRatio")) { NativeExports.SettingsSaveDword(SettingsID.FirstGfxSettings.getValue() + VideoSettingID.Set_aspect.getValue(), Integer.valueOf(sharedPreferences.getString(key, "0"))); getSupportFragmentManager().popBackStackImmediate(); getSupportFragmentManager().beginTransaction().replace(R.id.fragment_placeholder, new VideoFragment()).addToBackStack("main").commit(); } - else if (key.equals("MaxRomsRemembered")) { NativeExports.UISettingsSaveDword(UISettingID.File_RecentGameFileCount.getValue(), sharedPreferences.getInt(key, 10)); } + else if (key.equals("MaxRomsRemembered")) { NativeExports.UISettingsSaveDword(UISettingID.File_RecentGameFileCount.getValue(), sharedPreferences.getInt(key, 10)); }*/ } } diff --git a/Android/app/src/main/java/emu/project64/settings/SettingsFragment.java b/Android/app/src/main/java/emu/project64/settings/SettingsFragment.java index a1fdbca2c..8872e4aee 100644 --- a/Android/app/src/main/java/emu/project64/settings/SettingsFragment.java +++ b/Android/app/src/main/java/emu/project64/settings/SettingsFragment.java @@ -9,7 +9,7 @@ public class SettingsFragment extends BaseSettingsFragment @Override protected int getXml() { - if (NativeExports.SettingsLoadBool(SettingsID.UserInterface_BasicMode.getValue())) + if (NativeExports.SettingsLoadBool(SettingsID.UserInterface_BasicMode.toString())) { return R.xml.settings_basic; } diff --git a/Android/app/src/main/java/emu/project64/settings/TwoLinesListPreferenceDialogFragmentCompat.java b/Android/app/src/main/java/emu/project64/settings/TwoLinesListPreferenceDialogFragmentCompat.java index 6e54b2098..1983a1595 100644 --- a/Android/app/src/main/java/emu/project64/settings/TwoLinesListPreferenceDialogFragmentCompat.java +++ b/Android/app/src/main/java/emu/project64/settings/TwoLinesListPreferenceDialogFragmentCompat.java @@ -4,8 +4,8 @@ import emu.project64.R; import android.content.Context; import android.content.DialogInterface; import android.os.Bundle; -import android.support.v7.app.AlertDialog; -import android.support.v7.preference.PreferenceDialogFragmentCompat; +import androidx.appcompat.app.AlertDialog; +import androidx.preference.PreferenceDialogFragmentCompat; import android.view.LayoutInflater; import android.view.View; import android.view.View.OnClickListener; diff --git a/Android/app/src/main/java/emu/project64/util/DeviceUtil.java b/Android/app/src/main/java/emu/project64/util/DeviceUtil.java index 307b3bf00..1df540ae0 100644 --- a/Android/app/src/main/java/emu/project64/util/DeviceUtil.java +++ b/Android/app/src/main/java/emu/project64/util/DeviceUtil.java @@ -28,7 +28,7 @@ public final class DeviceUtil public static String getCpuInfo() { // From http://android-er.blogspot.com/2009/09/read-android-cpu-info.html - String result = Utility.executeShellCommand( "/system/bin/cat", "/proc/cpuinfo" ); + /*String result = Utility.executeShellCommand( "/system/bin/cat", "/proc/cpuinfo" ); // Remove the serial number for privacy Pattern pattern = Pattern.compile( "^serial\\s*?:.*?$", Pattern.CASE_INSENSITIVE @@ -46,17 +46,19 @@ public final class DeviceUtil result += "Manufacturer: " + Build.MANUFACTURER + "\n"; result += "Model: " + Build.MODEL + "\n"; result += "Product: " + Build.PRODUCT + "\n"; - return result; + return result;*/ + return ""; } public static String getLogCat() { - return Utility.executeShellCommand( "logcat", "-d", "-v", "long" ); + //return Utility.executeShellCommand( "logcat", "-d", "-v", "long" ); + return ""; } public static void clearLogCat() { - Utility.executeShellCommand( "logcat", "-c" ); + //Utility.executeShellCommand( "logcat", "-c" ); } @TargetApi( 12 ) diff --git a/Android/app/src/main/java/emu/project64/util/Notifier.java b/Android/app/src/main/java/emu/project64/util/Notifier.java index efacc8319..ccb8e50f5 100644 --- a/Android/app/src/main/java/emu/project64/util/Notifier.java +++ b/Android/app/src/main/java/emu/project64/util/Notifier.java @@ -1,13 +1,11 @@ package emu.project64.util; -import emu.project64.game.GameOverlay; +//import emu.project64.game.GameOverlay; import emu.project64.jni.NativeExports; import emu.project64.jni.SettingsID; import emu.project64.Project64Application; import emu.project64.R; -import com.google.android.gms.analytics.HitBuilders; - import android.app.Activity; import android.app.AlertDialog; import android.content.DialogInterface; @@ -81,11 +79,11 @@ public final class Notifier if( activity == null ) return; - GameOverlay overlay = (GameOverlay) activity.findViewById(R.id.gameOverlay); + /*GameOverlay overlay = (GameOverlay) activity.findViewById(R.id.gameOverlay); if (overlay == null) return; - overlay.SetDisplayMessage(message, Duratation); + overlay.SetDisplayMessage(message, Duratation);*/ } public static void showMessage2( Activity activity, String message ) @@ -93,17 +91,17 @@ public final class Notifier if( activity == null ) return; - GameOverlay overlay = (GameOverlay) activity.findViewById(R.id.gameOverlay); - overlay.SetDisplayMessage2(message); + /*GameOverlay overlay = (GameOverlay) activity.findViewById(R.id.gameOverlay); + overlay.SetDisplayMessage2(message);*/ } public static void EmulationStarted (Activity activity) { - ((Project64Application) activity.getApplication()).getDefaultTracker().send(new HitBuilders.EventBuilder() + /*((Project64Application) activity.getApplication()).getDefaultTracker().send(new HitBuilders.EventBuilder() .setCategory("game") .setAction(NativeExports.SettingsLoadString(SettingsID.Rdb_GoodName.getValue())) .setLabel(NativeExports.appVersion()) - .build()); + .build());*/ } private static Runnable runEmulationStopped = null; diff --git a/Android/app/src/main/java/emu/project64/util/Utility.java b/Android/app/src/main/java/emu/project64/util/Utility.java index 56b1c1d7e..96540ed33 100644 --- a/Android/app/src/main/java/emu/project64/util/Utility.java +++ b/Android/app/src/main/java/emu/project64/util/Utility.java @@ -9,54 +9,6 @@ import emu.project64.Project64Application; public final class Utility { - - /** - * Clamps a value to the limit defined by min and max. - * - * @param val The value to clamp to min and max. - * @param min The lowest number val can be equal to. - * @param max The largest number val can be equal to. - * - * @return If the value is lower than min, min is returned.
- * If the value is higher than max, max is returned. - */ - public static> T clamp( T val, T min, T max ) - { - final T temp; - - // val < max - if ( val.compareTo(max) < 0 ) - temp = val; - else - temp = max; - - // temp > min - if ( temp.compareTo(min) > 0 ) - return temp; - else - return min; - } - - public static String executeShellCommand(String... args) - { - try - { - Process process = Runtime.getRuntime().exec( args ); - BufferedReader reader = new BufferedReader( new InputStreamReader( process.getInputStream() ) ); - StringBuilder result = new StringBuilder(); - String line; - while( ( line = reader.readLine() ) != null ) - { - result.append( line + "\n" ); - } - return result.toString(); - } - catch( IOException ignored ) - { - } - return ""; - } - public static boolean close(Closeable closeable) { if (closeable != null) diff --git a/Android/app/src/main/res/values/attrs.xml b/Android/app/src/main/res/values/attrs.xml index e4025da0c..2079f4be4 100644 --- a/Android/app/src/main/res/values/attrs.xml +++ b/Android/app/src/main/res/values/attrs.xml @@ -17,4 +17,105 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/Android/app/src/main/res/values/colors.xml b/Android/app/src/main/res/values/colors.xml index dd57e68f2..40f91ca1c 100644 --- a/Android/app/src/main/res/values/colors.xml +++ b/Android/app/src/main/res/values/colors.xml @@ -8,7 +8,7 @@ #4683ec #ffffff - #000001 + #ffffff #F8E334 #F29620 @@ -22,21 +22,12 @@ #9C9897 #747273 #424042 - #fafafa - #f5f5f5 - #eeeeee + #FF8800 + #ff610a #e0e0e0 - #bdbdbd - #9e9e9e - #757575 #616161 - #424242 - #323232 - #2a2a2a - #212121 #33B5E5 #0099CC #AA66CC #9933CC - \ No newline at end of file diff --git a/Android/jni/Project64-core/CMakeLists.txt b/Android/jni/Project64-core/CMakeLists.txt index 43ee2831c..0746d0f64 100644 --- a/Android/jni/Project64-core/CMakeLists.txt +++ b/Android/jni/Project64-core/CMakeLists.txt @@ -19,11 +19,23 @@ add_library(Project64-core STATIC N64System/Interpreter/InterpreterCPU.cpp N64System/Interpreter/InterpreterOps.cpp N64System/Interpreter/InterpreterOps32.cpp - N64System/Mips/Audio.cpp + N64System/MemoryHandler/AudioInterfaceHandler.cpp + N64System/MemoryHandler/CartridgeDomain1Address1Handler.cpp + N64System/MemoryHandler/CartridgeDomain1Address3Handler.cpp + N64System/MemoryHandler/CartridgeDomain2Address1Handler.cpp + N64System/MemoryHandler/CartridgeDomain2Address2Handler.cpp + N64System/MemoryHandler/DisplayControlRegHandler.cpp + N64System/MemoryHandler/MIPSInterfaceHandler.cpp + N64System/MemoryHandler/PeripheralInterfaceHandler.cpp + N64System/MemoryHandler/PifRamHandler.cpp + N64System/MemoryHandler/RDRAMInterfaceHandler.cpp + N64System/MemoryHandler/RDRAMRegistersHandler.cpp + N64System/MemoryHandler/RomMemoryHandler.cpp + N64System/MemoryHandler/SerialInterfaceHandler.cpp + N64System/MemoryHandler/SPRegistersHandler.cpp + N64System/MemoryHandler/VideoInterfaceHandler.cpp N64System/Mips/Dma.cpp N64System/Mips/Disk.cpp - N64System/Mips/Eeprom.cpp - N64System/Mips/FlashRam.cpp N64System/Mips/GBCart.cpp N64System/Mips/MemoryVirtualMem.cpp N64System/Mips/Mempak.cpp @@ -32,7 +44,6 @@ add_library(Project64-core STATIC N64System/Mips/Register.cpp N64System/Mips/Rumblepak.cpp N64System/Mips/Transferpak.cpp - N64System/Mips/Sram.cpp N64System/Mips/SystemEvents.cpp N64System/Mips/SystemTiming.cpp N64System/Mips/TLB.cpp @@ -53,6 +64,9 @@ add_library(Project64-core STATIC N64System/Recompiler/x86/x86ops.cpp N64System/Recompiler/x86/x86RecompilerOps.cpp N64System/Recompiler/x86/x86RegInfo.cpp + N64System/SaveType/Eeprom.cpp + N64System/SaveType/FlashRam.cpp + N64System/SaveType/Sram.cpp N64System/FramePerSecond.cpp N64System/N64System.cpp N64System/N64Rom.cpp diff --git a/Source/Android/Bridge/jniBridge.cpp b/Source/Android/Bridge/jniBridge.cpp index 7275014bc..aa54fb235 100644 --- a/Source/Android/Bridge/jniBridge.cpp +++ b/Source/Android/Bridge/jniBridge.cpp @@ -6,6 +6,7 @@ #include #include #include +#include #include #include #include diff --git a/Source/Project64-core/MemoryExceptionFilter.cpp b/Source/Project64-core/MemoryExceptionFilter.cpp index 15c311ee2..67861c756 100644 --- a/Source/Project64-core/MemoryExceptionFilter.cpp +++ b/Source/Project64-core/MemoryExceptionFilter.cpp @@ -516,7 +516,7 @@ bool CMipsMemoryVM::FilterArmException(uint32_t MemAddress, mcontext_t & context return true; } - if (OpCode32->uint16.opcode == ArmLDRH_W) + /*if (OpCode32->uint16.opcode == ArmLDRH_W) { // f833 c001 ldrh.w ip, [r3, r1] g_MMU->LH_NonMemory((MemAddress | 0x80000000) ^ 2, ArmRegisters[OpCode32->uint16.rt]); @@ -539,7 +539,7 @@ bool CMipsMemoryVM::FilterArmException(uint32_t MemAddress, mcontext_t & context !g_MMU->LH_NonMemory((MemAddress | 0x80000000) ^ 2, ArmRegisters[OpCode32->reg_cond.rt], false); context.arm_pc = context.arm_pc + 4; return true; - } + }*/ if (OpCode32->reg_cond_imm5.opcode == 3 && OpCode32->reg_cond_imm5.opcode1 == 0 && OpCode32->reg_cond_imm5.opcode2 == 1 && OpCode32->reg_cond_imm5.opcode3 == 0) { diff --git a/Source/Project64-core/N64System/MemoryHandler/stdafx.h b/Source/Project64-core/N64System/MemoryHandler/stdafx.h new file mode 100644 index 000000000..8b696d0b1 --- /dev/null +++ b/Source/Project64-core/N64System/MemoryHandler/stdafx.h @@ -0,0 +1 @@ +#include "../stdafx.h" diff --git a/Source/Project64-core/N64System/N64System.h b/Source/Project64-core/N64System/N64System.h index 5ef436628..786d5f6c3 100644 --- a/Source/Project64-core/N64System/N64System.h +++ b/Source/Project64-core/N64System/N64System.h @@ -122,6 +122,7 @@ private: friend class CSystemTimer; friend class CRecompiler; friend class CX86RecompilerOps; + friend class CArmRecompilerOps; friend class CMipsMemoryVM; friend class CInterpreterCPU; friend class R4300iOp32; diff --git a/Source/Project64-core/N64System/Recompiler/Arm/ArmRecompilerOps.cpp b/Source/Project64-core/N64System/Recompiler/Arm/ArmRecompilerOps.cpp index c715b6468..72598f25f 100644 --- a/Source/Project64-core/N64System/Recompiler/Arm/ArmRecompilerOps.cpp +++ b/Source/Project64-core/N64System/Recompiler/Arm/ArmRecompilerOps.cpp @@ -24,7 +24,7 @@ CPU_Message("%s: %X t2: %X", __FUNCTION__,TestValue, g_Reg->m_GPR[10].UW[0]); }*/ void CArmRecompilerOps::PreCompileOpcode(void) { - if (m_PipelineStage != DELAY_SLOT_DONE) + if (m_PipelineStage != PIPELINE_STAGE_DELAY_SLOT_DONE) { CPU_Message(" %X %s", m_CompilePC, R4300iOpcodeName(m_Opcode.Hex, m_CompilePC)); } @@ -39,7 +39,7 @@ void CArmRecompilerOps::PreCompileOpcode(void) CallFunction(AddressOf(&TestFunc), "TestFunc"); m_RegWorkingSet.AfterCallDirect();*/ - /*if ((m_CompilePC == 0x8027F564 || m_CompilePC == 0x8027F574) && m_PipelineStage == NORMAL) + /*if ((m_CompilePC == 0x8027F564 || m_CompilePC == 0x8027F574) && m_PipelineStage == PIPELINE_STAGE_NORMAL) { m_RegWorkingSet.BeforeCallDirect(); MoveConstToArmReg(Arm_R0,(uint32_t)&TestValue, "TestValue"); @@ -64,7 +64,7 @@ void CArmRecompilerOps::PreCompileOpcode(void) } }*/ - /*if (m_CompilePC == 0x8027F564 && m_PipelineStage == NORMAL) + /*if (m_CompilePC == 0x8027F564 && m_PipelineStage == PIPELINE_STAGE_NORMAL) { m_RegWorkingSet.WriteBackRegisters(); UpdateCounters(m_RegWorkingSet,false,true); @@ -88,12 +88,17 @@ void CArmRecompilerOps::PostCompileOpcode(void) m_RegWorkingSet.ResetRegProtection(); } -CArmRecompilerOps::CArmRecompilerOps() : - m_PipelineStage(NORMAL) +CArmRecompilerOps::CArmRecompilerOps(CMipsMemoryVM & MMU) : + m_MMU(MMU), + m_PipelineStage(PIPELINE_STAGE_NORMAL) { memset(&m_Opcode, 0, sizeof(m_Opcode)); } +CArmRecompilerOps::~CArmRecompilerOps() +{ +} + bool DelaySlotEffectsCompare(uint32_t PC, uint32_t Reg1, uint32_t Reg2); void CArmRecompilerOps::Compile_TrapCompare(TRAP_COMPARE CompareType) @@ -192,7 +197,7 @@ void CArmRecompilerOps::Compile_Branch(BRANCH_COMPARE CompareType, BRANCH_TYPE B static bool EffectDelaySlot; OPCODE Command = { 0 }; - if (m_PipelineStage == NORMAL) + if (m_PipelineStage == PIPELINE_STAGE_NORMAL) { if (CompareType == CompareTypeCOP1BCF || CompareType == CompareTypeCOP1BCT) { @@ -322,7 +327,7 @@ void CArmRecompilerOps::Compile_Branch(BRANCH_COMPARE CompareType, BRANCH_TYPE B { g_Notify->BreakPoint(__FILE__, __LINE__); } - MoveConstToVariable(m_Section->m_Jump.TargetPC, &R4300iOp::m_JumpToLocation, "R4300iOp::m_JumpToLocation"); + MoveConstToVariable(m_Section->m_Jump.TargetPC, &g_System->m_JumpToLocation, "System::m_JumpToLocation"); } else if (m_Section->m_Cont.FallThrough) { @@ -330,7 +335,7 @@ void CArmRecompilerOps::Compile_Branch(BRANCH_COMPARE CompareType, BRANCH_TYPE B { g_Notify->BreakPoint(__FILE__, __LINE__); } - MoveConstToVariable(m_Section->m_Cont.TargetPC, &R4300iOp::m_JumpToLocation, "R4300iOp::m_JumpToLocation"); + MoveConstToVariable(m_Section->m_Cont.TargetPC, &g_System->m_JumpToLocation, "System::m_JumpToLocation"); } if (m_Section->m_Jump.LinkLocation != nullptr || m_Section->m_Jump.LinkLocation2 != nullptr) @@ -342,7 +347,7 @@ void CArmRecompilerOps::Compile_Branch(BRANCH_COMPARE CompareType, BRANCH_TYPE B CPU_Message(" "); CPU_Message(" %s:", m_Section->m_Jump.BranchLabel.c_str()); LinkJump(m_Section->m_Jump); - MoveConstToVariable(m_Section->m_Jump.TargetPC, &R4300iOp::m_JumpToLocation, "R4300iOp::m_JumpToLocation"); + MoveConstToVariable(m_Section->m_Jump.TargetPC, &g_System->m_JumpToLocation, "System::m_JumpToLocation"); } if (m_Section->m_Cont.LinkLocation != nullptr || m_Section->m_Cont.LinkLocation2 != nullptr) { @@ -353,7 +358,7 @@ void CArmRecompilerOps::Compile_Branch(BRANCH_COMPARE CompareType, BRANCH_TYPE B CPU_Message(" "); CPU_Message(" %s:", m_Section->m_Cont.BranchLabel.c_str()); LinkJump(m_Section->m_Cont); - MoveConstToVariable(m_Section->m_Cont.TargetPC, &R4300iOp::m_JumpToLocation, "R4300iOp::m_JumpToLocation"); + MoveConstToVariable(m_Section->m_Cont.TargetPC, &g_System->m_JumpToLocation, "System::m_JumpToLocation"); } if (DelayLinkLocation) { @@ -370,7 +375,7 @@ void CArmRecompilerOps::Compile_Branch(BRANCH_COMPARE CompareType, BRANCH_TYPE B } m_PipelineStage = PIPELINE_STAGE_DO_DELAY_SLOT; } - else if (m_PipelineStage == DELAY_SLOT_DONE) + else if (m_PipelineStage == PIPELINE_STAGE_DELAY_SLOT_DONE) { if (EffectDelaySlot) { @@ -461,7 +466,7 @@ void CArmRecompilerOps::Compile_Branch(BRANCH_COMPARE CompareType, BRANCH_TYPE B } } m_Section->GenerateSectionLinkage(); - m_PipelineStage = END_BLOCK; + m_PipelineStage = PIPELINE_STAGE_END_BLOCK; } else { @@ -474,7 +479,7 @@ void CArmRecompilerOps::Compile_Branch(BRANCH_COMPARE CompareType, BRANCH_TYPE B void CArmRecompilerOps::Compile_BranchLikely(BRANCH_COMPARE CompareType, bool Link) { - if (m_PipelineStage == NORMAL) + if (m_PipelineStage == PIPELINE_STAGE_NORMAL) { if (CompareType == CompareTypeCOP1BCF || CompareType == CompareTypeCOP1BCT) { @@ -556,7 +561,7 @@ void CArmRecompilerOps::Compile_BranchLikely(BRANCH_COMPARE CompareType, bool Li { LinkJump(m_Section->m_Jump); - MoveConstToVariable(m_Section->m_Jump.TargetPC, &R4300iOp::m_JumpToLocation, "R4300iOp::m_JumpToLocation"); + MoveConstToVariable(m_Section->m_Jump.TargetPC, &g_System->m_JumpToLocation, "System::m_JumpToLocation"); OverflowDelaySlot(false); CPU_Message(" "); CPU_Message(" %s:", m_Section->m_Cont.BranchLabel.c_str()); @@ -579,7 +584,7 @@ void CArmRecompilerOps::Compile_BranchLikely(BRANCH_COMPARE CompareType, bool Li { m_Section->m_Jump.RegSet = m_RegWorkingSet; m_Section->GenerateSectionLinkage(); - m_PipelineStage = END_BLOCK; + m_PipelineStage = PIPELINE_STAGE_END_BLOCK; } else { @@ -590,16 +595,16 @@ void CArmRecompilerOps::Compile_BranchLikely(BRANCH_COMPARE CompareType, bool Li g_Notify->BreakPoint(__FILE__, __LINE__); } m_Section->GenerateSectionLinkage(); - m_PipelineStage = END_BLOCK; + m_PipelineStage = PIPELINE_STAGE_END_BLOCK; } } } - else if (m_PipelineStage == DELAY_SLOT_DONE) + else if (m_PipelineStage == PIPELINE_STAGE_DELAY_SLOT_DONE) { ResetRegProtection(); m_Section->m_Jump.RegSet = m_RegWorkingSet; m_Section->GenerateSectionLinkage(); - m_PipelineStage = END_BLOCK; + m_PipelineStage = PIPELINE_STAGE_END_BLOCK; } else if (HaveDebugger()) { @@ -1835,11 +1840,11 @@ void CArmRecompilerOps::COP1_BCT_Compare() void CArmRecompilerOps::J() { - if (m_PipelineStage == NORMAL) + if (m_PipelineStage == PIPELINE_STAGE_NORMAL) { if ((m_CompilePC & 0xFFC) == 0xFFC) { - MoveConstToVariable((m_CompilePC & 0xF0000000) + (m_Opcode.target << 2), &R4300iOp::m_JumpToLocation, "R4300iOp::m_JumpToLocation"); + MoveConstToVariable((m_CompilePC & 0xF0000000) + (m_Opcode.target << 2), &g_System->m_JumpToLocation, "System::m_JumpToLocation"); OverflowDelaySlot(false); return; } @@ -1859,11 +1864,11 @@ void CArmRecompilerOps::J() m_Section->m_Jump.LinkLocation2 = nullptr; m_PipelineStage = PIPELINE_STAGE_DO_DELAY_SLOT; } - else if (m_PipelineStage == DELAY_SLOT_DONE) + else if (m_PipelineStage == PIPELINE_STAGE_DELAY_SLOT_DONE) { m_Section->m_Jump.RegSet = m_RegWorkingSet; m_Section->GenerateSectionLinkage(); - m_PipelineStage = END_BLOCK; + m_PipelineStage = PIPELINE_STAGE_END_BLOCK; } else if (HaveDebugger()) { @@ -1873,7 +1878,7 @@ void CArmRecompilerOps::J() void CArmRecompilerOps::JAL() { - if (m_PipelineStage == NORMAL) + if (m_PipelineStage == PIPELINE_STAGE_NORMAL) { Map_GPR_32bit(31, true, -1); MoveVariableToArmReg(_PROGRAM_COUNTER, "_PROGRAM_COUNTER", GetMipsRegMapLo(31)); @@ -1886,7 +1891,7 @@ void CArmRecompilerOps::JAL() if ((m_CompilePC & 0xFFC) == 0xFFC) { - MoveConstToVariable((m_CompilePC & 0xF0000000) + (m_Opcode.target << 2), &R4300iOp::m_JumpToLocation, "R4300iOp::m_JumpToLocation"); + MoveConstToVariable((m_CompilePC & 0xF0000000) + (m_Opcode.target << 2), &g_System->m_JumpToLocation, "System::m_JumpToLocation"); OverflowDelaySlot(false); return; } @@ -1905,7 +1910,7 @@ void CArmRecompilerOps::JAL() m_Section->m_Jump.LinkLocation2 = nullptr; m_PipelineStage = PIPELINE_STAGE_DO_DELAY_SLOT; } - else if (m_PipelineStage == DELAY_SLOT_DONE) + else if (m_PipelineStage == PIPELINE_STAGE_DELAY_SLOT_DONE) { if (m_Section->m_JumpSection) { @@ -1930,7 +1935,7 @@ void CArmRecompilerOps::JAL() CompileExit((uint32_t)-1, (uint32_t)-1, m_RegWorkingSet, bCheck ? CExitInfo::Normal : CExitInfo::Normal_NoSysCheck); } - m_PipelineStage = END_BLOCK; + m_PipelineStage = PIPELINE_STAGE_END_BLOCK; } else { @@ -2800,20 +2805,20 @@ void CArmRecompilerOps::SPECIAL_SRAV() void CArmRecompilerOps::SPECIAL_JR() { - if (m_PipelineStage == NORMAL) + if (m_PipelineStage == PIPELINE_STAGE_NORMAL) { if ((m_CompilePC & 0xFFC) == 0xFFC) { if (IsKnown(m_Opcode.rs) && IsMapped(m_Opcode.rs)) { - MoveArmRegToVariable(GetMipsRegMapLo(m_Opcode.rs), &R4300iOp::m_JumpToLocation, "R4300iOp::m_JumpToLocation"); + MoveArmRegToVariable(GetMipsRegMapLo(m_Opcode.rs), &g_System->m_JumpToLocation, "System::m_JumpToLocation"); m_RegWorkingSet.WriteBackRegisters(); } else { m_RegWorkingSet.WriteBackRegisters(); MoveVariableToArmReg(&_GPR[m_Opcode.rs].UW[0], CRegName::GPR_Lo[m_Opcode.rs], Arm_R0); - MoveConstToArmReg(Arm_R1, (uint32_t)&R4300iOp::m_JumpToLocation, "R4300iOp::m_JumpToLocation"); + MoveConstToArmReg(Arm_R1, (uint32_t)&g_System->m_JumpToLocation, "System::m_JumpToLocation"); StoreArmRegToArmRegPointer(Arm_R0, Arm_R1, 0); } OverflowDelaySlot(true); @@ -2849,7 +2854,7 @@ void CArmRecompilerOps::SPECIAL_JR() } m_PipelineStage = PIPELINE_STAGE_DO_DELAY_SLOT; } - else if (m_PipelineStage == DELAY_SLOT_DONE) + else if (m_PipelineStage == PIPELINE_STAGE_DELAY_SLOT_DONE) { if (DelaySlotEffectsCompare(m_CompilePC, m_Opcode.rs, 0)) { @@ -2884,7 +2889,7 @@ void CArmRecompilerOps::SPECIAL_JR() m_Section->GenerateSectionLinkage(); } } - m_PipelineStage = END_BLOCK; + m_PipelineStage = PIPELINE_STAGE_END_BLOCK; } else if (HaveDebugger()) { @@ -2894,7 +2899,7 @@ void CArmRecompilerOps::SPECIAL_JR() void CArmRecompilerOps::SPECIAL_JALR() { - if (m_PipelineStage == NORMAL) + if (m_PipelineStage == PIPELINE_STAGE_NORMAL) { if (DelaySlotEffectsCompare(m_CompilePC, m_Opcode.rs, 0) && (m_CompilePC & 0xFFC) != 0xFFC) { @@ -2913,7 +2918,7 @@ void CArmRecompilerOps::SPECIAL_JALR() if ((m_CompilePC & 0xFFC) == 0xFFC) { ArmReg TempRegVar = m_RegWorkingSet.Map_TempReg(Arm_Any, -1, false); - MoveConstToArmReg(TempRegVar, (uint32_t)&R4300iOp::m_JumpToLocation, "R4300iOp::m_JumpToLocation"); + MoveConstToArmReg(TempRegVar, (uint32_t)&g_System->m_JumpToLocation, "System::m_JumpToLocation"); ArmReg TempRegRs = Arm_Unknown; if (IsKnown(m_Opcode.rs) && IsMapped(m_Opcode.rs)) @@ -2941,7 +2946,7 @@ void CArmRecompilerOps::SPECIAL_JALR() m_PipelineStage = PIPELINE_STAGE_DO_DELAY_SLOT; } - else if (m_PipelineStage == DELAY_SLOT_DONE) + else if (m_PipelineStage == PIPELINE_STAGE_DELAY_SLOT_DONE) { if (DelaySlotEffectsCompare(m_CompilePC, m_Opcode.rs, 0)) { @@ -2963,7 +2968,7 @@ void CArmRecompilerOps::SPECIAL_JALR() m_Section->GenerateSectionLinkage(); } } - m_PipelineStage = END_BLOCK; + m_PipelineStage = PIPELINE_STAGE_END_BLOCK; } else if (HaveDebugger()) { @@ -2974,7 +2979,7 @@ void CArmRecompilerOps::SPECIAL_JALR() void CArmRecompilerOps::SPECIAL_SYSCALL() { CompileExit(m_CompilePC, (uint32_t)-1, m_RegWorkingSet, CExitInfo::DoSysCall); - m_PipelineStage = END_BLOCK; + m_PipelineStage = PIPELINE_STAGE_END_BLOCK; } void CArmRecompilerOps::SPECIAL_MFLO() @@ -4000,7 +4005,7 @@ void CArmRecompilerOps::COP0_CO_ERET() UpdateCounters(m_RegWorkingSet, true, true); CompileExit(m_CompilePC, (uint32_t)-1, m_RegWorkingSet, CExitInfo::Normal); - m_PipelineStage = END_BLOCK; + m_PipelineStage = PIPELINE_STAGE_END_BLOCK; } // COP1 functions @@ -4693,7 +4698,7 @@ void CArmRecompilerOps::UnknownOpcode() MoveConstToVariable(m_Opcode.Hex, &R4300iOp::m_Opcode.Hex, "R4300iOp::m_Opcode.Hex"); CallFunction((void *)R4300iOp::UnknownOpcode, "R4300iOp::UnknownOpcode"); ExitCodeBlock(); - if (m_PipelineStage == NORMAL) { m_PipelineStage = END_BLOCK; } + if (m_PipelineStage == PIPELINE_STAGE_NORMAL) { m_PipelineStage = PIPELINE_STAGE_END_BLOCK; } } void CArmRecompilerOps::EnterCodeBlock() @@ -5276,14 +5281,14 @@ void CArmRecompilerOps::CompileExit(uint32_t JumpPC, uint32_t TargetPC, CRegInfo ExitCodeBlock(); break; case CExitInfo::DoSysCall: - bDelay = m_PipelineStage == JUMP || m_PipelineStage == DELAY_SLOT; + bDelay = m_PipelineStage == PIPELINE_STAGE_JUMP || m_PipelineStage == PIPELINE_STAGE_DELAY_SLOT; MoveConstToArmReg(Arm_R1, (uint32_t)bDelay, bDelay ? "true" : "false"); MoveConstToArmReg(Arm_R0, (uint32_t)g_Reg); CallFunction(AddressOf(&CRegisters::DoSysCallException), "CRegisters::DoSysCallException"); ExitCodeBlock(); break; case CExitInfo::COP1_Unuseable: - bDelay = m_PipelineStage == JUMP || m_PipelineStage == DELAY_SLOT; + bDelay = m_PipelineStage == PIPELINE_STAGE_JUMP || m_PipelineStage == PIPELINE_STAGE_DELAY_SLOT; MoveConstToArmReg(Arm_R2, (uint32_t)1, "1"); MoveConstToArmReg(Arm_R1, (uint32_t)bDelay, bDelay ? "true" : "false"); MoveConstToArmReg(Arm_R0, (uint32_t)g_Reg); @@ -5291,7 +5296,7 @@ void CArmRecompilerOps::CompileExit(uint32_t JumpPC, uint32_t TargetPC, CRegInfo ExitCodeBlock(); break; case CExitInfo::TLBReadMiss: - bDelay = m_PipelineStage == JUMP || m_PipelineStage == DELAY_SLOT; + bDelay = m_PipelineStage == PIPELINE_STAGE_JUMP || m_PipelineStage == PIPELINE_STAGE_DELAY_SLOT; MoveVariableToArmReg(g_TLBLoadAddress, "g_TLBLoadAddress", Arm_R2); MoveConstToArmReg(Arm_R1, (uint32_t)bDelay, bDelay ? "true" : "false"); MoveConstToArmReg(Arm_R0, (uint32_t)g_Reg); @@ -5868,12 +5873,12 @@ void CArmRecompilerOps::SetCurrentSection(CCodeSection * section) m_Section = section; } -void CArmRecompilerOps::SetNextStepType(STEP_TYPE StepType) +void CArmRecompilerOps::SetNextStepType(PIPELINE_STAGE StepType) { m_PipelineStage = StepType; } -STEP_TYPE CArmRecompilerOps::GetNextStepType(void) +PIPELINE_STAGE CArmRecompilerOps::GetNextStepType(void) { return m_PipelineStage; } @@ -5970,7 +5975,7 @@ void CArmRecompilerOps::OverflowDelaySlot(bool TestTimer) CallFunction(AddressOf(&CN64System::SyncSystem), "CN64System::SyncSystem"); } - MoveConstToVariable(JUMP, &R4300iOp::m_PipelineStage, "R4300iOp::m_PipelineStage"); + MoveConstToVariable(PIPELINE_STAGE_JUMP, &g_System->m_PipelineStage, "g_System->m_PipelineStage"); if (TestTimer) { @@ -5991,7 +5996,7 @@ void CArmRecompilerOps::OverflowDelaySlot(bool TestTimer) } ExitCodeBlock(); - m_PipelineStage = END_BLOCK; + m_PipelineStage = PIPELINE_STAGE_END_BLOCK; } void CArmRecompilerOps::SW_Const(uint32_t Value, uint32_t VAddr) @@ -6012,7 +6017,7 @@ void CArmRecompilerOps::SW_Const(uint32_t Value, uint32_t VAddr) } uint32_t PAddr; - if (!g_TransVaddr->TranslateVaddr(VAddr, PAddr)) + if (!m_MMU.VAddrToPAddr(VAddr, PAddr)) { CPU_Message("%s\nFailed to translate address: %08X", __FUNCTION__, VAddr); if (ShowUnhandledMemory()) @@ -6073,9 +6078,10 @@ void CArmRecompilerOps::SW_Const(uint32_t Value, uint32_t VAddr) case 0x04040004: MoveConstToVariable(Value, &g_Reg->SP_DRAM_ADDR_REG, "SP_DRAM_ADDR_REG"); break; case 0x04040008: m_RegWorkingSet.BeforeCallDirect(); - PushImm32(0xFFFFFFFF); + ArmBreakPoint(__FILE__, __LINE__); + /*PushImm32(0xFFFFFFFF); PushImm32(Value); - PushImm32(PAddr & 0x1FFFFFFF); + PushImm32(PAddr & 0x1FFFFFFF);*/ MoveConstToArmReg(Arm_R0, (uint32_t)(MemoryHandler *)&g_MMU->m_SPRegistersHandler, "(MemoryHandler *)g_MMU->m_SPRegistersHandler"); CallFunction((void *)((long**)(MemoryHandler *)&g_MMU->m_SPRegistersHandler)[0][1], "SPRegistersHandler::Write32"); m_RegWorkingSet.AfterCallDirect(); @@ -6323,8 +6329,8 @@ void CArmRecompilerOps::SW_Const(uint32_t Value, uint32_t VAddr) if (g_System->bFixedAudio()) { ArmBreakPoint(__FILE__, __LINE__); - MoveConstToArmReg(Arm_R0, (uint32_t)g_Audio, "g_Audio"); - CallFunction(AddressOf(&CAudio::LenChanged), "LenChanged"); + //MoveConstToArmReg(Arm_R0, (uint32_t)g_Audio, "g_Audio"); + //CallFunction(AddressOf(&CAudio::LenChanged), "LenChanged"); } else { @@ -6529,7 +6535,7 @@ void CArmRecompilerOps::SW_Register(ArmReg Reg, uint32_t VAddr) } uint32_t PAddr; - if (!g_TransVaddr->TranslateVaddr(VAddr, PAddr)) + if (!m_MMU.VAddrToPAddr(VAddr, PAddr)) { CPU_Message("%s\nFailed to translate address: %08X", __FUNCTION__, VAddr); if (ShowUnhandledMemory()) @@ -6576,9 +6582,10 @@ void CArmRecompilerOps::SW_Register(ArmReg Reg, uint32_t VAddr) case 0x04040004: MoveArmRegToVariable(Reg, &g_Reg->SP_DRAM_ADDR_REG, "SP_DRAM_ADDR_REG"); break; case 0x04040008: m_RegWorkingSet.BeforeCallDirect(); - PushImm32(0xFFFFFFFF); + ArmBreakPoint(__FILE__, __LINE__); + /*PushImm32(0xFFFFFFFF); Push(Reg); - PushImm32(PAddr & 0x1FFFFFFF); + PushImm32(PAddr & 0x1FFFFFFF);*/ MoveConstToArmReg(Arm_R0, (uint32_t)(MemoryHandler *)&g_MMU->m_SPRegistersHandler, "(MemoryHandler *)g_MMU->m_SPRegistersHandler"); CallFunction((void *)((long**)(MemoryHandler *)&g_MMU->m_SPRegistersHandler)[0][1], "SPRegistersHandler::Write32"); m_RegWorkingSet.AfterCallDirect(); @@ -6641,11 +6648,12 @@ void CArmRecompilerOps::SW_Register(ArmReg Reg, uint32_t VAddr) switch (PAddr) { case 0x04300000: - MoveArmRegToVariable(Reg, &CMipsMemoryVM::m_MemLookupValue.UW[0], "CMipsMemoryVM::m_MemLookupValue.UW[0]"); + ArmBreakPoint(__FILE__, __LINE__); + /*MoveArmRegToVariable(Reg, &CMipsMemoryVM::m_MemLookupValue.UW[0], "CMipsMemoryVM::m_MemLookupValue.UW[0]"); MoveConstToVariable(PAddr, &CMipsMemoryVM::m_MemLookupAddress, "m_MemLookupAddress"); m_RegWorkingSet.BeforeCallDirect(); CallFunction((void *)CMipsMemoryVM::Write32MIPSInterface, "CMipsMemoryVM::Write32MIPSInterface"); - m_RegWorkingSet.AfterCallDirect(); + m_RegWorkingSet.AfterCallDirect();*/ break; case 0x0430000C: MoveArmRegToVariable(Reg, &CMipsMemoryVM::RegModValue, "CMipsMemoryVM::RegModValue"); @@ -6744,8 +6752,9 @@ void CArmRecompilerOps::SW_Register(ArmReg Reg, uint32_t VAddr) m_RegWorkingSet.BeforeCallDirect(); if (g_System->bFixedAudio()) { - MoveConstToArmReg(Arm_R0, (uint32_t)g_Audio, "g_Audio"); - CallFunction(AddressOf(&CAudio::LenChanged), "LenChanged"); + ArmBreakPoint(__FILE__, __LINE__); + //MoveConstToArmReg(Arm_R0, (uint32_t)g_Audio, "g_Audio"); + //CallFunction(AddressOf(&CAudio::LenChanged), "LenChanged"); } else { @@ -6982,7 +6991,7 @@ void CArmRecompilerOps::LB_KnownAddress(ArmReg Reg, uint32_t VAddr, bool SignExt } uint32_t PAddr; - if (!g_TransVaddr->TranslateVaddr(VAddr, PAddr)) + if (!m_MMU.VAddrToPAddr(VAddr, PAddr)) { g_Notify->BreakPoint(__FILE__, __LINE__); return; @@ -7031,7 +7040,7 @@ void CArmRecompilerOps::LW_KnownAddress(ArmReg Reg, uint32_t VAddr) else { uint32_t PAddr; - if (!g_TransVaddr->TranslateVaddr(VAddr, PAddr)) + if (!m_MMU.VAddrToPAddr(VAddr, PAddr)) { g_Notify->BreakPoint(__FILE__, __LINE__); } @@ -7078,13 +7087,14 @@ void CArmRecompilerOps::LW_KnownAddress(ArmReg Reg, uint32_t VAddr) } break; case 0x04100000: - m_RegWorkingSet.BeforeCallDirect(); + ArmBreakPoint(__FILE__, __LINE__); + /*m_RegWorkingSet.BeforeCallDirect(); MoveConstToArmReg(Arm_R1, PAddr); MoveConstToArmReg(Arm_R2, (uint32_t)&CMipsMemoryVM::m_MemLookupAddress, "m_MemLookupAddress"); StoreArmRegToArmRegPointer(Arm_R1, Arm_R2, 0); CallFunction((void *)CMipsMemoryVM::Load32DPCommand, "CMipsMemoryVM::Load32DPCommand"); m_RegWorkingSet.AfterCallDirect(); - MoveVariableToArmReg(&CMipsMemoryVM::m_MemLookupValue.UW[0], "CMipsMemoryVM::m_MemLookupValue.UW[0]", Reg); + MoveVariableToArmReg(&CMipsMemoryVM::m_MemLookupValue.UW[0], "CMipsMemoryVM::m_MemLookupValue.UW[0]", Reg);*/ break; case 0x04300000: switch (PAddr) @@ -7104,14 +7114,15 @@ void CArmRecompilerOps::LW_KnownAddress(ArmReg Reg, uint32_t VAddr) switch (PAddr) { case 0x04400010: - m_RegWorkingSet.SetBlockCycleCount(m_RegWorkingSet.GetBlockCycleCount() - g_System->CountPerOp()); + ArmBreakPoint(__FILE__, __LINE__); + /*m_RegWorkingSet.SetBlockCycleCount(m_RegWorkingSet.GetBlockCycleCount() - g_System->CountPerOp()); UpdateCounters(m_RegWorkingSet, false, true); m_RegWorkingSet.SetBlockCycleCount(m_RegWorkingSet.GetBlockCycleCount() + g_System->CountPerOp()); m_RegWorkingSet.BeforeCallDirect(); MoveConstToArmReg(Arm_R0, (uint32_t)g_MMU); CallFunction(AddressOf(&CMipsMemoryVM::UpdateHalfLine), "CMipsMemoryVM::UpdateHalfLine"); m_RegWorkingSet.AfterCallDirect(); - MoveVariableToArmReg((void *)&g_MMU->m_HalfLine, "MMU->m_HalfLine", Reg); + MoveVariableToArmReg((void *)&g_MMU->m_HalfLine, "MMU->m_HalfLine", Reg);*/ break; default: MoveConstToArmReg(Reg, (uint32_t)0); @@ -7126,7 +7137,8 @@ void CArmRecompilerOps::LW_KnownAddress(ArmReg Reg, uint32_t VAddr) case 0x04500004: if (g_System->bFixedAudio()) { - m_RegWorkingSet.SetBlockCycleCount(m_RegWorkingSet.GetBlockCycleCount() - g_System->CountPerOp()); + ArmBreakPoint(__FILE__, __LINE__); + /*m_RegWorkingSet.SetBlockCycleCount(m_RegWorkingSet.GetBlockCycleCount() - g_System->CountPerOp()); UpdateCounters(m_RegWorkingSet, false, true); m_RegWorkingSet.SetBlockCycleCount(m_RegWorkingSet.GetBlockCycleCount() + g_System->CountPerOp()); m_RegWorkingSet.BeforeCallDirect(); @@ -7135,7 +7147,7 @@ void CArmRecompilerOps::LW_KnownAddress(ArmReg Reg, uint32_t VAddr) MoveConstToArmReg(Arm_R1, (uint32_t)&m_TempValue, "m_TempValue"); StoreArmRegToArmRegPointer(Arm_R0, Arm_R1, 0); m_RegWorkingSet.AfterCallDirect(); - MoveVariableToArmReg(&m_TempValue, "m_TempValue", Reg); + MoveVariableToArmReg(&m_TempValue, "m_TempValue", Reg);*/ } else { @@ -7157,13 +7169,14 @@ void CArmRecompilerOps::LW_KnownAddress(ArmReg Reg, uint32_t VAddr) case 0x0450000C: if (g_System->bFixedAudio()) { - m_RegWorkingSet.BeforeCallDirect(); + ArmBreakPoint(__FILE__, __LINE__); + /*m_RegWorkingSet.BeforeCallDirect(); MoveConstToArmReg(Arm_R0, (uint32_t)g_Audio, "g_Audio"); CallFunction(AddressOf(&CAudio::GetStatus), "CAudio::GetStatus"); MoveConstToArmReg(Arm_R1, (uint32_t)&m_TempValue, "m_TempValue"); StoreArmRegToArmRegPointer(Arm_R0, Arm_R1, 0); m_RegWorkingSet.AfterCallDirect(); - MoveVariableToArmReg(&m_TempValue, "m_TempValue", Reg); + MoveVariableToArmReg(&m_TempValue, "m_TempValue", Reg);*/ } else { @@ -7279,13 +7292,14 @@ void CArmRecompilerOps::LW_KnownAddress(ArmReg Reg, uint32_t VAddr) } break; case 0x06000000: - m_RegWorkingSet.BeforeCallDirect(); + ArmBreakPoint(__FILE__, __LINE__); + /*m_RegWorkingSet.BeforeCallDirect(); MoveConstToArmReg(Arm_R1, PAddr); MoveConstToArmReg(Arm_R2, (uint32_t)&CMipsMemoryVM::m_MemLookupAddress, "m_MemLookupAddress"); StoreArmRegToArmRegPointer(Arm_R1, Arm_R2, 0); CallFunction((void *)CMipsMemoryVM::Load32CartridgeDomain1Address1, "CMipsMemoryVM::Load32CartridgeDomain1Address1"); m_RegWorkingSet.AfterCallDirect(); - MoveVariableToArmReg(&CMipsMemoryVM::m_MemLookupValue.UW[0], "CMipsMemoryVM::m_MemLookupValue.UW[0]", Reg); + MoveVariableToArmReg(&CMipsMemoryVM::m_MemLookupValue.UW[0], "CMipsMemoryVM::m_MemLookupValue.UW[0]", Reg);*/ break; default: if ((PAddr & 0xF0000000) == 0x10000000 && (PAddr - 0x10000000) < g_Rom->GetRomSize()) diff --git a/Source/Project64-core/N64System/Recompiler/Arm/ArmRecompilerOps.h b/Source/Project64-core/N64System/Recompiler/Arm/ArmRecompilerOps.h index ff814a5d2..26cd257e8 100644 --- a/Source/Project64-core/N64System/Recompiler/Arm/ArmRecompilerOps.h +++ b/Source/Project64-core/N64System/Recompiler/Arm/ArmRecompilerOps.h @@ -12,7 +12,8 @@ class CArmRecompilerOps : private CGameSettings { public: - CArmRecompilerOps(); + CArmRecompilerOps(CMipsMemoryVM & MMU); + ~CArmRecompilerOps(); // Trap functions void Compile_TrapCompare(TRAP_COMPARE CompareType); @@ -207,8 +208,8 @@ private: void SetCurrentPC(uint32_t ProgramCounter); uint32_t GetCurrentPC(void); void SetCurrentSection(CCodeSection * section); - void SetNextStepType(STEP_TYPE StepType); - STEP_TYPE GetNextStepType( void ); + void SetNextStepType(PIPELINE_STAGE StepType); + PIPELINE_STAGE GetNextStepType( void ); const OPCODE & GetOpcode ( void ) const; void PreCompileOpcode(void); void PostCompileOpcode ( void ); @@ -268,7 +269,8 @@ private: void OverflowDelaySlot(bool TestTimer); EXIT_LIST m_ExitInfo; - STEP_TYPE m_PipelineStage; + CMipsMemoryVM & m_MMU; + PIPELINE_STAGE m_PipelineStage; uint32_t m_CompilePC; OPCODE m_Opcode; CCodeSection * m_Section; diff --git a/Source/Project64-core/N64System/Recompiler/CodeBlock.cpp b/Source/Project64-core/N64System/Recompiler/CodeBlock.cpp index e43ff7e05..8b69a5ca6 100644 --- a/Source/Project64-core/N64System/Recompiler/CodeBlock.cpp +++ b/Source/Project64-core/N64System/Recompiler/CodeBlock.cpp @@ -35,7 +35,7 @@ CCodeBlock::CCodeBlock(CMipsMemoryVM & MMU, uint32_t VAddrEnter, uint8_t * Compi #if defined(__i386__) || defined(_M_IX86) m_RecompilerOps = new CX86RecompilerOps(MMU); #elif defined(__arm__) || defined(_M_ARM) - m_RecompilerOps = new CArmRecompilerOps; + m_RecompilerOps = new CArmRecompilerOps(MMU); #endif if (m_RecompilerOps == nullptr) { diff --git a/Source/Project64-core/N64System/Recompiler/x86/x86RecompilerOps.cpp b/Source/Project64-core/N64System/Recompiler/x86/x86RecompilerOps.cpp index 6b08abb52..99491b5af 100644 --- a/Source/Project64-core/N64System/Recompiler/x86/x86RecompilerOps.cpp +++ b/Source/Project64-core/N64System/Recompiler/x86/x86RecompilerOps.cpp @@ -10463,7 +10463,7 @@ void CX86RecompilerOps::SW_Const(uint32_t Value, uint32_t VAddr) Call_Direct((void *)((long**)(MemoryHandler *)&g_MMU->m_VideoInterfaceHandler)[0][1], "VideoInterfaceHandler::Write32"); #else PushImm32((uint32_t)&g_MMU->m_VideoInterfaceHandler); - Call_Direct(AddressOf(&m_VideoInterfaceHandler::Write32), "m_VideoInterfaceHandler::Write32"); + Call_Direct((void *)((long**)(MemoryHandler *)&g_MMU->m_VideoInterfaceHandler)[0][1], "VideoInterfaceHandler::Write32"); AddConstToX86Reg(x86_ESP, 16); #endif m_RegWorkingSet.AfterCallDirect(); diff --git a/Source/Project64-core/N64System/SaveType/stdafx.h b/Source/Project64-core/N64System/SaveType/stdafx.h new file mode 100644 index 000000000..8b696d0b1 --- /dev/null +++ b/Source/Project64-core/N64System/SaveType/stdafx.h @@ -0,0 +1 @@ +#include "../stdafx.h"