Esempio n. 1
0
            public bool Add(XInputSubscriptionRequest subReq, dynamic handler, string subscriberId, int povDirection)
            {
                switch (subReq.InputType)
                {
                case XIInputType.Axis:
                    //var axisId = (xinputAxes)subReq.InputIndex;
                    var axisId = subReq.InputIndex;
                    if (!SubscribedAxes.ContainsKey(axisId))
                    {
                        SubscribedAxes.Add(axisId, new SubscribedXIInput());
                    }
                    SubscribedAxes[axisId].Add(handler, subscriberId, povDirection);
                    break;

                case XIInputType.Button:
                    var buttonId = subReq.InputIndex;
                    if (!SubscribedButtons.ContainsKey(buttonId))
                    {
                        SubscribedButtons.Add(buttonId, new SubscribedXIInput());
                    }
                    SubscribedButtons[buttonId].Add(handler, subscriberId, povDirection);
                    break;

                case XIInputType.Dpad:
                    povDirection = subReq.InputIndex;
                    if (!SubscribedDpadDirections.ContainsKey(povDirection))
                    {
                        SubscribedDpadDirections.Add(povDirection, new SubscribedXIInput());
                    }
                    SubscribedDpadDirections[povDirection].Add(handler, subscriberId, 0);
                    break;
                }
                return(true);
            }
Esempio n. 2
0
            public bool Remove(XInputSubscriptionRequest subReq, string subscriberId, int povDirection)
            {
                bool ret;

                switch (subReq.InputType)
                {
                case XIInputType.Axis:
                    if (!SubscribedAxes.ContainsKey(subReq.InputIndex))
                    {
                        return(false);
                    }
                    ret = SubscribedAxes[subReq.InputIndex].Remove(subscriberId, povDirection);
                    if (SubscribedAxes[subReq.InputIndex].IsEmpty())
                    {
                        SubscribedAxes.Remove(subReq.InputIndex);
                    }
                    return(ret);

                case XIInputType.Button:
                    if (!SubscribedButtons.ContainsKey(subReq.InputIndex))
                    {
                        return(false);
                    }
                    ret = SubscribedButtons[subReq.InputIndex].Remove(subscriberId, povDirection);
                    if (SubscribedButtons[subReq.InputIndex].IsEmpty())
                    {
                        SubscribedButtons.Remove(subReq.InputIndex);
                    }
                    return(ret);

                case XIInputType.Dpad:
                    if (!SubscribedDpadDirections.ContainsKey(subReq.InputIndex))
                    {
                        return(false);
                    }
                    ret = SubscribedDpadDirections[subReq.InputIndex].Remove(subscriberId, povDirection);
                    if (SubscribedDpadDirections[subReq.InputIndex].IsEmpty())
                    {
                        SubscribedDpadDirections.Remove(subReq.InputIndex);
                    }
                    return(ret);
                }
                return(true);
            }