private void OnTapReady(TAPDevice tap, bool success) { this.pending.Remove(tap.Identifier); if (success) { TAPManagerLog.Instance.Log(TAPManagerLogEvent.Info, "TAP is Ready:" + tap.GetStringDescription()); tap.sendMode(); tap.SetEventActions(this.OnTapTapped, this.OnTapMoused); if (this.OnTapConnected != null) { this.OnTapConnected(tap.Identifier, tap.Name, tap.FW); } if (leftId == "") { leftId = tap.Identifier; } else { rightId = tap.Identifier; } } else { TAPManagerLog.Instance.Log(TAPManagerLogEvent.Error, "Couldn't make TAP Ready: " + tap.GetStringDescription()); this.taps.Remove(tap.Identifier); } }
private void PerformTapAction(Action <TAPDevice> action, string identifier = "") { if (!identifier.Equals("")) { TAPDevice tap; if (this.taps.TryGetValue(identifier, out tap)) { action(tap); } } else { foreach (KeyValuePair <string, TAPDevice> kv in this.taps) { TAPDevice tap = kv.Value; action(tap); } } }
private async void dw_added(DeviceWatcher sender, DeviceInformation deviceInfo) { TAPManagerLog.Instance.Log(TAPManagerLogEvent.Info, "Device Watcher added proc."); if ((bool)deviceInfo.Properties[this.property_IsConnected] == true && (bool)deviceInfo.Properties[this.property_IsPaired] == true) { if (taps.ContainsKey(deviceInfo.Id) && !pending.Contains(deviceInfo.Id)) { if (taps[deviceInfo.Id].IsConnected) { TAPManagerLog.Instance.Log(TAPManagerLogEvent.Info, string.Format("TAP {0} Reconnected. Making it ready...", taps[deviceInfo.Id].GetStringDescription())); await taps[deviceInfo.Id].Reconnect(this.defaultInputMode); //taps[deviceInfo.Id].MakeReady(); //this.OnTapReady(taps[deviceInfo.Id], true); } return; } TAPManagerLog.Instance.Log(TAPManagerLogEvent.Info, string.Format("Found Connected Device {0}", deviceInfo.Name)); if (!taps.ContainsKey(deviceInfo.Id) && !pending.Contains(deviceInfo.Id)) { TAPManagerLog.Instance.Log(TAPManagerLogEvent.Info, string.Format("{0} Is a new device. Checking if it's a TAP", deviceInfo.Name)); pending.Add(deviceInfo.Id); BluetoothLEDevice device = await BluetoothLEDevice.FromIdAsync(deviceInfo.Id); TAPDevice t = await TAPDevice.FromBluetoothLEDeviceAsync(device, this.defaultInputMode); if (t != null) { TAPManagerLog.Instance.Log(TAPManagerLogEvent.Info, "Found a connected TAP: " + t.GetStringDescription() + ". Making it ready..."); t.OnTapReady += OnTapReady; taps.Add(deviceInfo.Id, t); t.MakeReady(); } else { TAPManagerLog.Instance.Log(TAPManagerLogEvent.Info, string.Format("{0} Is Not a TAP", deviceInfo.Name)); pending.Remove(deviceInfo.Id); } } } }
public void SetTapInputMode(TAPInputMode newInputMode, string identifier = "") { if (newInputMode == TAPInputMode.Null) { return; } if (identifier != "") { TAPDevice tap; if (this.taps.TryGetValue(identifier, out tap)) { tap.InputMode = newInputMode; if (this.activated) { tap.sendMode(); } else { tap.sendMode(this.inputModeWhenDeactivated); } } } else { this.defaultInputMode = newInputMode; foreach (KeyValuePair <string, TAPDevice> kv in this.taps) { TAPDevice tap = kv.Value; tap.InputMode = newInputMode; if (this.activated) { tap.sendMode(); } else { tap.sendMode(this.inputModeWhenDeactivated); } } } }
private void OnTapReady(TAPDevice tap, bool success) { this.pending.Remove(tap.Identifier); if (success) { TAPManagerLog.Instance.Log(TAPManagerLogEvent.Info, "TAP is Ready:" + tap.GetStringDescription()); tap.sendMode(); tap.SetEventActions(this.OnTapTapped, this.OnTapMoused, this.OnTapChangedAirGestureState, this.OnTapAirGestured, this.OnTapRawSensorDataReceived); if (this.OnTapConnected != null) { this.OnTapConnected(tap.Identifier, tap.Name, tap.FW); } } else { TAPManagerLog.Instance.Log(TAPManagerLogEvent.Error, "Couldn't make TAP Ready: " + tap.GetStringDescription()); this.taps.Remove(tap.Identifier); } }