예제 #1
0
        public override Task WriteValueAsyncInternal(byte[] aValue,
                                                     ButtplugDeviceWriteOptions aOptions,
                                                     CancellationToken aToken = default(CancellationToken))
        {
            LastWritten.Add(new WriteData()
            {
                Value             = (byte[])aValue.Clone(),
                Endpoint          = aOptions.Endpoint,
                WriteWithResponse = aOptions.WriteWithResponse,
            });
            ValueWritten?.Invoke(this, new EventArgs());
            try
            {
                var valueStr = Encoding.UTF8.GetString(aValue, 0, aValue.Length);
                if (ExpectedNotify.ContainsKey(valueStr))
                {
                    InvokeDataReceived(new ButtplugDeviceDataEventArgs("tx", ExpectedNotify[valueStr]));
                }
            }
            catch
            {
                // noop.
            }

            return(Task.CompletedTask);
        }
예제 #2
0
 public Task <ButtplugMessage> WriteValueAsync(uint aMsgId, uint aCharacteristic, byte[] aValue, bool aWriteWithResponse, CancellationToken aToken)
 {
     LastWritten.Add(new WriteData()
     {
         Value             = (byte[])aValue.Clone(),
         MsgId             = aMsgId,
         Characteristic    = aCharacteristic,
         WriteWithResponse = aWriteWithResponse,
     });
     ValueWritten?.Invoke(this, new EventArgs());
     return(Task.FromResult <ButtplugMessage>(new Ok(aMsgId)));
 }
예제 #3
0
 public override Task WriteValueAsyncInternal(byte[] aValue,
                                              ButtplugDeviceWriteOptions aOptions,
                                              CancellationToken aToken = default(CancellationToken))
 {
     LastWritten.Add(new WriteData()
     {
         Value             = (byte[])aValue.Clone(),
         Endpoint          = aOptions.Endpoint,
         WriteWithResponse = aOptions.WriteWithResponse,
     });
     ValueWritten?.Invoke(this, new EventArgs());
     return(Task.CompletedTask);
 }
예제 #4
0
        public void Write(bool advanceCursor = true, params T[] vals)
        {
            if (vals.Length == 0)
            {
                return;
            }
            var curX = CursorX.Value;
            var curY = CursorY.Value;

            _raisePosChanged = false;
            foreach (var ele in vals)
            {
                _buffer[CurrentPos()] = ele;
                MoveRight();
            }
            ValueWritten?.Invoke(this, vals);
            if (!advanceCursor)
            {
                CursorX.Value = curX;
                CursorY.Value = curY;
            }
            RaisePosChanged();
            _raisePosChanged = true;
        }
예제 #5
0
 private void RaiseValueWritten()
 => ValueWritten?.Invoke(this, EventArgs.Empty);