_BUTTONCHANGE - mkilgore/QB64pe GitHub Wiki
The _BUTTONCHANGE function returns -1 or 1 when a specified button number on a controller device has been pressed or released.
- press% = _BUTTONCHANGE(button_number%)
- Values returned are -1 for a press and 1 when a button is released. No press or release event returns zero.
- The button_number% must be a number which does not exceed the number of buttons found by the _LASTBUTTON function.
- The number of _DEVICES must be read before using _DEVICE$, _DEVICEINPUT or _LASTBUTTON.
- Note: The center mouse button is button number 2. Center can also be read using _MOUSEBUTTON(3).
Example: Reading multiple controller device buttons, axis and wheels.
DO...LOOP d& = _DEVICEINPUT IF...THEN d& THEN ' the device number cannot be zero! PRINT "Found"; d&; FOR...NEXT b = 1 TO _LASTBUTTON(d&) PRINT _BUTTONCHANGE(b); _BUTTON(b); NEXT FOR...NEXT a = 1 TO _LASTAXIS(d&) PRINT _AXIS(a); NEXT FOR...NEXT w = 1 TO _LASTWHEEL(d&) PRINT _WHEEL(w); NEXT PRINT END IF LOOP UNTIL INKEY$ = CHR$(27) 'escape key exit END '' '' |
- Note: When there is no device control to read, a FOR n = 1 TO 0 loop will not run thus avoiding a control function read error.
- _LASTWHEEL, _LASTBUTTON, _LASTAXIS
- _AXIS, _WHEEL, _BUTTON
- _DEVICE$, _DEVICES
- _MOUSEBUTTON
- Controller Devices
Navigation:
Go to Keyword Reference - Alphabetical
Go to Keyword Reference - By usage
Go to Main WIKI Page