Compare commits

..

32 Commits

Author SHA1 Message Date
IvonWei
e54cde704f Merge 9356b68f26 into 6d75410bd2 2025-01-31 05:07:33 +01:00
Evan Husted
6d75410bd2 UI: Use the dynamic Ryujinx/Ryujinx Canary for dialog titles 2025-01-30 21:57:03 -06:00
Evan Husted
196b2eaf66 misc: chore: [ci skip] Remove needless fs integrity checks get in aoc extractor 2025-01-30 20:54:08 -06:00
Evan Husted
82fe519766 misc: chore: [ci skip] fix log on AOC extraction failure 2025-01-30 20:52:12 -06:00
madwind
9356b68f26 Add a '*' to label the virtual controller. 2025-01-13 08:41:32 +08:00
IvonWei
14aafebaa6 Merge branch 'Ryubing:master' into master 2025-01-13 08:33:30 +08:00
Evan Husted
4518666a04 Merge branch 'master' into master 2025-01-10 21:39:41 -06:00
madwind
4399edaa9f Fix typo: SQL_JOYBATTERYUPDATED => SDL_JOYBATTERYUPDATED 2025-01-02 11:50:20 +08:00
Evan Husted
4e77bcb55a Merge branch 'master' into master 2025-01-01 21:19:02 -06:00
IvonWei
3cbd7dc1a1 Merge branch 'Ryubing:master' into master 2024-12-31 19:21:10 +08:00
IvonWei
536f792558 Merge branch 'Ryubing:master' into master 2024-12-30 22:04:08 +08:00
madwind
7a451ab160 fix GetMappedStateSnapshot 2024-12-30 22:01:21 +08:00
IvonWei
99c7c3fb14 Merge branch 'Ryubing:master' into master 2024-12-29 18:37:03 +08:00
Evan Husted
09e7b660f4 Merge branch 'master' into master 2024-12-29 03:42:20 -06:00
madwind
69dfd8c60e fix right Stick 2024-12-29 02:11:31 +08:00
madwind
8e50dd9fa6 fix right JoyCon stick 2024-12-29 01:49:25 +08:00
madwind
68c03051ad For the JoyCon controller, wrap SDL2Gamepad as SDL2JoyCon to use a suitable layout and correct the motion sensing and joystick orientation. 2024-12-29 00:56:03 +08:00
Evan Husted
a837294b11 Merge branch 'master' into master 2024-12-28 06:01:06 -06:00
IvonWei
f1c0cc8076 Merge branch 'Ryubing:master' into master 2024-12-28 09:09:10 +08:00
madwind
6dec7ff8ba fix motionData 2024-12-28 09:07:22 +08:00
madwind
20fdbff964 clean log 2024-12-26 14:47:40 +08:00
IvonWei
e426680cb0 Merge branch 'GreemDev:master' into master 2024-12-26 11:58:50 +08:00
madwind
7863e97cb0 invoke OnGamepadConnected and OnGamepadDisconnected 2024-12-26 11:58:00 +08:00
madwind
c4dea0ee28 add SQL_JOYBATTERYUPDATED , OnJoyBatteryUpdated 2024-12-26 11:54:52 +08:00
IvonWei
e0b6a01e9d Merge branch 'GreemDev:master' into master 2024-12-25 17:00:53 +08:00
madwind
e509ffa716 delay 2000ms before ShowPowerLevel 2024-12-25 16:57:36 +08:00
IvonWei
714c68b548 Merge branch 'GreemDev:master' into master 2024-12-25 10:41:20 +08:00
madwind
fec197d9ec log powerLevel 2024-12-25 10:39:07 +08:00
IvonWei
a4b2feef79 Merge branch 'GreemDev:master' into master 2024-12-23 22:13:47 +08:00
IvonWei
ad7d9d1ce0 Update NpadController.cs
add ?
2024-12-23 18:55:49 +08:00
IvonWei
86f9544910 Update NpadController.cs
back to Debug
2024-12-23 18:54:11 +08:00
madwind
e9ecbd44fc Add a virtual controller to merge Joy-Cons. 2024-12-23 17:57:55 +08:00
11 changed files with 828 additions and 188 deletions

View File

