Difference between revisions of "STRIG"

From QB64 Wiki
Jump to navigation Jump to search
imported>Clippy
m
imported>Clippy
m
Line 9: Line 9:
* Button values used range from 0 to 7 only. Use joystick A values for just one joystick.
* Button values used range from 0 to 7 only. Use joystick A values for just one joystick.
* Returns True(-1) or False(0) button press values for 2 joysticks:
* Returns True(-1) or False(0) button press values for 2 joysticks:
:* STRIG(0) = -1 lower button 1 on joystick A pressed since last STRIG(0)
{{WhiteStart}}  STRIG(0) = -1 lower button 1 on joystick A pressed since last STRIG(0)
:* STRIG(1) = -1 lower button 1 on joystick A currently pressed
  STRIG(1) = -1 lower button 1 on joystick A currently pressed
:* STRIG(2) = -1 lower button 1 on joystick B pressed since last STRIG(2)
  STRIG(2) = -1 lower button 1 on joystick B pressed since last STRIG(2)
:* STRIG(3) = -1 lower button 1 on joystick B currently pressed
  STRIG(3) = -1 lower button 1 on joystick B currently pressed
:* STRIG(4) = -1 upper button 2 on joystick A pressed since last STRIG(4)
  STRIG(4) = -1 upper button 2 on joystick A pressed since last STRIG(4)
:* STRIG(5) = -1 upper button 2 on joystick A currently pressed
  STRIG(5) = -1 upper button 2 on joystick A currently pressed
:* STRIG(6) = -1 upper button 2 on joystick B pressed since last STRIG(6)"
  STRIG(6) = -1 upper button 2 on joystick B pressed since last STRIG(6)
:* STRIG(7) = -1 upper button 2 on joystick B currently pressed
  STRIG(7) = -1 upper button 2 on joystick B currently pressed
* STRIG(0), STRIG(2), STRIG(4) and STRIG(6) are used to monitor any presses that might have been missed.
  STRIG(8) = -1 upper button 3 on joystick A pressed since last STRIG(8)  'QB64 only
  STRIG(9) = -1 upper button 3 on joystick A currently pressed         
  STRIG(10) = -1 upper button 3 on joystick B pressed since last STRIG(10) 'QB64 only
  STRIG(11) = -1 upper button 3 on joystick B currently pressed
{{WhiteEnd}}
* STRIG(0), STRIG(2), STRIG(4), STRIG(6), STRIG(8), STRIG(10) are used to monitor any presses that might have been missed.
'''Note: Only resistance type joysticks can be read by [[STICK]]. Digital types cannot be read!'''
'''Note: Only resistance type joysticks can be read by [[STICK]]. Digital types cannot be read!'''
''Example:'' Displays the input from 3 joysticks, all with dual sticks and 3 buttons.
{{CodeStart}} '' ''
{{Cl|DO}}: {{Cl|_LIMIT}} 10
  {{Cl|LOCATE}} 1, 1
  {{Cl|PRINT}} "JOY1: {{Cl|STICK}}"; {{Cl|STICK}}(0); {{Cl|STICK}}(1); {{Cl|STICK}}(0, 2); {{Cl|STICK}}(1, 2);_ 'code to next line
  "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);_ 'code to next line
  "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);_ 'code to next line
  "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$}} > "" '' ''
{{CodeEnd}}
:''Explanation:'' Notice the extra '''QB64 only''' parameters used to cater for the 2nd stick and the buttons of the 3rd joystick.





Revision as of 16:03, 21 June 2011

The STRIG function returns button presses on game port (&H201) joystick(s).


Syntax

IF STRIG(button%) THEN code


Description:

  • Button values used range from 0 to 7 only. Use joystick A values for just one joystick.
  • Returns True(-1) or False(0) button press values for 2 joysticks:

STRIG(0) = -1 lower button 1 on joystick A pressed since last STRIG(0) STRIG(1) = -1 lower button 1 on joystick A currently pressed STRIG(2) = -1 lower button 1 on joystick B pressed since last STRIG(2) STRIG(3) = -1 lower button 1 on joystick B currently pressed STRIG(4) = -1 upper button 2 on joystick A pressed since last STRIG(4) STRIG(5) = -1 upper button 2 on joystick A currently pressed STRIG(6) = -1 upper button 2 on joystick B pressed since last STRIG(6) STRIG(7) = -1 upper button 2 on joystick B currently pressed STRIG(8) = -1 upper button 3 on joystick A pressed since last STRIG(8) 'QB64 only STRIG(9) = -1 upper button 3 on joystick A currently pressed STRIG(10) = -1 upper button 3 on joystick B pressed since last STRIG(10) 'QB64 only STRIG(11) = -1 upper button 3 on joystick B currently pressed

  • STRIG(0), STRIG(2), STRIG(4), STRIG(6), STRIG(8), STRIG(10) are used to monitor any presses that might have been missed.

Note: Only resistance type joysticks can be read by STICK. Digital types cannot be read!


Example: 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);_ 'code to next line "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);_ 'code to next line "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);_ 'code to next line "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.


See also:



Navigation:
Keyword Reference - Alphabetical
Keyword Reference - By Usage
Main Wiki Page