update JSL (DualSense Edge support)
add ability to update controller bindings
This commit is contained in:
parent
664d55e7a9
commit
b294c64852
|
|
@ -29,8 +29,11 @@ public static class JSL
|
||||||
public const int ButtonMaskPS = 16;
|
public const int ButtonMaskPS = 16;
|
||||||
public const int ButtonMaskCapture = 17;
|
public const int ButtonMaskCapture = 17;
|
||||||
public const int ButtonMaskTouchpadClick = 17;
|
public const int ButtonMaskTouchpadClick = 17;
|
||||||
public const int ButtonMaskSL = 18;
|
public const int ButtonMaskMic = 18;
|
||||||
public const int ButtonMaskSR = 19;
|
public const int ButtonMaskSL = 19;
|
||||||
|
public const int ButtonMaskSR = 20;
|
||||||
|
public const int ButtonMaskFnL = 19;
|
||||||
|
public const int ButtonMaskFnR = 20;
|
||||||
|
|
||||||
public const int TypeJoyConLeft = 1;
|
public const int TypeJoyConLeft = 1;
|
||||||
public const int TypeJoyConRight = 2;
|
public const int TypeJoyConRight = 2;
|
||||||
|
|
|
||||||
Binary file not shown.
|
|
@ -17,31 +17,33 @@
|
||||||
#define JS_SPLIT_TYPE_RIGHT 2
|
#define JS_SPLIT_TYPE_RIGHT 2
|
||||||
#define JS_SPLIT_TYPE_FULL 3
|
#define JS_SPLIT_TYPE_FULL 3
|
||||||
|
|
||||||
#define JSMASK_UP 0x00001
|
#define JSMASK_UP 0x000001
|
||||||
#define JSMASK_DOWN 0x00002
|
#define JSMASK_DOWN 0x000002
|
||||||
#define JSMASK_LEFT 0x00004
|
#define JSMASK_LEFT 0x000004
|
||||||
#define JSMASK_RIGHT 0x00008
|
#define JSMASK_RIGHT 0x000008
|
||||||
#define JSMASK_PLUS 0x00010
|
#define JSMASK_PLUS 0x000010
|
||||||
#define JSMASK_OPTIONS 0x00010
|
#define JSMASK_OPTIONS 0x000010
|
||||||
#define JSMASK_MINUS 0x00020
|
#define JSMASK_MINUS 0x000020
|
||||||
#define JSMASK_SHARE 0x00020
|
#define JSMASK_SHARE 0x000020
|
||||||
#define JSMASK_LCLICK 0x00040
|
#define JSMASK_LCLICK 0x000040
|
||||||
#define JSMASK_RCLICK 0x00080
|
#define JSMASK_RCLICK 0x000080
|
||||||
#define JSMASK_L 0x00100
|
#define JSMASK_L 0x000100
|
||||||
#define JSMASK_R 0x00200
|
#define JSMASK_R 0x000200
|
||||||
#define JSMASK_ZL 0x00400
|
#define JSMASK_ZL 0x000400
|
||||||
#define JSMASK_ZR 0x00800
|
#define JSMASK_ZR 0x000800
|
||||||
#define JSMASK_S 0x01000
|
#define JSMASK_S 0x001000
|
||||||
#define JSMASK_E 0x02000
|
#define JSMASK_E 0x002000
|
||||||
#define JSMASK_W 0x04000
|
#define JSMASK_W 0x004000
|
||||||
#define JSMASK_N 0x08000
|
#define JSMASK_N 0x008000
|
||||||
#define JSMASK_HOME 0x10000
|
#define JSMASK_HOME 0x010000
|
||||||
#define JSMASK_PS 0x10000
|
#define JSMASK_PS 0x010000
|
||||||
#define JSMASK_CAPTURE 0x20000
|
#define JSMASK_CAPTURE 0x020000
|
||||||
#define JSMASK_TOUCHPAD_CLICK 0x20000
|
#define JSMASK_TOUCHPAD_CLICK 0x020000
|
||||||
#define JSMASK_MIC 0x40000
|
#define JSMASK_MIC 0x040000
|
||||||
#define JSMASK_SL 0x40000
|
#define JSMASK_SL 0x080000
|
||||||
#define JSMASK_SR 0x80000
|
#define JSMASK_SR 0x100000
|
||||||
|
#define JSMASK_FNL 0x200000
|
||||||
|
#define JSMASK_FNR 0x400000
|
||||||
|
|
||||||
#define JSOFFSET_UP 0
|
#define JSOFFSET_UP 0
|
||||||
#define JSOFFSET_DOWN 1
|
#define JSOFFSET_DOWN 1
|
||||||
|
|
@ -66,8 +68,10 @@
|
||||||
#define JSOFFSET_CAPTURE 17
|
#define JSOFFSET_CAPTURE 17
|
||||||
#define JSOFFSET_TOUCHPAD_CLICK 17
|
#define JSOFFSET_TOUCHPAD_CLICK 17
|
||||||
#define JSOFFSET_MIC 18
|
#define JSOFFSET_MIC 18
|
||||||
#define JSOFFSET_SL 18
|
#define JSOFFSET_SL 19
|
||||||
#define JSOFFSET_SR 19
|
#define JSOFFSET_SR 20
|
||||||
|
#define JSOFFSET_FNL 21
|
||||||
|
#define JSOFFSET_FNR 22
|
||||||
|
|
||||||
// PS5 Player maps for the DS Player Lightbar
|
// PS5 Player maps for the DS Player Lightbar
|
||||||
#define DS5_PLAYER_1 4
|
#define DS5_PLAYER_1 4
|
||||||
|
|
|
||||||
Binary file not shown.
Binary file not shown.
|
|
@ -107,7 +107,7 @@ namespace HeavenStudio.InputSystem
|
||||||
"Joy-Con (R)",
|
"Joy-Con (R)",
|
||||||
"Pro Controller",
|
"Pro Controller",
|
||||||
"DualShock 4",
|
"DualShock 4",
|
||||||
"DualSense"
|
"DualSense/Edge" // jsl doesn't expose a new device ID for DSE
|
||||||
};
|
};
|
||||||
|
|
||||||
static readonly int[] dsPlayerColours = new[]
|
static readonly int[] dsPlayerColours = new[]
|
||||||
|
|
@ -228,6 +228,7 @@ namespace HeavenStudio.InputSystem
|
||||||
"X",
|
"X",
|
||||||
"Home",
|
"Home",
|
||||||
"Capture",
|
"Capture",
|
||||||
|
"", // mic on playstation, unused here
|
||||||
"SL",
|
"SL",
|
||||||
"SR",
|
"SR",
|
||||||
"Stick Up",
|
"Stick Up",
|
||||||
|
|
@ -256,6 +257,7 @@ namespace HeavenStudio.InputSystem
|
||||||
"Triangle",
|
"Triangle",
|
||||||
"PS",
|
"PS",
|
||||||
"Touchpad Click",
|
"Touchpad Click",
|
||||||
|
"Mic",
|
||||||
};
|
};
|
||||||
|
|
||||||
static readonly string[] ps5ButtonNames = new[]
|
static readonly string[] ps5ButtonNames = new[]
|
||||||
|
|
@ -279,6 +281,10 @@ namespace HeavenStudio.InputSystem
|
||||||
"PS",
|
"PS",
|
||||||
"Create",
|
"Create",
|
||||||
"Mic",
|
"Mic",
|
||||||
|
"Left Grip",
|
||||||
|
"Right Grip",
|
||||||
|
"Left Function",
|
||||||
|
"Right Function",
|
||||||
};
|
};
|
||||||
|
|
||||||
static readonly float debounceTime = 1f / 90f;
|
static readonly float debounceTime = 1f / 90f;
|
||||||
|
|
@ -599,6 +605,7 @@ namespace HeavenStudio.InputSystem
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
binds.PointerSensitivity = 3;
|
binds.PointerSensitivity = 3;
|
||||||
|
binds.version = 1;
|
||||||
return binds;
|
return binds;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -617,20 +624,45 @@ namespace HeavenStudio.InputSystem
|
||||||
currentBindings = newBinds;
|
currentBindings = newBinds;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public override ControlBindings UpdateBindings(ControlBindings lastBinds)
|
||||||
|
{
|
||||||
|
if (lastBinds.version == 0)
|
||||||
|
{
|
||||||
|
switch (type)
|
||||||
|
{
|
||||||
|
case TypeProController:
|
||||||
|
case TypeDualShock4:
|
||||||
|
case TypeDualSense:
|
||||||
|
return lastBinds;
|
||||||
|
case TypeJoyConLeft:
|
||||||
|
case TypeJoyConRight:
|
||||||
|
for (int i = 0; i < lastBinds.Pad.Length; i++)
|
||||||
|
{
|
||||||
|
if (lastBinds.Pad[i] is 18 or 19)
|
||||||
|
lastBinds.Pad[i] = lastBinds.Pad[i] + 1;
|
||||||
|
}
|
||||||
|
return lastBinds;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return lastBinds;
|
||||||
|
}
|
||||||
|
|
||||||
|
public override int GetBindingsVersion()
|
||||||
|
{
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
public override bool GetIsActionUnbindable(int action, ControlStyles style)
|
public override bool GetIsActionUnbindable(int action, ControlStyles style)
|
||||||
{
|
{
|
||||||
if (otherHalf == null)
|
if (otherHalf == null)
|
||||||
{
|
{
|
||||||
switch (splitType)
|
if (splitType is SplitLeft or SplitRight)
|
||||||
{
|
{
|
||||||
case SplitLeft:
|
switch (style)
|
||||||
case SplitRight:
|
{
|
||||||
switch (style)
|
case ControlStyles.Pad:
|
||||||
{
|
return action is 0 or 1 or 2 or 3;
|
||||||
case ControlStyles.Pad:
|
}
|
||||||
return action is 0 or 1 or 2 or 3;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
|
|
@ -721,7 +753,7 @@ namespace HeavenStudio.InputSystem
|
||||||
case InputAxis.AxisRStickY:
|
case InputAxis.AxisRStickY:
|
||||||
return joyBtStateCurrent.stickRY;
|
return joyBtStateCurrent.stickRY;
|
||||||
case InputAxis.PointerX: //isn't updated for now, so always returns 0f
|
case InputAxis.PointerX: //isn't updated for now, so always returns 0f
|
||||||
//return joyTouchStateCurrent.t0X;
|
//return joyTouchStateCurrent.t0X;
|
||||||
case InputAxis.PointerY:
|
case InputAxis.PointerY:
|
||||||
//return joyTouchStateCurrent.t0Y;
|
//return joyTouchStateCurrent.t0Y;
|
||||||
default:
|
default:
|
||||||
|
|
|
||||||
|
|
@ -131,6 +131,16 @@ namespace HeavenStudio.InputSystem
|
||||||
currentBindings = newBinds;
|
currentBindings = newBinds;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public override ControlBindings UpdateBindings(ControlBindings lastBinds)
|
||||||
|
{
|
||||||
|
return lastBinds;
|
||||||
|
}
|
||||||
|
|
||||||
|
public override int GetBindingsVersion()
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
public override bool GetIsActionUnbindable(int action, ControlStyles style)
|
public override bool GetIsActionUnbindable(int action, ControlStyles style)
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
|
|
|
||||||
|
|
@ -259,6 +259,16 @@ namespace HeavenStudio.InputSystem
|
||||||
currentBindings = newBinds;
|
currentBindings = newBinds;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public override ControlBindings UpdateBindings(ControlBindings lastBinds)
|
||||||
|
{
|
||||||
|
return lastBinds;
|
||||||
|
}
|
||||||
|
|
||||||
|
public override int GetBindingsVersion()
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
public override bool GetIsActionUnbindable(int action, ControlStyles style)
|
public override bool GetIsActionUnbindable(int action, ControlStyles style)
|
||||||
{
|
{
|
||||||
return action is 0;
|
return action is 0;
|
||||||
|
|
|
||||||
|
|
@ -141,6 +141,7 @@ namespace HeavenStudio.InputSystem
|
||||||
[System.Serializable]
|
[System.Serializable]
|
||||||
public struct ControlBindings
|
public struct ControlBindings
|
||||||
{
|
{
|
||||||
|
public int version;
|
||||||
public int[] Pad;
|
public int[] Pad;
|
||||||
public int[] Baton;
|
public int[] Baton;
|
||||||
public int[] Touch;
|
public int[] Touch;
|
||||||
|
|
@ -184,7 +185,19 @@ namespace HeavenStudio.InputSystem
|
||||||
string json = File.ReadAllText(path);
|
string json = File.ReadAllText(path);
|
||||||
if (json is not null or "")
|
if (json is not null or "")
|
||||||
{
|
{
|
||||||
currentBindings = JsonUtility.FromJson<ControlBindings>(json);
|
try
|
||||||
|
{
|
||||||
|
currentBindings = JsonUtility.FromJson<ControlBindings>(json);
|
||||||
|
if (currentBindings.version != GetBindingsVersion())
|
||||||
|
{
|
||||||
|
currentBindings = UpdateBindings(currentBindings);
|
||||||
|
SaveBindings();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (System.Exception)
|
||||||
|
{
|
||||||
|
ResetBindings();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|
@ -220,6 +233,19 @@ namespace HeavenStudio.InputSystem
|
||||||
/// <param name="newBinds"></param>
|
/// <param name="newBinds"></param>
|
||||||
public abstract void SetCurrentBindings(ControlBindings newBinds);
|
public abstract void SetCurrentBindings(ControlBindings newBinds);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// updates controller bindings to new versions
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="lastBinds">bindings of a previous version</param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public abstract ControlBindings UpdateBindings(ControlBindings lastBinds);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// gets the current bindings version for this controller
|
||||||
|
/// </summary>
|
||||||
|
/// <returns></returns>
|
||||||
|
public abstract int GetBindingsVersion();
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Whether a given action can have be rebount
|
/// Whether a given action can have be rebount
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|
|
||||||
|
|
@ -32,27 +32,44 @@ namespace HeavenStudio.Editor
|
||||||
if (File.Exists(Application.persistentDataPath + "/editorTheme.json"))
|
if (File.Exists(Application.persistentDataPath + "/editorTheme.json"))
|
||||||
{
|
{
|
||||||
string json = File.ReadAllText(Application.persistentDataPath + "/editorTheme.json");
|
string json = File.ReadAllText(Application.persistentDataPath + "/editorTheme.json");
|
||||||
theme = JsonConvert.DeserializeObject<Theme>(json);
|
if (json == "")
|
||||||
|
|
||||||
// Naive way of doing it? Possibly, but we should have a theme editor in the future.
|
|
||||||
if (defaultTheme.properties.LayerColors != null)
|
|
||||||
{
|
{
|
||||||
theme.properties.LayerColors = new string[]
|
PersistentDataManager.SaveTheme(ThemeTXT.text);
|
||||||
|
theme = defaultTheme;
|
||||||
|
theme.SetLayersGradient();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
try
|
||||||
|
{
|
||||||
|
theme = JsonConvert.DeserializeObject<Theme>(json);
|
||||||
|
|
||||||
|
// Naive way of doing it? Possibly, but we should have a theme editor in the future.
|
||||||
|
if (defaultTheme.properties.LayerColors != null)
|
||||||
{
|
{
|
||||||
theme.properties.Layer1Col,
|
theme.properties.LayerColors = new string[]
|
||||||
theme.properties.Layer2Col,
|
{
|
||||||
theme.properties.Layer3Col,
|
theme.properties.Layer1Col,
|
||||||
theme.properties.Layer4Col,
|
theme.properties.Layer2Col,
|
||||||
theme.properties.Layer5Col
|
theme.properties.Layer3Col,
|
||||||
};
|
theme.properties.Layer4Col,
|
||||||
// Create a function for this in the future.
|
theme.properties.Layer5Col
|
||||||
var savedTheme = JsonConvert.SerializeObject(theme, Formatting.Indented, new JsonSerializerSettings()
|
};
|
||||||
{
|
// Create a function for this in the future.
|
||||||
TypeNameHandling = TypeNameHandling.None,
|
var savedTheme = JsonConvert.SerializeObject(theme, Formatting.Indented, new JsonSerializerSettings()
|
||||||
NullValueHandling = NullValueHandling.Include,
|
{
|
||||||
ReferenceLoopHandling = ReferenceLoopHandling.Ignore,
|
TypeNameHandling = TypeNameHandling.None,
|
||||||
});
|
NullValueHandling = NullValueHandling.Include,
|
||||||
PersistentDataManager.SaveTheme(savedTheme);
|
ReferenceLoopHandling = ReferenceLoopHandling.Ignore,
|
||||||
|
});
|
||||||
|
PersistentDataManager.SaveTheme(savedTheme);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch
|
||||||
|
{
|
||||||
|
PersistentDataManager.SaveTheme(ThemeTXT.text);
|
||||||
|
theme = defaultTheme;
|
||||||
|
theme.SetLayersGradient();
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
|
|
||||||
|
|
@ -67,7 +67,22 @@ namespace HeavenStudio.Common
|
||||||
if (File.Exists(Application.persistentDataPath + "/settings.json"))
|
if (File.Exists(Application.persistentDataPath + "/settings.json"))
|
||||||
{
|
{
|
||||||
string json = File.ReadAllText(Application.persistentDataPath + "/settings.json");
|
string json = File.ReadAllText(Application.persistentDataPath + "/settings.json");
|
||||||
gameSettings = JsonUtility.FromJson<GameSettings>(json);
|
if (json == "")
|
||||||
|
{
|
||||||
|
GlobalGameManager.IsFirstBoot = true;
|
||||||
|
CreateDefaultSettings();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
try
|
||||||
|
{
|
||||||
|
gameSettings = JsonConvert.DeserializeObject<GameSettings>(json);
|
||||||
|
}
|
||||||
|
catch (Exception e)
|
||||||
|
{
|
||||||
|
Debug.LogError($"Error while loading settings, creating default settings;\n{e.Message}");
|
||||||
|
GlobalGameManager.IsFirstBoot = true;
|
||||||
|
CreateDefaultSettings();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue