async def init_buttplug():
     nonlocal dev
     client = ButtplugClient('Waves Client')
     connector = ButtplugClientWebsocketConnector('ws://127.0.0.1:12345')
     client.device_added_handler += on_device_added
     await client.connect(connector)
     with warnings.catch_warnings():
         warnings.simplefilter('ignore', category=RuntimeWarning)
         client.request_log('Off')
     await client.start_scanning()
     while dev == None:
         await asyncio.sleep(0.5)
     await client.stop_scanning()
     log.debug('device ready')
     return client
async def main():
    global devices
    global client
    global connector
    client = ButtplugClient("League of Legends")
    connector = CustomWebsocketConnection("ws://127.0.0.1:12345")
    client.device_added_handler += device_added
    client.device_removed_handler += device_removed
    try:
        await client.connect(connector)
    except ButtplugClientConnectorError as e:
        print("Could not connect to server (check Intiface desktop), exiting: {}".format(e.message))
        return
    await scan_and_pick_device()
    queue = SimpleQueue()
    queue2 = SimpleQueue()
    lol = League_Thread(queue)
    lol.start()
    bu = Buttplug_Thread(queue, chosen_device, queue2)
    bu.start()
    while True:
        item = queue2.get()
        #print(item)
        if item == "stop":
            await chosen_device.send_stop_device_cmd()
        else:
            await chosen_device.send_vibrate_cmd(item)
Beispiel #3
0
    async def vibrate(self, intensity=0.5, duration=0.3):
        self.intensity = intensity
        self.duration = duration
        # create client
        client = ButtplugClient(self.name)
        # connect to websocket of the intiface
        connector = ButtplugClientWebsocketConnector(self.ws)
        # add event handler
        client.device_added_handler += self.device_added
        # asyncio
        # connect to device
        try:
            await client.connect(connector)
        except ButtplugClientConnectorError as e:
            print("Could not connect to server, exiting: {}".format(e.message))
            return

        # get logs
        await client.request_log(ButtplugLogLevel.debug)
        # search for devices
        await client.start_scanning()

        # wait
        task = asyncio.create_task(self.cancel_me())
        try:
            await task
        except asyncio.CancelledError:
            pass

        # ctrl-c -> stop
        await client.stop_scanning()
        # Now that we've done that, we just disconnect and we're done!
        await client.disconnect()
Beispiel #4
0
    def __init__(self):
        self.running = False
        self.level = 0
        self.last_sent_level = 0

        # B******g Client
        self.bp_client = ButtplugClient('Drone Control 1')
        self.bp_connector = ButtplugClientWebsocketConnector(
            'ws://127.0.0.1:12345')
        self.bp_device = None

        self.bp_client.device_added_handler += self._device_added
        self.bp_client.device_removed_handler += self._device_removed

        asyncio.get_event_loop().run_until_complete(
            self._init_buttplug_client())
Beispiel #5
0
    def __init__(self):
        self.running = False
        self.level = 0
        self.last_sent_level = 0

        # Required for Kontroller
        self.kontrol = None
        self.channel = None

        # B******g Client
        self.bp_client = ButtplugClient("Drone Control 1")
        self.bp_connector = ButtplugClientWebsocketConnector(
            "ws://127.0.0.1:12345")
        self.bp_device = None

        threading.Thread(target=self._init_buttplug_client_thread,
                         daemon=True).start()

        logging.debug("Buttvibe Started")
Beispiel #6
0
async def main():
    # And now we're in the main function.
    #
    # First, we'll need to set up a client object. This is our conduit to the
    # server.
    #
    # We create a Client object, passing it the name we want for the client.
    # Names are shown in things like the Intiface Desktop Server GUI.

    client = ButtplugClient("Test Client")

    # Now we have a client called "Test Client", but it's not connected to
    # anything yet. We can fix that by creating a connector. Connectors
    # allow clients to talk to servers through different methods, including:
    #
    # - Websockets
    # - IPC (Not currently available in Python)
    # - WebRTC (Not currently available in Python)
    # - TCP/UDP (Not currently available in Python)
    #
    # For now, all we've implemented in python is a Websocket connector, so
    # we'll use that.

    connector = ButtplugClientWebsocketConnector("ws://127.0.0.1:12345")

    # This connector will connect to Intiface Desktop on the local machine,
    # using the default port for insecure websockets.
    #
    # There's one more step before we connect to a client, and that's
    # setting up an event handler.

    client.device_added_handler += device_added
    client.device_removed_handler += device_removed

    # Whenever we connect to a client, we'll instantly get a list of devices
    # already connected (yes, this sometimes happens, mostly due to windows
    # weirdness). We'll want to make sure we know about those.
    #
    # Finally, we connect.

    try:
        await client.connect(connector)
    except ButtplugClientConnectorError as e:
        logging.error("Could not connect to server, exiting: {}".format(
            e.message))
        return

    # If this succeeds, we'll be connected. If not, we'll probably have some
    # sort of exception thrown of type ButtplugClientConnectorException
    #
    # Let's receive log messages, since they're a handy way to find out what
    # the server is doing. We can choose the level from the ButtplugLogLevel
    # object.

    # await client.request_log(ButtplugLogLevel.info)

    # Now we move on to looking for devices.

    await client.start_scanning()

    # This will tell the server to start scanning for devices, and returns
    # while it's scanning. If we get any new devices, the device_added_task
    # function that we assigned as an event handler earlier will be called.
    #
    # Since everything interesting happens after devices have connected, now
    # all we have to do here is wait. So we do, asynchronously, so other things
    # can continue running. Now that you've made it this far, go look at what
    # the device_added_task does.

    task = asyncio.create_task(cancel_me())
    try:
        await task
    except asyncio.CancelledError:
        pass

    # Ok so someone hit Ctrl-C or something and we've broken out of our task
    # wait. Let's tell the server to stop scanning.
    await client.stop_scanning()

    # Now that we've done that, we just disconnect and we're done!
    await client.disconnect()
    logging.info("Disconnected, quitting")
Beispiel #7
0
 def __init__(self, bot):
     self.bot = bot
     self.buttplug_client = ButtplugClient("Lewd Bot")