Add Direct Mouse Support (#2374)
* and direct mouse support * and direct mouse support * hide cursor if mouse enabled * add config * update docs * sorted usings
This commit is contained in:
parent
a10b2c5ff2
commit
77aab9aca3
16 changed files with 200 additions and 32 deletions
|
@ -63,6 +63,7 @@ namespace Ryujinx.Ui
|
|||
|
||||
private int _windowHeight;
|
||||
private int _windowWidth;
|
||||
private bool _isMouseInClient;
|
||||
|
||||
public RendererWidgetBase(InputManager inputManager, GraphicsDebugLevel glLogLevel)
|
||||
{
|
||||
|
@ -87,6 +88,9 @@ namespace Ryujinx.Ui
|
|||
AddEvents((int)(EventMask.ButtonPressMask
|
||||
| EventMask.ButtonReleaseMask
|
||||
| EventMask.PointerMotionMask
|
||||
| EventMask.ScrollMask
|
||||
| EventMask.EnterNotifyMask
|
||||
| EventMask.LeaveNotifyMask
|
||||
| EventMask.KeyPressMask
|
||||
| EventMask.KeyReleaseMask));
|
||||
|
||||
|
@ -125,6 +129,8 @@ namespace Ryujinx.Ui
|
|||
{
|
||||
ConfigurationState.Instance.HideCursorOnIdle.Event -= HideCursorStateChanged;
|
||||
|
||||
Window.Cursor = null;
|
||||
|
||||
NpadManager.Dispose();
|
||||
Dispose();
|
||||
}
|
||||
|
@ -136,9 +142,34 @@ namespace Ryujinx.Ui
|
|||
_lastCursorMoveTime = Stopwatch.GetTimestamp();
|
||||
}
|
||||
|
||||
if(ConfigurationState.Instance.Hid.EnableMouse)
|
||||
{
|
||||
Window.Cursor = _invisibleCursor;
|
||||
}
|
||||
|
||||
_isMouseInClient = true;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
protected override bool OnEnterNotifyEvent(EventCrossing evnt)
|
||||
{
|
||||
Window.Cursor = ConfigurationState.Instance.Hid.EnableMouse ? _invisibleCursor : null;
|
||||
|
||||
_isMouseInClient = true;
|
||||
|
||||
return base.OnEnterNotifyEvent(evnt);
|
||||
}
|
||||
|
||||
protected override bool OnLeaveNotifyEvent(EventCrossing evnt)
|
||||
{
|
||||
Window.Cursor = null;
|
||||
|
||||
_isMouseInClient = false;
|
||||
|
||||
return base.OnLeaveNotifyEvent(evnt);
|
||||
}
|
||||
|
||||
protected override void OnGetPreferredHeight(out int minimumHeight, out int naturalHeight)
|
||||
{
|
||||
Gdk.Monitor monitor = Display.GetMonitorAtWindow(Window);
|
||||
|
@ -241,11 +272,16 @@ namespace Ryujinx.Ui
|
|||
|
||||
_toggleDockedMode = toggleDockedMode;
|
||||
|
||||
if (_hideCursorOnIdle)
|
||||
if (_hideCursorOnIdle && !ConfigurationState.Instance.Hid.EnableMouse)
|
||||
{
|
||||
long cursorMoveDelta = Stopwatch.GetTimestamp() - _lastCursorMoveTime;
|
||||
Window.Cursor = (cursorMoveDelta >= CursorHideIdleTime * Stopwatch.Frequency) ? _invisibleCursor : null;
|
||||
}
|
||||
|
||||
if(ConfigurationState.Instance.Hid.EnableMouse && _isMouseInClient)
|
||||
{
|
||||
Window.Cursor = _invisibleCursor;
|
||||
}
|
||||
}
|
||||
|
||||
public void Initialize(Switch device)
|
||||
|
@ -254,7 +290,7 @@ namespace Ryujinx.Ui
|
|||
Renderer = Device.Gpu.Renderer;
|
||||
Renderer?.Window.SetSize(_windowWidth, _windowHeight);
|
||||
|
||||
NpadManager.Initialize(device, ConfigurationState.Instance.Hid.InputConfig, ConfigurationState.Instance.Hid.EnableKeyboard);
|
||||
NpadManager.Initialize(device, ConfigurationState.Instance.Hid.InputConfig, ConfigurationState.Instance.Hid.EnableKeyboard, ConfigurationState.Instance.Hid.EnableMouse);
|
||||
TouchScreenManager.Initialize(device);
|
||||
}
|
||||
|
||||
|
@ -442,7 +478,7 @@ namespace Ryujinx.Ui
|
|||
});
|
||||
}
|
||||
|
||||
NpadManager.Update();
|
||||
NpadManager.Update(ConfigurationState.Instance.Graphics.AspectRatio.Value.ToFloat());
|
||||
|
||||
if ((Toplevel as MainWindow).IsFocused)
|
||||
{
|
||||
|
@ -461,7 +497,7 @@ namespace Ryujinx.Ui
|
|||
bool hasTouch = false;
|
||||
|
||||
// Get screen touch position
|
||||
if ((Toplevel as MainWindow).IsFocused)
|
||||
if ((Toplevel as MainWindow).IsFocused && !ConfigurationState.Instance.Hid.EnableMouse)
|
||||
{
|
||||
hasTouch = TouchScreenManager.Update(true, (_inputManager.MouseDriver as GTK3MouseDriver).IsButtonPressed(MouseButton.Button1), ConfigurationState.Instance.Graphics.AspectRatio.Value.ToFloat());
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue