JSL polling via event

This commit is contained in:
minenice55 2023-07-06 21:35:51 -04:00
parent 0f3a9f2b07
commit 7cd64de6ae
7 changed files with 392 additions and 117 deletions

View file

@ -137,7 +137,7 @@ public static class JSL
[DllImport("JoyShockLibrary")] [DllImport("JoyShockLibrary")]
public static extern void JslDisconnectAndDisposeAll(); public static extern void JslDisconnectAndDisposeAll();
[DllImport("JoyShockLibrary")] [DllImport("JoyShockLibrary")]
public static extern void JslStillConnected(int deviceId); public static extern bool JslStillConnected(int deviceId);
[DllImport("JoyShockLibrary", CallingConvention = CallingConvention.Cdecl)] [DllImport("JoyShockLibrary", CallingConvention = CallingConvention.Cdecl)]
public static extern JOY_SHOCK_STATE JslGetSimpleState(int deviceId); public static extern JOY_SHOCK_STATE JslGetSimpleState(int deviceId);

View file

@ -29,6 +29,7 @@ RectTransform:
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0} m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1} m_LocalScale: {x: 1, y: 1, z: 1}
m_ConstrainProportionsScale: 0
m_Children: m_Children:
- {fileID: 3918594454531700437} - {fileID: 3918594454531700437}
m_Father: {fileID: 3918594454557351925} m_Father: {fileID: 3918594454557351925}
@ -162,6 +163,7 @@ RectTransform:
m_LocalRotation: {x: -0, y: -0, z: -0, w: 1} m_LocalRotation: {x: -0, y: -0, z: -0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0} m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1} m_LocalScale: {x: 1, y: 1, z: 1}
m_ConstrainProportionsScale: 0
m_Children: m_Children:
- {fileID: 3918594454598345480} - {fileID: 3918594454598345480}
m_Father: {fileID: 3918594455428278210} m_Father: {fileID: 3918594455428278210}
@ -250,6 +252,7 @@ RectTransform:
m_LocalRotation: {x: -0, y: -0, z: -0, w: 1} m_LocalRotation: {x: -0, y: -0, z: -0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0} m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 0.9998709, y: 0.9998709, z: 0.9998709} m_LocalScale: {x: 0.9998709, y: 0.9998709, z: 0.9998709}
m_ConstrainProportionsScale: 0
m_Children: m_Children:
- {fileID: 3918594454521024533} - {fileID: 3918594454521024533}
- {fileID: 3918594455780710548} - {fileID: 3918594455780710548}
@ -316,6 +319,7 @@ RectTransform:
m_LocalRotation: {x: -0, y: -0, z: -0, w: 1} m_LocalRotation: {x: -0, y: -0, z: -0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0} m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 1.0000798, y: 1.0000798, z: 1.0000798} m_LocalScale: {x: 1.0000798, y: 1.0000798, z: 1.0000798}
m_ConstrainProportionsScale: 0
m_Children: [] m_Children: []
m_Father: {fileID: 3918594455809915007} m_Father: {fileID: 3918594455809915007}
m_RootOrder: 3 m_RootOrder: 3
@ -450,6 +454,7 @@ RectTransform:
m_LocalRotation: {x: -0, y: -0, z: -0, w: 1} m_LocalRotation: {x: -0, y: -0, z: -0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0} m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 1.0000798, y: 1.0000798, z: 1.0000798} m_LocalScale: {x: 1.0000798, y: 1.0000798, z: 1.0000798}
m_ConstrainProportionsScale: 0
m_Children: [] m_Children: []
m_Father: {fileID: 3918594454393827276} m_Father: {fileID: 3918594454393827276}
m_RootOrder: 0 m_RootOrder: 0
@ -586,6 +591,7 @@ RectTransform:
m_LocalRotation: {x: -0, y: -0, z: -0, w: 1} m_LocalRotation: {x: -0, y: -0, z: -0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0} m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 0.999721, y: 0.999721, z: 0.999721} m_LocalScale: {x: 0.999721, y: 0.999721, z: 0.999721}
m_ConstrainProportionsScale: 0
m_Children: [] m_Children: []
m_Father: {fileID: 3918594454379110541} m_Father: {fileID: 3918594454379110541}
m_RootOrder: 0 m_RootOrder: 0
@ -665,6 +671,7 @@ RectTransform:
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0} m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1} m_LocalScale: {x: 1, y: 1, z: 1}
m_ConstrainProportionsScale: 0
m_Children: m_Children:
- {fileID: 3918594454988680239} - {fileID: 3918594454988680239}
- {fileID: 3918594455644130455} - {fileID: 3918594455644130455}
@ -823,6 +830,7 @@ RectTransform:
m_LocalRotation: {x: -0, y: -0, z: -0, w: 1} m_LocalRotation: {x: -0, y: -0, z: -0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0} m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 0.9998709, y: 0.9998709, z: 0.9998709} m_LocalScale: {x: 0.9998709, y: 0.9998709, z: 0.9998709}
m_ConstrainProportionsScale: 0
m_Children: m_Children:
- {fileID: 3918594454379110541} - {fileID: 3918594454379110541}
- {fileID: 3918594455983756500} - {fileID: 3918594455983756500}
@ -960,6 +968,7 @@ RectTransform:
m_LocalRotation: {x: -0, y: -0, z: -0, w: 1} m_LocalRotation: {x: -0, y: -0, z: -0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0} m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1} m_LocalScale: {x: 1, y: 1, z: 1}
m_ConstrainProportionsScale: 0
m_Children: m_Children:
- {fileID: 3918594454792429615} - {fileID: 3918594454792429615}
- {fileID: 3918594455236935870} - {fileID: 3918594455236935870}
@ -1092,6 +1101,7 @@ RectTransform:
m_LocalRotation: {x: -0, y: -0, z: -0, w: 1} m_LocalRotation: {x: -0, y: -0, z: -0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0} m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1} m_LocalScale: {x: 1, y: 1, z: 1}
m_ConstrainProportionsScale: 0
m_Children: m_Children:
- {fileID: 3918594454557351925} - {fileID: 3918594454557351925}
- {fileID: 3918594455809915007} - {fileID: 3918594455809915007}
@ -1143,7 +1153,7 @@ MonoBehaviour:
m_ChildControlWidth: 0 m_ChildControlWidth: 0
m_ChildControlHeight: 0 m_ChildControlHeight: 0
m_ChildScaleWidth: 0 m_ChildScaleWidth: 0
m_ChildScaleHeight: 0 m_ChildScaleHeight: 1
m_ReverseArrangement: 0 m_ReverseArrangement: 0
--- !u!1 &3918594454606926957 --- !u!1 &3918594454606926957
GameObject: GameObject:
@ -1171,6 +1181,7 @@ RectTransform:
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0} m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1} m_LocalScale: {x: 1, y: 1, z: 1}
m_ConstrainProportionsScale: 0
m_Children: m_Children:
- {fileID: 3918594455132415350} - {fileID: 3918594455132415350}
m_Father: {fileID: 3918594455644130455} m_Father: {fileID: 3918594455644130455}
@ -1209,6 +1220,7 @@ RectTransform:
m_LocalRotation: {x: -0, y: -0, z: -0, w: 1} m_LocalRotation: {x: -0, y: -0, z: -0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0} m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1} m_LocalScale: {x: 1, y: 1, z: 1}
m_ConstrainProportionsScale: 0
m_Children: [] m_Children: []
m_Father: {fileID: 3918594456381758635} m_Father: {fileID: 3918594456381758635}
m_RootOrder: 0 m_RootOrder: 0
@ -1284,6 +1296,7 @@ RectTransform:
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0} m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1} m_LocalScale: {x: 1, y: 1, z: 1}
m_ConstrainProportionsScale: 0
m_Children: [] m_Children: []
m_Father: {fileID: 3918594455259951552} m_Father: {fileID: 3918594455259951552}
m_RootOrder: 2 m_RootOrder: 2
@ -1418,6 +1431,7 @@ RectTransform:
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0} m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1} m_LocalScale: {x: 1, y: 1, z: 1}
m_ConstrainProportionsScale: 0
m_Children: [] m_Children: []
m_Father: {fileID: 3918594454563211272} m_Father: {fileID: 3918594454563211272}
m_RootOrder: 0 m_RootOrder: 0
@ -1553,6 +1567,7 @@ RectTransform:
m_LocalRotation: {x: -0, y: -0, z: -0, w: 1} m_LocalRotation: {x: -0, y: -0, z: -0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0} m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1} m_LocalScale: {x: 1, y: 1, z: 1}
m_ConstrainProportionsScale: 0
m_Children: m_Children:
- {fileID: 3918594456381758635} - {fileID: 3918594456381758635}
m_Father: {fileID: 3918594455428278210} m_Father: {fileID: 3918594455428278210}
@ -1678,13 +1693,14 @@ RectTransform:
m_LocalRotation: {x: -0, y: -0, z: -0, w: 1} m_LocalRotation: {x: -0, y: -0, z: -0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0} m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1} m_LocalScale: {x: 1, y: 1, z: 1}
m_ConstrainProportionsScale: 0
m_Children: [] m_Children: []
m_Father: {fileID: 3918594456218978263} m_Father: {fileID: 9026175551012134334}
m_RootOrder: 1 m_RootOrder: 0
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0, y: 1} m_AnchorMin: {x: 0, y: 1}
m_AnchorMax: {x: 0, y: 1} m_AnchorMax: {x: 0, y: 1}
m_AnchoredPosition: {x: 571, y: -89.66667} m_AnchoredPosition: {x: 512, y: -69.66667}
m_SizeDelta: {x: 198.33331, y: 115.333336} m_SizeDelta: {x: 198.33331, y: 115.333336}
m_Pivot: {x: 0.5, y: 0.5} m_Pivot: {x: 0.5, y: 0.5}
--- !u!222 &3918594454983356897 --- !u!222 &3918594454983356897
@ -1754,6 +1770,7 @@ RectTransform:
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0} m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1} m_LocalScale: {x: 1, y: 1, z: 1}
m_ConstrainProportionsScale: 0
m_Children: m_Children:
- {fileID: 3918594456231380559} - {fileID: 3918594456231380559}
m_Father: {fileID: 3918594454549251010} m_Father: {fileID: 3918594454549251010}
@ -1843,6 +1860,7 @@ RectTransform:
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0} m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1} m_LocalScale: {x: 1, y: 1, z: 1}
m_ConstrainProportionsScale: 0
m_Children: [] m_Children: []
m_Father: {fileID: 3918594454606926956} m_Father: {fileID: 3918594454606926956}
m_RootOrder: 0 m_RootOrder: 0
@ -1919,6 +1937,7 @@ RectTransform:
m_LocalRotation: {x: -0, y: -0, z: -0, w: 1} m_LocalRotation: {x: -0, y: -0, z: -0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0} m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1} m_LocalScale: {x: 1, y: 1, z: 1}
m_ConstrainProportionsScale: 0
m_Children: m_Children:
- {fileID: 3918594455777867990} - {fileID: 3918594455777867990}
- {fileID: 3918594455724056079} - {fileID: 3918594455724056079}
@ -2052,6 +2071,7 @@ RectTransform:
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0} m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1} m_LocalScale: {x: 1, y: 1, z: 1}
m_ConstrainProportionsScale: 0
m_Children: [] m_Children: []
m_Father: {fileID: 3918594454563211272} m_Father: {fileID: 3918594454563211272}
m_RootOrder: 1 m_RootOrder: 1
@ -2126,6 +2146,7 @@ RectTransform:
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0} m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1} m_LocalScale: {x: 1, y: 1, z: 1}
m_ConstrainProportionsScale: 0
m_Children: m_Children:
- {fileID: 3918594455555356347} - {fileID: 3918594455555356347}
- {fileID: 3918594455678953489} - {fileID: 3918594455678953489}
@ -2214,6 +2235,7 @@ RectTransform:
m_LocalRotation: {x: -0, y: -0, z: -0, w: 1} m_LocalRotation: {x: -0, y: -0, z: -0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0} m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 1.0000798, y: 1.0000798, z: 1.0000798} m_LocalScale: {x: 1.0000798, y: 1.0000798, z: 1.0000798}
m_ConstrainProportionsScale: 0
m_Children: [] m_Children: []
m_Father: {fileID: 3918594454393827276} m_Father: {fileID: 3918594454393827276}
m_RootOrder: 2 m_RootOrder: 2
@ -2349,6 +2371,7 @@ RectTransform:
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0} m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1} m_LocalScale: {x: 1, y: 1, z: 1}
m_ConstrainProportionsScale: 0
m_Children: m_Children:
- {fileID: 3918594455428278210} - {fileID: 3918594455428278210}
- {fileID: 3918594456072477009} - {fileID: 3918594456072477009}
@ -2455,6 +2478,7 @@ RectTransform:
m_LocalRotation: {x: -0, y: -0, z: -0, w: 1} m_LocalRotation: {x: -0, y: -0, z: -0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0} m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1} m_LocalScale: {x: 1, y: 1, z: 1}
m_ConstrainProportionsScale: 0
m_Children: m_Children:
- {fileID: 3918594454383525696} - {fileID: 3918594454383525696}
- {fileID: 3918594454902271391} - {fileID: 3918594454902271391}
@ -2562,13 +2586,14 @@ RectTransform:
m_LocalRotation: {x: -0, y: -0, z: -0, w: 1} m_LocalRotation: {x: -0, y: -0, z: -0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0} m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1} m_LocalScale: {x: 1, y: 1, z: 1}
m_ConstrainProportionsScale: 0
m_Children: [] m_Children: []
m_Father: {fileID: 3918594456218978263} m_Father: {fileID: 9026175551012134334}
m_RootOrder: 3 m_RootOrder: 2
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0, y: 1} m_AnchorMin: {x: 0, y: 1}
m_AnchorMax: {x: 0, y: 1} m_AnchorMax: {x: 0, y: 1}
m_AnchoredPosition: {x: 571, y: -74.888885} m_AnchoredPosition: {x: 512, y: -42.888905}
m_SizeDelta: {x: 153.66667, y: 78.666664} m_SizeDelta: {x: 153.66667, y: 78.666664}
m_Pivot: {x: 0.5, y: 0.5} m_Pivot: {x: 0.5, y: 0.5}
--- !u!222 &3918594455474526704 --- !u!222 &3918594455474526704
@ -2637,6 +2662,7 @@ RectTransform:
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0} m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1} m_LocalScale: {x: 1, y: 1, z: 1}
m_ConstrainProportionsScale: 0
m_Children: [] m_Children: []
m_Father: {fileID: 3918594455259951552} m_Father: {fileID: 3918594455259951552}
m_RootOrder: 0 m_RootOrder: 0
@ -2712,13 +2738,14 @@ RectTransform:
m_LocalRotation: {x: -0, y: -0, z: -0, w: 1} m_LocalRotation: {x: -0, y: -0, z: -0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0} m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1} m_LocalScale: {x: 1, y: 1, z: 1}
m_ConstrainProportionsScale: 0
m_Children: [] m_Children: []
m_Father: {fileID: 3918594456218978263} m_Father: {fileID: 9026175551012134334}
m_RootOrder: 5 m_RootOrder: 4
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0, y: 1} m_AnchorMin: {x: 0, y: 1}
m_AnchorMax: {x: 0, y: 1} m_AnchorMax: {x: 0, y: 1}
m_AnchoredPosition: {x: 571, y: -116} m_AnchoredPosition: {x: 512, y: -84.000015}
m_SizeDelta: {x: 202, y: 140} m_SizeDelta: {x: 202, y: 140}
m_Pivot: {x: 0.5, y: 0.5} m_Pivot: {x: 0.5, y: 0.5}
--- !u!222 &3918594455571216814 --- !u!222 &3918594455571216814
@ -2787,13 +2814,14 @@ RectTransform:
m_LocalRotation: {x: -0, y: -0, z: -0, w: 1} m_LocalRotation: {x: -0, y: -0, z: -0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0} m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1} m_LocalScale: {x: 1, y: 1, z: 1}
m_ConstrainProportionsScale: 0
m_Children: [] m_Children: []
m_Father: {fileID: 3918594456218978263} m_Father: {fileID: 9026175551012134334}
m_RootOrder: 2 m_RootOrder: 1
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0, y: 1} m_AnchorMin: {x: 0, y: 1}
m_AnchorMax: {x: 0, y: 1} m_AnchorMax: {x: 0, y: 1}
m_AnchoredPosition: {x: 571, y: -71.33333} m_AnchoredPosition: {x: 512, y: -39.333347}
m_SizeDelta: {x: 154, y: 78.666664} m_SizeDelta: {x: 154, y: 78.666664}
m_Pivot: {x: 0.5, y: 0.5} m_Pivot: {x: 0.5, y: 0.5}
--- !u!222 &3918594455640061323 --- !u!222 &3918594455640061323
@ -2863,6 +2891,7 @@ RectTransform:
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0} m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1} m_LocalScale: {x: 1, y: 1, z: 1}
m_ConstrainProportionsScale: 0
m_Children: m_Children:
- {fileID: 3918594454606926956} - {fileID: 3918594454606926956}
m_Father: {fileID: 3918594454549251010} m_Father: {fileID: 3918594454549251010}
@ -2988,6 +3017,7 @@ RectTransform:
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0} m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1} m_LocalScale: {x: 1, y: 1, z: 1}
m_ConstrainProportionsScale: 0
m_Children: [] m_Children: []
m_Father: {fileID: 3918594455259951552} m_Father: {fileID: 3918594455259951552}
m_RootOrder: 1 m_RootOrder: 1
@ -3063,13 +3093,14 @@ RectTransform:
m_LocalRotation: {x: -0, y: -0, z: -0, w: 1} m_LocalRotation: {x: -0, y: -0, z: -0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0} m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1} m_LocalScale: {x: 1, y: 1, z: 1}
m_ConstrainProportionsScale: 0
m_Children: [] m_Children: []
m_Father: {fileID: 3918594456218978263} m_Father: {fileID: 9026175551012134334}
m_RootOrder: 7 m_RootOrder: 6
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0, y: 1} m_AnchorMin: {x: 0, y: 1}
m_AnchorMax: {x: 0, y: 1} m_AnchorMax: {x: 0, y: 1}
m_AnchoredPosition: {x: 571, y: -116} m_AnchoredPosition: {x: 512, y: -84.000015}
m_SizeDelta: {x: 208.33333, y: 144.66667} m_SizeDelta: {x: 208.33333, y: 144.66667}
m_Pivot: {x: 0.5, y: 0.5} m_Pivot: {x: 0.5, y: 0.5}
--- !u!222 &3918594455700716069 --- !u!222 &3918594455700716069
@ -3138,6 +3169,7 @@ RectTransform:
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0} m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1} m_LocalScale: {x: 1, y: 1, z: 1}
m_ConstrainProportionsScale: 0
m_Children: [] m_Children: []
m_Father: {fileID: 3918594455165826550} m_Father: {fileID: 3918594455165826550}
m_RootOrder: 1 m_RootOrder: 1
@ -3272,6 +3304,7 @@ RectTransform:
m_LocalRotation: {x: -0, y: -0, z: -0, w: 1} m_LocalRotation: {x: -0, y: -0, z: -0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0} m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1} m_LocalScale: {x: 1, y: 1, z: 1}
m_ConstrainProportionsScale: 0
m_Children: [] m_Children: []
m_Father: {fileID: 3918594455165826550} m_Father: {fileID: 3918594455165826550}
m_RootOrder: 0 m_RootOrder: 0
@ -3348,6 +3381,7 @@ RectTransform:
m_LocalRotation: {x: -0, y: -0, z: -0, w: 1} m_LocalRotation: {x: -0, y: -0, z: -0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0} m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1} m_LocalScale: {x: 1, y: 1, z: 1}
m_ConstrainProportionsScale: 0
m_Children: m_Children:
- {fileID: 3918594455818177326} - {fileID: 3918594455818177326}
- {fileID: 3918594456368854930} - {fileID: 3918594456368854930}
@ -3480,6 +3514,7 @@ RectTransform:
m_LocalRotation: {x: -0, y: -0, z: -0, w: 1} m_LocalRotation: {x: -0, y: -0, z: -0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0} m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 0.9998709, y: 0.9998709, z: 0.9998709} m_LocalScale: {x: 0.9998709, y: 0.9998709, z: 0.9998709}
m_ConstrainProportionsScale: 0
m_Children: m_Children:
- {fileID: 3918594455814386336} - {fileID: 3918594455814386336}
- {fileID: 3918594454563211272} - {fileID: 3918594454563211272}
@ -3547,6 +3582,7 @@ RectTransform:
m_LocalRotation: {x: -0, y: -0, z: -0, w: 1} m_LocalRotation: {x: -0, y: -0, z: -0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0} m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 1.0000798, y: 1.0000798, z: 1.0000798} m_LocalScale: {x: 1.0000798, y: 1.0000798, z: 1.0000798}
m_ConstrainProportionsScale: 0
m_Children: [] m_Children: []
m_Father: {fileID: 3918594455809915007} m_Father: {fileID: 3918594455809915007}
m_RootOrder: 0 m_RootOrder: 0
@ -3681,6 +3717,7 @@ RectTransform:
m_LocalRotation: {x: -0, y: -0, z: -0, w: 1} m_LocalRotation: {x: -0, y: -0, z: -0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0} m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1} m_LocalScale: {x: 1, y: 1, z: 1}
m_ConstrainProportionsScale: 0
m_Children: [] m_Children: []
m_Father: {fileID: 3918594455780710548} m_Father: {fileID: 3918594455780710548}
m_RootOrder: 0 m_RootOrder: 0
@ -3756,6 +3793,7 @@ RectTransform:
m_LocalRotation: {x: -0, y: -0, z: -0, w: 1} m_LocalRotation: {x: -0, y: -0, z: -0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0} m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1} m_LocalScale: {x: 1, y: 1, z: 1}
m_ConstrainProportionsScale: 0
m_Children: [] m_Children: []
m_Father: {fileID: 3918594456218978263} m_Father: {fileID: 3918594456218978263}
m_RootOrder: 0 m_RootOrder: 0
@ -3890,6 +3928,7 @@ RectTransform:
m_LocalRotation: {x: -0, y: -0, z: -0, w: 1} m_LocalRotation: {x: -0, y: -0, z: -0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0} m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1} m_LocalScale: {x: 1, y: 1, z: 1}
m_ConstrainProportionsScale: 0
m_Children: [] m_Children: []
m_Father: {fileID: 3918594456072477009} m_Father: {fileID: 3918594456072477009}
m_RootOrder: 0 m_RootOrder: 0
@ -4024,6 +4063,7 @@ RectTransform:
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0} m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1} m_LocalScale: {x: 1, y: 1, z: 1}
m_ConstrainProportionsScale: 0
m_Children: [] m_Children: []
m_Father: {fileID: 3918594454557351925} m_Father: {fileID: 3918594454557351925}
m_RootOrder: 1 m_RootOrder: 1
@ -4158,6 +4198,7 @@ RectTransform:
m_LocalRotation: {x: -0, y: -0, z: -0, w: 1} m_LocalRotation: {x: -0, y: -0, z: -0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0} m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1} m_LocalScale: {x: 1, y: 1, z: 1}
m_ConstrainProportionsScale: 0
m_Children: m_Children:
- {fileID: 3918594455960776193} - {fileID: 3918594455960776193}
m_Father: {fileID: 3918594455367347237} m_Father: {fileID: 3918594455367347237}
@ -4234,13 +4275,14 @@ RectTransform:
m_LocalRotation: {x: -0, y: -0, z: -0, w: 1} m_LocalRotation: {x: -0, y: -0, z: -0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0} m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1} m_LocalScale: {x: 1, y: 1, z: 1}
m_ConstrainProportionsScale: 0
m_Children: [] m_Children: []
m_Father: {fileID: 3918594456218978263} m_Father: {fileID: 9026175551012134334}
m_RootOrder: 6 m_RootOrder: 5
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0, y: 1} m_AnchorMin: {x: 0, y: 1}
m_AnchorMax: {x: 0, y: 1} m_AnchorMax: {x: 0, y: 1}
m_AnchoredPosition: {x: 571, y: -98.333336} m_AnchoredPosition: {x: 512, y: -66.33336}
m_SizeDelta: {x: 209.66667, y: 132.66667} m_SizeDelta: {x: 209.66667, y: 132.66667}
m_Pivot: {x: 0.5, y: 0.5} m_Pivot: {x: 0.5, y: 0.5}
--- !u!222 &3918594456177472899 --- !u!222 &3918594456177472899
@ -4309,13 +4351,14 @@ RectTransform:
m_LocalRotation: {x: -0, y: -0, z: -0, w: 1} m_LocalRotation: {x: -0, y: -0, z: -0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0} m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1} m_LocalScale: {x: 1, y: 1, z: 1}
m_ConstrainProportionsScale: 0
m_Children: [] m_Children: []
m_Father: {fileID: 3918594456218978263} m_Father: {fileID: 9026175551012134334}
m_RootOrder: 4 m_RootOrder: 3
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0, y: 1} m_AnchorMin: {x: 0, y: 1}
m_AnchorMax: {x: 0, y: 1} m_AnchorMax: {x: 0, y: 1}
m_AnchoredPosition: {x: 571, y: -109} m_AnchoredPosition: {x: 512, y: -77.000015}
m_SizeDelta: {x: 142, y: 154} m_SizeDelta: {x: 142, y: 154}
m_Pivot: {x: 0.5, y: 0.5} m_Pivot: {x: 0.5, y: 0.5}
--- !u!222 &3918594456187747141 --- !u!222 &3918594456187747141
@ -4368,6 +4411,7 @@ GameObject:
- component: {fileID: 3918594456218978261} - component: {fileID: 3918594456218978261}
- component: {fileID: 3918594456218978262} - component: {fileID: 3918594456218978262}
- component: {fileID: 3918594456218978260} - component: {fileID: 3918594456218978260}
- component: {fileID: 7064734900293365887}
m_Layer: 5 m_Layer: 5
m_Name: ControllerDisplay m_Name: ControllerDisplay
m_TagString: Untagged m_TagString: Untagged
@ -4385,22 +4429,17 @@ RectTransform:
m_LocalRotation: {x: -0, y: -0, z: -0, w: 1} m_LocalRotation: {x: -0, y: -0, z: -0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0} m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 0.9998709, y: 0.9998709, z: 0.9998709} m_LocalScale: {x: 0.9998709, y: 0.9998709, z: 0.9998709}
m_ConstrainProportionsScale: 0
m_Children: m_Children:
- {fileID: 3918594455881004028} - {fileID: 3918594455881004028}
- {fileID: 3918594454983356899} - {fileID: 9026175551012134334}
- {fileID: 3918594455640061333}
- {fileID: 3918594455474526706}
- {fileID: 3918594456187747143}
- {fileID: 3918594455571216808}
- {fileID: 3918594456177472909}
- {fileID: 3918594455700716071}
m_Father: {fileID: 3918594454598345480} m_Father: {fileID: 3918594454598345480}
m_RootOrder: 3 m_RootOrder: 3
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0, y: 0} m_AnchorMin: {x: 0, y: 0}
m_AnchorMax: {x: 0, y: 0} m_AnchorMax: {x: 0, y: 0}
m_AnchoredPosition: {x: 0, y: 0} m_AnchoredPosition: {x: 591, y: 0}
m_SizeDelta: {x: 1142, y: 200} m_SizeDelta: {x: 1142, y: 0}
m_Pivot: {x: 0.5, y: 0.5} m_Pivot: {x: 0.5, y: 0.5}
--- !u!222 &3918594456218978261 --- !u!222 &3918594456218978261
CanvasRenderer: CanvasRenderer:
@ -4455,7 +4494,7 @@ MonoBehaviour:
m_Padding: m_Padding:
m_Left: 0 m_Left: 0
m_Right: 0 m_Right: 0
m_Top: 0 m_Top: 8
m_Bottom: 0 m_Bottom: 0
m_ChildAlignment: 1 m_ChildAlignment: 1
m_Spacing: 0 m_Spacing: 0
@ -4466,6 +4505,20 @@ MonoBehaviour:
m_ChildScaleWidth: 0 m_ChildScaleWidth: 0
m_ChildScaleHeight: 0 m_ChildScaleHeight: 0
m_ReverseArrangement: 0 m_ReverseArrangement: 0
--- !u!114 &7064734900293365887
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 3918594456218978256}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 3245ec927659c4140ac4f8d17403cc18, type: 3}
m_Name:
m_EditorClassIdentifier:
m_HorizontalFit: 0
m_VerticalFit: 1
--- !u!1 &3918594456231380552 --- !u!1 &3918594456231380552
GameObject: GameObject:
m_ObjectHideFlags: 0 m_ObjectHideFlags: 0
@ -4492,6 +4545,7 @@ RectTransform:
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0} m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1} m_LocalScale: {x: 1, y: 1, z: 1}
m_ConstrainProportionsScale: 0
m_Children: m_Children:
- {fileID: 3918594455259951552} - {fileID: 3918594455259951552}
m_Father: {fileID: 3918594454988680239} m_Father: {fileID: 3918594454988680239}
@ -4530,6 +4584,7 @@ RectTransform:
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0} m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1} m_LocalScale: {x: 1, y: 1, z: 1}
m_ConstrainProportionsScale: 0
m_Children: [] m_Children: []
m_Father: {fileID: 3918594455780710548} m_Father: {fileID: 3918594455780710548}
m_RootOrder: 1 m_RootOrder: 1
@ -4662,6 +4717,7 @@ RectTransform:
m_LocalRotation: {x: -0, y: -0, z: -0, w: 1} m_LocalRotation: {x: -0, y: -0, z: -0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0} m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1} m_LocalScale: {x: 1, y: 1, z: 1}
m_ConstrainProportionsScale: 0
m_Children: m_Children:
- {fileID: 3918594454634310521} - {fileID: 3918594454634310521}
m_Father: {fileID: 3918594454902271391} m_Father: {fileID: 3918594454902271391}
@ -4672,3 +4728,82 @@ RectTransform:
m_AnchoredPosition: {x: 0, y: 0} m_AnchoredPosition: {x: 0, y: 0}
m_SizeDelta: {x: -20, y: -20} m_SizeDelta: {x: -20, y: -20}
m_Pivot: {x: 0.5, y: 0.5} m_Pivot: {x: 0.5, y: 0.5}
--- !u!1 &8203640970610497511
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 9026175551012134334}
- component: {fileID: 9113777502962941725}
- component: {fileID: 4639420071325041271}
m_Layer: 5
m_Name: BindingList
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!224 &9026175551012134334
RectTransform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 8203640970610497511}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_ConstrainProportionsScale: 0
m_Children:
- {fileID: 3918594454983356899}
- {fileID: 3918594455640061333}
- {fileID: 3918594455474526706}
- {fileID: 3918594456187747143}
- {fileID: 3918594455571216808}
- {fileID: 3918594456177472909}
- {fileID: 3918594455700716071}
m_Father: {fileID: 3918594456218978263}
m_RootOrder: 1
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0, y: 0}
m_AnchorMax: {x: 0, y: 0}
m_AnchoredPosition: {x: 0, y: 0}
m_SizeDelta: {x: 1024, y: 256}
m_Pivot: {x: 0.5, y: 0.5}
--- !u!222 &9113777502962941725
CanvasRenderer:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 8203640970610497511}
m_CullTransparentMesh: 1
--- !u!114 &4639420071325041271
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 8203640970610497511}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 30649d3a9faa99c48a7b1166b86bf2a0, type: 3}
m_Name:
m_EditorClassIdentifier:
m_Padding:
m_Left: 0
m_Right: 0
m_Top: 12
m_Bottom: 0
m_ChildAlignment: 1
m_Spacing: 0
m_ChildForceExpandWidth: 1
m_ChildForceExpandHeight: 1
m_ChildControlWidth: 0
m_ChildControlHeight: 0
m_ChildScaleWidth: 0
m_ChildScaleHeight: 0
m_ReverseArrangement: 0

