InputManager: Support inverted full axis
i.e. pedals
This commit is contained in:
@@ -59,6 +59,7 @@ add_library(core
|
||||
host_interface_progress_callback.cpp
|
||||
host_interface_progress_callback.h
|
||||
host_settings.h
|
||||
input_types.h
|
||||
interrupt_controller.cpp
|
||||
interrupt_controller.h
|
||||
libcrypt_serials.cpp
|
||||
|
||||
@@ -789,12 +789,12 @@ std::unique_ptr<AnalogController> AnalogController::Create(u32 index)
|
||||
static const Controller::ControllerBindingInfo s_binding_info[] = {
|
||||
#define BUTTON(name, display_name, button, genb) \
|
||||
{ \
|
||||
name, display_name, static_cast<u32>(button), Controller::ControllerBindingType::Button, genb \
|
||||
name, display_name, static_cast<u32>(button), InputBindingInfo::Type::Button, genb \
|
||||
}
|
||||
#define AXIS(name, display_name, halfaxis, genb) \
|
||||
{ \
|
||||
name, display_name, static_cast<u32>(AnalogController::Button::Count) + static_cast<u32>(halfaxis), \
|
||||
Controller::ControllerBindingType::HalfAxis, genb \
|
||||
InputBindingInfo::Type::HalfAxis, genb \
|
||||
}
|
||||
|
||||
BUTTON("Up", "D-Pad Up", AnalogController::Button::Up, GenericInputBinding::DPadUp),
|
||||
@@ -862,11 +862,11 @@ static const SettingInfo s_settings[] = {
|
||||
"functioning, try increasing this value."),
|
||||
"8", "0", "255", "1", "%d", nullptr, 1.0f},
|
||||
{SettingInfo::Type::IntegerList, "InvertLeftStick", TRANSLATABLE("AnalogController", "Invert Left Stick"),
|
||||
TRANSLATABLE("AnalogController", "Inverts the direction of the left analog stick."),
|
||||
"0", "0", "3", nullptr, nullptr, s_invert_settings, 0.0f},
|
||||
TRANSLATABLE("AnalogController", "Inverts the direction of the left analog stick."), "0", "0", "3", nullptr, nullptr,
|
||||
s_invert_settings, 0.0f},
|
||||
{SettingInfo::Type::IntegerList, "InvertRightStick", TRANSLATABLE("AnalogController", "Invert Right Stick"),
|
||||
TRANSLATABLE("AnalogController", "Inverts the direction of the right analog stick."),
|
||||
"0", "0", "3", nullptr, nullptr, s_invert_settings, 0.0f},
|
||||
TRANSLATABLE("AnalogController", "Inverts the direction of the right analog stick."), "0", "0", "3", nullptr,
|
||||
nullptr, s_invert_settings, 0.0f},
|
||||
};
|
||||
|
||||
const Controller::ControllerInfo AnalogController::INFO = {ControllerType::AnalogController,
|
||||
|
||||
@@ -335,12 +335,12 @@ std::unique_ptr<AnalogJoystick> AnalogJoystick::Create(u32 index)
|
||||
static const Controller::ControllerBindingInfo s_binding_info[] = {
|
||||
#define BUTTON(name, display_name, button, genb) \
|
||||
{ \
|
||||
name, display_name, static_cast<u32>(button), Controller::ControllerBindingType::Button, genb \
|
||||
name, display_name, static_cast<u32>(button), InputBindingInfo::Type::Button, genb \
|
||||
}
|
||||
#define AXIS(name, display_name, halfaxis, genb) \
|
||||
{ \
|
||||
name, display_name, static_cast<u32>(AnalogJoystick::Button::Count) + static_cast<u32>(halfaxis), \
|
||||
Controller::ControllerBindingType::HalfAxis, genb \
|
||||
InputBindingInfo::Type::HalfAxis, genb \
|
||||
}
|
||||
|
||||
BUTTON("Up", "D-Pad Up", AnalogJoystick::Button::Up, GenericInputBinding::DPadUp),
|
||||
@@ -391,11 +391,11 @@ static const SettingInfo s_settings[] = {
|
||||
"controllers, e.g. DualShock 4, Xbox One Controller."),
|
||||
"1.33f", "0.01f", "2.00f", "0.01f", "%.0f%%", nullptr, 100.0f},
|
||||
{SettingInfo::Type::IntegerList, "InvertLeftStick", TRANSLATABLE("AnalogJoystick", "Invert Left Stick"),
|
||||
TRANSLATABLE("AnalogJoystick", "Inverts the direction of the left analog stick."),
|
||||
"0", "0", "3", nullptr, nullptr, s_invert_settings, 0.0f},
|
||||
TRANSLATABLE("AnalogJoystick", "Inverts the direction of the left analog stick."), "0", "0", "3", nullptr, nullptr,
|
||||
s_invert_settings, 0.0f},
|
||||
{SettingInfo::Type::IntegerList, "InvertRightStick", TRANSLATABLE("AnalogJoystick", "Invert Right Stick"),
|
||||
TRANSLATABLE("AnalogJoystick", "Inverts the direction of the right analog stick."),
|
||||
"0", "0", "3", nullptr, nullptr, s_invert_settings, 0.0f},
|
||||
TRANSLATABLE("AnalogJoystick", "Inverts the direction of the right analog stick."), "0", "0", "3", nullptr, nullptr,
|
||||
s_invert_settings, 0.0f},
|
||||
};
|
||||
|
||||
const Controller::ControllerInfo AnalogJoystick::INFO = {ControllerType::AnalogJoystick,
|
||||
|
||||
@@ -148,7 +148,7 @@ std::vector<std::string> Controller::GetControllerBinds(const std::string_view&
|
||||
for (u32 i = 0; i < info->num_bindings; i++)
|
||||
{
|
||||
const ControllerBindingInfo& bi = info->bindings[i];
|
||||
if (bi.type == ControllerBindingType::Unknown || bi.type == ControllerBindingType::Motor)
|
||||
if (bi.type == InputBindingInfo::Type::Unknown || bi.type == InputBindingInfo::Type::Motor)
|
||||
continue;
|
||||
|
||||
ret.emplace_back(info->bindings[i].name);
|
||||
@@ -168,7 +168,7 @@ std::vector<std::string> Controller::GetControllerBinds(ControllerType type)
|
||||
for (u32 i = 0; i < info->num_bindings; i++)
|
||||
{
|
||||
const ControllerBindingInfo& bi = info->bindings[i];
|
||||
if (bi.type == ControllerBindingType::Unknown || bi.type == ControllerBindingType::Motor)
|
||||
if (bi.type == InputBindingInfo::Type::Unknown || bi.type == InputBindingInfo::Type::Motor)
|
||||
continue;
|
||||
|
||||
ret.emplace_back(info->bindings[i].name);
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
|
||||
#pragma once
|
||||
#include "common/image.h"
|
||||
#include "input_types.h"
|
||||
#include "settings.h"
|
||||
#include "types.h"
|
||||
#include <memory>
|
||||
@@ -16,21 +17,9 @@ class SettingsInterface;
|
||||
class StateWrapper;
|
||||
class HostInterface;
|
||||
|
||||
enum class GenericInputBinding : u8;
|
||||
|
||||
class Controller
|
||||
{
|
||||
public:
|
||||
enum class ControllerBindingType : u8
|
||||
{
|
||||
Unknown,
|
||||
Button,
|
||||
Axis,
|
||||
HalfAxis,
|
||||
Motor,
|
||||
Macro
|
||||
};
|
||||
|
||||
enum class VibrationCapabilities : u8
|
||||
{
|
||||
NoVibration,
|
||||
@@ -44,7 +33,7 @@ public:
|
||||
const char* name;
|
||||
const char* display_name;
|
||||
u32 bind_index;
|
||||
ControllerBindingType type;
|
||||
InputBindingInfo::Type type;
|
||||
GenericInputBinding generic_mapping;
|
||||
};
|
||||
|
||||
|
||||
@@ -128,6 +128,7 @@
|
||||
<ClInclude Include="host_display.h" />
|
||||
<ClInclude Include="host_interface_progress_callback.h" />
|
||||
<ClInclude Include="host_settings.h" />
|
||||
<ClInclude Include="input_types.h" />
|
||||
<ClInclude Include="interrupt_controller.h" />
|
||||
<ClInclude Include="libcrypt_serials.h" />
|
||||
<ClInclude Include="mdec.h" />
|
||||
|
||||
@@ -124,5 +124,6 @@
|
||||
<ClInclude Include="host_settings.h" />
|
||||
<ClInclude Include="achievements.h" />
|
||||
<ClInclude Include="game_database.h" />
|
||||
<ClInclude Include="input_types.h" />
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
@@ -146,7 +146,7 @@ std::unique_ptr<DigitalController> DigitalController::Create(u32 index)
|
||||
static const Controller::ControllerBindingInfo s_binding_info[] = {
|
||||
#define BUTTON(name, display_name, button, genb) \
|
||||
{ \
|
||||
name, display_name, static_cast<u32>(button), Controller::ControllerBindingType::Button, genb \
|
||||
name, display_name, static_cast<u32>(button), InputBindingInfo::Type::Button, genb \
|
||||
}
|
||||
|
||||
BUTTON("Up", "D-Pad Up", DigitalController::Button::Up, GenericInputBinding::DPadUp),
|
||||
|
||||
@@ -208,7 +208,7 @@ std::unique_ptr<GunCon> GunCon::Create(u32 index)
|
||||
static const Controller::ControllerBindingInfo s_binding_info[] = {
|
||||
#define BUTTON(name, display_name, button, genb) \
|
||||
{ \
|
||||
name, display_name, static_cast<u32>(button), Controller::ControllerBindingType::Button, genb \
|
||||
name, display_name, static_cast<u32>(button), InputBindingInfo::Type::Button, genb \
|
||||
}
|
||||
|
||||
BUTTON("Trigger", "Trigger", GunCon::Button::Trigger, GenericInputBinding::R2),
|
||||
|
||||
@@ -23,49 +23,6 @@ class CDImage;
|
||||
/// Marks a core string as being translatable.
|
||||
#define TRANSLATABLE(context, str) str
|
||||
|
||||
/// Generic input bindings. These roughly match a DualShock 4 or XBox One controller.
|
||||
/// They are used for automatic binding to PS2 controller types, and for big picture mode navigation.
|
||||
enum class GenericInputBinding : u8
|
||||
{
|
||||
Unknown,
|
||||
|
||||
DPadUp,
|
||||
DPadRight,
|
||||
DPadLeft,
|
||||
DPadDown,
|
||||
|
||||
LeftStickUp,
|
||||
LeftStickRight,
|
||||
LeftStickDown,
|
||||
LeftStickLeft,
|
||||
L3,
|
||||
|
||||
RightStickUp,
|
||||
RightStickRight,
|
||||
RightStickDown,
|
||||
RightStickLeft,
|
||||
R3,
|
||||
|
||||
Triangle, // Y on XBox pads.
|
||||
Circle, // B on XBox pads.
|
||||
Cross, // A on XBox pads.
|
||||
Square, // X on XBox pads.
|
||||
|
||||
Select, // Share on DS4, View on XBox pads.
|
||||
Start, // Options on DS4, Menu on XBox pads.
|
||||
System, // PS button on DS4, Guide button on XBox pads.
|
||||
|
||||
L1, // LB on Xbox pads.
|
||||
L2, // Left trigger on XBox pads.
|
||||
R1, // RB on XBox pads.
|
||||
R2, // Right trigger on Xbox pads.
|
||||
|
||||
SmallMotor, // High frequency vibration.
|
||||
LargeMotor, // Low frequency vibration.
|
||||
|
||||
Count,
|
||||
};
|
||||
|
||||
namespace Host {
|
||||
/// Reads a file from the resources directory of the application.
|
||||
/// This may be outside of the "normal" filesystem on platforms such as Mac.
|
||||
|
||||
71
src/core/input_types.h
Normal file
71
src/core/input_types.h
Normal file
@@ -0,0 +1,71 @@
|
||||
// SPDX-FileCopyrightText: 2022-2023 Connor McLaughlin <stenzek@gmail.com>
|
||||
// SPDX-License-Identifier: (GPL-3.0 OR CC-BY-NC-ND-4.0)
|
||||
|
||||
#pragma once
|
||||
#include "types.h"
|
||||
|
||||
enum class GenericInputBinding : u8;
|
||||
|
||||
struct InputBindingInfo
|
||||
{
|
||||
enum class Type : u8
|
||||
{
|
||||
Unknown,
|
||||
Button,
|
||||
Axis,
|
||||
HalfAxis,
|
||||
Motor,
|
||||
Pointer, // Receive relative mouse movement events, bind_index is offset by the axis.
|
||||
Macro,
|
||||
};
|
||||
|
||||
const char* name;
|
||||
const char* display_name;
|
||||
Type bind_type;
|
||||
u16 bind_index;
|
||||
GenericInputBinding generic_mapping;
|
||||
};
|
||||
|
||||
/// Generic input bindings. These roughly match a DualShock 4 or XBox One controller.
|
||||
/// They are used for automatic binding to PS2 controller types, and for big picture mode navigation.
|
||||
enum class GenericInputBinding : u8
|
||||
{
|
||||
Unknown,
|
||||
|
||||
DPadUp,
|
||||
DPadRight,
|
||||
DPadLeft,
|
||||
DPadDown,
|
||||
|
||||
LeftStickUp,
|
||||
LeftStickRight,
|
||||
LeftStickDown,
|
||||
LeftStickLeft,
|
||||
L3,
|
||||
|
||||
RightStickUp,
|
||||
RightStickRight,
|
||||
RightStickDown,
|
||||
RightStickLeft,
|
||||
R3,
|
||||
|
||||
Triangle, // Y on XBox pads.
|
||||
Circle, // B on XBox pads.
|
||||
Cross, // A on XBox pads.
|
||||
Square, // X on XBox pads.
|
||||
|
||||
Select, // Share on DS4, View on XBox pads.
|
||||
Start, // Options on DS4, Menu on XBox pads.
|
||||
System, // PS button on DS4, Guide button on XBox pads.
|
||||
|
||||
L1, // LB on Xbox pads.
|
||||
L2, // Left trigger on XBox pads.
|
||||
R1, // RB on XBox pads.
|
||||
R2, // Right trigger on Xbox pads.
|
||||
|
||||
SmallMotor, // High frequency vibration.
|
||||
LargeMotor, // Low frequency vibration.
|
||||
|
||||
Count,
|
||||
};
|
||||
|
||||
@@ -228,12 +228,12 @@ std::unique_ptr<NeGcon> NeGcon::Create(u32 index)
|
||||
static const Controller::ControllerBindingInfo s_binding_info[] = {
|
||||
#define BUTTON(name, display_name, button, genb) \
|
||||
{ \
|
||||
name, display_name, static_cast<u32>(button), Controller::ControllerBindingType::Button, genb \
|
||||
name, display_name, static_cast<u32>(button), InputBindingInfo::Type::Button, genb \
|
||||
}
|
||||
#define AXIS(name, display_name, halfaxis, genb) \
|
||||
{ \
|
||||
name, display_name, static_cast<u32>(NeGcon::Button::Count) + static_cast<u32>(halfaxis), \
|
||||
Controller::ControllerBindingType::HalfAxis, genb \
|
||||
InputBindingInfo::Type::HalfAxis, genb \
|
||||
}
|
||||
|
||||
BUTTON("Up", "D-Pad Up", NeGcon::Button::Up, GenericInputBinding::DPadUp),
|
||||
|
||||
@@ -179,7 +179,7 @@ std::unique_ptr<PlayStationMouse> PlayStationMouse::Create(u32 index)
|
||||
static const Controller::ControllerBindingInfo s_binding_info[] = {
|
||||
#define BUTTON(name, display_name, button, genb) \
|
||||
{ \
|
||||
name, display_name, static_cast<u32>(button), Controller::ControllerBindingType::Button, genb \
|
||||
name, display_name, static_cast<u32>(button), InputBindingInfo::Type::Button, genb \
|
||||
}
|
||||
|
||||
BUTTON("Left", "Left Button", PlayStationMouse::Button::Left, GenericInputBinding::Cross),
|
||||
|
||||
Reference in New Issue
Block a user