Skip to content

BASIC JOY Function

Curtis F Kaylor edited this page Feb 9, 2025 · 12 revisions

JOY

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        |
 +-----------------------+
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.


JOY$

TYPE: USB BASIC 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).
  • 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
Clone this wiki locally