11using System ;
22using System . Collections . Concurrent ;
3+ using System . Collections . Generic ;
34using System . Windows ;
45using Buttplug . Client ;
56using Buttplug . Components . Controls ;
@@ -71,7 +72,7 @@ private async void Connect()
7172
7273 foreach ( var dev in _client . getDevices ( ) )
7374 {
74- devControl . DeviceAdded ( new ButtplugDeviceInfo ( dev . Index , dev . Name , dev . AllowedMessages . ToArray ( ) ) ) ;
75+ devControl . DeviceAdded ( new ButtplugDeviceInfo ( dev . Index , dev . Name , dev . AllowedMessages ) ) ;
7576 }
7677 }
7778 }
@@ -86,7 +87,7 @@ private void OnDeviceChanged(object sender, DeviceEventArgs e)
8687 switch ( e . Action )
8788 {
8889 case DeviceAction . ADDED :
89- devControl . DeviceAdded ( new ButtplugDeviceInfo ( e . Device . Index , e . Device . Name , e . Device . AllowedMessages . ToArray ( ) ) ) ;
90+ devControl . DeviceAdded ( new ButtplugDeviceInfo ( e . Device . Index , e . Device . Name , e . Device . AllowedMessages ) ) ;
9091 break ;
9192
9293 case DeviceAction . REMOVED :
@@ -135,7 +136,7 @@ private void SendLinear_Click(object sender, RoutedEventArgs e)
135136
136137 foreach ( var dev in Devices . Values )
137138 {
138- if ( dev . AllowedMessages . Contains ( "FleshlightLaunchFW12Cmd" ) )
139+ if ( dev . AllowedMessages . ContainsKey ( "FleshlightLaunchFW12Cmd" ) )
139140 {
140141 _client . SendDeviceMessage ( dev ,
141142 new FleshlightLaunchFW12Cmd ( dev . Index ,
@@ -155,12 +156,24 @@ private void SendVibrate_Click(object sender, RoutedEventArgs e)
155156
156157 foreach ( var dev in Devices . Values )
157158 {
158- if ( dev . AllowedMessages . Contains ( "SingleMotorVibrateCmd" ) )
159+ if ( dev . AllowedMessages . TryGetValue ( "VibrateCmd" , out var attrs ) )
159160 {
160- _client . SendDeviceMessage ( dev ,
161- new SingleMotorVibrateCmd ( dev . Index ,
162- Convert . ToDouble ( VibrateSpeed . Value ) ,
163- _client . nextMsgId ) ) ;
161+ try
162+ {
163+ uint vibratorCount = attrs . FeatureCount ?? 0 ;
164+
165+ for ( uint i = 0 ; i < vibratorCount ; i ++ )
166+ {
167+ _client . SendDeviceMessage ( dev ,
168+ new VibrateCmd ( dev . Index ,
169+ new List < VibrateCmd . VibrateIndex >
170+ { new VibrateCmd . VibrateIndex ( i , VibrateSpeed . Value ) } ,
171+ _client . nextMsgId ) ) ;
172+ }
173+ }
174+ catch
175+ {
176+ }
164177 }
165178 }
166179 }
@@ -174,14 +187,45 @@ private void SendRotate_Click(object sender, RoutedEventArgs e)
174187
175188 foreach ( var dev in Devices . Values )
176189 {
177- if ( dev . AllowedMessages . Contains ( "VorzeA10CycloneCmd" ) )
190+ if ( dev . AllowedMessages . TryGetValue ( "RotateCmd" , out var attrs ) )
191+ {
192+ try
193+ {
194+ uint rotatorCount = attrs . FeatureCount ?? 0 ;
195+
196+ for ( uint i = 0 ; i < rotatorCount ; i ++ )
197+ {
198+ bool clockwise = RotateSpeed . Value > 0 ;
199+ _client . SendDeviceMessage ( dev ,
200+ new RotateCmd ( dev . Index ,
201+ new List < RotateCmd . RotateIndex >
202+ { new RotateCmd . RotateIndex ( i , RotateSpeed . Value * ( clockwise ? 1 : - 1 ) , clockwise ) } ,
203+ _client . nextMsgId ) ) ;
204+ }
205+ }
206+ catch
207+ {
208+ }
209+ }
210+ }
211+ }
212+
213+ private void SendLinear2_Click ( object sender , RoutedEventArgs e )
214+ {
215+ if ( ! _client . IsConnected )
216+ {
217+ return ;
218+ }
219+
220+ foreach ( var dev in Devices . Values )
221+ {
222+ if ( dev . AllowedMessages . ContainsKey ( "FleshlightLaunchFW12Cmd" ) )
178223 {
179- bool clockwise = RotateSpeed . Value > 0 ;
180224 _client . SendDeviceMessage ( dev ,
181- new VorzeA10CycloneCmd ( dev . Index ,
182- Convert . ToUInt32 ( RotateSpeed . Value * ( clockwise ? 1 : - 1 ) ) ,
183- clockwise ,
184- _client . nextMsgId ) ) ;
225+ new LinearCmd ( dev . Index , new List < LinearCmd . VectorIndex > ( )
226+ {
227+ new LinearCmd . VectorIndex ( 0 , Convert . ToUInt32 ( LinearDuration . Text ) , Linear2Position . Value ) ,
228+ } , _client . nextMsgId ) ) ;
185229 }
186230 }
187231 }
0 commit comments