Refactored all of the button mapping code

This commit is contained in:
John Clemis 2018-06-28 08:59:36 -05:00
parent b805f2171f
commit 60ad45cc29
8 changed files with 352 additions and 238 deletions

127
CONFIG.md
View file

@ -8,23 +8,23 @@
- `Logging_Enable_Trace` *(bool)* - `Logging_Enable_Trace` *(bool)*
Enable the Trace Logging (Enabled in Debug recommanded). Enable the Trace Logging (Enabled in Debug recommended).
- `Logging_Enable_Debug` *(bool)* - `Logging_Enable_Debug` *(bool)*
Enable the Debug Logging (Enabled in Debug recommanded). Enable the Debug Logging (Enabled in Debug recommended).
- `Logging_Enable_Warn` *(bool)* - `Logging_Enable_Warn` *(bool)*
Enable the Warning Logging (Enabled in Debug recommanded). Enable the Warning Logging (Enabled in Debug recommended).
- `Logging_Enable_Error` *(bool)* - `Logging_Enable_Error` *(bool)*
Enable the Error Logging (Enabled in Debug recommanded). Enable the Error Logging (Enabled in Debug recommended).
- `Logging_Enable_Fatal` *(bool)* - `Logging_Enable_Fatal` *(bool)*
Enable the Fatal Logging (Enabled in Debug recommanded). Enable the Fatal Logging (Enabled in Debug recommended).
- `Logging_Enable_Ipc` *(bool)* - `Logging_Enable_Ipc` *(bool)*
@ -34,46 +34,107 @@
Enable writing the logging inside a Ryujinx.log file. Enable writing the logging inside a Ryujinx.log file.
- `Controls_Left_FakeJoycon_XX` *(int)* - `GamePad_Index` *(int)*
The index of the Controller Device.
- `GamePad_Deadzone` *(float)*
The deadzone of both analog sticks on the Controller.
- `GamePad_Enable` *(bool)*
Whether or not to enable Controller Support.
- `Controls_Left_JoyConKeyboard_XX` *(int)*
``` ```
Controls_Left_FakeJoycon_Stick_Up (int) Controls_Left_JoyConKeyboard_Stick_Up (int)
Controls_Left_FakeJoycon_Stick_Down (int) Controls_Left_JoyConKeyboard_Stick_Down (int)
Controls_Left_FakeJoycon_Stick_Left (int) Controls_Left_JoyConKeyboard_Stick_Left (int)
Controls_Left_FakeJoycon_Stick_Right (int) Controls_Left_JoyConKeyboard_Stick_Right (int)
Controls_Left_FakeJoycon_Stick_Button (int) Controls_Left_JoyConKeyboard_Stick_Button (int)
Controls_Left_FakeJoycon_DPad_Up (int) Controls_Left_JoyConKeyboard_DPad_Up (int)
Controls_Left_FakeJoycon_DPad_Down (int) Controls_Left_JoyConKeyboard_DPad_Down (int)
Controls_Left_FakeJoycon_DPad_Left (int) Controls_Left_JoyConKeyboard_DPad_Left (int)
Controls_Left_FakeJoycon_DPad_Right (int) Controls_Left_JoyConKeyboard_DPad_Right (int)
Controls_Left_FakeJoycon_Button_Minus (int) Controls_Left_JoyConKeyboard_Button_Minus (int)
Controls_Left_FakeJoycon_Button_L (int) Controls_Left_JoyConKeyboard_Button_L (int)
Controls_Left_FakeJoycon_Button_ZL (int) Controls_Left_JoyConKeyboard_Button_ZL (int)
``` ```
Keys of the Left Emulated Joycon, the values depend of the [OpenTK Enum Keys](https://github.com/opentk/opentk/blob/develop/src/OpenTK/Input/Key.cs). Keys of the Left Emulated Joycon, the values depend of the [OpenTK Enum Keys](https://github.com/opentk/opentk/blob/develop/src/OpenTK/Input/Key.cs).
OpenTK use a QWERTY layout, so pay attention if you use another Keyboard Layout. OpenTK use a QWERTY layout, so pay attention if you use another Keyboard Layout.
Ex: `Controls_Left_FakeJoycon_Button_Minus = 52` > Tab key (All Layout). Ex: `Controls_Left_JoyConKeyboard_Button_Minus = 52` > Tab key (All Layout).
- `Controls_Right_FakeJoycon_XX` *(int)* - `Controls_Right_JoyConKeyboard_XX` *(int)*
``` ```
Controls_Right_FakeJoycon_Stick_Up (int) Controls_Right_JoyConKeyboard_Stick_Up (int)
Controls_Right_FakeJoycon_Stick_Down (int) Controls_Right_JoyConKeyboard_Stick_Down (int)
Controls_Right_FakeJoycon_Stick_Left (int) Controls_Right_JoyConKeyboard_Stick_Left (int)
Controls_Right_FakeJoycon_Stick_Right (int) Controls_Right_JoyConKeyboard_Stick_Right (int)
Controls_Right_FakeJoycon_Stick_Button (int) Controls_Right_JoyConKeyboard_Stick_Button (int)
Controls_Right_FakeJoycon_Button_A (int) Controls_Right_JoyConKeyboard_Button_A (int)
Controls_Right_FakeJoycon_Button_B (int) Controls_Right_JoyConKeyboard_Button_B (int)
Controls_Right_FakeJoycon_Button_X (int) Controls_Right_JoyConKeyboard_Button_X (int)
Controls_Right_FakeJoycon_Button_Y (int) Controls_Right_JoyConKeyboard_Button_Y (int)
Controls_Right_FakeJoycon_Button_Plus (int) Controls_Right_JoyConKeyboard_Button_Plus (int)
Controls_Right_FakeJoycon_Button_R (int) Controls_Right_JoyConKeyboard_Button_R (int)
Controls_Right_FakeJoycon_Button_ZR (int) Controls_Right_JoyConKeyboard_Button_ZR (int)
``` ```
Keys of the right Emulated Joycon, the values depend of the [OpenTK Enum Keys](https://github.com/opentk/opentk/blob/develop/src/OpenTK/Input/Key.cs). Keys of the right Emulated Joycon, the values depend of the [OpenTK Enum Keys](https://github.com/opentk/opentk/blob/develop/src/OpenTK/Input/Key.cs).
OpenTK use a QWERTY layout, so pay attention if you use another Keyboard Layout. OpenTK use a QWERTY layout, so pay attention if you use another Keyboard Layout.
Ex: `Controls_Right_FakeJoycon_Button_A = 83` > A key (QWERTY Layout) / Q key (AZERTY Layout). Ex: `Controls_Right_JoyConKeyboard_Button_A = 83` > A key (QWERTY Layout) / Q key (AZERTY Layout).
- `Controls_Left_JoyConController_XX` *(String)*
```
Controls_Left_JoyConController_Stick (String)
Controls_Left_JoyConController_Stick_Button (String)
Controls_Left_JoyConController_DPad_Up (String)
Controls_Left_JoyConController_DPad_Down (String)
Controls_Left_JoyConController_DPad_Left (String)
Controls_Left_JoyConController_DPad_Right (String)
Controls_Left_JoyConController_Button_Minus (String)
Controls_Left_JoyConController_Button_L (String)
Controls_Left_JoyConController_Button_ZL (String)
```
- `Controls_Right_JoyConController_XX` *(String)*
```
Controls_Right_JoyConController_Stick (String)
Controls_Right_JoyConController_Stick_Button (String)
Controls_Right_JoyConController_Button_A (String)
Controls_Right_JoyConController_Button_B (String)
Controls_Right_JoyConController_Button_X (String)
Controls_Right_JoyConController_Button_Y (String)
Controls_Right_JoyConController_Button_Plus (String)
Controls_Right_JoyConController_Button_R (String)
Controls_Right_JoyConController_Button_ZR (String)
```
- Valid Button Mappings
- A = The A / Cross Button
- B = The B / Circle Button
- X = The X / Square Button
- Y = The Y / Triangle Button
- LStick = The Left Analog Stick when Pressed Down
- RStick = The Right Analog Stick when Pressed Down
- Start = The Start / Options Button
- Back = The Select / Back / Share Button
- RShoulder = The Right Shoulder Button
- LShoulder = The Left Shoulder Button
- RTrigger = The Right Trigger
- LTrigger = The Left Trigger
- DPadUp = Up on the DPad
- DPadDown = Down on the DPad
- DPadLeft = Left on the DPad
- DpadRight = Right on the DPad
- Valid Joystick Mappings
- LJoystick = The Left Analog Stick
- RJoystick = The Right Analog Stick
On more obscure / weird controllers this can vary, so if this list doesn't work, trial and error will.

View file

@ -46,9 +46,32 @@ https://openal.org/downloads/OpenAL11CoreSDK.zip
- Plus = + - Plus = +
- R = U - R = U
- ZR = O - ZR = O
- For more information on how to configure these buttons see [CONFIG.md](CONFIG.md)
- Controller Input is partially supported:
- Left Joycon:
- Analog Stick = Left Analog Stick
- DPad Up = DPad Up
- DPad Down = DPad Down
- DPad Left = DPad Left
- DPad Right = DPad Right
- Minus = Select / Back / Share
- L = Left Shoulder Button
- ZL = Left Trigger
- Right Joycon:
- Analog Stick = Right Analog Stick
- A = B / Circle
- B = A / Cross
- X = Y / Triangle
- Y = X / Square
- Plus = Start / Options
- R = Right Shoulder Button
- ZR = Right Trigger
- For more information on how to configure these buttons see [CONFIG.md](CONFIG.md)
- Config File: `Ryujinx.conf` should be present in executable folder. - Config File: `Ryujinx.conf` should be present in executable folder.
For more informations [you can go here](CONFIG.md). For more information [you can go here](CONFIG.md).
- If you are a Windows user, you can configure your keys, the logs, install OpenAL, etc... with Ryujinx-Setting. - If you are a Windows user, you can configure your keys, the logs, install OpenAL, etc... with Ryujinx-Setting.
[Download it, right here](https://github.com/AcK77/Ryujinx-Settings) [Download it, right here](https://github.com/AcK77/Ryujinx-Settings)

View file

@ -1,5 +1,5 @@
using OpenTK.Input; using OpenTK.Input;
using Ryujinx.HLE.Input; using Ryujinx.Input;
using Ryujinx.HLE.Logging; using Ryujinx.HLE.Logging;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
@ -11,32 +11,13 @@ namespace Ryujinx
{ {
public static class Config public static class Config
{ {
public static JoyCon FakeJoyCon { get; private set; } public static JoyConKeyboard JoyConKeyboard { get; private set; }
public static JoyConController JoyConController { get; private set; }
public static float GamePad_Deadzone; public static float GamePad_Deadzone;
public static bool GamePad_Enable; public static bool GamePad_Enable;
public static int GamePad_Index; public static int GamePad_Index;
public static float GamePad_Trigger_Threshold;
public static string Controls_Right_FakeJoycon_GamePadButton_A;
public static string Controls_Right_FakeJoycon_GamePadButton_B;
public static string Controls_Right_FakeJoycon_GamePadButton_X;
public static string Controls_Right_FakeJoycon_GamePadButton_Y;
public static string Controls_Right_FakeJoycon_GamePadButton_Plus;
public static string Controls_Right_FakeJoycon_GamePadButton_R;
public static string Controls_Right_FakeJoycon_GamePadStick_Button;
public static string Controls_Right_FakeJoycon_GamePadTrigger_ZR;
public static string Controls_Left_FakeJoycon_GamePadDPad_Up;
public static string Controls_Left_FakeJoycon_GamePadDPad_Down;
public static string Controls_Left_FakeJoycon_GamePadDPad_Left;
public static string Controls_Left_FakeJoycon_GamePadDPad_Right;
public static string Controls_Left_FakeJoycon_GamePadButton_Minus;
public static string Controls_Left_FakeJoycon_GamePadButton_L;
public static string Controls_Left_FakeJoycon_GamePadStick_Button;
public static string Controls_Left_FakeJoycon_GamePadTrigger_ZL;
public static string Controls_Right_FakeJoycon_GamePadJoystick_R;
public static string Controls_Left_FakeJoycon_GamePadJoystick_L;
public static void Read(Logger Log) public static void Read(Logger Log)
{ {
@ -57,27 +38,7 @@ namespace Ryujinx
GamePad_Enable = Convert.ToBoolean(Parser.Value("GamePad_Enable")); GamePad_Enable = Convert.ToBoolean(Parser.Value("GamePad_Enable"));
GamePad_Index = Convert.ToInt32 (Parser.Value("GamePad_Index")); GamePad_Index = Convert.ToInt32 (Parser.Value("GamePad_Index"));
GamePad_Deadzone = (float)Convert.ToDouble (Parser.Value("GamePad_Deadzone")); GamePad_Deadzone = (float)Convert.ToDouble (Parser.Value("GamePad_Deadzone"));
GamePad_Trigger_Threshold = (float)Convert.ToDouble (Parser.Value("GamePad_Trigger_Threshold"));
Controls_Right_FakeJoycon_GamePadButton_A = Parser.Value("Controls_Right_FakeJoycon_GamePadButton_A");
Controls_Right_FakeJoycon_GamePadButton_B = Parser.Value("Controls_Right_FakeJoycon_GamePadButton_B");
Controls_Right_FakeJoycon_GamePadButton_X = Parser.Value("Controls_Right_FakeJoycon_GamePadButton_X");
Controls_Right_FakeJoycon_GamePadButton_Y = Parser.Value("Controls_Right_FakeJoycon_GamePadButton_Y");
Controls_Right_FakeJoycon_GamePadButton_Plus = Parser.Value("Controls_Right_FakeJoycon_GamePadButton_Plus");
Controls_Right_FakeJoycon_GamePadButton_R = Parser.Value("Controls_Right_FakeJoycon_GamePadButton_R");
Controls_Right_FakeJoycon_GamePadStick_Button = Parser.Value("Controls_Right_FakeJoycon_GamePadStick_Button");
Controls_Right_FakeJoycon_GamePadTrigger_ZR = Parser.Value("Controls_Right_FakeJoycon_GamePadTrigger_ZR");
Controls_Left_FakeJoycon_GamePadDPad_Up = Parser.Value("Controls_Left_FakeJoycon_GamePadDPad_Up");
Controls_Left_FakeJoycon_GamePadDPad_Down = Parser.Value("Controls_Left_FakeJoycon_GamePadDPad_Down");
Controls_Left_FakeJoycon_GamePadDPad_Left = Parser.Value("Controls_Left_FakeJoycon_GamePadDPad_Left");
Controls_Left_FakeJoycon_GamePadDPad_Right = Parser.Value("Controls_Left_FakeJoycon_GamePadDPad_Right");
Controls_Left_FakeJoycon_GamePadButton_Minus = Parser.Value("Controls_Left_FakeJoycon_GamePadButton_Minus");
Controls_Left_FakeJoycon_GamePadButton_L = Parser.Value("Controls_Left_FakeJoycon_GamePadButton_L");
Controls_Left_FakeJoycon_GamePadStick_Button = Parser.Value("Controls_Left_FakeJoycon_GamePadStick_Button");
Controls_Left_FakeJoycon_GamePadTrigger_ZL = Parser.Value("Controls_Left_FakeJoycon_GamePadTrigger_ZL");
Controls_Right_FakeJoycon_GamePadJoystick_R = Parser.Value("Controls_Right_FakeJoycon_GamePadJoystick_R");
Controls_Left_FakeJoycon_GamePadJoystick_L = Parser.Value("Controls_Left_FakeJoycon_GamePadJoystick_L");
string[] FilteredLogClasses = Parser.Value("Logging_Filtered_Classes").Split(',', StringSplitOptions.RemoveEmptyEntries); string[] FilteredLogClasses = Parser.Value("Logging_Filtered_Classes").Split(',', StringSplitOptions.RemoveEmptyEntries);
@ -107,38 +68,67 @@ namespace Ryujinx
} }
} }
FakeJoyCon = new JoyCon JoyConKeyboard = new JoyConKeyboard
{ {
Left = new JoyConLeft Left = new JoyConKeyboardLeft
{ {
StickUp = Convert.ToInt16(Parser.Value("Controls_Left_FakeJoycon_Stick_Up")), StickUp = Convert.ToInt16(Parser.Value("Controls_Left_JoyConKeyboard_Stick_Up")),
StickDown = Convert.ToInt16(Parser.Value("Controls_Left_FakeJoycon_Stick_Down")), StickDown = Convert.ToInt16(Parser.Value("Controls_Left_JoyConKeyboard_Stick_Down")),
StickLeft = Convert.ToInt16(Parser.Value("Controls_Left_FakeJoycon_Stick_Left")), StickLeft = Convert.ToInt16(Parser.Value("Controls_Left_JoyConKeyboard_Stick_Left")),
StickRight = Convert.ToInt16(Parser.Value("Controls_Left_FakeJoycon_Stick_Right")), StickRight = Convert.ToInt16(Parser.Value("Controls_Left_JoyConKeyboard_Stick_Right")),
StickButton = Convert.ToInt16(Parser.Value("Controls_Left_FakeJoycon_Stick_Button")), StickButton = Convert.ToInt16(Parser.Value("Controls_Left_JoyConKeyboard_Stick_Button")),
DPadUp = Convert.ToInt16(Parser.Value("Controls_Left_FakeJoycon_DPad_Up")), DPadUp = Convert.ToInt16(Parser.Value("Controls_Left_JoyConKeyboard_DPad_Up")),
DPadDown = Convert.ToInt16(Parser.Value("Controls_Left_FakeJoycon_DPad_Down")), DPadDown = Convert.ToInt16(Parser.Value("Controls_Left_JoyConKeyboard_DPad_Down")),
DPadLeft = Convert.ToInt16(Parser.Value("Controls_Left_FakeJoycon_DPad_Left")), DPadLeft = Convert.ToInt16(Parser.Value("Controls_Left_JoyConKeyboard_DPad_Left")),
DPadRight = Convert.ToInt16(Parser.Value("Controls_Left_FakeJoycon_DPad_Right")), DPadRight = Convert.ToInt16(Parser.Value("Controls_Left_JoyConKeyboard_DPad_Right")),
ButtonMinus = Convert.ToInt16(Parser.Value("Controls_Left_FakeJoycon_Button_Minus")), ButtonMinus = Convert.ToInt16(Parser.Value("Controls_Left_JoyConKeyboard_Button_Minus")),
ButtonL = Convert.ToInt16(Parser.Value("Controls_Left_FakeJoycon_Button_L")), ButtonL = Convert.ToInt16(Parser.Value("Controls_Left_JoyConKeyboard_Button_L")),
ButtonZL = Convert.ToInt16(Parser.Value("Controls_Left_FakeJoycon_Button_ZL")) ButtonZL = Convert.ToInt16(Parser.Value("Controls_Left_JoyConKeyboard_Button_ZL"))
}, },
Right = new JoyConRight Right = new JoyConKeyboardRight
{ {
StickUp = Convert.ToInt16(Parser.Value("Controls_Right_FakeJoycon_Stick_Up")), StickUp = Convert.ToInt16(Parser.Value("Controls_Right_JoyConKeyboard_Stick_Up")),
StickDown = Convert.ToInt16(Parser.Value("Controls_Right_FakeJoycon_Stick_Down")), StickDown = Convert.ToInt16(Parser.Value("Controls_Right_JoyConKeyboard_Stick_Down")),
StickLeft = Convert.ToInt16(Parser.Value("Controls_Right_FakeJoycon_Stick_Left")), StickLeft = Convert.ToInt16(Parser.Value("Controls_Right_JoyConKeyboard_Stick_Left")),
StickRight = Convert.ToInt16(Parser.Value("Controls_Right_FakeJoycon_Stick_Right")), StickRight = Convert.ToInt16(Parser.Value("Controls_Right_JoyConKeyboard_Stick_Right")),
StickButton = Convert.ToInt16(Parser.Value("Controls_Right_FakeJoycon_Stick_Button")), StickButton = Convert.ToInt16(Parser.Value("Controls_Right_JoyConKeyboard_Stick_Button")),
ButtonA = Convert.ToInt16(Parser.Value("Controls_Right_FakeJoycon_Button_A")), ButtonA = Convert.ToInt16(Parser.Value("Controls_Right_JoyConKeyboard_Button_A")),
ButtonB = Convert.ToInt16(Parser.Value("Controls_Right_FakeJoycon_Button_B")), ButtonB = Convert.ToInt16(Parser.Value("Controls_Right_JoyConKeyboard_Button_B")),
ButtonX = Convert.ToInt16(Parser.Value("Controls_Right_FakeJoycon_Button_X")), ButtonX = Convert.ToInt16(Parser.Value("Controls_Right_JoyConKeyboard_Button_X")),
ButtonY = Convert.ToInt16(Parser.Value("Controls_Right_FakeJoycon_Button_Y")), ButtonY = Convert.ToInt16(Parser.Value("Controls_Right_JoyConKeyboard_Button_Y")),
ButtonPlus = Convert.ToInt16(Parser.Value("Controls_Right_FakeJoycon_Button_Plus")), ButtonPlus = Convert.ToInt16(Parser.Value("Controls_Right_JoyConKeyboard_Button_Plus")),
ButtonR = Convert.ToInt16(Parser.Value("Controls_Right_FakeJoycon_Button_R")), ButtonR = Convert.ToInt16(Parser.Value("Controls_Right_JoyConKeyboard_Button_R")),
ButtonZR = Convert.ToInt16(Parser.Value("Controls_Right_FakeJoycon_Button_ZR")) ButtonZR = Convert.ToInt16(Parser.Value("Controls_Right_JoyConKeyboard_Button_ZR"))
}
};
JoyConController = new JoyConController
{
Left = new JoyConControllerLeft
{
Stick = Parser.Value("Controls_Left_JoyConController_Stick"),
StickButton = Parser.Value("Controls_Left_JoyConController_Stick_Button"),
DPadUp = Parser.Value("Controls_Left_JoyConController_DPad_Up"),
DPadDown = Parser.Value("Controls_Left_JoyConController_DPad_Down"),
DPadLeft = Parser.Value("Controls_Left_JoyConController_DPad_Left"),
DPadRight = Parser.Value("Controls_Left_JoyConController_DPad_Right"),
ButtonMinus = Parser.Value("Controls_Left_JoyConController_Button_Minus"),
ButtonL = Parser.Value("Controls_Left_JoyConController_Button_L"),
ButtonZL = Parser.Value("Controls_Left_JoyConController_Button_ZL")
},
Right = new JoyConControllerRight
{
Stick = Parser.Value("Controls_Right_JoyConController_Stick"),
StickButton = Parser.Value("Controls_Right_JoyConController_Stick_Button"),
ButtonA = Parser.Value("Controls_Right_JoyConController_Button_A"),
ButtonB = Parser.Value("Controls_Right_JoyConController_Button_B"),
ButtonX = Parser.Value("Controls_Right_JoyConController_Button_X"),
ButtonY = Parser.Value("Controls_Right_JoyConController_Button_Y"),
ButtonPlus = Parser.Value("Controls_Right_JoyConController_Button_Plus"),
ButtonR = Parser.Value("Controls_Right_JoyConController_Button_R"),
ButtonZR = Parser.Value("Controls_Right_JoyConController_Button_ZR")
} }
}; };
} }

View file

@ -0,0 +1,38 @@
using System;
using System.Collections.Generic;
using System.Text;
namespace Ryujinx.Input
{
public struct JoyConControllerLeft
{
public string Stick;
public string StickButton;
public string DPadUp;
public string DPadDown;
public string DPadLeft;
public string DPadRight;
public string ButtonMinus;
public string ButtonL;
public string ButtonZL;
}
public struct JoyConControllerRight
{
public string Stick;
public string StickButton;
public string ButtonA;
public string ButtonB;
public string ButtonX;
public string ButtonY;
public string ButtonPlus;
public string ButtonR;
public string ButtonZR;
}
public struct JoyConController
{
public JoyConControllerLeft Left;
public JoyConControllerRight Right;
}
}

View file

@ -1,7 +1,6 @@
//TODO: This is only used by Config, it doesn't belong to Core. namespace Ryujinx.Input
namespace Ryujinx.HLE.Input
{ {
public struct JoyConLeft public struct JoyConKeyboardLeft
{ {
public int StickUp; public int StickUp;
public int StickDown; public int StickDown;
@ -15,11 +14,9 @@ namespace Ryujinx.HLE.Input
public int ButtonMinus; public int ButtonMinus;
public int ButtonL; public int ButtonL;
public int ButtonZL; public int ButtonZL;
public int ButtonSL;
public int ButtonSR;
} }
public struct JoyConRight public struct JoyConKeyboardRight
{ {
public int StickUp; public int StickUp;
public int StickDown; public int StickDown;
@ -33,13 +30,11 @@ namespace Ryujinx.HLE.Input
public int ButtonPlus; public int ButtonPlus;
public int ButtonR; public int ButtonR;
public int ButtonZR; public int ButtonZR;
public int ButtonSL;
public int ButtonSR;
} }
public struct JoyCon public struct JoyConKeyboard
{ {
public JoyConLeft Left; public JoyConKeyboardLeft Left;
public JoyConRight Right; public JoyConKeyboardRight Right;
} }
} }

8
Ryujinx/JoyConReal.cs Normal file
View file

@ -0,0 +1,8 @@
using System;
using System.Collections.Generic;
using System.Text;
namespace Ryujinx.Input
{
//TODO: Add real Bluetooth Joy Con Support in the far future.
}

View file

@ -25,54 +25,58 @@ GamePad_Index = 0
#Controller Analog Stick Deadzone #Controller Analog Stick Deadzone
GamePad_Deadzone = 0.05 GamePad_Deadzone = 0.05
#The value of how pressed down each trigger has to be in order to register a button press
GamePad_Trigger_Threshold = 0.5
#Whether or not to enable Controller support #Whether or not to enable Controller support
GamePad_Enable = true GamePad_Enable = true
#https://github.com/opentk/opentk/blob/develop/src/OpenTK/Input/Key.cs #https://github.com/opentk/opentk/blob/develop/src/OpenTK/Input/Key.cs
Controls_Left_FakeJoycon_Stick_Up = 105 Controls_Left_JoyConKeyboard_Stick_Up = 105
Controls_Left_FakeJoycon_Stick_Down = 101 Controls_Left_JoyConKeyboard_Stick_Down = 101
Controls_Left_FakeJoycon_Stick_Left = 83 Controls_Left_JoyConKeyboard_Stick_Left = 83
Controls_Left_FakeJoycon_Stick_Right = 86 Controls_Left_JoyConKeyboard_Stick_Right = 86
Controls_Left_FakeJoycon_Stick_Button = 88 Controls_Left_JoyConKeyboard_Stick_Button = 88
Controls_Left_FakeJoycon_DPad_Up = 45 Controls_Left_JoyConKeyboard_DPad_Up = 45
Controls_Left_FakeJoycon_DPad_Down = 46 Controls_Left_JoyConKeyboard_DPad_Down = 46
Controls_Left_FakeJoycon_DPad_Left = 47 Controls_Left_JoyConKeyboard_DPad_Left = 47
Controls_Left_FakeJoycon_DPad_Right = 48 Controls_Left_JoyConKeyboard_DPad_Right = 48
Controls_Left_FakeJoycon_Button_Minus = 120 Controls_Left_JoyConKeyboard_Button_Minus = 120
Controls_Left_FakeJoycon_Button_L = 87 Controls_Left_JoyConKeyboard_Button_L = 87
Controls_Left_FakeJoycon_Button_ZL = 99 Controls_Left_JoyConKeyboard_Button_ZL = 99
Controls_Right_FakeJoycon_Stick_Up = 91 Controls_Right_JoyConKeyboard_Stick_Up = 91
Controls_Right_FakeJoycon_Stick_Down = 93 Controls_Right_JoyConKeyboard_Stick_Down = 93
Controls_Right_FakeJoycon_Stick_Left = 92 Controls_Right_JoyConKeyboard_Stick_Left = 92
Controls_Right_FakeJoycon_Stick_Right = 94 Controls_Right_JoyConKeyboard_Stick_Right = 94
Controls_Right_FakeJoycon_Stick_Button = 90 Controls_Right_JoyConKeyboard_Stick_Button = 90
Controls_Right_FakeJoycon_Button_A = 108 Controls_Right_JoyConKeyboard_Button_A = 108
Controls_Right_FakeJoycon_Button_B = 106 Controls_Right_JoyConKeyboard_Button_B = 106
Controls_Right_FakeJoycon_Button_X = 85 Controls_Right_JoyConKeyboard_Button_X = 85
Controls_Right_FakeJoycon_Button_Y = 104 Controls_Right_JoyConKeyboard_Button_Y = 104
Controls_Right_FakeJoycon_Button_Plus = 121 Controls_Right_JoyConKeyboard_Button_Plus = 121
Controls_Right_FakeJoycon_Button_R = 103 Controls_Right_JoyConKeyboard_Button_R = 103
Controls_Right_FakeJoycon_Button_ZR = 97 Controls_Right_JoyConKeyboard_Button_ZR = 97
#Controller Controls #Controller Controls
Controls_Right_FakeJoycon_GamePadButton_A = B
Controls_Right_FakeJoycon_GamePadButton_B = A
Controls_Right_FakeJoycon_GamePadButton_X = Y
Controls_Right_FakeJoycon_GamePadButton_Y = X
Controls_Right_FakeJoycon_GamePadButton_Plus = Start
Controls_Right_FakeJoycon_GamePadButton_R = RShoulder
Controls_Right_FakeJoycon_GamePadStick_Button = RStick
Controls_Right_FakeJoycon_GamePadTrigger_ZR = RTrigger
Controls_Left_FakeJoycon_GamePadDPad_Up = DPadUp Controls_Left_JoyConController_Stick_Button = LStick
Controls_Left_FakeJoycon_GamePadDPad_Down = DPadDown Controls_Left_JoyConController_DPad_Up = DPadUp
Controls_Left_FakeJoycon_GamePadDPad_Left = DPadLeft Controls_Left_JoyConController_DPad_Down = DPadDown
Controls_Left_FakeJoycon_GamePadDPad_Right = DPadRight Controls_Left_JoyConController_DPad_Left = DPadLeft
Controls_Left_FakeJoycon_GamePadButton_Minus = Back Controls_Left_JoyConController_DPad_Right = DPadRight
Controls_Left_FakeJoycon_GamePadButton_L = LShoulder Controls_Left_JoyConController_Button_Minus = Back
Controls_Left_FakeJoycon_GamePadStick_Button = LStick Controls_Left_JoyConController_Button_L = LShoulder
Controls_Left_FakeJoycon_GamePadTrigger_ZL = LTrigger Controls_Left_JoyConController_Button_ZL = LTrigger
Controls_Right_FakeJoycon_GamePadJoystick_R = RJoystick Controls_Right_JoyConController_Stick_Button = RStick
Controls_Left_FakeJoycon_GamePadJoystick_L = LJoystick Controls_Right_JoyConController_Button_A = B
Controls_Right_JoyConController_Button_B = A
Controls_Right_JoyConController_Button_X = Y
Controls_Right_JoyConController_Button_Y = X
Controls_Right_JoyConController_Button_Plus = Start
Controls_Right_JoyConController_Button_R = RShoulder
Controls_Right_JoyConController_Button_ZR = RTrigger
Controls_Left_JoyConController_Stick = LJoystick
Controls_Right_JoyConController_Stick = RJoystick

View file

@ -45,7 +45,19 @@ namespace Ryujinx
Renderer.FrameBuffer.SetWindowSize(Width, Height); Renderer.FrameBuffer.SetWindowSize(Width, Height);
} }
private ButtonState getGamePadButtonFromString(GamePadState gamePad, string str) //Please make this prettier if you can. private bool IsGamePadButtonPressedFromString(GamePadState gamePad, string str)
{
if (str == "LTrigger" || str == "RTrigger")
{
return GetGamePadTriggerFromString(gamePad, str) >= Config.GamePad_Trigger_Threshold;
}
else
{
return (GetGamePadButtonFromString(gamePad, str) == ButtonState.Pressed);
}
}
private ButtonState GetGamePadButtonFromString(GamePadState gamePad, string str) //Please make this prettier if you can.
{ {
ButtonState result = gamePad.Buttons.A; ButtonState result = gamePad.Buttons.A;
@ -101,7 +113,7 @@ namespace Ryujinx
return result; return result;
} }
private float getGamePadTriggerFromString(GamePadState gamePad, string str) private float GetGamePadTriggerFromString(GamePadState gamePad, string str)
{ {
float result = 0; float result = 0;
@ -121,7 +133,7 @@ namespace Ryujinx
return result; return result;
} }
private Vector2 getJoystickAxisFromString(GamePadState gamePad, string str) private Vector2 GetJoystickAxisFromString(GamePadState gamePad, string str)
{ {
Vector2 result = new Vector2(0, 0); Vector2 result = new Vector2(0, 0);
@ -161,36 +173,36 @@ namespace Ryujinx
if (Keyboard[Key.Escape]) this.Exit(); if (Keyboard[Key.Escape]) this.Exit();
//LeftJoystick //LeftJoystick
if (Keyboard[(Key)Config.FakeJoyCon.Left.StickUp]) LeftJoystickDY = short.MaxValue; if (Keyboard[(Key)Config.JoyConKeyboard.Left.StickUp]) LeftJoystickDY = short.MaxValue;
if (Keyboard[(Key)Config.FakeJoyCon.Left.StickDown]) LeftJoystickDY = -short.MaxValue; if (Keyboard[(Key)Config.JoyConKeyboard.Left.StickDown]) LeftJoystickDY = -short.MaxValue;
if (Keyboard[(Key)Config.FakeJoyCon.Left.StickLeft]) LeftJoystickDX = -short.MaxValue; if (Keyboard[(Key)Config.JoyConKeyboard.Left.StickLeft]) LeftJoystickDX = -short.MaxValue;
if (Keyboard[(Key)Config.FakeJoyCon.Left.StickRight]) LeftJoystickDX = short.MaxValue; if (Keyboard[(Key)Config.JoyConKeyboard.Left.StickRight]) LeftJoystickDX = short.MaxValue;
//LeftButtons //LeftButtons
if (Keyboard[(Key)Config.FakeJoyCon.Left.StickButton]) CurrentButton |= HidControllerButtons.KEY_LSTICK; if (Keyboard[(Key)Config.JoyConKeyboard.Left.StickButton]) CurrentButton |= HidControllerButtons.KEY_LSTICK;
if (Keyboard[(Key)Config.FakeJoyCon.Left.DPadUp]) CurrentButton |= HidControllerButtons.KEY_DUP; if (Keyboard[(Key)Config.JoyConKeyboard.Left.DPadUp]) CurrentButton |= HidControllerButtons.KEY_DUP;
if (Keyboard[(Key)Config.FakeJoyCon.Left.DPadDown]) CurrentButton |= HidControllerButtons.KEY_DDOWN; if (Keyboard[(Key)Config.JoyConKeyboard.Left.DPadDown]) CurrentButton |= HidControllerButtons.KEY_DDOWN;
if (Keyboard[(Key)Config.FakeJoyCon.Left.DPadLeft]) CurrentButton |= HidControllerButtons.KEY_DLEFT; if (Keyboard[(Key)Config.JoyConKeyboard.Left.DPadLeft]) CurrentButton |= HidControllerButtons.KEY_DLEFT;
if (Keyboard[(Key)Config.FakeJoyCon.Left.DPadRight]) CurrentButton |= HidControllerButtons.KEY_DRIGHT; if (Keyboard[(Key)Config.JoyConKeyboard.Left.DPadRight]) CurrentButton |= HidControllerButtons.KEY_DRIGHT;
if (Keyboard[(Key)Config.FakeJoyCon.Left.ButtonMinus]) CurrentButton |= HidControllerButtons.KEY_MINUS; if (Keyboard[(Key)Config.JoyConKeyboard.Left.ButtonMinus]) CurrentButton |= HidControllerButtons.KEY_MINUS;
if (Keyboard[(Key)Config.FakeJoyCon.Left.ButtonL]) CurrentButton |= HidControllerButtons.KEY_L; if (Keyboard[(Key)Config.JoyConKeyboard.Left.ButtonL]) CurrentButton |= HidControllerButtons.KEY_L;
if (Keyboard[(Key)Config.FakeJoyCon.Left.ButtonZL]) CurrentButton |= HidControllerButtons.KEY_ZL; if (Keyboard[(Key)Config.JoyConKeyboard.Left.ButtonZL]) CurrentButton |= HidControllerButtons.KEY_ZL;
//RightJoystick //RightJoystick
if (Keyboard[(Key)Config.FakeJoyCon.Right.StickUp]) RightJoystickDY = short.MaxValue; if (Keyboard[(Key)Config.JoyConKeyboard.Right.StickUp]) RightJoystickDY = short.MaxValue;
if (Keyboard[(Key)Config.FakeJoyCon.Right.StickDown]) RightJoystickDY = -short.MaxValue; if (Keyboard[(Key)Config.JoyConKeyboard.Right.StickDown]) RightJoystickDY = -short.MaxValue;
if (Keyboard[(Key)Config.FakeJoyCon.Right.StickLeft]) RightJoystickDX = -short.MaxValue; if (Keyboard[(Key)Config.JoyConKeyboard.Right.StickLeft]) RightJoystickDX = -short.MaxValue;
if (Keyboard[(Key)Config.FakeJoyCon.Right.StickRight]) RightJoystickDX = short.MaxValue; if (Keyboard[(Key)Config.JoyConKeyboard.Right.StickRight]) RightJoystickDX = short.MaxValue;
//RightButtons //RightButtons
if (Keyboard[(Key)Config.FakeJoyCon.Right.StickButton]) CurrentButton |= HidControllerButtons.KEY_RSTICK; if (Keyboard[(Key)Config.JoyConKeyboard.Right.StickButton]) CurrentButton |= HidControllerButtons.KEY_RSTICK;
if (Keyboard[(Key)Config.FakeJoyCon.Right.ButtonA]) CurrentButton |= HidControllerButtons.KEY_A; if (Keyboard[(Key)Config.JoyConKeyboard.Right.ButtonA]) CurrentButton |= HidControllerButtons.KEY_A;
if (Keyboard[(Key)Config.FakeJoyCon.Right.ButtonB]) CurrentButton |= HidControllerButtons.KEY_B; if (Keyboard[(Key)Config.JoyConKeyboard.Right.ButtonB]) CurrentButton |= HidControllerButtons.KEY_B;
if (Keyboard[(Key)Config.FakeJoyCon.Right.ButtonX]) CurrentButton |= HidControllerButtons.KEY_X; if (Keyboard[(Key)Config.JoyConKeyboard.Right.ButtonX]) CurrentButton |= HidControllerButtons.KEY_X;
if (Keyboard[(Key)Config.FakeJoyCon.Right.ButtonY]) CurrentButton |= HidControllerButtons.KEY_Y; if (Keyboard[(Key)Config.JoyConKeyboard.Right.ButtonY]) CurrentButton |= HidControllerButtons.KEY_Y;
if (Keyboard[(Key)Config.FakeJoyCon.Right.ButtonPlus]) CurrentButton |= HidControllerButtons.KEY_PLUS; if (Keyboard[(Key)Config.JoyConKeyboard.Right.ButtonPlus]) CurrentButton |= HidControllerButtons.KEY_PLUS;
if (Keyboard[(Key)Config.FakeJoyCon.Right.ButtonR]) CurrentButton |= HidControllerButtons.KEY_R; if (Keyboard[(Key)Config.JoyConKeyboard.Right.ButtonR]) CurrentButton |= HidControllerButtons.KEY_R;
if (Keyboard[(Key)Config.FakeJoyCon.Right.ButtonZR]) CurrentButton |= HidControllerButtons.KEY_ZR; if (Keyboard[(Key)Config.JoyConKeyboard.Right.ButtonZR]) CurrentButton |= HidControllerButtons.KEY_ZR;
} }
//Controller Input //Controller Input
@ -198,60 +210,43 @@ namespace Ryujinx
{ {
GamePadState gamePad = GamePad.GetState(Config.GamePad_Index); GamePadState gamePad = GamePad.GetState(Config.GamePad_Index);
//RightButtons
if (getGamePadButtonFromString(gamePad, Config.Controls_Right_FakeJoycon_GamePadButton_A)
== ButtonState.Pressed) CurrentButton |= HidControllerButtons.KEY_A;
if (getGamePadButtonFromString(gamePad, Config.Controls_Right_FakeJoycon_GamePadButton_B)
== ButtonState.Pressed) CurrentButton |= HidControllerButtons.KEY_B;
if (getGamePadButtonFromString(gamePad, Config.Controls_Right_FakeJoycon_GamePadButton_X)
== ButtonState.Pressed) CurrentButton |= HidControllerButtons.KEY_X;
if (getGamePadButtonFromString(gamePad, Config.Controls_Right_FakeJoycon_GamePadButton_Y)
== ButtonState.Pressed) CurrentButton |= HidControllerButtons.KEY_Y;
if (getGamePadButtonFromString(gamePad, Config.Controls_Right_FakeJoycon_GamePadStick_Button)
== ButtonState.Pressed) CurrentButton |= HidControllerButtons.KEY_RSTICK;
if (getGamePadButtonFromString(gamePad, Config.Controls_Right_FakeJoycon_GamePadButton_Plus)
== ButtonState.Pressed) CurrentButton |= HidControllerButtons.KEY_PLUS;
if (getGamePadButtonFromString(gamePad, Config.Controls_Right_FakeJoycon_GamePadButton_R)
== ButtonState.Pressed) CurrentButton |= HidControllerButtons.KEY_R;
if (getGamePadTriggerFromString(gamePad, Config.Controls_Right_FakeJoycon_GamePadTrigger_ZR)
>= 0.5) CurrentButton |= HidControllerButtons.KEY_ZR;
//LeftButtons //LeftButtons
if (getGamePadButtonFromString(gamePad, Config.Controls_Left_FakeJoycon_GamePadDPad_Up) if (IsGamePadButtonPressedFromString(gamePad, Config.JoyConController.Left.DPadUp)) CurrentButton |= HidControllerButtons.KEY_DUP;
== ButtonState.Pressed) CurrentButton |= HidControllerButtons.KEY_DUP; if (IsGamePadButtonPressedFromString(gamePad, Config.JoyConController.Left.DPadDown)) CurrentButton |= HidControllerButtons.KEY_DDOWN;
if (getGamePadButtonFromString(gamePad, Config.Controls_Left_FakeJoycon_GamePadDPad_Down) if (IsGamePadButtonPressedFromString(gamePad, Config.JoyConController.Left.DPadLeft)) CurrentButton |= HidControllerButtons.KEY_DLEFT;
== ButtonState.Pressed) CurrentButton |= HidControllerButtons.KEY_DDOWN; if (IsGamePadButtonPressedFromString(gamePad, Config.JoyConController.Left.DPadRight)) CurrentButton |= HidControllerButtons.KEY_DRIGHT;
if (getGamePadButtonFromString(gamePad, Config.Controls_Left_FakeJoycon_GamePadDPad_Left) if (IsGamePadButtonPressedFromString(gamePad, Config.JoyConController.Left.StickButton)) CurrentButton |= HidControllerButtons.KEY_LSTICK;
== ButtonState.Pressed) CurrentButton |= HidControllerButtons.KEY_DLEFT; if (IsGamePadButtonPressedFromString(gamePad, Config.JoyConController.Left.ButtonMinus)) CurrentButton |= HidControllerButtons.KEY_MINUS;
if (getGamePadButtonFromString(gamePad, Config.Controls_Left_FakeJoycon_GamePadDPad_Right) if (IsGamePadButtonPressedFromString(gamePad, Config.JoyConController.Left.ButtonL)) CurrentButton |= HidControllerButtons.KEY_L;
== ButtonState.Pressed) CurrentButton |= HidControllerButtons.KEY_DRIGHT; if (IsGamePadButtonPressedFromString(gamePad, Config.JoyConController.Left.ButtonZL)) CurrentButton |= HidControllerButtons.KEY_ZL;
if (getGamePadButtonFromString(gamePad, Config.Controls_Left_FakeJoycon_GamePadStick_Button)
== ButtonState.Pressed) CurrentButton |= HidControllerButtons.KEY_LSTICK;
if (getGamePadButtonFromString(gamePad, Config.Controls_Left_FakeJoycon_GamePadButton_Minus)
== ButtonState.Pressed) CurrentButton |= HidControllerButtons.KEY_MINUS;
if (getGamePadButtonFromString(gamePad, Config.Controls_Left_FakeJoycon_GamePadButton_L)
== ButtonState.Pressed) CurrentButton |= HidControllerButtons.KEY_L;
if (getGamePadTriggerFromString(gamePad, Config.Controls_Left_FakeJoycon_GamePadTrigger_ZL)
>= 0.5) CurrentButton |= HidControllerButtons.KEY_ZL;
//RightJoystick //RightButtons
if (IsGamePadButtonPressedFromString(gamePad, Config.JoyConController.Right.ButtonA)) CurrentButton |= HidControllerButtons.KEY_A;
if (getJoystickAxisFromString(gamePad, Config.Controls_Right_FakeJoycon_GamePadJoystick_R).X >= deadzone if (IsGamePadButtonPressedFromString(gamePad, Config.JoyConController.Right.ButtonB)) CurrentButton |= HidControllerButtons.KEY_B;
|| getJoystickAxisFromString(gamePad, Config.Controls_Right_FakeJoycon_GamePadJoystick_R).X <= -deadzone) if (IsGamePadButtonPressedFromString(gamePad, Config.JoyConController.Right.ButtonX)) CurrentButton |= HidControllerButtons.KEY_X;
RightJoystickDX = (int)(getJoystickAxisFromString(gamePad, Config.Controls_Right_FakeJoycon_GamePadJoystick_R).X * short.MaxValue); if (IsGamePadButtonPressedFromString(gamePad, Config.JoyConController.Right.ButtonY)) CurrentButton |= HidControllerButtons.KEY_Y;
if (IsGamePadButtonPressedFromString(gamePad, Config.JoyConController.Right.StickButton)) CurrentButton |= HidControllerButtons.KEY_RSTICK;
if (getJoystickAxisFromString(gamePad, Config.Controls_Right_FakeJoycon_GamePadJoystick_R).Y >= deadzone if (IsGamePadButtonPressedFromString(gamePad, Config.JoyConController.Right.ButtonPlus)) CurrentButton |= HidControllerButtons.KEY_PLUS;
|| getJoystickAxisFromString(gamePad, Config.Controls_Right_FakeJoycon_GamePadJoystick_R).Y <= -deadzone) if (IsGamePadButtonPressedFromString(gamePad, Config.JoyConController.Right.ButtonR)) CurrentButton |= HidControllerButtons.KEY_R;
RightJoystickDY = (int)(getJoystickAxisFromString(gamePad, Config.Controls_Right_FakeJoycon_GamePadJoystick_R).Y * short.MaxValue); if (IsGamePadButtonPressedFromString(gamePad, Config.JoyConController.Right.ButtonZR)) CurrentButton |= HidControllerButtons.KEY_ZR;
//LeftJoystick //LeftJoystick
if (getJoystickAxisFromString(gamePad, Config.Controls_Left_FakeJoycon_GamePadJoystick_L).X >= deadzone if (GetJoystickAxisFromString(gamePad, Config.JoyConController.Left.Stick).X >= deadzone
|| getJoystickAxisFromString(gamePad, Config.Controls_Left_FakeJoycon_GamePadJoystick_L).X <= -deadzone) || GetJoystickAxisFromString(gamePad, Config.JoyConController.Left.Stick).X <= -deadzone)
LeftJoystickDX = (int)(getJoystickAxisFromString(gamePad, Config.Controls_Left_FakeJoycon_GamePadJoystick_L).X * short.MaxValue); LeftJoystickDX = (int)(GetJoystickAxisFromString(gamePad, Config.JoyConController.Left.Stick).X * short.MaxValue);
if (getJoystickAxisFromString(gamePad, Config.Controls_Left_FakeJoycon_GamePadJoystick_L).Y >= deadzone if (GetJoystickAxisFromString(gamePad, Config.JoyConController.Left.Stick).Y >= deadzone
|| getJoystickAxisFromString(gamePad, Config.Controls_Left_FakeJoycon_GamePadJoystick_L).Y <= -deadzone) || GetJoystickAxisFromString(gamePad, Config.JoyConController.Left.Stick).Y <= -deadzone)
LeftJoystickDY = (int)(getJoystickAxisFromString(gamePad, Config.Controls_Left_FakeJoycon_GamePadJoystick_L).Y * short.MaxValue); LeftJoystickDY = (int)(GetJoystickAxisFromString(gamePad, Config.JoyConController.Left.Stick).Y * short.MaxValue);
//RightJoystick
if (GetJoystickAxisFromString(gamePad, Config.JoyConController.Right.Stick).X >= deadzone
|| GetJoystickAxisFromString(gamePad, Config.JoyConController.Right.Stick).X <= -deadzone)
RightJoystickDX = (int)(GetJoystickAxisFromString(gamePad, Config.JoyConController.Right.Stick).X * short.MaxValue);
if (GetJoystickAxisFromString(gamePad, Config.JoyConController.Right.Stick).Y >= deadzone
|| GetJoystickAxisFromString(gamePad, Config.JoyConController.Right.Stick).Y <= -deadzone)
RightJoystickDY = (int)(GetJoystickAxisFromString(gamePad, Config.JoyConController.Right.Stick).Y * short.MaxValue);
} }
LeftJoystick = new HidJoystickPosition LeftJoystick = new HidJoystickPosition