From aa4cdd73cb825a0f4b115407fe26335f4d75ee59 Mon Sep 17 00:00:00 2001 From: notaz Date: Sun, 30 Mar 2025 17:59:42 +0300 Subject: [PATCH] clean up pad plugin stuff pad code was never used as a plugin, and there is no benefit from all the indirection --- frontend/main.c | 14 +--- frontend/plugin.c | 28 +------ frontend/plugin.h | 5 +- include/psemu_plugin_defs.h | 2 +- libpcsxcore/plugins.c | 153 ++++-------------------------------- libpcsxcore/plugins.h | 49 ++---------- libpcsxcore/psxcommon.h | 2 - 7 files changed, 29 insertions(+), 224 deletions(-) diff --git a/frontend/main.c b/frontend/main.c index e1777ddd..2aa6fbd7 100644 --- a/frontend/main.c +++ b/frontend/main.c @@ -114,8 +114,6 @@ static void set_default_paths(void) strcpy(Config.PluginsDir, "plugins"); strcpy(Config.Gpu, "builtin_gpu"); strcpy(Config.Spu, "builtin_spu"); - strcpy(Config.Pad1, "builtin_pad"); - strcpy(Config.Pad2, "builtin_pad"); } void emu_set_default_config(void) @@ -909,10 +907,6 @@ static int _OpenPlugins(void) { // pcsx-rearmed: we handle gpu elsewhere //ret = GPU_open(&gpuDisp, "PCSX", NULL); //if (ret < 0) { SysMessage(_("Error opening GPU plugin!")); return -1; } - ret = PAD1_open(&gpuDisp); - if (ret < 0) { SysMessage(_("Error opening Controller 1 plugin!")); return -1; } - ret = PAD2_open(&gpuDisp); - if (ret < 0) { SysMessage(_("Error opening Controller 2 plugin!")); return -1; } return 0; } @@ -939,10 +933,6 @@ void ClosePlugins() { cdra_close(); ret = SPU_close(); if (ret < 0) { SysMessage(_("Error closing SPU plugin!")); } - ret = PAD1_close(); - if (ret < 0) { SysMessage(_("Error closing Controller 1 Plugin!")); } - ret = PAD2_close(); - if (ret < 0) { SysMessage(_("Error closing Controller 2 plugin!")); } // pcsx-rearmed: we handle gpu elsewhere //ret = GPU_close(); //if (ret < 0) { SysMessage(_("Error closing GPU plugin!")); return; } @@ -950,11 +940,11 @@ void ClosePlugins() { /* we hook statically linked plugins here */ static const char *builtin_plugins[] = { - "builtin_gpu", "builtin_spu", "builtin_pad", + "builtin_gpu", "builtin_spu" }; static const int builtin_plugin_ids[] = { - PLUGIN_GPU, PLUGIN_SPU, PLUGIN_PAD, + PLUGIN_GPU, PLUGIN_SPU }; void *SysLoadLibrary(const char *lib) { diff --git a/frontend/plugin.c b/frontend/plugin.c index 8db390a7..3263ae31 100644 --- a/frontend/plugin.c +++ b/frontend/plugin.c @@ -24,13 +24,7 @@ #include "../plugins/dfsound/spu.h" /* PAD */ -static long CALLBACK PADinit(long _) { return 0; } -static long CALLBACK PADopen(unsigned long *_) { return 0; } -static long CALLBACK PADshutdown(void) { return 0; } -static long CALLBACK PADclose(void) { return 0; } -static void CALLBACK PADsetSensitive(int _) { return; } - -static long CALLBACK PADreadPort1(PadDataS *pad) { +long PAD1_readPort(PadDataS *pad) { int pad_index = pad->requestPadIndex; pad->controllerType = in_type[pad_index]; @@ -58,7 +52,7 @@ static long CALLBACK PADreadPort1(PadDataS *pad) { return 0; } -static long CALLBACK PADreadPort2(PadDataS *pad) { +long PAD2_readPort(PadDataS *pad) { int pad_index = pad->requestPadIndex; pad->controllerType = in_type[pad_index]; @@ -110,7 +104,6 @@ extern void GPUrearmedCallbacks(const struct rearmed_cbs *cbs); #define DIRECT_SPU(name) DIRECT(PLUGIN_SPU, name) #define DIRECT_GPU(name) DIRECT(PLUGIN_GPU, name) -#define DIRECT_PAD(name) DIRECT(PLUGIN_PAD, name) static const struct { int id; @@ -133,23 +126,6 @@ static const struct { DIRECT_SPU(SPUasync), DIRECT_SPU(SPUplayCDDAchannel), DIRECT_SPU(SPUsetCDvol), - /* PAD */ - DIRECT_PAD(PADinit), - DIRECT_PAD(PADshutdown), - DIRECT_PAD(PADopen), - DIRECT_PAD(PADclose), - DIRECT_PAD(PADsetSensitive), - DIRECT_PAD(PADreadPort1), - DIRECT_PAD(PADreadPort2), -/* - DIRECT_PAD(PADquery), - DIRECT_PAD(PADconfigure), - DIRECT_PAD(PADtest), - DIRECT_PAD(PADabout), - DIRECT_PAD(PADkeypressed), - DIRECT_PAD(PADstartPoll), - DIRECT_PAD(PADpoll), -*/ /* GPU */ DIRECT_GPU(GPUupdateLace), DIRECT_GPU(GPUinit), diff --git a/frontend/plugin.h b/frontend/plugin.h index 996da557..20c622d7 100644 --- a/frontend/plugin.h +++ b/frontend/plugin.h @@ -10,10 +10,13 @@ enum builtint_plugins_e { PLUGIN_GPU, PLUGIN_SPU, - PLUGIN_PAD, }; void *plugin_link(enum builtint_plugins_e id, const char *sym); void plugin_call_rearmed_cbs(void); +struct PadDataS; +long PAD1_readPort(struct PadDataS *); +long PAD2_readPort(struct PadDataS *); + #endif /* __PLUGIN_H__ */ diff --git a/include/psemu_plugin_defs.h b/include/psemu_plugin_defs.h index 4e69b167..c2c61444 100644 --- a/include/psemu_plugin_defs.h +++ b/include/psemu_plugin_defs.h @@ -195,7 +195,7 @@ typedef struct #define PSE_PAD_WARN 80 -typedef struct +typedef struct PadDataS { // controller type - fill it withe predefined values above unsigned char controllerType; diff --git a/libpcsxcore/plugins.c b/libpcsxcore/plugins.c index 9953d1cd..3cf1cf61 100644 --- a/libpcsxcore/plugins.c +++ b/libpcsxcore/plugins.c @@ -61,34 +61,6 @@ SPUasync SPU_async; SPUplayCDDAchannel SPU_playCDDAchannel; SPUsetCDvol SPU_setCDvol; -PADconfigure PAD1_configure; -PADabout PAD1_about; -PADinit PAD1_init; -PADshutdown PAD1_shutdown; -PADtest PAD1_test; -PADopen PAD1_open; -PADclose PAD1_close; -PADquery PAD1_query; -PADreadPort1 PAD1_readPort1; -PADkeypressed PAD1_keypressed; -PADstartPoll PAD1_startPoll; -PADpoll PAD1_poll; -PADsetSensitive PAD1_setSensitive; - -PADconfigure PAD2_configure; -PADabout PAD2_about; -PADinit PAD2_init; -PADshutdown PAD2_shutdown; -PADtest PAD2_test; -PADopen PAD2_open; -PADclose PAD2_close; -PADquery PAD2_query; -PADreadPort2 PAD2_readPort2; -PADkeypressed PAD2_keypressed; -PADstartPoll PAD2_startPoll; -PADpoll PAD2_poll; -PADsetSensitive PAD2_setSensitive; - #ifdef ENABLE_SIO1API SIO1init SIO1_init; @@ -234,9 +206,6 @@ static int LoadSPUplugin(const char *SPUdll) { extern int in_type[8]; -void *hPAD1Driver = NULL; -void *hPAD2Driver = NULL; - // Pad information, keystate, mode, config mode, vibration static PadDataS pads[8]; @@ -727,12 +696,12 @@ static unsigned char PADpollMain(int port, unsigned char value, int *more_data) // refresh the button state on port 1. // int pad is not needed. -unsigned char CALLBACK PAD1__startPoll(int unused) { +unsigned char PAD1_startPoll(int unused) { int i; reqPos = 0; pads[0].requestPadIndex = 0; - PAD1_readPort1(&pads[0]); + PAD1_readPort(&pads[0]); pads[0].multitapLongModeEnabled = 0; if (pads[0].portMultitap) @@ -744,72 +713,24 @@ unsigned char CALLBACK PAD1__startPoll(int unused) { // a multitap is plugged and enabled: refresh pads 1-3 for (i = 1; i < 4; i++) { pads[i].requestPadIndex = i; - PAD1_readPort1(&pads[i]); + PAD1_readPort(&pads[i]); } } return 0xff; } -unsigned char CALLBACK PAD1__poll(unsigned char value, int *more_data) { +unsigned char PAD1_poll(unsigned char value, int *more_data) { return PADpollMain(0, value, more_data); } -long CALLBACK PAD1__configure(void) { return 0; } -void CALLBACK PAD1__about(void) {} -long CALLBACK PAD1__test(void) { return 0; } -long CALLBACK PAD1__query(void) { return 3; } -long CALLBACK PAD1__keypressed() { return 0; } - -#define LoadPad1Sym1(dest, name) \ - LoadSym(PAD1_##dest, PAD##dest, name, TRUE); - -#define LoadPad1SymN(dest, name) \ - LoadSym(PAD1_##dest, PAD##dest, name, FALSE); - -#define LoadPad1Sym0(dest, name) \ - LoadSym(PAD1_##dest, PAD##dest, name, FALSE); \ - if (PAD1_##dest == NULL) PAD1_##dest = (PAD##dest) PAD1__##dest; - -static int LoadPAD1plugin(const char *PAD1dll) { - void *drv; - size_t p; - - hPAD1Driver = SysLoadLibrary(PAD1dll); - if (hPAD1Driver == NULL) { - PAD1_configure = NULL; - SysMessage (_("Could not load Controller 1 plugin %s!"), PAD1dll); return -1; - } - drv = hPAD1Driver; - LoadPad1Sym1(init, "PADinit"); - LoadPad1Sym1(shutdown, "PADshutdown"); - LoadPad1Sym1(open, "PADopen"); - LoadPad1Sym1(close, "PADclose"); - LoadPad1Sym0(query, "PADquery"); - LoadPad1Sym1(readPort1, "PADreadPort1"); - LoadPad1Sym0(configure, "PADconfigure"); - LoadPad1Sym0(test, "PADtest"); - LoadPad1Sym0(about, "PADabout"); - LoadPad1Sym0(keypressed, "PADkeypressed"); - LoadPad1Sym0(startPoll, "PADstartPoll"); - LoadPad1Sym0(poll, "PADpoll"); - LoadPad1SymN(setSensitive, "PADsetSensitive"); - - memset(pads, 0, sizeof(pads)); - for (p = 0; p < sizeof(pads) / sizeof(pads[0]); p++) { - memset(pads[p].ds.cmd4dConfig, 0xff, sizeof(pads[p].ds.cmd4dConfig)); - } - - return 0; -} - -unsigned char CALLBACK PAD2__startPoll(int pad) { +unsigned char PAD2_startPoll(int pad) { int pad_index = pads[0].portMultitap ? 4 : 1; int i; reqPos = 0; pads[pad_index].requestPadIndex = pad_index; - PAD2_readPort2(&pads[pad_index]); + PAD2_readPort(&pads[pad_index]); pads[pad_index].multitapLongModeEnabled = 0; if (pads[pad_index].portMultitap) @@ -820,56 +741,23 @@ unsigned char CALLBACK PAD2__startPoll(int pad) { } else { for (i = 1; i < 4; i++) { pads[pad_index + i].requestPadIndex = pad_index + i; - PAD2_readPort2(&pads[pad_index + i]); + PAD2_readPort(&pads[pad_index + i]); } } return 0xff; } -unsigned char CALLBACK PAD2__poll(unsigned char value, int *more_data) { +unsigned char PAD2_poll(unsigned char value, int *more_data) { return PADpollMain(pads[0].portMultitap ? 4 : 1, value, more_data); } -long CALLBACK PAD2__configure(void) { return 0; } -void CALLBACK PAD2__about(void) {} -long CALLBACK PAD2__test(void) { return 0; } -long CALLBACK PAD2__query(void) { return PSE_PAD_USE_PORT1 | PSE_PAD_USE_PORT2; } -long CALLBACK PAD2__keypressed() { return 0; } - -#define LoadPad2Sym1(dest, name) \ - LoadSym(PAD2_##dest, PAD##dest, name, TRUE); - -#define LoadPad2Sym0(dest, name) \ - LoadSym(PAD2_##dest, PAD##dest, name, FALSE); \ - if (PAD2_##dest == NULL) PAD2_##dest = (PAD##dest) PAD2__##dest; - -#define LoadPad2SymN(dest, name) \ - LoadSym(PAD2_##dest, PAD##dest, name, FALSE); - -static int LoadPAD2plugin(const char *PAD2dll) { - void *drv; +static void PAD_init(void) { + size_t p; - hPAD2Driver = SysLoadLibrary(PAD2dll); - if (hPAD2Driver == NULL) { - PAD2_configure = NULL; - SysMessage (_("Could not load Controller 2 plugin %s!"), PAD2dll); return -1; + memset(pads, 0, sizeof(pads)); + for (p = 0; p < sizeof(pads) / sizeof(pads[0]); p++) { + memset(pads[p].ds.cmd4dConfig, 0xff, sizeof(pads[p].ds.cmd4dConfig)); } - drv = hPAD2Driver; - LoadPad2Sym1(init, "PADinit"); - LoadPad2Sym1(shutdown, "PADshutdown"); - LoadPad2Sym1(open, "PADopen"); - LoadPad2Sym1(close, "PADclose"); - LoadPad2Sym0(query, "PADquery"); - LoadPad2Sym1(readPort2, "PADreadPort2"); - LoadPad2Sym0(configure, "PADconfigure"); - LoadPad2Sym0(test, "PADtest"); - LoadPad2Sym0(about, "PADabout"); - LoadPad2Sym0(keypressed, "PADkeypressed"); - LoadPad2Sym0(startPoll, "PADstartPoll"); - LoadPad2Sym0(poll, "PADpoll"); - LoadPad2SymN(setSensitive, "PADsetSensitive"); - - return 0; } int padFreeze(void *f, int Mode) { @@ -1008,12 +896,6 @@ int LoadPlugins() { sprintf(Plugin, "%s/%s", Config.PluginsDir, Config.Spu); if (LoadSPUplugin(Plugin) == -1) return -1; - sprintf(Plugin, "%s/%s", Config.PluginsDir, Config.Pad1); - if (LoadPAD1plugin(Plugin) == -1) return -1; - - sprintf(Plugin, "%s/%s", Config.PluginsDir, Config.Pad2); - if (LoadPAD2plugin(Plugin) == -1) return -1; - #ifdef ENABLE_SIO1API sprintf(Plugin, "%s/%s", Config.PluginsDir, Config.Sio1); if (LoadSIO1plugin(Plugin) == -1) return -1; @@ -1025,10 +907,7 @@ int LoadPlugins() { if (ret < 0) { SysMessage (_("Error initializing GPU plugin: %d"), ret); return -1; } ret = SPU_init(); if (ret < 0) { SysMessage (_("Error initializing SPU plugin: %d"), ret); return -1; } - ret = PAD1_init(1); - if (ret < 0) { SysMessage (_("Error initializing Controller 1 plugin: %d"), ret); return -1; } - ret = PAD2_init(2); - if (ret < 0) { SysMessage (_("Error initializing Controller 2 plugin: %d"), ret); return -1; } + PAD_init(); #ifdef ENABLE_SIO1API ret = SIO1_init(); @@ -1043,13 +922,9 @@ void ReleasePlugins() { cdra_shutdown(); if (hGPUDriver != NULL) GPU_shutdown(); if (hSPUDriver != NULL) SPU_shutdown(); - if (hPAD1Driver != NULL) PAD1_shutdown(); - if (hPAD2Driver != NULL) PAD2_shutdown(); if (hGPUDriver != NULL) { SysCloseLibrary(hGPUDriver); hGPUDriver = NULL; } if (hSPUDriver != NULL) { SysCloseLibrary(hSPUDriver); hSPUDriver = NULL; } - if (hPAD1Driver != NULL) { SysCloseLibrary(hPAD1Driver); hPAD1Driver = NULL; } - if (hPAD2Driver != NULL) { SysCloseLibrary(hPAD2Driver); hPAD2Driver = NULL; } #ifdef ENABLE_SIO1API if (hSIO1Driver != NULL) { diff --git a/libpcsxcore/plugins.h b/libpcsxcore/plugins.h index bdea9187..d32c9e41 100644 --- a/libpcsxcore/plugins.h +++ b/libpcsxcore/plugins.h @@ -31,7 +31,6 @@ extern "C" { typedef long (CALLBACK *GPUopen)(unsigned long *, char *, char *); typedef long (CALLBACK *SPUopen)(void); -typedef long (CALLBACK *PADopen)(unsigned long *); typedef long (CALLBACK *SIO1open)(unsigned long *); #include "spu.h" @@ -138,48 +137,13 @@ extern SPUplayCDDAchannel SPU_playCDDAchannel; extern SPUsetCDvol SPU_setCDvol; // PAD Functions -typedef long (CALLBACK* PADconfigure)(void); -typedef void (CALLBACK* PADabout)(void); -typedef long (CALLBACK* PADinit)(long); -typedef long (CALLBACK* PADshutdown)(void); -typedef long (CALLBACK* PADtest)(void); -typedef long (CALLBACK* PADclose)(void); -typedef long (CALLBACK* PADquery)(void); -typedef long (CALLBACK* PADreadPort1)(PadDataS*); -typedef long (CALLBACK* PADreadPort2)(PadDataS*); -typedef long (CALLBACK* PADkeypressed)(void); -typedef unsigned char (CALLBACK* PADstartPoll)(int); -typedef unsigned char (CALLBACK* PADpoll)(unsigned char, int *); -typedef void (CALLBACK* PADsetSensitive)(int); +long PAD1_readPort(PadDataS *); +unsigned char PAD1_startPoll(int); +unsigned char PAD1_poll(unsigned char, int *); -// PAD function pointers -extern PADconfigure PAD1_configure; -extern PADabout PAD1_about; -extern PADinit PAD1_init; -extern PADshutdown PAD1_shutdown; -extern PADtest PAD1_test; -extern PADopen PAD1_open; -extern PADclose PAD1_close; -extern PADquery PAD1_query; -extern PADreadPort1 PAD1_readPort1; -extern PADkeypressed PAD1_keypressed; -extern PADstartPoll PAD1_startPoll; -extern PADpoll PAD1_poll; -extern PADsetSensitive PAD1_setSensitive; - -extern PADconfigure PAD2_configure; -extern PADabout PAD2_about; -extern PADinit PAD2_init; -extern PADshutdown PAD2_shutdown; -extern PADtest PAD2_test; -extern PADopen PAD2_open; -extern PADclose PAD2_close; -extern PADquery PAD2_query; -extern PADreadPort2 PAD2_readPort2; -extern PADkeypressed PAD2_keypressed; -extern PADstartPoll PAD2_startPoll; -extern PADpoll PAD2_poll; -extern PADsetSensitive PAD2_setSensitive; +long PAD2_readPort(PadDataS *); +unsigned char PAD2_startPoll(int); +unsigned char PAD2_poll(unsigned char, int *); #ifdef ENABLE_SIO1API @@ -264,7 +228,6 @@ int padToggleAnalog(unsigned int index); extern void pl_gun_byte2(int port, unsigned char byte); extern void plat_trigger_vibrate(int pad, int low, int high); -extern void plat_get_psx_resolution(int *xres, int *yres); #ifdef __cplusplus } diff --git a/libpcsxcore/psxcommon.h b/libpcsxcore/psxcommon.h index c852d1ba..53c23f16 100644 --- a/libpcsxcore/psxcommon.h +++ b/libpcsxcore/psxcommon.h @@ -119,8 +119,6 @@ void __Log(char *fmt, ...); typedef struct { char Gpu[MAXPATHLEN]; char Spu[MAXPATHLEN]; - char Pad1[MAXPATHLEN]; - char Pad2[MAXPATHLEN]; char Sio1[MAXPATHLEN]; char Mcd1[MAXPATHLEN]; char Mcd2[MAXPATHLEN]; -- 2.39.5