02-01-2026, 09:44 PM
For QB64PE v4.4.0 and up.
Input Devices Library
Unified Joystick and Mouse Handling for QB64
The Input Devices Library provides a clean, reliable, and modernized interface for reading joystick and mouse input in QB64. It wraps QB64’s low‑level device functions into a consistent, high‑level API that delivers stable axis values, normalized directional data, button states, click and hold detection, scroll events, and window‑boundary awareness.
This library is ideal for games, editors, UI systems, and any interactive application that needs precise, real‑time device input.
FEATURES
JOYSTICK SUPPORT
• Automatic detection of joystick hardware
• Reads all axes and buttons from the controller
• Normalizes analog stick values
• Converts analog movement into digital X/Y direction (−1, 0, 1)
• Computes 0–360 degree angle for each stick
• Dead‑zone filtering to eliminate drift
• Supports left stick, right stick, and D‑pad
• Captures Z‑axis triggers and stick‑press buttons
MOUSE SUPPORT
• Full bit‑field mouse event reporting
• Detects button down, click, hold, and scroll wheel movement
• Tracks drag start and drag end coordinates
• Optional automatic _MouseInput clearing
• Works seamlessly inside real‑time loops
WINDOW BOUNDARY DETECTION
• Determines whether the mouse cursor is inside the program window
• Uses Windows API for accurate desktop‑level positioning
• Essential for UI hover logic, pausing input, and preventing off‑window clicks
INCLUDED COMMANDS
ReadJoyStick
Reads all joystick axes and buttons, updates the JoyStick() and Button() shared arrays, applies dead‑zone filtering, computes angles, and normalizes direction values.
MouseButtonStatus
Returns a bit‑field integer describing all mouse events:
1 left down
2 right down
4 middle down
8 left click
16 right click
32 middle click
64 left held
128 right held
256 middle held
512 scroll down
1024 scroll up
Also tracks drag start and end positions.
MBS
Convenience wrapper for MouseButtonStatus.
MBS(1) is identical to MouseButtonStatus(1).
MouseInApp
Returns TRUE if the mouse cursor is inside the program window.
Uses Windows API + GLUT offsets to convert desktop coordinates into app‑relative coordinates.
Axis_Type, JoyStick(), Button()
Internal structures and arrays storing joystick axis data, direction, angle, activity state, and button states.
WHY USE THIS LIBRARY?
QB64’s built‑in device functions are powerful but low‑level.
This library:
• Normalizes inconsistent axis values
• Removes joystick drift
• Converts analog movement into simple digital directions
• Distinguishes click vs. hold events
• Provides a unified bit‑field for mouse input
• Handles drag detection automatically
• Makes joystick and mouse input predictable and easy to use
Instead of wrestling with raw device data, you get clean, ready‑to‑use values ideal for gameplay logic, UI navigation, and interactive tools.
SUMMARY
The Input Devices Library gives QB64 developers a compact but powerful toolkit for real‑time joystick and mouse interaction. It abstracts away hardware quirks, normalizes input, and provides clean, intuitive data structures that make interactive programming dramatically easier.
Input Devices Library
Unified Joystick and Mouse Handling for QB64
The Input Devices Library provides a clean, reliable, and modernized interface for reading joystick and mouse input in QB64. It wraps QB64’s low‑level device functions into a consistent, high‑level API that delivers stable axis values, normalized directional data, button states, click and hold detection, scroll events, and window‑boundary awareness.
This library is ideal for games, editors, UI systems, and any interactive application that needs precise, real‑time device input.
FEATURES
JOYSTICK SUPPORT
• Automatic detection of joystick hardware
• Reads all axes and buttons from the controller
• Normalizes analog stick values
• Converts analog movement into digital X/Y direction (−1, 0, 1)
• Computes 0–360 degree angle for each stick
• Dead‑zone filtering to eliminate drift
• Supports left stick, right stick, and D‑pad
• Captures Z‑axis triggers and stick‑press buttons
MOUSE SUPPORT
• Full bit‑field mouse event reporting
• Detects button down, click, hold, and scroll wheel movement
• Tracks drag start and drag end coordinates
• Optional automatic _MouseInput clearing
• Works seamlessly inside real‑time loops
WINDOW BOUNDARY DETECTION
• Determines whether the mouse cursor is inside the program window
• Uses Windows API for accurate desktop‑level positioning
• Essential for UI hover logic, pausing input, and preventing off‑window clicks
INCLUDED COMMANDS
ReadJoyStick
Reads all joystick axes and buttons, updates the JoyStick() and Button() shared arrays, applies dead‑zone filtering, computes angles, and normalizes direction values.
MouseButtonStatus
Returns a bit‑field integer describing all mouse events:
1 left down
2 right down
4 middle down
8 left click
16 right click
32 middle click
64 left held
128 right held
256 middle held
512 scroll down
1024 scroll up
Also tracks drag start and end positions.
MBS
Convenience wrapper for MouseButtonStatus.
MBS(1) is identical to MouseButtonStatus(1).
MouseInApp
Returns TRUE if the mouse cursor is inside the program window.
Uses Windows API + GLUT offsets to convert desktop coordinates into app‑relative coordinates.
Axis_Type, JoyStick(), Button()
Internal structures and arrays storing joystick axis data, direction, angle, activity state, and button states.
WHY USE THIS LIBRARY?
QB64’s built‑in device functions are powerful but low‑level.
This library:
• Normalizes inconsistent axis values
• Removes joystick drift
• Converts analog movement into simple digital directions
• Distinguishes click vs. hold events
• Provides a unified bit‑field for mouse input
• Handles drag detection automatically
• Makes joystick and mouse input predictable and easy to use
Instead of wrestling with raw device data, you get clean, ready‑to‑use values ideal for gameplay logic, UI navigation, and interactive tools.
SUMMARY
The Input Devices Library gives QB64 developers a compact but powerful toolkit for real‑time joystick and mouse interaction. It abstracts away hardware quirks, normalizes input, and provides clean, intuitive data structures that make interactive programming dramatically easier.


)