Interhaptics SDK for Unity 1.6
Loading...
Searching...
No Matches
GameInputProvider.cs
Go to the documentation of this file.
1/* ​
2* Copyright © 2023 Go Touch VR SAS. All rights reserved. ​
3* ​
4*/
5
6#if (UNITY_EDITOR_WIN || UNITY_STANDALONE_WIN) && !ENABLE_METAQUEST && !ENABLE_OPENXR
7using System.Runtime.InteropServices;
8
9
11{
12
13 public sealed class GameInputProvider : IHapticProvider
14 {
15
16 #region HAPTIC CHARACTERISTICS FIELDS
17 private const string DISPLAY_NAME = "GameInput";
18 private const string DESCRIPTION = "Controller APIs communication layer for GameInput";
19 private const string MANUFACTURER = "Microsoft";
20 private const string VERSION = "1.0";
21 #endregion
22
23 #region HAPTIC CHARACTERISTICS GETTERS
24 [UnityEngine.Scripting.Preserve]
25 public string DisplayName()
26 {
27 return DISPLAY_NAME;
28 }
29
30 [UnityEngine.Scripting.Preserve]
31 public string Description()
32 {
33 return DESCRIPTION;
34 }
35
36 [UnityEngine.Scripting.Preserve]
37 public string Manufacturer()
38 {
39 return MANUFACTURER;
40 }
41
42 [UnityEngine.Scripting.Preserve]
43 public string Version()
44 {
45 return VERSION;
46 }
47 #endregion
48
49 #region PROVIDER LOOP
50 private static class GameInputProviderNative
51 {
52 const string DLL_NAME = "Interhaptics.GameInputProvider";
53
54 [DllImport(DLL_NAME)]
55 public static extern bool ProviderInit();
56 [DllImport(DLL_NAME)]
57 public static extern bool ProviderIsPresent();
58 [DllImport(DLL_NAME)]
59 public static extern bool ProviderClean();
60 [DllImport(DLL_NAME)]
61 public static extern void ProviderRenderHaptics();
62 [DllImport(DLL_NAME)]
63 public static extern bool IsGameInputSupported();
64 [DllImport(DLL_NAME)]
65 public static extern void SetTriggerMode(bool transcodeStiffness);
66 }
67
68 [UnityEngine.Scripting.Preserve]
69 public bool Init()
70 {
71 bool res = GameInputProviderNative.ProviderInit();
72
73 if ((res) && (HapticManager.DebugSwitch))
74 {
75 UnityEngine.Debug.Log("GameInput haptic provider started.");
76 }
77 return res;
78 }
79
80 [UnityEngine.Scripting.Preserve]
81 public bool IsPresent()
82 {
83 return GameInputProviderNative.ProviderIsPresent();
84 }
85
86 [UnityEngine.Scripting.Preserve]
87 public bool Clean()
88 {
89 return GameInputProviderNative.ProviderClean();
90 }
91
92 [UnityEngine.Scripting.Preserve]
93 public void RenderHaptics()
94 {
95 GameInputProviderNative.ProviderRenderHaptics();
96 }
97
98 [UnityEngine.Scripting.Preserve]
99 public bool IsGameInputSupported()
100 {
101 return GameInputProviderNative.IsGameInputSupported();
102 }
103
104 [UnityEngine.Scripting.Preserve]
105 public void SetTriggerMode(bool transcodeStiffness)
106 {
107 GameInputProviderNative.SetTriggerMode(transcodeStiffness);
108 }
109 #endregion
110
111 }
112
113}
114#endif