Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

DarkBASIC Professional Discussion / Using two joysticks simultaneously... DB is pro again...

Author
Message
Quel
15
Years of Service
User Offline
Joined: 13th Mar 2009
Location:
Posted: 20th Jan 2012 23:20
For starters the help file is more generic on this one than ever.
Some of the explanations are like they weren't written by English speaking people.


Anyways:

There are two different ways to set the active joystick:

1.)
`in main loop
set control device index 0
joy1X# = joystick x() : joy1Y# = joystick y()
set control device index 1
joy2X# = joystick x() : joy2Y# = joystick y()

2.)
`initialize
perform checklist for control devices
P1_Controller$ = checklist string$(1)
P2_Controller$ = checklist string$(2)
empty checklist

`in main loop stuff
set control device P1_Controller$, 0
joy1X# = joystick x() : joy1Y# = joystick y()
set control device P2_Controller$, 1
joy2X# = joystick x() : joy2Y# = joystick y()


Method 1. makes the first joystick active... and the second is so dead like hell... i switch ID's, then the second works awesomely, and the first one is deaf.

Method 2. activates both, but very rarely. I mean they give signals like every 100(+rnd(50)*10, this is a kinda close estimation) fps'... PLUS this seems to lower the running speed of the program.

This is a WHATDA**** moment for me, again, now that i have wasted an other couple hours from my life for nothing.

HELP.

-Mental Hybrid: A unique heavy story based shoot'em ~40% (primary project)
-CoreFleet: An underground commander unit based RTS (canned) ~15%
IanM
Retired Moderator
21
Years of Service
User Offline
Joined: 11th Sep 2002
Location: In my moon base
Posted: 20th Jan 2012 23:41
What you should be doing is selecting a controller index and initialising the device to a different controller each time.

Here's code I wrote for testing multiple controllers with force-feedback:


The for-loop near the beginning loads and initialises up to 8 controllers simultaneously, and then allows you to switch between them using the numbers on your keyboard.

The command used to switch between controllers is the SET CONTROL DEVICE INDEX command, while the SET CONTROL DEVICE command is used to set each individual controller up against each index. Once the device has been set up once, it is never touched again (unless you decide you need to refresh the controllers for some reason, eg someone removed or added or both to the available controllers).

Quel
15
Years of Service
User Offline
Joined: 13th Mar 2009
Location:
Posted: 21st Jan 2012 00:02
Damn, this is so straight forward, nice and easy.

Okay, the Pro-ness has once more been saved. By you Ian. Thank you.

But nothing saves the help files from a good swearing behind the scenes from me.

-Mental Hybrid: A unique heavy story based shoot'em ~40% (primary project)
-CoreFleet: An underground commander unit based RTS (canned) ~15%
MrValentine
AGK Backer
13
Years of Service
User Offline
Joined: 5th Dec 2010
Playing: FFVII
Posted: 21st Jan 2012 04:12
Nice... shame I only got one joypad atm this will work on any joypad?... I intend to implement the wired X360 joypads...

Login to post a reply

Server time is: 2024-05-13 13:41:44
Your offset time is: 2024-05-13 13:41:44