android: remove deprecated GL2GLINative activity

This commit is contained in:
Flyinghead 2019-02-12 17:57:11 +01:00
parent 3bab26b079
commit e82b9c9b18
23 changed files with 135 additions and 543 deletions

View File

@ -30,7 +30,7 @@ public:
const std::string& name() { return _name; }
int maple_port() { return _maple_port; }
void set_maple_port(int port) { _maple_port = port; }
void gamepad_btn_input(u32 code, bool pressed);
virtual void gamepad_btn_input(u32 code, bool pressed);
void gamepad_axis_input(u32 code, int value);
virtual ~GamepadDevice() {
save_mapping();

View File

@ -442,6 +442,94 @@ static void detect_input_popup(int index, bool analog)
ImGui::PopStyleVar(2);
}
static void controller_mapping_popup(GamepadDevice *gamepad)
{
if (ImGui::BeginPopupModal("Controller Mapping", NULL, ImGuiWindowFlags_AlwaysAutoResize | ImGuiWindowFlags_NoMove))
{
const float width = 350 * scaling;
const float height = 450 * scaling;
const float col0_width = ImGui::CalcTextSize("Right DPad Downxxx").x + ImGui::GetStyle().FramePadding.x * 2.0f + ImGui::GetStyle().ItemSpacing.x;
const float col1_width = width
- ImGui::GetStyle().GrabMinSize
- (col0_width + ImGui::GetStyle().ItemSpacing.x)
- (ImGui::CalcTextSize("Map").x + ImGui::GetStyle().FramePadding.x * 2.0f + ImGui::GetStyle().ItemSpacing.x);
if (ImGui::Button("Done", ImVec2(100 * scaling, 30 * scaling)))
{
ImGui::CloseCurrentPopup();
gamepad->save_mapping();
}
ImGui::SetItemDefaultFocus();
char key_id[32];
ImGui::BeginGroup();
ImGui::Text(" Buttons ");
ImGui::BeginChildFrame(ImGui::GetID("buttons"), ImVec2(width, height), ImGuiWindowFlags_None);
ImGui::Columns(3, "bindings", false);
ImGui::SetColumnWidth(0, col0_width);
ImGui::SetColumnWidth(1, col1_width);
for (int j = 0; j < ARRAY_SIZE(button_keys); j++)
{
sprintf(key_id, "key_id%d", j);
ImGui::PushID(key_id);
ImGui::Text("%s", button_names[j]);
ImGui::NextColumn();
u32 code = gamepad->get_input_mapping()->get_button_code(button_keys[j]);
if (code != -1)
ImGui::Text("%d", code);
ImGui::NextColumn();
if (ImGui::Button("Map"))
{
map_start_time = os_GetSeconds();
ImGui::OpenPopup("Map Button");
mapped_device = gamepad;
mapped_code = -1;
gamepad->detect_btn_input(&input_detected);
}
detect_input_popup(j, false);
ImGui::NextColumn();
ImGui::PopID();
}
ImGui::EndChildFrame();
ImGui::EndGroup();
ImGui::SameLine();
ImGui::BeginGroup();
ImGui::Text(" Analog Axes ");
ImGui::BeginChildFrame(ImGui::GetID("analog"), ImVec2(width, height), ImGuiWindowFlags_None);
ImGui::Columns(3, "bindings", false);
ImGui::SetColumnWidth(0, col0_width);
ImGui::SetColumnWidth(1, col1_width);
for (int j = 0; j < ARRAY_SIZE(axis_keys); j++)
{
sprintf(key_id, "axis_id%d", j);
ImGui::PushID(key_id);
ImGui::Text("%s", axis_names[j]);
ImGui::NextColumn();
u32 code = gamepad->get_input_mapping()->get_axis_code(axis_keys[j]);
if (code != -1)
ImGui::Text("%d", code);
ImGui::NextColumn();
if (ImGui::Button("Map"))
{
map_start_time = os_GetSeconds();
ImGui::OpenPopup("Map Axis");
mapped_device = gamepad;
mapped_code = -1;
gamepad->detect_axis_input(&input_detected);
}
detect_input_popup(j, true);
ImGui::NextColumn();
ImGui::PopID();
}
ImGui::EndChildFrame();
ImGui::EndGroup();
ImGui::EndPopup();
}
}
static void gui_display_settings()
{
ImGui_Impl_NewFrame();
@ -640,91 +728,8 @@ static void gui_display_settings()
if (ImGui::Button("Map"))
ImGui::OpenPopup("Controller Mapping");
if (ImGui::BeginPopupModal("Controller Mapping", NULL, ImGuiWindowFlags_AlwaysAutoResize | ImGuiWindowFlags_NoMove))
{
const float width = 350 * scaling;
const float height = 450 * scaling;
const float col0_width = ImGui::CalcTextSize("Right DPad Downxxx").x + ImGui::GetStyle().FramePadding.x * 2.0f + ImGui::GetStyle().ItemSpacing.x;
const float col1_width = width
- ImGui::GetStyle().GrabMinSize
- (col0_width + ImGui::GetStyle().ItemSpacing.x)
- (ImGui::CalcTextSize("Map").x + ImGui::GetStyle().FramePadding.x * 2.0f + ImGui::GetStyle().ItemSpacing.x);
controller_mapping_popup(gamepad);
if (ImGui::Button("Done", ImVec2(100 * scaling, 30 * scaling)))
{
ImGui::CloseCurrentPopup();
gamepad->save_mapping();
}
ImGui::SetItemDefaultFocus();
char key_id[32];
ImGui::BeginGroup();
ImGui::Text(" Buttons ");
ImGui::BeginChildFrame(ImGui::GetID("buttons"), ImVec2(width, height), ImGuiWindowFlags_None);
ImGui::Columns(3, "bindings", false);
ImGui::SetColumnWidth(0, col0_width);
ImGui::SetColumnWidth(1, col1_width);
for (int j = 0; j < ARRAY_SIZE(button_keys); j++)
{
sprintf(key_id, "key_id%d", j);
ImGui::PushID(key_id);
ImGui::Text("%s", button_names[j]);
ImGui::NextColumn();
u32 code = gamepad->get_input_mapping()->get_button_code(button_keys[j]);
if (code != -1)
ImGui::Text("%d", code);
ImGui::NextColumn();
if (ImGui::Button("Map"))
{
map_start_time = os_GetSeconds();
ImGui::OpenPopup("Map Button");
mapped_device = gamepad;
mapped_code = -1;
gamepad->detect_btn_input(&input_detected);
}
detect_input_popup(j, false);
ImGui::NextColumn();
ImGui::PopID();
}
ImGui::EndChildFrame();
ImGui::EndGroup();
ImGui::SameLine();
ImGui::BeginGroup();
ImGui::Text(" Analog Axes ");
ImGui::BeginChildFrame(ImGui::GetID("analog"), ImVec2(width, height), ImGuiWindowFlags_None);
ImGui::Columns(3, "bindings", false);
ImGui::SetColumnWidth(0, col0_width);
ImGui::SetColumnWidth(1, col1_width);
for (int j = 0; j < ARRAY_SIZE(axis_keys); j++)
{
sprintf(key_id, "axis_id%d", j);
ImGui::PushID(key_id);
ImGui::Text("%s", axis_names[j]);
ImGui::NextColumn();
u32 code = gamepad->get_input_mapping()->get_axis_code(axis_keys[j]);
if (code != -1)
ImGui::Text("%d", code);
ImGui::NextColumn();
if (ImGui::Button("Map"))
{
map_start_time = os_GetSeconds();
ImGui::OpenPopup("Map Axis");
mapped_device = gamepad;
mapped_code = -1;
gamepad->detect_axis_input(&input_detected);
}
detect_input_popup(j, true);
ImGui::NextColumn();
ImGui::PopID();
}
ImGui::EndChildFrame();
ImGui::EndGroup();
ImGui::EndPopup();
}
ImGui::NextColumn();
ImGui::PopID();
}

