Adjust naming conventions and general refactoring in HLE Project (#490)
* Rename enum fields
* Naming conventions
* Remove unneeded ".this"
* Remove unneeded semicolons
* Remove unused Usings
* Don't use var
* Remove unneeded enum underlying types
* Explicitly label class visibility
* Remove unneeded @ prefixes
* Remove unneeded commas
* Remove unneeded if expressions
* Method doesn't use unsafe code
* Remove unneeded casts
* Initialized objects don't need an empty constructor
* Remove settings from DotSettings
* Revert "Explicitly label class visibility"
This reverts commit ad5eb5787c
.
* Small changes
* Revert external enum renaming
* Changes from feedback
* Remove unneeded property setters
This commit is contained in:
@ -5,130 +5,130 @@ namespace Ryujinx.HLE.Input
|
||||
{
|
||||
public partial class Hid
|
||||
{
|
||||
private Switch Device;
|
||||
private Switch _device;
|
||||
|
||||
public HidControllerBase PrimaryController { get; private set; }
|
||||
|
||||
internal long HidPosition;
|
||||
|
||||
public Hid(Switch Device, long HidPosition)
|
||||
public Hid(Switch device, long hidPosition)
|
||||
{
|
||||
this.Device = Device;
|
||||
this.HidPosition = HidPosition;
|
||||
_device = device;
|
||||
HidPosition = hidPosition;
|
||||
|
||||
Device.Memory.FillWithZeros(HidPosition, Horizon.HidSize);
|
||||
device.Memory.FillWithZeros(hidPosition, Horizon.HidSize);
|
||||
}
|
||||
|
||||
public void InitilizePrimaryController(HidControllerType ControllerType)
|
||||
public void InitilizePrimaryController(HidControllerType controllerType)
|
||||
{
|
||||
HidControllerId ControllerId = ControllerType == HidControllerType.Handheld ?
|
||||
HidControllerId.CONTROLLER_HANDHELD : HidControllerId.CONTROLLER_PLAYER_1;
|
||||
HidControllerId controllerId = controllerType == HidControllerType.Handheld ?
|
||||
HidControllerId.ControllerHandheld : HidControllerId.ControllerPlayer1;
|
||||
|
||||
if (ControllerType == HidControllerType.ProController)
|
||||
if (controllerType == HidControllerType.ProController)
|
||||
{
|
||||
PrimaryController = new HidProController(Device);
|
||||
PrimaryController = new HidProController(_device);
|
||||
}
|
||||
else
|
||||
{
|
||||
PrimaryController = new HidNpadController(ControllerType,
|
||||
Device,
|
||||
(NpadColor.Body_Neon_Red, NpadColor.Body_Neon_Red),
|
||||
(NpadColor.Buttons_Neon_Blue, NpadColor.Buttons_Neon_Blue));
|
||||
PrimaryController = new HidNpadController(controllerType,
|
||||
_device,
|
||||
(NpadColor.BodyNeonRed, NpadColor.BodyNeonRed),
|
||||
(NpadColor.ButtonsNeonBlue, NpadColor.ButtonsNeonBlue));
|
||||
}
|
||||
|
||||
PrimaryController.Connect(ControllerId);
|
||||
PrimaryController.Connect(controllerId);
|
||||
}
|
||||
|
||||
private HidControllerButtons UpdateStickButtons(
|
||||
HidJoystickPosition LeftStick,
|
||||
HidJoystickPosition RightStick)
|
||||
HidJoystickPosition leftStick,
|
||||
HidJoystickPosition rightStick)
|
||||
{
|
||||
HidControllerButtons Result = 0;
|
||||
HidControllerButtons result = 0;
|
||||
|
||||
if (RightStick.DX < 0)
|
||||
if (rightStick.Dx < 0)
|
||||
{
|
||||
Result |= HidControllerButtons.RStickLeft;
|
||||
result |= HidControllerButtons.RStickLeft;
|
||||
}
|
||||
|
||||
if (RightStick.DX > 0)
|
||||
if (rightStick.Dx > 0)
|
||||
{
|
||||
Result |= HidControllerButtons.RStickRight;
|
||||
result |= HidControllerButtons.RStickRight;
|
||||
}
|
||||
|
||||
if (RightStick.DY < 0)
|
||||
if (rightStick.Dy < 0)
|
||||
{
|
||||
Result |= HidControllerButtons.RStickDown;
|
||||
result |= HidControllerButtons.RStickDown;
|
||||
}
|
||||
|
||||
if (RightStick.DY > 0)
|
||||
if (rightStick.Dy > 0)
|
||||
{
|
||||
Result |= HidControllerButtons.RStickUp;
|
||||
result |= HidControllerButtons.RStickUp;
|
||||
}
|
||||
|
||||
if (LeftStick.DX < 0)
|
||||
if (leftStick.Dx < 0)
|
||||
{
|
||||
Result |= HidControllerButtons.LStickLeft;
|
||||
result |= HidControllerButtons.LStickLeft;
|
||||
}
|
||||
|
||||
if (LeftStick.DX > 0)
|
||||
if (leftStick.Dx > 0)
|
||||
{
|
||||
Result |= HidControllerButtons.LStickRight;
|
||||
result |= HidControllerButtons.LStickRight;
|
||||
}
|
||||
|
||||
if (LeftStick.DY < 0)
|
||||
if (leftStick.Dy < 0)
|
||||
{
|
||||
Result |= HidControllerButtons.LStickDown;
|
||||
result |= HidControllerButtons.LStickDown;
|
||||
}
|
||||
|
||||
if (LeftStick.DY > 0)
|
||||
if (leftStick.Dy > 0)
|
||||
{
|
||||
Result |= HidControllerButtons.LStickUp;
|
||||
result |= HidControllerButtons.LStickUp;
|
||||
}
|
||||
|
||||
return Result;
|
||||
return result;
|
||||
}
|
||||
|
||||
public void SetTouchPoints(params HidTouchPoint[] Points)
|
||||
public void SetTouchPoints(params HidTouchPoint[] points)
|
||||
{
|
||||
long TouchScreenOffset = HidPosition + HidTouchScreenOffset;
|
||||
long LastEntry = Device.Memory.ReadInt64(TouchScreenOffset + 0x10);
|
||||
long CurrEntry = (LastEntry + 1) % HidEntryCount;
|
||||
long Timestamp = GetTimestamp();
|
||||
long touchScreenOffset = HidPosition + HidTouchScreenOffset;
|
||||
long lastEntry = _device.Memory.ReadInt64(touchScreenOffset + 0x10);
|
||||
long currEntry = (lastEntry + 1) % HidEntryCount;
|
||||
long timestamp = GetTimestamp();
|
||||
|
||||
Device.Memory.WriteInt64(TouchScreenOffset + 0x00, Timestamp);
|
||||
Device.Memory.WriteInt64(TouchScreenOffset + 0x08, HidEntryCount);
|
||||
Device.Memory.WriteInt64(TouchScreenOffset + 0x10, CurrEntry);
|
||||
Device.Memory.WriteInt64(TouchScreenOffset + 0x18, HidEntryCount - 1);
|
||||
Device.Memory.WriteInt64(TouchScreenOffset + 0x20, Timestamp);
|
||||
_device.Memory.WriteInt64(touchScreenOffset + 0x00, timestamp);
|
||||
_device.Memory.WriteInt64(touchScreenOffset + 0x08, HidEntryCount);
|
||||
_device.Memory.WriteInt64(touchScreenOffset + 0x10, currEntry);
|
||||
_device.Memory.WriteInt64(touchScreenOffset + 0x18, HidEntryCount - 1);
|
||||
_device.Memory.WriteInt64(touchScreenOffset + 0x20, timestamp);
|
||||
|
||||
long TouchEntryOffset = TouchScreenOffset + HidTouchHeaderSize;
|
||||
long LastEntryOffset = TouchEntryOffset + LastEntry * HidTouchEntrySize;
|
||||
long SampleCounter = Device.Memory.ReadInt64(LastEntryOffset) + 1;
|
||||
long touchEntryOffset = touchScreenOffset + HidTouchHeaderSize;
|
||||
long lastEntryOffset = touchEntryOffset + lastEntry * HidTouchEntrySize;
|
||||
long sampleCounter = _device.Memory.ReadInt64(lastEntryOffset) + 1;
|
||||
|
||||
TouchEntryOffset += CurrEntry * HidTouchEntrySize;
|
||||
touchEntryOffset += currEntry * HidTouchEntrySize;
|
||||
|
||||
Device.Memory.WriteInt64(TouchEntryOffset + 0x00, SampleCounter);
|
||||
Device.Memory.WriteInt64(TouchEntryOffset + 0x08, Points.Length);
|
||||
_device.Memory.WriteInt64(touchEntryOffset + 0x00, sampleCounter);
|
||||
_device.Memory.WriteInt64(touchEntryOffset + 0x08, points.Length);
|
||||
|
||||
TouchEntryOffset += HidTouchEntryHeaderSize;
|
||||
touchEntryOffset += HidTouchEntryHeaderSize;
|
||||
|
||||
const int Padding = 0;
|
||||
const int padding = 0;
|
||||
|
||||
int Index = 0;
|
||||
int index = 0;
|
||||
|
||||
foreach (HidTouchPoint Point in Points)
|
||||
foreach (HidTouchPoint point in points)
|
||||
{
|
||||
Device.Memory.WriteInt64(TouchEntryOffset + 0x00, SampleCounter);
|
||||
Device.Memory.WriteInt32(TouchEntryOffset + 0x08, Padding);
|
||||
Device.Memory.WriteInt32(TouchEntryOffset + 0x0c, Index++);
|
||||
Device.Memory.WriteInt32(TouchEntryOffset + 0x10, Point.X);
|
||||
Device.Memory.WriteInt32(TouchEntryOffset + 0x14, Point.Y);
|
||||
Device.Memory.WriteInt32(TouchEntryOffset + 0x18, Point.DiameterX);
|
||||
Device.Memory.WriteInt32(TouchEntryOffset + 0x1c, Point.DiameterY);
|
||||
Device.Memory.WriteInt32(TouchEntryOffset + 0x20, Point.Angle);
|
||||
Device.Memory.WriteInt32(TouchEntryOffset + 0x24, Padding);
|
||||
_device.Memory.WriteInt64(touchEntryOffset + 0x00, sampleCounter);
|
||||
_device.Memory.WriteInt32(touchEntryOffset + 0x08, padding);
|
||||
_device.Memory.WriteInt32(touchEntryOffset + 0x0c, index++);
|
||||
_device.Memory.WriteInt32(touchEntryOffset + 0x10, point.X);
|
||||
_device.Memory.WriteInt32(touchEntryOffset + 0x14, point.Y);
|
||||
_device.Memory.WriteInt32(touchEntryOffset + 0x18, point.DiameterX);
|
||||
_device.Memory.WriteInt32(touchEntryOffset + 0x1c, point.DiameterY);
|
||||
_device.Memory.WriteInt32(touchEntryOffset + 0x20, point.Angle);
|
||||
_device.Memory.WriteInt32(touchEntryOffset + 0x24, padding);
|
||||
|
||||
TouchEntryOffset += HidTouchEntryTouchSize;
|
||||
touchEntryOffset += HidTouchEntryTouchSize;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -11,18 +11,18 @@ namespace Ryujinx.HLE.Input
|
||||
public long Offset { get; private set; }
|
||||
public bool Connected { get; protected set; }
|
||||
|
||||
public HidControllerBase(HidControllerType ControllerType, Switch Device)
|
||||
public HidControllerBase(HidControllerType controllerType, Switch device)
|
||||
{
|
||||
this.Device = Device;
|
||||
Device = device;
|
||||
|
||||
HidControllerType = ControllerType;
|
||||
HidControllerType = controllerType;
|
||||
}
|
||||
|
||||
public virtual void Connect(HidControllerId ControllerId)
|
||||
public virtual void Connect(HidControllerId controllerId)
|
||||
{
|
||||
this.ControllerId = ControllerId;
|
||||
ControllerId = controllerId;
|
||||
|
||||
Offset = Device.Hid.HidPosition + HidControllersOffset + (int)ControllerId * HidControllerSize;
|
||||
Offset = Device.Hid.HidPosition + HidControllersOffset + (int)controllerId * HidControllerSize;
|
||||
|
||||
Device.Memory.FillWithZeros(Offset, 0x5000);
|
||||
|
||||
@ -30,47 +30,47 @@ namespace Ryujinx.HLE.Input
|
||||
}
|
||||
|
||||
public abstract void SendInput(
|
||||
HidControllerButtons Buttons,
|
||||
HidJoystickPosition LeftStick,
|
||||
HidJoystickPosition RightStick);
|
||||
HidControllerButtons buttons,
|
||||
HidJoystickPosition leftStick,
|
||||
HidJoystickPosition rightStick);
|
||||
|
||||
protected long WriteInput(
|
||||
HidControllerButtons Buttons,
|
||||
HidJoystickPosition LeftStick,
|
||||
HidJoystickPosition RightStick,
|
||||
HidControllerLayouts ControllerLayout)
|
||||
HidControllerButtons buttons,
|
||||
HidJoystickPosition leftStick,
|
||||
HidJoystickPosition rightStick,
|
||||
HidControllerLayouts controllerLayout)
|
||||
{
|
||||
long ControllerOffset = Offset + HidControllerHeaderSize;
|
||||
long controllerOffset = Offset + HidControllerHeaderSize;
|
||||
|
||||
ControllerOffset += (int)ControllerLayout * HidControllerLayoutsSize;
|
||||
controllerOffset += (int)controllerLayout * HidControllerLayoutsSize;
|
||||
|
||||
long LastEntry = Device.Memory.ReadInt64(ControllerOffset + 0x10);
|
||||
long CurrEntry = (LastEntry + 1) % HidEntryCount;
|
||||
long Timestamp = GetTimestamp();
|
||||
long lastEntry = Device.Memory.ReadInt64(controllerOffset + 0x10);
|
||||
long currEntry = (lastEntry + 1) % HidEntryCount;
|
||||
long timestamp = GetTimestamp();
|
||||
|
||||
Device.Memory.WriteInt64(ControllerOffset + 0x00, Timestamp);
|
||||
Device.Memory.WriteInt64(ControllerOffset + 0x08, HidEntryCount);
|
||||
Device.Memory.WriteInt64(ControllerOffset + 0x10, CurrEntry);
|
||||
Device.Memory.WriteInt64(ControllerOffset + 0x18, HidEntryCount - 1);
|
||||
Device.Memory.WriteInt64(controllerOffset + 0x00, timestamp);
|
||||
Device.Memory.WriteInt64(controllerOffset + 0x08, HidEntryCount);
|
||||
Device.Memory.WriteInt64(controllerOffset + 0x10, currEntry);
|
||||
Device.Memory.WriteInt64(controllerOffset + 0x18, HidEntryCount - 1);
|
||||
|
||||
ControllerOffset += HidControllersLayoutHeaderSize;
|
||||
controllerOffset += HidControllersLayoutHeaderSize;
|
||||
|
||||
long LastEntryOffset = ControllerOffset + LastEntry * HidControllersInputEntrySize;
|
||||
long lastEntryOffset = controllerOffset + lastEntry * HidControllersInputEntrySize;
|
||||
|
||||
ControllerOffset += CurrEntry * HidControllersInputEntrySize;
|
||||
controllerOffset += currEntry * HidControllersInputEntrySize;
|
||||
|
||||
long SampleCounter = Device.Memory.ReadInt64(LastEntryOffset) + 1;
|
||||
long sampleCounter = Device.Memory.ReadInt64(lastEntryOffset) + 1;
|
||||
|
||||
Device.Memory.WriteInt64(ControllerOffset + 0x00, SampleCounter);
|
||||
Device.Memory.WriteInt64(ControllerOffset + 0x08, SampleCounter);
|
||||
Device.Memory.WriteInt64(ControllerOffset + 0x10, (uint)Buttons);
|
||||
Device.Memory.WriteInt64(controllerOffset + 0x00, sampleCounter);
|
||||
Device.Memory.WriteInt64(controllerOffset + 0x08, sampleCounter);
|
||||
Device.Memory.WriteInt64(controllerOffset + 0x10, (uint)buttons);
|
||||
|
||||
Device.Memory.WriteInt32(ControllerOffset + 0x18, LeftStick.DX);
|
||||
Device.Memory.WriteInt32(ControllerOffset + 0x1c, LeftStick.DY);
|
||||
Device.Memory.WriteInt32(ControllerOffset + 0x20, RightStick.DX);
|
||||
Device.Memory.WriteInt32(ControllerOffset + 0x24, RightStick.DY);
|
||||
Device.Memory.WriteInt32(controllerOffset + 0x18, leftStick.Dx);
|
||||
Device.Memory.WriteInt32(controllerOffset + 0x1c, leftStick.Dy);
|
||||
Device.Memory.WriteInt32(controllerOffset + 0x20, rightStick.Dx);
|
||||
Device.Memory.WriteInt32(controllerOffset + 0x24, rightStick.Dy);
|
||||
|
||||
return ControllerOffset;
|
||||
return controllerOffset;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -5,6 +5,6 @@ namespace Ryujinx.HLE.Input
|
||||
[Flags]
|
||||
public enum HidControllerColorDesc
|
||||
{
|
||||
ColorDesc_ColorsNonexistent = (1 << 1)
|
||||
ColorDescColorsNonexistent = (1 << 1)
|
||||
}
|
||||
}
|
@ -5,7 +5,7 @@ namespace Ryujinx.HLE.Input
|
||||
[Flags]
|
||||
public enum HidControllerConnState
|
||||
{
|
||||
Controller_State_Connected = (1 << 0),
|
||||
Controller_State_Wired = (1 << 1)
|
||||
ControllerStateConnected = (1 << 0),
|
||||
ControllerStateWired = (1 << 1)
|
||||
}
|
||||
}
|
@ -2,15 +2,15 @@ namespace Ryujinx.HLE.Input
|
||||
{
|
||||
public enum HidControllerId
|
||||
{
|
||||
CONTROLLER_PLAYER_1 = 0,
|
||||
CONTROLLER_PLAYER_2 = 1,
|
||||
CONTROLLER_PLAYER_3 = 2,
|
||||
CONTROLLER_PLAYER_4 = 3,
|
||||
CONTROLLER_PLAYER_5 = 4,
|
||||
CONTROLLER_PLAYER_6 = 5,
|
||||
CONTROLLER_PLAYER_7 = 6,
|
||||
CONTROLLER_PLAYER_8 = 7,
|
||||
CONTROLLER_HANDHELD = 8,
|
||||
CONTROLLER_UNKNOWN = 9
|
||||
ControllerPlayer1 = 0,
|
||||
ControllerPlayer2 = 1,
|
||||
ControllerPlayer3 = 2,
|
||||
ControllerPlayer4 = 3,
|
||||
ControllerPlayer5 = 4,
|
||||
ControllerPlayer6 = 5,
|
||||
ControllerPlayer7 = 6,
|
||||
ControllerPlayer8 = 7,
|
||||
ControllerHandheld = 8,
|
||||
ControllerUnknown = 9
|
||||
}
|
||||
}
|
@ -2,12 +2,12 @@ namespace Ryujinx.HLE.Input
|
||||
{
|
||||
public enum HidControllerLayouts
|
||||
{
|
||||
Pro_Controller = 0,
|
||||
Handheld_Joined = 1,
|
||||
Joined = 2,
|
||||
Left = 3,
|
||||
Right = 4,
|
||||
Main_No_Analog = 5,
|
||||
Main = 6
|
||||
ProController = 0,
|
||||
HandheldJoined = 1,
|
||||
Joined = 2,
|
||||
Left = 3,
|
||||
Right = 4,
|
||||
MainNoAnalog = 5,
|
||||
Main = 6
|
||||
}
|
||||
}
|
@ -2,7 +2,7 @@ namespace Ryujinx.HLE.Input
|
||||
{
|
||||
public struct HidJoystickPosition
|
||||
{
|
||||
public int DX;
|
||||
public int DY;
|
||||
public int Dx;
|
||||
public int Dy;
|
||||
}
|
||||
}
|
@ -2,85 +2,85 @@
|
||||
{
|
||||
public class HidNpadController : HidControllerBase
|
||||
{
|
||||
private (NpadColor Left, NpadColor Right) NpadBodyColors;
|
||||
private (NpadColor Left, NpadColor Right) NpadButtonColors;
|
||||
private (NpadColor Left, NpadColor Right) _npadBodyColors;
|
||||
private (NpadColor Left, NpadColor Right) _npadButtonColors;
|
||||
|
||||
private HidControllerLayouts CurrentLayout;
|
||||
private HidControllerLayouts _currentLayout;
|
||||
|
||||
private bool IsHalf;
|
||||
private bool _isHalf;
|
||||
|
||||
public HidNpadController(
|
||||
HidControllerType ControllerType,
|
||||
Switch Device,
|
||||
(NpadColor, NpadColor) NpadBodyColors,
|
||||
(NpadColor, NpadColor) NpadButtonColors) : base(ControllerType, Device)
|
||||
HidControllerType controllerType,
|
||||
Switch device,
|
||||
(NpadColor, NpadColor) npadBodyColors,
|
||||
(NpadColor, NpadColor) npadButtonColors) : base(controllerType, device)
|
||||
{
|
||||
this.NpadBodyColors = NpadBodyColors;
|
||||
this.NpadButtonColors = NpadButtonColors;
|
||||
_npadBodyColors = npadBodyColors;
|
||||
_npadButtonColors = npadButtonColors;
|
||||
|
||||
CurrentLayout = HidControllerLayouts.Handheld_Joined;
|
||||
_currentLayout = HidControllerLayouts.HandheldJoined;
|
||||
|
||||
switch (ControllerType)
|
||||
switch (controllerType)
|
||||
{
|
||||
case HidControllerType.NpadLeft:
|
||||
CurrentLayout = HidControllerLayouts.Left;
|
||||
_currentLayout = HidControllerLayouts.Left;
|
||||
break;
|
||||
case HidControllerType.NpadRight:
|
||||
CurrentLayout = HidControllerLayouts.Right;
|
||||
_currentLayout = HidControllerLayouts.Right;
|
||||
break;
|
||||
case HidControllerType.NpadPair:
|
||||
CurrentLayout = HidControllerLayouts.Joined;
|
||||
_currentLayout = HidControllerLayouts.Joined;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
public override void Connect(HidControllerId ControllerId)
|
||||
public override void Connect(HidControllerId controllerId)
|
||||
{
|
||||
if(HidControllerType != HidControllerType.NpadLeft && HidControllerType != HidControllerType.NpadRight)
|
||||
{
|
||||
IsHalf = false;
|
||||
_isHalf = false;
|
||||
}
|
||||
|
||||
base.Connect(CurrentLayout == HidControllerLayouts.Handheld_Joined ? HidControllerId.CONTROLLER_HANDHELD : ControllerId);
|
||||
base.Connect(_currentLayout == HidControllerLayouts.HandheldJoined ? HidControllerId.ControllerHandheld : controllerId);
|
||||
|
||||
HidControllerColorDesc SingleColorDesc =
|
||||
HidControllerColorDesc.ColorDesc_ColorsNonexistent;
|
||||
HidControllerColorDesc singleColorDesc =
|
||||
HidControllerColorDesc.ColorDescColorsNonexistent;
|
||||
|
||||
HidControllerColorDesc SplitColorDesc = 0;
|
||||
HidControllerColorDesc splitColorDesc = 0;
|
||||
|
||||
NpadColor SingleColorBody = NpadColor.Black;
|
||||
NpadColor SingleColorButtons = NpadColor.Black;
|
||||
NpadColor singleColorBody = NpadColor.Black;
|
||||
NpadColor singleColorButtons = NpadColor.Black;
|
||||
|
||||
Device.Memory.WriteInt32(Offset + 0x04, IsHalf ? 1 : 0);
|
||||
Device.Memory.WriteInt32(Offset + 0x04, _isHalf ? 1 : 0);
|
||||
|
||||
if (IsHalf)
|
||||
if (_isHalf)
|
||||
{
|
||||
Device.Memory.WriteInt32(Offset + 0x08, (int)SingleColorDesc);
|
||||
Device.Memory.WriteInt32(Offset + 0x0c, (int)SingleColorBody);
|
||||
Device.Memory.WriteInt32(Offset + 0x10, (int)SingleColorButtons);
|
||||
Device.Memory.WriteInt32(Offset + 0x14, (int)SplitColorDesc);
|
||||
Device.Memory.WriteInt32(Offset + 0x08, (int)singleColorDesc);
|
||||
Device.Memory.WriteInt32(Offset + 0x0c, (int)singleColorBody);
|
||||
Device.Memory.WriteInt32(Offset + 0x10, (int)singleColorButtons);
|
||||
Device.Memory.WriteInt32(Offset + 0x14, (int)splitColorDesc);
|
||||
}
|
||||
else
|
||||
{
|
||||
Device.Memory.WriteInt32(Offset + 0x18, (int)NpadBodyColors.Left);
|
||||
Device.Memory.WriteInt32(Offset + 0x1c, (int)NpadButtonColors.Left);
|
||||
Device.Memory.WriteInt32(Offset + 0x20, (int)NpadBodyColors.Right);
|
||||
Device.Memory.WriteInt32(Offset + 0x24, (int)NpadButtonColors.Right);
|
||||
Device.Memory.WriteInt32(Offset + 0x18, (int)_npadBodyColors.Left);
|
||||
Device.Memory.WriteInt32(Offset + 0x1c, (int)_npadButtonColors.Left);
|
||||
Device.Memory.WriteInt32(Offset + 0x20, (int)_npadBodyColors.Right);
|
||||
Device.Memory.WriteInt32(Offset + 0x24, (int)_npadButtonColors.Right);
|
||||
}
|
||||
|
||||
Connected = true;
|
||||
}
|
||||
|
||||
public override void SendInput
|
||||
(HidControllerButtons Buttons,
|
||||
HidJoystickPosition LeftStick,
|
||||
HidJoystickPosition RightStick)
|
||||
(HidControllerButtons buttons,
|
||||
HidJoystickPosition leftStick,
|
||||
HidJoystickPosition rightStick)
|
||||
{
|
||||
long ControllerOffset = WriteInput(Buttons, LeftStick, RightStick, CurrentLayout);
|
||||
long controllerOffset = WriteInput(buttons, leftStick, rightStick, _currentLayout);
|
||||
|
||||
Device.Memory.WriteInt64(ControllerOffset + 0x28,
|
||||
(Connected ? (uint)HidControllerConnState.Controller_State_Connected : 0) |
|
||||
(CurrentLayout == HidControllerLayouts.Handheld_Joined ? (uint)HidControllerConnState.Controller_State_Wired : 0));
|
||||
Device.Memory.WriteInt64(controllerOffset + 0x28,
|
||||
(Connected ? (uint)HidControllerConnState.ControllerStateConnected : 0) |
|
||||
(_currentLayout == HidControllerLayouts.HandheldJoined ? (uint)HidControllerConnState.ControllerStateWired : 0));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -2,43 +2,43 @@
|
||||
{
|
||||
public class HidProController : HidControllerBase
|
||||
{
|
||||
bool Wired = false;
|
||||
bool _wired = false;
|
||||
|
||||
public HidProController(Switch Device) : base(HidControllerType.ProController, Device)
|
||||
public HidProController(Switch device) : base(HidControllerType.ProController, device)
|
||||
{
|
||||
Wired = true;
|
||||
_wired = true;
|
||||
}
|
||||
|
||||
public override void Connect(HidControllerId ControllerId)
|
||||
public override void Connect(HidControllerId controllerId)
|
||||
{
|
||||
base.Connect(ControllerId);
|
||||
base.Connect(controllerId);
|
||||
|
||||
HidControllerColorDesc SingleColorDesc =
|
||||
HidControllerColorDesc.ColorDesc_ColorsNonexistent;
|
||||
HidControllerColorDesc singleColorDesc =
|
||||
HidControllerColorDesc.ColorDescColorsNonexistent;
|
||||
|
||||
HidControllerColorDesc SplitColorDesc = 0;
|
||||
HidControllerColorDesc splitColorDesc = 0;
|
||||
|
||||
NpadColor SingleColorBody = NpadColor.Black;
|
||||
NpadColor SingleColorButtons = NpadColor.Black;
|
||||
NpadColor singleColorBody = NpadColor.Black;
|
||||
NpadColor singleColorButtons = NpadColor.Black;
|
||||
|
||||
Device.Memory.WriteInt32(Offset + 0x08, (int)SingleColorDesc);
|
||||
Device.Memory.WriteInt32(Offset + 0x0c, (int)SingleColorBody);
|
||||
Device.Memory.WriteInt32(Offset + 0x10, (int)SingleColorButtons);
|
||||
Device.Memory.WriteInt32(Offset + 0x14, (int)SplitColorDesc);
|
||||
Device.Memory.WriteInt32(Offset + 0x08, (int)singleColorDesc);
|
||||
Device.Memory.WriteInt32(Offset + 0x0c, (int)singleColorBody);
|
||||
Device.Memory.WriteInt32(Offset + 0x10, (int)singleColorButtons);
|
||||
Device.Memory.WriteInt32(Offset + 0x14, (int)splitColorDesc);
|
||||
|
||||
Connected = true;
|
||||
}
|
||||
|
||||
public override void SendInput(
|
||||
HidControllerButtons Buttons,
|
||||
HidJoystickPosition LeftStick,
|
||||
HidJoystickPosition RightStick)
|
||||
HidControllerButtons buttons,
|
||||
HidJoystickPosition leftStick,
|
||||
HidJoystickPosition rightStick)
|
||||
{
|
||||
long ControllerOffset = WriteInput(Buttons, LeftStick, RightStick, HidControllerLayouts.Pro_Controller);
|
||||
long controllerOffset = WriteInput(buttons, leftStick, rightStick, HidControllerLayouts.ProController);
|
||||
|
||||
Device.Memory.WriteInt64(ControllerOffset + 0x28,
|
||||
(Connected ? (uint)HidControllerConnState.Controller_State_Connected : 0) |
|
||||
(Wired ? (uint)HidControllerConnState.Controller_State_Wired : 0));
|
||||
Device.Memory.WriteInt64(controllerOffset + 0x28,
|
||||
(Connected ? (uint)HidControllerConnState.ControllerStateConnected : 0) |
|
||||
(_wired ? (uint)HidControllerConnState.ControllerStateWired : 0));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,8 +1,4 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
namespace Ryujinx.HLE.Input
|
||||
namespace Ryujinx.HLE.Input
|
||||
{
|
||||
public partial class Hid
|
||||
{
|
||||
|
@ -1,8 +1,4 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
namespace Ryujinx.HLE.Input
|
||||
namespace Ryujinx.HLE.Input
|
||||
{
|
||||
interface IHidDevice
|
||||
{
|
||||
|
@ -4,20 +4,20 @@ namespace Ryujinx.HLE.Input
|
||||
{
|
||||
Black = 0,
|
||||
|
||||
Body_Grey = 0x828282,
|
||||
Body_Neon_Blue = 0x0AB9E6,
|
||||
Body_Neon_Red = 0xFF3C28,
|
||||
Body_Neon_Yellow = 0xE6FF00,
|
||||
Body_Neon_Pink = 0xFF3278,
|
||||
Body_Neon_Green = 0x1EDC00,
|
||||
Body_Red = 0xE10F00,
|
||||
BodyGrey = 0x828282,
|
||||
BodyNeonBlue = 0x0AB9E6,
|
||||
BodyNeonRed = 0xFF3C28,
|
||||
BodyNeonYellow = 0xE6FF00,
|
||||
BodyNeonPink = 0xFF3278,
|
||||
BodyNeonGreen = 0x1EDC00,
|
||||
BodyRed = 0xE10F00,
|
||||
|
||||
Buttons_Grey = 0x0F0F0F,
|
||||
Buttons_Neon_Blue = 0x001E1E,
|
||||
Buttons_Neon_Red = 0x1E0A0A,
|
||||
Buttons_Neon_Yellow = 0x142800,
|
||||
Buttons_Neon_Pink = 0x28001E,
|
||||
Buttons_Neon_Green = 0x002800,
|
||||
Buttons_Red = 0x280A0A
|
||||
ButtonsGrey = 0x0F0F0F,
|
||||
ButtonsNeonBlue = 0x001E1E,
|
||||
ButtonsNeonRed = 0x1E0A0A,
|
||||
ButtonsNeonYellow = 0x142800,
|
||||
ButtonsNeonPink = 0x28001E,
|
||||
ButtonsNeonGreen = 0x002800,
|
||||
ButtonsRed = 0x280A0A
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user