Skip to content

Commit a26ac7b

Browse files
committed
Merge branch 'c-compat' into develop
2 parents 17ea9ac + 61a04b3 commit a26ac7b

File tree

23 files changed

+361
-350
lines changed

23 files changed

+361
-350
lines changed

android/AndroidManifest.xml

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
<?xml version="1.0" encoding="utf-8"?>
22
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
33
package="com.rolandoislas.drcsimclient"
4-
android:versionCode="4"
5-
android:versionName="1.3" >
4+
android:versionCode="5"
5+
android:versionName="2.0" >
66

77
<uses-sdk android:minSdkVersion="9" android:targetSdkVersion="25" />
88

android/src/com/rolandoislas/drcsimclient/android/audio/AudioDevice.java

+4-1
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,9 @@ public void write(byte[] data) {
3838

3939
@Override
4040
public void write(byte[] data, int offset, int length) {
41-
audioTrack.write(data, offset, length);
41+
try {
42+
audioTrack.write(data, offset, length);
43+
}
44+
catch (IllegalStateException ignore) {}
4245
}
4346
}

build.gradle

+1-14
Original file line numberDiff line numberDiff line change
@@ -15,29 +15,19 @@ allprojects {
1515
apply plugin: "eclipse"
1616
apply plugin: "idea"
1717

18-
version = '1.2'
18+
version = '2.0'
1919
ext {
2020
appName = "drc-sim-client"
2121
gdxVersion = '1.9.4'
2222
roboVMVersion = '2.2.0'
23-
box2DLightsVersion = '1.4'
24-
ashleyVersion = '1.7.0'
25-
aiVersion = '1.8.0'
2623
guavaVersion = '19.0'
27-
gsonVersion = '2.8.0'
28-
beamApiVersion = '3.0.3-SNAPSHOT'
29-
beamInteractiveVersion = '1.5.1-SNAPSHOT'
3024
}
3125

3226
repositories {
3327
mavenLocal()
3428
mavenCentral()
3529
maven { url "https://oss.sonatype.org/content/repositories/snapshots/" }
3630
maven { url "https://oss.sonatype.org/content/repositories/releases/" }
37-
maven {
38-
name = "beam"
39-
url = "https://maven.beam.pro/content/repositories/snapshots"
40-
}
4131
}
4232
}
4333

@@ -52,8 +42,6 @@ project(":desktop") {
5242
compile "com.badlogicgames.gdx:gdx-controllers-desktop:$gdxVersion"
5343
compile "com.badlogicgames.gdx:gdx-controllers-platform:$gdxVersion:natives-desktop"
5444
compile "com.badlogicgames.gdx:gdx-freetype-platform:$gdxVersion:natives-desktop"
55-
compile "pro.beam:api:$beamApiVersion"
56-
compile "pro.beam:interactive:$beamInteractiveVersion"
5745
}
5846
}
5947

@@ -104,7 +92,6 @@ project(":core") {
10492
compile "com.badlogicgames.gdx:gdx:$gdxVersion"
10593
compile "com.badlogicgames.gdx:gdx-controllers:$gdxVersion"
10694
compile "com.google.guava:guava:$guavaVersion"
107-
compile "com.google.code.gson:gson:$gsonVersion"
10895
compile "com.badlogicgames.gdx:gdx-freetype:$gdxVersion"
10996
}
11097
}

core/src/com/rolandoislas/drcsimclient/Client.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ public Client(Control[] controls, Audio audio, ArgumentParser argumentParser) {
2525
Client.controls = controls;
2626
Client.audio = audio;
2727
Client.args = argumentParser;
28-
Logger.info("Starting %1$s version %2$s", Constants.NAME, Constants.VERSION);
28+
Logger.info("Starting %s version %s", Constants.NAME, Constants.VERSION);
2929
}
3030

