This commit is contained in:
twinaphex 2013-08-13 02:34:55 +02:00
commit d48a536bab
18 changed files with 359 additions and 311 deletions

View File

@ -27,12 +27,6 @@
#define MAX_TOUCH 16
typedef struct
{
float dzone_min;
float dzone_max;
} dpad_values_t;
typedef struct
{
int16_t lx, ly;
@ -48,7 +42,6 @@ static unsigned pads_connected;
static int state_device_ids[MAX_PADS];
static uint64_t state[MAX_PADS];
static uint64_t keycode_lut[LAST_KEYCODE];
dpad_values_t dpad_state[MAX_PADS];
analog_t analog_state[MAX_PADS];
struct input_pointer
@ -194,8 +187,8 @@ static void engine_handle_dpad_default(AInputEvent *event,
int source, bool debug_enable, unsigned emulation)
{
uint64_t *state_cur = &state[state_id];
float dzone_min = dpad_state[state_id].dzone_min;
float dzone_max = dpad_state[state_id].dzone_max;
float dzone_min = -g_settings.input.axis_threshold;
float dzone_max = g_settings.input.axis_threshold;
float x = AMotionEvent_getX(event, motion_pointer);
float y = AMotionEvent_getY(event, motion_pointer);
@ -221,8 +214,8 @@ static void engine_handle_dpad_getaxisvalue(AInputEvent *event,
bool debug_enable, unsigned emulation)
{
uint64_t *state_cur = &state[state_id];
float dzone_min = dpad_state[state_id].dzone_min;
float dzone_max = dpad_state[state_id].dzone_max;
float dzone_min = -g_settings.input.axis_threshold;
float dzone_max = g_settings.input.axis_threshold;
float x = AMotionEvent_getAxisValue(event, AXIS_X, motion_pointer);
float y = AMotionEvent_getAxisValue(event, AXIS_Y, motion_pointer);
float z = AMotionEvent_getAxisValue(event, AXIS_Z, motion_pointer);
@ -320,8 +313,6 @@ static void *android_input_init(void)
g_settings.input.binds[i][RETRO_DEVICE_ID_JOYPAD_L3].joykey = (1ULL << RETRO_DEVICE_ID_JOYPAD_L3);
g_settings.input.binds[i][RETRO_DEVICE_ID_JOYPAD_R3].joykey = (1ULL << RETRO_DEVICE_ID_JOYPAD_R3);
dpad_state[i].dzone_min = -0.99f;
dpad_state[i].dzone_max = 0.99f;
g_settings.input.dpad_emulation[i] = ANALOG_DPAD_LSTICK;
}
@ -511,9 +502,6 @@ static void android_input_set_keybinds(void *data, unsigned device,
g_settings.input.device[port] = device;
strlcpy(g_settings.input.device_names[port], "TTT THT Arcade",
sizeof(g_settings.input.device_names[port]));
dpad_state[id].dzone_min = -2.00f;
dpad_state[id].dzone_max = 1.00f;
/* same as Rumblepad 2 - merge? */
//keycode_lut[AKEYCODE_BUTTON_7] |= ((RETRO_DEVICE_ID_JOYPAD_L2+1) << shift);
@ -652,8 +640,6 @@ static void android_input_set_keybinds(void *data, unsigned device,
g_settings.input.device[port] = device;
strlcpy(g_settings.input.device_names[port], "Huijia USB SNES",
sizeof(g_settings.input.device_names[port]));
dpad_state[id].dzone_min = -1.00f;
dpad_state[id].dzone_max = 1.00f;
keycode_lut[AKEYCODE_BUTTON_3] |= ((RETRO_DEVICE_ID_JOYPAD_B+1) << shift);
keycode_lut[AKEYCODE_BUTTON_4] |= ((RETRO_DEVICE_ID_JOYPAD_Y+1) << shift);
@ -668,8 +654,6 @@ static void android_input_set_keybinds(void *data, unsigned device,
g_settings.input.device[port] = device;
strlcpy(g_settings.input.device_names[port], "Super Smartjoy",
sizeof(g_settings.input.device_names[port]));
dpad_state[id].dzone_min = -1.00f;
dpad_state[id].dzone_max = 1.00f;
keycode_lut[AKEYCODE_BUTTON_3] |= ((RETRO_DEVICE_ID_JOYPAD_B+1) << shift);
keycode_lut[AKEYCODE_BUTTON_4] |= ((RETRO_DEVICE_ID_JOYPAD_Y+1) << shift);
@ -738,6 +722,7 @@ static void android_input_set_keybinds(void *data, unsigned device,
sizeof(g_settings.input.device_names[port]));
g_settings.input.dpad_emulation[port] = ANALOG_DPAD_DUALANALOG;
keycode_lut[AKEYCODE_BUTTON_MODE] |= ((RARCH_MENU_TOGGLE + 1) << shift);
keycode_lut[AKEYCODE_BACK] |= ((RETRO_DEVICE_ID_JOYPAD_SELECT+1) << shift);
keycode_lut[AKEYCODE_BUTTON_SELECT] |= ((RETRO_DEVICE_ID_JOYPAD_SELECT+1) << shift);
keycode_lut[AKEYCODE_BUTTON_START] |= ((RETRO_DEVICE_ID_JOYPAD_START+1) << shift);
@ -854,52 +839,29 @@ static void android_input_set_keybinds(void *data, unsigned device,
keycode_lut[AKEYCODE_ESCAPE] |= ((RARCH_QUIT_KEY+1) << shift);
break;
case DEVICE_PLAYSTATION3_VERSION1:
g_settings.input.device[port] = device;
strlcpy(g_settings.input.device_names[port], "PlayStation3 Ver.1",
sizeof(g_settings.input.device_names[port]));
g_settings.input.dpad_emulation[port] = ANALOG_DPAD_NONE;
keycode_lut[AKEYCODE_DPAD_UP] |= ((RETRO_DEVICE_ID_JOYPAD_UP+1) << shift);
keycode_lut[AKEYCODE_DPAD_DOWN] |= ((RETRO_DEVICE_ID_JOYPAD_DOWN+1) << shift);
keycode_lut[AKEYCODE_DPAD_LEFT] |= ((RETRO_DEVICE_ID_JOYPAD_LEFT+1) << shift);
keycode_lut[AKEYCODE_DPAD_RIGHT] |= ((RETRO_DEVICE_ID_JOYPAD_RIGHT+1) << shift);
keycode_lut[AKEYCODE_BUTTON_A] |= ((RETRO_DEVICE_ID_JOYPAD_B+1) << shift);
keycode_lut[AKEYCODE_BUTTON_X] |= ((RETRO_DEVICE_ID_JOYPAD_Y+1) << shift);
keycode_lut[AKEYCODE_BUTTON_SELECT] |= ((RETRO_DEVICE_ID_JOYPAD_SELECT+1) << shift);
keycode_lut[AKEYCODE_BUTTON_START] |= ((RETRO_DEVICE_ID_JOYPAD_START+1) << shift);
keycode_lut[AKEYCODE_BUTTON_Y] |= ((RETRO_DEVICE_ID_JOYPAD_X+1) << shift);
keycode_lut[AKEYCODE_BUTTON_B] |= ((RETRO_DEVICE_ID_JOYPAD_A+1) << shift);
keycode_lut[AKEYCODE_BUTTON_L1] |= ((RETRO_DEVICE_ID_JOYPAD_L+1) << shift);
keycode_lut[AKEYCODE_BUTTON_R1] |= ((RETRO_DEVICE_ID_JOYPAD_R+1) << shift);
keycode_lut[AKEYCODE_BUTTON_L2] |= ((RETRO_DEVICE_ID_JOYPAD_L2+1) << shift);
keycode_lut[AKEYCODE_BUTTON_R2] |= ((RETRO_DEVICE_ID_JOYPAD_R2+1) << shift);
keycode_lut[AKEYCODE_BUTTON_THUMBL] |= ((RETRO_DEVICE_ID_JOYPAD_L3+1) << shift);
keycode_lut[AKEYCODE_BUTTON_THUMBR] |= ((RETRO_DEVICE_ID_JOYPAD_R3+1) << shift);
keycode_lut[AKEYCODE_BUTTON_1] |= ((RARCH_MENU_TOGGLE+1) << shift);
break;
case DEVICE_PLAYSTATION3_VERSION2:
g_settings.input.device[port] = device;
g_settings.input.dpad_emulation[port] = ANALOG_DPAD_NONE;
strlcpy(g_settings.input.device_names[port], "PlayStation3 Ver.2",
strlcpy(g_settings.input.device_names[port], "PlayStation3",
sizeof(g_settings.input.device_names[port]));
g_settings.input.dpad_emulation[port] = ANALOG_DPAD_NONE;
keycode_lut[AKEYCODE_DPAD_UP] |= ((RETRO_DEVICE_ID_JOYPAD_UP+1) << shift);
keycode_lut[AKEYCODE_DPAD_DOWN] |= ((RETRO_DEVICE_ID_JOYPAD_DOWN+1) << shift);
keycode_lut[AKEYCODE_DPAD_LEFT] |= ((RETRO_DEVICE_ID_JOYPAD_LEFT+1) << shift);
keycode_lut[AKEYCODE_DPAD_RIGHT] |= ((RETRO_DEVICE_ID_JOYPAD_RIGHT+1) << shift);
keycode_lut[AKEYCODE_BUTTON_1] |= ((RARCH_MENU_TOGGLE+1) << shift);
keycode_lut[AKEYCODE_BUTTON_A] |= ((RETRO_DEVICE_ID_JOYPAD_A+1) << shift);
keycode_lut[AKEYCODE_BUTTON_X] |= ((RETRO_DEVICE_ID_JOYPAD_X+1) << shift);
keycode_lut[AKEYCODE_BUTTON_A] |= ((RETRO_DEVICE_ID_JOYPAD_Y+1) << shift);
keycode_lut[AKEYCODE_BUTTON_X] |= ((RETRO_DEVICE_ID_JOYPAD_B+1) << shift);
keycode_lut[AKEYCODE_BUTTON_SELECT] |= ((RETRO_DEVICE_ID_JOYPAD_SELECT+1) << shift);
keycode_lut[AKEYCODE_BUTTON_START] |= ((RETRO_DEVICE_ID_JOYPAD_START+1) << shift);
keycode_lut[AKEYCODE_BUTTON_Y] |= ((RETRO_DEVICE_ID_JOYPAD_Y+1) << shift);
keycode_lut[AKEYCODE_BUTTON_B] |= ((RETRO_DEVICE_ID_JOYPAD_B+1) << shift);
keycode_lut[AKEYCODE_BUTTON_B] |= ((RETRO_DEVICE_ID_JOYPAD_X+1) << shift);
keycode_lut[AKEYCODE_BUTTON_Y] |= ((RETRO_DEVICE_ID_JOYPAD_A+1) << shift);
keycode_lut[AKEYCODE_BUTTON_L1] |= ((RETRO_DEVICE_ID_JOYPAD_L+1) << shift);
keycode_lut[AKEYCODE_BUTTON_R1] |= ((RETRO_DEVICE_ID_JOYPAD_R+1) << shift);
keycode_lut[AKEYCODE_BUTTON_L2] |= ((RETRO_DEVICE_ID_JOYPAD_L2+1) << shift);
keycode_lut[AKEYCODE_BUTTON_R2] |= ((RETRO_DEVICE_ID_JOYPAD_R2+1) << shift);
keycode_lut[AKEYCODE_BUTTON_THUMBL] |= ((RETRO_DEVICE_ID_JOYPAD_L3+1) << shift);
keycode_lut[AKEYCODE_BUTTON_THUMBR] |= ((RETRO_DEVICE_ID_JOYPAD_R3+1) << shift);
keycode_lut[AKEYCODE_BUTTON_1] |= ((RARCH_MENU_TOGGLE+1) << shift);
break;
case DEVICE_MOGA:
g_settings.input.device[port] = device;
@ -1076,8 +1038,6 @@ static void android_input_set_keybinds(void *data, unsigned device,
g_settings.input.device[port] = device;
strlcpy(g_settings.input.device_names[port], "Buffalo BGC FC801",
sizeof(g_settings.input.device_names[port]));
dpad_state[id].dzone_min = -1.00f;
dpad_state[id].dzone_max = 1.00f;
keycode_lut[AKEYCODE_BUTTON_1] |= ((RETRO_DEVICE_ID_JOYPAD_A+1) << shift);
keycode_lut[AKEYCODE_BUTTON_2] |= ((RETRO_DEVICE_ID_JOYPAD_B+1) << shift);

View File

@ -15,7 +15,7 @@
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:hasCode="true">
<activity android:name=".browser.RetroArch"></activity>
<activity android:name=".browser.CoreSelection"></activity>
<activity android:name=".browser.DisplayRefreshRateTest"></activity>
<activity android:name=".browser.RefreshRateSetOS"></activity>
<activity android:name=".browser.MainMenuActivity">
@ -24,7 +24,12 @@
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name=".browser.HoneycombPopupMenu"></activity>
<activity android:name=".browser.LazyPopupMenu"></activity>
<activity android:name=".browser.PopupMenuAbstract"></activity>
<activity android:name=".browser.ReportIME"></activity>
<activity android:name=".browser.HelpActivity"></activity>
<activity android:name=".browser.FileWrapper"></activity>
<activity android:name=".browser.DirectoryActivity"></activity>
<activity android:name=".browser.ROMActivity"></activity>

View File

@ -1,6 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<menu xmlns:android="http://schemas.android.com/apk/res/android" >
<item android:id="@+id/input_method_select" android:title="@string/input_method" android:showAsAction="ifRoom" />
<item android:id="@+id/report_ime" android:title="@string/report_ime"></item>
<item android:id="@+id/report_refreshrate" android:title="@string/report_refreshrate"></item>
</menu>

View File

@ -4,7 +4,7 @@
<PreferenceScreen android:title="Select Game">
<intent
android:targetClass="org.retroarch.browser.RetroArch"
android:targetClass="org.retroarch.browser.CoreSelection"
android:targetPackage="org.retroarch" />
</PreferenceScreen>
<PreferenceScreen android:title="Video Options" >
@ -34,7 +34,7 @@
</PreferenceCategory>
<PreferenceCategory android:title="Synchronization" >
<CheckBoxPreference
android:defaultValue="false"
android:defaultValue="true"
android:key="video_threaded"
android:summary="Uses a multi-threaded video driver. Is likely to improve performance at the expense of slightly more latency and jitter. Use this if you have troubles getting good video and audio."
android:title="Threaded video driver" />
@ -98,6 +98,12 @@
android:summary="Enable dynamic rate control (recommended)."
android:title="Dynamic Rate Control"
android:dependency="audio_enable" />
<CheckBoxPreference
android:defaultValue="false"
android:key="audio_high_latency"
android:summary="Use (very) high latency audio. Necessary for older Android devices with poor audio drivers."
android:title="High latency audio"
android:dependency="audio_enable" />
</PreferenceCategory>
</PreferenceScreen>
<PreferenceScreen android:title="Input Options" >
@ -383,6 +389,14 @@
android:title="R3 Button" />
</PreferenceScreen>
</PreferenceCategory>
<PreferenceCategory android:title="Diagnostics" >
<Preference android:title="Report IME"
android:summary="Reports the current IME (Input Method Editor) name.">
<intent
android:targetClass="org.retroarch.browser.ReportIME"
android:targetPackage="org.retroarch" />
</Preference>
</PreferenceCategory>
</PreferenceScreen>
<PreferenceScreen android:title="Path Options">
<PreferenceCategory android:title="ROM paths">

View File

@ -17,50 +17,14 @@ import android.util.Log;
import android.view.*;
import android.view.ContextMenu.ContextMenuInfo;
import android.view.inputmethod.*;
import android.graphics.drawable.*;
// JELLY_BEAN_MR1 = 17
class ModuleWrapper implements IconAdapterItem {
public final File file;
private ConfigFile config;
public ModuleWrapper(Context aContext, File aFile, ConfigFile config) throws IOException {
file = aFile;
this.config = config;
}
@Override
public boolean isEnabled() {
return true;
}
@Override
public String getText() {
String stripped = file.getName().replace(".so", "");
if (config.keyExists(stripped)) {
return config.getString(stripped);
} else
return stripped;
}
@Override
public int getIconResourceId() {
return 0;
}
@Override
public Drawable getIconDrawable() {
return null;
}
}
public class RetroArch extends Activity implements
public class CoreSelection extends Activity implements
AdapterView.OnItemClickListener {
private IconAdapter<ModuleWrapper> adapter;
static private final int ACTIVITY_LOAD_ROM = 0;
static private String libretro_path;
static private Double report_refreshrate;
static private final String TAG = "CoreSelection";
private ConfigFile config;
private ConfigFile core_config;
@ -140,7 +104,6 @@ public class RetroArch extends Activity implements
String cpuInfo = readCPUInfo();
boolean cpuIsNeon = cpuInfoIsNeon(cpuInfo);
report_refreshrate = getDisplayRefreshRate();
setContentView(R.layout.line_list);
@ -256,6 +219,7 @@ public class RetroArch extends Activity implements
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(getBaseContext());
config.setBoolean("audio_rate_control", prefs.getBoolean("audio_rate_control", true));
config.setInt("audio_out_rate", getOptimalSamplingRate());
config.setInt("audio_latency", prefs.getBoolean("audio_high_latency", false) ? 160 : 64);
config.setBoolean("audio_enable", prefs.getBoolean("audio_enable", true));
config.setBoolean("video_smooth", prefs.getBoolean("video_smooth", true));
config.setBoolean("video_allow_rotate", prefs.getBoolean("video_allow_rotate", true));
@ -272,7 +236,7 @@ public class RetroArch extends Activity implements
config.setInt("input_autodetect_icade_profile_pad4", Integer.valueOf(prefs.getString("input_autodetect_icade_profile_pad4", "0")));
config.setDouble("video_refresh_rate", getRefreshRate());
config.setBoolean("video_threaded", prefs.getBoolean("video_threaded", false));
config.setBoolean("video_threaded", prefs.getBoolean("video_threaded", true));
String aspect = prefs.getString("video_aspect_ratio", "auto");
if (aspect.equals("full")) {
@ -414,118 +378,8 @@ public class RetroArch extends Activity implements
InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
imm.showInputMethodPicker();
return true;
case R.id.report_ime:
String current_ime = Settings.Secure.getString(getContentResolver(), Settings.Secure.DEFAULT_INPUT_METHOD);
new AlertDialog.Builder(this).setMessage(current_ime).setNeutralButton("Close", null).show();
return true;
case R.id.report_refreshrate:
String current_rate = "Screen Refresh Rate: " + Double.valueOf(report_refreshrate).toString();
new AlertDialog.Builder(this).setMessage(current_rate).setNeutralButton("Close", null).show();
return true;
default:
return false;
}
}
}
abstract class LazyPopupMenu {
public abstract Menu getMenu();
public abstract MenuInflater getMenuInflater();
public abstract void setOnMenuItemClickListener(LazyPopupMenu.OnMenuItemClickListener listener);
public abstract void show();
public interface OnMenuItemClickListener {
public abstract boolean onMenuItemClick(MenuItem item);
}
}
@TargetApi(Build.VERSION_CODES.HONEYCOMB)
class HoneycombPopupMenu extends LazyPopupMenu {
private PopupMenu instance;
HoneycombPopupMenu.OnMenuItemClickListener listen;
public HoneycombPopupMenu(Context context, View anchor)
{
instance = new PopupMenu(context, anchor);
}
@Override
public void setOnMenuItemClickListener(HoneycombPopupMenu.OnMenuItemClickListener listener)
{
listen = listener;
instance.setOnMenuItemClickListener(new PopupMenu.OnMenuItemClickListener() {
@Override
public boolean onMenuItemClick(MenuItem item) {
return listen.onMenuItemClick(item);
}
});
}
@Override
public Menu getMenu() {
return instance.getMenu();
}
@Override
public MenuInflater getMenuInflater() {
return instance.getMenuInflater();
}
@Override
public void show() {
instance.show();
}
}
class PopupMenuAbstract extends LazyPopupMenu
{
private LazyPopupMenu lazy;
public PopupMenuAbstract(Context context, View anchor)
{
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB)
{
lazy = new HoneycombPopupMenu(context, anchor);
}
}
@Override
public Menu getMenu() {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB)
{
return lazy.getMenu();
}
else
{
return null;
}
}
@Override
public MenuInflater getMenuInflater() {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB)
{
return lazy.getMenuInflater();
}
else
{
return null;
}
}
@Override
public void setOnMenuItemClickListener(PopupMenuAbstract.OnMenuItemClickListener listener) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB)
{
lazy.setOnMenuItemClickListener(listener);
}
}
@Override
public void show() {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB)
{
lazy.show();
}
}
}

View File

@ -12,75 +12,7 @@ import android.os.*;
import android.preference.PreferenceManager;
import android.widget.*;
import android.view.*;
import android.graphics.drawable.*;
class FileWrapper implements IconAdapterItem {
public final File file;
public final boolean parentItem;
public final boolean dirSelectItem;
protected final boolean enabled;
public static final int DIRSELECT = 0;
public static final int PARENT = 1;
public static final int FILE = 2;
protected final int typeIndex;
public FileWrapper(File aFile, int type, boolean aIsEnabled) {
file = aFile;
parentItem = type == PARENT;
dirSelectItem = type == DIRSELECT;
typeIndex = type == FILE ? (FILE + (file.isDirectory() ? 0 : 1)) : type;
enabled = parentItem || dirSelectItem || aIsEnabled;
}
@Override
public boolean isEnabled() {
return enabled;
}
@Override
public String getText() {
if (dirSelectItem)
return "[[Use this directory]]";
else if (parentItem)
return "[Parent Directory]";
else
return file.getName();
}
@Override
public int getIconResourceId() {
if (!parentItem && !dirSelectItem) {
return file.isFile() ? R.drawable.ic_file : R.drawable.ic_dir;
} else {
return R.drawable.ic_dir;
}
}
@Override
public Drawable getIconDrawable() {
return null;
}
public int compareTo(FileWrapper aOther) {
if (aOther != null) {
// Who says ternary is hard to follow
if (isEnabled() == aOther.isEnabled()) {
return (typeIndex == aOther.typeIndex) ? file
.compareTo(aOther.file)
: ((typeIndex < aOther.typeIndex) ? -1 : 1);
} else {
return isEnabled() ? -1 : 1;
}
}
return -1;
}
}
public class DirectoryActivity extends Activity implements
AdapterView.OnItemClickListener {

View File

@ -0,0 +1,75 @@
package org.retroarch.browser;
import java.io.File;
import org.retroarch.R;
import android.graphics.drawable.Drawable;
class FileWrapper implements IconAdapterItem {
public final File file;
public final boolean parentItem;
public final boolean dirSelectItem;
protected final boolean enabled;
public static final int DIRSELECT = 0;
public static final int PARENT = 1;
public static final int FILE = 2;
protected final int typeIndex;
public FileWrapper(File aFile, int type, boolean aIsEnabled) {
file = aFile;
parentItem = type == PARENT;
dirSelectItem = type == DIRSELECT;
typeIndex = type == FILE ? (FILE + (file.isDirectory() ? 0 : 1)) : type;
enabled = parentItem || dirSelectItem || aIsEnabled;
}
@Override
public boolean isEnabled() {
return enabled;
}
@Override
public String getText() {
if (dirSelectItem)
return "[[Use this directory]]";
else if (parentItem)
return "[Parent Directory]";
else
return file.getName();
}
@Override
public int getIconResourceId() {
if (!parentItem && !dirSelectItem) {
return file.isFile() ? R.drawable.ic_file : R.drawable.ic_dir;
} else {
return R.drawable.ic_dir;
}
}
@Override
public Drawable getIconDrawable() {
return null;
}
public int compareTo(FileWrapper aOther) {
if (aOther != null) {
// Who says ternary is hard to follow
if (isEnabled() == aOther.isEnabled()) {
return (typeIndex == aOther.typeIndex) ? file
.compareTo(aOther.file)
: ((typeIndex < aOther.typeIndex) ? -1 : 1);
} else {
return isEnabled() ? -1 : 1;
}
}
return -1;
}
}

View File

@ -0,0 +1,49 @@
package org.retroarch.browser;
import android.annotation.TargetApi;
import android.content.Context;
import android.os.Build;
import android.view.Menu;
import android.view.MenuInflater;
import android.view.MenuItem;
import android.view.View;
import android.widget.PopupMenu;
@TargetApi(Build.VERSION_CODES.HONEYCOMB)
class HoneycombPopupMenu extends LazyPopupMenu {
private PopupMenu instance;
HoneycombPopupMenu.OnMenuItemClickListener listen;
public HoneycombPopupMenu(Context context, View anchor)
{
instance = new PopupMenu(context, anchor);
}
@Override
public void setOnMenuItemClickListener(HoneycombPopupMenu.OnMenuItemClickListener listener)
{
listen = listener;
instance.setOnMenuItemClickListener(new PopupMenu.OnMenuItemClickListener() {
@Override
public boolean onMenuItemClick(MenuItem item) {
return listen.onMenuItemClick(item);
}
});
}
@Override
public Menu getMenu() {
return instance.getMenu();
}
@Override
public MenuInflater getMenuInflater() {
return instance.getMenuInflater();
}
@Override
public void show() {
instance.show();
}
}

View File

@ -0,0 +1,15 @@
package org.retroarch.browser;
import android.view.Menu;
import android.view.MenuInflater;
import android.view.MenuItem;
abstract class LazyPopupMenu {
public abstract Menu getMenu();
public abstract MenuInflater getMenuInflater();
public abstract void setOnMenuItemClickListener(LazyPopupMenu.OnMenuItemClickListener listener);
public abstract void show();
public interface OnMenuItemClickListener {
public abstract boolean onMenuItemClick(MenuItem item);
}
}

View File

@ -13,7 +13,6 @@ import org.retroarch.R;
import android.app.AlertDialog;
import android.content.DialogInterface;
import android.content.Intent;
import android.content.SharedPreferences;
import android.content.pm.PackageManager.NameNotFoundException;
import android.content.res.AssetManager;
@ -155,18 +154,15 @@ public class MainMenuActivity extends PreferenceActivity {
boolean detectDevice(boolean show_dialog)
{
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(getBaseContext());
SharedPreferences.Editor edit = prefs.edit();
edit.putBoolean("video_threaded", true);
edit.commit();
boolean retval = false;
Log.i("Device MODEL", android.os.Build.MODEL);
if (android.os.Build.MODEL.equals("SHIELD"))
{
AlertDialog.Builder alert = new AlertDialog.Builder(this)
.setTitle("NVidia Shield detected")
.setMessage("Would you like to set up the ideal configuration options for your device?\nNOTE: For optimal performance, turn off Google Account sync, Google Play Store auto-updates, GPS and Wifi in your Android settings menu.")
.setPositiveButton("Yes", new DialogInterface.OnClickListener() {
.setMessage("The ideal configuration options for your device will now be preconfigured.\nNOTE: For optimal performance, turn off Google Account sync, Google Play Store auto-updates, GPS and Wifi in your Android settings menu.")
.setPositiveButton("OK", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(getBaseContext());
@ -176,17 +172,34 @@ public class MainMenuActivity extends PreferenceActivity {
edit.putBoolean("input_autodetect_enable", true);
edit.commit();
}
})
.setNegativeButton("No", null);
});
alert.show();
return true;
retval = true;
}
else if (android.os.Build.MODEL.equals( "OUYA Console"))
{
AlertDialog.Builder alert = new AlertDialog.Builder(this)
.setTitle("OUYA detected")
.setMessage("The ideal configuration options for your device will now be preconfigured.\nNOTE: For optimal performance, turn off Google Account sync, GPS and Wifi in your Android settings menu.")
.setPositiveButton("OK", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(getBaseContext());
SharedPreferences.Editor edit = prefs.edit();
edit.putBoolean("input_overlay_enable", false);
edit.putBoolean("input_autodetect_enable", true);
edit.commit();
}
});
alert.show();
retval = true;
}
else if (android.os.Build.ID.equals("JSS15J"))
{
AlertDialog.Builder alert = new AlertDialog.Builder(this)
.setTitle("Nexus 7 2013 detected")
.setMessage("Would you like to set up the ideal configuration options for your device?\nNOTE: For optimal performance, turn off Google Account sync, Google Play Store auto-updates, GPS and Wifi in your Android settings menu.")
.setPositiveButton("Yes", new DialogInterface.OnClickListener() {
.setMessage("The ideal configuration options for your device will now be preconfigured.\nNOTE: For optimal performance, turn off Google Account sync, Google Play Store auto-updates, GPS and Wifi in your Android settings menu.")
.setPositiveButton("OK", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(getBaseContext());
@ -194,10 +207,9 @@ public class MainMenuActivity extends PreferenceActivity {
edit.putString("video_refresh_rate", Double.valueOf(59.65).toString());
edit.commit();
}
})
.setNegativeButton("No", null);
});
alert.show();
return true;
retval = true;
}
if (show_dialog) {
@ -206,7 +218,7 @@ public class MainMenuActivity extends PreferenceActivity {
Toast.LENGTH_SHORT).show();
}
return false;
return retval;
}
@Override

