From b270c1bb67de83c0b8423857f54d782f9517a62f Mon Sep 17 00:00:00 2001 From: Shanoah Alkire Date: Sun, 28 Apr 2019 01:36:43 -0700 Subject: [PATCH] onepad: Cleanup in a few places. --- plugins/onepad/GamePad.cpp | 19 ++++++++++++++++++ plugins/onepad/GamePad.h | 20 +++++++++++++++++++ plugins/onepad/keyboard.cpp | 8 +++++++- plugins/onepad/state_management.cpp | 1 + .../onepad/wx_dialog/GamepadConfiguration.h | 7 ++++--- .../onepad/wx_dialog/JoystickConfiguration.h | 7 ++++--- plugins/onepad/wx_dialog/dialog.h | 6 +++--- plugins/onepad_legacy/GamePad.h | 2 ++ plugins/onepad_legacy/SDL/joystick.h | 7 ++++--- plugins/onepad_legacy/keyboard.cpp | 10 ++++++++-- plugins/onepad_legacy/state_management.cpp | 1 + .../wx_dialog/GamepadConfiguration.h | 7 ++++--- .../wx_dialog/JoystickConfiguration.h | 7 ++++--- plugins/onepad_legacy/wx_dialog/dialog.h | 6 +++--- 14 files changed, 84 insertions(+), 24 deletions(-) diff --git a/plugins/onepad/GamePad.cpp b/plugins/onepad/GamePad.cpp index a6e019e443..1227072566 100644 --- a/plugins/onepad/GamePad.cpp +++ b/plugins/onepad/GamePad.cpp @@ -1,3 +1,22 @@ +/* + * PCSX2 Dev Team + * Copyright (C) 2015 + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program 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 this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA + */ + #include "GamePad.h" #ifdef SDL_BUILD #include "SDL/joystick.h" diff --git a/plugins/onepad/GamePad.h b/plugins/onepad/GamePad.h index b9731dc2ac..5a0a2c81b0 100644 --- a/plugins/onepad/GamePad.h +++ b/plugins/onepad/GamePad.h @@ -1,7 +1,27 @@ +/* + * PCSX2 Dev Team + * Copyright (C) 2015 + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program 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 this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA + */ + #pragma once #include "onepad.h" #include "controller.h" + #ifdef SDL_BUILD #include #endif diff --git a/plugins/onepad/keyboard.cpp b/plugins/onepad/keyboard.cpp index e500293660..fd73d81f12 100644 --- a/plugins/onepad/keyboard.cpp +++ b/plugins/onepad/keyboard.cpp @@ -24,8 +24,11 @@ * Pragmatically, event handing's going in here too. */ +#if defined(__unix__) #include #include +#endif + #include "keyboard.h" #ifdef _WIN32 @@ -240,7 +243,10 @@ bool PollX11KeyboardMouseEvent(u32 &pkey) LRESULT WINAPI PADwndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam) { static bool lbutton = false, rbutton = false; - g_key_status.keyboard_state_acces(cpad); + for (int pad = 0; pad < GAMEPAD_NUMBER; ++pad) + { + g_key_status.keyboard_state_acces(pad); + } switch (msg) { case WM_KEYDOWN: diff --git a/plugins/onepad/state_management.cpp b/plugins/onepad/state_management.cpp index 7e8dbbecd7..3c7aa66bcc 100644 --- a/plugins/onepad/state_management.cpp +++ b/plugins/onepad/state_management.cpp @@ -20,6 +20,7 @@ */ #include "state_management.h" +#include "GamePad.h" // Typical packet response on the bus static const u8 ConfigExit[7] = {0x5A, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}; diff --git a/plugins/onepad/wx_dialog/GamepadConfiguration.h b/plugins/onepad/wx_dialog/GamepadConfiguration.h index 611834283c..a70f5560e5 100644 --- a/plugins/onepad/wx_dialog/GamepadConfiguration.h +++ b/plugins/onepad/wx_dialog/GamepadConfiguration.h @@ -28,9 +28,10 @@ #include #include #include -#include "GamePad.h" -#include "keyboard.h" -#include "onepad.h" + +#include "../GamePad.h" +#include "../keyboard.h" +#include "../onepad.h" class GamepadConfiguration : public wxDialog { diff --git a/plugins/onepad/wx_dialog/JoystickConfiguration.h b/plugins/onepad/wx_dialog/JoystickConfiguration.h index d486483be0..05c1dee91e 100644 --- a/plugins/onepad/wx_dialog/JoystickConfiguration.h +++ b/plugins/onepad/wx_dialog/JoystickConfiguration.h @@ -28,9 +28,10 @@ #include #include #include -#include "GamePad.h" -#include "keyboard.h" -#include "onepad.h" + +#include "../GamePad.h" +#include "../keyboard.h" +#include "../onepad.h" class JoystickConfiguration : public wxDialog { diff --git a/plugins/onepad/wx_dialog/dialog.h b/plugins/onepad/wx_dialog/dialog.h index d3039b7e60..ac0228b552 100644 --- a/plugins/onepad/wx_dialog/dialog.h +++ b/plugins/onepad/wx_dialog/dialog.h @@ -35,9 +35,9 @@ #include #include -#include "GamePad.h" -#include "keyboard.h" -#include "onepad.h" +#include "../GamePad.h" +#include "../keyboard.h" +#include "../onepad.h" #include "opPanel.h" #include "GamepadConfiguration.h" diff --git a/plugins/onepad_legacy/GamePad.h b/plugins/onepad_legacy/GamePad.h index fd7d7c3a7a..09975bdd07 100644 --- a/plugins/onepad_legacy/GamePad.h +++ b/plugins/onepad_legacy/GamePad.h @@ -23,8 +23,10 @@ #include "onepad.h" #include "controller.h" + #ifdef SDL_BUILD #include + #define HAT_UP SDL_HAT_UP #define HAT_DOWN SDL_HAT_DOWN #define HAT_RIGHT SDL_HAT_RIGHT diff --git a/plugins/onepad_legacy/SDL/joystick.h b/plugins/onepad_legacy/SDL/joystick.h index e16a547201..45edad5ea7 100644 --- a/plugins/onepad_legacy/SDL/joystick.h +++ b/plugins/onepad_legacy/SDL/joystick.h @@ -26,9 +26,10 @@ #include #endif -#include "GamePad.h" -#include "onepad.h" -#include "controller.h" +#include "../GamePad.h" +#include "../onepad.h" +#include "../controller.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 : GamePad diff --git a/plugins/onepad_legacy/keyboard.cpp b/plugins/onepad_legacy/keyboard.cpp index 52d2fda994..0efdb4206e 100644 --- a/plugins/onepad_legacy/keyboard.cpp +++ b/plugins/onepad_legacy/keyboard.cpp @@ -24,9 +24,12 @@ * Pragmatically, event handing's going in here too. */ +#include "keyboard.h" + +#if defined(__unix__) #include #include -#include "keyboard.h" +#endif #ifdef _WIN32 char *KeysymToChar(int keysym) @@ -276,7 +279,10 @@ bool PollX11KeyboardMouseEvent(u32 &pkey) LRESULT WINAPI PADwndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam) { static bool lbutton = false, rbutton = false; - key_status->keyboard_state_acces(cpad); + for (int pad = 0; pad < GAMEPAD_NUMBER; ++pad) + { + key_status->keyboard_state_acces(pad); + } switch (msg) { diff --git a/plugins/onepad_legacy/state_management.cpp b/plugins/onepad_legacy/state_management.cpp index acb307034b..6b092b6e49 100644 --- a/plugins/onepad_legacy/state_management.cpp +++ b/plugins/onepad_legacy/state_management.cpp @@ -20,6 +20,7 @@ */ #include "state_management.h" +#include "GamePad.h" // Typical packet response on the bus static const u8 ConfigExit[7] = {0x5A, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}; diff --git a/plugins/onepad_legacy/wx_dialog/GamepadConfiguration.h b/plugins/onepad_legacy/wx_dialog/GamepadConfiguration.h index 9b6bd7ff21..432aad10c8 100644 --- a/plugins/onepad_legacy/wx_dialog/GamepadConfiguration.h +++ b/plugins/onepad_legacy/wx_dialog/GamepadConfiguration.h @@ -28,9 +28,10 @@ #include #include #include -#include "GamePad.h" -#include "keyboard.h" -#include "onepad.h" + +#include "../GamePad.h" +#include "../keyboard.h" +#include "../onepad.h" class GamepadConfiguration : public wxDialog { diff --git a/plugins/onepad_legacy/wx_dialog/JoystickConfiguration.h b/plugins/onepad_legacy/wx_dialog/JoystickConfiguration.h index d486483be0..05c1dee91e 100644 --- a/plugins/onepad_legacy/wx_dialog/JoystickConfiguration.h +++ b/plugins/onepad_legacy/wx_dialog/JoystickConfiguration.h @@ -28,9 +28,10 @@ #include #include #include -#include "GamePad.h" -#include "keyboard.h" -#include "onepad.h" + +#include "../GamePad.h" +#include "../keyboard.h" +#include "../onepad.h" class JoystickConfiguration : public wxDialog { diff --git a/plugins/onepad_legacy/wx_dialog/dialog.h b/plugins/onepad_legacy/wx_dialog/dialog.h index 3e4a3593f6..7b210ff9bc 100644 --- a/plugins/onepad_legacy/wx_dialog/dialog.h +++ b/plugins/onepad_legacy/wx_dialog/dialog.h @@ -35,9 +35,9 @@ #include #include -#include "GamePad.h" -#include "keyboard.h" -#include "onepad.h" +#include "../GamePad.h" +#include "../keyboard.h" +#include "../onepad.h" #include "opPanel.h" #include "GamepadConfiguration.h"