3131
public Client(Control[] controls, Audio audio) {
@@ -67,7 +67,7 @@ public void resume() {
6767
}
6868

6969
public static void setStage(Stage stage) {
70-
Logger.debug("Setting stage to %1$s", stage.getClass().getSimpleName());
70+
Logger.debug("Setting stage to %s", stage.getClass().getSimpleName());
7171
try {
7272
Client.stage.dispose();
7373
}

core/src/com/rolandoislas/drcsimclient/audio/AudioThread.java

+8-5
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,14 @@ public void run() {
3333
}
3434
} catch (NetUtil.DisconnectedException e) {
3535
Logger.exception(e);
36-
running = false;
36+
Logger.info("Audio disconnected attempting to reconnect");
37+
try {
38+
Thread.sleep(5000);
39+
} catch (InterruptedException e1) {
40+
Logger.exception(e);
41+
}
42+
netUtil.resetTimeout();
43+
sockets.reconnectAudio();
3744
}
3845
}
3946
}
@@ -42,8 +49,4 @@ public void dispose() {
4249
running = false;
4350
audioUtil.dispose();
4451
}
45-
46-
public void resetTimeout() {
47-
netUtil.resetTimeout();
48-
}
4952
}

core/src/com/rolandoislas/drcsimclient/config/ConfigControllerConfig.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ public void set(String item, int input) {
5353
}
5454
@Override
5555
public String get(String key) {
56-
return config.getString(key);
56+
return String.valueOf(config.getInteger(key));
5757
}
5858

5959
}

core/src/com/rolandoislas/drcsimclient/control/ControlController.java

+6-7
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
import com.rolandoislas.drcsimclient.config.ConfigController;
77
import com.rolandoislas.drcsimclient.config.ConfigControllerConfig;
88
import com.rolandoislas.drcsimclient.data.Constants;
9-
import com.rolandoislas.drcsimclient.net.Codec;
109
import com.rolandoislas.drcsimclient.stage.StageControl;
1110

