void Awake() { if (instance != null) { Destroy(gameObject); } instance = this; DontDestroyOnLoad(this.gameObject); int i = 0; j = new List <Joycon>(); bool isLeft = false; HIDapi.hid_init(); IntPtr ptr = HIDapi.hid_enumerate(vendor_id, 0x0); IntPtr top_ptr = ptr; if (ptr == IntPtr.Zero) { ptr = HIDapi.hid_enumerate(vendor_id_, 0x0); if (ptr == IntPtr.Zero) { HIDapi.hid_free_enumeration(ptr); //Debug.Log ("No Joy-Cons found!"); } } hid_device_info enumerate; while (ptr != IntPtr.Zero) { enumerate = (hid_device_info)Marshal.PtrToStructure(ptr, typeof(hid_device_info)); //Debug.Log (enumerate.product_id); if (enumerate.product_id == product_l || enumerate.product_id == product_r) { if (enumerate.product_id == product_l) { isLeft = true; //Debug.Log ("Left Joy-Con connected."); } else if (enumerate.product_id == product_r) { isLeft = false; //Debug.Log ("Right Joy-Con connected."); } else { //Debug.Log ("Non Joy-Con input device skipped."); } IntPtr handle = HIDapi.hid_open_path(enumerate.path); HIDapi.hid_set_nonblocking(handle, 1); j.Add(new Joycon(handle, EnableIMU, EnableLocalize & EnableIMU, 0.05f, isLeft)); ++i; } ptr = enumerate.next; } HIDapi.hid_free_enumeration(top_ptr); }
void Update() { if (this.selectedButton) { return; } if (this.jSelector.Active) { return; } // 上下移動 var selectedButtonNum = this.selectButtonNum; selectedButtonNum -= JoyconManager.GetAxisY(); selectedButtonNum = Mathf.Clamp(selectedButtonNum, 0, 2); if (selectedButtonNum != this.selectButtonNum) { this.button[this.selectButtonNum].Select(false); this.selectButtonNum = selectedButtonNum; this.button[this.selectButtonNum].Select(true); } // 決定 if (JoyconManager.IsAnyButtonDown()) { this.selectedButton = true; SoundManager.PlaySE(SEID.UISelect); this.button[this.selectButtonNum].Selected(); StartCoroutine(PushButton()); } }
void Start() { joyconManager = JoyconManager.Instance; joycon = joyconManager.GetJoycon(joyconType); // get the public Joycon array attached to the JoyconManager in scene joycons = JoyconManager.Instance.j; }
void Awake() { if (instance != null) { Destroy(gameObject); } instance = this; j = new Joycon(); }
public override void Dispose() { connected.Remove(this.index); if (connected.Count() == 0) { manager.Dispose(); manager = null; } }
public JoyConController(int index) { if (manager == null) { manager = new JoyconManager(); connected = new HashSet <int>(); } this.index = index; connected.Add(this.index); }
void Awake() { if (instance != null) { Destroy(gameObject); } instance = this; j = new Joycon[2]; //0 is right j[0] = new Joycon(); //1 is left j[1] = new Joycon(); }
public void Awake() { instance = this; int i = 0; j = new List <Joycon>(); bool isLeft = false; HIDapi.hid_init(); IntPtr ptr = HIDapi.hid_enumerate(vendor_id, 0x0); IntPtr top_ptr = ptr; if (ptr == IntPtr.Zero) { ptr = HIDapi.hid_enumerate(vendor_id_, 0x0); if (ptr == IntPtr.Zero) { HIDapi.hid_free_enumeration(ptr); } } hid_device_info enumerate; while (ptr != IntPtr.Zero) { enumerate = (hid_device_info)Marshal.PtrToStructure(ptr, typeof(hid_device_info)); if (enumerate.product_id == product_l || enumerate.product_id == product_r) { if (enumerate.product_id == product_l) { isLeft = true; } else if (enumerate.product_id == product_r) { isLeft = false; } else { } IntPtr handle = HIDapi.hid_open_path(enumerate.path); HIDapi.hid_set_nonblocking(handle, 1); j.Add(new Joycon(handle, EnableIMU, EnableLocalize & EnableIMU, 0.05f, isLeft)); ++i; } ptr = enumerate.next; } HIDapi.hid_free_enumeration(top_ptr); }
void Awake() { if (instance != null) { Destroy(gameObject); } instance = this; j = new Joycon(); DontDestroyOnLoad(instance); if (SinglePlayerMode) { SceneManager.LoadSceneAsync("SinglePlayer", LoadSceneMode.Single); } else { SceneManager.LoadSceneAsync("Master", LoadSceneMode.Single); } }
void Update() { if (!this.active) { return; } // 左右キーで選択 var selectedNum = Mathf.Clamp(this.selectedNum + JoyconManager.GetAxisX(), 0, this.joyconsCount - 1); if (this.selectedNum != selectedNum) { this.joyconUIs[this.selectedNum].SetCursor(false); this.joyconUIs[this.selectedNum = selectedNum].SetCursor(true); } // ZLまたはZRで振動 if (JoyconManager.GetButton(Manager.Button.SHOLDER_2)) { JoyconManager.ConntectedJoycons[this.selectedNum].SetRumble(160f, 320f, 0.5f, 15); } }
static void Main(string[] args) { SetupLog4Net(); var manager = new JoyconManager(); manager.ConnectJoyCons(); manager.Start(); var firstJoyCon = manager.ConnectedJoyCons.FirstOrDefault(); while (true) { manager.Update(); Thread.Sleep(500); foreach (Button buttonType in Enum.GetValues(typeof(Button))) { var isPressed = firstJoyCon.GetButton(buttonType); Console.WriteLine(buttonType + (isPressed ? "isPressed" : "notPressed")); } } manager.DisconnectJoyCons(); }
public JoyconHelper() { _manager = new JoyconManager(); InitialiseJoycon(); }