BlitzMax

BlitzMax

  • Downloads
  • Docs
  • API
  • Resources
  • About

›BRL

BlitzMax API

  • Introduction

BRL

    Audio

    • Introduction
    • TChannel
    • TSound

    AudioSample

    • Introduction
    • TAudioSample
    • TAudioSampleLoader

    Bank

    • Introduction
    • TBank

    BankStream

    • Introduction
    • TBankStream

    Base64

    • Introduction
    • TBase64

    Blitz

    • Introduction
    • TArrayBoundsException
    • TBlitzException
    • TNullFunctionException
    • TNullMethodException
    • TNullObjectException
    • TOutOfDataException
    • TRuntimeException
  • BRL.BMPLoader
  • Clipboard

    • Introduction
    • TClipboard
    • TClipboardOpts
    • TWin32ClipboardOpts
    • TX11ClipboardOpts
  • BRL.D3D7Max2D
  • BRL.D3D9Max2D
  • BRL.DirectSoundAudio
  • BRL.EndianStream
  • Event

    • Introduction
    • TEvent
  • BRL.EventQueue
  • BRL.FileSystem
  • BRL.FreeAudioAudio
  • BRL.GLGraphics
  • BRL.GLMax2D
  • BRL.GNet
  • BRL.Graphics
  • BRL.Hook
  • IO

    • Introduction
    • MaxIO
  • BRL.JPGLoader
  • BRL.KeyCodes
  • LinkedList

    • Introduction
    • TList
    • TListEnum
    • TLink

    Map

    • Introduction
    • TMap
    • TIntMap
    • TIntKey
    • TPtrMap
    • TPtrKey
    • TStringMap
  • BRL.Math
  • Matrix

    • Introduction
    • SMat2D
    • SMat2F
    • SMat2I
    • SMat3D
    • SMat3F
    • SMat3I
    • SMat4D
    • SMat4F
    • SMat4I

    Max2D

    • Introduction
    • TImage

    MaxLua

    • Introduction
    • TLuaClass
    • TLuaObject
  • BRL.OGGLoader
  • BRL.OpenALAudio
  • ObjectList

    • Introduction
    • TObjectList
    • TObjectListEnumerator
    • TObjectListReverseEnumerator

    Pixmap

    • Introduction
    • TPixmap
    • TPixmapLoader
  • BRL.PNGLoader
  • BRL.PolledInput
  • Quaternion

    • Introduction
    • SQuatD
    • SQuatF
    • SQuatI
  • BRL.RamStream
  • Random

    • Introduction
    • TRandom

    Reflection

    • Introduction
    • TTypeId
    • TMember
    • TConstant
    • TField
    • TGlobal
    • TFunction
    • TMethod
  • BRL.Retro
  • BRL.Socket
  • BRL.SocketStream
  • BRL.StandardIO
  • Stream

    • Introduction
    • TCStream
    • TIO
    • TStream
    • TStreamException
    • TStreamFactory
    • TStreamReadException
    • TStreamWrapper
    • TStreamWriteException

    StringBuilder

    • Introduction
    • TStringBuilder
    • TSplitBuffer
  • BRL.System
  • BRL.SystemDefault
  • BRL.TextStream
  • BRL.TGALoader
  • ThreadPool

    • Introduction
    • TRunnable
    • TThreadPoolExecutor

    Threads

    • Introduction
    • TThread
    • TThreadData
    • TMutex
    • TSemaphore
    • TCondVar

    Timer

    • Introduction
    • TChrono
  • BRL.TimerDefault
  • Vector

    • Introduction
    • SVec2D
    • SVec2F
    • SVec2I
    • SVec3D
    • SVec3F
    • SVec3I
    • SVec4D
    • SVec4F
    • SVec4I

    Volumes

    • Introduction
    • TVolume
  • BRL.WAVLoader

