示例#1
0
        /// <summary>
        /// A constructor that builds a HidContactInfo from a WiiContact and a HID state.
        /// </summary>
        /// <param name="eState"></param>
        /// <param name="contact"></param>
        internal HidContactInfo(HidContactState eState, WiiContact pContact)
        {
            // Save the state.
            State = eState;

            // If we have a contact then shoehorn its details into our class.
            if (pContact != null)
            {
                // Convert the ID.  Perhaps ensure we are going to work with larger values.
                Id = unchecked ((UInt16)pContact.ID);

                // Convert the point into HID space.
                Point tPoint = transformPoint(pContact.Position);
                X = Convert.ToUInt16(tPoint.X);
                Y = Convert.ToUInt16(tPoint.Y);

                // Save the width and height.
                Width  = Convert.ToUInt16(pContact.Size.X);
                Height = Convert.ToUInt16(pContact.Size.Y);

                // Compute the pressure from the area.
                Pressure = Convert.ToUInt16(Math.Max(0, Math.Min(MaxSize, pContact.Area)));

                // Save the timestamp and WiiContact.
                Timestamp = DateTime.Now;
                Contact   = pContact;
            }
        }
		private HidContactInfo CreateContact(HidContactState state, int id, int x, int y, int width, int height)
		{
			long timestamp = Stopwatch.GetTimestamp();

			ContactData data = new ContactData();
			data.Id = id;
			data.Position = new Point(x, y);
			data.MajorAxis = width;
			data.MinorAxis = height;
			data.Area = width * height;
			Contact contact = new Contact(data, IntPtr.Zero, timestamp);
			HidContactInfo hidContactInfo = new HidContactInfo(state, contact);
			return hidContactInfo;
		}
        private HidContactInfo CreateContact(HidContactState state, int id, int x, int y, int width, int height)
        {
            long timestamp = Stopwatch.GetTimestamp();

            ContactData data = new ContactData();

            data.Id        = id;
            data.Position  = new Point(x, y);
            data.MajorAxis = width;
            data.MinorAxis = height;
            data.Area      = width * height;
            Contact        contact        = new Contact(data, IntPtr.Zero, timestamp);
            HidContactInfo hidContactInfo = new HidContactInfo(state, contact);

            return(hidContactInfo);
        }
        internal HidContactInfo(HidContactState state, Contact contact)
        {
            State = state;
            if (contact != null)
            {
                Point point = GetPoint(contact.Position);
                X        = Convert.ToUInt16(point.X);
                Y        = Convert.ToUInt16(point.Y);
                Width    = Convert.ToUInt16(contact.MajorAxis);
                Height   = Convert.ToUInt16(contact.MinorAxis);
                Pressure = Convert.ToUInt16(Math.Max(0, Math.Min(MaxSize, contact.Area)));

                UInt16 id = unchecked ((UInt16)contact.Id);

                Id        = id;
                Timestamp = DateTime.Now;
                Contact   = contact;
            }
        }
示例#5
0
 /// <summary>
 /// Enqueue a new contact into the current list.
 /// </summary>
 /// <remarks>Yes I know it is horrible and iccky to do this here.. but yea..  I didn't want to expose too much of the HID stuff at this stage.</remarks>
 /// <param name="eState">The HidContactState of the contact.</param>
 /// <param name="pContact">The reference to the WiiContact generated by the provider.</param>
 public void enqueueContact(HidContactState eState, WiiContact pContact)
 {
     this.enqueueContact(new HidContactInfo(eState, pContact));
 }
示例#6
0
 /// <summary>
 /// Enqueue a new contact into the current list.
 /// </summary>
 /// <remarks>Yes I know it is horrible and iccky to do this here.. but yea..  I didn't want to expose too much of the HID stuff at this stage.</remarks>
 /// <param name="eState">The HidContactState of the contact.</param>
 /// <param name="pContact">The reference to the WiiContact generated by the provider.</param>
 public void enqueueContact(HidContactState eState, WiiContact pContact)
 {
     this.enqueueContact(new HidContactInfo(eState, pContact));
 }