SecondBASIC Documentation v3

Home / Function Reference / JoyPad()

JoyPad()

Description: Returns the button state of a controller.

Syntax:

JoyPad(<port>)

Part Description
<port> Required. This is the port the controller is plugged into the console. 0 is Controller/Player 1 and 1 is Controller/Player 2.

Notes: If you're using a 3 button controller, it's not safe to assume that the upper bits will be cleared as they may be set based on button combinations.

Bit Hex Decimal Button
0 &H001 1 Up
1 &H002 2 Down
2 &H004 4 Left
3 &H008 8 Right
4 &H010 16 B
5 &H020 32 C
6 &H040 64 A
7 &H080 128 Start
8 &H100 256 Z
9 &H200 512 Y
10 &H400 1024 X
11 &H800 2048 Mode

Example:

        While 1
                j = JoyPad(0)
                If j.7 Then
                        Print "START"
                        Exit While
                End If
                Sleep 1
        Wend