GamePad Input

This section deals with gamepad input for your game.

GameMaker: Studio has a number of dedicated functions that can be used to detect both analogue and digital controls from multiple connected game pads. These functions work similar to the Device Inputs, in that you can detect up to four different game pads that are connected and deal with the input from each one using the same functions. Note that when a gamepad is plugged in to your device (or it is removed) then an asynchronous System Event is triggered where you can deal with the situation using the appropriate functions.

When working with the gamepad functions, there are a number of built-in constants that should be used for getting/defining buttons and stick axis etc...:

Constant Description
gp_face1 Top button 1 (this maps to the "A" on an Xbox 360 controller and the cross on a PS controller)
gp_face2 Top button 2 (this maps to the "B" on an Xbox 360 controller and the circle on a PS controller)
gp_face3 Top button 3 (this maps to the "X" on an Xbox 360 controller and the square on a PS controller)
gp_face4 Top button 4 (this maps to the "Y" on an Xbox 360 controller and the triangle on a PS controller)
gp_shoulderl Left shoulder button
gp_shoulderlb Left shoulder trigger
gp_shoulderr Right shoulder button
gp_shoulderrb Right shoulder trigger
gp_select The select button (this is a touch-pad press on a PS4 controller)
gp_start The start button (this is the "options" button on a PS4 controller)
gp_stickl The left stick pressed (as a button)
gp_stickr The right stick pressed (as a button)
gp_padu D-pad up
gp_padd D-pad down
gp_padl D-pad left
gp_padr D-pad right
gp_axislh Left stick horizontal axis (analogue)
gp_axislv Left stick vertical axis (analogue)
gp_axisrh Right stick horizontal axis (analogue)
gp_axisrv Right stick vertical axis (analogue)


To better understand exactly what part of the controller each constant represents, you can refer to the following image of a standard gamepad:

Below you can find a list of all the gamepad functions:

Compatibility

The following list shows current compatibility across the platforms (note that this will change with future updates):

  • Windows is fully supported with up to a maximum of 4 connected devices permitted at once. Note that on Windows, gamepads are handled using the XInput dll, meaning that only XBox controllers may be 100% compatible and that other controller types may require third-party tools to function.

  • Mac OSX is supported with up to a maximum of 4 connected devices permitted at once, and these devices can ONLY be of the type Playstation3 or Xbox 360. Please note that the "Build for Mac AppStore" option in Mac Global Game Settings needs to be OFF for pad support to work.

  • Ubuntu does also support GamePad input, but you may need to install additional libraries from the Ubuntu repository. You can do this easily by opening a command line terminal and typing the following:

    GML Code Example

    sudo apt-get install jstest-gtk
     sudo apt-get install joystick.
     

    This will install GUI support for the joystick as well as the joystick itself.

  • HTML5 games are only supported by most major browsers, except Safari.

  • Gamepad support also extends to iOS with the iCade cabinet. The left axis maps to the stick controller (although the input is digital, not analogue), the four "face" buttons map to the cabinet front buttons, and the four shoulder buttons map to those at the back of the cabinet.

  • Android export supports NYKO controllers and generic Bluetooth controllers (including the OUYA), but only when they are enabled, meaning that you will have to tick the iCade/Bluetooth option in the Android Tab of the Global Game Settings. They require API level 12 for them to work fully and it should be noted that GameMaker: Studio will register as connected any Bluetooth devices that your device is paired with, whether or not it’s actually connected. Therefore this should be taken into account when assigning and checking "slots".

  • On PS4, if you want to use the touch pad tracking you need to use the device_mouse_* buttons.





No Examples Submitted

Does this page need better examples? Be the first to Submit

No Edits Suggested

Is this page unclear or not descriptive enough? Suggest an edit to the page and with enough upvotes your changes will be made.

No Questions Have Been Ask

Do you have a question about this page? Ask it Here