OUYA GameController
Monkey Targets Forums/Android/OUYA GameController
| ||
| Hi, I currently playing around with the ouya and the game controller. I have modified mojo.android.java for this purpose. It's working great but I'm also wondering if this could be done as module, but for this I somehow have to hook in the MonkeyView.onKeyDown and onKeyUp methods. Any ideas how this could be achieved? For those who are interested, here is the diff with these changes I made to the original mojo.android.java (it's a little bit hacky at the moment, what I'm basically doing is to remap the ouya codes to monkey key codes):
30,31d29
< import tv.ouya.console.api.OuyaController;
<
85,177d82
<
< public boolean onKeyUp( int key,KeyEvent event ){
< int player = OuyaController.getPlayerNumByDeviceId(event.getDeviceId());
< boolean handled = false;
< int sendKey = 0;
<
< switch(event.getKeyCode()){
< case OuyaController.BUTTON_O:
< sendKey = 79; // KEY_O
< handled = true;
< break;
<
< case OuyaController.BUTTON_U:
< sendKey = 85; // KEY_U
< handled = true;
< break;
<
< case OuyaController.BUTTON_Y:
< sendKey = 89; // KEY_Y
< handled = true;
< break;
<
< case OuyaController.BUTTON_A:
< sendKey = 65; // KEY_A
< handled = true;
< break;
<
< case OuyaController.BUTTON_DPAD_DOWN:
< sendKey = 40; // KEY_DOWN
< handled = true;
< break;
<
< case OuyaController.BUTTON_DPAD_LEFT:
< sendKey = 37; // KEY_LEFT
< handled = true;
< break;
<
< case OuyaController.BUTTON_DPAD_RIGHT:
< sendKey = 39; // KEY_RIGHT
< handled = true;
< break;
<
< case OuyaController.BUTTON_DPAD_UP:
< sendKey = 38; // KEY_UP
< handled = true;
< break;
<
< case OuyaController.BUTTON_L1:
< sendKey = 49; // KEY_1
< handled = true;
< break;
<
< case OuyaController.BUTTON_L2:
< sendKey = 50; // KEY_2
< handled = true;
< break;
<
< case OuyaController.BUTTON_L3:
< sendKey = 51; // KEY_3
< handled = true;
< break;
<
< case OuyaController.BUTTON_R1:
< sendKey = 56; // KEY_8
< handled = true;
< break;
<
< case OuyaController.BUTTON_R2:
< sendKey = 57; // KEY_9
< handled = true;
< break;
<
< case OuyaController.BUTTON_R3:
< sendKey = 48; // KEY_0
< handled = true;
< break;
<
< case OuyaController.BUTTON_SYSTEM:
< sendKey = 27; // KEY_ESCAPE
< handled = true;
< break;
< }
<
< if (handled) {
< app.input.OnKeyUp( sendKey );
< return true;
< }
<
< return false;
< }
180,268c85
< if (app == null) return false;
<
< int player = OuyaController.getPlayerNumByDeviceId(event.getDeviceId());
< boolean handled = false;
< int sendKey = 0;
<
< switch(event.getKeyCode()){
< case OuyaController.BUTTON_O:
< sendKey = 79; // KEY_O
< handled = true;
< break;
<
< case OuyaController.BUTTON_U:
< sendKey = 85; // KEY_U
< handled = true;
< break;
<
< case OuyaController.BUTTON_Y:
< sendKey = 89; // KEY_Y
< handled = true;
< break;
<
< case OuyaController.BUTTON_A:
< sendKey = 65; // KEY_A
< handled = true;
< break;
<
< case OuyaController.BUTTON_DPAD_DOWN:
< sendKey = 40; // KEY_DOWN
< handled = true;
< break;
<
< case OuyaController.BUTTON_DPAD_LEFT:
< sendKey = 37; // KEY_LEFT
< handled = true;
< break;
<
< case OuyaController.BUTTON_DPAD_RIGHT:
< sendKey = 39; // KEY_RIGHT
< handled = true;
< break;
<
< case OuyaController.BUTTON_DPAD_UP:
< sendKey = 38; // KEY_UP
< handled = true;
< break;
<
< case OuyaController.BUTTON_L1:
< sendKey = 49; // KEY_1
< handled = true;
< break;
<
< case OuyaController.BUTTON_L2:
< sendKey = 50; // KEY_2
< handled = true;
< break;
<
< case OuyaController.BUTTON_L3:
< sendKey = 51; // KEY_3
< handled = true;
< break;
<
< case OuyaController.BUTTON_R1:
< sendKey = 56; // KEY_8
< handled = true;
< break;
<
< case OuyaController.BUTTON_R2:
< sendKey = 57; // KEY_9
< handled = true;
< break;
<
< case OuyaController.BUTTON_R3:
< sendKey = 48; // KEY_0
< handled = true;
< break;
<
< case OuyaController.BUTTON_SYSTEM:
< sendKey = 27; // KEY_ESCAPE
< handled = true;
< break;
< }
<
< if (handled) {
< app.input.OnKeyDown( sendKey );
< return true;
< }
<
< if( !app.input.keyboardEnabled ) return false;
---
> if( app==null || !app.input.keyboardEnabled ) return false;
|
| ||
| Great to see some OUYA progress! How far have you gotten? Can you play your Monkey games on the OUYA? I was going to look into creating a target for OUYA, however I'm not getting the Android target to work at all atm, not sure why so I'm kinda stuck before I even started. |
| ||
| Yes, it works on the OUYA. :-) ![]() I can check for all OuyaButtons and the D-Pad with the standard Monkey KeyDown/Hit/... Commands. I've mapped the DPad to KEY_DOWN, KEY_UP, KEY_LEFT, KEY_RIGHT for example. The Touchpad works "out-of-the-box" with the Monkey Touch-Commands. Next I will implement the analog sticks. Should be quite easy if the OUYA-Docs is right. So, everthing is quite easy, I Just wondered if there is a better way than patching mojo directly (I'm no JAVA/Android expert, so don't know if I can hook me in between the MonkeyView-EventLIsteners and mojo). |
| ||
| Cool!! Just got Android working, phew! Feels like hacking mojo should be avoided? I'd be happy just having OUYA.Controller(1).Key.X OUYA.Controller(2).LeftPad.Direction And so on. Very simple to just replace or mod that few parts of code that uses KeyDown to use ouya instead. Or do we really want/need the Keydown function? |
| ||
| I'm quite new to the Android world myself - literally just got the Nexus 7 yesterday and was estatic on how easy it was to deploy to it ( i did it wirelessly through dropbox). However, i was trying to get it to deploy to Ouya but got this error message : Apk error: package must accept one OUYA intent: tv.ouya.intent.category.GAME or tv.ouya.intent.category.APP Any ideas what the heck this means? |
| ||
Update, ok just figured out now. Had to add in the AndroidManifest file : <category android:name="tv.ouya.intent.category.GAME"/> Now just waiting for approval to see how this thing works... |
| ||
| Ahh, sweet!! It shows up on the Dev section on the Ouya and i was able to install and run it now :)! Hmm...now i got to work on the key mappings... |
| ||
| Are you guys been able to have some lib to work with the OUYA ? |
| ||
| Yes! Just got got building & running directly to the OUYA on Win8! Was not easy, if anyone else having trouble with drivers N that let me know and I'' do my best to explain. the TouchPad is super crappy for me, not playable, I can't even double tap it! How about yours? The coolest thing is that my Xbox controller connected to the OUYA's usb port works perfect! |
| ||
| I got mine running on the Ouya, but not the controls. How did you get it to work? Its not picking up the keys that is being sent. |
| ||
| The controls work in other games - but not in Monkey games yet. |
| ||
| FYI: http://www.monkeycoder.co.nz/Community/posts.php?topic=4760 |
| ||
| I am wondering if this is any further forward, using Monkey to target OUYA, as I'd like to try out a simple demo and am after a tutorial |
| ||
| FYI: http://www.monkeycoder.co.nz/Community/posts.php?topic=4760#61172 |
