XRInputManager.cs 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477
  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. #if UNITY_EDITOR
  183. Module_InputSystem.instance.SetActiveInputDevice(InputDeviceType.KS, false);
  184. Module_InputSystem.instance.SetActiveInputDevice(InputDeviceType.Head, true);
  185. Module_InputSystem.instance.SetActiveInputDevice(InputDeviceType.GGT26Dof, false);
  186. #endif
  187. /*
  188. left.gameObject.SetActive(false);
  189. right.gameObject.SetActive(false);
  190. List<UnityEngine.XR.InputDevice> inputDevices = new List<UnityEngine.XR.InputDevice>();
  191. InputDevices.GetDevices(inputDevices);
  192. for (int i = 0; i < inputDevices.Count; i++)
  193. {
  194. onDeviceConnected(inputDevices[i]);
  195. }*/
  196. }
  197. private void Update()
  198. {
  199. if (Input.GetKeyDown(KeyCode.X))
  200. {
  201. API_GSXR_Module_InputSystem_GGT26Dof.GSXR_GGTRight.inputDataGGT26Dof.inputKeys.InputDataAddKey(InputKeyCode.Enter, InputKeyState.DOWN);
  202. //API_GSXR_Module_InputSystem_KS.GSXR_KSLeft.inputDataKS.inputKeys.InputDataAddKey(InputKeyCode.X, InputKeyState.DOWN);
  203. }
  204. if (Input.GetKeyUp(KeyCode.X))
  205. {
  206. API_GSXR_Module_InputSystem_GGT26Dof.GSXR_GGTRight.inputDataGGT26Dof.inputKeys.InputDataAddKey(InputKeyCode.Enter, InputKeyState.UP);
  207. // API_GSXR_Module_InputSystem_KS.GSXR_KSLeft.inputDataKS.inputKeys.InputDataAddKey(InputKeyCode.X, InputKeyState.UP);
  208. }
  209. }
  210. private void onDeviceDisConnected(UnityEngine.XR.InputDevice obj)
  211. {
  212. if (obj.characteristics.ToString().Contains(InputDeviceCharacteristics.Left.ToString()))
  213. {
  214. Debug.Log("Left===>" + obj.isValid);
  215. left.gameObject.SetActive(obj.isValid);
  216. }
  217. if (obj.characteristics.ToString().Contains(InputDeviceCharacteristics.Right.ToString()))
  218. {
  219. Debug.Log("Right===>" + obj.isValid);
  220. right.gameObject.SetActive(obj.isValid);
  221. }
  222. }
  223. private void OnApplicationPause(bool pause)
  224. {
  225. if (!pause)
  226. {
  227. List<UnityEngine.XR.InputDevice> inputDevices = new List<UnityEngine.XR.InputDevice>();
  228. InputDevices.GetDevices(inputDevices);
  229. for (int i = 0; i < inputDevices.Count; i++)
  230. {
  231. onDeviceConnected(inputDevices[i]);
  232. }
  233. }
  234. }
  235. private void onDeviceConnected(UnityEngine.XR.InputDevice obj)
  236. {
  237. if (obj.characteristics.ToString().Contains(InputDeviceCharacteristics.Left.ToString()))
  238. {
  239. Debug.Log("Left===>" + obj.isValid);
  240. left.gameObject.SetActive(obj.isValid);
  241. }
  242. if (obj.characteristics.ToString().Contains(InputDeviceCharacteristics.Right.ToString()))
  243. {
  244. Debug.Log("Right===>" + obj.isValid);
  245. right.gameObject.SetActive(obj.isValid);
  246. }
  247. }
  248. private void OnCanceledEventL(InputAction.CallbackContext context)
  249. {
  250. Debug.Log("OnCanceledEventL" + context.control.name);
  251. switch (context.control.name)
  252. {
  253. case "secondarytouched":
  254. break;
  255. case "secondarybutton":
  256. API_GSXR_Module_InputSystem_KS.GSXR_KSLeft.inputDataKS.inputKeys.InputDataAddKey(InputKeyCode.Y, InputKeyState.UP);
  257. break;
  258. case "primarytouched":
  259. break;
  260. case "primarybutton":
  261. Debug.Log("InputKeyCode.A===¡·UP");
  262. API_GSXR_Module_InputSystem_KS.GSXR_KSLeft.inputDataKS.inputKeys.InputDataAddKey(InputKeyCode.X, InputKeyState.UP);
  263. API_GSXR_Module_InputSystem_KS.GSXR_KSLeft.inputDataKS.inputKeys.InputDataAddKey(InputKeyCode.Enter, InputKeyState.UP);
  264. break;
  265. case "touchpadtouched":
  266. break;
  267. case "thumbstickclicked":
  268. break;
  269. case "thumbstick":
  270. API_GSXR_Module_InputSystem_KS.GSXR_KSLeft.inputDataKS.JoystickX = xy + (int)(context.ReadValue<Vector2>().x * 10);
  271. API_GSXR_Module_InputSystem_KS.GSXR_KSLeft.inputDataKS.JoystickY = xy + (int)(context.ReadValue<Vector2>().y * 10);
  272. break;
  273. case "grip":
  274. API_GSXR_Module_InputSystem_KS.GSXR_KSLeft.inputDataKS.HallInside = 10 - (int)((context.ReadValue<float>()) * 10f);
  275. break;
  276. case "grippressed":
  277. API_GSXR_Module_InputSystem_KS.GSXR_KSLeft.inputDataKS.inputKeys.InputDataAddKey(InputKeyCode.LHallInside, InputKeyState.UP);
  278. break;
  279. case "trigger":
  280. API_GSXR_Module_InputSystem_KS.GSXR_KSLeft.inputDataKS.HallFoward = 10 - (int)((context.ReadValue<float>()) * 10f);
  281. break;
  282. case "menu":
  283. Module_InputSystem.instance.SetActiveInputDevice(InputDeviceType.KS, true);
  284. Module_InputSystem.instance.SetActiveInputDevice(InputDeviceType.Head, false);
  285. API_GSXR_Module_InputSystem_KS.GSXR_KSLeft.inputDataKS.inputKeys.InputDataAddKey(InputKeyCode.LFunction, InputKeyState.UP);
  286. break;
  287. }
  288. }
  289. void OnEventL(InputAction.CallbackContext context)
  290. {
  291. Debug.Log("OnEventL" + context.control.name);
  292. switch (context.control.name)
  293. {
  294. case "secondarytouched":
  295. break;
  296. case "secondarybutton":
  297. API_GSXR_Module_InputSystem_KS.GSXR_KSLeft.inputDataKS.inputKeys.InputDataAddKey(InputKeyCode.Y, InputKeyState.DOWN);
  298. break;
  299. case "primarytouched":
  300. break;
  301. case "primarybutton":
  302. Debug.Log("InputKeyCode.A===¡·DOWN");
  303. API_GSXR_Module_InputSystem_KS.GSXR_KSLeft.inputDataKS.inputKeys.InputDataAddKey(InputKeyCode.X, InputKeyState.DOWN);
  304. API_GSXR_Module_InputSystem_KS.GSXR_KSLeft.inputDataKS.inputKeys.InputDataAddKey(InputKeyCode.Enter, InputKeyState.DOWN);
  305. break;
  306. case "touchpadtouched":
  307. break;
  308. case "thumbstickclicked":
  309. break;
  310. case "thumbstick":
  311. API_GSXR_Module_InputSystem_KS.GSXR_KSLeft.inputDataKS.JoystickX = xy + (int)(context.ReadValue<Vector2>().x * 10);
  312. API_GSXR_Module_InputSystem_KS.GSXR_KSLeft.inputDataKS.JoystickY = xy + (int)(context.ReadValue<Vector2>().y * 10);
  313. break;
  314. case "grip":
  315. API_GSXR_Module_InputSystem_KS.GSXR_KSLeft.inputDataKS.HallInside = 10 - (int)((context.ReadValue<float>()) * 10f);
  316. break;
  317. case "grippressed":
  318. API_GSXR_Module_InputSystem_KS.GSXR_KSLeft.inputDataKS.inputKeys.InputDataAddKey(InputKeyCode.LHallInside, InputKeyState.DOWN);
  319. break;
  320. case "trigger":
  321. API_GSXR_Module_InputSystem_KS.GSXR_KSLeft.inputDataKS.HallFoward = 10 - (int)((context.ReadValue<float>()) * 10f);
  322. break;
  323. case "menu":
  324. API_GSXR_Module_InputSystem_KS.GSXR_KSLeft.inputDataKS.inputKeys.InputDataAddKey(InputKeyCode.LFunction, InputKeyState.DOWN);
  325. break;
  326. }
  327. }
  328. private void OnCanceledEventR(InputAction.CallbackContext context)
  329. {
  330. Debug.Log("OnCanceledEventR" + context.control.name);
  331. switch (context.control.name)
  332. {
  333. case "secondarytouched":
  334. break;
  335. case "secondarybutton":
  336. API_GSXR_Module_InputSystem_KS.GSXR_KSRight.inputDataKS.inputKeys.InputDataAddKey(InputKeyCode.B, InputKeyState.UP);
  337. break;
  338. case "primarytouched":
  339. break;
  340. case "primarybutton":
  341. API_GSXR_Module_InputSystem_KS.GSXR_KSRight.inputDataKS.inputKeys.InputDataAddKey(InputKeyCode.A, InputKeyState.UP);
  342. API_GSXR_Module_InputSystem_KS.GSXR_KSRight.inputDataKS.inputKeys.InputDataAddKey(InputKeyCode.Enter, InputKeyState.UP);
  343. break;
  344. case "touchpadtouched":
  345. break;
  346. case "thumbstickclicked":
  347. break;
  348. case "thumbstick":
  349. API_GSXR_Module_InputSystem_KS.GSXR_KSRight.inputDataKS.JoystickX = xy + (int)(context.ReadValue<Vector2>().x * 10);
  350. API_GSXR_Module_InputSystem_KS.GSXR_KSRight.inputDataKS.JoystickY = xy + (int)(context.ReadValue<Vector2>().y * 10);
  351. break;
  352. case "grip":
  353. API_GSXR_Module_InputSystem_KS.GSXR_KSRight.inputDataKS.HallInside = 10 - (int)((context.ReadValue<float>()) * 10f);
  354. break;
  355. case "grippressed":
  356. API_GSXR_Module_InputSystem_KS.GSXR_KSRight.inputDataKS.inputKeys.InputDataAddKey(InputKeyCode.RHallInside, InputKeyState.UP);
  357. break;
  358. case "trigger":
  359. API_GSXR_Module_InputSystem_KS.GSXR_KSRight.inputDataKS.HallFoward = 10 - (int)((context.ReadValue<float>()) * 10f);
  360. break;
  361. case "menu":
  362. API_GSXR_Module_InputSystem_KS.GSXR_KSRight.inputDataKS.inputKeys.InputDataAddKey(InputKeyCode.RFunction, InputKeyState.UP);
  363. break;
  364. }
  365. }
  366. void OnEventR(InputAction.CallbackContext context)
  367. {
  368. Debug.Log("OnEventR" + context.control.name);
  369. switch (context.control.name)
  370. {
  371. case "secondarytouched":
  372. break;
  373. case "secondarybutton":
  374. API_GSXR_Module_InputSystem_KS.GSXR_KSRight.inputDataKS.inputKeys.InputDataAddKey(InputKeyCode.B, InputKeyState.DOWN);
  375. break;
  376. case "primarytouched":
  377. break;
  378. case "primarybutton":
  379. API_GSXR_Module_InputSystem_KS.GSXR_KSRight.inputDataKS.inputKeys.InputDataAddKey(InputKeyCode.A, InputKeyState.DOWN);
  380. API_GSXR_Module_InputSystem_KS.GSXR_KSRight.inputDataKS.inputKeys.InputDataAddKey(InputKeyCode.Enter, InputKeyState.DOWN);
  381. break;
  382. case "touchpadtouched":
  383. break;
  384. case "thumbstickclicked":
  385. break;
  386. case "thumbstick":
  387. API_GSXR_Module_InputSystem_KS.GSXR_KSRight.inputDataKS.JoystickX = xy + (int)(context.ReadValue<Vector2>().x * 10);
  388. API_GSXR_Module_InputSystem_KS.GSXR_KSRight.inputDataKS.JoystickY = xy + (int)(context.ReadValue<Vector2>().y * 10);
  389. break;
  390. case "grip":
  391. API_GSXR_Module_InputSystem_KS.GSXR_KSRight.inputDataKS.HallInside = 10 - (int)((context.ReadValue<float>()) * 10f);
  392. break;
  393. case "grippressed":
  394. API_GSXR_Module_InputSystem_KS.GSXR_KSRight.inputDataKS.inputKeys.InputDataAddKey(InputKeyCode.RHallInside, InputKeyState.DOWN);
  395. break;
  396. case "trigger":
  397. API_GSXR_Module_InputSystem_KS.GSXR_KSRight.inputDataKS.HallFoward = 10 - (int)((context.ReadValue<float>()) * 10f);
  398. break;
  399. case "menu":
  400. Module_InputSystem.instance.SetActiveInputDevice(InputDeviceType.KS, true);
  401. Module_InputSystem.instance.SetActiveInputDevice(InputDeviceType.Head, false);
  402. API_GSXR_Module_InputSystem_KS.GSXR_KSRight.inputDataKS.inputKeys.InputDataAddKey(InputKeyCode.RFunction, InputKeyState.DOWN);
  403. break;
  404. }
  405. }
  406. // Debug.Log("OnEvent=name==>" + context.control.name);
  407. /*
  408. Debug.Log("OnEvent=layout==>" + context.control.layout);
  409. Debug.Log("OnEvent=noisy==>" + context.control.noisy);
  410. Debug.Log("OnEvent=path==>" + context.control.path);
  411. Debug.Log("OnEvent=shortDisplayName==>" + context.control.shortDisplayName);
  412. Debug.Log("OnEvent=synthetic==>" + context.control.synthetic);
  413. Debug.Log("OnEvent=valueSizeInBytes==>" + context.control.valueSizeInBytes);
  414. Debug.Log("OnEvent=valueType==>" + context.control.valueType.Name);
  415. Debug.Log("OnEvent=variants==>" + context.control.variants);
  416. Debug.Log("OnEvent=variants==>" + context.control.EvaluateMagnitude());*/
  417. }