File tree 3 files changed +21
-4
lines changed
3 files changed +21
-4
lines changed Original file line number Diff line number Diff line change @@ -154,9 +154,10 @@ public ControllerDevice[] detectControllers()
154
154
if ( devices [ i ] != null && ! directInput . IsDeviceAttached ( devices [ i ] . joystick . Information . InstanceGuid ) )
155
155
{
156
156
Console . WriteLine ( devices [ i ] . joystick . Properties . InstanceName + " Removed" ) ;
157
+ devices [ i ] = null ;
158
+ workers [ i ] . Abort ( ) ;
157
159
workers [ i ] = null ;
158
160
Unplug ( i + 1 ) ;
159
- devices [ i ] = null ;
160
161
}
161
162
}
162
163
@@ -204,6 +205,16 @@ public ControllerDevice[] detectControllers()
204
205
joystick . Acquire ( ) ;
205
206
206
207
devices [ spot ] = new ControllerDevice ( joystick , spot + 1 ) ;
208
+ if ( IsActive )
209
+ {
210
+ processingData [ spot ] = new ContData ( ) ;
211
+ Console . WriteLine ( "Plug " + spot ) ;
212
+ Plugin ( spot + 1 ) ;
213
+ int t = spot ;
214
+ workers [ spot ] = new Thread ( ( ) =>
215
+ { ProcessData ( t ) ; } ) ;
216
+ workers [ spot ] . Start ( ) ;
217
+ }
207
218
}
208
219
return devices ;
209
220
}
@@ -217,6 +228,7 @@ public override bool Stop()
217
228
{
218
229
if ( devices [ i ] != null && devices [ i ] . enabled )
219
230
{
231
+ Console . WriteLine ( i ) ;
220
232
workers [ i ] . Abort ( ) ;
221
233
workers [ i ] = null ;
222
234
Unplug ( i + 1 ) ;
@@ -279,6 +291,11 @@ private void ProcessData(int n)
279
291
{
280
292
lock ( ds4locks [ n ] )
281
293
{
294
+ if ( devices [ n ] == null )
295
+ {
296
+ //Console.WriteLine("die" + n.ToString());
297
+ //continue;
298
+ }
282
299
byte [ ] data = devices [ n ] . getoutput ( ) ;
283
300
if ( data != null && devices [ n ] . enabled )
284
301
{
Original file line number Diff line number Diff line change @@ -110,9 +110,9 @@ private void UpdateInfo(ControllerDevice[] dev)
110
110
111
111
private void Swap ( int i , int p )
112
112
{
113
- bool s = checks [ i ] . Checked ;
114
- checks [ i ] . Checked = checks [ p ] . Checked ;
115
- checks [ p ] . Checked = s ;
113
+ bool s = checks [ i - 1 ] . Checked ;
114
+ checks [ i - 1 ] . Checked = checks [ p - 1 ] . Checked ;
115
+ checks [ p - 1 ] . Checked = s ;
116
116
controllerManager . Swap ( i , p ) ;
117
117
118
118
UpdateInfo ( controllerManager . detectControllers ( ) ) ;
You can’t perform that action at this time.
0 commit comments