Text

    CSV

    • Introduction
    • TCsvParser
    • TCsvHeader
    • TCsvRow
    • TCsvOptions
    • SCsvColumn

    Format

    • Introduction
    • TFormatter

    Ini

    • Introduction
    • TIni
    • TIniProperty
    • TIniSection

    JConv

    • Introduction
    • TJConv
    • TJConvBuilder
    • TJConvSerializer

    Json

    • Introduction
    • TJSON
    • TJSONObject
    • TJSONString
    • TJSONInteger
    • TJSONReal
    • TJSONBool
    • TJSONArray
    • TJSONNull
    • TJSONError
    • TJSONNumber

    Regex

    • Introduction
    • TRegEx
    • TRegExMatch
    • TRegExOptions
    • TRegExException

    TOML

    • Introduction
    • ETomlNodeType
    • TToml
    • ITomlNode
    • STomlDate
    • STomlDateTime
    • STomlTime
    • TTomlArray
    • TTomlInteger
    • TTomlString
    • TTomlTable
    • TTomlBoolean

    Xml

    • Introduction
    • TxmlDoc
    • TxmlNode
    • TxmlAttribute

MaxGUI

  • MaxGUI.MaxGUI
  • MaxGUI.Drivers
  • MaxGUI.Localization
  • MaxGUI.ProxyGadgets
  • MaxGUI.CocoaMaxGUI
  • MaxGUI.Win32MaxGUIEx

PUB

  • Pub.FreeJoy
  • Pub.FreeProcess
  • Pub.Glad
  • Pub.Glew
  • Joystick

    • Introduction
    • TJoystickDriver
  • Pub.Lua
  • Pub.OpenAL
  • Pub.OpenGLES
  • Pub.xmmintrin
  • Pub.ZLib

Crypto

    Digest

    • Introduction
    • TMessageDigest
    • TDigestRegister
    • TNoSuchAlgorithmException

    Cipher

    • Introduction
    • TCipher
    • TCipherMode
    • Crypto.AESCipher
    • Crypto.AnubisCipher
    • Crypto.BlowfishCipher
    • Crypto.CamelliaCipher
    • Crypto.Cast5Cipher
    • Crypto.DESCipher
    • Crypto.IdeaCipher
    • Crypto.KasumiCipher
    • Crypto.KhazadCipher
    • Crypto.KSeedCipher
    • Crypto.NoekeonCipher
    • Crypto.SerpentCipher
    • Crypto.SkipjackCipher
    • Crypto.TwofishCipher
    • Crypto.XTeaCipher

    CBCMode

    • Introduction
    • TCBCCipherMode

    CFBMode

    • Introduction
    • TCFBCipherMode

    CTRMode

    • Introduction
    • TCTRCipherMode

    ECBMode

    • Introduction
    • TECBCipherMode

    F8Mode

    • Introduction
    • TF8CipherMode

    LRWMode

    • Introduction
    • TLRWCipherMode

    OFBMode

    • Introduction
    • TOFBCipherMode

    XTSMode

    • Introduction
    • TXTSCipherMode

    Blake2BDigest

    • Introduction
    • TBlake2B_512
    • TBlake2B_384
    • TBlake2B_256
    • TBlake2B_160

    CRC32

    • Introduction
    • TCRC32

    MD5Digest

    • Introduction
    • TMD5

    Ripemd320Digest

    • Introduction
    • TRipemd320

    Ripemd356Digest

    • Introduction
    • TRipemd256

    Ripemd160Digest

    • Introduction
    • TRipemd160

    Ripemd128Digest

    • Introduction
    • TRipemd128

    SHA1Digest

    • Introduction
    • TSHA1

    SHA256Digest

    • Introduction
    • TSHA256

    SHA512Digest

    • Introduction
    • TSHA512

    SHA3Digest

    • Introduction
    • TSHA3_512
    • TSHA3_384
    • TSHA3_256
    • TSHA3_224

    TigerDigest

    • Introduction
    • TTiger

    WhirlpoolDigest

    • Introduction
    • TWhirlpool

    Crypto

    • Introduction
    • TCryptoRandom
    • TCryptoSecretBox
    • TCryptoHash
    • TCryptoSign
    • TCryptoKeyExchange
    • TCryptoKey
    • TCryptoHashKey
    • TCryptoSecretBoxKey
    • TCryptoSignature
    • TCryptoExchangeKeyPair
    • TCryptoSessionKeyPair
    • TCryptoNPacket
    • TCryptoKK1Packet
    • TCryptoKK2Packet
    • TCryptoXX1Packet
    • TCryptoXX2Packet
    • TCryptoXX3Packet
    • TCryptoExchangeState
    • TCryptoPWHashMasterKey
    • TCryptoPWHashStoredKey
    • TCryptoPasswordHash

