PAD: continuing merge, header/export port

This commit is contained in:
Gauvain 'GovanifY' Roussel-Tarbouriech 2020-12-09 19:28:52 +01:00 committed by lightningterror
parent 93fba0a8e7
commit a691abc630
19 changed files with 57 additions and 268 deletions

View File

@ -73,7 +73,7 @@ typedef struct _keyEvent
///////////////////////////////////////////////////////////////////////
#if defined(GSdefs) defined(SIOdefs)
#if defined(GSdefs) || defined(SIOdefs)
#define COMMONdefs
#endif

View File

@ -457,7 +457,7 @@ endif()
set(PADImgHeader "${CMAKE_BINARY_DIR}/pcsx2/PAD/Linux/ImgHeader")
set(PADImg "${CMAKE_SOURCE_DIR}/pcsx2/PAD/Linux/Img")
file(MAKE_DIRECTORY ${compiled_images})
file(MAKE_DIRECTORY ${PADImgHeader})
foreach(result_file IN ITEMS
analog circle cross dp_bottom dp_left dp_right dp_up dualshock2
@ -468,7 +468,7 @@ foreach(result_file IN ITEMS
COMMAND perl ${CMAKE_SOURCE_DIR}/linux_various/hex2h.pl "${PADImg}/${result_file}.png" "${PADImgHeader}/${result_file}" )
endforeach()
add_custom_glib_res("resources" "onepad-res.xml" "onepad_res" res/game_controller_db.txt)
add_custom_glib_res("PAD/Linux/resources" "PAD/Linux/res/PAD-res.xml" "PAD_res" PAD/Linux/res/game_controller_db.txt)
# PAD/Linux sources
@ -478,7 +478,7 @@ set(pcsx2PAD/LinuxSources
PAD/Linux/SDL/joystick.cpp
PAD/Linux/keyboard.cpp
PAD/Linux/KeyStatus.cpp
PAD/Linux/onepad.cpp
PAD/Linux/PAD.cpp
PAD/Linux/resources.cpp
PAD/Linux/state_management.cpp
PAD/Linux/wx_dialog/dialog.cpp
@ -497,7 +497,7 @@ set(pcsx2PAD/LinuxHeaders
PAD/Linux/SDL/joystick.h
PAD/Linux/keyboard.h
PAD/Linux/KeyStatus.h
PAD/Linux/onepad.h
PAD/Linux/PAD.h
PAD/Linux/resources.h
PAD/Linux/state_management.h
PAD/Linux/wx_dialog/opPanel.h
@ -1056,9 +1056,6 @@ endif()
if(BUILTIN_GS)
set(pcsx2FinalLibs "${pcsx2FinalLibs} GSdx")
endif()
if(BUILTIN_PAD)
set(pcsx2FinalLibs "${pcsx2FinalLibs} onepad-1.2.0")
endif()
# additonal include directories
include_directories(

View File

@ -1,141 +0,0 @@
# Check that people use the good file
if(NOT TOP_CMAKE_WAS_SOURCED)
message(FATAL_ERROR "
You did not 'cmake' the good CMakeLists.txt file. Use the one in the top dir.
It is advice to delete all wrongly generated cmake stuff => CMakeFiles & CMakeCache.txt")
endif()
set(compiled_images "${CMAKE_BINARY_DIR}/plugins/onepad/ImgHeader")
set(image_sources "${CMAKE_SOURCE_DIR}/plugins/onepad/Img")
set(linux_sources "Linux")
set(linux_headers "Linux")
set(wx_sources "wx_dialog")
set(wx_headers "wx_dialog")
set(onepadGuiResources
${compiled_images}/analog.h
${compiled_images}/circle.h
${compiled_images}/cross.h
${compiled_images}/dp_bottom.h
${compiled_images}/dp_left.h
${compiled_images}/dp_right.h
${compiled_images}/dp_up.h
${compiled_images}/dualshock2.h
${compiled_images}/joystick_cursor.h
${compiled_images}/l1.h
${compiled_images}/r1.h
${compiled_images}/l2.h
${compiled_images}/r2.h
${compiled_images}/l3.h
${compiled_images}/r3.h
${compiled_images}/select.h
${compiled_images}/square.h
${compiled_images}/start.h
${compiled_images}/triangle.h
${compiled_images}/arrow_up.h
${compiled_images}/arrow_bottom.h
${compiled_images}/arrow_left.h
${compiled_images}/arrow_right.h
)
# plugin name
set(Output onepad)
set(onepadFinalFlags
-fvisibility=hidden
-Wall
-Wno-parentheses
)
# onepad sources
set(onepadSources
controller.cpp
GamePad.cpp
SDL/joystick.cpp
keyboard.cpp
KeyStatus.cpp
onepad.cpp
resources.cpp
state_management.cpp)
# onepad headers
set(onepadHeaders
bitwise.h
controller.h
GamePad.h
SDL/joystick.h
keyboard.h
KeyStatus.h
onepad.h
resources.h
state_management.h)
# onepad wx sources
set(onepadwxSources
${wx_sources}/dialog.cpp
${wx_sources}/opPanel.cpp
${wx_sources}/GamepadConfiguration.cpp
${wx_headers}/JoystickConfiguration.cpp)
# onepad wx headers
set(onepadwxHeaders
${wx_headers}/opPanel.h
${wx_headers}/GamepadConfiguration.h
${wx_headers}/JoystickConfiguration.h)
# onepad Linux sources
set(onepadLinuxSources
${linux_sources}/ini.cpp
${linux_sources}/linux.cpp)
# onepad Linux headers
set(onepadLinuxHeaders)
set(onepadFinalLibs ${SDL2_LIBRARIES})
add_definitions(-DSDL_BUILD)
set(onepadFinalLibs
${onepadFinalLibs}
${wxWidgets_LIBRARIES}
${GTK2_LIBRARIES}
${X11_LIBRARIES}
)
set(onepadFinalSources
${onepadSources}
${onepadHeaders}
${onepadwxSources}
${onepadwxHeaders}
${onepadLinuxSources}
${onepadLinuxHeaders}
${onepadGuiResources}
)
include_directories(
${CMAKE_BINARY_DIR}/plugins/onepad/
)
### Generate the resources files
file(MAKE_DIRECTORY ${compiled_images})
foreach(result_file IN ITEMS
analog circle cross dp_bottom dp_left dp_right dp_up dualshock2
joystick_cursor l1 r1 l2 r2 l3 r3 select square start triangle arrow_up
arrow_bottom arrow_left arrow_right)
add_custom_command(
OUTPUT "${compiled_images}/${result_file}.h"
COMMAND perl ${CMAKE_SOURCE_DIR}/linux_various/hex2h.pl "${image_sources}/${result_file}.png" "${compiled_images}/${result_file}" )
endforeach()
set(RESOURCE_FILES res/game_controller_db.txt)
add_custom_glib_res("resources" "onepad-res.xml" "onepad_res" ${RESOURCE_FILES})
if(BUILTIN_PAD)
add_pcsx2_lib(${Output} "${onepadFinalSources}" "${onepadFinalLibs}" "${onepadFinalFlags}")
else()
add_pcsx2_plugin(${Output} "${onepadFinalSources}" "${onepadFinalLibs}" "${onepadFinalFlags}")
endif()
target_compile_features(${Output} PRIVATE cxx_std_17)

View File

@ -19,7 +19,7 @@
#pragma once
#include "onepad.h"
#include "PAD.h"
#include "controller.h"
#ifdef SDL_BUILD

View File

@ -22,7 +22,7 @@
#ifndef __KEYSTATUS_H__
#define __KEYSTATUS_H__
#include "onepad.h"
#include "PAD.h"
typedef struct
{

View File

@ -26,8 +26,7 @@
#include <stdarg.h>
#include "keyboard.h"
#include "onepad.h"
#include "svnrev.h"
#include "PAD.h"
#include "state_management.h"
#ifdef __linux__
@ -46,9 +45,6 @@ static keyEvent s_event;
std::string s_strIniPath("inis/");
std::string s_strLogPath("logs/");
const u32 version = PS2E_PAD_VERSION;
const u32 revision = 2;
const u32 build = 0; // increase that with each version
#define PAD_SAVE_STATE_VERSION ((revision << 8) | (build << 0))
FILE *padLog = NULL;
@ -57,50 +53,6 @@ KeyStatus g_key_status;
MtQueue<keyEvent> g_ev_fifo;
static void InitLibraryName()
{
#ifdef PUBLIC
// Public Release!
// Output a simplified string that's just our name:
strcpy(libraryName, "OnePAD");
#else
// Use TortoiseSVN's SubWCRev utility's output
// to label the specific revision:
snprintf(libraryName, 255, "OnePAD %lld%s"
#ifdef PCSX2_DEBUG
"-Debug"
#elif defined(PCSX2_DEVBUILD)
"-Dev"
#endif
,
SVN_REV,
SVN_MODS ? "m" : "");
#endif
}
EXPORT_C_(u32)
PS2EgetLibType()
{
return PS2E_LT_PAD;
}
EXPORT_C_(const char *)
PS2EgetLibName()
{
InitLibraryName();
return libraryName;
}
EXPORT_C_(u32)
PS2EgetLibVersion2(u32 type)
{
return (version << 16) | (revision << 8) | build;
}
void __Log(const char *fmt, ...)
{
@ -153,8 +105,7 @@ void CloseLogging()
#endif
}
EXPORT_C_(s32)
PADinit(u32 flags)
s32 PADinit(u32 flags)
{
initLogging();
@ -170,14 +121,12 @@ PADinit(u32 flags)
return 0;
}
EXPORT_C_(void)
PADshutdown()
void PADshutdown()
{
CloseLogging();
}
EXPORT_C_(s32)
PADopen(void *pDsp)
s32 PADopen(void *pDsp)
{
memset(&event, 0, sizeof(event));
g_key_status.Init();
@ -190,15 +139,13 @@ PADopen(void *pDsp)
return _PADopen(pDsp);
}
EXPORT_C_(void)
PADsetSettingsDir(const char *dir)
void PADsetSettingsDir(const char *dir)
{
// Get the path to the ini directory.
s_strIniPath = (dir == NULL) ? "inis/" : dir;
}
EXPORT_C_(void)
PADsetLogDir(const char *dir)
void PADsetLogDir(const char *dir)
{
// Get the path to the log directory.
s_strLogPath = (dir == NULL) ? "logs/" : dir;
@ -208,20 +155,17 @@ PADsetLogDir(const char *dir)
initLogging();
}
EXPORT_C_(void)
PADclose()
void PADclose()
{
_PADclose();
}
EXPORT_C_(u32)
PADquery()
u32 PADquery()
{
return 3; // both
}
EXPORT_C_(s32)
PADsetSlot(u8 port, u8 slot)
s32 PADsetSlot(u8 port, u8 slot)
{
port--;
slot--;
@ -234,8 +178,7 @@ PADsetSlot(u8 port, u8 slot)
return 1;
}
EXPORT_C_(s32)
PADfreeze(int mode, freezeData *data)
s32 PADfreeze(int mode, freezeData *data)
{
if (!data)
return -1;
@ -303,21 +246,18 @@ PADfreeze(int mode, freezeData *data)
return 0;
}
EXPORT_C_(u8)
PADstartPoll(int pad)
u8 PADstartPoll(int pad)
{
return pad_start_poll(pad);
}
EXPORT_C_(u8)
PADpoll(u8 value)
u8 PADpoll(u8 value)
{
return pad_poll(value);
}
// PADkeyEvent is called every vsync (return NULL if no event)
EXPORT_C_(keyEvent *)
PADkeyEvent()
keyEvent * PADkeyEvent()
{
#ifdef SDL_BUILD
// Take the opportunity to handle hot plugging here
@ -347,8 +287,7 @@ PADkeyEvent()
}
#if defined(__unix__)
EXPORT_C_(void)
PADWriteEvent(keyEvent &evt)
void PADWriteEvent(keyEvent &evt)
{
// if (evt.evt != 6) { // Skip mouse move events for logging
// PAD_LOG("Pushing Event. Event Type: %d, Key: %d\n", evt.evt, evt.key);

View File

@ -18,9 +18,7 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
*/
#ifndef __PAD_H__
#define __PAD_H__
#pragma once
#define GAMEPAD_NUMBER 2 // numbers of gamepad
@ -109,12 +107,6 @@ enum gamePadValues {
#include "KeyStatus.h"
#include "mt_queue.h"
#ifdef _MSC_VER
#define EXPORT_C_(type) extern "C" __declspec(dllexport) type CALLBACK
#else
#define EXPORT_C_(type) extern "C" __attribute__((stdcall, externally_visible, visibility("default"))) type
#endif
extern FILE *padLog;
extern void initLogging();
@ -135,4 +127,21 @@ void SaveConfig();
void SysMessage(char *fmt, ...);
s32 PADinit(u32 flags);
void PADshutdown();
s32 PADopen(void *pDsp);
void PADsetSettingsDir(const char *dir);
void PADsetLogDir(const char *dir);
void PADclose();
u32 PADquery();
s32 PADsetSlot(u8 port, u8 slot);
s32 PADfreeze(int mode, freezeData *data);
u8 PADstartPoll(int pad);
u8 PADpoll(u8 value);
keyEvent * PADkeyEvent();
void PADupdate(int pad);
void PADconfigure();
#if defined(__unix__)
void PADWriteEvent(keyEvent &evt);
#endif

View File

@ -51,7 +51,7 @@ void JoystickInfo::EnumerateJoysticks(std::vector<std::unique_ptr<GamePad>> &vjo
SDL_EventState(SDL_CONTROLLERDEVICEREMOVED, SDL_ENABLE);
{ // Support as much Joystick as possible
GBytes *bytes = g_resource_lookup_data(onepad_res_get_resource(), "/onepad/res/game_controller_db.txt", G_RESOURCE_LOOKUP_FLAGS_NONE, nullptr);
GBytes *bytes = g_resource_lookup_data(onepad_res_get_resource(), "/PAD/res/game_controller_db.txt", G_RESOURCE_LOOKUP_FLAGS_NONE, nullptr);
size_t size = 0;
// SDL forget to add const for SDL_RWFromMem API...
@ -157,7 +157,7 @@ JoystickInfo::JoystickInfo(int id)
}
if (joy == nullptr) {
fprintf(stderr, "onepad:failed to open joystick %d\n", id);
fprintf(stderr, "PAD: failed to open joystick %d\n", id);
return;
}
@ -167,7 +167,7 @@ JoystickInfo::JoystickInfo(int id)
const char *devname = SDL_JoystickNameForIndex(id);
if (m_controller == nullptr) {
fprintf(stderr, "onepad: Joystick (%s,GUID:%s) isn't yet supported by the SDL2 game controller API\n"
fprintf(stderr, "PAD: Joystick (%s,GUID:%s) isn't yet supported by the SDL2 game controller API\n"
"Fortunately you can use AntiMicro (https://github.com/AntiMicro/antimicro) or Steam to configure your joystick\n"
"The mapping can be stored in OnePAD2.ini as 'SDL2 = <...mapping description...>'\n"
"Please report it to us (https://github.com/PCSX2/pcsx2/issues) so we can add your joystick to our internal database.",
@ -229,7 +229,7 @@ JoystickInfo::JoystickInfo(int id)
}
}
fprintf(stdout, "onepad: controller (%s) detected%s, GUID:%s\n",
fprintf(stdout, "PAD: controller (%s) detected%s, GUID:%s\n",
devname, m_haptic ? " with rumble support" : "", guid);
m_no_error = true;

View File

@ -25,7 +25,7 @@
#include <SDL_haptic.h>
#include "GamePad.h"
#include "onepad.h"
#include "PAD.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

View File

@ -19,7 +19,7 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
*/
#include "onepad.h"
#include "PAD.h"
#include "controller.h"
__forceinline void set_keyboard_key(int pad, int keysym, int index)

View File

@ -23,7 +23,7 @@
#include "GamePad.h"
#include "keyboard.h"
#include "onepad.h"
#include "PAD.h"
extern std::string s_strIniPath;

View File

@ -22,7 +22,7 @@
#ifndef __KEYBOARD_H__
#define __KEYBOARD_H__
#include "onepad.h"
#include "PAD.h"
#if defined(__unix__) || defined(__APPLE__)

View File

@ -20,7 +20,7 @@
*/
#include "GamePad.h"
#include "onepad.h"
#include "PAD.h"
#include "keyboard.h"
#include "state_management.h"
@ -48,18 +48,6 @@ static void SysMessage(const char *fmt, ...)
dialog.ShowModal();
}
EXPORT_C_(void)
PADabout()
{
SysMessage("OnePad is a rewrite of Zerofrog's ZeroPad, done by arcum42.");
}
EXPORT_C_(s32)
PADtest()
{
return 0;
}
s32 _PADopen(void *pDsp)
{
#ifndef __APPLE__
@ -94,8 +82,7 @@ void PollForJoystickInput(int cpad)
}
}
EXPORT_C_(void)
PADupdate(int pad)
void PADupdate(int pad)
{
#ifndef __APPLE__
// Gamepad inputs don't count as an activity. Therefore screensaver will
@ -131,8 +118,7 @@ PADupdate(int pad)
Pad::rumble_all();
}
EXPORT_C_(void)
PADconfigure()
void PADconfigure()
{
LoadConfig();

View File

@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<gresources>
<gresource prefix="/onepad/res/">
<gresource prefix="/PAD/res/">
<file>game_controller_db.txt</file>
</gresource>
</gresources>

View File

@ -19,7 +19,7 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
*/
#include "onepad.h"
#include "PAD.h"
#define MODE_DIGITAL 0x41
#define MODE_ANALOG 0x73

View File

@ -26,7 +26,7 @@
#include "../GamePad.h"
#include "../keyboard.h"
#include "../onepad.h"
#include "../PAD.h"
static const s32 rumble_slider_id = wxID_HIGHEST + 200 + 1;
static const s32 joy_slider_id = wxID_HIGHEST + 200 + 2;

View File

@ -26,7 +26,7 @@
#include "../GamePad.h"
#include "../keyboard.h"
#include "../onepad.h"
#include "../PAD.h"
static const s32 Lx_check_id = wxID_HIGHEST + 100 + 1;
static const s32 Ly_check_id = wxID_HIGHEST + 100 + 2;

View File

@ -623,8 +623,7 @@ void DisplayDialog()
{
if (g_conf.ftw) {
wxString info("The OnePad GUI is provided to map the keyboard/mouse to the virtual PS2 pad.\n\n"
"Gamepads/Joysticks are plug and play. The active gamepad can be selected in the 'Gamepad Configuration' panel.\n\n"
"If you prefer to manually map your gamepad, you should use the 'onepad-legacy' plugin instead.");
"Gamepads/Joysticks are plug and play. The active gamepad can be selected in the 'Gamepad Configuration' panel.\n\n");
wxMessageDialog ftw(nullptr, info);
ftw.ShowModal();

View File

@ -37,7 +37,7 @@
#include "../GamePad.h"
#include "../keyboard.h"
#include "../onepad.h"
#include "../PAD.h"
#include "opPanel.h"
#include "GamepadConfiguration.h"
@ -45,7 +45,7 @@
// Allow to found quickly button id
// e.g L2 → 0, triangle → 4, ...
// see onepad.h for more details about gamepad button id
// see PAD.h for more details about gamepad button id
enum gui_buttons {
Analog = PAD_R_LEFT + 1, // Analog button (not yet supported ?)