Game Development Community

Couple of joystick/gamepad issues

by Bhood · in Torque Game Engine · 12/16/2005 (7:18 am) · 2 replies

Hi there,

I'm in the process of testing out using a joystick or gamepad on my project and have come across a couple of issues...

- the version of my project written for joystick/gamepad I can no longer use the keyboard inputs. i.e. I'd like to have a joystick/gamepad or mouse and keyboard version but the joystick controls seem to override the keyboard - oh to clarify, I can still use the arrow forward/backward keyboard keys (and mouse still does pitch/yaw) but nothing that's been assigned a bind to any actual keys on the joystick works on keyboard anymore.

Anyone know a fix for this?

- Also, am having a problem assigning footstep sound to joystick movement, forward and back, well they play but won't stop (and play really fast!). I'll put code I'm using below, works fine when using arrows on keyboard.

//--joystick move forward function from presetkeys.cs (equivalent to default.bind.cs)

function moveforward2(%val)
{


if( %val > - 0.7 && %val < 0.7 )
{
$mvForwardAction = 0;
return;
}

$mvForwardAction = -%val*$movementSpeed;
if (%val)
commandToServer('startFootsteps');
else
commandToServer('stopFootsteps');
}

//--referencing this part of my file called footsteps.cs...

datablock AudioProfile(Footstep1)
{
fileName = "~/data/sound/FootStep1.wav";
description = "AudioClosest3d";
preload = true;
};

function serverCmdStartFootsteps(%client)
{
%client.player.schedule(200,playFootstep);
%client.player.footstepson = true;
}
function serverCmdStopFootsteps(%client)
{
%client.player.footstepson = false;
}

function Player::playFootstep(%this)
{
if(%this.footstepson)
{
serverPlay3D(FootStep1,%this.getTransform());
%this.schedule(500,playFootstep);
}
}

Can anyone suggest where I'm going wrong?
thanks, Bev

#1
12/16/2005 (8:07 am)
Joystick inputs and keyboard inputs are entirely different
The joystick will be providing constant updates to teh action map, which will continously call moveForward2. Well, it may not call it if you *dont* touch it and it stays still. Keyboard input is sent when you press and unpress a key. So for the arrow keys, it'll call start when you press, and stop when you unpress. moveForward is not called at all inbetween those 2 key events.

Torque in its current state does not allow you to bind 2 keys/buttons to 1 command.
You would need to setup a set of alternate commands and bind buttons/keys to that (as a purely script alternative to changing how Torque binds commands to keys)
#2
12/16/2005 (11:19 am)
Hi there, thanks for the reply...got it about creating a re-named set of bind keys, but

...to clarify is there something I can do instead then to get my sounds to play better for joystick/gamepad forward/back etc input? How do other folk do it?

thanks, bev