Skip to content
Narta Xaymar Dirks edited this page Oct 30, 2026 · 7 revisions

Blitz3DBlitzBasic

GetJoy

GetJoy:Int32 port:Int32=0
Parameter Mode Type Default Description
port In Int32 0 The joystick to ask, counted from 0. Defaults to 0.

Returns: The number of the button that was pressed (counted from 1), or 0.

Description

Takes the next joystick button press out of a queue and returns the number of the button, or 0 if no button was pressed since the last call. It is the joystick counterpart of GetMouse. GetJoy is undocumented in the original help but exists in all three dialects.

Differences

  • Up to 32 buttons per joystick are supported, and a joystick with more reports only the first 32.

Examples

Graphics 320, 240, 0, 2
SetBuffer BackBuffer()
Local prev = 0
While Not KeyHit(1)
	Local b = GetJoy()
	If b Then prev = b
	Cls
	Text 10, 10, "Press a joystick button, Escape ends"
	Text 10, 30, "Last button: " + prev
	Flip
Wend

Related Commands

FlushJoy, JoyChanged, JoyDeviceConnected, JoyDeviceCount, JoyDeviceName, JoyDown, JoyHat, WaitJoy

Home · Command Index



Differences
Language Features
BlitzBasic
Blitz3D
BlitzPlus

Clone this wiki locally