ImGuiManager: Use PromptFont icons for input OSD

This commit is contained in:
Stenzek 2023-11-26 20:30:10 +10:00
parent 8446856ecf
commit fc6359457b
No known key found for this signature in database
17 changed files with 352 additions and 178 deletions

Binary file not shown.

View file

@ -367,6 +367,101 @@ either in source code form or as a compiled binary, for any purpose, commercial
and by any means.
</pre>
<h3>PromptFont - </h3><a href="https://shinmera.github.io/promptfont/">https://shinmera.github.io/promptfont/</a></h3>
<pre>
This Font Software is licensed under the SIL Open Font License,
Version 1.1. This license is copied below, and is also available
with a FAQ at <http: //scripts.sil.org/OFL>
-----------------------------------------------------------
SIL OPEN FONT LICENSE Version 1.1 - 26 February 2007
-----------------------------------------------------------
PREAMBLE
The goals of the Open Font License (OFL) are to stimulate worldwide
development of collaborative font projects, to support the font creation
efforts of academic and linguistic communities, and to provide a free and
open framework in which fonts may be shared and improved in partnership
with others.
The OFL allows the licensed fonts to be used, studied, modified and
redistributed freely as long as they are not sold by themselves. The
fonts, including any derivative works, can be bundled, embedded,
redistributed and/or sold with any software provided that any reserved
names are not used by derivative works. The fonts and derivatives,
however, cannot be released under any other type of license. The
requirement for fonts to remain under this license does not apply
to any document created using the fonts or their derivatives.
DEFINITIONS
"Font Software" refers to the set of files released by the Copyright
Holder(s) under this license and clearly marked as such. This may
include source files, build scripts and documentation.
"Reserved Font Name" refers to any names specified as such after the
copyright statement(s).
"Original Version" refers to the collection of Font Software components as
distributed by the Copyright Holder(s).
"Modified Version" refers to any derivative made by adding to, deleting,
or substituting -- in part or in whole -- any of the components of the
Original Version, by changing formats or by porting the Font Software to a
new environment.
"Author" refers to any designer, engineer, programmer, technical
writer or other person who contributed to the Font Software.
PERMISSION & CONDITIONS
Permission is hereby granted, free of charge, to any person obtaining
a copy of the Font Software, to use, study, copy, merge, embed, modify,
redistribute, and sell modified and unmodified copies of the Font
Software, subject to the following conditions:
1) Neither the Font Software nor any of its individual components,
in Original or Modified Versions, may be sold by itself.
2) Original or Modified Versions of the Font Software may be bundled,
redistributed and/or sold with any software, provided that each copy
contains the above copyright notice and this license. These can be
included either as stand-alone text files, human-readable headers or
in the appropriate machine-readable metadata fields within text or
binary files as long as those fields can be easily viewed by the user.
3) No Modified Version of the Font Software may use the Reserved Font
Name(s) unless explicit written permission is granted by the corresponding
Copyright Holder. This restriction only applies to the primary font name as
presented to the users.
4) The name(s) of the Copyright Holder(s) or the Author(s) of the Font
Software shall not be used to promote, endorse or advertise any
Modified Version, except to acknowledge the contribution(s) of the
Copyright Holder(s) and the Author(s) or with their explicit written
permission.
5) The Font Software, modified or unmodified, in part or in whole,
must be distributed entirely under this license, and must not be
distributed under any other license. The requirement for fonts to
remain under this license does not apply to any document created
using the Font Software.
TERMINATION
This license becomes null and void if any of the above conditions are
not met.
DISCLAIMER
THE FONT SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT
OF COPYRIGHT, PATENT, TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL THE
COPYRIGHT HOLDER BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
INCLUDING ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL
DAMAGES, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
FROM, OUT OF THE USE OR INABILITY TO USE THE FONT SOFTWARE OR FROM
OTHER DEALINGS IN THE FONT SOFTWARE.
</pre>
<h3>rcheevos - <a href="https://github.com/RetroAchievements/rcheevos/">https://github.com/RetroAchievements/rcheevos/</a></h3>
<pre>
MIT License

View file

