SDL_Joystick and SDL_GameController

Expanding and utilizing the engine via C++.
  • 1
  • 2
14 posts Page 2 of 2
Steve_Yorkshire
Posts: 294
Joined: Tue Feb 03, 2015 10:30 pm
 
by Steve_Yorkshire » Fri Jul 20, 2018 6:18 pm
Just had a quick play with SDL_Joystick branch (minus testing branch). UK keyboard, X-Box Controller.

Xbox Gamepad:
Y axis on both thumbsticks are reversed (forwards=back, up=down). X axis works fine. Buttons work fine.

Keyboard:
Console is under Esc (which is not tilde on UK keyboard) but that is where everyone wants it. All other keys work as expected.
Steve_Yorkshire
Posts: 294
Joined: Tue Feb 03, 2015 10:30 pm
 
by Steve_Yorkshire » Fri Jul 20, 2018 9:10 pm
Had a play with the input monitor and moving the both left/right thumbsticks up/forward do give negative values (eg: -0.99999) whilst down/back is positive (eg: 1.0) so I reckon this need reversing :mrgreen:
Steve_Yorkshire
Posts: 294
Joined: Tue Feb 03, 2015 10:30 pm
 
by Steve_Yorkshire » Sat Jul 21, 2018 12:30 am
Swapping the +/- around in default.bind.cs does the trick
function gamePadMoveY( %val )
{
   if(%val > 0)
   {
      $mvForwardAction = -%val * $movementSpeed;//swapped to negative for sdl
      $mvBackwardAction = 0;
   }
   else
   {
      $mvForwardAction = 0;
      $mvBackwardAction = %val * $movementSpeed;//swapped to positive for sdl
   }
}

//...

function gamepadPitch(%val)
{
   %pitchAdj = getGamepadAdjustAmount(%val);
   if(ServerConnection.isControlObjectRotDampedCamera())
   {
      // Clamp and scale
      %pitchAdj = mClamp(%pitchAdj, -m2Pi()+0.01, m2Pi()-0.01);
      %pitchAdj *= 0.5;
   }

	if(%pitchAdj > 0)
   {
      $mvPitchDownSpeed = -%pitchAdj;//swapped to negative for sdl
      $mvPitchUpSpeed = 0;
   }
   else
   {
      $mvPitchDownSpeed = 0;
      $mvPitchUpSpeed = %pitchAdj;//swap to positive for sdl
   }
}
And then all is right with the world once more 8-)
Steve_Yorkshire
Posts: 294
Joined: Tue Feb 03, 2015 10:30 pm
 
by Steve_Yorkshire » Sat Jul 21, 2018 1:28 am
And a prettier way of doing it ...
function gamePadMoveY( %val )
{
   if(%val > 0)
   {
      $mvForwardAction = 0;
      $mvBackwardAction = %val * $movementSpeed;
   }
   else
   {
      $mvForwardAction = -%val * $movementSpeed;
      $mvBackwardAction = 0;
   }
}

//...

function gamepadPitch(%val)
{
   %pitchAdj = getGamepadAdjustAmount(%val);
   if(ServerConnection.isControlObjectRotDampedCamera())
   {
      // Clamp and scale
      %pitchAdj = mClamp(%pitchAdj, -m2Pi()+0.01, m2Pi()-0.01);
      %pitchAdj *= 0.5;
   }

	if(%pitchAdj > 0)
   {
      $mvPitchDownSpeed = 0;
      $mvPitchUpSpeed = %pitchAdj;//swap to positive for sdl
   }
   else
   {
      $mvPitchDownSpeed = -%pitchAdj;//swapped to negative for sdl
      $mvPitchUpSpeed = 0;
   }
}
  • 1
  • 2
14 posts Page 2 of 2

Who is online

Users browsing this forum: No registered users and 5 guests