early-access version 2233
This commit is contained in:
parent
ea40d85df3
commit
98868d5d3a
@ -1,7 +1,7 @@
|
||||
yuzu emulator early access
|
||||
=============
|
||||
|
||||
This is the source code for early-access 2232.
|
||||
This is the source code for early-access 2233.
|
||||
|
||||
## Legal Notice
|
||||
|
||||
|
@ -175,6 +175,28 @@ struct LedStatus {
|
||||
bool led_4{};
|
||||
};
|
||||
|
||||
// List of buttons to be passed to Qt that can be translated
|
||||
enum class ButtonNames {
|
||||
Undefined,
|
||||
Invalid,
|
||||
// This will display the engine name instead of the button name
|
||||
Engine,
|
||||
// This will display the button by value instead of the button name
|
||||
Value,
|
||||
ButtonLeft,
|
||||
ButtonRight,
|
||||
ButtonDown,
|
||||
ButtonUp,
|
||||
TriggerZ,
|
||||
TriggerR,
|
||||
TriggerL,
|
||||
ButtonA,
|
||||
ButtonB,
|
||||
ButtonX,
|
||||
ButtonY,
|
||||
ButtonStart,
|
||||
};
|
||||
|
||||
// Callback data consisting of an input type and the equivalent data status
|
||||
struct CallbackStatus {
|
||||
InputType type{InputType::None};
|
||||
|
@ -481,47 +481,47 @@ AnalogMapping GCAdapter::GetAnalogMappingForDevice(const Common::ParamPackage& p
|
||||
return mapping;
|
||||
}
|
||||
|
||||
std::string GCAdapter::GetUIButtonName(const Common::ParamPackage& params) const {
|
||||
Common::Input::ButtonNames GCAdapter::GetUIButtonName(const Common::ParamPackage& params) const {
|
||||
PadButton button = static_cast<PadButton>(params.Get("button", 0));
|
||||
switch (button) {
|
||||
case PadButton::ButtonLeft:
|
||||
return "left";
|
||||
return Common::Input::ButtonNames::ButtonLeft;
|
||||
case PadButton::ButtonRight:
|
||||
return "right";
|
||||
return Common::Input::ButtonNames::ButtonRight;
|
||||
case PadButton::ButtonDown:
|
||||
return "down";
|
||||
return Common::Input::ButtonNames::ButtonDown;
|
||||
case PadButton::ButtonUp:
|
||||
return "up";
|
||||
return Common::Input::ButtonNames::ButtonUp;
|
||||
case PadButton::TriggerZ:
|
||||
return "Z";
|
||||
return Common::Input::ButtonNames::TriggerZ;
|
||||
case PadButton::TriggerR:
|
||||
return "R";
|
||||
return Common::Input::ButtonNames::TriggerR;
|
||||
case PadButton::TriggerL:
|
||||
return "L";
|
||||
return Common::Input::ButtonNames::TriggerL;
|
||||
case PadButton::ButtonA:
|
||||
return "A";
|
||||
return Common::Input::ButtonNames::ButtonA;
|
||||
case PadButton::ButtonB:
|
||||
return "B";
|
||||
return Common::Input::ButtonNames::ButtonB;
|
||||
case PadButton::ButtonX:
|
||||
return "X";
|
||||
return Common::Input::ButtonNames::ButtonX;
|
||||
case PadButton::ButtonY:
|
||||
return "Y";
|
||||
return Common::Input::ButtonNames::ButtonY;
|
||||
case PadButton::ButtonStart:
|
||||
return "start";
|
||||
return Common::Input::ButtonNames::ButtonStart;
|
||||
default:
|
||||
return "Unknown GC";
|
||||
return Common::Input::ButtonNames::Undefined;
|
||||
}
|
||||
}
|
||||
|
||||
std::string GCAdapter::GetUIName(const Common::ParamPackage& params) const {
|
||||
Common::Input::ButtonNames GCAdapter::GetUIName(const Common::ParamPackage& params) const {
|
||||
if (params.Has("button")) {
|
||||
return fmt::format("Button {}", GetUIButtonName(params));
|
||||
return GetUIButtonName(params);
|
||||
}
|
||||
if (params.Has("axis")) {
|
||||
return fmt::format("Axis {}", params.Get("axis", 0));
|
||||
return Common::Input::ButtonNames::Value;
|
||||
}
|
||||
|
||||
return "Bad GC Adapter";
|
||||
return Common::Input::ButtonNames::Invalid;
|
||||
}
|
||||
|
||||
} // namespace InputCommon
|
||||
|
@ -34,7 +34,7 @@ public:
|
||||
std::vector<Common::ParamPackage> GetInputDevices() const override;
|
||||
ButtonMapping GetButtonMappingForDevice(const Common::ParamPackage& params) override;
|
||||
AnalogMapping GetAnalogMappingForDevice(const Common::ParamPackage& params) override;
|
||||
std::string GetUIName(const Common::ParamPackage& params) const override;
|
||||
Common::Input::ButtonNames GetUIName(const Common::ParamPackage& params) const override;
|
||||
|
||||
private:
|
||||
enum class PadButton {
|
||||
@ -112,7 +112,7 @@ private:
|
||||
/// Updates vibration state of all controllers
|
||||
void SendVibrations();
|
||||
|
||||
std::string GetUIButtonName(const Common::ParamPackage& params) const;
|
||||
Common::Input::ButtonNames GetUIButtonName(const Common::ParamPackage& params) const;
|
||||
|
||||
std::unique_ptr<LibUSBDeviceHandle> usb_adapter_handle;
|
||||
std::array<GCController, 4> pads;
|
||||
|
@ -171,12 +171,12 @@ AnalogMapping Mouse::GetAnalogMappingForDevice(
|
||||
return mapping;
|
||||
}
|
||||
|
||||
std::string Mouse::GetUIName(const Common::ParamPackage& params) const {
|
||||
Common::Input::ButtonNames Mouse::GetUIName(const Common::ParamPackage& params) const {
|
||||
if (params.Has("button")) {
|
||||
return fmt::format("Mouse {}", params.Get("button", 0));
|
||||
return Common::Input::ButtonNames::Value;
|
||||
}
|
||||
|
||||
return "Bad Mouse";
|
||||
return Common::Input::ButtonNames::Invalid;
|
||||
}
|
||||
|
||||
} // namespace InputCommon
|
||||
|
@ -63,7 +63,7 @@ public:
|
||||
|
||||
std::vector<Common::ParamPackage> GetInputDevices() const override;
|
||||
AnalogMapping GetAnalogMappingForDevice(const Common::ParamPackage& params) override;
|
||||
std::string GetUIName(const Common::ParamPackage& params) const override;
|
||||
Common::Input::ButtonNames GetUIName(const Common::ParamPackage& params) const override;
|
||||
|
||||
private:
|
||||
void UpdateThread(std::stop_token stop_token);
|
||||
|
@ -220,24 +220,6 @@ public:
|
||||
return "Unknown";
|
||||
}
|
||||
|
||||
bool IsYAxis(u8 index) {
|
||||
if (!sdl_controller) {
|
||||
return false;
|
||||
}
|
||||
|
||||
const auto& binding_left_y =
|
||||
SDL_GameControllerGetBindForAxis(sdl_controller.get(), SDL_CONTROLLER_AXIS_LEFTY);
|
||||
const auto& binding_right_y =
|
||||
SDL_GameControllerGetBindForAxis(sdl_controller.get(), SDL_CONTROLLER_AXIS_RIGHTY);
|
||||
if (index == binding_left_y.value.axis) {
|
||||
return true;
|
||||
}
|
||||
if (index == binding_right_y.value.axis) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private:
|
||||
std::string guid;
|
||||
int port;
|
||||
@ -376,11 +358,6 @@ void SDLDriver::HandleGameControllerEvent(const SDL_Event& event) {
|
||||
case SDL_JOYAXISMOTION: {
|
||||
if (const auto joystick = GetSDLJoystickBySDLID(event.jaxis.which)) {
|
||||
const PadIdentifier identifier = joystick->GetPadIdentifier();
|
||||
// Vertical axis is inverted on nintendo compared to SDL
|
||||
if (joystick->IsYAxis(event.jaxis.axis)) {
|
||||
SetAxis(identifier, event.jaxis.axis, -event.jaxis.value / 32767.0f);
|
||||
break;
|
||||
}
|
||||
SetAxis(identifier, event.jaxis.axis, event.jaxis.value / 32767.0f);
|
||||
}
|
||||
break;
|
||||
@ -892,26 +869,25 @@ MotionMapping SDLDriver::GetMotionMappingForDevice(const Common::ParamPackage& p
|
||||
return mapping;
|
||||
}
|
||||
|
||||
std::string SDLDriver::GetUIName(const Common::ParamPackage& params) const {
|
||||
Common::Input::ButtonNames SDLDriver::GetUIName(const Common::ParamPackage& params) const {
|
||||
if (params.Has("button")) {
|
||||
// TODO(German77): Find how to substitue the values for real button names
|
||||
return fmt::format("Button {}", params.Get("button", 0));
|
||||
return Common::Input::ButtonNames::Value;
|
||||
}
|
||||
if (params.Has("hat")) {
|
||||
return fmt::format("Hat {}", params.Get("direction", ""));
|
||||
return Common::Input::ButtonNames::Value;
|
||||
}
|
||||
if (params.Has("axis")) {
|
||||
return fmt::format("Axis {}", params.Get("axis", ""));
|
||||
return Common::Input::ButtonNames::Value;
|
||||
}
|
||||
if (params.Has("axis_x") && params.Has("axis_y") && params.Has("axis_z")) {
|
||||
return fmt::format("Axis {},{},{}", params.Get("axis_x", ""), params.Get("axis_y", ""),
|
||||
params.Get("axis_z", ""));
|
||||
return Common::Input::ButtonNames::Value;
|
||||
}
|
||||
if (params.Has("motion")) {
|
||||
return "SDL motion";
|
||||
return Common::Input::ButtonNames::Engine;
|
||||
}
|
||||
|
||||
return "Bad SDL";
|
||||
return Common::Input::ButtonNames::Invalid;
|
||||
}
|
||||
|
||||
std::string SDLDriver::GetHatButtonName(u8 direction_value) const {
|
||||
|
@ -53,7 +53,7 @@ public:
|
||||
ButtonMapping GetButtonMappingForDevice(const Common::ParamPackage& params) override;
|
||||
AnalogMapping GetAnalogMappingForDevice(const Common::ParamPackage& params) override;
|
||||
MotionMapping GetMotionMappingForDevice(const Common::ParamPackage& params) override;
|
||||
std::string GetUIName(const Common::ParamPackage& params) const override;
|
||||
Common::Input::ButtonNames GetUIName(const Common::ParamPackage& params) const override;
|
||||
|
||||
std::string GetHatButtonName(u8 direction_value) const override;
|
||||
u8 GetHatButtonId(const std::string& direction_name) const override;
|
||||
|
@ -161,8 +161,9 @@ public:
|
||||
};
|
||||
|
||||
/// Retrieves the name of the given input.
|
||||
virtual std::string GetUIName([[maybe_unused]] const Common::ParamPackage& params) const {
|
||||
return GetEngineName();
|
||||
virtual Common::Input::ButtonNames GetUIName(
|
||||
[[maybe_unused]] const Common::ParamPackage& params) const {
|
||||
return Common::Input::ButtonNames::Engine;
|
||||
};
|
||||
|
||||
/// Retrieves the index number of the given hat button direction
|
||||
|
@ -146,7 +146,8 @@ public:
|
||||
Common::Input::AnalogProperties properties_y_,
|
||||
InputEngine* input_engine_)
|
||||
: identifier(identifier_), axis_x(axis_x_), axis_y(axis_y_), properties_x(properties_x_),
|
||||
properties_y(properties_y_), input_engine(input_engine_) {
|
||||
properties_y(properties_y_),
|
||||
input_engine(input_engine_), invert_axis_y{input_engine_->GetEngineName() == "sdl"} {
|
||||
UpdateCallback engine_callback{[this]() { OnChange(); }};
|
||||
const InputIdentifier x_input_identifier{
|
||||
.identifier = identifier,
|
||||
@ -181,6 +182,11 @@ public:
|
||||
.raw_value = input_engine->GetAxis(identifier, axis_y),
|
||||
.properties = properties_y,
|
||||
};
|
||||
// This is a workaround too keep compatibility with old yuzu versions. Vertical axis is
|
||||
// inverted on SDL compared to Nintendo
|
||||
if (invert_axis_y) {
|
||||
status.y.raw_value = -status.y.raw_value;
|
||||
}
|
||||
return status;
|
||||
}
|
||||
|
||||
@ -220,6 +226,7 @@ private:
|
||||
float last_axis_x_value;
|
||||
float last_axis_y_value;
|
||||
InputEngine* input_engine;
|
||||
const bool invert_axis_y;
|
||||
};
|
||||
|
||||
class InputFromTouch final : public Common::Input::InputDevice {
|
||||
|
@ -205,9 +205,9 @@ struct InputSubsystem::Impl {
|
||||
return {};
|
||||
}
|
||||
|
||||
std::string GetButtonName(const Common::ParamPackage& params) const {
|
||||
Common::Input::ButtonNames GetButtonName(const Common::ParamPackage& params) const {
|
||||
if (!params.Has("engine") || params.Get("engine", "") == "any") {
|
||||
return "Unknown";
|
||||
return Common::Input::ButtonNames::Undefined;
|
||||
}
|
||||
const std::string engine = params.Get("engine", "");
|
||||
if (engine == mouse->GetEngineName()) {
|
||||
@ -227,7 +227,7 @@ struct InputSubsystem::Impl {
|
||||
return sdl->GetUIName(params);
|
||||
}
|
||||
#endif
|
||||
return "Bad engine";
|
||||
return Common::Input::ButtonNames::Invalid;
|
||||
}
|
||||
|
||||
bool IsController(const Common::ParamPackage& params) {
|
||||
@ -361,15 +361,8 @@ MotionMapping InputSubsystem::GetMotionMappingForDevice(const Common::ParamPacka
|
||||
return impl->GetMotionMappingForDevice(device);
|
||||
}
|
||||
|
||||
std::string InputSubsystem::GetButtonName(const Common::ParamPackage& params) const {
|
||||
const std::string toggle = params.Get("toggle", false) ? "~" : "";
|
||||
const std::string inverted = params.Get("inverted", false) ? "!" : "";
|
||||
const std::string button_name = impl->GetButtonName(params);
|
||||
std::string axis_direction = "";
|
||||
if (params.Has("axis")) {
|
||||
axis_direction = params.Get("invert", "+");
|
||||
}
|
||||
return fmt::format("{}{}{}{}", toggle, inverted, button_name, axis_direction);
|
||||
Common::Input::ButtonNames InputSubsystem::GetButtonName(const Common::ParamPackage& params) const {
|
||||
return impl->GetButtonName(params);
|
||||
}
|
||||
|
||||
bool InputSubsystem::IsController(const Common::ParamPackage& params) const {
|
||||
|
@ -13,6 +13,10 @@ namespace Common {
|
||||
class ParamPackage;
|
||||
}
|
||||
|
||||
namespace Common::Input {
|
||||
enum class ButtonNames;
|
||||
}
|
||||
|
||||
namespace Settings::NativeAnalog {
|
||||
enum Values : int;
|
||||
}
|
||||
@ -108,8 +112,9 @@ public:
|
||||
/// Retrieves the motion mappings for the given device.
|
||||
[[nodiscard]] MotionMapping GetMotionMappingForDevice(const Common::ParamPackage& device) const;
|
||||
|
||||
/// Returns a string contaning the name of the button from the input engine.
|
||||
[[nodiscard]] std::string GetButtonName(const Common::ParamPackage& params) const;
|
||||
/// Returns an enum contaning the name to be displayed from the input engine.
|
||||
[[nodiscard]] Common::Input::ButtonNames GetButtonName(
|
||||
const Common::ParamPackage& params) const;
|
||||
|
||||
/// Returns true if device is a controller.
|
||||
[[nodiscard]] bool IsController(const Common::ParamPackage& params) const;
|
||||
|
@ -10,8 +10,9 @@ layout(binding = 0) uniform sampler2D color_texture;
|
||||
void main() {
|
||||
ivec2 coord = ivec2(gl_FragCoord.xy);
|
||||
uvec4 color = uvec4(texelFetch(color_texture, coord, 0).rgba * (exp2(8) - 1.0f));
|
||||
uint depth_unorm = (color.r << 16) | (color.g << 8) | color.b;
|
||||
uvec4 bytes = color << uvec4(24, 16, 8, 0);
|
||||
uint depth_stencil_unorm = bytes.x | bytes.y | bytes.z | bytes.w;
|
||||
|
||||
gl_FragDepth = float(depth_unorm) / (exp2(24.0) - 1.0f);
|
||||
gl_FragStencilRefARB = int(color.a);
|
||||
gl_FragDepth = float(depth_stencil_unorm & 0x00FFFFFFu) / (exp2(24.0) - 1.0f);
|
||||
gl_FragStencilRefARB = int(depth_stencil_unorm >> 24);
|
||||
}
|
||||
|
@ -7,13 +7,21 @@
|
||||
|
||||
layout(binding = 0) uniform sampler2D color_texture;
|
||||
|
||||
uint conv_from_float(float value_f, uint mantissa_bits) {
|
||||
uint value = floatBitsToInt(value_f);
|
||||
uint exp = (value >> 23) & 0x1Fu;
|
||||
uint mantissa_shift = 32u - mantissa_bits;
|
||||
uint mantissa = (value << 9u) >> mantissa_shift;
|
||||
return (exp << mantissa_bits) | mantissa;
|
||||
}
|
||||
|
||||
void main() {
|
||||
ivec2 coord = ivec2(gl_FragCoord.xy);
|
||||
vec4 color = texelFetch(color_texture, coord, 0).rgba;
|
||||
uint depth_stencil_unorm = (uint(color.b * (exp2(10) - 1.0f)) << 22)
|
||||
| (uint(color.g * (exp2(11) - 1.0f)) << 11)
|
||||
| (uint(color.r * (exp2(11) - 1.0f)));
|
||||
uint depth_stencil_unorm = (conv_from_float(color.r, 6u) << 21)
|
||||
| (conv_from_float(color.g, 6u) << 10)
|
||||
| conv_from_float(color.b, 5u);
|
||||
|
||||
gl_FragDepth = float(depth_stencil_unorm >> 8) / (exp2(24.0) - 1.0f);
|
||||
gl_FragStencilRefARB = int(depth_stencil_unorm & 0x00FF);
|
||||
gl_FragDepth = float(depth_stencil_unorm & 0x00FFFFFFu) / (exp2(24.0) - 1.0f);
|
||||
gl_FragStencilRefARB = int(depth_stencil_unorm >> 24);
|
||||
}
|
||||
|
@ -14,8 +14,10 @@ void main() {
|
||||
uint depth = uint(textureLod(depth_tex, coord, 0).r * (exp2(24.0) - 1.0f));
|
||||
uint stencil = uint(textureLod(stencil_tex, coord, 0).r);
|
||||
|
||||
color.r = float(depth >> 16) / (exp2(8) - 1.0);
|
||||
color.g = float((depth >> 8) & 0x00FF) / (exp2(8) - 1.0);
|
||||
color.b = float(depth & 0x00FF) / (exp2(8) - 1.0);
|
||||
color.a = float(stencil) / (exp2(8) - 1.0);
|
||||
highp uint depth_val =
|
||||
uint(textureLod(depth_tex, coord, 0).r * (exp2(32.0) - 1.0));
|
||||
lowp uint stencil_val = textureLod(stencil_tex, coord, 0).r;
|
||||
highp uvec4 components =
|
||||
uvec4(stencil_val, (uvec3(depth_val) >> uvec3(24u, 16u, 8u)) & 0x000000FFu);
|
||||
color = vec4(components) / (exp2(8.0) - 1.0);
|
||||
}
|
||||
|
@ -9,13 +9,24 @@ layout(binding = 1) uniform isampler2D stencil_tex;
|
||||
|
||||
layout(location = 0) out vec4 color;
|
||||
|
||||
float conv_to_float(uint value, uint mantissa_bits) {
|
||||
uint exp = (value >> mantissa_bits) & 0x1Fu;
|
||||
uint mantissa_shift = 32u - mantissa_bits;
|
||||
uint mantissa = (value << mantissa_shift) >> mantissa_shift;
|
||||
return uintBitsToFloat((exp << 23) | (mantissa << (23 - mantissa_bits)));
|
||||
}
|
||||
|
||||
void main() {
|
||||
ivec2 coord = ivec2(gl_FragCoord.xy);
|
||||
uint depth = uint(textureLod(depth_tex, coord, 0).r * (exp2(24.0) - 1.0f));
|
||||
uint depth = uint(textureLod(depth_tex, coord, 0).r * (exp2(32.0) - 1.0f));
|
||||
uint stencil = uint(textureLod(stencil_tex, coord, 0).r);
|
||||
uint depth_stencil = (stencil << 24) | (depth >> 8);
|
||||
uint red_int = (depth_stencil >> 21) & 0x07FF;
|
||||
uint green_int = (depth_stencil >> 10) & 0x07FF;
|
||||
uint blue_int = depth_stencil & 0x03FF;
|
||||
|
||||
color.b = float(depth >> 22) / (exp2(10) - 1.0);
|
||||
color.g = float((depth >> 11) & 0x00FF) / (exp2(11) - 1.0);
|
||||
color.r = float(depth & 0x00FF) / (exp2(11) - 1.0);
|
||||
color.r = conv_to_float(red_int, 6u);
|
||||
color.g = conv_to_float(green_int, 6u);
|
||||
color.b = conv_to_float(blue_int, 5u);
|
||||
color.a = 1.0f;
|
||||
}
|
||||
|
@ -11,11 +11,12 @@ layout(location = 0) out vec4 color;
|
||||
|
||||
void main() {
|
||||
ivec2 coord = ivec2(gl_FragCoord.xy);
|
||||
uint depth = uint(textureLod(depth_tex, coord, 0).r * (exp2(24.0) - 1.0f));
|
||||
uint depth = uint(textureLod(depth_tex, coord, 0).r * (exp2(32.0) - 1.0f));
|
||||
uint stencil = uint(textureLod(stencil_tex, coord, 0).r);
|
||||
uint depth_stencil = (stencil << 24) | (depth >> 8);
|
||||
|
||||
color.r = float(depth >> 16) / (exp2(16) - 1.0);
|
||||
color.g = float((depth >> 16) & 0x00FF) / (exp2(16) - 1.0);
|
||||
color.r = float(depth_stencil & 0x0000FFFFu) / (exp2(16) - 1.0);
|
||||
color.g = float(depth_stencil >> 16) / (exp2(16) - 1.0);
|
||||
color.b = 0.0f;
|
||||
color.a = 1.0f;
|
||||
}
|
||||
|
@ -10,9 +10,10 @@ layout(binding = 0) uniform sampler2D color_texture;
|
||||
void main() {
|
||||
ivec2 coord = ivec2(gl_FragCoord.xy);
|
||||
vec4 color = texelFetch(color_texture, coord, 0).rgba;
|
||||
uint depth_stencil_unorm = (uint(color.r * (exp2(16) - 1.0f)) << 16)
|
||||
| (uint(color.g * (exp2(16) - 1.0f)) << 16);
|
||||
uvec2 bytes = uvec2(color.rg * (exp2(16) - 1.0f)) << uvec2(0, 16);
|
||||
uint depth_stencil_unorm =
|
||||
uint(color.r * (exp2(16) - 1.0f)) | (uint(color.g * (exp2(16) - 1.0f)) << 16);
|
||||
|
||||
gl_FragDepth = float(depth_stencil_unorm >> 8) / (exp2(24.0) - 1.0f);
|
||||
gl_FragStencilRefARB = int(depth_stencil_unorm & 0x00FF);
|
||||
gl_FragDepth = float(depth_stencil_unorm & 0x00FFFFFFu) / (exp2(24.0) - 1.0f);
|
||||
gl_FragStencilRefARB = int(depth_stencil_unorm >> 24);
|
||||
}
|
||||
|
@ -775,8 +775,13 @@ StagingBufferRef TextureCacheRuntime::DownloadStagingBuffer(size_t size) {
|
||||
|
||||
bool TextureCacheRuntime::ShouldReinterpret(Image& dst, Image& src) {
|
||||
if (VideoCore::Surface::GetFormatType(dst.info.format) ==
|
||||
VideoCore::Surface::SurfaceType::DepthStencil) {
|
||||
return !device.IsExtShaderStencilExportSupported();
|
||||
VideoCore::Surface::SurfaceType::DepthStencil &&
|
||||
!device.IsExtShaderStencilExportSupported()) {
|
||||
return true;
|
||||
}
|
||||
if (dst.info.format == PixelFormat::D32_FLOAT_S8_UINT ||
|
||||
src.info.format == PixelFormat::D32_FLOAT_S8_UINT) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
@ -52,6 +52,37 @@ QString GetKeyName(int key_code) {
|
||||
}
|
||||
}
|
||||
|
||||
QString GetButtonName(Common::Input::ButtonNames button_name) {
|
||||
switch (button_name) {
|
||||
case Common::Input::ButtonNames::ButtonLeft:
|
||||
return QObject::tr("Left");
|
||||
case Common::Input::ButtonNames::ButtonRight:
|
||||
return QObject::tr("Right");
|
||||
case Common::Input::ButtonNames::ButtonDown:
|
||||
return QObject::tr("Down");
|
||||
case Common::Input::ButtonNames::ButtonUp:
|
||||
return QObject::tr("Up");
|
||||
case Common::Input::ButtonNames::TriggerZ:
|
||||
return QObject::tr("Z");
|
||||
case Common::Input::ButtonNames::TriggerR:
|
||||
return QObject::tr("R");
|
||||
case Common::Input::ButtonNames::TriggerL:
|
||||
return QObject::tr("L");
|
||||
case Common::Input::ButtonNames::ButtonA:
|
||||
return QObject::tr("A");
|
||||
case Common::Input::ButtonNames::ButtonB:
|
||||
return QObject::tr("B");
|
||||
case Common::Input::ButtonNames::ButtonX:
|
||||
return QObject::tr("X");
|
||||
case Common::Input::ButtonNames::ButtonY:
|
||||
return QObject::tr("Y");
|
||||
case Common::Input::ButtonNames::ButtonStart:
|
||||
return QObject::tr("Start");
|
||||
default:
|
||||
return QObject::tr("[undefined]");
|
||||
}
|
||||
}
|
||||
|
||||
void SetAnalogParam(const Common::ParamPackage& input_param, Common::ParamPackage& analog_param,
|
||||
const std::string& button_name) {
|
||||
// The poller returned a complete axis, so set all the buttons
|
||||
@ -75,15 +106,64 @@ QString ConfigureInputPlayer::ButtonToText(const Common::ParamPackage& param) {
|
||||
return QObject::tr("[not set]");
|
||||
}
|
||||
|
||||
const QString toggle = QString::fromStdString(param.Get("toggle", false) ? "~" : "");
|
||||
const QString inverted = QString::fromStdString(param.Get("inverted", false) ? "!" : "");
|
||||
const auto common_button_name = input_subsystem->GetButtonName(param);
|
||||
|
||||
// Retrieve the names from Qt
|
||||
if (param.Get("engine", "") == "keyboard") {
|
||||
const QString button_str = GetKeyName(param.Get("code", 0));
|
||||
const QString toggle = QString::fromStdString(param.Get("toggle", false) ? "~" : "");
|
||||
return QObject::tr("%1%2").arg(toggle, button_str);
|
||||
}
|
||||
|
||||
std::string button_name = input_subsystem->GetButtonName(param);
|
||||
return QString::fromStdString(button_name);
|
||||
if (common_button_name == Common::Input::ButtonNames::Invalid) {
|
||||
return QObject::tr("[invalid]");
|
||||
}
|
||||
|
||||
if (common_button_name == Common::Input::ButtonNames::Engine) {
|
||||
return QString::fromStdString(param.Get("engine", ""));
|
||||
}
|
||||
|
||||
if (common_button_name == Common::Input::ButtonNames::Value) {
|
||||
if (param.Has("hat")) {
|
||||
const QString hat = QString::fromStdString(param.Get("direction", ""));
|
||||
return QObject::tr("%1%2Hat %3").arg(toggle, inverted, hat);
|
||||
}
|
||||
if (param.Has("axis")) {
|
||||
const QString axis = QString::fromStdString(param.Get("axis", ""));
|
||||
return QObject::tr("%1%2Axis %3").arg(toggle, inverted, axis);
|
||||
}
|
||||
if (param.Has("axis_x") && param.Has("axis_y") && param.Has("axis_z")) {
|
||||
const QString axis_x = QString::fromStdString(param.Get("axis_x", ""));
|
||||
const QString axis_y = QString::fromStdString(param.Get("axis_y", ""));
|
||||
const QString axis_z = QString::fromStdString(param.Get("axis_z", ""));
|
||||
return QObject::tr("%1%2Axis %3,%4,%5").arg(toggle, inverted, axis_x, axis_y, axis_z);
|
||||
}
|
||||
if (param.Has("motion")) {
|
||||
const QString motion = QString::fromStdString(param.Get("motion", ""));
|
||||
return QObject::tr("%1%2Motion %3").arg(toggle, inverted, motion);
|
||||
}
|
||||
if (param.Has("button")) {
|
||||
const QString button = QString::fromStdString(param.Get("button", ""));
|
||||
return QObject::tr("%1%2Button %3").arg(toggle, inverted, button);
|
||||
}
|
||||
}
|
||||
|
||||
QString button_name = GetButtonName(common_button_name);
|
||||
if (param.Has("hat")) {
|
||||
return QObject::tr("%1%2Hat %3").arg(toggle, inverted, button_name);
|
||||
}
|
||||
if (param.Has("axis")) {
|
||||
return QObject::tr("%1%2Axis %3").arg(toggle, inverted, button_name);
|
||||
}
|
||||
if (param.Has("motion")) {
|
||||
return QObject::tr("%1%2Axis %3").arg(toggle, inverted, button_name);
|
||||
}
|
||||
if (param.Has("button")) {
|
||||
return QObject::tr("%1%2Button %3").arg(toggle, inverted, button_name);
|
||||
}
|
||||
|
||||
return QObject::tr("[unknown]");
|
||||
}
|
||||
|
||||
QString ConfigureInputPlayer::AnalogToText(const Common::ParamPackage& param,
|
||||
|
Loading…
Reference in New Issue
Block a user