initial prep for rebinding controls
rename some bindings properly expose newer JSL stuff
This commit is contained in:
parent
7572106856
commit
800b934db8
|
@ -76,50 +76,50 @@ public static class JSL
|
||||||
|
|
||||||
[StructLayout(LayoutKind.Sequential)]
|
[StructLayout(LayoutKind.Sequential)]
|
||||||
public struct MOTION_STATE {
|
public struct MOTION_STATE {
|
||||||
float quatW;
|
public float quatW;
|
||||||
float quatX;
|
public float quatX;
|
||||||
float quatY;
|
public float quatY;
|
||||||
float quatZ;
|
public float quatZ;
|
||||||
float accelX;
|
public float accelX;
|
||||||
float accelY;
|
public float accelY;
|
||||||
float accelZ;
|
public float accelZ;
|
||||||
float gravX;
|
public float gravX;
|
||||||
float gravY;
|
public float gravY;
|
||||||
float gravZ;
|
public float gravZ;
|
||||||
}
|
}
|
||||||
|
|
||||||
[StructLayout(LayoutKind.Sequential)]
|
[StructLayout(LayoutKind.Sequential)]
|
||||||
public struct TOUCH_STATE {
|
public struct TOUCH_STATE {
|
||||||
int t0Id;
|
public int t0Id;
|
||||||
int t1Id;
|
public int t1Id;
|
||||||
bool t0Down;
|
public bool t0Down;
|
||||||
bool t1Down;
|
public bool t1Down;
|
||||||
float t0X;
|
public float t0X;
|
||||||
float t0Y;
|
public float t0Y;
|
||||||
float t1X;
|
public float t1X;
|
||||||
float t1Y;
|
public float t1Y;
|
||||||
}
|
}
|
||||||
|
|
||||||
[StructLayout(LayoutKind.Sequential)]
|
[StructLayout(LayoutKind.Sequential)]
|
||||||
public struct JSL_AUTO_CALIBRATION {
|
public struct JSL_AUTO_CALIBRATION {
|
||||||
float confidence;
|
public float confidence;
|
||||||
bool autoCalibrationEnabled;
|
public bool autoCalibrationEnabled;
|
||||||
bool isSteady;
|
public bool isSteady;
|
||||||
}
|
}
|
||||||
|
|
||||||
[StructLayout(LayoutKind.Sequential)]
|
[StructLayout(LayoutKind.Sequential)]
|
||||||
public struct JSL_SETTINGS {
|
public struct JSL_SETTINGS {
|
||||||
int gyroSpace;
|
public int gyroSpace;
|
||||||
int bodyColour;
|
public int bodyColour;
|
||||||
int lGripColour;
|
public int lGripColour;
|
||||||
int rGripColour;
|
public int rGripColour;
|
||||||
int buttonColour;
|
public int buttonColour;
|
||||||
int playerNumber;
|
public int playerNumber;
|
||||||
int controllerType;
|
public int controllerType;
|
||||||
int splitType;
|
public int splitType;
|
||||||
bool isCalibrating;
|
public bool isCalibrating;
|
||||||
bool autoCalibrationEnabled;
|
public bool autoCalibrationEnabled;
|
||||||
bool isConnected;
|
public bool isConnected;
|
||||||
}
|
}
|
||||||
|
|
||||||
public delegate void EventCallback(int handle, JOY_SHOCK_STATE state, JOY_SHOCK_STATE lastState,
|
public delegate void EventCallback(int handle, JOY_SHOCK_STATE state, JOY_SHOCK_STATE lastState,
|
||||||
|
|
|
@ -120,7 +120,7 @@ namespace HeavenStudio.InputSystem
|
||||||
};
|
};
|
||||||
|
|
||||||
//TODO: see if single joy-con mappings differ from a normal pad (they don't!)
|
//TODO: see if single joy-con mappings differ from a normal pad (they don't!)
|
||||||
int[] mappings = new[]
|
int[] defaultMappings = new[]
|
||||||
{
|
{
|
||||||
ButtonMaskUp,
|
ButtonMaskUp,
|
||||||
ButtonMaskDown,
|
ButtonMaskDown,
|
||||||
|
@ -133,8 +133,9 @@ namespace HeavenStudio.InputSystem
|
||||||
ButtonMaskL,
|
ButtonMaskL,
|
||||||
ButtonMaskR,
|
ButtonMaskR,
|
||||||
ButtonMaskPlus,
|
ButtonMaskPlus,
|
||||||
|
-1
|
||||||
};
|
};
|
||||||
int[] mappingsSplitLeft = new[]
|
int[] defaultMappingsL = new[]
|
||||||
{
|
{
|
||||||
-1,
|
-1,
|
||||||
-1,
|
-1,
|
||||||
|
@ -147,8 +148,9 @@ namespace HeavenStudio.InputSystem
|
||||||
ButtonMaskSL,
|
ButtonMaskSL,
|
||||||
ButtonMaskSR,
|
ButtonMaskSR,
|
||||||
ButtonMaskMinus,
|
ButtonMaskMinus,
|
||||||
|
-1
|
||||||
};
|
};
|
||||||
int[] mappingsSplitRight = new[]
|
int[] defaultMappingsR = new[]
|
||||||
{
|
{
|
||||||
-1,
|
-1,
|
||||||
-1,
|
-1,
|
||||||
|
@ -161,6 +163,7 @@ namespace HeavenStudio.InputSystem
|
||||||
ButtonMaskSL,
|
ButtonMaskSL,
|
||||||
ButtonMaskSR,
|
ButtonMaskSR,
|
||||||
ButtonMaskPlus,
|
ButtonMaskPlus,
|
||||||
|
-1
|
||||||
};
|
};
|
||||||
|
|
||||||
public static Dictionary<int, InputJoyshock> joyshocks;
|
public static Dictionary<int, InputJoyshock> joyshocks;
|
||||||
|
@ -172,16 +175,19 @@ namespace HeavenStudio.InputSystem
|
||||||
int splitType;
|
int splitType;
|
||||||
int lightbarColour;
|
int lightbarColour;
|
||||||
string joyshockName;
|
string joyshockName;
|
||||||
double totalReportDt;
|
DateTime startTime;
|
||||||
|
|
||||||
//buttons, sticks, triggers
|
//buttons, sticks, triggers
|
||||||
JoyshockButtonState[] buttonStates = new JoyshockButtonState[11];
|
JoyshockButtonState[] buttonStates = new JoyshockButtonState[BINDS_MAX];
|
||||||
JOY_SHOCK_STATE joyBtStateCurrent;
|
JOY_SHOCK_STATE joyBtStateCurrent;
|
||||||
//gyro and accelerometer
|
//gyro and accelerometer
|
||||||
IMU_STATE joyImuStateCurrent, joyImuStateLast;
|
IMU_STATE joyImuStateCurrent, joyImuStateLast;
|
||||||
//touchpad
|
//touchpad
|
||||||
TOUCH_STATE joyTouchStateCurrent, joyTouchStateLast;
|
TOUCH_STATE joyTouchStateCurrent, joyTouchStateLast;
|
||||||
|
|
||||||
|
// controller settings
|
||||||
|
JSL_SETTINGS joySettings;
|
||||||
|
|
||||||
InputJoyshock otherHalf;
|
InputJoyshock otherHalf;
|
||||||
|
|
||||||
public struct JoyshockButtonState
|
public struct JoyshockButtonState
|
||||||
|
@ -207,6 +213,24 @@ namespace HeavenStudio.InputSystem
|
||||||
joyshockHandle = handle;
|
joyshockHandle = handle;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int GetButtonForSplitType(int action)
|
||||||
|
{
|
||||||
|
if (action < 0 || action >= BINDS_MAX) return -1;
|
||||||
|
if (otherHalf == null)
|
||||||
|
{
|
||||||
|
switch (splitType)
|
||||||
|
{
|
||||||
|
case SplitLeft:
|
||||||
|
return defaultMappingsL[action];
|
||||||
|
case SplitRight:
|
||||||
|
return defaultMappingsR[action];
|
||||||
|
default:
|
||||||
|
return defaultMappings[action];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return defaultMappings[action];
|
||||||
|
}
|
||||||
|
|
||||||
public static void JslEventInit()
|
public static void JslEventInit()
|
||||||
{
|
{
|
||||||
JslSetCallback(JslEventCallback);
|
JslSetCallback(JslEventCallback);
|
||||||
|
@ -224,22 +248,21 @@ namespace HeavenStudio.InputSystem
|
||||||
{
|
{
|
||||||
js.inputStack.Clear();
|
js.inputStack.Clear();
|
||||||
js.wantClearInputStack = false;
|
js.wantClearInputStack = false;
|
||||||
js.totalReportDt -= js.reportTime;
|
|
||||||
}
|
}
|
||||||
js.totalReportDt += deltaTime;
|
|
||||||
js.inputStack.Add(new TimestampedState
|
js.inputStack.Add(new TimestampedState
|
||||||
{
|
{
|
||||||
timestamp = js.totalReportDt,
|
timestamp = (DateTime.Now - js.startTime).TotalSeconds,
|
||||||
input = state
|
input = state
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void InitializeController()
|
public override void InitializeController()
|
||||||
{
|
{
|
||||||
|
startTime = DateTime.Now;
|
||||||
inputStack = new();
|
inputStack = new();
|
||||||
lastInputStack = new();
|
lastInputStack = new();
|
||||||
|
|
||||||
buttonStates = new JoyshockButtonState[11];
|
buttonStates = new JoyshockButtonState[BINDS_MAX];
|
||||||
joyBtStateCurrent = new JOY_SHOCK_STATE();
|
joyBtStateCurrent = new JOY_SHOCK_STATE();
|
||||||
|
|
||||||
joyImuStateCurrent = new IMU_STATE();
|
joyImuStateCurrent = new IMU_STATE();
|
||||||
|
@ -248,12 +271,14 @@ namespace HeavenStudio.InputSystem
|
||||||
joyTouchStateCurrent = new TOUCH_STATE();
|
joyTouchStateCurrent = new TOUCH_STATE();
|
||||||
joyTouchStateLast = new TOUCH_STATE();
|
joyTouchStateLast = new TOUCH_STATE();
|
||||||
|
|
||||||
|
|
||||||
//FUTURE: remappable controls
|
//FUTURE: remappable controls
|
||||||
|
|
||||||
type = JslGetControllerType(joyshockHandle);
|
joySettings = JslGetControllerInfoAndSettings(joyshockHandle);
|
||||||
|
type = joySettings.controllerType;
|
||||||
joyshockName = joyShockNames[type];
|
joyshockName = joyShockNames[type];
|
||||||
|
|
||||||
splitType = JslGetControllerSplitType(joyshockHandle);
|
splitType = joySettings.splitType;
|
||||||
|
|
||||||
joyshocks.Add(joyshockHandle, this);
|
joyshocks.Add(joyshockHandle, this);
|
||||||
}
|
}
|
||||||
|
@ -266,9 +291,9 @@ namespace HeavenStudio.InputSystem
|
||||||
|
|
||||||
public override void UpdateState()
|
public override void UpdateState()
|
||||||
{
|
{
|
||||||
|
reportTime = (DateTime.Now - startTime).TotalSeconds;
|
||||||
lastInputStack = new(inputStack);
|
lastInputStack = new(inputStack);
|
||||||
wantClearInputStack = true;
|
wantClearInputStack = true;
|
||||||
reportTime = totalReportDt;
|
|
||||||
|
|
||||||
for (int i = 0; i < buttonStates.Length; i++)
|
for (int i = 0; i < buttonStates.Length; i++)
|
||||||
{
|
{
|
||||||
|
@ -280,22 +305,7 @@ namespace HeavenStudio.InputSystem
|
||||||
|
|
||||||
for (int i = 0; i < buttonStates.Length; i++)
|
for (int i = 0; i < buttonStates.Length; i++)
|
||||||
{
|
{
|
||||||
int bt = mappings[i];
|
int bt = GetButtonForSplitType(i);
|
||||||
if (otherHalf == null)
|
|
||||||
{
|
|
||||||
switch (splitType)
|
|
||||||
{
|
|
||||||
case SplitLeft:
|
|
||||||
bt = mappingsSplitLeft[i];
|
|
||||||
break;
|
|
||||||
case SplitRight:
|
|
||||||
bt = mappingsSplitRight[i];
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (bt != -1)
|
if (bt != -1)
|
||||||
{
|
{
|
||||||
bool pressed = BitwiseUtils.WantCurrent(state.input.buttons, 1 << bt);
|
bool pressed = BitwiseUtils.WantCurrent(state.input.buttons, 1 << bt);
|
||||||
|
@ -409,17 +419,20 @@ namespace HeavenStudio.InputSystem
|
||||||
|
|
||||||
public override bool GetButton(int button)
|
public override bool GetButton(int button)
|
||||||
{
|
{
|
||||||
|
if (button == -1) {return false;}
|
||||||
return buttonStates[button].pressed;
|
return buttonStates[button].pressed;
|
||||||
}
|
}
|
||||||
|
|
||||||
public override bool GetButtonDown(int button, out double dt)
|
public override bool GetButtonDown(int button, out double dt)
|
||||||
{
|
{
|
||||||
|
if (button == -1) {dt = 0; return false;}
|
||||||
dt = buttonStates[button].dt;
|
dt = buttonStates[button].dt;
|
||||||
return buttonStates[button].pressed && buttonStates[button].isDelta;
|
return buttonStates[button].pressed && buttonStates[button].isDelta;
|
||||||
}
|
}
|
||||||
|
|
||||||
public override bool GetButtonUp(int button, out double dt)
|
public override bool GetButtonUp(int button, out double dt)
|
||||||
{
|
{
|
||||||
|
if (button == -1) {dt = 0; return false;}
|
||||||
dt = buttonStates[button].dt;
|
dt = buttonStates[button].dt;
|
||||||
return !buttonStates[button].pressed && buttonStates[button].isDelta;
|
return !buttonStates[button].pressed && buttonStates[button].isDelta;
|
||||||
}
|
}
|
||||||
|
@ -455,16 +468,16 @@ namespace HeavenStudio.InputSystem
|
||||||
switch (direction)
|
switch (direction)
|
||||||
{
|
{
|
||||||
case InputDirection.Up:
|
case InputDirection.Up:
|
||||||
bt = mappings[0];
|
bt = GetButtonForSplitType(0);
|
||||||
break;
|
break;
|
||||||
case InputDirection.Down:
|
case InputDirection.Down:
|
||||||
bt = mappings[1];
|
bt = GetButtonForSplitType(1);
|
||||||
break;
|
break;
|
||||||
case InputDirection.Left:
|
case InputDirection.Left:
|
||||||
bt = mappings[2];
|
bt = GetButtonForSplitType(2);
|
||||||
break;
|
break;
|
||||||
case InputDirection.Right:
|
case InputDirection.Right:
|
||||||
bt = mappings[3];
|
bt = GetButtonForSplitType(3);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
return false;
|
return false;
|
||||||
|
@ -478,16 +491,16 @@ namespace HeavenStudio.InputSystem
|
||||||
switch (direction)
|
switch (direction)
|
||||||
{
|
{
|
||||||
case InputDirection.Up:
|
case InputDirection.Up:
|
||||||
bt = mappings[0];
|
bt = GetButtonForSplitType(0);
|
||||||
break;
|
break;
|
||||||
case InputDirection.Down:
|
case InputDirection.Down:
|
||||||
bt = mappings[1];
|
bt = GetButtonForSplitType(1);
|
||||||
break;
|
break;
|
||||||
case InputDirection.Left:
|
case InputDirection.Left:
|
||||||
bt = mappings[2];
|
bt = GetButtonForSplitType(2);
|
||||||
break;
|
break;
|
||||||
case InputDirection.Right:
|
case InputDirection.Right:
|
||||||
bt = mappings[3];
|
bt = GetButtonForSplitType(3);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
dt = 0;
|
dt = 0;
|
||||||
|
@ -504,16 +517,16 @@ namespace HeavenStudio.InputSystem
|
||||||
switch (direction)
|
switch (direction)
|
||||||
{
|
{
|
||||||
case InputDirection.Up:
|
case InputDirection.Up:
|
||||||
bt = mappings[0];
|
bt = GetButtonForSplitType(0);
|
||||||
break;
|
break;
|
||||||
case InputDirection.Down:
|
case InputDirection.Down:
|
||||||
bt = mappings[1];
|
bt = GetButtonForSplitType(1);
|
||||||
break;
|
break;
|
||||||
case InputDirection.Left:
|
case InputDirection.Left:
|
||||||
bt = mappings[2];
|
bt = GetButtonForSplitType(2);
|
||||||
break;
|
break;
|
||||||
case InputDirection.Right:
|
case InputDirection.Right:
|
||||||
bt = mappings[3];
|
bt = GetButtonForSplitType(3);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
dt = 0;
|
dt = 0;
|
||||||
|
@ -558,32 +571,32 @@ namespace HeavenStudio.InputSystem
|
||||||
if (otherHalf != null)
|
if (otherHalf != null)
|
||||||
{
|
{
|
||||||
// gets the colour of the right controller if is split
|
// gets the colour of the right controller if is split
|
||||||
return BitwiseUtils.IntToRgb(splitType == SplitRight ? JslGetControllerColour(joyshockHandle) : JslGetControllerColour(GetOtherHalf().GetHandle()));
|
return BitwiseUtils.IntToRgb(splitType == SplitRight ? joySettings.bodyColour : GetOtherHalf().joySettings.bodyColour);
|
||||||
}
|
}
|
||||||
return BitwiseUtils.IntToRgb(JslGetControllerColour(joyshockHandle));
|
return BitwiseUtils.IntToRgb(joySettings.bodyColour);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Color GetButtonColor()
|
public Color GetButtonColor()
|
||||||
{
|
{
|
||||||
return BitwiseUtils.IntToRgb(JslGetControllerButtonColour(joyshockHandle));
|
return BitwiseUtils.IntToRgb(joySettings.buttonColour);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Color GetLeftGripColor()
|
public Color GetLeftGripColor()
|
||||||
{
|
{
|
||||||
if (otherHalf != null)
|
if (otherHalf != null)
|
||||||
{
|
{
|
||||||
return BitwiseUtils.IntToRgb(splitType == SplitLeft ? JslGetControllerColour(joyshockHandle) : JslGetControllerColour(GetOtherHalf().GetHandle()));
|
return BitwiseUtils.IntToRgb(splitType == SplitLeft ? joySettings.lGripColour : GetOtherHalf().joySettings.lGripColour);
|
||||||
}
|
}
|
||||||
return BitwiseUtils.IntToRgb(JslGetControllerLeftGripColour(joyshockHandle));
|
return BitwiseUtils.IntToRgb(joySettings.lGripColour);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Color GetRightGripColor()
|
public Color GetRightGripColor()
|
||||||
{
|
{
|
||||||
if (otherHalf != null)
|
if (otherHalf != null)
|
||||||
{
|
{
|
||||||
return BitwiseUtils.IntToRgb(splitType == SplitRight ? JslGetControllerColour(joyshockHandle) : JslGetControllerColour(GetOtherHalf().GetHandle()));
|
return BitwiseUtils.IntToRgb(splitType == SplitRight ? joySettings.rGripColour : GetOtherHalf().joySettings.rGripColour);
|
||||||
}
|
}
|
||||||
return BitwiseUtils.IntToRgb(JslGetControllerRightGripColour(joyshockHandle));
|
return BitwiseUtils.IntToRgb(joySettings.rGripColour);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Color GetLightbarColour()
|
public Color GetLightbarColour()
|
||||||
|
|
|
@ -42,7 +42,7 @@ namespace HeavenStudio.InputSystem
|
||||||
|
|
||||||
//FUTURE: remappable controls
|
//FUTURE: remappable controls
|
||||||
//KeyCode[] mappings = new KeyCode[Enum.GetNames(typeof(ButtonsPad)).Length];
|
//KeyCode[] mappings = new KeyCode[Enum.GetNames(typeof(ButtonsPad)).Length];
|
||||||
KeyCode[] mappings = new KeyCode[]
|
KeyCode[] defaultMappings = new KeyCode[]
|
||||||
{
|
{
|
||||||
KeyCode.W, // dpad up
|
KeyCode.W, // dpad up
|
||||||
KeyCode.S, // dpad down
|
KeyCode.S, // dpad down
|
||||||
|
@ -110,19 +110,19 @@ namespace HeavenStudio.InputSystem
|
||||||
|
|
||||||
public override bool GetButton(int button)
|
public override bool GetButton(int button)
|
||||||
{
|
{
|
||||||
return Input.GetKey(mappings[button]);
|
return Input.GetKey(defaultMappings[button]);
|
||||||
}
|
}
|
||||||
|
|
||||||
public override bool GetButtonDown(int button, out double dt)
|
public override bool GetButtonDown(int button, out double dt)
|
||||||
{
|
{
|
||||||
dt = 0;
|
dt = 0;
|
||||||
return Input.GetKeyDown(mappings[button]);
|
return Input.GetKeyDown(defaultMappings[button]);
|
||||||
}
|
}
|
||||||
|
|
||||||
public override bool GetButtonUp(int button, out double dt)
|
public override bool GetButtonUp(int button, out double dt)
|
||||||
{
|
{
|
||||||
dt = 0;
|
dt = 0;
|
||||||
return Input.GetKeyUp(mappings[button]);
|
return Input.GetKeyUp(defaultMappings[button]);
|
||||||
}
|
}
|
||||||
|
|
||||||
public override float GetAxis(InputAxis axis)
|
public override float GetAxis(InputAxis axis)
|
||||||
|
@ -136,13 +136,13 @@ namespace HeavenStudio.InputSystem
|
||||||
switch (direction)
|
switch (direction)
|
||||||
{
|
{
|
||||||
case InputDirection.Up:
|
case InputDirection.Up:
|
||||||
return Input.GetKey(mappings[0]);
|
return Input.GetKey(defaultMappings[0]);
|
||||||
case InputDirection.Down:
|
case InputDirection.Down:
|
||||||
return Input.GetKey(mappings[1]);
|
return Input.GetKey(defaultMappings[1]);
|
||||||
case InputDirection.Left:
|
case InputDirection.Left:
|
||||||
return Input.GetKey(mappings[2]);
|
return Input.GetKey(defaultMappings[2]);
|
||||||
case InputDirection.Right:
|
case InputDirection.Right:
|
||||||
return Input.GetKey(mappings[3]);
|
return Input.GetKey(defaultMappings[3]);
|
||||||
default:
|
default:
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -154,13 +154,13 @@ namespace HeavenStudio.InputSystem
|
||||||
switch (direction)
|
switch (direction)
|
||||||
{
|
{
|
||||||
case InputDirection.Up:
|
case InputDirection.Up:
|
||||||
return Input.GetKeyDown(mappings[0]);
|
return Input.GetKeyDown(defaultMappings[0]);
|
||||||
case InputDirection.Down:
|
case InputDirection.Down:
|
||||||
return Input.GetKeyDown(mappings[1]);
|
return Input.GetKeyDown(defaultMappings[1]);
|
||||||
case InputDirection.Left:
|
case InputDirection.Left:
|
||||||
return Input.GetKeyDown(mappings[2]);
|
return Input.GetKeyDown(defaultMappings[2]);
|
||||||
case InputDirection.Right:
|
case InputDirection.Right:
|
||||||
return Input.GetKeyDown(mappings[3]);
|
return Input.GetKeyDown(defaultMappings[3]);
|
||||||
default:
|
default:
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -172,13 +172,13 @@ namespace HeavenStudio.InputSystem
|
||||||
switch (direction)
|
switch (direction)
|
||||||
{
|
{
|
||||||
case InputDirection.Up:
|
case InputDirection.Up:
|
||||||
return Input.GetKeyUp(mappings[0]);
|
return Input.GetKeyUp(defaultMappings[0]);
|
||||||
case InputDirection.Down:
|
case InputDirection.Down:
|
||||||
return Input.GetKeyUp(mappings[1]);
|
return Input.GetKeyUp(defaultMappings[1]);
|
||||||
case InputDirection.Left:
|
case InputDirection.Left:
|
||||||
return Input.GetKeyUp(mappings[2]);
|
return Input.GetKeyUp(defaultMappings[2]);
|
||||||
case InputDirection.Right:
|
case InputDirection.Right:
|
||||||
return Input.GetKeyUp(mappings[3]);
|
return Input.GetKeyUp(defaultMappings[3]);
|
||||||
default:
|
default:
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,34 +10,6 @@ namespace HeavenStudio.InputSystem
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public abstract class InputController
|
public abstract class InputController
|
||||||
{
|
{
|
||||||
//Buttons and Axis used by most controllers
|
|
||||||
public enum InputButtons : int
|
|
||||||
{
|
|
||||||
ButtonPadUp = 0,
|
|
||||||
ButtonPadDown = 1,
|
|
||||||
ButtonPadLeft = 2,
|
|
||||||
ButtonPadRight = 3,
|
|
||||||
ButtonPlus = 4,
|
|
||||||
ButtonOptions = 4,
|
|
||||||
ButtonMinus = 5,
|
|
||||||
ButtonShare = 5,
|
|
||||||
ButtonLClick = 6,
|
|
||||||
ButtonRClick = 7,
|
|
||||||
ButtonL = 8,
|
|
||||||
ButtonR = 9,
|
|
||||||
ButtonZL = 10,
|
|
||||||
ButtonZR = 11,
|
|
||||||
ButtonFaceS = 12,
|
|
||||||
ButtonFaceE = 13,
|
|
||||||
ButtonFaceW = 14,
|
|
||||||
ButtonFaceN = 15,
|
|
||||||
ButtonHome = 16,
|
|
||||||
ButtonPS = 16,
|
|
||||||
ButtonCapture = 17,
|
|
||||||
ButtonTouchpadClick = 17,
|
|
||||||
ButtonSL = 18,
|
|
||||||
ButtonSR = 19,
|
|
||||||
}
|
|
||||||
public enum InputAxis : int
|
public enum InputAxis : int
|
||||||
{
|
{
|
||||||
AxisLTrigger = 4,
|
AxisLTrigger = 4,
|
||||||
|
@ -101,45 +73,56 @@ namespace HeavenStudio.InputSystem
|
||||||
Move
|
Move
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public const int BINDS_MAX = 12; //maximum number of binds per controller
|
||||||
|
|
||||||
//buttons used in Heaven Studio gameplay (Pad Style)
|
//buttons used in Heaven Studio gameplay (Pad Style)
|
||||||
public enum ButtonsPad : int
|
public enum ButtonsPad : int
|
||||||
{
|
{
|
||||||
PadUp = 0,
|
Up = 0,
|
||||||
PadDown = 1,
|
Down = 1,
|
||||||
PadLeft = 2,
|
Left = 2,
|
||||||
PadRight = 3,
|
Right = 3,
|
||||||
PadS = 4,
|
South = 4,
|
||||||
PadE = 5,
|
East = 5,
|
||||||
PadW = 6,
|
West = 6,
|
||||||
PadN = 7,
|
North = 7,
|
||||||
PadL = 8,
|
L = 8,
|
||||||
PadR = 9,
|
R = 9,
|
||||||
PadPause = 10,
|
Pause = 10,
|
||||||
}
|
}
|
||||||
|
|
||||||
//FUTURE: buttons used in Heaven Studio gameplay ("Form Baton" / WiiMote Style)
|
//FUTURE: buttons used in Heaven Studio gameplay ("Form Baton" / WiiMote Style)
|
||||||
public enum ButtonsBaton : int
|
public enum ButtonsBaton : int
|
||||||
{
|
{
|
||||||
BatonS = 0, //-- all these...
|
South = 0, //-- all these...
|
||||||
BatonE = 1, // |
|
East = 1, // |
|
||||||
BatonW = 2, // |
|
West = 2, // |
|
||||||
BatonN = 3, //--
|
North = 3, //--
|
||||||
BatonFace = 4, // < ...map to this, but are directional
|
Face = 4, // < ...are also equivalent to this, but with added directionality
|
||||||
BatonTrigger = 5, // should never be used alone
|
Trigger = 5, // should never be used alone, but still bindable separately (controller logic should handle confirming & timestamping face + trigger input)
|
||||||
Baton1 = 6,
|
Up = 6, // Wiimote 1
|
||||||
Baton2 = 7,
|
Down = 7, // Wiimote 2
|
||||||
BatonPause = 8,
|
Pause = 8,
|
||||||
}
|
}
|
||||||
|
|
||||||
//FUTURE: buttons used in Heaven Studio gameplay (Touch Style)
|
//FUTURE: buttons used in Heaven Studio gameplay (Touch Style)
|
||||||
public enum ButtonsTouch : int
|
public enum ButtonsTouch : int
|
||||||
{
|
{
|
||||||
TouchL = 0,
|
Tap = 0, // flicks are handled like a motion, don't have a binding
|
||||||
TouchR = 1,
|
Left = 1, // also maps to tap, but with directionality (tap the left side of the panel)
|
||||||
TouchTap = 2,
|
Right = 2, // also maps to tap, but with directionality (tap the right side of the panel)
|
||||||
TouchFlick = 3,
|
ButtonL = 3,
|
||||||
TouchButtonL = 4,
|
ButtonR = 4,
|
||||||
TouchButtonR = 5,
|
Pause = 5,
|
||||||
|
}
|
||||||
|
|
||||||
|
[System.Serializable]
|
||||||
|
public struct ControlBindings
|
||||||
|
{
|
||||||
|
public string ControllerName;
|
||||||
|
public int[] Pad;
|
||||||
|
public int[] Baton;
|
||||||
|
public int[] Touch;
|
||||||
}
|
}
|
||||||
|
|
||||||
// FUTURE: Move Style needs to be implemented per-game (maybe implement checks for common actions?)
|
// FUTURE: Move Style needs to be implemented per-game (maybe implement checks for common actions?)
|
||||||
|
@ -159,6 +142,10 @@ namespace HeavenStudio.InputSystem
|
||||||
public abstract bool GetIsConnected();
|
public abstract bool GetIsConnected();
|
||||||
public abstract bool GetIsPoorConnection();
|
public abstract bool GetIsPoorConnection();
|
||||||
|
|
||||||
|
// public abstract int[] GetDefaultMappings(ControlStyles style);
|
||||||
|
// public abstract int[] GetCurrentMappings(ControlStyles style);
|
||||||
|
// public abstract int[] SetCurrentMappings(ControlStyles style);
|
||||||
|
|
||||||
public abstract int GetLastButtonDown(); // Get the last button down
|
public abstract int GetLastButtonDown(); // Get the last button down
|
||||||
public abstract KeyCode GetLastKeyDown(); // Get the last key down (used for keyboards and other devices that use Keycode)
|
public abstract KeyCode GetLastKeyDown(); // Get the last key down (used for keyboards and other devices that use Keycode)
|
||||||
public abstract bool GetButton(int button); // is button currently pressed?
|
public abstract bool GetButton(int button); // is button currently pressed?
|
||||||
|
|
|
@ -30,6 +30,7 @@ namespace HeavenStudio
|
||||||
public const int LEFT = 3;
|
public const int LEFT = 3;
|
||||||
|
|
||||||
static List<InputController> inputDevices;
|
static List<InputController> inputDevices;
|
||||||
|
static InputController.ControlStyles currentControlStyle = InputController.ControlStyles.Pad;
|
||||||
|
|
||||||
public delegate InputController[] InputControllerInitializer();
|
public delegate InputController[] InputControllerInitializer();
|
||||||
|
|
||||||
|
@ -191,62 +192,62 @@ namespace HeavenStudio
|
||||||
|
|
||||||
public static bool Pressed(bool includeDPad = false)
|
public static bool Pressed(bool includeDPad = false)
|
||||||
{
|
{
|
||||||
bool keyDown = GetInputController(1).GetButtonDown((int) InputController.ButtonsPad.PadE, out _) || (includeDPad && GetAnyDirectionDown());
|
bool keyDown = GetInputController(1).GetButtonDown((int) InputController.ButtonsPad.East, out _) || (includeDPad && GetAnyDirectionDown());
|
||||||
return keyDown && !GameManager.instance.autoplay && Conductor.instance.isPlaying && GameManager.instance.canInput;
|
return keyDown && !GameManager.instance.autoplay && Conductor.instance.isPlaying && GameManager.instance.canInput;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static bool Pressed(out double dt, bool includeDPad = false)
|
public static bool Pressed(out double dt, bool includeDPad = false)
|
||||||
{
|
{
|
||||||
bool keyDown = GetInputController(1).GetButtonDown((int) InputController.ButtonsPad.PadE, out dt) || (includeDPad && GetAnyDirectionDown());
|
bool keyDown = GetInputController(1).GetButtonDown((int) InputController.ButtonsPad.East, out dt) || (includeDPad && GetAnyDirectionDown());
|
||||||
return keyDown && !GameManager.instance.autoplay && Conductor.instance.isPlaying && GameManager.instance.canInput;
|
return keyDown && !GameManager.instance.autoplay && Conductor.instance.isPlaying && GameManager.instance.canInput;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static bool PressedUp(bool includeDPad = false)
|
public static bool PressedUp(bool includeDPad = false)
|
||||||
{
|
{
|
||||||
bool keyUp = GetInputController(1).GetButtonUp((int) InputController.ButtonsPad.PadE, out _) || (includeDPad && GetAnyDirectionUp());
|
bool keyUp = GetInputController(1).GetButtonUp((int) InputController.ButtonsPad.East, out _) || (includeDPad && GetAnyDirectionUp());
|
||||||
return keyUp && !GameManager.instance.autoplay && Conductor.instance.isPlaying && GameManager.instance.canInput;
|
return keyUp && !GameManager.instance.autoplay && Conductor.instance.isPlaying && GameManager.instance.canInput;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static bool PressedUp(out double dt, bool includeDPad = false)
|
public static bool PressedUp(out double dt, bool includeDPad = false)
|
||||||
{
|
{
|
||||||
bool keyUp = GetInputController(1).GetButtonUp((int) InputController.ButtonsPad.PadE, out dt) || (includeDPad && GetAnyDirectionUp());
|
bool keyUp = GetInputController(1).GetButtonUp((int) InputController.ButtonsPad.East, out dt) || (includeDPad && GetAnyDirectionUp());
|
||||||
return keyUp && !GameManager.instance.autoplay && Conductor.instance.isPlaying && GameManager.instance.canInput;
|
return keyUp && !GameManager.instance.autoplay && Conductor.instance.isPlaying && GameManager.instance.canInput;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static bool Pressing(bool includeDPad = false)
|
public static bool Pressing(bool includeDPad = false)
|
||||||
{
|
{
|
||||||
bool pressing = GetInputController(1).GetButton((int) InputController.ButtonsPad.PadE) || (includeDPad && GetAnyDirection());
|
bool pressing = GetInputController(1).GetButton((int) InputController.ButtonsPad.East) || (includeDPad && GetAnyDirection());
|
||||||
return pressing && !GameManager.instance.autoplay && Conductor.instance.isPlaying && GameManager.instance.canInput;
|
return pressing && !GameManager.instance.autoplay && Conductor.instance.isPlaying && GameManager.instance.canInput;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public static bool AltPressed()
|
public static bool AltPressed()
|
||||||
{
|
{
|
||||||
bool down = GetInputController(1).GetButtonDown((int) InputController.ButtonsPad.PadS, out _);
|
bool down = GetInputController(1).GetButtonDown((int) InputController.ButtonsPad.South, out _);
|
||||||
return down && PlayerHasControl();
|
return down && PlayerHasControl();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static bool AltPressed(out double dt)
|
public static bool AltPressed(out double dt)
|
||||||
{
|
{
|
||||||
bool down = GetInputController(1).GetButtonDown((int) InputController.ButtonsPad.PadS, out dt);
|
bool down = GetInputController(1).GetButtonDown((int) InputController.ButtonsPad.South, out dt);
|
||||||
return down && PlayerHasControl();
|
return down && PlayerHasControl();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static bool AltPressedUp()
|
public static bool AltPressedUp()
|
||||||
{
|
{
|
||||||
bool up = GetInputController(1).GetButtonUp((int) InputController.ButtonsPad.PadS, out _);
|
bool up = GetInputController(1).GetButtonUp((int) InputController.ButtonsPad.South, out _);
|
||||||
return up && PlayerHasControl();
|
return up && PlayerHasControl();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static bool AltPressedUp(out double dt)
|
public static bool AltPressedUp(out double dt)
|
||||||
{
|
{
|
||||||
bool up = GetInputController(1).GetButtonUp((int) InputController.ButtonsPad.PadS, out dt);
|
bool up = GetInputController(1).GetButtonUp((int) InputController.ButtonsPad.South, out dt);
|
||||||
return up && PlayerHasControl();
|
return up && PlayerHasControl();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static bool AltPressing()
|
public static bool AltPressing()
|
||||||
{
|
{
|
||||||
bool pressing = GetInputController(1).GetButton((int) InputController.ButtonsPad.PadS);
|
bool pressing = GetInputController(1).GetButton((int) InputController.ButtonsPad.South);
|
||||||
return pressing && PlayerHasControl();
|
return pressing && PlayerHasControl();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -85,7 +85,7 @@ namespace HeavenStudio.Common
|
||||||
void Update()
|
void Update()
|
||||||
{
|
{
|
||||||
if (isQuitting) return;
|
if (isQuitting) return;
|
||||||
if (PlayerInput.GetInputController(1).GetButtonDown((int) InputController.ButtonsPad.PadPause, out _))
|
if (PlayerInput.GetInputController(1).GetButtonDown((int) InputController.ButtonsPad.Pause, out _))
|
||||||
{
|
{
|
||||||
if (isPaused)
|
if (isPaused)
|
||||||
{
|
{
|
||||||
|
@ -98,7 +98,7 @@ namespace HeavenStudio.Common
|
||||||
}
|
}
|
||||||
else if (isPaused && canPick && !settingsDialog.IsOpen)
|
else if (isPaused && canPick && !settingsDialog.IsOpen)
|
||||||
{
|
{
|
||||||
if (Input.GetKeyDown(KeyCode.UpArrow) || PlayerInput.GetInputController(1).GetButtonDown((int)InputController.ButtonsPad.PadUp, out _))
|
if (Input.GetKeyDown(KeyCode.UpArrow) || PlayerInput.GetInputController(1).GetButtonDown((int)InputController.ButtonsPad.Up, out _))
|
||||||
{
|
{
|
||||||
optionSelected--;
|
optionSelected--;
|
||||||
if (optionSelected < 0)
|
if (optionSelected < 0)
|
||||||
|
@ -107,7 +107,7 @@ namespace HeavenStudio.Common
|
||||||
}
|
}
|
||||||
ChooseOption((Options) optionSelected);
|
ChooseOption((Options) optionSelected);
|
||||||
}
|
}
|
||||||
else if (Input.GetKeyDown(KeyCode.DownArrow) || PlayerInput.GetInputController(1).GetButtonDown((int)InputController.ButtonsPad.PadDown, out _))
|
else if (Input.GetKeyDown(KeyCode.DownArrow) || PlayerInput.GetInputController(1).GetButtonDown((int)InputController.ButtonsPad.Down, out _))
|
||||||
{
|
{
|
||||||
optionSelected++;
|
optionSelected++;
|
||||||
if (optionSelected > optionHolder.transform.childCount - 1)
|
if (optionSelected > optionHolder.transform.childCount - 1)
|
||||||
|
@ -116,7 +116,7 @@ namespace HeavenStudio.Common
|
||||||
}
|
}
|
||||||
ChooseOption((Options) optionSelected);
|
ChooseOption((Options) optionSelected);
|
||||||
}
|
}
|
||||||
else if (Input.GetKeyDown(KeyCode.Return) || PlayerInput.GetInputController(1).GetButtonDown((int)InputController.ButtonsPad.PadE, out _))
|
else if (Input.GetKeyDown(KeyCode.Return) || PlayerInput.GetInputController(1).GetButtonDown((int)InputController.ButtonsPad.East, out _))
|
||||||
{
|
{
|
||||||
UseOption((Options) optionSelected);
|
UseOption((Options) optionSelected);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue