Пример #1
0
        PointerData[] CreateMultiPointerInputActions(
            IList <PointI> locations,
            POINTER_FLAGS flag,
            IList <uint> pointerIds = null)
        {
            var pointerDataArray = new PointerData[locations.Count];

            for (var index = 0; index < locations.Count; ++index)
            {
                pointerDataArray[index].flags     = flag | POINTER_FLAGS.CONFIDENCE | POINTER_FLAGS.PRIMARY;
                pointerDataArray[index].location  = locations[index : index];
                pointerDataArray[index].pointerId = pointerIds != null ? pointerIds[index : index] : (uint)index;
            }

            return(pointerDataArray);
        }
Пример #2
0
        public void InjectDynamicPointers(PointerData[] pointerDataArray)
        {
            lock (this.downPressLock) {
                var dictionary = new Dictionary <uint, PointerData>(dictionary: this._activePointerStates);
                foreach (var pointerData1 in pointerDataArray)
                {
                    var pointerId = pointerData1.pointerId;
                    if ((pointerData1.flags & POINTER_FLAGS.ContactDown) == POINTER_FLAGS.ContactDown)
                    {
                        dictionary[key : pointerId] = pointerData1;
                        var pointerData2 = pointerData1;
                        pointerData2.flags = POINTER_FLAGS.ContactMoves;
                        this._activePointerStates[key : pointerId] = pointerData2;
                    }
                    else if ((pointerData1.flags & POINTER_FLAGS.ContactMoves) == POINTER_FLAGS.ContactMoves)
                    {
                        if (!this._activePointerStates.ContainsKey(key: pointerId))
                        {
                            throw new ArgumentException(message: "$Contact moves cannot take place before contact down: {contactId}");
                        }
                        dictionary[key : pointerId] = pointerData1;
                        this._activePointerStates[key : pointerId] = pointerData1;
                    }
                    else
                    {
                        dictionary[key : pointerId] = (pointerData1.flags & POINTER_FLAGS.UP) == POINTER_FLAGS.UP ? pointerData1 : throw new Exception(message : "Unexpected condition!");
                        this._activePointerStates.Remove(key: pointerId);
                    }
                }

                var pointerDataArray1 = new PointerData[dictionary.Count];
                dictionary.Values.CopyTo(array: pointerDataArray1, index: 0);
                this.backgroundInputActions.AddRange(collection: this.inputAlgorithms.DynamicPointerActions(pointerDataArray: pointerDataArray1));
            }

            if (this._activePointerStates.Count <= 0)
            {
                return;
            }
            while (this.backgroundInputActions.Count > 0)
            {
                _StartDownpressThread();
                Thread.Sleep(millisecondsTimeout: (int)DefaultPacketDelta);
            }
        }
Пример #3
0
        InjectedInputPenInfo GetInjectedInputPenInfo(PointerData pointerData)
        {
            var injectedInputPenInfo = new InjectedInputPenInfo();

            injectedInputPenInfo.PenParameters = 0;
            InjectedInputPoint injectedInputPoint;

            injectedInputPoint.PositionX = pointerData.location.X;
            injectedInputPoint.PositionY = pointerData.location.Y;
            InjectedInputPointerInfo inputPointerInfo;

            inputPointerInfo.PointerOptions           = (InjectedInputPointerOptions)(int)pointerData.flags;
            inputPointerInfo.PointerId                = (uint)(int)pointerData.pointerId;
            inputPointerInfo.PixelLocation            = injectedInputPoint;
            inputPointerInfo.PerformanceCount         = 0L;
            inputPointerInfo.TimeOffsetInMilliseconds = 0;
            injectedInputPenInfo.PointerInfo          = inputPointerInfo;
            return(injectedInputPenInfo);
        }
