• Print

Author Topic: Am i doing it wrong or is it a bug? Gamepad...  (Read 298 times)

unseenmachine

  • Hero Member
  • *****
  • Posts: 3285
  • A fish, a fish, a fishy o!
Am i doing it wrong or is it a bug? Gamepad...
« on: September 26, 2011, 05:58:07 PM »
STICK(0, 2) seems to be attached to my Z axis (Left and right trigger buttons) instead of the x axis on the second stick, is it me doing it wrong? (i got it from the wiki) or a bug? Y axis returns fine on the second stick and the first stick works fine.

Code: [Select]
'http:// UnseenGDK - Gamepad patch v.01
DIM Pad AS GamepadState

DO
   _LIMIT 30
   CLS
   GDK_Gamepad_GetState Pad, 1
   PRINT Pad.X, Pad.Y, Pad.X2, Pad.Y2
   _DISPLAY
LOOP


TYPE GamepadState
   B1 AS INTEGER
   B2 AS INTEGER
   B3 AS INTEGER
   B4 AS INTEGER
   B5 AS INTEGER
   B6 AS INTEGER
   B7 AS INTEGER
   B8 AS INTEGER
   B9 AS INTEGER
   B10 AS INTEGER
   B11 AS INTEGER
   B12 AS INTEGER
   X AS INTEGER
   Y AS INTEGER
   Z AS INTEGER
   X2 AS INTEGER
   Y2 AS INTEGER
   POV AS INTEGER
END TYPE



SUB GDK_Gamepad_GetState (Gpad AS GamepadState, PadNum AS INTEGER)
SELECT CASE PadNum%
   CASE 1
      Gpad.X = STICK(0)
      Gpad.Y = STICK(1)
      Gpad.X2 = STICK(0, 2)
      Gpad.Y2 = STICK(1, 2)
   CASE 2
      Gpad.X = STICK(2)
      Gpad.Y = STICK(3)
   CASE ELSE

END SELECT

END SUB



     
UnseenGDK Download : http://dl.dropbox.com/u/8822351/UnseenGDK.bm
GDK Tutorial : http://dl.dropbox.com/u/8822351/UnseenGDK_Tutorial.doc
VQB02 : http://dl.dropbox.com/u/8822351/VQB02.zip

Cyperium

  • Hero Member
  • *****
  • Posts: 3308
  • Knowledge is good, but understanding is better
    • Cyperium
    • Email
Re: Am i doing it wrong or is it a bug? Gamepad...
« Reply #1 on: September 26, 2011, 06:34:06 PM »
Quote
STICK(0, 2) seems to be attached to my Z axis
lol
Venture - New Prototype, QB64 Editor v1.95b (linux compatible, if you compile the source).

Clippy

  • Hero Member
  • *****
  • Posts: 16446
  • I LOVE π = 4 * ATN(1)    Use the QB64 WIKI >>>
    • Pete's Qbasic Site
    • Email
Re: Am i doing it wrong or is it a bug? Gamepad...
« Reply #2 on: September 26, 2011, 06:39:07 PM »
According to my Sidewinder the first 2 are the main axis, the third is the slider, and the last one is the Z axis.


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); "   "

0 and 1 designate the first controller. The axis number becomes 2 and increases as you go.
« Last Edit: September 26, 2011, 06:55:58 PM by Clippy »
QB64 WIKI: Main Page
Download Q-Basics Code Demo: Q-Basics.zip
Download QB64 BAT, IconAdder and VBS shortcuts: QB64BAT.zip
Download QB64 DLL files in a ZIP: Program64.zip

unseenmachine

  • Hero Member
  • *****
  • Posts: 3285
  • A fish, a fish, a fishy o!
Re: Am i doing it wrong or is it a bug? Gamepad...
« Reply #3 on: September 26, 2011, 08:29:13 PM »
So i assume that it's working differantly for each type of gamepad (Mines an Xbox 360 controller for pc).

Whats a "Slider"?

On my system...

(0, 1) and (1, 1) is left stick and works fine.
(0, 2) is the Z axis (L&R triggers) and (1, 2) is the Y axis on the second stick...

I can't find a setting that allows me to read the X axis on the second stick...

John
UnseenGDK Download : http://dl.dropbox.com/u/8822351/UnseenGDK.bm
GDK Tutorial : http://dl.dropbox.com/u/8822351/UnseenGDK_Tutorial.doc
VQB02 : http://dl.dropbox.com/u/8822351/VQB02.zip

Clippy

  • Hero Member
  • *****
  • Posts: 16446
  • I LOVE π = 4 * ATN(1)    Use the QB64 WIKI >>>
    • Pete's Qbasic Site
    • Email
Re: Am i doing it wrong or is it a bug? Gamepad...
« Reply #4 on: September 26, 2011, 10:55:43 PM »
Did you try STICK(0, 3) ? 0 is for the x axis.
QB64 WIKI: Main Page
Download Q-Basics Code Demo: Q-Basics.zip
Download QB64 BAT, IconAdder and VBS shortcuts: QB64BAT.zip
Download QB64 DLL files in a ZIP: Program64.zip

unseenmachine

  • Hero Member
  • *****
  • Posts: 3285
  • A fish, a fish, a fishy o!
Re: Am i doing it wrong or is it a bug? Gamepad...
« Reply #5 on: September 27, 2011, 03:20:57 PM »
STICK (0, 3) works! Nice one clippy. But that leads me to assume that not all gamepads will function the same...should i alert Galleon to this one?
UnseenGDK Download : http://dl.dropbox.com/u/8822351/UnseenGDK.bm
GDK Tutorial : http://dl.dropbox.com/u/8822351/UnseenGDK_Tutorial.doc
VQB02 : http://dl.dropbox.com/u/8822351/VQB02.zip

Clippy

  • Hero Member
  • *****
  • Posts: 16446
  • I LOVE π = 4 * ATN(1)    Use the QB64 WIKI >>>
    • Pete's Qbasic Site
    • Email
Re: Am i doing it wrong or is it a bug? Gamepad...
« Reply #6 on: September 27, 2011, 05:38:07 PM »
No, each game controller will have their own order of things. When in doubt just add some extra STICK commands to find them all. They won't create any errors, but it may cause problems setting a game up to use them.

My Sidewinder has the main axis first as should all other controllers. Your's has a Z axis where mine has a slider control. Then mine has the Z axis. My last axis is the Hat control for 2 point of view coordinates.

_DEVICES will tell you the number of buttons with _LASTBUTTON. Don't know how to count axis...
QB64 WIKI: Main Page
Download Q-Basics Code Demo: Q-Basics.zip
Download QB64 BAT, IconAdder and VBS shortcuts: QB64BAT.zip
Download QB64 DLL files in a ZIP: Program64.zip

  • Print