[↑]
SmileBASIC4 Replica Reference
BUTTON
1. Get the operation status of a specific button on the controller

BUTTON(ControllerID,ButtonID[,FunctionID])

Arguments

ControllerID

ID of a controller to check

0 Default Controller
1 to 4 Normal Controller

・For details on the controller ID, refer to the help for the CONTROLLER function.

ButtonID

ID of a button to check

Correspondence between button ID and button is as follows

・Correspondence between button ID and button is different for each operation style.

Button ID Full, dual-controller grip held vertically held horizontally
#B_RUP X Button Up Button Up Button
#B_RDOWN B Button Down Button Down Button
#B_RLEFT Y Button Left Button Left Button
#B_RRIGHT A Button Right Button Right Button
#B_LUP Up Button
#B_LDOWN Down Button
#B_LLEFT Left Button
#B_LRIGHT Right Button
#B_L1
#B_SL
L SL SL
#B_R1
#B_SR
R SR SR
#B_L2
#B_S1
ZL L or R L or R
#B_R2
#B_S2
ZR ZL or ZR ZL or ZR
#B_LSTICK Press the L Stick Press the Stick Press the Stick
#B_RSTICK Press the R Stick
#B_RANY Any of A/B/X/Y Buttons
#B_LANY Any of Up/Down/Left/Right Buttons
#B_ANY Any Buttons other than Press the Stick

・The top, bottom, left and right of the directional buttons are the button positions relative to the direction with the controller. The vertically held “up” is the horizontally held “left”.

FunctionID

Type of condition you want to know

・0, if not specified.

0 Button is pressed
1 The moment the button is pressed (with BREPEAT support)
2 The moment the button is pressed (no BREPEAT support)
3 The moment the button is released

Return Value

1 if the specified button satisfies the specified function ID conditions, 0 otherwise

2. Acquire all button status of controller together

BUTTON(ControllerID)
BUTTON(ControllerID,-1[,FunctionID])

・If you only want to get the status of one button, see the help for another BUTTON function.

Arguments

ControllerID

ID of controller to check

0 Default Controller
1 to 4 Normal Controller

・For details on the controller ID, refer to the help for the CONTROLLER function.

-1

If button ID is specified to -1, all button states will be collected together.

・If only controller ID is specified, -1 is specified.

FunctionID

Type of condition you want to know

・0, if not specified.

0 Button is pressed
1 The moment the button is pressed (with BREPEAT support)
2 The moment the button is pressed (no BREPEAT support)
3 The moment the button is released

Return Value

The button state of the specified controller is returned with each bit.

To check if the button is pressed, you can write the following program

'To create a value with the bit corresponding to the button turned ON, shift 1 to the left (<<) by the button ID
'For example, if you want to check if #B_RLEFT is pressed
BTNBIT_RLEFT = 1 << #B_RLEFT
'Once the bit value is created, the result of the BUTTON function and the AND are calculated. If the result is other than 0, it is pressed.
IF (BUTTON(0) AND BTNBIT_RLEFT) !=0 THEN PRINT "Left Button" 
About this site
Our site is an unofficial manual site of programming software "SmileBASIC" for NintendoSwitch™.
I acquire the content of the site from the official reference site of the SmileBoom Co.Ltd. that is the development and sales cause of the software in real time (a minimum period of 24 hours update) and display it. For automatic update, contents may become improper.
Please confirm the correct content in an official site.

June 3, 2020
by mim
OK
|