Compare commits
11 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 6b55d158b7 | |||
| 91f73a4891 | |||
| 883d4d863a | |||
| ca5de909a1 | |||
| 5172567b08 | |||
| 6fe4cee7c0 | |||
| 8623452abc | |||
| 17e8ae1d9a | |||
| 7591b07fce | |||
| 89b4389ed2 | |||
| d9ee729199 |
@@ -29,7 +29,7 @@ env:
|
|||||||
jobs:
|
jobs:
|
||||||
tag:
|
tag:
|
||||||
name: Create tag
|
name: Create tag
|
||||||
runs-on: ubuntu-20.04
|
runs-on: ubuntu-24.04
|
||||||
steps:
|
steps:
|
||||||
- name: Get version info
|
- name: Get version info
|
||||||
id: version_info
|
id: version_info
|
||||||
@@ -202,7 +202,7 @@ jobs:
|
|||||||
|
|
||||||
macos_release:
|
macos_release:
|
||||||
name: Release MacOS universal
|
name: Release MacOS universal
|
||||||
runs-on: ubuntu-20.04
|
runs-on: ubuntu-24.04
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v4
|
- uses: actions/checkout@v4
|
||||||
|
|
||||||
|
|||||||
@@ -18,7 +18,7 @@ env:
|
|||||||
jobs:
|
jobs:
|
||||||
tag:
|
tag:
|
||||||
name: Create tag
|
name: Create tag
|
||||||
runs-on: ubuntu-20.04
|
runs-on: ubuntu-24.04
|
||||||
steps:
|
steps:
|
||||||
- name: Get version info
|
- name: Get version info
|
||||||
id: version_info
|
id: version_info
|
||||||
@@ -183,7 +183,7 @@ jobs:
|
|||||||
|
|
||||||
macos_release:
|
macos_release:
|
||||||
name: Release MacOS universal
|
name: Release MacOS universal
|
||||||
runs-on: ubuntu-20.04
|
runs-on: ubuntu-24.04
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v4
|
- uses: actions/checkout@v4
|
||||||
|
|
||||||
|
|||||||
@@ -39,12 +39,12 @@
|
|||||||
<p align="center">
|
<p align="center">
|
||||||
Click below to join the Discord:
|
Click below to join the Discord:
|
||||||
<br>
|
<br>
|
||||||
<a href="https://discord.gg/dHPrkBkkyA">
|
<a href="https://discord.gg/PEuzjrFXUA">
|
||||||
<img src="https://img.shields.io/discord/1294443224030511104?color=5865F2&label=Ryubing&logo=discord&logoColor=white" alt="Discord">
|
<img src="https://img.shields.io/discord/1294443224030511104?color=5865F2&label=Ryubing&logo=discord&logoColor=white" alt="Discord">
|
||||||
</a>
|
</a>
|
||||||
<br>
|
<br>
|
||||||
<br>
|
<br>
|
||||||
<img src="https://raw.githubusercontent.com/GreemDev/Ryujinx/refs/heads/master/docs/shell.png">
|
<img src="https://raw.githubusercontent.com/Ryubing/Ryujinx/refs/heads/master/docs/shell.png">
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
## Usage
|
## Usage
|
||||||
|
|||||||
@@ -1249,7 +1249,7 @@
|
|||||||
0100A6B00D4EC000,"Furwind",,playable,2021-02-19 19:44:08
|
0100A6B00D4EC000,"Furwind",,playable,2021-02-19 19:44:08
|
||||||
0100ECE00C0C4000,"Fury Unleashed",crash;services,ingame,2020-10-18 11:52:40
|
0100ECE00C0C4000,"Fury Unleashed",crash;services,ingame,2020-10-18 11:52:40
|
||||||
010070000ED9E000,"Fury Unleashed Demo",,playable,2020-10-08 20:09:21
|
010070000ED9E000,"Fury Unleashed Demo",,playable,2020-10-08 20:09:21
|
||||||
0100E1F013674000,"FUSER™",nvdec;UE4,playable,2022-10-17 20:58:32
|
0100E1F013674000,"FUSER™",nvdec;UE4;slow;gpu,ingame,2025-02-12 16:03:00
|
||||||
0100A7A015E4C000,"Fushigi no Gensokyo Lotus Labyrinth",Needs Update;audio;gpu;nvdec,ingame,2021-01-20 15:30:02
|
0100A7A015E4C000,"Fushigi no Gensokyo Lotus Labyrinth",Needs Update;audio;gpu;nvdec,ingame,2021-01-20 15:30:02
|
||||||
01003C300B274000,"Futari de! Nyanko Daisensou",,playable,2024-01-05 22:26:52
|
01003C300B274000,"Futari de! Nyanko Daisensou",,playable,2024-01-05 22:26:52
|
||||||
010055801134E000,"FUZE Player",online-broken;vulkan-backend-bug,ingame,2022-10-18 12:23:53
|
010055801134E000,"FUZE Player",online-broken;vulkan-backend-bug,ingame,2022-10-18 12:23:53
|
||||||
@@ -2988,8 +2988,8 @@
|
|||||||
010015D003EE4000,"The Jackbox Party Pack 2",online-working,playable,2022-08-22 18:23:40
|
010015D003EE4000,"The Jackbox Party Pack 2",online-working,playable,2022-08-22 18:23:40
|
||||||
0100CC80013D6000,"The Jackbox Party Pack 3",slow;online-working,playable,2022-08-22 18:41:06
|
0100CC80013D6000,"The Jackbox Party Pack 3",slow;online-working,playable,2022-08-22 18:41:06
|
||||||
0100E1F003EE8000,"The Jackbox Party Pack 4",online-working,playable,2022-08-22 18:56:34
|
0100E1F003EE8000,"The Jackbox Party Pack 4",online-working,playable,2022-08-22 18:56:34
|
||||||
01006fe0096ac000,"The Jackbox Party Pack 5",ldn-untested,boots,2025-02-03 22:32:00
|
01006fe0096ac000,"The Jackbox Party Pack 5",slow;online-working,ingame,2025-02-14 05:32:00
|
||||||
01005a400db52000,"The Jackbox Party Pack 6",ldn-untested,boots,2025-02-03 22:32:00
|
01005a400db52000,"The Jackbox Party Pack 6",slow;online-working,ingame,2025-02-14 05:26:00
|
||||||
010052C00B184000,"The Journey Down: Chapter One",nvdec,playable,2021-02-24 13:32:41
|
010052C00B184000,"The Journey Down: Chapter One",nvdec,playable,2021-02-24 13:32:41
|
||||||
01006BC00B188000,"The Journey Down: Chapter Three",nvdec,playable,2021-02-24 13:45:27
|
01006BC00B188000,"The Journey Down: Chapter Three",nvdec,playable,2021-02-24 13:45:27
|
||||||
01009AB00B186000,"The Journey Down: Chapter Two",nvdec,playable,2021-02-24 13:32:13
|
01009AB00B186000,"The Journey Down: Chapter Two",nvdec,playable,2021-02-24 13:32:13
|
||||||
|
|||||||
|
@@ -1,4 +1,3 @@
|
|||||||
using Ryujinx.Common.Logging;
|
|
||||||
using Ryujinx.SDL2.Common;
|
using Ryujinx.SDL2.Common;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
@@ -37,7 +36,6 @@ namespace Ryujinx.Input.SDL2
|
|||||||
SDL2Driver.Instance.Initialize();
|
SDL2Driver.Instance.Initialize();
|
||||||
SDL2Driver.Instance.OnJoyStickConnected += HandleJoyStickConnected;
|
SDL2Driver.Instance.OnJoyStickConnected += HandleJoyStickConnected;
|
||||||
SDL2Driver.Instance.OnJoystickDisconnected += HandleJoyStickDisconnected;
|
SDL2Driver.Instance.OnJoystickDisconnected += HandleJoyStickDisconnected;
|
||||||
SDL2Driver.Instance.OnJoyBatteryUpdated += HandleJoyBatteryUpdated;
|
|
||||||
|
|
||||||
// Add already connected gamepads
|
// Add already connected gamepads
|
||||||
int numJoysticks = SDL_NumJoysticks();
|
int numJoysticks = SDL_NumJoysticks();
|
||||||
@@ -85,30 +83,19 @@ namespace Ryujinx.Input.SDL2
|
|||||||
|
|
||||||
private void HandleJoyStickDisconnected(int joystickInstanceId)
|
private void HandleJoyStickDisconnected(int joystickInstanceId)
|
||||||
{
|
{
|
||||||
bool joyConPairDisconnected = false;
|
|
||||||
if (!_gamepadsInstanceIdsMapping.Remove(joystickInstanceId, out string id))
|
if (!_gamepadsInstanceIdsMapping.Remove(joystickInstanceId, out string id))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
lock (_lock)
|
lock (_lock)
|
||||||
{
|
{
|
||||||
_gamepadsIds.Remove(id);
|
_gamepadsIds.Remove(id);
|
||||||
if (!SDL2JoyConPair.IsCombinable(_gamepadsIds))
|
|
||||||
{
|
|
||||||
_gamepadsIds.Remove(SDL2JoyConPair.Id);
|
|
||||||
joyConPairDisconnected = true;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
OnGamepadDisconnected?.Invoke(id);
|
OnGamepadDisconnected?.Invoke(id);
|
||||||
if (joyConPairDisconnected)
|
|
||||||
{
|
|
||||||
OnGamepadDisconnected?.Invoke(SDL2JoyConPair.Id);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void HandleJoyStickConnected(int joystickDeviceId, int joystickInstanceId)
|
private void HandleJoyStickConnected(int joystickDeviceId, int joystickInstanceId)
|
||||||
{
|
{
|
||||||
bool joyConPairConnected = false;
|
|
||||||
if (SDL_IsGameController(joystickDeviceId) == SDL_bool.SDL_TRUE)
|
if (SDL_IsGameController(joystickDeviceId) == SDL_bool.SDL_TRUE)
|
||||||
{
|
{
|
||||||
if (_gamepadsInstanceIdsMapping.ContainsKey(joystickInstanceId))
|
if (_gamepadsInstanceIdsMapping.ContainsKey(joystickInstanceId))
|
||||||
@@ -133,29 +120,13 @@ namespace Ryujinx.Input.SDL2
|
|||||||
_gamepadsIds.Insert(joystickDeviceId, id);
|
_gamepadsIds.Insert(joystickDeviceId, id);
|
||||||
else
|
else
|
||||||
_gamepadsIds.Add(id);
|
_gamepadsIds.Add(id);
|
||||||
if (SDL2JoyConPair.IsCombinable(_gamepadsIds))
|
|
||||||
{
|
|
||||||
_gamepadsIds.Remove(SDL2JoyConPair.Id);
|
|
||||||
_gamepadsIds.Add(SDL2JoyConPair.Id);
|
|
||||||
joyConPairConnected = true;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
OnGamepadConnected?.Invoke(id);
|
OnGamepadConnected?.Invoke(id);
|
||||||
if (joyConPairConnected)
|
|
||||||
{
|
|
||||||
OnGamepadConnected?.Invoke(SDL2JoyConPair.Id);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void HandleJoyBatteryUpdated(int joystickDeviceId, SDL_JoystickPowerLevel powerLevel)
|
|
||||||
{
|
|
||||||
Logger.Info?.Print(LogClass.Hid,
|
|
||||||
$"{SDL_GameControllerNameForIndex(joystickDeviceId)} power level: {powerLevel}");
|
|
||||||
}
|
|
||||||
|
|
||||||
protected virtual void Dispose(bool disposing)
|
protected virtual void Dispose(bool disposing)
|
||||||
{
|
{
|
||||||
if (disposing)
|
if (disposing)
|
||||||
@@ -186,14 +157,6 @@ namespace Ryujinx.Input.SDL2
|
|||||||
|
|
||||||
public IGamepad GetGamepad(string id)
|
public IGamepad GetGamepad(string id)
|
||||||
{
|
{
|
||||||
if (id == SDL2JoyConPair.Id)
|
|
||||||
{
|
|
||||||
lock (_lock)
|
|
||||||
{
|
|
||||||
return SDL2JoyConPair.GetGamepad(_gamepadsIds);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
int joystickIndex = GetJoystickIndexByGamepadId(id);
|
int joystickIndex = GetJoystickIndexByGamepadId(id);
|
||||||
|
|
||||||
if (joystickIndex == -1)
|
if (joystickIndex == -1)
|
||||||
@@ -202,16 +165,12 @@ namespace Ryujinx.Input.SDL2
|
|||||||
}
|
}
|
||||||
|
|
||||||
nint gamepadHandle = SDL_GameControllerOpen(joystickIndex);
|
nint gamepadHandle = SDL_GameControllerOpen(joystickIndex);
|
||||||
|
|
||||||
if (gamepadHandle == nint.Zero)
|
if (gamepadHandle == nint.Zero)
|
||||||
{
|
{
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (SDL_GameControllerName(gamepadHandle).StartsWith(SDL2JoyCon.Prefix))
|
|
||||||
{
|
|
||||||
return new SDL2JoyCon(gamepadHandle, id);
|
|
||||||
}
|
|
||||||
|
|
||||||
return new SDL2Gamepad(gamepadHandle, id);
|
return new SDL2Gamepad(gamepadHandle, id);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,409 +0,0 @@
|
|||||||
using Ryujinx.Common.Configuration.Hid;
|
|
||||||
using Ryujinx.Common.Configuration.Hid.Controller;
|
|
||||||
using Ryujinx.Common.Logging;
|
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Numerics;
|
|
||||||
using System.Threading;
|
|
||||||
using static SDL2.SDL;
|
|
||||||
|
|
||||||
namespace Ryujinx.Input.SDL2
|
|
||||||
{
|
|
||||||
internal class SDL2JoyCon : IGamepad
|
|
||||||
{
|
|
||||||
private bool HasConfiguration => _configuration != null;
|
|
||||||
|
|
||||||
private readonly record struct ButtonMappingEntry(GamepadButtonInputId To, GamepadButtonInputId From)
|
|
||||||
{
|
|
||||||
public bool IsValid => To is not GamepadButtonInputId.Unbound && From is not GamepadButtonInputId.Unbound;
|
|
||||||
}
|
|
||||||
|
|
||||||
private StandardControllerInputConfig _configuration;
|
|
||||||
|
|
||||||
private readonly Dictionary<GamepadButtonInputId,SDL_GameControllerButton> _leftButtonsDriverMapping = new()
|
|
||||||
{
|
|
||||||
{ GamepadButtonInputId.LeftStick , SDL_GameControllerButton.SDL_CONTROLLER_BUTTON_LEFTSTICK },
|
|
||||||
{GamepadButtonInputId.DpadUp ,SDL_GameControllerButton.SDL_CONTROLLER_BUTTON_Y},
|
|
||||||
{GamepadButtonInputId.DpadDown ,SDL_GameControllerButton.SDL_CONTROLLER_BUTTON_A},
|
|
||||||
{GamepadButtonInputId.DpadLeft ,SDL_GameControllerButton.SDL_CONTROLLER_BUTTON_B},
|
|
||||||
{GamepadButtonInputId.DpadRight ,SDL_GameControllerButton.SDL_CONTROLLER_BUTTON_X},
|
|
||||||
{GamepadButtonInputId.Minus ,SDL_GameControllerButton.SDL_CONTROLLER_BUTTON_START},
|
|
||||||
{GamepadButtonInputId.LeftShoulder,SDL_GameControllerButton.SDL_CONTROLLER_BUTTON_PADDLE2},
|
|
||||||
{GamepadButtonInputId.LeftTrigger,SDL_GameControllerButton.SDL_CONTROLLER_BUTTON_PADDLE4},
|
|
||||||
{GamepadButtonInputId.SingleRightTrigger0,SDL_GameControllerButton.SDL_CONTROLLER_BUTTON_RIGHTSHOULDER},
|
|
||||||
{GamepadButtonInputId.SingleLeftTrigger0,SDL_GameControllerButton.SDL_CONTROLLER_BUTTON_LEFTSHOULDER},
|
|
||||||
};
|
|
||||||
private readonly Dictionary<GamepadButtonInputId,SDL_GameControllerButton> _rightButtonsDriverMapping = new()
|
|
||||||
{
|
|
||||||
{GamepadButtonInputId.RightStick,SDL_GameControllerButton.SDL_CONTROLLER_BUTTON_LEFTSTICK},
|
|
||||||
{GamepadButtonInputId.A,SDL_GameControllerButton.SDL_CONTROLLER_BUTTON_B},
|
|
||||||
{GamepadButtonInputId.B,SDL_GameControllerButton.SDL_CONTROLLER_BUTTON_Y},
|
|
||||||
{GamepadButtonInputId.X,SDL_GameControllerButton.SDL_CONTROLLER_BUTTON_A},
|
|
||||||
{GamepadButtonInputId.Y,SDL_GameControllerButton.SDL_CONTROLLER_BUTTON_X},
|
|
||||||
{GamepadButtonInputId.Plus,SDL_GameControllerButton.SDL_CONTROLLER_BUTTON_START},
|
|
||||||
{GamepadButtonInputId.RightShoulder,SDL_GameControllerButton.SDL_CONTROLLER_BUTTON_PADDLE1},
|
|
||||||
{GamepadButtonInputId.RightTrigger,SDL_GameControllerButton.SDL_CONTROLLER_BUTTON_PADDLE3},
|
|
||||||
{GamepadButtonInputId.SingleRightTrigger1,SDL_GameControllerButton.SDL_CONTROLLER_BUTTON_RIGHTSHOULDER},
|
|
||||||
{GamepadButtonInputId.SingleLeftTrigger1,SDL_GameControllerButton.SDL_CONTROLLER_BUTTON_LEFTSHOULDER}
|
|
||||||
};
|
|
||||||
|
|
||||||
private readonly Dictionary<GamepadButtonInputId, SDL_GameControllerButton> _buttonsDriverMapping;
|
|
||||||
private readonly Lock _userMappingLock = new();
|
|
||||||
|
|
||||||
private readonly List<ButtonMappingEntry> _buttonsUserMapping;
|
|
||||||
|
|
||||||
private readonly StickInputId[] _stickUserMapping = new StickInputId[(int)StickInputId.Count]
|
|
||||||
{
|
|
||||||
StickInputId.Unbound, StickInputId.Left, StickInputId.Right,
|
|
||||||
};
|
|
||||||
|
|
||||||
public GamepadFeaturesFlag Features { get; }
|
|
||||||
|
|
||||||
private nint _gamepadHandle;
|
|
||||||
|
|
||||||
private enum JoyConType
|
|
||||||
{
|
|
||||||
Left, Right
|
|
||||||
}
|
|
||||||
|
|
||||||
public const string Prefix = "Nintendo Switch Joy-Con";
|
|
||||||
public const string LeftName = "Nintendo Switch Joy-Con (L)";
|
|
||||||
public const string RightName = "Nintendo Switch Joy-Con (R)";
|
|
||||||
|
|
||||||
private readonly JoyConType _joyConType;
|
|
||||||
|
|
||||||
public SDL2JoyCon(nint gamepadHandle, string driverId)
|
|
||||||
{
|
|
||||||
_gamepadHandle = gamepadHandle;
|
|
||||||
_buttonsUserMapping = new List<ButtonMappingEntry>(10);
|
|
||||||
|
|
||||||
Name = SDL_GameControllerName(_gamepadHandle);
|
|
||||||
Id = driverId;
|
|
||||||
Features = GetFeaturesFlag();
|
|
||||||
|
|
||||||
// Enable motion tracking
|
|
||||||
if (Features.HasFlag(GamepadFeaturesFlag.Motion))
|
|
||||||
{
|
|
||||||
if (SDL_GameControllerSetSensorEnabled(_gamepadHandle, SDL_SensorType.SDL_SENSOR_ACCEL,
|
|
||||||
SDL_bool.SDL_TRUE) != 0)
|
|
||||||
{
|
|
||||||
Logger.Error?.Print(LogClass.Hid,
|
|
||||||
$"Could not enable data reporting for SensorType {SDL_SensorType.SDL_SENSOR_ACCEL}.");
|
|
||||||
}
|
|
||||||
|
|
||||||
if (SDL_GameControllerSetSensorEnabled(_gamepadHandle, SDL_SensorType.SDL_SENSOR_GYRO,
|
|
||||||
SDL_bool.SDL_TRUE) != 0)
|
|
||||||
{
|
|
||||||
Logger.Error?.Print(LogClass.Hid,
|
|
||||||
$"Could not enable data reporting for SensorType {SDL_SensorType.SDL_SENSOR_GYRO}.");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
switch (Name)
|
|
||||||
{
|
|
||||||
case LeftName:
|
|
||||||
{
|
|
||||||
_buttonsDriverMapping = _leftButtonsDriverMapping;
|
|
||||||
_joyConType = JoyConType.Left;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case RightName:
|
|
||||||
{
|
|
||||||
_buttonsDriverMapping = _rightButtonsDriverMapping;
|
|
||||||
_joyConType = JoyConType.Right;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private GamepadFeaturesFlag GetFeaturesFlag()
|
|
||||||
{
|
|
||||||
GamepadFeaturesFlag result = GamepadFeaturesFlag.None;
|
|
||||||
|
|
||||||
if (SDL_GameControllerHasSensor(_gamepadHandle, SDL_SensorType.SDL_SENSOR_ACCEL) == SDL_bool.SDL_TRUE &&
|
|
||||||
SDL_GameControllerHasSensor(_gamepadHandle, SDL_SensorType.SDL_SENSOR_GYRO) == SDL_bool.SDL_TRUE)
|
|
||||||
{
|
|
||||||
result |= GamepadFeaturesFlag.Motion;
|
|
||||||
}
|
|
||||||
|
|
||||||
int error = SDL_GameControllerRumble(_gamepadHandle, 0, 0, 100);
|
|
||||||
|
|
||||||
if (error == 0)
|
|
||||||
{
|
|
||||||
result |= GamepadFeaturesFlag.Rumble;
|
|
||||||
}
|
|
||||||
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
public string Id { get; }
|
|
||||||
public string Name { get; }
|
|
||||||
public bool IsConnected => SDL_GameControllerGetAttached(_gamepadHandle) == SDL_bool.SDL_TRUE;
|
|
||||||
|
|
||||||
protected virtual void Dispose(bool disposing)
|
|
||||||
{
|
|
||||||
if (disposing && _gamepadHandle != nint.Zero)
|
|
||||||
{
|
|
||||||
SDL_GameControllerClose(_gamepadHandle);
|
|
||||||
|
|
||||||
_gamepadHandle = nint.Zero;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public void Dispose()
|
|
||||||
{
|
|
||||||
Dispose(true);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
public void SetTriggerThreshold(float triggerThreshold)
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
public void Rumble(float lowFrequency, float highFrequency, uint durationMs)
|
|
||||||
{
|
|
||||||
if (!Features.HasFlag(GamepadFeaturesFlag.Rumble))
|
|
||||||
return;
|
|
||||||
|
|
||||||
ushort lowFrequencyRaw = (ushort)(lowFrequency * ushort.MaxValue);
|
|
||||||
ushort highFrequencyRaw = (ushort)(highFrequency * ushort.MaxValue);
|
|
||||||
|
|
||||||
if (durationMs == uint.MaxValue)
|
|
||||||
{
|
|
||||||
if (SDL_GameControllerRumble(_gamepadHandle, lowFrequencyRaw, highFrequencyRaw, SDL_HAPTIC_INFINITY) !=
|
|
||||||
0)
|
|
||||||
Logger.Error?.Print(LogClass.Hid, "Rumble is not supported on this game controller.");
|
|
||||||
}
|
|
||||||
else if (durationMs > SDL_HAPTIC_INFINITY)
|
|
||||||
{
|
|
||||||
Logger.Error?.Print(LogClass.Hid, $"Unsupported rumble duration {durationMs}");
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
if (SDL_GameControllerRumble(_gamepadHandle, lowFrequencyRaw, highFrequencyRaw, durationMs) != 0)
|
|
||||||
Logger.Error?.Print(LogClass.Hid, "Rumble is not supported on this game controller.");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public Vector3 GetMotionData(MotionInputId inputId)
|
|
||||||
{
|
|
||||||
SDL_SensorType sensorType = inputId switch
|
|
||||||
{
|
|
||||||
MotionInputId.Accelerometer => SDL_SensorType.SDL_SENSOR_ACCEL,
|
|
||||||
MotionInputId.Gyroscope => SDL_SensorType.SDL_SENSOR_GYRO,
|
|
||||||
_ => SDL_SensorType.SDL_SENSOR_INVALID
|
|
||||||
};
|
|
||||||
|
|
||||||
if (!Features.HasFlag(GamepadFeaturesFlag.Motion) || sensorType is SDL_SensorType.SDL_SENSOR_INVALID)
|
|
||||||
return Vector3.Zero;
|
|
||||||
|
|
||||||
const int ElementCount = 3;
|
|
||||||
|
|
||||||
unsafe
|
|
||||||
{
|
|
||||||
float* values = stackalloc float[ElementCount];
|
|
||||||
|
|
||||||
int result = SDL_GameControllerGetSensorData(_gamepadHandle, sensorType, (nint)values, ElementCount);
|
|
||||||
|
|
||||||
if (result != 0)
|
|
||||||
return Vector3.Zero;
|
|
||||||
|
|
||||||
Vector3 value = _joyConType switch
|
|
||||||
{
|
|
||||||
JoyConType.Left => new Vector3(-values[2], values[1], values[0]),
|
|
||||||
JoyConType.Right => new Vector3(values[2], values[1], -values[0])
|
|
||||||
};
|
|
||||||
|
|
||||||
return inputId switch
|
|
||||||
{
|
|
||||||
MotionInputId.Gyroscope => RadToDegree(value),
|
|
||||||
MotionInputId.Accelerometer => GsToMs2(value),
|
|
||||||
_ => value
|
|
||||||
};
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private static Vector3 RadToDegree(Vector3 rad) => rad * (180 / MathF.PI);
|
|
||||||
|
|
||||||
private static Vector3 GsToMs2(Vector3 gs) => gs / SDL_STANDARD_GRAVITY;
|
|
||||||
|
|
||||||
public void SetConfiguration(InputConfig configuration)
|
|
||||||
{
|
|
||||||
lock (_userMappingLock)
|
|
||||||
{
|
|
||||||
_configuration = (StandardControllerInputConfig)configuration;
|
|
||||||
|
|
||||||
_buttonsUserMapping.Clear();
|
|
||||||
|
|
||||||
// First update sticks
|
|
||||||
_stickUserMapping[(int)StickInputId.Left] = (StickInputId)_configuration.LeftJoyconStick.Joystick;
|
|
||||||
_stickUserMapping[(int)StickInputId.Right] = (StickInputId)_configuration.RightJoyconStick.Joystick;
|
|
||||||
|
|
||||||
|
|
||||||
switch (_joyConType)
|
|
||||||
{
|
|
||||||
case JoyConType.Left:
|
|
||||||
_buttonsUserMapping.Add(new ButtonMappingEntry(GamepadButtonInputId.LeftStick, (GamepadButtonInputId)_configuration.LeftJoyconStick.StickButton));
|
|
||||||
_buttonsUserMapping.Add(new ButtonMappingEntry(GamepadButtonInputId.DpadUp, (GamepadButtonInputId)_configuration.LeftJoycon.DpadUp));
|
|
||||||
_buttonsUserMapping.Add(new ButtonMappingEntry(GamepadButtonInputId.DpadDown, (GamepadButtonInputId)_configuration.LeftJoycon.DpadDown));
|
|
||||||
_buttonsUserMapping.Add(new ButtonMappingEntry(GamepadButtonInputId.DpadLeft, (GamepadButtonInputId)_configuration.LeftJoycon.DpadLeft));
|
|
||||||
_buttonsUserMapping.Add(new ButtonMappingEntry(GamepadButtonInputId.DpadRight, (GamepadButtonInputId)_configuration.LeftJoycon.DpadRight));
|
|
||||||
_buttonsUserMapping.Add(new ButtonMappingEntry(GamepadButtonInputId.Minus, (GamepadButtonInputId)_configuration.LeftJoycon.ButtonMinus));
|
|
||||||
_buttonsUserMapping.Add(new ButtonMappingEntry(GamepadButtonInputId.LeftShoulder, (GamepadButtonInputId)_configuration.LeftJoycon.ButtonL));
|
|
||||||
_buttonsUserMapping.Add(new ButtonMappingEntry(GamepadButtonInputId.LeftTrigger, (GamepadButtonInputId)_configuration.LeftJoycon.ButtonZl));
|
|
||||||
_buttonsUserMapping.Add(new ButtonMappingEntry(GamepadButtonInputId.SingleRightTrigger0, (GamepadButtonInputId)_configuration.LeftJoycon.ButtonSr));
|
|
||||||
_buttonsUserMapping.Add(new ButtonMappingEntry(GamepadButtonInputId.SingleLeftTrigger0, (GamepadButtonInputId)_configuration.LeftJoycon.ButtonSl));
|
|
||||||
break;
|
|
||||||
case JoyConType.Right:
|
|
||||||
_buttonsUserMapping.Add(new ButtonMappingEntry(GamepadButtonInputId.RightStick, (GamepadButtonInputId)_configuration.RightJoyconStick.StickButton));
|
|
||||||
_buttonsUserMapping.Add(new ButtonMappingEntry(GamepadButtonInputId.A, (GamepadButtonInputId)_configuration.RightJoycon.ButtonA));
|
|
||||||
_buttonsUserMapping.Add(new ButtonMappingEntry(GamepadButtonInputId.B, (GamepadButtonInputId)_configuration.RightJoycon.ButtonB));
|
|
||||||
_buttonsUserMapping.Add(new ButtonMappingEntry(GamepadButtonInputId.X, (GamepadButtonInputId)_configuration.RightJoycon.ButtonX));
|
|
||||||
_buttonsUserMapping.Add(new ButtonMappingEntry(GamepadButtonInputId.Y, (GamepadButtonInputId)_configuration.RightJoycon.ButtonY));
|
|
||||||
_buttonsUserMapping.Add(new ButtonMappingEntry(GamepadButtonInputId.Plus, (GamepadButtonInputId)_configuration.RightJoycon.ButtonPlus));
|
|
||||||
_buttonsUserMapping.Add(new ButtonMappingEntry(GamepadButtonInputId.RightShoulder, (GamepadButtonInputId)_configuration.RightJoycon.ButtonR));
|
|
||||||
_buttonsUserMapping.Add(new ButtonMappingEntry(GamepadButtonInputId.RightTrigger, (GamepadButtonInputId)_configuration.RightJoycon.ButtonZr));
|
|
||||||
_buttonsUserMapping.Add(new ButtonMappingEntry(GamepadButtonInputId.SingleRightTrigger1, (GamepadButtonInputId)_configuration.RightJoycon.ButtonSr));
|
|
||||||
_buttonsUserMapping.Add(new ButtonMappingEntry(GamepadButtonInputId.SingleLeftTrigger1, (GamepadButtonInputId)_configuration.RightJoycon.ButtonSl));
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
throw new ArgumentOutOfRangeException();
|
|
||||||
}
|
|
||||||
|
|
||||||
SetTriggerThreshold(_configuration.TriggerThreshold);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public GamepadStateSnapshot GetStateSnapshot()
|
|
||||||
{
|
|
||||||
return IGamepad.GetStateSnapshot(this);
|
|
||||||
}
|
|
||||||
|
|
||||||
public GamepadStateSnapshot GetMappedStateSnapshot()
|
|
||||||
{
|
|
||||||
GamepadStateSnapshot rawState = GetStateSnapshot();
|
|
||||||
GamepadStateSnapshot result = default;
|
|
||||||
|
|
||||||
lock (_userMappingLock)
|
|
||||||
{
|
|
||||||
if (_buttonsUserMapping.Count == 0)
|
|
||||||
return rawState;
|
|
||||||
|
|
||||||
|
|
||||||
// ReSharper disable once ForeachCanBePartlyConvertedToQueryUsingAnotherGetEnumerator
|
|
||||||
foreach (ButtonMappingEntry entry in _buttonsUserMapping)
|
|
||||||
{
|
|
||||||
if (!entry.IsValid)
|
|
||||||
continue;
|
|
||||||
|
|
||||||
// Do not touch state of button already pressed
|
|
||||||
if (!result.IsPressed(entry.To))
|
|
||||||
{
|
|
||||||
result.SetPressed(entry.To, rawState.IsPressed(entry.From));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
(float leftStickX, float leftStickY) = rawState.GetStick(_stickUserMapping[(int)StickInputId.Left]);
|
|
||||||
(float rightStickX, float rightStickY) = rawState.GetStick(_stickUserMapping[(int)StickInputId.Right]);
|
|
||||||
|
|
||||||
result.SetStick(StickInputId.Left, leftStickX, leftStickY);
|
|
||||||
result.SetStick(StickInputId.Right, rightStickX, rightStickY);
|
|
||||||
}
|
|
||||||
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
private static float ConvertRawStickValue(short value)
|
|
||||||
{
|
|
||||||
const float ConvertRate = 1.0f / (short.MaxValue + 0.5f);
|
|
||||||
|
|
||||||
return value * ConvertRate;
|
|
||||||
}
|
|
||||||
|
|
||||||
private JoyconConfigControllerStick<GamepadInputId, Common.Configuration.Hid.Controller.StickInputId>
|
|
||||||
GetLogicalJoyStickConfig(StickInputId inputId)
|
|
||||||
{
|
|
||||||
switch (inputId)
|
|
||||||
{
|
|
||||||
case StickInputId.Left:
|
|
||||||
if (_configuration.RightJoyconStick.Joystick ==
|
|
||||||
Common.Configuration.Hid.Controller.StickInputId.Left)
|
|
||||||
return _configuration.RightJoyconStick;
|
|
||||||
else
|
|
||||||
return _configuration.LeftJoyconStick;
|
|
||||||
case StickInputId.Right:
|
|
||||||
if (_configuration.LeftJoyconStick.Joystick ==
|
|
||||||
Common.Configuration.Hid.Controller.StickInputId.Right)
|
|
||||||
return _configuration.LeftJoyconStick;
|
|
||||||
else
|
|
||||||
return _configuration.RightJoyconStick;
|
|
||||||
}
|
|
||||||
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
public (float, float) GetStick(StickInputId inputId)
|
|
||||||
{
|
|
||||||
if (inputId == StickInputId.Unbound)
|
|
||||||
return (0.0f, 0.0f);
|
|
||||||
|
|
||||||
if (inputId == StickInputId.Left && _joyConType == JoyConType.Right || inputId == StickInputId.Right && _joyConType == JoyConType.Left)
|
|
||||||
{
|
|
||||||
return (0.0f, 0.0f);
|
|
||||||
}
|
|
||||||
|
|
||||||
(short stickX, short stickY) = GetStickXY();
|
|
||||||
|
|
||||||
float resultX = ConvertRawStickValue(stickX);
|
|
||||||
float resultY = -ConvertRawStickValue(stickY);
|
|
||||||
|
|
||||||
if (HasConfiguration)
|
|
||||||
{
|
|
||||||
var joyconStickConfig = GetLogicalJoyStickConfig(inputId);
|
|
||||||
|
|
||||||
if (joyconStickConfig != null)
|
|
||||||
{
|
|
||||||
if (joyconStickConfig.InvertStickX)
|
|
||||||
resultX = -resultX;
|
|
||||||
|
|
||||||
if (joyconStickConfig.InvertStickY)
|
|
||||||
resultY = -resultY;
|
|
||||||
|
|
||||||
if (joyconStickConfig.Rotate90CW)
|
|
||||||
{
|
|
||||||
float temp = resultX;
|
|
||||||
resultX = resultY;
|
|
||||||
resultY = -temp;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return inputId switch
|
|
||||||
{
|
|
||||||
StickInputId.Left when _joyConType == JoyConType.Left => (resultY, -resultX),
|
|
||||||
StickInputId.Right when _joyConType == JoyConType.Right => (-resultY, resultX),
|
|
||||||
_ => (0.0f, 0.0f)
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
private (short, short) GetStickXY()
|
|
||||||
{
|
|
||||||
return (
|
|
||||||
SDL_GameControllerGetAxis(_gamepadHandle, SDL_GameControllerAxis.SDL_CONTROLLER_AXIS_LEFTX),
|
|
||||||
SDL_GameControllerGetAxis(_gamepadHandle, SDL_GameControllerAxis.SDL_CONTROLLER_AXIS_LEFTY));
|
|
||||||
}
|
|
||||||
|
|
||||||
public bool IsPressed(GamepadButtonInputId inputId)
|
|
||||||
{
|
|
||||||
if (!_buttonsDriverMapping.TryGetValue(inputId, out var button))
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
return SDL_GameControllerGetButton(_gamepadHandle, button) == 1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,142 +0,0 @@
|
|||||||
using Ryujinx.Common.Configuration.Hid;
|
|
||||||
using Ryujinx.Common.Configuration.Hid.Controller;
|
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Numerics;
|
|
||||||
using static SDL2.SDL;
|
|
||||||
|
|
||||||
namespace Ryujinx.Input.SDL2
|
|
||||||
{
|
|
||||||
internal class SDL2JoyConPair(IGamepad left, IGamepad right) : IGamepad
|
|
||||||
{
|
|
||||||
private StandardControllerInputConfig _configuration;
|
|
||||||
|
|
||||||
private readonly StickInputId[] _stickUserMapping =
|
|
||||||
[
|
|
||||||
StickInputId.Unbound,
|
|
||||||
StickInputId.Left,
|
|
||||||
StickInputId.Right
|
|
||||||
];
|
|
||||||
|
|
||||||
public GamepadFeaturesFlag Features => (left?.Features ?? GamepadFeaturesFlag.None) |
|
|
||||||
(right?.Features ?? GamepadFeaturesFlag.None);
|
|
||||||
|
|
||||||
public const string Id = "JoyConPair";
|
|
||||||
string IGamepad.Id => Id;
|
|
||||||
|
|
||||||
public string Name => "* Nintendo Switch Joy-Con (L/R)";
|
|
||||||
public bool IsConnected => left is { IsConnected: true } && right is { IsConnected: true };
|
|
||||||
|
|
||||||
public void Dispose()
|
|
||||||
{
|
|
||||||
left?.Dispose();
|
|
||||||
right?.Dispose();
|
|
||||||
}
|
|
||||||
|
|
||||||
public GamepadStateSnapshot GetMappedStateSnapshot()
|
|
||||||
{
|
|
||||||
return GetStateSnapshot();
|
|
||||||
}
|
|
||||||
|
|
||||||
public Vector3 GetMotionData(MotionInputId inputId)
|
|
||||||
{
|
|
||||||
return inputId switch
|
|
||||||
{
|
|
||||||
MotionInputId.Accelerometer or
|
|
||||||
MotionInputId.Gyroscope => left.GetMotionData(inputId),
|
|
||||||
MotionInputId.SecondAccelerometer => right.GetMotionData(MotionInputId.Accelerometer),
|
|
||||||
MotionInputId.SecondGyroscope => right.GetMotionData(MotionInputId.Gyroscope),
|
|
||||||
_ => Vector3.Zero
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
public GamepadStateSnapshot GetStateSnapshot()
|
|
||||||
{
|
|
||||||
return IGamepad.GetStateSnapshot(this);
|
|
||||||
}
|
|
||||||
|
|
||||||
public (float, float) GetStick(StickInputId inputId)
|
|
||||||
{
|
|
||||||
return inputId switch
|
|
||||||
{
|
|
||||||
StickInputId.Left => left.GetStick(StickInputId.Left),
|
|
||||||
StickInputId.Right => right.GetStick(StickInputId.Right),
|
|
||||||
_ => (0, 0)
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
public bool IsPressed(GamepadButtonInputId inputId)
|
|
||||||
{
|
|
||||||
return left.IsPressed(inputId) || right.IsPressed(inputId);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void Rumble(float lowFrequency, float highFrequency, uint durationMs)
|
|
||||||
{
|
|
||||||
if (lowFrequency != 0)
|
|
||||||
{
|
|
||||||
right.Rumble(lowFrequency, lowFrequency, durationMs);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (highFrequency != 0)
|
|
||||||
{
|
|
||||||
left.Rumble(highFrequency, highFrequency, durationMs);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (lowFrequency == 0 && highFrequency == 0)
|
|
||||||
{
|
|
||||||
left.Rumble(0, 0, durationMs);
|
|
||||||
right.Rumble(0, 0, durationMs);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public void SetConfiguration(InputConfig configuration)
|
|
||||||
{
|
|
||||||
left.SetConfiguration(configuration);
|
|
||||||
right.SetConfiguration(configuration);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void SetTriggerThreshold(float triggerThreshold)
|
|
||||||
{
|
|
||||||
left.SetTriggerThreshold(triggerThreshold);
|
|
||||||
right.SetTriggerThreshold(triggerThreshold);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static bool IsCombinable(List<string> gamepadsIds)
|
|
||||||
{
|
|
||||||
(int leftIndex, int rightIndex) = DetectJoyConPair(gamepadsIds);
|
|
||||||
return leftIndex >= 0 && rightIndex >= 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
private static (int leftIndex, int rightIndex) DetectJoyConPair(List<string> gamepadsIds)
|
|
||||||
{
|
|
||||||
var gamepadNames = gamepadsIds.Where(gamepadId => gamepadId != Id)
|
|
||||||
.Select((_, index) => SDL_GameControllerNameForIndex(index)).ToList();
|
|
||||||
int leftIndex = gamepadNames.IndexOf(SDL2JoyCon.LeftName);
|
|
||||||
int rightIndex = gamepadNames.IndexOf(SDL2JoyCon.RightName);
|
|
||||||
|
|
||||||
return (leftIndex, rightIndex);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static IGamepad GetGamepad(List<string> gamepadsIds)
|
|
||||||
{
|
|
||||||
(int leftIndex, int rightIndex) = DetectJoyConPair(gamepadsIds);
|
|
||||||
if (leftIndex == -1 || rightIndex == -1)
|
|
||||||
{
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
nint leftGamepadHandle = SDL_GameControllerOpen(leftIndex);
|
|
||||||
nint rightGamepadHandle = SDL_GameControllerOpen(rightIndex);
|
|
||||||
|
|
||||||
if (leftGamepadHandle == nint.Zero || rightGamepadHandle == nint.Zero)
|
|
||||||
{
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
return new SDL2JoyConPair(new SDL2JoyCon(leftGamepadHandle, gamepadsIds[leftIndex]),
|
|
||||||
new SDL2JoyCon(rightGamepadHandle, gamepadsIds[rightIndex]));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -269,7 +269,6 @@ namespace Ryujinx.Input.HLE
|
|||||||
if (motionConfig.MotionBackend != MotionInputBackendType.CemuHook)
|
if (motionConfig.MotionBackend != MotionInputBackendType.CemuHook)
|
||||||
{
|
{
|
||||||
_leftMotionInput = new MotionInput();
|
_leftMotionInput = new MotionInput();
|
||||||
_rightMotionInput = new MotionInput();
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -302,20 +301,7 @@ namespace Ryujinx.Input.HLE
|
|||||||
|
|
||||||
if (controllerConfig.ControllerType == ConfigControllerType.JoyconPair)
|
if (controllerConfig.ControllerType == ConfigControllerType.JoyconPair)
|
||||||
{
|
{
|
||||||
if (gamepad.Id== "JoyConPair")
|
_rightMotionInput = _leftMotionInput;
|
||||||
{
|
|
||||||
Vector3 rightAccelerometer = gamepad.GetMotionData(MotionInputId.SecondAccelerometer);
|
|
||||||
Vector3 rightGyroscope = gamepad.GetMotionData(MotionInputId.SecondGyroscope);
|
|
||||||
|
|
||||||
rightAccelerometer = new Vector3(rightAccelerometer.X, -rightAccelerometer.Z, rightAccelerometer.Y);
|
|
||||||
rightGyroscope = new Vector3(rightGyroscope.X, -rightGyroscope.Z, rightGyroscope.Y);
|
|
||||||
|
|
||||||
_rightMotionInput.Update(rightAccelerometer, rightGyroscope, (ulong)PerformanceCounter.ElapsedNanoseconds / 1000, controllerConfig.Motion.Sensitivity, (float)controllerConfig.Motion.GyroDeadzone);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
_rightMotionInput = _leftMotionInput;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -350,7 +336,6 @@ namespace Ryujinx.Input.HLE
|
|||||||
// Reset states
|
// Reset states
|
||||||
State = default;
|
State = default;
|
||||||
_leftMotionInput = null;
|
_leftMotionInput = null;
|
||||||
_rightMotionInput = null;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -21,17 +21,5 @@ namespace Ryujinx.Input
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
/// <remarks>Values are in degrees</remarks>
|
/// <remarks>Values are in degrees</remarks>
|
||||||
Gyroscope,
|
Gyroscope,
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Second accelerometer.
|
|
||||||
/// </summary>
|
|
||||||
/// <remarks>Values are in m/s^2</remarks>
|
|
||||||
SecondAccelerometer,
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Second gyroscope.
|
|
||||||
/// </summary>
|
|
||||||
/// <remarks>Values are in degrees</remarks>
|
|
||||||
SecondGyroscope
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -25,17 +25,14 @@ namespace Ryujinx.SDL2.Common
|
|||||||
|
|
||||||
public static Action<Action> MainThreadDispatcher { get; set; }
|
public static Action<Action> MainThreadDispatcher { get; set; }
|
||||||
|
|
||||||
private const uint SdlInitFlags = SDL_INIT_EVENTS | SDL_INIT_GAMECONTROLLER | SDL_INIT_JOYSTICK |
|
private const uint SdlInitFlags = SDL_INIT_EVENTS | SDL_INIT_GAMECONTROLLER | SDL_INIT_JOYSTICK | SDL_INIT_AUDIO | SDL_INIT_VIDEO;
|
||||||
SDL_INIT_AUDIO | SDL_INIT_VIDEO;
|
|
||||||
|
|
||||||
private bool _isRunning;
|
private bool _isRunning;
|
||||||
private uint _refereceCount;
|
private uint _refereceCount;
|
||||||
private Thread _worker;
|
private Thread _worker;
|
||||||
|
|
||||||
private const uint SDL_JOYBATTERYUPDATED = 1543;
|
|
||||||
public event Action<int, int> OnJoyStickConnected;
|
public event Action<int, int> OnJoyStickConnected;
|
||||||
public event Action<int> OnJoystickDisconnected;
|
public event Action<int> OnJoystickDisconnected;
|
||||||
public event Action<int, SDL_JoystickPowerLevel> OnJoyBatteryUpdated;
|
|
||||||
|
|
||||||
private ConcurrentDictionary<uint, Action<SDL_Event>> _registeredWindowHandlers;
|
private ConcurrentDictionary<uint, Action<SDL_Event>> _registeredWindowHandlers;
|
||||||
|
|
||||||
@@ -81,14 +78,12 @@ namespace Ryujinx.SDL2.Common
|
|||||||
// First ensure that we only enable joystick events (for connected/disconnected).
|
// First ensure that we only enable joystick events (for connected/disconnected).
|
||||||
if (SDL_GameControllerEventState(SDL_IGNORE) != SDL_IGNORE)
|
if (SDL_GameControllerEventState(SDL_IGNORE) != SDL_IGNORE)
|
||||||
{
|
{
|
||||||
Logger.Error?.PrintMsg(LogClass.Application,
|
Logger.Error?.PrintMsg(LogClass.Application, "Couldn't change the state of game controller events.");
|
||||||
"Couldn't change the state of game controller events.");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (SDL_JoystickEventState(SDL_ENABLE) < 0)
|
if (SDL_JoystickEventState(SDL_ENABLE) < 0)
|
||||||
{
|
{
|
||||||
Logger.Error?.PrintMsg(LogClass.Application,
|
Logger.Error?.PrintMsg(LogClass.Application, $"Failed to enable joystick event polling: {SDL_GetError()}");
|
||||||
$"Failed to enable joystick event polling: {SDL_GetError()}");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Disable all joysticks information, we don't need them no need to flood the event queue for that.
|
// Disable all joysticks information, we don't need them no need to flood the event queue for that.
|
||||||
@@ -148,12 +143,7 @@ namespace Ryujinx.SDL2.Common
|
|||||||
|
|
||||||
OnJoystickDisconnected?.Invoke(evnt.cbutton.which);
|
OnJoystickDisconnected?.Invoke(evnt.cbutton.which);
|
||||||
}
|
}
|
||||||
else if ((uint)evnt.type == SDL_JOYBATTERYUPDATED)
|
else if (evnt.type is SDL_EventType.SDL_WINDOWEVENT or SDL_EventType.SDL_MOUSEBUTTONDOWN or SDL_EventType.SDL_MOUSEBUTTONUP)
|
||||||
{
|
|
||||||
OnJoyBatteryUpdated?.Invoke(evnt.cbutton.which, (SDL_JoystickPowerLevel)evnt.user.code);
|
|
||||||
}
|
|
||||||
else if (evnt.type is SDL_EventType.SDL_WINDOWEVENT or SDL_EventType.SDL_MOUSEBUTTONDOWN
|
|
||||||
or SDL_EventType.SDL_MOUSEBUTTONUP)
|
|
||||||
{
|
{
|
||||||
if (_registeredWindowHandlers.TryGetValue(evnt.window.windowID, out Action<SDL_Event> handler))
|
if (_registeredWindowHandlers.TryGetValue(evnt.window.windowID, out Action<SDL_Event> handler))
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -517,7 +517,7 @@ namespace Ryujinx.Ava
|
|||||||
Device?.System.ChangeDockedModeState(e.NewValue);
|
Device?.System.ChangeDockedModeState(e.NewValue);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void UpdateAudioVolumeState(object sender, ReactiveEventArgs<float> e)
|
public void UpdateAudioVolumeState(object sender, ReactiveEventArgs<float> e)
|
||||||
{
|
{
|
||||||
Device?.SetVolume(e.NewValue);
|
Device?.SetVolume(e.NewValue);
|
||||||
|
|
||||||
|
|||||||
+407
-257
File diff suppressed because it is too large
Load Diff
@@ -1,14 +0,0 @@
|
|||||||
using System;
|
|
||||||
|
|
||||||
namespace Ryujinx.Ava.Common
|
|
||||||
{
|
|
||||||
public static class ThemeManager
|
|
||||||
{
|
|
||||||
public static event Action ThemeChanged;
|
|
||||||
|
|
||||||
public static void OnThemeChanged()
|
|
||||||
{
|
|
||||||
ThemeChanged?.Invoke();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -22,6 +22,8 @@ namespace Ryujinx.Ava
|
|||||||
{
|
{
|
||||||
public class RyujinxApp : Application
|
public class RyujinxApp : Application
|
||||||
{
|
{
|
||||||
|
public static event Action ThemeChanged;
|
||||||
|
|
||||||
internal static string FormatTitle(LocaleKeys? windowTitleKey = null, bool includeVersion = true)
|
internal static string FormatTitle(LocaleKeys? windowTitleKey = null, bool includeVersion = true)
|
||||||
=> windowTitleKey is null
|
=> windowTitleKey is null
|
||||||
? $"{FullAppName}{(includeVersion ? $" {Program.Version}" : string.Empty)}"
|
? $"{FullAppName}{(includeVersion ? $" {Program.Version}" : string.Empty)}"
|
||||||
@@ -112,7 +114,7 @@ namespace Ryujinx.Ava
|
|||||||
baseStyle = ConfigurationState.Instance.UI.BaseStyle;
|
baseStyle = ConfigurationState.Instance.UI.BaseStyle;
|
||||||
}
|
}
|
||||||
|
|
||||||
ThemeManager.OnThemeChanged();
|
ThemeChanged?.Invoke();
|
||||||
|
|
||||||
RequestedThemeVariant = baseStyle switch
|
RequestedThemeVariant = baseStyle switch
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -25,10 +25,10 @@ namespace Ryujinx.Ava.UI.ViewModels
|
|||||||
Version = RyujinxApp.FullAppName + "\n" + Program.Version;
|
Version = RyujinxApp.FullAppName + "\n" + Program.Version;
|
||||||
UpdateLogoTheme(ConfigurationState.Instance.UI.BaseStyle.Value);
|
UpdateLogoTheme(ConfigurationState.Instance.UI.BaseStyle.Value);
|
||||||
|
|
||||||
ThemeManager.ThemeChanged += ThemeManager_ThemeChanged;
|
RyujinxApp.ThemeChanged += Ryujinx_ThemeChanged;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void ThemeManager_ThemeChanged()
|
private void Ryujinx_ThemeChanged()
|
||||||
{
|
{
|
||||||
Dispatcher.UIThread.Post(() => UpdateLogoTheme(ConfigurationState.Instance.UI.BaseStyle.Value));
|
Dispatcher.UIThread.Post(() => UpdateLogoTheme(ConfigurationState.Instance.UI.BaseStyle.Value));
|
||||||
}
|
}
|
||||||
@@ -49,7 +49,7 @@ namespace Ryujinx.Ava.UI.ViewModels
|
|||||||
|
|
||||||
public void Dispose()
|
public void Dispose()
|
||||||
{
|
{
|
||||||
ThemeManager.ThemeChanged -= ThemeManager_ThemeChanged;
|
RyujinxApp.ThemeChanged -= Ryujinx_ThemeChanged;
|
||||||
|
|
||||||
GithubLogo.Dispose();
|
GithubLogo.Dispose();
|
||||||
DiscordLogo.Dispose();
|
DiscordLogo.Dispose();
|
||||||
|
|||||||
@@ -128,6 +128,8 @@ namespace Ryujinx.Ava.UI.ViewModels
|
|||||||
public bool EnableMouse { get; set; }
|
public bool EnableMouse { get; set; }
|
||||||
public bool DisableInputWhenOutOfFocus { get; set; }
|
public bool DisableInputWhenOutOfFocus { get; set; }
|
||||||
|
|
||||||
|
public int FocusLostActionType { get; set; }
|
||||||
|
|
||||||
public VSyncMode VSyncMode
|
public VSyncMode VSyncMode
|
||||||
{
|
{
|
||||||
get => _vSyncMode;
|
get => _vSyncMode;
|
||||||
@@ -481,6 +483,7 @@ namespace Ryujinx.Ava.UI.ViewModels
|
|||||||
ShowTitleBar = config.ShowTitleBar;
|
ShowTitleBar = config.ShowTitleBar;
|
||||||
HideCursor = (int)config.HideCursor.Value;
|
HideCursor = (int)config.HideCursor.Value;
|
||||||
UpdateCheckerType = (int)config.UpdateCheckerType.Value;
|
UpdateCheckerType = (int)config.UpdateCheckerType.Value;
|
||||||
|
FocusLostActionType = (int)config.FocusLostActionType.Value;
|
||||||
|
|
||||||
GameDirectories.Clear();
|
GameDirectories.Clear();
|
||||||
GameDirectories.AddRange(config.UI.GameDirs.Value);
|
GameDirectories.AddRange(config.UI.GameDirs.Value);
|
||||||
@@ -589,6 +592,7 @@ namespace Ryujinx.Ava.UI.ViewModels
|
|||||||
config.ShowTitleBar.Value = ShowTitleBar;
|
config.ShowTitleBar.Value = ShowTitleBar;
|
||||||
config.HideCursor.Value = (HideCursorMode)HideCursor;
|
config.HideCursor.Value = (HideCursorMode)HideCursor;
|
||||||
config.UpdateCheckerType.Value = (UpdaterType)UpdateCheckerType;
|
config.UpdateCheckerType.Value = (UpdaterType)UpdateCheckerType;
|
||||||
|
config.FocusLostActionType.Value = (FocusLostType)FocusLostActionType;
|
||||||
|
|
||||||
if (GameDirectoryChanged)
|
if (GameDirectoryChanged)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -37,12 +37,33 @@
|
|||||||
<CheckBox IsChecked="{Binding RememberWindowState}">
|
<CheckBox IsChecked="{Binding RememberWindowState}">
|
||||||
<TextBlock Text="{ext:Locale SettingsTabGeneralRememberWindowState}" />
|
<TextBlock Text="{ext:Locale SettingsTabGeneralRememberWindowState}" />
|
||||||
</CheckBox>
|
</CheckBox>
|
||||||
<CheckBox IsChecked="{Binding DisableInputWhenOutOfFocus}">
|
|
||||||
<TextBlock Text="{ext:Locale SettingsTabGeneralDisableInputWhenOutOfFocus}" />
|
|
||||||
</CheckBox>
|
|
||||||
<CheckBox IsChecked="{Binding ShowTitleBar}" IsVisible="{x:Static helper:RunningPlatform.IsWindows}">
|
<CheckBox IsChecked="{Binding ShowTitleBar}" IsVisible="{x:Static helper:RunningPlatform.IsWindows}">
|
||||||
<TextBlock Text="{ext:Locale SettingsTabGeneralShowTitleBar}" />
|
<TextBlock Text="{ext:Locale SettingsTabGeneralShowTitleBar}" />
|
||||||
</CheckBox>
|
</CheckBox>
|
||||||
|
<StackPanel Margin="0, 15, 0, 0" Orientation="Horizontal">
|
||||||
|
<TextBlock VerticalAlignment="Center"
|
||||||
|
Text="{ext:Locale SettingsTabGeneralFocusLossType}"
|
||||||
|
Width="150" />
|
||||||
|
<ComboBox SelectedIndex="{Binding FocusLostActionType}"
|
||||||
|
HorizontalContentAlignment="Left"
|
||||||
|
MinWidth="100">
|
||||||
|
<ComboBoxItem>
|
||||||
|
<TextBlock Text="{ext:Locale SettingsTabGeneralFocusLossTypeDoNothing}" />
|
||||||
|
</ComboBoxItem>
|
||||||
|
<ComboBoxItem>
|
||||||
|
<TextBlock Text="{ext:Locale SettingsTabGeneralFocusLossTypeBlockInput}" />
|
||||||
|
</ComboBoxItem>
|
||||||
|
<ComboBoxItem>
|
||||||
|
<TextBlock Text="{ext:Locale SettingsTabGeneralFocusLossTypeMuteAudio}" />
|
||||||
|
</ComboBoxItem>
|
||||||
|
<ComboBoxItem>
|
||||||
|
<TextBlock Text="{ext:Locale SettingsTabGeneralFocusLossTypeBlockInputAndMuteAudio}" />
|
||||||
|
</ComboBoxItem>
|
||||||
|
<ComboBoxItem>
|
||||||
|
<TextBlock Text="{ext:Locale SettingsTabGeneralFocusLossTypePauseEmulation}" />
|
||||||
|
</ComboBoxItem>
|
||||||
|
</ComboBox>
|
||||||
|
</StackPanel>
|
||||||
<StackPanel Margin="0, 15, 0, 0" Orientation="Horizontal">
|
<StackPanel Margin="0, 15, 0, 0" Orientation="Horizontal">
|
||||||
<TextBlock VerticalAlignment="Center"
|
<TextBlock VerticalAlignment="Center"
|
||||||
Text="{ext:Locale SettingsTabGeneralCheckUpdatesOnLaunch}"
|
Text="{ext:Locale SettingsTabGeneralCheckUpdatesOnLaunch}"
|
||||||
|
|||||||
@@ -765,31 +765,116 @@ namespace Ryujinx.Ava.UI.Windows
|
|||||||
|
|
||||||
private void InputElement_OnGotFocus(object sender, GotFocusEventArgs e)
|
private void InputElement_OnGotFocus(object sender, GotFocusEventArgs e)
|
||||||
{
|
{
|
||||||
if (!_didDisableInputUpdates)
|
if (ViewModel.AppHost is null) return;
|
||||||
|
|
||||||
|
if (!_focusLoss.Active)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (!ConfigurationState.Instance.Hid.DisableInputWhenOutOfFocus)
|
switch (_focusLoss.Type)
|
||||||
return;
|
{
|
||||||
|
case FocusLostType.BlockInput:
|
||||||
|
{
|
||||||
|
if (!ViewModel.AppHost.NpadManager.InputUpdatesBlocked)
|
||||||
|
{
|
||||||
|
_focusLoss = default;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (ViewModel.AppHost is not { NpadManager.InputUpdatesBlocked: true } appHost)
|
ViewModel.AppHost.NpadManager.UnblockInputUpdates();
|
||||||
return;
|
_focusLoss = default;
|
||||||
|
break;
|
||||||
appHost.NpadManager.UnblockInputUpdates();
|
}
|
||||||
_didDisableInputUpdates = appHost.NpadManager.InputUpdatesBlocked;
|
case FocusLostType.MuteAudio:
|
||||||
|
{
|
||||||
|
if (!ViewModel.AppHost.Device.IsAudioMuted())
|
||||||
|
{
|
||||||
|
_focusLoss = default;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
ViewModel.AppHost.Device.SetVolume(ViewModel.VolumeBeforeMute);
|
||||||
|
|
||||||
|
_focusLoss = default;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case FocusLostType.BlockInputAndMuteAudio:
|
||||||
|
{
|
||||||
|
if (!ViewModel.AppHost.Device.IsAudioMuted())
|
||||||
|
goto case FocusLostType.BlockInput;
|
||||||
|
|
||||||
|
ViewModel.AppHost.Device.SetVolume(ViewModel.VolumeBeforeMute);
|
||||||
|
ViewModel.AppHost.NpadManager.UnblockInputUpdates();
|
||||||
|
|
||||||
|
_focusLoss = default;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case FocusLostType.PauseEmulation:
|
||||||
|
{
|
||||||
|
if (!ViewModel.AppHost.Device.System.IsPaused)
|
||||||
|
{
|
||||||
|
_focusLoss = default;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
ViewModel.AppHost.Resume();
|
||||||
|
|
||||||
|
_focusLoss = default;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private bool _didDisableInputUpdates;
|
private (FocusLostType Type, bool Active) _focusLoss;
|
||||||
|
|
||||||
private void InputElement_OnLostFocus(object sender, RoutedEventArgs e)
|
private void InputElement_OnLostFocus(object sender, RoutedEventArgs e)
|
||||||
{
|
{
|
||||||
if (!ConfigurationState.Instance.Hid.DisableInputWhenOutOfFocus)
|
if (ConfigurationState.Instance.FocusLostActionType.Value is FocusLostType.DoNothing)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (ViewModel.AppHost is not { NpadManager.InputUpdatesBlocked: false } appHost)
|
if (ViewModel.AppHost is null) return;
|
||||||
return;
|
|
||||||
|
switch (ConfigurationState.Instance.FocusLostActionType.Value)
|
||||||
|
{
|
||||||
|
case FocusLostType.BlockInput:
|
||||||
|
{
|
||||||
|
if (ViewModel.AppHost.NpadManager.InputUpdatesBlocked)
|
||||||
|
return;
|
||||||
|
|
||||||
appHost.NpadManager.BlockInputUpdates();
|
ViewModel.AppHost.NpadManager.BlockInputUpdates();
|
||||||
_didDisableInputUpdates = appHost.NpadManager.InputUpdatesBlocked;
|
_focusLoss = (FocusLostType.BlockInput, ViewModel.AppHost.NpadManager.InputUpdatesBlocked);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case FocusLostType.MuteAudio:
|
||||||
|
{
|
||||||
|
if (ViewModel.AppHost.Device.GetVolume() is 0)
|
||||||
|
return;
|
||||||
|
|
||||||
|
ViewModel.VolumeBeforeMute = ViewModel.AppHost.Device.GetVolume();
|
||||||
|
ViewModel.AppHost.Device.SetVolume(0);
|
||||||
|
_focusLoss = (FocusLostType.MuteAudio, ViewModel.AppHost.Device.GetVolume() is 0f);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case FocusLostType.BlockInputAndMuteAudio:
|
||||||
|
{
|
||||||
|
if (ViewModel.AppHost.Device.GetVolume() is 0)
|
||||||
|
goto case FocusLostType.BlockInput;
|
||||||
|
|
||||||
|
ViewModel.VolumeBeforeMute = ViewModel.AppHost.Device.GetVolume();
|
||||||
|
ViewModel.AppHost.Device.SetVolume(0);
|
||||||
|
ViewModel.AppHost.NpadManager.BlockInputUpdates();
|
||||||
|
_focusLoss = (FocusLostType.BlockInputAndMuteAudio, ViewModel.AppHost.Device.GetVolume() is 0f && ViewModel.AppHost.NpadManager.InputUpdatesBlocked);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case FocusLostType.PauseEmulation:
|
||||||
|
{
|
||||||
|
if (ViewModel.AppHost.Device.System.IsPaused)
|
||||||
|
return;
|
||||||
|
|
||||||
|
ViewModel.AppHost.Pause();
|
||||||
|
_focusLoss = (FocusLostType.PauseEmulation, ViewModel.AppHost.Device.System.IsPaused);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -15,7 +15,7 @@ namespace Ryujinx.Ava.Utilities.Configuration
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// The current version of the file format
|
/// The current version of the file format
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public const int CurrentVersion = 66;
|
public const int CurrentVersion = 67;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Version of the configuration file format
|
/// Version of the configuration file format
|
||||||
@@ -171,6 +171,11 @@ namespace Ryujinx.Ava.Utilities.Configuration
|
|||||||
/// Checks for updates when Ryujinx starts when enabled, either prompting when an update is found or just showing a notification.
|
/// Checks for updates when Ryujinx starts when enabled, either prompting when an update is found or just showing a notification.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public UpdaterType UpdateCheckerType { get; set; }
|
public UpdaterType UpdateCheckerType { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// How the emulator should behave when you click off/on the window.
|
||||||
|
/// </summary>
|
||||||
|
public FocusLostType FocusLostActionType { get; set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Show "Confirm Exit" Dialog
|
/// Show "Confirm Exit" Dialog
|
||||||
|
|||||||
@@ -46,6 +46,7 @@ namespace Ryujinx.Ava.Utilities.Configuration
|
|||||||
EnableDiscordIntegration.Value = cff.EnableDiscordIntegration;
|
EnableDiscordIntegration.Value = cff.EnableDiscordIntegration;
|
||||||
CheckUpdatesOnStart.Value = cff.CheckUpdatesOnStart;
|
CheckUpdatesOnStart.Value = cff.CheckUpdatesOnStart;
|
||||||
UpdateCheckerType.Value = cff.UpdateCheckerType;
|
UpdateCheckerType.Value = cff.UpdateCheckerType;
|
||||||
|
FocusLostActionType.Value = cff.FocusLostActionType;
|
||||||
ShowConfirmExit.Value = cff.ShowConfirmExit;
|
ShowConfirmExit.Value = cff.ShowConfirmExit;
|
||||||
RememberWindowState.Value = cff.RememberWindowState;
|
RememberWindowState.Value = cff.RememberWindowState;
|
||||||
ShowTitleBar.Value = cff.ShowTitleBar;
|
ShowTitleBar.Value = cff.ShowTitleBar;
|
||||||
@@ -435,7 +436,8 @@ namespace Ryujinx.Ava.Utilities.Configuration
|
|||||||
(63, static cff => cff.MatchSystemTime = false),
|
(63, static cff => cff.MatchSystemTime = false),
|
||||||
(64, static cff => cff.LoggingEnableAvalonia = false),
|
(64, static cff => cff.LoggingEnableAvalonia = false),
|
||||||
(65, static cff => cff.UpdateCheckerType = cff.CheckUpdatesOnStart ? UpdaterType.PromptAtStartup : UpdaterType.Off),
|
(65, static cff => cff.UpdateCheckerType = cff.CheckUpdatesOnStart ? UpdaterType.PromptAtStartup : UpdaterType.Off),
|
||||||
(66, static cff => cff.DisableInputWhenOutOfFocus = false)
|
(66, static cff => cff.DisableInputWhenOutOfFocus = false),
|
||||||
|
(67, static cff => cff.FocusLostActionType = cff.DisableInputWhenOutOfFocus ? FocusLostType.BlockInput : FocusLostType.DoNothing)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -779,6 +779,11 @@ namespace Ryujinx.Ava.Utilities.Configuration
|
|||||||
/// Checks for updates when Ryujinx starts when enabled, either prompting when an update is found or just showing a notification.
|
/// Checks for updates when Ryujinx starts when enabled, either prompting when an update is found or just showing a notification.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public ReactiveObject<UpdaterType> UpdateCheckerType { get; private set; }
|
public ReactiveObject<UpdaterType> UpdateCheckerType { get; private set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// How the emulator should behave when you click off/on the window.
|
||||||
|
/// </summary>
|
||||||
|
public ReactiveObject<FocusLostType> FocusLostActionType { get; private set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Show "Confirm Exit" Dialog
|
/// Show "Confirm Exit" Dialog
|
||||||
@@ -817,6 +822,7 @@ namespace Ryujinx.Ava.Utilities.Configuration
|
|||||||
EnableDiscordIntegration = new ReactiveObject<bool>();
|
EnableDiscordIntegration = new ReactiveObject<bool>();
|
||||||
CheckUpdatesOnStart = new ReactiveObject<bool>();
|
CheckUpdatesOnStart = new ReactiveObject<bool>();
|
||||||
UpdateCheckerType = new ReactiveObject<UpdaterType>();
|
UpdateCheckerType = new ReactiveObject<UpdaterType>();
|
||||||
|
FocusLostActionType = new ReactiveObject<FocusLostType>();
|
||||||
ShowConfirmExit = new ReactiveObject<bool>();
|
ShowConfirmExit = new ReactiveObject<bool>();
|
||||||
RememberWindowState = new ReactiveObject<bool>();
|
RememberWindowState = new ReactiveObject<bool>();
|
||||||
ShowTitleBar = new ReactiveObject<bool>();
|
ShowTitleBar = new ReactiveObject<bool>();
|
||||||
|
|||||||
@@ -57,6 +57,7 @@ namespace Ryujinx.Ava.Utilities.Configuration
|
|||||||
EnableDiscordIntegration = EnableDiscordIntegration,
|
EnableDiscordIntegration = EnableDiscordIntegration,
|
||||||
CheckUpdatesOnStart = CheckUpdatesOnStart,
|
CheckUpdatesOnStart = CheckUpdatesOnStart,
|
||||||
UpdateCheckerType = UpdateCheckerType,
|
UpdateCheckerType = UpdateCheckerType,
|
||||||
|
FocusLostActionType = FocusLostActionType,
|
||||||
ShowConfirmExit = ShowConfirmExit,
|
ShowConfirmExit = ShowConfirmExit,
|
||||||
RememberWindowState = RememberWindowState,
|
RememberWindowState = RememberWindowState,
|
||||||
ShowTitleBar = ShowTitleBar,
|
ShowTitleBar = ShowTitleBar,
|
||||||
@@ -178,6 +179,7 @@ namespace Ryujinx.Ava.Utilities.Configuration
|
|||||||
System.EnableDockedMode.Value = true;
|
System.EnableDockedMode.Value = true;
|
||||||
EnableDiscordIntegration.Value = true;
|
EnableDiscordIntegration.Value = true;
|
||||||
UpdateCheckerType.Value = UpdaterType.PromptAtStartup;
|
UpdateCheckerType.Value = UpdaterType.PromptAtStartup;
|
||||||
|
FocusLostActionType.Value = FocusLostType.DoNothing;
|
||||||
ShowConfirmExit.Value = true;
|
ShowConfirmExit.Value = true;
|
||||||
RememberWindowState.Value = true;
|
RememberWindowState.Value = true;
|
||||||
ShowTitleBar.Value = !OperatingSystem.IsWindows();
|
ShowTitleBar.Value = !OperatingSystem.IsWindows();
|
||||||
|
|||||||
@@ -0,0 +1,15 @@
|
|||||||
|
using Ryujinx.Common.Utilities;
|
||||||
|
using System.Text.Json.Serialization;
|
||||||
|
|
||||||
|
namespace Ryujinx.Ava.Utilities.Configuration.UI
|
||||||
|
{
|
||||||
|
[JsonConverter(typeof(TypedStringEnumConverter<FocusLostType>))]
|
||||||
|
public enum FocusLostType
|
||||||
|
{
|
||||||
|
DoNothing,
|
||||||
|
BlockInput,
|
||||||
|
MuteAudio,
|
||||||
|
BlockInputAndMuteAudio,
|
||||||
|
PauseEmulation
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user