Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MouseState._pressedButtons not return to MemoryPool #2411

Open
Sarofc opened this issue Jan 14, 2025 · 0 comments
Open

MouseState._pressedButtons not return to MemoryPool #2411

Sarofc opened this issue Jan 14, 2025 · 0 comments
Labels
area-Input bug Something isn't working

Comments

@Sarofc
Copy link

Sarofc commented Jan 14, 2025

version 2.22

Image
internal MouseState(IMouse mouse, MemoryPool<byte> pool)
{
	//IL_0097: Unknown result type (might be due to invalid IL or missing references)
	//IL_009d: Expected I4, but got Unknown
	//IL_015f: Unknown result type (might be due to invalid IL or missing references)
	//IL_0164: Unknown result type (might be due to invalid IL or missing references)
	Name = ((IInputDevice)mouse).Name;
	Index = ((IInputDevice)mouse).Index;
	IsConnected = ((IInputDevice)mouse).IsConnected;
	IReadOnlyList<MouseButton> supportedButtons = mouse.SupportedButtons;
	_buttonCount = supportedButtons.Count;
	_buttons = pool.Rent(_buttonCount * 4);
	_pressedButtons = pool.Rent(_buttonCount * 4);
	_pressedButtonCount = _buttonCount;
	Span<MouseButton> supportedButtons2 = GetSupportedButtons();
	Span<MouseButton> pressedButtons = GetPressedButtons();
	_pressedButtonCount = 0;
	for (int i = 0; i < _buttonCount; i++)
	{
		supportedButtons2[i] = (MouseButton)(int)supportedButtons[i];
		if (mouse.IsButtonPressed(supportedButtons2[i]))
		{
			pressedButtons[_pressedButtonCount++] = supportedButtons2[i];
		}
	}
	using (_pressedButtons)
	{
		Span<MouseButton> pressedButtons2 = GetPressedButtons();
		_pressedButtons = pool.Rent(_pressedButtonCount * 4);
		pressedButtons = GetPressedButtons();
		pressedButtons2.CopyTo(pressedButtons);
		IReadOnlyList<ScrollWheel> scrollWheels = mouse.ScrollWheels;
		_scrollWheelCount = scrollWheels.Count;
		_scrollWheels = pool.Rent(_scrollWheelCount * Unsafe.SizeOf<ScrollWheel>());
		Span<ScrollWheel> scrollWheels2 = GetScrollWheels();
		for (int j = 0; j < _scrollWheelCount; j++)
		{
			scrollWheels2[j] = scrollWheels[j];
		}
		Position = mouse.Position;
	}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-Input bug Something isn't working
Projects
Status: Todo
Development

No branches or pull requests

2 participants