SDL

    SDL

    • Introduction
    • TSDLStream

    SDLSystem

    • Introduction
    • TSDLMultiGesture

    SDLVideo

    • Introduction
    • TSDLDisplay
    • TSDLDisplayMode
    • TSDLGLContext
    • TSDLWindow

    SDLRender

    • Introduction
    • TSDLRenderer
    • TSDLTexture

    SDLTimer

    • Introduction
    • TSDLTimer

    SDLHaptic

    • Introduction
    • TSDLHaptic
    • TSDLHapticCondition
    • TSDLHapticConstant
    • TSDLHapticCustom
    • TSDLHapticDirection
    • TSDLHapticEffect
    • TSDLHapticLeftRight
    • TSDLHapticPeriodic
    • TSDLHapticRamp

    SDLSensor

    • Introduction
    • TSDLSensor
  • SDL.SDLFreeAudio
  • SDL.GLSDLMax2D
  • SDL.GL2SDLMax2D
  • SDL.D3D9SDLMax2D
  • SDLVirtualJoystick

    • Introduction
    • TVirtualJoystick

Steam

    SteamSDK

    • Introduction
    • TSteamClient
    • TSteamUtils
    • TSteamUserStats
    • TSteamFriends
    • TSteamUGC
    • ISteamFriendsListener
    • ISteamUGCListener
    • ISteamUserStatsListener
    • ISteamUtilsListener
    • EItemPreviewType
    • EPersonaChange
    • EPersonaState
    • ERemoteStoragePublishedFileVisibility
    • EUGCMatchingUGCType
    • EUGCQuery
    • EUserRestriction
    • EUserUGCList
    • EWorkshopFileType
Edit

BRL.PolledInput

The polled input module provides an easy way to detect keyboard and mouse input.

The functions in this module are only available when your program is running in Graphics mode. When working on GUI applications, you should use events instead.

Functions

Function AppSuspended()

Get app suspended state

Returns

True if application is currently suspended.

Example

SuperStrict

SetGraphicsDriver GLMax2DDriver()
Graphics 800,600

While Not KeyHit(KEY_ESCAPE)
    Cls
    If AppSuspended() = True
        DrawText "Application Suspended!",10,10
    Else
        DrawText "Application Running...",10,10
    EndIf
    Flip
Wend


Function AppTerminate()

Return app terminate state

Returns

True if user has requested to terminate application

Example

SuperStrict

Graphics 640,480,0

While Not AppTerminate() Or Not Confirm( "Terminate?" )

    Cls
    DrawText MouseX()+","+MouseY(),0,0
    Flip

Wend


Function KeyHit( key )

Check for key hit

The returned value represents the number of the times key has been hit since the last call to KeyHit with the same key.

See the key codes module for a list of valid key codes.

Returns

Number of times key has been hit.

Example

' keyhit.bmx

' the following code draws a circle every time the
' program detects the spacebar has been pressed
' and exits when it detects the ESCAPE key has
' been pressed

SuperStrict

Graphics 640,480
While Not KeyHit(KEY_ESCAPE)
    Cls
    If KeyHit(KEY_SPACE) DrawOval 0,0,640,480
    Flip
Wend


Function KeyDown( key )

Check for key state

See the key codes module for a list of valid keycodes.

Returns

True if key is currently down

Example

' keydown.bmx

' the following code draws a circle if the
' program detects the spacebar is pressed
' and exits when it detects the ESCAPE key has
' been pressed

SuperStrict

Graphics 640,480
While Not KeyHit(KEY_ESCAPE)
    Cls
    If KeyDown(KEY_SPACE) DrawOval 0,0,640,480
    Flip
Wend


Function GetChar()

Get next character

As the user hits keys on the keyboard, BlitzMax records the character codes of these keystrokes into an internal 'character queue'.

GetChar removes the next character code from this queue and returns it the application.

If the character queue is empty, 0 is returned.

Returns

The character code of the next character.


Function FlushKeys(resetStates:Int = True)

Flush key states and character queue.

FlushKeys resets the state of all keys to 'off', and resets the character queue used by GetChar.


Function MouseX()

Get mouse x location

The returned value is relative to the left of the screen.

Returns

Mouse x axis location

Example

' mousex.bmx

' the following tracks the position of the mouse

SuperStrict

Graphics 640,480
While Not KeyHit(KEY_ESCAPE)
    Cls
    DrawOval MouseX()-10,MouseY()-10,20,20
    Flip
Wend


Function MouseY()