@ -7,6 +7,7 @@ import re
#src_file = "src/duckstation-qt/qttranslations.cpp"
src_dir = os.path.join(os.path.dirname(__file__), "..", "src")
fa_file = os.path.join(os.path.dirname(__file__), "..", "dep", "imgui", "include", "IconsFontAwesome5.h")
pf_file = os.path.join(os.path.dirname(__file__), "..", "dep", "imgui", "include", "IconsPromptFont.h")
dst_file = os.path.join(os.path.dirname(__file__), "..", "src", "util", "imgui_manager.cpp")
all_source_files = glob.glob(os.path.join(src_dir, "**", "*.cpp"), recursive=True) + \
@ -14,6 +15,7 @@ all_source_files = glob.glob(os.path.join(src_dir, "**", "*.cpp"), recursive=Tru
glob.glob(os.path.join(src_dir, "**", "*.inl"), recursive=True)
tokens = set()
pf_tokens = set()
for filename in all_source_files:
data = None
with open(filename, "r") as f:
@ -23,9 +25,10 @@ for filename in all_source_files:
continue
tokens = tokens.union(set(re.findall("(ICON_FA_[a-zA-Z0-9_]+)", data)))
pf_tokens = pf_tokens.union(set(re.findall("(ICON_PF_[a-zA-Z0-9_]+)", data)))
print("{} tokens found.".format(len(tokens)))
if len(tokens) == 0:
print("{}/{} tokens found.".format(len(tokens), len(pf_tokens)))
if len(tokens) == 0 and len(pf_tokens) == 0:
sys.exit(0)
u8_encodings = {}
@ -35,16 +38,24 @@ with open(fa_file, "r") as f:
if match is None:
continue
u8_encodings[match[1]] = bytes.fromhex(match[2].replace("\\x", ""))
with open(pf_file, "r") as f:
for line in f.readlines():
match = re.match("#define (ICON_PF_[^ ]+) \"([^\"]+)\"", line)
if match is None:
continue
u8_encodings[match[1]] = bytes.fromhex(match[2].replace("\\x", ""))
out_pattern = "(static constexpr ImWchar range_fa\[\] = \{)[0-9A-Z_a-z, \n]+(\};)"
out_pf_pattern = "(static constexpr ImWchar range_pf\[\] = \{)[0-9A-Z_a-z, \n]+(\};)"
def get_pairs(tokens):
codepoints = list()
for token in tokens:
u8_bytes = u8_encodings[token]
u8 = str(u8_bytes, "utf-8")
u16 = u8.encode("utf-16le")
if len(u16) > 2:
raise ValueError("{} too long".format(u8_bytes))
raise ValueError("{} {} too long".format(u8_bytes, token))
codepoint = int.from_bytes(u16, byteorder="little", signed=False)
codepoints.append(codepoint)
@ -65,10 +76,12 @@ for codepoint in codepoints:
pairs.append(endc)
pairs_str = ",".join(list(map(lambda x: "0x{:x}".format(x), pairs)))
return pairs_str
with open(dst_file, "r") as f:
original = f.read()
updated = re.sub(out_pattern, "\\1 " + pairs_str + " \\2", original)
updated = re.sub(out_pattern, "\\1 " + get_pairs(tokens) + " \\2", original)
updated = re.sub(out_pf_pattern, "\\1 " + get_pairs(pf_tokens) + " \\2", original)
if original != updated:
with open(dst_file, "w") as f:
f.write(updated)

View file

@ -15,6 +15,7 @@
#include "common/string_util.h"
#include "IconsFontAwesome5.h"
#include "IconsPromptFont.h"
#include <cmath>
@ -789,43 +790,43 @@ std::unique_ptr<AnalogController> AnalogController::Create(u32 index)
}
static const Controller::ControllerBindingInfo s_binding_info[] = {
#define BUTTON(name, display_name, button, genb) \
#define BUTTON(name, display_name, icon_name, button, genb) \
{ \
name, display_name, static_cast<u32>(button), InputBindingInfo::Type::Button, genb \
name, display_name, icon_name, static_cast<u32>(button), InputBindingInfo::Type::Button, genb \
}
#define AXIS(name, display_name, halfaxis, genb) \
#define AXIS(name, display_name, icon_name, halfaxis, genb) \
{ \
name, display_name, static_cast<u32>(AnalogController::Button::Count) + static_cast<u32>(halfaxis), \
name, display_name, icon_name, static_cast<u32>(AnalogController::Button::Count) + static_cast<u32>(halfaxis), \
InputBindingInfo::Type::HalfAxis, genb \
}
// clang-format off
BUTTON("Up", TRANSLATE_NOOP("AnalogController", "D-Pad Up"), AnalogController::Button::Up, GenericInputBinding::DPadUp),
BUTTON("Right", TRANSLATE_NOOP("AnalogController", "D-Pad Right"), AnalogController::Button::Right, GenericInputBinding::DPadRight),
BUTTON("Down", TRANSLATE_NOOP("AnalogController", "D-Pad Down"), AnalogController::Button::Down, GenericInputBinding::DPadDown),
BUTTON("Left", TRANSLATE_NOOP("AnalogController", "D-Pad Left"), AnalogController::Button::Left, GenericInputBinding::DPadLeft),
BUTTON("Triangle", TRANSLATE_NOOP("AnalogController", "Triangle"), AnalogController::Button::Triangle, GenericInputBinding::Triangle),
BUTTON("Circle", TRANSLATE_NOOP("AnalogController", "Circle"), AnalogController::Button::Circle, GenericInputBinding::Circle),
BUTTON("Cross", TRANSLATE_NOOP("AnalogController", "Cross"), AnalogController::Button::Cross, GenericInputBinding::Cross),
BUTTON("Square", TRANSLATE_NOOP("AnalogController", "Square"), AnalogController::Button::Square, GenericInputBinding::Square),
BUTTON("Select", TRANSLATE_NOOP("AnalogController", "Select"), AnalogController::Button::Select, GenericInputBinding::Select),
BUTTON("Start", TRANSLATE_NOOP("AnalogController", "Start"), AnalogController::Button::Start, GenericInputBinding::Start),
BUTTON("Analog", TRANSLATE_NOOP("AnalogController", "Analog Toggle"), AnalogController::Button::Analog, GenericInputBinding::System),
BUTTON("L1", TRANSLATE_NOOP("AnalogController", "L1"), AnalogController::Button::L1, GenericInputBinding::L1),
BUTTON("R1", TRANSLATE_NOOP("AnalogController", "R1"), AnalogController::Button::R1, GenericInputBinding::R1),
BUTTON("L2", TRANSLATE_NOOP("AnalogController", "L2"), AnalogController::Button::L2, GenericInputBinding::L2),
BUTTON("R2", TRANSLATE_NOOP("AnalogController", "R2"), AnalogController::Button::R2, GenericInputBinding::R2),
BUTTON("L3", TRANSLATE_NOOP("AnalogController", "L3"), AnalogController::Button::L3, GenericInputBinding::L3),
BUTTON("R3", TRANSLATE_NOOP("AnalogController", "R3"), AnalogController::Button::R3, GenericInputBinding::R3),
BUTTON("Up", TRANSLATE_NOOP("AnalogController", "D-Pad Up"), ICON_PF_DPAD_UP, AnalogController::Button::Up, GenericInputBinding::DPadUp),
BUTTON("Right", TRANSLATE_NOOP("AnalogController", "D-Pad Right"), ICON_PF_DPAD_RIGHT, AnalogController::Button::Right, GenericInputBinding::DPadRight),
BUTTON("Down", TRANSLATE_NOOP("AnalogController", "D-Pad Down"), ICON_PF_DPAD_DOWN, AnalogController::Button::Down, GenericInputBinding::DPadDown),
BUTTON("Left", TRANSLATE_NOOP("AnalogController", "D-Pad Left"), ICON_PF_DPAD_LEFT, AnalogController::Button::Left, GenericInputBinding::DPadLeft),
BUTTON("Triangle", TRANSLATE_NOOP("AnalogController", "Triangle"), ICON_PF_BUTTON_TRIANGLE, AnalogController::Button::Triangle, GenericInputBinding::Triangle),
BUTTON("Circle", TRANSLATE_NOOP("AnalogController", "Circle"), ICON_PF_BUTTON_CIRCLE, AnalogController::Button::Circle, GenericInputBinding::Circle),
BUTTON("Cross", TRANSLATE_NOOP("AnalogController", "Cross"), ICON_PF_BUTTON_CROSS, AnalogController::Button::Cross, GenericInputBinding::Cross),
BUTTON("Square", TRANSLATE_NOOP("AnalogController", "Square"), ICON_PF_BUTTON_SQUARE, AnalogController::Button::Square, GenericInputBinding::Square),
BUTTON("Select", TRANSLATE_NOOP("AnalogController", "Select"), ICON_PF_SELECT_SHARE, AnalogController::Button::Select, GenericInputBinding::Select),
BUTTON("Start", TRANSLATE_NOOP("AnalogController", "Start"),ICON_PF_START, AnalogController::Button::Start, GenericInputBinding::Start),
BUTTON("Analog", TRANSLATE_NOOP("AnalogController", "Analog Toggle"), ICON_PF_ANALOG_LEFT_RIGHT, AnalogController::Button::Analog, GenericInputBinding::System),
BUTTON("L1", TRANSLATE_NOOP("AnalogController", "L1"), ICON_PF_LEFT_SHOULDER_L1, AnalogController::Button::L1, GenericInputBinding::L1),
BUTTON("R1", TRANSLATE_NOOP("AnalogController", "R1"), ICON_PF_RIGHT_SHOULDER_R1, AnalogController::Button::R1, GenericInputBinding::R1),
BUTTON("L2", TRANSLATE_NOOP("AnalogController", "L2"), ICON_PF_LEFT_TRIGGER_L2, AnalogController::Button::L2, GenericInputBinding::L2),
BUTTON("R2", TRANSLATE_NOOP("AnalogController", "R2"), ICON_PF_RIGHT_TRIGGER_R2, AnalogController::Button::R2, GenericInputBinding::R2),
BUTTON("L3", TRANSLATE_NOOP("AnalogController", "L3"), ICON_PF_LEFT_ANALOG_CLICK, AnalogController::Button::L3, GenericInputBinding::L3),
BUTTON("R3", TRANSLATE_NOOP("AnalogController", "R3"), ICON_PF_RIGHT_ANALOG_CLICK, AnalogController::Button::R3, GenericInputBinding::R3),
AXIS("LLeft", TRANSLATE_NOOP("AnalogController", "Left Stick Left"), AnalogController::HalfAxis::LLeft, GenericInputBinding::LeftStickLeft),
AXIS("LRight", TRANSLATE_NOOP("AnalogController", "Left Stick Right"), AnalogController::HalfAxis::LRight, GenericInputBinding::LeftStickRight),
AXIS("LDown", TRANSLATE_NOOP("AnalogController", "Left Stick Down"), AnalogController::HalfAxis::LDown, GenericInputBinding::LeftStickDown),
AXIS("LUp", TRANSLATE_NOOP("AnalogController", "Left Stick Up"), AnalogController::HalfAxis::LUp, GenericInputBinding::LeftStickUp),
AXIS("RLeft", TRANSLATE_NOOP("AnalogController", "Right Stick Left"), AnalogController::HalfAxis::RLeft, GenericInputBinding::RightStickLeft),
AXIS("RRight", TRANSLATE_NOOP("AnalogController", "Right Stick Right"), AnalogController::HalfAxis::RRight, GenericInputBinding::RightStickRight),
AXIS("RDown", TRANSLATE_NOOP("AnalogController", "Right Stick Down"), AnalogController::HalfAxis::RDown, GenericInputBinding::RightStickDown),
AXIS("RUp", TRANSLATE_NOOP("AnalogController", "Right Stick Up"), AnalogController::HalfAxis::RUp, GenericInputBinding::RightStickUp),
AXIS("LLeft", TRANSLATE_NOOP("AnalogController", "Left Stick Left"), ICON_PF_LEFT_ANALOG_LEFT, AnalogController::HalfAxis::LLeft, GenericInputBinding::LeftStickLeft),
AXIS("LRight", TRANSLATE_NOOP("AnalogController", "Left Stick Right"), ICON_PF_LEFT_ANALOG_RIGHT, AnalogController::HalfAxis::LRight, GenericInputBinding::LeftStickRight),
AXIS("LDown", TRANSLATE_NOOP("AnalogController", "Left Stick Down"), ICON_PF_LEFT_ANALOG_DOWN, AnalogController::HalfAxis::LDown, GenericInputBinding::LeftStickDown),
AXIS("LUp", TRANSLATE_NOOP("AnalogController", "Left Stick Up"), ICON_PF_LEFT_ANALOG_UP, AnalogController::HalfAxis::LUp, GenericInputBinding::LeftStickUp),
AXIS("RLeft", TRANSLATE_NOOP("AnalogController", "Right Stick Left"), ICON_PF_RIGHT_ANALOG_LEFT, AnalogController::HalfAxis::RLeft, GenericInputBinding::RightStickLeft),
AXIS("RRight", TRANSLATE_NOOP("AnalogController", "Right Stick Right"), ICON_PF_RIGHT_ANALOG_RIGHT, AnalogController::HalfAxis::RRight, GenericInputBinding::RightStickRight),
AXIS("RDown", TRANSLATE_NOOP("AnalogController", "Right Stick Down"), ICON_PF_RIGHT_ANALOG_DOWN, AnalogController::HalfAxis::RDown, GenericInputBinding::RightStickDown),
AXIS("RUp", TRANSLATE_NOOP("AnalogController", "Right Stick Up"), ICON_PF_RIGHT_ANALOG_UP, AnalogController::HalfAxis::RUp, GenericInputBinding::RightStickUp),
// clang-format on
#undef AXIS
@ -875,6 +876,7 @@ static const SettingInfo s_settings[] = {
const Controller::ControllerInfo AnalogController::INFO = {ControllerType::AnalogController,
"AnalogController",
TRANSLATE_NOOP("ControllerType", "Analog Controller"),
ICON_PF_GAMEPAD,
s_binding_info,
s_settings,
Controller::VibrationCapabilities::LargeSmallMotors};

View file

@ -12,6 +12,8 @@
#include "common/log.h"
#include "common/string_util.h"
#include "IconsPromptFont.h"
#include <cmath>
Log_SetChannel(AnalogJoystick);
@ -337,43 +339,43 @@ std::unique_ptr<AnalogJoystick> AnalogJoystick::Create(u32 index)
}
static const Controller::ControllerBindingInfo s_binding_info[] = {
#define BUTTON(name, display_name, button, genb) \
#define BUTTON(name, display_name, icon_name, button, genb) \
{ \
name, display_name, static_cast<u32>(button), InputBindingInfo::Type::Button, genb \
name, display_name, icon_name, static_cast<u32>(button), InputBindingInfo::Type::Button, genb \
}
#define AXIS(name, display_name, halfaxis, genb) \
#define AXIS(name, display_name, icon_name, halfaxis, genb) \
{ \
name, display_name, static_cast<u32>(AnalogJoystick::Button::Count) + static_cast<u32>(halfaxis), \
name, display_name, icon_name, static_cast<u32>(AnalogJoystick::Button::Count) + static_cast<u32>(halfaxis), \
InputBindingInfo::Type::HalfAxis, genb \
}
// clang-format off
BUTTON("Up", TRANSLATE_NOOP("AnalogJoystick", "D-Pad Up"), AnalogJoystick::Button::Up, GenericInputBinding::DPadUp),
BUTTON("Right", TRANSLATE_NOOP("AnalogJoystick", "D-Pad Right"), AnalogJoystick::Button::Right, GenericInputBinding::DPadRight),
BUTTON("Down", TRANSLATE_NOOP("AnalogJoystick", "D-Pad Down"), AnalogJoystick::Button::Down, GenericInputBinding::DPadDown),
BUTTON("Left", TRANSLATE_NOOP("AnalogJoystick", "D-Pad Left"), AnalogJoystick::Button::Left, GenericInputBinding::DPadLeft),
BUTTON("Triangle", TRANSLATE_NOOP("AnalogJoystick", "Triangle"), AnalogJoystick::Button::Triangle, GenericInputBinding::Triangle),
BUTTON("Circle", TRANSLATE_NOOP("AnalogJoystick", "Circle"), AnalogJoystick::Button::Circle, GenericInputBinding::Circle),
BUTTON("Cross", TRANSLATE_NOOP("AnalogJoystick", "Cross"), AnalogJoystick::Button::Cross, GenericInputBinding::Cross),
BUTTON("Square", TRANSLATE_NOOP("AnalogJoystick", "Square"), AnalogJoystick::Button::Square, GenericInputBinding::Square),
BUTTON("Select", TRANSLATE_NOOP("AnalogJoystick", "Select"), AnalogJoystick::Button::Select, GenericInputBinding::Select),
BUTTON("Start", TRANSLATE_NOOP("AnalogJoystick", "Start"), AnalogJoystick::Button::Start, GenericInputBinding::Start),
BUTTON("Mode", TRANSLATE_NOOP("AnalogJoystick", "Mode Toggle"), AnalogJoystick::Button::Mode, GenericInputBinding::System),
BUTTON("L1", TRANSLATE_NOOP("AnalogJoystick", "L1"), AnalogJoystick::Button::L1, GenericInputBinding::L1),
BUTTON("R1", TRANSLATE_NOOP("AnalogJoystick", "R1"), AnalogJoystick::Button::R1, GenericInputBinding::R1),
BUTTON("L2", TRANSLATE_NOOP("AnalogJoystick", "L2"), AnalogJoystick::Button::L2, GenericInputBinding::L2),
BUTTON("R2", TRANSLATE_NOOP("AnalogJoystick", "R2"), AnalogJoystick::Button::R2, GenericInputBinding::R2),
BUTTON("L3", TRANSLATE_NOOP("AnalogJoystick", "L3"), AnalogJoystick::Button::L3, GenericInputBinding::L3),
BUTTON("R3", TRANSLATE_NOOP("AnalogJoystick", "R3"), AnalogJoystick::Button::R3, GenericInputBinding::R3),
BUTTON("Up", TRANSLATE_NOOP("AnalogJoystick", "D-Pad Up"), ICON_PF_DPAD_UP, AnalogJoystick::Button::Up, GenericInputBinding::DPadUp),
BUTTON("Right", TRANSLATE_NOOP("AnalogJoystick", "D-Pad Right"), ICON_PF_DPAD_RIGHT, AnalogJoystick::Button::Right, GenericInputBinding::DPadRight),
BUTTON("Down", TRANSLATE_NOOP("AnalogJoystick", "D-Pad Down"), ICON_PF_DPAD_DOWN, AnalogJoystick::Button::Down, GenericInputBinding::DPadDown),
BUTTON("Left", TRANSLATE_NOOP("AnalogJoystick", "D-Pad Left"), ICON_PF_DPAD_LEFT, AnalogJoystick::Button::Left, GenericInputBinding::DPadLeft),
BUTTON("Triangle", TRANSLATE_NOOP("AnalogJoystick", "Triangle"), ICON_PF_BUTTON_TRIANGLE, AnalogJoystick::Button::Triangle, GenericInputBinding::Triangle),
BUTTON("Circle", TRANSLATE_NOOP("AnalogJoystick", "Circle"), ICON_PF_BUTTON_CIRCLE, AnalogJoystick::Button::Circle, GenericInputBinding::Circle),
BUTTON("Cross", TRANSLATE_NOOP("AnalogJoystick", "Cross"), ICON_PF_BUTTON_CROSS, AnalogJoystick::Button::Cross, GenericInputBinding::Cross),
BUTTON("Square", TRANSLATE_NOOP("AnalogJoystick", "Square"), ICON_PF_BUTTON_SQUARE, AnalogJoystick::Button::Square, GenericInputBinding::Square),
BUTTON("Select", TRANSLATE_NOOP("AnalogJoystick", "Select"), ICON_PF_SELECT_SHARE, AnalogJoystick::Button::Select, GenericInputBinding::Select),
BUTTON("Start", TRANSLATE_NOOP("AnalogJoystick", "Start"), ICON_PF_START, AnalogJoystick::Button::Start, GenericInputBinding::Start),
BUTTON("Mode", TRANSLATE_NOOP("AnalogJoystick", "Mode Toggle"), ICON_PF_ANALOG_LEFT_RIGHT, AnalogJoystick::Button::Mode, GenericInputBinding::System),
BUTTON("L1", TRANSLATE_NOOP("AnalogJoystick", "L1"), ICON_PF_LEFT_SHOULDER_L1, AnalogJoystick::Button::L1, GenericInputBinding::L1),
BUTTON("R1", TRANSLATE_NOOP("AnalogJoystick", "R1"), ICON_PF_RIGHT_SHOULDER_R1, AnalogJoystick::Button::R1, GenericInputBinding::R1),
BUTTON("L2", TRANSLATE_NOOP("AnalogJoystick", "L2"), ICON_PF_LEFT_TRIGGER_L2, AnalogJoystick::Button::L2, GenericInputBinding::L2),
BUTTON("R2", TRANSLATE_NOOP("AnalogJoystick", "R2"), ICON_PF_RIGHT_TRIGGER_R2, AnalogJoystick::Button::R2, GenericInputBinding::R2),
BUTTON("L3", TRANSLATE_NOOP("AnalogJoystick", "L3"), ICON_PF_LEFT_ANALOG_CLICK, AnalogJoystick::Button::L3, GenericInputBinding::L3),
BUTTON("R3", TRANSLATE_NOOP("AnalogJoystick", "R3"), ICON_PF_RIGHT_ANALOG_CLICK, AnalogJoystick::Button::R3, GenericInputBinding::R3),
AXIS("LLeft", TRANSLATE_NOOP("AnalogJoystick", "Left Stick Left"), AnalogJoystick::HalfAxis::LLeft, GenericInputBinding::LeftStickLeft),
AXIS("LRight", TRANSLATE_NOOP("AnalogJoystick", "Left Stick Right"), AnalogJoystick::HalfAxis::LRight, GenericInputBinding::LeftStickRight),
AXIS("LDown", TRANSLATE_NOOP("AnalogJoystick", "Left Stick Down"), AnalogJoystick::HalfAxis::LDown, GenericInputBinding::LeftStickDown),
AXIS("LUp", TRANSLATE_NOOP("AnalogJoystick", "Left Stick Up"), AnalogJoystick::HalfAxis::LUp, GenericInputBinding::LeftStickUp),
AXIS("RLeft", TRANSLATE_NOOP("AnalogJoystick", "Right Stick Left"), AnalogJoystick::HalfAxis::RLeft, GenericInputBinding::RightStickLeft),
AXIS("RRight", TRANSLATE_NOOP("AnalogJoystick", "Right Stick Right"), AnalogJoystick::HalfAxis::RRight, GenericInputBinding::RightStickRight),
AXIS("RDown", TRANSLATE_NOOP("AnalogJoystick", "Right Stick Down"), AnalogJoystick::HalfAxis::RDown, GenericInputBinding::RightStickDown),
AXIS("RUp", TRANSLATE_NOOP("AnalogJoystick", "Right Stick Up"), AnalogJoystick::HalfAxis::RUp, GenericInputBinding::RightStickUp),
AXIS("LLeft", TRANSLATE_NOOP("AnalogJoystick", "Left Stick Left"), ICON_PF_LEFT_ANALOG_LEFT, AnalogJoystick::HalfAxis::LLeft, GenericInputBinding::LeftStickLeft),
AXIS("LRight", TRANSLATE_NOOP("AnalogJoystick", "Left Stick Right"), ICON_PF_LEFT_ANALOG_RIGHT, AnalogJoystick::HalfAxis::LRight, GenericInputBinding::LeftStickRight),
AXIS("LDown", TRANSLATE_NOOP("AnalogJoystick", "Left Stick Down"), ICON_PF_LEFT_ANALOG_DOWN, AnalogJoystick::HalfAxis::LDown, GenericInputBinding::LeftStickDown),
AXIS("LUp", TRANSLATE_NOOP("AnalogJoystick", "Left Stick Up"), ICON_PF_LEFT_ANALOG_UP, AnalogJoystick::HalfAxis::LUp, GenericInputBinding::LeftStickUp),
AXIS("RLeft", TRANSLATE_NOOP("AnalogJoystick", "Right Stick Left"), ICON_PF_RIGHT_ANALOG_LEFT, AnalogJoystick::HalfAxis::RLeft, GenericInputBinding::RightStickLeft),
AXIS("RRight", TRANSLATE_NOOP("AnalogJoystick", "Right Stick Right"), ICON_PF_RIGHT_ANALOG_RIGHT, AnalogJoystick::HalfAxis::RRight, GenericInputBinding::RightStickRight),
AXIS("RDown", TRANSLATE_NOOP("AnalogJoystick", "Right Stick Down"), ICON_PF_RIGHT_ANALOG_DOWN, AnalogJoystick::HalfAxis::RDown, GenericInputBinding::RightStickDown),
AXIS("RUp", TRANSLATE_NOOP("AnalogJoystick", "Right Stick Up"), ICON_PF_RIGHT_ANALOG_UP, AnalogJoystick::HalfAxis::RUp, GenericInputBinding::RightStickUp),
// clang-format on
#undef AXIS
@ -407,6 +409,7 @@ static const SettingInfo s_settings[] = {
const Controller::ControllerInfo AnalogJoystick::INFO = {ControllerType::AnalogJoystick,
"AnalogJoystick",
TRANSLATE_NOOP("ControllerType", "Analog Joystick"),
ICON_PF_GAMEPAD,
s_binding_info,
s_settings,
Controller::VibrationCapabilities::NoVibration};

View file

@ -15,6 +15,7 @@
static const Controller::ControllerInfo s_none_info = {ControllerType::None,
"None",
TRANSLATE_NOOP("ControllerType", "Not Connected"),
nullptr,
{},
{},
Controller::VibrationCapabilities::NoVibration};

View file

@ -36,6 +36,7 @@ public:
{
const char* name;
const char* display_name;
const char* icon_name;
u32 bind_index;
InputBindingInfo::Type type;
GenericInputBinding generic_mapping;
@ -46,6 +47,7 @@ public:
ControllerType type;
const char* name;
const char* display_name;
const char* icon_name;
std::span<const ControllerBindingInfo> bindings;
std::span<const SettingInfo> settings;
VibrationCapabilities vibration_caps;

View file

@ -7,6 +7,8 @@
#include "util/state_wrapper.h"
#include "IconsPromptFont.h"
#include "common/assert.h"
#include "common/bitutils.h"
@ -146,26 +148,26 @@ std::unique_ptr<DigitalController> DigitalController::Create(u32 index)
}
static const Controller::ControllerBindingInfo s_binding_info[] = {
#define BUTTON(name, display_name, button, genb) \
#define BUTTON(name, display_name, icon_name, button, genb) \
{ \
name, display_name, static_cast<u32>(button), InputBindingInfo::Type::Button, genb \
name, display_name, icon_name, static_cast<u32>(button), InputBindingInfo::Type::Button, genb \
}
// clang-format off
BUTTON("Up", TRANSLATE_NOOP("DigitalController", "D-Pad Up"), DigitalController::Button::Up, GenericInputBinding::DPadUp),
BUTTON("Right", TRANSLATE_NOOP("DigitalController", "D-Pad Right"), DigitalController::Button::Right, GenericInputBinding::DPadRight),
BUTTON("Down", TRANSLATE_NOOP("DigitalController", "D-Pad Down"), DigitalController::Button::Down, GenericInputBinding::DPadDown),
BUTTON("Left", TRANSLATE_NOOP("DigitalController", "D-Pad Left"), DigitalController::Button::Left, GenericInputBinding::DPadLeft),
BUTTON("Triangle", TRANSLATE_NOOP("DigitalController", "Triangle"), DigitalController::Button::Triangle, GenericInputBinding::Triangle),
BUTTON("Circle", TRANSLATE_NOOP("DigitalController", "Circle"), DigitalController::Button::Circle, GenericInputBinding::Circle),
BUTTON("Cross", TRANSLATE_NOOP("DigitalController", "Cross"), DigitalController::Button::Cross, GenericInputBinding::Cross),
BUTTON("Square", TRANSLATE_NOOP("DigitalController", "Square"), DigitalController::Button::Square, GenericInputBinding::Square),
BUTTON("Select", TRANSLATE_NOOP("DigitalController", "Select"), DigitalController::Button::Select, GenericInputBinding::Select),
BUTTON("Start", TRANSLATE_NOOP("DigitalController", "Start"), DigitalController::Button::Start, GenericInputBinding::Start),
BUTTON("L1", TRANSLATE_NOOP("DigitalController", "L1"), DigitalController::Button::L1, GenericInputBinding::L1),
BUTTON("R1", TRANSLATE_NOOP("DigitalController", "R1"), DigitalController::Button::R1, GenericInputBinding::R1),
BUTTON("L2", TRANSLATE_NOOP("DigitalController", "L2"), DigitalController::Button::L2, GenericInputBinding::L2),
BUTTON("R2", TRANSLATE_NOOP("DigitalController", "R2"), DigitalController::Button::R2, GenericInputBinding::R2),
BUTTON("Up", TRANSLATE_NOOP("DigitalController", "D-Pad Up"), ICON_PF_DPAD_UP, DigitalController::Button::Up, GenericInputBinding::DPadUp),
BUTTON("Right", TRANSLATE_NOOP("DigitalController", "D-Pad Right"), ICON_PF_DPAD_RIGHT, DigitalController::Button::Right, GenericInputBinding::DPadRight),
BUTTON("Down", TRANSLATE_NOOP("DigitalController", "D-Pad Down"), ICON_PF_DPAD_DOWN, DigitalController::Button::Down, GenericInputBinding::DPadDown),
BUTTON("Left", TRANSLATE_NOOP("DigitalController", "D-Pad Left"), ICON_PF_DPAD_LEFT, DigitalController::Button::Left, GenericInputBinding::DPadLeft),
BUTTON("Triangle", TRANSLATE_NOOP("DigitalController", "Triangle"), ICON_PF_BUTTON_TRIANGLE, DigitalController::Button::Triangle, GenericInputBinding::Triangle),
BUTTON("Circle", TRANSLATE_NOOP("DigitalController", "Circle"), ICON_PF_BUTTON_CIRCLE, DigitalController::Button::Circle, GenericInputBinding::Circle),
BUTTON("Cross", TRANSLATE_NOOP("DigitalController", "Cross"), ICON_PF_BUTTON_CROSS, DigitalController::Button::Cross, GenericInputBinding::Cross),
BUTTON("Square", TRANSLATE_NOOP("DigitalController", "Square"), ICON_PF_BUTTON_SQUARE, DigitalController::Button::Square, GenericInputBinding::Square),
BUTTON("Select", TRANSLATE_NOOP("DigitalController", "Select"), ICON_PF_SELECT_SHARE, DigitalController::Button::Select, GenericInputBinding::Select),
BUTTON("Start", TRANSLATE_NOOP("DigitalController", "Start"), ICON_PF_START, DigitalController::Button::Start, GenericInputBinding::Start),
BUTTON("L1", TRANSLATE_NOOP("DigitalController", "L1"), ICON_PF_LEFT_SHOULDER_L1, DigitalController::Button::L1, GenericInputBinding::L1),
BUTTON("R1", TRANSLATE_NOOP("DigitalController", "R1"), ICON_PF_RIGHT_SHOULDER_R1, DigitalController::Button::R1, GenericInputBinding::R1),
BUTTON("L2", TRANSLATE_NOOP("DigitalController", "L2"), ICON_PF_LEFT_TRIGGER_L2, DigitalController::Button::L2, GenericInputBinding::L2),
BUTTON("R2", TRANSLATE_NOOP("DigitalController", "R2"), ICON_PF_RIGHT_TRIGGER_R2, DigitalController::Button::R2, GenericInputBinding::R2),
// clang-format on
#undef BUTTON
@ -180,6 +182,7 @@ static const SettingInfo s_settings[] = {
const Controller::ControllerInfo DigitalController::INFO = {ControllerType::DigitalController,
"DigitalController",
TRANSLATE_NOOP("ControllerType", "Digital Controller"),
ICON_PF_GAMEPAD,
s_binding_info,
s_settings,
Controller::VibrationCapabilities::NoVibration};

View file

@ -390,7 +390,8 @@ static void BeginInputBinding(SettingsInterface* bsi, InputBindingInfo::Type typ
const std::string_view& key, const std::string_view& display_name);
static void DrawInputBindingWindow();
static void DrawInputBindingButton(SettingsInterface* bsi, InputBindingInfo::Type type, const char* section,
const char* name, const char* display_name, bool show_type = true);
const char* name, const char* display_name, const char* icon_name,
bool show_type = true);
static void ClearInputBindingVariables();
static void StartAutomaticBinding(u32 port);
@ -1342,7 +1343,8 @@ std::string FullscreenUI::GetEffectiveStringSetting(SettingsInterface* bsi, cons
}
void FullscreenUI::DrawInputBindingButton(SettingsInterface* bsi, InputBindingInfo::Type type, const char* section,
const char* name, const char* display_name, bool show_type)
const char* name, const char* display_name, const char* icon_name,
bool show_type)
{
if (type == InputBindingInfo::Type::Pointer)
return;
@ -1362,6 +1364,12 @@ void FullscreenUI::DrawInputBindingButton(SettingsInterface* bsi, InputBindingIn
const ImRect summary_bb(ImVec2(bb.Min.x, midpoint), bb.Max);
if (show_type)
{
if (icon_name)
{
title.fmt("{} {}", icon_name, display_name);
}
else
{
switch (type)
{
@ -1383,6 +1391,7 @@ void FullscreenUI::DrawInputBindingButton(SettingsInterface* bsi, InputBindingIn
break;
}
}
}
ImGui::PushFont(g_large_font);
ImGui::RenderTextClipped(title_bb.Min, title_bb.Max, show_type ? title.c_str() : display_name, nullptr, nullptr,
@ -3354,7 +3363,7 @@ void FullscreenUI::DrawControllerSettingsPage()
for (const Controller::ControllerBindingInfo& bi : ci->bindings)
{
DrawInputBindingButton(bsi, bi.type, section.c_str(), bi.name,
Host::TranslateToCString(ci->name, bi.display_name), true);
Host::TranslateToCString(ci->name, bi.display_name), bi.icon_name, true);
}
if (mtap_enabled[mtap_port])
@ -3372,7 +3381,7 @@ void FullscreenUI::DrawControllerSettingsPage()
{
DrawInputBindingButton(bsi, InputBindingInfo::Type::Macro, section.c_str(),
TinyString::from_fmt("Macro{}", macro_index + 1),
TinyString::from_fmt(FSUI_FSTR("Macro {} Trigger"), macro_index + 1));
TinyString::from_fmt(FSUI_FSTR("Macro {} Trigger"), macro_index + 1), nullptr);
std::string binds_string(
bsi->GetStringValue(section.c_str(), fmt::format("Macro{}Binds", macro_index + 1).c_str()));
@ -3548,7 +3557,7 @@ void FullscreenUI::DrawHotkeySettingsPage()
}
DrawInputBindingButton(bsi, InputBindingInfo::Type::Button, "Hotkeys", hotkey->name,
Host::TranslateToCString("Hotkeys", hotkey->display_name), false);
Host::TranslateToCString("Hotkeys", hotkey->display_name), nullptr, false);
}
EndMenuButtons();

View file

@ -14,6 +14,8 @@
#include "common/path.h"
#include "common/string_util.h"
#include "IconsPromptFont.h"
#include <array>
#ifdef _DEBUG
@ -261,25 +263,25 @@ std::unique_ptr<GunCon> GunCon::Create(u32 index)
}
static const Controller::ControllerBindingInfo s_binding_info[] = {
#define BUTTON(name, display_name, binding, genb) \
#define BUTTON(name, display_name, icon_name, binding, genb) \
{ \
name, display_name, static_cast<u32>(binding), InputBindingInfo::Type::Button, genb \
name, display_name, icon_name, static_cast<u32>(binding), InputBindingInfo::Type::Button, genb \
}
#define HALFAXIS(name, display_name, binding, genb) \
#define HALFAXIS(name, display_name, icon_name, binding, genb) \
{ \
name, display_name, static_cast<u32>(binding), InputBindingInfo::Type::HalfAxis, genb \
name, display_name, icon_name, static_cast<u32>(binding), InputBindingInfo::Type::HalfAxis, genb \
}
// clang-format off
BUTTON("Trigger", TRANSLATE_NOOP("GunCon", "Trigger"), GunCon::Binding::Trigger, GenericInputBinding::R2),
BUTTON("ShootOffscreen", TRANSLATE_NOOP("GunCon", "Shoot Offscreen"), GunCon::Binding::ShootOffscreen, GenericInputBinding::L2),
BUTTON("A", TRANSLATE_NOOP("GunCon", "A"), GunCon::Binding::A, GenericInputBinding::Cross),
BUTTON("B", TRANSLATE_NOOP("GunCon", "B"), GunCon::Binding::B, GenericInputBinding::Circle),
BUTTON("Trigger", TRANSLATE_NOOP("GunCon", "Trigger"), nullptr, GunCon::Binding::Trigger, GenericInputBinding::R2),
BUTTON("ShootOffscreen", TRANSLATE_NOOP("GunCon", "Shoot Offscreen"), nullptr, GunCon::Binding::ShootOffscreen, GenericInputBinding::L2),
BUTTON("A", TRANSLATE_NOOP("GunCon", "A"), ICON_PF_BUTTON_A, GunCon::Binding::A, GenericInputBinding::Cross),
BUTTON("B", TRANSLATE_NOOP("GunCon", "B"), ICON_PF_BUTTON_B, GunCon::Binding::B, GenericInputBinding::Circle),
HALFAXIS("RelativeLeft", TRANSLATE_NOOP("GunCon", "Relative Left"), GunCon::Binding::RelativeLeft, GenericInputBinding::Unknown),
HALFAXIS("RelativeRight", TRANSLATE_NOOP("GunCon", "Relative Right"), GunCon::Binding::RelativeRight, GenericInputBinding::Unknown),
HALFAXIS("RelativeUp", TRANSLATE_NOOP("GunCon", "Relative Up"), GunCon::Binding::RelativeUp, GenericInputBinding::Unknown),
HALFAXIS("RelativeDown", TRANSLATE_NOOP("GunCon", "Relative Down"), GunCon::Binding::RelativeDown, GenericInputBinding::Unknown),
HALFAXIS("RelativeLeft", TRANSLATE_NOOP("GunCon", "Relative Left"), ICON_PF_ANALOG_LEFT, GunCon::Binding::RelativeLeft, GenericInputBinding::Unknown),
HALFAXIS("RelativeRight", TRANSLATE_NOOP("GunCon", "Relative Right"), ICON_PF_ANALOG_RIGHT, GunCon::Binding::RelativeRight, GenericInputBinding::Unknown),
HALFAXIS("RelativeUp", TRANSLATE_NOOP("GunCon", "Relative Up"), ICON_PF_ANALOG_UP, GunCon::Binding::RelativeUp, GenericInputBinding::Unknown),
HALFAXIS("RelativeDown", TRANSLATE_NOOP("GunCon", "Relative Down"), ICON_PF_ANALOG_DOWN, GunCon::Binding::RelativeDown, GenericInputBinding::Unknown),
// clang-format on
#undef BUTTON
@ -301,7 +303,7 @@ static const SettingInfo s_settings[] = {
"%.0f%%", nullptr, 100.0f}};
const Controller::ControllerInfo GunCon::INFO = {
ControllerType::GunCon, "GunCon", TRANSLATE_NOOP("ControllerType", "GunCon"),
ControllerType::GunCon, "GunCon", TRANSLATE_NOOP("ControllerType", "GunCon"), nullptr,
s_binding_info, s_settings, Controller::VibrationCapabilities::NoVibration};
void GunCon::LoadSettings(SettingsInterface& si, const char* section)

View file

@ -581,7 +581,7 @@ void ImGuiManager::DrawInputsOverlay()
const float shadow_offset = 1.0f * scale;
const float margin = 10.0f * scale;
const float spacing = 5.0f * scale;
ImFont* font = ImGuiManager::GetFixedFont();
ImFont* font = ImGuiManager::GetStandardFont();
static constexpr u32 text_color = IM_COL32(0xff, 0xff, 0xff, 255);
static constexpr u32 shadow_color = IM_COL32(0x00, 0x00, 0x00, 100);
@ -614,7 +614,10 @@ void ImGuiManager::DrawInputsOverlay()
if (!cinfo)
continue;
text.fmt("P{} |", port + 1u);
if (cinfo->icon_name)
text.append_fmt("{} {} |", cinfo->icon_name, port + 1u);
else
text.append_fmt("{} |", port + 1u);
for (const Controller::ControllerBindingInfo& bi : cinfo->bindings)
{
@ -626,9 +629,9 @@ void ImGuiManager::DrawInputsOverlay()
// axes are always shown
const float value = controller->GetBindState(bi.bind_index);
if (value >= (254.0f / 255.0f))
text.append_fmt(" {}", bi.name);
text.append_fmt(" {}", bi.icon_name ? bi.icon_name : bi.name);
else if (value > (1.0f / 255.0f))
text.append_fmt(" {}: {:.2f}", bi.name, value);
text.append_fmt(" {}: {:.2f}", bi.icon_name ? bi.icon_name : bi.name, value);
}
break;
@ -637,7 +640,7 @@ void ImGuiManager::DrawInputsOverlay()
// buttons only shown when active
const float value = controller->GetBindState(bi.bind_index);
if (value >= 0.5f)
text.append_fmt(" {}", bi.name);
text.append_fmt(" {}", bi.icon_name ? bi.icon_name : bi.name);
}
break;

View file

@ -11,6 +11,8 @@
#include "common/bitutils.h"
#include "common/log.h"
#include "IconsPromptFont.h"
#include <array>
#include <cmath>
@ -230,30 +232,30 @@ std::unique_ptr<NeGcon> NeGcon::Create(u32 index)
}
static const Controller::ControllerBindingInfo s_binding_info[] = {
#define BUTTON(name, display_name, button, genb) \
#define BUTTON(name, display_name, icon_name, button, genb) \
{ \
name, display_name, static_cast<u32>(button), InputBindingInfo::Type::Button, genb \
name, display_name, icon_name, static_cast<u32>(button), InputBindingInfo::Type::Button, genb \
}
#define AXIS(name, display_name, halfaxis, genb) \
#define AXIS(name, display_name, icon_name, halfaxis, genb) \
{ \
name, display_name, static_cast<u32>(NeGcon::Button::Count) + static_cast<u32>(halfaxis), \
name, display_name, icon_name, static_cast<u32>(NeGcon::Button::Count) + static_cast<u32>(halfaxis), \
InputBindingInfo::Type::HalfAxis, genb \
}
// clang-format off
BUTTON("Up", TRANSLATE_NOOP("NeGcon", "D-Pad Up"), NeGcon::Button::Up, GenericInputBinding::DPadUp),
BUTTON("Right", TRANSLATE_NOOP("NeGcon", "D-Pad Right"), NeGcon::Button::Right, GenericInputBinding::DPadRight),
BUTTON("Down", TRANSLATE_NOOP("NeGcon", "D-Pad Down"), NeGcon::Button::Down, GenericInputBinding::DPadDown),
BUTTON("Left", TRANSLATE_NOOP("NeGcon", "D-Pad Left"), NeGcon::Button::Left, GenericInputBinding::DPadLeft),
BUTTON("Start", TRANSLATE_NOOP("NeGcon", "Start"), NeGcon::Button::Start, GenericInputBinding::Start),
BUTTON("A", TRANSLATE_NOOP("NeGcon", "A Button"), NeGcon::Button::A, GenericInputBinding::Circle),
BUTTON("B", TRANSLATE_NOOP("NeGcon", "B Button"), NeGcon::Button::B, GenericInputBinding::Triangle),
AXIS("I", TRANSLATE_NOOP("NeGcon", "I Button"), NeGcon::HalfAxis::I, GenericInputBinding::R2),
AXIS("II", TRANSLATE_NOOP("NeGcon", "II Button"), NeGcon::HalfAxis::II, GenericInputBinding::L2),
AXIS("L", TRANSLATE_NOOP("NeGcon", "Left Trigger"), NeGcon::HalfAxis::L, GenericInputBinding::L1),
BUTTON("R", TRANSLATE_NOOP("NeGcon", "Right Trigger"), NeGcon::Button::R, GenericInputBinding::R1),
AXIS("SteeringLeft", TRANSLATE_NOOP("NeGcon", "Steering (Twist) Left"), NeGcon::HalfAxis::SteeringLeft, GenericInputBinding::LeftStickLeft),
AXIS("SteeringRight", TRANSLATE_NOOP("NeGcon", "Steering (Twist) Right"), NeGcon::HalfAxis::SteeringRight, GenericInputBinding::LeftStickRight),
BUTTON("Up", TRANSLATE_NOOP("NeGcon", "D-Pad Up"), ICON_PF_DPAD_UP, NeGcon::Button::Up, GenericInputBinding::DPadUp),
BUTTON("Right", TRANSLATE_NOOP("NeGcon", "D-Pad Right"), ICON_PF_DPAD_RIGHT, NeGcon::Button::Right, GenericInputBinding::DPadRight),
BUTTON("Down", TRANSLATE_NOOP("NeGcon", "D-Pad Down"), ICON_PF_DPAD_DOWN, NeGcon::Button::Down, GenericInputBinding::DPadDown),
BUTTON("Left", TRANSLATE_NOOP("NeGcon", "D-Pad Left"), ICON_PF_DPAD_LEFT, NeGcon::Button::Left, GenericInputBinding::DPadLeft),
BUTTON("Start", TRANSLATE_NOOP("NeGcon", "Start"), ICON_PF_START, NeGcon::Button::Start, GenericInputBinding::Start),
BUTTON("A", TRANSLATE_NOOP("NeGcon", "A Button"), ICON_PF_BUTTON_A, NeGcon::Button::A, GenericInputBinding::Circle),
BUTTON("B", TRANSLATE_NOOP("NeGcon", "B Button"), ICON_PF_BUTTON_B, NeGcon::Button::B, GenericInputBinding::Triangle),
AXIS("I", TRANSLATE_NOOP("NeGcon", "I Button"), ICON_PF_BUTTON_ALT_1, NeGcon::HalfAxis::I, GenericInputBinding::R2),
AXIS("II", TRANSLATE_NOOP("NeGcon", "II Button"), ICON_PF_BUTTON_ALT_2, NeGcon::HalfAxis::II, GenericInputBinding::L2),
AXIS("L", TRANSLATE_NOOP("NeGcon", "Left Trigger"), ICON_PF_LEFT_TRIGGER_LT, NeGcon::HalfAxis::L, GenericInputBinding::L1),
BUTTON("R", TRANSLATE_NOOP("NeGcon", "Right Trigger"), ICON_PF_RIGHT_TRIGGER_RT, NeGcon::Button::R, GenericInputBinding::R1),
AXIS("SteeringLeft", TRANSLATE_NOOP("NeGcon", "Steering (Twist) Left"), ICON_PF_ANALOG_LEFT, NeGcon::HalfAxis::SteeringLeft, GenericInputBinding::LeftStickLeft),
AXIS("SteeringRight", TRANSLATE_NOOP("NeGcon", "Steering (Twist) Right"), ICON_PF_ANALOG_RIGHT, NeGcon::HalfAxis::SteeringRight, GenericInputBinding::LeftStickRight),
// clang-format on
#undef AXIS
@ -270,7 +272,7 @@ static const SettingInfo s_settings[] = {
};
const Controller::ControllerInfo NeGcon::INFO = {
ControllerType::NeGcon, "NeGcon", TRANSLATE_NOOP("ControllerType", "NeGcon"),
ControllerType::NeGcon, "NeGcon", TRANSLATE_NOOP("ControllerType", "NeGcon"), ICON_PF_GAMEPAD,
s_binding_info, s_settings, Controller::VibrationCapabilities::NoVibration};
void NeGcon::LoadSettings(SettingsInterface& si, const char* section)

View file

@ -11,6 +11,8 @@
#include "common/assert.h"
#include "common/log.h"
#include "IconsPromptFont.h"
#include <array>
Log_SetChannel(PlayStationMouse);
@ -193,15 +195,15 @@ std::unique_ptr<PlayStationMouse> PlayStationMouse::Create(u32 index)
}
static const Controller::ControllerBindingInfo s_binding_info[] = {
#define BUTTON(name, display_name, button, genb) \
#define BUTTON(name, display_name, icon_name, button, genb) \
{ \
name, display_name, static_cast<u32>(button), InputBindingInfo::Type::Button, genb \
name, display_name, icon_name, static_cast<u32>(button), InputBindingInfo::Type::Button, genb \
}
// clang-format off
{ "Pointer", TRANSLATE_NOOP("PlaystationMouse", "Pointer"), static_cast<u32>(PlayStationMouse::Binding::PointerX), InputBindingInfo::Type::Pointer, GenericInputBinding::Unknown },
BUTTON("Left", TRANSLATE_NOOP("PlayStationMouse", "Left Button"), PlayStationMouse::Binding::Left, GenericInputBinding::Cross),
BUTTON("Right", TRANSLATE_NOOP("PlayStationMouse", "Right Button"), PlayStationMouse::Binding::Right, GenericInputBinding::Circle),
{ "Pointer", TRANSLATE_NOOP("PlaystationMouse", "Pointer"), ICON_PF_MOUSE_ANY, static_cast<u32>(PlayStationMouse::Binding::PointerX), InputBindingInfo::Type::Pointer, GenericInputBinding::Unknown },
BUTTON("Left", TRANSLATE_NOOP("PlayStationMouse", "Left Button"), ICON_PF_MOUSE_BUTTON_1, PlayStationMouse::Binding::Left, GenericInputBinding::Cross),
BUTTON("Right", TRANSLATE_NOOP("PlayStationMouse", "Right Button"), ICON_PF_MOUSE_BUTTON_2, PlayStationMouse::Binding::Right, GenericInputBinding::Circle),
// clang-format on
#undef BUTTON
@ -218,6 +220,7 @@ static const SettingInfo s_settings[] = {
const Controller::ControllerInfo PlayStationMouse::INFO = {ControllerType::PlayStationMouse,
"PlayStationMouse",
TRANSLATE_NOOP("ControllerType", "PlayStation Mouse"),
ICON_PF_MOUSE,
s_binding_info,
s_settings,
Controller::VibrationCapabilities::NoVibration};

View file

@ -1,10 +1,13 @@
// SPDX-FileCopyrightText: 2019-2022 Connor McLaughlin <stenzek@gmail.com>
// SPDX-FileCopyrightText: 2019-2023 Connor McLaughlin <stenzek@gmail.com>
// SPDX-License-Identifier: (GPL-3.0 OR CC-BY-NC-ND-4.0)
#include "qtutils.h"
#include "common/string_util.h"
#include "fmt/format.h"
#include "util/input_manager.h"
#include <QtGui/QKeyEvent>
struct KeyCodeName
@ -454,7 +457,7 @@ static constexpr KeyCodeName s_qt_key_names[] = {{Qt::Key_Escape, "Escape"},
std::optional<u32> InputManager::ConvertHostKeyboardStringToCode(const std::string_view& str)
{
std::string compare_name(str);
std::string_view compare_name = str;
u32 modifier_bits = 0;
if (StringUtil::StartsWith(compare_name, "Numpad"))
{

View file

@ -45,7 +45,6 @@ static void DrawMessageDialog();
static void DrawBackgroundProgressDialogs(ImVec2& position, float spacing);
static void DrawNotifications(ImVec2& position, float spacing);
static void DrawToast();
static void GetMenuButtonFrameBounds(float height, ImVec2* pos, ImVec2* size);
static bool MenuButtonFrame(const char* str_id, bool enabled, float height, bool* visible, bool* hovered, ImRect* bb,
ImGuiButtonFlags flags = 0, float hover_alpha = 1.0f);
static void PopulateFileSelectorItems();

View file

@ -171,6 +171,7 @@ void EndFullscreenWindow();
void BeginMenuButtons(u32 num_items = 0, float y_align = 0.0f, float x_padding = LAYOUT_MENU_BUTTON_X_PADDING,
float y_padding = LAYOUT_MENU_BUTTON_Y_PADDING, float item_height = LAYOUT_MENU_BUTTON_HEIGHT);
void EndMenuButtons();
void GetMenuButtonFrameBounds(float height, ImVec2* pos, ImVec2* size);
bool MenuButtonFrame(const char* str_id, bool enabled, float height, bool* visible, bool* hovered, ImVec2* min,
ImVec2* max, ImGuiButtonFlags flags = 0, float hover_alpha = 1.0f);
void MenuHeading(const char* title, bool draw_line = true);

View file

@ -83,7 +83,8 @@ static ImFont* s_large_font;
static std::vector<u8> s_standard_font_data;
static std::vector<u8> s_fixed_font_data;
static std::vector<u8> s_icon_font_data;
static std::vector<u8> s_icon_fa_font_data;
static std::vector<u8> s_icon_pf_font_data;
static float s_window_width;
static float s_window_height;
@ -479,13 +480,22 @@ bool ImGuiManager::LoadFontData()
s_fixed_font_data = std::move(font_data.value());
}
if (s_icon_font_data.empty())
if (s_icon_fa_font_data.empty())
{
std::optional<std::vector<u8>> font_data = Host::ReadResourceFile("fonts/fa-solid-900.ttf");
if (!font_data.has_value())
return false;
s_icon_font_data = std::move(font_data.value());
s_icon_fa_font_data = std::move(font_data.value());
}
if (s_icon_pf_font_data.empty())
{
std::optional<std::vector<u8>> font_data = Host::ReadResourceFile("fonts/promptfont.otf");
if (!font_data.has_value())
return false;
s_icon_pf_font_data = std::move(font_data.value());
}
return true;
@ -544,7 +554,9 @@ bool ImGuiManager::AddIconFonts(float size)
0xf545, 0xf545, 0xf547, 0xf548, 0xf552, 0xf552, 0xf57a, 0xf57a, 0xf5a2, 0xf5a2, 0xf5aa, 0xf5aa, 0xf5e7, 0xf5e7,
0xf65d, 0xf65e, 0xf6a9, 0xf6a9, 0xf7c2, 0xf7c2, 0xf807, 0xf807, 0xf815, 0xf815, 0xf818, 0xf818, 0xf84c, 0xf84c,
0xf8cc, 0xf8cc, 0x0, 0x0};
static constexpr ImWchar range_pf[] = { 0x2196,0x2199,0x219e,0x21a1,0x21b0,0x21b3,0x21ba,0x21c3,0x21c7,0x21ca,0x21d0,0x21d4,0x21e0,0x21e3,0x21ed,0x21ee,0x21f7,0x21f8,0x220b,0x220b,0x227a,0x227d,0x23ce,0x23ce,0x23f4,0x23f7,0x2427,0x243a,0x243c,0x243c,0x243e,0x243e,0x2460,0x246b,0x24f5,0x24fd,0x24ff,0x24ff,0x278a,0x278b,0x27fc,0x27fc,0xff21,0xff3a,0x0,0x0 };
{
ImFontConfig cfg;
cfg.MergeMode = true;
cfg.PixelSnapH = true;
@ -552,8 +564,29 @@ bool ImGuiManager::AddIconFonts(float size)
cfg.GlyphMaxAdvanceX = size;
cfg.FontDataOwnedByAtlas = false;
return (ImGui::GetIO().Fonts->AddFontFromMemoryTTF(s_icon_font_data.data(), static_cast<int>(s_icon_font_data.size()),
size * 0.75f, &cfg, range_fa) != nullptr);
if (!ImGui::GetIO().Fonts->AddFontFromMemoryTTF(
s_icon_fa_font_data.data(), static_cast<int>(s_icon_fa_font_data.size()), size * 0.75f, &cfg, range_fa))
{
return false;
}
}
{
ImFontConfig cfg;
cfg.MergeMode = true;
cfg.PixelSnapH = true;
cfg.GlyphMinAdvanceX = size;
cfg.GlyphMaxAdvanceX = size;
cfg.FontDataOwnedByAtlas = false;
if (!ImGui::GetIO().Fonts->AddFontFromMemoryTTF(
s_icon_pf_font_data.data(), static_cast<int>(s_icon_pf_font_data.size()), size * 1.2f, &cfg, range_pf))
{
return false;
}
}
return true;
}
bool ImGuiManager::AddImGuiFonts(bool fullscreen_fonts)