MICILE EZ_Gamepad Documentation
version: 0.9
A few notes about our documentation:
  • The intentions of this documentation are to keep things simple.
  • Please see the examples at the end of each section for concrete examples of how to use each function.
  • If in doubt how to use a function, experiment!
  • We don't believe in writing more words just to make the documentation look more substantial
  • Quick Reference
    Function List
    Compatible Devices
    Generic DragonRise Gamepad
    Generic gamepad using the DragonRise chipset. Supports rumble motors!
    eBay / Amazon
    Frisby Wireless Gamepad

    Any USB Gamepad should be compatible.

    * Please contact us for information on adding support for a device.


    Gamepad Functions
    gamepad_names()
    Returns a list of the names of the gamepads that were found attached to the tablet. The position in the list is used with the gamepad_read_axis, gamepad_read_button, and gamepad_rumble functions.

    For example, this function might return ['Generic Gamepad', 'Namebrand Gamepad'] if two gamepads were attached to the tablet.
    gamepad_read_axis(gamepad_number, axis_number)
    Returns the value of the axis (0 to 255) for the gamepad specified by gamepad_number.

    Different joystick brands have the axis mapped differently between the thumbpad, and the two thumb sticks.

    Valid values of axis_number are:

    GAMEPAD_AXIS_X0
    GAMEPAD_AXIS_Y0
    GAMEPAD_AXIS_X1
    GAMEPAD_AXIS_Y1
    GAMEPAD_AXIS_X2
    GAMEPAD_AXIS_Y2
    gamepad_read_button(gamepad_number, button)
    Returns whether a button is depressed for the gamepad specified by gamepad_number.
    Most buttons are self explanatory, the STICKL and STICKR correspond to depressing the thumb joysticks.

    Valid values of button are:

    GAMEPAD_BTN_A
    GAMEPAD_BTN_B
    GAMEPAD_BTN_C
    GAMEPAD_BTN_X
    GAMEPAD_BTN_TL
    GAMEPAD_BTN_TR
    GAMEPAD_BTN_TL2
    GAMEPAD_BTN_TR2
    GAMEPAD_BTN_SELECT
    GAMEPAD_BTN_START
    GAMEPAD_BTN_STICKL
    GAMEPAD_BTN_STICKR
    gamepad_rumble(gamepad_number, milliseconds, left_strength, right_strenght)
    Turns on the forcefeedback rumble function of the gamepad specified by gamepad_number.
    Gamepads usually have a rumble pack on the left side and on the right side which can have independent strengths.
    For example if in a car racing game and a collision occurs on the right side of the car, only the right rumble pack would be activated.

    The length of the rumble in milliseconds came be set with the milliseconds parameter. Setting the milliseconds parameter to zero turns on a continous rumble. To turn off a rumble in progress, set the milliseconds parameter to a very short time like 1 millisecond.

    The left_strength and right_strength can have valid values of 0 to 65535 where 65535 is full rumble.
    # --------------------------------------------------
    # gamepad_demo.py
    # --------------------------------------------------
     
    # import the ez_graphics libary v0.9
    from ez_graphics_09 import *
     
    # import the ez_gamepad library v0.9
    from ez_gamepad_09 import *
     
    # Loop
    while True:
        # clear the background
        clear_screen('black')
     
        # draw the new joystick position
        set_color('red')
        fill_rect(gamepad_read_axis(0GAMEPAD_AXIS_X0)gamepad_read_axis(0GAMEPAD_AXIS_Y0)2020)
        
        # check for button press
        if gamepad_read_button(0GAMEPAD_BTN_A):
            # draw a box in the upper left hand corner
            set_color('blue')
            fill_rect(00100100)
            # make it rumble
            gamepad_rumble(05006553565535)
        
        # flip the buffering
        flip_page()

    gamepad demo