XRInputManager.cs 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472
  1. using NRKernal;
  2. using SC.XR.Unity.Module_InputSystem;
  3. using System;
  4. using System.Collections;
  5. using System.Collections.Generic;
  6. using UnityEngine;
  7. using UnityEngine.InputSystem;
  8. using UnityEngine.XR;
  9. using UnityEngine.XR.OpenXR.Input;
  10. public class XRInputManager : MonoBehaviour
  11. {
  12. public static bool isCheckHand;
  13. public static bool leftDown;
  14. public static bool rightDown;
  15. public Transform left = null;
  16. public Transform right = null;
  17. public InputActionProperty inputEvent;
  18. public List<InputActionReference> listinput;
  19. int xy = 8;
  20. private void Awake()
  21. {
  22. if(isHand)
  23. {
  24. handinput.SetActive(true);
  25. cinput.SetActive(false);
  26. }else
  27. {
  28. handinput.SetActive(false);
  29. cinput.SetActive(true);
  30. }
  31. isCheckHand = isHand;
  32. }
  33. // Start is called before the first frame update
  34. void Start()
  35. {
  36. // API_GSXR_Module_InputSystem_GGT26Dof.GSXR_GGTLeft.inputDataGGT26Dof.inputKeys.InputDataAddKey(InputKeyCode.Enter, InputKeyState.DOWN);
  37. /*
  38. NRInput.AddDownListener(ControllerHandEnum.Right, ControllerButton.APP, () => {
  39. Debug.Log("ControllerButton.APP===>Down");
  40. API_GSXR_Module_InputSystem_KS.GSXR_KSRight.inputDataKS.inputKeys.InputDataAddKey(InputKeyCode.Enter, InputKeyState.DOWN);
  41. API_GSXR_Module_InputSystem_GGT26Dof.GSXR_GGTRight.inputDataGGT26Dof.inputKeys.InputDataAddKey(InputKeyCode.Enter, InputKeyState.DOWN);
  42. });
  43. NRInput.AddDownListener(ControllerHandEnum.Right, ControllerButton.BEGIN, () => {
  44. Debug.Log("ControllerButton.BEGIN===>Down");
  45. API_GSXR_Module_InputSystem_KS.GSXR_KSRight.inputDataKS.inputKeys.InputDataAddKey(InputKeyCode.Enter, InputKeyState.DOWN);
  46. API_GSXR_Module_InputSystem_GGT26Dof.GSXR_GGTRight.inputDataGGT26Dof.inputKeys.InputDataAddKey(InputKeyCode.Enter, InputKeyState.DOWN);
  47. });
  48. NRInput.AddDownListener(ControllerHandEnum.Right, ControllerButton.END, () => {
  49. Debug.Log("ControllerButton.END===>Down");
  50. API_GSXR_Module_InputSystem_KS.GSXR_KSRight.inputDataKS.inputKeys.InputDataAddKey(InputKeyCode.Enter, InputKeyState.DOWN);
  51. API_GSXR_Module_InputSystem_GGT26Dof.GSXR_GGTRight.inputDataGGT26Dof.inputKeys.InputDataAddKey(InputKeyCode.Enter, InputKeyState.DOWN);
  52. });
  53. NRInput.AddDownListener(ControllerHandEnum.Right, ControllerButton.GRIP, () => {
  54. Debug.Log("ControllerButton.GRIP===>Down");
  55. API_GSXR_Module_InputSystem_KS.GSXR_KSRight.inputDataKS.inputKeys.InputDataAddKey(InputKeyCode.Enter, InputKeyState.DOWN);
  56. API_GSXR_Module_InputSystem_GGT26Dof.GSXR_GGTRight.inputDataGGT26Dof.inputKeys.InputDataAddKey(InputKeyCode.Enter, InputKeyState.DOWN);
  57. });
  58. NRInput.AddDownListener(ControllerHandEnum.Right, ControllerButton.HOME, () => {
  59. Debug.Log("ControllerButton.HOME===>Down");
  60. API_GSXR_Module_InputSystem_KS.GSXR_KSRight.inputDataKS.inputKeys.InputDataAddKey(InputKeyCode.Enter, InputKeyState.DOWN);
  61. API_GSXR_Module_InputSystem_GGT26Dof.GSXR_GGTRight.inputDataGGT26Dof.inputKeys.InputDataAddKey(InputKeyCode.Enter, InputKeyState.DOWN);
  62. });*/
  63. NRInput.AddDownListener(ControllerHandEnum.Right, ControllerButton.TRIGGER, () => {
  64. Debug.Log("ControllerButton.TRIGGER===>Down");
  65. if (isHand)
  66. {
  67. // API_GSXR_Module_InputSystem_KS.GSXR_KSRight.inputDataKS.inputKeys.InputDataAddKey(InputKeyCode.Enter, InputKeyState.DOWN);
  68. rightDown = true;
  69. API_GSXR_Module_InputSystem_GGT26Dof.GSXR_GGTRight.inputDataGGT26Dof.inputKeys.InputDataAddKey(InputKeyCode.Enter, InputKeyState.DOWN);
  70. }
  71. else
  72. {
  73. API_GSXR_Module_InputSystem_KS.GSXR_KSRight.inputDataKS.inputKeys.InputDataAddKey(InputKeyCode.Enter, InputKeyState.DOWN);
  74. }
  75. });
  76. /*
  77. NRInput.AddDownListener(ControllerHandEnum.Right, ControllerButton.TOUCHPAD_BUTTON, () => {
  78. Debug.Log("ControllerButton.TOUCHPAD_BUTTON===>Down");
  79. API_GSXR_Module_InputSystem_KS.GSXR_KSRight.inputDataKS.inputKeys.InputDataAddKey(InputKeyCode.Enter, InputKeyState.DOWN);
  80. API_GSXR_Module_InputSystem_GGT26Dof.GSXR_GGTRight.inputDataGGT26Dof.inputKeys.InputDataAddKey(InputKeyCode.Enter, InputKeyState.DOWN);
  81. });
  82. NRInput.AddUpListener(ControllerHandEnum.Right, ControllerButton.APP, () => {
  83. Debug.Log("ControllerButton.APP===>UP");
  84. API_GSXR_Module_InputSystem_GGT26Dof.GSXR_GGTRight.inputDataGGT26Dof.inputKeys.InputDataAddKey(InputKeyCode.Enter, InputKeyState.UP);
  85. API_GSXR_Module_InputSystem_KS.GSXR_KSRight.inputDataKS.inputKeys.InputDataAddKey(InputKeyCode.Enter, InputKeyState.UP);
  86. });
  87. NRInput.AddUpListener(ControllerHandEnum.Right, ControllerButton.BEGIN, () => {
  88. Debug.Log("ControllerButton.BEGIN===>UP");
  89. API_GSXR_Module_InputSystem_GGT26Dof.GSXR_GGTRight.inputDataGGT26Dof.inputKeys.InputDataAddKey(InputKeyCode.Enter, InputKeyState.UP);
  90. API_GSXR_Module_InputSystem_KS.GSXR_KSRight.inputDataKS.inputKeys.InputDataAddKey(InputKeyCode.Enter, InputKeyState.UP);
  91. });
  92. NRInput.AddUpListener(ControllerHandEnum.Right, ControllerButton.END, () => {
  93. Debug.Log("ControllerButton.END===>UP");
  94. API_GSXR_Module_InputSystem_GGT26Dof.GSXR_GGTRight.inputDataGGT26Dof.inputKeys.InputDataAddKey(InputKeyCode.Enter, InputKeyState.UP);
  95. API_GSXR_Module_InputSystem_KS.GSXR_KSRight.inputDataKS.inputKeys.InputDataAddKey(InputKeyCode.Enter, InputKeyState.UP);
  96. });
  97. NRInput.AddUpListener(ControllerHandEnum.Right, ControllerButton.GRIP, () => {
  98. Debug.Log("ControllerButton.GRIP===>UP");
  99. API_GSXR_Module_InputSystem_GGT26Dof.GSXR_GGTRight.inputDataGGT26Dof.inputKeys.InputDataAddKey(InputKeyCode.Enter, InputKeyState.UP);
  100. API_GSXR_Module_InputSystem_KS.GSXR_KSRight.inputDataKS.inputKeys.InputDataAddKey(InputKeyCode.Enter, InputKeyState.UP);
  101. });
  102. NRInput.AddUpListener(ControllerHandEnum.Right, ControllerButton.HOME, () => {
  103. Debug.Log("ControllerButton.HOME===>UP");
  104. API_GSXR_Module_InputSystem_GGT26Dof.GSXR_GGTRight.inputDataGGT26Dof.inputKeys.InputDataAddKey(InputKeyCode.Enter, InputKeyState.UP);
  105. API_GSXR_Module_InputSystem_KS.GSXR_KSRight.inputDataKS.inputKeys.InputDataAddKey(InputKeyCode.Enter, InputKeyState.UP);
  106. });*/
  107. NRInput.AddUpListener(ControllerHandEnum.Right, ControllerButton.TRIGGER, () => {
  108. Debug.Log("ControllerButton.HOME===>TRIGGER");
  109. if (isHand)
  110. {
  111. rightDown = false;
  112. API_GSXR_Module_InputSystem_GGT26Dof.GSXR_GGTRight.inputDataGGT26Dof.inputKeys.InputDataAddKey(InputKeyCode.Enter, InputKeyState.UP);
  113. // API_GSXR_Module_InputSystem_KS.GSXR_KSRight.inputDataKS.inputKeys.InputDataAddKey(InputKeyCode.Enter, InputKeyState.UP);
  114. }else
  115. {
  116. API_GSXR_Module_InputSystem_KS.GSXR_KSRight.inputDataKS.inputKeys.InputDataAddKey(InputKeyCode.Enter, InputKeyState.UP);
  117. }
  118. });/*
  119. NRInput.AddUpListener(ControllerHandEnum.Right, ControllerButton.TOUCHPAD_BUTTON, () => {
  120. Debug.Log("ControllerButton.HOME===>TOUCHPAD_BUTTON");
  121. API_GSXR_Module_InputSystem_GGT26Dof.GSXR_GGTRight.inputDataGGT26Dof.inputKeys.InputDataAddKey(InputKeyCode.Enter, InputKeyState.UP);
  122. API_GSXR_Module_InputSystem_KS.GSXR_KSRight.inputDataKS.inputKeys.InputDataAddKey(InputKeyCode.Enter, InputKeyState.UP);
  123. });
  124. */
  125. NRInput.AddDownListener(ControllerHandEnum.Left, ControllerButton.TRIGGER, () => {
  126. Debug.Log("ControllerButton.HOME===>TRIGGER");
  127. if (isHand)
  128. {
  129. leftDown = false;
  130. API_GSXR_Module_InputSystem_GGT26Dof.GSXR_GGTLeft.inputDataGGT26Dof.inputKeys.InputDataAddKey(InputKeyCode.Enter, InputKeyState.DOWN);
  131. }
  132. });
  133. NRInput.AddUpListener(ControllerHandEnum.Left, ControllerButton.TRIGGER, () => {
  134. Debug.Log("ControllerButton.HOME===>TRIGGER");
  135. if (isHand)
  136. {
  137. leftDown = false;
  138. API_GSXR_Module_InputSystem_GGT26Dof.GSXR_GGTLeft.inputDataGGT26Dof.inputKeys.InputDataAddKey(InputKeyCode.Enter, InputKeyState.UP);
  139. // API_GSXR_Module_InputSystem_KS.GSXR_KSRight.inputDataKS.inputKeys.InputDataAddKey(InputKeyCode.Enter, InputKeyState.UP);
  140. }
  141. });
  142. Invoke("startXR", 1f);
  143. /*
  144. return;
  145. for (int i = 0; i < 15; i++)
  146. {
  147. listinput[i].action.Enable();
  148. listinput[i].action.performed += OnEventL;
  149. listinput[i].action.canceled += OnCanceledEventL;
  150. }
  151. for (int i = 15; i < listinput.Count; i++)
  152. {
  153. listinput[i].action.Enable();
  154. listinput[i].action.performed += OnEventR;
  155. listinput[i].action.canceled += OnCanceledEventR;
  156. }
  157. InputDevices.deviceConnected += onDeviceConnected;
  158. InputDevices.deviceDisconnected += onDeviceDisConnected;
  159. Invoke("startXR", 1f);*/
  160. }
  161. private void downTP()
  162. {
  163. }
  164. public GameObject handinput;
  165. public GameObject cinput;
  166. public bool isHand;
  167. List<Vector3> leftInfo = new List<Vector3>();
  168. List<Vector3> rightInfo = new List<Vector3>();
  169. void startXR()
  170. {
  171. if(isHand)
  172. {
  173. Module_InputSystem.instance.SetActiveInputDevice(InputDeviceType.KS, false);
  174. Module_InputSystem.instance.SetActiveInputDevice(InputDeviceType.Head, false);
  175. Module_InputSystem.instance.SetActiveInputDevice(InputDeviceType.GGT26Dof, true);
  176. }else
  177. {
  178. Module_InputSystem.instance.SetActiveInputDevice(InputDeviceType.KS, true);
  179. Module_InputSystem.instance.SetActiveInputDevice(InputDeviceType.Head, false);
  180. Module_InputSystem.instance.SetActiveInputDevice(InputDeviceType.GGT26Dof, false);
  181. }
  182. /*
  183. left.gameObject.SetActive(false);
  184. right.gameObject.SetActive(false);
  185. List<UnityEngine.XR.InputDevice> inputDevices = new List<UnityEngine.XR.InputDevice>();
  186. InputDevices.GetDevices(inputDevices);
  187. for (int i = 0; i < inputDevices.Count; i++)
  188. {
  189. onDeviceConnected(inputDevices[i]);
  190. }*/
  191. }
  192. private void Update()
  193. {
  194. if (Input.GetKeyDown(KeyCode.X))
  195. {
  196. API_GSXR_Module_InputSystem_GGT26Dof.GSXR_GGTRight.inputDataGGT26Dof.inputKeys.InputDataAddKey(InputKeyCode.Enter, InputKeyState.DOWN);
  197. //API_GSXR_Module_InputSystem_KS.GSXR_KSLeft.inputDataKS.inputKeys.InputDataAddKey(InputKeyCode.X, InputKeyState.DOWN);
  198. }
  199. if (Input.GetKeyUp(KeyCode.X))
  200. {
  201. API_GSXR_Module_InputSystem_GGT26Dof.GSXR_GGTRight.inputDataGGT26Dof.inputKeys.InputDataAddKey(InputKeyCode.Enter, InputKeyState.UP);
  202. // API_GSXR_Module_InputSystem_KS.GSXR_KSLeft.inputDataKS.inputKeys.InputDataAddKey(InputKeyCode.X, InputKeyState.UP);
  203. }
  204. }
  205. private void onDeviceDisConnected(UnityEngine.XR.InputDevice obj)
  206. {
  207. if (obj.characteristics.ToString().Contains(InputDeviceCharacteristics.Left.ToString()))
  208. {
  209. Debug.Log("Left===>" + obj.isValid);
  210. left.gameObject.SetActive(obj.isValid);
  211. }
  212. if (obj.characteristics.ToString().Contains(InputDeviceCharacteristics.Right.ToString()))
  213. {
  214. Debug.Log("Right===>" + obj.isValid);
  215. right.gameObject.SetActive(obj.isValid);
  216. }
  217. }
  218. private void OnApplicationPause(bool pause)
  219. {
  220. if (!pause)
  221. {
  222. List<UnityEngine.XR.InputDevice> inputDevices = new List<UnityEngine.XR.InputDevice>();
  223. InputDevices.GetDevices(inputDevices);
  224. for (int i = 0; i < inputDevices.Count; i++)
  225. {
  226. onDeviceConnected(inputDevices[i]);
  227. }
  228. }
  229. }
  230. private void onDeviceConnected(UnityEngine.XR.InputDevice obj)
  231. {
  232. if (obj.characteristics.ToString().Contains(InputDeviceCharacteristics.Left.ToString()))
  233. {
  234. Debug.Log("Left===>" + obj.isValid);
  235. left.gameObject.SetActive(obj.isValid);
  236. }
  237. if (obj.characteristics.ToString().Contains(InputDeviceCharacteristics.Right.ToString()))
  238. {
  239. Debug.Log("Right===>" + obj.isValid);
  240. right.gameObject.SetActive(obj.isValid);
  241. }
  242. }
  243. private void OnCanceledEventL(InputAction.CallbackContext context)
  244. {
  245. Debug.Log("OnCanceledEventL" + context.control.name);
  246. switch (context.control.name)
  247. {
  248. case "secondarytouched":
  249. break;
  250. case "secondarybutton":
  251. API_GSXR_Module_InputSystem_KS.GSXR_KSLeft.inputDataKS.inputKeys.InputDataAddKey(InputKeyCode.Y, InputKeyState.UP);
  252. break;
  253. case "primarytouched":
  254. break;
  255. case "primarybutton":
  256. Debug.Log("InputKeyCode.A===¡·UP");
  257. API_GSXR_Module_InputSystem_KS.GSXR_KSLeft.inputDataKS.inputKeys.InputDataAddKey(InputKeyCode.X, InputKeyState.UP);
  258. API_GSXR_Module_InputSystem_KS.GSXR_KSLeft.inputDataKS.inputKeys.InputDataAddKey(InputKeyCode.Enter, InputKeyState.UP);
  259. break;
  260. case "touchpadtouched":
  261. break;
  262. case "thumbstickclicked":
  263. break;
  264. case "thumbstick":
  265. API_GSXR_Module_InputSystem_KS.GSXR_KSLeft.inputDataKS.JoystickX = xy + (int)(context.ReadValue<Vector2>().x * 10);
  266. API_GSXR_Module_InputSystem_KS.GSXR_KSLeft.inputDataKS.JoystickY = xy + (int)(context.ReadValue<Vector2>().y * 10);
  267. break;
  268. case "grip":
  269. API_GSXR_Module_InputSystem_KS.GSXR_KSLeft.inputDataKS.HallInside = 10 - (int)((context.ReadValue<float>()) * 10f);
  270. break;
  271. case "grippressed":
  272. API_GSXR_Module_InputSystem_KS.GSXR_KSLeft.inputDataKS.inputKeys.InputDataAddKey(InputKeyCode.LHallInside, InputKeyState.UP);
  273. break;
  274. case "trigger":
  275. API_GSXR_Module_InputSystem_KS.GSXR_KSLeft.inputDataKS.HallFoward = 10 - (int)((context.ReadValue<float>()) * 10f);
  276. break;
  277. case "menu":
  278. Module_InputSystem.instance.SetActiveInputDevice(InputDeviceType.KS, true);
  279. Module_InputSystem.instance.SetActiveInputDevice(InputDeviceType.Head, false);
  280. API_GSXR_Module_InputSystem_KS.GSXR_KSLeft.inputDataKS.inputKeys.InputDataAddKey(InputKeyCode.LFunction, InputKeyState.UP);
  281. break;
  282. }
  283. }
  284. void OnEventL(InputAction.CallbackContext context)
  285. {
  286. Debug.Log("OnEventL" + context.control.name);
  287. switch (context.control.name)
  288. {
  289. case "secondarytouched":
  290. break;
  291. case "secondarybutton":
  292. API_GSXR_Module_InputSystem_KS.GSXR_KSLeft.inputDataKS.inputKeys.InputDataAddKey(InputKeyCode.Y, InputKeyState.DOWN);
  293. break;
  294. case "primarytouched":
  295. break;
  296. case "primarybutton":
  297. Debug.Log("InputKeyCode.A===¡·DOWN");
  298. API_GSXR_Module_InputSystem_KS.GSXR_KSLeft.inputDataKS.inputKeys.InputDataAddKey(InputKeyCode.X, InputKeyState.DOWN);
  299. API_GSXR_Module_InputSystem_KS.GSXR_KSLeft.inputDataKS.inputKeys.InputDataAddKey(InputKeyCode.Enter, InputKeyState.DOWN);
  300. break;
  301. case "touchpadtouched":
  302. break;
  303. case "thumbstickclicked":
  304. break;
  305. case "thumbstick":
  306. API_GSXR_Module_InputSystem_KS.GSXR_KSLeft.inputDataKS.JoystickX = xy + (int)(context.ReadValue<Vector2>().x * 10);
  307. API_GSXR_Module_InputSystem_KS.GSXR_KSLeft.inputDataKS.JoystickY = xy + (int)(context.ReadValue<Vector2>().y * 10);
  308. break;
  309. case "grip":
  310. API_GSXR_Module_InputSystem_KS.GSXR_KSLeft.inputDataKS.HallInside = 10 - (int)((context.ReadValue<float>()) * 10f);
  311. break;
  312. case "grippressed":
  313. API_GSXR_Module_InputSystem_KS.GSXR_KSLeft.inputDataKS.inputKeys.InputDataAddKey(InputKeyCode.LHallInside, InputKeyState.DOWN);
  314. break;
  315. case "trigger":
  316. API_GSXR_Module_InputSystem_KS.GSXR_KSLeft.inputDataKS.HallFoward = 10 - (int)((context.ReadValue<float>()) * 10f);
  317. break;
  318. case "menu":
  319. API_GSXR_Module_InputSystem_KS.GSXR_KSLeft.inputDataKS.inputKeys.InputDataAddKey(InputKeyCode.LFunction, InputKeyState.DOWN);
  320. break;
  321. }
  322. }
  323. private void OnCanceledEventR(InputAction.CallbackContext context)
  324. {
  325. Debug.Log("OnCanceledEventR" + context.control.name);
  326. switch (context.control.name)
  327. {
  328. case "secondarytouched":
  329. break;
  330. case "secondarybutton":
  331. API_GSXR_Module_InputSystem_KS.GSXR_KSRight.inputDataKS.inputKeys.InputDataAddKey(InputKeyCode.B, InputKeyState.UP);
  332. break;
  333. case "primarytouched":
  334. break;
  335. case "primarybutton":
  336. API_GSXR_Module_InputSystem_KS.GSXR_KSRight.inputDataKS.inputKeys.InputDataAddKey(InputKeyCode.A, InputKeyState.UP);
  337. API_GSXR_Module_InputSystem_KS.GSXR_KSRight.inputDataKS.inputKeys.InputDataAddKey(InputKeyCode.Enter, InputKeyState.UP);
  338. break;
  339. case "touchpadtouched":
  340. break;
  341. case "thumbstickclicked":
  342. break;
  343. case "thumbstick":
  344. API_GSXR_Module_InputSystem_KS.GSXR_KSRight.inputDataKS.JoystickX = xy + (int)(context.ReadValue<Vector2>().x * 10);
  345. API_GSXR_Module_InputSystem_KS.GSXR_KSRight.inputDataKS.JoystickY = xy + (int)(context.ReadValue<Vector2>().y * 10);
  346. break;
  347. case "grip":
  348. API_GSXR_Module_InputSystem_KS.GSXR_KSRight.inputDataKS.HallInside = 10 - (int)((context.ReadValue<float>()) * 10f);
  349. break;
  350. case "grippressed":
  351. API_GSXR_Module_InputSystem_KS.GSXR_KSRight.inputDataKS.inputKeys.InputDataAddKey(InputKeyCode.RHallInside, InputKeyState.UP);
  352. break;
  353. case "trigger":
  354. API_GSXR_Module_InputSystem_KS.GSXR_KSRight.inputDataKS.HallFoward = 10 - (int)((context.ReadValue<float>()) * 10f);
  355. break;
  356. case "menu":
  357. API_GSXR_Module_InputSystem_KS.GSXR_KSRight.inputDataKS.inputKeys.InputDataAddKey(InputKeyCode.RFunction, InputKeyState.UP);
  358. break;
  359. }
  360. }
  361. void OnEventR(InputAction.CallbackContext context)
  362. {
  363. Debug.Log("OnEventR" + context.control.name);
  364. switch (context.control.name)
  365. {
  366. case "secondarytouched":
  367. break;
  368. case "secondarybutton":
  369. API_GSXR_Module_InputSystem_KS.GSXR_KSRight.inputDataKS.inputKeys.InputDataAddKey(InputKeyCode.B, InputKeyState.DOWN);
  370. break;
  371. case "primarytouched":
  372. break;
  373. case "primarybutton":
  374. API_GSXR_Module_InputSystem_KS.GSXR_KSRight.inputDataKS.inputKeys.InputDataAddKey(InputKeyCode.A, InputKeyState.DOWN);
  375. API_GSXR_Module_InputSystem_KS.GSXR_KSRight.inputDataKS.inputKeys.InputDataAddKey(InputKeyCode.Enter, InputKeyState.DOWN);
  376. break;
  377. case "touchpadtouched":
  378. break;
  379. case "thumbstickclicked":
  380. break;
  381. case "thumbstick":
  382. API_GSXR_Module_InputSystem_KS.GSXR_KSRight.inputDataKS.JoystickX = xy + (int)(context.ReadValue<Vector2>().x * 10);
  383. API_GSXR_Module_InputSystem_KS.GSXR_KSRight.inputDataKS.JoystickY = xy + (int)(context.ReadValue<Vector2>().y * 10);
  384. break;
  385. case "grip":
  386. API_GSXR_Module_InputSystem_KS.GSXR_KSRight.inputDataKS.HallInside = 10 - (int)((context.ReadValue<float>()) * 10f);
  387. break;
  388. case "grippressed":
  389. API_GSXR_Module_InputSystem_KS.GSXR_KSRight.inputDataKS.inputKeys.InputDataAddKey(InputKeyCode.RHallInside, InputKeyState.DOWN);
  390. break;
  391. case "trigger":
  392. API_GSXR_Module_InputSystem_KS.GSXR_KSRight.inputDataKS.HallFoward = 10 - (int)((context.ReadValue<float>()) * 10f);
  393. break;
  394. case "menu":
  395. Module_InputSystem.instance.SetActiveInputDevice(InputDeviceType.KS, true);
  396. Module_InputSystem.instance.SetActiveInputDevice(InputDeviceType.Head, false);
  397. API_GSXR_Module_InputSystem_KS.GSXR_KSRight.inputDataKS.inputKeys.InputDataAddKey(InputKeyCode.RFunction, InputKeyState.DOWN);
  398. break;
  399. }
  400. }
  401. // Debug.Log("OnEvent=name==>" + context.control.name);
  402. /*
  403. Debug.Log("OnEvent=layout==>" + context.control.layout);
  404. Debug.Log("OnEvent=noisy==>" + context.control.noisy);
  405. Debug.Log("OnEvent=path==>" + context.control.path);
  406. Debug.Log("OnEvent=shortDisplayName==>" + context.control.shortDisplayName);
  407. Debug.Log("OnEvent=synthetic==>" + context.control.synthetic);
  408. Debug.Log("OnEvent=valueSizeInBytes==>" + context.control.valueSizeInBytes);
  409. Debug.Log("OnEvent=valueType==>" + context.control.valueType.Name);
  410. Debug.Log("OnEvent=variants==>" + context.control.variants);
  411. Debug.Log("OnEvent=variants==>" + context.control.EvaluateMagnitude());*/
  412. }