mirror of
https://git.ryujinx.app/ryubing/ryujinx.git
synced 2025-08-02 22:17:13 +02:00
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());
|
||||
}
|
||||
|
|
|
@ -1150,7 +1150,7 @@ namespace Ryujinx.Ui.Windows
|
|||
|
||||
if (_mainWindow.RendererWidget != null)
|
||||
{
|
||||
_mainWindow.RendererWidget.NpadManager.ReloadConfiguration(newConfig, ConfigurationState.Instance.Hid.EnableKeyboard);
|
||||
_mainWindow.RendererWidget.NpadManager.ReloadConfiguration(newConfig, ConfigurationState.Instance.Hid.EnableKeyboard, ConfigurationState.Instance.Hid.EnableMouse);
|
||||
}
|
||||
|
||||
// Atomically replace and signal input change.
|
||||
|
|
|
@ -56,6 +56,7 @@ namespace Ryujinx.Ui.Windows
|
|||
[GUI] CheckButton _expandRamToggle;
|
||||
[GUI] CheckButton _ignoreToggle;
|
||||
[GUI] CheckButton _directKeyboardAccess;
|
||||
[GUI] CheckButton _directMouseAccess;
|
||||
[GUI] ComboBoxText _systemLanguageSelect;
|
||||
[GUI] ComboBoxText _systemRegionSelect;
|
||||
[GUI] Entry _systemTimeZoneEntry;
|
||||
|
@ -245,6 +246,11 @@ namespace Ryujinx.Ui.Windows
|
|||
_directKeyboardAccess.Click();
|
||||
}
|
||||
|
||||
if (ConfigurationState.Instance.Hid.EnableMouse)
|
||||
{
|
||||
_directMouseAccess.Click();
|
||||
}
|
||||
|
||||
if (ConfigurationState.Instance.Ui.EnableCustomTheme)
|
||||
{
|
||||
_custThemeToggle.Click();
|
||||
|
@ -461,6 +467,7 @@ namespace Ryujinx.Ui.Windows
|
|||
ConfigurationState.Instance.System.ExpandRam.Value = _expandRamToggle.Active;
|
||||
ConfigurationState.Instance.System.IgnoreMissingServices.Value = _ignoreToggle.Active;
|
||||
ConfigurationState.Instance.Hid.EnableKeyboard.Value = _directKeyboardAccess.Active;
|
||||
ConfigurationState.Instance.Hid.EnableMouse.Value = _directMouseAccess.Active;
|
||||
ConfigurationState.Instance.Ui.EnableCustomTheme.Value = _custThemeToggle.Active;
|
||||
ConfigurationState.Instance.System.Language.Value = Enum.Parse<Language>(_systemLanguageSelect.ActiveId);
|
||||
ConfigurationState.Instance.System.Region.Value = Enum.Parse<Configuration.System.Region>(_systemRegionSelect.ActiveId);
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!-- Generated with glade 3.38.1 -->
|
||||
<!-- Generated with glade 3.38.2 -->
|
||||
<interface>
|
||||
<requires lib="gtk+" version="3.20"/>
|
||||
<object class="GtkAdjustment" id="_fsLogSpinAdjustment">
|
||||
|
@ -520,6 +520,22 @@
|
|||
<property name="position">1</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkCheckButton" id="_directMouseAccess">
|
||||
<property name="label" translatable="yes">Direct Mouse Access</property>
|
||||
<property name="visible">True</property>
|
||||
<property name="can-focus">True</property>
|
||||
<property name="receives-default">False</property>
|
||||
<property name="tooltip-text" translatable="yes">Enable or disable "direct keyboard access (HID) support" (Provides games access to your keyboard as a text entry device)</property>
|
||||
<property name="draw-indicator">True</property>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="expand">False</property>
|
||||
<property name="fill">False</property>
|
||||
<property name="padding">10</property>
|
||||
<property name="position">2</property>
|
||||
</packing>
|
||||
</child>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="expand">False</property>
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue