This repository has been archived by the owner on Jan 5, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 33
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Applying deadzone calculations to Xinput logic (Windows platform)
- Loading branch information
Jibran Ibrahim Syed
committed
Dec 21, 2016
1 parent
337a2b4
commit ec72b8b
Showing
4 changed files
with
203 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
107 changes: 107 additions & 0 deletions
107
XboxCtrlrInput/Assets/Plugins/XboxCtrlrInput_Helpers/XciAxisDeadzoneData.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,107 @@ | ||
using UnityEngine; | ||
|
||
namespace XboxCtrlrInput | ||
{ | ||
/// <summary> | ||
/// Contains deadzone data of every axis for every joystick number (see XboxController enum). | ||
/// Mostly for use with XInput (Windows API) | ||
/// </summary> | ||
public class XciAxisDeadzoneData | ||
{ | ||
private float[] leftStickX = new float[5]; | ||
private float[] leftStickY = new float[5]; | ||
private float[] rightStickX = new float[5]; | ||
private float[] rightStickY = new float[5]; | ||
private float[] leftTrigger = new float[5]; | ||
private float[] rightTrigger = new float[5]; | ||
|
||
|
||
public void Init(XciInputManagerClone inputManager) | ||
{ | ||
this.leftStickX[0] = inputManager.SearchInputByName("XboxAxisXJoy0").dead; | ||
this.leftStickX[1] = inputManager.SearchInputByName("XboxAxisXJoy1").dead; | ||
this.leftStickX[2] = inputManager.SearchInputByName("XboxAxisXJoy2").dead; | ||
this.leftStickX[3] = inputManager.SearchInputByName("XboxAxisXJoy3").dead; | ||
this.leftStickX[4] = inputManager.SearchInputByName("XboxAxisXJoy4").dead; | ||
|
||
this.leftStickY[0] = inputManager.SearchInputByName("XboxAxisYJoy0").dead; | ||
this.leftStickY[1] = inputManager.SearchInputByName("XboxAxisYJoy1").dead; | ||
this.leftStickY[2] = inputManager.SearchInputByName("XboxAxisYJoy2").dead; | ||
this.leftStickY[3] = inputManager.SearchInputByName("XboxAxisYJoy3").dead; | ||
this.leftStickY[4] = inputManager.SearchInputByName("XboxAxisYJoy4").dead; | ||
|
||
this.rightStickX[0] = inputManager.SearchInputByName("XboxAxis4Joy0").dead; | ||
this.rightStickX[1] = inputManager.SearchInputByName("XboxAxis4Joy1").dead; | ||
this.rightStickX[2] = inputManager.SearchInputByName("XboxAxis4Joy2").dead; | ||
this.rightStickX[3] = inputManager.SearchInputByName("XboxAxis4Joy3").dead; | ||
this.rightStickX[4] = inputManager.SearchInputByName("XboxAxis4Joy4").dead; | ||
|
||
this.rightStickY[0] = inputManager.SearchInputByName("XboxAxis5Joy0").dead; | ||
this.rightStickY[1] = inputManager.SearchInputByName("XboxAxis5Joy1").dead; | ||
this.rightStickY[2] = inputManager.SearchInputByName("XboxAxis5Joy2").dead; | ||
this.rightStickY[3] = inputManager.SearchInputByName("XboxAxis5Joy3").dead; | ||
this.rightStickY[4] = inputManager.SearchInputByName("XboxAxis5Joy4").dead; | ||
|
||
this.leftTrigger[0] = inputManager.SearchInputByName("XboxAxis3Joy0").dead; | ||
this.leftTrigger[1] = inputManager.SearchInputByName("XboxAxis3Joy1").dead; | ||
this.leftTrigger[2] = inputManager.SearchInputByName("XboxAxis3Joy2").dead; | ||
this.leftTrigger[3] = inputManager.SearchInputByName("XboxAxis3Joy3").dead; | ||
this.leftTrigger[4] = inputManager.SearchInputByName("XboxAxis3Joy4").dead; | ||
|
||
this.rightTrigger[0] = inputManager.SearchInputByName("XboxAxis3Joy0").dead; | ||
this.rightTrigger[1] = inputManager.SearchInputByName("XboxAxis3Joy1").dead; | ||
this.rightTrigger[2] = inputManager.SearchInputByName("XboxAxis3Joy2").dead; | ||
this.rightTrigger[3] = inputManager.SearchInputByName("XboxAxis3Joy3").dead; | ||
this.rightTrigger[4] = inputManager.SearchInputByName("XboxAxis3Joy4").dead; | ||
} | ||
|
||
|
||
public float[] LeftStickX | ||
{ | ||
get | ||
{ | ||
return this.leftStickX; | ||
} | ||
} | ||
|
||
public float[] LeftStickY | ||
{ | ||
get | ||
{ | ||
return this.leftStickY; | ||
} | ||
} | ||
|
||
public float[] RightStickX | ||
{ | ||
get | ||
{ | ||
return this.rightStickX; | ||
} | ||
} | ||
|
||
public float[] RightStickY | ||
{ | ||
get | ||
{ | ||
return this.rightStickY; | ||
} | ||
} | ||
|
||
public float[] LeftTrigger | ||
{ | ||
get | ||
{ | ||
return this.leftTrigger; | ||
} | ||
} | ||
|
||
public float[] RightTrigger | ||
{ | ||
get | ||
{ | ||
return this.rightTrigger; | ||
} | ||
} | ||
} | ||
} |
12 changes: 12 additions & 0 deletions
12
XboxCtrlrInput/Assets/Plugins/XboxCtrlrInput_Helpers/XciAxisDeadzoneData.cs.meta
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters