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); }
private bool Subscribe(UserIndex controllerId, XInputSubscriptionRequest subReq, dynamic handler, string id, int povDirection = 0) { lock (stickSubscriptions.XInputSticks) { return(stickSubscriptions.Add(controllerId, subReq, handler, id, povDirection)); } }
private bool UnSubscribe(UserIndex controllerId, XInputSubscriptionRequest subReq, string id, int povDirection = 0) { // Block the Monitor thread from polling while we update the data structures lock (stickSubscriptions.XInputSticks) { return(stickSubscriptions.Remove(controllerId, subReq, id, povDirection)); } }
public bool Remove(UserIndex controllerId, XInputSubscriptionRequest subReq, string id, int povDirection = 0) { if (!XInputSticks.ContainsKey(controllerId)) { return(false); } var ret = XInputSticks[controllerId].Remove(subReq, id, povDirection); RemoveStickIfEmpty(controllerId); return(ret); }
// XInput public bool Add(UserIndex controllerId, XInputSubscriptionRequest subReq, dynamic handler, string subscriberId, int povDirection = 0) { if (!RegisterStick(controllerId)) { return(false); } if (!XInputSticks[controllerId].Add(subReq, handler, subscriberId, povDirection)) { //RemoveStickIfEmpty(controllerId); // If the stick was valid, but non-existent axis or button, then remove the stick again if it is empty return(false); } SetMonitorState(); return(true); }
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); }
public bool UnSubscribeXboxPovDirection(int controllerId, int povDirection, string subscriberId = "0") { var subReq = new XInputSubscriptionRequest(XIInputType.Dpad, povDirection); return(UnSubscribe((UserIndex)controllerId - 1, subReq, subscriberId)); }
public bool UnSubscribeXboxButton(int controllerId, int buttonId, string subscriberId = "0") { var subReq = new XInputSubscriptionRequest(XIInputType.Button, buttonId); return(UnSubscribe((UserIndex)controllerId - 1, subReq, subscriberId)); }
public bool UnSubscribeXboxAxis(int controllerId, int axisId, string subscriberId = "0") { var subReq = new XInputSubscriptionRequest(XIInputType.Axis, axisId); return(UnSubscribe((UserIndex)controllerId - 1, subReq, subscriberId)); }