This site requires JavaScript, please enable it in your browser!
Greenfoot back

Gamepad Setup Instructions

  • First download the project template from here. This contains all of the libraries and classes needed for interacting between your project and your gamepad.

  • Extract the project template from the zip file to somewhere on your machine.

  • Open it up in Greenfoot, and that's it! (You'll need a copy of this project for each of the projects that you want to use a gamepad with.)

Gamepad Classes

You can then use your gamepad using the two classes decribed below.

  • GamePad - JavaDoc

    A singleton class for retrieving the GamePad's currently plugged into your machine. Individual pads can be retrieved via it's static 'getGamePad' method.

    On the GamePad objects you can poll each of it's buttons and analog sticks using the 'isDown' and 'getAxis' methods.

    Finally the GamePad class holds two enums: Axis and Button. These are passed in when polling for the state of an analog stick or one of the buttons.

  • Direction - JavaDoc

    Movement on the analog sticks is returned as Direction objects. This holds the direction that the stick is moving in and the amount of force being expressed in that direction.

    If a stick is no longer moving then a Direction will hold the direction it was last moving in with a force of 0.