Android: Add dynamic per-player peripheral support

Android: Add a UI shell for implementing peripherals

Android: Replace hardcoded mic assignment with dynamic

Android: Convert mic option to general recording option

Android: Hardcoded VMUs for controller 1

Android: Fix preferences and config for microphone

Android: Add defaults, documentation, and wiring
This commit is contained in:
Ender's Games 2018-08-21 10:07:07 -04:00
parent b5dc68dbac
commit 1619d85663
20 changed files with 484 additions and 143 deletions

View File

@ -89,9 +89,12 @@ public class GL2JNIActivity extends Activity {
prefs.getString(Gamepad.pref_player4, null), 3);
pad.deviceDescriptor_PlayerNum.remove(null);
boolean controllerTwoConnected = false;
boolean controllerThreeConnected = false;
boolean controllerFourConnected = false;
boolean player2connected = false;
boolean player3connected = false;
boolean player4connected = false;
int p2periphs[] = {0, 0};
int p3periphs[] = {0, 0};
int p4periphs[] = {0, 0};
for (HashMap.Entry<String, Integer> e : pad.deviceDescriptor_PlayerNum.entrySet()) {
String descriptor = e.getKey();
@ -99,22 +102,32 @@ public class GL2JNIActivity extends Activity {
switch (playerNum) {
case 1:
if (descriptor != null)
controllerTwoConnected = true;
if (descriptor != null) {
player2connected = true;
p2periphs[0] = prefs.getInt(Gamepad.p2_peripheral + 1, 0);
p2periphs[1] = prefs.getInt(Gamepad.p2_peripheral + 2, 0);
}
break;
case 2:
if (descriptor != null)
controllerThreeConnected = true;
if (descriptor != null) {
player3connected = true;
p3periphs[0] = prefs.getInt(Gamepad.p3_peripheral + 1, 0);
p3periphs[1] = prefs.getInt(Gamepad.p3_peripheral + 2, 0);
}
break;
case 3:
if (descriptor != null)
controllerFourConnected = true;
if (descriptor != null) {
player4connected = true;
p4periphs[0] = prefs.getInt(Gamepad.p4_peripheral + 1, 0);
p4periphs[1] = prefs.getInt(Gamepad.p4_peripheral + 2, 0);
}
break;
}
}
JNIdc.initControllers(new boolean[] { controllerTwoConnected,
controllerThreeConnected, controllerFourConnected });
JNIdc.initControllers(
new boolean[] { player2connected, player3connected, player4connected },
new int[][] { p2periphs, p3periphs, p4periphs });
int joys[] = InputDevice.getDeviceIds();
for (int joy: joys) {
String descriptor = null;
@ -189,8 +202,8 @@ public class GL2JNIActivity extends Activity {
setContentView(mView);
//setup mic
boolean micPluggedIn = prefs.getBoolean(Config.pref_mic, false);
if(micPluggedIn){
boolean micPluggedIn = prefs.getBoolean(Gamepad.pref_mic, false);
if (micPluggedIn) {
SipEmulator sip = new SipEmulator();
sip.startRecording();
JNIdc.setupMic(sip);

View File

@ -90,9 +90,12 @@ public class GL2JNINative extends NativeActivity {
prefs.getString(Gamepad.pref_player4, null), 3);
pad.deviceDescriptor_PlayerNum.remove(null);
boolean controllerTwoConnected = false;
boolean controllerThreeConnected = false;
boolean controllerFourConnected = false;
boolean player2connected = false;
boolean player3connected = false;
boolean player4connected = false;
int p2periphs[] = {0, 0};
int p3periphs[] = {0, 0};
int p4periphs[] = {0, 0};
for (HashMap.Entry<String, Integer> e : pad.deviceDescriptor_PlayerNum
.entrySet()) {
@ -101,22 +104,32 @@ public class GL2JNINative extends NativeActivity {
switch (playerNum) {
case 1:
if (descriptor != null)
controllerTwoConnected = true;
if (descriptor != null) {
player2connected = true;
p2periphs[0] = prefs.getInt(Gamepad.p2_peripheral + 1, 0);
p2periphs[1] = prefs.getInt(Gamepad.p2_peripheral + 2, 0);
}
break;
case 2:
if (descriptor != null)
controllerThreeConnected = true;
if (descriptor != null) {
player3connected = true;
p3periphs[0] = prefs.getInt(Gamepad.p3_peripheral + 1, 0);
p3periphs[1] = prefs.getInt(Gamepad.p3_peripheral + 2, 0);
}
break;
case 3:
if (descriptor != null)
controllerFourConnected = true;
if (descriptor != null) {
player4connected = true;
p4periphs[0] = prefs.getInt(Gamepad.p4_peripheral + 1, 0);
p4periphs[1] = prefs.getInt(Gamepad.p4_peripheral + 2, 0);
}
break;
}
}
JNIdc.initControllers(new boolean[] { controllerTwoConnected,
controllerThreeConnected, controllerFourConnected });
JNIdc.initControllers(
new boolean[] { player2connected, player3connected, player4connected },
new int[][] { p2periphs, p3periphs, p4periphs });
int joys[] = InputDevice.getDeviceIds();
for (int joy : joys) {
String descriptor = descriptor = InputDevice.getDevice(joy).getDescriptor();
@ -189,7 +202,7 @@ public class GL2JNINative extends NativeActivity {
setContentView(mView);
//setup mic
boolean micPluggedIn = prefs.getBoolean(Config.pref_mic, false);
boolean micPluggedIn = prefs.getBoolean(Gamepad.pref_mic, false);
if(micPluggedIn){
SipEmulator sip = new SipEmulator();
sip.startRecording();

View File

@ -21,7 +21,6 @@ public class Config {
public static int vibrationDuration = 20;
public static final String pref_mic = "mic_plugged_in";
public static final String pref_vmu = "vmu_floating";
public static String git_api = "https://api.github.com/repos/reicast/reicast-emulator/commits";

View File

@ -18,12 +18,15 @@ import android.view.KeyEvent;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.AdapterView;
import android.widget.ArrayAdapter;
import android.widget.Button;
import android.widget.CompoundButton;
import android.widget.CompoundButton.OnCheckedChangeListener;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.SeekBar;
import android.widget.Spinner;
import android.widget.TextView;
import android.widget.Toast;
@ -35,9 +38,9 @@ public class InputFragment extends Fragment {
private int listenForButton = 0;
private AlertDialog alertDialogSelectController;
private SharedPreferences sharedPreferences;
private SharedPreferences mPrefs;
private CompoundButton switchTouchVibrationEnabled;
private CompoundButton micPluggedIntoFirstController;
private CompoundButton micPluggedIntoController;
private Gamepad pad = new Gamepad();
Vibrator vib;
@ -56,10 +59,9 @@ public class InputFragment extends Fragment {
@Override
public void onViewCreated(View view, Bundle savedInstanceState) {
sharedPreferences = PreferenceManager
.getDefaultSharedPreferences(getActivity());
mPrefs = PreferenceManager.getDefaultSharedPreferences(getActivity());
Config.vibrationDuration = sharedPreferences.getInt(Config.pref_vibrationDuration, 20);
Config.vibrationDuration = mPrefs.getInt(Config.pref_vibrationDuration, 20);
vib = (Vibrator) getActivity().getSystemService(Context.VIBRATOR_SERVICE);
ImageView icon_a = (ImageView) getView().findViewById(
@ -84,7 +86,6 @@ public class InputFragment extends Fragment {
}
});
SharedPreferences mPrefs = PreferenceManager.getDefaultSharedPreferences(getActivity());
String home_directory = mPrefs.getString(Config.pref_home,
Environment.getExternalStorageDirectory().getAbsolutePath());
@ -95,7 +96,7 @@ public class InputFragment extends Fragment {
final LinearLayout vibLay = (LinearLayout) getView().findViewById(R.id.vibDuration_layout);
final SeekBar vibSeek = (SeekBar) getView().findViewById(R.id.vib_seekBar);
if (sharedPreferences.getBoolean(Config.pref_touchvibe, true)) {
if (mPrefs.getBoolean(Config.pref_touchvibe, true)) {
vibLay.setVisibility(View.VISIBLE);
} else {
vibLay.setVisibility(View.GONE);
@ -115,7 +116,7 @@ public class InputFragment extends Fragment {
public void onStopTrackingTouch(SeekBar seekBar) {
int progress = seekBar.getProgress() + 5;
sharedPreferences.edit().putInt(Config.pref_vibrationDuration, progress).apply();
mPrefs.edit().putInt(Config.pref_vibrationDuration, progress).apply();
Config.vibrationDuration = progress;
vib.vibrate(progress);
}
@ -124,14 +125,13 @@ public class InputFragment extends Fragment {
OnCheckedChangeListener touch_vibration = new OnCheckedChangeListener() {
public void onCheckedChanged(CompoundButton buttonView,
boolean isChecked) {
sharedPreferences.edit()
.putBoolean(Config.pref_touchvibe, isChecked).apply();
mPrefs.edit().putBoolean(Config.pref_touchvibe, isChecked).apply();
vibLay.setVisibility( isChecked ? View.VISIBLE : View.GONE );
}
};
switchTouchVibrationEnabled = (CompoundButton) getView().findViewById(
R.id.switchTouchVibrationEnabled);
boolean vibrate = sharedPreferences.getBoolean(Config.pref_touchvibe, true);
boolean vibrate = mPrefs.getBoolean(Config.pref_touchvibe, true);
if (vibrate) {
switchTouchVibrationEnabled.setChecked(true);
} else {
@ -139,23 +139,19 @@ public class InputFragment extends Fragment {
}
switchTouchVibrationEnabled.setOnCheckedChangeListener(touch_vibration);
micPluggedIntoFirstController = (CompoundButton) getView().findViewById(
R.id.micInPort2);
boolean micPluggedIn = sharedPreferences.getBoolean(Config.pref_mic,
false);
micPluggedIntoFirstController.setChecked(micPluggedIn);
if (getActivity().getPackageManager().hasSystemFeature(
PackageManager.FEATURE_MICROPHONE)) {
micPluggedIntoController = (CompoundButton) getView().findViewById(R.id.micEnabled);
boolean micPluggedIn = mPrefs.getBoolean(Gamepad.pref_mic, false);
micPluggedIntoController.setChecked(micPluggedIn);
if (getActivity().getPackageManager().hasSystemFeature(PackageManager.FEATURE_MICROPHONE)) {
// Microphone is present on the device
micPluggedIntoFirstController
micPluggedIntoController
.setOnCheckedChangeListener(new OnCheckedChangeListener() {
public void onCheckedChanged(CompoundButton buttonView,
boolean isChecked) {
sharedPreferences.edit().putBoolean(Config.pref_mic, isChecked).apply();
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
mPrefs.edit().putBoolean(Gamepad.pref_mic, isChecked).apply();
}
});
} else {
micPluggedIntoFirstController.setEnabled(false);
micPluggedIntoController.setEnabled(false);
}
Button buttonKeycodeEditor = (Button) getView().findViewById(
@ -164,10 +160,9 @@ public class InputFragment extends Fragment {
public void onClick(View v) {
InputModFragment inputModFrag = new InputModFragment();
getActivity()
.getSupportFragmentManager()
.beginTransaction()
.replace(R.id.fragment_container, inputModFrag,
"INPUT_MOD_FRAG").addToBackStack(null).commit();
.getSupportFragmentManager().beginTransaction()
.replace(R.id.fragment_container, inputModFrag, "INPUT_MOD_FRAG")
.addToBackStack(null).commit();
}
});
@ -246,20 +241,15 @@ public class InputFragment extends Fragment {
}
private void updateVibration() {
boolean touchVibrationEnabled = sharedPreferences.getBoolean(
Config.pref_touchvibe, true);
boolean touchVibrationEnabled = mPrefs.getBoolean(Config.pref_touchvibe, true);
switchTouchVibrationEnabled.setChecked(touchVibrationEnabled);
}
private void updateControllers() {
String deviceDescriptorPlayer1 = sharedPreferences.getString(
Gamepad.pref_player1, null);
String deviceDescriptorPlayer2 = sharedPreferences.getString(
Gamepad.pref_player2, null);
String deviceDescriptorPlayer3 = sharedPreferences.getString(
Gamepad.pref_player3, null);
String deviceDescriptorPlayer4 = sharedPreferences.getString(
Gamepad.pref_player4, null);
String deviceDescriptorPlayer1 = mPrefs.getString(Gamepad.pref_player1, null);
String deviceDescriptorPlayer2 = mPrefs.getString(Gamepad.pref_player2, null);
String deviceDescriptorPlayer3 = mPrefs.getString(Gamepad.pref_player3, null);
String deviceDescriptorPlayer4 = mPrefs.getString(Gamepad.pref_player4, null);
String labelPlayer1 = null, labelPlayer2 = null, labelPlayer3 = null, labelPlayer4 = null;
@ -319,6 +309,48 @@ public class InputFragment extends Fragment {
}
}
String[] periphs = getResources().getStringArray(R.array.peripherals);
Spinner p2periph1spnr = (Spinner) getView().findViewById(R.id.spnr_player2_periph1);
ArrayAdapter<String> p2periph1Adapter = new ArrayAdapter<String>(
getActivity(), R.layout.spinner_selected, periphs);
p2periph1Adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
p2periph1spnr.setAdapter(p2periph1Adapter);
String p2periph1 = String.valueOf(mPrefs.getInt(Gamepad.p2_peripheral + 1, 0));
p2periph1spnr.setSelection(p2periph1Adapter.getPosition(p2periph1), true);
p2periph1spnr.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
public void onItemSelected(AdapterView<?> parent, View view, int pos, long id) {
mPrefs.edit().putInt(Gamepad.p2_peripheral + 1, pos).apply();
}
public void onNothingSelected(AdapterView<?> arg0) {
}
});
Spinner p2periph2spnr = (Spinner) getView().findViewById(R.id.spnr_player2_periph2);
ArrayAdapter<String> p2periph2Adapter = new ArrayAdapter<String>(
getActivity(), R.layout.spinner_selected, periphs);
p2periph2Adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
p2periph2spnr.setAdapter(p2periph2Adapter);
String p2periph2 = String.valueOf(mPrefs.getInt(Gamepad.p2_peripheral + 2, 0));
p2periph2spnr.setSelection(p2periph2Adapter.getPosition(p2periph2), true);
p2periph2spnr.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
public void onItemSelected(AdapterView<?> parent, View view, int pos, long id) {
mPrefs.edit().putInt(Gamepad.p2_peripheral + 2, pos).apply();
}
public void onNothingSelected(AdapterView<?> arg0) {
}
});
TextView textViewDeviceDescriptorPlayer3 = (TextView) getView()
.findViewById(R.id.textViewDeviceDescriptorPlayer3);
Button buttonRemoveControllerPlayer3 = (Button) getView().findViewById(
@ -339,6 +371,46 @@ public class InputFragment extends Fragment {
}
}
Spinner p3periph1spnr = (Spinner) getView().findViewById(R.id.spnr_player3_periph1);
ArrayAdapter<String> p3periph1Adapter = new ArrayAdapter<String>(
getActivity(), R.layout.spinner_selected, periphs);
p3periph1Adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
p3periph1spnr.setAdapter(p3periph1Adapter);
String p3periph1 = String.valueOf(mPrefs.getInt(Gamepad.p3_peripheral + 1, 0));
p3periph1spnr.setSelection(p3periph1Adapter.getPosition(p3periph1), true);
p3periph1spnr.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
public void onItemSelected(AdapterView<?> parent, View view, int pos, long id) {
mPrefs.edit().putInt(Gamepad.p3_peripheral + 1, pos).apply();
}
public void onNothingSelected(AdapterView<?> arg0) {
}
});
Spinner p3periph2spnr = (Spinner) getView().findViewById(R.id.spnr_player3_periph2);
ArrayAdapter<String> p3periph2Adapter = new ArrayAdapter<String>(
getActivity(), R.layout.spinner_selected, periphs);
p3periph2Adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
p3periph2spnr.setAdapter(p3periph2Adapter);
String p3periph2 = String.valueOf(mPrefs.getInt(Gamepad.p3_peripheral + 2, 0));
p3periph2spnr.setSelection(p3periph2Adapter.getPosition(p3periph2), true);
p3periph2spnr.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
public void onItemSelected(AdapterView<?> parent, View view, int pos, long id) {
mPrefs.edit().putInt(Gamepad.p3_peripheral + 2, pos).apply();
}
public void onNothingSelected(AdapterView<?> arg0) {
}
});
TextView textViewDeviceDescriptorPlayer4 = (TextView) getView()
.findViewById(R.id.textViewDeviceDescriptorPlayer4);
Button buttonRemoveControllerPlayer4 = (Button) getView().findViewById(
@ -358,6 +430,46 @@ public class InputFragment extends Fragment {
buttonRemoveControllerPlayer4.setEnabled(false);
}
}
Spinner p4periph1spnr = (Spinner) getView().findViewById(R.id.spnr_player4_periph1);
ArrayAdapter<String> p4periph1Adapter = new ArrayAdapter<String>(
getActivity(), R.layout.spinner_selected, periphs);
p4periph1Adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
p4periph1spnr.setAdapter(p4periph1Adapter);
String p4periph1 = String.valueOf(mPrefs.getInt(Gamepad.p4_peripheral + 1, 0));
p4periph1spnr.setSelection(p2periph2Adapter.getPosition(p4periph1), true);
p4periph1spnr.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
public void onItemSelected(AdapterView<?> parent, View view, int pos, long id) {
mPrefs.edit().putInt(Gamepad.p4_peripheral + 1, pos).apply();
}
public void onNothingSelected(AdapterView<?> arg0) {
}
});
Spinner p4periph2spnr = (Spinner) getView().findViewById(R.id.spnr_player4_periph2);
ArrayAdapter<String> p4periph2Adapter = new ArrayAdapter<String>(
getActivity(), R.layout.spinner_selected, periphs);
p4periph2Adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
p4periph2spnr.setAdapter(p4periph2Adapter);
String p4periph2 = String.valueOf(mPrefs.getInt(Gamepad.p4_peripheral + 2, 0));
p4periph2spnr.setSelection(p2periph2Adapter.getPosition(p4periph2), true);
p4periph2spnr.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
public void onItemSelected(AdapterView<?> parent, View view, int pos, long id) {
mPrefs.edit().putInt(Gamepad.p4_peripheral + 2, pos).apply();
}
public void onNothingSelected(AdapterView<?> arg0) {
}
});
}
private void selectController(int playerNum) {
@ -414,14 +526,10 @@ public class InputFragment extends Fragment {
if (descriptor == null)
return false;
String deviceDescriptorPlayer1 = sharedPreferences.getString(
Gamepad.pref_player1, null);
String deviceDescriptorPlayer2 = sharedPreferences.getString(
Gamepad.pref_player2, null);
String deviceDescriptorPlayer3 = sharedPreferences.getString(
Gamepad.pref_player3, null);
String deviceDescriptorPlayer4 = sharedPreferences.getString(
Gamepad.pref_player4, null);
String deviceDescriptorPlayer1 = mPrefs.getString(Gamepad.pref_player1, null);
String deviceDescriptorPlayer2 = mPrefs.getString(Gamepad.pref_player2, null);
String deviceDescriptorPlayer3 = mPrefs.getString(Gamepad.pref_player3, null);
String deviceDescriptorPlayer4 = mPrefs.getString(Gamepad.pref_player4, null);
if (descriptor.equals(deviceDescriptorPlayer1)
|| descriptor.equals(deviceDescriptorPlayer2)
@ -436,16 +544,16 @@ public class InputFragment extends Fragment {
case 0:
return false;
case 1:
sharedPreferences.edit().putString(Gamepad.pref_player1, descriptor).apply();
mPrefs.edit().putString(Gamepad.pref_player1, descriptor).apply();
break;
case 2:
sharedPreferences.edit().putString(Gamepad.pref_player2, descriptor).apply();
mPrefs.edit().putString(Gamepad.pref_player2, descriptor).apply();
break;
case 3:
sharedPreferences.edit().putString(Gamepad.pref_player3, descriptor).apply();
mPrefs.edit().putString(Gamepad.pref_player3, descriptor).apply();
break;
case 4:
sharedPreferences.edit().putString(Gamepad.pref_player4, descriptor).apply();
mPrefs.edit().putString(Gamepad.pref_player4, descriptor).apply();
break;
}
@ -461,16 +569,16 @@ public class InputFragment extends Fragment {
private void removeController(int playerNum) {
switch (playerNum) {
case 1:
sharedPreferences.edit().putString(Gamepad.pref_player1, null).apply();
mPrefs.edit().putString(Gamepad.pref_player1, null).apply();
break;
case 2:
sharedPreferences.edit().putString(Gamepad.pref_player2, null).apply();
mPrefs.edit().putString(Gamepad.pref_player2, null).apply();
break;
case 3:
sharedPreferences.edit().putString(Gamepad.pref_player3, null).apply();
mPrefs.edit().putString(Gamepad.pref_player3, null).apply();
break;
case 4:
sharedPreferences.edit().putString(Gamepad.pref_player4, null).apply();
mPrefs.edit().putString(Gamepad.pref_player4, null).apply();
break;
}

View File

@ -22,7 +22,7 @@ public final class JNIdc
public static native void vjoy(int id,float x, float y, float w, float h);
//public static native int play(short result[],int size);
public static native void initControllers(boolean[] controllers);
public static native void initControllers(boolean[] controllers, int[][] peripherals);
public static native void setupMic(Object sip);
public static native void diskSwap(String disk);

View File

@ -23,6 +23,12 @@ public class Gamepad {
public static final String pref_player4 = "device_descriptor_player_4";
public static final String pref_pad = "controller";
public static final String pref_mic = "mic_plugged_in";
public static final String p2_peripheral = "p2_peripheral";
public static final String p3_peripheral = "p3_peripheral";
public static final String p4_peripheral = "p4_peripheral";
public static final String pref_js_modified = "modified_key_layout";
public static final String pref_js_compat = "controller_compat";
public static final String pref_js_merged = "merged_joystick";

View File

@ -36,7 +36,7 @@ JNIEXPORT void JNICALL Java_com_reicast_emulator_emu_JNIdc_kcode(JNIEnv * env, j
JNIEXPORT void JNICALL Java_com_reicast_emulator_emu_JNIdc_vjoy(JNIEnv * env, jobject obj,u32 id,float x, float y, float w, float h) __attribute__((visibility("default")));
//JNIEXPORT jint JNICALL Java_com_reicast_emulator_emu_JNIdc_play(JNIEnv *env,jobject obj,jshortArray result,jint size);
JNIEXPORT void JNICALL Java_com_reicast_emulator_emu_JNIdc_initControllers(JNIEnv *env, jobject obj, jbooleanArray controllers) __attribute__((visibility("default")));
JNIEXPORT void JNICALL Java_com_reicast_emulator_emu_JNIdc_initControllers(JNIEnv *env, jobject obj, jbooleanArray controllers, jobjectArray peripherals) __attribute__((visibility("default")));
JNIEXPORT void JNICALL Java_com_reicast_emulator_emu_JNIdc_setupMic(JNIEnv *env,jobject obj,jobject sip) __attribute__((visibility("default")));
JNIEXPORT void JNICALL Java_com_reicast_emulator_emu_JNIdc_diskSwap(JNIEnv *env,jobject obj, jstring newdisk) __attribute__((visibility("default")));
@ -186,6 +186,7 @@ static char CurFileName[256];
// Additonal controllers 2, 3 and 4 connected ?
static bool add_controllers[3] = { false, false, false };
int **controller_periphs;
u16 kcode[4];
u32 vks[4];
@ -256,6 +257,21 @@ void *libPvr_GetRenderSurface()
void common_linux_setup();
MapleDeviceType GetMapleDeviceType(int value)
{
switch (value)
{
case 1:
return MDT_SegaVMU;
case 2:
return MDT_Microphone;
case 3:
return MDT_PurupuruPack;
default:
return MDT_None;
}
}
void os_SetupInput()
{
// Create first controller
@ -265,7 +281,10 @@ void os_SetupInput()
for (int i = 0; i < 3; i++)
{
if (add_controllers[i])
mcfg_CreateController(i+1, MDT_None, MDT_None);
mcfg_CreateController(i + 1,
GetMapleDeviceType(controller_periphs[i + 1][0]),
GetMapleDeviceType(controller_periphs[i + 1][1])
);
}
}
@ -384,8 +403,17 @@ JNIEXPORT void JNICALL Java_com_reicast_emulator_emu_JNIdc_setupMic(JNIEnv *env,
{
sipemu = env->NewGlobalRef(sip);
getmicdata = env->GetMethodID(env->GetObjectClass(sipemu),"getData","()[B");
delete MapleDevices[0][1];
mcfg_Create(MDT_Microphone,0,1);
for (int i = 0; i < 3; i++)
{
if (controller_periphs[i + 1][0] == MDT_Microphone) {
delete MapleDevices[i + 1][0];
mcfg_Create(MDT_Microphone, i + 1, 0);
}
if (controller_periphs[i + 1][1] == MDT_Microphone) {
delete MapleDevices[i + 1][1];
mcfg_Create(MDT_Microphone, i + 1, 1);
}
}
}
JNIEXPORT void JNICALL Java_com_reicast_emulator_emu_JNIdc_setupVmu(JNIEnv *env,jobject obj,jobject vmu)
@ -527,11 +555,30 @@ JNIEXPORT void JNICALL Java_com_reicast_emulator_emu_JNIdc_vjoy(JNIEnv * env, jo
}
}
JNIEXPORT void JNICALL Java_com_reicast_emulator_emu_JNIdc_initControllers(JNIEnv *env, jobject obj, jbooleanArray controllers)
JNIEXPORT void JNICALL Java_com_reicast_emulator_emu_JNIdc_initControllers(JNIEnv *env, jobject obj, jbooleanArray controllers, jobjectArray peripherals)
{
jboolean *controllers_body = env->GetBooleanArrayElements(controllers, 0);
memcpy(add_controllers, controllers_body, 3);
env->ReleaseBooleanArrayElements(controllers, controllers_body, 0);
int obj_len = env->GetArrayLength(peripherals);
jintArray port = (jintArray) env->GetObjectArrayElement(peripherals, 0);
int port_len = env->GetArrayLength(port);
controller_periphs = new int*[obj_len];
for (int i = 0; i < obj_len; ++i) {
port = (jintArray) env->GetObjectArrayElement(peripherals, i);
jint *items = env->GetIntArrayElements(port, 0);
controller_periphs[i] = new int[port_len];
for (int j = 0; j < port_len; ++j) {
controller_periphs[i][j]= items[j];
}
}
for (int i = 0; i < obj_len; i++) {
jintArray port = (jintArray) env->GetObjectArrayElement(peripherals, i);
jint *items = env->GetIntArrayElements(port, 0);
env->ReleaseIntArrayElements(port, items, 0);
env->DeleteLocalRef(port);
}
}
// Audio Stuff

View File

@ -148,35 +148,35 @@
android:text="@string/launch_editor" />
</LinearLayout>
</TableRow>
<TableRow
<TableRow
android:layout_marginTop="25dp"
android:gravity="center_vertical" >
<LinearLayout
android:layout_width="wrap_content"
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:layout_marginLeft="6dp"
android:gravity="center_vertical" >
<ImageView
app:srcCompat="@drawable/mic_icon"
android:layout_width="48dp"
<ImageView
app:srcCompat="@drawable/mic_icon"
android:layout_width="48dp"
android:layout_height="48dp"
android:layout_centerInParent="true"
android:scaleType="fitCenter" />
<TextView
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="0.5"
android:ems="10"
android:gravity="center_vertical|left"
android:layout_marginLeft="6dp"
android:text="@string/mic_in_port_2" />
</LinearLayout>
<TextView
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="0.5"
android:ems="10"
android:gravity="center_vertical|left"
android:layout_marginLeft="6dp"
android:text="@string/enable_microphone" />
</LinearLayout>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
@ -185,7 +185,7 @@
android:orientation="vertical" >
<Switch
android:id="@+id/micInPort2"
android:id="@+id/micEnabled"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:focusable="true" />
@ -255,6 +255,15 @@
android:layout_height="wrap_content"
android:ems="10"
android:text="@string/controller_none_selected" />
<TextView
android:id="@+id/textViewPeripheralsPlayer1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:layout_marginLeft="5dp"
android:ems="10"
android:text="@string/controller_1_vmu" />
</LinearLayout>
</LinearLayout>
@ -337,6 +346,29 @@
android:layout_height="wrap_content"
android:ems="10"
android:text="@string/controller_none_selected" />
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:orientation="horizontal" >
<Spinner
android:id="@+id/spnr_player2_periph1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:ems="6"
android:entries="@array/peripherals" />
<Spinner
android:id="@+id/spnr_player2_periph2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:ems="6"
android:entries="@array/peripherals" />
</LinearLayout>
</LinearLayout>
</LinearLayout>
@ -419,6 +451,29 @@
android:layout_height="wrap_content"
android:ems="10"
android:text="@string/controller_none_selected" />
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:orientation="horizontal" >
<Spinner
android:id="@+id/spnr_player3_periph1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:ems="6"
android:entries="@array/peripherals" />
<Spinner
android:id="@+id/spnr_player3_periph2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:ems="6"
android:entries="@array/peripherals" />
</LinearLayout>
</LinearLayout>
</LinearLayout>
@ -501,6 +556,29 @@
android:layout_height="wrap_content"
android:ems="10"
android:text="@string/controller_none_selected" />
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:orientation="horizontal" >
<Spinner
android:id="@+id/spnr_player4_periph1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:ems="6"
android:entries="@array/peripherals" />
<Spinner
android:id="@+id/spnr_player4_periph2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:ems="6"
android:entries="@array/peripherals" />
</LinearLayout>
</LinearLayout>
</LinearLayout>

View File

@ -148,35 +148,35 @@
android:text="@string/launch_editor" />
</LinearLayout>
</TableRow>
<TableRow
<TableRow
android:layout_marginTop="25dp"
android:gravity="center_vertical" >
<LinearLayout
android:layout_width="wrap_content"
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:layout_marginLeft="6dp"
android:gravity="center_vertical" >
<ImageView
app:srcCompat="@drawable/mic_icon"
android:layout_width="48dp"
<ImageView
app:srcCompat="@drawable/mic_icon"
android:layout_width="48dp"
android:layout_height="48dp"
android:layout_centerInParent="true"
android:scaleType="fitCenter" />
<TextView
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="0.5"
android:ems="10"
android:gravity="center_vertical|left"
android:layout_marginLeft="6dp"
android:text="@string/mic_in_port_2" />
</LinearLayout>
<TextView
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="0.5"
android:ems="10"
android:gravity="center_vertical|left"
android:layout_marginLeft="6dp"
android:text="@string/enable_microphone" />
</LinearLayout>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
@ -185,7 +185,7 @@
android:orientation="vertical" >
<Checkbox
android:id="@+id/micInPort2"
android:id="@+id/micEnabled"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:focusable="true" />
@ -255,6 +255,15 @@
android:layout_height="wrap_content"
android:ems="10"
android:text="@string/controller_none_selected" />
<TextView
android:id="@+id/textViewPeripheralsPlayer1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:layout_marginLeft="5dp"
android:ems="10"
android:text="@string/controller_1_vmu" />
</LinearLayout>
</LinearLayout>
@ -337,6 +346,29 @@
android:layout_height="wrap_content"
android:ems="10"
android:text="@string/controller_none_selected" />
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:orientation="horizontal" >
<Spinner
android:id="@+id/spnr_player2_periph1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:ems="6"
android:entries="@array/peripherals" />
<Spinner
android:id="@+id/spnr_player2_periph2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:ems="6"
android:entries="@array/peripherals" />
</LinearLayout>
</LinearLayout>
</LinearLayout>
@ -419,6 +451,29 @@
android:layout_height="wrap_content"
android:ems="10"
android:text="@string/controller_none_selected" />
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:orientation="horizontal" >
<Spinner
android:id="@+id/spnr_player3_periph1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:ems="6"
android:entries="@array/peripherals" />
<Spinner
android:id="@+id/spnr_player3_periph2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:ems="6"
android:entries="@array/peripherals" />
</LinearLayout>
</LinearLayout>
</LinearLayout>
@ -501,6 +556,29 @@
android:layout_height="wrap_content"
android:ems="10"
android:text="@string/controller_none_selected" />
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:orientation="horizontal" >
<Spinner
android:id="@+id/spnr_player4_periph1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:ems="6"
android:entries="@array/peripherals" />
<Spinner
android:id="@+id/spnr_player4_periph2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:ems="6"
android:entries="@array/peripherals" />
</LinearLayout>
</LinearLayout>
</LinearLayout>

View File

@ -66,8 +66,7 @@
<string name="modified_layout">Aktiver brugerdefineret layout</string>
<string name="controller_compat">Aktiver kompatibilitesmode</string>
<string name="controller_unavailable">Gamepad IME detekteret!\nDeaktiver native interface</string>
<string name="mic_in_port_2">Mikrofon tilsluttet port 2</string>
<string name="customize_physical_controls">Tilpas fysiske taster</string>
<string name="map_keycode_title">Tilpas controller</string>
<string name="map_keycode_message">Tryk på den nye controller taste for %1$s</string>

View File

@ -75,8 +75,7 @@
<string name="modified_layout">Benutzerdefiniertes Layout</string>
<string name="controller_compat">Kompatibilitätsmodus aktivieren</string>
<string name="controller_unavailable">Gamepad-IME erkannt!\nBitte deaktivieren Sie das native Interface.</string>
<string name="mic_in_port_2">Mikrophon in Port 2 eingesteckt</string>
<string name="customize_physical_controls">Physische Controller anpassen</string>
<string name="map_keycode_title">Controller ändern</string>
<string name="map_keycode_message">Drücken Sie die neue Controller-Taste für %1$s</string>

View File

@ -72,8 +72,7 @@ Last Edit: 21 May 2014
<string name="modified_layout">Activer la fonction de disposition des touches</string>
<string name="controller_compat">Activer le mode de compatibilité</string>
<string name="controller_unavailable">Manette IME détéctée!\nVeuillez S\'il vous plait désactiver l\'interface native</string>
<string name="mic_in_port_2">Microphone branché au port 2</string>
<string name="customize_physical_controls">Customiser les touches physiques</string>
<string name="map_keycode_title">Modifier la manette</string>
<string name="map_keycode_message">Pressez une nouvelle touche pour %1$s</string>

View File

@ -72,8 +72,7 @@
<string name="modified_layout">Abilita la Disposizione Personalizzata dei Tasti</string>
<string name="controller_compat">Abilita Modalità di Compatibilità</string>
<string name="controller_unavailable">Rilevato Gamepad IME !\nPer favore disabilita l\'interfaccia nativa</string>
<string name="mic_in_port_2">Microfono inserito nella porta 2</string>
<string name="customize_physical_controls">Personalizza Controlli Fisici</string>
<string name="map_keycode_title">Modifica Controller</string>
<string name="map_keycode_message">Premi il nuovo tasto sul controller per %1$s</string>

View File

@ -58,8 +58,7 @@
<string name="joystick_layout">Dパッドとしてジョイスティックを使用</string>
<string name="modified_layout">カスタムキーレイアウトを有効に</string>
<string name="controller_compat">互換モードを有効に</string>
<string name="mic_in_port_2">ポート2に接続されたマイク</string>
<string name="customize_physical_controls">物理コントロールを編集</string>
<string name="map_keycode_title">コントローラを編集する</string>
<string name="map_keycode_message">%1$sボタンを押してください</string>

View File

@ -75,9 +75,8 @@
<string name="joystick_layout">Usar Joystick para entrada D-Pad</string>
<string name="modified_layout">Habilitar layout de botões personalizado</string>
<string name="controller_compat">Habilitar modo de compatibilidade</string>
<string name="controller_unavailable">Gamepad IME detectado!\nPor favor, desative a interface nativa</string>
<string name="mic_in_port_2">Microfone conectado na porta 2</string>
<string name="controller_unavailable">Gamepad IME detectado!\nPor favor, desative a interface nativa</string>
<string name="customize_physical_controls">Personalizar controles físicos</string>
<string name="map_keycode_title">Modificar controle</string>
<string name="map_keycode_message">Pressione o novo botão para o controle %1$s</string>

View File

@ -79,8 +79,7 @@
<string name="modified_layout">Разрешить изменение раскладки</string>
<string name="controller_compat">Режим совместимости</string>
<string name="controller_unavailable">Обнаружен Gamepad IME!\nПожалуйста, отключите нативный интерфейс</string>
<string name="mic_in_port_2">Подключить микрофон к порту 2</string>
<string name="customize_physical_controls">Настройка аппаратных кнопок</string>
<string name="map_keycode_title">Настройка контроллера</string>
<string name="map_keycode_message">Нажмите кнопку контроллера для %1$s</string>

View File

@ -40,7 +40,6 @@
<string name="controller_already_in_use">该控制器已被使用!</string>
<string name="modified_layout">启用自定义按键布局</string>
<string name="controller_compat">启用兼容模式</string>
<string name="mic_in_port_2">麦克风已插入 Port 2</string>
<string name="customize_physical_controls">自定义物理控制</string>
<string name="map_keycode_title">修改控制器</string>
<string name="map_keycode_message">按下控制器按钮来映射 %1$s</string>

View File

@ -40,7 +40,6 @@
<string name="controller_already_in_use">該控制器已被使用!</string>
<string name="modified_layout">啟用自定義按鍵布局</string>
<string name="controller_compat">啟用兼容模式</string>
<string name="mic_in_port_2">麥克風已插入 Port 2</string>
<string name="customize_physical_controls">自定義物理控制</string>
<string name="map_keycode_title">修改控制器</string>
<string name="map_keycode_message">按下控制器按鈕來映射 %1$s</string>

View File

@ -67,4 +67,11 @@
<item>pgc</item>
</string-array>
<string-array name="peripherals">
<item>None</item>
<item>VMU</item>
<item>Microphone</item>
<item>Purupuru</item>
</string-array>
</resources>

View File

@ -94,7 +94,8 @@
<string name="modified_layout">Enable Custom Key Layout</string>
<string name="controller_compat">Enable Compatibility Mode</string>
<string name="controller_unavailable">Gamepad IME detected!\nPlease disable native interface</string>
<string name="mic_in_port_2">Microphone plugged into port 2</string>
<string name="enable_microphone">Enable Microphone(s)</string>
<string name="controller_1_vmu">Includes 2 VMUs (Cannot be modified)</string>
<string name="customize_physical_controls">Customize Physical Controls</string>
<string name="map_keycode_title">Modify Controller</string>