@@ -1,3 +1,4 @@
using Ryujinx.Common.Logging;
using Ryujinx.SDL2.Common;
using System;
using System.Collections.Generic;
@@ -36,6 +37,7 @@ namespace Ryujinx.Input.SDL2
SDL2Driver.Instance.Initialize();
SDL2Driver.Instance.OnJoyStickConnected += HandleJoyStickConnected;
SDL2Driver.Instance.OnJoystickDisconnected += HandleJoyStickDisconnected;
SDL2Driver.Instance.OnJoyBatteryUpdated += HandleJoyBatteryUpdated;
// Add already connected gamepads
int numJoysticks = SDL_NumJoysticks();
@@ -83,19 +85,30 @@ namespace Ryujinx.Input.SDL2
private void HandleJoyStickDisconnected(int joystickInstanceId)
{
bool joyConPairDisconnected = false;
if (!_gamepadsInstanceIdsMapping.Remove(joystickInstanceId, out string id))
return;
lock (_lock)
{
_gamepadsIds.Remove(id);
if (!SDL2JoyConPair.IsCombinable(_gamepadsIds))
{
_gamepadsIds.Remove(SDL2JoyConPair.Id);
joyConPairDisconnected = true;
}
}
OnGamepadDisconnected?.Invoke(id);
if (joyConPairDisconnected)
{
OnGamepadDisconnected?.Invoke(SDL2JoyConPair.Id);
}
}
private void HandleJoyStickConnected(int joystickDeviceId, int joystickInstanceId)
{
bool joyConPairConnected = false;
if (SDL_IsGameController(joystickDeviceId) == SDL_bool.SDL_TRUE)
{
if (_gamepadsInstanceIdsMapping.ContainsKey(joystickInstanceId))
@@ -120,13 +133,29 @@ namespace Ryujinx.Input.SDL2
_gamepadsIds.Insert(joystickDeviceId, id);
else
_gamepadsIds.Add(id);
if (SDL2JoyConPair.IsCombinable(_gamepadsIds))
{
_gamepadsIds.Remove(SDL2JoyConPair.Id);
_gamepadsIds.Add(SDL2JoyConPair.Id);
joyConPairConnected = true;
}
}
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)
{
if (disposing)
@@ -157,6 +186,14 @@ namespace Ryujinx.Input.SDL2
public IGamepad GetGamepad(string id)
{
if (id == SDL2JoyConPair.Id)
{
lock (_lock)
{
return SDL2JoyConPair.GetGamepad(_gamepadsIds);
}
}
int joystickIndex = GetJoystickIndexByGamepadId(id);
if (joystickIndex == -1)
@@ -165,12 +202,16 @@ namespace Ryujinx.Input.SDL2
}
nint gamepadHandle = SDL_GameControllerOpen(joystickIndex);
if (gamepadHandle == nint.Zero)
{
return null;
}
if (SDL_GameControllerName(gamepadHandle).StartsWith(SDL2JoyCon.Prefix))
{
return new SDL2JoyCon(gamepadHandle, id);
}
return new SDL2Gamepad(gamepadHandle, id);
}

View File

@@ -0,0 +1,409 @@
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;
}
}
}

View File

@@ -0,0 +1,142 @@
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]));
}
}
}

View File

@@ -269,6 +269,7 @@ namespace Ryujinx.Input.HLE
if (motionConfig.MotionBackend != MotionInputBackendType.CemuHook)
{
_leftMotionInput = new MotionInput();
_rightMotionInput = new MotionInput();
}
else
{
@@ -301,7 +302,20 @@ namespace Ryujinx.Input.HLE
if (controllerConfig.ControllerType == ConfigControllerType.JoyconPair)
{
_rightMotionInput = _leftMotionInput;
if (gamepad.Id== "JoyConPair")
{
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;
}
}
}
}
@@ -336,6 +350,7 @@ namespace Ryujinx.Input.HLE
// Reset states
State = default;
_leftMotionInput = null;
_rightMotionInput = null;
}
}

View File

@@ -21,5 +21,17 @@ namespace Ryujinx.Input
/// </summary>
/// <remarks>Values are in degrees</remarks>
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
}
}

View File

