Merge pull request #323 from ThePlayground/master
Let's let Moga start actually handling Moga events, Fix Rjoy
This commit is contained in:
commit
631c5bae5b
|
@ -37,7 +37,7 @@
|
|||
|
||||
<string name="report_issue">Previous Crash Detected</string>
|
||||
<string name="platform">Copying logcat content to clipboard\nPlease paste in the issue report</string>
|
||||
<string name="log_saved">Log saved to %1$s</string>
|
||||
<string name="log_saved">Log saved to \"System Path\"</string>
|
||||
<string name="bios_config">Configuration failed!</string>
|
||||
<string name="menu_debug">Submit Error Logs</string>
|
||||
|
||||
|
|
|
@ -272,11 +272,7 @@ public class GL2JNIActivity extends Activity {
|
|||
if (playerNum == null || playerNum == -1)
|
||||
return false;
|
||||
|
||||
if (pad.isActiveMoga[playerNum]) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!pad.compat[playerNum]) {
|
||||
if (!pad.compat[playerNum] && !pad.isActiveMoga[playerNum]) {
|
||||
// TODO: Moga should handle this locally
|
||||
|
||||
// Joystick
|
||||
|
@ -303,14 +299,15 @@ public class GL2JNIActivity extends Activity {
|
|||
|
||||
if (prefs.getBoolean("right_buttons", true)) {
|
||||
if (RS_Y > 0.5) {
|
||||
handle_key(playerNum, pad.map[playerNum][0], true);
|
||||
handle_key(playerNum, pad.map[playerNum][1], false);
|
||||
handle_key(playerNum, pad.map[playerNum][0]/* A */, true);
|
||||
pad.wasKeyStick[playerNum] = true;
|
||||
} else if (RS_Y < 0.5) {
|
||||
handle_key(playerNum, pad.map[playerNum][0], false);
|
||||
handle_key(playerNum, pad.map[playerNum][1], true);
|
||||
} else {
|
||||
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.5) {
|
||||
|
@ -320,9 +317,8 @@ public class GL2JNIActivity extends Activity {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
mView.pushInput();
|
||||
}
|
||||
mView.pushInput();
|
||||
if ((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))
|
||||
// Only handle Left Stick on an Xbox 360 controller if there was
|
||||
|
@ -379,7 +375,7 @@ public class GL2JNIActivity extends Activity {
|
|||
* };
|
||||
*/
|
||||
|
||||
boolean handle_key(Integer playerNum, int kc, boolean down) {
|
||||
public boolean handle_key(Integer playerNum, int kc, boolean down) {
|
||||
if (playerNum == null || playerNum == -1)
|
||||
return false;
|
||||
if (pad.isActiveMoga[playerNum]) {
|
||||
|
@ -461,6 +457,10 @@ public class GL2JNIActivity extends Activity {
|
|||
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 (Build.VERSION.SDK_INT >= Build.VERSION_CODES.GINGERBREAD && playerNum == -1) {
|
||||
|
@ -470,7 +470,7 @@ public class GL2JNIActivity extends Activity {
|
|||
playerNum = -1;
|
||||
}
|
||||
|
||||
if (playerNum != null && playerNum != -1) {
|
||||
if (playerNum != null && playerNum != -1 && !pad.isActiveMoga[playerNum]) {
|
||||
if (pad.compat[playerNum] || pad.custom[playerNum]) {
|
||||
String id = pad.portId[playerNum];
|
||||
if (keyCode == prefs.getInt("l_button" + id,
|
||||
|
@ -482,8 +482,15 @@ public class GL2JNIActivity extends Activity {
|
|||
}
|
||||
}
|
||||
|
||||
return handle_key(playerNum, keyCode, false)
|
||||
|| super.onKeyUp(keyCode, event);
|
||||
if (!pad.isActiveMoga[playerNum]) {
|
||||
return handle_key(playerNum, keyCode, false)
|
||||
|| super.onKeyUp(keyCode, event);
|
||||
} else if (keyCode == KeyEvent.KEYCODE_VOLUME_UP
|
||||
|| keyCode == KeyEvent.KEYCODE_VOLUME_DOWN) {
|
||||
return super.onKeyUp(keyCode, event);
|
||||
} else {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
public boolean onKeyDown(int keyCode, KeyEvent event) {
|
||||
|
@ -494,8 +501,8 @@ public class GL2JNIActivity extends Activity {
|
|||
} else {
|
||||
playerNum = -1;
|
||||
}
|
||||
|
||||
if (playerNum != null && playerNum != -1) {
|
||||
|
||||
if (playerNum != null && playerNum != -1 && !pad.isActiveMoga[playerNum]) {
|
||||
if (pad.compat[playerNum] || pad.custom[playerNum]) {
|
||||
String id = pad.portId[playerNum];
|
||||
if (keyCode == prefs.getInt("l_button" + id, KeyEvent.KEYCODE_BUTTON_L1)) {
|
||||
|
@ -507,10 +514,12 @@ public class GL2JNIActivity extends Activity {
|
|||
}
|
||||
}
|
||||
|
||||
if (handle_key(playerNum, keyCode, true)) {
|
||||
if (playerNum == 0)
|
||||
JNIdc.hide_osd();
|
||||
return true;
|
||||
if (!pad.isActiveMoga[playerNum]) {
|
||||
if (handle_key(playerNum, keyCode, true)) {
|
||||
if (playerNum == 0)
|
||||
JNIdc.hide_osd();
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
if (keyCode == KeyEvent.KEYCODE_BUTTON_SELECT) {
|
||||
|
@ -530,7 +539,14 @@ public class GL2JNIActivity extends Activity {
|
|||
return showMenu();
|
||||
}
|
||||
}
|
||||
return super.onKeyDown(keyCode, event);
|
||||
if (!pad.isActiveMoga[playerNum]) {
|
||||
return super.onKeyDown(keyCode, event);
|
||||
} else if (keyCode == KeyEvent.KEYCODE_VOLUME_UP
|
||||
|| keyCode == KeyEvent.KEYCODE_VOLUME_DOWN) {
|
||||
return super.onKeyUp(keyCode, event);
|
||||
} else {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
private boolean showMenu() {
|
||||
|
|
|
@ -10,8 +10,6 @@ import java.io.InputStream;
|
|||
import java.io.InputStreamReader;
|
||||
|
||||
import android.content.Context;
|
||||
import android.net.ConnectivityManager;
|
||||
import android.net.NetworkInfo;
|
||||
import android.os.AsyncTask;
|
||||
import android.os.Build;
|
||||
import android.os.Handler;
|
||||
|
@ -40,7 +38,6 @@ public class GenerateLogs extends AsyncTask<String, Integer, String> {
|
|||
|
||||
private Context mContext;
|
||||
private String currentTime;
|
||||
private String debug_directory;
|
||||
|
||||
public GenerateLogs(Context mContext) {
|
||||
this.mContext = mContext;
|
||||
|
@ -121,8 +118,7 @@ public class GenerateLogs extends AsyncTask<String, Integer, String> {
|
|||
|
||||
@Override
|
||||
protected String doInBackground(String... params) {
|
||||
debug_directory = params[0];
|
||||
File logFile = new File(debug_directory, currentTime + ".txt");
|
||||
File logFile = new File(params[0], currentTime + ".txt");
|
||||
Process mLogcatProc = null;
|
||||
BufferedReader reader = null;
|
||||
final StringBuilder log = new StringBuilder();
|
||||
|
@ -235,46 +231,17 @@ public class GenerateLogs extends AsyncTask<String, Integer, String> {
|
|||
@Override
|
||||
protected void onPostExecute(final String response) {
|
||||
if (response != null && !response.equals(null)) {
|
||||
if (isNetworkAvailable(false)) {
|
||||
Toast.makeText(mContext, mContext.getString(R.string.platform),
|
||||
Toast.LENGTH_SHORT).show();
|
||||
UploadLogs mUploadLogs = new UploadLogs(mContext, currentTime);
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
|
||||
mUploadLogs.executeOnExecutor(
|
||||
AsyncTask.THREAD_POOL_EXECUTOR, response);
|
||||
} else {
|
||||
mUploadLogs.execute(response);
|
||||
}
|
||||
Toast.makeText(mContext, mContext.getString(R.string.log_saved),
|
||||
Toast.LENGTH_SHORT).show();
|
||||
Toast.makeText(mContext, mContext.getString(R.string.platform),
|
||||
Toast.LENGTH_SHORT).show();
|
||||
UploadLogs mUploadLogs = new UploadLogs(mContext, currentTime);
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
|
||||
mUploadLogs.executeOnExecutor(
|
||||
AsyncTask.THREAD_POOL_EXECUTOR, response);
|
||||
} else {
|
||||
Toast.makeText(
|
||||
mContext,
|
||||
mContext.getString(R.string.log_saved, debug_directory),
|
||||
Toast.LENGTH_SHORT).show();
|
||||
mUploadLogs.execute(response);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Check for network connectivity, either wifi or any
|
||||
*
|
||||
* @param boolean
|
||||
* Whether to consider all data or just wifi
|
||||
*/
|
||||
public boolean isNetworkAvailable(boolean wifi_only) {
|
||||
ConnectivityManager connectivityManager = (ConnectivityManager) mContext
|
||||
.getSystemService(Context.CONNECTIVITY_SERVICE);
|
||||
NetworkInfo activeNetworkInfo = connectivityManager
|
||||
.getActiveNetworkInfo();
|
||||
if (wifi_only) {
|
||||
return activeNetworkInfo != null
|
||||
/*
|
||||
* && activeNetworkInfo.getType() ==
|
||||
* ConnectivityManager.TYPE_WIFI
|
||||
*/
|
||||
&& connectivityManager.getNetworkInfo(
|
||||
ConnectivityManager.TYPE_WIFI).isConnected();
|
||||
} else {
|
||||
return activeNetworkInfo != null && activeNetworkInfo.isConnected();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -43,6 +43,20 @@ public class UploadLogs extends AsyncTask<String, Integer, Object> {
|
|||
this.mContext = mContext;
|
||||
this.currentTime = currentTime;
|
||||
}
|
||||
|
||||
private void RedirectSubmission(Header[] headers, String content) {
|
||||
UploadLogs mUploadLogs = new UploadLogs(mContext,
|
||||
currentTime);
|
||||
mUploadLogs.setPostUrl(headers[headers.length - 1]
|
||||
.getValue());
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
|
||||
mUploadLogs.executeOnExecutor(
|
||||
AsyncTask.THREAD_POOL_EXECUTOR, content);
|
||||
} else {
|
||||
mUploadLogs.execute(content);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the URL for where the log will be uploaded
|
||||
*
|
||||
|
@ -79,16 +93,7 @@ public class UploadLogs extends AsyncTask<String, Integer, Object> {
|
|||
if (statusCode != HttpStatus.SC_OK) {
|
||||
Header[] headers = getResponse.getHeaders("Location");
|
||||
if (headers != null && headers.length != 0) {
|
||||
UploadLogs mUploadLogs = new UploadLogs(mContext,
|
||||
currentTime);
|
||||
mUploadLogs.setPostUrl(headers[headers.length - 1]
|
||||
.getValue());
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
|
||||
mUploadLogs.executeOnExecutor(
|
||||
AsyncTask.THREAD_POOL_EXECUTOR, params[0]);
|
||||
} else {
|
||||
mUploadLogs.execute(params[0]);
|
||||
}
|
||||
RedirectSubmission(headers, params[0]);
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
|
|
|
@ -26,7 +26,7 @@ import com.reicast.emulator.periph.VmuLcd;
|
|||
|
||||
public class OnScreenMenu {
|
||||
|
||||
private Context mContext;
|
||||
private Activity mContext;
|
||||
private SharedPreferences prefs;
|
||||
private LinearLayout hlay;
|
||||
private LayoutParams params;
|
||||
|
@ -38,7 +38,7 @@ public class OnScreenMenu {
|
|||
private File sdcard = Environment.getExternalStorageDirectory();
|
||||
private String home_directory = sdcard + "/dc";
|
||||
|
||||
public OnScreenMenu(Context context, SharedPreferences prefs) {
|
||||
public OnScreenMenu(Activity context, SharedPreferences prefs) {
|
||||
if (context instanceof GL2JNIActivity) {
|
||||
this.mContext = (GL2JNIActivity) context;
|
||||
}
|
||||
|
@ -61,7 +61,6 @@ public class OnScreenMenu {
|
|||
if (mContext instanceof GL2JNIActivity) {
|
||||
((GL2JNIActivity) mContext).displayDebug(new DebugPopup(mContext));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public class FpsPopup extends PopupWindow {
|
||||
|
@ -84,6 +83,15 @@ public class OnScreenMenu {
|
|||
}
|
||||
}
|
||||
|
||||
private void removePopUp(PopupWindow window) {
|
||||
window.dismiss();
|
||||
popups.remove(window);
|
||||
if (mContext instanceof GL2JNIActivity) {
|
||||
((GL2JNIActivity) mContext)
|
||||
.displayPopUp(((GL2JNIActivity) OnScreenMenu.this.mContext).popUp);
|
||||
}
|
||||
}
|
||||
|
||||
public class DebugPopup extends PopupWindow {
|
||||
|
||||
public DebugPopup(Context c) {
|
||||
|
@ -98,12 +106,7 @@ public class OnScreenMenu {
|
|||
|
||||
hlay.addView(addbut(R.drawable.up, new OnClickListener() {
|
||||
public void onClick(View v) {
|
||||
popups.remove(this);
|
||||
dismiss();
|
||||
if (mContext instanceof GL2JNIActivity) {
|
||||
((GL2JNIActivity) mContext)
|
||||
.displayPopUp(((GL2JNIActivity) OnScreenMenu.this.mContext).popUp);
|
||||
}
|
||||
removePopUp(DebugPopup.this);
|
||||
}
|
||||
}), debugParams);
|
||||
|
||||
|
@ -137,7 +140,7 @@ public class OnScreenMenu {
|
|||
|
||||
hlay.addView(addbut(R.drawable.close, new OnClickListener() {
|
||||
public void onClick(View v) {
|
||||
popups.remove(this);
|
||||
popups.remove(DebugPopup.this);
|
||||
dismiss();
|
||||
}
|
||||
}), debugParams);
|
||||
|
@ -178,12 +181,7 @@ public class OnScreenMenu {
|
|||
|
||||
hlay.addView(addbut(R.drawable.up, new OnClickListener() {
|
||||
public void onClick(View v) {
|
||||
popups.remove(this);
|
||||
dismiss();
|
||||
if (mContext instanceof GL2JNIActivity) {
|
||||
((GL2JNIActivity) mContext)
|
||||
.displayPopUp(((GL2JNIActivity) OnScreenMenu.this.mContext).popUp);
|
||||
}
|
||||
removePopUp(ConfigPopup.this);
|
||||
}
|
||||
}), configParams);
|
||||
|
||||
|
@ -284,7 +282,7 @@ public class OnScreenMenu {
|
|||
|
||||
hlay.addView(addbut(R.drawable.close, new OnClickListener() {
|
||||
public void onClick(View v) {
|
||||
popups.remove(this);
|
||||
popups.remove(ConfigPopup.this);
|
||||
dismiss();
|
||||
}
|
||||
}), configParams);
|
||||
|
|
|
@ -21,6 +21,7 @@ public class Gamepad {
|
|||
public int[] name = { -1, -1, -1, -1 };
|
||||
public float[] globalLS_X = new float[4], globalLS_Y = new float[4],
|
||||
previousLS_X = new float[4], previousLS_Y = new float[4];
|
||||
public boolean[] wasKeyStick = { false, false, false, false };
|
||||
public int map[][] = new int[4][];
|
||||
|
||||
public SparseArray<String> deviceId_deviceDescriptor = new SparseArray<String>();
|
||||
|
|
|
@ -3,13 +3,14 @@ package com.reicast.emulator.periph;
|
|||
|
||||
/******************************************************************************/
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Arrays;
|
||||
|
||||
import tv.ouya.console.api.OuyaController;
|
||||
import android.app.Activity;
|
||||
import android.content.SharedPreferences;
|
||||
import android.os.Build;
|
||||
import android.os.Handler;
|
||||
import android.preference.PreferenceManager;
|
||||
import android.util.SparseArray;
|
||||
import android.widget.Toast;
|
||||
|
||||
import com.bda.controller.Controller;
|
||||
|
@ -17,6 +18,7 @@ import com.bda.controller.ControllerListener;
|
|||
import com.bda.controller.KeyEvent;
|
||||
import com.bda.controller.MotionEvent;
|
||||
import com.bda.controller.StateEvent;
|
||||
import com.reicast.emulator.GL2JNIActivity;
|
||||
import com.reicast.emulator.R;
|
||||
import com.reicast.emulator.emu.GL2JNIView;
|
||||
import com.reicast.emulator.emu.JNIdc;
|
||||
|
@ -133,83 +135,100 @@ public class MOGAInput
|
|||
{
|
||||
public void onKeyEvent(KeyEvent event)
|
||||
{
|
||||
Integer playerNum = pad.deviceDescriptor_PlayerNum.get(pad.deviceId_deviceDescriptor.get(event.getControllerId()));
|
||||
|
||||
if (playerNum == null)
|
||||
Integer playerNum = Arrays.asList(pad.name).indexOf(event.getControllerId());
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.GINGERBREAD && playerNum == -1) {
|
||||
playerNum = pad.deviceDescriptor_PlayerNum
|
||||
.get(pad.deviceId_deviceDescriptor.get(event.getControllerId()));
|
||||
} else {
|
||||
playerNum = -1;
|
||||
}
|
||||
if (playerNum == null || playerNum == -1)
|
||||
return;
|
||||
|
||||
String id = pad.portId[playerNum];
|
||||
if (pad.custom[playerNum]) {
|
||||
if (event.getKeyCode() == prefs.getInt("l_button" + id, KeyEvent.KEYCODE_BUTTON_L1)) {
|
||||
if (playerNum != null && playerNum != -1) {
|
||||
String id = pad.portId[playerNum];
|
||||
if (event.getAction() == KeyEvent.ACTION_DOWN) {
|
||||
if (event.getKeyCode() == prefs.getInt("l_button" + id, KeyEvent.KEYCODE_BUTTON_L1)) {
|
||||
simulatedTouchEvent(playerNum, 1.0f, 0.0f);
|
||||
simulatedTouchEvent(playerNum, 0.0f, 0.0f);
|
||||
}
|
||||
if (event.getKeyCode() == prefs.getInt("r_button" + id, KeyEvent.KEYCODE_BUTTON_R1)) {
|
||||
} else if (event.getKeyCode() == prefs.getInt("r_button" + id, KeyEvent.KEYCODE_BUTTON_R1)) {
|
||||
simulatedTouchEvent(playerNum, 0.0f, 1.0f);
|
||||
simulatedTouchEvent(playerNum, 0.0f, 0.0f);
|
||||
} else if (((GL2JNIActivity) act).handle_key(playerNum, event.getKeyCode(), true)) {
|
||||
if (playerNum == 0)
|
||||
JNIdc.hide_osd();
|
||||
}
|
||||
}
|
||||
if (event.getAction() == KeyEvent.ACTION_UP) {
|
||||
if (event.getKeyCode() == prefs.getInt("l_button" + id,
|
||||
KeyEvent.KEYCODE_BUTTON_L1)
|
||||
|| event.getKeyCode() == prefs.getInt("r_button" + id,
|
||||
KeyEvent.KEYCODE_BUTTON_R1)) {
|
||||
simulatedTouchEvent(playerNum, 0.0f, 0.0f);
|
||||
} else {
|
||||
((GL2JNIActivity) act).handle_key(playerNum, event.getKeyCode(), false);
|
||||
}
|
||||
}
|
||||
|
||||
if(playerNum == 0)
|
||||
JNIdc.hide_osd();
|
||||
|
||||
for (int i = 0; i < pad.map.length; i += 2) {
|
||||
if (pad.map[playerNum][i + 0] == event.getKeyCode()) {
|
||||
if (event.getAction() == 0) //FIXME to const
|
||||
GL2JNIView.kcode_raw[playerNum] &= ~pad.map[playerNum][i + 1];
|
||||
else
|
||||
GL2JNIView.kcode_raw[playerNum] |= pad.map[playerNum][i + 1];
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void simulatedTouchEvent(int playerNum, float L2, float R2) {
|
||||
if(playerNum == 0)
|
||||
JNIdc.hide_osd();
|
||||
pad.previousLS_X[playerNum] = pad.globalLS_X[playerNum];
|
||||
pad.previousLS_Y[playerNum] = pad.globalLS_Y[playerNum];
|
||||
pad.globalLS_X[playerNum] = 0;
|
||||
pad.globalLS_Y[playerNum] = 0;
|
||||
GL2JNIView.lt[playerNum] = (int) (L2 * 255);
|
||||
GL2JNIView.rt[playerNum] = (int) (R2 * 255);
|
||||
GL2JNIView.jx[playerNum] = (int) (0 * 126);
|
||||
GL2JNIView.jy[playerNum] = (int) (0 * 126);
|
||||
}
|
||||
|
||||
public void onMotionEvent(MotionEvent event)
|
||||
{
|
||||
Integer playerNum = pad.deviceDescriptor_PlayerNum.get(pad.deviceId_deviceDescriptor.get(event.getControllerId()));
|
||||
|
||||
if (playerNum == null)
|
||||
Integer playerNum = Arrays.asList(pad.name).indexOf(event.getControllerId());
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.GINGERBREAD && playerNum == -1) {
|
||||
playerNum = pad.deviceDescriptor_PlayerNum
|
||||
.get(pad.deviceId_deviceDescriptor.get(event.getControllerId()));
|
||||
} else {
|
||||
playerNum = -1;
|
||||
}
|
||||
if (playerNum == null || playerNum == -1)
|
||||
return;
|
||||
if (!pad.compat[playerNum]) {
|
||||
// Joystick
|
||||
// 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(playerNum == 0)
|
||||
JNIdc.hide_osd();
|
||||
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;
|
||||
|
||||
float S_X = event.getAxisValue(MotionEvent.AXIS_X);
|
||||
float S_Y = event.getAxisValue(MotionEvent.AXIS_Y);
|
||||
float L2 = event.getAxisValue(MotionEvent.AXIS_LTRIGGER);
|
||||
float R2 = event.getAxisValue(MotionEvent.AXIS_RTRIGGER);
|
||||
GL2JNIView.lt[playerNum] = (int) (L2 * 255);
|
||||
GL2JNIView.rt[playerNum] = (int) (R2 * 255);
|
||||
|
||||
pad.previousLS_X[playerNum] = pad.globalLS_X[playerNum];
|
||||
pad.previousLS_Y[playerNum] = pad.globalLS_Y[playerNum];
|
||||
pad.globalLS_X[playerNum] = S_X;
|
||||
pad.globalLS_Y[playerNum] = S_Y;
|
||||
GL2JNIView.jx[playerNum] = (int) (LS_X * 126);
|
||||
GL2JNIView.jy[playerNum] = (int) (LS_Y * 126);
|
||||
|
||||
if (prefs.getBoolean("right_buttons", true)) {
|
||||
if (RS_Y > 0.5) {
|
||||
((GL2JNIActivity) act).handle_key(playerNum, pad.map[playerNum][0]/* A */, true);
|
||||
pad.wasKeyStick[playerNum] = true;
|
||||
} else if (RS_Y < 0.5) {
|
||||
((GL2JNIActivity) act).handle_key(playerNum, pad.map[playerNum][1]/* B */, true);
|
||||
pad.wasKeyStick[playerNum] = true;
|
||||
} else if (pad.wasKeyStick[playerNum]){
|
||||
((GL2JNIActivity) act).handle_key(playerNum, pad.map[playerNum][0], false);
|
||||
((GL2JNIActivity) act).handle_key(playerNum, pad.map[playerNum][1], false);
|
||||
pad.wasKeyStick[playerNum] = false;
|
||||
}
|
||||
} else {
|
||||
if (RS_Y > 0.5) {
|
||||
GL2JNIView.rt[playerNum] = (int) (RS_Y * 255);
|
||||
} else if (RS_Y < 0.5) {
|
||||
GL2JNIView.lt[playerNum] = (int) (-(RS_Y) * 255);
|
||||
}
|
||||
}
|
||||
((GL2JNIActivity) act).getGameView().pushInput();
|
||||
}
|
||||
}
|
||||
|
||||
public boolean simulatedTouchEvent(int playerNum, float L2, float R2) {
|
||||
GL2JNIView.lt[playerNum] = (int) (L2 * 255);
|
||||
GL2JNIView.rt[playerNum] = (int) (R2 * 255);
|
||||
|
||||
GL2JNIView.jx[playerNum] = (int) (S_X * 126);
|
||||
GL2JNIView.jy[playerNum] = (int) (S_Y * 126);
|
||||
|
||||
/*
|
||||
for(final Entry<Integer, ExampleFloat> entry : mMotions.entrySet())
|
||||
{
|
||||
final int key = entry.getKey();
|
||||
final ExampleFloat value = entry.getValue();
|
||||
value.mValue = event.getAxisValue(key);
|
||||
}*/
|
||||
((GL2JNIActivity) act).getGameView().pushInput();
|
||||
return true;
|
||||
}
|
||||
|
||||
public void onStateEvent(StateEvent event)
|
||||
|
|
Loading…
Reference in New Issue