Getting GameMaker to See Your OUYA Controllers


For anyone looking to get started developing for the OUYA with GameMaker, one of the first roadblocks you will hit, at least as of today, is getting GameMaker to see your OUYA controllers. Here we will go over a basic, single player, setup to get you on the road to making your app/game.


The first place to look in getting your controller working is to ensure Bluetooth Gamepad/iCade Support is enabled.This can be done inside your project by going into the Resources menu item and clicking Change Global Games Settings.

Access the Change Global Game Settigns Enable Bluetooth Gamepad/iCade Support

Next we need to create a script to hold the actual detection process, create a script called detect_controller and fill it with the following.


/* detect_controller()
 * This sets up the controllers, if any, in a pair of global variables
 * [Global Variables]
 * gp_count      - Represents the number of game pads detected
 * gp_connected  - Array of gamepad numbers that are valid

// Let's see what devices are connected
gp_count = gamepad_get_device_count();

// Setup some variables
controller = 0;

for (count = 0; count <= gp_count; count++)
    if (gamepad_is_connected(count))
        global.gp_connected[controller++] = count;

        // If any controllers are found then increment the count.


if (global.gp_count < 1)
    show_debug_message("No Controllers Connected, Use Keyboard");
    show_debug_message(string(global.gp_count) + " Controllers Detected");

Next we will create an object called obj_controller_detector, the name is not important, but it does lend itself well to the purpose. Once created, we need to ensure that it is persistent by double clicking on the new object and checking the persistent check box. With this set we do not have to place the object in every subsequent room, as it will carry over from this one.

Make Controller Detector Persistant

Then add a Create event and fill it with the following code.


/* This alarm is needed to ensure OUYA controllers are detected,
 * for some reason OUYA controllers are not available in the first
 * few frames.

// Setup the initial
global.gp_count = 0

alarm[0] = 3;

Then add an Alarm 0 event to the obj_controller_detector and fill it with the following.

obj_controller_detector.Alarm 0

//This tries to detect any controllers and get them ready to work

Now all you need to do is drop the obj_controller_detector into the first Room and it will take care of setting up a Global variable that will contain the slot numbers for each controller detected, global.gp_connected is the name of said variable. You do not need to add it to


Now that we have the global gp_connected variable if we want to refer to the first available controller we need to reference it by using the regular gamepad_button_check method as follows

Use of OUYA gamepad

/* Note PLAYER_ID should be defined in the player instance create function;
 * for a single player game 0 would be the first character so a proper
 * definition would be PLAYER_ID = 0;
 * Some of the button mappings are as follows:
 * gp_pad1 = O
 * gp_pad2 = U
 * gp_pad3 = Y
 * gp_pad4 = A
 * gp_padl = Dpad Left
 * gp_padu = Dpad Up
 * gp_padd = Dpad Down
 * gp_padr = Dpad Right

// This would detect a player 1 press of the "O" button
- By: Posted on:


Small ad here
Select a size at which to preview the size