@@ -25,14 +25,17 @@ namespace Ryujinx.SDL2.Common
public static Action<Action> MainThreadDispatcher { get; set; }
private const uint SdlInitFlags = SDL_INIT_EVENTS | SDL_INIT_GAMECONTROLLER | SDL_INIT_JOYSTICK | SDL_INIT_AUDIO | SDL_INIT_VIDEO;
private const uint SdlInitFlags = SDL_INIT_EVENTS | SDL_INIT_GAMECONTROLLER | SDL_INIT_JOYSTICK |
SDL_INIT_AUDIO | SDL_INIT_VIDEO;
private bool _isRunning;
private uint _refereceCount;
private Thread _worker;
private const uint SDL_JOYBATTERYUPDATED = 1543;
public event Action<int, int> OnJoyStickConnected;
public event Action<int> OnJoystickDisconnected;
public event Action<int, SDL_JoystickPowerLevel> OnJoyBatteryUpdated;
private ConcurrentDictionary<uint, Action<SDL_Event>> _registeredWindowHandlers;
@@ -78,12 +81,14 @@ namespace Ryujinx.SDL2.Common
// First ensure that we only enable joystick events (for connected/disconnected).
if (SDL_GameControllerEventState(SDL_IGNORE) != SDL_IGNORE)
{
Logger.Error?.PrintMsg(LogClass.Application, "Couldn't change the state of game controller events.");
Logger.Error?.PrintMsg(LogClass.Application,
"Couldn't change the state of game controller events.");
}
if (SDL_JoystickEventState(SDL_ENABLE) < 0)
{
Logger.Error?.PrintMsg(LogClass.Application, $"Failed to enable joystick event polling: {SDL_GetError()}");
Logger.Error?.PrintMsg(LogClass.Application,
$"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.
@@ -143,7 +148,12 @@ namespace Ryujinx.SDL2.Common
OnJoystickDisconnected?.Invoke(evnt.cbutton.which);
}
else if (evnt.type is SDL_EventType.SDL_WINDOWEVENT or SDL_EventType.SDL_MOUSEBUTTONDOWN or SDL_EventType.SDL_MOUSEBUTTONUP)
else if ((uint)evnt.type == SDL_JOYBATTERYUPDATED)
{
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))
{

View File

@@ -11475,126 +11475,126 @@
{
"ID": "DialogConfirmationTitle",
"Translations": {
"ar_SA": "ريوجينكس - تأكيد",
"de_DE": "Ryujinx - Bestätigung",
"el_GR": "Ryujinx - Επιβεβαίωση",
"en_US": "Ryujinx - Confirmation",
"es_ES": "Ryujinx - Confirmación",
"ar_SA": "{0} - تأكيد",
"de_DE": "{0} - Bestätigung",
"el_GR": "{0} - Επιβεβαίωση",
"en_US": "{0} - Confirmation",
"es_ES": "{0} - Confirmación",
"fr_FR": "",
"he_IL": "ריוג'ינקס - אישור",
"it_IT": "Ryujinx - Conferma",
"ja_JP": "Ryujinx - 確認",
"ko_KR": "Ryujinx - 확인",
"no_NO": "Ryujinx - Bekreftelse",
"pl_PL": "Ryujinx - Potwierdzenie",
"pt_BR": "Ryujinx - Confirmação",
"ru_RU": "Ryujinx - Подтверждение",
"sv_SE": "Ryujinx - Bekräftelse",
"th_TH": "Ryujinx - ยืนยัน",
"tr_TR": "Ryujinx - Onay",
"uk_UA": "Ryujinx - Підтвердження",
"zh_CN": "Ryujinx - 确认",
"zh_TW": "Ryujinx - 確認"
"he_IL": "{0} - אישור",
"it_IT": "{0} - Conferma",
"ja_JP": "{0} - 確認",
"ko_KR": "{0} - 확인",
"no_NO": "{0} - Bekreftelse",
"pl_PL": "{0} - Potwierdzenie",
"pt_BR": "{0} - Confirmação",
"ru_RU": "{0} - Подтверждение",
"sv_SE": "{0} - Bekräftelse",
"th_TH": "{0} - ยืนยัน",
"tr_TR": "{0} - Onay",
"uk_UA": "{0} - Підтвердження",
"zh_CN": "{0} - 确认",
"zh_TW": "{0} - 確認"
}
},
{
"ID": "DialogUpdaterTitle",
"Translations": {
"ar_SA": "ريوجينكس - المحدث",
"ar_SA": "{0} - المحدث",
"de_DE": "",
"el_GR": "Ryujinx - Ενημερωτής",
"en_US": "Ryujinx - Updater",
"es_ES": "Ryujinx - Actualizador",
"fr_FR": "Ryujinx - Mise à Jour",
"he_IL": "ריוג'ינקס - מעדכן",
"it_IT": "Ryujinx - Aggiornamento",
"ja_JP": "Ryujinx - アップデータ",
"ko_KR": "Ryujinx - 업데이터",
"no_NO": "Ryujinx Oppdaterer",
"pl_PL": "Ryujinx - Asystent aktualizacji",
"pt_BR": "Ryujinx - Atualizador",
"ru_RU": "Ryujinx - Обновление",
"sv_SE": "Ryujinx - Uppdatering",
"th_TH": "Ryujinx - อัพเดต",
"tr_TR": "Ryujinx - Güncelleyici",
"uk_UA": "Ryujinx - Програма оновлення",
"zh_CN": "Ryujinx - 更新",
"zh_TW": "Ryujinx - 更新程式"
"el_GR": "{0} - Ενημερωτής",
"en_US": "{0} - Updater",
"es_ES": "{0} - Actualizador",
"fr_FR": "{0} - Mise à Jour",
"he_IL": "{0} - מעדכן",
"it_IT": "{0} - Aggiornamento",
"ja_JP": "{0} - アップデータ",
"ko_KR": "{0} - 업데이터",
"no_NO": "{0} Oppdaterer",
"pl_PL": "{0} - Asystent aktualizacji",
"pt_BR": "{0} - Atualizador",
"ru_RU": "{0} - Обновление",
"sv_SE": "{0} - Uppdatering",
"th_TH": "{0} - อัพเดต",
"tr_TR": "{0} - Güncelleyici",
"uk_UA": "{0} - Програма оновлення",
"zh_CN": "{0} - 更新",
"zh_TW": "{0} - 更新程式"
}
},
{
"ID": "DialogErrorTitle",
"Translations": {
"ar_SA": "ريوجينكس - خطأ",
"de_DE": "Ryujinx - Fehler",
"el_GR": "Ryujinx - Σφάλμα",
"en_US": "Ryujinx - Error",
"ar_SA": "{0} - خطأ",
"de_DE": "{0} - Fehler",
"el_GR": "{0} - Σφάλμα",
"en_US": "{0} - Error",
"es_ES": "",
"fr_FR": "Ryujinx - Erreur",
"he_IL": "ריוג'ינקס - שגיאה",
"it_IT": "Ryujinx - Errore",
"ja_JP": "Ryujinx - エラー",
"ko_KR": "Ryujinx - 오류",
"no_NO": "Ryujinx - Feil",
"pl_PL": "Ryujinx - Błąd",
"pt_BR": "Ryujinx - Erro",
"ru_RU": "Ryujinx - Ошибка",
"sv_SE": "Ryujinx - Fel",
"th_TH": "Ryujinx - ผิดพลาด",
"tr_TR": "Ryujinx - Hata",
"uk_UA": "Ryujinx - Помилка",
"zh_CN": "Ryujinx - 错误",
"zh_TW": "Ryujinx - 錯誤"
"fr_FR": "{0} - Erreur",
"he_IL": "{0} - שגיאה",
"it_IT": "{0} - Errore",
"ja_JP": "{0} - エラー",
"ko_KR": "{0} - 오류",
"no_NO": "{0} - Feil",
"pl_PL": "{0} - Błąd",
"pt_BR": "{0} - Erro",
"ru_RU": "{0} - Ошибка",
"sv_SE": "{0} - Fel",
"th_TH": "{0} - ผิดพลาด",
"tr_TR": "{0} - Hata",
"uk_UA": "{0} - Помилка",
"zh_CN": "{0} - 错误",
"zh_TW": "{0} - 錯誤"
}
},
{
"ID": "DialogWarningTitle",
"Translations": {
"ar_SA": "ريوجينكس - تحذير",
"de_DE": "Ryujinx - Warnung",
"el_GR": "Ryujinx - Προειδοποίηση",
"en_US": "Ryujinx - Warning",
"es_ES": "Ryujinx - Advertencia",
"fr_FR": "Ryujinx - Avertissement",
"he_IL": "ריוג'ינקס - אזהרה",
"it_IT": "Ryujinx - Avviso",
"ja_JP": "Ryujinx - 警告",
"ko_KR": "Ryujinx - 경고",
"no_NO": "Ryujinx - Advarsel",
"pl_PL": "Ryujinx - Ostrzeżenie",
"pt_BR": "Ryujinx - Alerta",
"ru_RU": "Ryujinx - Предупреждение",
"sv_SE": "Ryujinx - Varning",
"th_TH": "Ryujinx - คำเตือน",
"tr_TR": "Ryujinx - Uyarı",
"uk_UA": "Ryujinx - Попередження",
"zh_CN": "Ryujinx - 警告",
"zh_TW": "Ryujinx - 警告"
"ar_SA": "{0} - تحذير",
"de_DE": "{0} - Warnung",
"el_GR": "{0} - Προειδοποίηση",
"en_US": "{0} - Warning",
"es_ES": "{0} - Advertencia",
"fr_FR": "{0} - Avertissement",
"he_IL": "{0} - אזהרה",
"it_IT": "{0} - Avviso",
"ja_JP": "{0} - 警告",
"ko_KR": "{0} - 경고",
"no_NO": "{0} - Advarsel",
"pl_PL": "{0} - Ostrzeżenie",
"pt_BR": "{0} - Alerta",
"ru_RU": "{0} - Предупреждение",
"sv_SE": "{0} - Varning",
"th_TH": "{0} - คำเตือน",
"tr_TR": "{0} - Uyarı",
"uk_UA": "{0} - Попередження",
"zh_CN": "{0} - 警告",
"zh_TW": "{0} - 警告"
}
},
{
"ID": "DialogExitTitle",
"Translations": {
"ar_SA": "ريوجينكس - الخروج",
"de_DE": "Ryujinx - Beenden",
"el_GR": "Ryujinx - Έξοδος",
"en_US": "Ryujinx - Exit",
"es_ES": "Ryujinx - Salir",
"fr_FR": "Ryujinx - Quitter",
"he_IL": "ריוג'ינקס - יציאה",
"it_IT": "Ryujinx - Esci",
"ja_JP": "Ryujinx - 終了",
"ko_KR": "Ryujinx - 종료",
"no_NO": "Ryujinx - Avslutt",
"pl_PL": "Ryujinx - Wyjdź",
"pt_BR": "Ryujinx - Sair",
"ru_RU": "Ryujinx - Выход",
"sv_SE": "Ryujinx - Avslut",
"th_TH": "Ryujinx - ออก",
"tr_TR": "Ryujinx - Çıkış",
"uk_UA": "Ryujinx - Вихід",
"zh_CN": "Ryujinx - 退出",
"zh_TW": "Ryujinx - 結束"
"ar_SA": "{0} - الخروج",
"de_DE": "{0} - Beenden",
"el_GR": "{0} - Έξοδος",
"en_US": "{0} - Exit",
"es_ES": "{0} - Salir",
"fr_FR": "{0} - Quitter",
"he_IL": "{0} - יציאה",
"it_IT": "{0} - Esci",
"ja_JP": "{0} - 終了",
"ko_KR": "{0} - 종료",
"no_NO": "{0} - Avslutt",
"pl_PL": "{0} - Wyjdź",
"pt_BR": "{0} - Sair",
"ru_RU": "{0} - Выход",
"sv_SE": "{0} - Avslut",
"th_TH": "{0} - ออก",
"tr_TR": "{0} - Çıkış",
"uk_UA": "{0} - Вихід",
"zh_CN": "{0} - 退出",
"zh_TW": "{0} - 結束"
}
},
{
@@ -17025,26 +17025,26 @@
{
"ID": "DialogStopEmulationTitle",
"Translations": {
"ar_SA": "ريوجينكس - إيقاف المحاكاة",
"de_DE": "Ryujinx - Beende Emulation",
"el_GR": "Ryujinx - Διακοπή εξομοίωσης",
"en_US": "Ryujinx - Stop Emulation",
"es_ES": "Ryujinx - Detener emulación",
"fr_FR": "Ryujinx - Arrêt de l'émulation",
"he_IL": "ריוג'ינקס - עצור אמולציה",
"it_IT": "Ryujinx - Ferma emulazione",
"ja_JP": "Ryujinx - エミュレーションを中止",
"ko_KR": "Ryujinx - 에뮬레이션 중지",
"no_NO": "Ryujinx - Stopp emulasjon",
"pl_PL": "Ryujinx - Zatrzymaj Emulację",
"pt_BR": "Ryujinx - Parar emulação",
"ru_RU": "Ryujinx - Остановка эмуляции",
"sv_SE": "Ryujinx - Stoppa emulering",
"th_TH": "Ryujinx - หยุดการจำลอง",
"tr_TR": "Ryujinx - Emülasyonu Durdur",
"uk_UA": "Ryujinx - Зупинити емуляцію",
"zh_CN": "Ryujinx - 停止模拟",
"zh_TW": "Ryujinx - 停止模擬"
"ar_SA": "{0} - إيقاف المحاكاة",
"de_DE": "{0} - Beende Emulation",
"el_GR": "{0} - Διακοπή εξομοίωσης",
"en_US": "{0} - Stop Emulation",
"es_ES": "{0} - Detener emulación",
"fr_FR": "{0} - Arrêt de l'émulation",
"he_IL": "{0} - עצור אמולציה",
"it_IT": "{0} - Ferma emulazione",
"ja_JP": "{0} - エミュレーションを中止",
"ko_KR": "{0} - 에뮬레이션 중지",
"no_NO": "{0} - Stopp emulasjon",
"pl_PL": "{0} - Zatrzymaj Emulację",
"pt_BR": "{0} - Parar emulação",
"ru_RU": "{0} - Остановка эмуляции",
"sv_SE": "{0} - Stoppa emulering",
"th_TH": "{0} - หยุดการจำลอง",
"tr_TR": "{0} - Emülasyonu Durdur",
"uk_UA": "{0} - Зупинити емуляцію",
"zh_CN": "{0} - 停止模拟",
"zh_TW": "{0} - 停止模擬"
}
},
{
@@ -17950,51 +17950,51 @@
{
"ID": "RyujinxInfo",
"Translations": {
"ar_SA": "ريوجينكس - معلومات",
"ar_SA": "{0} - معلومات",
"de_DE": "",
"el_GR": "Ryujinx - Πληροφορίες",
"en_US": "Ryujinx - Info",
"el_GR": "{0} - Πληροφορίες",
"en_US": "{0} - Info",
"es_ES": "",
"fr_FR": "",
"he_IL": "ריוג'ינקס - מידע",
"it_IT": "Ryujinx - Informazioni",
"ja_JP": "Ryujinx - 情報",
"ko_KR": "Ryujinx - 정보",
"no_NO": "Ryujinx - Informasjon",
"he_IL": "{0} - מידע",
"it_IT": "{0} - Informazioni",
"ja_JP": "{0} - 情報",
"ko_KR": "{0} - 정보",
"no_NO": "{0} - Informasjon",
"pl_PL": "",
"pt_BR": "Ryujinx - Informação",
"ru_RU": "Ryujinx - Информация",
"pt_BR": "{0} - Informação",
"ru_RU": "{0} - Информация",
"sv_SE": "",
"th_TH": "Ryujinx ข้อมูล",
"tr_TR": "Ryujinx - Bilgi",
"uk_UA": "Ryujin x - Інформація",
"zh_CN": "Ryujinx - 信息",
"zh_TW": "Ryujinx - 資訊"
"th_TH": "{0} ข้อมูล",
"tr_TR": "{0} - Bilgi",
"uk_UA": "{0} - Інформація",
"zh_CN": "{0} - 信息",
"zh_TW": "{0} - 資訊"
}
},
{
"ID": "RyujinxConfirm",
"Translations": {
"ar_SA": "ريوجينكس - تأكيد",
"de_DE": "Ryujinx - Bestätigung",
"el_GR": "Ryujinx - Επιβεβαίωση",
"en_US": "Ryujinx - Confirmation",
"es_ES": "Ryujinx - Confirmación",
"ar_SA": "{0} - تأكيد",
"de_DE": "{0} - Bestätigung",
"el_GR": "{0} - Επιβεβαίωση",
"en_US": "{0} - Confirmation",
"es_ES": "{0} - Confirmación",
"fr_FR": "",
"he_IL": "ריוג'ינקס - אישור",
"it_IT": "Ryujinx - Conferma",
"ja_JP": "Ryujinx - 確認",
"ko_KR": "Ryujinx - 확인",
"no_NO": "Ryujinx - Bekreftelse",
"pl_PL": "Ryujinx - Potwierdzenie",
"pt_BR": "Ryujinx - Confirmação",
"ru_RU": "Ryujinx - Подтверждение",
"sv_SE": "Ryujinx - Bekräfta",
"th_TH": "Ryujinx - ยืนยัน",
"tr_TR": "Ryujinx - Doğrulama",
"uk_UA": "Ryujinx - Підтвердження",
"zh_CN": "Ryujinx - 确认",
"zh_TW": "Ryujinx - 確認"
"he_IL": "{0} - אישור",
"it_IT": "{0} - Conferma",
"ja_JP": "{0} - 確認",
"ko_KR": "{0} - 확인",
"no_NO": "{0} - Bekreftelse",
"pl_PL": "{0} - Potwierdzenie",
"pt_BR": "{0} - Confirmação",
"ru_RU": "{0} - Подтверждение",
"sv_SE": "{0} - Bekräfta",
"th_TH": "{0} - ยืนยัน",
"tr_TR": "{0} - Doğrulama",
"uk_UA": "{0} - Підтвердження",
"zh_CN": "{0} - 确认",
"zh_TW": "{0} - 確認"
}
},
{
@@ -18800,26 +18800,26 @@
{
"ID": "RyujinxUpdater",
"Translations": {
"ar_SA": "محدث ريوجينكس",
"de_DE": "Ryujinx - Updater",
"el_GR": "Ryujinx Ενημερωτής",
"en_US": "Ryujinx Updater",
"es_ES": "Actualizador de Ryujinx",
"fr_FR": "Mise à jour de Ryujinx",
"he_IL": "מעדכן ריוג'ינקס",
"it_IT": "Aggiornamento di Ryujinx",
"ja_JP": "Ryujinx アップデータ",
"ko_KR": "Ryujinx 업데이터",
"no_NO": "Ryujinx Oppgradering",
"pl_PL": "Aktualizator Ryujinx",
"pt_BR": "Atualizador do Ryujinx",
"ru_RU": "Ryujinx - Обновление",
"sv_SE": "Uppdaterare för Ryujinx",
"th_TH": "ตัวอัปเดต Ryujinx",
"tr_TR": "Ryujinx Güncelleyicisi",
"uk_UA": "Програма оновлення Ryujinx",
"zh_CN": "Ryujinx 更新",
"zh_TW": "Ryujinx 更新程式"
"ar_SA": "محدث {0}",
"de_DE": "",
"el_GR": "{0} Ενημερωτής",
"en_US": "{0} Updater",
"es_ES": "Actualizador de {0}",
"fr_FR": "Mise à jour de {0}",
"he_IL": "מעדכן {0}",
"it_IT": "Aggiornamento di {0}",
"ja_JP": "{0} アップデータ",
"ko_KR": "{0} 업데이터",
"no_NO": "{0} Oppgradering",
"pl_PL": "Aktualizator {0}",
"pt_BR": "Atualizador do {0}",
"ru_RU": "{0} Обновление",
"sv_SE": "Uppdaterare för {0}",
"th_TH": "ตัวอัปเดต {0}",
"tr_TR": "{0} Güncelleyicisi",
"uk_UA": "Програма оновлення {0}",
"zh_CN": "{0} 更新",
"zh_TW": "{0} 更新程式"
}
},
{

View File

@@ -337,7 +337,7 @@ namespace Ryujinx.Ava.Common
if (publicDataNca is null)
{
Logger.Error?.Print(LogClass.Application, "Extraction failure. The NCA was not present in the selected file");
Logger.Error?.Print(LogClass.Application, "Extraction failure. The PublicData NCA was not present in the selected file");
Dispatcher.UIThread.InvokeAsync(async () =>
{
@@ -349,10 +349,6 @@ namespace Ryujinx.Ava.Common
return;
}
IntegrityCheckLevel checkLevel = ConfigurationState.Instance.System.EnableFsIntegrityChecks
? IntegrityCheckLevel.ErrorOnInvalid
: IntegrityCheckLevel.None;
int index = Nca.GetSectionIndexFromType(NcaSectionType.Data, publicDataNca.Header.ContentType);
try

View File

@@ -44,6 +44,16 @@ namespace Ryujinx.Ava.Common.Locale
ConfigurationState.Instance.ToFileFormat().SaveConfig(Program.ConfigurationPath);
}
SetDynamicValues(LocaleKeys.DialogConfirmationTitle, RyujinxApp.FullAppName);
SetDynamicValues(LocaleKeys.DialogUpdaterTitle, RyujinxApp.FullAppName);
SetDynamicValues(LocaleKeys.DialogErrorTitle, RyujinxApp.FullAppName);
SetDynamicValues(LocaleKeys.DialogWarningTitle, RyujinxApp.FullAppName);
SetDynamicValues(LocaleKeys.DialogExitTitle, RyujinxApp.FullAppName);
SetDynamicValues(LocaleKeys.DialogStopEmulationTitle, RyujinxApp.FullAppName);
SetDynamicValues(LocaleKeys.RyujinxInfo, RyujinxApp.FullAppName);
SetDynamicValues(LocaleKeys.RyujinxConfirm, RyujinxApp.FullAppName);
SetDynamicValues(LocaleKeys.RyujinxUpdater, RyujinxApp.FullAppName);
}
public string this[LocaleKeys key]
@@ -88,11 +98,16 @@ namespace Ryujinx.Ava.Common.Locale
public static string FormatDynamicValue(LocaleKeys key, params object[] values)
=> Instance.UpdateAndGetDynamicValue(key, values);
public string UpdateAndGetDynamicValue(LocaleKeys key, params object[] values)
public void SetDynamicValues(LocaleKeys key, params object[] values)
{
_dynamicValues[key] = values;
OnPropertyChanged("Translation");
}
public string UpdateAndGetDynamicValue(LocaleKeys key, params object[] values)
{
SetDynamicValues(key, values);
return this[key];
}

View File

@@ -22,12 +22,12 @@ namespace Ryujinx.Ava
{
public class RyujinxApp : Application
{
internal static string FormatTitle(LocaleKeys? windowTitleKey = null)
internal static string FormatTitle(LocaleKeys? windowTitleKey = null, bool includeVersion = true)
=> windowTitleKey is null
? $"{FullAppName} {Program.Version}"
: $"{FullAppName} {Program.Version} - {LocaleManager.Instance[windowTitleKey.Value]}";
? $"{FullAppName}{(includeVersion ? $" {Program.Version}" : string.Empty)}"
: $"{FullAppName}{(includeVersion ? $" {Program.Version}" : string.Empty)} - {LocaleManager.Instance[windowTitleKey.Value]}";
public static readonly string FullAppName = ReleaseInformation.IsCanaryBuild ? "Ryujinx Canary" : "Ryujinx";
public static readonly string FullAppName = string.Intern(ReleaseInformation.IsCanaryBuild ? "Ryujinx Canary" : "Ryujinx");
public static MainWindow MainWindow => Current!
.ApplicationLifetime.Cast<IClassicDesktopStyleApplicationLifetime>()

View File

@@ -302,7 +302,7 @@ namespace Ryujinx.Ava.UI.Windows
LinuxHelper.RecommendedVmMaxMapCount);
UserResult response = await ContentDialogHelper.ShowTextDialog(
$"Ryujinx - {LocaleManager.Instance[LocaleKeys.LinuxVmMaxMapCountDialogTitle]}",
RyujinxApp.FormatTitle(LocaleKeys.LinuxVmMaxMapCountDialogTitle, false),
LocaleManager.Instance[LocaleKeys.LinuxVmMaxMapCountDialogTextPrimary],
LocaleManager.Instance[LocaleKeys.LinuxVmMaxMapCountDialogTextSecondary],
LocaleManager.Instance[LocaleKeys.LinuxVmMaxMapCountDialogButtonUntilRestart],