Handheld Gyro
This commit is contained in:
parent
0137c9e635
commit
2200dac64f
23 changed files with 169 additions and 12 deletions
|
@ -3,6 +3,7 @@
|
||||||
<ManagePackageVersionsCentrally>true</ManagePackageVersionsCentrally>
|
<ManagePackageVersionsCentrally>true</ManagePackageVersionsCentrally>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
<PackageVersion Include="Alimer.Bindings.SDL" Version="3.7.1" />
|
||||||
<PackageVersion Include="Avalonia" Version="11.0.10" />
|
<PackageVersion Include="Avalonia" Version="11.0.10" />
|
||||||
<PackageVersion Include="Avalonia.Controls.DataGrid" Version="11.0.10" />
|
<PackageVersion Include="Avalonia.Controls.DataGrid" Version="11.0.10" />
|
||||||
<PackageVersion Include="Avalonia.Desktop" Version="11.0.10" />
|
<PackageVersion Include="Avalonia.Desktop" Version="11.0.10" />
|
||||||
|
@ -49,4 +50,4 @@
|
||||||
<PackageVersion Include="System.Management" Version="8.0.0" />
|
<PackageVersion Include="System.Management" Version="8.0.0" />
|
||||||
<PackageVersion Include="UnicornEngine.Unicorn" Version="2.0.2-rc1-fb78016" />
|
<PackageVersion Include="UnicornEngine.Unicorn" Version="2.0.2-rc1-fb78016" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
</Project>
|
</Project>
|
||||||
|
|
11
Ryujinx.sln
11
Ryujinx.sln
|
@ -87,6 +87,10 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Ryujinx.Horizon", "src\Ryuj
|
||||||
EndProject
|
EndProject
|
||||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Ryujinx.Horizon.Kernel.Generators", "src\Ryujinx.Horizon.Kernel.Generators\Ryujinx.Horizon.Kernel.Generators.csproj", "{7F55A45D-4E1D-4A36-ADD3-87F29A285AA2}"
|
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Ryujinx.Horizon.Kernel.Generators", "src\Ryujinx.Horizon.Kernel.Generators\Ryujinx.Horizon.Kernel.Generators.csproj", "{7F55A45D-4E1D-4A36-ADD3-87F29A285AA2}"
|
||||||
EndProject
|
EndProject
|
||||||
|
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{D796F12C-217B-4BBF-A131-B6DCB72C6282}"
|
||||||
|
EndProject
|
||||||
|
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Ryujinx.Input.SDL3", "src\Ryujinx.Input.SDL3\Ryujinx.Input.SDL3.csproj", "{3BF24278-547D-42C2-9D43-182B978F54DD}"
|
||||||
|
EndProject
|
||||||
Global
|
Global
|
||||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||||
Debug|Any CPU = Debug|Any CPU
|
Debug|Any CPU = Debug|Any CPU
|
||||||
|
@ -249,6 +253,10 @@ Global
|
||||||
{7F55A45D-4E1D-4A36-ADD3-87F29A285AA2}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
{7F55A45D-4E1D-4A36-ADD3-87F29A285AA2}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
{7F55A45D-4E1D-4A36-ADD3-87F29A285AA2}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
{7F55A45D-4E1D-4A36-ADD3-87F29A285AA2}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
{7F55A45D-4E1D-4A36-ADD3-87F29A285AA2}.Release|Any CPU.Build.0 = Release|Any CPU
|
{7F55A45D-4E1D-4A36-ADD3-87F29A285AA2}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||||
|
{3BF24278-547D-42C2-9D43-182B978F54DD}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||||
|
{3BF24278-547D-42C2-9D43-182B978F54DD}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
|
{3BF24278-547D-42C2-9D43-182B978F54DD}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
|
{3BF24278-547D-42C2-9D43-182B978F54DD}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||||
EndGlobalSection
|
EndGlobalSection
|
||||||
GlobalSection(SolutionProperties) = preSolution
|
GlobalSection(SolutionProperties) = preSolution
|
||||||
HideSolutionNode = FALSE
|
HideSolutionNode = FALSE
|
||||||
|
@ -256,4 +264,7 @@ Global
|
||||||
GlobalSection(ExtensibilityGlobals) = postSolution
|
GlobalSection(ExtensibilityGlobals) = postSolution
|
||||||
SolutionGuid = {110169B3-3328-4730-8AB0-BA05BEF75C1A}
|
SolutionGuid = {110169B3-3328-4730-8AB0-BA05BEF75C1A}
|
||||||
EndGlobalSection
|
EndGlobalSection
|
||||||
|
GlobalSection(NestedProjects) = preSolution
|
||||||
|
{3BF24278-547D-42C2-9D43-182B978F54DD} = {D796F12C-217B-4BBF-A131-B6DCB72C6282}
|
||||||
|
EndGlobalSection
|
||||||
EndGlobal
|
EndGlobal
|
||||||
|
|
|
@ -56,6 +56,7 @@ namespace Ryujinx.Common.Configuration.Hid.Controller.Motion
|
||||||
return motionBackendType switch
|
return motionBackendType switch
|
||||||
{
|
{
|
||||||
MotionInputBackendType.GamepadDriver => JsonSerializer.Deserialize(ref reader, _serializerContext.StandardMotionConfigController),
|
MotionInputBackendType.GamepadDriver => JsonSerializer.Deserialize(ref reader, _serializerContext.StandardMotionConfigController),
|
||||||
|
MotionInputBackendType.Handheld => JsonSerializer.Deserialize(ref reader, _serializerContext.StandardMotionConfigController),
|
||||||
MotionInputBackendType.CemuHook => JsonSerializer.Deserialize(ref reader, _serializerContext.CemuHookMotionConfigController),
|
MotionInputBackendType.CemuHook => JsonSerializer.Deserialize(ref reader, _serializerContext.CemuHookMotionConfigController),
|
||||||
_ => throw new InvalidOperationException($"Unknown backend type {motionBackendType}"),
|
_ => throw new InvalidOperationException($"Unknown backend type {motionBackendType}"),
|
||||||
};
|
};
|
||||||
|
@ -66,6 +67,7 @@ namespace Ryujinx.Common.Configuration.Hid.Controller.Motion
|
||||||
switch (value.MotionBackend)
|
switch (value.MotionBackend)
|
||||||
{
|
{
|
||||||
case MotionInputBackendType.GamepadDriver:
|
case MotionInputBackendType.GamepadDriver:
|
||||||
|
case MotionInputBackendType.Handheld:
|
||||||
JsonSerializer.Serialize(writer, value as StandardMotionConfigController, _serializerContext.StandardMotionConfigController);
|
JsonSerializer.Serialize(writer, value as StandardMotionConfigController, _serializerContext.StandardMotionConfigController);
|
||||||
break;
|
break;
|
||||||
case MotionInputBackendType.CemuHook:
|
case MotionInputBackendType.CemuHook:
|
||||||
|
|
|
@ -9,5 +9,6 @@ namespace Ryujinx.Common.Configuration.Hid.Controller.Motion
|
||||||
Invalid,
|
Invalid,
|
||||||
GamepadDriver,
|
GamepadDriver,
|
||||||
CemuHook,
|
CemuHook,
|
||||||
|
Handheld,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -36,6 +36,7 @@
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ProjectReference Include="..\Ryujinx.Input\Ryujinx.Input.csproj" />
|
<ProjectReference Include="..\Ryujinx.Input\Ryujinx.Input.csproj" />
|
||||||
<ProjectReference Include="..\Ryujinx.Input.SDL2\Ryujinx.Input.SDL2.csproj" />
|
<ProjectReference Include="..\Ryujinx.Input.SDL2\Ryujinx.Input.SDL2.csproj" />
|
||||||
|
<ProjectReference Include="..\Ryujinx.Input.SDL3\Ryujinx.Input.SDL3.csproj" />
|
||||||
<ProjectReference Include="..\Ryujinx.Audio.Backends.OpenAL\Ryujinx.Audio.Backends.OpenAL.csproj" />
|
<ProjectReference Include="..\Ryujinx.Audio.Backends.OpenAL\Ryujinx.Audio.Backends.OpenAL.csproj" />
|
||||||
<ProjectReference Include="..\Ryujinx.Audio.Backends.SDL2\Ryujinx.Audio.Backends.SDL2.csproj" />
|
<ProjectReference Include="..\Ryujinx.Audio.Backends.SDL2\Ryujinx.Audio.Backends.SDL2.csproj" />
|
||||||
<ProjectReference Include="..\Ryujinx.Audio.Backends.SoundIo\Ryujinx.Audio.Backends.SoundIo.csproj" />
|
<ProjectReference Include="..\Ryujinx.Audio.Backends.SoundIo\Ryujinx.Audio.Backends.SoundIo.csproj" />
|
||||||
|
|
|
@ -26,6 +26,7 @@ using Ryujinx.Input.GTK3;
|
||||||
using Ryujinx.Input.HLE;
|
using Ryujinx.Input.HLE;
|
||||||
using Ryujinx.Input.SDL2;
|
using Ryujinx.Input.SDL2;
|
||||||
using Ryujinx.Modules;
|
using Ryujinx.Modules;
|
||||||
|
using Ryujinx.SDL3;
|
||||||
using Ryujinx.UI.App.Common;
|
using Ryujinx.UI.App.Common;
|
||||||
using Ryujinx.UI.Applet;
|
using Ryujinx.UI.Applet;
|
||||||
using Ryujinx.UI.Common;
|
using Ryujinx.UI.Common;
|
||||||
|
@ -339,7 +340,7 @@ namespace Ryujinx.UI
|
||||||
|
|
||||||
Task.Run(RefreshFirmwareLabel);
|
Task.Run(RefreshFirmwareLabel);
|
||||||
|
|
||||||
InputManager = new InputManager(new GTK3KeyboardDriver(this), new SDL2GamepadDriver());
|
InputManager = new InputManager(new GTK3KeyboardDriver(this), new SDL2GamepadDriver(), new SDL3MotionDriver());
|
||||||
}
|
}
|
||||||
|
|
||||||
private void UpdateMultiplayerLanInterfaceId(object sender, ReactiveEventArgs<string> args)
|
private void UpdateMultiplayerLanInterfaceId(object sender, ReactiveEventArgs<string> args)
|
||||||
|
|
|
@ -47,6 +47,7 @@ namespace Ryujinx.UI.Windows
|
||||||
[GUI] Adjustment _gyroDeadzone;
|
[GUI] Adjustment _gyroDeadzone;
|
||||||
[GUI] CheckButton _enableMotion;
|
[GUI] CheckButton _enableMotion;
|
||||||
[GUI] CheckButton _enableCemuHook;
|
[GUI] CheckButton _enableCemuHook;
|
||||||
|
[GUI] CheckButton _enableHandheld;
|
||||||
[GUI] CheckButton _mirrorInput;
|
[GUI] CheckButton _mirrorInput;
|
||||||
[GUI] Entry _dsuServerHost;
|
[GUI] Entry _dsuServerHost;
|
||||||
[GUI] Entry _dsuServerPort;
|
[GUI] Entry _dsuServerPort;
|
||||||
|
@ -185,6 +186,7 @@ namespace Ryujinx.UI.Windows
|
||||||
_rSl.Clicked += Button_Pressed;
|
_rSl.Clicked += Button_Pressed;
|
||||||
_rSr.Clicked += Button_Pressed;
|
_rSr.Clicked += Button_Pressed;
|
||||||
_enableCemuHook.Clicked += CemuHookCheckButtonPressed;
|
_enableCemuHook.Clicked += CemuHookCheckButtonPressed;
|
||||||
|
_enableHandheld.Clicked += HandheldCheckButtonPressed;
|
||||||
|
|
||||||
// Setup current values.
|
// Setup current values.
|
||||||
UpdateInputDeviceList();
|
UpdateInputDeviceList();
|
||||||
|
@ -202,6 +204,11 @@ namespace Ryujinx.UI.Windows
|
||||||
_mainWindow.RendererWidget?.NpadManager.BlockInputUpdates();
|
_mainWindow.RendererWidget?.NpadManager.BlockInputUpdates();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void HandheldCheckButtonPressed(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
UpdateCemuHookSpecificFieldsVisibility();
|
||||||
|
}
|
||||||
|
|
||||||
private void CemuHookCheckButtonPressed(object sender, EventArgs e)
|
private void CemuHookCheckButtonPressed(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
UpdateCemuHookSpecificFieldsVisibility();
|
UpdateCemuHookSpecificFieldsVisibility();
|
||||||
|
@ -291,8 +298,13 @@ namespace Ryujinx.UI.Windows
|
||||||
|
|
||||||
private void UpdateCemuHookSpecificFieldsVisibility()
|
private void UpdateCemuHookSpecificFieldsVisibility()
|
||||||
{
|
{
|
||||||
|
if (_enableHandheld.Active)
|
||||||
|
{
|
||||||
|
_enableCemuHook.Active = false;
|
||||||
|
}
|
||||||
if (_enableCemuHook.Active)
|
if (_enableCemuHook.Active)
|
||||||
{
|
{
|
||||||
|
_enableHandheld.Active = false;
|
||||||
_dsuServerHostBox.Show();
|
_dsuServerHostBox.Show();
|
||||||
_dsuServerPortBox.Show();
|
_dsuServerPortBox.Show();
|
||||||
_motionControllerSlot.Show();
|
_motionControllerSlot.Show();
|
||||||
|
@ -429,6 +441,7 @@ namespace Ryujinx.UI.Windows
|
||||||
_mirrorInput.Active = false;
|
_mirrorInput.Active = false;
|
||||||
_enableMotion.Active = false;
|
_enableMotion.Active = false;
|
||||||
_enableCemuHook.Active = false;
|
_enableCemuHook.Active = false;
|
||||||
|
_enableHandheld.Active = false;
|
||||||
_slotNumber.Value = 0;
|
_slotNumber.Value = 0;
|
||||||
_altSlotNumber.Value = 0;
|
_altSlotNumber.Value = 0;
|
||||||
_sensitivity.Value = 100;
|
_sensitivity.Value = 100;
|
||||||
|
@ -528,6 +541,7 @@ namespace Ryujinx.UI.Windows
|
||||||
_gyroDeadzone.Value = controllerConfig.Motion.GyroDeadzone;
|
_gyroDeadzone.Value = controllerConfig.Motion.GyroDeadzone;
|
||||||
_enableMotion.Active = controllerConfig.Motion.EnableMotion;
|
_enableMotion.Active = controllerConfig.Motion.EnableMotion;
|
||||||
_enableCemuHook.Active = controllerConfig.Motion.MotionBackend == MotionInputBackendType.CemuHook;
|
_enableCemuHook.Active = controllerConfig.Motion.MotionBackend == MotionInputBackendType.CemuHook;
|
||||||
|
_enableHandheld.Active = controllerConfig.Motion.MotionBackend == MotionInputBackendType.Handheld;
|
||||||
|
|
||||||
// If both stick ranges are 0 (usually indicative of an outdated profile load) then both sticks will be set to 1.0.
|
// If both stick ranges are 0 (usually indicative of an outdated profile load) then both sticks will be set to 1.0.
|
||||||
if (_controllerRangeLeft.Value <= 0.0 && _controllerRangeRight.Value <= 0.0)
|
if (_controllerRangeLeft.Value <= 0.0 && _controllerRangeRight.Value <= 0.0)
|
||||||
|
@ -688,7 +702,7 @@ namespace Ryujinx.UI.Windows
|
||||||
{
|
{
|
||||||
motionConfig = new StandardMotionConfigController
|
motionConfig = new StandardMotionConfigController
|
||||||
{
|
{
|
||||||
MotionBackend = MotionInputBackendType.GamepadDriver,
|
MotionBackend = _enableHandheld.Active ? MotionInputBackendType.Handheld : MotionInputBackendType.GamepadDriver,
|
||||||
EnableMotion = _enableMotion.Active,
|
EnableMotion = _enableMotion.Active,
|
||||||
Sensitivity = (int)_sensitivity.Value,
|
Sensitivity = (int)_sensitivity.Value,
|
||||||
GyroDeadzone = _gyroDeadzone.Value,
|
GyroDeadzone = _gyroDeadzone.Value,
|
||||||
|
|
|
@ -1867,6 +1867,20 @@
|
||||||
<property name="position">1</property>
|
<property name="position">1</property>
|
||||||
</packing>
|
</packing>
|
||||||
</child>
|
</child>
|
||||||
|
<child>
|
||||||
|
<object class="GtkCheckButton" id="_enableHandheld">
|
||||||
|
<property name="label" translatable="yes">Use Handheld compatible motion</property>
|
||||||
|
<property name="visible">True</property>
|
||||||
|
<property name="can_focus">True</property>
|
||||||
|
<property name="receives_default">False</property>
|
||||||
|
<property name="draw_indicator">True</property>
|
||||||
|
</object>
|
||||||
|
<packing>
|
||||||
|
<property name="expand">False</property>
|
||||||
|
<property name="fill">True</property>
|
||||||
|
<property name="position">2</property>
|
||||||
|
</packing>
|
||||||
|
</child>
|
||||||
<child>
|
<child>
|
||||||
<object class="GtkCheckButton" id="_enableCemuHook">
|
<object class="GtkCheckButton" id="_enableCemuHook">
|
||||||
<property name="label" translatable="yes">Use CemuHook compatible motion</property>
|
<property name="label" translatable="yes">Use CemuHook compatible motion</property>
|
||||||
|
|
|
@ -28,6 +28,7 @@ using Ryujinx.Input;
|
||||||
using Ryujinx.Input.HLE;
|
using Ryujinx.Input.HLE;
|
||||||
using Ryujinx.Input.SDL2;
|
using Ryujinx.Input.SDL2;
|
||||||
using Ryujinx.SDL2.Common;
|
using Ryujinx.SDL2.Common;
|
||||||
|
using Ryujinx.SDL3;
|
||||||
using Silk.NET.Vulkan;
|
using Silk.NET.Vulkan;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
@ -339,7 +340,7 @@ namespace Ryujinx.Headless.SDL2
|
||||||
_accountManager = new AccountManager(_libHacHorizonManager.RyujinxClient, option.UserProfile);
|
_accountManager = new AccountManager(_libHacHorizonManager.RyujinxClient, option.UserProfile);
|
||||||
_userChannelPersistence = new UserChannelPersistence();
|
_userChannelPersistence = new UserChannelPersistence();
|
||||||
|
|
||||||
_inputManager = new InputManager(new SDL2KeyboardDriver(), new SDL2GamepadDriver());
|
_inputManager = new InputManager(new SDL2KeyboardDriver(), new SDL2GamepadDriver(), new SDL3MotionDriver());
|
||||||
|
|
||||||
GraphicsConfig.EnableShaderCache = true;
|
GraphicsConfig.EnableShaderCache = true;
|
||||||
|
|
||||||
|
|
|
@ -24,6 +24,7 @@
|
||||||
<ProjectReference Include="..\Ryujinx.Graphics.Vulkan\Ryujinx.Graphics.Vulkan.csproj" />
|
<ProjectReference Include="..\Ryujinx.Graphics.Vulkan\Ryujinx.Graphics.Vulkan.csproj" />
|
||||||
<ProjectReference Include="..\Ryujinx.Input\Ryujinx.Input.csproj" />
|
<ProjectReference Include="..\Ryujinx.Input\Ryujinx.Input.csproj" />
|
||||||
<ProjectReference Include="..\Ryujinx.Input.SDL2\Ryujinx.Input.SDL2.csproj" />
|
<ProjectReference Include="..\Ryujinx.Input.SDL2\Ryujinx.Input.SDL2.csproj" />
|
||||||
|
<ProjectReference Include="..\Ryujinx.Input.SDL3\Ryujinx.Input.SDL3.csproj" />
|
||||||
<ProjectReference Include="..\Ryujinx.Audio.Backends.SDL2\Ryujinx.Audio.Backends.SDL2.csproj" />
|
<ProjectReference Include="..\Ryujinx.Audio.Backends.SDL2\Ryujinx.Audio.Backends.SDL2.csproj" />
|
||||||
<ProjectReference Include="..\Ryujinx.Common\Ryujinx.Common.csproj" />
|
<ProjectReference Include="..\Ryujinx.Common\Ryujinx.Common.csproj" />
|
||||||
<ProjectReference Include="..\Ryujinx.HLE\Ryujinx.HLE.csproj" />
|
<ProjectReference Include="..\Ryujinx.HLE\Ryujinx.HLE.csproj" />
|
||||||
|
|
13
src/Ryujinx.Input.SDL3/Ryujinx.Input.SDL3.csproj
Normal file
13
src/Ryujinx.Input.SDL3/Ryujinx.Input.SDL3.csproj
Normal file
|
@ -0,0 +1,13 @@
|
||||||
|
<Project Sdk="Microsoft.NET.Sdk">
|
||||||
|
|
||||||
|
<PropertyGroup>
|
||||||
|
<TargetFramework>net8.0</TargetFramework>
|
||||||
|
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
|
||||||
|
</PropertyGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<ProjectReference Include="..\Ryujinx.Input\Ryujinx.Input.csproj" />
|
||||||
|
<PackageReference Include="Alimer.Bindings.SDL" />
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
|
</Project>
|
35
src/Ryujinx.Input.SDL3/SDL3MotionDriver.cs
Normal file
35
src/Ryujinx.Input.SDL3/SDL3MotionDriver.cs
Normal file
|
@ -0,0 +1,35 @@
|
||||||
|
using Ryujinx.Input;
|
||||||
|
using SDL3;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Numerics;
|
||||||
|
using static SDL3.SDL3;
|
||||||
|
|
||||||
|
namespace Ryujinx.SDL3;
|
||||||
|
public unsafe class SDL3MotionDriver : IHandheld
|
||||||
|
{
|
||||||
|
private Dictionary<SDL_SensorType, SDL_Sensor> sensors;
|
||||||
|
public SDL3MotionDriver()
|
||||||
|
{
|
||||||
|
SDL_Init(SDL_InitFlags.Sensor);
|
||||||
|
sensors = SDL_GetSensors().ToArray().ToDictionary(SDL_GetSensorTypeForID, SDL_OpenSensor);
|
||||||
|
}
|
||||||
|
|
||||||
|
public Vector3 GetMotionData(MotionInputId gyroscope)
|
||||||
|
{
|
||||||
|
var data = stackalloc float[3];
|
||||||
|
|
||||||
|
switch (gyroscope)
|
||||||
|
{
|
||||||
|
case MotionInputId.Gyroscope:
|
||||||
|
SDL_GetSensorData(sensors[SDL_SensorType.Gyro], data, 3);
|
||||||
|
return new Vector3(data[0], data[1], data[2]) * (180 / MathF.PI);
|
||||||
|
case MotionInputId.Accelerometer:
|
||||||
|
SDL_GetSensorData(sensors[SDL_SensorType.Accel], data, 3);
|
||||||
|
return new Vector3(data[0], data[1], data[2]) / SDL_STANDARD_GRAVITY;
|
||||||
|
default:
|
||||||
|
return Vector3.Zero;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -7,9 +7,11 @@ namespace Ryujinx.Input.HLE
|
||||||
public IGamepadDriver KeyboardDriver { get; private set; }
|
public IGamepadDriver KeyboardDriver { get; private set; }
|
||||||
public IGamepadDriver GamepadDriver { get; private set; }
|
public IGamepadDriver GamepadDriver { get; private set; }
|
||||||
public IGamepadDriver MouseDriver { get; private set; }
|
public IGamepadDriver MouseDriver { get; private set; }
|
||||||
|
public IHandheld Handheld { get; private set; }
|
||||||
|
|
||||||
public InputManager(IGamepadDriver keyboardDriver, IGamepadDriver gamepadDriver)
|
public InputManager(IGamepadDriver keyboardDriver, IGamepadDriver gamepadDriver, IHandheld handheld)
|
||||||
{
|
{
|
||||||
|
Handheld = handheld;
|
||||||
KeyboardDriver = keyboardDriver;
|
KeyboardDriver = keyboardDriver;
|
||||||
GamepadDriver = gamepadDriver;
|
GamepadDriver = gamepadDriver;
|
||||||
}
|
}
|
||||||
|
@ -23,7 +25,7 @@ namespace Ryujinx.Input.HLE
|
||||||
|
|
||||||
public NpadManager CreateNpadManager()
|
public NpadManager CreateNpadManager()
|
||||||
{
|
{
|
||||||
return new NpadManager(KeyboardDriver, GamepadDriver, MouseDriver);
|
return new NpadManager(KeyboardDriver, GamepadDriver, MouseDriver, Handheld);
|
||||||
}
|
}
|
||||||
|
|
||||||
public TouchScreenManager CreateTouchScreenManager()
|
public TouchScreenManager CreateTouchScreenManager()
|
||||||
|
|
|
@ -215,12 +215,14 @@ namespace Ryujinx.Input.HLE
|
||||||
public string Id { get; private set; }
|
public string Id { get; private set; }
|
||||||
|
|
||||||
private readonly CemuHookClient _cemuHookClient;
|
private readonly CemuHookClient _cemuHookClient;
|
||||||
|
private readonly IHandheld _handheld;
|
||||||
|
|
||||||
public NpadController(CemuHookClient cemuHookClient)
|
public NpadController(CemuHookClient cemuHookClient, IHandheld handheld)
|
||||||
{
|
{
|
||||||
State = default;
|
State = default;
|
||||||
Id = null;
|
Id = null;
|
||||||
_cemuHookClient = cemuHookClient;
|
_cemuHookClient = cemuHookClient;
|
||||||
|
_handheld = handheld;
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool UpdateDriverConfiguration(IGamepadDriver gamepadDriver, InputConfig config)
|
public bool UpdateDriverConfiguration(IGamepadDriver gamepadDriver, InputConfig config)
|
||||||
|
@ -284,6 +286,18 @@ namespace Ryujinx.Input.HLE
|
||||||
|
|
||||||
if (_config is StandardControllerInputConfig controllerConfig && controllerConfig.Motion.EnableMotion)
|
if (_config is StandardControllerInputConfig controllerConfig && controllerConfig.Motion.EnableMotion)
|
||||||
{
|
{
|
||||||
|
if (controllerConfig.Motion.MotionBackend == MotionInputBackendType.Handheld)
|
||||||
|
{
|
||||||
|
Vector3 accelerometer = _handheld.GetMotionData(MotionInputId.Accelerometer);
|
||||||
|
Vector3 gyroscope = _handheld.GetMotionData(MotionInputId.Gyroscope);
|
||||||
|
|
||||||
|
accelerometer = new Vector3(accelerometer.X, -accelerometer.Z, accelerometer.Y);
|
||||||
|
gyroscope = new Vector3(gyroscope.X, -gyroscope.Z, gyroscope.Y);
|
||||||
|
|
||||||
|
_leftMotionInput.Update(accelerometer, gyroscope, (ulong)PerformanceCounter.ElapsedNanoseconds / 1000, controllerConfig.Motion.Sensitivity, (float)controllerConfig.Motion.GyroDeadzone);
|
||||||
|
_rightMotionInput = _leftMotionInput;
|
||||||
|
}
|
||||||
|
|
||||||
if (controllerConfig.Motion.MotionBackend == MotionInputBackendType.GamepadDriver)
|
if (controllerConfig.Motion.MotionBackend == MotionInputBackendType.GamepadDriver)
|
||||||
{
|
{
|
||||||
if (gamepad.Features.HasFlag(GamepadFeaturesFlag.Motion))
|
if (gamepad.Features.HasFlag(GamepadFeaturesFlag.Motion))
|
||||||
|
|
|
@ -29,6 +29,7 @@ namespace Ryujinx.Input.HLE
|
||||||
private readonly IGamepadDriver _keyboardDriver;
|
private readonly IGamepadDriver _keyboardDriver;
|
||||||
private readonly IGamepadDriver _gamepadDriver;
|
private readonly IGamepadDriver _gamepadDriver;
|
||||||
private readonly IGamepadDriver _mouseDriver;
|
private readonly IGamepadDriver _mouseDriver;
|
||||||
|
private readonly IHandheld _handheld;
|
||||||
private bool _isDisposed;
|
private bool _isDisposed;
|
||||||
|
|
||||||
private List<InputConfig> _inputConfig;
|
private List<InputConfig> _inputConfig;
|
||||||
|
@ -36,7 +37,7 @@ namespace Ryujinx.Input.HLE
|
||||||
private bool _enableMouse;
|
private bool _enableMouse;
|
||||||
private Switch _device;
|
private Switch _device;
|
||||||
|
|
||||||
public NpadManager(IGamepadDriver keyboardDriver, IGamepadDriver gamepadDriver, IGamepadDriver mouseDriver)
|
public NpadManager(IGamepadDriver keyboardDriver, IGamepadDriver gamepadDriver, IGamepadDriver mouseDriver, IHandheld handheld)
|
||||||
{
|
{
|
||||||
_controllers = new NpadController[MaxControllers];
|
_controllers = new NpadController[MaxControllers];
|
||||||
_cemuHookClient = new CemuHookClient(this);
|
_cemuHookClient = new CemuHookClient(this);
|
||||||
|
@ -44,6 +45,7 @@ namespace Ryujinx.Input.HLE
|
||||||
_keyboardDriver = keyboardDriver;
|
_keyboardDriver = keyboardDriver;
|
||||||
_gamepadDriver = gamepadDriver;
|
_gamepadDriver = gamepadDriver;
|
||||||
_mouseDriver = mouseDriver;
|
_mouseDriver = mouseDriver;
|
||||||
|
_handheld = handheld;
|
||||||
_inputConfig = new List<InputConfig>();
|
_inputConfig = new List<InputConfig>();
|
||||||
|
|
||||||
_gamepadDriver.OnGamepadConnected += HandleOnGamepadConnected;
|
_gamepadDriver.OnGamepadConnected += HandleOnGamepadConnected;
|
||||||
|
@ -137,7 +139,7 @@ namespace Ryujinx.Input.HLE
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
controller = new(_cemuHookClient);
|
controller = new(_cemuHookClient, _handheld);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool isValid = DriverConfigurationUpdate(ref controller, inputConfigEntry);
|
bool isValid = DriverConfigurationUpdate(ref controller, inputConfigEntry);
|
||||||
|
|
8
src/Ryujinx.Input/IHandheld.cs
Normal file
8
src/Ryujinx.Input/IHandheld.cs
Normal file
|
@ -0,0 +1,8 @@
|
||||||
|
using System.Numerics;
|
||||||
|
|
||||||
|
namespace Ryujinx.Input;
|
||||||
|
|
||||||
|
public interface IHandheld
|
||||||
|
{
|
||||||
|
Vector3 GetMotionData(MotionInputId gyroscope);
|
||||||
|
}
|
|
@ -264,6 +264,7 @@
|
||||||
"ControllerSettingsTriggerThreshold": "Trigger Threshold:",
|
"ControllerSettingsTriggerThreshold": "Trigger Threshold:",
|
||||||
"ControllerSettingsMotion": "Motion",
|
"ControllerSettingsMotion": "Motion",
|
||||||
"ControllerSettingsMotionUseCemuhookCompatibleMotion": "Use CemuHook compatible motion",
|
"ControllerSettingsMotionUseCemuhookCompatibleMotion": "Use CemuHook compatible motion",
|
||||||
|
"ControllerSettingsMotionUseHandheldCompatibleMotion": "Use Handheld compatible motion",
|
||||||
"ControllerSettingsMotionControllerSlot": "Controller Slot:",
|
"ControllerSettingsMotionControllerSlot": "Controller Slot:",
|
||||||
"ControllerSettingsMotionMirrorInput": "Mirror Input",
|
"ControllerSettingsMotionMirrorInput": "Mirror Input",
|
||||||
"ControllerSettingsMotionRightJoyConSlot": "Right JoyCon Slot:",
|
"ControllerSettingsMotionRightJoyConSlot": "Right JoyCon Slot:",
|
||||||
|
|
|
@ -61,6 +61,7 @@
|
||||||
<ProjectReference Include="..\Ryujinx.Graphics.Vulkan\Ryujinx.Graphics.Vulkan.csproj" />
|
<ProjectReference Include="..\Ryujinx.Graphics.Vulkan\Ryujinx.Graphics.Vulkan.csproj" />
|
||||||
<ProjectReference Include="..\Ryujinx.Input\Ryujinx.Input.csproj" />
|
<ProjectReference Include="..\Ryujinx.Input\Ryujinx.Input.csproj" />
|
||||||
<ProjectReference Include="..\Ryujinx.Input.SDL2\Ryujinx.Input.SDL2.csproj" />
|
<ProjectReference Include="..\Ryujinx.Input.SDL2\Ryujinx.Input.SDL2.csproj" />
|
||||||
|
<ProjectReference Include="..\Ryujinx.Input.SDL3\Ryujinx.Input.SDL3.csproj" />
|
||||||
<ProjectReference Include="..\Ryujinx.Audio.Backends.OpenAL\Ryujinx.Audio.Backends.OpenAL.csproj" />
|
<ProjectReference Include="..\Ryujinx.Audio.Backends.OpenAL\Ryujinx.Audio.Backends.OpenAL.csproj" />
|
||||||
<ProjectReference Include="..\Ryujinx.Audio.Backends.SoundIo\Ryujinx.Audio.Backends.SoundIo.csproj" />
|
<ProjectReference Include="..\Ryujinx.Audio.Backends.SoundIo\Ryujinx.Audio.Backends.SoundIo.csproj" />
|
||||||
<ProjectReference Include="..\Ryujinx.Common\Ryujinx.Common.csproj" />
|
<ProjectReference Include="..\Ryujinx.Common\Ryujinx.Common.csproj" />
|
||||||
|
|
|
@ -9,6 +9,7 @@ namespace Ryujinx.Ava.UI.Models.Input
|
||||||
public class GamepadInputConfig : BaseModel
|
public class GamepadInputConfig : BaseModel
|
||||||
{
|
{
|
||||||
public bool EnableCemuHookMotion { get; set; }
|
public bool EnableCemuHookMotion { get; set; }
|
||||||
|
public bool EnableHandheldMotion { get; set; }
|
||||||
public string DsuServerHost { get; set; }
|
public string DsuServerHost { get; set; }
|
||||||
public int DsuServerPort { get; set; }
|
public int DsuServerPort { get; set; }
|
||||||
public int Slot { get; set; }
|
public int Slot { get; set; }
|
||||||
|
@ -465,7 +466,7 @@ namespace Ryujinx.Ava.UI.Models.Input
|
||||||
EnableMotion = controllerInput.Motion.EnableMotion;
|
EnableMotion = controllerInput.Motion.EnableMotion;
|
||||||
GyroDeadzone = controllerInput.Motion.GyroDeadzone;
|
GyroDeadzone = controllerInput.Motion.GyroDeadzone;
|
||||||
Sensitivity = controllerInput.Motion.Sensitivity;
|
Sensitivity = controllerInput.Motion.Sensitivity;
|
||||||
|
EnableHandheldMotion = controllerInput.Motion.MotionBackend == MotionInputBackendType.Handheld;
|
||||||
if (controllerInput.Motion is CemuHookMotionConfigController cemuHook)
|
if (controllerInput.Motion is CemuHookMotionConfigController cemuHook)
|
||||||
{
|
{
|
||||||
EnableCemuHookMotion = true;
|
EnableCemuHookMotion = true;
|
||||||
|
@ -568,7 +569,7 @@ namespace Ryujinx.Ava.UI.Models.Input
|
||||||
config.Motion = new StandardMotionConfigController
|
config.Motion = new StandardMotionConfigController
|
||||||
{
|
{
|
||||||
EnableMotion = EnableMotion,
|
EnableMotion = EnableMotion,
|
||||||
MotionBackend = MotionInputBackendType.GamepadDriver,
|
MotionBackend = EnableHandheldMotion ? MotionInputBackendType.Handheld : MotionInputBackendType.GamepadDriver,
|
||||||
GyroDeadzone = GyroDeadzone,
|
GyroDeadzone = GyroDeadzone,
|
||||||
Sensitivity = Sensitivity,
|
Sensitivity = Sensitivity,
|
||||||
};
|
};
|
||||||
|
|
|
@ -85,9 +85,28 @@ namespace Ryujinx.Ava.UI.ViewModels.Input
|
||||||
get => _enableCemuHookMotion;
|
get => _enableCemuHookMotion;
|
||||||
set
|
set
|
||||||
{
|
{
|
||||||
|
if (value)
|
||||||
|
{
|
||||||
|
EnableHandheldMotion = false;
|
||||||
|
}
|
||||||
_enableCemuHookMotion = value;
|
_enableCemuHookMotion = value;
|
||||||
OnPropertyChanged();
|
OnPropertyChanged();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private bool _enableHandheldMotion;
|
||||||
|
public bool EnableHandheldMotion
|
||||||
|
{
|
||||||
|
get => _enableHandheldMotion;
|
||||||
|
set
|
||||||
|
{
|
||||||
|
if (value)
|
||||||
|
{
|
||||||
|
EnableCemuHookMotion = false;
|
||||||
|
}
|
||||||
|
_enableHandheldMotion = value;
|
||||||
|
OnPropertyChanged();
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -61,6 +61,17 @@
|
||||||
Margin="5, 0"
|
Margin="5, 0"
|
||||||
Text="{Binding GyroDeadzone, StringFormat=\{0:0.00\}}" />
|
Text="{Binding GyroDeadzone, StringFormat=\{0:0.00\}}" />
|
||||||
</StackPanel>
|
</StackPanel>
|
||||||
|
<Separator
|
||||||
|
Height="1"
|
||||||
|
Margin="0,5" />
|
||||||
|
<CheckBox
|
||||||
|
Margin="5"
|
||||||
|
IsChecked="{Binding EnableHandheldMotion}">
|
||||||
|
<TextBlock
|
||||||
|
Margin="0,3,0,0"
|
||||||
|
VerticalAlignment="Center"
|
||||||
|
Text="{locale:Locale ControllerSettingsMotionUseHandheldCompatibleMotion}" />
|
||||||
|
</CheckBox>
|
||||||
<Separator
|
<Separator
|
||||||
Height="1"
|
Height="1"
|
||||||
Margin="0,5" />
|
Margin="0,5" />
|
||||||
|
|
|
@ -29,6 +29,7 @@ namespace Ryujinx.Ava.UI.Views.Input
|
||||||
Sensitivity = config.Sensitivity,
|
Sensitivity = config.Sensitivity,
|
||||||
GyroDeadzone = config.GyroDeadzone,
|
GyroDeadzone = config.GyroDeadzone,
|
||||||
EnableCemuHookMotion = config.EnableCemuHookMotion,
|
EnableCemuHookMotion = config.EnableCemuHookMotion,
|
||||||
|
EnableHandheldMotion = config.EnableHandheldMotion,
|
||||||
};
|
};
|
||||||
|
|
||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
|
@ -57,6 +58,7 @@ namespace Ryujinx.Ava.UI.Views.Input
|
||||||
config.DsuServerHost = content._viewModel.DsuServerHost;
|
config.DsuServerHost = content._viewModel.DsuServerHost;
|
||||||
config.DsuServerPort = content._viewModel.DsuServerPort;
|
config.DsuServerPort = content._viewModel.DsuServerPort;
|
||||||
config.EnableCemuHookMotion = content._viewModel.EnableCemuHookMotion;
|
config.EnableCemuHookMotion = content._viewModel.EnableCemuHookMotion;
|
||||||
|
config.EnableHandheldMotion = content._viewModel.EnableHandheldMotion;
|
||||||
config.MirrorInput = content._viewModel.MirrorInput;
|
config.MirrorInput = content._viewModel.MirrorInput;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -20,6 +20,7 @@ using Ryujinx.HLE.HOS.Services.Account.Acc;
|
||||||
using Ryujinx.Input.HLE;
|
using Ryujinx.Input.HLE;
|
||||||
using Ryujinx.Input.SDL2;
|
using Ryujinx.Input.SDL2;
|
||||||
using Ryujinx.Modules;
|
using Ryujinx.Modules;
|
||||||
|
using Ryujinx.SDL3;
|
||||||
using Ryujinx.UI.App.Common;
|
using Ryujinx.UI.App.Common;
|
||||||
using Ryujinx.UI.Common;
|
using Ryujinx.UI.Common;
|
||||||
using Ryujinx.UI.Common.Configuration;
|
using Ryujinx.UI.Common.Configuration;
|
||||||
|
@ -89,7 +90,7 @@ namespace Ryujinx.Ava.UI.Windows
|
||||||
|
|
||||||
if (Program.PreviewerDetached)
|
if (Program.PreviewerDetached)
|
||||||
{
|
{
|
||||||
InputManager = new InputManager(new AvaloniaKeyboardDriver(this), new SDL2GamepadDriver());
|
InputManager = new InputManager(new AvaloniaKeyboardDriver(this), new SDL2GamepadDriver(), new SDL3MotionDriver());
|
||||||
|
|
||||||
this.GetObservable(IsActiveProperty).Subscribe(IsActiveChanged);
|
this.GetObservable(IsActiveProperty).Subscribe(IsActiveChanged);
|
||||||
this.ScalingChanged += OnScalingChanged;
|
this.ScalingChanged += OnScalingChanged;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue