Counting joysticks?
by Jon Mitchell · in Torque Game Builder · 04/02/2007 (11:14 am) · 3 replies
I spent the better part of the day searching for various functions related to joysticks and direct input, I am trying to find a way to count the number of joysticks acquired.
The closest I have come was on TDN here:
http://tdn.garagegames.com/wiki/TorqueScript_Console_Functions_6#isJoystickDetected.28.29
I can not seem to find any other info on the isJoystickDetected() function to see if it can be expanded or do any sort of output.
The closest I have come was on TDN here:
http://tdn.garagegames.com/wiki/TorqueScript_Console_Functions_6#isJoystickDetected.28.29
I can not seem to find any other info on the isJoystickDetected() function to see if it can be expanded or do any sort of output.
#2
A joystick script, which activates a package, and in the package it listens to joystick0-9 (first 10 joysticks) and has a bind setup for Button0 on all of them, and then calls a "joystickIsActive(%index)" ... this way, if they have 3-4 joysticks setup ... and the user input requested is to be joystick based ... all the users have to identify them selves by pressing there 0 button ... I've seen quite a few games that do this, even on consoles ... such as the XBOX and Gamecube ... even the Wii ... where it asks who has the First Player control, and who has the Second Player control ... rather then assuming Joystick0 is Player 1 and Joystick1 is Player 2 ...
This could be used to allow the players to pick up a random gamepad, and then assign themselves to the Player slots ... rather then forcing it based on the gamepad index they are controlling ... for a PC, this would probably be a preferred method, as they could be attaching the gamepads through various external USB Hubs or various USB Slots ... and there is no real "first gamepad" as far as the user sees it ... since windows registers them in the order they were plugged in ...
To do this, you could have a custom GUI that can be displayed, or you can simply load a custom level that is designed specifically to configure player input preferences ... before the game starts, then retain this information throughout the duration of the gameplay, and possibly even store it in a config file and just verify it before the game starts again the next time they launch it ...
04/02/2007 (12:29 pm)
You could, in the event the user wants to use more then one joystick, simply prompt the user to press the Button0 button on the additional joystick ... have something like the following;A joystick script, which activates a package, and in the package it listens to joystick0-9 (first 10 joysticks) and has a bind setup for Button0 on all of them, and then calls a "joystickIsActive(%index)" ... this way, if they have 3-4 joysticks setup ... and the user input requested is to be joystick based ... all the users have to identify them selves by pressing there 0 button ... I've seen quite a few games that do this, even on consoles ... such as the XBOX and Gamecube ... even the Wii ... where it asks who has the First Player control, and who has the Second Player control ... rather then assuming Joystick0 is Player 1 and Joystick1 is Player 2 ...
This could be used to allow the players to pick up a random gamepad, and then assign themselves to the Player slots ... rather then forcing it based on the gamepad index they are controlling ... for a PC, this would probably be a preferred method, as they could be attaching the gamepads through various external USB Hubs or various USB Slots ... and there is no real "first gamepad" as far as the user sees it ... since windows registers them in the order they were plugged in ...
To do this, you could have a custom GUI that can be displayed, or you can simply load a custom level that is designed specifically to configure player input preferences ... before the game starts, then retain this information throughout the duration of the gameplay, and possibly even store it in a config file and just verify it before the game starts again the next time they launch it ...
#3
Currently I let a person set their action binding, but I am thinking about scrapping that in favor of pre-defined keys, the method I am using is very poor because I tried to re-invent the wheel so to speak instead of figuring out how to use the built in function of TGB that will allow you to use custom key mappings, it was done in the Adventure kit too, unfortunately how it is done I think may still be a little above me still.
...anyhow Thanks for the info David! :-)
04/09/2007 (7:04 am)
That is a really clever idea David, I will need to remember that for a later date though. The game I am tinkering around with right now uses keyboard or gamepad input and I think your idea would be excellent for a game that uses just gamepads, unless I set an extra option for a key, so it would say player 1 press space or button 0 on the game pad..... I hate it when I get thinking more halfway through a post :-pCurrently I let a person set their action binding, but I am thinking about scrapping that in favor of pre-defined keys, the method I am using is very poor because I tried to re-invent the wheel so to speak instead of figuring out how to use the built in function of TGB that will allow you to use custom key mappings, it was done in the Adventure kit too, unfortunately how it is done I think may still be a little above me still.
...anyhow Thanks for the info David! :-)
Torque Owner Jon Mitchell
Studio with out a name
In the control set up for player 2 I check to see if player one has set their option to use a gamepad and I set the bindings based on that info:
//if gamepad is set, set bindings
//check if P1 is using gamepad, if they are set ours to the second controller
if($options::p2gamepad == true)
{
if($options::p1gamepad == true)
{
%p2inputMethod = "joystick1";
} else { %p2inputMethod = "joystick0"; }