Ejemplo n.º 1
0
        public async void sendMode(TAPInputMode overrideMode = TAPInputMode.Null)
        {
            TAPInputMode mode = overrideMode == TAPInputMode.Null ? this.InputMode : overrideMode;

            if (mode != TAPInputMode.Null)
            {
                if (this.isReady && this.IsConnected)
                {
                    if (mode != TAPInputMode.Null)
                    {
                        if (mode == TAPInputMode.Controller_With_MouseHID && this.fw < 010615)
                        {
                            Debug.WriteLine("NOT SUPPORTED");
                            mode = TAPInputMode.Controller;
                        }

                        DataWriter writer = new DataWriter();

                        byte[] data = { 0x3, 0xc, 0x0, (byte)mode };
                        writer.WriteBytes(data);
                        TAPManagerLog.Instance.Log(TAPManagerLogEvent.Info, String.Format("TAP {0} ({1}) Sent mode ({2})", this.Name, this.Identifier, mode.ToString()));
                        GattCommunicationStatus result = await rx.WriteValueAsync(writer.DetachBuffer(), GattWriteOption.WriteWithoutResponse);
                    }
                }
            }
        }
        public async void sendMode(TAPInputMode overrideMode = null)
        {
            if (this.isReady && this.IsConnected)
            {
                TAPInputMode mode = overrideMode == null ? this.InputMode : overrideMode;
                mode = mode.makeCompatibleWithFWVersion(this.fw);
                if (mode.isValid)
                {
                    byte[] data = mode.getBytes();
                    Debug.WriteLine("[{0}]", string.Join(", ", data));
                    DataWriter writer = new DataWriter();
                    writer.WriteBytes(data);
                    GattCommunicationStatus result = await rx.WriteValueAsync(writer.DetachBuffer(), GattWriteOption.WriteWithoutResponse);



                    //if (mode != TAPInputMode.Null)
                    //{

                    //    if (mode == TAPInputMode.Controller_With_MouseHID && this.fw < 010615) {
                    //        Debug.WriteLine("NOT SUPPORTED");
                    //        mode = TAPInputMode.Controller;
                    //    }

                    //    DataWriter writer = new DataWriter();

                    //    byte[] data = { 0x3, 0xc, 0x0, (byte)mode };
                    //    writer.WriteBytes(data);
                    //    TAPManagerLog.Instance.Log(TAPManagerLogEvent.Info, String.Format("TAP {0} ({1}) Sent mode ({2})", this.Name, this.Identifier, mode.ToString()));
                    //    GattCommunicationStatus result = await rx.WriteValueAsync(writer.DetachBuffer(), GattWriteOption.WriteWithoutResponse);
                    //}
                }
            }
        }
Ejemplo n.º 3
0
 private TAPManager()
 {
     this.activated                = false;
     this.defaultInputMode         = TAPInputMode.Controller();
     this.inputModeWhenDeactivated = TAPInputMode.Text();
     this.started        = false;
     this.taps           = new Dictionary <string, TAPDevice>();
     this.pending        = new HashSet <string>();
     this.restartWatcher = false;
 }
Ejemplo n.º 4
0
 //internal void Finalize()
 //{
 //    Debug.WriteLine("DESTRUCATOR");
 //    device.Dispose();
 //    device = null;
 //    tapData = null;
 //    rx = null;
 //    mouseData = null;
 //}
 private TAPDevice(BluetoothLEDevice d, TAPInputMode mode)
 {
     this.fw            = 0;
     this.device        = d;
     this.isReady       = false;
     this.InputMode     = mode;
     this.mouseData     = null;
     this.supportsMouse = false;
     this.tapDataValueChangedAssigned   = false;
     this.mouseDataValueChangedAssigned = false;
 }
Ejemplo n.º 5
0
 internal TAPInputMode makeCompatibleWithFWVersion(int fwVersion)
 {
     if (this.mode.Equals(TAPInputMode.kControllerWithMouseHID) && fwVersion < 010615)
     {
         return(TAPInputMode.Controller());
     }
     else
     {
         return(this);
     }
 }
Ejemplo n.º 6
0
        internal async Task Reconnect(TAPInputMode inputMode)
        {
            this._inputMode = inputMode;
            if (tapData == null && rx == null && !this.IsConnected && !this.IsReady)
            {
                TAPProperties properties = await GetTAPPropertiesAsync(this.device);

                if (properties.tapData != null && properties.nusRx != null)
                {
                    tapData   = properties.tapData;
                    rx        = properties.nusRx;
                    mouseData = properties.mouseData;
                    fw        = properties.fwVersion;
                }
            }
            this.MakeReady();
        }
Ejemplo n.º 7
0
 public void SetTapInputMode(TAPInputMode newInputMode, string identifier = "")
 {
     if (!newInputMode.isValid)
     {
         return;
     }
     this.PerformTapAction((tap) =>
     {
         tap.InputMode = newInputMode;
         if (this.activated)
         {
             tap.sendMode();
         }
         else
         {
             tap.sendMode(this.inputModeWhenDeactivated);
         }
     });
 }
Ejemplo n.º 8
0
 public void SetDefaultInputMode(TAPInputMode newDefaultInputMode, bool applyToCurrentTaps)
 {
     this.defaultInputMode = newDefaultInputMode;
     if (applyToCurrentTaps)
     {
         this.PerformTapAction((tap) =>
         {
             tap.InputMode = newDefaultInputMode;
             if (this.activated)
             {
                 tap.sendMode();
             }
             else
             {
                 tap.sendMode(this.inputModeWhenDeactivated);
             }
         });
     }
 }
Ejemplo n.º 9
0
        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);
                    }
                }
            }
        }
        public static async Task <TAPDevice> FromBluetoothLEDeviceAsync(BluetoothLEDevice d, TAPInputMode inputMode)
        {
            TAPProperties properties = await GetTAPPropertiesAsync(d);

            if (properties.tapData != null && properties.nusRx != null)
            {
                TAPDevice t = new TAPDevice(d, inputMode);
                t.tapData         = properties.tapData;
                t.rx              = properties.nusRx;
                t.mouseData       = properties.mouseData;
                t.fw              = properties.fwVersion;
                t.airGesturesData = properties.airGestures;
                t.uiCommands      = properties.uiCommands;
                t.tx              = properties.nusTx;
                return(t);
            }

            return(null);
        }