net.dreditor.input 0.1.6 → 0.1.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.attestation.p7m +0 -0
- package/AnyInputDetector.cs +131 -131
- package/AnyInputDetector.cs.meta +1 -1
- package/DREditor.Input.asmdef +17 -17
- package/DREditor.Input.asmdef.meta +7 -7
- package/IInputManager.cs +50 -50
- package/IInputManager.cs.meta +1 -1
- package/PlayerInputHandler.cs +306 -306
- package/PlayerInputHandler.cs.meta +11 -11
- package/{Samples → Samples~}/Player_Input_Handler.prefab +135 -135
- package/{Samples → Samples~}/Player_Input_Handler.prefab.meta +7 -7
- package/{Samples → Samples~}/Set_Scheme_From_Device.prefab +46 -46
- package/{Samples → Samples~}/Set_Scheme_From_Device.prefab.meta +7 -7
- package/SetSchemeFromDevice.cs +145 -145
- package/SetSchemeFromDevice.cs.meta +11 -11
- package/package.json +40 -35
- package/package.json.meta +7 -7
- package/Samples.meta +0 -8
package/.attestation.p7m
ADDED
|
Binary file
|
package/AnyInputDetector.cs
CHANGED
|
@@ -1,132 +1,132 @@
|
|
|
1
|
-
//Author: Benjamin "Sweden" Jillson : Discord: sweden_gaming For Project Eden's Garden
|
|
2
|
-
using UnityEngine;
|
|
3
|
-
using UnityEngine.InputSystem;
|
|
4
|
-
using UnityEngine.InputSystem.Controls;
|
|
5
|
-
using UnityEngine.InputSystem.LowLevel;
|
|
6
|
-
|
|
7
|
-
namespace DREditor.Input
|
|
8
|
-
{
|
|
9
|
-
/// <summary>
|
|
10
|
-
///
|
|
11
|
-
/// </summary>
|
|
12
|
-
public abstract class AnyInputDetector : MonoBehaviour
|
|
13
|
-
{
|
|
14
|
-
/// <summary>
|
|
15
|
-
///
|
|
16
|
-
/// </summary>
|
|
17
|
-
protected InputEventPtr eventPtr;
|
|
18
|
-
|
|
19
|
-
/// <summary>
|
|
20
|
-
///
|
|
21
|
-
/// </summary>
|
|
22
|
-
protected InputDevice device;
|
|
23
|
-
|
|
24
|
-
/// <summary>
|
|
25
|
-
///
|
|
26
|
-
/// </summary>
|
|
27
|
-
protected ButtonControl currentControl;
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
/// <summary>
|
|
31
|
-
///
|
|
32
|
-
/// </summary>
|
|
33
|
-
/// <remarks></remarks>
|
|
34
|
-
public virtual void Subscribe() => InputSystem.onEvent += OnAnyInputNoticed;
|
|
35
|
-
|
|
36
|
-
/// <summary>
|
|
37
|
-
///
|
|
38
|
-
/// </summary>
|
|
39
|
-
/// <remarks></remarks>
|
|
40
|
-
public virtual void Unsubscribe() => InputSystem.onEvent -= OnAnyInputNoticed;
|
|
41
|
-
|
|
42
|
-
/// <summary>
|
|
43
|
-
///
|
|
44
|
-
/// </summary>
|
|
45
|
-
/// <param name="eventPtr"></param>
|
|
46
|
-
/// <param name="device"></param>
|
|
47
|
-
protected virtual void OnAnyInputNoticed(InputEventPtr eventPtr, InputDevice device)
|
|
48
|
-
{
|
|
49
|
-
InitializeInputData(eventPtr, device);
|
|
50
|
-
|
|
51
|
-
CheckNoticedKey();
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
/// <summary>
|
|
55
|
-
///
|
|
56
|
-
/// </summary>
|
|
57
|
-
/// <param name="eventPtr"></param>
|
|
58
|
-
/// <param name="device"></param>
|
|
59
|
-
protected virtual void InitializeInputData(InputEventPtr eventPtr, InputDevice device)
|
|
60
|
-
{
|
|
61
|
-
this.eventPtr = eventPtr;
|
|
62
|
-
|
|
63
|
-
this.device = device;
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
/// <summary>
|
|
67
|
-
///
|
|
68
|
-
/// </summary>
|
|
69
|
-
protected virtual void CheckNoticedKey()
|
|
70
|
-
{
|
|
71
|
-
if (ValidKeyNoticed())
|
|
72
|
-
OnInputsDetected();
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
/// <summary>
|
|
76
|
-
///
|
|
77
|
-
/// </summary>
|
|
78
|
-
/// <returns></returns>
|
|
79
|
-
protected virtual bool ValidKeyNoticed() => eventPtr.IsA<StateEvent>() || eventPtr.IsA<DeltaStateEvent>();
|
|
80
|
-
|
|
81
|
-
/// <summary>
|
|
82
|
-
///
|
|
83
|
-
/// </summary>
|
|
84
|
-
protected virtual void OnInputsDetected()
|
|
85
|
-
{
|
|
86
|
-
for (var i = 0; i < device.allControls.Count; ++i)
|
|
87
|
-
if (AssignCurrentControlInvalid(device.allControls[i], out currentControl))
|
|
88
|
-
continue;
|
|
89
|
-
else if (FoundValidInput())
|
|
90
|
-
break;
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
/// <summary>
|
|
94
|
-
///
|
|
95
|
-
/// </summary>
|
|
96
|
-
/// <returns></returns>
|
|
97
|
-
protected virtual bool FoundValidInput()
|
|
98
|
-
{
|
|
99
|
-
bool result = CurrentControlIsValid();
|
|
100
|
-
|
|
101
|
-
if (result)
|
|
102
|
-
OnValidInputFound();
|
|
103
|
-
|
|
104
|
-
return result;
|
|
105
|
-
}
|
|
106
|
-
|
|
107
|
-
/// <summary>
|
|
108
|
-
///
|
|
109
|
-
/// </summary>
|
|
110
|
-
/// <returns></returns>
|
|
111
|
-
protected virtual bool CurrentControlIsValid() =>
|
|
112
|
-
currentControl.ReadValueFromEvent(eventPtr, out var value) && value >= 1;
|
|
113
|
-
|
|
114
|
-
/// <summary>
|
|
115
|
-
///
|
|
116
|
-
/// </summary>
|
|
117
|
-
protected abstract void OnValidInputFound();
|
|
118
|
-
|
|
119
|
-
/// <summary>
|
|
120
|
-
///
|
|
121
|
-
/// </summary>
|
|
122
|
-
/// <param name="control"></param>
|
|
123
|
-
/// <param name="buttonControl"></param>
|
|
124
|
-
/// <returns></returns>
|
|
125
|
-
protected virtual bool AssignCurrentControlInvalid(InputControl control, out ButtonControl buttonControl)
|
|
126
|
-
{
|
|
127
|
-
buttonControl = control as ButtonControl;
|
|
128
|
-
|
|
129
|
-
return buttonControl == null || buttonControl.synthetic || buttonControl.noisy;
|
|
130
|
-
}
|
|
131
|
-
}
|
|
1
|
+
//Author: Benjamin "Sweden" Jillson : Discord: sweden_gaming For Project Eden's Garden
|
|
2
|
+
using UnityEngine;
|
|
3
|
+
using UnityEngine.InputSystem;
|
|
4
|
+
using UnityEngine.InputSystem.Controls;
|
|
5
|
+
using UnityEngine.InputSystem.LowLevel;
|
|
6
|
+
|
|
7
|
+
namespace DREditor.Input
|
|
8
|
+
{
|
|
9
|
+
/// <summary>
|
|
10
|
+
///
|
|
11
|
+
/// </summary>
|
|
12
|
+
public abstract class AnyInputDetector : MonoBehaviour
|
|
13
|
+
{
|
|
14
|
+
/// <summary>
|
|
15
|
+
///
|
|
16
|
+
/// </summary>
|
|
17
|
+
protected InputEventPtr eventPtr;
|
|
18
|
+
|
|
19
|
+
/// <summary>
|
|
20
|
+
///
|
|
21
|
+
/// </summary>
|
|
22
|
+
protected InputDevice device;
|
|
23
|
+
|
|
24
|
+
/// <summary>
|
|
25
|
+
///
|
|
26
|
+
/// </summary>
|
|
27
|
+
protected ButtonControl currentControl;
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
/// <summary>
|
|
31
|
+
///
|
|
32
|
+
/// </summary>
|
|
33
|
+
/// <remarks></remarks>
|
|
34
|
+
public virtual void Subscribe() => InputSystem.onEvent += OnAnyInputNoticed;
|
|
35
|
+
|
|
36
|
+
/// <summary>
|
|
37
|
+
///
|
|
38
|
+
/// </summary>
|
|
39
|
+
/// <remarks></remarks>
|
|
40
|
+
public virtual void Unsubscribe() => InputSystem.onEvent -= OnAnyInputNoticed;
|
|
41
|
+
|
|
42
|
+
/// <summary>
|
|
43
|
+
///
|
|
44
|
+
/// </summary>
|
|
45
|
+
/// <param name="eventPtr"></param>
|
|
46
|
+
/// <param name="device"></param>
|
|
47
|
+
protected virtual void OnAnyInputNoticed(InputEventPtr eventPtr, InputDevice device)
|
|
48
|
+
{
|
|
49
|
+
InitializeInputData(eventPtr, device);
|
|
50
|
+
|
|
51
|
+
CheckNoticedKey();
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
/// <summary>
|
|
55
|
+
///
|
|
56
|
+
/// </summary>
|
|
57
|
+
/// <param name="eventPtr"></param>
|
|
58
|
+
/// <param name="device"></param>
|
|
59
|
+
protected virtual void InitializeInputData(InputEventPtr eventPtr, InputDevice device)
|
|
60
|
+
{
|
|
61
|
+
this.eventPtr = eventPtr;
|
|
62
|
+
|
|
63
|
+
this.device = device;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
/// <summary>
|
|
67
|
+
///
|
|
68
|
+
/// </summary>
|
|
69
|
+
protected virtual void CheckNoticedKey()
|
|
70
|
+
{
|
|
71
|
+
if (ValidKeyNoticed())
|
|
72
|
+
OnInputsDetected();
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
/// <summary>
|
|
76
|
+
///
|
|
77
|
+
/// </summary>
|
|
78
|
+
/// <returns></returns>
|
|
79
|
+
protected virtual bool ValidKeyNoticed() => eventPtr.IsA<StateEvent>() || eventPtr.IsA<DeltaStateEvent>();
|
|
80
|
+
|
|
81
|
+
/// <summary>
|
|
82
|
+
///
|
|
83
|
+
/// </summary>
|
|
84
|
+
protected virtual void OnInputsDetected()
|
|
85
|
+
{
|
|
86
|
+
for (var i = 0; i < device.allControls.Count; ++i)
|
|
87
|
+
if (AssignCurrentControlInvalid(device.allControls[i], out currentControl))
|
|
88
|
+
continue;
|
|
89
|
+
else if (FoundValidInput())
|
|
90
|
+
break;
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
/// <summary>
|
|
94
|
+
///
|
|
95
|
+
/// </summary>
|
|
96
|
+
/// <returns></returns>
|
|
97
|
+
protected virtual bool FoundValidInput()
|
|
98
|
+
{
|
|
99
|
+
bool result = CurrentControlIsValid();
|
|
100
|
+
|
|
101
|
+
if (result)
|
|
102
|
+
OnValidInputFound();
|
|
103
|
+
|
|
104
|
+
return result;
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
/// <summary>
|
|
108
|
+
///
|
|
109
|
+
/// </summary>
|
|
110
|
+
/// <returns></returns>
|
|
111
|
+
protected virtual bool CurrentControlIsValid() =>
|
|
112
|
+
currentControl.ReadValueFromEvent(eventPtr, out var value) && value >= 1;
|
|
113
|
+
|
|
114
|
+
/// <summary>
|
|
115
|
+
///
|
|
116
|
+
/// </summary>
|
|
117
|
+
protected abstract void OnValidInputFound();
|
|
118
|
+
|
|
119
|
+
/// <summary>
|
|
120
|
+
///
|
|
121
|
+
/// </summary>
|
|
122
|
+
/// <param name="control"></param>
|
|
123
|
+
/// <param name="buttonControl"></param>
|
|
124
|
+
/// <returns></returns>
|
|
125
|
+
protected virtual bool AssignCurrentControlInvalid(InputControl control, out ButtonControl buttonControl)
|
|
126
|
+
{
|
|
127
|
+
buttonControl = control as ButtonControl;
|
|
128
|
+
|
|
129
|
+
return buttonControl == null || buttonControl.synthetic || buttonControl.noisy;
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
132
|
}
|
package/AnyInputDetector.cs.meta
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
fileFormatVersion: 2
|
|
1
|
+
fileFormatVersion: 2
|
|
2
2
|
guid: 095649847ce37e640bf687aeef6da1a2
|
package/DREditor.Input.asmdef
CHANGED
|
@@ -1,18 +1,18 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "DREditor.Input",
|
|
3
|
-
"rootNamespace": "",
|
|
4
|
-
"references": [
|
|
5
|
-
"Unity.InputSystem",
|
|
6
|
-
"DREditor",
|
|
7
|
-
"DREditor.Controls"
|
|
8
|
-
],
|
|
9
|
-
"includePlatforms": [],
|
|
10
|
-
"excludePlatforms": [],
|
|
11
|
-
"allowUnsafeCode": false,
|
|
12
|
-
"overrideReferences": false,
|
|
13
|
-
"precompiledReferences": [],
|
|
14
|
-
"autoReferenced": true,
|
|
15
|
-
"defineConstraints": [],
|
|
16
|
-
"versionDefines": [],
|
|
17
|
-
"noEngineReferences": false
|
|
1
|
+
{
|
|
2
|
+
"name": "DREditor.Input",
|
|
3
|
+
"rootNamespace": "",
|
|
4
|
+
"references": [
|
|
5
|
+
"Unity.InputSystem",
|
|
6
|
+
"DREditor",
|
|
7
|
+
"DREditor.Controls"
|
|
8
|
+
],
|
|
9
|
+
"includePlatforms": [],
|
|
10
|
+
"excludePlatforms": [],
|
|
11
|
+
"allowUnsafeCode": false,
|
|
12
|
+
"overrideReferences": false,
|
|
13
|
+
"precompiledReferences": [],
|
|
14
|
+
"autoReferenced": true,
|
|
15
|
+
"defineConstraints": [],
|
|
16
|
+
"versionDefines": [],
|
|
17
|
+
"noEngineReferences": false
|
|
18
18
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
fileFormatVersion: 2
|
|
2
|
-
guid: 2657ea440406c0d4bbf2ba2aeee1b63d
|
|
3
|
-
AssemblyDefinitionImporter:
|
|
4
|
-
externalObjects: {}
|
|
5
|
-
userData:
|
|
6
|
-
assetBundleName:
|
|
7
|
-
assetBundleVariant:
|
|
1
|
+
fileFormatVersion: 2
|
|
2
|
+
guid: 2657ea440406c0d4bbf2ba2aeee1b63d
|
|
3
|
+
AssemblyDefinitionImporter:
|
|
4
|
+
externalObjects: {}
|
|
5
|
+
userData:
|
|
6
|
+
assetBundleName:
|
|
7
|
+
assetBundleVariant:
|
package/IInputManager.cs
CHANGED
|
@@ -1,51 +1,51 @@
|
|
|
1
|
-
//Author: Benjamin "Sweden" Jillson : Discord: sweden_gaming For Project Eden's Garden
|
|
2
|
-
using UnityEngine.InputSystem;
|
|
3
|
-
|
|
4
|
-
namespace DREditor.Input
|
|
5
|
-
{
|
|
6
|
-
/// <summary>
|
|
7
|
-
///
|
|
8
|
-
/// </summary>
|
|
9
|
-
public interface IInputManager
|
|
10
|
-
{
|
|
11
|
-
/// <summary>
|
|
12
|
-
///
|
|
13
|
-
/// </summary>
|
|
14
|
-
void Enable();
|
|
15
|
-
|
|
16
|
-
/// <summary>
|
|
17
|
-
///
|
|
18
|
-
/// </summary>
|
|
19
|
-
void Disable();
|
|
20
|
-
|
|
21
|
-
/// <summary>
|
|
22
|
-
///
|
|
23
|
-
/// </summary>
|
|
24
|
-
/// <returns></returns>
|
|
25
|
-
bool UsingGamepadScheme();
|
|
26
|
-
|
|
27
|
-
/// <summary>
|
|
28
|
-
///
|
|
29
|
-
/// </summary>
|
|
30
|
-
/// <param name="device"></param>
|
|
31
|
-
void SetSchemeByDevice(InputDevice device);
|
|
32
|
-
|
|
33
|
-
/// <summary>
|
|
34
|
-
///
|
|
35
|
-
/// </summary>
|
|
36
|
-
/// <returns></returns>
|
|
37
|
-
string GetCurrentScheme();
|
|
38
|
-
|
|
39
|
-
/// <summary>
|
|
40
|
-
///
|
|
41
|
-
/// </summary>
|
|
42
|
-
/// <returns></returns>
|
|
43
|
-
InputAction GetLeave();
|
|
44
|
-
|
|
45
|
-
/// <summary>
|
|
46
|
-
///
|
|
47
|
-
/// </summary>
|
|
48
|
-
/// <returns></returns>
|
|
49
|
-
InputAction GetCancel();
|
|
50
|
-
}
|
|
1
|
+
//Author: Benjamin "Sweden" Jillson : Discord: sweden_gaming For Project Eden's Garden
|
|
2
|
+
using UnityEngine.InputSystem;
|
|
3
|
+
|
|
4
|
+
namespace DREditor.Input
|
|
5
|
+
{
|
|
6
|
+
/// <summary>
|
|
7
|
+
///
|
|
8
|
+
/// </summary>
|
|
9
|
+
public interface IInputManager
|
|
10
|
+
{
|
|
11
|
+
/// <summary>
|
|
12
|
+
///
|
|
13
|
+
/// </summary>
|
|
14
|
+
void Enable();
|
|
15
|
+
|
|
16
|
+
/// <summary>
|
|
17
|
+
///
|
|
18
|
+
/// </summary>
|
|
19
|
+
void Disable();
|
|
20
|
+
|
|
21
|
+
/// <summary>
|
|
22
|
+
///
|
|
23
|
+
/// </summary>
|
|
24
|
+
/// <returns></returns>
|
|
25
|
+
bool UsingGamepadScheme();
|
|
26
|
+
|
|
27
|
+
/// <summary>
|
|
28
|
+
///
|
|
29
|
+
/// </summary>
|
|
30
|
+
/// <param name="device"></param>
|
|
31
|
+
void SetSchemeByDevice(InputDevice device);
|
|
32
|
+
|
|
33
|
+
/// <summary>
|
|
34
|
+
///
|
|
35
|
+
/// </summary>
|
|
36
|
+
/// <returns></returns>
|
|
37
|
+
string GetCurrentScheme();
|
|
38
|
+
|
|
39
|
+
/// <summary>
|
|
40
|
+
///
|
|
41
|
+
/// </summary>
|
|
42
|
+
/// <returns></returns>
|
|
43
|
+
InputAction GetLeave();
|
|
44
|
+
|
|
45
|
+
/// <summary>
|
|
46
|
+
///
|
|
47
|
+
/// </summary>
|
|
48
|
+
/// <returns></returns>
|
|
49
|
+
InputAction GetCancel();
|
|
50
|
+
}
|
|
51
51
|
}
|
package/IInputManager.cs.meta
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
fileFormatVersion: 2
|
|
1
|
+
fileFormatVersion: 2
|
|
2
2
|
guid: 1bd30416c18777844ba4f4a33a345e8e
|