View File

@ -0,0 +1,41 @@
package org.retroarch.browser;
import java.io.File;
import java.io.IOException;
import android.content.Context;
import android.graphics.drawable.Drawable;
class ModuleWrapper implements IconAdapterItem {
public final File file;
private ConfigFile config;
public ModuleWrapper(Context aContext, File aFile, ConfigFile config) throws IOException {
file = aFile;
this.config = config;
}
@Override
public boolean isEnabled() {
return true;
}
@Override
public String getText() {
String stripped = file.getName().replace(".so", "");
if (config.keyExists(stripped)) {
return config.getString(stripped);
} else
return stripped;
}
@Override
public int getIconResourceId() {
return 0;
}
@Override
public Drawable getIconDrawable() {
return null;
}
}

View File

@ -0,0 +1,60 @@
package org.retroarch.browser;
import android.content.Context;
import android.os.Build;
import android.view.Menu;
import android.view.MenuInflater;
import android.view.View;
class PopupMenuAbstract extends LazyPopupMenu
{
private LazyPopupMenu lazy;
public PopupMenuAbstract(Context context, View anchor)
{
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB)
{
lazy = new HoneycombPopupMenu(context, anchor);
}
}
@Override
public Menu getMenu() {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB)
{
return lazy.getMenu();
}
else
{
return null;
}
}
@Override
public MenuInflater getMenuInflater() {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB)
{
return lazy.getMenuInflater();
}
else
{
return null;
}
}
@Override
public void setOnMenuItemClickListener(PopupMenuAbstract.OnMenuItemClickListener listener) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB)
{
lazy.setOnMenuItemClickListener(listener);
}
}
@Override
public void show() {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB)
{
lazy.show();
}
}
}

