XRInputManager.cs 27 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606
  1. using Rokid.UXR.Interaction;
  2. using Rokid.UXR.Module;
  3. using SC.XR.Unity.Module_InputSystem;
  4. using System;
  5. using System.Collections;
  6. using System.Collections.Generic;
  7. using UnityEngine;
  8. using UnityEngine.Android;
  9. using UnityEngine.InputSystem;
  10. using UnityEngine.XR;
  11. using UnityEngine.XR.OpenXR.Input;
  12. public class XRInputManager : MonoBehaviour
  13. {
  14. public static bool isCheckHand;
  15. public static bool leftDown;
  16. public static bool rightDown;
  17. public Transform left = null;
  18. public Transform right = null;
  19. public InputActionProperty inputEvent;
  20. public List<InputActionReference> listinput;
  21. int xy = 8;
  22. private void Awake()
  23. {
  24. if (!Permission.HasUserAuthorizedPermission("android.permission.RECORD_AUDIO"))
  25. {
  26. Permission.RequestUserPermission("android.permission.RECORD_AUDIO");
  27. }
  28. isHand = true;
  29. isCheckHand = isHand;
  30. }
  31. public void OnReceive(string msg)
  32. {
  33. }
  34. // Start is called before the first frame update
  35. void Start()
  36. {
  37. ModuleManager.Instance.RegistModule("com.rokid.voicecommand.VoiceCommandHelper", false);
  38. // API_GSXR_Module_InputSystem_GGT26Dof.GSXR_GGTLeft.inputDataGGT26Dof.inputKeys.InputDataAddKey(InputKeyCode.Enter, InputKeyState.DOWN);
  39. /*
  40. NRInput.AddDownListener(ControllerHandEnum.Right, ControllerButton.APP, () => {
  41. Debug.Log("ControllerButton.APP===>Down");
  42. API_GSXR_Module_InputSystem_KS.GSXR_KSRight.inputDataKS.inputKeys.InputDataAddKey(InputKeyCode.Enter, InputKeyState.DOWN);
  43. API_GSXR_Module_InputSystem_GGT26Dof.GSXR_GGTRight.inputDataGGT26Dof.inputKeys.InputDataAddKey(InputKeyCode.Enter, InputKeyState.DOWN);
  44. });
  45. NRInput.AddDownListener(ControllerHandEnum.Right, ControllerButton.BEGIN, () => {
  46. Debug.Log("ControllerButton.BEGIN===>Down");
  47. API_GSXR_Module_InputSystem_KS.GSXR_KSRight.inputDataKS.inputKeys.InputDataAddKey(InputKeyCode.Enter, InputKeyState.DOWN);
  48. API_GSXR_Module_InputSystem_GGT26Dof.GSXR_GGTRight.inputDataGGT26Dof.inputKeys.InputDataAddKey(InputKeyCode.Enter, InputKeyState.DOWN);
  49. });
  50. NRInput.AddDownListener(ControllerHandEnum.Right, ControllerButton.END, () => {
  51. Debug.Log("ControllerButton.END===>Down");
  52. API_GSXR_Module_InputSystem_KS.GSXR_KSRight.inputDataKS.inputKeys.InputDataAddKey(InputKeyCode.Enter, InputKeyState.DOWN);
  53. API_GSXR_Module_InputSystem_GGT26Dof.GSXR_GGTRight.inputDataGGT26Dof.inputKeys.InputDataAddKey(InputKeyCode.Enter, InputKeyState.DOWN);
  54. });
  55. NRInput.AddDownListener(ControllerHandEnum.Right, ControllerButton.GRIP, () => {
  56. Debug.Log("ControllerButton.GRIP===>Down");
  57. API_GSXR_Module_InputSystem_KS.GSXR_KSRight.inputDataKS.inputKeys.InputDataAddKey(InputKeyCode.Enter, InputKeyState.DOWN);
  58. API_GSXR_Module_InputSystem_GGT26Dof.GSXR_GGTRight.inputDataGGT26Dof.inputKeys.InputDataAddKey(InputKeyCode.Enter, InputKeyState.DOWN);
  59. });
  60. NRInput.AddDownListener(ControllerHandEnum.Right, ControllerButton.HOME, () => {
  61. Debug.Log("ControllerButton.HOME===>Down");
  62. API_GSXR_Module_InputSystem_KS.GSXR_KSRight.inputDataKS.inputKeys.InputDataAddKey(InputKeyCode.Enter, InputKeyState.DOWN);
  63. API_GSXR_Module_InputSystem_GGT26Dof.GSXR_GGTRight.inputDataGGT26Dof.inputKeys.InputDataAddKey(InputKeyCode.Enter, InputKeyState.DOWN);
  64. });*/
  65. /*
  66. NRInput.AddDownListener(ControllerHandEnum.Right, ControllerButton.TRIGGER, () => {
  67. Debug.Log("ControllerButton.TRIGGER===>Down");
  68. if (isHand)
  69. {
  70. // API_GSXR_Module_InputSystem_KS.GSXR_KSRight.inputDataKS.inputKeys.InputDataAddKey(InputKeyCode.Enter, InputKeyState.DOWN);
  71. rightDown = true;
  72. API_GSXR_Module_InputSystem_GGT26Dof.GSXR_GGTRight.inputDataGGT26Dof.inputKeys.InputDataAddKey(InputKeyCode.Enter, InputKeyState.DOWN);
  73. }
  74. else
  75. {
  76. API_GSXR_Module_InputSystem_KS.GSXR_KSRight.inputDataKS.inputKeys.InputDataAddKey(InputKeyCode.Enter, InputKeyState.DOWN);
  77. }
  78. });*/
  79. /*
  80. NRInput.AddDownListener(ControllerHandEnum.Right, ControllerButton.TOUCHPAD_BUTTON, () => {
  81. Debug.Log("ControllerButton.TOUCHPAD_BUTTON===>Down");
  82. API_GSXR_Module_InputSystem_KS.GSXR_KSRight.inputDataKS.inputKeys.InputDataAddKey(InputKeyCode.Enter, InputKeyState.DOWN);
  83. API_GSXR_Module_InputSystem_GGT26Dof.GSXR_GGTRight.inputDataGGT26Dof.inputKeys.InputDataAddKey(InputKeyCode.Enter, InputKeyState.DOWN);
  84. });
  85. NRInput.AddUpListener(ControllerHandEnum.Right, ControllerButton.APP, () => {
  86. Debug.Log("ControllerButton.APP===>UP");
  87. API_GSXR_Module_InputSystem_GGT26Dof.GSXR_GGTRight.inputDataGGT26Dof.inputKeys.InputDataAddKey(InputKeyCode.Enter, InputKeyState.UP);
  88. API_GSXR_Module_InputSystem_KS.GSXR_KSRight.inputDataKS.inputKeys.InputDataAddKey(InputKeyCode.Enter, InputKeyState.UP);
  89. });
  90. NRInput.AddUpListener(ControllerHandEnum.Right, ControllerButton.BEGIN, () => {
  91. Debug.Log("ControllerButton.BEGIN===>UP");
  92. API_GSXR_Module_InputSystem_GGT26Dof.GSXR_GGTRight.inputDataGGT26Dof.inputKeys.InputDataAddKey(InputKeyCode.Enter, InputKeyState.UP);
  93. API_GSXR_Module_InputSystem_KS.GSXR_KSRight.inputDataKS.inputKeys.InputDataAddKey(InputKeyCode.Enter, InputKeyState.UP);
  94. });
  95. NRInput.AddUpListener(ControllerHandEnum.Right, ControllerButton.END, () => {
  96. Debug.Log("ControllerButton.END===>UP");
  97. API_GSXR_Module_InputSystem_GGT26Dof.GSXR_GGTRight.inputDataGGT26Dof.inputKeys.InputDataAddKey(InputKeyCode.Enter, InputKeyState.UP);
  98. API_GSXR_Module_InputSystem_KS.GSXR_KSRight.inputDataKS.inputKeys.InputDataAddKey(InputKeyCode.Enter, InputKeyState.UP);
  99. });
  100. NRInput.AddUpListener(ControllerHandEnum.Right, ControllerButton.GRIP, () => {
  101. Debug.Log("ControllerButton.GRIP===>UP");
  102. API_GSXR_Module_InputSystem_GGT26Dof.GSXR_GGTRight.inputDataGGT26Dof.inputKeys.InputDataAddKey(InputKeyCode.Enter, InputKeyState.UP);
  103. API_GSXR_Module_InputSystem_KS.GSXR_KSRight.inputDataKS.inputKeys.InputDataAddKey(InputKeyCode.Enter, InputKeyState.UP);
  104. });
  105. NRInput.AddUpListener(ControllerHandEnum.Right, ControllerButton.HOME, () => {
  106. Debug.Log("ControllerButton.HOME===>UP");
  107. API_GSXR_Module_InputSystem_GGT26Dof.GSXR_GGTRight.inputDataGGT26Dof.inputKeys.InputDataAddKey(InputKeyCode.Enter, InputKeyState.UP);
  108. API_GSXR_Module_InputSystem_KS.GSXR_KSRight.inputDataKS.inputKeys.InputDataAddKey(InputKeyCode.Enter, InputKeyState.UP);
  109. });*/
  110. /*
  111. NRInput.AddUpListener(ControllerHandEnum.Right, ControllerButton.TRIGGER, () => {
  112. Debug.Log("ControllerButton.HOME===>TRIGGER");
  113. if (isHand)
  114. {
  115. rightDown = false;
  116. API_GSXR_Module_InputSystem_GGT26Dof.GSXR_GGTRight.inputDataGGT26Dof.inputKeys.InputDataAddKey(InputKeyCode.Enter, InputKeyState.UP);
  117. // API_GSXR_Module_InputSystem_KS.GSXR_KSRight.inputDataKS.inputKeys.InputDataAddKey(InputKeyCode.Enter, InputKeyState.UP);
  118. }else
  119. {
  120. API_GSXR_Module_InputSystem_KS.GSXR_KSRight.inputDataKS.inputKeys.InputDataAddKey(InputKeyCode.Enter, InputKeyState.UP);
  121. }
  122. });*/
  123. /*
  124. NRInput.AddUpListener(ControllerHandEnum.Right, ControllerButton.TOUCHPAD_BUTTON, () => {
  125. Debug.Log("ControllerButton.HOME===>TOUCHPAD_BUTTON");
  126. API_GSXR_Module_InputSystem_GGT26Dof.GSXR_GGTRight.inputDataGGT26Dof.inputKeys.InputDataAddKey(InputKeyCode.Enter, InputKeyState.UP);
  127. API_GSXR_Module_InputSystem_KS.GSXR_KSRight.inputDataKS.inputKeys.InputDataAddKey(InputKeyCode.Enter, InputKeyState.UP);
  128. });
  129. *//*
  130. NRInput.AddDownListener(ControllerHandEnum.Left, ControllerButton.TRIGGER, () => {
  131. Debug.Log("ControllerButton.HOME===>TRIGGER");
  132. if (isHand)
  133. {
  134. leftDown = false;
  135. API_GSXR_Module_InputSystem_GGT26Dof.GSXR_GGTLeft.inputDataGGT26Dof.inputKeys.InputDataAddKey(InputKeyCode.Enter, InputKeyState.DOWN);
  136. }
  137. });
  138. NRInput.AddUpListener(ControllerHandEnum.Left, ControllerButton.TRIGGER, () => {
  139. Debug.Log("ControllerButton.HOME===>TRIGGER");
  140. if (isHand)
  141. {
  142. leftDown = false;
  143. API_GSXR_Module_InputSystem_GGT26Dof.GSXR_GGTLeft.inputDataGGT26Dof.inputKeys.InputDataAddKey(InputKeyCode.Enter, InputKeyState.UP);
  144. // API_GSXR_Module_InputSystem_KS.GSXR_KSRight.inputDataKS.inputKeys.InputDataAddKey(InputKeyCode.Enter, InputKeyState.UP);
  145. }
  146. });*/
  147. Invoke("startXR", 1f);
  148. /*
  149. return;
  150. for (int i = 0; i < 15; i++)
  151. {
  152. listinput[i].action.Enable();
  153. listinput[i].action.performed += OnEventL;
  154. listinput[i].action.canceled += OnCanceledEventL;
  155. }
  156. for (int i = 15; i < listinput.Count; i++)
  157. {
  158. listinput[i].action.Enable();
  159. listinput[i].action.performed += OnEventR;
  160. listinput[i].action.canceled += OnCanceledEventR;
  161. }
  162. InputDevices.deviceConnected += onDeviceConnected;
  163. InputDevices.deviceDisconnected += onDeviceDisConnected;
  164. Invoke("startXR", 1f);*/
  165. }
  166. private void downTP()
  167. {
  168. }
  169. public static bool isHand;
  170. List<Vector3> leftInfo = new List<Vector3>();
  171. List<Vector3> rightInfo = new List<Vector3>();
  172. void startXR()
  173. {
  174. InteractorGroup.OnDownOrUp += OnDownOrUp;
  175. InputModuleManager.OnModuleActive += OnModuleActive;
  176. InteractorStateChange.OnPokePoseUpdate += OnPokePoseUpdate;
  177. ThreeDofEventInput.OnPhoneRayForward += OnPhoneRayForward;
  178. if (isHand)
  179. {
  180. Module_InputSystem.instance.SetActiveInputDevice(InputDeviceType.KS, false);
  181. Module_InputSystem.instance.SetActiveInputDevice(InputDeviceType.Head, false);
  182. Module_InputSystem.instance.SetActiveInputDevice(InputDeviceType.GGT26Dof, true);
  183. }else
  184. {
  185. Module_InputSystem.instance.SetActiveInputDevice(InputDeviceType.KS, true);
  186. Module_InputSystem.instance.SetActiveInputDevice(InputDeviceType.Head, false);
  187. Module_InputSystem.instance.SetActiveInputDevice(InputDeviceType.GGT26Dof, false);
  188. }
  189. isHand=!InputModuleManager.Instance.GetThreeDofActive();
  190. #if UNITY_EDITOR
  191. // Module_InputSystem.instance.SetActiveInputDevice(InputDeviceType.KS, false);
  192. // Module_InputSystem.instance.SetActiveInputDevice(InputDeviceType.Head, true);
  193. // Module_InputSystem.instance.SetActiveInputDevice(InputDeviceType.GGT26Dof, false);
  194. #endif
  195. /*
  196. left.gameObject.SetActive(false);
  197. right.gameObject.SetActive(false);
  198. List<UnityEngine.XR.InputDevice> inputDevices = new List<UnityEngine.XR.InputDevice>();
  199. InputDevices.GetDevices(inputDevices);
  200. for (int i = 0; i < inputDevices.Count; i++)
  201. {
  202. onDeviceConnected(inputDevices[i]);
  203. }*/
  204. }
  205. private void OnDownOrUp(bool obj)
  206. {
  207. if(!isHand)
  208. {
  209. if (obj)
  210. {
  211. // API_GSXR_Module_InputSystem_GGT26Dof.GSXR_GGTLeft.inputDataGGT26Dof.inputKeys.InputDataAddKey(InputKeyCode.Enter, InputKeyState.DOWN);
  212. // API_GSXR_Module_InputSystem_GGT26Dof.GSXR_GGTRight.inputDataGGT26Dof.inputKeys.InputDataAddKey(InputKeyCode.Enter, InputKeyState.DOWN);
  213. }
  214. else
  215. {
  216. // API_GSXR_Module_InputSystem_GGT26Dof.GSXR_GGTRight.inputDataGGT26Dof.inputKeys.InputDataAddKey(InputKeyCode.Enter, InputKeyState.UP);
  217. }
  218. }
  219. }
  220. private void OnModuleActive(InputModuleType obj)
  221. {
  222. if(obj==InputModuleType.ThreeDof)
  223. {
  224. isHand = false;
  225. }
  226. else
  227. {
  228. isHand = true;
  229. }
  230. }
  231. private void OnPhoneRayForward(Vector3 obj)
  232. {
  233. if(!isHand)
  234. {
  235. rootRightHand.transform.eulerAngles = obj;
  236. // rootLeftHand.transform.localPosition = new Vector3(rootLeftHand.transform.localPosition.x-20, rootLeftHand.transform.localPosition.y, rootLeftHand.transform.localPosition.z);
  237. rootRightHand.transform.localPosition = new Vector3(0, -0.5f, 0.2f);
  238. }
  239. }
  240. public GameObject rootLeftHand;
  241. public GameObject rootRightHand;
  242. private void OnPokePoseUpdate(HandType arg0, UnityEngine.Pose arg1)
  243. {
  244. if (isHand)
  245. {
  246. if (HandType.LeftHand == arg0)
  247. {
  248. // rootLeftHand.transform.position = arg1.position;
  249. // rootLeftHand.transform.rotation = arg1.rotation;
  250. }
  251. else
  252. {
  253. // rootRightHand.transform.position = arg1.position;
  254. // rootRightHand.transform.rotation = arg1.rotation;
  255. }
  256. }
  257. }
  258. private void Update()
  259. {
  260. if (Input.GetKeyDown(KeyCode.I))
  261. {
  262. isHand = false;
  263. }
  264. if (Input.GetKeyDown(KeyCode.U))
  265. {
  266. isHand = true;
  267. }
  268. if (Input.GetKeyUp(KeyCode.LeftArrow) || Input.GetKeyUp(KeyCode.RightArrow) || Input.GetKeyUp(KeyCode.UpArrow) || Input.GetKeyUp(KeyCode.DownArrow)
  269. || RKNativeInput.Instance.GetKeyUp(RKKeyEvent.KEY_LEFT) || RKNativeInput.Instance.GetKeyUp(RKKeyEvent.KEY_RIGHT) || RKNativeInput.Instance.GetKeyUp(RKKeyEvent.KEY_UP) || RKNativeInput.Instance.GetKeyUp(RKKeyEvent.KEY_DOWN)
  270. || Input.GetKeyUp(KeyCode.JoystickButton0))
  271. {
  272. API_GSXR_Module_InputSystem_GGT26Dof.GSXR_GGTRight.inputDataGGT26Dof.inputKeys.InputDataAddKey(InputKeyCode.Enter, InputKeyState.UP);
  273. }
  274. if (Input.GetKeyDown(KeyCode.LeftArrow) || Input.GetKeyDown(KeyCode.RightArrow) || Input.GetKeyDown(KeyCode.UpArrow) || Input.GetKeyDown(KeyCode.DownArrow)
  275. || RKNativeInput.Instance.GetKeyDown(RKKeyEvent.KEY_LEFT) || RKNativeInput.Instance.GetKeyDown(RKKeyEvent.KEY_RIGHT) || RKNativeInput.Instance.GetKeyDown(RKKeyEvent.KEY_UP) || RKNativeInput.Instance.GetKeyDown(RKKeyEvent.KEY_DOWN)
  276. || Input.GetKeyDown(KeyCode.JoystickButton0))
  277. {
  278. API_GSXR_Module_InputSystem_GGT26Dof.GSXR_GGTRight.inputDataGGT26Dof.inputKeys.InputDataAddKey(InputKeyCode.Enter, InputKeyState.DOWN);
  279. }
  280. bool ldown = GesEventInput.Instance.GetHandDown(HandType.LeftHand);
  281. if(ldown)
  282. {
  283. Debug.Log(".GetHandDown(HandType.LeftHand)");
  284. API_GSXR_Module_InputSystem_GGT26Dof.GSXR_GGTLeft.inputDataGGT26Dof.inputKeys.InputDataAddKey(InputKeyCode.Enter, InputKeyState.DOWN);
  285. }
  286. bool rdown = GesEventInput.Instance.GetHandDown(HandType.RightHand);
  287. if (rdown)
  288. {
  289. Debug.Log(".GetHandDown(HandType.RightHand)");
  290. // rightDown = false;
  291. API_GSXR_Module_InputSystem_GGT26Dof.GSXR_GGTRight.inputDataGGT26Dof.inputKeys.InputDataAddKey(InputKeyCode.Enter, InputKeyState.DOWN);
  292. }
  293. bool lup = GesEventInput.Instance.GetHandUp(HandType.LeftHand);
  294. if (lup)
  295. {
  296. Debug.Log(".GetHandUp(HandType.LeftHand)");
  297. API_GSXR_Module_InputSystem_GGT26Dof.GSXR_GGTLeft.inputDataGGT26Dof.inputKeys.InputDataAddKey(InputKeyCode.Enter, InputKeyState.UP);
  298. }
  299. bool rup = GesEventInput.Instance.GetHandUp(HandType.RightHand);
  300. if (rup)
  301. {
  302. Debug.Log(".GetHandUp(HandType.RightHand)");
  303. // rightDown = false;
  304. API_GSXR_Module_InputSystem_GGT26Dof.GSXR_GGTRight.inputDataGGT26Dof.inputKeys.InputDataAddKey(InputKeyCode.Enter, InputKeyState.UP);
  305. }
  306. if (Input.GetKeyDown(KeyCode.X))
  307. {
  308. API_GSXR_Module_InputSystem_GGT26Dof.GSXR_GGTRight.inputDataGGT26Dof.inputKeys.InputDataAddKey(InputKeyCode.Enter, InputKeyState.DOWN);
  309. //API_GSXR_Module_InputSystem_KS.GSXR_KSLeft.inputDataKS.inputKeys.InputDataAddKey(InputKeyCode.X, InputKeyState.DOWN);
  310. }
  311. if (Input.GetKeyUp(KeyCode.X))
  312. {
  313. API_GSXR_Module_InputSystem_GGT26Dof.GSXR_GGTRight.inputDataGGT26Dof.inputKeys.InputDataAddKey(InputKeyCode.Enter, InputKeyState.UP);
  314. // API_GSXR_Module_InputSystem_KS.GSXR_KSLeft.inputDataKS.inputKeys.InputDataAddKey(InputKeyCode.X, InputKeyState.UP);
  315. }
  316. }
  317. private void onDeviceDisConnected(UnityEngine.XR.InputDevice obj)
  318. {
  319. if (obj.characteristics.ToString().Contains(InputDeviceCharacteristics.Left.ToString()))
  320. {
  321. Debug.Log("Left===>" + obj.isValid);
  322. left.gameObject.SetActive(obj.isValid);
  323. }
  324. if (obj.characteristics.ToString().Contains(InputDeviceCharacteristics.Right.ToString()))
  325. {
  326. Debug.Log("Right===>" + obj.isValid);
  327. right.gameObject.SetActive(obj.isValid);
  328. }
  329. }
  330. private void OnApplicationPause(bool pause)
  331. {
  332. if (!pause)
  333. {
  334. List<UnityEngine.XR.InputDevice> inputDevices = new List<UnityEngine.XR.InputDevice>();
  335. InputDevices.GetDevices(inputDevices);
  336. for (int i = 0; i < inputDevices.Count; i++)
  337. {
  338. onDeviceConnected(inputDevices[i]);
  339. }
  340. }
  341. }
  342. private void onDeviceConnected(UnityEngine.XR.InputDevice obj)
  343. {
  344. if (obj.characteristics.ToString().Contains(InputDeviceCharacteristics.Left.ToString()))
  345. {
  346. Debug.Log("Left===>" + obj.isValid);
  347. left.gameObject.SetActive(obj.isValid);
  348. }
  349. if (obj.characteristics.ToString().Contains(InputDeviceCharacteristics.Right.ToString()))
  350. {
  351. Debug.Log("Right===>" + obj.isValid);
  352. right.gameObject.SetActive(obj.isValid);
  353. }
  354. }
  355. private void OnCanceledEventL(InputAction.CallbackContext context)
  356. {
  357. Debug.Log("OnCanceledEventL" + context.control.name);
  358. switch (context.control.name)
  359. {
  360. case "secondarytouched":
  361. break;
  362. case "secondarybutton":
  363. API_GSXR_Module_InputSystem_KS.GSXR_KSLeft.inputDataKS.inputKeys.InputDataAddKey(InputKeyCode.Y, InputKeyState.UP);
  364. break;
  365. case "primarytouched":
  366. break;
  367. case "primarybutton":
  368. Debug.Log("InputKeyCode.A===¡·UP");
  369. API_GSXR_Module_InputSystem_KS.GSXR_KSLeft.inputDataKS.inputKeys.InputDataAddKey(InputKeyCode.X, InputKeyState.UP);
  370. API_GSXR_Module_InputSystem_KS.GSXR_KSLeft.inputDataKS.inputKeys.InputDataAddKey(InputKeyCode.Enter, InputKeyState.UP);
  371. break;
  372. case "touchpadtouched":
  373. break;
  374. case "thumbstickclicked":
  375. break;
  376. case "thumbstick":
  377. API_GSXR_Module_InputSystem_KS.GSXR_KSLeft.inputDataKS.JoystickX = xy + (int)(context.ReadValue<Vector2>().x * 10);
  378. API_GSXR_Module_InputSystem_KS.GSXR_KSLeft.inputDataKS.JoystickY = xy + (int)(context.ReadValue<Vector2>().y * 10);
  379. break;
  380. case "grip":
  381. API_GSXR_Module_InputSystem_KS.GSXR_KSLeft.inputDataKS.HallInside = 10 - (int)((context.ReadValue<float>()) * 10f);
  382. break;
  383. case "grippressed":
  384. API_GSXR_Module_InputSystem_KS.GSXR_KSLeft.inputDataKS.inputKeys.InputDataAddKey(InputKeyCode.LHallInside, InputKeyState.UP);
  385. break;
  386. case "trigger":
  387. API_GSXR_Module_InputSystem_KS.GSXR_KSLeft.inputDataKS.HallFoward = 10 - (int)((context.ReadValue<float>()) * 10f);
  388. break;
  389. case "menu":
  390. Module_InputSystem.instance.SetActiveInputDevice(InputDeviceType.KS, true);
  391. Module_InputSystem.instance.SetActiveInputDevice(InputDeviceType.Head, false);
  392. API_GSXR_Module_InputSystem_KS.GSXR_KSLeft.inputDataKS.inputKeys.InputDataAddKey(InputKeyCode.LFunction, InputKeyState.UP);
  393. break;
  394. }
  395. }
  396. void OnEventL(InputAction.CallbackContext context)
  397. {
  398. Debug.Log("OnEventL" + context.control.name);
  399. switch (context.control.name)
  400. {
  401. case "secondarytouched":
  402. break;
  403. case "secondarybutton":
  404. API_GSXR_Module_InputSystem_KS.GSXR_KSLeft.inputDataKS.inputKeys.InputDataAddKey(InputKeyCode.Y, InputKeyState.DOWN);
  405. break;
  406. case "primarytouched":
  407. break;
  408. case "primarybutton":
  409. Debug.Log("InputKeyCode.A===¡·DOWN");
  410. API_GSXR_Module_InputSystem_KS.GSXR_KSLeft.inputDataKS.inputKeys.InputDataAddKey(InputKeyCode.X, InputKeyState.DOWN);
  411. API_GSXR_Module_InputSystem_KS.GSXR_KSLeft.inputDataKS.inputKeys.InputDataAddKey(InputKeyCode.Enter, InputKeyState.DOWN);
  412. break;
  413. case "touchpadtouched":
  414. break;
  415. case "thumbstickclicked":
  416. break;
  417. case "thumbstick":
  418. API_GSXR_Module_InputSystem_KS.GSXR_KSLeft.inputDataKS.JoystickX = xy + (int)(context.ReadValue<Vector2>().x * 10);
  419. API_GSXR_Module_InputSystem_KS.GSXR_KSLeft.inputDataKS.JoystickY = xy + (int)(context.ReadValue<Vector2>().y * 10);
  420. break;
  421. case "grip":
  422. API_GSXR_Module_InputSystem_KS.GSXR_KSLeft.inputDataKS.HallInside = 10 - (int)((context.ReadValue<float>()) * 10f);
  423. break;
  424. case "grippressed":
  425. API_GSXR_Module_InputSystem_KS.GSXR_KSLeft.inputDataKS.inputKeys.InputDataAddKey(InputKeyCode.LHallInside, InputKeyState.DOWN);
  426. break;
  427. case "trigger":
  428. API_GSXR_Module_InputSystem_KS.GSXR_KSLeft.inputDataKS.HallFoward = 10 - (int)((context.ReadValue<float>()) * 10f);
  429. break;
  430. case "menu":
  431. API_GSXR_Module_InputSystem_KS.GSXR_KSLeft.inputDataKS.inputKeys.InputDataAddKey(InputKeyCode.LFunction, InputKeyState.DOWN);
  432. break;
  433. }
  434. }
  435. private void OnCanceledEventR(InputAction.CallbackContext context)
  436. {
  437. Debug.Log("OnCanceledEventR" + context.control.name);
  438. switch (context.control.name)
  439. {
  440. case "secondarytouched":
  441. break;
  442. case "secondarybutton":
  443. API_GSXR_Module_InputSystem_KS.GSXR_KSRight.inputDataKS.inputKeys.InputDataAddKey(InputKeyCode.B, InputKeyState.UP);
  444. break;
  445. case "primarytouched":
  446. break;
  447. case "primarybutton":
  448. API_GSXR_Module_InputSystem_KS.GSXR_KSRight.inputDataKS.inputKeys.InputDataAddKey(InputKeyCode.A, InputKeyState.UP);
  449. API_GSXR_Module_InputSystem_KS.GSXR_KSRight.inputDataKS.inputKeys.InputDataAddKey(InputKeyCode.Enter, InputKeyState.UP);
  450. break;
  451. case "touchpadtouched":
  452. break;
  453. case "thumbstickclicked":
  454. break;
  455. case "thumbstick":
  456. API_GSXR_Module_InputSystem_KS.GSXR_KSRight.inputDataKS.JoystickX = xy + (int)(context.ReadValue<Vector2>().x * 10);
  457. API_GSXR_Module_InputSystem_KS.GSXR_KSRight.inputDataKS.JoystickY = xy + (int)(context.ReadValue<Vector2>().y * 10);
  458. break;
  459. case "grip":
  460. API_GSXR_Module_InputSystem_KS.GSXR_KSRight.inputDataKS.HallInside = 10 - (int)((context.ReadValue<float>()) * 10f);
  461. break;
  462. case "grippressed":
  463. API_GSXR_Module_InputSystem_KS.GSXR_KSRight.inputDataKS.inputKeys.InputDataAddKey(InputKeyCode.RHallInside, InputKeyState.UP);
  464. break;
  465. case "trigger":
  466. API_GSXR_Module_InputSystem_KS.GSXR_KSRight.inputDataKS.HallFoward = 10 - (int)((context.ReadValue<float>()) * 10f);
  467. break;
  468. case "menu":
  469. API_GSXR_Module_InputSystem_KS.GSXR_KSRight.inputDataKS.inputKeys.InputDataAddKey(InputKeyCode.RFunction, InputKeyState.UP);
  470. break;
  471. }
  472. }
  473. void OnEventR(InputAction.CallbackContext context)
  474. {
  475. Debug.Log("OnEventR" + context.control.name);
  476. switch (context.control.name)
  477. {
  478. case "secondarytouched":
  479. break;
  480. case "secondarybutton":
  481. API_GSXR_Module_InputSystem_KS.GSXR_KSRight.inputDataKS.inputKeys.InputDataAddKey(InputKeyCode.B, InputKeyState.DOWN);
  482. break;
  483. case "primarytouched":
  484. break;
  485. case "primarybutton":
  486. API_GSXR_Module_InputSystem_KS.GSXR_KSRight.inputDataKS.inputKeys.InputDataAddKey(InputKeyCode.A, InputKeyState.DOWN);
  487. API_GSXR_Module_InputSystem_KS.GSXR_KSRight.inputDataKS.inputKeys.InputDataAddKey(InputKeyCode.Enter, InputKeyState.DOWN);
  488. break;
  489. case "touchpadtouched":
  490. break;
  491. case "thumbstickclicked":
  492. break;
  493. case "thumbstick":
  494. API_GSXR_Module_InputSystem_KS.GSXR_KSRight.inputDataKS.JoystickX = xy + (int)(context.ReadValue<Vector2>().x * 10);
  495. API_GSXR_Module_InputSystem_KS.GSXR_KSRight.inputDataKS.JoystickY = xy + (int)(context.ReadValue<Vector2>().y * 10);
  496. break;
  497. case "grip":
  498. API_GSXR_Module_InputSystem_KS.GSXR_KSRight.inputDataKS.HallInside = 10 - (int)((context.ReadValue<float>()) * 10f);
  499. break;
  500. case "grippressed":
  501. API_GSXR_Module_InputSystem_KS.GSXR_KSRight.inputDataKS.inputKeys.InputDataAddKey(InputKeyCode.RHallInside, InputKeyState.DOWN);
  502. break;
  503. case "trigger":
  504. API_GSXR_Module_InputSystem_KS.GSXR_KSRight.inputDataKS.HallFoward = 10 - (int)((context.ReadValue<float>()) * 10f);
  505. break;
  506. case "menu":
  507. Module_InputSystem.instance.SetActiveInputDevice(InputDeviceType.KS, true);
  508. Module_InputSystem.instance.SetActiveInputDevice(InputDeviceType.Head, false);
  509. API_GSXR_Module_InputSystem_KS.GSXR_KSRight.inputDataKS.inputKeys.InputDataAddKey(InputKeyCode.RFunction, InputKeyState.DOWN);
  510. break;
  511. }
  512. }
  513. // Debug.Log("OnEvent=name==>" + context.control.name);
  514. /*
  515. Debug.Log("OnEvent=layout==>" + context.control.layout);
  516. Debug.Log("OnEvent=noisy==>" + context.control.noisy);
  517. Debug.Log("OnEvent=path==>" + context.control.path);
  518. Debug.Log("OnEvent=shortDisplayName==>" + context.control.shortDisplayName);
  519. Debug.Log("OnEvent=synthetic==>" + context.control.synthetic);
  520. Debug.Log("OnEvent=valueSizeInBytes==>" + context.control.valueSizeInBytes);
  521. Debug.Log("OnEvent=valueType==>" + context.control.valueType.Name);
  522. Debug.Log("OnEvent=variants==>" + context.control.variants);
  523. Debug.Log("OnEvent=variants==>" + context.control.EvaluateMagnitude());*/
  524. }