OUYA + Processing

First of all, as this is my first post, let me introduce myself: I am mdb, a OUYA owner since a few weeks, and a spare time programmer. 

I have already managed to load sketches that supports OUYA ODK (at least, controllers), with Processing IDE, using Android Mode. Could be a little tricky, as you have to re-compile the IDE, and Processing Android Mode with some modifications. But it works.

I have written a step-by-step guide hereI hope you could find this useful. 

Regards,
mdb.

Comments

  • trodosstrodoss Posts: 2Member
    Sounds excellent, however I tried to view the linked site without any success.
    If you would not mind re-posting the steps here it would be appreciated.
  • trodosstrodoss Posts: 2Member
    edited August 2013
    I did find information on Processing for Android:
    http://wiki.processing.org/w/Android

    I was also able to find the forums for Android Processing, and I noticed that there was a similar post there (search for "Ouya")
    http://forum.processing.org/android-processing

    I haven't been able to get to the page mdblabs.com/blog/ouya-processing-dev-hack/
    Post edited by trodoss on
  • mdblabsmdblabs Posts: 4Member
    I ´m sorry trodoss, but I have no problem accessing: link is ok, and server is up and running.

    Try to access via my blog, www.mdblabs.com/blog it will be the first entry. Or even www.mdblabs.com and then, the blog link.

    Yes, the origin of the post is the answer to the Ouya question in the Processing forum. I decided to post it here as well.


  • mdblabsmdblabs Posts: 4Member
    Here is a copy of my blog entry:

    "What do we need?

    1.-OUYA console. I have done it with a standard one, no dev, pre-release one.

    2.-Computer with the Android SDK installed, ant, etc, etc.

    3.-Console already set up. Follow this guide, from OUYA.

    Now, follow these steps:

    First of all, download the OUYA SDK (ODK) files from here, and save them in a good place (doesn’t matter where, as these libraries will be included in our Processing Sketch directory later).

    We need to replace one of the files in the ODK with a newer version. Unzip the odk-x.x.x.zip file. A OUYA-ODK directory will be created. There, inside the libs directory, we need to replace the commons-lang-2.6.jar with the newest version (at the time of writing, 3.1). You can download it here. Replace the older version file with the new one downloaded.

    Download Processing source code from its GitHub repository. We will need the Android Mode source code as well.

    First, we will compile Processing, following this instructions.

    Then, we need to modify two files in processing-android, in order to compile sketches for the 16 SDK. I followed this thread.

    AndroidBuild.java, in processing-android/src/processing/mode/android/

    static final String sdkName = "4.1.2";
    static final String sdkVersion = "16";

    build.xml in processing-android/core/

    <available file="${env.ANDROID_SDK}/platforms/android-16/android.jar"

    Now, compile first the processing-android core, to generate the android-core.zip, and then, compile the whole processing-android code.

    If everything finished with a “BUILD SUCCESSFULLY”, place the built Processing in your favorite directory (Applications, in my case), and run it. It will lunch the IDE and will generate the sketches directory, configured in the Preferences.

    Move the whole android-mode files inside the “modes” directory inside the Processing sketches directory. (In MacOS, Documents/Processing/modes/AndroidMode)

    Re-lunch the IDE. Now, you can change the mode to Android.This was the tricky part.

    After this, we are ready to configure the sketch in order to include the OUYA libs.

    Create a folder inside the sketch directory, name it “code”, and put in there all the ODK files.

    In the sketch, import all these Android libraries, in the beginning:

    import android.app.Activity;
    import android.os.Bundle;
    import android.view.KeyEvent;
    import android.view.InputEvent;
    import android.view.MotionEvent;
    import android.view.InputDevice;

    Now, you can add the functions necessary to configure the controllers in your sketch as usual. Just follow the official guide from the OUYA Dev page.  Program your sketch, connect your OUYA to your USB port, lunch the sketch in Android Mode, and you are done."

  • lapiezalapieza Posts: 3Member
    This looks great, but all the compiling seems a lil tricky, don't know if you can share some precompiled for windows or linux 32bits, for quick testing

    Anyways thanks for sharing, I'll favorite this page to look at it latter.
  • lapiezalapieza Posts: 3Member
    Hi, I managed to do your isntructions, and it's working thank you.

    My compiled AndroidMode.jar can be downloaded from my dropbox in this LINK .
    But I will like to add the same disclamer that mdlabs. (It's not fully tested, try it at your own risk).

    It was compiled on Windos XP, also tested it at Win7, soon will try on Linux (32bits all),
    I guess it will work as .jar seems to be multiplataform in most of the cases.

    For people that want to compile the .jar by themselves I recomend to use an apache ant installer cause it's easy to install ant that way.

    Also you don't need to compile Processing, but you need to download the source files cause you will need some of them to complie the android-core, because the build.xml look for them. In that step you will need to set an enviroment variable for ANDROID_SDK, with the path to the sdk location, or specify it on the build.xml.

    After compiled the AndrodMode.jar, I looked for the "modes" folder renamed the old AndroidMode.jar (in case I want to go back to it) and put the new in that folder, the forder is located the same as where the sketches are placed by default, in my case: mydocuments/processing/modes/androidMode/mode

    Finaly I don't think It's necesary to put the ODK in the sketch directoy in "code", because it seems that I'm not doing nothing with it, as I couldn't load the OuyaController class, and got to erase all the refrences to it in my Processing sketch in order to make it run.

    I did get the values for the inputs and controller IDs, and can use them on the sketches, and practically just had to deleted "OuyaController." from each line, and replace the the log.i for println.

    But I think something is missing to load the complete ODK, and that is needed to do the in app purchase/donate. 
    If someone wanna do that part and share it will be great.

    I'm really glad that the controller part it's working cause my first motivation for getting an OUYA, was to have an easy to carry and set up device for showing Processing sketches on interactive art expositions.

  • mdblabsmdblabs Posts: 4Member
    Thanks lapieza for looking further into my hack! Apreciated. 

    Yeah, the in app purchase is a point. I have no too much feedback from this hack, but if we can find more people interested, may be we can look for it.

  • lapiezalapieza Posts: 3Member
    For adding the library as usual in the library folder, you need to change the name of the ouya-odk folder from "OUYA-ODK" to "ouya" then you can import the ouya library without much trouble, including the store api.

    Having tested it yet, but in theory it's posible, as the other stuff seems to work as expected.
Sign In or Register to comment.