Get mouse y location

The returned value is relative to the top of the screen.

Returns

Mouse y axis location

Example

' mousey.bmx

' the following tracks the position of the mouse

SuperStrict

Graphics 640,480
While Not KeyHit(KEY_ESCAPE)
    Cls
    DrawRect MouseX()-10,MouseY()-10,20,20
    Flip
Wend


Function MouseZ()

Get mouse wheel

The mouse wheel value increments when the mouse wheel is rolled 'away' from the user, and decrements when the mouse wheel is rolled 'towards' the user.

Returns

Mouse wheel value

Example

' mousez.bmx

' prints mousez() the mousewheel position

SuperStrict

Graphics 640,480
While Not KeyHit(KEY_ESCAPE)
    Cls
    DrawText "MouseZ()="+MouseZ(),0,0
    Flip
Wend


Function MouseXSpeed()

Get mouse x speed

Returns

Mouse x speed


Function MouseYSpeed()

Get mouse y speed

Returns

Mouse y speed


Function MouseZSpeed()

Get mouse z speed

Returns

Mouse z speed


Function FlushMouse()

Flush mouse button states

FlushMouse resets the state of all mouse buttons to 'off'.


Function MouseHit( button )

Check for mouse button click

The returned value represents the number of the times button has been clicked since the last call to MouseHit with the same button.

button should be 1 for the left mouse button, 2 for the right mouse button or 3 for the middle mouse button. Two further buttons, 4 and 5, are also available for mice that support them.

Returns

Number of times button has been clicked.

Example

' mousehit.bmx

SuperStrict

Graphics 640,480

While Not KeyHit(KEY_ESCAPE)
    Cls
    If MouseHit(1) DrawRect 0,0,200,200
    If MouseHit(2) DrawRect 200,0,200,200
    If MouseHit(3) DrawRect 400,0,200,200
    Flip
Wend


Function MouseDown( button )

Check for mouse button down state

button should be 1 for the left mouse button, 2 for the right mouse button or 3 for the middle mouse button. Two further buttons, 4 and 5, are also available for mice that support them.

Returns

True if button is currently down

Example

' mousedown.bmx

SuperStrict

Graphics 640,480

While Not KeyHit(KEY_ESCAPE)
    Cls
    If MouseDown(1) DrawRect 0,0,200,200
    If MouseDown(2) DrawRect 200,0,200,200
    If MouseDown(3) DrawRect 400,0,200,200
    Flip
Wend


Function WaitKey()

Wait for a key press

WaitKey suspends program execution until a key has been hit. The keycode of this key is then returned to the application.

See the key codes module for a list of valid keycodes.

Returns

The keycode of the pressed key

Example

SuperStrict

Graphics 640,480

DrawText "Press any key to end this program.", 10 , 10
Flip
WaitKey()


Function WaitChar()

Wait for a key press

WaitChar suspends program execution until a character is available from GetChar. This character is then returned to the application.

Returns

The character code of the pressed key


Function WaitMouse()

Wait for mouse button click

WaitMouse suspends program execution until a mouse button is clicked.

WaitMouse returns 1 if the left mouse button was clicked, 2 if the right mouse button was clicked or 3 if the middle mouse button was clicked.

Returns

The clicked button

Example

'detects which mouse button was pressed 

SuperStrict

Graphics 640,480

Repeat
    DrawText "Click Mouse to exit" , 200 , 200
    Flip 
Until WaitMouse()


Function SetAutoPoll(value:Int)

Enables or disables autopolling.


← BRL.PNGLoaderIntroduction →
  • Functions
    • Function AppSuspended()
    • Function AppTerminate()
    • Function KeyHit( key )
    • Function KeyDown( key )
    • Function GetChar()
    • Function FlushKeys(resetStates:Int = True)
    • Function MouseX()
    • Function MouseY()
    • Function MouseZ()
    • Function MouseXSpeed()
    • Function MouseYSpeed()
    • Function MouseZSpeed()
    • Function FlushMouse()
    • Function MouseHit( button )
    • Function MouseDown( button )
    • Function WaitKey()
    • Function WaitChar()
    • Function WaitMouse()
    • Function SetAutoPoll(value:Int)
BlitzMax
Docs
Getting StartedDownloadsAbout
Community
ResourcesSyntaxBomb Forums
More
GitHubStarChat on Discord
Copyright © 2023 Bruce A Henderson