Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
Libretro
flycast
Commits
a7530724
Commit
a7530724
authored
Feb 26, 2014
by
TwistedUmbrella
Browse files
Begin merging in NativeActive and compatibility fallback - r7
parent
f670a397
Changes
12
Expand all
Hide whitespace changes
Inline
Side-by-side
README.md
View file @
a7530724
...
...
@@ -25,8 +25,17 @@ Tools required:
From project root directory:
```
cd shell\android
android update project -p .
cd shell\android\xperia
rm -rf libs
android update project -p . --target "android-9"
ndk-build -j4
cd ..\
android update project -p . --target "android-19"
ant debug
```
...
...
shell/android/jni/Application.mk
View file @
a7530724
APP_STL
:=
stlport_static
APP_ABI
:=
armeabi-v7a
APP_PLATFORM
:=
android-18
NDK_TOOLCHAIN_VERSION
:=
4.8
\ No newline at end of file
shell/android/jni/src/Android.cpp
View file @
a7530724
...
...
@@ -56,7 +56,7 @@ extern "C"
JNIEXPORT
void
JNICALL
Java_com_reicast_emulator_emu_JNIdc_frameskip
(
JNIEnv
*
env
,
jobject
obj
,
jint
frames
)
__attribute__
((
visibility
(
"default"
)));
JNIEXPORT
void
JNICALL
Java_com_reicast_emulator_emu_JNIdc_pvrrender
(
JNIEnv
*
env
,
jobject
obj
,
jint
render
)
__attribute__
((
visibility
(
"default"
)));
JNIEXPORT
void
JNICALL
Java_com_reicast_emulator_emu_JNIdc_cheatdisk
(
JNIEnv
*
env
,
jobject
obj
,
jstring
disk
)
__attribute__
((
visibility
(
"default"
)));
JNIEXPORT
void
JNICALL
Java_com_reicast_emulator_emu_JNIdc_dreamtime
(
JNIEnv
*
env
,
jobject
obj
,
u32
clock
)
__attribute__
((
visibility
(
"default"
)));
JNIEXPORT
void
JNICALL
Java_com_reicast_emulator_emu_JNIdc_dreamtime
(
JNIEnv
*
env
,
jobject
obj
,
jlong
clock
)
__attribute__
((
visibility
(
"default"
)));
};
JNIEXPORT
void
JNICALL
Java_com_reicast_emulator_emu_JNIdc_dynarec
(
JNIEnv
*
env
,
jobject
obj
,
jint
dynarec
)
...
...
@@ -129,9 +129,9 @@ JNIEXPORT void JNICALL Java_com_reicast_emulator_emu_JNIdc_cheatdisk(JNIEnv *env
}
JNIEXPORT
void
JNICALL
Java_com_reicast_emulator_emu_JNIdc_dreamtime
(
JNIEnv
*
env
,
jobject
obj
,
u32
clock
)
JNIEXPORT
void
JNICALL
Java_com_reicast_emulator_emu_JNIdc_dreamtime
(
JNIEnv
*
env
,
jobject
obj
,
jlong
clock
)
{
settings
.
dreamcast
.
RTC
=
clock
;
settings
.
dreamcast
.
RTC
=
(
u32
)(
clock
)
;
}
void
egl_stealcntx
();
...
...
shell/android/src/com/reicast/emulator/GL2JNINative.java
0 → 100644
View file @
a7530724
This diff is collapsed.
Click to expand it.
shell/android/src/com/reicast/emulator/MainActivity.java
View file @
a7530724
...
...
@@ -64,21 +64,21 @@ public class MainActivity extends SlidingFragmentActivity implements
mUEHandler
=
new
Thread
.
UncaughtExceptionHandler
()
{
public
void
uncaughtException
(
Thread
t
,
Throwable
error
)
{
if
(
error
!=
null
)
{
StringBuilder
output
=
new
StringBuilder
();
output
.
append
(
"Thread:\n"
);
for
(
StackTraceElement
trace
:
t
.
getStackTrace
())
{
output
.
append
(
trace
.
toString
()
+
" "
);
}
output
.
append
(
"\n\nError:\n"
);
for
(
StackTraceElement
trace
:
error
.
getStackTrace
())
{
output
.
append
(
trace
.
toString
()
+
" "
);
if
(
error
!=
null
)
{
StringBuilder
output
=
new
StringBuilder
();
output
.
append
(
"Thread:\n"
);
for
(
StackTraceElement
trace
:
t
.
getStackTrace
())
{
output
.
append
(
trace
.
toString
()
+
"\n"
);
}
output
.
append
(
"\nError:\n"
);
for
(
StackTraceElement
trace
:
error
.
getStackTrace
())
{
output
.
append
(
trace
.
toString
()
+
"\n"
);
}
String
log
=
output
.
toString
();
mPrefs
.
edit
().
putString
(
"prior_error"
,
log
).
commit
();
error
.
printStackTrace
();
MainActivity
.
this
.
finish
();
}
String
log
=
output
.
toString
();
mPrefs
.
edit
().
putString
(
"prior_error"
,
log
).
commit
();
error
.
printStackTrace
();
MainActivity
.
this
.
finish
();
}
}
};
Thread
.
setDefaultUncaughtExceptionHandler
(
mUEHandler
);
...
...
@@ -292,10 +292,8 @@ public class MainActivity extends SlidingFragmentActivity implements
/**
* Display a dialog to notify the user of prior crash
*
* @param
string
* @param
error
* A generalized summary of the crash cause
* @param bundle
* The savedInstanceState passed from onCreate
*/
private
void
initiateReport
(
final
String
error
)
{
AlertDialog
.
Builder
builder
=
new
AlertDialog
.
Builder
(
MainActivity
.
this
);
...
...
@@ -407,9 +405,13 @@ public class MainActivity extends SlidingFragmentActivity implements
// show it
alertDialog
.
show
();
}
else
{
Intent
inte
=
new
Intent
(
Intent
.
ACTION_VIEW
,
uri
,
getBaseContext
(),
GL2JNIActivity
.
class
);
startActivity
(
inte
);
if
(
Build
.
VERSION
.
SDK_INT
>=
Build
.
VERSION_CODES
.
GINGERBREAD
)
{
startActivity
(
new
Intent
(
Intent
.
ACTION_VIEW
,
uri
,
getBaseContext
(),
GL2JNINative
.
class
));
}
else
{
startActivity
(
new
Intent
(
Intent
.
ACTION_VIEW
,
uri
,
getBaseContext
(),
GL2JNIActivity
.
class
));
}
}
}
...
...
shell/android/src/com/reicast/emulator/emu/GL2JNIView.java
View file @
a7530724
...
...
@@ -28,6 +28,7 @@ import android.view.ScaleGestureDetector.SimpleOnScaleGestureListener;
import
android.view.View
;
import
com.reicast.emulator.GL2JNIActivity
;
import
com.reicast.emulator.GL2JNINative
;
import
com.reicast.emulator.config.Config
;
import
com.reicast.emulator.emu.OnScreenMenu.FpsPopup
;
import
com.reicast.emulator.periph.VJoy
;
...
...
@@ -169,8 +170,13 @@ public class GL2JNIView extends GLSurfaceView
// This is the game we are going to run
fileName
=
newFileName
;
if
(
GL2JNIActivity
.
syms
!=
null
)
JNIdc
.
data
(
1
,
GL2JNIActivity
.
syms
);
if
(
Build
.
VERSION
.
SDK_INT
>=
Build
.
VERSION_CODES
.
GINGERBREAD
)
{
if
(
GL2JNINative
.
syms
!=
null
)
JNIdc
.
data
(
1
,
GL2JNINative
.
syms
);
}
else
{
if
(
GL2JNIActivity
.
syms
!=
null
)
JNIdc
.
data
(
1
,
GL2JNIActivity
.
syms
);
}
JNIdc
.
init
(
fileName
);
...
...
shell/android/src/com/reicast/emulator/emu/OnScreenMenu.java
View file @
a7530724
...
...
@@ -19,6 +19,7 @@ import android.widget.PopupWindow;
import
android.widget.TextView
;
import
com.reicast.emulator.GL2JNIActivity
;
import
com.reicast.emulator.GL2JNINative
;
import
com.reicast.emulator.MainActivity
;
import
com.reicast.emulator.R
;
import
com.reicast.emulator.config.Config
;
...
...
@@ -46,6 +47,9 @@ public class OnScreenMenu {
private
boolean
boosted
=
false
;
public
OnScreenMenu
(
Activity
context
,
SharedPreferences
prefs
)
{
if
(
context
instanceof
GL2JNINative
)
{
this
.
mContext
=
(
GL2JNINative
)
context
;
}
if
(
context
instanceof
GL2JNIActivity
)
{
this
.
mContext
=
(
GL2JNIActivity
)
context
;
}
...
...
@@ -59,6 +63,9 @@ public class OnScreenMenu {
vmuLcd
=
new
VmuLcd
(
mContext
);
vmuLcd
.
setOnClickListener
(
new
OnClickListener
()
{
public
void
onClick
(
View
v
)
{
if
(
mContext
instanceof
GL2JNINative
)
{
((
GL2JNINative
)
OnScreenMenu
.
this
.
mContext
).
toggleVmu
();
}
if
(
mContext
instanceof
GL2JNIActivity
)
{
((
GL2JNIActivity
)
OnScreenMenu
.
this
.
mContext
).
toggleVmu
();
}
...
...
@@ -67,9 +74,13 @@ public class OnScreenMenu {
}
void
displayDebugPopup
(
final
PopupWindow
popUp
)
{
if
(
mContext
instanceof
GL2JNINative
)
{
((
GL2JNINative
)
mContext
).
displayDebug
(
new
DebugPopup
(
mContext
));
}
if
(
mContext
instanceof
GL2JNIActivity
)
{
((
GL2JNIActivity
)
mContext
).
displayDebug
(
new
DebugPopup
(
mContext
));
}
}
public
class
FpsPopup
extends
PopupWindow
{
...
...
@@ -95,6 +106,10 @@ public class OnScreenMenu {
private
void
removePopUp
(
PopupWindow
window
)
{
window
.
dismiss
();
popups
.
remove
(
window
);
if
(
mContext
instanceof
GL2JNINative
)
{
((
GL2JNINative
)
mContext
)
.
displayPopUp
(((
GL2JNINative
)
OnScreenMenu
.
this
.
mContext
).
popUp
);
}
if
(
mContext
instanceof
GL2JNIActivity
)
{
((
GL2JNIActivity
)
mContext
)
.
displayPopUp
(((
GL2JNIActivity
)
OnScreenMenu
.
this
.
mContext
).
popUp
);
...
...
@@ -160,6 +175,9 @@ public class OnScreenMenu {
}
void
displayConfigPopup
(
final
PopupWindow
popUp
)
{
if
(
mContext
instanceof
GL2JNINative
)
{
((
GL2JNINative
)
mContext
).
displayConfig
(
new
ConfigPopup
(
mContext
));
}
if
(
mContext
instanceof
GL2JNIActivity
)
{
((
GL2JNIActivity
)
mContext
)
.
displayConfig
(
new
ConfigPopup
(
mContext
));
...
...
@@ -262,21 +280,29 @@ public class OnScreenMenu {
new
OnClickListener
()
{
public
void
onClick
(
View
v
)
{
if
(
audio
)
{
if
(
mContext
instanceof
GL2JNINative
)
{
((
GL2JNINative
)
mContext
).
mView
.
audioDisable
(
true
);
}
if
(
mContext
instanceof
GL2JNIActivity
)
{
((
GL2JNIActivity
)
mContext
).
mView
.
audioDisable
(
true
);
}
audio
=
false
;
((
ImageButton
)
audiosetting
)
.
setImageResource
(
R
.
drawable
.
enable_sound
);
audio
=
false
;
}
else
{
if
(
mContext
instanceof
GL2JNINative
)
{
((
GL2JNINative
)
mContext
).
mView
.
audioDisable
(
false
);
}
if
(
mContext
instanceof
GL2JNIActivity
)
{
((
GL2JNIActivity
)
mContext
).
mView
.
audioDisable
(
false
);
}
audio
=
true
;
((
ImageButton
)
audiosetting
)
.
setImageResource
(
R
.
drawable
.
mute_sound
);
audio
=
true
;
}
}
});
...
...
@@ -292,6 +318,10 @@ public class OnScreenMenu {
fastforward
=
addbut
(
R
.
drawable
.
star
,
new
OnClickListener
()
{
public
void
onClick
(
View
v
)
{
if
(
boosted
)
{
if
(
mContext
instanceof
GL2JNINative
)
{
((
GL2JNINative
)
mContext
).
mView
.
audioDisable
(!
audio
);
}
if
(
mContext
instanceof
GL2JNIActivity
)
{
((
GL2JNIActivity
)
mContext
).
mView
.
audioDisable
(!
audio
);
...
...
@@ -301,6 +331,9 @@ public class OnScreenMenu {
framelimit
.
setEnabled
(
true
);
JNIdc
.
frameskip
(
frames
);
enableState
(
fdown
,
fup
);
if
(
mContext
instanceof
GL2JNINative
)
{
((
GL2JNINative
)
mContext
).
mView
.
fastForward
(
false
);
}
if
(
mContext
instanceof
GL2JNIActivity
)
{
((
GL2JNIActivity
)
mContext
).
mView
.
fastForward
(
false
);
}
...
...
@@ -308,6 +341,10 @@ public class OnScreenMenu {
((
ImageButton
)
fastforward
)
.
setImageResource
(
R
.
drawable
.
star
);
}
else
{
if
(
mContext
instanceof
GL2JNINative
)
{
((
GL2JNINative
)
mContext
).
mView
.
audioDisable
(
true
);
}
if
(
mContext
instanceof
GL2JNIActivity
)
{
((
GL2JNIActivity
)
mContext
).
mView
.
audioDisable
(
true
);
...
...
@@ -318,6 +355,9 @@ public class OnScreenMenu {
JNIdc
.
frameskip
(
5
);
fdown
.
setEnabled
(
false
);
fup
.
setEnabled
(
false
);
if
(
mContext
instanceof
GL2JNINative
)
{
((
GL2JNINative
)
mContext
).
mView
.
fastForward
(
true
);
}
if
(
mContext
instanceof
GL2JNIActivity
)
{
((
GL2JNIActivity
)
mContext
).
mView
.
fastForward
(
true
);
}
...
...
shell/android/src/com/reicast/emulator/periph/Gamepad.java
View file @
a7530724
...
...
@@ -6,7 +6,6 @@ import java.util.List;
import
tv.ouya.console.api.OuyaController
;
import
tv.ouya.console.api.OuyaFacade
;
import
android.annotation.TargetApi
;
import
android.content.Context
;
import
android.content.SharedPreferences
;
import
android.content.pm.PackageManager
;
...
...
@@ -103,7 +102,6 @@ public class Gamepad {
};
}
@TargetApi
(
Build
.
VERSION_CODES
.
GINGERBREAD
)
public
int
[]
getMogaController
()
{
return
new
int
[]
{
KeyEvent
.
KEYCODE_BUTTON_A
,
key_CONT_A
,
...
...
shell/android/src/com/reicast/emulator/periph/SipEmulator.java
View file @
a7530724
...
...
@@ -98,8 +98,7 @@ public class SipEmulator extends Thread {
while
(
continueRecording
){
byte
[]
freshData
=
new
byte
[
ONE_BLIP_SIZE
];
// read blocks
int
bytesRead
=
record
.
read
(
freshData
,
0
,
ONE_BLIP_SIZE
);
//Log.d(TAG, "recordThread recorded: "+bytesRead);
record
.
read
(
freshData
,
0
,
ONE_BLIP_SIZE
);
if
(!
firstGet
){
bytesReadBuffer
.
add
(
freshData
);
}
...
...
shell/android/xperia/jni/Android.mk
0 → 100644
View file @
a7530724
LOCAL_PATH
:=
$(
call
my-dir
)
include
$(CLEAR_VARS)
LOCAL_MODULE
:=
sexplay
LOCAL_SRC_FILES
:=
XperiaPlay.c
LOCAL_LDLIBS
:=
-llog
-landroid
-lEGL
-lGLESv1_CM
LOCAL_STATIC_LIBRARIES
:=
android_native_app_glue
include
$(BUILD_SHARED_LIBRARY)
$(call
import-module,android/native_app_glue)
\ No newline at end of file
shell/android/xperia/jni/Application.mk
0 → 100644
View file @
a7530724
APP_ABI
:=
armeabi-v7a
APP_PLATFORM
:=
android-9
NDK_TOOLCHAIN_VERSION
:=
4.8
\ No newline at end of file
shell/android/xperia/jni/XperiaPlay.c
0 → 100755
View file @
a7530724
/*
* Copyright (c) 2011, Sony Ericsson Mobile Communications AB.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* * Neither the name of the Sony Ericsson Mobile Communications AB nor the
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
#include <dlfcn.h>
#include <stdio.h>
#include <stdbool.h>
#include <string.h>
#include <android/log.h>
#include <jni.h>
#include <errno.h>
#include <android_native_app_glue.h>
#include <time.h>
#include <unistd.h>
#include <sys/system_properties.h>
#define EXPORT_XPLAY __attribute__ ((visibility("default")))
static
JavaVM
*
jVM
;
typedef
unsigned
char
BOOL
;
#define FALSE 0
#define TRUE 1
static
jobject
g_pActivity
=
0
;
static
jmethodID
javaOnNDKTouch
=
0
;
static
jmethodID
javaOnNDKKey
=
0
;
int
target
;
/**
* Our saved state data.
*/
struct
TOUCHSTATE
{
int
down
;
int
x
;
int
y
;
};
/**
* Shared state for our app.
*/
struct
ENGINE
{
struct
android_app
*
app
;
int
render
;
int
width
;
int
height
;
int
has_focus
;
//ugly way to track touch states
struct
TOUCHSTATE
touchstate_screen
[
64
];
struct
TOUCHSTATE
touchstate_pad
[
64
];
};
void
attach
(){
}
/**
* Process the next input event.
*/
static
int32_t
engine_handle_input
(
struct
android_app
*
app
,
AInputEvent
*
event
)
{
JNIEnv
*
jni
;
(
*
jVM
)
->
AttachCurrentThread
(
jVM
,
&
jni
,
NULL
);
struct
ENGINE
*
engine
=
(
struct
ENGINE
*
)
app
->
userData
;
if
(
AInputEvent_getType
(
event
)
==
AINPUT_EVENT_TYPE_KEY
){
int
device
=
AInputEvent_getDeviceId
(
event
);
int
action
=
AKeyEvent_getAction
(
event
);
int
keyCode
=
AKeyEvent_getKeyCode
(
event
);
if
(
jni
&&
g_pActivity
){
if
((
*
jni
)
->
ExceptionCheck
(
jni
))
{
(
*
jni
)
->
ExceptionDescribe
(
jni
);
(
*
jni
)
->
ExceptionClear
(
jni
);
}
(
*
jni
)
->
CallIntMethod
(
jni
,
g_pActivity
,
javaOnNDKKey
,
device
,
keyCode
,
action
,
AKeyEvent_getMetaState
(
event
));
if
(
!
(
keyCode
==
AKEYCODE_MENU
||
keyCode
==
AKEYCODE_BACK
||
keyCode
==
AKEYCODE_BUTTON_THUMBR
||
keyCode
==
AKEYCODE_VOLUME_UP
||
keyCode
==
AKEYCODE_VOLUME_DOWN
||
keyCode
==
AKEYCODE_BUTTON_SELECT
))
{
return
1
;
}
}
}
else
if
(
AInputEvent_getType
(
event
)
==
AINPUT_EVENT_TYPE_MOTION
)
{
int
device
=
AInputEvent_getDeviceId
(
event
);
int
nSourceId
=
AInputEvent_getSource
(
event
);
int
nPointerCount
=
AMotionEvent_getPointerCount
(
event
);
int
n
;
jboolean
newTouch
=
JNI_TRUE
;
for
(
n
=
0
;
n
<
nPointerCount
;
++
n
)
{
int
nPointerId
=
AMotionEvent_getPointerId
(
event
,
n
);
int
nAction
=
AMOTION_EVENT_ACTION_MASK
&
AMotionEvent_getAction
(
event
);
int
nRawAction
=
AMotionEvent_getAction
(
event
);
struct
TOUCHSTATE
*
touchstate
=
0
;
if
(
nSourceId
==
AINPUT_SOURCE_TOUCHPAD
)
{
touchstate
=
engine
->
touchstate_pad
;
}
else
{
touchstate
=
engine
->
touchstate_screen
;
}
if
(
nAction
==
AMOTION_EVENT_ACTION_POINTER_DOWN
||
nAction
==
AMOTION_EVENT_ACTION_POINTER_UP
)
{
int
nPointerIndex
=
(
AMotionEvent_getAction
(
event
)
&
AMOTION_EVENT_ACTION_POINTER_INDEX_MASK
)
>>
AMOTION_EVENT_ACTION_POINTER_INDEX_SHIFT
;
nPointerId
=
AMotionEvent_getPointerId
(
event
,
nPointerIndex
);
}
if
(
nAction
==
AMOTION_EVENT_ACTION_DOWN
||
nAction
==
AMOTION_EVENT_ACTION_POINTER_DOWN
)
{
touchstate
[
nPointerId
].
down
=
1
;
}
else
if
(
nAction
==
AMOTION_EVENT_ACTION_UP
||
nAction
==
AMOTION_EVENT_ACTION_POINTER_UP
||
nAction
==
AMOTION_EVENT_ACTION_CANCEL
)
{
touchstate
[
nPointerId
].
down
=
0
;
}
if
(
touchstate
[
nPointerId
].
down
==
1
)
{
touchstate
[
nPointerId
].
x
=
AMotionEvent_getX
(
event
,
n
);
touchstate
[
nPointerId
].
y
=
AMotionEvent_getY
(
event
,
n
);
}
if
(
jni
&&
g_pActivity
&&
device
==
target
)
{
(
*
jni
)
->
CallVoidMethod
(
jni
,
g_pActivity
,
javaOnNDKTouch
,
device
,
nSourceId
,
nRawAction
,
touchstate
[
nPointerId
].
x
,
touchstate
[
nPointerId
].
y
,
newTouch
);
}
newTouch
=
JNI_FALSE
;
}
if
(
device
==
target
)
{
return
1
;
}
else
{
return
0
;
}
}
return
0
;
}
/**
* Process the next main command.
*/
static
void
engine_handle_cmd
(
struct
android_app
*
app
,
int32_t
cmd
)
{
struct
ENGINE
*
engine
=
(
struct
ENGINE
*
)
app
->
userData
;
switch
(
cmd
)
{
case
APP_CMD_SAVE_STATE
:
// The system has asked us to save our current state. Do so if needed
break
;
case
APP_CMD_INIT_WINDOW
:
// The window is being shown, get it ready.
if
(
engine
->
app
->
window
!=
NULL
)
{
engine
->
has_focus
=
1
;
}
break
;
case
APP_CMD_GAINED_FOCUS
:
engine
->
has_focus
=
1
;
break
;
case
APP_CMD_LOST_FOCUS
:
// When our app loses focus, we stop rendering.
engine
->
render
=
0
;
engine
->
has_focus
=
0
;
//engine_draw_frame( engine );
break
;
}
}
static
bool
IsXperiaPlay
()
{
char
mod
[
PROP_VALUE_MAX
+
1
];
int
lmod
=
__system_property_get
(
"ro.product.model"
,
mod
);
return
mod
==
"R800a"
||
mod
==
"R800i"
||
mod
==
"R800x"
||
mod
==
"R800at"
||
mod
==
"SO-01D"
||
mod
==
"zeus"
;
}
/**
* This is the main entry point of a native application that is using
* android_native_app_glue. It runs in its own thread, with its own
* event loop for receiving input events and doing other things (rendering).
*/
void
android_main
(
struct
android_app
*
state
)
{
struct
ENGINE
engine
;
// Make sure glue isn't stripped.
app_dummy
();
memset
(
&
engine
,
0
,
sizeof
(
engine
)
);
state
->
userData
=
&
engine
;
state
->
onAppCmd
=
engine_handle_cmd
;
state
->
onInputEvent
=
engine_handle_input
;
engine
.
app
=
state
;
//setup(state);
//JNIEnv *env;
//(*jVM)->AttachCurrentThread(jVM, &env, NULL);
if
(
state
->
savedState
!=
NULL
)
{
// We are starting with a previous saved state; restore from it.
}
// our 'main loop'
while
(
1
)
{
// Read all pending events.
int
ident
;
int
events
;
struct
android_poll_source
*
source
;
// If not rendering, we will block forever waiting for events.
// If rendering, we loop until all events are read, then continue
// to draw the next frame.
while
(
(
ident
=
ALooper_pollAll
(
250
,
NULL
,
&
events
,
(
void
**
)
&
source
)
)
>=
0
)
{
// Process this event.
// This will call the function pointer android_app:nInputEvent() which in our case is
// engine_handle_input()
if
(
source
!=
NULL
)
{
source
->
process
(
state
,
source
);
}
// Check if we are exiting.
if
(
state
->
destroyRequested
!=
0
)
{
return
;
}
//usleep(20000); //20 miliseconds
}
}
}
void
EXPORT_XPLAY
JNICALL
Java_com_reicast_emulator_GL2JNINative_registerNative
(
JNIEnv
*
env
,
jobject
clazz
)
{
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
;
}
jint
EXPORT_XPLAY
JNICALL
JNI_OnLoad
(
JavaVM
*
vm
,
void
*
reserved
)
{
JNIEnv
*
env
;
jVM
=
vm
;
if
((
*
vm
)
->
GetEnv
(
vm
,
(
void
**
)
&
env
,
JNI_VERSION_1_4
)
!=
JNI_OK
)
{
return
-
1
;
}
const
char
*
interface_path
=
"com/reicast/emulator/GL2JNINative"
;
jclass
java_activity_class
=
(
*
env
)
->
FindClass
(
env
,
interface_path
);
javaOnNDKTouch
=
(
*
env
)
->
GetMethodID
(
env
,
java_activity_class
,
"OnNativeMotion"
,
"(IIIIIZ)Z"
);
javaOnNDKKey
=
(
*
env
)
->
GetMethodID
(
env
,
java_activity_class
,
"OnNativeKeyPress"
,
"(IIII)Z"
);
return
JNI_VERSION_1_4
;
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment