Various Inputs

XCTRLSTYLE MaxNumberOfConnections,OperationStyle[,MotionSensorUseFlag,IRSensorUseFlag[,ConnectionDialogFlag]]

Set the maximum number of controllers connections, operation style, and functions

・Depending on the setting operation style, the types of controllers that can be connected, the expected Joy-Con holding method, the types of buttons and Stick that can be acquired, and the controller functions that can be used vary.
・The operation result on the connection confirmation display can be confirmed with the RESULT function (1: Success, -1: Cancel).
・Calls from subprograms are ignored.

Arguments

MaxNumberOfConnections

Specify the maximum number of controllers you want to connect

・The range of values that can be specified varies depending on the operation style.

Full 1 to 2
dual-controller grip 1 to 2
held horizontally 2 to 4
held vertically 2 to 4

OperationStyle

Operation style to be set: 0 to 3

Number Style Name Available Controllers
0 Full handheld mode, dual-controller grip, Pro Controller
1 dual-controller grip dual-controller grip
2 held horizontally Joy-Con (L)/(R) held horizontally, Pro Controller
3 held vertically Joy-Con (L)/(R) held vertically

MotionSensorUseFlag

Specify 1 if you want to use motion sensors (accelerometer, gyroscope) or 0 if you do not use it.

・0, if not specified.

IRSensorUseFlag

Specify 1 if you want to use IR Motion Camera, 0 if you do not use it.

・0, if not specified.
・When using IR Motion Camera, the operation style must be 1 (dual-controller grip).

ConnectionDialogFlag

Specify whether to always display the controller connection display

・If 1 is specified, the controller connection display will be displayed.
・If 0 is specified, the controller connection display is displayed only when the setting is changed.
・0, if not specified.

XCTRLSTYLE 0

Reset the controller operation style to the startup state

・If only 0 is specified, the controller operation style is reset to the startup state.
・Same as specifying XCTRLSTYLE 1,0,0,0.
・The operation result on the connection confirmation display can be confirmed with the RESULT function (1: Success, -1: Cancel).
・Calls from subprograms are ignored.

Argument

0 (zero)

Specify only numeric zero

・An error occurs if a different value is specified.

XCTRLSTYLE OUT MaxNumberOfConnections,OperationStyle

Obtaining the current maximum controller connections and operation style

Return Value

MaxNumberOfConnections

Maximum number of controllers that can be connected

Operation style

OperationStyle

0 Full
1 dual-controller grip
2 held horizontally
3 held vertically

CONTROLLER(ControllerID)

Check controller type and connection status

Argument

ControllerID

0 Default Controller
1 to 4 Normal Controller

・The normal controller ID corresponds to the number of player LED on the connected controllers.
・If the handheld mode controller can be used, the ID is always 1.
・The default controller combines the inputs of all connected controllers and always treats them as inputs equivalent to the handheld mode controller regardless of the currently set operation style.
・When using controller IDs 1 to 4, it is strongly recommended to set the operation style you want to use with the XCTRLSTYLE command in advance.

Return Value

0 Not Connected
1 handheld mode controller
2 Pro Controller
3 dual-controller grip
4 Joy-Con (L)
5 Joy-Con (R)

CONTROLLER ControllerID OUT ControllerType,MainColor,SubColor
CONTROLLER ControllerID OUT ControllerType,LeftMainColor,LeftSubColor,RightMainColor,RightSubColor

Check controller connection status and type

Argument

ControllerID

0 Default Controller
1 to 4 Normal Controller

・The normal controller ID corresponds to the number of player LED on the connected controllers.
・If the handheld mode controller can be used, the ID is always 1.
・The default controller combines the inputs of all connected controllers and always treats them as inputs equivalent to the handheld mode controller regardless of the currently set operation style.
・When using controller IDs 1 to 4, it is strongly recommended to set the operation style you want to use with the XCTRLSTYLE command in advance.

Return Value

Controller type

0 Not Connected
1 handheld mode controller
2 Pro Controller
3 dual-controller grip
4 Joy-Con (L)
5 Joy-Con (R)

MainColor,SubColor

Returns the controller color in two color codes, the main color and the sub color

・The obtained color code can be used as the color code for other drawing commands.
・If the controller is not connected, the main and sub will return black.

LeftMainColor,LeftSubColor,RightMainColor,RightSubColor

When dual-controller grip or handheld mode controller are used, the left and right controller colors can be acquired separately.

・Black is returned to the right main color and the right sub color when it is held horizontally and held vertically.

BUTTON(ControllerID,ButtonID[,FunctionID])

Get the operation status of a specific button on the controller

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

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

Acquire all button status of controller together

・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" 

BREPEAT ButtonID,RepeatStartTime,RepeatInterval

Set the button repeat speed

・This affects the result when 1 is specified for the function ID of the BUTTON function.
・Affects all connected controllers.

Arguments

ButtonID

ID of the button which wants to set repeat speed

・For details on the button ID, refer to the help for the BUTTON function.

RepeatStartTime

Frame count from when the button starts to be pressed until repeat starts

RepeatInterval

Frame count from the occurrence of a repeat until the next repeat occurs

BREPEAT ButtonID OUT RepeatStartTime,RepeatInterval

Get button repeat speed

Argument

Button ID

ID of the button which wants to obtain repeat speed

・For details on the button ID, refer to the help for the BUTTON function.

Return Value

RepeatStartTime

Frame count from when the button starts to be pressed until repeat starts

RepeatInterval

Frame count from the occurrence of a repeat until the next repeat occurs

STICK ControllerID[,StickID] OUT X,Y

Check controller Stick status

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.

StickID

0 L Stick
1 R Stick

・0, if not specified.
・Specifying 1 when there is only one Stick does not cause an error, and 0 is returned for both X and Y.

Return Value

X,Y

Stick tilt information

・Left <-> Right 1.0<>1.0 in the horizontal direction (X).
・Up <-> Down 1.0<>1.0 in the vertical direction (Y).
・When no operation is performed, 0 is returned for both X and Y.

ACCEL ControllerID[,SensorID] OUT X,Y,Z

Acquire accelerometer information

・If the motion sensor is not enabled in XCTRLSTYLE, normal values will not be returned.

Arguments

ControllerID

ID of a controller you want to check: 1 to 4

・ControllerID 0 cannot be specified.
・For details on the controller ID, refer to the help for the CONTROLLER function.

SensorID

ID of sensor to check: 0 to 1

・A meaningful value with ID 1 is returned only when dual-controller grip is used.
・0, if not specified.

Return Value

X,Y,Z

Accelerometer value

・The unit is acceleration of gravity.
・X is the left/right directional button (right button direction is positive)
・Y is the up/down directional button (down button direction is positive)
・Z is perpendicular to the controller surface (upward is positive)

GYROV ControllerID [,SensorID] OUT X,Y,Z

Get angular velocity of gyroscope

・If the motion sensor is not enabled in XCTRLSTYLE, normal values will not be returned.

Arguments

ControllerID

ID of the controller you want to check: 1 to 4

・ControllerID 0 cannot be specified.
・For details on the controller ID, refer to the help for the CONTROLLER function.

SensorID

ID of sensor to check: 0 to 1

・ID 1 is valid only when dual-controller grip is used.
・0, if not specified.

Return value

X,Y,Z

Angular velocity of gyroscope around each axis

・The unit is radian/second.
・X is pitch.
・Y is roll.
・Z is yaw.
・The direction in which the right screw rotates in each positive direction is a positive value.

GYROA ControllerID [,SensorID] OUT X,Y,Z

Get the angle of gyroscope

・If the motion sensor is not enabled in XCTRLSTYLE, 0 will be returned to all.
・If you move the controller violently or continue to use it for a long time, errors will accumulate and the correct value will not be returned. So, it is necessary to reset the angle by calling the GYROSYNC command at the required timing.

Arguments

ControllerID

ID of the controller you want to check: 1 to 4

・ControllerID 0 cannot be specified.
・For details on the controller ID, refer to the help for the CONTROLLER function.

SensorID

ID of sensor to check: 0 to 1

・ID 1 is valid only when dual-controller grip is used.
・0, if not specified.

Return value

X, Y, Z

Gyroscope angle around each axis

・The unit is radian.
・X is pitch.
・Y is a roll.
・Z is yaw.
・The direction in which the right screw rotates in each positive direction is a positive value.

GYROSYNC ControllerID [,SensorID]

Reset the angle of gyroscope

・The controller posture immediately after calling the command is X:0,Y:0,Z:0.
・A maximum time of 1V count is required until the actual reset is performed after using the GYROSYNC command.

Arguments

ControllerID

Controller ID to be reset: 1 to 4

・Controller ID 0 cannot be specified.
・For details on the controller ID, refer to the help for the CONTROLLER function.

SensorID

ID of sensor to be reset: 0 to 1

・When it's other than dual-controller grip, even if 1 is specified, it is ignored.
・0, if not specified.

VIBRATE ControllerID [,LeftRightDesignation],VibrationPatternNumber

Vibrate the controller

・Calls from subprograms are ignored.

Arguments

ControllerID

Controller ID to be vibrated: 1 to 4

・ControllerID 0 cannot be specified.
・For details on the controller ID, refer to the help for the CONTROLLER function.

LeftRightDesignation

Specify left and right controller to vibrate

0 Left
1 Right

・If not specified, both left and right vibrate.
・In case of held vertically and held horizontally, even if 1 is specified, it is ignored.

VibrationPatternNumber

Preset vibration pattern number: 0 to 62

・Vibration stops when 0 is specified.

Example

VIBRATE 1,40
VIBRATE 1,0,1:VIBRATE 1,1,3

VIBRATE ControllerID [,LeftRightDesignation],LowBandFrequency,LowBandAmplitude,HighBandFrequency,HighBandAmplitude

Specify the frequency and amplitude to vibrate the controller

・Calls from subprograms are ignored.

Arguments

ControllerID

Controller ID to be vibrated: 1 to 4

・ControllerID 0 cannot be specified.
・For details on the controller ID, refer to the help for the CONTROLLER function.

LeftRightDesignation

Specify left and right controller to vibrate

0 Left
1 Right

・If not specified, both left and right vibrate.
・In case of held vertically and held horizontally, even if 1 is specified, it is ignored.

LowBandFrequency

Vibration frequency (Hz)

・Vibration stops when 0 is specified.

LowBandAmplitude

Vibration amplitude: -128.0 to 127.0

・Vibration stops when 0 is specified.

HighBandFrequency

Vibration frequency (Hz)

・Vibration stops when 0 is specified.

HighBandAmplitude

Vibration amplitude: -128.0 to 127.0

・Vibration stops when 0 is specified.

Example

VIBRATE 1,440,127,220,64

VIBRATE(ControllerID[,LeftRightDesignation])

Get controller vibration status

Arguments

ControllerID

Controller ID for acquiring vibration status: 1 to 4

・ControllerID 0 cannot be specified.
・For details on the controller ID, refer to the help for the CONTROLLER function.

LeftRightDesignation

Specify whether to acquire vibration status of left or right

0 Left
1 Right

・If not specified, the combined value of the left and right states is returned.
・In the case of held vertically and held horizontally, if 1 is specified, 0 is always returned.

Return Value

・If it is vibrating, it returns the vibration pattern number. If frequency/amplitude is directly specified, it returns 65535.
・0 when it's not vibrating.
・If the left / right designation is not specified except for held vertically or held horizontally, RightStateValue*65536+LeftStateValue is returned.
・If left and right designation is not specified for held vertically and held horizontally, only the left state value is returned.

Example

PRINT VIBRATE(1,0)

VIBRATE

Stop vibration of all controllers

・Calls from subprograms are ignored.

Example

VIBRATE

TOUCH [TouchID[,CoordinateSystemConversionFlag]] OUT TouchTime,X,Y[,TouchArea]

Return touch information on the touch screen

・The TOUCH function does not return a valid value in TV mode.

Arguments

TouchID

With multi-touch, you can specify up to 0, 1, 2, 3 ... and 9 in the order of the touch start point.

・0, if not specified.

CoordinateSystemConversionFlag

If 0 is specified, the touch coordinates are converted to the coordinates on the BASIC display where the touch coordinates are displayed, and touches outside the display are treated as untouched actions.

If 1 is specified, the touch coordinates on the entire LCD display are acquired regardless of the BASIC display.

・0, if not specified.

Return Value

TouchTime

Frame count from start of touch to present

・0 is returned when it's not touched.

X,Y

Coordinates when touched

・If it is not touched, a meaningless value is returned.

TouchArea

Touch area when touched

・If it is not touched, a meaningless value is returned.

MOUSE [CoordinateSystemConversionFlag] OUT X,Y [,Wheel]

Return mouse coordinate information

Arguments

CoordinateSystemConversionFlag

If 0 is specified, mouse coordinates are converted to the coordinates of the BASIC display on which they are displayed.

