예제 #1
0
 private void Characteristic_ValueChanged(Uap.GattCharacteristic sender, Uap.GattValueChangedEventArgs args)
 {
     OnCharacteristicValueChanged();
 }
예제 #2
0
 private void Characteristic_ValueChanged(Uap.GattCharacteristic sender, Uap.GattValueChangedEventArgs args)
 {
     OnCharacteristicValueChanged(new GattCharacteristicValueChangedEventArgs(args.CharacteristicValue.ToArray()));
 }
        private void SelectedCharacteristic_ValueChanged(Windows.Devices.Bluetooth.GenericAttributeProfile.GattCharacteristic sender, Windows.Devices.Bluetooth.GenericAttributeProfile.GattValueChangedEventArgs args)
        {
            if (eventData.Length != args.CharacteristicValue.Length)
            {
                eventData = new byte[args.CharacteristicValue.Length];
            }

            Windows.Storage.Streams.DataReader.FromBuffer(args.CharacteristicValue).ReadBytes(eventData);


            val1 = GetBitValue(388, 396);
            val2 = GetBitValue(404, 412);
            val3 = GetBitValue(418, 426);

            if (val1 == 0)
            {
                Console.WriteLine("elo!!!");
            }


            axisX = axisY = 0;

            axisY += (eventData[55] & (1 << 3)) != 0 ? (1 << 0) : 0;
            axisY += (eventData[55] & (1 << 4)) != 0 ? (1 << 1) : 0;
            axisY += (eventData[55] & (1 << 5)) != 0 ? (1 << 2) : 0;
            axisY += (eventData[55] & (1 << 6)) != 0 ? (1 << 3) : 0;
            axisY += (eventData[55] & (1 << 7)) != 0 ? (1 << 4) : 0;
            axisY += (eventData[54] & (1 << 0)) != 0 ? (1 << 5) : 0;
            axisY += (eventData[54] & (1 << 1)) != 0 ? (1 << 6) : 0;
            axisY += (eventData[54] & (1 << 2)) != 0 ? (1 << 7) : 0;

            axisX += (eventData[55] & (1 << 0)) != 0 ? (1 << 7) : 0;
            axisX += (eventData[56] & (1 << 7)) != 0 ? (1 << 6) : 0;
            axisX += (eventData[56] & (1 << 6)) != 0 ? (1 << 5) : 0;
            axisX += (eventData[56] & (1 << 5)) != 0 ? (1 << 4) : 0;
            axisX += (eventData[56] & (1 << 4)) != 0 ? (1 << 3) : 0;
            axisX += (eventData[56] & (1 << 3)) != 0 ? (1 << 2) : 0;
            axisX += (eventData[56] & (1 << 2)) != 0 ? (1 << 1) : 0;
            axisX += (eventData[56] & (1 << 1)) != 0 ? (1 << 0) : 0;



            BitArray bits = new BitArray(eventData);

            for (int i = 0; i < bits.Count; i++)
            {
                eventBits[i] = bits[i] ? 1 : 0;
                if (bits[i])
                {
                    if (eventAnalysis[i] < 0)
                    {
                        eventAnalysis[i] = 0;
                    }
                    else
                    {
                        eventAnalysis[i] = Math.Min(eventAnalysis[i] + 1, eventAnalysisThr);
                    }
                }
                else
                {
                    if (eventAnalysis[i] > 0)
                    {
                        eventAnalysis[i] = 0;
                    }
                    else
                    {
                        eventAnalysis[i] = Math.Max(eventAnalysis[i] - 1, -eventAnalysisThr);
                    }
                }
            }

            triggerButton    = 0 != (eventData[58] & (1 << 0));
            homeButton       = 0 != (eventData[58] & (1 << 1));
            backButton       = 0 != (eventData[58] & (1 << 2));
            touchpadButton   = 0 != (eventData[58] & (1 << 3));
            volumeDownButton = 0 != (eventData[58] & (1 << 4));
            volumeUpButton   = 0 != (eventData[58] & (1 << 5));
            touchpadPressed  = axisX != 0 && axisY != 0;
        }
예제 #4
0
 private void Characteristic_ValueChanged(Win.GattCharacteristic sender, Win.GattValueChangedEventArgs args)
 {
     OnValueChanged(args.CharacteristicValue.ToMemory());
 }