BASIC JOY Function - fvdhoef/aquarius-plus GitHub Wiki
TYPE: USB BASIC system statement
FORMAT: JOY ( stick )
Action: Reads the Aquarius game controller(s).
-
stick is an integer value specifying which control pad to read.
-
0
will read left or right control pad -
1
will read left control pad only -
2
will read right control pad only
-
Return Values
+-----------------------+
| [ 64] [132] [160] |
| [ 32] [130] [129] |
| |
| 12 4 20 |
| 28 | 22 |
| \ | / |
| 24 \ | / 6 |
| \ | / |
| 8 -------*------- 2 |
| / | \ |
| 9 / | \ 18 |
| / | \ |
| 25 | 19 |
| 17 1 3 |
+-----------------------+
Note: Simultaneous multiple presses generate a combination of their individual values.
Examples
PRINT JOY(0)
Prints input value of either/both control pads (not effective in immediate mode).
10 PRINT JOY(1)
20 GOTO 10
Continuously reads and prints the input value from only the left control pad.
Extended Hand Controller Functions
TYPE: plusBASIC v0.24g system functions
FORMAT: JOYx ( argument )
Action: Returns a decoded hand controller result.
- To read and decode the current controller state use argument
0
,1
, or2
as per theJOY()
function. - To decode a previous
JOY()
pass in the negative of that result.
Function | Description | Notes |
---|---|---|
JOYD() |
Down | 1 2 3 |
JOYJ() |
Joystick direction | 1 3 |
JOYK() |
Button id | 1 |
JOYL() |
Left | 1 2 3 |
JOYP() |
Thumbpad direction | 1 |
JOYR() |
Right | 1 2 3 |
JOYU() |
Up | 1 2 3 |
1 - Returns 0
if a direction and any buttons other than 1 or 4 are pressed at the same time.
2 - Returns -1
if respective direction is pressed or 0
if not.
- Diagonal presses result in the two corresponding directions returning
-1
.
3 - Compatible with both the hand controller and an Atari style joystick with the approriate interface.
Button IDs and Thumpad and Joystick directions
+-----------------------+
| [ 1 ] [ 2 ] [ 3 ] |
| [ 4 ] [ 5 ] [ 6 ] | +---------------------+
| | | [1] 6 7 8 |
| 12 13 14 | | \ | / |
| 11 | 15 | | \ | / |
| \ | / | | 5-----O-----1 |
| 10 \ | / 16 | | / | \ |
| \ | / | | / | \ |
| 9 -------*------- 1 | | 4 | 2 |
| / | \ | | 3 |
| 8 / | \ 2 | +---------------------+
| / | \ |
| 7 | 3 |
| 6 5 4 |
+-----------------------+
TYPE: plusBASIC system statement
FORMAT: JOY$ ( controller )
Action: Reads a paired Xbox Bluetooth controller.
-
controller is an integer value specifying the controller ID.
- At this time the Aquarius+ only supports one controller is supported (ID
0
).
- At this time the Aquarius+ only supports one controller is supported (ID
- Returns an 8 character binary string containing the controller state (see table below).
- Returns a string with length 0 if no controller is found.
Result String
Byte | Type | Control |
---|---|---|
1 | Signed | Left stick X |
2 | Signed | Left stick Y |
3 | Signed | Right stick X |
4 | Signed | Right stick Y |
5 | Unsigned | Left trigger |
6 | Unsigned | Right trigger |
7-8 | BitFlags | Buttons |
Bit | Button | Bit | Button |
---|---|---|---|
0 | A | 8 | Right stick button |
1 | B | 9 | Left shoulder button |
2 | X | 10 | Right shoulder button |
3 | Y | 11 | D-pad up |
4 | View | 12 | D-pad down |
5 | Guide (Xbox button) | 13 | D-pad left |
6 | Menu | 14 | D-pad right |
7 | Left stick button | 15 | Share* |
* Xbox Series S/X controller only
Example
- Warning: This code has not been tested.
800 REM Read Xbox Controller
810 JX$=JOY$(0)
820 LX=BYTE(JX$,1): 'Left Stick X
825 LY=BYTE(JX$,2): 'Left Stick Y
830 RX=BYTE(JX$,3): 'Right Stick X
835 RY=BYTE(JX$,4): 'Right Stick Y
840 LT=ASC(JX$,5): 'Right Stick X
845 RT=ASC(JX$,6): 'Right Stick Y
850 JB=WORD(JX$,7): 'Buttons
860 BA=BIT(JB,0): 'A button
861 BB=BIT(JB,1): 'B button
862 BX=BIT(JB,2): 'X button
863 BY=BIT(JB,3): 'Y button
864 BV=BIT(JB,4): 'View
865 BG=BIT(JB,5): 'Guide (Xbox)
866 BM=BIT(JB,6): 'Menu
867 LS=BIT(JB,7): 'Left Stick
870 LR=BIT(JB,8): 'Right stick
871 SL=BIT(JB,9): 'Left shoulder
872 SR=BIT(JB,10): 'Right shoulder button
873 DU=BIT(JB,11): 'D-pad up
874 DD=BIT(JB,12): 'D-pad down
875 DL=BIT(JB,13): 'D-pad left
876 DR=BIT(JB,14): 'D-pad right
877 BS=BIT(JB,15): 'Share<sup>*</sup>
890 RETURN
Extended Bluetooth Controller Functions
TYPE: plusBASIC v0.24e system functions
FORMAT: JOYxx ( argument)
Action: Returns the state of the corresponding control on the wireless controller.
- To read the current state of a control, use a numeric argument as per the
JOY$()
function. - To return the state of a control from a previous
JOY$()
call, pass in the string result of that call. - Any and all combinations of controls are reported as expected.
Function | Description | Notes |
---|---|---|
JOYBA() |
A button | 1 |
JOYBB() |
B button | 1 |
JOYBG() |
Guide button | 1 |
JOYBL() |
Left Shoulder button | 1 |
JOYBM() |
Menu button | 1 |
JOYBR() |
Right Shoulder button | 1 |
JOYBS() |
Share button | 1 |
JOYBT() |
Left Stick button | 1 |
JOYBU() |
Right Stick button | 1 |
JOYBV() |
View button | 1 |
JOYBX() |
X button | 1 |
JOYBY() |
Y button | 1 |
JOYDD() |
D-pad Down | 1 |
JOYDL() |
D-pad Left | 1 |
JOYDR() |
D-pad Right | 1 |
JOYDU() |
D-pad Up | 1 |
JOYLT() |
Left Trigger | 3 |
JOYLX() |
Left Stick X | 2 |
JOYLY() |
Left Stick Y | 2 |
JOYRT() |
Right Trigger | 3 |
JOYRX() |
Right Stick X | 2 |
JOYRY() |
Right Stick Y | 2 |
1 - Returns -1
if respective buttom or d-pad direction is pressed, or 0
if not.
- Diagonal presses on the d-pad result in the two corresponding directions returning
-1
.
2 - Returns an integer number in the range -128
through 127
.
3 - Returns an integer number in the range 0
through 255
.