public static void update() { WiimoteManager.FindWiimotes(); //TODO: run less often? Debug.Log("Wiimotes: " + WiimoteManager.HasWiimote()); if (!WiimoteManager.HasWiimote()) { return; } //update wiimotes; turn IR on for new wiimotes WiimoteApi.Wiimote w; for (int i = 0; i < WiimoteManager.Wiimotes.Count; i++) { w = WiimoteManager.Wiimotes[i]; if (!haveSeenWiimote[i]) { haveSeenWiimote[i] = true; //w.SetupIRCamera(IRDataType.BASIC); } Debug.Log(" Wiimote " + i + " ext: " + w.current_ext.ToString()); } // find wiimote (vs balance board, etc) //TODO Wiimote.wiimote = WiimoteManager.Wiimotes[0]; // read wiimote data, wiimote plus data int ret; do { ret = wiimote.ReadWiimoteData(); if (ret > 0 && wiimote.current_ext == ExtensionController.MOTIONPLUS) { Vector3 offset = new Vector3(-wiimote.MotionPlus.PitchSpeed, wiimote.MotionPlus.YawSpeed, wiimote.MotionPlus.RollSpeed) / 95f; // Divide by 95Hz (average updates per second from wiimote) //wmpOffset += offset; //model.rot.Rotate(offset, Space.Self); } } while (ret > 0); // get IR pointer position float[] pointer = wiimote.Ir.GetPointingPosition(); position = new Vector2(pointer[0], pointer[1]); // get button states button_a = wiimote.Button.a; button_1 = wiimote.Button.one; // check for events if (position != last_position) Wiimote.onMove(); if (button_a != last_button_a) Wiimote.onButton_A(); if (button_1 != last_button_1) Wiimote.onButton_1(); // update stored state velocity = position - last_position; last_position = position; last_button_a = button_a; last_button_1 = button_1; }
public WiiUProData(Wiimote owner) : base(owner) { _lstick = new ushort[2]; _lstick_readonly = new ReadOnlyArray <ushort>(_lstick); _rstick = new ushort[2]; _rstick_readonly = new ReadOnlyArray <ushort>(_rstick); }
public GuitarData(Wiimote Owner) : base(Owner) { _stick = new byte[2]; _stick_readonly = new ReadOnlyArray <byte>(_stick); _frets = new bool[5]; _frets_readonly = new ReadOnlyArray <bool> (_frets); }
public ClassicControllerData(Wiimote owner) : base(owner) { _lstick = new byte[2]; _lstick_readonly = new ReadOnlyArray <byte>(_lstick); _rstick = new byte[2]; _rstick_readonly = new ReadOnlyArray <byte>(_rstick); }
public GuitarData(Wiimote Owner) : base(Owner) { _stick = new byte[2]; _stick_readonly = new ReadOnlyArray<byte>(_stick); _frets = new bool[5]; _frets_readonly = new ReadOnlyArray<bool> (_frets); }
public NunchuckData(Wiimote Owner) : base(Owner) { _accel = new int[3]; _accel_readonly = new ReadOnlyArray<int>(_accel); _stick = new byte[2]; _stick_readonly = new ReadOnlyArray<byte>(_stick); }
public NunchuckData(Wiimote Owner) : base(Owner) { _accel = new int[3]; _accel_readonly = new ReadOnlyArray <int>(_accel); _stick = new byte[2]; _stick_readonly = new ReadOnlyArray <byte>(_stick); }
/// \brief Disables the given \c Wiimote by closing its bluetooth HID connection. Also removes the remote from Wiimotes /// \param remote The remote to cleanup public static void Cleanup(Wiimote remote) { if (remote != null) { if (remote.hidapi_handle != IntPtr.Zero) HIDapi.hid_close(remote.hidapi_handle); Wiimotes.Remove(remote); } }
/// <summary> /// Initiate the Wiimotes /// </summary> void InitWiimotes() { WiimoteManager.FindWiimotes(); foreach (WiimoteApi.Wiimote remote in WiimoteManager.Wiimotes) { wiimote = remote; wiimote.SendPlayerLED(false, false, false, false); } //If there's no Wiimote detected if (wiimote == null) { isWiimote = false; return; } wiimote.SendDataReportMode(InputDataType.REPORT_BUTTONS_ACCEL_EXT16); isWiimote = true; }
public override void Start() { base.Start(); #if UP_USE_WII_INPUT_MANAGER WiimoteManager.FindWiimotes(); // Poll native bluetooth drivers to find Wiimotes foreach(Wiimote r in WiimoteManager.Wiimotes) { remote = r; remote.SendPlayerLED(true, false, false, true); remote.SendDataReportMode(InputDataType.REPORT_BUTTONS); } #endif }
public MotionPlusData(Wiimote Owner) : base(Owner) { }
public AccelData(Wiimote Owner) : base(Owner) { _accel = new int[3]; _accel_readonly = new ReadOnlyArray<int>(_accel); }
public AccelData(Wiimote Owner) : base(Owner) { _accel = new int[3]; _accel_readonly = new ReadOnlyArray <int>(_accel); }
public static void update() { //Debug.Log("Wiimotes: " + WiimoteManager.HasWiimote()); if (!WiimoteManager.HasWiimote()) { return; };//Debug.Log("No Wiimotes found."); return; } //update wiimotes; turn IR on for new wiimotes WiimoteApi.Wiimote w; for (int i = 0; i < WiimoteManager.Wiimotes.Count; i++) { w = WiimoteManager.Wiimotes[i]; if (!haveSeenWiimote[i]) { haveSeenWiimote[i] = true; //w.SetupIRCamera(IRDataType.BASIC); //w.SendStatusInfoRequest(); //w.SendPlayerLED(true, true, false, false); } //Debug.Log(" Wiimote " + i + " ext: " + w.current_ext.ToString()); //Debug.Log("Wiimote " + i + ": " + w.hidapi_handle); } // find wiimote (vs balance board, etc) //TODO Wiimote.wiimote = WiimoteManager.Wiimotes[0]; //wiimote.SendPlayerLED(true, false, true, false); //wiimote.RequestIdentifyWiiMotionPlus(); //wiimote.ActivateWiiMotionPlus(); //wiimote.SetupIRCamera(IRDataType.BASIC); // read wiimote data, wiimote plus data rot_delta = Quaternion.identity; int ret; do { ret = wiimote.ReadWiimoteData(); if (ret > 0 && wiimote.current_ext == ExtensionController.MOTIONPLUS) { Vector3 offset = new Vector3(-wiimote.MotionPlus.PitchSpeed, wiimote.MotionPlus.YawSpeed, wiimote.MotionPlus.RollSpeed )/ 95f; // Divide by 95Hz (average updates per second from wiimote) rot_delta = Quaternion.Euler( offset ); rotation *= rot_delta; //TODO: calibrate 0? Debug.Log("read WMP: " + offset + " : " + rot_delta.eulerAngles + " : " + rotation); //TODO: this could probably use some smoothing } } while (ret > 0); // get IR pointer position float[] pointer = wiimote.Ir.GetPointingPosition(); position = new Vector2(pointer[0], pointer[1]); //TODO: this could probably use some smoothing, as well // get button states button_a = wiimote.Button.a; button_1 = wiimote.Button.one; is_wmp_active = is_extension_motion_plus(wiimote); // check for events if (position != last_position) Wiimote.onMove(); if (rot_delta != Quaternion.identity) Wiimote.onRotate(); if (button_a != last_button_a) Wiimote.onButton_A(); if (button_1 != last_button_1) Wiimote.onButton_1(); // update stored state velocity = position - last_position; last_position = position; last_button_a = button_a; last_button_1 = button_1; //Debug.Log("WIIMOTE: " + button_1); //Debug.Log( "is_wmp_active: " + is_wmp_active ); }
public WiiUProData(Wiimote owner) : base(owner) { _lstick = new ushort[2]; _lstick_readonly = new ReadOnlyArray<ushort>(_lstick); _rstick = new ushort[2]; _rstick_readonly = new ReadOnlyArray<ushort>(_rstick); }
public WiimoteData(Wiimote Owner) { this.Owner = Owner; }
public IRData(Wiimote Owner) : base(Owner) { _ir = new int[4, 8]; _ir_readonly = new ReadOnlyMatrix <int>(_ir); }
public StatusData(Wiimote Owner) : base(Owner) { _led = new bool[4]; _led_readonly = new ReadOnlyArray<bool>(_led); }
private static bool _FindWiimotes(WiimoteType type) { //if (hidapi_wiimote != IntPtr.Zero) // HIDapi.hid_close(hidapi_wiimote); ushort vendor = 0; ushort product = 0; if (type == WiimoteType.WIIMOTE) { vendor = vendor_id_wiimote; product = product_id_wiimote; } else if (type == WiimoteType.WIIMOTEPLUS || type == WiimoteType.PROCONTROLLER) { vendor = vendor_id_wiimote; product = product_id_wiimoteplus; } IntPtr ptr = HIDapi.hid_enumerate(vendor, product); IntPtr cur_ptr = ptr; if (ptr == IntPtr.Zero) return false; hid_device_info enumerate = (hid_device_info)Marshal.PtrToStructure(ptr, typeof(hid_device_info)); bool found = false; while (cur_ptr != IntPtr.Zero) { Wiimote remote = null; bool fin = false; foreach (Wiimote r in Wiimotes) { if (fin) continue; if (r.hidapi_path.Equals(enumerate.path)) { remote = r; fin = true; } } if (remote == null) { IntPtr handle = HIDapi.hid_open_path(enumerate.path); WiimoteType trueType = type; // Wii U Pro Controllers have the same identifiers as the newer Wii Remote Plus except for product // string (WHY nintendo...) if (enumerate.product_string.EndsWith("UC")) trueType = WiimoteType.PROCONTROLLER; remote = new Wiimote(handle, enumerate.path, trueType); if (Debug_Messages) Debug.Log("Found New Remote: " + remote.hidapi_path); Wiimotes.Add(remote); remote.SendDataReportMode(InputDataType.REPORT_BUTTONS); remote.SendStatusInfoRequest(); } cur_ptr = enumerate.next; if (cur_ptr != IntPtr.Zero) enumerate = (hid_device_info)Marshal.PtrToStructure(cur_ptr, typeof(hid_device_info)); } HIDapi.hid_free_enumeration(ptr); return found; }
public IRData(Wiimote Owner) : base(Owner) { _ir = new int[4, 8]; _ir_readonly = new ReadOnlyMatrix<int>(_ir); }
public StatusData(Wiimote Owner) : base(Owner) { _led = new bool[4]; _led_readonly = new ReadOnlyArray <bool>(_led); }
public ClassicControllerData(Wiimote owner) : base(owner) { _lstick = new byte[2]; _lstick_readonly = new ReadOnlyArray<byte>(_lstick); _rstick = new byte[2]; _rstick_readonly = new ReadOnlyArray<byte>(_rstick); }
/// \brief Disables the given \c Wiimote by closing its bluetooth HID connection. Also removes the remote from Wiimotes /// \param remote The remote to cleanup public static void Cleanup(Wiimote remote) { if (remote.hidapi_handle != IntPtr.Zero) HIDapi.hid_close(remote.hidapi_handle); Wiimotes.Remove(remote); }
private static bool _FindWiimotes(WiimoteType type) { //if (hidapi_wiimote != IntPtr.Zero) // HIDapi.hid_close(hidapi_wiimote); ushort vendor = 0; ushort product = 0; if(type == WiimoteType.WIIMOTE) { vendor = vendor_id_wiimote; product = product_id_wiimote; } else if(type == WiimoteType.WIIMOTEPLUS || type == WiimoteType.PROCONTROLLER) { vendor = vendor_id_wiimote; product = product_id_wiimoteplus; } IntPtr ptr = HIDapi.hid_enumerate(vendor, product); IntPtr cur_ptr = ptr; if (ptr == IntPtr.Zero) return false; hid_device_info enumerate = (hid_device_info)Marshal.PtrToStructure(ptr, typeof(hid_device_info)); bool found = false; while(cur_ptr != IntPtr.Zero) { Wiimote remote = null; bool fin = false; foreach (Wiimote r in Wiimotes) { if (fin) continue; if (r.hidapi_path.Equals(enumerate.path)) { remote = r; fin = true; } } if (remote == null) { IntPtr handle = HIDapi.hid_open_path(enumerate.path); WiimoteType trueType = type; // Wii U Pro Controllers have the same identifiers as the newer Wii Remote Plus except for product // string (WHY nintendo...) if(enumerate.product_string.EndsWith("UC")) trueType = WiimoteType.PROCONTROLLER; remote = new Wiimote(handle, enumerate.path, trueType); if (Debug_Messages) Debug.Log("Found New Remote: " + remote.hidapi_path); Wiimotes.Add(remote); remote.SendDataReportMode(InputDataType.REPORT_BUTTONS); remote.SendStatusInfoRequest(); } cur_ptr = enumerate.next; if(cur_ptr != IntPtr.Zero) enumerate = (hid_device_info)Marshal.PtrToStructure(cur_ptr, typeof(hid_device_info)); } HIDapi.hid_free_enumeration(ptr); return found; }
private Wiimote wm; // wiiリモコンハンドル public WiimoteSpeaker(Wiimote Owner) : base(Owner) { }