Skip to content

Commit 7d09b96

Browse files
committed
Updated implementation
- Move raphnet handling out of emulate_game_controller_via_libretro - Setup plugin connector similar to other plugin types - Improve raphnet portmap and adapter handling and a bit
1 parent a9e520e commit 7d09b96

File tree

10 files changed

+740
-154
lines changed

10 files changed

+740
-154
lines changed

Makefile.common

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -412,7 +412,7 @@ ifeq ($(HAVE_RAPHNET_INPUT), 1)
412412
LDFLAGS += -ludev -ldl
413413

414414
SOURCES_C += $(ROOT_DIR)/custom/mupen64plus-input-raphnetraw/plugin_front.c \
415-
$(INPUTDIR_RAPHNET)/src/plugin_back.c \
415+
$(ROOT_DIR)/custom/mupen64plus-input-raphnetraw/plugin_back.c \
416416
$(INPUTDIR_RAPHNET)/src/hexdump.c \
417417
$(INPUTDIR_RAPHNET)/src/gcn64lib.c \
418418
$(INPUTDIR_RAPHNET)/src/gcn64.c

custom/mupen64plus-core/plugin/emulate_game_controller_via_libretro.c

Lines changed: 5 additions & 89 deletions
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,6 @@
2222
#include "emulate_game_controller_via_input_plugin.h"
2323
#include "plugin/plugin.h"
2424

25-
#ifdef HAVE_RAPHNET_INPUT
26-
#include "mupen64plus-input-raphnetraw/plugin_front.h"
27-
#include "plugin_back.h"
28-
#endif
29-
3025
#include "api/m64p_plugin.h"
3126
#include "device/controllers/game_controller.h"
3227
#include <libretro.h>
@@ -53,7 +48,6 @@ extern int l_cbutton;
5348
extern int d_cbutton;
5449
extern int u_cbutton;
5550
extern bool alternate_mapping;
56-
extern int raw_input_adapter;
5751
static bool libretro_supports_bitmasks = false;
5852

5953
extern m64p_rom_header ROM_HEADER;
@@ -80,14 +74,6 @@ void inputGetKeys_default( int Control, BUTTONS *Keys );
8074
typedef void (*get_keys_t)(int, BUTTONS*);
8175
static get_keys_t getKeys = inputGetKeys_default;
8276

83-
void inputControllerCommand_default( int Control, unsigned char *Command );
84-
typedef void (*controller_command_t)(int, unsigned char*);
85-
static controller_command_t controllerCommand = inputControllerCommand_default;
86-
87-
void inputReadController_default( int Control, unsigned char *Command );
88-
typedef void (*read_controller_t)(int, unsigned char*);
89-
static read_controller_t readController = inputReadController_default;
90-
9177
static void inputGetKeys_default_descriptor(void)
9278
{
9379
if (alternate_mapping)
@@ -161,31 +147,11 @@ EXPORT m64p_error CALL inputPluginStartup(m64p_dynlib_handle CoreLibHandle, void
161147
libretro_supports_bitmasks = true;
162148
getKeys = inputGetKeys_default;
163149
inputGetKeys_default_descriptor();
164-
165-
#ifdef HAVE_RAPHNET_INPUT
166-
if (raw_input_adapter == 1)
167-
{
168-
controllerCommand = raphnetControllerCommand;
169-
readController = raphnetReadController;
170-
raphnetPluginStartup(CoreLibHandle, Context, DebugCallback);
171-
}
172-
else
173-
{
174-
controllerCommand = inputControllerCommand_default;
175-
readController = inputReadController_default;
176-
}
177-
#endif
178-
179150
return M64ERR_SUCCESS;
180151
}
181152

182153
EXPORT m64p_error CALL inputPluginShutdown(void)
183154
{
184-
#ifdef HAVE_RAPHNET_INPUT
185-
if (raw_input_adapter == 1)
186-
raphnetPluginShutdown();
187-
#endif
188-
189155
libretro_supports_bitmasks = false;
190156
abort();
191157
return 0;
@@ -237,14 +203,8 @@ static unsigned char DataCRC( unsigned char *Data, int iLenght )
237203
initilize controller: 01 03 00 FF FF FF
238204
read controller: 01 04 01 FF FF FF FF
239205
*******************************************************************/
240-
EXPORT void CALL inputControllerCommand_default(int Control, unsigned char *Command)
206+
EXPORT void CALL inputControllerCommand(int Control, unsigned char *Command)
241207
{
242-
if (controllerCommand != inputControllerCommand_default)
243-
{
244-
controllerCommand(Control, Command);
245-
return;
246-
}
247-
248208
unsigned char *Data = &Command[5];
249209

250210
if (Control == -1)
@@ -454,20 +414,6 @@ EXPORT void CALL inputInitiateControllers(CONTROL_INFO ControlInfo)
454414

455415
getKeys = inputGetKeys_default;
456416
inputGetKeys_default_descriptor();
457-
458-
#ifdef HAVE_RAPHNET_INPUT
459-
if (raw_input_adapter == 1)
460-
{
461-
controllerCommand = raphnetControllerCommand;
462-
readController = raphnetReadController;
463-
pb_scanControllers();
464-
}
465-
else
466-
{
467-
controllerCommand = inputControllerCommand_default;
468-
readController = inputReadController_default;
469-
}
470-
#endif
471417
}
472418

473419
/******************************************************************
@@ -481,12 +427,9 @@ EXPORT void CALL inputInitiateControllers(CONTROL_INFO ControlInfo)
481427
note: This function is only needed if the DLL is allowing raw
482428
data.
483429
*******************************************************************/
484-
EXPORT void CALL inputReadController_default(int Control, unsigned char *Command)
430+
EXPORT void CALL inputReadController(int Control, unsigned char *Command)
485431
{
486-
if (readController != inputReadController_default)
487-
readController(Control, Command);
488-
else
489-
inputControllerCommand_default(Control, Command);
432+
inputControllerCommand(Control, Command);
490433
}
491434

492435
/******************************************************************
@@ -495,12 +438,7 @@ EXPORT void CALL inputReadController_default(int Control, unsigned char *Command
495438
input: none
496439
output: none
497440
*******************************************************************/
498-
EXPORT void CALL inputRomClosed(void) {
499-
#ifdef HAVE_RAPHNET_INPUT
500-
if (raw_input_adapter == 1)
501-
raphnetRomClosed();
502-
#endif
503-
}
441+
EXPORT void CALL inputRomClosed(void) { }
504442

505443
/******************************************************************
506444
Function: RomOpen
@@ -509,29 +447,7 @@ EXPORT void CALL inputRomClosed(void) {
509447
input: none
510448
output: none
511449
*******************************************************************/
512-
EXPORT int CALL inputRomOpen(void) {
513-
#ifdef HAVE_RAPHNET_INPUT
514-
if (raw_input_adapter == 1)
515-
{
516-
bool all_unset = true;
517-
518-
for (int i = 0; i < 4; i++)
519-
{
520-
if (pad_rawdata[i] == 1)
521-
all_unset = false;
522-
}
523-
524-
// HACK: handle a special case if we enable raphnet support, but
525-
// don't change any of the controllers to actually use raw data
526-
if (all_unset)
527-
raphnetPluginShutdown();
528-
else
529-
raphnetRomOpen();
530-
}
531-
#endif
532-
533-
return 1;
534-
}
450+
EXPORT int CALL inputRomOpen(void) { return 1; }
535451

536452

537453
int egcvip_is_connected(void* opaque, enum pak_type* pak)

0 commit comments

Comments
 (0)