misc: chore: Use explicit types in input projects

This commit is contained in:
Evan Husted 2025-01-25 14:09:05 -06:00
parent 1712d69dcd
commit ac401034d7
8 changed files with 20 additions and 18 deletions

View file

@ -373,7 +373,7 @@ namespace Ryujinx.Input.SDL2
if (HasConfiguration)
{
var joyconStickConfig = GetLogicalJoyStickConfig(inputId);
JoyconConfigControllerStick<GamepadInputId, Common.Configuration.Hid.Controller.StickInputId> joyconStickConfig = GetLogicalJoyStickConfig(inputId);
if (joyconStickConfig != null)
{

View file

@ -55,7 +55,7 @@ namespace Ryujinx.Input.SDL2
public IEnumerable<IGamepad> GetGamepads()
{
foreach (var keyboardId in _keyboardIdentifers)
foreach (string keyboardId in _keyboardIdentifers)
{
yield return GetGamepad(keyboardId);
}

View file

@ -144,7 +144,7 @@ namespace Ryujinx.Input.Assigner
{
StringWriter writer = new();
foreach (var kvp in _stats)
foreach (KeyValuePair<GamepadButtonInputId, InputSummary> kvp in _stats)
{
writer.WriteLine($"Button {kvp.Key} -> {kvp.Value}");
}

View file

@ -49,7 +49,7 @@ namespace Ryujinx.Input
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public (float, float) GetStick(StickInputId inputId)
{
var result = _joysticksState[(int)inputId];
Array2<float> result = _joysticksState[(int)inputId];
return (result[0], result[1]);
}

View file

@ -276,7 +276,7 @@ namespace Ryujinx.Input.HLE
public void Update()
{
// _gamepad may be altered by other threads
var gamepad = _gamepad;
IGamepad gamepad = _gamepad;
if (gamepad != null && GamepadDriver != null)
{
@ -489,7 +489,7 @@ namespace Ryujinx.Input.HLE
public static KeyboardInput GetHLEKeyboardInput(IGamepadDriver KeyboardDriver)
{
var keyboard = KeyboardDriver.GetGamepad("0") as IKeyboard;
IKeyboard keyboard = KeyboardDriver.GetGamepad("0") as IKeyboard;
KeyboardStateSnapshot keyboardState = keyboard.GetKeyboardStateSnapshot();

View file

@ -6,6 +6,7 @@ using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Numerics;
using System.Runtime.CompilerServices;
using System.Threading;
using CemuHookClient = Ryujinx.Input.Motion.CemuHook.Client;
@ -56,7 +57,7 @@ namespace Ryujinx.Input.HLE
lock (_lock)
{
List<InputConfig> validInputs = new();
foreach (var inputConfigEntry in _inputConfig)
foreach (InputConfig inputConfigEntry in _inputConfig)
{
if (_controllers[(int)inputConfigEntry.PlayerIndex] != null)
{
@ -234,7 +235,7 @@ namespace Ryujinx.Input.HLE
isJoyconPair = inputConfig.ControllerType == ControllerType.JoyconPair;
var altMotionState = isJoyconPair ? controller.GetHLEMotionState(true) : default;
SixAxisInput altMotionState = isJoyconPair ? controller.GetHLEMotionState(true) : default;
motionState = (controller.GetHLEMotionState(), altMotionState);
}
@ -273,9 +274,9 @@ namespace Ryujinx.Input.HLE
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;
@ -304,7 +305,7 @@ namespace Ryujinx.Input.HLE
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);
}

View file

@ -2,6 +2,7 @@ using Ryujinx.HLE;
using Ryujinx.HLE.HOS.Services.Hid;
using Ryujinx.HLE.HOS.Services.Hid.Types.SharedMemory.TouchScreen;
using System;
using System.Numerics;
namespace Ryujinx.Input.HLE
{
@ -29,7 +30,7 @@ namespace Ryujinx.Input.HLE
if (_wasClicking && !isClicking)
{
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()
{
@ -58,7 +59,7 @@ namespace Ryujinx.Input.HLE
if (aspectRatio > 0)
{
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;

View file

@ -48,7 +48,7 @@ namespace Ryujinx.Input.Motion.CemuHook
lock (_clients)
{
foreach (var client in _clients)
foreach (KeyValuePair<int, UdpClient> client in _clients)
{
try
{
@ -209,7 +209,7 @@ namespace Ryujinx.Input.Motion.CemuHook
{
client.Client.ReceiveTimeout = timeout;
var result = client?.Receive(ref endPoint);
byte[] result = client?.Receive(ref endPoint);
if (result.Length > 0)
{
@ -225,7 +225,7 @@ namespace Ryujinx.Input.Motion.CemuHook
private void SetRetryTimer(int clientId)
{
var elapsedMs = PerformanceCounter.ElapsedMilliseconds;
long elapsedMs = PerformanceCounter.ElapsedMilliseconds;
_clientRetryTimer[clientId] = elapsedMs;
}
@ -338,9 +338,9 @@ namespace Ryujinx.Input.Motion.CemuHook
{
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);
}