Skip to content

Commit

Permalink
Revert "Add UI to configure keyboard-to-controller mapping (shadps4-e…
Browse files Browse the repository at this point in the history
…mu#308)"

This reverts commit fdb13a3.
  • Loading branch information
georgemoralis committed Sep 11, 2024
1 parent c27d79c commit dd61c2a
Show file tree
Hide file tree
Showing 18 changed files with 173 additions and 1,436 deletions.
19 changes: 5 additions & 14 deletions .ci/clang-format.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,6 @@
# SPDX-FileCopyrightText: 2023 Citra Emulator Project
# SPDX-License-Identifier: GPL-2.0-or-later

fix=false
if [ "$1" == "--fix" ]; then
fix=true
fi

if grep -nrI '\s$' src *.yml *.txt *.md Doxyfile .gitignore .gitmodules .ci* dist/*.desktop \
dist/*.svg dist/*.xml; then
echo Trailing whitespace found, aborting
Expand All @@ -30,15 +25,11 @@ fi
set +x

for f in $files_to_lint; do
if [ "$fix" = true ]; then
$CLANG_FORMAT -i "$f"
else
d=$(diff -u "$f" <($CLANG_FORMAT "$f") || true)
if ! [ -z "$d" ]; then
echo "!!! $f not compliant to coding style, here is the fix:"
echo "$d"
fail=1
fi
d=$(diff -u "$f" <($CLANG_FORMAT "$f") || true)
if ! [ -z "$d" ]; then
echo "!!! $f not compliant to coding style, here is the fix:"
echo "$d"
fail=1
fi
done

Expand Down
8 changes: 1 addition & 7 deletions .github/workflows/linux-qt.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,7 @@ jobs:

- name: Install misc packages
run: >
sudo apt-get update && sudo apt install libx11-dev libxext-dev libwayland-dev libfuse2 clang build-essential
- name: Setup Qt
uses: jurplel/install-qt-action@v4
with:
arch: linux_gcc_64
version: 6.7.1
sudo apt-get update && sudo apt install libx11-dev libxext-dev libwayland-dev libfuse2 clang build-essential qt6-base-dev qt6-tools-dev
- name: Cache CMake dependency source code
uses: actions/cache@v4
Expand Down
1 change: 0 additions & 1 deletion .reuse/dep5
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ Files: CMakeSettings.json
documents/Screenshots/Undertale.png
documents/Screenshots/We are DOOMED.png
scripts/ps4_names.txt
src/images/PS4_controller_scheme.png
src/images/about_icon.png
src/images/controller_icon.png
src/images/exit_icon.png
Expand Down
4 changes: 0 additions & 4 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -607,7 +607,6 @@ set(IMGUI src/imgui/imgui_config.h

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

set(EMULATOR src/emulator.cpp
Expand Down Expand Up @@ -652,9 +651,6 @@ set(QT_GUI src/qt_gui/about_dialog.cpp
src/qt_gui/settings_dialog.cpp
src/qt_gui/settings_dialog.h
src/qt_gui/settings_dialog.ui
src/qt_gui/keyboardcontrolswindow.h
src/qt_gui/keyboardcontrolswindow.cpp
src/qt_gui/keyboardcontrolswindow.ui
src/qt_gui/main.cpp
${EMULATOR}
${RESOURCE_FILES}
Expand Down
45 changes: 1 addition & 44 deletions src/common/config.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,6 @@ std::vector<std::string> m_recent_files;
std::string emulator_language = "en";
// Settings
u32 m_language = 1; // english
std::map<u32, KeysMapping> m_keyboard_binding_map;

bool isNeoMode() {
return isNeo;
Expand Down Expand Up @@ -284,12 +283,7 @@ void setRecentFiles(const std::vector<std::string>& recentFiles) {
void setEmulatorLanguage(std::string language) {
emulator_language = language;
}
void setKeyboardBindingMap(std::map<u32, KeysMapping> map) {
m_keyboard_binding_map = map;
}
const std::map<u32, KeysMapping>& getKeyboardBindingMap() {
return m_keyboard_binding_map;
}

u32 getMainWindowGeometryX() {
return main_window_geometry_x;
}
Expand Down Expand Up @@ -437,34 +431,6 @@ void load(const std::filesystem::path& path) {

m_language = toml::find_or<int>(settings, "consoleLanguage", 1);
}

if (data.contains("Controls")) {
auto controls = toml::find<toml::table>(data, "Controls");

toml::table keyboardBindings{};
auto it = controls.find("keyboardBindings");
if (it != controls.end() && it->second.is_table()) {
keyboardBindings = it->second.as_table();
}

// Convert TOML table to std::map<u32, KeysMapping>
for (const auto& [key, value] : keyboardBindings) {
try {
Uint32 int_key = static_cast<u32>(std::stoll(key));
if (value.is_integer()) {
// Convert the TOML integer value to KeysMapping (int)
int int_value = value.as_integer();

// Add to the map
m_keyboard_binding_map[int_key] = static_cast<KeysMapping>(int_value);
} else {
fmt::print("Unexpected type for value: expected integer, got other type\n");
}
} catch (const std::exception& e) {
fmt::print("Error processing key-value pair: {}\n", e.what());
}
}
}
}
void save(const std::filesystem::path& path) {
toml::value data;
Expand Down Expand Up @@ -526,15 +492,6 @@ void save(const std::filesystem::path& path) {
data["GUI"]["recentFiles"] = m_recent_files;
data["GUI"]["emulatorLanguage"] = emulator_language;

// Create a TOML table with keyboard bindings
toml::table keyboardBindingsTable;
// Serialize the map to the TOML table
for (const auto& [key, value] : m_keyboard_binding_map) {
keyboardBindingsTable[std::to_string(key)] = static_cast<int>(value);
}

data["Controls"]["keyboardBindings"] = keyboardBindingsTable;

data["Settings"]["consoleLanguage"] = m_language;

std::ofstream file(path, std::ios::out);
Expand Down
5 changes: 0 additions & 5 deletions src/common/config.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,7 @@
#pragma once

#include <filesystem>
#include <map>
#include <vector>
#include "SDL3/SDL_stdinc.h"
#include "input/keys_constants.h"
#include "types.h"

namespace Config {
Expand Down Expand Up @@ -82,8 +79,6 @@ void setPkgViewer(const std::vector<std::string>& pkgList);
void setElfViewer(const std::vector<std::string>& elfList);
void setRecentFiles(const std::vector<std::string>& recentFiles);
void setEmulatorLanguage(std::string language);
void setKeyboardBindingMap(std::map<u32, KeysMapping> map);
const std::map<u32, KeysMapping>& getKeyboardBindingMap();

u32 getMainWindowGeometryX();
u32 getMainWindowGeometryY();
Expand Down
2 changes: 1 addition & 1 deletion src/emulator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ void Emulator::Run(const std::filesystem::path& file) {
}
window = std::make_unique<Frontend::WindowSDL>(
Config::getScreenWidth(), Config::getScreenHeight(), controller, window_title);
window->setKeysBindingsMap(Config::getKeyboardBindingMap());

g_window = window.get();

const auto& mount_data_dir = Common::FS::GetUserPath(Common::FS::PathType::GameDataDir) / id;
Expand Down
2 changes: 1 addition & 1 deletion src/emulator.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,6 @@ class Emulator {
Input::GameController* controller;
Core::Linker* linker;
std::unique_ptr<Frontend::WindowSDL> window;
std::map<u32, KeysMapping> m_keysBindingsMap;
};

} // namespace Core
Binary file removed src/images/PS4_controller_scheme.png
Binary file not shown.
30 changes: 0 additions & 30 deletions src/input/keys_constants.h

This file was deleted.

Loading

0 comments on commit dd61c2a

Please sign in to comment.