View file

@ -13,7 +13,11 @@ namespace HeavenStudio.InputSystem.Loaders
[LoadOrder(1)] [LoadOrder(1)]
public static InputController[] Initialize() public static InputController[] Initialize()
{ {
InputJoyshock.joyshocks = new();
PlayerInput.PlayerInputCleanUp += DisposeJoyshocks; PlayerInput.PlayerInputCleanUp += DisposeJoyshocks;
PlayerInput.PlayerInputRefresh.Add(Refresh);
InputJoyshock.JslEventInit();
InputController[] controllers; InputController[] controllers;
int jslDevicesFound = 0; int jslDevicesFound = 0;
@ -54,6 +58,35 @@ namespace HeavenStudio.InputSystem.Loaders
{ {
JslDisconnectAndDisposeAll(); JslDisconnectAndDisposeAll();
} }
public static InputController[] Refresh()
{
InputJoyshock.joyshocks.Clear();
InputController[] controllers;
int jslDevicesFound = 0;
int jslDevicesConnected = 0;
int[] jslDeviceHandles;
jslDevicesFound = JslConnectDevices();
if (jslDevicesFound > 0)
{
jslDeviceHandles = new int[jslDevicesFound];
jslDevicesConnected = JslGetConnectedDeviceHandles(jslDeviceHandles, jslDevicesFound);
controllers = new InputController[jslDevicesConnected];
foreach (int i in jslDeviceHandles)
{
Debug.Log("Setting up JoyShock: ( Handle " + i + ", type " + JslGetControllerType(i) + " )");
InputJoyshock joyshock = new InputJoyshock(i);
joyshock.SetPlayer(null);
joyshock.InitializeController();
controllers[i] = joyshock;
}
return controllers;
}
Debug.Log("No JoyShocks found.");
return null;
}
} }
} }
@ -126,6 +159,8 @@ namespace HeavenStudio.InputSystem
ButtonMaskPlus, ButtonMaskPlus,
}; };
public static Dictionary<int, InputJoyshock> joyshocks;
float stickDeadzone = 0.5f; float stickDeadzone = 0.5f;
int joyshockHandle; int joyshockHandle;
@ -133,9 +168,11 @@ namespace HeavenStudio.InputSystem
int splitType; int splitType;
int lightbarColour; int lightbarColour;
string joyshockName; string joyshockName;
double totalReportDt;
//buttons, sticks, triggers //buttons, sticks, triggers
JOY_SHOCK_STATE joyBtStateCurrent, joyBtStateLast; JoyshockButtonState[] buttonStates = new JoyshockButtonState[11];
JOY_SHOCK_STATE joyBtStateCurrent;
//gyro and accelerometer //gyro and accelerometer
IMU_STATE joyImuStateCurrent, joyImuStateLast; IMU_STATE joyImuStateCurrent, joyImuStateLast;
//touchpad //touchpad
@ -143,17 +180,69 @@ namespace HeavenStudio.InputSystem
InputJoyshock otherHalf; InputJoyshock otherHalf;
public struct JoyshockButtonState
{
public double time; // time passed since state
public bool pressed; // true if button is down
public bool isDelta; // true if the button changed state since last frame
}
public struct TimestampedState
{
public double timestamp;
public JOY_SHOCK_STATE input;
}
protected List<TimestampedState> inputStack; // asynnc input events / polling should feed into this dict
protected List<TimestampedState> lastInputStack; // when processing input copy the inputStack to this dict
protected bool wantClearInputStack = false; // strobe from main thread to clear the input stack
protected double reportTime = 0; // same timeline as Time.timeSinceStartup
protected double lastReportTime = 0; // same timeline as Time.timeSinceStartup
public InputJoyshock(int handle) public InputJoyshock(int handle)
{ {
joyshockHandle = handle; joyshockHandle = handle;
} }
public static void JslEventInit()
{
JslSetCallback(JslEventCallback);
}
static void JslEventCallback(int handle, JOY_SHOCK_STATE state, JOY_SHOCK_STATE lastState,
IMU_STATE imuState, IMU_STATE lastImuState, float deltaTime)
{
if (!joyshocks.ContainsKey(handle)) return;
InputJoyshock js = joyshocks[handle];
if (js == null) return;
if (js.inputStack == null) return;
if (js.wantClearInputStack)
{
js.inputStack.Clear();
js.wantClearInputStack = false;
js.totalReportDt = (js.lastReportTime*2) - js.reportTime;
js.lastReportTime = js.reportTime;
}
js.totalReportDt += deltaTime;
js.inputStack.Add(new TimestampedState
{
timestamp = js.totalReportDt,
input = state
});
}
public override void InitializeController() public override void InitializeController()
{ {
inputStack = new();
lastInputStack = new();
buttonStates = new JoyshockButtonState[11];
joyBtStateCurrent = new JOY_SHOCK_STATE(); joyBtStateCurrent = new JOY_SHOCK_STATE();
joyBtStateLast = new JOY_SHOCK_STATE();
joyImuStateCurrent = new IMU_STATE(); joyImuStateCurrent = new IMU_STATE();
joyImuStateLast = new IMU_STATE(); joyImuStateLast = new IMU_STATE();
joyTouchStateCurrent = new TOUCH_STATE(); joyTouchStateCurrent = new TOUCH_STATE();
joyTouchStateLast = new TOUCH_STATE(); joyTouchStateLast = new TOUCH_STATE();
@ -163,23 +252,60 @@ namespace HeavenStudio.InputSystem
joyshockName = joyShockNames[type]; joyshockName = joyShockNames[type];
splitType = JslGetControllerSplitType(joyshockHandle); splitType = JslGetControllerSplitType(joyshockHandle);
joyshocks.Add(joyshockHandle, this);
} }
public override void UpdateState() public override void UpdateState()
{ {
//buttons lastInputStack = new(inputStack);
joyBtStateLast = joyBtStateCurrent; wantClearInputStack = true;
joyBtStateCurrent = JslGetSimpleState(joyshockHandle); reportTime = Time.realtimeSinceStartupAsDouble;
//gyro and accelerometer // Debug.Log($"=== updating state for {joyshockName} id {joyshockHandle} ===");
joyImuStateLast = joyImuStateCurrent; for (int i = 0; i < buttonStates.Length; i++)
joyImuStateCurrent = JslGetIMUState(joyshockHandle); {
buttonStates[i].isDelta = false;
}
foreach(TimestampedState state in lastInputStack)
{
// Debug.Log($"checking state at {state.timestamp} ({reportTime - state.timestamp}s ago), input {state.input.buttons}");
joyBtStateCurrent = state.input;
//touchpad for (int i = 0; i < buttonStates.Length; i++)
joyTouchStateLast = joyTouchStateCurrent; {
joyTouchStateCurrent = JslGetTouchState(joyshockHandle); JoyshockButtonState st = buttonStates[i];
int bt = mappings[i];
if (otherHalf == null)
{
switch (splitType)
{
case SplitLeft:
bt = mappingsSplitLeft[i];
break;
case SplitRight:
bt = mappingsSplitRight[i];
break;
default:
break;
}
}
//stick direction state if (bt != -1)
{
bool pressed = BitwiseUtils.WantCurrent(state.input.buttons, 1 << bt);
if (pressed != st.pressed && !st.isDelta)
{
Debug.Log($"button {i} ({bt}) state changed to {pressed}, was {st.pressed} (time {reportTime - state.timestamp}s ago)");
buttonStates[i].pressed = pressed;
buttonStates[i].isDelta = true;
buttonStates[i].time = reportTime - state.timestamp;
}
}
}
}
//stick direction state, only handled on update
//split controllers will need to be rotated to compensate //split controllers will need to be rotated to compensate
//left rotates counterclockwise, right rotates clockwise, all by 90 degrees //left rotates counterclockwise, right rotates clockwise, all by 90 degrees
float xAxis = 0f; float xAxis = 0f;
@ -215,6 +341,8 @@ namespace HeavenStudio.InputSystem
directionStateCurrent |= ((xAxis >= stickDeadzone) ? (1 << ((int) InputDirection.Right)) : 0); directionStateCurrent |= ((xAxis >= stickDeadzone) ? (1 << ((int) InputDirection.Right)) : 0);
directionStateCurrent |= ((xAxis <= -stickDeadzone) ? (1 << ((int) InputDirection.Left)) : 0); directionStateCurrent |= ((xAxis <= -stickDeadzone) ? (1 << ((int) InputDirection.Left)) : 0);
//Debug.Log("stick direction: " + directionStateCurrent + "| x axis: " + xAxis + " y axis: " + yAxis); //Debug.Log("stick direction: " + directionStateCurrent + "| x axis: " + xAxis + " y axis: " + yAxis);
lastInputStack.Clear();
} }
public override string GetDeviceName() public override string GetDeviceName()
@ -248,9 +376,26 @@ namespace HeavenStudio.InputSystem
return features; return features;
} }
public override bool GetIsConnected()
{
return JslStillConnected(joyshockHandle);
}
public override bool GetIsPoorConnection()
{
return false;
}
public override int GetLastButtonDown() public override int GetLastButtonDown()
{ {
return BitwiseUtils.FirstSetBit(joyBtStateCurrent.buttons & joyBtStateLast.buttons); for (int i = 0; i < buttonStates.Length; i++)
{
if (buttonStates[i].pressed && buttonStates[i].isDelta)
{
return i;
}
}
return -1;
} }
public override KeyCode GetLastKeyDown() public override KeyCode GetLastKeyDown()
@ -260,71 +405,17 @@ namespace HeavenStudio.InputSystem
public override bool GetButton(int button) public override bool GetButton(int button)
{ {
int bt = 0; return buttonStates[button].pressed;
if (otherHalf == null)
{
if (splitType == SplitLeft)
{
bt = mappingsSplitLeft[button];
}
else if (splitType == SplitRight)
{
bt = mappingsSplitRight[button];
}
else
{
bt = mappings[button];
}
return BitwiseUtils.WantCurrent(joyBtStateCurrent.buttons, 1 << bt);
}
bt = mappings[button];
return BitwiseUtils.WantCurrent(joyBtStateCurrent.buttons, 1 << bt) || BitwiseUtils.WantCurrent(otherHalf.joyBtStateCurrent.buttons, 1 << bt);
} }
public override bool GetButtonDown(int button) public override bool GetButtonDown(int button)
{ {
int bt = 0; return buttonStates[button].pressed && buttonStates[button].isDelta;
if (otherHalf == null)
{
if (splitType == SplitLeft)
{
bt = mappingsSplitLeft[button];
}
else if (splitType == SplitRight)
{
bt = mappingsSplitRight[button];
}
else
{
bt = mappings[button];
}
return BitwiseUtils.WantCurrentAndNotLast(joyBtStateCurrent.buttons, joyBtStateLast.buttons, 1 << bt);
}
bt = mappings[button];
return BitwiseUtils.WantCurrentAndNotLast(joyBtStateCurrent.buttons, joyBtStateLast.buttons, 1 << bt) || BitwiseUtils.WantCurrentAndNotLast(otherHalf.joyBtStateCurrent.buttons, otherHalf.joyBtStateLast.buttons, 1 << bt);
} }
public override bool GetButtonUp(int button) public override bool GetButtonUp(int button)
{ {
int bt = 0; return (!buttonStates[button].pressed) && buttonStates[button].isDelta;
if (otherHalf == null)
{
if (splitType == SplitLeft)
{
bt = mappingsSplitLeft[button];
}
else if (splitType == SplitRight)
{
bt = mappingsSplitRight[button];
}
else
{
bt = mappings[button];
}
return BitwiseUtils.WantNotCurrentAndLast(joyBtStateCurrent.buttons, joyBtStateLast.buttons, 1 << bt);
}
bt = mappings[button];
return BitwiseUtils.WantNotCurrentAndLast(joyBtStateCurrent.buttons, joyBtStateLast.buttons, 1 << bt) || BitwiseUtils.WantNotCurrentAndLast(otherHalf.joyBtStateCurrent.buttons, otherHalf.joyBtStateLast.buttons, 1 << bt);
} }
public override float GetAxis(InputAxis axis) public override float GetAxis(InputAxis axis)
@ -354,7 +445,6 @@ namespace HeavenStudio.InputSystem
public override bool GetHatDirection(InputDirection direction) public override bool GetHatDirection(InputDirection direction)
{ {
//todo: check analogue stick hat direction too
int bt; int bt;
switch (direction) switch (direction)
{ {
@ -378,7 +468,6 @@ namespace HeavenStudio.InputSystem
public override bool GetHatDirectionDown(InputDirection direction) public override bool GetHatDirectionDown(InputDirection direction)
{ {
//todo: check analogue stick hat direction too
int bt; int bt;
switch (direction) switch (direction)
{ {
@ -402,7 +491,6 @@ namespace HeavenStudio.InputSystem
public override bool GetHatDirectionUp(InputDirection direction) public override bool GetHatDirectionUp(InputDirection direction)
{ {
//todo: check analogue stick hat direction too
int bt; int bt;
switch (direction) switch (direction)
{ {

View file

@ -1,3 +1,5 @@
using System;
using System.Linq;
using System.Collections; using System.Collections;
using System.Collections.Generic; using System.Collections.Generic;
using UnityEngine; using UnityEngine;
@ -10,6 +12,16 @@ namespace HeavenStudio.InputSystem.Loaders
{ {
[LoadOrder(0)] [LoadOrder(0)]
public static InputController[] Initialize() public static InputController[] Initialize()
{
PlayerInput.PlayerInputRefresh.Add(Refresh);
InputKeyboard keyboard = new InputKeyboard();
keyboard.SetPlayer(1);
keyboard.InitializeController();
return new InputController[] { keyboard };
}
public static InputController[] Refresh()
{ {
InputKeyboard keyboard = new InputKeyboard(); InputKeyboard keyboard = new InputKeyboard();
keyboard.SetPlayer(1); keyboard.SetPlayer(1);
@ -23,7 +35,10 @@ namespace HeavenStudio.InputSystem
{ {
public class InputKeyboard : InputController public class InputKeyboard : InputController
{ {
static KeyCode[] keyCodes = (KeyCode[]) System.Enum.GetValues(typeof(UnityEngine.KeyCode)); private static readonly KeyCode[] keyCodes = Enum.GetValues(typeof(KeyCode))
.Cast<KeyCode>()
.Where(k => ((int)k < (int)KeyCode.Mouse0))
.ToArray();
//FUTURE: remappable controls //FUTURE: remappable controls
//KeyCode[] mappings = new KeyCode[Enum.GetNames(typeof(ButtonsPad)).Length]; //KeyCode[] mappings = new KeyCode[Enum.GetNames(typeof(ButtonsPad)).Length];
@ -65,6 +80,16 @@ namespace HeavenStudio.InputSystem
return InputFeatures.Readable_StringInput | InputFeatures.Style_Pad | InputFeatures.Style_Baton; return InputFeatures.Readable_StringInput | InputFeatures.Style_Pad | InputFeatures.Style_Baton;
} }
public override bool GetIsConnected()
{
return true;
}
public override bool GetIsPoorConnection()
{
return false;
}
public override int GetLastButtonDown() public override int GetLastButtonDown()
{ {
return 0; return 0;
@ -72,9 +97,13 @@ namespace HeavenStudio.InputSystem
public override KeyCode GetLastKeyDown() public override KeyCode GetLastKeyDown()
{ {
for(KeyCode i = keyCodes[1]; i <= KeyCode.Menu; i++) { if (Input.anyKeyDown)
if (Input.GetKeyDown(i)) {
return i; for (KeyCode i = keyCodes[1]; i <= KeyCode.Menu; i++)
{
if (Input.GetKeyDown(i))
return i;
}
} }
return KeyCode.None; return KeyCode.None;
} }

View file

@ -120,10 +120,10 @@ namespace HeavenStudio.InputSystem
//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... BatonS = 0, //-- all these...
BatonE = 1, // | BatonE = 1, // |
BatonW = 2, // | BatonW = 2, // |
BatonN = 3, //-- BatonN = 3, //--
BatonFace = 4, // < ...map to this, but are directional BatonFace = 4, // < ...map to this, but are directional
BatonTrigger = 5, // should never be used alone BatonTrigger = 5, // should never be used alone
Baton1 = 6, Baton1 = 6,
@ -139,11 +139,14 @@ namespace HeavenStudio.InputSystem
TouchTap = 2, TouchTap = 2,
TouchFlick = 3, TouchFlick = 3,
TouchButtonL = 4, TouchButtonL = 4,
TouchButtonR = 4, TouchButtonR = 5,
} }
// 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?)
protected int currentInputFlags = 0;
protected int lastInputFlags = 0;
protected int? playerNum; protected int? playerNum;
protected int directionStateCurrent = 0; protected int directionStateCurrent = 0;
protected int directionStateLast = 0; protected int directionStateLast = 0;
@ -153,6 +156,8 @@ namespace HeavenStudio.InputSystem
public abstract string GetDeviceName(); // Get the name of the controller public abstract string GetDeviceName(); // Get the name of 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 GetIsPoorConnection();
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)

View file

@ -36,8 +36,12 @@ namespace HeavenStudio
public delegate void InputControllerDispose(); public delegate void InputControllerDispose();
public static event InputControllerDispose PlayerInputCleanUp; public static event InputControllerDispose PlayerInputCleanUp;
public delegate InputController[] InputControllerRefresh();
public static List<InputControllerRefresh> PlayerInputRefresh;
static List<InputControllerInitializer> loadRunners; static List<InputControllerInitializer> loadRunners;
static void BuildLoadRunnerList() { static void BuildLoadRunnerList() {
PlayerInputRefresh = new();
loadRunners = System.Reflection.Assembly.GetExecutingAssembly() loadRunners = System.Reflection.Assembly.GetExecutingAssembly()
.GetTypes() .GetTypes()
.Where(x => x.Namespace == "HeavenStudio.InputSystem.Loaders" && x.GetMethod("Initialize", BindingFlags.Public | BindingFlags.Static) != null) .Where(x => x.Namespace == "HeavenStudio.InputSystem.Loaders" && x.GetMethod("Initialize", BindingFlags.Public | BindingFlags.Static) != null)
@ -67,6 +71,20 @@ namespace HeavenStudio
return inputDevices.Count; return inputDevices.Count;
} }
public static int RefreshInputControllers()
{
inputDevices = new List<InputController>();
if (PlayerInputRefresh != null) {
foreach (InputControllerRefresh runner in PlayerInputRefresh) {
InputController[] controllers = runner();
if (controllers != null) {
inputDevices.AddRange(controllers);
}
}
}
return inputDevices.Count;
}
public static int GetNumControllersConnected() public static int GetNumControllersConnected()
{ {
return inputDevices.Count; return inputDevices.Count;

View file

@ -147,7 +147,7 @@ namespace HeavenStudio.Editor
public void SearchAndConnectControllers() public void SearchAndConnectControllers()
{ {
int connected = PlayerInput.InitInputControllers(); int connected = PlayerInput.RefreshInputControllers();
numConnectedLabel.text = "Connected: " + connected; numConnectedLabel.text = "Connected: " + connected;
currentControllerLabel.text = "Current Controller: " + PlayerInput.GetInputController(1).GetDeviceName(); currentControllerLabel.text = "Current Controller: " + PlayerInput.GetInputController(1).GetDeviceName();
PopulateControllersDropdown(); PopulateControllersDropdown();