10
10
using osu . Framework . Input ;
11
11
using osu . Framework . Input . Bindings ;
12
12
using osu . Framework . Input . Events ;
13
- using osu . Framework . Input . StateChanges ;
14
13
using osu . Framework . Input . States ;
15
14
using osu . Framework . Testing ;
16
15
using osu . Framework . Timing ;
@@ -225,37 +224,27 @@ private void addHitCircleAtPen()
225
224
} ) ;
226
225
}
227
226
228
- private void pressPen ( )
229
- {
230
- AddStep ( "Press pen" , ( ) =>
231
- {
232
- InputManager . MovePenTo ( getSanePositionForPen ( ) , TabletPenDeviceType . Direct ) ;
233
- InputManager . PressPen ( TabletPenDeviceType . Direct ) ;
234
- } ) ;
235
- }
236
-
237
- private void releasePen ( )
238
- {
239
- AddStep ( "Release pen" , ( ) => InputManager . ReleasePen ( TabletPenDeviceType . Direct ) ) ;
240
- }
227
+ private void pressPen ( ) => beginTouch ( TouchSource . PenTouch ) ;
228
+ private void releasePen ( ) => endTouch ( TouchSource . PenTouch ) ;
241
229
242
230
private void beginTouch ( TouchSource source , Vector2 ? screenSpacePosition = null ) =>
243
231
AddStep ( $ "Begin touch for { source } ", ( ) => InputManager . BeginTouch ( new Touch ( source , screenSpacePosition ??= getSanePositionForTouch ( source ) ) ) ) ;
244
232
245
233
private void endTouch ( TouchSource source , Vector2 ? screenSpacePosition = null ) =>
246
234
AddStep ( $ "Release touch for { source } ", ( ) => InputManager . EndTouch ( new Touch ( source , screenSpacePosition ??= getSanePositionForTouch ( source ) ) ) ) ;
247
235
248
- private Vector2 getSanePositionForPen ( )
236
+ private Vector2 getSanePositionForPen ( ) => getSanePositionForTouch ( TouchSource . PenTouch ) ;
237
+
238
+ private Vector2 getSanePositionForTouch ( TouchSource source )
249
239
{
240
+ int index = source == TouchSource . PenTouch ? - 1 : ( int ) source ;
241
+
250
242
return new Vector2 (
251
- osuInputManager . ScreenSpaceDrawQuad . Centre . X + osuInputManager . ScreenSpaceDrawQuad . Width * - 1 / 8 ,
243
+ osuInputManager . ScreenSpaceDrawQuad . Centre . X + osuInputManager . ScreenSpaceDrawQuad . Width * index / 8 ,
252
244
osuInputManager . ScreenSpaceDrawQuad . Centre . Y - 100
253
245
) ;
254
246
}
255
247
256
- private Vector2 getSanePositionForTouch ( TouchSource source )
257
- => getSanePositionForPen ( ) + new Vector2 ( osuInputManager . ScreenSpaceDrawQuad . Width * ( int ) ( 1 + source ) / 8 , 0 ) ;
258
-
259
248
private void checkPositionIsAtPen ( ) =>
260
249
AddAssert ( "Cursor position is correct" , ( ) => osuInputManager . CurrentState . Mouse . Position , ( ) => Is . EqualTo ( getSanePositionForPen ( ) ) ) ;
261
250
@@ -267,7 +256,7 @@ private void assertKeyCounter(int left, int right)
267
256
268
257
private void releaseAllInput ( )
269
258
{
270
- AddStep ( "Release pen" , ( ) => InputManager . ReleasePen ( ) ) ;
259
+ releasePen ( ) ;
271
260
AddStep ( "Release all touches" , ( ) =>
272
261
{
273
262
config . SetValue ( OsuSetting . MouseDisableButtons , false ) ;
@@ -309,7 +298,7 @@ public void OnReleased(KeyBindingReleaseEvent<OsuAction> e)
309
298
310
299
public partial class TouchVisualiser : CompositeDrawable
311
300
{
312
- private readonly Drawable ? [ ] drawableTouches = new Drawable ? [ TouchState . MAX_TOUCH_COUNT ] ;
301
+ private readonly Drawable ? [ ] drawableTouches = new Drawable ? [ TouchState . MAX_SOURCES_COUNT ] ;
313
302
314
303
public TouchVisualiser ( )
315
304
{
0 commit comments