mirror of
https://github.com/moonlight-stream/moonlight-android.git
synced 2025-07-20 11:33:06 +00:00
added basic ouya input
This commit is contained in:
parent
3433ab1ccc
commit
ca3758106a
@ -19,11 +19,6 @@
|
|||||||
<activity
|
<activity
|
||||||
android:name="com.limelight.Connection"
|
android:name="com.limelight.Connection"
|
||||||
android:label="@string/app_name" >
|
android:label="@string/app_name" >
|
||||||
<intent-filter>
|
|
||||||
<action android:name="android.intent.action.MAIN" />
|
|
||||||
|
|
||||||
<category android:name="android.intent.category.LAUNCHER" />
|
|
||||||
</intent-filter>
|
|
||||||
</activity>
|
</activity>
|
||||||
<activity
|
<activity
|
||||||
android:name="com.limelight.Game"
|
android:name="com.limelight.Game"
|
||||||
@ -34,6 +29,12 @@
|
|||||||
<meta-data
|
<meta-data
|
||||||
android:name="android.support.PARENT_ACTIVITY"
|
android:name="android.support.PARENT_ACTIVITY"
|
||||||
android:value="com.limelight.Connection" />
|
android:value="com.limelight.Connection" />
|
||||||
|
<intent-filter>
|
||||||
|
<action android:name="android.intent.action.MAIN" />
|
||||||
|
|
||||||
|
<category android:name="android.intent.category.LAUNCHER" />
|
||||||
|
</intent-filter>
|
||||||
|
|
||||||
</activity>
|
</activity>
|
||||||
<service
|
<service
|
||||||
android:name="com.limelight.RelayService"></service>
|
android:name="com.limelight.RelayService"></service>
|
||||||
|
@ -34,9 +34,6 @@ or to a theme attribute in the form "<code>?[<i>package</i>:][<i>type</i>:]<i>na
|
|||||||
public static final class drawable {
|
public static final class drawable {
|
||||||
public static final int ic_launcher=0x7f020000;
|
public static final int ic_launcher=0x7f020000;
|
||||||
}
|
}
|
||||||
public static final class id {
|
|
||||||
public static final int videoView=0x7f080000;
|
|
||||||
}
|
|
||||||
public static final class layout {
|
public static final class layout {
|
||||||
public static final int activity_connection=0x7f030000;
|
public static final int activity_connection=0x7f030000;
|
||||||
public static final int activity_game=0x7f030001;
|
public static final int activity_game=0x7f030001;
|
||||||
@ -110,7 +107,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>"
|
<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>".
|
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;
|
public static final int ButtonBarContainerTheme_buttonBarButtonStyle = 1;
|
||||||
/**
|
/**
|
||||||
@ -120,7 +117,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>"
|
<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>".
|
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;
|
public static final int ButtonBarContainerTheme_buttonBarStyle = 0;
|
||||||
};
|
};
|
||||||
|
BIN
libs/ouya-sdk.jar
Normal file
BIN
libs/ouya-sdk.jar
Normal file
Binary file not shown.
@ -5,9 +5,9 @@
|
|||||||
android:background="#0099cc"
|
android:background="#0099cc"
|
||||||
tools:context=".Game" >
|
tools:context=".Game" >
|
||||||
|
|
||||||
<VideoView
|
<!--VideoView
|
||||||
android:id="@+id/videoView"
|
android:id="@+id/videoView"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent" />
|
android:layout_height="match_parent" /> -->
|
||||||
|
|
||||||
</FrameLayout>
|
</FrameLayout>
|
||||||
|
@ -16,22 +16,7 @@ public class Connection extends Activity {
|
|||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
setContentView(R.layout.activity_connection);
|
setContentView(R.layout.activity_connection);
|
||||||
|
|
||||||
new Thread(new Runnable() {
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void run() {
|
|
||||||
try {
|
|
||||||
new NvConnection("141.213.191.238").doShit();
|
|
||||||
} catch (XmlPullParserException e) {
|
|
||||||
// TODO Auto-generated catch block
|
|
||||||
e.printStackTrace();
|
|
||||||
} catch (IOException e) {
|
|
||||||
// TODO Auto-generated catch block
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}).start();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -1,8 +1,18 @@
|
|||||||
package com.limelight;
|
package com.limelight;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
|
|
||||||
|
import org.xmlpull.v1.XmlPullParserException;
|
||||||
|
|
||||||
|
import com.limelight.nvstream.NvConnection;
|
||||||
|
import com.limelight.nvstream.input.NvController;
|
||||||
|
import com.limelight.nvstream.input.NvInputPacket;
|
||||||
|
|
||||||
|
import tv.ouya.console.api.OuyaController;
|
||||||
import android.app.Activity;
|
import android.app.Activity;
|
||||||
import android.net.Uri;
|
import android.net.Uri;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
|
import android.view.KeyEvent;
|
||||||
import android.widget.MediaController;
|
import android.widget.MediaController;
|
||||||
import android.widget.VideoView;
|
import android.widget.VideoView;
|
||||||
|
|
||||||
@ -10,13 +20,33 @@ import android.widget.VideoView;
|
|||||||
public class Game extends Activity {
|
public class Game extends Activity {
|
||||||
private VideoView vv;
|
private VideoView vv;
|
||||||
private MediaController mc;
|
private MediaController mc;
|
||||||
|
private short inputMap = 0x0000;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onCreate(Bundle savedInstanceState) {
|
protected void onCreate(Bundle savedInstanceState) {
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
|
OuyaController.init(this);
|
||||||
|
|
||||||
|
new Thread(new Runnable() {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
try {
|
||||||
|
new NvConnection("141.213.191.238").doShit();
|
||||||
|
} catch (XmlPullParserException e) {
|
||||||
|
// TODO Auto-generated catch block
|
||||||
|
e.printStackTrace();
|
||||||
|
} catch (IOException e) {
|
||||||
|
// TODO Auto-generated catch block
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}).start();
|
||||||
|
|
||||||
setContentView(R.layout.activity_game);
|
setContentView(R.layout.activity_game);
|
||||||
|
|
||||||
vv = (VideoView) findViewById(R.id.videoView);
|
/*vv = (VideoView) findViewById(R.id.videoView);
|
||||||
|
|
||||||
mc = new MediaController(this);
|
mc = new MediaController(this);
|
||||||
mc.setAnchorView(vv);
|
mc.setAnchorView(vv);
|
||||||
@ -25,6 +55,139 @@ public class Game extends Activity {
|
|||||||
vv.setMediaController(mc);
|
vv.setMediaController(mc);
|
||||||
vv.setVideoURI(video);
|
vv.setVideoURI(video);
|
||||||
|
|
||||||
vv.start();
|
vv.start();*/
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean onKeyDown(int keyCode, KeyEvent event) {
|
||||||
|
// int player = OuyaController.getPlayerNumByDeviceId(event.getDeviceId());
|
||||||
|
|
||||||
|
switch (keyCode) {
|
||||||
|
case OuyaController.BUTTON_MENU:
|
||||||
|
System.out.println("Pressed Menu Button");
|
||||||
|
inputMap |= NvInputPacket.PLAY_FLAG;
|
||||||
|
break;
|
||||||
|
case OuyaController.BUTTON_DPAD_LEFT:
|
||||||
|
System.out.println("Pressed Dpad Left");
|
||||||
|
inputMap |= NvInputPacket.LEFT_FLAG;
|
||||||
|
break;
|
||||||
|
case OuyaController.BUTTON_DPAD_RIGHT:
|
||||||
|
System.out.println("Pressed Dpad Right");
|
||||||
|
inputMap |= NvInputPacket.RIGHT_FLAG;
|
||||||
|
break;
|
||||||
|
case OuyaController.BUTTON_DPAD_UP:
|
||||||
|
System.out.println("Pressed Dpad Up");
|
||||||
|
inputMap |= NvInputPacket.UP_FLAG;
|
||||||
|
break;
|
||||||
|
case OuyaController.BUTTON_DPAD_DOWN:
|
||||||
|
System.out.println("Pressed Dpad Down");
|
||||||
|
inputMap |= NvInputPacket.DOWN_FLAG;
|
||||||
|
break;
|
||||||
|
case OuyaController.BUTTON_A:
|
||||||
|
System.out.println("Pressed A");
|
||||||
|
inputMap |= NvInputPacket.B_FLAG;
|
||||||
|
break;
|
||||||
|
case OuyaController.BUTTON_O:
|
||||||
|
System.out.println("Pressed O");
|
||||||
|
inputMap |= NvInputPacket.A_FLAG;
|
||||||
|
break;
|
||||||
|
case OuyaController.BUTTON_U:
|
||||||
|
System.out.println("Pressed U");
|
||||||
|
inputMap |= NvInputPacket.X_FLAG;
|
||||||
|
break;
|
||||||
|
case OuyaController.BUTTON_Y:
|
||||||
|
System.out.println("Pressed Y");
|
||||||
|
inputMap |= NvInputPacket.Y_FLAG;
|
||||||
|
break;
|
||||||
|
case OuyaController.BUTTON_L1:
|
||||||
|
System.out.println("Pressed L1");
|
||||||
|
inputMap |= NvInputPacket.LB_FLAG;
|
||||||
|
break;
|
||||||
|
case OuyaController.BUTTON_R1:
|
||||||
|
System.out.println("Pressed R1");
|
||||||
|
inputMap |= NvInputPacket.RB_FLAG;
|
||||||
|
break;
|
||||||
|
case OuyaController.BUTTON_L3:
|
||||||
|
System.out.println("Pressed L3");
|
||||||
|
inputMap |= NvInputPacket.LS_CLK_FLAG;
|
||||||
|
break;
|
||||||
|
case OuyaController.BUTTON_R3:
|
||||||
|
System.out.println("Pressed R3");
|
||||||
|
inputMap |= NvInputPacket.RS_CLK_FLAG;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
System.out.println("Pressed some button: " + keyCode);
|
||||||
|
return super.onKeyDown(keyCode, event);
|
||||||
|
}
|
||||||
|
sendInputPacket();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean onKeyUp(int keyCode, KeyEvent event) {
|
||||||
|
switch (keyCode) {
|
||||||
|
case OuyaController.BUTTON_MENU:
|
||||||
|
System.out.println("Released Menu Button");
|
||||||
|
inputMap &= ~NvInputPacket.PLAY_FLAG;
|
||||||
|
break;
|
||||||
|
case OuyaController.BUTTON_DPAD_LEFT:
|
||||||
|
System.out.println("Released Dpad Left");
|
||||||
|
inputMap &= ~NvInputPacket.LEFT_FLAG;
|
||||||
|
break;
|
||||||
|
case OuyaController.BUTTON_DPAD_RIGHT:
|
||||||
|
System.out.println("Released Dpad Right");
|
||||||
|
inputMap &= ~NvInputPacket.RIGHT_FLAG;
|
||||||
|
break;
|
||||||
|
case OuyaController.BUTTON_DPAD_UP:
|
||||||
|
System.out.println("Released Dpad Up");
|
||||||
|
inputMap &= ~NvInputPacket.UP_FLAG;
|
||||||
|
break;
|
||||||
|
case OuyaController.BUTTON_DPAD_DOWN:
|
||||||
|
System.out.println("Released Dpad Down");
|
||||||
|
inputMap &= ~NvInputPacket.DOWN_FLAG;
|
||||||
|
break;
|
||||||
|
case OuyaController.BUTTON_A:
|
||||||
|
System.out.println("Released A");
|
||||||
|
inputMap &= ~NvInputPacket.B_FLAG;
|
||||||
|
break;
|
||||||
|
case OuyaController.BUTTON_O:
|
||||||
|
System.out.println("Released O");
|
||||||
|
inputMap &= ~NvInputPacket.A_FLAG;
|
||||||
|
break;
|
||||||
|
case OuyaController.BUTTON_U:
|
||||||
|
System.out.println("Released U");
|
||||||
|
inputMap &= ~NvInputPacket.X_FLAG;
|
||||||
|
break;
|
||||||
|
case OuyaController.BUTTON_Y:
|
||||||
|
System.out.println("Released Y");
|
||||||
|
inputMap &= ~NvInputPacket.Y_FLAG;
|
||||||
|
break;
|
||||||
|
case OuyaController.BUTTON_L1:
|
||||||
|
System.out.println("Released L1");
|
||||||
|
inputMap &= ~NvInputPacket.LB_FLAG;
|
||||||
|
break;
|
||||||
|
case OuyaController.BUTTON_R1:
|
||||||
|
System.out.println("Released R1");
|
||||||
|
inputMap &= ~NvInputPacket.RB_FLAG;
|
||||||
|
break;
|
||||||
|
case OuyaController.BUTTON_L3:
|
||||||
|
System.out.println("Released L3");
|
||||||
|
inputMap &= ~NvInputPacket.LS_CLK_FLAG;
|
||||||
|
break;
|
||||||
|
case OuyaController.BUTTON_R3:
|
||||||
|
System.out.println("Released R3");
|
||||||
|
inputMap &= ~NvInputPacket.RS_CLK_FLAG;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
System.out.println("Released some button: " + keyCode);
|
||||||
|
return super.onKeyUp(keyCode, event);
|
||||||
|
}
|
||||||
|
sendInputPacket();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void sendInputPacket() {
|
||||||
|
NvInputPacket inputPacket = new NvInputPacket(inputMap, (byte)0, (byte)0, (byte)0, (byte)0);
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -4,6 +4,8 @@ import java.io.IOException;
|
|||||||
|
|
||||||
import org.xmlpull.v1.XmlPullParserException;
|
import org.xmlpull.v1.XmlPullParserException;
|
||||||
|
|
||||||
|
import com.limelight.nvstream.input.NvController;
|
||||||
|
|
||||||
public class NvConnection {
|
public class NvConnection {
|
||||||
private String host;
|
private String host;
|
||||||
|
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
package com.limelight.nvstream;
|
package com.limelight.nvstream.input;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.OutputStream;
|
import java.io.OutputStream;
|
||||||
@ -7,6 +7,7 @@ import java.net.UnknownHostException;
|
|||||||
import java.nio.ByteBuffer;
|
import java.nio.ByteBuffer;
|
||||||
import java.nio.ByteOrder;
|
import java.nio.ByteOrder;
|
||||||
|
|
||||||
|
|
||||||
public class NvController {
|
public class NvController {
|
||||||
|
|
||||||
public final static int PORT = 35043;
|
public final static int PORT = 35043;
|
@ -1,4 +1,4 @@
|
|||||||
package com.limelight.nvstream;
|
package com.limelight.nvstream.input;
|
||||||
|
|
||||||
import java.nio.ByteBuffer;
|
import java.nio.ByteBuffer;
|
||||||
import java.nio.ByteOrder;
|
import java.nio.ByteOrder;
|
Loading…
x
Reference in New Issue
Block a user