diff --git a/pcsx2/CMakeLists.txt b/pcsx2/CMakeLists.txt index e7894ab08a..01c8e8e301 100644 --- a/pcsx2/CMakeLists.txt +++ b/pcsx2/CMakeLists.txt @@ -516,8 +516,8 @@ add_custom_command( # PAD/Linux sources set(pcsx2PADSources - PAD/Linux/controller.cpp - PAD/Linux/GamePad.cpp + PAD/Linux/Device.cpp + PAD/Linux/InputManager.cpp PAD/Linux/SDL/joystick.cpp PAD/Linux/keyboard.cpp PAD/Linux/KeyStatus.cpp @@ -527,7 +527,7 @@ set(pcsx2PADSources PAD/Linux/wx_dialog/opPanel.cpp PAD/Linux/wx_dialog/GamepadConfiguration.cpp PAD/Linux/wx_dialog/JoystickConfiguration.cpp - PAD/Linux/ini.cpp + PAD/Linux/Config.cpp PAD/Linux/linux.cpp ${CMAKE_BINARY_DIR}/pcsx2/PAD/Linux/resources_pad.cpp ) @@ -535,8 +535,10 @@ set(pcsx2PADSources # PAD/Linux headers set(pcsx2PADHeaders PAD/Linux/bitwise.h - PAD/Linux/controller.h - PAD/Linux/GamePad.h + PAD/Linux/Config.h + PAD/Linux/Device.h + PAD/Linux/Global.h + PAD/Linux/InputManager.h PAD/Linux/SDL/joystick.h PAD/Linux/keyboard.h PAD/Linux/KeyStatus.h diff --git a/pcsx2/PAD/Linux/ini.cpp b/pcsx2/PAD/Linux/Config.cpp similarity index 96% rename from pcsx2/PAD/Linux/ini.cpp rename to pcsx2/PAD/Linux/Config.cpp index 19511176ac..7ce050a982 100644 --- a/pcsx2/PAD/Linux/ini.cpp +++ b/pcsx2/PAD/Linux/Config.cpp @@ -13,12 +13,10 @@ * If not, see . */ -#include - -#include "GamePad.h" +#include "Global.h" +#include "Device.h" #include "keyboard.h" #include "AppConfig.h" -#include "PAD.h" void DefaultKeyboardValues() { @@ -59,7 +57,7 @@ void PADSaveConfig() fprintf(f, "uid[0] = %zu\n", g_conf.get_joy_uid(0)); fprintf(f, "uid[1] = %zu\n", g_conf.get_joy_uid(1)); - for (int pad = 0; pad < GAMEPAD_NUMBER; pad++) + for (u32 pad = 0; pad < GAMEPAD_NUMBER; pad++) for (auto const& it : g_conf.keysym_map[pad]) fprintf(f, "PAD %d:KEYSYM 0x%x = %d\n", pad, it.first, it.second); @@ -80,7 +78,7 @@ void PADLoadConfig() wxString iniName(L"PAD.ini"); const std::string iniFile = std::string(GetSettingsFolder().Combine(iniName).GetFullPath()); // default path, just in case f = fopen(iniFile.c_str(), "r"); - if (f == NULL) + if (f == nullptr) { printf("OnePAD: failed to load ini %s\n", iniFile.c_str()); PADSaveConfig(); //save and return @@ -113,6 +111,7 @@ void PADLoadConfig() u32 pad; u32 keysym; u32 index; + while (fscanf(f, "PAD %u:KEYSYM 0x%x = %u\n", &pad, &keysym, &index) == 3) { set_keyboard_key(pad & 1, keysym, index); diff --git a/pcsx2/PAD/Linux/controller.h b/pcsx2/PAD/Linux/Config.h similarity index 83% rename from pcsx2/PAD/Linux/controller.h rename to pcsx2/PAD/Linux/Config.h index 7b2e6a2cd1..26f46f0ed6 100644 --- a/pcsx2/PAD/Linux/controller.h +++ b/pcsx2/PAD/Linux/Config.h @@ -14,12 +14,8 @@ */ #pragma once -#include // for memset -#define MAX_KEYS 24 -extern void set_keyboard_key(int pad, int keysym, int index); -extern int get_keyboard_key(int pad, int keysym); -extern bool IsAnalogKey(int index); +#include "Global.h" class PADconf { @@ -58,7 +54,7 @@ public: packed_options = 0; ff_intensity = 0x7FFF; // set it at max value by default sensibility = 100; - for (int pad = 0; pad < GAMEPAD_NUMBER; pad++) + for (u32 pad = 0; pad < GAMEPAD_NUMBER; pad++) { keysym_map[pad].clear(); } @@ -123,3 +119,19 @@ public: } }; extern PADconf g_conf; + +static __forceinline void set_keyboard_key(int pad, int keysym, int index) +{ + g_conf.keysym_map[pad][keysym] = index; +} + +static __forceinline int get_keyboard_key(int pad, int keysym) +{ + // You must use find instead of [] + // [] will create an element if the key does not exist and return 0 + std::map::iterator it = g_conf.keysym_map[pad].find(keysym); + if (it != g_conf.keysym_map[pad].end()) + return it->second; + else + return -1; +} diff --git a/pcsx2/PAD/Linux/GamePad.cpp b/pcsx2/PAD/Linux/Device.cpp similarity index 63% rename from pcsx2/PAD/Linux/GamePad.cpp rename to pcsx2/PAD/Linux/Device.cpp index 8749765b56..4056e1bdeb 100644 --- a/pcsx2/PAD/Linux/GamePad.cpp +++ b/pcsx2/PAD/Linux/Device.cpp @@ -13,60 +13,48 @@ * If not, see . */ -#include "GamePad.h" +#include "Device.h" #ifdef SDL_BUILD #include "SDL/joystick.h" #endif -std::vector> s_vgamePad; - /** * Following static methods are just forwarders to their backend * This is where link between agnostic and specific code is done **/ -/** - * Find every interesting devices and create right structure for them(depend on backend) - **/ -void GamePad::EnumerateGamePads(std::vector>& vgamePad) -{ -#ifdef SDL_BUILD - JoystickInfo::EnumerateJoysticks(vgamePad); -#endif -} - /** * Safely dispatch to the Rumble method above **/ -void GamePad::DoRumble(unsigned type, unsigned pad) +void Device::DoRumble(unsigned type, unsigned pad) { int index = uid_to_index(pad); if (index >= 0) - s_vgamePad[index]->Rumble(type, pad); + device_manager->devices[index]->Rumble(type, pad); } -size_t GamePad::index_to_uid(int index) +size_t Device::index_to_uid(int index) { - if ((index >= 0) && (index < (int)s_vgamePad.size())) - return s_vgamePad[index]->GetUniqueIdentifier(); + if ((index >= 0) && (index < (int)device_manager->devices.size())) + return device_manager->devices[index]->GetUniqueIdentifier(); else return 0; } -int GamePad::uid_to_index(int pad) +int Device::uid_to_index(int pad) { size_t uid = g_conf.get_joy_uid(pad); - for (int i = 0; i < (int)s_vgamePad.size(); ++i) + for (int i = 0; i < (int)device_manager->devices.size(); ++i) { - if (s_vgamePad[i]->GetUniqueIdentifier() == uid) + if (device_manager->devices[i]->GetUniqueIdentifier() == uid) return i; } // Current uid wasn't found maybe the pad was unplugged. Or // user didn't select it. Fallback to 1st pad for // 1st player. And 2nd pad for 2nd player. - if ((int)s_vgamePad.size() > pad) + if ((int)device_manager->devices.size() > pad) return pad; return -1; diff --git a/pcsx2/PAD/Linux/GamePad.h b/pcsx2/PAD/Linux/Device.h similarity index 75% rename from pcsx2/PAD/Linux/GamePad.h rename to pcsx2/PAD/Linux/Device.h index f0d755b422..38e8c2ed12 100644 --- a/pcsx2/PAD/Linux/GamePad.h +++ b/pcsx2/PAD/Linux/Device.h @@ -15,38 +15,52 @@ #pragma once -#include "PAD.h" -#include "controller.h" +#include "Global.h" +#include "InputManager.h" #ifdef SDL_BUILD #include #endif -class GamePad +enum DeviceAPI +{ + NO_API = 0, + KEYBOARD_API = 16, + SDL_AUTO = 17 +}; + +enum DeviceType +{ + NO_DEVICE = 0, + KEYBOARD = 1, + MOUSE = 2, + OTHER = 3 +}; + +class Device { public: - GamePad() - : m_deadzone(1500) + Device() + : m_unique_id(0) + , m_device_name("") + , api(NO_API) + , type(NO_DEVICE) + , m_deadzone(1500) , m_no_error(false) { } - virtual ~GamePad() + virtual ~Device() { } - GamePad(const GamePad&); // copy constructor - GamePad& operator=(const GamePad&); // assignment - - /* - * Find every interesting devices and create right structure for them(depend on backend) - */ - static void EnumerateGamePads(std::vector>& vgamePad); + Device(const Device&); // copy constructor + Device& operator=(const Device&); // assignment /* * Update state of every attached devices */ - virtual void UpdateGamePadState() = 0; + virtual void UpdateDeviceState() = 0; /* * Causes devices to rumble @@ -82,9 +96,12 @@ public: return m_no_error; } + size_t m_unique_id; + std::string m_device_name; + DeviceAPI api; + DeviceType type; + protected: int m_deadzone; bool m_no_error; }; - -extern std::vector> s_vgamePad; diff --git a/pcsx2/PAD/Linux/Global.h b/pcsx2/PAD/Linux/Global.h new file mode 100644 index 0000000000..b16e0d24b3 --- /dev/null +++ b/pcsx2/PAD/Linux/Global.h @@ -0,0 +1,109 @@ +/* PCSX2 - PS2 Emulator for PCs + * Copyright (C) 2002-2021 PCSX2 Dev Team + * + * PCSX2 is free software: you can redistribute it and/or modify it under the terms + * of the GNU Lesser General Public License as published by the Free Software Found- + * ation, either version 3 of the License, or (at your option) any later version. + * + * PCSX2 is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; + * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR + * PURPOSE. See the GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along with PCSX2. + * If not, see . + */ + +#pragma once + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "Pcsx2Defs.h" +#include "bitwise.h" + +#include "Utilities/pxStreams.h" +#include "Utilities/Console.h" +#include "App.h" +#include "DebugTools/Debug.h" + +#define PADdefs + +static const u32 GAMEPAD_NUMBER = 2; +static const u32 MAX_KEYS = 24; + +#include "Config.h" + +enum gamePadValues +{ + PAD_L2 = 0, // L2 button + PAD_R2, // R2 button + PAD_L1, // L1 button + PAD_R1, // R1 button + PAD_TRIANGLE, // Triangle button ▲ + PAD_CIRCLE, // Circle button ● + PAD_CROSS, // Cross button ✖ + PAD_SQUARE, // Square button ■ + PAD_SELECT, // Select button + PAD_L3, // Left joystick button (L3) + PAD_R3, // Right joystick button (R3) + PAD_START, // Start button + PAD_UP, // Directional pad ↑ + PAD_RIGHT, // Directional pad → + PAD_DOWN, // Directional pad ↓ + PAD_LEFT, // Directional pad ← + PAD_L_UP, // Left joystick (Up) ↑ + PAD_L_RIGHT, // Left joystick (Right) → + PAD_L_DOWN, // Left joystick (Down) ↓ + PAD_L_LEFT, // Left joystick (Left) ← + PAD_R_UP, // Right joystick (Up) ↑ + PAD_R_RIGHT, // Right joystick (Right) → + PAD_R_DOWN, // Right joystick (Down) ↓ + PAD_R_LEFT // Right joystick (Left) ← +}; + +static const std::array all_keys = + { + PAD_L2, // L2 button + PAD_R2, // R2 button + PAD_L1, // L1 button + PAD_R1, // R1 button + PAD_TRIANGLE, // Triangle button ▲ + PAD_CIRCLE, // Circle button ● + PAD_CROSS, // Cross button ✖ + PAD_SQUARE, // Square button ■ + PAD_SELECT, // Select button + PAD_L3, // Left joystick button (L3) + PAD_R3, // Right joystick button (R3) + PAD_START, // Start button + PAD_UP, // Directional pad ↑ + PAD_RIGHT, // Directional pad → + PAD_DOWN, // Directional pad ↓ + PAD_LEFT, // Directional pad ← + PAD_L_UP, // Left joystick (Up) ↑ + PAD_L_RIGHT, // Left joystick (Right) → + PAD_L_DOWN, // Left joystick (Down) ↓ + PAD_L_LEFT, // Left joystick (Left) ← + PAD_R_UP, // Right joystick (Up) ↑ + PAD_R_RIGHT, // Right joystick (Right) → + PAD_R_DOWN, // Right joystick (Down) ↓ + PAD_R_LEFT // Right joystick (Left) ← + +}; + +static bool IsAnalogKey(int index) +{ + return ((index >= PAD_L_UP) && (index <= PAD_R_LEFT)); +} + +#include "KeyStatus.h" + +void __LogToConsole(const char* fmt, ...); +void PADLoadConfig(); +void PADSaveConfig(); diff --git a/pcsx2/PAD/Linux/InputManager.cpp b/pcsx2/PAD/Linux/InputManager.cpp new file mode 100644 index 0000000000..e3fdc591f6 --- /dev/null +++ b/pcsx2/PAD/Linux/InputManager.cpp @@ -0,0 +1,88 @@ +/* PCSX2 - PS2 Emulator for PCs + * Copyright (C) 2002-2021 PCSX2 Dev Team + * + * PCSX2 is free software: you can redistribute it and/or modify it under the terms + * of the GNU Lesser General Public License as published by the Free Software Found- + * ation, either version 3 of the License, or (at your option) any later version. + * + * PCSX2 is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; + * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR + * PURPOSE. See the GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along with PCSX2. + * If not, see . + */ + +#include "InputManager.h" +#include "Device.h" +#include "keyboard.h" +#include "state_management.h" + +#ifdef SDL_BUILD +#include "SDL/joystick.h" +#endif + +std::unique_ptr device_manager(new InputDeviceManager); + +InputDeviceManager::InputDeviceManager() +{ +} + +InputDeviceManager::~InputDeviceManager() +{ + device_manager->devices.clear(); +} + +// Needs to be moved to individual device code, as does the keyboard input. +void PollForJoystickInput(int cpad) +{ + int index = Device::uid_to_index(cpad); + if (index < 0) + return; + + auto& gamePad = device_manager->devices[index]; + + gamePad->UpdateDeviceState(); + + for (u32 i = 0; i < MAX_KEYS; i++) + { + s32 value = gamePad->GetInput((gamePadValues)i); + if (value != 0) + g_key_status.press(cpad, i, value); + else + g_key_status.release(cpad, i); + } +} + +void InputDeviceManager::Update() +{ + // Poll keyboard/mouse event. There is currently no way to separate pad0 from pad1 event. + // So we will populate both pad in the same time + for (u32 cpad = 0; cpad < GAMEPAD_NUMBER; cpad++) + { + g_key_status.keyboard_state_acces(cpad); + } + UpdateKeyboardInput(); + + // Get joystick state + Commit + for (u32 cpad = 0; cpad < GAMEPAD_NUMBER; cpad++) + { + g_key_status.joystick_state_acces(cpad); + + PollForJoystickInput(cpad); + + g_key_status.commit_status(cpad); + } + + Pad::rumble_all(); +} + +/* + * Find and set up joysticks, potentially other devices. + */ +void EnumerateDevices() +{ +#ifdef SDL_BUILD + JoystickInfo::EnumerateJoysticks(device_manager->devices); +#endif +} diff --git a/pcsx2/PAD/Linux/controller.cpp b/pcsx2/PAD/Linux/InputManager.h similarity index 52% rename from pcsx2/PAD/Linux/controller.cpp rename to pcsx2/PAD/Linux/InputManager.h index 4ff38716e8..7ec7b5b1b0 100644 --- a/pcsx2/PAD/Linux/controller.cpp +++ b/pcsx2/PAD/Linux/InputManager.h @@ -1,5 +1,5 @@ /* PCSX2 - PS2 Emulator for PCs - * Copyright (C) 2002-2020 PCSX2 Dev Team + * Copyright (C) 2002-2021 PCSX2 Dev Team * * PCSX2 is free software: you can redistribute it and/or modify it under the terms * of the GNU Lesser General Public License as published by the Free Software Found- @@ -13,26 +13,26 @@ * If not, see . */ -#include "PAD.h" -#include "controller.h" +#pragma once -__forceinline void set_keyboard_key(int pad, int keysym, int index) -{ - g_conf.keysym_map[pad][keysym] = index; -} +#include +#include -__forceinline int get_keyboard_key(int pad, int keysym) -{ - // You must use find instead of [] - // [] will create an element if the key does not exist and return 0 - std::map::iterator it = g_conf.keysym_map[pad].find(keysym); - if (it != g_conf.keysym_map[pad].end()) - return it->second; - else - return -1; -} +class Device; -__forceinline bool IsAnalogKey(int index) +class InputDeviceManager { - return ((index >= PAD_L_UP) && (index <= PAD_R_LEFT)); -} +public: + InputDeviceManager(); + ~InputDeviceManager(); + void Update(); + + std::vector> devices; +}; + +extern std::unique_ptr device_manager; + +/* + * Find every interesting device and create right structure for them(depends on backend) + */ +extern void EnumerateDevices(); diff --git a/pcsx2/PAD/Linux/KeyStatus.cpp b/pcsx2/PAD/Linux/KeyStatus.cpp index 0ec7a9aeef..c1da84f01c 100644 --- a/pcsx2/PAD/Linux/KeyStatus.cpp +++ b/pcsx2/PAD/Linux/KeyStatus.cpp @@ -14,17 +14,18 @@ */ #include "KeyStatus.h" +#include "Config.h" void KeyStatus::Init() { - for (int pad = 0; pad < GAMEPAD_NUMBER; pad++) + for (u32 pad = 0; pad < GAMEPAD_NUMBER; pad++) { m_button[pad] = 0xFFFF; m_internal_button_kbd[pad] = 0xFFFF; m_internal_button_joy[pad] = 0xFFFF; m_state_acces[pad] = false; - for (int index = 0; index < MAX_KEYS; index++) + for (u32 index = 0; index < MAX_KEYS; index++) { m_button_pressure[pad][index] = 0xFF; m_internal_button_pressure[pad][index] = 0xFF; @@ -193,7 +194,7 @@ void KeyStatus::commit_status(u32 pad) { m_button[pad] = m_internal_button_kbd[pad] & m_internal_button_joy[pad]; - for (int index = 0; index < MAX_KEYS; index++) + for (u32 index = 0; index < MAX_KEYS; index++) m_button_pressure[pad][index] = m_internal_button_pressure[pad][index]; m_analog[pad].lx = analog_merge(m_internal_analog_kbd[pad].lx, m_internal_analog_joy[pad].lx); diff --git a/pcsx2/PAD/Linux/KeyStatus.h b/pcsx2/PAD/Linux/KeyStatus.h index c6ab3435f3..2893beb558 100644 --- a/pcsx2/PAD/Linux/KeyStatus.h +++ b/pcsx2/PAD/Linux/KeyStatus.h @@ -13,10 +13,9 @@ * If not, see . */ -#ifndef __KEYSTATUS_H__ -#define __KEYSTATUS_H__ +#pragma once -#include "PAD.h" +#include "Global.h" typedef struct { @@ -70,5 +69,3 @@ public: }; extern KeyStatus g_key_status; - -#endif diff --git a/pcsx2/PAD/Linux/PAD.cpp b/pcsx2/PAD/Linux/PAD.cpp index f45c6d0f6b..2964116846 100644 --- a/pcsx2/PAD/Linux/PAD.cpp +++ b/pcsx2/PAD/Linux/PAD.cpp @@ -16,20 +16,19 @@ #include #include #include -#include #include -#include "Utilities/pxStreams.h" #include "keyboard.h" #include "PAD.h" #include "state_management.h" +#if defined(__unix__) || defined(__APPLE__) +#include "Device.h" +#endif + #ifdef __linux__ #include #endif -#ifdef _MSC_VER -#define snprintf sprintf_s -#endif const u32 revision = 3; const u32 build = 0; // increase that with each version @@ -118,7 +117,7 @@ s32 PADopen(void* pDsp) g_ev_fifo.reset(); #if defined(__unix__) || defined(__APPLE__) - GamePad::EnumerateGamePads(s_vgamePad); + EnumerateDevices(); #endif return _PADopen(pDsp); } @@ -252,7 +251,7 @@ keyEvent* PADkeyEvent() { case SDL_CONTROLLERDEVICEADDED: case SDL_CONTROLLERDEVICEREMOVED: - GamePad::EnumerateGamePads(s_vgamePad); + EnumerateDevices(); break; default: break; @@ -274,10 +273,10 @@ keyEvent* PADkeyEvent() // PAD_LOG("Returning Event. Event Type: %d, Key: %d\n", s_event.evt, s_event.key); return &s_event; #else // MacOS - s_event = event; - event.evt = 0; - event.key = 0; - return &s_event; + s_event = event; + event.evt = 0; + event.key = 0; + return &s_event; #endif } diff --git a/pcsx2/PAD/Linux/PAD.h b/pcsx2/PAD/Linux/PAD.h index bb0f9af09f..f010b22ba6 100644 --- a/pcsx2/PAD/Linux/PAD.h +++ b/pcsx2/PAD/Linux/PAD.h @@ -15,41 +15,8 @@ #pragma once -#define GAMEPAD_NUMBER 2 // numbers of gamepad - -#include -#include -#include -#include -#include -#include "Utilities/pxStreams.h" -#include "Utilities/Console.h" -#include "App.h" -#include -#include - -#ifdef _WIN32 -#include -#include - -#else -/* -#include -#include -#include -*/ - -#endif - -#include -#include -#include -#include -#include -#include -#include - -#define PADdefs +#include "Global.h" +#include "mt_queue.h" enum PadOptions { @@ -62,63 +29,9 @@ enum PadOptions PADOPTION_MOUSE_R = 0x40, }; -enum PadCommands -{ - CMD_SET_VREF_PARAM = 0x40, - CMD_QUERY_DS2_ANALOG_MODE = 0x41, - CMD_READ_DATA_AND_VIBRATE = 0x42, - CMD_CONFIG_MODE = 0x43, - CMD_SET_MODE_AND_LOCK = 0x44, - CMD_QUERY_MODEL_AND_MODE = 0x45, - CMD_QUERY_ACT = 0x46, // ?? - CMD_QUERY_COMB = 0x47, // ?? - CMD_QUERY_MODE = 0x4C, // QUERY_MODE ?? - CMD_VIBRATION_TOGGLE = 0x4D, - CMD_SET_DS2_NATIVE_MODE = 0x4F // SET_DS2_NATIVE_MODE -}; - -enum gamePadValues -{ - PAD_L2 = 0, // L2 button - PAD_R2, // R2 button - PAD_L1, // L1 button - PAD_R1, // R1 button - PAD_TRIANGLE, // Triangle button ▲ - PAD_CIRCLE, // Circle button ● - PAD_CROSS, // Cross button ✖ - PAD_SQUARE, // Square button ■ - PAD_SELECT, // Select button - PAD_L3, // Left joystick button (L3) - PAD_R3, // Right joystick button (R3) - PAD_START, // Start button - PAD_UP, // Directional pad ↑ - PAD_RIGHT, // Directional pad → - PAD_DOWN, // Directional pad ↓ - PAD_LEFT, // Directional pad ← - PAD_L_UP, // Left joystick (Up) ↑ - PAD_L_RIGHT, // Left joystick (Right) → - PAD_L_DOWN, // Left joystick (Down) ↓ - PAD_L_LEFT, // Left joystick (Left) ← - PAD_R_UP, // Right joystick (Up) ↑ - PAD_R_RIGHT, // Right joystick (Right) → - PAD_R_DOWN, // Right joystick (Down) ↓ - PAD_R_LEFT // Right joystick (Left) ← -}; - -#if defined(__unix__) || defined(__APPLE__) -#include "GamePad.h" -#endif -#include "bitwise.h" -#include "controller.h" -#include "KeyStatus.h" -#include "mt_queue.h" - extern FILE* padLog; extern void initLogging(); -//#define PAD_LOG __Log -//#define PAD_LOG __LogToConsole - extern keyEvent event; extern MtQueue g_ev_fifo; @@ -126,10 +39,6 @@ s32 _PADopen(void* pDsp); void _PADclose(); void PADsetMode(int pad, int mode); -void __LogToConsole(const char* fmt, ...); -void PADLoadConfig(); -void PADSaveConfig(); - void SysMessage(char* fmt, ...); s32 PADinit(); diff --git a/pcsx2/PAD/Linux/SDL/joystick.cpp b/pcsx2/PAD/Linux/SDL/joystick.cpp index 548b72e024..933bc4f4c7 100644 --- a/pcsx2/PAD/Linux/SDL/joystick.cpp +++ b/pcsx2/PAD/Linux/SDL/joystick.cpp @@ -22,7 +22,7 @@ ////////////////////////// // opens handles to all possible joysticks -void JoystickInfo::EnumerateJoysticks(std::vector>& vjoysticks) +void JoystickInfo::EnumerateJoysticks(std::vector>& vjoysticks) { uint32_t flag = SDL_INIT_JOYSTICK | SDL_INIT_HAPTIC | SDL_INIT_EVENTS | SDL_INIT_GAMECONTROLLER; @@ -66,7 +66,7 @@ void JoystickInfo::EnumerateJoysticks(std::vector>& vjo for (int i = 0; i < SDL_NumJoysticks(); ++i) { - vjoysticks.push_back(std::unique_ptr(new JoystickInfo(i))); + vjoysticks.push_back(std::unique_ptr(new JoystickInfo(i))); // Something goes wrong in the init, let's drop it if (!vjoysticks.back()->IsProperlyInitialized()) vjoysticks.pop_back(); @@ -116,7 +116,7 @@ JoystickInfo::~JoystickInfo() } JoystickInfo::JoystickInfo(int id) - : GamePad() + : Device() , m_controller(nullptr) , m_haptic(nullptr) , m_unique_id(0) @@ -168,7 +168,7 @@ JoystickInfo::JoystickInfo(int id) // Collect Device Information char guid[64]; SDL_JoystickGetGUIDString(SDL_JoystickGetGUID(joy), guid, 64); - const char* devname = SDL_JoystickNameForIndex(id); + m_device_name = SDL_JoystickNameForIndex(id); if (m_controller == nullptr) { @@ -176,7 +176,7 @@ JoystickInfo::JoystickInfo(int id) "You can use SDL2 Gamepad Tool (https://www.generalarcade.com/gamepadtool/) or Steam to configure your joystick\n" "The mapping can be stored in PAD.ini as 'SDL2 = <...mapping description...>'\n" "Please post the new generated mapping to (https://github.com/gabomdq/SDL_GameControllerDB) so it can be added to the database.", - devname, guid); + m_device_name.c_str(), guid); #if SDL_MINOR_VERSION >= 4 // Version before 2.0.4 are bugged, JoystickClose crashes randomly SDL_JoystickClose(joy); @@ -242,7 +242,7 @@ JoystickInfo::JoystickInfo(int id) } fprintf(stdout, "PAD: controller (%s) detected%s, GUID:%s\n", - devname, m_haptic ? " with rumble support" : "", guid); + m_device_name.c_str(), m_haptic ? " with rumble support" : "", guid); m_no_error = true; } @@ -299,7 +299,7 @@ int JoystickInfo::GetInput(gamePadValues input) return value ? 0xFF : 0; // Max pressure } -void JoystickInfo::UpdateGamePadState() +void JoystickInfo::UpdateDeviceState() { SDL_GameControllerUpdate(); } diff --git a/pcsx2/PAD/Linux/SDL/joystick.h b/pcsx2/PAD/Linux/SDL/joystick.h index 72ed99c2b3..323e2bc72f 100644 --- a/pcsx2/PAD/Linux/SDL/joystick.h +++ b/pcsx2/PAD/Linux/SDL/joystick.h @@ -18,12 +18,13 @@ #include #include -#include "PAD/Linux/GamePad.h" -#include "PAD/Linux/PAD.h" -#include "PAD/Linux/controller.h" +#include "../Global.h" +#include "../Device.h" + #define NB_EFFECT 2 // Don't use more than two, ps2 only has one for big motor and one for small(like most systems) + // holds all joystick info -class JoystickInfo : public GamePad +class JoystickInfo : public Device { public: JoystickInfo(int id); @@ -34,7 +35,7 @@ public: // opens handles to all possible joysticks - static void EnumerateJoysticks(std::vector>& vjoysticks); + static void EnumerateJoysticks(std::vector>& vjoysticks); void Rumble(unsigned type, unsigned pad) override; @@ -44,7 +45,7 @@ public: int GetInput(gamePadValues input) final; - void UpdateGamePadState() final; + void UpdateDeviceState() final; size_t GetUniqueIdentifier() final; diff --git a/pcsx2/PAD/Linux/bitwise.h b/pcsx2/PAD/Linux/bitwise.h index 35216007d4..a9a48169b7 100644 --- a/pcsx2/PAD/Linux/bitwise.h +++ b/pcsx2/PAD/Linux/bitwise.h @@ -13,6 +13,8 @@ * If not, see . */ +#pragma once + template static void __forceinline set_bit(T& value, int bit) { diff --git a/pcsx2/PAD/Linux/keyboard.cpp b/pcsx2/PAD/Linux/keyboard.cpp index c15932f907..fbeee4a7d8 100644 --- a/pcsx2/PAD/Linux/keyboard.cpp +++ b/pcsx2/PAD/Linux/keyboard.cpp @@ -18,24 +18,12 @@ * Pragmatically, event handing's going in here too. */ -#if defined(__unix__) -#include -#include -#elif defined(__APPLE__) -#include -#endif - +#include "Global.h" #include "keyboard.h" -#ifdef _WIN32 -char* KeysymToChar(int keysym) -{ - LPWORD temp; - - ToAscii((UINT)keysym, NULL, NULL, temp, NULL); - return (char*)temp; -} -#endif +#include "mt_queue.h" +extern keyEvent event; +extern MtQueue g_ev_fifo; /// g_key_status.press but with proper handling for analog buttons static void PressButton(u32 pad, u32 button) @@ -76,7 +64,7 @@ static void PressButton(u32 pad, u32 button) void UpdateKeyboardInput() { - for (int pad = 0; pad < GAMEPAD_NUMBER; pad++) + for (u32 pad = 0; pad < GAMEPAD_NUMBER; pad++) { const auto& map = g_conf.keysym_map[pad]; // If we loop over all keys press/release based on current state, @@ -135,7 +123,7 @@ void AnalyzeKeyEvent(keyEvent& evt) int pad = 0; int index = -1; - for (int cpad = 0; cpad < GAMEPAD_NUMBER; cpad++) + for (u32 cpad = 0; cpad < GAMEPAD_NUMBER; cpad++) { int tmp_index = get_keyboard_key(cpad, key); if (tmp_index != -1) @@ -321,73 +309,4 @@ bool PollForNewKeyboardKeys(u32& pkey) return false; } - -#else -LRESULT WINAPI PADwndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam) -{ - static bool lbutton = false, rbutton = false; - for (int pad = 0; pad < GAMEPAD_NUMBER; ++pad) - { - g_key_status.keyboard_state_acces(pad); - } - - switch (msg) - { - case WM_KEYDOWN: - if (lParam & 0x40000000) - return TRUE; - - for (int pad = 0; pad < GAMEPAD_NUMBER; ++pad) - { - for (int i = 0; i < MAX_KEYS; i++) - { - assert(0); -#if 0 - if (wParam == get_key(pad, i)) { - g_key_status.press(pad, i); - break; - } -#endif - } - } - - event.evt = KEYPRESS; - event.key = wParam; - break; - - case WM_KEYUP: - for (int pad = 0; pad < GAMEPAD_NUMBER; ++pad) - { - for (int i = 0; i < MAX_KEYS; i++) - { - assert(0); -#if 0 - if (wParam == get_key(pad, i)) { - g_key_status.release(pad, i); - break; - } -#endif - } - } - - - event.evt = KEYRELEASE; - event.key = wParam; - break; - - case WM_DESTROY: - case WM_QUIT: - event.evt = KEYPRESS; - event.key = VK_ESCAPE; - return GSwndProc(hWnd, msg, wParam, lParam); - - default: - return GSwndProc(hWnd, msg, wParam, lParam); - } - - for (int pad = 0; pad < GAMEPAD_NUMBER; ++pad) - g_key_status.commit_status(pad); - - return TRUE; -} #endif diff --git a/pcsx2/PAD/Linux/keyboard.h b/pcsx2/PAD/Linux/keyboard.h index 4ba2d1efdc..5ddcd0b819 100644 --- a/pcsx2/PAD/Linux/keyboard.h +++ b/pcsx2/PAD/Linux/keyboard.h @@ -13,33 +13,32 @@ * If not, see . */ -#ifndef __KEYBOARD_H__ -#define __KEYBOARD_H__ +#pragma once -#include "PAD.h" +#include "Pcsx2Defs.h" +#include "App.h" #if defined(__unix__) || defined(__APPLE__) #include #include #include + // x11 is dumb like that #undef DisableScreenSaver extern void AnalyzeKeyEvent(keyEvent& evt); extern void UpdateKeyboardInput(); extern bool PollForNewKeyboardKeys(u32& pkey); -#ifndef __APPLE__ +#endif + +#if defined(__unix__) +#include +#include + extern Display* GSdsp; extern Window GSwin; -#endif - -#else - -extern char* KeysymToChar(int keysym); -extern WNDPROC GSwndProc; -extern HWND GShwnd; - -#endif - + +#elif defined(__APPLE__) +#include #endif diff --git a/pcsx2/PAD/Linux/linux.cpp b/pcsx2/PAD/Linux/linux.cpp index ada5a99c51..3bfe0e9b8e 100644 --- a/pcsx2/PAD/Linux/linux.cpp +++ b/pcsx2/PAD/Linux/linux.cpp @@ -13,13 +13,12 @@ * If not, see . */ +#include "Global.h" #include "AppCoreThread.h" -#include "GamePad.h" -#include "PAD.h" +#include "Device.h" #include "keyboard.h" #include "state_management.h" -#include #include "wx_dialog/dialog.h" #ifndef __APPLE__ @@ -55,27 +54,7 @@ s32 _PADopen(void* pDsp) void _PADclose() { - s_vgamePad.clear(); -} - -void PollForJoystickInput(int cpad) -{ - int index = GamePad::uid_to_index(cpad); - if (index < 0) - return; - - auto& gamePad = s_vgamePad[index]; - - gamePad->UpdateGamePadState(); - - for (int i = 0; i < MAX_KEYS; i++) - { - s32 value = gamePad->GetInput((gamePadValues)i); - if (value != 0) - g_key_status.press(cpad, i, value); - else - g_key_status.release(cpad, i); - } + device_manager->devices.clear(); } void PADupdate(int pad) @@ -95,26 +74,7 @@ void PADupdate(int pad) // Actually PADupdate is always call with pad == 0. So you need to update both // pads -- Gregory - - // Poll keyboard/mouse event. There is currently no way to separate pad0 from pad1 event. - // So we will populate both pad in the same time - for (int cpad = 0; cpad < GAMEPAD_NUMBER; cpad++) - { - g_key_status.keyboard_state_acces(cpad); - } - UpdateKeyboardInput(); - - // Get joystick state + Commit - for (int cpad = 0; cpad < GAMEPAD_NUMBER; cpad++) - { - g_key_status.joystick_state_acces(cpad); - - PollForJoystickInput(cpad); - - g_key_status.commit_status(cpad); - } - - Pad::rumble_all(); + device_manager->Update(); } void PADconfigure() diff --git a/pcsx2/PAD/Linux/state_management.cpp b/pcsx2/PAD/Linux/state_management.cpp index 4bb74a74d6..37a0867a68 100644 --- a/pcsx2/PAD/Linux/state_management.cpp +++ b/pcsx2/PAD/Linux/state_management.cpp @@ -14,7 +14,7 @@ */ #include "state_management.h" -#include "GamePad.h" +#include "Device.h" // Typical packet response on the bus static const u8 ConfigExit[7] = {0x5A, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}; @@ -112,7 +112,7 @@ void Pad::rumble(unsigned port) { currentVibrate[motor] = nextVibrate[motor]; - GamePad::DoRumble(motor, port); + Device::DoRumble(motor, port); } } } diff --git a/pcsx2/PAD/Linux/state_management.h b/pcsx2/PAD/Linux/state_management.h index efc8ee3373..50dd28f712 100644 --- a/pcsx2/PAD/Linux/state_management.h +++ b/pcsx2/PAD/Linux/state_management.h @@ -13,12 +13,29 @@ * If not, see . */ -#include "PAD.h" +#pragma once + +#include "Global.h" #define MODE_DIGITAL 0x41 #define MODE_ANALOG 0x73 #define MODE_DS2_NATIVE 0x79 +enum PadCommands +{ + CMD_SET_VREF_PARAM = 0x40, + CMD_QUERY_DS2_ANALOG_MODE = 0x41, + CMD_READ_DATA_AND_VIBRATE = 0x42, + CMD_CONFIG_MODE = 0x43, + CMD_SET_MODE_AND_LOCK = 0x44, + CMD_QUERY_MODEL_AND_MODE = 0x45, + CMD_QUERY_ACT = 0x46, // ?? + CMD_QUERY_COMB = 0x47, // ?? + CMD_QUERY_MODE = 0x4C, // QUERY_MODE ?? + CMD_VIBRATION_TOGGLE = 0x4D, + CMD_SET_DS2_NATIVE_MODE = 0x4F // SET_DS2_NATIVE_MODE +}; + // The state of the PS2 bus struct QueryInfo { diff --git a/pcsx2/PAD/Linux/wx_dialog/GamepadConfiguration.cpp b/pcsx2/PAD/Linux/wx_dialog/GamepadConfiguration.cpp index 7cc4ab6bc6..be0bb23564 100644 --- a/pcsx2/PAD/Linux/wx_dialog/GamepadConfiguration.cpp +++ b/pcsx2/PAD/Linux/wx_dialog/GamepadConfiguration.cpp @@ -17,14 +17,14 @@ GamepadConfiguration::GamepadConfiguration(int pad, wxWindow* parent) : wxDialog(parent, wxID_ANY, _T("Gamepad"), wxDefaultPosition, wxDefaultSize, - wxSYSTEM_MENU | wxCAPTION | wxCLOSE_BOX | wxCLIP_CHILDREN) + wxSYSTEM_MENU | wxCAPTION | wxCLOSE_BOX | wxCLIP_CHILDREN) { m_pad_id = pad; wxBoxSizer* gamepad_box = new wxBoxSizer(wxVERTICAL); wxArrayString choices; - for (const auto& j : s_vgamePad) + for (const auto& j : device_manager->devices) { choices.Add(j->GetName()); } @@ -34,11 +34,11 @@ GamepadConfiguration::GamepadConfiguration(int pad, wxWindow* parent) wxStaticBoxSizer* rumble_box = new wxStaticBoxSizer(wxVERTICAL, this, wxT("Rumble intensity")); m_sl_rumble_intensity = new wxSlider(this, rumble_slider_id, 0, 0, 0x7FFF, wxDefaultPosition, wxDefaultSize, - wxSL_HORIZONTAL | wxSL_LABELS | wxSL_BOTTOM); + wxSL_HORIZONTAL | wxSL_LABELS | wxSL_BOTTOM); wxStaticBoxSizer* joy_box = new wxStaticBoxSizer(wxVERTICAL, this, wxT("Joystick sensibility")); m_sl_joystick_sensibility = new wxSlider(this, joy_slider_id, 0, 0, 200, wxDefaultPosition, wxDefaultSize, - wxSL_HORIZONTAL | wxSL_LABELS | wxSL_BOTTOM); + wxSL_HORIZONTAL | wxSL_LABELS | wxSL_BOTTOM); gamepad_box->Add(m_joy_map, wxSizerFlags().Expand().Border(wxALL, 5)); gamepad_box->Add(m_cb_rumble, wxSizerFlags().Expand()); @@ -70,9 +70,9 @@ void GamepadConfiguration::InitGamepadConfiguration() * Check if there exist at least one pad available * if the pad id is 0, you need at least 1 gamepad connected, * if the pad id is 1, you need at least 2 gamepads connected, - * Prevent to use a none initialized value on s_vgamePad (core dump) + * Prevent to use a non-initialized value (core dump) */ - if (s_vgamePad.size() >= m_pad_id + 1) + if (device_manager->devices.size() >= m_pad_id + 1) { /* * Determine if the device can use rumble @@ -81,7 +81,7 @@ void GamepadConfiguration::InitGamepadConfiguration() */ // Bad idea. Some connected devices might support rumble but not all connected devices. - // if (!s_vgamePad[m_pad_id]->TestForce(0.001f)) { + // if (!device_manager->devices[m_pad_id]->TestForce(0.001f)) { // wxMessageBox(L"Rumble is not available for your device."); // m_cb_rumble->Disable(); // disable the rumble checkbox // m_sl_rumble_intensity->Disable(); // disable the rumble intensity slider @@ -114,7 +114,7 @@ void GamepadConfiguration::OnSliderReleased(wxCommandEvent& event) // convert in a float value between 0 and 1, and run rumble feedback. // 0 to 1 scales to 0x0 to 0x7FFF - s_vgamePad[m_joy_map->GetSelection()]->TestForce(m_sl_rumble_intensity->GetValue() / (float)0x7FFF); + device_manager->devices[m_pad_id]->TestForce(m_sl_rumble_intensity->GetValue() / (float)0x7FFF); } else if (sl_id == joy_slider_id) { @@ -135,7 +135,7 @@ void GamepadConfiguration::OnCheckboxChange(wxCommandEvent& event) g_conf.pad_options[m_pad_id].forcefeedback = (m_cb_rumble->GetValue()) ? (u32)1 : (u32)0; if (m_cb_rumble->GetValue()) { - s_vgamePad[m_joy_map->GetSelection()]->TestForce(); + device_manager->devices[m_pad_id]->TestForce(); m_sl_rumble_intensity->Enable(); } else @@ -154,7 +154,7 @@ void GamepadConfiguration::OnChoiceChange(wxCommandEvent& event) int id = choice_tmp->GetSelection(); if (id != wxNOT_FOUND) { - g_conf.set_joy_uid(m_pad_id, GamePad::index_to_uid(id)); + g_conf.set_joy_uid(m_pad_id, Device::index_to_uid(id)); } } @@ -170,7 +170,7 @@ void GamepadConfiguration::repopulate() m_sl_rumble_intensity->SetValue(g_conf.get_ff_intensity()); m_sl_joystick_sensibility->SetValue(g_conf.get_sensibility()); - u32 joyid = GamePad::uid_to_index(m_pad_id); + u32 joyid = Device::uid_to_index(m_pad_id); if (joyid < m_joy_map->GetCount() && !m_joy_map->IsEmpty()) m_joy_map->SetSelection(joyid); diff --git a/pcsx2/PAD/Linux/wx_dialog/GamepadConfiguration.h b/pcsx2/PAD/Linux/wx_dialog/GamepadConfiguration.h index bc9fa1cb1b..2797c1ef3e 100644 --- a/pcsx2/PAD/Linux/wx_dialog/GamepadConfiguration.h +++ b/pcsx2/PAD/Linux/wx_dialog/GamepadConfiguration.h @@ -15,14 +15,11 @@ #pragma once -#ifndef __GAMEPADCONFIGURATION_H__ -#define __GAMEPADCONFIGURATION_H__ - #include -#include "PAD/Linux/GamePad.h" -#include "PAD/Linux/keyboard.h" -#include "PAD/Linux/PAD.h" +#include "../Device.h" +#include "../keyboard.h" +#include "../Global.h" static const s32 rumble_slider_id = wxID_HIGHEST + 200 + 1; static const s32 joy_slider_id = wxID_HIGHEST + 200 + 2; @@ -48,5 +45,3 @@ public: GamepadConfiguration(int, wxWindow*); void InitGamepadConfiguration(); }; - -#endif // __GAMEPADCONFIGURATION_H__ diff --git a/pcsx2/PAD/Linux/wx_dialog/JoystickConfiguration.cpp b/pcsx2/PAD/Linux/wx_dialog/JoystickConfiguration.cpp index d1ecdebd47..e44a767f7f 100644 --- a/pcsx2/PAD/Linux/wx_dialog/JoystickConfiguration.cpp +++ b/pcsx2/PAD/Linux/wx_dialog/JoystickConfiguration.cpp @@ -22,7 +22,7 @@ static const s32 joy_check_id = wxID_HIGHEST + 100 + 3; // Constructor of JoystickConfiguration JoystickConfiguration::JoystickConfiguration(int pad, bool left, wxWindow* parent) : wxDialog(parent, wxID_ANY, _T("Joystick configuration"), wxDefaultPosition, wxDefaultSize, - wxSYSTEM_MENU | wxCAPTION | wxCLOSE_BOX | wxCLIP_CHILDREN) + wxSYSTEM_MENU | wxCAPTION | wxCLOSE_BOX | wxCLIP_CHILDREN) { m_pad_id = pad; m_isForLeftJoystick = left; @@ -62,11 +62,11 @@ void JoystickConfiguration::InitJoystickConfiguration() * Check if there exist at least one pad available * if the pad id is 0, you need at least 1 gamepad connected, * if the pad id is 1, you need at least 2 gamepads connected, - * Prevent to use a none initialized value on s_vgamePad (core dump) + * Prevent using a non-initialized value (core dump) */ - if (s_vgamePad.size() < m_pad_id + 1) + if (device_manager->devices.size() < m_pad_id + 1) { - if (s_vgamePad.empty()) + if (device_manager->devices.empty()) wxMessageBox(L"No gamepad detected."); else wxMessageBox(L"No second gamepad detected."); diff --git a/pcsx2/PAD/Linux/wx_dialog/JoystickConfiguration.h b/pcsx2/PAD/Linux/wx_dialog/JoystickConfiguration.h index a396ff43c1..d5cb3371bf 100644 --- a/pcsx2/PAD/Linux/wx_dialog/JoystickConfiguration.h +++ b/pcsx2/PAD/Linux/wx_dialog/JoystickConfiguration.h @@ -15,14 +15,11 @@ #pragma once -#ifndef __JOYSTICKCONFIGURATION_H__ -#define __JOYSTICKCONFIGURATION_H__ - #include -#include "PAD/Linux/GamePad.h" -#include "PAD/Linux/keyboard.h" -#include "PAD/Linux/PAD.h" +#include "../Global.h" +#include "../Device.h" +#include "../keyboard.h" class JoystickConfiguration : public wxDialog { @@ -43,5 +40,3 @@ public: JoystickConfiguration(int, bool, wxWindow*); void InitJoystickConfiguration(); }; - -#endif // __JOYSTICKCONFIGURATION_H__ diff --git a/pcsx2/PAD/Linux/wx_dialog/dialog.cpp b/pcsx2/PAD/Linux/wx_dialog/dialog.cpp index 8b8c43af31..4ac445a06b 100644 --- a/pcsx2/PAD/Linux/wx_dialog/dialog.cpp +++ b/pcsx2/PAD/Linux/wx_dialog/dialog.cpp @@ -36,9 +36,10 @@ static std::string KeyName(int pad, int key, int keysym) } } + + // clang-format off switch (keysym) { - // clang-format off case kVK_ANSI_A: return "A"; case kVK_ANSI_B: return "B"; case kVK_ANSI_C: return "C"; @@ -159,8 +160,8 @@ static std::string KeyName(int pad, int key, int keysym) case kVK_JIS_Eisu: return "英数"; case kVK_JIS_Kana: return "かな"; default: return "Key " + std::to_string(keysym); - // clang-format on } + // clang-format on } #else static std::string KeyName(int pad, int key, int keysym) @@ -191,7 +192,7 @@ static std::string KeyName(int pad, int key, int keysym) PADDialog::PADDialog() : wxDialog(NULL, // Parent wxID_ANY, // ID - _T("GamePad configuration"), // Title + _T("GamePad configuration"), // Title wxDefaultPosition, // Position wxSize(DEFAULT_WIDTH, DEFAULT_HEIGHT), // Width + Lenght // Style @@ -404,7 +405,7 @@ PADDialog::PADDialog() // create a new Notebook m_tab_gamepad = new wxNotebook(this, wxID_ANY); - for (int i = 0; i < GAMEPAD_NUMBER; ++i) + for (u32 i = 0; i < GAMEPAD_NUMBER; ++i) { // Tabs panels m_pan_tabs[i] = new opPanel( @@ -449,7 +450,7 @@ PADDialog::PADDialog() Bind(wxEVT_BUTTON, &PADDialog::OnButtonClicked, this); - for (int i = 0; i < GAMEPAD_NUMBER; ++i) + for (u32 i = 0; i < GAMEPAD_NUMBER; ++i) { for (int j = 0; j < NB_IMG; ++j) { @@ -460,9 +461,9 @@ PADDialog::PADDialog() void PADDialog::InitDialog() { - GamePad::EnumerateGamePads(s_vgamePad); // activate gamepads - PADLoadConfig(); // Load configuration from the ini file - repopulate(); // Set label and fit simulated key array + EnumerateDevices(); // activate gamepads + PADLoadConfig(); // Load configuration from the ini file + repopulate(); // Set label and fit simulated key array } /****************************************/ @@ -504,7 +505,7 @@ void PADDialog::OnButtonClicked(wxCommandEvent& event) } else if (bt_id == Set_all) { // If the button ID is equals to the Set_all button ID - for (int i = 0; i < MAX_KEYS; ++i) + for (u32 i = 0; i < MAX_KEYS; ++i) { bt_tmp = m_bt_gamepad[gamepad_id][i]; switch (i) @@ -632,7 +633,7 @@ void PADDialog::clear_key(int pad, int key) // Set button values void PADDialog::repopulate() { - for (int gamepad_id = 0; gamepad_id < GAMEPAD_NUMBER; ++gamepad_id) + for (u32 gamepad_id = 0; gamepad_id < GAMEPAD_NUMBER; ++gamepad_id) { // keyboard/mouse key for (const auto& it : g_conf.keysym_map[gamepad_id]) diff --git a/pcsx2/PAD/Linux/wx_dialog/dialog.h b/pcsx2/PAD/Linux/wx_dialog/dialog.h index ea41f690d5..aa908e65de 100644 --- a/pcsx2/PAD/Linux/wx_dialog/dialog.h +++ b/pcsx2/PAD/Linux/wx_dialog/dialog.h @@ -15,9 +15,6 @@ #pragma once -#ifndef __DIALOG_H__ -#define __DIALOG_H__ - #include #include #include @@ -28,12 +25,11 @@ #include #include -#include #include -#include "PAD/Linux/GamePad.h" -#include "PAD/Linux/keyboard.h" -#include "PAD/Linux/PAD.h" +#include "../InputManager.h" +#include "../keyboard.h" +#include "../Global.h" #include "opPanel.h" #include "GamepadConfiguration.h" @@ -41,7 +37,7 @@ // Allow to found quickly button id // e.g L2 → 0, triangle → 4, ... -// see PAD.h for more details about gamepad button id +// see Global.h for more details about gamepad button id enum gui_buttons { @@ -91,5 +87,3 @@ public: }; extern void DisplayDialog(); // Main function - -#endif // __DIALOG_H__ diff --git a/pcsx2/PAD/Linux/wx_dialog/opPanel.h b/pcsx2/PAD/Linux/wx_dialog/opPanel.h index dfaa20f9d4..a1bbcac125 100644 --- a/pcsx2/PAD/Linux/wx_dialog/opPanel.h +++ b/pcsx2/PAD/Linux/wx_dialog/opPanel.h @@ -15,9 +15,6 @@ #pragma once -#ifndef __OPPANEL_H__ -#define __OPPANEL_H__ - #include #include "EmbeddedImage.h" @@ -70,5 +67,3 @@ public: void ShowImg(int); void MoveJoystick(int, int); }; - -#endif // __OPPANEL_H__