mirror of
https://github.com/moonlight-stream/moonlight-android.git
synced 2026-02-16 10:31:07 +00:00
fiddled with analog sticks
This commit is contained in:
@@ -1,4 +1,11 @@
|
||||
eclipse.preferences.version=1
|
||||
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
|
||||
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6
|
||||
org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
|
||||
org.eclipse.jdt.core.compiler.compliance=1.6
|
||||
org.eclipse.jdt.core.compiler.debug.lineNumber=generate
|
||||
org.eclipse.jdt.core.compiler.debug.localVariable=generate
|
||||
org.eclipse.jdt.core.compiler.debug.sourceFile=generate
|
||||
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
|
||||
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
|
||||
org.eclipse.jdt.core.compiler.source=1.6
|
||||
|
||||
@@ -112,7 +112,7 @@ or to a theme attribute in the form "<code>?[<i>package</i>:][<i>type</i>:]<i>na
|
||||
|
||||
<p>Must be a reference to another resource, in the form "<code>@[+][<i>package</i>:]<i>type</i>:<i>name</i></code>"
|
||||
or to a theme attribute in the form "<code>?[<i>package</i>:][<i>type</i>:]<i>name</i></code>".
|
||||
@attr name android:buttonBarButtonStyle
|
||||
@attr name com.limelight:buttonBarButtonStyle
|
||||
*/
|
||||
public static final int ButtonBarContainerTheme_buttonBarButtonStyle = 1;
|
||||
/**
|
||||
@@ -122,7 +122,7 @@ or to a theme attribute in the form "<code>?[<i>package</i>:][<i>type</i>:]<i>na
|
||||
|
||||
<p>Must be a reference to another resource, in the form "<code>@[+][<i>package</i>:]<i>type</i>:<i>name</i></code>"
|
||||
or to a theme attribute in the form "<code>?[<i>package</i>:][<i>type</i>:]<i>name</i></code>".
|
||||
@attr name android:buttonBarStyle
|
||||
@attr name com.limelight:buttonBarStyle
|
||||
*/
|
||||
public static final int ButtonBarContainerTheme_buttonBarStyle = 0;
|
||||
};
|
||||
|
||||
@@ -15,7 +15,7 @@ public class Connection extends Activity {
|
||||
private SharedPreferences prefs;
|
||||
|
||||
private static final String DEFAULT_HOST = "141.213.191.238";
|
||||
public static final String HOST_KEY = "hostKey";
|
||||
public static final String HOST_KEY = "hostText";
|
||||
|
||||
|
||||
@Override
|
||||
@@ -27,7 +27,7 @@ public class Connection extends Activity {
|
||||
public void onPause() {
|
||||
SharedPreferences.Editor editor = prefs.edit();
|
||||
|
||||
editor.putString(Connection.HOST_KEY, this.hostText.toString());
|
||||
editor.putString(Connection.HOST_KEY, this.hostText.getText().toString());
|
||||
editor.apply();
|
||||
|
||||
super.onPause();
|
||||
|
||||
@@ -14,13 +14,19 @@ import tv.ouya.console.api.OuyaController;
|
||||
import android.app.Activity;
|
||||
import android.net.Uri;
|
||||
import android.os.Bundle;
|
||||
import android.view.InputDevice;
|
||||
import android.view.KeyEvent;
|
||||
import android.view.MotionEvent;
|
||||
import android.widget.MediaController;
|
||||
import android.widget.VideoView;
|
||||
|
||||
|
||||
public class Game extends Activity {
|
||||
private short inputMap = 0x0000;
|
||||
private byte leftTrigger = 0x0000;
|
||||
private byte rightTrigger = 0x0000;
|
||||
private int rightStick = 0x00000000;
|
||||
private int leftStick = 0x00000000;
|
||||
|
||||
private NvConnection conn;
|
||||
|
||||
@@ -163,7 +169,54 @@ public class Game extends Activity {
|
||||
return true;
|
||||
}
|
||||
|
||||
private void sendInputPacket() {
|
||||
conn.sendControllerInput(inputMap, (byte)0, (byte)0, (byte)0, (byte)0);
|
||||
@Override
|
||||
public boolean onGenericMotionEvent(MotionEvent event) {
|
||||
if ((event.getSource() & InputDevice.SOURCE_CLASS_JOYSTICK) != 0) {
|
||||
//Get all the axis for the event
|
||||
float LS_X = event.getAxisValue(OuyaController.AXIS_LS_X);
|
||||
float LS_Y = event.getAxisValue(OuyaController.AXIS_LS_Y);
|
||||
float RS_X = event.getAxisValue(OuyaController.AXIS_RS_X);
|
||||
float RS_Y = event.getAxisValue(OuyaController.AXIS_RS_Y);
|
||||
|
||||
if (LS_X * LS_X + LS_Y * LS_Y < OuyaController.STICK_DEADZONE * OuyaController.STICK_DEADZONE) {
|
||||
LS_X = LS_Y = 0.0f;
|
||||
}
|
||||
|
||||
if (RS_X * RS_X + RS_Y * RS_Y < OuyaController.STICK_DEADZONE * OuyaController.STICK_DEADZONE) {
|
||||
RS_X = RS_Y = 0.0f;
|
||||
}
|
||||
|
||||
System.out.println("LS_X: " + LS_X + "\t" +
|
||||
"LS_Y: " + LS_Y + "\t" +
|
||||
"RS_X: " + RS_X + "\t" +
|
||||
"RS_Y: " + RS_Y + "\t");
|
||||
|
||||
leftStick = ((int)Math.round(LS_X * 0x7FFF) << 16) & 0xFFFF0000;
|
||||
leftStick |= (int)Math.round(-LS_Y * 0x7FFF) & 0xFFFF;
|
||||
|
||||
rightStick = ((int)Math.round(RS_X * 0x7FFF) << 16) & 0xFFFF0000;
|
||||
rightStick |= (int)Math.round(-RS_Y * 0x7FFF) & 0xFFFF;
|
||||
|
||||
|
||||
System.out.printf("0x%x 0x%x\n", leftStick, rightStick);
|
||||
}
|
||||
|
||||
float L2 = event.getAxisValue(OuyaController.AXIS_L2);
|
||||
float R2 = event.getAxisValue(OuyaController.AXIS_R2);
|
||||
|
||||
System.out.println("L2: " + L2 + "\t" + " R2: " + R2 + "\t");
|
||||
|
||||
leftTrigger = (byte)Math.round(L2 * 0xFF);
|
||||
rightTrigger = (byte)Math.round(R2 * 0xFF);
|
||||
|
||||
sendInputPacket();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
private void sendInputPacket() {
|
||||
conn.sendControllerInput(inputMap, leftTrigger, rightTrigger, leftStick, rightStick);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -62,8 +62,11 @@ public class NvConnection {
|
||||
|
||||
public void sendControllerInput(final short buttonFlags,
|
||||
final byte leftTrigger, final byte rightTrigger,
|
||||
final short leftStick, final short rightStick)
|
||||
final int leftStick, final int rightStick)
|
||||
{
|
||||
if (inputStream == null)
|
||||
return;
|
||||
|
||||
threadPool.execute(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
|
||||
@@ -15,10 +15,11 @@ public class NvController {
|
||||
public NvController(String host) throws UnknownHostException, IOException
|
||||
{
|
||||
s = new Socket(host, PORT);
|
||||
s.setTcpNoDelay(true);
|
||||
out = s.getOutputStream();
|
||||
}
|
||||
|
||||
public void sendControllerInput(short buttonFlags, byte leftTrigger, byte rightTrigger, short leftStick, short rightStick) throws IOException
|
||||
public void sendControllerInput(short buttonFlags, byte leftTrigger, byte rightTrigger, int leftStick, int rightStick) throws IOException
|
||||
{
|
||||
out.write(new NvInputPacket(buttonFlags, leftTrigger, rightTrigger, leftStick, rightStick).toWire());
|
||||
out.flush();
|
||||
|
||||
@@ -28,31 +28,31 @@ public class NvInputPacket {
|
||||
0x00
|
||||
};
|
||||
|
||||
public static final short A_FLAG = 0x1000;
|
||||
public static final short B_FLAG = 0x2000;
|
||||
public static final short X_FLAG = 0x4000;
|
||||
public static final short Y_FLAG = (short)0x8000;
|
||||
public static final short UP_FLAG = 0x0001;
|
||||
public static final short DOWN_FLAG = 0x0002;
|
||||
public static final short LEFT_FLAG = 0x0004;
|
||||
public static final short RIGHT_FLAG = 0x0008;
|
||||
public static final short RB_FLAG = 0x0100;
|
||||
public static final short LB_FLAG = 0x0200;
|
||||
public static final short LS_CLK_FLAG = 0x0004;
|
||||
public static final short RS_CLK_FLAG = 0x0008;
|
||||
public static final short PLAY_FLAG = 0x0001;
|
||||
public static final short BACK_FLAG = 0x0002;
|
||||
public static final short A_FLAG = 0x0010;
|
||||
public static final short B_FLAG = 0x0020;
|
||||
public static final short X_FLAG = 0x0040;
|
||||
public static final short Y_FLAG = 0x0080;
|
||||
public static final short UP_FLAG = 0x0100;
|
||||
public static final short DOWN_FLAG = 0x0200;
|
||||
public static final short LEFT_FLAG = 0x0400;
|
||||
public static final short RIGHT_FLAG = 0x0800;
|
||||
public static final short RB_FLAG = 0x0001;
|
||||
public static final short LB_FLAG = 0x0002;
|
||||
public static final short LS_CLK_FLAG = 0x0400;
|
||||
public static final short RS_CLK_FLAG = 0x0800;
|
||||
public static final short PLAY_FLAG = 0x0100;
|
||||
public static final short BACK_FLAG = 0x0200;
|
||||
|
||||
public static final short PACKET_LENGTH = 28;
|
||||
|
||||
private short buttonFlags;
|
||||
private byte leftTrigger;
|
||||
private byte rightTrigger;
|
||||
private short leftStick;
|
||||
private short rightStick;
|
||||
private int leftStick;
|
||||
private int rightStick;
|
||||
|
||||
public NvInputPacket(short buttonFlags, byte leftTrigger, byte rightTrigger,
|
||||
short leftStick, short rightStick)
|
||||
int leftStick, int rightStick)
|
||||
{
|
||||
this.buttonFlags = buttonFlags;
|
||||
this.leftTrigger = leftTrigger;
|
||||
@@ -63,14 +63,14 @@ public class NvInputPacket {
|
||||
|
||||
public byte[] toWire()
|
||||
{
|
||||
ByteBuffer bb = ByteBuffer.allocate(PACKET_LENGTH).order(ByteOrder.LITTLE_ENDIAN);
|
||||
ByteBuffer bb = ByteBuffer.allocate(PACKET_LENGTH);
|
||||
|
||||
bb.put(HEADER);
|
||||
bb.putShort(buttonFlags);
|
||||
bb.put(leftTrigger);
|
||||
bb.put(rightTrigger);
|
||||
bb.putShort(leftStick);
|
||||
bb.putShort(rightStick);
|
||||
bb.putInt(leftStick);
|
||||
bb.putInt(rightStick);
|
||||
bb.put(TAIL);
|
||||
|
||||
return bb.array();
|
||||
|
||||
Reference in New Issue
Block a user