mirror of
https://github.com/citra-emu/citra.git
synced 2024-11-25 23:40:14 +00:00
Fix various style issues. Update copyright. Fix clang issues
This commit is contained in:
parent
63fc6e6c48
commit
b9d9452334
@ -8,19 +8,18 @@
|
||||
#define SDL_MAIN_HANDLED
|
||||
#include <SDL.h>
|
||||
#include <glad/glad.h>
|
||||
|
||||
#include "common/logging/log.h"
|
||||
#include "common/scm_rev.h"
|
||||
#include "common/string_util.h"
|
||||
#include "core/hle/service/hid/hid.h"
|
||||
#include "core/settings.h"
|
||||
|
||||
#include "input_core/devices/keyboard.h"
|
||||
#include "input_core/input_core.h"
|
||||
#include "video_core/video_core.h"
|
||||
|
||||
#include "citra/emu_window/emu_window_sdl2.h"
|
||||
|
||||
#include "video_core/video_core.h"
|
||||
|
||||
void EmuWindow_SDL2::OnMouseMotion(s32 x, s32 y) {
|
||||
TouchMoved((unsigned)std::max(x, 0), (unsigned)std::max(y, 0));
|
||||
motion_emu->Tilt(x, y);
|
||||
|
@ -100,11 +100,11 @@ void ConfigureInput::loadConfiguration() {
|
||||
updateButtonLabels();
|
||||
}
|
||||
|
||||
void ConfigureInput::setKey(Settings::InputDeviceMapping keyPressed) {
|
||||
if (keyPressed.key == -1 || keyPressed.key == Qt::Key_Escape) {
|
||||
void ConfigureInput::setKey(Settings::InputDeviceMapping key_pressed) {
|
||||
if (key_pressed.key == -1 || key_pressed.key == Qt::Key_Escape) {
|
||||
} else {
|
||||
key_map[changing_button] = keyPressed;
|
||||
removeDuplicates(keyPressed);
|
||||
key_map[changing_button] = key_pressed;
|
||||
removeDuplicates(key_pressed);
|
||||
}
|
||||
updateButtonLabels();
|
||||
releaseKeyboard();
|
||||
@ -136,10 +136,10 @@ QString ConfigureInput::getKeyName(Settings::InputDeviceMapping mapping) {
|
||||
return QKeySequence(mapping.key).toString();
|
||||
}
|
||||
|
||||
void ConfigureInput::removeDuplicates(const Settings::InputDeviceMapping newValue) {
|
||||
void ConfigureInput::removeDuplicates(const Settings::InputDeviceMapping new_value) {
|
||||
for (auto& entry : key_map) {
|
||||
if (changing_button != entry.first) {
|
||||
if (newValue == entry.second && newValue.key == entry.second.key) {
|
||||
if (new_value == entry.second && new_value.key == entry.second.key) {
|
||||
entry.second = Settings::InputDeviceMapping();
|
||||
}
|
||||
}
|
||||
|
@ -40,7 +40,7 @@ private:
|
||||
|
||||
/// Check all inputs for duplicate keys. Clears out any other button with the same value as this
|
||||
/// button's new value.
|
||||
void removeDuplicates(const Settings::InputDeviceMapping newValue);
|
||||
void removeDuplicates(const Settings::InputDeviceMapping new_value);
|
||||
|
||||
/// Handle keykoard key press event for input tab when a button is 'waiting'.
|
||||
void keyPressEvent(QKeyEvent* event) override;
|
||||
@ -49,7 +49,7 @@ private:
|
||||
static QString getKeyName(Settings::InputDeviceMapping mapping);
|
||||
|
||||
/// Set button text to name of key pressed.
|
||||
void setKey(Settings::InputDeviceMapping keyPressed);
|
||||
void setKey(Settings::InputDeviceMapping key_pressed);
|
||||
|
||||
/// Event handler for all button released() event.
|
||||
void handleClick(QPushButton* sender);
|
||||
|
@ -1,4 +1,4 @@
|
||||
// Copyright 2016 Citra Emulator Project
|
||||
// Copyright 2017 Citra Emulator Project
|
||||
// Licensed under GPLv2 or any later version
|
||||
// Refer to the license.txt file included.
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
// Copyright 2016 Citra Emulator Project
|
||||
// Copyright 2017 Citra Emulator Project
|
||||
// Licensed under GPLv2 or any later version
|
||||
// Refer to the license.txt file included.
|
||||
|
||||
|
@ -30,7 +30,7 @@ set(SRCS
|
||||
file_sys/path_parser.cpp
|
||||
file_sys/savedata_archive.cpp
|
||||
frontend/emu_window.cpp
|
||||
frontend/motion_emu.cpp
|
||||
frontend/motion_emu.cpp
|
||||
gdbstub/gdbstub.cpp
|
||||
hle/config_mem.cpp
|
||||
hle/applets/applet.cpp
|
||||
@ -203,7 +203,7 @@ set(HEADERS
|
||||
file_sys/path_parser.h
|
||||
file_sys/savedata_archive.h
|
||||
frontend/emu_window.h
|
||||
frontend/motion_emu.h
|
||||
frontend/motion_emu.h
|
||||
gdbstub/gdbstub.h
|
||||
hle/config_mem.h
|
||||
hle/function_wrappers.h
|
||||
|
@ -7,11 +7,10 @@
|
||||
#include "common/assert.h"
|
||||
#include "common/profiler_reporting.h"
|
||||
#include "core/frontend/emu_window.h"
|
||||
#include "input_core/input_core.h"
|
||||
#include "video_core/video_core.h"
|
||||
|
||||
#include "emu_window.h"
|
||||
#include "input_core/input_core.h"
|
||||
#include "video_core/video_core.h"
|
||||
|
||||
/**
|
||||
* Check if the given x/y coordinates are within the touchpad specified by the framebuffer layout
|
||||
|
@ -10,15 +10,14 @@
|
||||
#include "core/hle/service/hid/hid_user.h"
|
||||
#include "core/hle/service/service.h"
|
||||
|
||||
#include "input_core/input_core.h"
|
||||
|
||||
#include "core/core_timing.h"
|
||||
#include "core/hle/kernel/event.h"
|
||||
#include "core/hle/kernel/shared_memory.h"
|
||||
#include "core/hle/service/hid/hid.h"
|
||||
#include "core/hle/service/hid/hid_spvr.h"
|
||||
#include "core/hle/service/hid/hid_user.h"
|
||||
#include "core/hle/service/service.h"
|
||||
|
||||
#include "input_core/input_core.h"
|
||||
#include "video_core/video_core.h"
|
||||
|
||||
namespace Service {
|
||||
|
@ -1,4 +1,4 @@
|
||||
// Copyright 2016 Citra Emulator Project
|
||||
// Copyright 2017 Citra Emulator Project
|
||||
// Licensed under GPLv2 or any later version
|
||||
// Refer to the license.txt file included.
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
// Copyright 2016 Citra Emulator Project
|
||||
// Copyright 2017 Citra Emulator Project
|
||||
// Licensed under GPLv2 or any later version
|
||||
// Refer to the license.txt file included.
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
// Copyright 2016 Citra Emulator Project
|
||||
// Copyright 2017 Citra Emulator Project
|
||||
// Licensed under GPLv2 or any later version
|
||||
// Refer to the license.txt file included.
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
// Copyright 2016 Citra Emulator Project
|
||||
// Copyright 2017 Citra Emulator Project
|
||||
// Licensed under GPLv2 or any later version
|
||||
// Refer to the license.txt file included.
|
||||
|
||||
@ -7,9 +7,9 @@
|
||||
|
||||
#include "input_core/devices/keyboard.h"
|
||||
|
||||
Keyboard::Keyboard() {}
|
||||
Keyboard::Keyboard() = default;
|
||||
|
||||
Keyboard::~Keyboard() {}
|
||||
Keyboard::~Keyboard() = default;
|
||||
|
||||
bool Keyboard::InitDevice(int number, Settings::InputDeviceMapping device_mapping) {
|
||||
input_device_mapping = device_mapping;
|
||||
@ -17,14 +17,13 @@ bool Keyboard::InitDevice(int number, Settings::InputDeviceMapping device_mappin
|
||||
}
|
||||
|
||||
std::map<Settings::InputDeviceMapping, float> Keyboard::ProcessInput() {
|
||||
std::map<KeyboardKey, bool> keysPressedCopy;
|
||||
std::map<KeyboardKey, bool> keys_pressed_copy;
|
||||
{
|
||||
std::lock_guard<std::mutex> lock(m);
|
||||
keysPressedCopy = keys_pressed;
|
||||
keys_pressed_copy = keys_pressed;
|
||||
}
|
||||
std::map<Settings::InputDeviceMapping, float> button_status;
|
||||
bool circlePadModPressed = keysPressedCopy[circle_pad_modifier];
|
||||
for (const auto& key : keysPressedCopy) {
|
||||
for (const auto& key : keys_pressed_copy) {
|
||||
input_device_mapping.key = key.first.key;
|
||||
button_status.emplace(input_device_mapping, key.second ? 1.0 : 0.0);
|
||||
}
|
||||
|
@ -1,4 +1,4 @@
|
||||
// Copyright 2016 Citra Emulator Project
|
||||
// Copyright 2017 Citra Emulator Project
|
||||
// Licensed under GPLv2 or any later version
|
||||
// Refer to the license.txt file included.
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
// Copyright 2016 Citra Emulator Project
|
||||
// Copyright 2017 Citra Emulator Project
|
||||
// Licensed under GPLv2 or any later version
|
||||
// Refer to the license.txt file included.
|
||||
|
||||
@ -16,7 +16,7 @@
|
||||
|
||||
bool SDLGamepad::SDLInitialized = false;
|
||||
|
||||
SDLGamepad::SDLGamepad() {}
|
||||
SDLGamepad::SDLGamepad() = default;
|
||||
SDLGamepad::SDLGamepad(int number_, _SDL_GameController* gamepad_)
|
||||
: number(number_), gamepad(gamepad_) {}
|
||||
SDLGamepad::~SDLGamepad() {
|
||||
@ -51,14 +51,15 @@ std::map<Settings::InputDeviceMapping, float> SDLGamepad::ProcessInput() {
|
||||
SDL_GameControllerButton button = static_cast<SDL_GameControllerButton>(i);
|
||||
Uint8 pressed = SDL_GameControllerGetButton(gamepad, button);
|
||||
input_device_mapping.key = static_cast<int>(
|
||||
gamepadinput_to_sdlname_mapping2[SDL_GameControllerGetStringForButton(button)]);
|
||||
gamepadinput_to_sdlname_mapping[SDL_GameControllerGetStringForButton(button)]);
|
||||
button_status.emplace(input_device_mapping, pressed);
|
||||
}
|
||||
for (int i = 0; i < SDL_GameControllerAxis::SDL_CONTROLLER_AXIS_MAX; i++) {
|
||||
SDL_GameControllerAxis axis = static_cast<SDL_GameControllerAxis>(i);
|
||||
float strength = fmaxf(-1, (float)SDL_GameControllerGetAxis(gamepad, axis) / 32767.0);
|
||||
float strength =
|
||||
fmaxf(-1, static_cast<float>(SDL_GameControllerGetAxis(gamepad, axis) / 32767.0));
|
||||
input_device_mapping.key = static_cast<int>(
|
||||
gamepadinput_to_sdlname_mapping2[SDL_GameControllerGetStringForAxis(axis)]);
|
||||
gamepadinput_to_sdlname_mapping[SDL_GameControllerGetStringForAxis(axis)]);
|
||||
if (strength < 0) {
|
||||
button_status.emplace(input_device_mapping, 0);
|
||||
input_device_mapping.key += 1; // minus axis value is always one greater
|
||||
@ -94,6 +95,7 @@ std::vector<std::shared_ptr<IDevice>> SDLGamepad::GetAllDevices() {
|
||||
}
|
||||
|
||||
void SDLGamepad::LoadGameControllerDB() {
|
||||
// gamecontrollerdb file is split into 4 sections due to exceeding max length of string.
|
||||
std::vector<std::string> lines1, lines2, lines3, lines4;
|
||||
Common::SplitString(SDLGameControllerDB::db_file1, '\n', lines1);
|
||||
Common::SplitString(SDLGameControllerDB::db_file2, '\n', lines2);
|
||||
@ -102,7 +104,7 @@ void SDLGamepad::LoadGameControllerDB() {
|
||||
lines1.insert(lines1.end(), lines2.begin(), lines2.end());
|
||||
lines1.insert(lines1.end(), lines3.begin(), lines3.end());
|
||||
lines1.insert(lines1.end(), lines4.begin(), lines4.end());
|
||||
for (std::string s : lines1) {
|
||||
for (const auto s : lines1) {
|
||||
SDL_GameControllerAddMapping(s.c_str());
|
||||
}
|
||||
}
|
||||
@ -112,7 +114,7 @@ Settings::InputDeviceMapping SDLGamepad::GetInput() {
|
||||
return Settings::InputDeviceMapping("");
|
||||
|
||||
auto results = ProcessInput();
|
||||
for (auto& input : results) {
|
||||
for (const auto& input : results) {
|
||||
if (input.second > 0.5)
|
||||
return input.first;
|
||||
}
|
||||
|
@ -1,4 +1,4 @@
|
||||
// Copyright 2016 Citra Emulator Project
|
||||
// Copyright 2017 Citra Emulator Project
|
||||
// Licensed under GPLv2 or any later version
|
||||
// Refer to the license.txt file included.
|
||||
|
||||
@ -52,33 +52,7 @@ public:
|
||||
private:
|
||||
/// Maps the friendly name shown on GUI with the string name for getting the SDL button
|
||||
/// instance.
|
||||
std::map<GamepadInputs, std::string> gamepadinput_to_sdlname_mapping = {
|
||||
{GamepadInputs::ButtonA, "a"},
|
||||
{GamepadInputs::ButtonB, "b"},
|
||||
{GamepadInputs::ButtonX, "x"},
|
||||
{GamepadInputs::ButtonY, "y"},
|
||||
{GamepadInputs::LeftShoulder, "leftshoulder"},
|
||||
{GamepadInputs::RightShoulder, "rightshoulder"},
|
||||
{GamepadInputs::Start, "start"},
|
||||
{GamepadInputs::Back, "back"},
|
||||
{GamepadInputs::DPadUp, "dpup"},
|
||||
{GamepadInputs::DpadDown, "dpdown"},
|
||||
{GamepadInputs::DpadLeft, "dpleft"},
|
||||
{GamepadInputs::DpadRight, "dpright"},
|
||||
{GamepadInputs::L3, "leftstick"},
|
||||
{GamepadInputs::R3, "rightstick"},
|
||||
{GamepadInputs::LeftTrigger, "lefttrigger"},
|
||||
{GamepadInputs::RightTrigger, "righttrigger"},
|
||||
{GamepadInputs::LeftYPlus, "lefty"},
|
||||
{GamepadInputs::LeftYMinus, "lefty"},
|
||||
{GamepadInputs::LeftXPlus, "leftx"},
|
||||
{GamepadInputs::LeftXMinus, "leftx"},
|
||||
{GamepadInputs::RightYPlus, "righty"},
|
||||
{GamepadInputs::RightYMinus, "righty"},
|
||||
{GamepadInputs::RightXPlus, "rightx"},
|
||||
{GamepadInputs::RightXMinus, "rightx"},
|
||||
};
|
||||
std::map<std::string, GamepadInputs> gamepadinput_to_sdlname_mapping2 = {
|
||||
std::map<std::string, GamepadInputs> gamepadinput_to_sdlname_mapping = {
|
||||
{"a", GamepadInputs::ButtonA},
|
||||
{"b", GamepadInputs::ButtonB},
|
||||
{"x", GamepadInputs::ButtonX},
|
||||
|
@ -1,4 +1,4 @@
|
||||
// Copyright 2016 Citra Emulator Project
|
||||
// Copyright 2017 Citra Emulator Project
|
||||
// Licensed under GPLv2 or any later version
|
||||
// Refer to the license.txt file included.
|
||||
|
||||
@ -28,7 +28,7 @@ std::mutex InputCore::touch_mutex;
|
||||
u16 InputCore::touch_x; ///< Touchpad X-position in native 3DS pixel coordinates (0-320)
|
||||
u16 InputCore::touch_y; ///< Touchpad Y-position in native 3DS pixel coordinates (0-240)
|
||||
bool InputCore::touch_pressed; ///< True if touchpad area is currently pressed, otherwise false
|
||||
const float input_detect_threshold =
|
||||
const float InputCore::input_detect_threshold =
|
||||
0.45; ///< Applies to analog controls being used for digital 3ds inputs.
|
||||
|
||||
void InputCore::Init() {
|
||||
@ -60,7 +60,7 @@ void InputCore::UpdateEmulatorInputs(
|
||||
std::lock_guard<std::mutex> lock(pad_state_mutex);
|
||||
|
||||
// Apply deadzone for circle pad
|
||||
float leftx = 0, lefty = 0;
|
||||
float left_x = 0, left_y = 0;
|
||||
float circle_pad_modifier = 1.0;
|
||||
auto circle_pad_modifier_mapping = Settings::values.pad_circle_modifier;
|
||||
for (auto& input_device : inputs) {
|
||||
@ -69,13 +69,13 @@ void InputCore::UpdateEmulatorInputs(
|
||||
auto emulator_inputs = key_mappings[button_states.first];
|
||||
for (auto& emulator_input : emulator_inputs) {
|
||||
if (emulator_input == Service::HID::PAD_CIRCLE_UP && abs(strength) > 0) {
|
||||
lefty = -strength;
|
||||
left_y = -strength;
|
||||
} else if (emulator_input == Service::HID::PAD_CIRCLE_DOWN && abs(strength) > 0) {
|
||||
lefty = strength;
|
||||
left_y = strength;
|
||||
} else if (emulator_input == Service::HID::PAD_CIRCLE_LEFT && abs(strength) > 0) {
|
||||
leftx = -strength;
|
||||
left_x = -strength;
|
||||
} else if (emulator_input == Service::HID::PAD_CIRCLE_RIGHT && abs(strength) > 0) {
|
||||
leftx = strength;
|
||||
left_x = strength;
|
||||
}
|
||||
}
|
||||
if (button_states.first == circle_pad_modifier_mapping)
|
||||
@ -85,7 +85,7 @@ void InputCore::UpdateEmulatorInputs(
|
||||
}
|
||||
}
|
||||
float deadzone = Settings::values.pad_circle_deadzone;
|
||||
std::tuple<float, float> left_stick = ApplyDeadzone(leftx, lefty, deadzone);
|
||||
std::tuple<float, float> left_stick = ApplyDeadzone(left_x, left_y, deadzone);
|
||||
|
||||
// Set emulator circlepad values
|
||||
std::get<0>(circle_pad) =
|
||||
@ -149,24 +149,26 @@ void InputCore::SetTouchState(std::tuple<u16, u16, bool> value) {
|
||||
std::tie(touch_x, touch_y, touch_pressed) = value;
|
||||
}
|
||||
|
||||
bool InputCore::CheckIfMappingExists(const std::vector<Settings::InputDeviceMapping>& uniqueMapping,
|
||||
Settings::InputDeviceMapping mappingToCheck) {
|
||||
return std::any_of(uniqueMapping.begin(), uniqueMapping.end(),
|
||||
[mappingToCheck](const auto& mapping) { return mapping == mappingToCheck; });
|
||||
bool InputCore::CheckIfMappingExists(
|
||||
const std::vector<Settings::InputDeviceMapping>& unique_mapping,
|
||||
Settings::InputDeviceMapping mapping_to_check) {
|
||||
return std::any_of(
|
||||
unique_mapping.begin(), unique_mapping.end(),
|
||||
[mapping_to_check](const auto& mapping) { return mapping == mapping_to_check; });
|
||||
}
|
||||
|
||||
std::vector<Settings::InputDeviceMapping> InputCore::GatherUniqueMappings() {
|
||||
std::vector<Settings::InputDeviceMapping> uniqueMappings;
|
||||
std::vector<Settings::InputDeviceMapping> unique_mappings;
|
||||
|
||||
for (const auto& mapping : Settings::values.input_mappings) {
|
||||
if (!CheckIfMappingExists(uniqueMappings, mapping)) {
|
||||
uniqueMappings.push_back(mapping);
|
||||
if (!CheckIfMappingExists(unique_mappings, mapping)) {
|
||||
unique_mappings.push_back(mapping);
|
||||
}
|
||||
}
|
||||
if (!CheckIfMappingExists(uniqueMappings, Settings::values.pad_circle_modifier)) {
|
||||
uniqueMappings.push_back(Settings::values.pad_circle_modifier);
|
||||
if (!CheckIfMappingExists(unique_mappings, Settings::values.pad_circle_modifier)) {
|
||||
unique_mappings.push_back(Settings::values.pad_circle_modifier);
|
||||
}
|
||||
return uniqueMappings;
|
||||
return unique_mappings;
|
||||
}
|
||||
|
||||
void InputCore::BuildKeyMapping() {
|
||||
@ -237,7 +239,7 @@ std::vector<std::shared_ptr<IDevice>> InputCore::GetAllDevices() {
|
||||
}
|
||||
|
||||
Settings::InputDeviceMapping InputCore::DetectInput(int max_time,
|
||||
std::function<void(void)> update_GUI) {
|
||||
std::function<void(void)> update_gui) {
|
||||
auto devices = GetAllDevices();
|
||||
for (auto& device : devices) {
|
||||
device->Clear();
|
||||
@ -245,7 +247,7 @@ Settings::InputDeviceMapping InputCore::DetectInput(int max_time,
|
||||
Settings::InputDeviceMapping input_device;
|
||||
auto start = std::chrono::high_resolution_clock::now();
|
||||
while (input_device.key == -1) {
|
||||
update_GUI();
|
||||
update_gui();
|
||||
auto duration = std::chrono::duration_cast<std::chrono::milliseconds>(
|
||||
std::chrono::high_resolution_clock::now() - start)
|
||||
.count();
|
||||
|
@ -1,4 +1,4 @@
|
||||
// Copyright 2016 Citra Emulator Project
|
||||
// Copyright 2017 Citra Emulator Project
|
||||
// Licensed under GPLv2 or any later version
|
||||
// Refer to the license.txt file included.
|
||||
|
||||
@ -92,6 +92,7 @@ private:
|
||||
static u16 touch_x; ///< Touchpad X-position in native 3DS pixel coordinates (0-320)
|
||||
static u16 touch_y; ///< Touchpad Y-position in native 3DS pixel coordinates (0-240)
|
||||
static bool touch_pressed; ///< True if touchpad area is currently pressed, otherwise false
|
||||
static const float input_detect_threshold;
|
||||
|
||||
/**
|
||||
* Loops through all unique input devices, and all bound inputs to update the emulator's input
|
||||
|
@ -1,4 +1,4 @@
|
||||
// Copyright 2016 Citra Emulator Project
|
||||
// Copyright 2017 Citra Emulator Project
|
||||
// Licensed under GPLv2 or any later version
|
||||
// Refer to the license.txt file included.
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
// Copyright 2016 Citra Emulator Project
|
||||
// Copyright 2017 Citra Emulator Project
|
||||
// Licensed under GPLv2 or any later version
|
||||
// Refer to the license.txt file included.
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user