View File

@ -0,0 +1,15 @@
package org.retroarch.browser;
import android.app.Activity;
import android.app.AlertDialog;
import android.os.Bundle;
import android.provider.Settings;
public class ReportIME extends Activity {
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
String current_ime = Settings.Secure.getString(getContentResolver(), Settings.Secure.DEFAULT_INPUT_METHOD);
new AlertDialog.Builder(this).setMessage(current_ime).setNeutralButton("Close", null).show();
}
}

View File

@ -62,7 +62,7 @@ static void hid_input_callback(void* inContext, IOReturn inResult, void* inSende
if (state) g_current_input_data.pad_buttons[slot] |= (1 << (use - 1));
else g_current_input_data.pad_buttons[slot] &= ~(1 << (use - 1));
}
else if (type == kIOHIDElementTypeInput_Axis && page == kHIDPage_GenericDesktop)
else if (type == kIOHIDElementTypeInput_Misc && page == kHIDPage_GenericDesktop)
{
static const uint32_t axis_use_ids[4] = { 48, 49, 50, 53 };
for (int i = 0; i < 4; i ++)

View File

@ -86,6 +86,11 @@ void apple_input_enable_icade(bool on)
icade_buttons = 0;
}
uint32_t apple_input_get_icade_buttons()
{
return icade_enabled ? icade_buttons : 0;
}
void apple_input_handle_key_event(unsigned keycode, bool down)
{
keycode = HIDKEY(keycode);
@ -131,7 +136,7 @@ static void apple_input_poll(void *data)
}
input_joypad_poll(g_joydriver);
g_polled_input_data.pad_buttons[0] |= icade_buttons;
g_polled_input_data.pad_buttons[0] |= apple_input_get_icade_buttons();
g_current_input_data.mouse_delta[0] = 0;
g_current_input_data.mouse_delta[1] = 0;