View File

@ -16,6 +16,8 @@
You should have received a copy of the GNU General Public License
along with reicast. If not, see <https://www.gnu.org/licenses/>.
*/
#pragma once
void gui_init();
void gui_open_settings();
bool gui_is_open();

View File

@ -1,5 +1,6 @@
#include "../input/gamepad_device.h"
#include "sdl.h"
#include "rend/gui.h"
class DefaultInputMapping : public InputMapping
{
@ -161,5 +162,13 @@ public:
input_mapper = new MouseInputMapping();
}
virtual ~SDLMouseGamepadDevice() {}
void gamepad_btn_input(u32 code, bool pressed) override
{
if (gui_is_open())
// Don't register mouse clicks as gamepad presses when gui is open
// This makes the gamepad presses to be handled first and the mouse position to be ignored
// TODO Make this generic
return;
}
};

View File

@ -64,12 +64,6 @@
android:screenOrientation="sensorLandscape"
android:theme="@android:style/Theme.NoTitleBar.Fullscreen" >
</activity>
<activity
android:name="com.reicast.emulator.GL2JNINative"
android:configChanges="orientation|navigation|screenSize|screenLayout|uiMode|keyboard|keyboardHidden"
android:screenOrientation="sensorLandscape"
android:theme="@android:style/Theme.NoTitleBar.Fullscreen" >
</activity>
<activity
android:name="com.dropbox.client2.android.AuthActivity"
android:configChanges="orientation|keyboard"

