summaryrefslogtreecommitdiff
path: root/Thronefall_v1.0/Rewired/Rewired.Integration.UnityUI/RewiredPointerInputModule.cs
blob: 27d419b533ea369c3a3067f72c1dc71ba87ead0a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
using System;
using System.Collections.Generic;
using System.Text;
using Rewired.UI;
using Rewired.Utils;
using UnityEngine;
using UnityEngine.EventSystems;

namespace Rewired.Integration.UnityUI;

public abstract class RewiredPointerInputModule : BaseInputModule
{
	protected class MouseState
	{
		private List<ButtonState> m_TrackedButtons = new List<ButtonState>();

		public bool AnyPressesThisFrame()
		{
			for (int i = 0; i < m_TrackedButtons.Count; i++)
			{
				if (m_TrackedButtons[i].eventData.PressedThisFrame())
				{
					return true;
				}
			}
			return false;
		}

		public bool AnyReleasesThisFrame()
		{
			for (int i = 0; i < m_TrackedButtons.Count; i++)
			{
				if (m_TrackedButtons[i].eventData.ReleasedThisFrame())
				{
					return true;
				}
			}
			return false;
		}

		public ButtonState GetButtonState(int button)
		{
			ButtonState buttonState = null;
			for (int i = 0; i < m_TrackedButtons.Count; i++)
			{
				if (m_TrackedButtons[i].button == button)
				{
					buttonState = m_TrackedButtons[i];
					break;
				}
			}
			if (buttonState == null)
			{
				buttonState = new ButtonState
				{
					button = button,
					eventData = new MouseButtonEventData()
				};
				m_TrackedButtons.Add(buttonState);
			}
			return buttonState;
		}

		public void SetButtonState(int button, PointerEventData.FramePressState stateForMouseButton, PlayerPointerEventData data)
		{
			ButtonState buttonState = GetButtonState(button);
			buttonState.eventData.buttonState = stateForMouseButton;
			buttonState.eventData.buttonData = data;
		}
	}

	public class MouseButtonEventData
	{
		public PointerEventData.FramePressState buttonState;

		public PlayerPointerEventData buttonData;

		public bool PressedThisFrame()
		{
			if (buttonState != 0)
			{
				return buttonState == PointerEventData.FramePressState.PressedAndReleased;
			}
			return true;
		}

		public bool ReleasedThisFrame()
		{
			if (buttonState != PointerEventData.FramePressState.Released)
			{
				return buttonState == PointerEventData.FramePressState.PressedAndReleased;
			}
			return true;
		}
	}

	protected class ButtonState
	{
		private int m_Button;

		private MouseButtonEventData m_EventData;

		public MouseButtonEventData eventData
		{
			get
			{
				return m_EventData;
			}
			set
			{
				m_EventData = value;
			}
		}

		public int button
		{
			get
			{
				return m_Button;
			}
			set
			{
				m_Button = value;
			}
		}
	}

	private sealed class UnityInputSource : IMouseInputSource, ITouchInputSource
	{
		private Vector2 m_MousePosition;

		private Vector2 m_MousePositionPrev;

		private int m_LastUpdatedFrame = -1;

		int IMouseInputSource.playerId
		{
			get
			{
				TryUpdate();
				return 0;
			}
		}

		int ITouchInputSource.playerId
		{
			get
			{
				TryUpdate();
				return 0;
			}
		}

		bool IMouseInputSource.enabled
		{
			get
			{
				TryUpdate();
				return Input.mousePresent;
			}
		}

		bool IMouseInputSource.locked
		{
			get
			{
				TryUpdate();
				return Cursor.lockState == CursorLockMode.Locked;
			}
		}

		int IMouseInputSource.buttonCount
		{
			get
			{
				TryUpdate();
				return 3;
			}
		}

		Vector2 IMouseInputSource.screenPosition
		{
			get
			{
				TryUpdate();
				return Input.mousePosition;
			}
		}

		Vector2 IMouseInputSource.screenPositionDelta
		{
			get
			{
				TryUpdate();
				return m_MousePosition - m_MousePositionPrev;
			}
		}

		Vector2 IMouseInputSource.wheelDelta
		{
			get
			{
				TryUpdate();
				return Input.mouseScrollDelta;
			}
		}

		bool ITouchInputSource.touchSupported
		{
			get
			{
				TryUpdate();
				return Input.touchSupported;
			}
		}

		int ITouchInputSource.touchCount
		{
			get
			{
				TryUpdate();
				return Input.touchCount;
			}
		}

		bool IMouseInputSource.GetButtonDown(int button)
		{
			TryUpdate();
			return Input.GetMouseButtonDown(button);
		}

		bool IMouseInputSource.GetButtonUp(int button)
		{
			TryUpdate();
			return Input.GetMouseButtonUp(button);
		}

		bool IMouseInputSource.GetButton(int button)
		{
			TryUpdate();
			return Input.GetMouseButton(button);
		}

		Touch ITouchInputSource.GetTouch(int index)
		{
			TryUpdate();
			return Input.GetTouch(index);
		}

		private void TryUpdate()
		{
			if (Time.frameCount != m_LastUpdatedFrame)
			{
				m_LastUpdatedFrame = Time.frameCount;
				m_MousePositionPrev = m_MousePosition;
				m_MousePosition = Input.mousePosition;
			}
		}
	}

	public const int kMouseLeftId = -1;

	public const int kMouseRightId = -2;

	public const int kMouseMiddleId = -3;

	public const int kFakeTouchesId = -4;

	private const int customButtonsStartingId = -2147483520;

	private const int customButtonsMaxCount = 128;

	private const int customButtonsLastId = -2147483392;

	private readonly List<IMouseInputSource> m_MouseInputSourcesList = new List<IMouseInputSource>();

	private Dictionary<int, Dictionary<int, PlayerPointerEventData>[]> m_PlayerPointerData = new Dictionary<int, Dictionary<int, PlayerPointerEventData>[]>();

	private ITouchInputSource m_UserDefaultTouchInputSource;

	private UnityInputSource __m_DefaultInputSource;

	private readonly MouseState m_MouseState = new MouseState();

	private UnityInputSource defaultInputSource
	{
		get
		{
			if (__m_DefaultInputSource == null)
			{
				return __m_DefaultInputSource = new UnityInputSource();
			}
			return __m_DefaultInputSource;
		}
	}

	private IMouseInputSource defaultMouseInputSource => defaultInputSource;

	protected ITouchInputSource defaultTouchInputSource => defaultInputSource;

	protected virtual bool isMouseSupported
	{
		get
		{
			int count = m_MouseInputSourcesList.Count;
			if (count == 0)
			{
				return defaultMouseInputSource.enabled;
			}
			for (int i = 0; i < count; i++)
			{
				if (m_MouseInputSourcesList[i].enabled)
				{
					return true;
				}
			}
			return false;
		}
	}

	protected bool IsDefaultMouse(IMouseInputSource mouse)
	{
		return defaultMouseInputSource == mouse;
	}

	public IMouseInputSource GetMouseInputSource(int playerId, int mouseIndex)
	{
		if (mouseIndex < 0)
		{
			throw new ArgumentOutOfRangeException("mouseIndex");
		}
		if (m_MouseInputSourcesList.Count == 0 && IsDefaultPlayer(playerId))
		{
			return defaultMouseInputSource;
		}
		int count = m_MouseInputSourcesList.Count;
		int num = 0;
		for (int i = 0; i < count; i++)
		{
			IMouseInputSource mouseInputSource = m_MouseInputSourcesList[i];
			if (!UnityTools.IsNullOrDestroyed(mouseInputSource) && mouseInputSource.playerId == playerId)
			{
				if (mouseIndex == num)
				{
					return mouseInputSource;
				}
				num++;
			}
		}
		return null;
	}

	public void RemoveMouseInputSource(IMouseInputSource source)
	{
		if (source == null)
		{
			throw new ArgumentNullException("source");
		}
		m_MouseInputSourcesList.Remove(source);
	}

	public void AddMouseInputSource(IMouseInputSource source)
	{
		if (UnityTools.IsNullOrDestroyed(source))
		{
			throw new ArgumentNullException("source");
		}
		m_MouseInputSourcesList.Add(source);
	}

	public int GetMouseInputSourceCount(int playerId)
	{
		if (m_MouseInputSourcesList.Count == 0 && IsDefaultPlayer(playerId))
		{
			return 1;
		}
		int count = m_MouseInputSourcesList.Count;
		int num = 0;
		for (int i = 0; i < count; i++)
		{
			IMouseInputSource mouseInputSource = m_MouseInputSourcesList[i];
			if (!UnityTools.IsNullOrDestroyed(mouseInputSource) && mouseInputSource.playerId == playerId)
			{
				num++;
			}
		}
		return num;
	}

	public ITouchInputSource GetTouchInputSource(int playerId, int sourceIndex)
	{
		if (!UnityTools.IsNullOrDestroyed(m_UserDefaultTouchInputSource))
		{
			return m_UserDefaultTouchInputSource;
		}
		return defaultTouchInputSource;
	}

	public void RemoveTouchInputSource(ITouchInputSource source)
	{
		if (source == null)
		{
			throw new ArgumentNullException("source");
		}
		if (m_UserDefaultTouchInputSource == source)
		{
			m_UserDefaultTouchInputSource = null;
		}
	}

	public void AddTouchInputSource(ITouchInputSource source)
	{
		if (UnityTools.IsNullOrDestroyed(source))
		{
			throw new ArgumentNullException("source");
		}
		m_UserDefaultTouchInputSource = source;
	}

	public int GetTouchInputSourceCount(int playerId)
	{
		if (!IsDefaultPlayer(playerId))
		{
			return 0;
		}
		return 1;
	}

	protected void ClearMouseInputSources()
	{
		m_MouseInputSourcesList.Clear();
	}

	protected abstract bool IsDefaultPlayer(int playerId);

	protected bool GetPointerData(int playerId, int pointerIndex, int pointerTypeId, out PlayerPointerEventData data, bool create, PointerEventType pointerEventType)
	{
		if (!m_PlayerPointerData.TryGetValue(playerId, out var value))
		{
			value = new Dictionary<int, PlayerPointerEventData>[pointerIndex + 1];
			for (int i = 0; i < value.Length; i++)
			{
				value[i] = new Dictionary<int, PlayerPointerEventData>();
			}
			m_PlayerPointerData.Add(playerId, value);
		}
		if (pointerIndex >= value.Length)
		{
			Dictionary<int, PlayerPointerEventData>[] array = new Dictionary<int, PlayerPointerEventData>[pointerIndex + 1];
			for (int j = 0; j < value.Length; j++)
			{
				array[j] = value[j];
			}
			array[pointerIndex] = new Dictionary<int, PlayerPointerEventData>();
			value = array;
			m_PlayerPointerData[playerId] = value;
		}
		Dictionary<int, PlayerPointerEventData> dictionary = value[pointerIndex];
		if (!dictionary.TryGetValue(pointerTypeId, out data))
		{
			if (!create)
			{
				return false;
			}
			data = CreatePointerEventData(playerId, pointerIndex, pointerTypeId, pointerEventType);
			dictionary.Add(pointerTypeId, data);
			return true;
		}
		data.mouseSource = ((pointerEventType == PointerEventType.Mouse) ? GetMouseInputSource(playerId, pointerIndex) : null);
		data.touchSource = ((pointerEventType == PointerEventType.Touch) ? GetTouchInputSource(playerId, pointerIndex) : null);
		return false;
	}

	private PlayerPointerEventData CreatePointerEventData(int playerId, int pointerIndex, int pointerTypeId, PointerEventType pointerEventType)
	{
		PlayerPointerEventData playerPointerEventData = new PlayerPointerEventData(base.eventSystem)
		{
			playerId = playerId,
			inputSourceIndex = pointerIndex,
			pointerId = pointerTypeId,
			sourceType = pointerEventType
		};
		switch (pointerEventType)
		{
		case PointerEventType.Mouse:
			playerPointerEventData.mouseSource = GetMouseInputSource(playerId, pointerIndex);
			break;
		case PointerEventType.Touch:
			playerPointerEventData.touchSource = GetTouchInputSource(playerId, pointerIndex);
			break;
		}
		if (pointerTypeId == -1)
		{
			playerPointerEventData.buttonIndex = 0;
		}
		else if (pointerTypeId == -2)
		{
			playerPointerEventData.buttonIndex = 1;
		}
		else if (pointerTypeId == -3)
		{
			playerPointerEventData.buttonIndex = 2;
		}
		else if (pointerTypeId >= -2147483520 && pointerTypeId <= -2147483392)
		{
			playerPointerEventData.buttonIndex = pointerTypeId - -2147483520;
		}
		return playerPointerEventData;
	}

	protected void RemovePointerData(PlayerPointerEventData data)
	{
		if (m_PlayerPointerData.TryGetValue(data.playerId, out var value) && (uint)data.inputSourceIndex < (uint)value.Length)
		{
			value[data.inputSourceIndex].Remove(data.pointerId);
		}
	}

	protected PlayerPointerEventData GetTouchPointerEventData(int playerId, int touchDeviceIndex, Touch input, out bool pressed, out bool released)
	{
		PlayerPointerEventData data;
		bool pointerData = GetPointerData(playerId, touchDeviceIndex, input.fingerId, out data, create: true, PointerEventType.Touch);
		data.Reset();
		pressed = pointerData || input.phase == TouchPhase.Began;
		released = input.phase == TouchPhase.Canceled || input.phase == TouchPhase.Ended;
		if (pointerData)
		{
			data.position = input.position;
		}
		if (pressed)
		{
			data.delta = Vector2.zero;
		}
		else
		{
			data.delta = input.position - data.position;
		}
		data.position = input.position;
		data.button = PointerEventData.InputButton.Left;
		base.eventSystem.RaycastAll(data, m_RaycastResultCache);
		RaycastResult pointerCurrentRaycast = BaseInputModule.FindFirstRaycast(m_RaycastResultCache);
		data.pointerCurrentRaycast = pointerCurrentRaycast;
		m_RaycastResultCache.Clear();
		return data;
	}

	protected virtual MouseState GetMousePointerEventData(int playerId, int mouseIndex)
	{
		IMouseInputSource mouseInputSource = GetMouseInputSource(playerId, mouseIndex);
		if (mouseInputSource == null)
		{
			return null;
		}
		PlayerPointerEventData data;
		bool pointerData = GetPointerData(playerId, mouseIndex, -1, out data, create: true, PointerEventType.Mouse);
		data.Reset();
		if (pointerData)
		{
			data.position = mouseInputSource.screenPosition;
		}
		Vector2 screenPosition = mouseInputSource.screenPosition;
		if (mouseInputSource.locked || !mouseInputSource.enabled)
		{
			data.position = new Vector2(-1f, -1f);
			data.delta = Vector2.zero;
		}
		else
		{
			data.delta = screenPosition - data.position;
			data.position = screenPosition;
		}
		data.scrollDelta = mouseInputSource.wheelDelta;
		data.button = PointerEventData.InputButton.Left;
		base.eventSystem.RaycastAll(data, m_RaycastResultCache);
		RaycastResult pointerCurrentRaycast = BaseInputModule.FindFirstRaycast(m_RaycastResultCache);
		data.pointerCurrentRaycast = pointerCurrentRaycast;
		m_RaycastResultCache.Clear();
		GetPointerData(playerId, mouseIndex, -2, out var data2, create: true, PointerEventType.Mouse);
		CopyFromTo(data, data2);
		data2.button = PointerEventData.InputButton.Right;
		GetPointerData(playerId, mouseIndex, -3, out var data3, create: true, PointerEventType.Mouse);
		CopyFromTo(data, data3);
		data3.button = PointerEventData.InputButton.Middle;
		for (int i = 3; i < mouseInputSource.buttonCount; i++)
		{
			GetPointerData(playerId, mouseIndex, -2147483520 + i, out var data4, create: true, PointerEventType.Mouse);
			CopyFromTo(data, data4);
			data4.button = (PointerEventData.InputButton)(-1);
		}
		m_MouseState.SetButtonState(0, StateForMouseButton(playerId, mouseIndex, 0), data);
		m_MouseState.SetButtonState(1, StateForMouseButton(playerId, mouseIndex, 1), data2);
		m_MouseState.SetButtonState(2, StateForMouseButton(playerId, mouseIndex, 2), data3);
		for (int j = 3; j < mouseInputSource.buttonCount; j++)
		{
			GetPointerData(playerId, mouseIndex, -2147483520 + j, out var data5, create: false, PointerEventType.Mouse);
			m_MouseState.SetButtonState(j, StateForMouseButton(playerId, mouseIndex, j), data5);
		}
		return m_MouseState;
	}

	protected PlayerPointerEventData GetLastPointerEventData(int playerId, int pointerIndex, int pointerTypeId, bool ignorePointerTypeId, PointerEventType pointerEventType)
	{
		if (!ignorePointerTypeId)
		{
			GetPointerData(playerId, pointerIndex, pointerTypeId, out var data, create: false, pointerEventType);
			return data;
		}
		if (!m_PlayerPointerData.TryGetValue(playerId, out var value))
		{
			return null;
		}
		if ((uint)pointerIndex >= (uint)value.Length)
		{
			return null;
		}
		using (Dictionary<int, PlayerPointerEventData>.Enumerator enumerator = value[pointerIndex].GetEnumerator())
		{
			if (enumerator.MoveNext())
			{
				return enumerator.Current.Value;
			}
		}
		return null;
	}

	private static bool ShouldStartDrag(Vector2 pressPos, Vector2 currentPos, float threshold, bool useDragThreshold)
	{
		if (!useDragThreshold)
		{
			return true;
		}
		return (pressPos - currentPos).sqrMagnitude >= threshold * threshold;
	}

	protected virtual void ProcessMove(PlayerPointerEventData pointerEvent)
	{
		GameObject newEnterTarget;
		if (pointerEvent.sourceType == PointerEventType.Mouse)
		{
			IMouseInputSource mouseInputSource = GetMouseInputSource(pointerEvent.playerId, pointerEvent.inputSourceIndex);
			newEnterTarget = ((mouseInputSource == null) ? null : ((!mouseInputSource.enabled || mouseInputSource.locked) ? null : pointerEvent.pointerCurrentRaycast.gameObject));
		}
		else
		{
			if (pointerEvent.sourceType != PointerEventType.Touch)
			{
				throw new NotImplementedException();
			}
			newEnterTarget = pointerEvent.pointerCurrentRaycast.gameObject;
		}
		HandlePointerExitAndEnter(pointerEvent, newEnterTarget);
	}

	protected virtual void ProcessDrag(PlayerPointerEventData pointerEvent)
	{
		if (!pointerEvent.IsPointerMoving() || pointerEvent.pointerDrag == null)
		{
			return;
		}
		if (pointerEvent.sourceType == PointerEventType.Mouse)
		{
			IMouseInputSource mouseInputSource = GetMouseInputSource(pointerEvent.playerId, pointerEvent.inputSourceIndex);
			if (mouseInputSource == null || mouseInputSource.locked || !mouseInputSource.enabled)
			{
				return;
			}
		}
		if (!pointerEvent.dragging && ShouldStartDrag(pointerEvent.pressPosition, pointerEvent.position, base.eventSystem.pixelDragThreshold, pointerEvent.useDragThreshold))
		{
			ExecuteEvents.Execute(pointerEvent.pointerDrag, pointerEvent, ExecuteEvents.beginDragHandler);
			pointerEvent.dragging = true;
		}
		if (pointerEvent.dragging)
		{
			if (pointerEvent.pointerPress != pointerEvent.pointerDrag)
			{
				ExecuteEvents.Execute(pointerEvent.pointerPress, pointerEvent, ExecuteEvents.pointerUpHandler);
				pointerEvent.eligibleForClick = false;
				pointerEvent.pointerPress = null;
				pointerEvent.rawPointerPress = null;
			}
			ExecuteEvents.Execute(pointerEvent.pointerDrag, pointerEvent, ExecuteEvents.dragHandler);
		}
	}

	public override bool IsPointerOverGameObject(int pointerTypeId)
	{
		foreach (KeyValuePair<int, Dictionary<int, PlayerPointerEventData>[]> playerPointerDatum in m_PlayerPointerData)
		{
			Dictionary<int, PlayerPointerEventData>[] value = playerPointerDatum.Value;
			for (int i = 0; i < value.Length; i++)
			{
				if (value[i].TryGetValue(pointerTypeId, out var value2) && value2.pointerEnter != null)
				{
					return true;
				}
			}
		}
		return false;
	}

	protected void ClearSelection()
	{
		BaseEventData baseEventData = GetBaseEventData();
		foreach (KeyValuePair<int, Dictionary<int, PlayerPointerEventData>[]> playerPointerDatum in m_PlayerPointerData)
		{
			Dictionary<int, PlayerPointerEventData>[] value = playerPointerDatum.Value;
			for (int i = 0; i < value.Length; i++)
			{
				foreach (KeyValuePair<int, PlayerPointerEventData> item in value[i])
				{
					HandlePointerExitAndEnter(item.Value, null);
				}
				value[i].Clear();
			}
		}
		base.eventSystem.SetSelectedGameObject(null, baseEventData);
	}

	public override string ToString()
	{
		StringBuilder stringBuilder = new StringBuilder("<b>Pointer Input Module of type: </b>" + GetType());
		stringBuilder.AppendLine();
		foreach (KeyValuePair<int, Dictionary<int, PlayerPointerEventData>[]> playerPointerDatum in m_PlayerPointerData)
		{
			stringBuilder.AppendLine("<B>Player Id:</b> " + playerPointerDatum.Key);
			Dictionary<int, PlayerPointerEventData>[] value = playerPointerDatum.Value;
			for (int i = 0; i < value.Length; i++)
			{
				stringBuilder.AppendLine("<B>Pointer Index:</b> " + i);
				foreach (KeyValuePair<int, PlayerPointerEventData> item in value[i])
				{
					stringBuilder.AppendLine("<B>Button Id:</b> " + item.Key);
					stringBuilder.AppendLine(item.Value.ToString());
				}
			}
		}
		return stringBuilder.ToString();
	}

	protected void DeselectIfSelectionChanged(GameObject currentOverGo, BaseEventData pointerEvent)
	{
		if (ExecuteEvents.GetEventHandler<ISelectHandler>(currentOverGo) != base.eventSystem.currentSelectedGameObject)
		{
			base.eventSystem.SetSelectedGameObject(null, pointerEvent);
		}
	}

	protected void CopyFromTo(PointerEventData from, PointerEventData to)
	{
		to.position = from.position;
		to.delta = from.delta;
		to.scrollDelta = from.scrollDelta;
		to.pointerCurrentRaycast = from.pointerCurrentRaycast;
		to.pointerEnter = from.pointerEnter;
	}

	protected PointerEventData.FramePressState StateForMouseButton(int playerId, int mouseIndex, int buttonId)
	{
		IMouseInputSource mouseInputSource = GetMouseInputSource(playerId, mouseIndex);
		if (mouseInputSource == null)
		{
			return PointerEventData.FramePressState.NotChanged;
		}
		bool buttonDown = mouseInputSource.GetButtonDown(buttonId);
		bool buttonUp = mouseInputSource.GetButtonUp(buttonId);
		if (buttonDown && buttonUp)
		{
			return PointerEventData.FramePressState.PressedAndReleased;
		}
		if (buttonDown)
		{
			return PointerEventData.FramePressState.Pressed;
		}
		if (buttonUp)
		{
			return PointerEventData.FramePressState.Released;
		}
		return PointerEventData.FramePressState.NotChanged;
	}
}