mirror of
https://git.ryujinx.app/ryubing/ryujinx.git
synced 2025-04-24 04:37:42 +02:00
misc: chore: Use explicit types in input projects
This commit is contained in:
parent
1712d69dcd
commit
ac401034d7
8 changed files with 20 additions and 18 deletions
|
@ -373,7 +373,7 @@ namespace Ryujinx.Input.SDL2
|
||||||
|
|
||||||
if (HasConfiguration)
|
if (HasConfiguration)
|
||||||
{
|
{
|
||||||
var joyconStickConfig = GetLogicalJoyStickConfig(inputId);
|
JoyconConfigControllerStick<GamepadInputId, Common.Configuration.Hid.Controller.StickInputId> joyconStickConfig = GetLogicalJoyStickConfig(inputId);
|
||||||
|
|
||||||
if (joyconStickConfig != null)
|
if (joyconStickConfig != null)
|
||||||
{
|
{
|
||||||
|
|
|
@ -55,7 +55,7 @@ namespace Ryujinx.Input.SDL2
|
||||||
|
|
||||||
public IEnumerable<IGamepad> GetGamepads()
|
public IEnumerable<IGamepad> GetGamepads()
|
||||||
{
|
{
|
||||||
foreach (var keyboardId in _keyboardIdentifers)
|
foreach (string keyboardId in _keyboardIdentifers)
|
||||||
{
|
{
|
||||||
yield return GetGamepad(keyboardId);
|
yield return GetGamepad(keyboardId);
|
||||||
}
|
}
|
||||||
|
|
|
@ -144,7 +144,7 @@ namespace Ryujinx.Input.Assigner
|
||||||
{
|
{
|
||||||
StringWriter writer = new();
|
StringWriter writer = new();
|
||||||
|
|
||||||
foreach (var kvp in _stats)
|
foreach (KeyValuePair<GamepadButtonInputId, InputSummary> kvp in _stats)
|
||||||
{
|
{
|
||||||
writer.WriteLine($"Button {kvp.Key} -> {kvp.Value}");
|
writer.WriteLine($"Button {kvp.Key} -> {kvp.Value}");
|
||||||
}
|
}
|
||||||
|
|
|
@ -49,7 +49,7 @@ namespace Ryujinx.Input
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||||
public (float, float) GetStick(StickInputId inputId)
|
public (float, float) GetStick(StickInputId inputId)
|
||||||
{
|
{
|
||||||
var result = _joysticksState[(int)inputId];
|
Array2<float> result = _joysticksState[(int)inputId];
|
||||||
|
|
||||||
return (result[0], result[1]);
|
return (result[0], result[1]);
|
||||||
}
|
}
|
||||||
|
|
|
@ -276,7 +276,7 @@ namespace Ryujinx.Input.HLE
|
||||||
public void Update()
|
public void Update()
|
||||||
{
|
{
|
||||||
// _gamepad may be altered by other threads
|
// _gamepad may be altered by other threads
|
||||||
var gamepad = _gamepad;
|
IGamepad gamepad = _gamepad;
|
||||||
|
|
||||||
if (gamepad != null && GamepadDriver != null)
|
if (gamepad != null && GamepadDriver != null)
|
||||||
{
|
{
|
||||||
|
@ -489,7 +489,7 @@ namespace Ryujinx.Input.HLE
|
||||||
|
|
||||||
public static KeyboardInput GetHLEKeyboardInput(IGamepadDriver KeyboardDriver)
|
public static KeyboardInput GetHLEKeyboardInput(IGamepadDriver KeyboardDriver)
|
||||||
{
|
{
|
||||||
var keyboard = KeyboardDriver.GetGamepad("0") as IKeyboard;
|
IKeyboard keyboard = KeyboardDriver.GetGamepad("0") as IKeyboard;
|
||||||
|
|
||||||
KeyboardStateSnapshot keyboardState = keyboard.GetKeyboardStateSnapshot();
|
KeyboardStateSnapshot keyboardState = keyboard.GetKeyboardStateSnapshot();
|
||||||
|
|
||||||
|
|
|
@ -6,6 +6,7 @@ using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Diagnostics;
|
using System.Diagnostics;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
|
using System.Numerics;
|
||||||
using System.Runtime.CompilerServices;
|
using System.Runtime.CompilerServices;
|
||||||
using System.Threading;
|
using System.Threading;
|
||||||
using CemuHookClient = Ryujinx.Input.Motion.CemuHook.Client;
|
using CemuHookClient = Ryujinx.Input.Motion.CemuHook.Client;
|
||||||
|
@ -56,7 +57,7 @@ namespace Ryujinx.Input.HLE
|
||||||
lock (_lock)
|
lock (_lock)
|
||||||
{
|
{
|
||||||
List<InputConfig> validInputs = new();
|
List<InputConfig> validInputs = new();
|
||||||
foreach (var inputConfigEntry in _inputConfig)
|
foreach (InputConfig inputConfigEntry in _inputConfig)
|
||||||
{
|
{
|
||||||
if (_controllers[(int)inputConfigEntry.PlayerIndex] != null)
|
if (_controllers[(int)inputConfigEntry.PlayerIndex] != null)
|
||||||
{
|
{
|
||||||
|
@ -234,7 +235,7 @@ namespace Ryujinx.Input.HLE
|
||||||
|
|
||||||
isJoyconPair = inputConfig.ControllerType == ControllerType.JoyconPair;
|
isJoyconPair = inputConfig.ControllerType == ControllerType.JoyconPair;
|
||||||
|
|
||||||
var altMotionState = isJoyconPair ? controller.GetHLEMotionState(true) : default;
|
SixAxisInput altMotionState = isJoyconPair ? controller.GetHLEMotionState(true) : default;
|
||||||
|
|
||||||
motionState = (controller.GetHLEMotionState(), altMotionState);
|
motionState = (controller.GetHLEMotionState(), altMotionState);
|
||||||
}
|
}
|
||||||
|
@ -273,9 +274,9 @@ namespace Ryujinx.Input.HLE
|
||||||
|
|
||||||
if (_enableMouse)
|
if (_enableMouse)
|
||||||
{
|
{
|
||||||
var mouse = _mouseDriver.GetGamepad("0") as IMouse;
|
IMouse mouse = _mouseDriver.GetGamepad("0") as IMouse;
|
||||||
|
|
||||||
var mouseInput = IMouse.GetMouseStateSnapshot(mouse);
|
MouseStateSnapshot mouseInput = IMouse.GetMouseStateSnapshot(mouse);
|
||||||
|
|
||||||
uint buttons = 0;
|
uint buttons = 0;
|
||||||
|
|
||||||
|
@ -304,7 +305,7 @@ namespace Ryujinx.Input.HLE
|
||||||
buttons |= 1 << 4;
|
buttons |= 1 << 4;
|
||||||
}
|
}
|
||||||
|
|
||||||
var position = IMouse.GetScreenPosition(mouseInput.Position, mouse.ClientSize, aspectRatio);
|
Vector2 position = IMouse.GetScreenPosition(mouseInput.Position, mouse.ClientSize, aspectRatio);
|
||||||
|
|
||||||
_device.Hid.Mouse.Update((int)position.X, (int)position.Y, buttons, (int)mouseInput.Scroll.X, (int)mouseInput.Scroll.Y, true);
|
_device.Hid.Mouse.Update((int)position.X, (int)position.Y, buttons, (int)mouseInput.Scroll.X, (int)mouseInput.Scroll.Y, true);
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,6 +2,7 @@ using Ryujinx.HLE;
|
||||||
using Ryujinx.HLE.HOS.Services.Hid;
|
using Ryujinx.HLE.HOS.Services.Hid;
|
||||||
using Ryujinx.HLE.HOS.Services.Hid.Types.SharedMemory.TouchScreen;
|
using Ryujinx.HLE.HOS.Services.Hid.Types.SharedMemory.TouchScreen;
|
||||||
using System;
|
using System;
|
||||||
|
using System.Numerics;
|
||||||
|
|
||||||
namespace Ryujinx.Input.HLE
|
namespace Ryujinx.Input.HLE
|
||||||
{
|
{
|
||||||
|
@ -29,7 +30,7 @@ namespace Ryujinx.Input.HLE
|
||||||
if (_wasClicking && !isClicking)
|
if (_wasClicking && !isClicking)
|
||||||
{
|
{
|
||||||
MouseStateSnapshot snapshot = IMouse.GetMouseStateSnapshot(_mouse);
|
MouseStateSnapshot snapshot = IMouse.GetMouseStateSnapshot(_mouse);
|
||||||
var touchPosition = IMouse.GetScreenPosition(snapshot.Position, _mouse.ClientSize, aspectRatio);
|
Vector2 touchPosition = IMouse.GetScreenPosition(snapshot.Position, _mouse.ClientSize, aspectRatio);
|
||||||
|
|
||||||
TouchPoint currentPoint = new()
|
TouchPoint currentPoint = new()
|
||||||
{
|
{
|
||||||
|
@ -58,7 +59,7 @@ namespace Ryujinx.Input.HLE
|
||||||
if (aspectRatio > 0)
|
if (aspectRatio > 0)
|
||||||
{
|
{
|
||||||
MouseStateSnapshot snapshot = IMouse.GetMouseStateSnapshot(_mouse);
|
MouseStateSnapshot snapshot = IMouse.GetMouseStateSnapshot(_mouse);
|
||||||
var touchPosition = IMouse.GetScreenPosition(snapshot.Position, _mouse.ClientSize, aspectRatio);
|
Vector2 touchPosition = IMouse.GetScreenPosition(snapshot.Position, _mouse.ClientSize, aspectRatio);
|
||||||
|
|
||||||
TouchAttribute attribute = TouchAttribute.None;
|
TouchAttribute attribute = TouchAttribute.None;
|
||||||
|
|
||||||
|
|
|
@ -48,7 +48,7 @@ namespace Ryujinx.Input.Motion.CemuHook
|
||||||
|
|
||||||
lock (_clients)
|
lock (_clients)
|
||||||
{
|
{
|
||||||
foreach (var client in _clients)
|
foreach (KeyValuePair<int, UdpClient> client in _clients)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
@ -209,7 +209,7 @@ namespace Ryujinx.Input.Motion.CemuHook
|
||||||
{
|
{
|
||||||
client.Client.ReceiveTimeout = timeout;
|
client.Client.ReceiveTimeout = timeout;
|
||||||
|
|
||||||
var result = client?.Receive(ref endPoint);
|
byte[] result = client?.Receive(ref endPoint);
|
||||||
|
|
||||||
if (result.Length > 0)
|
if (result.Length > 0)
|
||||||
{
|
{
|
||||||
|
@ -225,7 +225,7 @@ namespace Ryujinx.Input.Motion.CemuHook
|
||||||
|
|
||||||
private void SetRetryTimer(int clientId)
|
private void SetRetryTimer(int clientId)
|
||||||
{
|
{
|
||||||
var elapsedMs = PerformanceCounter.ElapsedMilliseconds;
|
long elapsedMs = PerformanceCounter.ElapsedMilliseconds;
|
||||||
|
|
||||||
_clientRetryTimer[clientId] = elapsedMs;
|
_clientRetryTimer[clientId] = elapsedMs;
|
||||||
}
|
}
|
||||||
|
@ -338,9 +338,9 @@ namespace Ryujinx.Input.Motion.CemuHook
|
||||||
{
|
{
|
||||||
int slot = inputData.Shared.Slot;
|
int slot = inputData.Shared.Slot;
|
||||||
|
|
||||||
if (_motionData.TryGetValue(clientId, out var motionDataItem))
|
if (_motionData.TryGetValue(clientId, out Dictionary<int, MotionInput> motionDataItem))
|
||||||
{
|
{
|
||||||
if (motionDataItem.TryGetValue(slot, out var previousData))
|
if (motionDataItem.TryGetValue(slot, out MotionInput previousData))
|
||||||
{
|
{
|
||||||
previousData.Update(accelerometer, gyroscrope, timestamp, cemuHookConfig.Sensitivity, (float)cemuHookConfig.GyroDeadzone);
|
previousData.Update(accelerometer, gyroscrope, timestamp, cemuHookConfig.Sensitivity, (float)cemuHookConfig.GyroDeadzone);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue