1
1
Fork 0
mirror of https://github.com/QB64-Phoenix-Edition/QB64pe.git synced 2024-07-26 16:45:53 +00:00
QB64-PE/internal/help/_BUTTON.txt
SMcNeill 6e01fc8dce Altered string compare routines (<,<=,>,>=) so they don't give false results with CHR$(0).
Added new _STRCMP and _STRICMP commands for quick string comparisons.
Cleaned up QB64 to finish removing the QUI (quick user insert) code and folders.
Altered UCASE and LCASE routines to be faster in some situations for us.
2014-09-22 08:19:03 -04:00

50 lines
2 KiB
Plaintext

The '''_BUTTON''' function returns -1 when specified button number on a controller device is pressed.
{{PageSyntax}}
::: press = _BUTTON(''button_number%'')
* Values returned are -1 for a press and 0 when a button is released or not pressed.
* 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 number 2 button is the center button in this device configuration. Center is also designated as [[_MOUSEBUTTON]](3).
''Example:'' Reading multiple controller device buttons, axis and wheels.
{{CodeStart}} '' ''
{{Cl|FOR...NEXT|FOR}} i = 1 {{Cl|TO}} {{Cl|_DEVICES}}
{{Cl|PRINT}} {{Cl|STR$}}(i) + &quot;) &quot; + {{Cl|_DEVICE$}}(i) + &quot; Buttons:&quot;; {{Cl|_LASTBUTTON}}(i); &quot;,Axis:&quot;; {{Cl|_LASTAXIS}}(i); &quot;,Wheel:&quot;; {{Cl|_LASTWHEEL}}(i)
{{Cl|NEXT}}
{{Cl|DO...LOOP|DO}}
d&amp; = {{Cl|_DEVICEINPUT}}
{{Cl|IF...THEN|IF}} d&amp; {{Cl|THEN}} ' the device number cannot be zero!
{{Cl|PRINT}} &quot;Found&quot;; d&amp;;
{{Cl|FOR...NEXT|FOR}} b = 1 {{Cl|TO}} {{Cl|_LASTBUTTON}}(d&amp;)
{{Cl|PRINT}} {{Cl|_BUTTONCHANGE}}(b); {{Cl|_BUTTON}}(b);
{{Cl|NEXT}}
{{Cl|FOR...NEXT|FOR}} a = 1 {{Cl|TO}} {{Cl|_LASTAXIS}}(d&amp;)
{{Cl|PRINT}} {{Cl|_AXIS}}(a);
{{Cl|NEXT}}
{{Cl|FOR...NEXT|FOR}} w = 1 {{Cl|TO}} {{Cl|_LASTWHEEL}}(d&amp;)
{{Cl|PRINT}} {{Cl|_WHEEL}}(w);
{{Cl|NEXT}}
{{Cl|PRINT}}
{{Cl|END IF}}
{{Cl|LOOP}} {{Cl|UNTIL}} {{Cl|INKEY$}} = {{Cl|CHR$}}(27) 'escape key exit
{{Cl|END}} '' ''
{{CodeEnd}}
: ''Note:'' When there is no device control to read, a [[FOR...NEXT|FOR]] n = 1 TO 0 loop will not run thus avoiding a control function read error.
''See also:''
* [[_LASTWHEEL]], [[_LASTBUTTON]], [[_LASTAXIS]]
* [[_AXIS]], [[_WHEEL]], [[_BUTTONCHANGE]]
* [[_DEVICE$]], [[_DEVICES]]
* [[_MOUSEBUTTON]]
* [[Controller Devices]]
{{PageNavigation}}