Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added keyboard and mouse input remapping, rudimentary mouse movement to joystick logic and more #1356

Open
wants to merge 66 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
66 commits
Select commit Hold shift + click to select a range
81e0f14
added support for loading keyboard config from file
kalaposfos13 Oct 12, 2024
94c0764
final minor update before pull request
kalaposfos13 Oct 12, 2024
37dcdce
fix messing up the merge
kalaposfos13 Oct 12, 2024
f6d54bf
fix waitEvent to correctly handle mouse inputs
kalaposfos13 Oct 12, 2024
3dda62f
add license
kalaposfos13 Oct 12, 2024
9820022
Applied coding style fixes
kalaposfos13 Oct 12, 2024
22e4ab8
clang-format fucked up the .ini file
kalaposfos13 Oct 12, 2024
31caf01
Merge branch 'shadps4-emu:main' into main
kalaposfos13 Oct 12, 2024
45f05c0
actually fix clang changing ini syntax
kalaposfos13 Oct 12, 2024
b15810d
remove big commented out code blocks,
kalaposfos13 Oct 13, 2024
719a36c
fix windows hating me
kalaposfos13 Oct 13, 2024
607514e
added mouse config option
kalaposfos13 Oct 13, 2024
6a2eab3
added toggle for mouse movement input (f7)
kalaposfos13 Oct 13, 2024
b300ffe
fix license and style
kalaposfos13 Oct 13, 2024
ef7b0ad
add numpad support i accidentally left out
kalaposfos13 Oct 13, 2024
17e44de
added support for mouse wheel (to buttons only)
kalaposfos13 Oct 14, 2024
1ec9dc0
if keyboard config doesn't exist, autogenerate it
kalaposfos13 Oct 14, 2024
f486663
added keybinds for "walk mode"
kalaposfos13 Oct 14, 2024
bd2acfa
Mouse movement input is now off by default
kalaposfos13 Oct 15, 2024
c5391ba
Merge branch 'shadps4-emu:main' into main
kalaposfos13 Oct 15, 2024
4c6bee8
code cleanup and misc fixes
kalaposfos13 Oct 15, 2024
60d9e7b
delete config file since it is now autogenerated
kalaposfos13 Oct 15, 2024
a76b792
F6 = F7 + F9
kalaposfos13 Oct 15, 2024
649a5c0
Merge branch 'shadps4-emu:main' into main
kalaposfos13 Oct 15, 2024
92bbe40
added better mouse handling with config options
kalaposfos13 Oct 16, 2024
1788aed
Added capslock support
kalaposfos13 Oct 16, 2024
b00ebf3
fix clang-format
kalaposfos13 Oct 17, 2024
5fdaea8
Added support for mod key toggle key
kalaposfos13 Oct 17, 2024
52b06c4
F6 and F7 are removed, F9 captures and enables the mouse
kalaposfos13 Oct 17, 2024
d0238e1
Merge remote-tracking branch 'upstream/main'
kalaposfos13 Oct 18, 2024
24348f6
Encapsulated globals and new classes in a new namespace
kalaposfos13 Oct 18, 2024
2c913a1
Added mouse side button support
kalaposfos13 Oct 18, 2024
2c51aee
Merge remote-tracking branch 'upstream/main'
kalaposfos13 Oct 18, 2024
e0b288a
Added per-game config
kalaposfos13 Oct 18, 2024
942c1d8
relocated input parser to the new namespace
kalaposfos13 Oct 18, 2024
52ad7e0
changed parser parameters to make it possible to use it from the gui
kalaposfos13 Oct 18, 2024
050ba2e
added home, end, pgup and pgdown
kalaposfos13 Oct 18, 2024
abbff1f
Merge branch 'upstreamMain'
kalaposfos13 Oct 20, 2024
f7b8f5e
Resolved merge conflict and refactored code
kalaposfos13 Oct 20, 2024
7ab5085
Updated default keybindings
kalaposfos13 Oct 20, 2024
e3408a2
Merge remote-tracking branch 'upstream/main' - update to 0.4.0
kalaposfos13 Oct 31, 2024
cd4d3c5
Changed input handling to be single-threaded
kalaposfos13 Oct 31, 2024
9958033
General code cleanup
kalaposfos13 Oct 31, 2024
204f906
Merge remote-tracking branch 'upstream/main'
kalaposfos13 Nov 2, 2024
a657e22
Merge remote-tracking branch 'upstream/main'
kalaposfos13 Nov 7, 2024
7a95c27
Start working on new backend
kalaposfos13 Nov 12, 2024
1884b39
Mouse polling, CMakeLists, and basic framework
kalaposfos13 Nov 13, 2024
d92a83c
Output update handling, and reworked file creating, reading and parsing
kalaposfos13 Nov 13, 2024
86c8701
Parsing works now
kalaposfos13 Nov 13, 2024
5c2d09d
Single key button inputs work now
kalaposfos13 Nov 13, 2024
df738c6
Axis outputs work now
kalaposfos13 Nov 13, 2024
0d87d0d
Wheel works now (for me), l2/r2 handling improvements, and misc bugfixes
kalaposfos13 Nov 14, 2024
6ad6079
Downgraded prints to log_debug, and implemented input hierarchy
kalaposfos13 Nov 14, 2024
09b945c
Implemented key toggle
kalaposfos13 Nov 14, 2024
1a8f177
Added mouse parameter parsing
kalaposfos13 Nov 14, 2024
9c81f8e
clang-format
kalaposfos13 Nov 14, 2024
e215530
Merge remote-tracking branch 'upstream/main'
kalaposfos13 Nov 14, 2024
e38e75b
Merge branch 'new-kbm'
kalaposfos13 Nov 14, 2024
3e512bc
Fixed clang and added a const keyword for mac
kalaposfos13 Nov 14, 2024
1efd247
Fix input hierarchy
kalaposfos13 Nov 14, 2024
e43d60e
Fixed joysick halfmodes, and possibly the last update on input hierarchy
kalaposfos13 Nov 15, 2024
900b578
clang-format
kalaposfos13 Nov 15, 2024
94c6a9f
Rewrote the default config to reflect new changes
kalaposfos13 Nov 15, 2024
9d6dd79
clang
kalaposfos13 Nov 15, 2024
91e30ac
Update code style
kalaposfos13 Nov 15, 2024
f5f988d
Updated sorting to accomodate for that one specific edge case
kalaposfos13 Nov 15, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -724,6 +724,8 @@ set(IMGUI src/imgui/imgui_config.h

set(INPUT src/input/controller.cpp
src/input/controller.h
src/input/input_handler.cpp
src/input/input_handler.h
)

set(EMULATOR src/emulator.cpp
Expand Down
115 changes: 115 additions & 0 deletions src/common/config.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -701,4 +701,119 @@ void setDefaultValues() {
gpuId = -1;
}

constexpr std::string_view GetDefaultKeyboardConfig() {
return R"(#This is the default keybinding config
#To change per-game configs, modify the CUSAXXXXX.ini files
#To change the default config that applies to new games without modifying already existing configs, modify default.ini
#If you don't like certain mappings, delete, change or comment them out.
#You can add any amount of KBM keybinds to a single controller input,
#but you can use each KBM keybind for one controller input.
#Every input consists of up to 3 different keys.

#Keybinds used by the emulator (these are unchangeable):
#F12 : Trigger Renderdoc capture
#F11 : Fullscreen
#F10 : FPS counter
#Ctrl + F10 : Debug overlay
#F9 : Pause emulator, but only if the debug overlay is active
#F8 : reparse keyboard input(this)
#F7 : toggle mouse-to-joystick input
# (it overwrites everything else to that joystick, so this is required)

#This is a mapping for Bloodborne, inspired by other Souls titles on PC.

#Specifies which joystick the mouse movement controls.
mouse_to_joystick = right;

#Use healing item, change status in inventory
triangle = f;
#Dodge, back in inventory
circle = space;
#Interact, select item in inventory
cross = e;
#Use quick item, remove item in inventory
square = r;

#Emergency extra bullets
up = w, lalt;
up = mousewheelup;
#Change quick item
down = s, lalt;
down = mousewheeldown;
#Change weapon in left hand
left = a, lalt;
left = mousewheelleft;
#Change weapon in right hand
right = d, lalt;
right = mousewheelright;
#Change into 'inventory mode', so you don't have to hold the secondary key every time you go into menus
key_toggle = i, lalt;

#Menu
options = escape;
#Gestures
touchpad = g;

#Transform
l1 = rightbutton, lshift;
#Shoot
r1 = leftbutton;
#Light attack
l2 = rightbutton;
#Heavy attack
r2 = leftbutton, lshift;
#Does nothing
l3 = x;
#Center cam, lock on
r3 = q;
r3 = middlebutton;

#Axis mappings
#Move
#Change to 'walk mode' by holding the following key:
#(halves the distance the inputs push the virtual joystick to a given direction)
leftjoystick_halfmode = lctrl;
axis_left_x_minus = a;
axis_left_x_plus = d;
axis_left_y_minus = w;
axis_left_y_plus = s;

)";
}
std::filesystem::path GetFoolproofKbmConfigFile(const std::string& game_id) {
// Read configuration file of the game, and if it doesn't exist, generate it from default
// If that doesn't exist either, generate that from getDefaultConfig() and try again
// If even the folder is missing, we start with that.

const auto config_dir = Common::FS::GetUserPath(Common::FS::PathType::UserDir) / "kbmConfig";
const auto config_file = config_dir / (game_id + ".ini");
const auto default_config_file = config_dir / "default.ini";

// Ensure the config directory exists
if (!std::filesystem::exists(config_dir)) {
std::filesystem::create_directories(config_dir);
}

// Check if the default config exists
if (!std::filesystem::exists(default_config_file)) {
// If the default config is also missing, create it from getDefaultConfig()
const auto default_config = GetDefaultKeyboardConfig();
std::ofstream default_config_stream(default_config_file);
if (default_config_stream) {
default_config_stream << default_config;
}
}

// if empty, we only need to execute the function up until this point
if (game_id.empty()) {
return default_config_file;
}

// If game-specific config doesn't exist, create it from the default config
if (!std::filesystem::exists(config_file)) {
std::filesystem::copy(default_config_file, config_file);
}
return config_file;
}

} // namespace Config
3 changes: 3 additions & 0 deletions src/common/config.h
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,9 @@ std::string getEmulatorLanguage();

void setDefaultValues();

// todo: name and function location pending
std::filesystem::path GetFoolproofKbmConfigFile(const std::string& game_id = "");

// settings
u32 GetLanguage();
}; // namespace Config
Loading