1211
import static com.rolandoislas.drcsimclient.Client.sockets;
@@ -24,7 +23,7 @@ public void init(StageControl stage) {
2423

2524
@Override
2625
public void update() {
27-
int buttonBits = 0;
26+
short buttonBits = 0;
2827
float[] axes = {0, 0, 0, 0};
2928
for (Controller controller : Controllers.getControllers()) {
3029
ConfigControllerConfig config = this.config.get(controller.getName());
@@ -65,12 +64,12 @@ public void update() {
6564
buttonBits |= Constants.BUTTON_HOME;
6665
// Microphone
6766
if (controller.getButton(config.micBlow))
68-
sockets.sendCommand(Constants.COMMAND_INPUT_MIC_BLOW, Codec.encodeInput(true));
67+
sockets.sendMicBlow();
6968
// Check joystick
70-
axes[0] = controller.getAxis(config.joystickLeftX);
71-
axes[1] = controller.getAxis(config.joystickLeftY);
72-
axes[2] = controller.getAxis(config.joystickRightX);
73-
axes[3] = controller.getAxis(config.joystickRightY);
69+
axes[0] = (short) controller.getAxis(config.joystickLeftX);
70+
axes[1] = (short) controller.getAxis(config.joystickLeftY);
71+
axes[2] = (short) controller.getAxis(config.joystickRightX);
72+
axes[3] = (short) controller.getAxis(config.joystickRightY);
7473
}
7574
sockets.sendButtonInput(buttonBits);
7675
sockets.sendJoystickInput(axes);

core/src/com/rolandoislas/drcsimclient/control/ControlKeyboard.java

+3-4
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
import com.badlogic.gdx.Gdx;
44
import com.rolandoislas.drcsimclient.config.ConfigKeyboard;
55
import com.rolandoislas.drcsimclient.data.Constants;
6-
import com.rolandoislas.drcsimclient.net.Codec;
76
import com.rolandoislas.drcsimclient.stage.StageControl;
87

98
import static com.rolandoislas.drcsimclient.Client.sockets;
@@ -23,7 +22,7 @@ public void init(StageControl stage) {
2322
@Override
2423
public void update() {
2524
// Check Buttons
26-
int buttonbits = 0;
25+
short buttonbits = 0;
2726
if (Gdx.input.isKeyPressed(config.buttonA))
2827
buttonbits |= Constants.BUTTON_A;
2928
if (Gdx.input.isKeyPressed(config.buttonB))
@@ -56,15 +55,15 @@ public void update() {
5655
buttonbits |= Constants.BUTTON_HOME;
5756
sockets.sendButtonInput(buttonbits);
5857
// Extra
59-
int extraButtonBits = 0;
58+
short extraButtonBits = 0;
6059
if (Gdx.input.isKeyPressed(config.buttonL3))
6160
extraButtonBits |= Constants.BUTTON_L3;
6261
if (Gdx.input.isKeyPressed(config.buttonR3))
6362
extraButtonBits |= Constants.BUTTON_R3;
6463
sockets.sendExtraButtonInput(extraButtonBits);
6564
// Mic
6665
if (Gdx.input.isKeyPressed(config.micBlow))
67-
sockets.sendCommand(Constants.COMMAND_INPUT_MIC_BLOW, Codec.encodeInput(true));
66+
sockets.sendMicBlow();
6867
// Joystick
6968
// TODO get joystick input based on mouse capture
7069
}

core/src/com/rolandoislas/drcsimclient/control/ControlTouch.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -113,9 +113,9 @@ public void init(StageControl stage) {
113113
public void update() {
114114
// Check touchpad (joystick) input
115115
if (touchpad.isTouched())
116-
sockets.sendJoystickInput(touchpad.getKnobPercentX(), touchpad.getKnobPercentY() * -1);
116+
sockets.sendJoystickInput(touchpad.getKnobPercentX(), touchpad.getKnobPercentY());
117117
// Check buttons
118-
int buttonBits = 0;
118+
short buttonBits = 0;
119119
if (buttonA.isPressed())
120120
buttonBits |= Constants.BUTTON_A;
121121
if (buttonB.isPressed())

core/src/com/rolandoislas/drcsimclient/data/Constants.java

+10-10
Original file line numberDiff line numberDiff line change
@@ -8,21 +8,21 @@
88
public class Constants {
99
// Info
1010
public static final String NAME = "DRC Sim Client";
11-
public static final String VERSION = "1.3";
11+
public static final String VERSION = "2.0";
1212
// Ports
1313
public static final int PORT_SERVER_VID = 50000;
1414
public static final int PORT_SERVER_AUD = 50001;
1515
public static final int PORT_SERVER_CMD = 50002;
1616
// Commands
17-
public static final String COMMAND_REGISTER = "REGISTER";
18-
public static final String COMMAND_INPUT_BUTTON = "INPUT_BUTTON";
19-
public static final String COMMAND_INPUT_BUTTON_EXTRA = "INPUT_L3R3"; // TODO rename on server
20-
public static final String COMMAND_INPUT_TOUCH = "INPUT_TOUCH";
21-
public static final String COMMAND_INPUT_JOYSTICK = "INPUT_JOYSTICK";
22-
public static final String COMMAND_INPUT_MIC_BLOW = "INPUT_MIC_BLOW";
23-
public static final String COMMAND_VIBRATE = "VIBRATE";
24-
public static final String COMMAND_PING = "PING";
25-
public static final String COMMAND_PONG = "PONG";
17+
public static final short COMMAND_REGISTER = 0;
18+
public static final short COMMAND_PING = 1;
19+
public static final short COMMAND_PONG = 2;
20+
public static final short COMMAND_INPUT_VIBRATE = 3;
21+
public static final short COMMAND_INPUT_MIC_BLOW = 4;
22+
public static final short COMMAND_INPUT_BUTTON = 5;
23+
public static final short COMMAND_INPUT_JOYSTICK = 6;
24+
public static final short COMMAND_INPUT_TOUCH = 7;
25+
public static final short COMMAND_INPUT_BUTTON_EXTRA = 8;
2626
// Buttons
2727
public static final int BUTTON_A = 0x8000;
2828
public static final int BUTTON_B = 0x4000;

core/src/com/rolandoislas/drcsimclient/graphics/VideoThread.java

+11-6
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,17 @@ public void run() {
3434
}
3535
} catch (NetUtil.DisconnectedException e) {
3636
Logger.exception(e);
37-
Logger.info("Disconnected");
38-
dispose();
37+
Logger.info("Video disconnected attempting to reconnect");
38+
synchronized (this) {
39+
imageData = new byte[1]; // Dirty way to get the main thread to update the video to the placeholder
40+
}
41+
try {
42+
Thread.sleep(5000);
43+
} catch (InterruptedException e1) {
44+
Logger.exception(e);
45+
}
46+
netUtil.resetTimeout();
47+
sockets.reconnectVideo();
3948
}
4049
}
4150
}
@@ -52,8 +61,4 @@ public byte[] getImageData() {
5261
}
5362
return data;
5463
}
55-
56-
public void resetTimeout() {
57-
netUtil.resetTimeout();
58-
}
5964
}

core/src/com/rolandoislas/drcsimclient/net/Codec.java

-50
This file was deleted.

0 commit comments

Comments
 (0)