public Vibratissimo(IButtplugLogManager aLogManager, IBluetoothDeviceInterface aInterface, IBluetoothDeviceInfo aInfo) : base(aLogManager, $"Vibratissimo Device ({aInterface.Name})", aInterface, aInfo) { MsgFuncs.Add(typeof(SingleMotorVibrateCmd), HandleSingleMotorVibrateCmd); MsgFuncs.Add(typeof(StopDeviceCmd), HandleStopDeviceCmd); }
public DeviceManager(IButtplugLogManager aLogManager) { _bpLogManager = aLogManager; _bpLogger = _bpLogManager.GetLogger(GetType()); _bpLogger.Trace("Setting up DeviceManager"); _sentFinished = true; _devices = new Dictionary <uint, IButtplugDevice>(); _deviceIndexCounter = 0; _managers = new List <IDeviceSubtypeManager>(); }
protected HidButtplugDevice(IButtplugLogManager aLogManager, IHidDevice aHid, IHidDeviceInfo aDeviceInfo) : base(aLogManager, aDeviceInfo.Name, aHid.DevicePath) { LogManager = aLogManager; _hid = aHid; DeviceInfo = aDeviceInfo; _tokenSource = new CancellationTokenSource(); _hid.Inserted += DeviceAttachedHandler; _hid.Removed += DeviceRemovedHandler; }
public Lovense(IButtplugLogManager aLogManager, IBluetoothDeviceInterface aInterface, IBluetoothDeviceInfo aInfo) : base(aLogManager, $"Lovense Device ({friendlyNames[aInterface.Name]})", aInterface, aInfo) { MsgFuncs.Add(typeof(SingleMotorVibrateCmd), HandleSingleMotorVibrateCmd); MsgFuncs.Add(typeof(StopDeviceCmd), HandleStopDeviceCmd); }
public XInputGamepadDevice(IButtplugLogManager aLogManager, Controller aDevice) : base(aLogManager, "XBox Compatible Gamepad (XInput)", aDevice.UserIndex.ToString()) { _device = aDevice; MsgFuncs.Add(typeof(SingleMotorVibrateCmd), new ButtplugDeviceWrapper(HandleSingleMotorVibrateCmd)); MsgFuncs.Add(typeof(VibrateCmd), new ButtplugDeviceWrapper(HandleVibrateCmd, new MessageAttributes() { FeatureCount = 2 })); MsgFuncs.Add(typeof(StopDeviceCmd), new ButtplugDeviceWrapper(HandleStopDeviceCmd)); }
public TestProtocol(IButtplugLogManager aLogManager, IButtplugDeviceImpl aInterface) : base(aLogManager, "Test Device", aInterface) { Name = aInterface.Name; AddMessageHandler <SingleMotorVibrateCmd>(HandleSingleMotorVibrateCmd); AddMessageHandler <VibrateCmd>(HandleVibrateCmd, new MessageAttributes() { FeatureCount = 2 }); AddMessageHandler <StopDeviceCmd>(HandleStopDeviceCmd); }
public FleshlightLaunch([NotNull] IButtplugLogManager aLogManager, [NotNull] IBluetoothDeviceInterface aInterface, [NotNull] IBluetoothDeviceInfo aInfo) : base(aLogManager, "Fleshlight Launch", aInterface, aInfo) { // Setup message function array MsgFuncs.Add(typeof(FleshlightLaunchFW12Cmd), HandleFleshlightLaunchRawCmd); MsgFuncs.Add(typeof(StopDeviceCmd), HandleStopDeviceCmd); }
protected ButtplugBluetoothDevice([NotNull] IButtplugLogManager aLogManager, [NotNull] string aName, [NotNull] IBluetoothDeviceInterface aInterface, [NotNull] IBluetoothDeviceInfo aInfo) : base(aLogManager, aName, aInterface.Address.ToString()) { Interface = aInterface; Info = aInfo; Interface.DeviceRemoved += DeviceRemovedHandler; }
public VibratissimoProtocol(IButtplugLogManager aLogManager, IButtplugDeviceImpl aInterface) : base(aLogManager, $"Vibratissimo Device ({aInterface.Name})", aInterface) { AddMessageHandler <SingleMotorVibrateCmd>(HandleSingleMotorVibrateCmd); AddMessageHandler <VibrateCmd>(HandleVibrateCmd, new MessageAttributes { FeatureCount = 1 }); AddMessageHandler <StopDeviceCmd>(HandleStopDeviceCmd); }
public ButtplugWebsocketServerSession(IButtplugLogManager aLogManager, ButtplugServer aServer, WebSocket aSocket, CancellationTokenSource aExternalCancelSource) { _logger = aLogManager.GetLogger(GetType()); _internalCancelSource = new CancellationTokenSource(); _linkedCancelSource = CancellationTokenSource.CreateLinkedTokenSource(aExternalCancelSource.Token, _internalCancelSource.Token); _ws = aSocket; _server = aServer; _server.MessageReceived += ReceiveMessageFromServerHandler; _server.ClientConnected += ClientConnectedHandler; _server.PingTimeout += PingTimeoutHandler; }
public RealovProtocol(IButtplugLogManager aLogManager, IButtplugDeviceImpl aInterface) : base(aLogManager, "Realov Device", aInterface) { AddMessageHandler <SingleMotorVibrateCmd>(HandleSingleMotorVibrateCmd); AddMessageHandler <VibrateCmd>(HandleVibrateCmd, new MessageAttributes() { FeatureCount = 1 }); AddMessageHandler <StopDeviceCmd>(HandleStopDeviceCmd); }
public UWPBluetoothManager(IButtplugLogManager aLogManager) : base(aLogManager) { BpLogger.Info("Loading UWP Bluetooth Manager"); _currentlyConnecting = new List <ulong>(); // Introspect the ButtplugDevices namespace for all Factory classes, then create // instances of all of them. _deviceFactories = new List <UWPBluetoothDeviceFactory>(); BuiltinDevices.ForEach(aDeviceFactory => { BpLogger.Debug($"Loading Bluetooth Device Factory: {aDeviceFactory.GetType().Name}"); _deviceFactories.Add(new UWPBluetoothDeviceFactory(aLogManager, aDeviceFactory)); }); _bleWatcher = new BluetoothLEAdvertisementWatcher { ScanningMode = BluetoothLEScanningMode.Active }; // We can't filter device advertisements because you can only add one LocalName filter at // a time, meaning we would have to set up multiple watchers for multiple devices. We'll // handle our own filtering via the factory classes whenever we receive a device. _bleWatcher.Received += OnAdvertisementReceived; _bleWatcher.Stopped += OnWatcherStopped; var adapterTask = Task.Run(() => BluetoothAdapter.GetDefaultAsync().AsTask()); adapterTask.Wait(); var adapter = adapterTask.Result; if (adapter == null) { BpLogger.Warn("No bluetooth adapter available for UWP Bluetooth Manager Connection"); return; } if (!adapter.IsLowEnergySupported) { BpLogger.Warn("Bluetooth adapter available but does not support Bluetooth Low Energy."); return; } BpLogger.Debug("UWP Manager found working Bluetooth LE Adapter"); // Only run radio information lookup if we're actually logging at the level it will show. if (aLogManager.Level >= ButtplugLogLevel.Debug) { // Do radio lookup in a background task, as the search query is very slow. // TODO Should probably try and cancel this if it's still running on object destruction, but the Get() call is uninterruptable? _radioTask = Task.Run(() => LogBluetoothRadioInfo()); } }
public ButtplugJsonMessageParser([NotNull] IButtplugLogManager aLogManager) { _bpLogger = aLogManager.GetLogger(GetType()); _bpLogger.Info($"Setting up {GetType().Name}"); IEnumerable <Type> allTypes; // Some classes in the library may not load on certain platforms due to missing symbols. // If this is the case, we should still find messages even though an exception was thrown. try { allTypes = Assembly.GetAssembly(typeof(ButtplugMessage)).GetTypes(); } catch (ReflectionTypeLoadException e) { allTypes = e.Types; } var messageClasses = from t in allTypes where t != null && t.IsClass && t.Namespace == "B******g.Core.Messages" && typeof(ButtplugMessage).IsAssignableFrom(t) select t; var enumerable = messageClasses as Type[] ?? messageClasses.ToArray(); _bpLogger.Debug($"Message type count: {enumerable.Length}"); _messageTypes = new Dictionary <string, Type>(); enumerable.ToList().ForEach(aMessageType => { _bpLogger.Debug($"- {aMessageType.Name}"); _messageTypes.Add(aMessageType.Name, aMessageType); }); // Load the schema for validation var assembly = Assembly.GetExecutingAssembly(); const string resourceName = "B******g.Core.b******g-schema.json"; Stream stream = null; try { stream = assembly.GetManifestResourceStream(resourceName); using (var reader = new StreamReader(stream)) { stream = null; var result = reader.ReadToEnd(); _schema = JsonSchema4.FromJsonAsync(result).GetAwaiter().GetResult(); } } finally { stream?.Dispose(); } }
public Vibratissimo(IButtplugLogManager aLogManager, IBluetoothDeviceInterface aInterface, IBluetoothDeviceInfo aInfo) : base(aLogManager, $"Vibratissimo Device ({aInterface.Name})", aInterface, aInfo) { AddMessageHandler <SingleMotorVibrateCmd>(HandleSingleMotorVibrateCmd); AddMessageHandler <VibrateCmd>(HandleVibrateCmd, new MessageAttributes { FeatureCount = 1 }); AddMessageHandler <StopDeviceCmd>(HandleStopDeviceCmd); }
public KiirooGen21Protocol([NotNull] IButtplugLogManager aLogManager, IButtplugDeviceImpl aInterface) : base(aLogManager, "Kiiroo Onyx2.1", aInterface) { // Setup message function array AddMessageHandler <FleshlightLaunchFW12Cmd>(HandleFleshlightLaunchFW12Cmd); AddMessageHandler <LinearCmd>(HandleLinearCmd, new MessageAttributes() { FeatureCount = 1 }); AddMessageHandler <StopDeviceCmd>(HandleStopDeviceCmd); }
public XamarinBluetoothManager(IButtplugLogManager aLogManager) : base(aLogManager) { BpLogger.Info("Loading UWP Bluetooth Manager"); _adapter = CrossBluetoothLE.Current.Adapter; if (_adapter == null) { BpLogger.Warn("No bluetooth adapter available for UWP Bluetooth Manager Connection"); return; } _adapter.DeviceAdvertised += _adapter_DeviceAdvertised; BpLogger.Debug("UWP Manager found working Bluetooth LE Adapter"); }
public OhMiBodFuse([NotNull] IButtplugLogManager aLogManager, [NotNull] IBluetoothDeviceInterface aInterface, [NotNull] IBluetoothDeviceInfo aInfo) : base(aLogManager, $"OhMiBod {aInterface.Name}", aInterface, aInfo) { MsgFuncs.Add(typeof(StopDeviceCmd), new ButtplugDeviceWrapper(HandleStopDeviceCmd)); MsgFuncs.Add(typeof(VibrateCmd), new ButtplugDeviceWrapper(HandleVibrateCmd, new MessageAttributes() { FeatureCount = 2 })); MsgFuncs.Add(typeof(SingleMotorVibrateCmd), new ButtplugDeviceWrapper(HandleSingleMotorVibrateCmd)); }
public WeVibe(IButtplugLogManager aLogManager, IBluetoothDeviceInterface aInterface, IBluetoothDeviceInfo aInfo) : base(aLogManager, $"WeVibe Device ({aInterface.Name})", aInterface, aInfo) { MsgFuncs.Add(typeof(SingleMotorVibrateCmd), new ButtplugDeviceWrapper(HandleSingleMotorVibrateCmd)); MsgFuncs.Add(typeof(VibrateCmd), new ButtplugDeviceWrapper(HandleVibrateCmd, new MessageAttributes() { FeatureCount = 1 })); MsgFuncs.Add(typeof(StopDeviceCmd), new ButtplugDeviceWrapper(HandleStopDeviceCmd)); }
public VorzeA10Cyclone(IButtplugLogManager aLogManager, IBluetoothDeviceInterface aInterface, IBluetoothDeviceInfo aInfo) : base(aLogManager, "Vorze A10 Cyclone", aInterface, aInfo) { MsgFuncs.Add(typeof(VorzeA10CycloneCmd), new ButtplugDeviceWrapper(HandleVorzeA10CycloneCmd)); MsgFuncs.Add(typeof(RotateCmd), new ButtplugDeviceWrapper(HandleRotateCmd, new MessageAttributes() { FeatureCount = 1 })); MsgFuncs.Add(typeof(StopDeviceCmd), new ButtplugDeviceWrapper(HandleStopDeviceCmd)); }
public KiirooGen2Vibe([NotNull] IButtplugLogManager aLogManager, [NotNull] IBluetoothDeviceInterface aInterface, [NotNull] IBluetoothDeviceInfo aInfo) : base(aLogManager, $"{DevInfos[aInterface.Name].Brand} {aInterface.Name}", aInterface, aInfo) { _devInfo = DevInfos[aInterface.Name]; MsgFuncs.Add(typeof(StopDeviceCmd), new ButtplugDeviceWrapper(HandleStopDeviceCmd)); MsgFuncs.Add(typeof(VibrateCmd), new ButtplugDeviceWrapper(HandleVibrateCmd, new MessageAttributes { FeatureCount = _devInfo.VibeCount })); MsgFuncs.Add(typeof(SingleMotorVibrateCmd), new ButtplugDeviceWrapper(HandleSingleMotorVibrateCmd)); }
public Lovense(IButtplugLogManager aLogManager, IBluetoothDeviceInterface aInterface, IBluetoothDeviceInfo aInfo) : base(aLogManager, "Lovense Unknown Device", aInterface, aInfo) { MsgFuncs.Add(typeof(SingleMotorVibrateCmd), new ButtplugDeviceWrapper(HandleSingleMotorVibrateCmd)); MsgFuncs.Add(typeof(VibrateCmd), new ButtplugDeviceWrapper(HandleVibrateCmd, new MessageAttributes() { FeatureCount = _vibratorCount })); MsgFuncs.Add(typeof(StopDeviceCmd), new ButtplugDeviceWrapper(HandleStopDeviceCmd)); }
public FleshlightLaunch([NotNull] IButtplugLogManager aLogManager, [NotNull] IBluetoothDeviceInterface aInterface, [NotNull] IBluetoothDeviceInfo aInfo) : base(aLogManager, "Fleshlight Launch", aInterface, aInfo) { // Setup message function array MsgFuncs.Add(typeof(FleshlightLaunchFW12Cmd), new ButtplugDeviceWrapper(HandleFleshlightLaunchRawCmd)); MsgFuncs.Add(typeof(LinearCmd), new ButtplugDeviceWrapper(HandleLinearCmd, new MessageAttributes() { FeatureCount = 1 })); MsgFuncs.Add(typeof(StopDeviceCmd), new ButtplugDeviceWrapper(HandleStopDeviceCmd)); }
/// <summary> /// Initializes a new instance of the <see cref="ButtplugClient"/> class. /// </summary> /// <param name="aClientName">The name of the client (used by the server for UI and permissions).</param> /// <param name="aConnector">Connector for the client.</param> public ButtplugClient([NotNull] string aClientName, [NotNull] IButtplugClientConnector aConnector) { ButtplugUtils.ArgumentNotNull(aConnector, nameof(aConnector)); Name = aClientName; _connector = aConnector; _connector.Disconnected += (aObj, aEventArgs) => { ServerDisconnect?.Invoke(aObj, aEventArgs); }; _connector.InvalidMessageReceived += ConnectorErrorHandler; _bpLogManager = new ButtplugLogManager(); _connector.LogManager = _bpLogManager; _bpLogger = _bpLogManager.GetLogger(GetType()); _bpLogger.Info("Finished setting up ButtplugClient"); }
protected BluetoothSubtypeManager([NotNull] IButtplugLogManager aLogManager) : base(aLogManager) { // This used to go through all assemblies looking for IBluetoothDeviceInfo, but that // ended up constantly breaking due to Reflection issues on different platforms/setups. // Now we just build a new info array on manager load, keeps things simple, and outside info can be added via AddInfo calls. BuiltinDevices = new List <IBluetoothDeviceInfo> { new FleshlightLaunchBluetoothInfo(), new KiirooBluetoothInfo(), new LovenseRev1BluetoothInfo(), new LovenseRev2BluetoothInfo(), new LovenseRev3BluetoothInfo(), new VorzeA10CycloneInfo(), }; }
/// <summary> /// Initializes a new instance of the <see cref="ButtplugJsonMessageParser"/> class. /// </summary> /// <param name="aLogManager">Log manager, passed from the parser owner.</param> public ButtplugJsonMessageParser([NotNull] IButtplugLogManager aLogManager) { // Set up logging. if (aLogManager == null) { throw new ArgumentNullException(nameof(aLogManager)); } _bpLogger = aLogManager.GetLogger(GetType()); _bpLogger?.Info($"Setting up {GetType().Name}"); _serializer = new JsonSerializer { MissingMemberHandling = MissingMemberHandling.Error }; _messageTypes = new Dictionary <string, Type>(); foreach (var aMessageType in ButtplugUtils.GetAllMessageTypes()) { _bpLogger?.Debug($"- {aMessageType.Name}"); _messageTypes.Add(aMessageType.Name, aMessageType); } // If we can't find any message types in our assembly, the system is basically useless. if (!_messageTypes.Any()) { throw new ButtplugMessageException(_bpLogger, "No message types available."); } // Load the schema for validation. Schema file is an embedded resource in the library. var assembly = Assembly.GetExecutingAssembly(); const string resourceName = "B******g.b******g-schema.json"; var stream = assembly.GetManifestResourceStream(resourceName); try { using (var reader = new StreamReader(stream ?? throw new InvalidOperationException())) { stream = null; var result = reader.ReadToEnd(); _schema = JsonSchema4.FromJsonAsync(result)?.GetAwaiter().GetResult() ?? throw new InvalidOperationException(); } } finally { // Always make sure we dispose of the resource stream, even if we throw. All // exceptions should be rethrown though. stream?.Dispose(); } }
public LiBo(IButtplugLogManager aLogManager, IBluetoothDeviceInterface aInterface, IBluetoothDeviceInfo aInfo) : base(aLogManager, $"LiBo ({aInterface.Name})", aInterface, aInfo) { MsgFuncs.Add(typeof(SingleMotorVibrateCmd), new ButtplugDeviceWrapper(HandleSingleMotorVibrateCmd)); MsgFuncs.Add(typeof(VibrateCmd), new ButtplugDeviceWrapper(HandleVibrateCmd, new MessageAttributes() { FeatureCount = _vibratorCount })); // TODO Add a handler for Estim shocking, add a battery handler. MsgFuncs.Add(typeof(StopDeviceCmd), new ButtplugDeviceWrapper(HandleStopDeviceCmd)); }
public LiBo(IButtplugLogManager aLogManager, IBluetoothDeviceInterface aInterface, IBluetoothDeviceInfo aInfo) : base(aLogManager, $"LiBo ({aInterface.Name})", aInterface, aInfo) { AddMessageHandler <SingleMotorVibrateCmd>(HandleSingleMotorVibrateCmd); AddMessageHandler <VibrateCmd>(HandleVibrateCmd, new MessageAttributes() { FeatureCount = _vibratorCount }); AddMessageHandler <StopDeviceCmd>(HandleStopDeviceCmd); // TODO Add a handler for Estim shocking, add a battery handler. }
public DeviceManager(IButtplugLogManager aLogManager, List <string> aSearchDirs = null) { ButtplugUtils.ArgumentNotNull(aLogManager, nameof(aLogManager)); _bpLogManager = aLogManager; _bpLogger = _bpLogManager.GetLogger(GetType()); _bpLogger.Info("Setting up DeviceManager"); _sentFinished = true; Devices = new Dictionary <uint, IButtplugDevice>(); DeviceIds = new Dictionary <string, uint>(); _deviceIndexCounter = 0; _isScanning = false; _managerSearchDirs = aSearchDirs ?? new List <string> { Directory.GetCurrentDirectory() }; _managers = new List <IDeviceSubtypeManager>(); }
public WeVibeProtocol(IButtplugLogManager aLogManager, IButtplugDeviceImpl aInterface) : base(aLogManager, $"WeVibe {aInterface.Name}", aInterface) { if (DualVibes.Contains(aInterface.Name)) { _vibratorCount = 2; } AddMessageHandler <SingleMotorVibrateCmd>(HandleSingleMotorVibrateCmd); AddMessageHandler <VibrateCmd>(HandleVibrateCmd, new MessageAttributes() { FeatureCount = _vibratorCount }); AddMessageHandler <StopDeviceCmd>(HandleStopDeviceCmd); }
public PicobongProtocol(IButtplugLogManager aLogManager, IButtplugDeviceImpl aInterface) : base(aLogManager, $"Picobong {aInterface.Name}", aInterface) { if (NameMap.ContainsKey(Name)) { Name = NameMap[Name]; } AddMessageHandler <SingleMotorVibrateCmd>(HandleSingleMotorVibrateCmd); AddMessageHandler <VibrateCmd>(HandleVibrateCmd, new MessageAttributes() { FeatureCount = 1 }); AddMessageHandler <StopDeviceCmd>(HandleStopDeviceCmd); }