77// <script src="https://cdn.jsdelivr.net/npm/buttplug@4.0.0/dist/web/buttplug.min.js"></script>
88
99async function runDeviceControlExample ( ) {
10- const connector = new Buttplug . ButtplugBrowserWebsocketClientConnector ( "ws://127.0.0.1:12345" ) ;
11- const client = new Buttplug . ButtplugClient ( "Device Control Example" ) ;
10+ const connector = new buttplug . ButtplugBrowserWebsocketClientConnector ( "ws://127.0.0.1:12345" ) ;
11+ const client = new buttplug . ButtplugClient ( "Device Control Example" ) ;
1212
1313 // Set up event handlers before connecting
1414 client . addListener ( "deviceadded" , async ( device ) => {
@@ -21,7 +21,7 @@ async function runDeviceControlExample() {
2121 }
2222
2323 // Check if device supports vibration using v4 API
24- if ( ! device . hasOutput ( Buttplug . OutputType . Vibrate ) ) {
24+ if ( ! device . hasOutput ( buttplug . OutputType . Vibrate ) ) {
2525 console . log ( "Device does not support vibration, skipping control demo." ) ;
2626 return ;
2727 }
@@ -31,7 +31,7 @@ async function runDeviceControlExample() {
3131 try {
3232 // Use the v4 command builder API
3333 console . log ( "Vibrating at 100%..." ) ;
34- await device . runOutput ( Buttplug . DeviceOutput . Vibrate . percent ( 1.0 ) ) ;
34+ await device . runOutput ( buttplug . DeviceOutput . Vibrate . percent ( 1.0 ) ) ;
3535
3636 await new Promise ( r => setTimeout ( r , 1000 ) ) ;
3737
@@ -44,13 +44,13 @@ async function runDeviceControlExample() {
4444 await device . stop ( ) ;
4545 } catch ( e ) {
4646 console . log ( "Error sending command:" , e ) ;
47- if ( e instanceof Buttplug . ButtplugDeviceError ) {
47+ if ( e instanceof buttplug . ButtplugDeviceError ) {
4848 console . log ( "This is a device error - device may have disconnected." ) ;
4949 }
5050 }
5151
5252 // Check for battery support using v4 API
53- if ( device . hasInput ( Buttplug . InputType . Battery ) ) {
53+ if ( device . hasInput ( buttplug . InputType . Battery ) ) {
5454 try {
5555 const level = await device . battery ( ) ;
5656 console . log ( `${ device . name } Battery Level: ${ ( level * 100 ) . toFixed ( 0 ) } %` ) ;
@@ -60,16 +60,16 @@ async function runDeviceControlExample() {
6060 }
6161
6262 // Demonstrate other output types if available
63- if ( device . hasOutput ( Buttplug . OutputType . Rotate ) ) {
63+ if ( device . hasOutput ( buttplug . OutputType . Rotate ) ) {
6464 console . log ( "Device supports rotation. Rotating at 50%..." ) ;
65- await device . runOutput ( Buttplug . DeviceOutput . Rotate . percent ( 0.5 ) ) ;
65+ await device . runOutput ( buttplug . DeviceOutput . Rotate . percent ( 0.5 ) ) ;
6666 await new Promise ( r => setTimeout ( r , 1000 ) ) ;
6767 await device . stop ( ) ;
6868 }
6969
70- if ( device . hasOutput ( Buttplug . OutputType . Position ) ) {
70+ if ( device . hasOutput ( buttplug . OutputType . Position ) ) {
7171 console . log ( "Device supports position control. Moving..." ) ;
72- await device . runOutput ( Buttplug . DeviceOutput . PositionWithDuration . percent ( 1.0 , 500 ) ) ;
72+ await device . runOutput ( buttplug . DeviceOutput . PositionWithDuration . percent ( 1.0 , 500 ) ) ;
7373 await new Promise ( r => setTimeout ( r , 1000 ) ) ;
7474 await device . runOutput ( Buttplug . DeviceOutput . PositionWithDuration . percent ( 0.0 , 500 ) ) ;
7575 }
0 commit comments