OUYA

Monkey Targets Forums/User Targets/OUYA

maverick69(Posted 2013) [#1]
Hi,

I just uplaoded my OUYA Target to GitHub. Feel free to use it or give feedback on how I can improve it:

https://github.com/JochenHeizmann/monkey-ouya


Neuro(Posted 2013) [#2]
This looks good, but i'm stuck at the "Compile transcc" section. Do i do this in dos prompt? I get a unrecognized message when trying to run RM.


maverick69(Posted 2013) [#3]
Are you on Windows?

The RM-Line just deletes the transcc.build folder. You can do this manually (it's probably not required at all but I wanted to play it safe).

You can also try to build transcc manually with Ted and the copy the build into your bin-Monkey folder.


Neuro(Posted 2013) [#4]
Yes i'm doing this on Windows. But i got it now to compile and the Ouya_game target does show up. However, when building the Ouya_game target i'm failing with this :

Translating...
Building...
FOPEN 'wb' for SaveString 'res/layout/main.xml' failed
TRANS FAILED: Android build failed.
Abnormal program termination. Exit code: -1



maverick69(Posted 2013) [#5]
This is because the layout-directory doesn't exist in the target-template (because git doesn't support empty directories). I've added it via a small hack, so just pull it and everything should be fine.


Neuro(Posted 2013) [#6]
Ok the res-layout issue is gone, but now no error messages at all but still fails. The Android target still builds just fine though.


maverick69(Posted 2013) [#7]
When does it fail? MonkeyTrans works fine, then ant fails building the APK? Or do you get a valid APK but it isn't deployed?


Rushino(Posted 2013) [#8]
Thanks for this. I havent tried it but it seem nice. I wish i had ordered the ouya.


Neuro(Posted 2013) [#9]
It fails during the Trans itself. What i did was re-built transcc in Monkey and copied and replaced the new transccc. However, since i was using Windows i didn't built it using the C++ Tool target, but rather GLFW..maybe thats my problem.




Neuro(Posted 2013) [#10]
Ok...figured out now to finally get it build without errors.

Aside from needing to rebuild transcc using the C++ Tool target, also had to copy the "ouyaiap" into modules (since it appears the template code was already using it). Now it builds beatifully :). Only thing is that i'm still at work and can't test it yet on the ouya...


maverick69(Posted 2013) [#11]
Copy ouyaiap into modules shouldn't be necessary. I will have a look at it.


Neuro(Posted 2013) [#12]
Yeah that was a fluke. Not sure why it works sometimes and other times it doesn't. But now when i run the game on Ouya, get a message saying its unable to run it now...weird cause if i built it directly to Android target and load on Ouya, it will actually run.


maverick69(Posted 2013) [#13]
whats the exact message?


Neuro(Posted 2013) [#14]
It says : "Unfortunately, has stopped". This goes for any games i've loaded.


maverick69(Posted 2013) [#15]
What's says logcat?


Tibit(Posted 2013) [#16]
I did not see this until now!

This is great!

I had on my ToDo list to create a proper OUYA target, and now before I even started it is done and ready, I love this community!

Thanks maverick69 for sharing. Will test on OUYA sooooon :)


Tibit(Posted 2013) [#17]
I encountered some error trying to build transcc.monkey using the C++ Tool

Here is the error:
C:\Google Drive\Projects - Games\Monkey Folder\MonkeyPro68c\bin\transcc_winnt.exe -build -config=release -target=C++_Tool -modpath="C:\Google Drive\Projects - Games\Monkey Folder\MonkeyPro68c\modules;C:\Google Drive\Projects - Games\Monkey Folder\MonkeyModulesFolder;"  "C:\Google Drive\Projects - Games\Monkey Folder\MonkeyPro68c\src\transcc\transcc.monkey"
TRANS monkey compiler V1.46
Parsing...
Semanting...
Translating...
Building...
main.cpp: In member function 'virtual c_Expr* c_Parser::p_ParseAddSubExpr()':
main.cpp:1012:16: warning: attempt to free a non-heap object 'String::nullRep' [-Wfree-nonheap-object]
main.cpp:1012:16: warning: attempt to free a non-heap object 'String::nullRep' [-Wfree-nonheap-object]
main.cpp: In member function 'virtual c_Expr* c_Parser::p_ParseBitandExpr()':
main.cpp:1012:16: warning: attempt to free a non-heap object 'String::nullRep' [-Wfree-nonheap-object]
main.cpp:1012:16: warning: attempt to free a non-heap object 'String::nullRep' [-Wfree-nonheap-object]
main.cpp: In member function 'virtual c_Expr* c_Parser::p_ParseOrExpr()':
main.cpp:1012:16: warning: attempt to free a non-heap object 'String::nullRep' [-Wfree-nonheap-object]
main.cpp:1012:16: warning: attempt to free a non-heap object 'String::nullRep' [-Wfree-nonheap-object]
main.cpp: In member function 'virtual c_Expr* c_Parser::p_ParseAndExpr()':
main.cpp:1012:16: warning: attempt to free a non-heap object 'String::nullRep' [-Wfree-nonheap-object]
main.cpp:1012:16: warning: attempt to free a non-heap object 'String::nullRep' [-Wfree-nonheap-object]
main.cpp: In member function 'virtual c_Expr* c_Parser::p_ParseBitorExpr()':
main.cpp:1012:16: warning: attempt to free a non-heap object 'String::nullRep' [-Wfree-nonheap-object]
main.cpp:1012:16: warning: attempt to free a non-heap object 'String::nullRep' [-Wfree-nonheap-object]
main.cpp: In member function 'virtual c_FuncDecl* c_ScopeDecl::p_FindFuncDecl(String, Array<c_Expr*>, int)':
main.cpp:1012:16: warning: attempt to free a non-heap object 'String::nullRep' [-Wfree-nonheap-object]
main.cpp: In member function 'virtual c_Expr* c_Parser::p_ParseMulDivExpr()':
main.cpp:1012:16: warning: attempt to free a non-heap object 'String::nullRep' [-Wfree-nonheap-object]
main.cpp:1012:16: warning: attempt to free a non-heap object 'String::nullRep' [-Wfree-nonheap-object]
main.cpp: In member function 'virtual c_Expr* c_Parser::p_ParseCompareExpr()':
main.cpp:1012:16: warning: attempt to free a non-heap object 'String::nullRep' [-Wfree-nonheap-object]
main.cpp:1012:16: warning: attempt to free a non-heap object 'String::nullRep' [-Wfree-nonheap-object]
main.cpp: In member function 'virtual int c_Parser::p_ParseDeclStmts()':
main.cpp:1012:16: warning: attempt to free a non-heap object 'String::nullRep' [-Wfree-nonheap-object]
main.cpp:1012:16: warning: attempt to free a non-heap object 'String::nullRep' [-Wfree-nonheap-object]
main.cpp: In function 'String bb_preprocessor_Eval(String, c_Type*)':
main.cpp:1012:16: warning: attempt to free a non-heap object 'String::nullRep' [-Wfree-nonheap-object]
main.cpp:1012:16: warning: attempt to free a non-heap object 'String::nullRep' [-Wfree-nonheap-object]
main.cpp:1012:16: warning: attempt to free a non-heap object 'String::nullRep' [-Wfree-nonheap-object]
main.cpp:1012:16: warning: attempt to free a non-heap object 'String::nullRep' [-Wfree-nonheap-object]
main.cpp: In member function 'virtual int c_Parser::p_ParseSelectStmt()':
main.cpp:1012:16: warning: attempt to free a non-heap object 'String::nullRep' [-Wfree-nonheap-object]
main.cpp:1012:16: warning: attempt to free a non-heap object 'String::nullRep' [-Wfree-nonheap-object]
main.cpp:1012:16: warning: attempt to free a non-heap object 'String::nullRep' [-Wfree-nonheap-object]
main.cpp:1012:16: warning: attempt to free a non-heap object 'String::nullRep' [-Wfree-nonheap-object]
main.cpp:1012:16: warning: attempt to free a non-heap object 'String::nullRep' [-Wfree-nonheap-object]
main.cpp:1012:16: warning: attempt to free a non-heap object 'String::nullRep' [-Wfree-nonheap-object]
main.cpp: In member function 'virtual c_Expr* c_Parser::p_ParsePrimaryExpr(int)':
main.cpp:1012:16: warning: attempt to free a non-heap object 'String::nullRep' [-Wfree-nonheap-object]
main.cpp:1012:16: warning: attempt to free a non-heap object 'String::nullRep' [-Wfree-nonheap-object]
main.cpp: In member function 'virtual int c_Parser::p_ParseTryStmt()':
main.cpp:1012:16: warning: attempt to free a non-heap object 'String::nullRep' [-Wfree-nonheap-object]
main.cpp:1012:16: warning: attempt to free a non-heap object 'String::nullRep' [-Wfree-nonheap-object]
main.cpp: In member function 'virtual int c_Parser::p_ImportModule(String, int)':
main.cpp:1012:16: warning: attempt to free a non-heap object 'String::nullRep' [-Wfree-nonheap-object]
Process ended with return code 0 at 17-Mar 01:23:58


Any suggestions?


Tibit(Posted 2013) [#18]
Actualy despite the slightly missleading ERROR monkeyC++Tool still spit out an exe. I tested it and it did contain OUYA_Game and it shows up as a Target in Jungle.

Great.

So I made a simple test:


I compile using Android target and it runs fine on the OUYA. But I cannot move around since there are no controller support.

I compile using Ouya target and I get:


So it appears the file does not get the correct libraries. However I checked in the newly created build folder and the required libraries are in /lib/

So why are they not imported? Or what can it be otherwise?


Tibit(Posted 2013) [#19]
Still not sure about why the imports fail for me.

However I was looking on how to get multiple Controllers working.

I made a Wrapper for OuyaController that can be wrapped in Monkey
Monkey Code:


Java Code: (Also needs a few more rows in MonkeyGame.java, see below!)


Then the only thing needed in the MonkeyGame.java file is this:
@Override
public boolean onKeyDown(int keyCode, KeyEvent event) {
boolean handled = OuyaController.onKeyDown(keyCode, event);
return handled || super.onKeyDown(keyCode, event);
}

@Override
public boolean onKeyUp(int keyCode, KeyEvent event) {
boolean handled = OuyaController.onKeyUp(keyCode, event);
return handled || super.onKeyUp(keyCode, event);
}

@Override
public boolean onGenericMotionEvent(MotionEvent event) {
boolean handled = OuyaController.onGenericMotionEvent(event);
return handled || super.onGenericMotionEvent(event);
}

And OUYA's class takes care of the rest.

We can then using Monkey use Ouya.Controller

Haven't been able to run the code yet, maybe you can make it work? Hope it helps a little anyway!


maverick69(Posted 2013) [#20]
Hi,

I guess it fails to compile beacuse there are missing some imports. Can you test the following please:

Can you add

Import ouyaiap.payment

...

PaymentWrapper.Init("foo", "bar", ["nothing"], True)


to your example from above.

I guess it doesn't work because I have some imports in the IAP Lib that are required even if you don't want to use it.

Will also have a look into it myself. If this is the problem I can easily fix it by adding some imports to the target.


maverick69(Posted 2013) [#21]
I've just pushed a hotfix. Can you please update and test it if it compiles now?


maverick69(Posted 2013) [#22]
BTW: I love your OuyaController-Class. I wanted to do something like that myself but haven't started yet.

Am I allowed to add it to my ouya target?


Tibit(Posted 2013) [#23]
Am I allowed to add it to my ouya target?

Of course, that was the very idea. That code is your code.

Slight update on java part of the controller:


I think the controller should really be in androidgame.java at the bottom. And the @override part needs to be inside a class. I think this is the public static class GameView extends GLSurfaceView{?

Also need to add:
OuyaController.init(this); in OnCreate in void init(){ in the same class as above.

I also noticed the extern OuyaController in monkey needs = "OuyaControllerWrap" and it should have Fields instead of most methods ofc! :)

My progress update:
With import and update I got compile errors, however those where due to my controller and once I fixed those it ran but I got a runtime exception which I think is due to the controller not being initialized.

Let me know how it goes! Eager to test on the OUYA :)


Neuro(Posted 2013) [#24]
What's says logcat?

How do you check this? Sorry not familiar enough with Android devices yet.


maverick69(Posted 2013) [#25]
http://developer.android.com/tools/help/logcat.html


Neuro(Posted 2013) [#26]
Whoohoooo!!! Finally got the damn Ouya controller to work now!!!!!!! I couldn't for the life of me get the Ouya target to run so I ended up just hacking the Android target based on the keycode mods by maverick. Not exactly the best way to do this...i'd rather have the target working but at least i'm finally getting somewhere with this now :).


Why0Why(Posted 2013) [#27]
Has anyone been using this regularly? Are the kinks worked out and what is the best way to use it?


DrT(Posted 2013) [#28]
Success. I've been able to target the Ouya Controller using some of the advise from this forum thread. Here is how I did it.

01) Set up monkey for the Android target according to the monkey docs.

02) Install the following items from the Android SDK Manager: Android SDK Tools, Android SDK Platform Tools, Android SDK Build Tools, Android 4.1.2 (API 16) SDK Platform, Intel X86 Atom System Image, Google USB Driver, and Intel X86 Emulator Accelerator (HAXM).

03) Instead of creating a new Ouya target as suggest by Maverick69, I decided to hack the existing Android target instead because I just plan on targeting the Ouya.

04) Go to C:\MonkeyPro70g\targets\android\template and edit the project properties files so that the android target is 16.

05) Copy the ouya-sdk file to C:\MonkeyPro70g\targets\android\template\libs.

06) Go to C:\MonkeyPro70g\targets\android\modules\native and edit the monkeytarget java file.

Add the following code to the top of the file.
import tv.ouya.console.api.OuyaController;


Add the following code to the top of the OnCreate method in the MonkeyGame class.
OuyaController.init(this);


Add the following code to the bottom of the MonkeyGame class.
@Override
public boolean onKeyDown(int keyCode, KeyEvent event) {
  boolean handled = OuyaController.onKeyDown(keyCode, event);
  return handled || super.onKeyDown(keyCode, event);
}
	
@Override
public boolean onKeyUp(int keyCode, KeyEvent event) {
  boolean handled = OuyaController.onKeyUp(keyCode, event);
  return handled || super.onKeyUp(keyCode, event);
}
	
@Override
public boolean onGenericMotionEvent(MotionEvent event) {
  boolean handled = OuyaController.onGenericMotionEvent(event);
  return handled || super.onGenericMotionEvent(event);
}

Add the following proof-of-concept code below the MonkeyGame class.
class MonkeyOuyaController {

  public static OuyaController controller;

  public static void OuyaStart() {
    controller  = OuyaController.getControllerByPlayer(0);
  }
  
  public static boolean OuyaOButton() {
    if (controller != null)
      return controller.getButton(OuyaController.BUTTON_O);
    return false;
  }

  public static float OuyaLeftJoystickX() {
    if (controller != null)
      return controller.getAxisValue(OuyaController.AXIS_LS_X);
    return 0.0f;
  }
	
}

07) Go to C:\MonkeyPro70g\targets\android\modules and edit the monkeytarget monkey file.

Add the following code to the bottom of the file.

Function OuyaStart:Void() = "MonkeyOuyaController.OuyaStart"
Function OuyaOButton:Bool() = "MonkeyOuyaController.OuyaOButton"
Function OuyaLeftJoystickX:Float() = "MonkeyOuyaController.OuyaLeftJoystickX"


08) Go to C:\MonkeyPro70g\targets\android\template\templates and edit the AndroidManifest XML document.

Replace the existing activing code with the following.

<activity
  android:name="MonkeyGame"
  android:label="${ANDROID_APP_LABEL}">
  <intent-filter>
    <action android:name="android.intent.action.MAIN" />
    <category android:name="android.intent.category.LAUNCHER" />
    <category android:name="tv.ouya.intent.category.GAME" />
  </intent-filter>
</activity>


09) Create a test program in Monkey.

Strict

Import mojo

Class MyApp Extends App

  Method OnCreate:Int()
    OuyaStart()
    SetUpdateRate(60)
    Return 0
  End

  Method OnRender:Int()
    Cls()
    If OuyaOButton()
      DrawText("O Button Pressed", 100, 100)
    EndIf
    DrawText(OuyaLeftJoystickX(), 100, 200)
    Return 0
  End
	
End

Function Main:Int()
  New MyApp()
  Return 0
End

10) Create an emulator with the Android AVD Manager. I used the following settings for testing purposes.
Device: 3.2" QVGA 320 x 480
Target: Android 4.1.2 - API 16
CPU/ABI: Intel Atom X86

11) Start the emulator.

12) Once the emulator is started, run your test program to make sure that it pops up in the emulator.

13) Since my computer is not near the Ouya, I transfer the apk file to it via the internet.

a) Go to your build folder\android\bin and ftp your MonkeyGame-debug.apk to
a folder in your website.

From the Ouya,

b) From the main menu, go to MAKE then SOFTWARE to get to your web browser. Direct the browser to your apk and it will be downloaded.

c) From the main menu, go to MANAGE then SYSTEM then ADVANCED. Select Storage. Then select Downloads. Select your apk to install and open it.


Why0Why(Posted 2013) [#29]
Thanks for the step by step!


DrT(Posted 2013) [#30]
Got anytime querying (see Ouya Controller docs) working for all controls except the Home button.

Replace the MonkeyOuyaController Class in step 6 with the following code.

class MonkeyOuyaController {
	
	public static OuyaController controller1;
	public static OuyaController controller2;
	public static OuyaController controller3;
	public static OuyaController controller4;
	
	public static void OuyaStart() {
		controller1 = OuyaController.getControllerByPlayer(0);
		controller2 = OuyaController.getControllerByPlayer(1);
		controller3 = OuyaController.getControllerByPlayer(2);
		controller4 = OuyaController.getControllerByPlayer(3);
	}
	
	private static OuyaController GetOuyaController(int playerNumber) {
		OuyaController controller;
		switch (playerNumber) {
			case 1:
				controller = controller1;
				break;
			case 2:
				controller = controller2;
				break;
			case 3:
				controller = controller3;
				break;
			case 4:
				controller = controller4;
				break;
			default:
				controller = null;
				break;
		};
		return controller;
	}
	
	public static boolean OuyaOButton(int playerNumber) {
		OuyaController controller = GetOuyaController(playerNumber);
		if (controller != null)
			return controller.getButton(OuyaController.BUTTON_O);
		return false;
	}
	
	public static boolean OuyaUButton(int playerNumber) {
		OuyaController controller = GetOuyaController(playerNumber);
		if (controller != null)
			return controller.getButton(OuyaController.BUTTON_U);
		return false;
	}

	public static boolean OuyaYButton(int playerNumber) {
		OuyaController controller = GetOuyaController(playerNumber);
		if (controller != null)
			return controller.getButton(OuyaController.BUTTON_Y);
		return false;
	}

	public static boolean OuyaAButton(int playerNumber) {
		OuyaController controller = GetOuyaController(playerNumber);
		if (controller != null)
			return controller.getButton(OuyaController.BUTTON_A);
		return false;
	}

	public static boolean OuyaUpDPad(int playerNumber) {
		OuyaController controller = GetOuyaController(playerNumber);
		if (controller != null)
			return controller.getButton(OuyaController.BUTTON_DPAD_UP);
		return false;
	}
	
	public static boolean OuyaDownDPad(int playerNumber) {
		OuyaController controller = GetOuyaController(playerNumber);
		if (controller != null)
			return controller.getButton(OuyaController.BUTTON_DPAD_DOWN);
		return false;
	}

	public static boolean OuyaLeftDPad(int playerNumber) {
		OuyaController controller = GetOuyaController(playerNumber);
		if (controller != null)
			return controller.getButton(OuyaController.BUTTON_DPAD_LEFT);
		return false;
	}

	public static boolean OuyaRightDPad(int playerNumber) {
		OuyaController controller = GetOuyaController(playerNumber);
		if (controller != null)
			return controller.getButton(OuyaController.BUTTON_DPAD_RIGHT);
		return false;
	}	

	public static boolean OuyaLeftBumper(int playerNumber) {
		OuyaController controller = GetOuyaController(playerNumber);
		if (controller != null)
			return controller.getButton(OuyaController.BUTTON_L1);
		return false;
	}	

	public static float OuyaLeftTrigger(int playerNumber) {
		OuyaController controller = GetOuyaController(playerNumber);
		if (controller != null)
			return controller.getAxisValue(OuyaController.AXIS_L2);
		return 0.0f;
	}

	public static boolean OuyaRightBumper(int playerNumber) {
		OuyaController controller = GetOuyaController(playerNumber);
		if (controller != null)
			return controller.getButton(OuyaController.BUTTON_R1);
		return false;
	}	

	public static float OuyaRightTrigger(int playerNumber) {
		OuyaController controller = GetOuyaController(playerNumber);
		if (controller != null)
			return controller.getAxisValue(OuyaController.AXIS_R2);
		return 0.0f;
	}

	public static float OuyaLeftJoystickX(int playerNumber) {
		OuyaController controller = GetOuyaController(playerNumber);
		if (controller != null)
			return controller.getAxisValue(OuyaController.AXIS_LS_X);
		return 0.0f;
	}

	public static float OuyaLeftJoystickY(int playerNumber) {
		OuyaController controller = GetOuyaController(playerNumber);
		if (controller != null)
			return controller.getAxisValue(OuyaController.AXIS_LS_Y);
		return 0.0f;
	}
	
	public static boolean OuyaLeftJoystickButton(int playerNumber) {
		OuyaController controller = GetOuyaController(playerNumber);
		if (controller != null)
			return controller.getButton(OuyaController.BUTTON_L3);
		return false;
	}
	
	public static float OuyaRightJoystickX(int playerNumber) {
		OuyaController controller = GetOuyaController(playerNumber);
		if (controller != null)
			return controller.getAxisValue(OuyaController.AXIS_RS_X);
		return 0.0f;
	}

	public static float OuyaRightJoystickY(int playerNumber) {
		OuyaController controller = GetOuyaController(playerNumber);
		if (controller != null)
			return controller.getAxisValue(OuyaController.AXIS_RS_Y);
		return 0.0f;
	}
	
	public static boolean OuyaRightJoystickButton(int playerNumber) {
		OuyaController controller = GetOuyaController(playerNumber);
		if (controller != null)
			return controller.getButton(OuyaController.BUTTON_R3);
		return false;
	}

}


Replace the function definitions in step 7 with the following code.

Function OuyaStart:Void() = "MonkeyOuyaController.OuyaStart"

Function OuyaOButton:Bool(playerNumber:int) = "MonkeyOuyaController.OuyaOButton"
Function OuyaUButton:Bool(playerNumber:int) = "MonkeyOuyaController.OuyaUButton"
Function OuyaYButton:Bool(playerNumber:int) = "MonkeyOuyaController.OuyaYButton"
Function OuyaAButton:Bool(playerNumber:int) = "MonkeyOuyaController.OuyaAButton"

Function OuyaUpDPad:Bool(playerNumber:int) = "MonkeyOuyaController.OuyaUpDPad"
Function OuyaDownDPad:Bool(playerNumber:int) = "MonkeyOuyaController.OuyaDownDPad"
Function OuyaLeftDPad:Bool(playerNumber:int) = "MonkeyOuyaController.OuyaLeftDPad"
Function OuyaRightDPad:Bool(playerNumber:int) = "MonkeyOuyaController.OuyaRightDPad"

Function OuyaLeftBumper:Bool(playerNumber:Int) = "MonkeyOuyaController.OuyaLeftBumper"
Function OuyaLeftTrigger:Float(playerNumber:Int) = "MonkeyOuyaController.OuyaLeftTrigger"
	
Function OuyaRightBumper:Bool(playerNumber:Int) = "MonkeyOuyaController.OuyaRightBumper"
Function OuyaRightTrigger:Float(playerNumber:Int) = "MonkeyOuyaController.OuyaRightTrigger"

Function OuyaLeftJoystickX:Float(playerNumber:int) = "MonkeyOuyaController.OuyaLeftJoystickX"
Function OuyaLeftJoystickY:Float(playerNumber:int) = "MonkeyOuyaController.OuyaLeftJoystickY"
Function OuyaLeftJoystickButton:Bool(playerNumber:int) = "MonkeyOuyaController.OuyaLeftJoystickButton"

Function OuyaRightJoystickX:Float(playerNumber:int) = "MonkeyOuyaController.OuyaRightJoystickX"
Function OuyaRightJoystickY:Float(playerNumber:int) = "MonkeyOuyaController.OuyaRightJoystickY"
Function OuyaRightJoystickButton:Bool(playerNumber:int) = "MonkeyOuyaController.OuyaRightJoystickButton"


Replace the test program in step 9 with the following code.

Strict

Import mojo

Class MyApp Extends App

	Method OnCreate:Int()
		OuyaStart()
		SetUpdateRate(60)
		Return 0
	End
	
	Method OnRender:Int()
		Cls()
		If OuyaOButton(1)
			DrawText("O Button Pressed", 100, 25)
		EndIf
		If OuyaUButton(1)
			DrawText("U Button Pressed", 100, 50)
		EndIf
		If OuyaYButton(1)
			DrawText("Y Button Pressed", 100, 75)
		EndIf
		If OuyaAButton(1)
			DrawText("A Button Pressed", 100, 100)
		EndIf
		If OuyaUpDPad(1)
			DrawText("Up DPad Pressed", 100, 125)
		EndIf
		If OuyaDownDPad(1)
			DrawText("Down DPad Pressed", 100, 150)
		EndIf
		If OuyaLeftDPad(1)
			DrawText("Left DPad Pressed", 100, 175)
		EndIf
		If OuyaRightDPad(1)
			DrawText("Right DPad Pressed", 100, 200)
		EndIf
		If OuyaLeftBumper(1)
			DrawText("Left Bumper Pressed", 100, 225)
		EndIf
		DrawText("Left Trigger:  " + OuyaLeftTrigger(1), 100, 250)
		If OuyaRightBumper(1)
			DrawText("Right Bumper Pressed", 100, 275)
		EndIf
		DrawText("Right Trigger:  " + OuyaRightTrigger(1), 100, 300)
		DrawText("Left Joystick X:  " + OuyaLeftJoystickX(1), 100, 325)
		DrawText("Left Joystick Y:  " + OuyaLeftJoystickY(1), 100, 350)
		If OuyaLeftJoystickButton(1)
			DrawText("Left Joystick Button Pressed", 100, 375)
		EndIf
		DrawText("Right Joystick X:  " + OuyaRightJoystickX(1), 100, 400)
		DrawText("Right Joystick Y:  " + OuyaRightJoystickY(1), 100, 425)
		If OuyaRightJoystickButton(1)
			DrawText("Right Joystick Button Pressed", 100, 450)
		EndIf
		Return 0
	End
	
End

Function Main:Int()
	New MyApp()
	Return 0
End



zardon(Posted 2013) [#31]
This is great, looking forward to videos of this in action


jasongosen(Posted 2013) [#32]
I'm using this target and it's working great so far. Are there any plans to add some of the code here into the GitHub repo? I've been trying to implement the multiple controller code myself but have been having trouble.


AdamRedwoods(Posted 2013) [#33]
took a quick look and found a couple problems. so far I have one controller working, but the Screen's 0,0 seems to be off up in the corner off screen by about 20px. Anyone else have this problem?

also, exiting gives a crash
java.lang.RuntimeException: Unable to destroy activity {com.monkey/com.monkey.MonkeyGame}: java.lang.NullPointerException


i'll look into these and perhaps push to someone's github.


Spinal(Posted 2013) [#34]
I gave the above step-by-step a try and got an error -

Syntax error - unexpected token '='

on line

Function OuyaStart:Void() = "MonkeyOuyaController.OuyaStart"

using 71c. Can someone shed a little light on this? I assume I've done something wrong maybe, as everyone else seems to be managing OK.


AdamRedwoods(Posted 2013) [#35]
that step 7 should be placed in an EXTERN declaration.


AdamRedwoods(Posted 2013) [#36]
ok, now i'm getting strange array out of bounds errors, which seem to be originating from the PushErr() and PopErr().

digging deeper, I see that Java has deprecated Vector class (which Monkey's errStack is based on) due to concurrency problems.

Anyone else see this? ugggggghhhhh.


AdamRedwoods(Posted 2013) [#37]
concurrency issue with the Vector errStack....
http://monkeycoder.co.nz/Community/posts.php?topic=5567

i'll post my working Ouya target on github soon.

P.S. was able to get the miniB3D animation demo working, about 100 zombies @ 20 fps in DEBUG MODE. I think I can try to do better...


Spinal(Posted 2013) [#38]
OK, now I'm getting a whole pile of errors along the lines of -

[javac] Compiling 3 source files to /Users/me/Documents/monkey/My Games/ouyatest/ouyatetst.build/ouya/bin/classes
[javac] /Users/me/Documents/monkey/My Games/ouyatest/ouyatetst.build/ouya/src/com/monkey/MonkeyGame.java:1715: cannot find symbol
[javac] symbol : class gxtkGraphics
[javac] location: class com.monkey.c_GameDelegate
[javac] gxtkGraphics m__graphics=null;
[javac] ^


AdamRedwoods(Posted 2013) [#39]
after getting the Ouya to appear with google's driver, here's my monkey version, which is basically drag-n-drop into the targets folder.

https://github.com/adamredwoods/monkey-ouya

my steps:
[code]
1. unzip file, drop into targets folder. rename folder as "ouya"
2. copy examples/src/transcc/builders/builders.monkey file into Monkey folder of same name.
3. open transcc and compile for cpp_tool. (or copy my ouya differences over)
4. backup old transs, copy new one in.
5. profit.


Spinal(Posted 2013) [#40]
/Applications/Monkey/src/transcc/builders/builders.monkey<5> : Error : Module 'android_ndk' not found.


I think I'll give up on this indefinitely.

Right, now to become the first ever coder to have usable touch controls in an Android/iOS game....


AdamRedwoods(Posted 2013) [#41]
/Applications/Monkey/src/transcc/builders/builders.monkey<5> : Error : Module 'android_ndk' not found.

i'm using the latest monkey version, but you can comment out the "import android_ndk" and the "bulders.Set" ndk part, should work.


Oddball(Posted 2013) [#42]
Hey Adam I've got this working with all four controllers using all sticks, triggers, and buttons. I've tested with OUYA and Xbox360 controllers. The values can be a bit twitchy on the analogue sticks, but it's working well otherwise. Where do I send you the updated 'androidgame.java' so that you can add it to your repo?


AdamRedwoods(Posted 2013) [#43]
you can just send it zipped up in an email and i'll put it on github and do a pull to the others. unless you have a github fork setup yourself. awpiette at yahoo blah blah.


zoqfotpik(Posted 2013) [#44]
This looks great, I'm all over this. Great to have such good support for such a new product.

Question: Once you have a working game, how many hours approximately does it take to ready it for Ouya? Is it as simple as another Android platform?


computercoder(Posted 2013) [#45]
First, GREAT job getting this target up and working! I'm planning/have been on using it as my target for OUYA! :)

Just a few things about using this target that I have noticed. I modified the "ouya_joystick_test.monkey" example code as follows:

1) The buttons O,U,Y, A, L1, and R1 don't respond using the KeyDown() command.
2) For some reason O works with JoyDown(JoyA, 0), and shows up as the z-axis on the Left Stick
3) The same goes for L3 for the z-axis on the Left Stick and R3 on the z-axis on the Right Stick.
4) I have yet to figure out how to use multiple controllers to get the left and right sticks to work, although its setup in the target to support them.

The above code is modified to make use of all the features of the OUYA controller, but for ONE controller. However, if I use controllers 2 - 4, I do not get use of Left and Right stick movement, the O,U,Y,A buttons nor L1 and R1. Everything else seems to work just fine. I think if the mappings were supported correctly to the JoyDown/JoyHit commands or the KeyDown/KeyHit, it may work ok. I know that Mojo auto-detects input for the controllers on XNA, but I'm not sure how it handles Android in that manner.

So I am extremely happy I got full use of a single controller, but now I want to figure out the second, third, and fourth controllers :) I will continue to work on getting these mappings up.

Ideally, I want to be able to know which controller is sending which signals and handle them accordingly. I'd love to get the ID of the controller and then know the state of its controls.


Snader(Posted 2013) [#46]
EDIT: Already fixed by reinstalling MinGW..

Somehow I am not able to build transcc on windows. Getting this message:

cc1plus.exe: error: unrecognized command line option "-Wno-free-nonheap-object"
TRANS FAILED: Error executing 'g++ -Wno-free-nonheap-object -O3 -DNDEBUG -o main_winnt main.cpp -lwinmm -lws2_32', return code=1


Sensei(Posted 2013) [#47]
Hi guys,

I'm new to the Monkey scene (though had played with BB on Windows for a while beforehand).
I've managed to get various targets working including XNA, Android, etc, but I'm really struggling to get Ouya working.
I've copied maverick69's github Zip and followed the instructions to place files and configs where needed, but my problem currently is that I am unable to compile transcc successfully.
I'm running Windows 7 64bit.

In Commandline, I've done this:
C:\MonkeyPro73b\bin>transcc_winnt.exe -config=release -target=Glfw_Game -modpath="C:\MonkeyPro73b\modules;" -build "C:\MonkeyPro73b\src\transcc\transcc.monkey"

Beforte this I also tried using -target=C++_Tools but then I get invalid target:

C:\MonkeyPro73b\bin>transcc_winnt.exe -config=release -target=C++_Tool -modpath="C:\MonkeyPro73b\modules;C:\MonkeyPro73b\targets\ouya\modules;" -build "C:\MonkeyPro73b\src\transcc\transcc.monkey"
TRANS monkey compiler V1.51
TRANS FAILED: Invalid target

As it currently stands, I get this:

C:\MonkeyPro73b\bin>transcc_winnt.exe -config=release -target=Glfw_Game -modpath="C:\MonkeyPro73b\modules;C:\MonkeyPro73b\targets\ouya\modules;" -build "C:\MonkeyPro73b\src\transcc\transcc.monkey"
TRANS monkey compiler V1.51
Parsing...
Ouya Target
C:/MonkeyPro73b/src/transcc/builders/builders.monkey<2> : Error : Syntax error - expecting declaration.

I renamed the zip folder to ouya and it's in the path C:\MonkeyPro73b\targets\ouya with files in them (TARGET.MONKEY), etc

In my C:\MonkeyPro73b\src\transcc\builders\builders.monkey file the content is:
transcc


Import ouya Import android
Import android_ndk
Import flash
Import glfw
Import html5
Import ios
Import psm
Import stdcpp
Import win8
Import xna

Function Builders:StringMap<Builder>( tcc:TransCC )
Local builders:=New StringMap<Builder>

builders.Set "ouya",New OuyaBuilder( tcc ) builders.Set "android",New AndroidBuilder( tcc )
builders.Set "android_ndk",New AndroidNdkBuilder( tcc )
builders.Set "glfw",New GlfwBuilder( tcc )
builders.Set "html5",New Html5Builder( tcc )
builders.Set "ios",New IosBuilder( tcc )
builders.Set "flash",New FlashBuilder( tcc )
builders.Set "psm",New PsmBuilder( tcc )
builders.Set "stdcpp",New StdcppBuilder( tcc )
builders.Set "win8",New Win8Builder( tcc )
builders.Set "xna",New XnaBuilder( tcc )

Return builders
End

When I run transcc_winnt.exe on its own, I don't see the ouya target in the list:

C:\MonkeyPro73b\bin>transcc_winnt.exe
TRANS monkey compiler V1.51
TRANS Usage: transcc [-update] [-build] [-run] [-clean] [-config=...] [-target=...] [-cfgfile=...] [-modpath=...] <main_monkey_source_file>
Valid targets: Android_Game Flash_Game Glfw_Game Html5_Game Windows_8_Game Windows_Phone_8_Game Xna_Game
Valid configs: debug release

Anybody have any ideas how I can compile transcc?

**HELP** :)


rIKmAN(Posted 2013) [#48]
I *think* you have to compile trans using the stdcpp target, though I've never done it myself I'm sure I've read that on here somewhere.


Sensei(Posted 2013) [#49]
Thanks for the update rIKmAN.
I tried but basically, no matter which target I try, I consistently get an Invalid Target.
I did notice a type in the \builders\builders.monkey file though: I had deleted "Import" from the first line before transcc - I also compared the file to the original and the only addition now is the Import ouya and builders.Set "ouya",New OuyaBuilder( tcc ) lines.

Even if I type transcc_winnt.exe -update I get an invalid target.


Sensei(Posted 2013) [#50]
OK, as an "update" of sorts, I'm not sure why this is working, but I thought I'd download the latest monkey version 75c. I noticed that Mark added the android_ouya target in there. I copied that folder to my version 73b and Ouya appeared on my Target list. I tested it and it compiled perfectly onto my ouya! Happy days.
Don't ask me why this worked as I have no clue. It might be partly due to the previous configuration changes I added as per maverick69's GIT pack.


AdamRedwoods(Posted 2013) [#51]
re:invalid target

i usually have to put the target in quotes when using the command line.
-target="C++ Tool"
the target is case sensitive, and you may need spaces.


Sensei(Posted 2013) [#52]
Thanks Adam! Will keep that in mind for future.


computercoder(Posted 2013) [#53]
The reason it worked and the OUYA CE version did not is due to the fact you HAD Android target running. Mark's version uses "android" as the build system, but defines a new target name to the target called "Android (Ouya) Game"

Notice the android target "TARGET.MONKEY":
#TARGET_NAME="Android Game"
#TARGET_SYSTEM="android"
#TARGET_BUILDER="android"


And here's the android_ouya target "TARGET.MONKEY"
#TARGET_NAME="Android (Ouya) Game"
#TARGET_SYSTEM="android"
#TARGET_BUILDER="android"

The compiler knows which you are pointing at by the name. The fact they are in two separate folders allows the IDE to detect them as different targets.

Since you never successfully compiled transcc with the new "ouya" target type, it could NOT determine it existed even with the folder being in the targets folder.

Had you changed the "ouya" target "TARGET.MONKEY from:
#TARGET_NAME="Ouya Game"
#TARGET_SYSTEM="android"
#TARGET_BUILDER="ouya"

To the following:
#TARGET_NAME="Ouya Game"
#TARGET_SYSTEM="android"
#TARGET_BUILDER="android"

It would have just piggy-backed off the android builder already compiled into transcc. :)

I've played around with this target quite a bit and then just flat-out tried doing the changes above. I realized that since OUYA is based on the droid anyways, it should just work. In 75b I did try to do that, and watched it work. So realistically, you do not need to recompile the transcc. You do need to follow everything else to get the Android target running. Keep in mind that with OUYA, you need version 16 of the SDK. Just follow the OUYA installation instruction on their developer site to get everything set is the only extra step for OUYA above Android - and they even show you how to setup for the SDK to Android :)

I hope this helps!