Are you intending to develop Corona apps for your OUYA? Use this app as a starting point. I put this together myself in a few hours by experimenting; your milage may vary.
-- -- main.lua -- display.setStatusBar(display.HiddenStatusBar); local ouya = require("ouya"); local n\_screenWidth = display.contentWidth; local n\_screenHeight = display.contentHeight; local rect\_BehindBackground = display.newRect(-25, -25, n\_screenWidth+50, n\_screenHeight+50); rect\_BehindBackground:setFillColor(0, 0, 255); local rect\_Background = display.newRect(0, 0, n\_screenWidth, n\_screenHeight); rect\_Background:setFillColor(80, 80, 140); local text\_test = display.newText('Testing Ouya Buttons', 0, 0, native.systemFont, 64); text\_test:setTextColor(255, 255, 0); local text\_pxdim = display.newText('Pixel Width: '..display.pixelWidth..' Pixel Height: '..display.pixelHeight, 0, 100, native.systemFont, 64); text\_pxdim:setTextColor(255, 255, 0); local text\_contdim = display.newText('Content Width: '..n\_screenWidth..' Content Height: '..n\_screenHeight, 0, 200, native.systemFont, 64); text\_contdim:setTextColor(255, 255, 0); local text\_origin = display.newText('Origin X: '..display.screenOriginX..' Origin Y: '..display.screenOriginY, 0, 300, native.systemFont, 64); text\_origin:setTextColor(255, 255, 0); controllerListener = function(e) local buttonName = e.buttonName; local isDown = e.isDown; if(isDown) then text\_test.text = buttonName..' -\> press'; else text\_test.text = buttonName..' -\> release'; end end ouya.setListener(controllerListener); -- -- ouya.lua -- local callbackFunction = nil; local isListening = false; local ouyaListener = function(event) local e = {}; if(event.keyName == 'menu') then e.buttonName = 'POWER'; elseif(event.keyName == 'leftShoulderButton1') then e.buttonName = 'L1'; elseif(event.keyName == 'leftShoulderButton2') then e.buttonName = 'L2'; elseif(event.keyName == 'rightShoulderButton1') then e.buttonName = 'R1'; elseif(event.keyName == 'rightShoulderButton2') then e.buttonName = 'R2'; elseif(event.keyName == 'buttonX') then e.buttonName = 'U'; elseif(event.keyName == 'buttonY') then e.buttonName = 'Y'; elseif(event.keyName == 'buttonA') then e.buttonName = 'O'; elseif(event.keyName == 'buttonB') then e.buttonName = 'A'; else e.buttonName = event.keyName; end if (event.phase == "down") then e.isDown = true; elseif (event.phase == "up") then e.isDown = false; end callbackFunction(e); return true end local PUBLIC = {}; PUBLIC.setListener = function(c) if(c ~= nil) then callbackFunction = c; end if(isListening == false) then Runtime:addEventListener("key", ouyaListener); isListening = true; end end PUBLIC.removeListener = function() if(isListening) then Runtime:removeEventListener("key", ouyaListener); isListening = false; end end return PUBLIC; -- -- build.settings -- settings = { orientation = { default = "landscape", supported = { "landscape", } }, android = { mainIntentFilter = { categories = { "tv.ouya.intent.category.GAME" }, }, }, } -- -- config.lua -- application = { content = { width = 720, height = 1280, scale = "letterBox", xAlign = "center", yAlign = "center", imageSuffix = { ["@2x"] = 1.5, }, }, }
Notice that I forced the orientation to ‘landscape’ in build.settings and reversed my width and height in config.lua. I don’t know why this works, but it was the only way I could get the Ouya to stop cutting off the left and right edges of my screen.
Anyway, if you are wondering what my procedure is for loading/testing, I think I have it pretty well streamlined.
- Build for Android like you normally would
- Upload to dropbox
- On your Ouya, go to Make -> Software -> Browser
- When the Browser pops up, enter the URL of the APK you uploaded to dropbox. At first I found the Ouya browser to be fairly infuriating, but I discovered there is a way to create a bookmark and alter its URL. That made things so much easier later on. You may also want to put your dropbox public link to bit.ly to save yourself some typing.
- When the Ouya’s browser sees an APK you should see “Starting download…”
- Now back out of your browser, all the way back to the start, and go into Manage -> System -> Advanced.
- This resembles an actual Android settings page. Find your way to Storage -> Downloaded.
- You should see the APK you just downloaded. Select it and hit “O”. It will tell you you are about to install an app. Say yes.
- If your build.settings is correct, your app will show up under Play on the start page. If it doesn’t, look under Make -> Software.
Happy coding & what not,
GreenCastle