diff --git a/shell/android-studio/reicast/src/main/java/com/reicast/emulator/AboutFragment.java b/shell/android-studio/reicast/src/main/java/com/reicast/emulator/AboutFragment.java index a3fee9fd7..9e88b6db2 100644 --- a/shell/android-studio/reicast/src/main/java/com/reicast/emulator/AboutFragment.java +++ b/shell/android-studio/reicast/src/main/java/com/reicast/emulator/AboutFragment.java @@ -51,7 +51,7 @@ public class AboutFragment extends Fragment { @Override public View onCreateView(LayoutInflater inflater, ViewGroup container, - Bundle savedInstanceState) { + Bundle savedInstanceState) { // Inflate the layout for this fragment return inflater.inflate(R.layout.about_fragment, container, false); } @@ -207,14 +207,14 @@ public class AboutFragment extends Fragment { list.setOnItemClickListener(new OnItemClickListener() { public void onItemClick(AdapterView parent, View view, - int position, long id) { + int position, long id) { slidingGithub.open(); } }); } } - + private JSONArray getContent(String urlString) throws IOException, JSONException { HttpURLConnection conn = (HttpURLConnection) new URL(urlString).openConnection(); conn.setRequestMethod("GET"); diff --git a/shell/android-studio/reicast/src/main/java/com/reicast/emulator/CloudFragment.java b/shell/android-studio/reicast/src/main/java/com/reicast/emulator/CloudFragment.java index 20de3af0f..6918c7f24 100644 --- a/shell/android-studio/reicast/src/main/java/com/reicast/emulator/CloudFragment.java +++ b/shell/android-studio/reicast/src/main/java/com/reicast/emulator/CloudFragment.java @@ -4,7 +4,7 @@ package com.reicast.emulator; * File: CloudFragment.java * Author: Luca D'Amico (Luca91) * Last Edit: 11 May 2014 - * + * * Reference: http://forums.reicast.com/index.php?topic=160.msg422 */ @@ -45,20 +45,20 @@ import java.util.concurrent.ExecutionException; public class CloudFragment extends Fragment { - + Button uploadBtn; Button downloadBtn; - AlertDialog.Builder confirmDialog = null; + AlertDialog.Builder confirmDialog = null; boolean actionRequired=false; public String task = ""; DropBoxClient client = null; private String home_directory; - + String[] vmus = {"vmu_save_A1.bin","vmu_save_A2.bin", - "vmu_save_B1.bin","vmu_save_B2.bin", - "vmu_save_C1.bin","vmu_save_C2.bin", - "vmu_save_D1.bin","vmu_save_D2.bin"}; - + "vmu_save_B1.bin","vmu_save_B2.bin", + "vmu_save_C1.bin","vmu_save_C2.bin", + "vmu_save_D1.bin","vmu_save_D2.bin"}; + @Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { return inflater.inflate(R.layout.cloud_fragment, container, false); @@ -69,58 +69,58 @@ public class CloudFragment extends Fragment { SharedPreferences mPrefs = PreferenceManager.getDefaultSharedPreferences(getActivity()); home_directory = mPrefs.getString(Config.pref_home, Environment.getExternalStorageDirectory().getAbsolutePath()); - buttonListener(); - confirmDialog = new AlertDialog.Builder(getActivity()); - setClient(); + buttonListener(); + confirmDialog = new AlertDialog.Builder(getActivity()); + setClient(); } - + public void setClient(){ if(client==null) - client = new DropBoxClient(getActivity()); + client = new DropBoxClient(getActivity()); } - - + + public void buttonListener() { uploadBtn = (Button) getView().findViewById(R.id.uploadBtn); uploadBtn.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View arg0) { confirmDialog.setMessage(R.string.uploadWarning); - confirmDialog.setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() { - public void onClick(DialogInterface dialog, int which) { - setClient(); - task = "Upload"; - client.startLogin(); - actionRequired = true; - } - }); - confirmDialog.setNegativeButton(R.string.cancel, null); - confirmDialog.show(); + confirmDialog.setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() { + public void onClick(DialogInterface dialog, int which) { + setClient(); + task = "Upload"; + client.startLogin(); + actionRequired = true; + } + }); + confirmDialog.setNegativeButton(R.string.cancel, null); + confirmDialog.show(); + + } + }); + - } - }); - - downloadBtn = (Button) getView().findViewById(R.id.downloadBtn); downloadBtn.setOnClickListener(new View.OnClickListener() { - @Override - public void onClick(View arg0) { - confirmDialog.setMessage(R.string.downloadWarning); - confirmDialog.setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() { - public void onClick(DialogInterface dialog, int which) { - setClient(); - task = "Download"; - client.startLogin(); - actionRequired = true; - } - }); - confirmDialog.setNegativeButton(R.string.cancel, null); - confirmDialog.show(); - } - }); - } - - + @Override + public void onClick(View arg0) { + confirmDialog.setMessage(R.string.downloadWarning); + confirmDialog.setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() { + public void onClick(DialogInterface dialog, int which) { + setClient(); + task = "Download"; + client.startLogin(); + actionRequired = true; + } + }); + confirmDialog.setNegativeButton(R.string.cancel, null); + confirmDialog.show(); + } + }); + } + + @Override public void onResume(){ super.onResume(); @@ -143,7 +143,7 @@ public class CloudFragment extends Fragment { try { String vmuPath = home_directory+"/"+vmus[k]; File vmu = new File(vmuPath); - if(vmu.exists() || task.equals("Download") ){ + if(vmu.exists() || task.equals("Download") ){ result = new netOperation(client, home_directory).execute( task,vmuPath,vmus[k]).get(); } @@ -166,175 +166,175 @@ public class CloudFragment extends Fragment { actionRequired = false; } } - - + + } class DropBoxClient { - + Context context; - - final static private String APP_KEY = "7d7tw1t57sbzrj5"; - final static private String APP_SECRET = "5xxqa2uctousyi2"; - - public DropboxAPI mDBApi; - AndroidAuthSession session; - - public DropBoxClient(Context context){ - this.context = context; - session = buildSession(); - mDBApi = new DropboxAPI(session); - } - - public void startLogin(){ - mDBApi.getSession().startOAuth2Authentication(context); - } - + + final static private String APP_KEY = "7d7tw1t57sbzrj5"; + final static private String APP_SECRET = "5xxqa2uctousyi2"; + + public DropboxAPI mDBApi; + AndroidAuthSession session; + + public DropBoxClient(Context context){ + this.context = context; + session = buildSession(); + mDBApi = new DropboxAPI(session); + } + + public void startLogin(){ + mDBApi.getSession().startOAuth2Authentication(context); + } + public String[] getKeys() { - SharedPreferences prefs = context.getSharedPreferences("ReicastVMUUploader", 0); - String key = prefs.getString("DBoxKey", null); - String secret = prefs.getString("DBoxSecret", null); - if (key != null && secret != null) { - String[] ret = new String[2]; - ret[0] = key; - ret[1] = secret; - return ret; - } else { - return null; - } - } - + SharedPreferences prefs = context.getSharedPreferences("ReicastVMUUploader", 0); + String key = prefs.getString("DBoxKey", null); + String secret = prefs.getString("DBoxSecret", null); + if (key != null && secret != null) { + String[] ret = new String[2]; + ret[0] = key; + ret[1] = secret; + return ret; + } else { + return null; + } + } - - public void storeKeys(String key, String secret) { - SharedPreferences prefs = context.getSharedPreferences("ReicastVMUUploader", 0); - Editor edit = prefs.edit(); - edit.putString("DBoxKey", key); - edit.putString("DBoxSecret", secret); - edit.commit(); - } - - - - private AndroidAuthSession buildSession() { - AppKeyPair appKeyPair = new AppKeyPair(APP_KEY, APP_SECRET); - AndroidAuthSession session; + public void storeKeys(String key, String secret) { + SharedPreferences prefs = context.getSharedPreferences("ReicastVMUUploader", 0); + Editor edit = prefs.edit(); + edit.putString("DBoxKey", key); + edit.putString("DBoxSecret", secret); + edit.commit(); + } - String[] stored = getKeys(); - if (stored != null) { - AccessTokenPair accessToken = new AccessTokenPair(stored[0], stored[1]); - session = new AndroidAuthSession(appKeyPair, accessToken); - } else { - session = new AndroidAuthSession(appKeyPair); - } - return session; - } + + + + private AndroidAuthSession buildSession() { + AppKeyPair appKeyPair = new AppKeyPair(APP_KEY, APP_SECRET); + AndroidAuthSession session; + + String[] stored = getKeys(); + if (stored != null) { + AccessTokenPair accessToken = new AccessTokenPair(stored[0], stored[1]); + session = new AndroidAuthSession(appKeyPair, accessToken); + } else { + session = new AndroidAuthSession(appKeyPair); + } + + return session; + } } class netOperation extends AsyncTask { - + DropBoxClient client = null; private String home_directory; - + public netOperation(DropBoxClient client, String home_directory){ this.client = client; this.home_directory = home_directory; } public boolean uploadFile(String filePath, String fileName) { - File file = new File(filePath); - FileInputStream inputStream = null; - try { - inputStream = new FileInputStream(file); - } catch (FileNotFoundException e) { - e.printStackTrace(); - } + File file = new File(filePath); + FileInputStream inputStream = null; + try { + inputStream = new FileInputStream(file); + } catch (FileNotFoundException e) { + e.printStackTrace(); + } - DropboxAPI.Entry response = null; - try { - response = client.mDBApi.putFileOverwrite("/"+fileName, inputStream, file.length(), null); - } catch (DropboxException e) { - e.printStackTrace(); - } - Log.i("FileInfos", "The uploaded file's rev is: "+ response); - return true; - } + DropboxAPI.Entry response = null; + try { + response = client.mDBApi.putFileOverwrite("/"+fileName, inputStream, file.length(), null); + } catch (DropboxException e) { + e.printStackTrace(); + } + Log.i("FileInfos", "The uploaded file's rev is: "+ response); + return true; + } - public boolean downloadFile(String filePath, String fileName) { - DropboxAPI.DropboxFileInfo info = null; - try { - Entry remoteFile = client.mDBApi.metadata("/"+fileName, 1, null, false, null); - if((remoteFile.rev != null) && (remoteFile.bytes > 0)){ // Avoid to download 0 bytes vmus! - File file = new File(filePath); - if(file.exists()) - createBackupOfVmu(fileName); - FileOutputStream out = null; - try { - out = new FileOutputStream(file); - } catch (FileNotFoundException e) { - e.printStackTrace(); - } - info = client.mDBApi.getFile("/"+fileName,null,out,null); - } - } catch (DropboxException e) { - e.printStackTrace(); - } - Log.i("FileInfos", "The downloaded file's rev is: "+ info); - return true; - } + public boolean downloadFile(String filePath, String fileName) { + DropboxAPI.DropboxFileInfo info = null; + try { + Entry remoteFile = client.mDBApi.metadata("/"+fileName, 1, null, false, null); + if((remoteFile.rev != null) && (remoteFile.bytes > 0)){ // Avoid to download 0 bytes vmus! + File file = new File(filePath); + if(file.exists()) + createBackupOfVmu(fileName); + FileOutputStream out = null; + try { + out = new FileOutputStream(file); + } catch (FileNotFoundException e) { + e.printStackTrace(); + } + info = client.mDBApi.getFile("/"+fileName,null,out,null); + } + } catch (DropboxException e) { + e.printStackTrace(); + } + Log.i("FileInfos", "The downloaded file's rev is: "+ info); + return true; + } - @Override - protected void onPostExecute(String result) { + @Override + protected void onPostExecute(String result) { - } + } - @Override - protected String doInBackground(String... strings) { - if(strings[0].equals("Upload")){ - if(uploadFile(strings[1],strings[2])) - return "Ok"; - else - return "No"; - } - else if(strings[0].equals("Download")){ - if(downloadFile(strings[1],strings[2])) - return "Ok"; - else - return "No"; - } - else - return "Unknown"; - } + @Override + protected String doInBackground(String... strings) { + if(strings[0].equals("Upload")){ + if(uploadFile(strings[1],strings[2])) + return "Ok"; + else + return "No"; + } + else if(strings[0].equals("Download")){ + if(downloadFile(strings[1],strings[2])) + return "Ok"; + else + return "No"; + } + else + return "Unknown"; + } - @Override - protected void onPreExecute() {} + @Override + protected void onPreExecute() {} - @Override - protected void onProgressUpdate(Void... values) {} - - - void createBackupOfVmu(String vmuName){ - File backupDir = new File(home_directory+"/VmuBackups/"); - if(!backupDir.exists()) { - backupDir.mkdirs(); - } - - File source = new File(home_directory+"/"+vmuName); - File destination = new File(home_directory+"/VmuBackups/"+vmuName); - if(!destination.exists()) { - try { + @Override + protected void onProgressUpdate(Void... values) {} + + + void createBackupOfVmu(String vmuName){ + File backupDir = new File(home_directory+"/VmuBackups/"); + if(!backupDir.exists()) { + backupDir.mkdirs(); + } + + File source = new File(home_directory+"/"+vmuName); + File destination = new File(home_directory+"/VmuBackups/"+vmuName); + if(!destination.exists()) { + try { destination.createNewFile(); } catch (IOException e) { e.printStackTrace(); } - } - try { + } + try { InputStream in = new FileInputStream(source); OutputStream out = new FileOutputStream(destination); byte[] buffer = new byte[1024]; @@ -349,6 +349,6 @@ class netOperation extends AsyncTask { } catch (IOException e) { e.printStackTrace(); } - } - + } + } diff --git a/shell/android-studio/reicast/src/main/java/com/reicast/emulator/GL2JNIActivity.java b/shell/android-studio/reicast/src/main/java/com/reicast/emulator/GL2JNIActivity.java index d7ddc7fc2..71fd12eba 100644 --- a/shell/android-studio/reicast/src/main/java/com/reicast/emulator/GL2JNIActivity.java +++ b/shell/android-studio/reicast/src/main/java/com/reicast/emulator/GL2JNIActivity.java @@ -39,562 +39,562 @@ import java.util.HashMap; import tv.ouya.console.api.OuyaController; public class GL2JNIActivity extends Activity { - private Intent serviceIntent; - public GL2JNIView mView; - OnScreenMenu menu; - public MainPopup popUp; - VmuPopup vmuPop; - FpsPopup fpsPop; - MOGAInput moga = new MOGAInput(); - private SharedPreferences prefs; + private Intent serviceIntent; + public GL2JNIView mView; + OnScreenMenu menu; + public MainPopup popUp; + VmuPopup vmuPop; + FpsPopup fpsPop; + MOGAInput moga = new MOGAInput(); + private SharedPreferences prefs; - private Gamepad pad = new Gamepad(); + private Gamepad pad = new Gamepad(); - public static byte[] syms; + public static byte[] syms; - @Override - protected void onCreate(Bundle icicle) { - requestWindowFeature(Window.FEATURE_NO_TITLE); - prefs = PreferenceManager.getDefaultSharedPreferences(this); - if (prefs.getInt(Config.pref_rendertype, 2) == 2) { - getWindow().setFlags( - WindowManager.LayoutParams.FLAG_HARDWARE_ACCELERATED, - WindowManager.LayoutParams.FLAG_HARDWARE_ACCELERATED); - } - //serviceIntent = new Intent(this, EmuService.class); - //serviceIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_FROM_BACKGROUND); - //serviceIntent.addFlags(Intent.FLAG_INCLUDE_STOPPED_PACKAGES | Intent.FLAG_ACTIVITY_NO_ANIMATION); - //startService(serviceIntent); + @Override + protected void onCreate(Bundle icicle) { + requestWindowFeature(Window.FEATURE_NO_TITLE); + prefs = PreferenceManager.getDefaultSharedPreferences(this); + if (prefs.getInt(Config.pref_rendertype, 2) == 2) { + getWindow().setFlags( + WindowManager.LayoutParams.FLAG_HARDWARE_ACCELERATED, + WindowManager.LayoutParams.FLAG_HARDWARE_ACCELERATED); + } + //serviceIntent = new Intent(this, EmuService.class); + //serviceIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_FROM_BACKGROUND); + //serviceIntent.addFlags(Intent.FLAG_INCLUDE_STOPPED_PACKAGES | Intent.FLAG_ACTIVITY_NO_ANIMATION); + //startService(serviceIntent); - Emulator app = (Emulator)getApplicationContext(); - app.getConfigurationPrefs(prefs); - menu = new OnScreenMenu(GL2JNIActivity.this, prefs); + Emulator app = (Emulator)getApplicationContext(); + app.getConfigurationPrefs(prefs); + menu = new OnScreenMenu(GL2JNIActivity.this, prefs); - pad.isOuyaOrTV = pad.IsOuyaOrTV(GL2JNIActivity.this); + pad.isOuyaOrTV = pad.IsOuyaOrTV(GL2JNIActivity.this); // pad.isNvidiaShield = pad.IsNvidiaShield(); - /* - * try { //int rID = - * getResources().getIdentifier("fortyonepost.com.lfas:raw/syms.map", - * null, null); //get the file as a stream InputStream is = - * getResources().openRawResource(R.raw.syms); - * - * syms = new byte[(int) is.available()]; is.read(syms); is.close(); } - * catch (IOException e) { e.getMessage(); e.printStackTrace(); } - */ - - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) { - pad.compat[0] = true; - pad.compat[1] = true; - pad.compat[2] = true; - pad.compat[3] = true; - } + /* + * try { //int rID = + * getResources().getIdentifier("fortyonepost.com.lfas:raw/syms.map", + * null, null); //get the file as a stream InputStream is = + * getResources().openRawResource(R.raw.syms); + * + * syms = new byte[(int) is.available()]; is.read(syms); is.close(); } + * catch (IOException e) { e.getMessage(); e.printStackTrace(); } + */ - String fileName = null; + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) { + pad.compat[0] = true; + pad.compat[1] = true; + pad.compat[2] = true; + pad.compat[3] = true; + } - // Call parent onCreate() - super.onCreate(icicle); - OuyaController.init(this); + String fileName = null; - // Populate device descriptor-to-player-map from preferences - pad.deviceDescriptor_PlayerNum.put( - prefs.getString(Gamepad.pref_player1, null), 0); - pad.deviceDescriptor_PlayerNum.put( - prefs.getString(Gamepad.pref_player2, null), 1); - pad.deviceDescriptor_PlayerNum.put( - prefs.getString(Gamepad.pref_player3, null), 2); - pad.deviceDescriptor_PlayerNum.put( - prefs.getString(Gamepad.pref_player4, null), 3); - pad.deviceDescriptor_PlayerNum.remove(null); + // Call parent onCreate() + super.onCreate(icicle); + OuyaController.init(this); - moga.onCreate(this, pad); - moga.mListener.setPlayerNum(1); + // Populate device descriptor-to-player-map from preferences + pad.deviceDescriptor_PlayerNum.put( + prefs.getString(Gamepad.pref_player1, null), 0); + pad.deviceDescriptor_PlayerNum.put( + prefs.getString(Gamepad.pref_player2, null), 1); + pad.deviceDescriptor_PlayerNum.put( + prefs.getString(Gamepad.pref_player3, null), 2); + pad.deviceDescriptor_PlayerNum.put( + prefs.getString(Gamepad.pref_player4, null), 3); + pad.deviceDescriptor_PlayerNum.remove(null); - boolean controllerTwoConnected = false; - boolean controllerThreeConnected = false; - boolean controllerFourConnected = false; + moga.onCreate(this, pad); + moga.mListener.setPlayerNum(1); - for (HashMap.Entry e : pad.deviceDescriptor_PlayerNum.entrySet()) { - String descriptor = e.getKey(); - Integer playerNum = e.getValue(); + boolean controllerTwoConnected = false; + boolean controllerThreeConnected = false; + boolean controllerFourConnected = false; - switch (playerNum) { - case 1: - if (descriptor != null) - controllerTwoConnected = true; - break; - case 2: - if (descriptor != null) - controllerThreeConnected = true; - break; - case 3: - if (descriptor != null) - controllerFourConnected = true; - break; - } - } + for (HashMap.Entry e : pad.deviceDescriptor_PlayerNum.entrySet()) { + String descriptor = e.getKey(); + Integer playerNum = e.getValue(); - JNIdc.initControllers(new boolean[] { controllerTwoConnected, - controllerThreeConnected, controllerFourConnected }); - int joys[] = InputDevice.getDeviceIds(); - for (int joy: joys) { - String descriptor = null; - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) { - descriptor = InputDevice.getDevice(joy).getDescriptor(); - } else { - descriptor = InputDevice.getDevice(joy).getName(); - } - Log.d("reicast", "InputDevice ID: " + joy); - Log.d("reicast", - "InputDevice Name: " - + InputDevice.getDevice(joy).getName()); - Log.d("reicast", "InputDevice Descriptor: " + descriptor); - pad.deviceId_deviceDescriptor.put(joy, descriptor); - } + switch (playerNum) { + case 1: + if (descriptor != null) + controllerTwoConnected = true; + break; + case 2: + if (descriptor != null) + controllerThreeConnected = true; + break; + case 3: + if (descriptor != null) + controllerFourConnected = true; + break; + } + } - for (int joy :joys) { - Integer playerNum = pad.deviceDescriptor_PlayerNum - .get(pad.deviceId_deviceDescriptor.get(joy)); + JNIdc.initControllers(new boolean[] { controllerTwoConnected, + controllerThreeConnected, controllerFourConnected }); + int joys[] = InputDevice.getDeviceIds(); + for (int joy: joys) { + String descriptor = null; + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) { + descriptor = InputDevice.getDevice(joy).getDescriptor(); + } else { + descriptor = InputDevice.getDevice(joy).getName(); + } + Log.d("reicast", "InputDevice ID: " + joy); + Log.d("reicast", + "InputDevice Name: " + + InputDevice.getDevice(joy).getName()); + Log.d("reicast", "InputDevice Descriptor: " + descriptor); + pad.deviceId_deviceDescriptor.put(joy, descriptor); + } - if (playerNum != null) { - String id = pad.portId[playerNum]; - pad.custom[playerNum] = prefs.getBoolean(Gamepad.pref_js_modified + id, false); - pad.compat[playerNum] = prefs.getBoolean(Gamepad.pref_js_compat + id, false); - pad.joystick[playerNum] = prefs.getBoolean(Gamepad.pref_js_merged + id, false); - if (InputDevice.getDevice(joy).getName() - .contains(Gamepad.controllers_gamekey)) { - if (pad.custom[playerNum]) { - pad.setCustomMapping(id, playerNum, prefs); - } else { - pad.map[playerNum] = pad.getConsoleController(); - } - } else if (!pad.compat[playerNum]) { - if (pad.custom[playerNum]) { - pad.setCustomMapping(id, playerNum, prefs); - } else if (InputDevice.getDevice(joy).getName() - .equals(Gamepad.controllers_sony)) { - pad.map[playerNum] = pad.getConsoleController(); - } else if (InputDevice.getDevice(joy).getName() - .equals(Gamepad.controllers_xbox)) { - pad.map[playerNum] = pad.getConsoleController(); - } else if (InputDevice.getDevice(joy).getName() - .contains(Gamepad.controllers_shield)) { - pad.map[playerNum] = pad.getConsoleController(); - } else if (!pad.isActiveMoga[playerNum]) { // Ouya controller - pad.map[playerNum] = pad.getOUYAController(); - } - } else { - pad.getCompatibilityMap(playerNum, id, prefs); - } - pad.initJoyStickLayout(playerNum); - } else { - pad.runCompatibilityMode(joy, prefs); - } - } - if (joys.length == 0) { - pad.fullCompatibilityMode(prefs); - } + for (int joy :joys) { + Integer playerNum = pad.deviceDescriptor_PlayerNum + .get(pad.deviceId_deviceDescriptor.get(joy)); - app.loadConfigurationPrefs(); + if (playerNum != null) { + String id = pad.portId[playerNum]; + pad.custom[playerNum] = prefs.getBoolean(Gamepad.pref_js_modified + id, false); + pad.compat[playerNum] = prefs.getBoolean(Gamepad.pref_js_compat + id, false); + pad.joystick[playerNum] = prefs.getBoolean(Gamepad.pref_js_merged + id, false); + if (InputDevice.getDevice(joy).getName() + .contains(Gamepad.controllers_gamekey)) { + if (pad.custom[playerNum]) { + pad.setCustomMapping(id, playerNum, prefs); + } else { + pad.map[playerNum] = pad.getConsoleController(); + } + } else if (!pad.compat[playerNum]) { + if (pad.custom[playerNum]) { + pad.setCustomMapping(id, playerNum, prefs); + } else if (InputDevice.getDevice(joy).getName() + .equals(Gamepad.controllers_sony)) { + pad.map[playerNum] = pad.getConsoleController(); + } else if (InputDevice.getDevice(joy).getName() + .equals(Gamepad.controllers_xbox)) { + pad.map[playerNum] = pad.getConsoleController(); + } else if (InputDevice.getDevice(joy).getName() + .contains(Gamepad.controllers_shield)) { + pad.map[playerNum] = pad.getConsoleController(); + } else if (!pad.isActiveMoga[playerNum]) { // Ouya controller + pad.map[playerNum] = pad.getOUYAController(); + } + } else { + pad.getCompatibilityMap(playerNum, id, prefs); + } + pad.initJoyStickLayout(playerNum); + } else { + pad.runCompatibilityMode(joy, prefs); + } + } + if (joys.length == 0) { + pad.fullCompatibilityMode(prefs); + } - // When viewing a resource, pass its URI to the native code for opening - if (getIntent().getAction().equals("com.reicast.EMULATOR")) - fileName = Uri.decode(getIntent().getData().toString()); + app.loadConfigurationPrefs(); - // Create the actual GLES view - mView = new GL2JNIView(GL2JNIActivity.this, fileName, false, - prefs.getInt(Config.pref_renderdepth, 24), 0, false); - setContentView(mView); + // When viewing a resource, pass its URI to the native code for opening + if (getIntent().getAction().equals("com.reicast.EMULATOR")) + fileName = Uri.decode(getIntent().getData().toString()); - //setup mic - boolean micPluggedIn = prefs.getBoolean(Config.pref_mic, false); - if(micPluggedIn){ - SipEmulator sip = new SipEmulator(); - sip.startRecording(); - JNIdc.setupMic(sip); - } - - popUp = menu.new MainPopup(this); - vmuPop = menu.new VmuPopup(this); - if(prefs.getBoolean(Config.pref_vmu, false)){ - //kind of a hack - if the user last had the vmu on screen - //inverse it and then "toggle" - prefs.edit().putBoolean(Config.pref_vmu, false).apply(); - //can only display a popup after onCreate - mView.post(new Runnable() { - public void run() { - toggleVmu(); - } - }); - } - JNIdc.setupVmu(menu.getVmu()); - if (prefs.getBoolean(Config.pref_showfps, false)) { - fpsPop = menu.new FpsPopup(this); - mView.setFpsDisplay(fpsPop); - mView.post(new Runnable() { - public void run() { - displayFPS(); - } - }); - } - } + // Create the actual GLES view + mView = new GL2JNIView(GL2JNIActivity.this, fileName, false, + prefs.getInt(Config.pref_renderdepth, 24), 0, false); + setContentView(mView); - @Override - public boolean onGenericMotionEvent(MotionEvent event) { - Integer playerNum = Arrays.asList(pad.name).indexOf(event.getDeviceId()); - if (playerNum == -1) { - playerNum = pad.deviceDescriptor_PlayerNum - .get(pad.deviceId_deviceDescriptor.get(event.getDeviceId())); - } else { - playerNum = -1; - } + //setup mic + boolean micPluggedIn = prefs.getBoolean(Config.pref_mic, false); + if(micPluggedIn){ + SipEmulator sip = new SipEmulator(); + sip.startRecording(); + JNIdc.setupMic(sip); + } - if (playerNum == null || playerNum == -1) - return false; + popUp = menu.new MainPopup(this); + vmuPop = menu.new VmuPopup(this); + if(prefs.getBoolean(Config.pref_vmu, false)){ + //kind of a hack - if the user last had the vmu on screen + //inverse it and then "toggle" + prefs.edit().putBoolean(Config.pref_vmu, false).apply(); + //can only display a popup after onCreate + mView.post(new Runnable() { + public void run() { + toggleVmu(); + } + }); + } + JNIdc.setupVmu(menu.getVmu()); + if (prefs.getBoolean(Config.pref_showfps, false)) { + fpsPop = menu.new FpsPopup(this); + mView.setFpsDisplay(fpsPop); + mView.post(new Runnable() { + public void run() { + displayFPS(); + } + }); + } + } - if (!pad.compat[playerNum]) { + @Override + public boolean onGenericMotionEvent(MotionEvent event) { + Integer playerNum = Arrays.asList(pad.name).indexOf(event.getDeviceId()); + if (playerNum == -1) { + playerNum = pad.deviceDescriptor_PlayerNum + .get(pad.deviceId_deviceDescriptor.get(event.getDeviceId())); + } else { + playerNum = -1; + } - // Joystick - if ((event.getSource() & InputDevice.SOURCE_CLASS_JOYSTICK) != 0) { + if (playerNum == null || playerNum == -1) + return false; - // do other things with joystick - float LS_X = event.getAxisValue(OuyaController.AXIS_LS_X); - float LS_Y = event.getAxisValue(OuyaController.AXIS_LS_Y); - float RS_X = event.getAxisValue(OuyaController.AXIS_RS_X); - float RS_Y = event.getAxisValue(OuyaController.AXIS_RS_Y); - float L2 = event.getAxisValue(OuyaController.AXIS_L2); - float R2 = event.getAxisValue(OuyaController.AXIS_R2); + if (!pad.compat[playerNum]) { - if (!pad.joystick[playerNum]) { - pad.previousLS_X[playerNum] = pad.globalLS_X[playerNum]; - pad.previousLS_Y[playerNum] = pad.globalLS_Y[playerNum]; - pad.globalLS_X[playerNum] = LS_X; - pad.globalLS_Y[playerNum] = LS_Y; - } + // Joystick + if ((event.getSource() & InputDevice.SOURCE_CLASS_JOYSTICK) != 0) { - GL2JNIView.jx[playerNum] = (int) (LS_X * 126); - GL2JNIView.jy[playerNum] = (int) (LS_Y * 126); + // do other things with joystick + float LS_X = event.getAxisValue(OuyaController.AXIS_LS_X); + float LS_Y = event.getAxisValue(OuyaController.AXIS_LS_Y); + float RS_X = event.getAxisValue(OuyaController.AXIS_RS_X); + float RS_Y = event.getAxisValue(OuyaController.AXIS_RS_Y); + float L2 = event.getAxisValue(OuyaController.AXIS_L2); + float R2 = event.getAxisValue(OuyaController.AXIS_R2); - GL2JNIView.lt[playerNum] = (int) (L2 * 255); - GL2JNIView.rt[playerNum] = (int) (R2 * 255); + if (!pad.joystick[playerNum]) { + pad.previousLS_X[playerNum] = pad.globalLS_X[playerNum]; + pad.previousLS_Y[playerNum] = pad.globalLS_Y[playerNum]; + pad.globalLS_X[playerNum] = LS_X; + pad.globalLS_Y[playerNum] = LS_Y; + } - if (prefs.getBoolean(Gamepad.pref_js_rbuttons + pad.portId[playerNum], true)) { - if (RS_Y > 0.25) { - handle_key(playerNum, pad.map[playerNum][0]/* A */, true); - pad.wasKeyStick[playerNum] = true; - } else if (RS_Y < 0.25) { - handle_key(playerNum, pad.map[playerNum][1]/* B */, true); - pad.wasKeyStick[playerNum] = true; - } else if (pad.wasKeyStick[playerNum]){ - handle_key(playerNum, pad.map[playerNum][0], false); - handle_key(playerNum, pad.map[playerNum][1], false); - pad.wasKeyStick[playerNum] = false; - } - } else { - if (RS_Y > 0.25) { - GL2JNIView.rt[playerNum] = (int) (RS_Y * 255); - GL2JNIView.lt[playerNum] = (int) (L2 * 255); - } else if (RS_Y < 0.25) { - GL2JNIView.rt[playerNum] = (int) (R2 * 255); - GL2JNIView.lt[playerNum] = (int) (-(RS_Y) * 255); - } - } - } + GL2JNIView.jx[playerNum] = (int) (LS_X * 126); + GL2JNIView.jy[playerNum] = (int) (LS_Y * 126); - } - mView.pushInput(); - // Only handle Left Stick on an Xbox 360 controller if there was - // some actual motion on the stick, - // so otherwise the event can be handled as a DPAD event - return (pad.joystick[playerNum] || (!(pad.globalLS_X[playerNum] == pad.previousLS_X[playerNum]) - || !(pad.globalLS_Y[playerNum] == pad.previousLS_Y[playerNum]))) - && (!(pad.previousLS_X[playerNum] == 0.0f) || !(pad.previousLS_Y[playerNum] == 0.0f)); - } - - public boolean motionEventHandler(Integer playerNum, com.bda.controller.MotionEvent event) { - if (playerNum == null || playerNum == -1) - return false; + GL2JNIView.lt[playerNum] = (int) (L2 * 255); + GL2JNIView.rt[playerNum] = (int) (R2 * 255); - if (!pad.compat[playerNum]) { + if (prefs.getBoolean(Gamepad.pref_js_rbuttons + pad.portId[playerNum], true)) { + if (RS_Y > 0.25) { + handle_key(playerNum, pad.map[playerNum][0]/* A */, true); + pad.wasKeyStick[playerNum] = true; + } else if (RS_Y < 0.25) { + handle_key(playerNum, pad.map[playerNum][1]/* B */, true); + pad.wasKeyStick[playerNum] = true; + } else if (pad.wasKeyStick[playerNum]){ + handle_key(playerNum, pad.map[playerNum][0], false); + handle_key(playerNum, pad.map[playerNum][1], false); + pad.wasKeyStick[playerNum] = false; + } + } else { + if (RS_Y > 0.25) { + GL2JNIView.rt[playerNum] = (int) (RS_Y * 255); + GL2JNIView.lt[playerNum] = (int) (L2 * 255); + } else if (RS_Y < 0.25) { + GL2JNIView.rt[playerNum] = (int) (R2 * 255); + GL2JNIView.lt[playerNum] = (int) (-(RS_Y) * 255); + } + } + } - // do other things with joystick - float LS_X = event.getAxisValue(OuyaController.AXIS_LS_X); - float LS_Y = event.getAxisValue(OuyaController.AXIS_LS_Y); - float RS_X = event.getAxisValue(OuyaController.AXIS_RS_X); - float RS_Y = event.getAxisValue(OuyaController.AXIS_RS_Y); - float L2 = event.getAxisValue(OuyaController.AXIS_L2); - float R2 = event.getAxisValue(OuyaController.AXIS_R2); + } + mView.pushInput(); + // Only handle Left Stick on an Xbox 360 controller if there was + // some actual motion on the stick, + // so otherwise the event can be handled as a DPAD event + return (pad.joystick[playerNum] || (!(pad.globalLS_X[playerNum] == pad.previousLS_X[playerNum]) + || !(pad.globalLS_Y[playerNum] == pad.previousLS_Y[playerNum]))) + && (!(pad.previousLS_X[playerNum] == 0.0f) || !(pad.previousLS_Y[playerNum] == 0.0f)); + } - if (!pad.joystick[playerNum]) { - pad.previousLS_X[playerNum] = pad.globalLS_X[playerNum]; - pad.previousLS_Y[playerNum] = pad.globalLS_Y[playerNum]; - pad.globalLS_X[playerNum] = LS_X; - pad.globalLS_Y[playerNum] = LS_Y; - } + public boolean motionEventHandler(Integer playerNum, com.bda.controller.MotionEvent event) { + if (playerNum == null || playerNum == -1) + return false; - GL2JNIView.jx[playerNum] = (int) (LS_X * 126); - GL2JNIView.jy[playerNum] = (int) (LS_Y * 126); + if (!pad.compat[playerNum]) { - GL2JNIView.lt[playerNum] = (int) (L2 * 255); - GL2JNIView.rt[playerNum] = (int) (R2 * 255); + // do other things with joystick + float LS_X = event.getAxisValue(OuyaController.AXIS_LS_X); + float LS_Y = event.getAxisValue(OuyaController.AXIS_LS_Y); + float RS_X = event.getAxisValue(OuyaController.AXIS_RS_X); + float RS_Y = event.getAxisValue(OuyaController.AXIS_RS_Y); + float L2 = event.getAxisValue(OuyaController.AXIS_L2); + float R2 = event.getAxisValue(OuyaController.AXIS_R2); - if (prefs.getBoolean(Gamepad.pref_js_rbuttons + pad.portId[playerNum], true)) { - if (RS_Y > 0.25) { - handle_key(playerNum, pad.map[playerNum][0]/* A */, true); - pad.wasKeyStick[playerNum] = true; - } else if (RS_Y < 0.25) { - handle_key(playerNum, pad.map[playerNum][1]/* B */, true); - pad.wasKeyStick[playerNum] = true; - } else if (pad.wasKeyStick[playerNum]){ - handle_key(playerNum, pad.map[playerNum][0], false); - handle_key(playerNum, pad.map[playerNum][1], false); - pad.wasKeyStick[playerNum] = false; - } - } else { - if (RS_Y > 0.25) { - GL2JNIView.rt[playerNum] = (int) (RS_Y * 255); - GL2JNIView.lt[playerNum] = (int) (L2 * 255); - } else if (RS_Y < 0.25) { - GL2JNIView.rt[playerNum] = (int) (R2 * 255); - GL2JNIView.lt[playerNum] = (int) (-(RS_Y) * 255); - } - } + if (!pad.joystick[playerNum]) { + pad.previousLS_X[playerNum] = pad.globalLS_X[playerNum]; + pad.previousLS_Y[playerNum] = pad.globalLS_Y[playerNum]; + pad.globalLS_X[playerNum] = LS_X; + pad.globalLS_Y[playerNum] = LS_Y; + } - } - mView.pushInput(); - // Only handle Left Stick on an Xbox 360 controller if there was - // some actual motion on the stick, - // so otherwise the event can be handled as a DPAD event - return (pad.joystick[playerNum] || (!(pad.globalLS_X[playerNum] == pad.previousLS_X[playerNum]) - || !(pad.globalLS_Y[playerNum] == pad.previousLS_Y[playerNum]))) - && (!(pad.previousLS_X[playerNum] == 0.0f) || !(pad.previousLS_Y[playerNum] == 0.0f)); - } - - public boolean simulatedTouchEvent(int playerNum, float L2, float R2) { - GL2JNIView.lt[playerNum] = (int) (L2 * 255); - GL2JNIView.rt[playerNum] = (int) (R2 * 255); - mView.pushInput(); - return true; - } + GL2JNIView.jx[playerNum] = (int) (LS_X * 126); + GL2JNIView.jy[playerNum] = (int) (LS_Y * 126); - public boolean handle_key(Integer playerNum, int kc, boolean down) { - if (playerNum == null || playerNum == -1) - return false; - if (kc == pad.getSelectButtonCode()) { - return false; - } + GL2JNIView.lt[playerNum] = (int) (L2 * 255); + GL2JNIView.rt[playerNum] = (int) (R2 * 255); - boolean rav = false; - for (int i = 0; i < pad.map[playerNum].length; i += 2) { - if (pad.map[playerNum][i + 0] == kc) { - if (down) - GL2JNIView.kcode_raw[playerNum] &= ~pad.map[playerNum][i + 1]; - else - GL2JNIView.kcode_raw[playerNum] |= pad.map[playerNum][i + 1]; - rav = true; - break; - } - } - mView.pushInput(); - return rav; + if (prefs.getBoolean(Gamepad.pref_js_rbuttons + pad.portId[playerNum], true)) { + if (RS_Y > 0.25) { + handle_key(playerNum, pad.map[playerNum][0]/* A */, true); + pad.wasKeyStick[playerNum] = true; + } else if (RS_Y < 0.25) { + handle_key(playerNum, pad.map[playerNum][1]/* B */, true); + pad.wasKeyStick[playerNum] = true; + } else if (pad.wasKeyStick[playerNum]){ + handle_key(playerNum, pad.map[playerNum][0], false); + handle_key(playerNum, pad.map[playerNum][1], false); + pad.wasKeyStick[playerNum] = false; + } + } else { + if (RS_Y > 0.25) { + GL2JNIView.rt[playerNum] = (int) (RS_Y * 255); + GL2JNIView.lt[playerNum] = (int) (L2 * 255); + } else if (RS_Y < 0.25) { + GL2JNIView.rt[playerNum] = (int) (R2 * 255); + GL2JNIView.lt[playerNum] = (int) (-(RS_Y) * 255); + } + } - } - - public void displayPopUp(PopupWindow popUp) { - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) { - popUp.showAtLocation(mView, Gravity.BOTTOM, 0, 60); - } else { - popUp.showAtLocation(mView, Gravity.BOTTOM, 0, 0); - } - popUp.update(LayoutParams.WRAP_CONTENT, - LayoutParams.WRAP_CONTENT); - } - - public void displayDebug(PopupWindow popUpDebug) { - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) { - popUpDebug.showAtLocation(mView, Gravity.BOTTOM, 0, 60); - } else { - popUpDebug.showAtLocation(mView, Gravity.BOTTOM, 0, 0); - } - popUpDebug.update(LayoutParams.WRAP_CONTENT, - LayoutParams.WRAP_CONTENT); - } + } + mView.pushInput(); + // Only handle Left Stick on an Xbox 360 controller if there was + // some actual motion on the stick, + // so otherwise the event can be handled as a DPAD event + return (pad.joystick[playerNum] || (!(pad.globalLS_X[playerNum] == pad.previousLS_X[playerNum]) + || !(pad.globalLS_Y[playerNum] == pad.previousLS_Y[playerNum]))) + && (!(pad.previousLS_X[playerNum] == 0.0f) || !(pad.previousLS_Y[playerNum] == 0.0f)); + } - public void displayFPS() { - fpsPop.showAtLocation(mView, Gravity.TOP | Gravity.LEFT, 20, 20); - fpsPop.update(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT); - } + public boolean simulatedTouchEvent(int playerNum, float L2, float R2) { + GL2JNIView.lt[playerNum] = (int) (L2 * 255); + GL2JNIView.rt[playerNum] = (int) (R2 * 255); + mView.pushInput(); + return true; + } - public void toggleVmu() { - boolean showFloating = !prefs.getBoolean(Config.pref_vmu, false); - if (showFloating) { - if (popUp.isShowing()) { - popUp.dismiss(); - } - //remove from popup menu - popUp.hideVmu(); - //add to floating window - vmuPop.showVmu(); - vmuPop.showAtLocation(mView, Gravity.TOP | Gravity.RIGHT, 4, 4); - vmuPop.update(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT); - } else { - vmuPop.dismiss(); - //remove from floating window - vmuPop.hideVmu(); - //add back to popup menu - popUp.showVmu(); - } - prefs.edit().putBoolean(Config.pref_vmu, showFloating).apply(); - } - - public void displayConfig(PopupWindow popUpConfig) { - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) { - popUpConfig.showAtLocation(mView, Gravity.BOTTOM, 0, 60); - } else { - popUpConfig.showAtLocation(mView, Gravity.BOTTOM, 0, 0); - } - popUpConfig.update(LayoutParams.WRAP_CONTENT, - LayoutParams.WRAP_CONTENT); - } + public boolean handle_key(Integer playerNum, int kc, boolean down) { + if (playerNum == null || playerNum == -1) + return false; + if (kc == pad.getSelectButtonCode()) { + return false; + } - public boolean onKeyUp(int keyCode, KeyEvent event) { - Integer playerNum = Arrays.asList(pad.name).indexOf(event.getDeviceId()); - if (playerNum == -1) { - playerNum = pad.deviceDescriptor_PlayerNum - .get(pad.deviceId_deviceDescriptor.get(event.getDeviceId())); - } else { - playerNum = -1; - } + boolean rav = false; + for (int i = 0; i < pad.map[playerNum].length; i += 2) { + if (pad.map[playerNum][i + 0] == kc) { + if (down) + GL2JNIView.kcode_raw[playerNum] &= ~pad.map[playerNum][i + 1]; + else + GL2JNIView.kcode_raw[playerNum] |= pad.map[playerNum][i + 1]; + rav = true; + break; + } + } + mView.pushInput(); + return rav; - if (playerNum != null && playerNum != -1) { - if (pad.compat[playerNum] || pad.custom[playerNum]) { - String id = pad.portId[playerNum]; - if (keyCode == prefs.getInt(Gamepad.pref_button_l + id, - KeyEvent.KEYCODE_BUTTON_L1) - || keyCode == prefs.getInt(Gamepad.pref_button_r + id, - KeyEvent.KEYCODE_BUTTON_R1)) { - return simulatedTouchEvent(playerNum, 0.0f, 0.0f); - } - } - } + } - return handle_key(playerNum, keyCode, false) - || super.onKeyUp(keyCode, event); - } + public void displayPopUp(PopupWindow popUp) { + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) { + popUp.showAtLocation(mView, Gravity.BOTTOM, 0, 60); + } else { + popUp.showAtLocation(mView, Gravity.BOTTOM, 0, 0); + } + popUp.update(LayoutParams.WRAP_CONTENT, + LayoutParams.WRAP_CONTENT); + } - public boolean onKeyDown(int keyCode, KeyEvent event) { - Integer playerNum = Arrays.asList(pad.name).indexOf(event.getDeviceId()); - if (playerNum == -1) { - playerNum = pad.deviceDescriptor_PlayerNum - .get(pad.deviceId_deviceDescriptor.get(event.getDeviceId())); - } else { - playerNum = -1; - } + public void displayDebug(PopupWindow popUpDebug) { + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) { + popUpDebug.showAtLocation(mView, Gravity.BOTTOM, 0, 60); + } else { + popUpDebug.showAtLocation(mView, Gravity.BOTTOM, 0, 0); + } + popUpDebug.update(LayoutParams.WRAP_CONTENT, + LayoutParams.WRAP_CONTENT); + } - if (playerNum != null && playerNum != -1) { - if (pad.compat[playerNum] || pad.custom[playerNum]) { - String id = pad.portId[playerNum]; - if (keyCode == prefs.getInt(Gamepad.pref_button_l + id, KeyEvent.KEYCODE_BUTTON_L1)) { - return simulatedTouchEvent(playerNum, 1.0f, 0.0f); - } - if (keyCode == prefs.getInt(Gamepad.pref_button_r + id, KeyEvent.KEYCODE_BUTTON_R1)) { - return simulatedTouchEvent(playerNum, 0.0f, 1.0f); - } - } - } + public void displayFPS() { + fpsPop.showAtLocation(mView, Gravity.TOP | Gravity.LEFT, 20, 20); + fpsPop.update(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT); + } - if (handle_key(playerNum, keyCode, true)) { - if (playerNum == 0) - JNIdc.hide_osd(); - return true; - } + public void toggleVmu() { + boolean showFloating = !prefs.getBoolean(Config.pref_vmu, false); + if (showFloating) { + if (popUp.isShowing()) { + popUp.dismiss(); + } + //remove from popup menu + popUp.hideVmu(); + //add to floating window + vmuPop.showVmu(); + vmuPop.showAtLocation(mView, Gravity.TOP | Gravity.RIGHT, 4, 4); + vmuPop.update(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT); + } else { + vmuPop.dismiss(); + //remove from floating window + vmuPop.hideVmu(); + //add back to popup menu + popUp.showVmu(); + } + prefs.edit().putBoolean(Config.pref_vmu, showFloating).apply(); + } - if (keyCode == pad.getSelectButtonCode()) { - return showMenu(); - } - if (ViewConfiguration.get(this).hasPermanentMenuKey()) { - if (keyCode == KeyEvent.KEYCODE_MENU) { - return showMenu(); - } - } - if (keyCode == KeyEvent.KEYCODE_BACK) { - return showMenu(); - } - return super.onKeyDown(keyCode, event); - } + public void displayConfig(PopupWindow popUpConfig) { + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) { + popUpConfig.showAtLocation(mView, Gravity.BOTTOM, 0, 60); + } else { + popUpConfig.showAtLocation(mView, Gravity.BOTTOM, 0, 0); + } + popUpConfig.update(LayoutParams.WRAP_CONTENT, + LayoutParams.WRAP_CONTENT); + } - public GL2JNIView getGameView() { - return mView; - } + public boolean onKeyUp(int keyCode, KeyEvent event) { + Integer playerNum = Arrays.asList(pad.name).indexOf(event.getDeviceId()); + if (playerNum == -1) { + playerNum = pad.deviceDescriptor_PlayerNum + .get(pad.deviceId_deviceDescriptor.get(event.getDeviceId())); + } else { + playerNum = -1; + } - public void screenGrab() { - mView.screenGrab(); - } - - private boolean showMenu() { - if (popUp != null) { - if (!menu.dismissPopUps()) { - if (!popUp.isShowing()) { - displayPopUp(popUp); - } else { - popUp.dismiss(); - } - } else { - popUp.dismiss(); - } - } - return true; - } + if (playerNum != null && playerNum != -1) { + if (pad.compat[playerNum] || pad.custom[playerNum]) { + String id = pad.portId[playerNum]; + if (keyCode == prefs.getInt(Gamepad.pref_button_l + id, + KeyEvent.KEYCODE_BUTTON_L1) + || keyCode == prefs.getInt(Gamepad.pref_button_r + id, + KeyEvent.KEYCODE_BUTTON_R1)) { + return simulatedTouchEvent(playerNum, 0.0f, 0.0f); + } + } + } - public boolean serviceRunning(Class javaclass) { - ActivityManager manager = (ActivityManager) - getSystemService(Context.ACTIVITY_SERVICE); - try { - for (ActivityManager.RunningServiceInfo service : manager.getRunningServices(Integer.MAX_VALUE)) { - if (javaclass.getName().equals( - service.service.getClassName())) { - return true; - } - } - } catch (NullPointerException e) { - e.printStackTrace(); - } - return false; - } + return handle_key(playerNum, keyCode, false) + || super.onKeyUp(keyCode, event); + } - @Override - protected void onPause() { - super.onPause(); - mView.onPause(); - moga.onPause(); - } + public boolean onKeyDown(int keyCode, KeyEvent event) { + Integer playerNum = Arrays.asList(pad.name).indexOf(event.getDeviceId()); + if (playerNum == -1) { + playerNum = pad.deviceDescriptor_PlayerNum + .get(pad.deviceId_deviceDescriptor.get(event.getDeviceId())); + } else { + playerNum = -1; + } - @Override - protected void onDestroy() { - super.onDestroy(); - //if (serviceRunning(EmuService.class)) - // stopService(serviceIntent); - mView.onDestroy(); - JNIdc.terminate(); - moga.onDestroy(); - } + if (playerNum != null && playerNum != -1) { + if (pad.compat[playerNum] || pad.custom[playerNum]) { + String id = pad.portId[playerNum]; + if (keyCode == prefs.getInt(Gamepad.pref_button_l + id, KeyEvent.KEYCODE_BUTTON_L1)) { + return simulatedTouchEvent(playerNum, 1.0f, 0.0f); + } + if (keyCode == prefs.getInt(Gamepad.pref_button_r + id, KeyEvent.KEYCODE_BUTTON_R1)) { + return simulatedTouchEvent(playerNum, 0.0f, 1.0f); + } + } + } - @Override - protected void onStop() { - // TODO Auto-generated method stub - super.onStop(); + if (handle_key(playerNum, keyCode, true)) { + if (playerNum == 0) + JNIdc.hide_osd(); + return true; + } + + if (keyCode == pad.getSelectButtonCode()) { + return showMenu(); + } + if (ViewConfiguration.get(this).hasPermanentMenuKey()) { + if (keyCode == KeyEvent.KEYCODE_MENU) { + return showMenu(); + } + } + if (keyCode == KeyEvent.KEYCODE_BACK) { + return showMenu(); + } + return super.onKeyDown(keyCode, event); + } + + public GL2JNIView getGameView() { + return mView; + } + + public void screenGrab() { + mView.screenGrab(); + } + + private boolean showMenu() { + if (popUp != null) { + if (!menu.dismissPopUps()) { + if (!popUp.isShowing()) { + displayPopUp(popUp); + } else { + popUp.dismiss(); + } + } else { + popUp.dismiss(); + } + } + return true; + } + + public boolean serviceRunning(Class javaclass) { + ActivityManager manager = (ActivityManager) + getSystemService(Context.ACTIVITY_SERVICE); + try { + for (ActivityManager.RunningServiceInfo service : manager.getRunningServices(Integer.MAX_VALUE)) { + if (javaclass.getName().equals( + service.service.getClassName())) { + return true; + } + } + } catch (NullPointerException e) { + e.printStackTrace(); + } + return false; + } + + @Override + protected void onPause() { + super.onPause(); + mView.onPause(); + moga.onPause(); + } + + @Override + protected void onDestroy() { + super.onDestroy(); + //if (serviceRunning(EmuService.class)) + // stopService(serviceIntent); + mView.onDestroy(); + JNIdc.terminate(); + moga.onDestroy(); + } + + @Override + protected void onStop() { + // TODO Auto-generated method stub + super.onStop(); // mView.onStop(); - } + } - @Override - public void onConfigurationChanged(Configuration newConfig) { - super.onConfigurationChanged(newConfig); - } + @Override + public void onConfigurationChanged(Configuration newConfig) { + super.onConfigurationChanged(newConfig); + } - @Override - protected void onResume() { - super.onResume(); - mView.onResume(); - moga.onResume(); - } + @Override + protected void onResume() { + super.onResume(); + mView.onResume(); + moga.onResume(); + } } diff --git a/shell/android-studio/reicast/src/main/java/com/reicast/emulator/GL2JNINative.java b/shell/android-studio/reicast/src/main/java/com/reicast/emulator/GL2JNINative.java index 22e94a230..7bb2c80f1 100644 --- a/shell/android-studio/reicast/src/main/java/com/reicast/emulator/GL2JNINative.java +++ b/shell/android-studio/reicast/src/main/java/com/reicast/emulator/GL2JNINative.java @@ -68,7 +68,7 @@ public class GL2JNINative extends NativeActivity { pad.isOuyaOrTV = pad.IsOuyaOrTV(GL2JNINative.this); // isNvidiaShield = Gamepad.IsNvidiaShield(); - + RegisterNative(false); Emulator app = (Emulator)getApplicationContext(); @@ -105,18 +105,18 @@ public class GL2JNINative extends NativeActivity { Integer playerNum = e.getValue(); switch (playerNum) { - case 1: - if (descriptor != null) - controllerTwoConnected = true; - break; - case 2: - if (descriptor != null) - controllerThreeConnected = true; - break; - case 3: - if (descriptor != null) - controllerFourConnected = true; - break; + case 1: + if (descriptor != null) + controllerTwoConnected = true; + break; + case 2: + if (descriptor != null) + controllerThreeConnected = true; + break; + case 3: + if (descriptor != null) + controllerFourConnected = true; + break; } } @@ -197,7 +197,7 @@ public class GL2JNINative extends NativeActivity { sip.startRecording(); JNIdc.setupMic(sip); } - + popUp = menu.new MainPopup(this); vmuPop = menu.new VmuPopup(this); if(prefs.getBoolean(Config.pref_vmu, false)){ @@ -222,14 +222,14 @@ public class GL2JNINative extends NativeActivity { }); } } - + public boolean simulatedTouchEvent(int playerNum, float L2, float R2) { GL2JNIView.lt[playerNum] = (int) (L2 * 255); GL2JNIView.rt[playerNum] = (int) (R2 * 255); mView.pushInput(); return true; } - + public void displayPopUp(PopupWindow popUp) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) { popUp.showAtLocation(mView, Gravity.BOTTOM, 0, 60); @@ -239,7 +239,7 @@ public class GL2JNINative extends NativeActivity { popUp.update(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT); } - + public void displayDebug(PopupWindow popUpDebug) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) { popUpDebug.showAtLocation(mView, Gravity.BOTTOM, 0, 60); @@ -276,7 +276,7 @@ public class GL2JNINative extends NativeActivity { } prefs.edit().putBoolean(Config.pref_vmu, showFloating).apply(); } - + public void displayConfig(PopupWindow popUpConfig) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) { popUpConfig.showAtLocation(mView, Gravity.BOTTOM, 0, 60); @@ -286,7 +286,7 @@ public class GL2JNINative extends NativeActivity { popUpConfig.update(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT); } - + public boolean motionEventHandler(Integer playerNum, com.bda.controller.MotionEvent event) { if (playerNum == null || playerNum == -1) return false; @@ -385,7 +385,7 @@ public class GL2JNINative extends NativeActivity { GL2JNIView.jx[playerNum] = (int) (LS_X * 126); GL2JNIView.jy[playerNum] = (int) (LS_Y * 126); - + GL2JNIView.lt[playerNum] = (int) (L2 * 255); GL2JNIView.rt[playerNum] = (int) (R2 * 255); @@ -493,7 +493,7 @@ public class GL2JNINative extends NativeActivity { if (keyCode == prefs.getInt(Gamepad.pref_button_l + id, KeyEvent.KEYCODE_BUTTON_L1) || keyCode == prefs.getInt(Gamepad.pref_button_r + id, - KeyEvent.KEYCODE_BUTTON_R1)) { + KeyEvent.KEYCODE_BUTTON_R1)) { return simulatedTouchEvent(playerNum, 0.0f, 0.0f); } else { return handle_key(playerNum, keyCode, false); @@ -503,10 +503,10 @@ public class GL2JNINative extends NativeActivity { return false; } -// public boolean OnNativeMotion(int device, int source, int action, int x, + // public boolean OnNativeMotion(int device, int source, int action, int x, // int y, boolean newEvent) { public boolean OnNativeMotion(int device, int source, int action, int x, - int y) { + int y) { Integer playerNum = pad.playerNumX.get(device); if (playerNum != null && playerNum != -1) { Log.d("reicast", playerNum + " - " + device + ": " + source); @@ -547,7 +547,7 @@ public class GL2JNINative extends NativeActivity { public void screenGrab() { mView.screenGrab(); } - + private boolean showMenu() { if (popUp != null) { if (!menu.dismissPopUps()) { diff --git a/shell/android-studio/reicast/src/main/java/com/reicast/emulator/MainActivity.java b/shell/android-studio/reicast/src/main/java/com/reicast/emulator/MainActivity.java index dc8c99eba..7826c8691 100644 --- a/shell/android-studio/reicast/src/main/java/com/reicast/emulator/MainActivity.java +++ b/shell/android-studio/reicast/src/main/java/com/reicast/emulator/MainActivity.java @@ -52,7 +52,7 @@ public class MainActivity extends AppCompatActivity implements private SharedPreferences mPrefs; private boolean hasAndroidMarket = false; - + private UncaughtExceptionHandler mUEHandler; Gamepad pad = new Gamepad(); @@ -61,7 +61,7 @@ public class MainActivity extends AppCompatActivity implements public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); - + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) { getWindow().getDecorView().setOnSystemUiVisibilityChangeListener (new OnSystemUiVisibilityChangeListener() { public void onSystemUiVisibilityChange(int visibility) { @@ -69,16 +69,16 @@ public class MainActivity extends AppCompatActivity implements getWindow().getDecorView().setSystemUiVisibility( // View.SYSTEM_UI_FLAG_LAYOUT_STABLE | View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION - | View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN - | View.SYSTEM_UI_FLAG_HIDE_NAVIGATION - | View.SYSTEM_UI_FLAG_FULLSCREEN - | View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY); + | View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN + | View.SYSTEM_UI_FLAG_HIDE_NAVIGATION + | View.SYSTEM_UI_FLAG_FULLSCREEN + | View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY); } } }); } else { getWindow().setFlags (WindowManager.LayoutParams.FLAG_FULLSCREEN, - WindowManager.LayoutParams.FLAG_FULLSCREEN); + WindowManager.LayoutParams.FLAG_FULLSCREEN); } mPrefs = PreferenceManager.getDefaultSharedPreferences(this); @@ -130,15 +130,15 @@ public class MainActivity extends AppCompatActivity implements onGameSelected(Uri.parse(intent.getData().toString())); // Flush the intent to prevent multiple calls getIntent().setData(null); - setIntent(null); - Config.externalIntent = true; + setIntent(null); + Config.externalIntent = true; } } // Check that the activity is using the layout version with // the fragment_container FrameLayout if (findViewById(R.id.fragment_container) != null) { - onMainBrowseSelected(true, null, false, null); + onMainBrowseSelected(true, null, false, null); } Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar); @@ -160,10 +160,10 @@ public class MainActivity extends AppCompatActivity implements toggle.syncState(); NavigationView navigationView = (NavigationView) findViewById(R.id.nav_view); - if (!hasAndroidMarket) { + if (!hasAndroidMarket) { navigationView.getMenu().findItem(R.id.rateme_menu).setEnabled(false); navigationView.getMenu().findItem(R.id.rateme_menu).setVisible(false); - } + } navigationView.setNavigationItemSelectedListener(this); final SearchView searchView = (SearchView) findViewById(R.id.searchView); @@ -172,9 +172,9 @@ public class MainActivity extends AppCompatActivity implements searchView.setOnQueryTextListener(new SearchView.OnQueryTextListener() { @Override public boolean onQueryTextSubmit(String query) { - onMainBrowseSelected(true, mPrefs.getString(Config.pref_games, - Environment.getExternalStorageDirectory().getAbsolutePath()), - true, query); + onMainBrowseSelected(true, mPrefs.getString(Config.pref_games, + Environment.getExternalStorageDirectory().getAbsolutePath()), + true, query); searchView.onActionViewCollapsed(); return false; } @@ -192,7 +192,7 @@ public class MainActivity extends AppCompatActivity implements /** * Display a dialog to notify the user of prior crash - * + * * @param error * A generalized summary of the crash cause */ @@ -216,13 +216,13 @@ public class MainActivity extends AppCompatActivity implements builder.show(); } - public static boolean isBiosExisting(String home_directory) { - return new File (home_directory, "data/dc_boot.bin").exists(); - } + public static boolean isBiosExisting(String home_directory) { + return new File (home_directory, "data/dc_boot.bin").exists(); + } - public static boolean isFlashExisting(String home_directory) { + public static boolean isFlashExisting(String home_directory) { return new File (home_directory, "data/dc_flash.bin").exists(); - } + } public void onGameSelected(Uri uri) { if (Config.readOutput("uname -a").equals(getString(R.string.error_kernel))) { @@ -231,37 +231,37 @@ public class MainActivity extends AppCompatActivity implements String home_directory = mPrefs.getString(Config.pref_home, Environment.getExternalStorageDirectory().getAbsolutePath()); - if (!isBiosExisting(home_directory)) { - launchBIOSdetection(); - return; - } + if (!isBiosExisting(home_directory)) { + launchBIOSdetection(); + return; + } if (!isFlashExisting(home_directory)) { - launchBIOSdetection(); - return; - } + launchBIOSdetection(); + return; + } JNIdc.config(home_directory); - Emulator.nativeact = PreferenceManager.getDefaultSharedPreferences( - getApplicationContext()).getBoolean(Emulator.pref_nativeact, Emulator.nativeact); - if (Emulator.nativeact) { - startActivity(new Intent("com.reicast.EMULATOR", uri, getApplicationContext(), - GL2JNINative.class)); - } else { - startActivity(new Intent("com.reicast.EMULATOR", uri, getApplicationContext(), - GL2JNIActivity.class)); - } + Emulator.nativeact = PreferenceManager.getDefaultSharedPreferences( + getApplicationContext()).getBoolean(Emulator.pref_nativeact, Emulator.nativeact); + if (Emulator.nativeact) { + startActivity(new Intent("com.reicast.EMULATOR", uri, getApplicationContext(), + GL2JNINative.class)); + } else { + startActivity(new Intent("com.reicast.EMULATOR", uri, getApplicationContext(), + GL2JNIActivity.class)); + } } - + private void launchBIOSdetection() { AlertDialog.Builder builder = new AlertDialog.Builder(this); builder.setTitle(R.string.bios_selection); builder.setPositiveButton(R.string.browse, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { - onMainBrowseSelected(false, - Environment.getExternalStorageDirectory().getAbsolutePath(), - false, null); + onMainBrowseSelected(false, + Environment.getExternalStorageDirectory().getAbsolutePath(), + false, null); } }); builder.setNegativeButton(R.string.gdrive, @@ -292,29 +292,29 @@ public class MainActivity extends AppCompatActivity implements return; } - /** - * Launch the browser activity with specified parameters - * - * @param browse - * Conditional for image files or folders - * @param path - * The root path of the browser fragment - * @param games - * Conditional for viewing games or BIOS - * @param query - * Search parameters to limit list items - */ + /** + * Launch the browser activity with specified parameters + * + * @param browse + * Conditional for image files or folders + * @param path + * The root path of the browser fragment + * @param games + * Conditional for viewing games or BIOS + * @param query + * Search parameters to limit list items + */ public void onMainBrowseSelected(boolean browse, String path, boolean games, String query) { FileBrowser firstFragment = new FileBrowser(); Bundle args = new Bundle(); // args.putBoolean("ImgBrowse", false); - args.putBoolean("ImgBrowse", browse); + args.putBoolean("ImgBrowse", browse); // specify ImgBrowse option. true = images, false = folders only args.putString("browse_entry", path); // specify a path for selecting folder options args.putBoolean("games_entry", games); // specify if the desired path is for games or data - args.putString("search_params", query); + args.putString("search_params", query); firstFragment.setArguments(args); // In case this activity was started with special instructions from @@ -326,7 +326,7 @@ public class MainActivity extends AppCompatActivity implements .beginTransaction() .replace(R.id.fragment_container, firstFragment, "MAIN_BROWSER") .addToBackStack(null).commit(); - setTitle(R.string.browser); + setTitle(R.string.browser); } @Override @@ -360,9 +360,9 @@ public class MainActivity extends AppCompatActivity implements return super.onKeyDown(keyCode, event); } - + private void launchMainFragment() { - onMainBrowseSelected(true, null, false, null); + onMainBrowseSelected(true, null, false, null); } @Override @@ -399,14 +399,14 @@ public class MainActivity extends AppCompatActivity implements fragment.moga.onResume(); } } - + CloudFragment cloudfragment = (CloudFragment) getSupportFragmentManager() .findFragmentByTag("CLOUD_FRAG"); if (cloudfragment != null && cloudfragment.isVisible()) { cloudfragment.onResume(); } } - + @Override public void onPostCreate(Bundle savedInstanceState) { super.onPostCreate(savedInstanceState); @@ -546,11 +546,11 @@ public class MainActivity extends AppCompatActivity implements if (hasFocus && Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) { getWindow().getDecorView().setSystemUiVisibility( View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION - | View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN - | View.SYSTEM_UI_FLAG_HIDE_NAVIGATION - | View.SYSTEM_UI_FLAG_FULLSCREEN - | View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY); - } + | View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN + | View.SYSTEM_UI_FLAG_HIDE_NAVIGATION + | View.SYSTEM_UI_FLAG_FULLSCREEN + | View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY); + } } public boolean isCallable(Intent intent) { diff --git a/shell/android-studio/reicast/src/main/java/com/reicast/emulator/XMLParser.java b/shell/android-studio/reicast/src/main/java/com/reicast/emulator/XMLParser.java index be5da8df0..2f45e67ef 100644 --- a/shell/android-studio/reicast/src/main/java/com/reicast/emulator/XMLParser.java +++ b/shell/android-studio/reicast/src/main/java/com/reicast/emulator/XMLParser.java @@ -79,7 +79,7 @@ public class XMLParser extends AsyncTask { this.childview = childview; this.mCallback = mCallback; } - + public void setGameID(String id) { this.gameId = id; initializeDefaults(); @@ -157,7 +157,7 @@ public class XMLParser extends AsyncTask { } } } catch (Exception e) { - + } } @@ -168,7 +168,7 @@ public class XMLParser extends AsyncTask { } else { ((ImageView) childview.findViewById(R.id.item_icon)).setImageBitmap(coverart); } - + if (mPrefs.getBoolean(Config.pref_gamedetails, false)) { childview.findViewById(R.id.childview).setOnLongClickListener( new OnLongClickListener() { @@ -202,7 +202,7 @@ public class XMLParser extends AsyncTask { childview.setTag(game_name); } - + private void initializeDefaults() { game_details = mContext.getString(R.string.info_unavailable); final String nameLower = game.getName().toLowerCase( @@ -218,7 +218,7 @@ public class XMLParser extends AsyncTask { public boolean isNetworkAvailable() { ConnectivityManager connectivityManager = (ConnectivityManager) mContext - .getSystemService(Context.CONNECTIVITY_SERVICE); + .getSystemService(Context.CONNECTIVITY_SERVICE); NetworkInfo mWifi = connectivityManager.getNetworkInfo(ConnectivityManager.TYPE_WIFI); NetworkInfo mMobile = connectivityManager.getNetworkInfo(ConnectivityManager.TYPE_MOBILE); NetworkInfo activeNetworkInfo = connectivityManager.getActiveNetworkInfo(); @@ -232,7 +232,7 @@ public class XMLParser extends AsyncTask { public Drawable getGameIcon() { return game_icon; } - + public Bitmap getGameCover() { return coverart; } @@ -240,7 +240,7 @@ public class XMLParser extends AsyncTask { public String getGameTitle() { return game_name; } - + public String getGameDetails() { return game_details; } diff --git a/shell/android-studio/reicast/src/main/java/com/reicast/emulator/config/Config.java b/shell/android-studio/reicast/src/main/java/com/reicast/emulator/config/Config.java index 39341e669..d28dd35b2 100644 --- a/shell/android-studio/reicast/src/main/java/com/reicast/emulator/config/Config.java +++ b/shell/android-studio/reicast/src/main/java/com/reicast/emulator/config/Config.java @@ -32,7 +32,7 @@ public class Config { /** * Read the output of a shell command - * + * * @param command * The shell command being issued to the terminal */ diff --git a/shell/android-studio/reicast/src/main/java/com/reicast/emulator/config/EditVJoyActivity.java b/shell/android-studio/reicast/src/main/java/com/reicast/emulator/config/EditVJoyActivity.java index 86bee746b..33b8fded9 100644 --- a/shell/android-studio/reicast/src/main/java/com/reicast/emulator/config/EditVJoyActivity.java +++ b/shell/android-studio/reicast/src/main/java/com/reicast/emulator/config/EditVJoyActivity.java @@ -30,7 +30,7 @@ public class EditVJoyActivity extends Activity { GL2JNIView mView; PopupWindow popUp; LayoutParams params; - + private float[][] vjoy_d_cached; View addbut(int x, OnClickListener ocl) { @@ -46,7 +46,7 @@ public class EditVJoyActivity extends Activity { @Override protected void onCreate(Bundle icicle) { requestWindowFeature(Window.FEATURE_NO_TITLE); - + popUp = createVJoyPopup(); // Call parent onCreate() @@ -65,7 +65,7 @@ public class EditVJoyActivity extends Activity { vjoy_d_cached = VJoy.readCustomVjoyValues(getApplicationContext()); - JNIdc.show_osd(); + JNIdc.show_osd(); } @Override @@ -91,7 +91,7 @@ public class EditVJoyActivity extends Activity { super.onDestroy(); mView.onDestroy(); } - + PopupWindow createVJoyPopup() { final PopupWindow popUp = new PopupWindow(this); int p = OnScreenMenu.getPixelsFromDp(60, this); @@ -151,7 +151,7 @@ public class EditVJoyActivity extends Activity { } else return super.onKeyDown(keyCode, event); } - + @Override public void onConfigurationChanged(Configuration newConfig) { super.onConfigurationChanged(newConfig); diff --git a/shell/android-studio/reicast/src/main/java/com/reicast/emulator/config/InputFragment.java b/shell/android-studio/reicast/src/main/java/com/reicast/emulator/config/InputFragment.java index 2232f1ad6..cfa61c0fb 100644 --- a/shell/android-studio/reicast/src/main/java/com/reicast/emulator/config/InputFragment.java +++ b/shell/android-studio/reicast/src/main/java/com/reicast/emulator/config/InputFragment.java @@ -59,7 +59,7 @@ public class InputFragment extends Fragment { @Override public View onCreateView(LayoutInflater inflater, ViewGroup container, - Bundle savedInstanceState) { + Bundle savedInstanceState) { // Inflate the layout for this fragment return inflater.inflate(R.layout.input_fragment, container, false); } @@ -109,34 +109,34 @@ public class InputFragment extends Fragment { final SeekBar vibSeek = (SeekBar) getView().findViewById(R.id.vib_seekBar); if (sharedPreferences.getBoolean(Config.pref_touchvibe, true)) { - vibLay.setVisibility(View.VISIBLE); + vibLay.setVisibility(View.VISIBLE); } else { - vibLay.setVisibility(View.GONE); + vibLay.setVisibility(View.GONE); } duration.setText(String.valueOf(Config.vibrationDuration + " ms")); vibSeek.setProgress(Config.vibrationDuration); vibSeek.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() { - public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) { - duration.setText(String.valueOf(progress + 5 + " ms")); - } + public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) { + duration.setText(String.valueOf(progress + 5 + " ms")); + } - public void onStartTrackingTouch(SeekBar seekBar) { - // TODO Auto-generated method stub - } + public void onStartTrackingTouch(SeekBar seekBar) { + // TODO Auto-generated method stub + } - public void onStopTrackingTouch(SeekBar seekBar) { - int progress = seekBar.getProgress() + 5; - sharedPreferences.edit().putInt(Config.pref_vibrationDuration, progress).apply(); - Config.vibrationDuration = progress; - vib.vibrate(progress); - } + public void onStopTrackingTouch(SeekBar seekBar) { + int progress = seekBar.getProgress() + 5; + sharedPreferences.edit().putInt(Config.pref_vibrationDuration, progress).apply(); + Config.vibrationDuration = progress; + vib.vibrate(progress); + } }); OnCheckedChangeListener touch_vibration = new OnCheckedChangeListener() { public void onCheckedChanged(CompoundButton buttonView, - boolean isChecked) { + boolean isChecked) { sharedPreferences.edit() .putBoolean(Config.pref_touchvibe, isChecked).apply(); vibLay.setVisibility( isChecked ? View.VISIBLE : View.GONE ); @@ -163,7 +163,7 @@ public class InputFragment extends Fragment { micPluggedIntoFirstController .setOnCheckedChangeListener(new OnCheckedChangeListener() { public void onCheckedChanged(CompoundButton buttonView, - boolean isChecked) { + boolean isChecked) { sharedPreferences.edit().putBoolean(Config.pref_mic, isChecked).apply(); } }); @@ -406,7 +406,7 @@ public class InputFragment extends Fragment { }); builder.setOnKeyListener(new Dialog.OnKeyListener() { public boolean onKey(DialogInterface dialog, int keyCode, - KeyEvent event) { + KeyEvent event) { return mapDevice(keyCode, event); } }); @@ -452,20 +452,20 @@ public class InputFragment extends Fragment { } switch (listenForButton) { - case 0: - return false; - case 1: - sharedPreferences.edit().putString(Gamepad.pref_player1, descriptor).apply(); - break; - case 2: - sharedPreferences.edit().putString(Gamepad.pref_player2, descriptor).apply(); - break; - case 3: - sharedPreferences.edit().putString(Gamepad.pref_player3, descriptor).apply(); - break; - case 4: - sharedPreferences.edit().putString(Gamepad.pref_player4, descriptor).apply(); - break; + case 0: + return false; + case 1: + sharedPreferences.edit().putString(Gamepad.pref_player1, descriptor).apply(); + break; + case 2: + sharedPreferences.edit().putString(Gamepad.pref_player2, descriptor).apply(); + break; + case 3: + sharedPreferences.edit().putString(Gamepad.pref_player3, descriptor).apply(); + break; + case 4: + sharedPreferences.edit().putString(Gamepad.pref_player4, descriptor).apply(); + break; } Log.d("New port " + listenForButton + " controller:", descriptor); @@ -479,18 +479,18 @@ public class InputFragment extends Fragment { private void removeController(int playerNum) { switch (playerNum) { - case 1: - sharedPreferences.edit().putString(Gamepad.pref_player1, null).apply(); - break; - case 2: - sharedPreferences.edit().putString(Gamepad.pref_player2, null).apply(); - break; - case 3: - sharedPreferences.edit().putString(Gamepad.pref_player3, null).apply(); - break; - case 4: - sharedPreferences.edit().putString(Gamepad.pref_player4, null).apply(); - break; + case 1: + sharedPreferences.edit().putString(Gamepad.pref_player1, null).apply(); + break; + case 2: + sharedPreferences.edit().putString(Gamepad.pref_player2, null).apply(); + break; + case 3: + sharedPreferences.edit().putString(Gamepad.pref_player3, null).apply(); + break; + case 4: + sharedPreferences.edit().putString(Gamepad.pref_player4, null).apply(); + break; } updateControllers(); @@ -519,13 +519,13 @@ public class InputFragment extends Fragment { public void onStateEvent(StateEvent event) { if (event.getState() == StateEvent.STATE_CONNECTION && - event.getAction() == MOGAInput.ACTION_CONNECTED) { + event.getAction() == MOGAInput.ACTION_CONNECTED) { int mControllerVersion = moga.mController - .getState(Controller.STATE_CURRENT_PRODUCT_VERSION); + .getState(Controller.STATE_CURRENT_PRODUCT_VERSION); if (mControllerVersion == Controller.ACTION_VERSION_MOGA || - mControllerVersion == Controller.ACTION_VERSION_MOGAPRO) { + mControllerVersion == Controller.ACTION_VERSION_MOGAPRO) { pad.isActiveMoga[playerNum] = true; } } diff --git a/shell/android-studio/reicast/src/main/java/com/reicast/emulator/config/InputModFragment.java b/shell/android-studio/reicast/src/main/java/com/reicast/emulator/config/InputModFragment.java index 756074453..06c8641ba 100644 --- a/shell/android-studio/reicast/src/main/java/com/reicast/emulator/config/InputModFragment.java +++ b/shell/android-studio/reicast/src/main/java/com/reicast/emulator/config/InputModFragment.java @@ -73,7 +73,7 @@ public class InputModFragment extends Fragment { @Override public View onCreateView(LayoutInflater inflater, ViewGroup container, - Bundle savedInstanceState) { + Bundle savedInstanceState) { // Inflate the layout for this fragment return inflater.inflate(R.layout.input_mod_fragment, container, false); } @@ -89,7 +89,7 @@ public class InputModFragment extends Fragment { if (b != null) { playerNum = b.getInt("portNumber", -1); } - + switchJoystickDpadEnabled = (CompoundButton) getView().findViewById( R.id.switchJoystickDpadEnabled); switchRightStickLREnabled = (CompoundButton) getView().findViewById( @@ -101,41 +101,41 @@ public class InputModFragment extends Fragment { OnCheckedChangeListener joystick_mode = new OnCheckedChangeListener() { public void onCheckedChanged(CompoundButton buttonView, - boolean isChecked) { + boolean isChecked) { mPrefs.edit().putBoolean(Gamepad.pref_js_merged + player, isChecked).apply(); } }; - + switchJoystickDpadEnabled.setOnCheckedChangeListener(joystick_mode); - + OnCheckedChangeListener rstick_mode = new OnCheckedChangeListener() { public void onCheckedChanged(CompoundButton buttonView, - boolean isChecked) { + boolean isChecked) { mPrefs.edit().putBoolean(Gamepad.pref_js_rbuttons + player, isChecked).apply(); } }; - + switchRightStickLREnabled.setOnCheckedChangeListener(rstick_mode); OnCheckedChangeListener modified_layout = new OnCheckedChangeListener() { public void onCheckedChanged(CompoundButton buttonView, - boolean isChecked) { + boolean isChecked) { mPrefs.edit().putBoolean(Gamepad.pref_js_modified + player, isChecked).apply(); } }; - + switchModifiedLayoutEnabled.setOnCheckedChangeListener(modified_layout); OnCheckedChangeListener compat_mode = new OnCheckedChangeListener() { public void onCheckedChanged(CompoundButton buttonView, - boolean isChecked) { + boolean isChecked) { mPrefs.edit().putBoolean(Gamepad.pref_js_compat + player, isChecked).apply(); if (isChecked) { selectController(); } } }; - + switchCompatibilityEnabled.setOnCheckedChangeListener(compat_mode); mKey = new mapKeyCode(getActivity()); @@ -358,11 +358,11 @@ public class InputModFragment extends Fragment { player_spnr.setOnItemSelectedListener(new OnItemSelectedListener() { public void onItemSelected(AdapterView parent, View view, - int pos, long id) { + int pos, long id) { String selection = parent.getItemAtPosition(pos).toString(); player = "_" + selection.substring(selection.lastIndexOf(" ") + 1, - selection.length()); + selection.length()); playerNum = pos; updateController(player); } @@ -377,7 +377,7 @@ public class InputModFragment extends Fragment { /** * Retrieve an image to serve as a visual representation - * + * * @param x * The x start value of the image within the atlas * @param y @@ -430,7 +430,7 @@ public class InputModFragment extends Fragment { /** * Prompt the user to specify the controller to modify - * + * */ private void selectController() { AlertDialog.Builder builder = new AlertDialog.Builder(getActivity()); @@ -464,7 +464,7 @@ public class InputModFragment extends Fragment { /** * Prompt the user for the button to be assigned - * + * * @param button * The name of the emulator button being defined * @param output @@ -498,7 +498,7 @@ public class InputModFragment extends Fragment { /** * Assign the user button to the emulator button - * + * * @param keyCode * The keycode generated by the button being assigned * @param event @@ -549,7 +549,7 @@ public class InputModFragment extends Fragment { if (label.contains(":")) { label = label.substring(0, label.indexOf(":")); } - + output.setText(label + ": " + ev.getAction()); } diff --git a/shell/android-studio/reicast/src/main/java/com/reicast/emulator/config/OptionsFragment.java b/shell/android-studio/reicast/src/main/java/com/reicast/emulator/config/OptionsFragment.java index 61d7cd076..a0167e02f 100644 --- a/shell/android-studio/reicast/src/main/java/com/reicast/emulator/config/OptionsFragment.java +++ b/shell/android-studio/reicast/src/main/java/com/reicast/emulator/config/OptionsFragment.java @@ -62,18 +62,18 @@ public class OptionsFragment extends Fragment { private File sdcard = Environment.getExternalStorageDirectory(); private String home_directory = sdcard.getAbsolutePath(); private String game_directory = sdcard.getAbsolutePath(); - + private String[] codes; // Container Activity must implement this interface public interface OnClickListener { - void onMainBrowseSelected(boolean browse, String path_entry, boolean games, String query); + void onMainBrowseSelected(boolean browse, String path_entry, boolean games, String query); } @Override public void onAttach(Activity activity) { super.onAttach(activity); - + // This makes sure that the container activity has implemented // the callback interface. If not, it throws an exception try { @@ -100,16 +100,16 @@ public class OptionsFragment extends Fragment { @Override public View onCreateView(LayoutInflater inflater, ViewGroup container, - Bundle savedInstanceState) { + Bundle savedInstanceState) { // Inflate the layout for this fragment return inflater.inflate(R.layout.configure_fragment, container, false); } @Override public void onViewCreated(View view, Bundle savedInstanceState) { - + mPrefs = PreferenceManager.getDefaultSharedPreferences(getActivity()); - + // Specialized handler for devices with an extSdCard mount for external HashSet extStorage = FileBrowser.getExternalMounts(); if (extStorage != null && !extStorage.isEmpty()) { @@ -120,7 +120,7 @@ public class OptionsFragment extends Fragment { } } } - + home_directory = mPrefs.getString(Config.pref_home, home_directory); Emulator app = (Emulator) getActivity().getApplicationContext(); app.getConfigurationPrefs(mPrefs); @@ -137,7 +137,7 @@ public class OptionsFragment extends Fragment { mainBrowse.setOnClickListener(new View.OnClickListener() { public void onClick(View view) { mPrefs.edit().remove(Config.pref_home).apply(); - hideSoftKeyBoard(); + hideSoftKeyBoard(); mCallback.onMainBrowseSelected(false, home_directory, false, null); } }); @@ -163,11 +163,11 @@ public class OptionsFragment extends Fragment { public void onTextChanged(CharSequence s, int start, int before, int count) { } }); - + OnCheckedChangeListener reios_options = new OnCheckedChangeListener() { public void onCheckedChanged(CompoundButton buttonView, - boolean isChecked) { + boolean isChecked) { mPrefs.edit().putBoolean(Emulator.pref_usereios, isChecked).apply(); } }; @@ -175,11 +175,11 @@ public class OptionsFragment extends Fragment { R.id.reios_option); reios_opt.setChecked(mPrefs.getBoolean(Emulator.pref_usereios, false)); reios_opt.setOnCheckedChangeListener(reios_options); - + OnCheckedChangeListener details_options = new OnCheckedChangeListener() { public void onCheckedChanged(CompoundButton buttonView, - boolean isChecked) { + boolean isChecked) { mPrefs.edit().putBoolean(Config.pref_gamedetails, isChecked).apply(); if (!isChecked) { File dir = new File(getActivity().getExternalFilesDir(null), "images"); @@ -209,7 +209,7 @@ public class OptionsFragment extends Fragment { if (editBrowse.getText() != null) { game_directory = editGames.getText().toString(); } - hideSoftKeyBoard(); + hideSoftKeyBoard(); mCallback.onMainBrowseSelected(false, game_directory, true, null); } }); @@ -243,12 +243,12 @@ public class OptionsFragment extends Fragment { bios_spnr.setOnItemSelectedListener(new OnItemSelectedListener() { public void onItemSelected(AdapterView parent, View view, - int pos, long id) { - flashBios(codes[pos]); + int pos, long id) { + flashBios(codes[pos]); } public void onNothingSelected(AdapterView arg0) { - + } }); @@ -256,7 +256,7 @@ public class OptionsFragment extends Fragment { OnCheckedChangeListener native_options = new OnCheckedChangeListener() { public void onCheckedChanged(CompoundButton buttonView, - boolean isChecked) { + boolean isChecked) { mPrefs.edit().putBoolean(Emulator.pref_nativeact, isChecked).apply(); Emulator.nativeact = isChecked; } @@ -269,7 +269,7 @@ public class OptionsFragment extends Fragment { OnCheckedChangeListener dynarec_options = new OnCheckedChangeListener() { public void onCheckedChanged(CompoundButton buttonView, - boolean isChecked) { + boolean isChecked) { mPrefs.edit().putBoolean(Emulator.pref_dynarecopt, isChecked).apply(); Emulator.dynarecopt = isChecked; } @@ -282,7 +282,7 @@ public class OptionsFragment extends Fragment { OnCheckedChangeListener unstable_option = new OnCheckedChangeListener() { public void onCheckedChanged(CompoundButton buttonView, - boolean isChecked) { + boolean isChecked) { mPrefs.edit().putBoolean(Emulator.pref_unstable, isChecked).apply(); Emulator.unstableopt = isChecked; } @@ -311,7 +311,7 @@ public class OptionsFragment extends Fragment { cable_spnr.setOnItemSelectedListener(new OnItemSelectedListener() { public void onItemSelected(AdapterView parent, View view, - int pos, long id) { + int pos, long id) { mPrefs.edit().putInt(Emulator.pref_cable, pos + 1).apply(); Emulator.cable = pos + 1; } @@ -458,7 +458,7 @@ public class OptionsFragment extends Fragment { pvr_render.setChecked(Emulator.pvrrender); pvr_render.setOnCheckedChangeListener(pvr_rendering); - OnCheckedChangeListener synchronous = new OnCheckedChangeListener() { + OnCheckedChangeListener synchronous = new OnCheckedChangeListener() { public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { mPrefs.edit().putBoolean(Emulator.pref_syncedrender, isChecked).apply(); Emulator.syncedrender = isChecked; @@ -514,7 +514,7 @@ public class OptionsFragment extends Fragment { OnCheckedChangeListener fps_options = new OnCheckedChangeListener() { public void onCheckedChanged(CompoundButton buttonView, - boolean isChecked) { + boolean isChecked) { mPrefs.edit().putBoolean(Config.pref_showfps, isChecked).apply(); } }; @@ -595,7 +595,7 @@ public class OptionsFragment extends Fragment { } }); } - + private final class LocateThemes extends AsyncTask> { @Override protected List doInBackground(String... paths) { @@ -663,7 +663,7 @@ public class OptionsFragment extends Fragment { iMm.hideSoftInputFromWindow(getActivity().getCurrentFocus().getWindowToken(), 0); } } - + private void copy(File src, File dst) throws IOException { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) { try (InputStream in = new FileInputStream(src)) { @@ -692,7 +692,7 @@ public class OptionsFragment extends Fragment { } } } - + private void flashBios(String localized) { File local = new File(home_directory, "data/dc_flash[" + localized + "].bin"); diff --git a/shell/android-studio/reicast/src/main/java/com/reicast/emulator/debug/GenerateLogs.java b/shell/android-studio/reicast/src/main/java/com/reicast/emulator/debug/GenerateLogs.java index 4cdcb5bb4..cc192b136 100644 --- a/shell/android-studio/reicast/src/main/java/com/reicast/emulator/debug/GenerateLogs.java +++ b/shell/android-studio/reicast/src/main/java/com/reicast/emulator/debug/GenerateLogs.java @@ -59,7 +59,7 @@ public class GenerateLogs extends AsyncTask { /** * Obtain the specific parameters of the current device - * + * */ private String discoverCPUData() { String s = "MODEL: " + Build.MODEL; @@ -108,7 +108,7 @@ public class GenerateLogs extends AsyncTask { /** * Read the output of a shell command - * + * * @param command * The shell command being issued to the terminal */ diff --git a/shell/android-studio/reicast/src/main/java/com/reicast/emulator/debug/GitAdapter.java b/shell/android-studio/reicast/src/main/java/com/reicast/emulator/debug/GitAdapter.java index ebd847ecc..8808899b1 100644 --- a/shell/android-studio/reicast/src/main/java/com/reicast/emulator/debug/GitAdapter.java +++ b/shell/android-studio/reicast/src/main/java/com/reicast/emulator/debug/GitAdapter.java @@ -114,7 +114,7 @@ public class GitAdapter extends BaseAdapter { } private void displayCommit(final String sha, String message, String url, - Context context) { + Context context) { final AlertDialog.Builder builder = new AlertDialog.Builder(context); builder.setCancelable(true); builder.setTitle(sha.substring(0,7)); @@ -138,7 +138,7 @@ public class GitAdapter extends BaseAdapter { @SuppressLint("SetJavaScriptEnabled") @SuppressWarnings("deprecation") private WebView configureWebview(String url, Context context, - WebView mWebView) { + WebView mWebView) { mWebView.getSettings().setSupportZoom(true); mWebView.getSettings().setBuiltInZoomControls(true); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) { diff --git a/shell/android-studio/reicast/src/main/java/com/reicast/emulator/emu/GL2JNIView.java b/shell/android-studio/reicast/src/main/java/com/reicast/emulator/emu/GL2JNIView.java index aaac44d6d..9d1be7143 100644 --- a/shell/android-studio/reicast/src/main/java/com/reicast/emulator/emu/GL2JNIView.java +++ b/shell/android-studio/reicast/src/main/java/com/reicast/emulator/emu/GL2JNIView.java @@ -11,6 +11,7 @@ import android.graphics.PixelFormat; import android.media.AudioFormat; import android.media.AudioManager; import android.media.AudioTrack; +import android.opengl.GLES20; import android.opengl.GLSurfaceView; import android.os.Build; import android.os.Environment; @@ -64,307 +65,308 @@ import javax.microedition.khronos.opengles.GL10; public class GL2JNIView extends GLSurfaceView { - public static final boolean DEBUG = false; + public static final boolean DEBUG = false; - public static final int LAYER_TYPE_SOFTWARE = 1; - public static final int LAYER_TYPE_HARDWARE = 2; + public static final int LAYER_TYPE_SOFTWARE = 1; + public static final int LAYER_TYPE_HARDWARE = 2; - private static String fileName; - //private AudioThread audioThread; - private EmuThread ethd; - private Handler handler = new Handler(); + private static String fileName; + //private AudioThread audioThread; + private EmuThread ethd; + private Handler handler = new Handler(); - private static int sWidth; - private static int sHeight; + private static int sWidth; + private static int sHeight; - Vibrator vib; + Vibrator vib; - private boolean editVjoyMode = false; - private int selectedVjoyElement = -1; - private ScaleGestureDetector scaleGestureDetector; + private boolean editVjoyMode = false; + private int selectedVjoyElement = -1; + private ScaleGestureDetector scaleGestureDetector; - public float[][] vjoy_d_custom; + public float[][] vjoy_d_custom; - private static final float[][] vjoy = VJoy.baseVJoy(); + private static final float[][] vjoy = VJoy.baseVJoy(); - Renderer rend; + Renderer rend; - private boolean touchVibrationEnabled; - private int vibrationDuration; - Context context; + private boolean touchVibrationEnabled; + private int vibrationDuration; + Context context; - public void restoreCustomVjoyValues(float[][] vjoy_d_cached) { - vjoy_d_custom = vjoy_d_cached; - VJoy.writeCustomVjoyValues(vjoy_d_cached, context); + public void restoreCustomVjoyValues(float[][] vjoy_d_cached) { + vjoy_d_custom = vjoy_d_cached; + VJoy.writeCustomVjoyValues(vjoy_d_cached, context); - resetEditMode(); - requestLayout(); - } + resetEditMode(); + requestLayout(); + } - public void setFpsDisplay(FpsPopup fpsPop) { - rend.fpsPop = fpsPop; - } + public void setFpsDisplay(FpsPopup fpsPop) { + rend.fpsPop = fpsPop; + } - public GL2JNIView(Context context) { - super(context); - } + public GL2JNIView(Context context) { + super(context); + } - public GL2JNIView(Context context, AttributeSet attrs) { - super(context, attrs); - } + public GL2JNIView(Context context, AttributeSet attrs) { + super(context, attrs); + } - @TargetApi(Build.VERSION_CODES.HONEYCOMB) - public GL2JNIView(Context context, String newFileName, - boolean translucent, int depth, int stencil, boolean editVjoyMode) { - super(context); - this.context = context; - this.editVjoyMode = editVjoyMode; - setKeepScreenOn(true); + @TargetApi(Build.VERSION_CODES.HONEYCOMB) + public GL2JNIView(Context context, String newFileName, + boolean translucent, int depth, int stencil, boolean editVjoyMode) { + super(context); + this.context = context; + this.editVjoyMode = editVjoyMode; + setKeepScreenOn(true); - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) { - setOnSystemUiVisibilityChangeListener (new OnSystemUiVisibilityChangeListener() { - public void onSystemUiVisibilityChange(int visibility) { - if ((visibility & SYSTEM_UI_FLAG_FULLSCREEN) == 0) { - GL2JNIView.this.setSystemUiVisibility( - SYSTEM_UI_FLAG_IMMERSIVE_STICKY - | SYSTEM_UI_FLAG_FULLSCREEN - | SYSTEM_UI_FLAG_HIDE_NAVIGATION); - requestLayout(); - } - } - }); - } + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) { + setOnSystemUiVisibilityChangeListener (new OnSystemUiVisibilityChangeListener() { + public void onSystemUiVisibilityChange(int visibility) { + if ((visibility & SYSTEM_UI_FLAG_FULLSCREEN) == 0) { + GL2JNIView.this.setSystemUiVisibility( + SYSTEM_UI_FLAG_IMMERSIVE_STICKY + | SYSTEM_UI_FLAG_FULLSCREEN + | SYSTEM_UI_FLAG_HIDE_NAVIGATION); + requestLayout(); + } + } + }); + } - setPreserveEGLContextOnPause(true); + setPreserveEGLContextOnPause(true); - vib=(Vibrator) context.getSystemService(Context.VIBRATOR_SERVICE); + vib=(Vibrator) context.getSystemService(Context.VIBRATOR_SERVICE); - DisplayMetrics metrics = new DisplayMetrics(); - //((Activity) context).getWindowManager().getDefaultDisplay().getMetrics(metrics); - ((WindowManager) context.getSystemService(Context.WINDOW_SERVICE)) - .getDefaultDisplay().getMetrics(metrics); - final float scale = context.getResources().getDisplayMetrics().density; - sWidth = (int) (metrics.widthPixels * scale + 0.5f); - sHeight = (int) (metrics.heightPixels * scale + 0.5f); + DisplayMetrics metrics = new DisplayMetrics(); + //((Activity) context).getWindowManager().getDefaultDisplay().getMetrics(metrics); + ((WindowManager) context.getSystemService(Context.WINDOW_SERVICE)) + .getDefaultDisplay().getMetrics(metrics); + final float scale = context.getResources().getDisplayMetrics().density; + sWidth = (int) (metrics.widthPixels * scale + 0.5f); + sHeight = (int) (metrics.heightPixels * scale + 0.5f); - SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context); + SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context); JNIdc.config(prefs.getString(Config.pref_home, Environment.getExternalStorageDirectory().getAbsolutePath())); - ethd = new EmuThread(!Emulator.nosound); + ethd = new EmuThread(!Emulator.nosound); - touchVibrationEnabled = prefs.getBoolean(Config.pref_touchvibe, true); - vibrationDuration = prefs.getInt(Config.pref_vibrationDuration, 20); + touchVibrationEnabled = prefs.getBoolean(Config.pref_touchvibe, true); + vibrationDuration = prefs.getInt(Config.pref_vibrationDuration, 20); - this.setLayerType(prefs.getInt(Config.pref_rendertype, LAYER_TYPE_HARDWARE), null); + this.setLayerType(prefs.getInt(Config.pref_rendertype, LAYER_TYPE_HARDWARE), null); - vjoy_d_custom = VJoy.readCustomVjoyValues(context); + vjoy_d_custom = VJoy.readCustomVjoyValues(context); - scaleGestureDetector = new ScaleGestureDetector(context, new OscOnScaleGestureListener()); + scaleGestureDetector = new ScaleGestureDetector(context, new OscOnScaleGestureListener()); - // This is the game we are going to run - fileName = newFileName; + // This is the game we are going to run + fileName = newFileName; - if (Emulator.nativeact) { - if (GL2JNINative.syms != null) - JNIdc.data(1, GL2JNINative.syms); - } else { - if (GL2JNIActivity.syms != null) - JNIdc.data(1, GL2JNIActivity.syms); - } + if (Emulator.nativeact) { + if (GL2JNINative.syms != null) + JNIdc.data(1, GL2JNINative.syms); + } else { + if (GL2JNIActivity.syms != null) + JNIdc.data(1, GL2JNIActivity.syms); + } - JNIdc.init(fileName); + JNIdc.init(fileName); - // By default, GLSurfaceView() creates a RGB_565 opaque surface. - // If we want a translucent one, we should change the surface's - // format here, using PixelFormat.TRANSLUCENT for GL Surfaces - // is interpreted as any 32-bit surface with alpha by SurfaceFlinger. - if(translucent) this.getHolder().setFormat(PixelFormat.TRANSLUCENT); + // By default, GLSurfaceView() creates a RGB_565 opaque surface. + // If we want a translucent one, we should change the surface's + // format here, using PixelFormat.TRANSLUCENT for GL Surfaces + // is interpreted as any 32-bit surface with alpha by SurfaceFlinger. + if(translucent) this.getHolder().setFormat(PixelFormat.TRANSLUCENT); - if (prefs.getBoolean(Config.pref_egl14, false)) { - setEGLContextFactory(new GLCFactory14.ContextFactory()); - setEGLConfigChooser( - translucent? - new GLCFactory14.ConfigChooser(8, 8, 8, 8, depth, stencil) - : new GLCFactory14.ConfigChooser(5, 6, 5, 0, depth, stencil) - ); - } else { - // Setup the context factory for 2.0 rendering. - // See ContextFactory class definition below - setEGLContextFactory(new GLCFactory.ContextFactory()); + if (prefs.getBoolean(Config.pref_egl14, false)) { + setEGLContextFactory(new GLCFactory14.ContextFactory()); + setEGLConfigChooser( + translucent? + new GLCFactory14.ConfigChooser(8, 8, 8, 8, depth, stencil) + : new GLCFactory14.ConfigChooser(5, 6, 5, 0, depth, stencil) + ); + GLES20.glEnable(GLES20.GL_DEPTH_TEST); + } else { + // Setup the context factory for 2.0 rendering. + // See ContextFactory class definition below + setEGLContextFactory(new GLCFactory.ContextFactory()); - // We need to choose an EGLConfig that matches the format of - // our surface exactly. This is going to be done in our - // custom config chooser. See ConfigChooser class definition - // below. - setEGLConfigChooser( - translucent? - new GLCFactory.ConfigChooser(8, 8, 8, 8, depth, stencil) - : new GLCFactory.ConfigChooser(5, 6, 5, 0, depth, stencil) - ); - } + // We need to choose an EGLConfig that matches the format of + // our surface exactly. This is going to be done in our + // custom config chooser. See ConfigChooser class definition + // below. + setEGLConfigChooser( + translucent? + new GLCFactory.ConfigChooser(8, 8, 8, 8, depth, stencil) + : new GLCFactory.ConfigChooser(5, 6, 5, 0, depth, stencil) + ); + } - // Set the renderer responsible for frame rendering - setRenderer(rend=new Renderer(this)); + // Set the renderer responsible for frame rendering + setRenderer(rend=new Renderer(this)); - pushInput(); //initializes controller codes + pushInput(); //initializes controller codes - ethd.start(); + ethd.start(); - } + } - public GLSurfaceView.Renderer getRenderer() - { - return rend; - } + public GLSurfaceView.Renderer getRenderer() + { + return rend; + } - private void reset_analog() - { + private void reset_analog() + { - int j=11; - vjoy[j+1][0]=vjoy[j][0]+vjoy[j][2]/2-vjoy[j+1][2]/2; - vjoy[j+1][1]=vjoy[j][1]+vjoy[j][3]/2-vjoy[j+1][3]/2; - JNIdc.vjoy(j+1, vjoy[j+1][0], vjoy[j+1][1], vjoy[j+1][2], vjoy[j+1][3]); - } + int j=11; + vjoy[j+1][0]=vjoy[j][0]+vjoy[j][2]/2-vjoy[j+1][2]/2; + vjoy[j+1][1]=vjoy[j][1]+vjoy[j][3]/2-vjoy[j+1][3]/2; + JNIdc.vjoy(j+1, vjoy[j+1][0], vjoy[j+1][1], vjoy[j+1][2], vjoy[j+1][3]); + } - int get_anal(int j, int axis) - { - return (int) (((vjoy[j+1][axis]+vjoy[j+1][axis+2]/2) - vjoy[j][axis] - vjoy[j][axis+2]/2)*254/vjoy[j][axis+2]); - } + int get_anal(int j, int axis) + { + return (int) (((vjoy[j+1][axis]+vjoy[j+1][axis+2]/2) - vjoy[j][axis] - vjoy[j][axis+2]/2)*254/vjoy[j][axis+2]); + } - float vbase(float p, float m, float scl) - { - return (int) ( m - (m -p)*scl); - } + float vbase(float p, float m, float scl) + { + return (int) ( m - (m -p)*scl); + } - float vbase(float p, float scl) - { - return (int) (p*scl ); - } + float vbase(float p, float scl) + { + return (int) (p*scl ); + } - public boolean isTablet() { - return (getContext().getResources().getConfiguration().screenLayout - & Configuration.SCREENLAYOUT_SIZE_MASK) - >= Configuration.SCREENLAYOUT_SIZE_LARGE; - } + public boolean isTablet() { + return (getContext().getResources().getConfiguration().screenLayout + & Configuration.SCREENLAYOUT_SIZE_MASK) + >= Configuration.SCREENLAYOUT_SIZE_LARGE; + } - @Override - protected void onLayout(boolean changed, int left, int top, int right, int bottom) - { - super.onLayout(changed, left, top, right, bottom); - //dcpx/cm = dcpx/px * px/cm - float magic = isTablet() ? 0.8f : 0.7f; - float scl=480.0f/getHeight() * getContext().getResources().getDisplayMetrics().density * magic; - float scl_dc=getHeight()/480.0f; - float tx = ((getWidth()-640.0f*scl_dc)/2)/scl_dc; + @Override + protected void onLayout(boolean changed, int left, int top, int right, int bottom) + { + super.onLayout(changed, left, top, right, bottom); + //dcpx/cm = dcpx/px * px/cm + float magic = isTablet() ? 0.8f : 0.7f; + float scl = 480.0f/getHeight() * getContext().getResources().getDisplayMetrics().density * magic; + float scl_dc = getHeight()/480.0f; + float tx = ((getWidth()-640.0f*scl_dc)/2)/scl_dc; - float a_x = -tx+ 24*scl; - float a_y=- 24*scl; + float a_x = -tx+ 24*scl; + float a_y=- 24*scl; - float[][] vjoy_d = VJoy.getVjoy_d(vjoy_d_custom); + float[][] vjoy_d = VJoy.getVjoy_d(vjoy_d_custom); - for(int i=0;ivjoy[j][0] && x<=(vjoy[j][0]+vjoy[j][2])) - { + for (int i=0;ivjoy[j][0] && x<=(vjoy[j][0]+vjoy[j][2])) + { /* //Disable pressure sensitive R/L //Doesn't really work properly @@ -378,320 +380,320 @@ public class GL2JNIView extends GLSurfaceView if (pre>255) pre=255; */ - int pre = 255; + int pre = 255; - if(y>vjoy[j][1] && y<=(vjoy[j][1]+vjoy[j][3])) - { - if (vjoy[j][4]>=-2) - { - if (vjoy[j][5]==0) - if (!editVjoyMode && touchVibrationEnabled) - vib.vibrate(vibrationDuration); - vjoy[j][5]=2; - } + if (y>vjoy[j][1] && y<=(vjoy[j][1]+vjoy[j][3])) + { + if (vjoy[j][4]>=-2) + { + if (vjoy[j][5]==0) + if (!editVjoyMode && touchVibrationEnabled) + vib.vibrate(vibrationDuration); + vjoy[j][5]=2; + } - if(vjoy[j][4]==-3) - { - if (editVjoyMode) { - selectedVjoyElement = 5; // Analog - resetEditMode(); - } else { - vjoy[j+1][0]=x-vjoy[j+1][2]/2; - vjoy[j+1][1]=y-vjoy[j+1][3]/2; + if (vjoy[j][4]==-3) + { + if (editVjoyMode) { + selectedVjoyElement = 5; // Analog + resetEditMode(); + } else { + vjoy[j+1][0]=x-vjoy[j+1][2]/2; + vjoy[j+1][1]=y-vjoy[j+1][3]/2; - JNIdc.vjoy(j+1, vjoy[j+1][0], vjoy[j+1][1] , vjoy[j+1][2], vjoy[j+1][3]); - anal_id=event.getPointerId(i); - } - } - else if (vjoy[j][4]==-4); - else if(vjoy[j][4]==-1) { - if (editVjoyMode) { - selectedVjoyElement = 3; // Left Trigger - resetEditMode(); - } else { - lt[0]=pre; - lt_id=event.getPointerId(i); - } - } - else if(vjoy[j][4]==-2) { - if (editVjoyMode) { - selectedVjoyElement = 4; // Right Trigger - resetEditMode(); - } else{ - rt[0]=pre; - rt_id=event.getPointerId(i); - } - } - else { - if (editVjoyMode) { - selectedVjoyElement = getElementIdFromButtonId(j); - resetEditMode(); - } else - rv&=~(int)vjoy[j][4]; - } - } - } - } - } - else - { - if (x(vjoy[11][0]+vjoy[11][2])) - x=vjoy[11][0]+vjoy[11][2]; + JNIdc.vjoy(j+1, vjoy[j+1][0], vjoy[j+1][1] , vjoy[j+1][2], vjoy[j+1][3]); + anal_id=event.getPointerId(i); + } + } + else if (vjoy[j][4]==-4); + else if(vjoy[j][4]==-1) { + if (editVjoyMode) { + selectedVjoyElement = 3; // Left Trigger + resetEditMode(); + } else { + lt[0]=pre; + lt_id=event.getPointerId(i); + } + } + else if (vjoy[j][4]==-2) { + if (editVjoyMode) { + selectedVjoyElement = 4; // Right Trigger + resetEditMode(); + } else{ + rt[0]=pre; + rt_id=event.getPointerId(i); + } + } + else { + if (editVjoyMode) { + selectedVjoyElement = getElementIdFromButtonId(j); + resetEditMode(); + } else + rv&=~(int)vjoy[j][4]; + } + } + } + } + } + else + { + if (x(vjoy[11][0]+vjoy[11][2])) + x=vjoy[11][0]+vjoy[11][2]; - if (y(vjoy[11][1]+vjoy[11][3])) - y=vjoy[11][1]+vjoy[11][3]; + if (y(vjoy[11][1]+vjoy[11][3])) + y=vjoy[11][1]+vjoy[11][3]; - int j=11; - vjoy[j+1][0]=x-vjoy[j+1][2]/2; - vjoy[j+1][1]=y-vjoy[j+1][3]/2; + int j=11; + vjoy[j+1][0]=x-vjoy[j+1][2]/2; + vjoy[j+1][1]=y-vjoy[j+1][3]/2; - JNIdc.vjoy(j+1, vjoy[j+1][0], vjoy[j+1][1] , vjoy[j+1][2], vjoy[j+1][3]); + JNIdc.vjoy(j+1, vjoy[j+1][0], vjoy[j+1][1] , vjoy[j+1][2], vjoy[j+1][3]); - } - } + } + } - for(int j=0;j= 1000000000) { - mView.post(new Runnable() { - public void run() { - if (frames > 0) { - fpsPop.setText(frames); - } - } - }); - startTime = System.nanoTime(); - frames = 0; - } - } - } - } + public void logFrame() { + frames++; + if (System.nanoTime() - startTime >= 1000000000) { + mView.post(new Runnable() { + public void run() { + if (frames > 0) { + fpsPop.setText(frames); + } + } + }); + startTime = System.nanoTime(); + frames = 0; + } + } + } + } - public void audioDisable(boolean disabled) { - if (disabled) { - ethd.Player.pause(); - } else { - ethd.Player.play(); - } - } + public void audioDisable(boolean disabled) { + if (disabled) { + ethd.Player.pause(); + } else { + ethd.Player.play(); + } + } - public void fastForward(boolean enabled) { - if (enabled) { - ethd.setPriority(Thread.MIN_PRIORITY); - } else { - ethd.setPriority(Thread.NORM_PRIORITY); - } - } + public void fastForward(boolean enabled) { + if (enabled) { + ethd.setPriority(Thread.MIN_PRIORITY); + } else { + ethd.setPriority(Thread.NORM_PRIORITY); + } + } - class EmuThread extends Thread - { - AudioTrack Player; - long pos; //write position - long size; //size in frames - private boolean sound; + class EmuThread extends Thread + { + AudioTrack Player; + long pos; //write position + long size; //size in frames + private boolean sound; - public EmuThread(boolean sound) { - this.sound = sound; - } + public EmuThread(boolean sound) { + this.sound = sound; + } - @Override public void run() - { - if (sound) { - int min=AudioTrack.getMinBufferSize(44100,AudioFormat.CHANNEL_OUT_STEREO,AudioFormat.ENCODING_PCM_16BIT); + @Override public void run() + { + if (sound) { + int min=AudioTrack.getMinBufferSize(44100,AudioFormat.CHANNEL_OUT_STEREO,AudioFormat.ENCODING_PCM_16BIT); - if (2048>min) - min=2048; + if (2048>min) + min=2048; - Player = new AudioTrack( - AudioManager.STREAM_MUSIC, - 44100, - AudioFormat.CHANNEL_OUT_STEREO, - AudioFormat.ENCODING_PCM_16BIT, - min, - AudioTrack.MODE_STREAM - ); + Player = new AudioTrack( + AudioManager.STREAM_MUSIC, + 44100, + AudioFormat.CHANNEL_OUT_STEREO, + AudioFormat.ENCODING_PCM_16BIT, + min, + AudioTrack.MODE_STREAM + ); - size=min/4; - pos=0; + size=min/4; + pos=0; - Log.i("audcfg", "Audio streaming: buffer size " + min + " samples / " + min/44100.0 + " ms"); - Player.play(); - } + Log.i("audcfg", "Audio streaming: buffer size " + min + " samples / " + min/44100.0 + " ms"); + Player.play(); + } - JNIdc.run(this); - } + JNIdc.run(this); + } - int WriteBuffer(short[] samples, int wait) - { - if (sound) { - int newdata=samples.length/2; + int WriteBuffer(short[] samples, int wait) + { + if (sound) { + int newdata=samples.length/2; - if (wait==0) - { - //user bytes = write-read - //available = size - (write - play) - long used=pos-Player.getPlaybackHeadPosition(); - long avail=size-used; + if (wait==0) + { + //user bytes = write-read + //available = size - (write - play) + long used=pos-Player.getPlaybackHeadPosition(); + long avail=size-used; - //Log.i("audcfg", "u: " + used + " a: " + avail); - if (avail= Build.VERSION_CODES.KITKAT) { - GL2JNIView.this.setSystemUiVisibility( - View.SYSTEM_UI_FLAG_LAYOUT_STABLE - | View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION - | View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN - | View.SYSTEM_UI_FLAG_HIDE_NAVIGATION - | View.SYSTEM_UI_FLAG_FULLSCREEN - | View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY); - requestLayout(); - } - } + @TargetApi(19) + @Override + public void onWindowFocusChanged(boolean hasFocus) { + super.onWindowFocusChanged(hasFocus); + if (hasFocus && Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) { + GL2JNIView.this.setSystemUiVisibility( + View.SYSTEM_UI_FLAG_LAYOUT_STABLE + | View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION + | View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN + | View.SYSTEM_UI_FLAG_HIDE_NAVIGATION + | View.SYSTEM_UI_FLAG_FULLSCREEN + | View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY); + requestLayout(); + } + } + + private boolean takeScreenshot = false; + public void screenGrab() { + takeScreenshot = true; + } - private boolean takeScreenshot = false; - public void screenGrab() { - takeScreenshot = true; - } - } diff --git a/shell/android-studio/reicast/src/main/java/com/reicast/emulator/emu/GLCFactory.java b/shell/android-studio/reicast/src/main/java/com/reicast/emulator/emu/GLCFactory.java index a33516cbd..cf8b63717 100644 --- a/shell/android-studio/reicast/src/main/java/com/reicast/emulator/emu/GLCFactory.java +++ b/shell/android-studio/reicast/src/main/java/com/reicast/emulator/emu/GLCFactory.java @@ -12,226 +12,230 @@ import javax.microedition.khronos.egl.EGLDisplay; public class GLCFactory { - private static void LOGI(String S) { Log.i("GL2JNIView",S); } - private static void LOGW(String S) { Log.w("GL2JNIView",S); } - private static void LOGE(String S) { Log.e("GL2JNIView",S); } + private static void LOGI(String S) { Log.i("GL2JNIView",S); } + private static void LOGW(String S) { Log.w("GL2JNIView",S); } + private static void LOGE(String S) { Log.e("GL2JNIView",S); } - public static class ContextFactory implements GLSurfaceView.EGLContextFactory - { - private static final int EGL_CONTEXT_CLIENT_VERSION = 0x3098; + private int DEPTH_COMPONENT16_NONLINEAR_NV = 0x8E2C; + private int EGL_DEPTH_ENCODING_NV = 0x30E2; + private int EGL_DEPTH_ENCODING_NONLINEAR_NV = 0x30E3; - public EGLContext createContext(EGL10 egl,EGLDisplay display,EGLConfig eglConfig) - { - int[] attrList = { EGL_CONTEXT_CLIENT_VERSION, 2, EGL10.EGL_NONE }; + public static class ContextFactory implements GLSurfaceView.EGLContextFactory + { + private static final int EGL_CONTEXT_CLIENT_VERSION = 0x3098; - LOGI("Creating OpenGL ES 2.0 context"); + public EGLContext createContext(EGL10 egl,EGLDisplay display,EGLConfig eglConfig) + { + int[] attrList = { EGL_CONTEXT_CLIENT_VERSION, 2, EGL10.EGL_NONE }; - checkEglError("Before eglCreateContext",egl); - EGLContext context = egl.eglCreateContext(display,eglConfig,EGL10.EGL_NO_CONTEXT,attrList); - checkEglError("After eglCreateContext",egl); - return(context); - } + LOGI("Creating OpenGL ES 2.0 context"); - public void destroyContext(EGL10 egl,EGLDisplay display,EGLContext context) - { - LOGI("Destroying OpenGL ES 2.0 context"); - egl.eglDestroyContext(display,context); - } - } + checkEglError("Before eglCreateContext",egl); + EGLContext context = egl.eglCreateContext(display,eglConfig,EGL10.EGL_NO_CONTEXT,attrList); + checkEglError("After eglCreateContext",egl); + return(context); + } - private static void checkEglError(String prompt,EGL10 egl) - { - int error; + public void destroyContext(EGL10 egl,EGLDisplay display,EGLContext context) + { + LOGI("Destroying OpenGL ES 2.0 context"); + egl.eglDestroyContext(display,context); + } + } - while((error=egl.eglGetError()) != EGL10.EGL_SUCCESS) - LOGE(String.format("%s: EGL error: 0x%x",prompt,error)); - } + private static void checkEglError(String prompt,EGL10 egl) + { + int error; - public static class ConfigChooser implements GLSurfaceView.EGLConfigChooser - { - // Subclasses can adjust these values: - protected int mRedSize; - protected int mGreenSize; - protected int mBlueSize; - protected int mAlphaSize; - protected int mDepthSize; - protected int mStencilSize; - private int[] mValue = new int[1]; + while((error=egl.eglGetError()) != EGL10.EGL_SUCCESS) + LOGE(String.format("%s: EGL error: 0x%x",prompt,error)); + } - public ConfigChooser(int r,int g,int b,int a,int depth,int stencil) - { - mRedSize = r; - mGreenSize = g; - mBlueSize = b; - mAlphaSize = a; - mDepthSize = depth; - mStencilSize = stencil; - } + public static class ConfigChooser implements GLSurfaceView.EGLConfigChooser + { + // Subclasses can adjust these values: + protected int mRedSize; + protected int mGreenSize; + protected int mBlueSize; + protected int mAlphaSize; + protected int mDepthSize; + protected int mStencilSize; + private int[] mValue = new int[1]; - // This EGL config specification is used to specify 2.0 rendering. - // We use a minimum size of 4 bits for red/green/blue, but will - // perform actual matching in chooseConfig() below. - private static final int EGL_OPENGL_ES2_BIT = 4; - private static final int[] cfgAttrs = - { - EGL10.EGL_RED_SIZE, 4, - EGL10.EGL_GREEN_SIZE, 4, - EGL10.EGL_BLUE_SIZE, 4, - EGL10.EGL_RENDERABLE_TYPE, EGL_OPENGL_ES2_BIT, - EGL10.EGL_DEPTH_SIZE, 24, - EGL10.EGL_NONE - }; + public ConfigChooser(int r,int g,int b,int a,int depth,int stencil) + { + mRedSize = r; + mGreenSize = g; + mBlueSize = b; + mAlphaSize = a; + mDepthSize = depth; + mStencilSize = stencil; + } - public EGLConfig chooseConfig(EGL10 egl,EGLDisplay display) - { - // Get the number of minimally matching EGL configurations - int[] cfgCount = new int[1]; - egl.eglChooseConfig(display,cfgAttrs,null,0,cfgCount); + // This EGL config specification is used to specify 2.0 rendering. + // We use a minimum size of 4 bits for red/green/blue, but will + // perform actual matching in chooseConfig() below. + private static final int EGL_OPENGL_ES2_BIT = 4; + private static final int[] cfgAttrs = + { + EGL10.EGL_RED_SIZE, 4, + EGL10.EGL_GREEN_SIZE, 4, + EGL10.EGL_BLUE_SIZE, 4, + EGL10.EGL_RENDERABLE_TYPE, EGL_OPENGL_ES2_BIT, + EGL10.EGL_DEPTH_SIZE, 24, + EGL10.EGL_NONE + }; - if(cfgCount[0]<=0) - { - cfgAttrs[9]=16; - egl.eglChooseConfig(display,cfgAttrs,null,0,cfgCount); - } + public EGLConfig chooseConfig(EGL10 egl,EGLDisplay display) + { + // Get the number of minimally matching EGL configurations + int[] cfgCount = new int[1]; + egl.eglChooseConfig(display,cfgAttrs,null,0,cfgCount); + + if (cfgCount[0]<=0) + { + cfgAttrs[9]=16; + egl.eglChooseConfig(display,cfgAttrs,null,0,cfgCount); + } - if(cfgCount[0]<=0) - throw new IllegalArgumentException("No configs match configSpec"); + if (cfgCount[0]<=0) + throw new IllegalArgumentException("No configs match configSpec"); - // Allocate then read the array of minimally matching EGL configs - EGLConfig[] configs = new EGLConfig[cfgCount[0]]; - egl.eglChooseConfig(display,cfgAttrs,configs,cfgCount[0],cfgCount); + // Allocate then read the array of minimally matching EGL configs + EGLConfig[] configs = new EGLConfig[cfgCount[0]]; + egl.eglChooseConfig(display,cfgAttrs,configs,cfgCount[0],cfgCount); - if(GL2JNIView.DEBUG) - printConfigs(egl,display,configs); + if (GL2JNIView.DEBUG) + printConfigs(egl,display,configs); - // Now return the "best" one - return(chooseConfig(egl,display,configs)); - } + // Now return the "best" one + return(chooseConfig(egl,display,configs)); + } - public EGLConfig chooseConfig(EGL10 egl,EGLDisplay display,EGLConfig[] configs) - { - for(EGLConfig config : configs) - { - int d = findConfigAttrib(egl,display,config,EGL10.EGL_DEPTH_SIZE,0); - int s = findConfigAttrib(egl,display,config,EGL10.EGL_STENCIL_SIZE,0); + public EGLConfig chooseConfig(EGL10 egl,EGLDisplay display,EGLConfig[] configs) + { + for (EGLConfig config : configs) + { + int d = findConfigAttrib(egl,display,config,EGL10.EGL_DEPTH_SIZE,0); + int s = findConfigAttrib(egl,display,config,EGL10.EGL_STENCIL_SIZE,0); - // We need at least mDepthSize and mStencilSize bits - if(d>=mDepthSize || s>=mStencilSize) - { - // We want an *exact* match for red/green/blue/alpha - int r = findConfigAttrib(egl,display,config,EGL10.EGL_RED_SIZE, 0); - int g = findConfigAttrib(egl,display,config,EGL10.EGL_GREEN_SIZE,0); - int b = findConfigAttrib(egl,display,config,EGL10.EGL_BLUE_SIZE, 0); - int a = findConfigAttrib(egl,display,config,EGL10.EGL_ALPHA_SIZE,0); + // We need at least mDepthSize and mStencilSize bits + if (d>=mDepthSize || s>=mStencilSize) + { + // We want an *exact* match for red/green/blue/alpha + int r = findConfigAttrib(egl,display,config,EGL10.EGL_RED_SIZE, 0); + int g = findConfigAttrib(egl,display,config,EGL10.EGL_GREEN_SIZE,0); + int b = findConfigAttrib(egl,display,config,EGL10.EGL_BLUE_SIZE, 0); + int a = findConfigAttrib(egl,display,config,EGL10.EGL_ALPHA_SIZE,0); - if(r==mRedSize && g==mGreenSize && b==mBlueSize && a==mAlphaSize) - return(config); - } - } + if(r==mRedSize && g==mGreenSize && b==mBlueSize && a==mAlphaSize) + return(config); + } + } - return(null); - } + return(null); + } - private int findConfigAttrib(EGL10 egl,EGLDisplay display,EGLConfig config,int attribute,int defaultValue) - { - return(egl.eglGetConfigAttrib(display,config,attribute,mValue)? mValue[0] : defaultValue); - } + private int findConfigAttrib(EGL10 egl,EGLDisplay display,EGLConfig config,int attribute,int defaultValue) + { + return(egl.eglGetConfigAttrib(display,config,attribute,mValue)? mValue[0] : defaultValue); + } - private void printConfigs(EGL10 egl,EGLDisplay display,EGLConfig[] configs) - { - LOGW(String.format(Locale.getDefault(), "%d configurations", configs.length)); + private void printConfigs(EGL10 egl,EGLDisplay display,EGLConfig[] configs) + { + LOGW(String.format(Locale.getDefault(), "%d configurations", configs.length)); - for(int i=0 ; i. - * + * * Authors: Paul Lamb */ package com.reicast.emulator.periph; @@ -37,11 +37,11 @@ import java.util.List; * Temporary hack for crash in MOGA library on Lollipop. This hack can be removed once MOGA fixes * their library. The actual issue is caused by the use of implicit service intents, which are * illegal in Lollipop, as seen in the logcat message below. - * + * *
  * {@code Service Intent must be explicit: Intent { act=com.bda.controller.IControllerService } }
  * 
- * + * * @see MOGA developer site * @see * Discussion on explicit intents @@ -50,7 +50,7 @@ public class MogaHack { public static void init( Controller controller, Context context ) { - if (Build.VERSION.SDK_INT > Build.VERSION_CODES.KITKAT) + if (Build.VERSION.SDK_INT > Build.VERSION_CODES.KITKAT) { boolean mIsBound = false; java.lang.reflect.Field fIsBound = null; @@ -64,7 +64,7 @@ public class MogaHack mIsBound = fIsBound.getBoolean( controller ); fServiceConnection = cMogaController.getDeclaredField( "mServiceConnection" ); fServiceConnection.setAccessible( true ); - mServiceConnection = ( android.content.ServiceConnection ) fServiceConnection.get( controller ); + mServiceConnection = ( android.content.ServiceConnection ) fServiceConnection.get( controller ); } catch( NoSuchFieldException e ) { @@ -92,7 +92,7 @@ public class MogaHack String packageName = serviceInfo.packageName; String className = serviceInfo.name; intent.setComponent( new ComponentName( packageName, className ) ); - + // Start the service explicitly context.startService( intent ); context.bindService( intent, mServiceConnection, 1 ); diff --git a/shell/android-studio/reicast/src/main/java/com/reicast/emulator/periph/SipEmulator.java b/shell/android-studio/reicast/src/main/java/com/reicast/emulator/periph/SipEmulator.java index 0eac26498..8195321aa 100644 --- a/shell/android-studio/reicast/src/main/java/com/reicast/emulator/periph/SipEmulator.java +++ b/shell/android-studio/reicast/src/main/java/com/reicast/emulator/periph/SipEmulator.java @@ -8,19 +8,19 @@ import android.util.Log; import java.util.concurrent.ConcurrentLinkedQueue; public class SipEmulator extends Thread { - + static final String TAG = "SipEmulator"; - + //one second of audio data in bytes static final int BUFFER_SIZE = 22050; //this needs to get set to the amount the mic normally sends per data request //...cant be bigger than a maple packet // 240 16 (or 14) bit samples static final int ONE_BLIP_SIZE = 480; //ALSO DEFINED IN maple_devs.h - + private AudioRecord record; private ConcurrentLinkedQueue bytesReadBuffer; - + private boolean continueRecording; private boolean firstGet; @@ -29,31 +29,31 @@ public class SipEmulator extends Thread { == 176.4 kbit/s == 22050 bytes/s */ - + public SipEmulator(){ - + Log.d(TAG, "SipEmulator constructor called"); - + init(); - + } - + private void init(){ Log.d(TAG, "SipEmulator init called"); record = new AudioRecord( - MediaRecorder.AudioSource.VOICE_RECOGNITION, - 11025, - AudioFormat.CHANNEL_IN_MONO, - AudioFormat.ENCODING_PCM_16BIT, + MediaRecorder.AudioSource.VOICE_RECOGNITION, + 11025, + AudioFormat.CHANNEL_IN_MONO, + AudioFormat.ENCODING_PCM_16BIT, BUFFER_SIZE); - + bytesReadBuffer = new ConcurrentLinkedQueue(); - + continueRecording = false; firstGet = true; } - + public void startRecording(){ Log.d(TAG, "SipEmulator startRecording called"); if(continueRecording){ @@ -63,13 +63,13 @@ public class SipEmulator extends Thread { continueRecording = true; this.start(); } - + public void stopRecording(){ Log.d(TAG, "SipEmulator stopRecording called"); continueRecording = false; record.stop(); } - + public byte[] getData(){ //Log.d(TAG, "SipEmulator getData called"); //Log.d(TAG, "SipEmulator getData bytesReadBuffer size: "+bytesReadBuffer.size()); @@ -79,26 +79,26 @@ public class SipEmulator extends Thread { } return bytesReadBuffer.poll(); } - + private byte[] catchUp(){ Log.d(TAG, "SipEmulator catchUp"); byte[] last = bytesReadBuffer.poll(); bytesReadBuffer.clear(); return last; } - + public void configSomething(int what, int setting){ Log.d(TAG, "SipEmulator configSomething called"); - + } - + public void run() { Log.d(TAG, "recordThread starting"); - + while(continueRecording){ byte[] freshData = new byte[ONE_BLIP_SIZE]; // read blocks - record.read(freshData, 0, ONE_BLIP_SIZE); + record.read(freshData, 0, ONE_BLIP_SIZE); if(!firstGet){ bytesReadBuffer.add(freshData); } diff --git a/shell/android-studio/reicast/src/main/java/com/reicast/emulator/periph/VJoy.java b/shell/android-studio/reicast/src/main/java/com/reicast/emulator/periph/VJoy.java index 54076f993..9006351ec 100644 --- a/shell/android-studio/reicast/src/main/java/com/reicast/emulator/periph/VJoy.java +++ b/shell/android-studio/reicast/src/main/java/com/reicast/emulator/periph/VJoy.java @@ -22,87 +22,87 @@ public class VJoy { public static int VJoyCount = 13; public static float[][] baseVJoy() { - return new float[][] { - new float[] { 24+0, 24+64, 64,64, VJoy.key_CONT_DPAD_LEFT, 0}, - new float[] { 24+64, 24+0, 64,64, VJoy.key_CONT_DPAD_UP, 0}, - new float[] { 24+128, 24+64, 64,64, VJoy.key_CONT_DPAD_RIGHT, 0}, - new float[] { 24+64, 24+128, 64,64, VJoy.key_CONT_DPAD_DOWN, 0}, + return new float[][] { + new float[] { 24+0, 24+64, 64,64, VJoy.key_CONT_DPAD_LEFT, 0}, + new float[] { 24+64, 24+0, 64,64, VJoy.key_CONT_DPAD_UP, 0}, + new float[] { 24+128, 24+64, 64,64, VJoy.key_CONT_DPAD_RIGHT, 0}, + new float[] { 24+64, 24+128, 64,64, VJoy.key_CONT_DPAD_DOWN, 0}, - new float[] { 440+0, 280+64, 64,64, VJoy.key_CONT_X, 0}, - new float[] { 440+64, 280+0, 64,64, VJoy.key_CONT_Y, 0}, - new float[] { 440+128, 280+64, 64,64, VJoy.key_CONT_B, 0}, - new float[] { 440+64, 280+128, 64,64, VJoy.key_CONT_A, 0}, + new float[] { 440+0, 280+64, 64,64, VJoy.key_CONT_X, 0}, + new float[] { 440+64, 280+0, 64,64, VJoy.key_CONT_Y, 0}, + new float[] { 440+128, 280+64, 64,64, VJoy.key_CONT_B, 0}, + new float[] { 440+64, 280+128, 64,64, VJoy.key_CONT_A, 0}, - new float[] { 320-32, 360+32, 64,64, VJoy.key_CONT_START, 0}, + new float[] { 320-32, 360+32, 64,64, VJoy.key_CONT_START, 0}, - new float[] { 440, 200, 90,64, -1, 0}, - new float[] { 542, 200, 90,64, -2, 0}, + new float[] { 440, 200, 90,64, -1, 0}, + new float[] { 542, 200, 90,64, -2, 0}, - new float[] { 0, 128+224, 128,128, -3, 0}, - new float[] { 96, 320, 32,32, -4, 0}, + new float[] { 0, 128+224, 128,128, -3, 0}, + new float[] { 96, 320, 32,32, -4, 0}, - new float[] { 20+0 , 288+0 , 64,64, key_CONT_DPAD_LEFT|key_CONT_DPAD_UP, 0}, - new float[] { 20+128, 288+0 , 64,64, key_CONT_DPAD_RIGHT|key_CONT_DPAD_UP, 0}, - new float[] { 20+0 , 288+128, 64,64, key_CONT_DPAD_LEFT|key_CONT_DPAD_DOWN, 0}, - new float[] { 20+128, 288+128, 64,64, key_CONT_DPAD_RIGHT|key_CONT_DPAD_DOWN, 0}, + new float[] { 20+0 , 288+0 , 64,64, key_CONT_DPAD_LEFT|key_CONT_DPAD_UP, 0}, + new float[] { 20+128, 288+0 , 64,64, key_CONT_DPAD_RIGHT|key_CONT_DPAD_UP, 0}, + new float[] { 20+0 , 288+128, 64,64, key_CONT_DPAD_LEFT|key_CONT_DPAD_DOWN, 0}, + new float[] { 20+128, 288+128, 64,64, key_CONT_DPAD_RIGHT|key_CONT_DPAD_DOWN, 0}, }; } public static float[][] readCustomVjoyValues(Context context) { SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context); return new float[][] { - // x-shift, y-shift, sizing-factor - new float[] { prefs.getFloat("touch_x_shift_dpad", 0), - prefs.getFloat("touch_y_shift_dpad", 0), - prefs.getFloat("touch_scale_dpad", 1) - }, // DPAD - new float[] { prefs.getFloat("touch_x_shift_buttons", 0), - prefs.getFloat("touch_y_shift_buttons", 0), - prefs.getFloat("touch_scale_buttons", 1) - }, // X, Y, B, A Buttons - new float[] { prefs.getFloat("touch_x_shift_start", 0), - prefs.getFloat("touch_y_shift_start", 0), - prefs.getFloat("touch_scale_start", 1) - }, // Start - new float[] { prefs.getFloat("touch_x_shift_left_trigger", 0), - prefs.getFloat("touch_y_shift_left_trigger", 0), - prefs.getFloat("touch_scale_left_trigger", 1) - }, // Left Trigger - new float[] { prefs.getFloat("touch_x_shift_right_trigger", 0), - prefs.getFloat("touch_y_shift_right_trigger", 0), - prefs.getFloat("touch_scale_right_trigger", 1) - }, // Right Trigger - new float[] { prefs.getFloat("touch_x_shift_analog", 0), - prefs.getFloat("touch_y_shift_analog", 0), - prefs.getFloat("touch_scale_analog", 1) - } // Analog Stick + // x-shift, y-shift, sizing-factor + new float[] { prefs.getFloat("touch_x_shift_dpad", 0), + prefs.getFloat("touch_y_shift_dpad", 0), + prefs.getFloat("touch_scale_dpad", 1) + }, // DPAD + new float[] { prefs.getFloat("touch_x_shift_buttons", 0), + prefs.getFloat("touch_y_shift_buttons", 0), + prefs.getFloat("touch_scale_buttons", 1) + }, // X, Y, B, A Buttons + new float[] { prefs.getFloat("touch_x_shift_start", 0), + prefs.getFloat("touch_y_shift_start", 0), + prefs.getFloat("touch_scale_start", 1) + }, // Start + new float[] { prefs.getFloat("touch_x_shift_left_trigger", 0), + prefs.getFloat("touch_y_shift_left_trigger", 0), + prefs.getFloat("touch_scale_left_trigger", 1) + }, // Left Trigger + new float[] { prefs.getFloat("touch_x_shift_right_trigger", 0), + prefs.getFloat("touch_y_shift_right_trigger", 0), + prefs.getFloat("touch_scale_right_trigger", 1) + }, // Right Trigger + new float[] { prefs.getFloat("touch_x_shift_analog", 0), + prefs.getFloat("touch_y_shift_analog", 0), + prefs.getFloat("touch_scale_analog", 1) + } // Analog Stick }; } public static float[][] getVjoy_d(float[][] vjoy_d_custom) { - return new float[][] { - new float[] { 20+0*vjoy_d_custom[0][2]+vjoy_d_custom[0][0], 288+64*vjoy_d_custom[0][2]+vjoy_d_custom[0][1], 64*vjoy_d_custom[0][2],64*vjoy_d_custom[0][2], key_CONT_DPAD_LEFT}, - new float[] { 20+64*vjoy_d_custom[0][2]+vjoy_d_custom[0][0], 288+0*vjoy_d_custom[0][2]+vjoy_d_custom[0][1], 64*vjoy_d_custom[0][2],64*vjoy_d_custom[0][2], key_CONT_DPAD_UP}, - new float[] { 20+128*vjoy_d_custom[0][2]+vjoy_d_custom[0][0], 288+64*vjoy_d_custom[0][2]+vjoy_d_custom[0][1], 64*vjoy_d_custom[0][2],64*vjoy_d_custom[0][2], key_CONT_DPAD_RIGHT}, - new float[] { 20+64*vjoy_d_custom[0][2]+vjoy_d_custom[0][0], 288+128*vjoy_d_custom[0][2]+vjoy_d_custom[0][1], 64*vjoy_d_custom[0][2],64*vjoy_d_custom[0][2], key_CONT_DPAD_DOWN}, + return new float[][] { + new float[] { 20+0*vjoy_d_custom[0][2]+vjoy_d_custom[0][0], 288+64*vjoy_d_custom[0][2]+vjoy_d_custom[0][1], 64*vjoy_d_custom[0][2],64*vjoy_d_custom[0][2], key_CONT_DPAD_LEFT}, + new float[] { 20+64*vjoy_d_custom[0][2]+vjoy_d_custom[0][0], 288+0*vjoy_d_custom[0][2]+vjoy_d_custom[0][1], 64*vjoy_d_custom[0][2],64*vjoy_d_custom[0][2], key_CONT_DPAD_UP}, + new float[] { 20+128*vjoy_d_custom[0][2]+vjoy_d_custom[0][0], 288+64*vjoy_d_custom[0][2]+vjoy_d_custom[0][1], 64*vjoy_d_custom[0][2],64*vjoy_d_custom[0][2], key_CONT_DPAD_RIGHT}, + new float[] { 20+64*vjoy_d_custom[0][2]+vjoy_d_custom[0][0], 288+128*vjoy_d_custom[0][2]+vjoy_d_custom[0][1], 64*vjoy_d_custom[0][2],64*vjoy_d_custom[0][2], key_CONT_DPAD_DOWN}, - new float[] { 448+0*vjoy_d_custom[1][2]+vjoy_d_custom[1][0], 288+64*vjoy_d_custom[1][2]+vjoy_d_custom[1][1], 64*vjoy_d_custom[1][2],64*vjoy_d_custom[1][2], key_CONT_X}, - new float[] { 448+64*vjoy_d_custom[1][2]+vjoy_d_custom[1][0], 288+0*vjoy_d_custom[1][2]+vjoy_d_custom[1][1], 64*vjoy_d_custom[1][2],64*vjoy_d_custom[1][2], key_CONT_Y}, - new float[] { 448+128*vjoy_d_custom[1][2]+vjoy_d_custom[1][0], 288+64*vjoy_d_custom[1][2]+vjoy_d_custom[1][1], 64*vjoy_d_custom[1][2],64*vjoy_d_custom[1][2], key_CONT_B}, - new float[] { 448+64*vjoy_d_custom[1][2]+vjoy_d_custom[1][0], 288+128*vjoy_d_custom[1][2]+vjoy_d_custom[1][1], 64*vjoy_d_custom[1][2],64*vjoy_d_custom[1][2], key_CONT_A}, + new float[] { 448+0*vjoy_d_custom[1][2]+vjoy_d_custom[1][0], 288+64*vjoy_d_custom[1][2]+vjoy_d_custom[1][1], 64*vjoy_d_custom[1][2],64*vjoy_d_custom[1][2], key_CONT_X}, + new float[] { 448+64*vjoy_d_custom[1][2]+vjoy_d_custom[1][0], 288+0*vjoy_d_custom[1][2]+vjoy_d_custom[1][1], 64*vjoy_d_custom[1][2],64*vjoy_d_custom[1][2], key_CONT_Y}, + new float[] { 448+128*vjoy_d_custom[1][2]+vjoy_d_custom[1][0], 288+64*vjoy_d_custom[1][2]+vjoy_d_custom[1][1], 64*vjoy_d_custom[1][2],64*vjoy_d_custom[1][2], key_CONT_B}, + new float[] { 448+64*vjoy_d_custom[1][2]+vjoy_d_custom[1][0], 288+128*vjoy_d_custom[1][2]+vjoy_d_custom[1][1], 64*vjoy_d_custom[1][2],64*vjoy_d_custom[1][2], key_CONT_A}, - new float[] { 320-32+vjoy_d_custom[2][0], 288+128+vjoy_d_custom[2][1], 64*vjoy_d_custom[2][2],64*vjoy_d_custom[2][2], key_CONT_START}, + new float[] { 320-32+vjoy_d_custom[2][0], 288+128+vjoy_d_custom[2][1], 64*vjoy_d_custom[2][2],64*vjoy_d_custom[2][2], key_CONT_START}, - new float[] { 440+vjoy_d_custom[3][0], 200+vjoy_d_custom[3][1], 90*vjoy_d_custom[3][2],64*vjoy_d_custom[3][2], -1}, - new float[] { 542+vjoy_d_custom[4][0], 200+vjoy_d_custom[4][1], 90*vjoy_d_custom[4][2],64*vjoy_d_custom[4][2], -2}, + new float[] { 440+vjoy_d_custom[3][0], 200+vjoy_d_custom[3][1], 90*vjoy_d_custom[3][2],64*vjoy_d_custom[3][2], -1}, + new float[] { 542+vjoy_d_custom[4][0], 200+vjoy_d_custom[4][1], 90*vjoy_d_custom[4][2],64*vjoy_d_custom[4][2], -2}, - new float[] { 16+vjoy_d_custom[5][0], 24+32+vjoy_d_custom[5][1], 128*vjoy_d_custom[5][2],128*vjoy_d_custom[5][2], -3}, - new float[] { 96+vjoy_d_custom[5][0], 320+vjoy_d_custom[5][1], 32*vjoy_d_custom[5][2],32*vjoy_d_custom[5][2], -4}, + new float[] { 16+vjoy_d_custom[5][0], 24+32+vjoy_d_custom[5][1], 128*vjoy_d_custom[5][2],128*vjoy_d_custom[5][2], -3}, + new float[] { 96+vjoy_d_custom[5][0], 320+vjoy_d_custom[5][1], 32*vjoy_d_custom[5][2],32*vjoy_d_custom[5][2], -4}, - new float[] { 20+0*vjoy_d_custom[0][2]+vjoy_d_custom[0][0], 288+0*vjoy_d_custom[0][2]+vjoy_d_custom[0][1], 64*vjoy_d_custom[0][2],64*vjoy_d_custom[0][2], key_CONT_DPAD_LEFT|key_CONT_DPAD_UP}, - new float[] { 20+128*vjoy_d_custom[0][2]+vjoy_d_custom[0][0], 288+0*vjoy_d_custom[0][2]+vjoy_d_custom[0][1], 64*vjoy_d_custom[0][2],64*vjoy_d_custom[0][2], key_CONT_DPAD_RIGHT|key_CONT_DPAD_UP}, - new float[] { 20+0*vjoy_d_custom[0][2]+vjoy_d_custom[0][0], 288+128*vjoy_d_custom[0][2]+vjoy_d_custom[0][1], 64*vjoy_d_custom[0][2],64*vjoy_d_custom[0][2], key_CONT_DPAD_LEFT|key_CONT_DPAD_DOWN}, - new float[] { 20+128*vjoy_d_custom[0][2]+vjoy_d_custom[0][0], 288+128*vjoy_d_custom[0][2]+vjoy_d_custom[0][1], 64*vjoy_d_custom[0][2],64*vjoy_d_custom[0][2], key_CONT_DPAD_RIGHT|key_CONT_DPAD_DOWN}, + new float[] { 20+0*vjoy_d_custom[0][2]+vjoy_d_custom[0][0], 288+0*vjoy_d_custom[0][2]+vjoy_d_custom[0][1], 64*vjoy_d_custom[0][2],64*vjoy_d_custom[0][2], key_CONT_DPAD_LEFT|key_CONT_DPAD_UP}, + new float[] { 20+128*vjoy_d_custom[0][2]+vjoy_d_custom[0][0], 288+0*vjoy_d_custom[0][2]+vjoy_d_custom[0][1], 64*vjoy_d_custom[0][2],64*vjoy_d_custom[0][2], key_CONT_DPAD_RIGHT|key_CONT_DPAD_UP}, + new float[] { 20+0*vjoy_d_custom[0][2]+vjoy_d_custom[0][0], 288+128*vjoy_d_custom[0][2]+vjoy_d_custom[0][1], 64*vjoy_d_custom[0][2],64*vjoy_d_custom[0][2], key_CONT_DPAD_LEFT|key_CONT_DPAD_DOWN}, + new float[] { 20+128*vjoy_d_custom[0][2]+vjoy_d_custom[0][0], 288+128*vjoy_d_custom[0][2]+vjoy_d_custom[0][1], 64*vjoy_d_custom[0][2],64*vjoy_d_custom[0][2], key_CONT_DPAD_RIGHT|key_CONT_DPAD_DOWN}, }; } @@ -133,7 +133,7 @@ public class VJoy { prefs.edit().putFloat("touch_y_shift_analog", vjoy_d_custom[5][1]).apply(); prefs.edit().putFloat("touch_scale_analog", vjoy_d_custom[5][2]).apply(); } - + public static void resetCustomVjoyValues(Context context) { SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context); diff --git a/shell/android-studio/reicast/src/main/java/com/reicast/emulator/periph/VmuLcd.java b/shell/android-studio/reicast/src/main/java/com/reicast/emulator/periph/VmuLcd.java index c82491d08..13522c6ef 100644 --- a/shell/android-studio/reicast/src/main/java/com/reicast/emulator/periph/VmuLcd.java +++ b/shell/android-studio/reicast/src/main/java/com/reicast/emulator/periph/VmuLcd.java @@ -11,26 +11,26 @@ import android.view.View; import com.reicast.emulator.emu.OnScreenMenu; public class VmuLcd extends View { - + public final static int w = 48; public final static int h = 32; - + private int[] image = new int[w*h]; private Bitmap current = Bitmap.createBitmap(w, h, Bitmap.Config.ARGB_8888); private float scale; private Paint paint; - + public VmuLcd(Context context) { super(context); paint = new Paint(); scale = (float)OnScreenMenu.getPixelsFromDp(60, getContext()) / w; Log.d("VmuLcd", "scale: "+scale); } - + public void configureScale(int dp) { scale = (float)OnScreenMenu.getPixelsFromDp(dp, getContext()) / w; } - + public void updateBytes(byte[] data){ for(int i=0; i