コード例 #1
0
    private static bool _FindWiimotes(WiimoteType a_MoteType)
    {
        ushort uVendor = 0;
        ushort uProduct = 0;

        if(a_MoteType == WiimoteType.WIIMOTE) {
            uVendor = c_uVendorIDWiiMote;
            uProduct = c_uProductIDWiiMote;
        }

        IntPtr ptr = CS_HIDapi.hid_enumerate(uVendor, uProduct);
        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 bHasFound = false;

        while(cur_ptr != IntPtr.Zero)
        {
            CS_WiiMote Remote = null;
            bool bEnd = false;
            foreach (CS_WiiMote r in Wiimotes)
            {
                if (bEnd)
                    continue;

                if (r.hidapi_path.Equals(enumerate.path))
                {
                    Remote = r;
                    bEnd = true;
                }
            }
            if (Remote == null)
            {
                IntPtr handle = CS_HIDapi.hid_open_path(enumerate.path);

                Remote = new CS_WiiMote(handle, enumerate.path, a_MoteType);

                if (bDebugMessages)
                    Debug.Log("Found New Remote: " + Remote.hidapi_path);

                Wiimotes.Add(Remote);
                Remote.SendStatusInfoRequest();
            }

            cur_ptr = enumerate.next;
            if(cur_ptr != IntPtr.Zero)
                enumerate = (hid_device_info)Marshal.PtrToStructure(cur_ptr, typeof(hid_device_info));
        }

        CS_HIDapi.hid_free_enumeration(ptr);

        return bHasFound;
    }
コード例 #2
0
    // Disables the given Wiimote by closing its bluetooth HID connection.  Also removes the remote from Wiimotes
    // Not Currently Implemented
    public static void Clean(CS_WiiMote remote)
    {
        if (remote != null)
		{
			if (remote.hidapi_handle != IntPtr.Zero)
				CS_HIDapi.hid_close (remote.hidapi_handle);

			Wiimotes.Remove (remote);
		}
    }
コード例 #3
0
 public CS_NunchuckData(CS_WiiMote Owner)
     : base(Owner)
 {
     _stick          = new byte[2];
     _stick_readonly = new CS_ReadOnlyArray <byte>(_stick);
 }
コード例 #4
0
 //Can be extended to take into account other extensions or battery levels
 public CS_StatusData(CS_WiiMote Owner)
     : base(Owner)
 {
     //Constructor
 }
コード例 #5
0
 public CS_WiiMoteData(CS_WiiMote a_Owner)
 {
     this.Owner = a_Owner;
 }