STICK: Difference between revisions
Jump to navigation
Jump to search
Sidewinder Precision Pro game port to USB adapter
Navigation:
Main Page with Articles and Tutorials
Keyword Reference - Alphabetical
Keyword Reference - By usage
Report a broken link
(Created page with "The '''STICK''' function returns the directional axis coordinate move of game port (&H201) joystick or USB controller devices. {{PageSyntax}} :: coordinate_move% = STICK(direction%) QB64 {{PageSyntax}} :: coordinate_move% = STICK(''direction%''[, ''axis_number%'']) ''Description:'' * '''QB64''' allows any number of coordinate pairs for more than two game device controllers. STICK will not read a mouse axis. * ''axis_number'' can be used as the next axis parameter...") |
No edit summary |
||
(11 intermediate revisions by 2 users not shown) | |||
Line 3: | Line 3: | ||
{{PageSyntax}} | {{PageSyntax}} | ||
:: coordinate_move% = STICK(direction%) | ;QuickBASIC:coordinate_move% = [[STICK]]{{Parameter|(direction%)}} | ||
;QB64:coordinate_move% = [[STICK]]{{Parameter|(direction%[, axis_number%])}} | |||
{{PageDescription}} | |||
* '''QB64''' allows any number of coordinate pairs for more than two game device controllers. STICK will not read a mouse axis. | * '''QB64''' allows any number of coordinate pairs for more than two game device controllers. STICK will not read a mouse axis. | ||
* ''axis_number'' can be used as the next axis parameter for controllers with multiple axis using the SAME ''directional'' parameters. | * ''axis_number'' can be used as the next axis parameter for controllers with multiple axis using the SAME ''directional'' parameters. | ||
* The ''axis_number'' 1 can be omitted for the main stick column and row parameter reads. | * The ''axis_number'' 1 can be omitted for the main stick column and row parameter reads. | ||
* Point of view "hats" also have 2 axis. Slide, turn or twist controls have one. The device determines the order of the axis. | * Point of view "hats" also have 2 axis. Slide, turn or twist controls have one. The device determines the order of the axis. | ||
* Returns coordinate values from 1 to 254. | * Returns coordinate values from 1 to 254. QBasic only returned values from 1 to 200. | ||
* STICK(0) is required to get values from the other STICK functions. Always read it first! | * STICK(0) is required to get values from the other STICK functions. Always read it first! | ||
{{ | {{FixedStart}}'''STICK(0) returns the column coordinate of device 1. Enables reads of the other STICK values.''' | ||
'''STICK(1) returns row coordinate of device 1.''' | '''STICK(1) returns row coordinate of device 1.''' | ||
STICK(2) returns column coordinate of device 2. (second joystick if used) | STICK(2) returns column coordinate of device 2. (second joystick if used) | ||
STICK(3) returns row coordinate of device 2 if used. ( | STICK(3) returns row coordinate of device 2 if used. (QBasic maximum was 2 controllers) | ||
'''STICK(4) returns column coordinate of device 3. (other joysticks if used in QB64 only!)''' | '''STICK(4) returns column coordinate of device 3. (other joysticks if used in QB64 only!)''' | ||
'''STICK(5) returns row coordinate of device 3 if used.''' | '''STICK(5) returns row coordinate of device 3 if used.''' | ||
{{ | {{FixedEnd}} | ||
* '''QB64''' allows more joysticks by extending the numbers in pairs like device 3 above. EX: STICK(6): STICK(7) 'device 4 | * '''QB64''' allows more joysticks by extending the numbers in pairs like device 3 above. EX: STICK(6): STICK(7) 'device 4 | ||
* '''QB64''' allows a dual stick to be read using the same first parameters and 2 as the second parameter. EX: STICK(0, 2) | * '''QB64''' allows a dual stick to be read using the same first parameters and 2 as the second parameter. EX: STICK(0, 2) | ||
Line 29: | Line 26: | ||
{{PageExamples}} | |||
''Example 1:'' Displays the input from 3 joysticks, all with dual sticks and 3 buttons. | ''Example 1:'' Displays the input from 3 joysticks, all with dual sticks and 3 buttons. | ||
{{CodeStart}} | {{CodeStart}} | ||
{{Cl|DO}}: {{Cl|_LIMIT}} 10 | {{Cl|DO}}: {{Cl|_LIMIT}} 10 | ||
{{Cl|LOCATE}} 1, 1 | {{Cl|LOCATE}} 1, 1 | ||
{{Cl|PRINT}} "JOY1: {{Cl|STICK}}"; {{Cl|STICK}}(0); {{Cl|STICK}}(1); {{Cl|STICK}}(0, 2); {{Cl|STICK}}(1, 2);_ | {{Cl|PRINT}} "JOY1: {{Cl|STICK}}"; {{Cl|STICK}}(0); {{Cl|STICK}}(1); {{Cl|STICK}}(0, 2); {{Cl|STICK}}(1, 2);_ | ||
"STRIG"; {{Cl|STRIG}}(0); {{Cl|STRIG}}(1); {{Cl|STRIG}}(4); {{Cl|STRIG}}(5); {{Cl|STRIG}}(8); {{Cl|STRIG}}(9) | "STRIG"; {{Cl|STRIG}}(0); {{Cl|STRIG}}(1); {{Cl|STRIG}}(4); {{Cl|STRIG}}(5); {{Cl|STRIG}}(8); {{Cl|STRIG}}(9) | ||
{{Cl|PRINT}} "JOY2: {{Cl|STICK}}"; {{Cl|STICK}}(2); {{Cl|STICK}}(3); {{Cl|STICK}}(2, 2); {{Cl|STICK}}(3, 2);_ | {{Cl|PRINT}} "JOY2: {{Cl|STICK}}"; {{Cl|STICK}}(2); {{Cl|STICK}}(3); {{Cl|STICK}}(2, 2); {{Cl|STICK}}(3, 2);_ | ||
"STRIG"; {{Cl|STRIG}}(2); {{Cl|STRIG}}(3); {{Cl|STRIG}}(6); {{Cl|STRIG}}(7); {{Cl|STRIG}}(10); {{Cl|STRIG}}(11) | "STRIG"; {{Cl|STRIG}}(2); {{Cl|STRIG}}(3); {{Cl|STRIG}}(6); {{Cl|STRIG}}(7); {{Cl|STRIG}}(10); {{Cl|STRIG}}(11) | ||
{{Cl|PRINT}} "JOY3: {{Cl|STICK}}"; {{Cl|STICK}}(4); {{Cl|STICK}}(5); {{Cl|STICK}}(4, 2); {{Cl|STICK}}(5, 2);_ | {{Cl|PRINT}} "JOY3: {{Cl|STICK}}"; {{Cl|STICK}}(4); {{Cl|STICK}}(5); {{Cl|STICK}}(4, 2); {{Cl|STICK}}(5, 2);_ | ||
"STRIG"; {{Cl|STRIG}}(0, 3); {{Cl|STRIG}}(1, 3); {{Cl|STRIG}}(4, 3); {{Cl|STRIG}}(5, 3); {{Cl|STRIG}}(8, 3); {{Cl|STRIG}}(9, 3) | "STRIG"; {{Cl|STRIG}}(0, 3); {{Cl|STRIG}}(1, 3); {{Cl|STRIG}}(4, 3); {{Cl|STRIG}}(5, 3); {{Cl|STRIG}}(8, 3); {{Cl|STRIG}}(9, 3) | ||
{{Cl|LOOP}} {{Cl|UNTIL}} {{Cl|INKEY$}} > "" | {{Cl|LOOP}} {{Cl|UNTIL}} {{Cl|INKEY$}} > "" | ||
{{CodeEnd}} | {{CodeEnd}} | ||
:''Explanation:'' Notice the extra '''QB64 only''' parameters used to cater for the 2nd stick and the buttons of the 3rd joystick. | :''Explanation:'' Notice the extra '''QB64 only''' parameters used to cater for the 2nd stick and the buttons of the 3rd joystick. | ||
Line 49: | Line 47: | ||
''Example 2:'' Displays the Sidewinder Precision Pro Stick, Slider, Z Axis, and Hat Point of View. | ''Example 2:'' Displays the Sidewinder Precision Pro Stick, Slider, Z Axis, and Hat Point of View. | ||
{{CodeStart}} | {{CodeStart}} | ||
{{Cl|SCREEN}} 12 | {{Cl|SCREEN}} 12 | ||
d = {{Cl|_DEVICES}} | d = {{Cl|_DEVICES}} | ||
Line 68: | Line 66: | ||
{{Cl|NEXT}} | {{Cl|NEXT}} | ||
{{Cl|PRINT}} | {{Cl|PRINT}} | ||
{{Cl|LOOP}} {{Cl|UNTIL}} {{Cl|INKEY$}} <> "" | {{Cl|LOOP}} {{Cl|UNTIL}} {{Cl|INKEY$}} <> "" | ||
{{CodeEnd}} | {{CodeEnd}} | ||
: ''Explanation:'' Each axis on the first controller found is either STICK(0, n) or STICK(1, n) with n increasing when necessary. | : ''Explanation:'' Each axis on the first controller found is either STICK(0, n) or STICK(1, n) with n increasing when necessary. | ||
Line 86: | Line 84: | ||
-0 -1 █ 0 0 █ 0 0 █ 0 0 █ 0 0 █ 0 0 █ 0 0 █ 0 0 █ 0 0 █ | -0 -1 █ 0 0 █ 0 0 █ 0 0 █ 0 0 █ 0 0 █ 0 0 █ 0 0 █ 0 0 █ | ||
{{OutputEnd}} | {{OutputEnd}} | ||
: ''Note:'' A Sidewinder Precision Pro requires that pins 2 and 7(blue and purple) be connected together for | : ''Note:'' A Sidewinder Precision Pro requires that pins 2 and 7(blue and purple) be connected together for digital USB recognition. | ||
<center> [http://www.amazon.com/Belkin-F3U200-08INCH-Joystick-Adapter-SideWinder/dp/B000067RIV Sidewinder Precision Pro game port to USB adapter]</center> | <center>[http://www.amazon.com/Belkin-F3U200-08INCH-Joystick-Adapter-SideWinder/dp/B000067RIV Sidewinder Precision Pro game port to USB adapter]</center> | ||
{{PageSeeAlso}} | |||
* [[STRIG]] | * [[STRIG]] | ||
* [[ON STRIG(n)]] | * [[ON STRIG(n)]] | ||
* [[_DEVICES]], [[_DEVICE$]], [[_LASTBUTTON]] | * [[_DEVICES]], [[_DEVICE$]], [[_LASTBUTTON]] | ||
* [ | * [[Wikipedia:Analog stick|Single and Dual Stick Controllers]] | ||
{{PageNavigation}} | {{PageNavigation}} |
Latest revision as of 16:33, 14 June 2024
The STICK function returns the directional axis coordinate move of game port (&H201) joystick or USB controller devices.
Syntax
- QuickBASIC
- coordinate_move% = STICK(direction%)
- QB64
- coordinate_move% = STICK(direction%[, axis_number%])
Description
- QB64 allows any number of coordinate pairs for more than two game device controllers. STICK will not read a mouse axis.
- axis_number can be used as the next axis parameter for controllers with multiple axis using the SAME directional parameters.
- The axis_number 1 can be omitted for the main stick column and row parameter reads.
- Point of view "hats" also have 2 axis. Slide, turn or twist controls have one. The device determines the order of the axis.
- Returns coordinate values from 1 to 254. QBasic only returned values from 1 to 200.
- STICK(0) is required to get values from the other STICK functions. Always read it first!
STICK(0) returns the column coordinate of device 1. Enables reads of the other STICK values. STICK(1) returns row coordinate of device 1. STICK(2) returns column coordinate of device 2. (second joystick if used) STICK(3) returns row coordinate of device 2 if used. (QBasic maximum was 2 controllers) STICK(4) returns column coordinate of device 3. (other joysticks if used in QB64 only!) STICK(5) returns row coordinate of device 3 if used. |
- QB64 allows more joysticks by extending the numbers in pairs like device 3 above. EX: STICK(6): STICK(7) 'device 4
- QB64 allows a dual stick to be read using the same first parameters and 2 as the second parameter. EX: STICK(0, 2)
- There will not be an error if you try to read too many device axis or buttons!
Examples
Example 1: Displays the input from 3 joysticks, all with dual sticks and 3 buttons.
DO: _LIMIT 10 LOCATE 1, 1 PRINT "JOY1: STICK"; STICK(0); STICK(1); STICK(0, 2); STICK(1, 2);_ "STRIG"; STRIG(0); STRIG(1); STRIG(4); STRIG(5); STRIG(8); STRIG(9) PRINT "JOY2: STICK"; STICK(2); STICK(3); STICK(2, 2); STICK(3, 2);_ "STRIG"; STRIG(2); STRIG(3); STRIG(6); STRIG(7); STRIG(10); STRIG(11) PRINT "JOY3: STICK"; STICK(4); STICK(5); STICK(4, 2); STICK(5, 2);_ "STRIG"; STRIG(0, 3); STRIG(1, 3); STRIG(4, 3); STRIG(5, 3); STRIG(8, 3); STRIG(9, 3) LOOP UNTIL INKEY$ > "" |
- Explanation: Notice the extra QB64 only parameters used to cater for the 2nd stick and the buttons of the 3rd joystick.
Example 2: Displays the Sidewinder Precision Pro Stick, Slider, Z Axis, and Hat Point of View.
SCREEN 12 d = _DEVICES PRINT "Number of input devices found ="; d FOR i = 1 TO d PRINT _DEVICE$(i) buttons = _LASTBUTTON(i) PRINT "Buttons:"; buttons NEXT DO: _LIMIT 50 LOCATE 10, 1 PRINT " X Main Y Slider Z-axis POV" PRINT STICK(0, 1), STICK(1, 1), STICK(0, 2), STICK(1, 2), STICK(0, 3); STICK(1, 3); " " PRINT " Buttons" FOR i = 0 TO 4 * buttons - 1 STEP 4 PRINT STRIG(i); STRIG(i + 1); CHR$(219); NEXT PRINT LOOP UNTIL INKEY$ <> "" |
- Explanation: Each axis on the first controller found is either STICK(0, n) or STICK(1, n) with n increasing when necessary.
Number of input devices found = 3 [KEYBOARD][BUTTON]] Buttons: 512 [MOUSE][BUTTON][AXIS][WHEEL] Buttons: 3 [CONTROLLER][[NAME][Microsoft Sidewinder Precision Pro (USB)]][BUTTON][AXIS] Buttons: 9 X Main Y Slider Z-axis POV 127 127 254 127 127 127 Buttons -0 -1 █ 0 0 █ 0 0 █ 0 0 █ 0 0 █ 0 0 █ 0 0 █ 0 0 █ 0 0 █ |
- Note: A Sidewinder Precision Pro requires that pins 2 and 7(blue and purple) be connected together for digital USB recognition.
See also