Ejemplo n.º 1
0
 static void Main()
 {
     TAPManager.Instance.SetTapInputMode(TAPInputMode.RawSensor(new RawSensorSensitivity()));
     Application.EnableVisualStyles();
     Application.SetCompatibleTextRenderingDefault(false);
     Application.Run(new Form1());
 }
Ejemplo n.º 2
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)
                        {
                            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
        //-----------------------------------
        //             Mouse MODE
        //-----------------------------------


        private void btn_mouse_Click(object sender, RoutedEventArgs e)
        {
            TAPManager.Instance.OnMoused += OnMoused;
            TAPManager.Instance.SetTapInputMode(TAPInputMode.Controller());
            TAPManager.Instance.SetTapInputMode(TAPInputMode.ControllerWithMouseHID());
            TAPManager.Instance.SetTapInputMode(TAPInputMode.Text());

            TAPManager.Instance.Start();
        }
Ejemplo n.º 4
0
 private TAPManager()
 {
     this.activated                = false;
     this.defaultInputMode         = TAPInputMode.Controller_With_MouseHID;
     this.inputModeWhenDeactivated = TAPInputMode.Text;
     this.started        = false;
     this.taps           = new Dictionary <string, TAPDevice>();
     this.pending        = new HashSet <string>();
     this.restartWatcher = false;
 }
Ejemplo n.º 5
0
 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.fwChar        = null;
     this.tapDataValueChangedAssigned   = false;
     this.mouseDataValueChangedAssigned = false;
 }
        //--------------------------
        //        TAP STRAP
        //--------------------------

        protected override void OnActivated(EventArgs e)
        {
            base.OnActivated(e);
            if (this.Once)
            {
                this.Once = false;
                TAPManager.Instance.OnTapped += this.OnTapped;

                TAPManager.Instance.SetDefaultInputMode(TAPInputMode.Text(), true);
                TAPManager.Instance.Start();
            }
        }
Ejemplo n.º 7
0
        //-----------------------------------
        //             RAW MODE
        //-----------------------------------

        private void btn_raw_Click(object sender, RoutedEventArgs e)
        {
            ///Setup Raw Mode
            TAPManager.Instance.OnRawSensorDataReceieved += OnRawSensorDataReceieved;
            ///Setup Sensitivity of the device accelerometre, mouse gyro, mouse accelerometre
            byte deviceAccelerometerSensitivity = 1;
            byte imuGyroSensitivity             = 2;
            byte imuAccelerometerSensitivity    = 1;

            TAPManager.Instance.SetTapInputMode(TAPInputMode.RawSensor(new RawSensorSensitivity(deviceAccelerometerSensitivity, imuGyroSensitivity, imuAccelerometerSensitivity)));

            TAPManager.Instance.Start();
        }
Ejemplo n.º 8
0
 private void button2_Click(object sender, EventArgs e)
 {
     if (!this.rawMode)
     {
         TAPManager.Instance.SetTapInputMode(TAPInputMode.RawSensor(new RawSensorSensitivity()));
         Console.WriteLine("Turn to RawSensor mode");
         this.LogLine("Turn to RawSensor mode");
     }
     else
     {
         TAPManager.Instance.SetTapInputMode(TAPInputMode.Text());
         Console.WriteLine("Turn to text mode");
         this.LogLine("Turn to text mode");
     }
     this.rawMode = !this.rawMode;
 }
Ejemplo n.º 9
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.º 10
0
        protected override void OnActivated(EventArgs e)
        {
            base.OnActivated(e);
            if (this.once)
            {
                this.once = false;
                TAPManager.Instance.OnMoused          += this.OnMoused;
                TAPManager.Instance.OnTapped          += this.OnTapped;
                TAPManager.Instance.OnTapConnected    += this.OnTapConnected;
                TAPManager.Instance.OnTapDisconnected += this.OnTapDisconnected;

                TAPManager.Instance.OnAirGestured            += this.OnAirGestured;
                TAPManager.Instance.OnChangedAirGestureState += this.OnChangedAirGestureState;
                TAPManager.Instance.OnRawSensorDataReceieved += this.OnRawSensorDataReceieved;


                TAPManager.Instance.SetDefaultInputMode(TAPInputMode.Controller(), true);
                TAPManager.Instance.Start();
            }
        }
Ejemplo n.º 11
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);
                    }
                }
            }
        }
Ejemplo n.º 12
0
        protected override void OnActivated(EventArgs e)
        {
            base.OnActivated(e);
            if (this.once)
            {
                this.once = false;
                TAPManager.Instance.OnMoused          += this.OnMoused;
                TAPManager.Instance.OnTapped          += this.OnTapped;
                TAPManager.Instance.OnTapConnected    += this.OnTapConnected;
                TAPManager.Instance.OnTapDisconnected += this.OnTapDisconnected;

                TAPManager.Instance.OnAirGestured            += this.OnAirGestured;
                TAPManager.Instance.OnChangedAirGestureState += this.OnChangedAirGestureState;
                TAPManager.Instance.OnRawSensorDataReceieved += this.OnRawSensorDataReceieved;


                TAPManager.Instance.SetTapInputMode(TAPInputMode.RawSensor(new RawSensorSensitivity()));
                counter = 0;
                //button1.Click += new EventHandler(button1_Click);
                TAPManager.Instance.Start();
            }
        }
Ejemplo n.º 13
0
 private void OnTapConnected(string identifier, string name, int fw)
 {
     this.LogLine(identifier + " connected. (" + name + ", fw " + fw.ToString() + ")");
     TAPManager.Instance.SetTapInputMode(TAPInputMode.RawSensor(new RawSensorSensitivity()));
 }
Ejemplo n.º 14
0
 public Form1()
 {
     this.once = true;
     TAPManager.Instance.SetTapInputMode(TAPInputMode.RawSensor(new RawSensorSensitivity()));
     InitializeComponent();
 }
Ejemplo n.º 15
0
        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;
                return(t);
            }

            return(null);
        }