Fix return intent from games, Fix touchscreen in native mode

This commit is contained in:
TwistedUmbrella 2014-04-04 01:12:07 -04:00
parent 0ba8350c3a
commit 014daafa2a
4 changed files with 30 additions and 22 deletions

View File

@ -50,7 +50,8 @@ static jobject g_pActivity = 0;
static jmethodID javaOnNDKTouch = 0;
static jmethodID javaOnNDKKey = 0;
int target;
//int target;
static bool isXperiaPlay;
/**
* Our saved state data.
@ -146,12 +147,14 @@ engine_handle_input( struct android_app* app, AInputEvent* event )
touchstate[nPointerId].x = AMotionEvent_getX( event, n );
touchstate[nPointerId].y = AMotionEvent_getY( event, n );
}
if( jni && g_pActivity && device == target ) {
//if( jni && g_pActivity && device == target ) {
if( jni && g_pActivity && isXperiaPlay) {
(*jni)->CallVoidMethod( jni, g_pActivity, javaOnNDKTouch, device, nSourceId, nRawAction, touchstate[nPointerId].x, touchstate[nPointerId].y, newTouch);
}
newTouch = JNI_FALSE;
}
if( device == target ) {
// if( device == target ) {
if( isXperiaPlay ) {
return 1;
} else {
return 0;
@ -225,6 +228,8 @@ android_main( struct android_app* state )
//JNIEnv *env;
//(*jVM)->AttachCurrentThread(jVM, &env, NULL);
isXperiaPlay = IsXperiaPlay();
if( state->savedState != NULL )
{
// We are starting with a previous saved state; restore from it.
@ -262,10 +267,10 @@ void EXPORT_XPLAY JNICALL Java_com_reicast_emulator_GL2JNINative_registerNative(
{
g_pActivity = (jobject)(*env)->NewGlobalRef(env, clazz);
}
void EXPORT_XPLAY JNICALL Java_com_reicast_emulator_GL2JNINative_registerXperia(JNIEnv *env, jobject clazz, jint xperia)
{
target = xperia;
}
//void EXPORT_XPLAY JNICALL Java_com_reicast_emulator_GL2JNINative_registerXperia(JNIEnv *env, jobject clazz, jint xperia)
//{
// target = xperia;
//}
jint EXPORT_XPLAY JNICALL JNI_OnLoad(JavaVM * vm, void * reserved)
{
JNIEnv *env;

View File

@ -56,7 +56,7 @@ public class GL2JNINative extends NativeActivity {
}
public native void registerNative();
public native void registerXperia(int xperia);
// public native void registerXperia(int xperia);
@TargetApi(Build.VERSION_CODES.JELLY_BEAN)
@Override
@ -142,12 +142,12 @@ public class GL2JNINative extends NativeActivity {
if (pad.isXperiaPlay) {
if (InputDevice.getDevice(joy).getName()
.contains(Gamepad.controllers_play_gp)) {
pad.keypadZeus.add(joy);
pad.keypadZeus[0] = joy;
}
if (InputDevice.getDevice(joy).getName()
.contains("synaptics_touchpad")) {
registerXperia(joy);
pad.keypadZeus.add(joy);
.contains(Gamepad.controllers_play_tp)) {
// registerXperia(joy);
pad.keypadZeus[1] = joy;
}
}
Log.d("reidc", "InputDevice Descriptor: " + descriptor);
@ -515,12 +515,12 @@ public class GL2JNINative extends NativeActivity {
return false;
}
public boolean OnNativeMotion(int device, int source, int action, int x, int y, boolean newEvent) {
if (newEvent && source == Gamepad.Xperia_Touchpad) {
// Source is Xperia Play touchpad
Integer playerNum = pad.playerNumX.get(device);
if (playerNum != null && playerNum != -1) {
Log.d("reidc", playerNum + " - " + device + ": " + source);
public boolean OnNativeMotion(int device, int source, int action, int x,
int y, boolean newEvent) {
Integer playerNum = pad.playerNumX.get(device);
if (playerNum != null && playerNum != -1) {
Log.d("reidc", playerNum + " - " + device + ": " + source);
if (newEvent && source == Gamepad.Xperia_Touchpad) {
if (action == MotionEvent.ACTION_UP) {
x = 0;
y = 0;
@ -532,7 +532,7 @@ public class GL2JNINative extends NativeActivity {
x = 640;
}
if (x >= 640) {
x = x - 640;
x = x - 640;
}
y = 366 - y;
// Right stick is an extension of left stick

View File

@ -111,8 +111,10 @@ public class MainActivity extends SlidingFragmentActivity implements
// When viewing a resource, pass its URI to the native code for opening
Intent intent = getIntent();
if (intent.getAction().equals(Intent.ACTION_VIEW))
onGameSelected(Uri.parse(intent.getData().toString()));
if (intent.getAction() != null) {
if (intent.getAction().equals(Intent.ACTION_VIEW))
onGameSelected(Uri.parse(intent.getData().toString()));
}
// Check that the activity is using the layout version with
// the fragment_container FrameLayout

View File

@ -47,6 +47,7 @@ public class Gamepad {
public static final String controllers_shield = "NVIDIA Corporation NVIDIA Controller";
public static final String controllers_play = "keypad-zeus";
public static final String controllers_play_gp = "keypad-game-zeus";
public static final String controllers_play_tp = "synaptics_touchpad";
public String[] portId = { "_A", "_B", "_C", "_D" };
public boolean[] compat = { false, false, false, false };
@ -65,7 +66,7 @@ public class Gamepad {
public boolean isMogaPro[] = { false, false, false, false };
public SparseArray<Integer> playerNumX = new SparseArray<Integer>();
public List<Integer> keypadZeus = new ArrayList<Integer>();
public int[] keypadZeus = new int[2];
public boolean isXperiaPlay;
public boolean isOuyaOrTV;