Improved XInput controls

This commit is contained in:
dexy
2019-12-11 18:46:36 +11:00
Unverified
parent 567218d5c7
commit 5672ea6dc3
6 changed files with 65 additions and 112 deletions
+13 -27
View File
@@ -867,7 +867,7 @@ namespace CodeWalker.Forms
float moveSpeed = 2.0f;
Input.Update(elapsed);
Input.Update();
if (Input.xbenable)
{
@@ -890,6 +890,17 @@ namespace CodeWalker.Forms
Vector3 movevec = Input.KeyboardMoveVec(false);
if (Input.xbenable)
{
movevec.X += Input.xblx;
movevec.Z -= Input.xbly;
moveSpeed *= (1.0f + (Math.Min(Math.Max(Input.xblt, 0.0f), 1.0f) * 15.0f)); //boost with left trigger
if (Input.ControllerButtonPressed(GamepadButtonFlags.A | GamepadButtonFlags.RightShoulder | GamepadButtonFlags.LeftShoulder))
{
moveSpeed *= 5.0f;
}
}
//if (MapViewEnabled == true)
//{
@@ -918,7 +929,7 @@ namespace CodeWalker.Forms
if (Input.xbenable)
{
camera.ControllerRotate(Input.xblx + Input.xbrx, Input.xbly + Input.xbry);
camera.ControllerRotate(Input.xbrx, Input.xbry, elapsed);
float zoom = 0.0f;
float zoomspd = s.XInputZoomSpeed;
@@ -928,31 +939,6 @@ namespace CodeWalker.Forms
camera.ControllerZoom(zoom);
float acc = 0.0f;
float accspd = s.XInputMoveSpeed;//actually accel speed...
acc += Input.xbrt * accspd;
acc -= Input.xblt * accspd;
Vector3 newdir = camera.ViewDirection; //maybe use the "vehicle" direction...?
Input.xbcontrolvelocity += (acc * elapsed);
if (Input.ControllerButtonPressed(GamepadButtonFlags.A | GamepadButtonFlags.RightShoulder)) //handbrake...
{
Input.xbcontrolvelocity *= Math.Max(0.75f - elapsed, 0);//not ideal for low fps...
//xbcontrolvelocity = 0.0f;
if (Math.Abs(Input.xbcontrolvelocity) < 0.001f) Input.xbcontrolvelocity = 0.0f;
}
camEntity.Velocity = newdir * Input.xbcontrolvelocity;
camEntity.Position += camEntity.Velocity * elapsed;
//fire!
//if (ControllerButtonJustPressed(GamepadButtonFlags.LeftShoulder))
//{
// SpawnTestEntity(true);
//}
}