View File

@ -47,6 +47,7 @@ extern apple_input_data_t g_polled_input_data; //< Game thread data
// Main thread only
void apple_input_enable_icade(bool on);
uint32_t apple_input_get_icade_buttons();
void apple_input_handle_key_event(unsigned keycode, bool down);
#endif

View File

@ -755,7 +755,6 @@ static NSArray* build_input_port_group(config_file_t* config, uint32_t player)
{ "nul", 0x00},
};
for (int i = 0; ios_key_name_map[i].hid_id; i++)
{
if (g_current_input_data.keys[ios_key_name_map[i].hid_id])
@ -767,9 +766,12 @@ static NSArray* build_input_port_group(config_file_t* config, uint32_t player)
}
// Pad Buttons
for (int i = 0; g_current_input_data.pad_buttons[_value.player] && i < sizeof(g_current_input_data.pad_buttons[_value.player]) * 8; i++)
uint32_t buttons = g_current_input_data.pad_buttons[_value.player] |
((_value.player == 0) ? apple_input_get_icade_buttons() : 0);
for (int i = 0; buttons && i < sizeof(buttons) * 8; i++)
{
if (g_current_input_data.pad_buttons[_value.player] & (1 << i))
if (buttons & (1 << i))
{
_value.msubValues[1] = [NSString stringWithFormat:@"%d", i];
[self finish];

View File

@ -33,13 +33,10 @@
#define SLPlayItf_SetPlayState(a, ...) ((*(a))->SetPlayState(a, __VA_ARGS__))
// TODO: Are these sane?
#define BUFFER_SIZE (2 * 1024)
#define BUFFER_COUNT 16
typedef struct sl
{
uint8_t buffer[BUFFER_COUNT][BUFFER_SIZE];
uint8_t **buffer;
uint8_t *buffer_chunk;
unsigned buffer_index;
unsigned buffer_ptr;
volatile unsigned buffered_blocks;
@ -55,6 +52,7 @@ typedef struct sl
slock_t *lock;
scond_t *cond;
bool nonblock;
unsigned buf_size;
unsigned buf_count;
} sl_t;
@ -93,6 +91,8 @@ static void sl_free(void *data)
if (sl->cond)
scond_free(sl->cond);
free(sl->buffer);
free(sl->buffer_chunk);
free(sl);
}
@ -122,11 +122,23 @@ static void *sl_init(const char *device, unsigned rate, unsigned latency)
GOTO_IF_FAIL(SLEngineItf_CreateOutputMix(sl->engine, &sl->output_mix, 0, NULL, NULL));
GOTO_IF_FAIL(SLObjectItf_Realize(sl->output_mix, SL_BOOLEAN_FALSE));
sl->buf_size = next_pow2(32 * latency);
sl->buf_count = (latency * 4 * out_rate + 500) / 1000;
sl->buf_count = (sl->buf_count + BUFFER_SIZE / 2) / BUFFER_SIZE;
sl->buf_count = min(sl->buf_count, BUFFER_COUNT);
sl->buf_count = (sl->buf_count + sl->buf_size / 2) / sl->buf_size;
RARCH_LOG("[SLES] : Setting audio latency (buffer size: [%d]) ...\n", sl->buf_count * BUFFER_SIZE);
sl->buffer = (uint8_t**)calloc(sizeof(uint8_t*), sl->buf_count);
if (!sl->buffer)
goto error;
sl->buffer_chunk = (uint8_t*)calloc(sl->buf_count, sl->buf_size);
if (!sl->buffer_chunk)
goto error;
for (unsigned i = 0; i < sl->buf_count; i++)
sl->buffer[i] = sl->buffer_chunk + i * sl->buf_size;
RARCH_LOG("[SLES] : Setting audio latency: Block size = %u, Blocks = %u, Total = %u ...\n",
sl->buf_size, sl->buf_count, sl->buf_size * sl->buf_count);
fmt_pcm.formatType = SL_DATAFORMAT_PCM;
fmt_pcm.numChannels = 2;
@ -164,7 +176,7 @@ static void *sl_init(const char *device, unsigned rate, unsigned latency)
sl->buffered_blocks = sl->buf_count;
sl->buffer_index = 0;
for (unsigned i = 0; i < sl->buf_count; i++)
(*sl->buffer_queue)->Enqueue(sl->buffer_queue, sl->buffer[i], BUFFER_SIZE);
(*sl->buffer_queue)->Enqueue(sl->buffer_queue, sl->buffer[i], sl->buf_size);
GOTO_IF_FAIL(SLObjectItf_GetInterface(sl->buffer_queue_object, SL_IID_PLAY, &sl->player));
GOTO_IF_FAIL(SLPlayItf_SetPlayState(sl->player, SL_PLAYSTATE_PLAYING));
@ -218,7 +230,7 @@ static ssize_t sl_write(void *data, const void *buf_, size_t size)
slock_unlock(sl->lock);
}
size_t avail_write = min(BUFFER_SIZE - sl->buffer_ptr, size);
size_t avail_write = min(sl->buf_size - sl->buffer_ptr, size);
if (avail_write)
{
memcpy(sl->buffer[sl->buffer_index] + sl->buffer_ptr, buf, avail_write);
@ -228,9 +240,9 @@ static ssize_t sl_write(void *data, const void *buf_, size_t size)
written += avail_write;
}
if (sl->buffer_ptr >= BUFFER_SIZE)
if (sl->buffer_ptr >= sl->buf_size)
{
SLresult res = (*sl->buffer_queue)->Enqueue(sl->buffer_queue, sl->buffer[sl->buffer_index], BUFFER_SIZE);
SLresult res = (*sl->buffer_queue)->Enqueue(sl->buffer_queue, sl->buffer[sl->buffer_index], sl->buf_size);
sl->buffer_index = (sl->buffer_index + 1) % sl->buf_count;
__sync_fetch_and_add(&sl->buffered_blocks, 1);
sl->buffer_ptr = 0;
@ -243,22 +255,20 @@ static ssize_t sl_write(void *data, const void *buf_, size_t size)
}
}
//RARCH_LOG("Blocks: %u\n", sl->buffered_blocks);
return written;
}
static size_t sl_write_avail(void *data)
{
sl_t *sl = (sl_t*)data;
size_t avail = (sl->buf_count - (int)sl->buffered_blocks - 1) * BUFFER_SIZE + (BUFFER_SIZE - (int)sl->buffer_ptr);
size_t avail = (sl->buf_count - (int)sl->buffered_blocks - 1) * sl->buf_size + (sl->buf_size - (int)sl->buffer_ptr);
return avail;
}
static size_t sl_buffer_size(void *data)
{
sl_t *sl = (sl_t*)data;
return BUFFER_SIZE * sl->buf_count;
return sl->buf_size * sl->buf_count;
}
static bool sl_use_float(void *data)