Пример #4
0
 public virtual void InjectPointer(PointerData pointerData)
 {
     throw new NotImplementedException(message: "InjectPointer is not implemented in this InputDevice object");
 }
        protected PointerTypeInfo TransformPointer(
            PointerData pointerData,
            POINTER_INPUT_TYPE inputType)
        {
            var pointerTypeInfo = new PointerTypeInfo();

            pointerTypeInfo.type = inputType;
            var pointerInfo = new PointerInfo();

            pointerInfo.pointerType   = inputType;
            pointerInfo.pointerId     = pointerData.pointerId;
            pointerInfo.pointerFlags  = pointerData.flags;
            pointerInfo.pixelLocation = pointerData.location;
            switch (inputType)
            {
            case POINTER_INPUT_TYPE.TOUCH:
                pointerTypeInfo.data.touchInfo.pointerInfo = pointerInfo;
                pointerTypeInfo.data.touchInfo.touchMask   = TOUCH_MASK.NONE;
                pointerTypeInfo.data.touchInfo.touchFlags  = (TOUCH_FLAGS)pointerData.pressedButton;
                if (pointerData.width.HasValue && pointerData.height.HasValue)
                {
                    pointerTypeInfo.data.touchInfo.contact = new Rect {
                        left   = pointerTypeInfo.data.touchInfo.pointerInfo.pixelLocation.X - pointerData.width.Value / 2,
                        right  = pointerTypeInfo.data.touchInfo.pointerInfo.pixelLocation.X + pointerData.width.Value / 2,
                        top    = pointerTypeInfo.data.touchInfo.pointerInfo.pixelLocation.Y - pointerData.height.Value / 2,
                        bottom = pointerTypeInfo.data.touchInfo.pointerInfo.pixelLocation.Y + pointerData.height.Value / 2
                    };
                    pointerTypeInfo.data.touchInfo.touchMask |= TOUCH_MASK.CONTACTAREA;
                }

                if (pointerData.pressure.HasValue)
                {
                    pointerTypeInfo.data.touchInfo.pressure   = pointerData.pressure.Value;
                    pointerTypeInfo.data.touchInfo.touchMask |= TOUCH_MASK.PRESSURE;
                }

                if (pointerData.twist.HasValue)
                {
                    pointerTypeInfo.data.touchInfo.orientation = pointerData.twist.Value;
                    pointerTypeInfo.data.touchInfo.touchMask  |= TOUCH_MASK.ORIENTATION;
                }

                break;

            case POINTER_INPUT_TYPE.PEN:
                pointerTypeInfo.data.penInfo.pointerInfo = pointerInfo;
                pointerTypeInfo.data.penInfo.penMask     = PEN_MASK.NONE;
                pointerTypeInfo.data.penInfo.penFlags    = (PEN_FLAGS)pointerData.pressedButton;
                if (pointerData.tiltX.HasValue)
                {
                    pointerTypeInfo.data.penInfo.tiltX    = pointerData.tiltX.Value;
                    pointerTypeInfo.data.penInfo.penMask |= PEN_MASK.TILT_X;
                }

                if (pointerData.tiltY.HasValue)
                {
                    pointerTypeInfo.data.penInfo.tiltY    = pointerData.tiltY.Value;
                    pointerTypeInfo.data.penInfo.penMask |= PEN_MASK.TILT_Y;
                }

                if (pointerData.pressure.HasValue)
                {
                    pointerTypeInfo.data.penInfo.pressure = pointerData.pressure.Value;
                    pointerTypeInfo.data.penInfo.penMask |= PEN_MASK.PRESSURE;
                }

                if (pointerData.twist.HasValue)
                {
                    pointerTypeInfo.data.penInfo.rotation = pointerData.twist.Value;
                    pointerTypeInfo.data.penInfo.penMask |= PEN_MASK.ROTATION;
                }

                break;

            default:
                pointerTypeInfo.data.touchInfo.pointerInfo = pointerInfo;
                pointerTypeInfo.data.touchInfo.touchMask   = TOUCH_MASK.NONE;
                break;
            }

            return(pointerTypeInfo);
        }
Пример #6
0
 public override void InjectPointer(PointerData pointerData)
 {
     Log.Out(msg: "Inject Pointer: {0}", (object)pointerData.ToString());
     this.injector.InjectPenInput(input: GetInjectedInputPenInfo(pointerData: pointerData));
 }