View File

@ -10,8 +10,6 @@ import android.util.Log;
import com.reicast.emulator.emu.JNIdc;
public class Emulator extends Application {
public static final String pref_nativeact = "enable_native";
public static final String pref_dynarecopt = "dynarec_opt";
public static final String pref_unstable = "unstable_opt";
public static final String pref_dynsafemode = "dyn_safemode";
@ -44,25 +42,24 @@ public class Emulator extends Application {
public static boolean dynarecopt = true;
public static boolean idleskip = true;
public static boolean unstableopt = false;
public static boolean dynsafemode = false;
public static boolean dynsafemode = true;
public static int cable = 3;
public static int dcregion = 3;
public static int broadcast = 4;
public static int language = 6;
public static boolean limitfps = true;
public static boolean nobatch = true;
public static boolean nobatch = false;
public static boolean nosound = false;
public static boolean interrupt = false;
public static boolean mipmaps = true;
public static boolean widescreen = false;
public static int frameskip = 0;
public static int pvrrender = 0;
public static boolean syncedrender = false;
public static boolean syncedrender = true;
public static boolean modvols = true;
public static boolean clipping = true;
public static String bootdisk = null;
public static boolean usereios = false;
public static boolean nativeact = false;
public static boolean customtextures = false;
public static boolean showfps = false;
public static boolean RenderToTextureBuffer = false;
@ -96,7 +93,6 @@ public class Emulator extends Application {
Emulator.clipping = mPrefs.getBoolean(pref_clipping, clipping);
Emulator.bootdisk = mPrefs.getString(pref_bootdisk, bootdisk);
Emulator.usereios = mPrefs.getBoolean(pref_usereios, usereios);
Emulator.nativeact = mPrefs.getBoolean(pref_nativeact, nativeact);
Emulator.customtextures = mPrefs.getBoolean(pref_customtextures, customtextures);
Emulator.showfps = mPrefs.getBoolean(pref_showfps, showfps);
Emulator.RenderToTextureBuffer = mPrefs.getBoolean(pref_RenderToTextureBuffer, RenderToTextureBuffer);

View File

@ -243,22 +243,12 @@ public class MainActivity extends AppCompatActivity implements
+ uri.getAuthority() + "/external_files", "/storage"));
}
Emulator.nativeact = PreferenceManager.getDefaultSharedPreferences(
getApplicationContext()).getBoolean(Emulator.pref_nativeact, Emulator.nativeact);
if (Emulator.nativeact) {
Intent intent = new Intent("com.reicast.EMULATOR",
uri, getApplicationContext(), GL2JNINative.class);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N)
intent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
startActivity(intent);
} else {
Intent intent = new Intent("com.reicast.EMULATOR",
uri, getApplicationContext(), GL2JNIActivity.class);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N)
intent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
startActivity(intent);
}
}
public void onFolderSelected(Uri uri) {
FileBrowser browserFrag = (FileBrowser) getSupportFragmentManager()

View File

@ -257,17 +257,6 @@ public class OptionsFragment extends Fragment {
});
OnCheckedChangeListener native_options = new OnCheckedChangeListener() {
public void onCheckedChanged(CompoundButton buttonView,
boolean isChecked) {
mPrefs.edit().putBoolean(Emulator.pref_nativeact, isChecked).apply();
}
};
CompoundButton native_opt = (CompoundButton) getView().findViewById(R.id.native_option);
native_opt.setChecked(mPrefs.getBoolean(Emulator.pref_nativeact, Emulator.nativeact));
native_opt.setOnCheckedChangeListener(native_options);
OnCheckedChangeListener dynarec_options = new OnCheckedChangeListener() {
public void onCheckedChanged(CompoundButton buttonView,
@ -722,7 +711,6 @@ public class OptionsFragment extends Fragment {
private void resetEmuSettings() {
mPrefs.edit().remove(Emulator.pref_usereios).apply();
mPrefs.edit().remove(Config.pref_gamedetails).apply();
mPrefs.edit().remove(Emulator.pref_nativeact).apply();
mPrefs.edit().remove(Emulator.pref_dynarecopt).apply();
mPrefs.edit().remove(Emulator.pref_unstable).apply();
mPrefs.edit().remove(Emulator.pref_cable).apply();
@ -747,6 +735,28 @@ public class OptionsFragment extends Fragment {
mPrefs.edit().remove(Config.pref_renderdepth).apply();
mPrefs.edit().remove(Config.pref_theme).apply();
Emulator.usereios = false;
Emulator.dynarecopt = true;
Emulator.unstableopt = false;
Emulator.cable = 3;
Emulator.dcregion = 3;
Emulator.broadcast = 4;
Emulator.language = 6;
Emulator.limitfps = true;
Emulator.mipmaps = true;
Emulator.widescreen = false;
Emulator.frameskip = 0;
Emulator.pvrrender = 0;
Emulator.syncedrender = true;
Emulator.bootdisk = null;
Emulator.nosound = false;
Emulator.nobatch = false;
Emulator.customtextures = false;
Emulator.modvols = true;
Emulator.clipping = true;
Emulator.dynsafemode = true;
getActivity().finish();
}

View File

@ -28,7 +28,6 @@ import android.widget.Toast;
import com.android.util.FileUtils;
import com.reicast.emulator.Emulator;
import com.reicast.emulator.GL2JNIActivity;
import com.reicast.emulator.GL2JNINative;
import com.reicast.emulator.R;
import com.reicast.emulator.config.Config;
import com.reicast.emulator.emu.OnScreenMenu.FpsPopup;
@ -155,13 +154,9 @@ public class GL2JNIView extends GLSurfaceView
// 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);
}
JNIdc.init(fileName);
JNIdc.query(ethd, context.getApplicationContext());
@ -707,10 +702,6 @@ public class GL2JNIView extends GLSurfaceView
((GL2JNIActivity) context).getPad().joystick[0] = mPrefs.getBoolean(
Gamepad.pref_js_merged + "_A",
((GL2JNIActivity) context).getPad().joystick[0]);
if (context instanceof GL2JNINative)
((GL2JNINative) context).getPad().joystick[0] = mPrefs.getBoolean(
Gamepad.pref_js_merged + "_A",
((GL2JNINative) context).getPad().joystick[0]);
mPrefs.edit().putString(Config.game_title, reiosSoftware.trim()).apply();
}
}

View File

@ -1,29 +1,14 @@
package com.reicast.emulator.emu;
import android.annotation.SuppressLint;
import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;
import android.graphics.drawable.BitmapDrawable;
import android.graphics.drawable.Drawable;
import android.view.Gravity;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.ViewGroup.LayoutParams;
import android.widget.Button;
import android.widget.LinearLayout;
import android.widget.PopupWindow;
import android.widget.ScrollView;
import android.widget.TextView;
import com.reicast.emulator.Emulator;
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;
import com.reicast.emulator.periph.VmuLcd;
import java.util.Vector;
@ -32,9 +17,6 @@ public class OnScreenMenu {
private Activity mContext;
public OnScreenMenu(Activity context, SharedPreferences prefs) {
if (context instanceof GL2JNINative) {
this.mContext = context;
}
if (context instanceof GL2JNIActivity) {
this.mContext = context;
}

View File

@ -113,8 +113,6 @@ else
endif
endif
#
# android has poor support for hardfp calling.
# r9b+ is required, and it only works for internal calls
@ -134,14 +132,3 @@ endif
#endif
include $(BUILD_SHARED_LIBRARY)
include $(CLEAR_VARS)
LOCAL_MODULE := sexplay
LOCAL_SRC_FILES := $(wildcard $(LOCAL_PATH)/jni/src/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)

View File

@ -1,310 +0,0 @@
/*
* 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")))
#define TAG "reicast"
#define LOGW(...) ((void)__android_log_print( ANDROID_LOG_WARN, TAG, __VA_ARGS__ ))
#undef NUM_METHODS
#define NUM_METHODS(x) (sizeof(x)/sizeof(*(x)))
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;
static bool isXperiaPlay;
/**
* 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 && isXperiaPlay) {
// (*jni)->CallVoidMethod( jni, g_pActivity, javaOnNDKTouch, device, nSourceId, nRawAction, touchstate[nPointerId].x, touchstate[nPointerId].y, newTouch);
(*jni)->CallVoidMethod( jni, g_pActivity, javaOnNDKTouch, device, nSourceId, nRawAction, touchstate[nPointerId].x, touchstate[nPointerId].y);
}
newTouch = JNI_FALSE;
}
if( isXperiaPlay ) {
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;
}
}
/**
* 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;
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
}
}
}
static
int
RegisterNative( JNIEnv* env, jobject clazz, jboolean touchpad )
{
g_pActivity = (jobject)(*env)->NewGlobalRef( env, clazz );
isXperiaPlay = (bool) touchpad;
return 0;
}
static const JNINativeMethod activity_methods[] =
{
{ "RegisterNative", "(Z)I", (void*)RegisterNative },
};
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)
{
LOGW("%s - Failed to get the environment using GetEnv()", __FUNCTION__);
return -1;
}
const char* interface_path = "com/reicast/emulator/GL2JNINative";
jclass java_activity_class = (*env)->FindClass( env, interface_path );
if( !java_activity_class )
{
LOGW( "%s - Failed to get %s class reference", __FUNCTION__, interface_path );
return -1;
}
if( (*env)->RegisterNatives( env, java_activity_class, activity_methods, NUM_METHODS(activity_methods) ) != JNI_OK )
{
LOGW( "%s - Failed to register native activity methods", __FUNCTION__ );
return -1;
}
char device_type[PROP_VALUE_MAX];
__system_property_get("ro.product.model", device_type);
if( isXperiaPlay ) {
LOGW( "%s touchpad enabled", device_type );
} else {
LOGW( "%s touchpad ignored", device_type );
}
// javaOnNDKTouch = (*env)->GetMethodID( env, java_activity_class, "OnNativeMotion", "(IIIIIZ)Z");
javaOnNDKTouch = (*env)->GetMethodID( env, java_activity_class, "OnNativeMotion", "(IIIII)Z");
javaOnNDKKey = (*env)->GetMethodID( env, java_activity_class, "OnNativeKeyPress", "(IIII)Z");
return JNI_VERSION_1_4;
}

View File

@ -217,34 +217,6 @@
android:layout_marginLeft="6dp"
android:stretchColumns="*" >
<TableRow
android:layout_marginTop="10dp"
android:gravity="center_vertical" >
<TextView
android:id="@+id/native_text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="0.5"
android:ems="10"
android:gravity="center_vertical|left"
android:text="@string/select_native" />
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:gravity="right"
android:orientation="vertical" >
<Switch
android:id="@+id/native_option"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:focusable="true" />
</LinearLayout>
</TableRow>
<TableRow
android:layout_marginTop="10dp"
android:gravity="center_vertical" >

View File

@ -25,7 +25,7 @@
android:layout_marginRight="6dp"
android:layout_marginTop="2dp"
android:scaleType="fitCenter"
app:srcCompat="@drawable/gdi" />
app:srcCompat="@drawable/disk_unknown" />
<TextView
android:id="@+id/item_name"

View File

@ -217,34 +217,6 @@
android:layout_marginLeft="6dp"
android:stretchColumns="*" >
<TableRow
android:layout_marginTop="10dp"
android:gravity="center_vertical" >
<TextView
android:id="@+id/native_text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="0.5"
android:ems="10"
android:gravity="center_vertical|left"
android:text="@string/select_native" />
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:gravity="right"
android:orientation="vertical" >
<Checkbox
android:id="@+id/native_option"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:focusable="true" />
</LinearLayout>
</TableRow>
<TableRow
android:layout_marginTop="10dp"
android:gravity="center_vertical" >

View File

@ -24,7 +24,6 @@
<string name="optimization_opts">Optimerings- og fejlfindingsopsætninger</string>
<string name="experimental_opts">Eksperimentel (Kan medføre vidtspredt panik)</string>
<string name="select_details">Aktiver spil detaljer</string>
<string name="select_native">Aktiver native interface</string>
<string name="select_dynarec">Dynarec option</string>
<string name="select_unstable">Ustabile optimeringer</string>
<string name="select_region">DC region</string>

View File

@ -31,7 +31,6 @@
<string name="select_reios">Verwende reios-BIOS</string>
<string name="select_bios">BIOS-Region (dc_flash[X].bin)</string>
<string name="select_details">Aktiviere Spiele-Details</string>
<string name="select_native">Nativer Modus [Kein OSD]</string>
<string name="select_dynarec">Dynarec-Optionen</string>
<string name="select_unstable">Instabile Optimierungen</string>
<string name="select_cable">Kabeltyp</string>

View File

@ -30,7 +30,6 @@ Last Edit: 21 May 2014
<string name="optimization_opts">Options d\'optimisations et de débogage</string>
<string name="experimental_opts">Experimental (peut causer des crashs)</string>
<string name="select_details">Activer le détail des jeux</string>
<string name="select_native">Activer l\'interface native</string>
<string name="select_dynarec">Dynarec</string>
<string name="select_unstable">Optimisations instables</string>
<string name="select_region">Région du bios</string>

View File

@ -30,7 +30,6 @@
<string name="optimization_opts">Opzioni di Ottimizzazione e di Debugging </string>
<string name="experimental_opts">Opzioni Sperimentali (Possono causare problemi)</string>
<string name="select_details">Abilita i Dettagli del Gioco</string>
<string name="select_native">Abilita Interfaccia Nativa</string>
<string name="select_dynarec">Dynarec</string>
<string name="select_unstable">Ottimizzazioni Instabili</string>
<string name="select_region">Regione del DC</string>

View File

@ -21,7 +21,6 @@
<string name="optimization_opts">最適化とデバッグの設定</string>
<string name="experimental_opts">実験的</string>
<string name="select_native">ネイティブインタフェースを使用</string>
<string name="select_dynarec">Dynarecの設定</string>
<string name="select_unstable">不安定な最適化</string>
<string name="select_region">DC地域</string>

View File

@ -31,7 +31,6 @@
<string name="select_reios">Usar reios BIOS</string>
<string name="select_bios">Região da BIOS (dc_flash[X].bin)</string>
<string name="select_details">Habilitar detalhes do jogo</string>
<string name="select_native">Modo nativo [Sem OSD]</string>
<string name="select_dynarec">Habilitar Recompilador Dinâmico (Dynarec)</string>
<string name="select_unstable">Otimizações instáveis</string>
<string name="select_cable">Tipo de cabo</string>

View File

@ -33,7 +33,6 @@
<string name="select_reios">Использовать reios BIOS</string>
<string name="select_bios">Регион BIOS (dc_flash[X].bin)</string>
<string name="select_details">Информация об игре</string>
<string name="select_native">Нативный режим (без индикации)</string>
<string name="select_dynarec">Динамическая рекомпиляция</string>
<string name="select_unstable">Нестабильные оптимизации</string>
<string name="select_cable">Тип кабеля</string>

View File

@ -35,7 +35,6 @@
<string name="select_reios">Use reios BIOS</string>
<string name="select_bios">BIOS Region (dc_flash[X].bin)</string>
<string name="select_details">Enable Game Details</string>
<string name="select_native">Native Gamepad Mode [No OSD]</string>
<string name="select_dynarec">Dynamic Recompiler</string>
<string name="select_unstable">Unstable Optimisations</string>
<string name="select_safemode">Bypass Div Matching</string>