misc: chore: Use explicit types & fix object creation

This commit is contained in:
KeatonTheBot committed 2026-05-30 16:26:50 -05:00
1 parent 9d3fecf334
commit 76a123b81d
454 files changed
+3042 -2961

No files matched your search

@@ -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}");
}
+2 -2
View File
@@ -281,7 +281,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)
{
@@ -508,7 +508,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();
+6 -5
View File
@@ -7,6 +7,7 @@ using System.Buffers;
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;
@@ -60,7 +61,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)
{
@@ -238,7 +239,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);
}
@@ -277,9 +278,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;
@@ -310,7 +311,7 @@ namespace Ryujinx.Input.HLE
if (mouse != null)
{
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);
+3 -2
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;
+5 -5
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);
}