If 1 is specified, the mouse coordinates of the entire LCD display are acquired regardless of the BASIC display.

Return Value

X,Y

Current mouse coordinates

Wheel

Current wheel value

MOUSE X,Y[,CoordinateSystemConversionFlag]

Set mouse coordinates

Arguments

X,Y

Mouse coordinates to set

CoordinateSystemConversionFlag

If 0 is specified, X and Y are handled as BASIC display coordinates.

If 1 is specified, X and Y are handled as coordinates on the entire LCD display.

・0, if not specified.

MBUTTON()

Get all mouse button statuses together

・If you want to get the status of only one button, refer to another MBUTTON help page.

Argument

Return Value

Mouse button state is returned bit by bit

MBUTTON(ButtonID[,FunctionID])

Get the operation status of a specific mouse button

Argument

ButtonID

ID of a button you want to check

0 Left Button
1 Right Button
2 Center Button
3 Button 4
4 Button 5

FunctionID

Type of condition you want to know

0 Button is pressed
1 (Not Available)
2 The moment the button is pressed
3 The moment the button is released

・0, if not specified.

Return Value

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

IRSTART ControllerID,IRRecognitionType

Start using the IR Motion Camera

・It is necessary to turn on the IR usage flag beforehand in XCTRLSTYLE.
・Calls from subprograms are ignored.

Arguments

ControllerID

ID of the controller using the IR Motion Camera: 1 to 2

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

IRRecognitionType

Specify the IR Motion Camera recognition method

0 Clustering Mode
1 Shooting Mode
2 Moment Mode

・Clustering mode recognizes bright areas as rectangles. A maximum of 16 areas can be recognized simultaneously.
・In the shooting mode, images captured by the IR Motion Camera are acquired as images.
・Data taken in the shooting mode can be displayed in IRSPRITE. Data cannot be retrieved into a BASIC program.
・Display capture is prohibited while the shooting mode is activated.
・In the moment mode, the imaging range is divided into 8x6 small areas, and each piece of recognition information is acquired.

IRSTART ControllerID,0,[LightingType],[Gain],[Exposure],[MinCluster],[MaxCluster],[MinBrightness]

Start using IR Motion Camera (Clustering mode detailed parameter setting type)

・It is necessary to turn on the IR usage flag beforehand in XCTRLSTYLE.
・Calls from subprograms are ignored.

Arguments

ControllerID

ID of the controller using the IR Motion Camera: 1 to 2

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

0

Specify 0 for the clustering mode

LightingType

Specify IR Motion Camera lighting

0 All (Far + Near)
1 For Long Range Only
2 For Short Range Only
3 Lighting Off

・0, if not specified.

Gain

IR Motion Camera shooting gain: 1 to 16

・2 is the default.

Exposure

IR Motion Camera exposure time: 7 to 600

・200 is the default.

MinCluster

Minimum area (number of pixels) that can be recognized as a cluster: 0 to 76800

・3 is the default.

MaxCluster

Maximum area (number of pixels) that can be recognized as a cluster: 0 to 76800

・76800 is the default.

MinBrightness

Minimum brightness to recognize as a cluster: 0 to 255

・150 is the default.

IRSTART ControllerID,1,[LightingType],[Gain],[Exposure],[ImageSize]

Start using the IR Motion Camera (shooting mode detailed parameter setting type)

・It is necessary to turn on the IR usage flag beforehand in XCTRLSTYLE.
・Data taken in the shooting mode can be displayed in IRSPRITE. Data cannot be retrieved into a BASIC program.
・Display capture is prohibited while the shooting mode is activated.
・Calls from subprograms are ignored.

Arguments

ControllerID

ID of controller using IR Motion Camera: 1

・You can specify only 1 in the shooting mode.
・For details on the controller ID, refer to the help for the CONTROLLER function.

IRRecognitionType

Always specify 1 for the shooting mode

LightingType

Specify IR Camera lighting

0 All (Far + Near)
1 For Long Range Only
2 For Short Range Only
3 Lighting Off

・0, if not specified.

Gain

IR Motion Camera shooting gain: 1 to 16

・8 is the default.

Exposure

IR Motion Camera exposure time: 7 to 600

・300 is the default.

ImageSize

Specify the size of the shot image

0 320×240
1 160×120
2 80×60
3 40×30
4 20×15

・The larger the image size, the longer it takes to transfer. 320×240 for a minimum of 4 seconds, 4 times faster for each smaller size.
・2 is the default.

IRSTART ControllerID,2,[LightingType],[Gain],[Exposure]

Start using the IR Motion Camera (moment mode detailed parameter setting type)

・It is necessary to turn on the IR usage flag beforehand in XCTRLSTYLE.
・Calls from subprograms are ignored.

Arguments

ControllerID

ID of the controller using the IR Motion Camera: 1 to 2

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

2

Specify 2 for the moment mode

LightingType

Specify IR Motion Camera lighting

0 All (Far + Near)
1 For Long Range Only
2 For Short Range Only
3 Lighting Off

・0, if not specified.

Gain

IR Motion Camera shooting gain: 1 to 16

・8 is the default.

Exposure

IR Camera exposure time: 7 to 600

・300 is the default.

IRSTOP ControllerID

Stop using the IR Motion Camera

・Calls from subprograms are ignored.

Argument

ControllerID

ID of the controller that stops using the IR Motion Camera: 1 to 2

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

IRSTATE(ControllerID)

Get IR Motion Camera starting status

Argument

ControllerID

ID of the controller that acquires the status of the IR Motion Camera: 1 to 2

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

Return Value

IR Camera status

0 Not in Use
1 Stopped
2 Starting Clustering
3 Starting Shooting Mode
4 Starting Moment Mode

IRREAD ControllerID OUT SamplingNumber,NoiseLevel,NumberOfData,DataArray

Read IR Motion Camera recognition results

・It is necessary to start using the IR Motion Camera with IRSTART.

Argument

ControllerID

ID of the controller that reads the recognition result of the IR Motion Camera: 1 to 2

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

Return Value

SamplingNumber

A number that increases by 1 each time new data is read

・If the same number is acquired continuously, it indicates that new data has not been received yet.

NoiseLevel

Noise level during recognition

・A value between 0 and 2 is returned. The smaller the value, the less noise and the more accurate the value is.

NumberOfData

The number of data contained in the data array

・In the clustering mode, the number of recognized clusters is displayed. The array contains information for each cluster.
・It's always 48 in the moment mode. The array contains information of each block obtained by dividing the imaging area into 8×6.

DataArray

An array containing the read recognition results

・A 2D array with a width of 8.
・The height contains a meaningful value from 0 to the number of data -1.
・The coordinate range is X: (0 to 320) Y: (0 to 240).
・The data format for the clustering mode is as follows.

0 Cluster X Coordinate
1 Cluster Y Coordinate
2 Cluster Width
3 Cluster Height
4 Number of Pixels in Cluster
5 Cluster Barycentric Coordinates X
6 Cluster Barycentric Coordinates Y
7 Average Cluster Brightness

・Data format in the moment mode is as follows.

0 Average Block Brightness
1 Block Barycentric Coordinates X
2 Block Barycentric Coordinates Y

IRSPRITE ControllerID,SpriteID

Paste motion IR Motion Camera image acquired in the shooting mode to sprite

・The captured image continues to be reflected in the specified sprite in real time.
・Sprites created with IRSPRITE can be handled in the same way as normal sprites. However, if SPPAGE is specified, it cannot be restored.
・Shooting data in the shooting mode cannot be acquired as BASIC data.
・Calls from subprograms are ignored.

Arguments

ControllerID

ID of controller with IR Motion Camera linked to sprite: 1

・Only 1 can be specified in IRSPRITE.
・For details on the controller ID, refer to the help for the CONTROLLER function.

SpriteID

Sprite ID to be linked to the shot image: 0 to 4095

KEYBOARD(ScanCode[,FunctionID])
KEYBOARD ScanCode [,FunctionID] OUT Result,ModifierKeyInformation

Get USB keyboard input information

・Return values are all zero when the USB keyboard is not connected.

Arguments

ScanCode

USB Usage ID of the key you want to check: 0 to 255

FunctionID

The type of condition you want to know.

0 Key is pressed
1 Cannot be used (if specified, zero is returned as the result)
2 The moment the key is pressed
3 The moment the key is released

・0, if not specified.

Return Value

Results

1 if the key is specified by the function ID, 0 if not

ModifierKeyInformation

Returns modifier key press information in bits

bit0 Windows Key
bit1 Shift Key
bit2 Ctrl Key
bit3 Alt Key