Skip to content
This repository has been archived by the owner on Jul 10, 2023. It is now read-only.

Commit

Permalink
Android: Add dynamic per-player peripheral support
Browse files Browse the repository at this point in the history
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
  • Loading branch information
AbandonedCart committed Aug 21, 2018
1 parent b5dc68d commit 1619d85
Show file tree
Hide file tree
Showing 20 changed files with 484 additions and 143 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -89,32 +89,45 @@ protected void onCreate(Bundle icicle) {
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();
Integer playerNum = e.getValue();

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;
Expand Down Expand Up @@ -189,8 +202,8 @@ protected void onCreate(Bundle icicle) {
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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,9 +90,12 @@ protected void onCreate(Bundle icicle) {
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()) {
Expand All @@ -101,22 +104,32 @@ protected void onCreate(Bundle icicle) {

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();
Expand Down Expand Up @@ -189,7 +202,7 @@ public void run() {
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();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down
Loading

0 comments on commit 1619d85

Please sign in to comment.