show bindings in settings menu
This commit is contained in:
parent
cf31db9f87
commit
83306561fc
File diff suppressed because it is too large
Load diff
|
@ -2,14 +2,15 @@
|
||||||
%TAG !u! tag:unity3d.com,2011:
|
%TAG !u! tag:unity3d.com,2011:
|
||||||
--- !u!21 &2100000
|
--- !u!21 &2100000
|
||||||
Material:
|
Material:
|
||||||
serializedVersion: 6
|
serializedVersion: 8
|
||||||
m_ObjectHideFlags: 0
|
m_ObjectHideFlags: 0
|
||||||
m_CorrespondingSourceObject: {fileID: 0}
|
m_CorrespondingSourceObject: {fileID: 0}
|
||||||
m_PrefabInstance: {fileID: 0}
|
m_PrefabInstance: {fileID: 0}
|
||||||
m_PrefabAsset: {fileID: 0}
|
m_PrefabAsset: {fileID: 0}
|
||||||
m_Name: ButtonSDFMaterial
|
m_Name: ButtonSDFMaterial
|
||||||
m_Shader: {fileID: 4800000, guid: 574134bcfa99f7140a2cd7986bf57c25, type: 3}
|
m_Shader: {fileID: 4800000, guid: 574134bcfa99f7140a2cd7986bf57c25, type: 3}
|
||||||
m_ShaderKeywords:
|
m_ValidKeywords: []
|
||||||
|
m_InvalidKeywords: []
|
||||||
m_LightmapFlags: 4
|
m_LightmapFlags: 4
|
||||||
m_EnableInstancingVariants: 0
|
m_EnableInstancingVariants: 0
|
||||||
m_DoubleSidedGI: 0
|
m_DoubleSidedGI: 0
|
||||||
|
@ -67,6 +68,7 @@ Material:
|
||||||
m_Texture: {fileID: 0}
|
m_Texture: {fileID: 0}
|
||||||
m_Scale: {x: 1, y: 1}
|
m_Scale: {x: 1, y: 1}
|
||||||
m_Offset: {x: 0, y: 0}
|
m_Offset: {x: 0, y: 0}
|
||||||
|
m_Ints: []
|
||||||
m_Floats:
|
m_Floats:
|
||||||
- _Ambient: 0.5
|
- _Ambient: 0.5
|
||||||
- _Bevel: 0.5
|
- _Bevel: 0.5
|
||||||
|
@ -101,7 +103,7 @@ Material:
|
||||||
- _Mode: 0
|
- _Mode: 0
|
||||||
- _OcclusionStrength: 1
|
- _OcclusionStrength: 1
|
||||||
- _OffBright: 0.25
|
- _OffBright: 0.25
|
||||||
- _OutSmoothness: 0.075
|
- _OutSmoothness: 0.025
|
||||||
- _OutThickness: 0.6
|
- _OutThickness: 0.6
|
||||||
- _OutlineSoftness: 0
|
- _OutlineSoftness: 0
|
||||||
- _OutlineUVSpeedX: 0
|
- _OutlineUVSpeedX: 0
|
||||||
|
@ -118,7 +120,7 @@ Material:
|
||||||
- _ScaleY: 1
|
- _ScaleY: 1
|
||||||
- _ShaderFlags: 0
|
- _ShaderFlags: 0
|
||||||
- _Sharpness: 0
|
- _Sharpness: 0
|
||||||
- _Smoothness: 0.075
|
- _Smoothness: 0.025
|
||||||
- _SmoothnessTextureChannel: 0
|
- _SmoothnessTextureChannel: 0
|
||||||
- _SpecularHighlights: 1
|
- _SpecularHighlights: 1
|
||||||
- _SpecularPower: 2
|
- _SpecularPower: 2
|
||||||
|
|
|
@ -165,6 +165,97 @@ namespace HeavenStudio.InputSystem
|
||||||
-1
|
-1
|
||||||
};
|
};
|
||||||
|
|
||||||
|
static readonly string[] nsProButtonNames = new[]
|
||||||
|
{
|
||||||
|
"Up",
|
||||||
|
"Down",
|
||||||
|
"Left",
|
||||||
|
"Right",
|
||||||
|
"Plus",
|
||||||
|
"Minus",
|
||||||
|
"Left Stick Click",
|
||||||
|
"Right Stick Click",
|
||||||
|
"L",
|
||||||
|
"R",
|
||||||
|
"ZL",
|
||||||
|
"ZR",
|
||||||
|
"B",
|
||||||
|
"A",
|
||||||
|
"Y",
|
||||||
|
"X",
|
||||||
|
"Home",
|
||||||
|
"Capture",
|
||||||
|
};
|
||||||
|
|
||||||
|
static readonly string[] nsConButtonNames = new[]
|
||||||
|
{
|
||||||
|
"Up",
|
||||||
|
"Down",
|
||||||
|
"Left",
|
||||||
|
"Right",
|
||||||
|
"Plus",
|
||||||
|
"Minus",
|
||||||
|
"Left Stick Click",
|
||||||
|
"Right Stick Click",
|
||||||
|
"L",
|
||||||
|
"R",
|
||||||
|
"ZL",
|
||||||
|
"ZR",
|
||||||
|
"B",
|
||||||
|
"A",
|
||||||
|
"Y",
|
||||||
|
"X",
|
||||||
|
"Home",
|
||||||
|
"Capture",
|
||||||
|
"SL",
|
||||||
|
"SR",
|
||||||
|
};
|
||||||
|
|
||||||
|
static readonly string[] ps4ButtonNames = new[]
|
||||||
|
{
|
||||||
|
"Up",
|
||||||
|
"Down",
|
||||||
|
"Left",
|
||||||
|
"Right",
|
||||||
|
"Options",
|
||||||
|
"Share",
|
||||||
|
"L3",
|
||||||
|
"R3",
|
||||||
|
"L",
|
||||||
|
"R",
|
||||||
|
"L2",
|
||||||
|
"R2",
|
||||||
|
"X",
|
||||||
|
"Circle",
|
||||||
|
"Square",
|
||||||
|
"Triangle",
|
||||||
|
"PS",
|
||||||
|
"Touchpad Click",
|
||||||
|
};
|
||||||
|
|
||||||
|
static readonly string[] ps5ButtonNames = new[]
|
||||||
|
{
|
||||||
|
"Up",
|
||||||
|
"Down",
|
||||||
|
"Left",
|
||||||
|
"Right",
|
||||||
|
"Options",
|
||||||
|
"Share",
|
||||||
|
"L3",
|
||||||
|
"R3",
|
||||||
|
"L",
|
||||||
|
"R",
|
||||||
|
"L2",
|
||||||
|
"R2",
|
||||||
|
"X",
|
||||||
|
"Circle",
|
||||||
|
"Square",
|
||||||
|
"Triangle",
|
||||||
|
"PS",
|
||||||
|
"Create",
|
||||||
|
"Mic",
|
||||||
|
};
|
||||||
|
|
||||||
public static Dictionary<int, InputJoyshock> joyshocks;
|
public static Dictionary<int, InputJoyshock> joyshocks;
|
||||||
|
|
||||||
float stickDeadzone = 0.5f;
|
float stickDeadzone = 0.5f;
|
||||||
|
@ -215,7 +306,7 @@ namespace HeavenStudio.InputSystem
|
||||||
|
|
||||||
int GetButtonForSplitType(int action)
|
int GetButtonForSplitType(int action)
|
||||||
{
|
{
|
||||||
if (currentBindings.ControllerName == null) return -1;
|
if (currentBindings.Pad == null) return -1;
|
||||||
if (action < 0 || action >= BINDS_MAX) return -1;
|
if (action < 0 || action >= BINDS_MAX) return -1;
|
||||||
ControlBindings actionMap = currentBindings;
|
ControlBindings actionMap = currentBindings;
|
||||||
if (otherHalf == null)
|
if (otherHalf == null)
|
||||||
|
@ -367,6 +458,21 @@ namespace HeavenStudio.InputSystem
|
||||||
return joyshockName;
|
return joyshockName;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public override string[] GetButtonNames()
|
||||||
|
{
|
||||||
|
switch (type)
|
||||||
|
{
|
||||||
|
case TypeProController:
|
||||||
|
return nsProButtonNames;
|
||||||
|
case TypeDualShock4:
|
||||||
|
return ps4ButtonNames;
|
||||||
|
case TypeDualSense:
|
||||||
|
return ps5ButtonNames;
|
||||||
|
default:
|
||||||
|
return nsConButtonNames;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public override InputFeatures GetFeatures()
|
public override InputFeatures GetFeatures()
|
||||||
{
|
{
|
||||||
InputFeatures features = InputFeatures.Readable_MotionSensor | InputFeatures.Extra_Rumble | InputFeatures.Style_Pad | InputFeatures.Style_Baton;
|
InputFeatures features = InputFeatures.Readable_MotionSensor | InputFeatures.Extra_Rumble | InputFeatures.Style_Pad | InputFeatures.Style_Baton;
|
||||||
|
@ -408,23 +514,18 @@ namespace HeavenStudio.InputSystem
|
||||||
{
|
{
|
||||||
case TypeJoyConLeft:
|
case TypeJoyConLeft:
|
||||||
binds.Pad = defaultMappingsL;
|
binds.Pad = defaultMappingsL;
|
||||||
binds.ControllerName = "Joy-Con (L)";
|
|
||||||
break;
|
break;
|
||||||
case TypeJoyConRight:
|
case TypeJoyConRight:
|
||||||
binds.Pad = defaultMappingsR;
|
binds.Pad = defaultMappingsR;
|
||||||
binds.ControllerName = "Joy-Con (R)";
|
|
||||||
break;
|
break;
|
||||||
case TypeProController:
|
case TypeProController:
|
||||||
binds.Pad = defaultMappings;
|
binds.Pad = defaultMappings;
|
||||||
binds.ControllerName = "Pro Controller";
|
|
||||||
break;
|
break;
|
||||||
case TypeDualShock4:
|
case TypeDualShock4:
|
||||||
binds.Pad = defaultMappings;
|
binds.Pad = defaultMappings;
|
||||||
binds.ControllerName = "DualShock 4";
|
|
||||||
break;
|
break;
|
||||||
case TypeDualSense:
|
case TypeDualSense:
|
||||||
binds.Pad = defaultMappings;
|
binds.Pad = defaultMappings;
|
||||||
binds.ControllerName = "DualSense";
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
return binds;
|
return binds;
|
||||||
|
|
|
@ -42,7 +42,6 @@ namespace HeavenStudio.InputSystem
|
||||||
|
|
||||||
static readonly ControlBindings defaultBindings = new()
|
static readonly ControlBindings defaultBindings = new()
|
||||||
{
|
{
|
||||||
ControllerName = "Keyboard",
|
|
||||||
Pad = new int[]
|
Pad = new int[]
|
||||||
{
|
{
|
||||||
(int)KeyCode.W,
|
(int)KeyCode.W,
|
||||||
|
@ -77,6 +76,16 @@ namespace HeavenStudio.InputSystem
|
||||||
return "Keyboard";
|
return "Keyboard";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public override string[] GetButtonNames()
|
||||||
|
{
|
||||||
|
string[] names = new string[(int)KeyCode.Mouse0];
|
||||||
|
for (int i = 0; i < keyCodes.Length; i++)
|
||||||
|
{
|
||||||
|
names[(int)keyCodes[i]] = keyCodes[i].ToString();
|
||||||
|
}
|
||||||
|
return names;
|
||||||
|
}
|
||||||
|
|
||||||
public override InputFeatures GetFeatures()
|
public override InputFeatures GetFeatures()
|
||||||
{
|
{
|
||||||
return InputFeatures.Readable_StringInput | InputFeatures.Style_Pad | InputFeatures.Style_Baton;
|
return InputFeatures.Readable_StringInput | InputFeatures.Style_Pad | InputFeatures.Style_Baton;
|
||||||
|
|
|
@ -119,7 +119,6 @@ namespace HeavenStudio.InputSystem
|
||||||
[System.Serializable]
|
[System.Serializable]
|
||||||
public struct ControlBindings
|
public struct ControlBindings
|
||||||
{
|
{
|
||||||
public string ControllerName;
|
|
||||||
public int[] Pad;
|
public int[] Pad;
|
||||||
public int[] Baton;
|
public int[] Baton;
|
||||||
public int[] Touch;
|
public int[] Touch;
|
||||||
|
@ -137,6 +136,7 @@ namespace HeavenStudio.InputSystem
|
||||||
public abstract void UpdateState(); // Update the state of the controller
|
public abstract void UpdateState(); // Update the state of the controller
|
||||||
|
|
||||||
public abstract string GetDeviceName(); // Get the name of the controller
|
public abstract string GetDeviceName(); // Get the name of the controller
|
||||||
|
public abstract string[] GetButtonNames(); // Get the names of the buttons on the controller
|
||||||
public abstract InputFeatures GetFeatures(); // Get the features of the controller
|
public abstract InputFeatures GetFeatures(); // Get the features of the controller
|
||||||
public abstract bool GetIsConnected();
|
public abstract bool GetIsConnected();
|
||||||
public abstract bool GetIsPoorConnection();
|
public abstract bool GetIsPoorConnection();
|
||||||
|
|
|
@ -25,6 +25,14 @@ namespace HeavenStudio.Editor
|
||||||
|
|
||||||
[SerializeField] private Material controllerMat;
|
[SerializeField] private Material controllerMat;
|
||||||
|
|
||||||
|
[SerializeField] private List<GameObject> PadBindingsMenus;
|
||||||
|
[SerializeField] private List<GameObject> BatonBindingsMenus;
|
||||||
|
[SerializeField] private List<GameObject> TouchBindingsMenus;
|
||||||
|
|
||||||
|
[SerializeField] private List<TMP_Text> PadBindingsTxt;
|
||||||
|
[SerializeField] private List<TMP_Text> BatonBindingsTxt;
|
||||||
|
[SerializeField] private List<TMP_Text> TouchBindingsTxt;
|
||||||
|
|
||||||
private bool isAutoSearching = false;
|
private bool isAutoSearching = false;
|
||||||
private bool isPairSearching = false;
|
private bool isPairSearching = false;
|
||||||
private bool pairSelectLR = false; //true = left, false = right
|
private bool pairSelectLR = false; //true = left, false = right
|
||||||
|
@ -171,6 +179,31 @@ namespace HeavenStudio.Editor
|
||||||
public void ShowControllerIcon(InputController controller)
|
public void ShowControllerIcon(InputController controller)
|
||||||
{
|
{
|
||||||
string name = controller.GetDeviceName();
|
string name = controller.GetDeviceName();
|
||||||
|
string[] buttons = controller.GetButtonNames();
|
||||||
|
|
||||||
|
//show binds
|
||||||
|
int ac = 0;
|
||||||
|
foreach (int i in controller.GetCurrentBindings().Pad)
|
||||||
|
{
|
||||||
|
if (ac >= PadBindingsTxt.Count) break;
|
||||||
|
if (buttons[i] == null)
|
||||||
|
{
|
||||||
|
PadBindingsTxt[ac].text = "UNKNOWN";
|
||||||
|
ac++;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if (i != -1)
|
||||||
|
{
|
||||||
|
PadBindingsTxt[ac].text = buttons[i];
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
PadBindingsTxt[ac].text = "NOT BOUND";
|
||||||
|
}
|
||||||
|
ac++;
|
||||||
|
}
|
||||||
|
|
||||||
|
//show icon
|
||||||
foreach (var icon in controllerIcons)
|
foreach (var icon in controllerIcons)
|
||||||
{
|
{
|
||||||
if (icon.name == name)
|
if (icon.name == name)
|
||||||
|
@ -182,6 +215,7 @@ namespace HeavenStudio.Editor
|
||||||
icon.SetActive(false);
|
icon.SetActive(false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//setup material
|
//setup material
|
||||||
Color colour;
|
Color colour;
|
||||||
switch (name)
|
switch (name)
|
||||||
|
|
Loading…
Reference in a new issue