Blockland Forums > General Discussion

Gamepad compatibility script for BL

Pages: << < (3/5) > >>

Chrono:


--- Quote from: ._maxwell23461_. on July 12, 2012, 10:18:13 PM ---http://forum.blockland.us/index.php?topic=135523.0

--- End quote ---
>joy2key

Well it's a damn shame that topic doesn't use the native support TGE has!

Chrono:

Here's the code you're looking for.
Sorry that it's not in add-on format. I kinda ripped it apart and kept the old code in a text file.


--- Code: ---$Pref::Input::JoystickDeadZone = "-0.26 0.26";
$Pref::Input::JoystickEnabled = true;
$Pref::Input::JoystickInvert = false;
$Pref::Input::JoystickSensitivity = 0.1;
$Pref::Input::JoystickSouthPaw = false;

if($Pref::Input::JoystickEnabled)
enableJoystick();

function joystickMoveX(%val)
{
if(%val > 0)
{
$mvRightAction = %val * $movementSpeed;
$mvLeftAction = 0;
}
else
{
$mvLeftAction = -%val * $movementSpeed;
$mvRightAction = 0;
}
}

function joystickMoveY(%val)
{
if(%val > 0)
{
$mvBackwardAction = %val * $movementSpeed;
$mvForwardAction = 0;
}
else
{
$mvForwardAction = -%val * $movementSpeed;
$mvBackwardAction = 0;
}
}

function getJoystickAdjustAmount(%val)
{
   // based on a default camera FOV of 90'
   return(%val * ($cameraFov / 90) * $Pref::Input::JoystickSensitivity);
}

function joystickYaw(%val)
{
if(%val > 0)
{
$mvYawLeftSpeed = getJoystickAdjustAmount(%val);
$mvYawRightSpeed = 0;
}
else
{
$mvYawRightSpeed = getJoystickAdjustAmount(-%val);
$mvYawLeftSpeed = 0;
}
}

function joystickPitch(%val)
{
if($Pref::Input::JoystickInvert)
%val = -%val;

if(%val > 0)
{
$mvPitchUpSpeed = getJoystickAdjustAmount(%val);
$mvPitchDownSpeed = 0;
}
else
{
$mvPitchDownSpeed = getJoystickAdjustAmount(-%val);
$mvPitchUpSpeed = 0;
}
}

function joystickFire(%val)
{
if(%val < 0)
{
$mvTriggerCount0++;
}
else if(%val > 0)
{
$mvTriggerCount4++;
}
else
{
$mvTriggerCount0 = 0;
$mvTriggerCount4 = 0;
}
}

function joystickShowPlayerList(%val)
{
if(%val)
Canvas.pushDialog(NewPlayerListGui);
else
Canvas.popDialog(NewPlayerListGui);
}

function joystickToggleEscapeMenu(%val)
{
if(%val)
escapeMenu.toggle();
}

if($Pref::Input::JoystickSouthPaw)
{
moveMap.bind(joystick, "rxaxis", "D", $Pref::Input::JoystickDeadZone, joystickMoveX);
moveMap.bind(joystick, "ryaxis", "D", $Pref::Input::JoystickDeadZone, joystickMoveY);
moveMap.bind(joystick, "xaxis", "D", $Pref::Input::JoystickDeadZone, joystickYaw);
moveMap.bind(joystick, "yaxis", "D", $Pref::Input::JoystickDeadZone, joystickPitch);
}
else
{
moveMap.bind(joystick, "xaxis", "D", $Pref::Input::JoystickDeadZone, joystickMoveX);
moveMap.bind(joystick, "yaxis", "D", $Pref::Input::JoystickDeadZone, joystickMoveY);
moveMap.bind(joystick, "rxaxis", "D", $Pref::Input::JoystickDeadZone, joystickYaw);
moveMap.bind(joystick, "ryaxis", "D", $Pref::Input::JoystickDeadZone, joystickPitch);
}

moveMap.bind(joystick, "zaxis", "D", $Pref::Input::JoystickDeadZone, joystickFire);

moveMap.bind(joystick, "button0", plantBrick);
moveMap.bind(joystick, "button1", openBSD);
moveMap.bind(joystick, "button2", useBricks);
moveMap.bind(joystick, "button3", useTools);
moveMap.bind(joystick, "button4", shiftBrickDown);
moveMap.bind(joystick, "button5", shiftBrickUp);
moveMap.bind(joystick, "button6", invLeft);
moveMap.bind(joystick, "button7", invRight);
moveMap.bind(joystick, "button8", RotateBrickCCW);
moveMap.bind(joystick, "button9", RotateBrickCW);

moveMap.bind(joystick, "lpov", shiftBrickLeft);
moveMap.bind(joystick, "rpov", shiftBrickRight);
moveMap.bind(joystick, "upov", shiftBrickAway);
moveMap.bind(joystick, "dpov", shiftBrickTowards);
--- End code ---


Uxie²:


--- Quote from: Nobot on July 12, 2012, 09:51:11 PM ---You can use an Xbox controller for Blockland? :o

Is it possible with a PS3 controller too?

--- End quote ---
Ive done it.

Gen. Hothauser:

Now, someone make one for the Nintendo 64 controller!

Why does Nintendo have to use their own special connections instead of standard USB stuff.

And here's an idea I will post in requests later, control Blockland with a Guitar Hero/Rock Band Guitar, just for the hell of it.

DontCare4Free:


--- Quote from: Gen. Hothauser on July 13, 2012, 12:26:23 AM ---Now, someone make one for the Nintendo 64 controller!

Why does Nintendo have to use their own special connections instead of standard USB stuff.

And here's an idea I will post in requests later, control Blockland with a Guitar Hero/Rock Band Guitar, just for the hell of it.

--- End quote ---
Nintendo uses standard Bluetooth stuff. Ninty64/GameCube are from the "let's invent propretariary plugs for everything" era; both Xbox (the original) and PS1/2 had propretariary plugs too.

Pages: << < (3/5) > >>

Go to full version