Game Development Community

Trouble with joystick binding

by Mindworks Learning · in Torque Game Builder · 06/15/2006 (3:33 pm) · 1 replies

Hello,

I'm trying to set the binding for the the joystick but I'm not getting any response. Here's the code:

function setBindings(){
moveMap.bind(joystick0, "xaxis", testJoy);
moveMap.bind(joystick0, "button1", testJoy);
moveMap.bind(keyboard0, "a", testKey);
}

function testKey(){
echo ("key pressed");
}

function testJoy(){
echo ("joy move");
}

After I call setBindings the keyboard press is detected but not the gamepad activity. The console output seems to indicate that the gamepad is being detected:

keyboard0 input device created.
mouse0 input device created.
joystick0 input device created.


Any info is apprectiated!

#1
06/16/2006 (4:30 pm)
Figured it out. Here's the corrected code:

function setBindings(){
$enableDirectInput = "1";
activateDirectInput();

moveMap.bind(joystick0, "xaxis", moveJoyX);
moveMap.bind(joystick0, "button1", joyPress1);
moveMap.bind(keyboard0, "a", testKey);
}


function moveJoyX(%val){
echo("joy move x:" SPC %val);
}

function joyPress1(){
echo("joy press 1");
}



Also $pref::Input::JoystickEnabled = "1"; needs to be in common\preferences\defaultPrefs.cs