@@ -36,6 +36,7 @@ private static void Run(string[]? args = null)
36
36
37
37
static Key [ ] _allKeys = Enum . GetValues ( typeof ( Key ) ) . Cast < Key > ( ) . Where ( x => x != Key . Unknown ) . ToArray ( ) ;
38
38
static List < Key > _keysDown = new List < Key > ( ) ;
39
+ static List < int > _scancodesDown = new List < int > ( ) ;
39
40
40
41
public static Action OnLoad ( IView window ) =>
41
42
( ) =>
@@ -86,6 +87,14 @@ public static Action<double> OnUpdate(IInputContext input) =>
86
87
Console . WriteLine ( $ "[ERROR] IsKeyPressed() and event mismatch! Key { k } ") ;
87
88
}
88
89
}
90
+
91
+ for ( int s = 0 ; s < 256 ; s ++ )
92
+ {
93
+ if ( _scancodesDown . Contains ( s ) != input . Keyboards . Any ( x => x . IsScancodePressed ( s ) ) )
94
+ {
95
+ Console . WriteLine ( $ "[ERROR] IsScancodePressed() and event mismatch! Scancode { s } ") ;
96
+ }
97
+ }
89
98
} ;
90
99
91
100
private static void GamepadOnTriggerMoved ( IGamepad gamepad , Trigger trigger )
@@ -274,12 +283,18 @@ private static void KeyboardOnKeyUp(IKeyboard keyboard, Key key, int scancode)
274
283
275
284
if ( key != Key . Unknown )
276
285
{
277
- int index = _keysDown . IndexOf ( key ) ;
278
- if ( index < 0 )
286
+ int keyIndex = _keysDown . IndexOf ( key ) ;
287
+ if ( keyIndex < 0 )
279
288
Console . WriteLine ( $ "[ERROR] Double key up detected? K{ keyboard . Index } > { key } up.") ;
280
289
else
281
- _keysDown . RemoveAt ( index ) ;
290
+ _keysDown . RemoveAt ( keyIndex ) ;
282
291
}
292
+
293
+ int scancodeIndex = _scancodesDown . IndexOf ( scancode ) ;
294
+ if ( scancodeIndex < 0 )
295
+ Console . WriteLine ( $ "[ERROR] Double scancode up detected? K{ keyboard . Index } > { scancode } up.") ;
296
+ else
297
+ _scancodesDown . RemoveAt ( scancodeIndex ) ;
283
298
}
284
299
285
300
private static void KeyboardOnKeyDown ( IKeyboard keyboard , Key key , int scancode )
@@ -293,6 +308,11 @@ private static void KeyboardOnKeyDown(IKeyboard keyboard, Key key, int scancode)
293
308
else
294
309
_keysDown . Add ( key ) ;
295
310
}
311
+
312
+ if ( _scancodesDown . Contains ( scancode ) )
313
+ Console . WriteLine ( $ "[ERROR] Double scancode down detected? K{ keyboard . Index } > { scancode } down.") ;
314
+ else
315
+ _scancodesDown . Add ( scancode ) ;
296
316
}
297
317
}
298
318
}
0 commit comments