From 485a61050ba83a43b3fc5aafb8d877488a749eb3 Mon Sep 17 00:00:00 2001 From: "Mark W. Kidd" Date: Thu, 3 Jun 2021 15:46:16 -0400 Subject: [PATCH 01/28] do not cache lightgun input --- src/mame2003/mame2003.c | 91 ++++++++++++++++++++++------------------- src/mame2003/mame2003.h | 17 ++++---- 2 files changed, 58 insertions(+), 50 deletions(-) diff --git a/src/mame2003/mame2003.c b/src/mame2003/mame2003.c index aab85c1b9..1475d915f 100644 --- a/src/mame2003/mame2003.c +++ b/src/mame2003/mame2003.c @@ -59,10 +59,6 @@ int16_t mouse_y[MAX_PLAYER_COUNT]= {0}; int16_t prev_pointer_x; int16_t prev_pointer_y; -/* data structures to store lightgun coordinates */ -int16_t lightgun_x[MAX_PLAYER_COUNT]= {0}; -int16_t lightgun_y[MAX_PLAYER_COUNT]= {0}; - /* data structures to store position data for analog joysticks */ int16_t analogjoy[MAX_PLAYER_COUNT][4]= {0}; @@ -155,7 +151,7 @@ static void check_system_specs(void); unsigned encode_osd_joycode(unsigned player_number, unsigned joycode); unsigned decode_osd_joycode(unsigned joycode); unsigned calc_player_number(unsigned joycode); - int normalize_lightgun(int libretro_coordinate); + int rescale_analog(int libretro_coordinate); int analog_deadzone_rescale(int input); static void remove_slash (char* temp); @@ -1241,8 +1237,6 @@ void retro_run (void) analogjoy[port][3] = 0; mouse_x[port] = 0; mouse_y[port] = 0; - lightgun_x[port] = 0; - lightgun_y[port] = 0; } for(port = 0; port < MAX_PLAYER_COUNT; port++) @@ -1308,30 +1302,6 @@ void retro_run (void) mouse_x[port] = pointer_pressed ? get_pointer_delta(input_cb(port, RETRO_DEVICE_POINTER, 0, RETRO_DEVICE_ID_POINTER_X), &prev_pointer_x) : 0; mouse_y[port] = pointer_pressed ? get_pointer_delta(input_cb(port, RETRO_DEVICE_POINTER, 0, RETRO_DEVICE_ID_POINTER_Y), &prev_pointer_y) : 0; } - else if (options.mouse_device == RETRO_DEVICE_LIGHTGUN) - { - lightgun_x[port] = normalize_lightgun(input_cb(port, RETRO_DEVICE_LIGHTGUN, 0, RETRO_DEVICE_ID_LIGHTGUN_SCREEN_X)); - lightgun_y[port] = normalize_lightgun(input_cb(port, RETRO_DEVICE_LIGHTGUN, 0, RETRO_DEVICE_ID_LIGHTGUN_SCREEN_Y)); - retroJsState[port][OSD_LIGHTGUN_IS_TRIGGER] = input_cb(port, RETRO_DEVICE_LIGHTGUN, 0, RETRO_DEVICE_ID_LIGHTGUN_TRIGGER); /*Status Check*/ - retroJsState[port][OSD_LIGHTGUN_RELOAD] = input_cb(port, RETRO_DEVICE_LIGHTGUN, 0, RETRO_DEVICE_ID_LIGHTGUN_RELOAD); /*Forced off-screen shot*/ - retroJsState[port][OSD_LIGHTGUN_AUX_A] = input_cb(port, RETRO_DEVICE_LIGHTGUN, 0, RETRO_DEVICE_ID_LIGHTGUN_AUX_A); - retroJsState[port][OSD_LIGHTGUN_AUX_B] = input_cb(port, RETRO_DEVICE_LIGHTGUN, 0, RETRO_DEVICE_ID_LIGHTGUN_AUX_B); - retroJsState[port][OSD_LIGHTGUN_START] = input_cb(port, RETRO_DEVICE_LIGHTGUN, 0, RETRO_DEVICE_ID_LIGHTGUN_START); - retroJsState[port][OSD_LIGHTGUN_SELECT] = input_cb(port, RETRO_DEVICE_LIGHTGUN, 0, RETRO_DEVICE_ID_LIGHTGUN_SELECT); - retroJsState[port][OSD_LIGHTGUN_AUX_C] = input_cb(port, RETRO_DEVICE_LIGHTGUN, 0, RETRO_DEVICE_ID_LIGHTGUN_AUX_C); - retroJsState[port][OSD_LIGHTGUN_DPAD_UP] = input_cb(port, RETRO_DEVICE_LIGHTGUN, 0, RETRO_DEVICE_ID_LIGHTGUN_DPAD_UP); - retroJsState[port][OSD_LIGHTGUN_DPAD_DOWN] = input_cb(port, RETRO_DEVICE_LIGHTGUN, 0, RETRO_DEVICE_ID_LIGHTGUN_DPAD_DOWN); - retroJsState[port][OSD_LIGHTGUN_DPAD_LEFT] = input_cb(port, RETRO_DEVICE_LIGHTGUN, 0, RETRO_DEVICE_ID_LIGHTGUN_DPAD_LEFT); - retroJsState[port][OSD_LIGHTGUN_DPAD_RIGHT] = input_cb(port, RETRO_DEVICE_LIGHTGUN, 0, RETRO_DEVICE_ID_LIGHTGUN_DPAD_RIGHT); - - /* simulated lightgun reload hack */ - if(retroJsState[port][OSD_LIGHTGUN_RELOAD]) - { - retroJsState[port][OSD_LIGHTGUN_IS_TRIGGER] = true; - lightgun_x[port] = -128; - lightgun_y[port] = -128; - } - } } } @@ -2162,9 +2132,25 @@ int osd_is_joy_pressed(int joycode) if (options.input_interface == RETRO_DEVICE_KEYBOARD) return 0; /* disregard joystick input */ unsigned player_number = calc_player_number(joycode); + unsigned port = player_number - 1; unsigned osd_code = decode_osd_joycode(joycode); + unsigned retro_code = INT_MAX; /*log_cb(RETRO_LOG_DEBUG, "MAME is polling joysticks -- joycode: %i player_number: %i osd_code: %i\n", joycode, player_number, osd_code); */ + + /*** Check whether this is an osd code from the range for lightguns ***/ + retro_code = get_retrogun_code(osd_code); + if(retro_code != INT_MAX) + { + if(retro_code == RETRO_DEVICE_ID_LIGHTGUN_TRIGGER) + { + if(input_cb(port, RETRO_DEVICE_LIGHTGUN, 0, RETRO_DEVICE_ID_LIGHTGUN_RELOAD)) + return 1; /* lightgun reload hack, report trigger as being pressed no matter what */ + } + return input_cb(port, RETRO_DEVICE_LIGHTGUN, 0, retro_code); + } + + /*** Use the cached input states ***/ return retroJsState[player_number-1][osd_code]; } @@ -2330,27 +2316,48 @@ void osd_trak_read(int player, int *deltax, int *deltay) *******************************************************************************/ void osd_lightgun_read(int player, int *deltax, int *deltay) { - *deltax = lightgun_x[player]; - *deltay = lightgun_y[player]; + if (options.mouse_device != RETRO_DEVICE_LIGHTGUN) + { + *deltax = 0; + *deltay = 0; + return; + } + + /* simulated lightgun reload hack */ + if(input_cb(player, RETRO_DEVICE_LIGHTGUN, 0, RETRO_DEVICE_ID_LIGHTGUN_RELOAD)) + { + retroJsState[player][OSD_LIGHTGUN_IS_TRIGGER] = true; + *deltax = -128; + *deltay = -128; + return; + } + + *deltax = rescale_analog(input_cb(player, RETRO_DEVICE_LIGHTGUN, 0, RETRO_DEVICE_ID_LIGHTGUN_SCREEN_X)); + *deltay = rescale_analog(input_cb(player, RETRO_DEVICE_LIGHTGUN, 0, RETRO_DEVICE_ID_LIGHTGUN_SCREEN_Y)); } /****************************************************************************** - * normalize_lightgun converts between the libretro coordinate system and the + * rescale_analog converts between the libretro coordinate system and the * MAME OSD coordinate system. * - * RETRO_DEVICE_LIGHTGUN reports X/Y coordinates in screen space in the range - * [-0x8000, 0x7fff] in both axes, with zero being center and -0x8000 being - * out of bounds. + * RETRO_DEVICE_LIGHTGUN report X/Y coordinates in the range [-0x8000, 0x7fff] + * in both axes, with zero being center and -0x8000 being out of bounds. + * RETRO_DEVICE_ANALOG uses the same [-0x8000, 0x7fff] range. * - * Meanwhile the MAME OSD uses delta from the middle of the screen - * when the lightgun is fired and 0 when the gun is inactive. The value returned - * by the OSD layer should be -128 to 128, same as analog joysticks. + * For lightguns, the MAME OSD uses delta from the middle of the screen when + * the lightgun is fired, and 0 when the gun is inactive with a range of + * -128 to 128. MAME OSD uses this same range for analog joysticks. + * + * Therefore we can use a common function to scale input from lightguns and + * analog controls. ******************************************************************************/ -int normalize_lightgun(int libretro_coordinate) +int rescale_analog(int libretro_coordinate) { + static const float scale_factor = (float)MAME_ANALOG_MAX / LIBRETRO_ANALOG_MAX; + if (libretro_coordinate == 0 || libretro_coordinate == LIBRETRO_ANALOG_MIN) return 0; - return round(((float)libretro_coordinate / LIBRETRO_ANALOG_MAX) * ANALOG_MAX); + return round(scale_factor * libretro_coordinate); } /****************************************************************************** diff --git a/src/mame2003/mame2003.h b/src/mame2003/mame2003.h index 4f2b2f1e4..01b087f85 100644 --- a/src/mame2003/mame2003.h +++ b/src/mame2003/mame2003.h @@ -55,17 +55,18 @@ extern "C" { ***************************************************************************/ -#define APPNAME "mame2003-plus" +#define APPNAME "mame2003-plus" -#define FRAMES_PER_FPS_UPDATE 12 -#define MAX_GFX_ELEMENTS 32 -#define MAX_MEMORY_REGIONS 32 +#define FRAMES_PER_FPS_UPDATE 12 +#define MAX_GFX_ELEMENTS 32 +#define MAX_MEMORY_REGIONS 32 + +#define LIBRETRO_ANALOG_MIN -32768 +#define LIBRETRO_ANALOG_MAX 32767 +#define MAME_ANALOG_MIN -128 +#define MAME_ANALOG_MAX 128 #define INPUT_BUTTON_AXIS_THRESHOLD 64 -#define LIBRETRO_ANALOG_MIN -32768 -#define LIBRETRO_ANALOG_MAX 32767 -#define ANALOG_MIN -128 -#define ANALOG_MAX 128 enum { From c5f66d0e6b3477039bec135ff4797badf6f4d92d Mon Sep 17 00:00:00 2001 From: mahoneyt944 <49591133+mahoneyt944@users.noreply.github.com> Date: Thu, 3 Jun 2021 16:31:13 -0400 Subject: [PATCH 02/28] Add check for core option --- src/mame2003/mame2003.c | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/src/mame2003/mame2003.c b/src/mame2003/mame2003.c index 1475d915f..d9e68025a 100644 --- a/src/mame2003/mame2003.c +++ b/src/mame2003/mame2003.c @@ -2138,16 +2138,18 @@ int osd_is_joy_pressed(int joycode) /*log_cb(RETRO_LOG_DEBUG, "MAME is polling joysticks -- joycode: %i player_number: %i osd_code: %i\n", joycode, player_number, osd_code); */ - /*** Check whether this is an osd code from the range for lightguns ***/ - retro_code = get_retrogun_code(osd_code); - if(retro_code != INT_MAX) + if (options.mouse_device == RETRO_DEVICE_LIGHTGUN) { - if(retro_code == RETRO_DEVICE_ID_LIGHTGUN_TRIGGER) + retro_code = get_retrogun_code(osd_code); + if(retro_code != INT_MAX) { - if(input_cb(port, RETRO_DEVICE_LIGHTGUN, 0, RETRO_DEVICE_ID_LIGHTGUN_RELOAD)) - return 1; /* lightgun reload hack, report trigger as being pressed no matter what */ + if(retro_code == RETRO_DEVICE_ID_LIGHTGUN_TRIGGER) + { + if(input_cb(port, RETRO_DEVICE_LIGHTGUN, 0, RETRO_DEVICE_ID_LIGHTGUN_RELOAD)) + return 1; /* lightgun reload hack, report trigger as being pressed no matter what */ + } + return input_cb(port, RETRO_DEVICE_LIGHTGUN, 0, retro_code); } - return input_cb(port, RETRO_DEVICE_LIGHTGUN, 0, retro_code); } /*** Use the cached input states ***/ From beeb0931f9c4828b1f280729aa22d3311f0826c0 Mon Sep 17 00:00:00 2001 From: "Mark W. Kidd" Date: Thu, 3 Jun 2021 18:07:00 -0400 Subject: [PATCH 03/28] remove obsolete line --- src/mame2003/mame2003.c | 1 - 1 file changed, 1 deletion(-) diff --git a/src/mame2003/mame2003.c b/src/mame2003/mame2003.c index d9e68025a..13d244a99 100644 --- a/src/mame2003/mame2003.c +++ b/src/mame2003/mame2003.c @@ -2328,7 +2328,6 @@ void osd_lightgun_read(int player, int *deltax, int *deltay) /* simulated lightgun reload hack */ if(input_cb(player, RETRO_DEVICE_LIGHTGUN, 0, RETRO_DEVICE_ID_LIGHTGUN_RELOAD)) { - retroJsState[player][OSD_LIGHTGUN_IS_TRIGGER] = true; *deltax = -128; *deltay = -128; return; From 0720a3f68f10b3e29d44c714ec4d9ce151bc9f92 Mon Sep 17 00:00:00 2001 From: "Mark W. Kidd" Date: Fri, 4 Jun 2021 18:15:07 -0400 Subject: [PATCH 04/28] logging --- src/mame2003/mame2003.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/mame2003/mame2003.c b/src/mame2003/mame2003.c index 13d244a99..07595e6f8 100644 --- a/src/mame2003/mame2003.c +++ b/src/mame2003/mame2003.c @@ -2136,7 +2136,7 @@ int osd_is_joy_pressed(int joycode) unsigned osd_code = decode_osd_joycode(joycode); unsigned retro_code = INT_MAX; - /*log_cb(RETRO_LOG_DEBUG, "MAME is polling joysticks -- joycode: %i player_number: %i osd_code: %i\n", joycode, player_number, osd_code); */ + /*log_cb(RETRO_LOG_DEBUG, "MAME is polling joysticks -- joycode: %i player_number: %i osd_code: %i\n", joycode, player_number, osd_code);*/ if (options.mouse_device == RETRO_DEVICE_LIGHTGUN) { @@ -2145,8 +2145,12 @@ int osd_is_joy_pressed(int joycode) { if(retro_code == RETRO_DEVICE_ID_LIGHTGUN_TRIGGER) { + log_cb(RETRO_LOG_DEBUG, "MAME is polling a trigger -- joycode: %i player_number: %i osd_code: %i\n", joycode, player_number, osd_code); if(input_cb(port, RETRO_DEVICE_LIGHTGUN, 0, RETRO_DEVICE_ID_LIGHTGUN_RELOAD)) + { + log_cb(RETRO_LOG_DEBUG, "Trigger true\n", joycode, player_number, osd_code); return 1; /* lightgun reload hack, report trigger as being pressed no matter what */ + } } return input_cb(port, RETRO_DEVICE_LIGHTGUN, 0, retro_code); } From 5fdb32d08a99b6fe910d1dcc6580cb82df1ef9ab Mon Sep 17 00:00:00 2001 From: "Mark W. Kidd" Date: Wed, 9 Jun 2021 18:07:21 -0400 Subject: [PATCH 05/28] precompiler attempt to accomodate retroarch android input bug --- Makefile | 13 +++++++++++-- src/mame2003/mame2003.c | 39 ++++++++++++++++++++++++++++++++++++--- 2 files changed, 47 insertions(+), 5 deletions(-) diff --git a/Makefile b/Makefile index f700d6f0b..ce56bc70d 100644 --- a/Makefile +++ b/Makefile @@ -708,6 +708,14 @@ else CFLAGS += -D__WIN32__ endif + +# All Android platforms ############################# +ifneq ($(findstring Android, $(platform)), ) + PLATCFLAGS += -D__ANDROID__ +else ifneq ($(findstring android, $(platform)), ) + PLATCFLAGS += -D__ANDROID__ +endif + # Architecture-specific flags ############################# ifeq ($(BIGENDIAN), 1) @@ -716,9 +724,10 @@ endif # End of architecture-specific flags ###################### -# Compiler flags for all platforms ############################# +# Compiler flags for all platforms ######################## -# explictly use -fsigned-char on all platforms to solve problems with code written/tested on x86 but used on ARM +# explictly use -fsigned-char on all platforms to solve problems +# with code written/tested on x86 but used on ARM # for example, audio on rtype leo is wrong on ARM without this flag ifeq (,$(findstring msvc,$(platform))) CFLAGS += -fsigned-char diff --git a/src/mame2003/mame2003.c b/src/mame2003/mame2003.c index 07595e6f8..848bb5f96 100644 --- a/src/mame2003/mame2003.c +++ b/src/mame2003/mame2003.c @@ -2137,18 +2137,21 @@ int osd_is_joy_pressed(int joycode) unsigned retro_code = INT_MAX; /*log_cb(RETRO_LOG_DEBUG, "MAME is polling joysticks -- joycode: %i player_number: %i osd_code: %i\n", joycode, player_number, osd_code);*/ - + if (options.mouse_device == RETRO_DEVICE_LIGHTGUN) { retro_code = get_retrogun_code(osd_code); if(retro_code != INT_MAX) { +#if defined(__ANDROID__) + if(port > 0) return 0; +#endif if(retro_code == RETRO_DEVICE_ID_LIGHTGUN_TRIGGER) { - log_cb(RETRO_LOG_DEBUG, "MAME is polling a trigger -- joycode: %i player_number: %i osd_code: %i\n", joycode, player_number, osd_code); + /*log_cb(RETRO_LOG_DEBUG, "MAME is polling a trigger -- joycode: %i player_number: %i osd_code: %i\n", joycode, player_number, osd_code);*/ if(input_cb(port, RETRO_DEVICE_LIGHTGUN, 0, RETRO_DEVICE_ID_LIGHTGUN_RELOAD)) { - log_cb(RETRO_LOG_DEBUG, "Trigger true\n", joycode, player_number, osd_code); + /*log_cb(RETRO_LOG_DEBUG, "Trigger true\n", joycode, player_number, osd_code);*/ return 1; /* lightgun reload hack, report trigger as being pressed no matter what */ } } @@ -2156,6 +2159,19 @@ int osd_is_joy_pressed(int joycode) } } + if (options.mouse_device == RETRO_DEVICE_MOUSE || options.mouse_device == RETRO_DEVICE_POINTER) + { + retro_code = get_retromouse_code(osd_code); + if(retro_code != INT_MAX) + { +#if defined(__ANDROID__) + if(port > 0) return 0; +#endif + + /*non-cached mouse and pointer input polling to be added here */ + } + } + /*** Use the cached input states ***/ return retroJsState[player_number-1][osd_code]; } @@ -2299,6 +2315,14 @@ void osd_joystick_end_calibration(void) { } */ void osd_trak_read(int player, int *deltax, int *deltay) { +#if defined(__ANDROID__) + if(player > 0) + { + *deltax = 0; + *deltay = 0; + return; + } +#endif *deltax = mouse_x[player]; *deltay = mouse_y[player]; } @@ -2329,6 +2353,15 @@ void osd_lightgun_read(int player, int *deltax, int *deltay) return; } +#if defined(__ANDROID__) + if(player > 0) + { + *deltax = 0; + *deltay = 0; + return; + } +#endif + /* simulated lightgun reload hack */ if(input_cb(player, RETRO_DEVICE_LIGHTGUN, 0, RETRO_DEVICE_ID_LIGHTGUN_RELOAD)) { From af39339a88e7f5dd6d8777eedcdc73b3ac133b2d Mon Sep 17 00:00:00 2001 From: "Mark W. Kidd" Date: Wed, 9 Jun 2021 20:46:03 -0400 Subject: [PATCH 06/28] fixup --- src/mame2003/mame2003.c | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/src/mame2003/mame2003.c b/src/mame2003/mame2003.c index 848bb5f96..82df92549 100644 --- a/src/mame2003/mame2003.c +++ b/src/mame2003/mame2003.c @@ -240,7 +240,12 @@ void retro_get_system_info(struct retro_system_info *info) #ifndef GIT_VERSION #define GIT_VERSION "" #endif + +#ifdef __ANDROID__ + info->library_version = "ANDROID TESTING"; +#else info->library_version = GIT_VERSION; +#endif info->valid_extensions = "zip"; info->need_fullpath = true; info->block_extract = true; @@ -2143,7 +2148,7 @@ int osd_is_joy_pressed(int joycode) retro_code = get_retrogun_code(osd_code); if(retro_code != INT_MAX) { -#if defined(__ANDROID__) +#ifdef __ANDROID__ if(port > 0) return 0; #endif if(retro_code == RETRO_DEVICE_ID_LIGHTGUN_TRIGGER) @@ -2164,7 +2169,8 @@ int osd_is_joy_pressed(int joycode) retro_code = get_retromouse_code(osd_code); if(retro_code != INT_MAX) { -#if defined(__ANDROID__) + +#ifdef __ANDROID__ if(port > 0) return 0; #endif @@ -2315,7 +2321,7 @@ void osd_joystick_end_calibration(void) { } */ void osd_trak_read(int player, int *deltax, int *deltay) { -#if defined(__ANDROID__) +#ifdef __ANDROID__ if(player > 0) { *deltax = 0; @@ -2353,7 +2359,7 @@ void osd_lightgun_read(int player, int *deltax, int *deltay) return; } -#if defined(__ANDROID__) +#ifdef __ANDROID__ if(player > 0) { *deltax = 0; From fd7c796a37c0a4b426b131c3eb25175ef140bc5f Mon Sep 17 00:00:00 2001 From: "Mark W. Kidd" Date: Wed, 9 Jun 2021 21:54:06 -0400 Subject: [PATCH 07/28] remove temporary debugging info --- src/mame2003/mame2003.c | 5 ----- 1 file changed, 5 deletions(-) diff --git a/src/mame2003/mame2003.c b/src/mame2003/mame2003.c index 82df92549..483788795 100644 --- a/src/mame2003/mame2003.c +++ b/src/mame2003/mame2003.c @@ -240,12 +240,7 @@ void retro_get_system_info(struct retro_system_info *info) #ifndef GIT_VERSION #define GIT_VERSION "" #endif - -#ifdef __ANDROID__ - info->library_version = "ANDROID TESTING"; -#else info->library_version = GIT_VERSION; -#endif info->valid_extensions = "zip"; info->need_fullpath = true; info->block_extract = true; From be1b720ee768ac7861e54ca73c0aad4e000935ba Mon Sep 17 00:00:00 2001 From: mahoneyt944 <49591133+mahoneyt944@users.noreply.github.com> Date: Thu, 10 Jun 2021 01:26:20 -0400 Subject: [PATCH 08/28] osd_xy_device_read --- src/inptport.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/inptport.c b/src/inptport.c index a8bd808bb..0fa3572ef 100644 --- a/src/inptport.c +++ b/src/inptport.c @@ -1491,10 +1491,12 @@ profiler_mark(PROFILER_INPUT); osd_analogjoy_read (i, analog_current_axis[i], analogjoy_input[i]); /* update mouse/trackball position */ - osd_trak_read (i, &(mouse_delta_axis[i])[X_AXIS], &(mouse_delta_axis[i])[Y_AXIS]); + if(options.mouse_device == MOUSE || options.mouse_device == POINTER) + osd_xy_device_read (i, &(mouse_delta_axis[i])[X_AXIS], &(mouse_delta_axis[i])[Y_AXIS]); /* update lightgun position, if any */ - osd_lightgun_read (i, &(lightgun_delta_axis[i])[X_AXIS], &(lightgun_delta_axis[i])[Y_AXIS]); + else if(options.mouse_device == LIGHTGUN) + osd_xy_device_read (i, &(lightgun_delta_axis[i])[X_AXIS], &(lightgun_delta_axis[i])[Y_AXIS]); } for (i = 0;i < MAX_INPUT_PORTS;i++) From bebc901083124f1fd65633fb98c369f2feef1417 Mon Sep 17 00:00:00 2001 From: mahoneyt944 <49591133+mahoneyt944@users.noreply.github.com> Date: Thu, 10 Jun 2021 01:34:31 -0400 Subject: [PATCH 09/28] Update mame2003.h --- src/mame2003/mame2003.h | 31 +++---------------------------- 1 file changed, 3 insertions(+), 28 deletions(-) diff --git a/src/mame2003/mame2003.h b/src/mame2003/mame2003.h index 01b087f85..9b87f3821 100644 --- a/src/mame2003/mame2003.h +++ b/src/mame2003/mame2003.h @@ -397,37 +397,12 @@ void osd_joystick_end_calibration(void); /****************************************************************************** - Trackball, Spinner, Mouse + Trackball, Spinner, Mouse, Pointer, Lightgun ******************************************************************************/ -/* osd_track_read expects the OSD to return the relative change in mouse or trackball - * coordinates since the last reading. If the user has set their mouse type to - * `pointer` in the core options, its coordinates are translated from absolute to - * relative coordinates before being stored in `mouse_x[]`. - */ -void osd_trak_read(int player, int *deltax, int *deltay); - - -/****************************************************************************** - - Lightgun - -******************************************************************************/ - -/****************************************************************************** - The osd_lightgun_read call should return the delta from the middle of the screen - when the gun is fired (not the absolute pixel value), and 0 when the gun is - inactive. - - When osd_lightgun_read returns 0, control passes through to the analog joystick, - and mouse, in that order. In other words, when osd_lightgun_read returns a - value it overrides both mouse & analog joystick. - - The value returned by the OSD layer should be -128 to 128, same as analog - joysticks. (yes, 128, not 127). -*******************************************************************************/ -void osd_lightgun_read(int player, int *deltax, int *deltay); +/* TO DO: notes */ +void osd_xy_device_read(int player, int *deltax, int *deltay); /****************************************************************************** From a645f71f4cfc9e41505a414ccc70afc2512f04f5 Mon Sep 17 00:00:00 2001 From: mahoneyt944 <49591133+mahoneyt944@users.noreply.github.com> Date: Thu, 10 Jun 2021 01:45:44 -0400 Subject: [PATCH 10/28] Update mame2003.c --- src/mame2003/mame2003.c | 67 ++++++++++++++--------------------------- 1 file changed, 22 insertions(+), 45 deletions(-) diff --git a/src/mame2003/mame2003.c b/src/mame2003/mame2003.c index 483788795..b9bdb2f02 100644 --- a/src/mame2003/mame2003.c +++ b/src/mame2003/mame2003.c @@ -2305,16 +2305,11 @@ void osd_joystick_end_calibration(void) { } /****************************************************************************** - Trackball, Spinner, Mouse + Trackball, Spinner, Mouse, Pointer, Lightgun ******************************************************************************/ -/* osd_track_read expects the OSD to return the relative change in mouse or trackball - * coordinates since the last reading. If the user has set their mouse type to - * `pointer` in the core options, its coordinates are translated from absolute to - * relative coordinates before being stored in `mouse_x[]`. - */ -void osd_trak_read(int player, int *deltax, int *deltay) +void osd_xy_device_read(int player, int *deltax, int *deltay) { #ifdef __ANDROID__ if(player > 0) @@ -2324,55 +2319,37 @@ void osd_trak_read(int player, int *deltax, int *deltay) return; } #endif - *deltax = mouse_x[player]; - *deltay = mouse_y[player]; -} - - - -/****************************************************************************** - - Lightgun -******************************************************************************/ + if (options.mouse_device == RETRO_DEVICE_POINTER) + { + *deltax = mouse_x[player]; /* temp use of cache */ + *deltay = mouse_y[player]; + } -/****************************************************************************** - * osd_lightgun_read should return the delta from the middle of the screen - * when the gun is fired and 0 when the gun is inactive. The value returned - * by the OSD layer should be -128 to 128, same as analog joysticks. - * - * When the OSD lightgun returns 0, control passes through to the analog joystick, - * and mouse, in that order. In other words, when the OSD lightgun returns a - * value it overrides both mouse & analog joystick. -*******************************************************************************/ -void osd_lightgun_read(int player, int *deltax, int *deltay) -{ - if (options.mouse_device != RETRO_DEVICE_LIGHTGUN) + else if (options.mouse_device == RETRO_DEVICE_MOUSE) { - *deltax = 0; - *deltay = 0; - return; + *deltax = input_cb(player, RETRO_DEVICE_MOUSE, 0, RETRO_DEVICE_ID_MOUSE_X); + *deltay = input_cb(player, RETRO_DEVICE_MOUSE, 0, RETRO_DEVICE_ID_MOUSE_Y); } -#ifdef __ANDROID__ - if(player > 0) + else if (options.mouse_device == RETRO_DEVICE_LIGHTGUN) + { + /* simulated lightgun reload hack */ + if(input_cb(player, RETRO_DEVICE_LIGHTGUN, 0, RETRO_DEVICE_ID_LIGHTGUN_RELOAD)) { - *deltax = 0; - *deltay = 0; + *deltax = -128; + *deltay = -128; return; } -#endif + *deltax = rescale_analog(input_cb(player, RETRO_DEVICE_LIGHTGUN, 0, RETRO_DEVICE_ID_LIGHTGUN_SCREEN_X)); + *deltay = rescale_analog(input_cb(player, RETRO_DEVICE_LIGHTGUN, 0, RETRO_DEVICE_ID_LIGHTGUN_SCREEN_Y)); + } - /* simulated lightgun reload hack */ - if(input_cb(player, RETRO_DEVICE_LIGHTGUN, 0, RETRO_DEVICE_ID_LIGHTGUN_RELOAD)) + else /* RETRO_DEVICE_NONE */ { - *deltax = -128; - *deltay = -128; - return; + *deltax = 0; + *deltay = 0; } - - *deltax = rescale_analog(input_cb(player, RETRO_DEVICE_LIGHTGUN, 0, RETRO_DEVICE_ID_LIGHTGUN_SCREEN_X)); - *deltay = rescale_analog(input_cb(player, RETRO_DEVICE_LIGHTGUN, 0, RETRO_DEVICE_ID_LIGHTGUN_SCREEN_Y)); } /****************************************************************************** From 66ac43f79fe7a8d2a1bba701b36db45446d10983 Mon Sep 17 00:00:00 2001 From: mahoneyt944 <49591133+mahoneyt944@users.noreply.github.com> Date: Thu, 10 Jun 2021 01:53:38 -0400 Subject: [PATCH 11/28] Oops --- src/inptport.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/inptport.c b/src/inptport.c index 0fa3572ef..8c9de6f06 100644 --- a/src/inptport.c +++ b/src/inptport.c @@ -1491,11 +1491,11 @@ profiler_mark(PROFILER_INPUT); osd_analogjoy_read (i, analog_current_axis[i], analogjoy_input[i]); /* update mouse/trackball position */ - if(options.mouse_device == MOUSE || options.mouse_device == POINTER) + if(options.mouse_device == RETRO_DEVICE_MOUSE || options.mouse_device == RETRO_DEVICE_POINTER) osd_xy_device_read (i, &(mouse_delta_axis[i])[X_AXIS], &(mouse_delta_axis[i])[Y_AXIS]); /* update lightgun position, if any */ - else if(options.mouse_device == LIGHTGUN) + else if(options.mouse_device == RETRO_DEVICE_LIGHTGUN) osd_xy_device_read (i, &(lightgun_delta_axis[i])[X_AXIS], &(lightgun_delta_axis[i])[Y_AXIS]); } From 27811250fc0b61ab780499584533a9d3abd65310 Mon Sep 17 00:00:00 2001 From: mahoneyt944 <49591133+mahoneyt944@users.noreply.github.com> Date: Thu, 10 Jun 2021 02:00:47 -0400 Subject: [PATCH 12/28] Pointer only for now --- src/mame2003/mame2003.c | 12 +----------- 1 file changed, 1 insertion(+), 11 deletions(-) diff --git a/src/mame2003/mame2003.c b/src/mame2003/mame2003.c index b9bdb2f02..3c3bd781f 100644 --- a/src/mame2003/mame2003.c +++ b/src/mame2003/mame2003.c @@ -1285,17 +1285,7 @@ void retro_run (void) /* Only poll X-Y device if selected by its core option */ if(options.mouse_device != RETRO_DEVICE_NONE) { - if(options.mouse_device == RETRO_DEVICE_MOUSE) - { - retroJsState[port][OSD_MOUSE_BUTTON_1] = input_cb(port, RETRO_DEVICE_MOUSE, 0, RETRO_DEVICE_ID_MOUSE_LEFT); - retroJsState[port][OSD_MOUSE_BUTTON_2] = input_cb(port, RETRO_DEVICE_MOUSE, 0, RETRO_DEVICE_ID_MOUSE_RIGHT); - retroJsState[port][OSD_MOUSE_BUTTON_3] = input_cb(port, RETRO_DEVICE_MOUSE, 0, RETRO_DEVICE_ID_MOUSE_MIDDLE); - retroJsState[port][OSD_MOUSE_BUTTON_4] = input_cb(port, RETRO_DEVICE_MOUSE, 0, RETRO_DEVICE_ID_MOUSE_BUTTON_4); - retroJsState[port][OSD_MOUSE_BUTTON_5] = input_cb(port, RETRO_DEVICE_MOUSE, 0, RETRO_DEVICE_ID_MOUSE_BUTTON_5); - mouse_x[port] = input_cb(port, RETRO_DEVICE_MOUSE, 0, RETRO_DEVICE_ID_MOUSE_X); - mouse_y[port] = input_cb(port, RETRO_DEVICE_MOUSE, 0, RETRO_DEVICE_ID_MOUSE_Y); - } - else if (options.mouse_device == RETRO_DEVICE_POINTER) + if (options.mouse_device == RETRO_DEVICE_POINTER) { bool pointer_pressed = input_cb(port, RETRO_DEVICE_POINTER, 0, RETRO_DEVICE_ID_POINTER_PRESSED); retroJsState[port][OSD_MOUSE_BUTTON_1] = pointer_pressed; From 524850f4b7ee707d0801b469e782a257b34eea96 Mon Sep 17 00:00:00 2001 From: mahoneyt944 <49591133+mahoneyt944@users.noreply.github.com> Date: Thu, 10 Jun 2021 05:54:31 -0400 Subject: [PATCH 13/28] Pointer polling --- src/mame2003/mame2003.c | 23 +++-------------------- 1 file changed, 3 insertions(+), 20 deletions(-) diff --git a/src/mame2003/mame2003.c b/src/mame2003/mame2003.c index 3c3bd781f..6c8125225 100644 --- a/src/mame2003/mame2003.c +++ b/src/mame2003/mame2003.c @@ -50,10 +50,6 @@ int retroKeyState[RETROK_LAST] = {0}; /* initialise to ze /* data structures for joystick/retropad state */ int retroJsState[MAX_PLAYER_COUNT][OSD_INPUT_CODES_PER_PLAYER]= {{0}}; /* initialise to zero, polled in retro_run */ -/* data structures to store trackball/spinner/mouse coordinates */ -int16_t mouse_x[MAX_PLAYER_COUNT]= {0}; -int16_t mouse_y[MAX_PLAYER_COUNT]= {0}; - /* temporary variables to convert absolute coordinates polled by pointer fallback, which is used * as a fallback for libretro frontends without DEVICE_RETRO_MOUSE implementations */ int16_t prev_pointer_x; @@ -1235,8 +1231,6 @@ void retro_run (void) analogjoy[port][1] = 0; analogjoy[port][2] = 0; analogjoy[port][3] = 0; - mouse_x[port] = 0; - mouse_y[port] = 0; } for(port = 0; port < MAX_PLAYER_COUNT; port++) @@ -1281,18 +1275,6 @@ void retro_run (void) retroJsState[port][OSD_ANALOG_RIGHT_POSITIVE_X] = (analogjoy[port][2] > INPUT_BUTTON_AXIS_THRESHOLD) ? analogjoy[port][2] : 0; retroJsState[port][OSD_ANALOG_RIGHT_NEGATIVE_Y] = (analogjoy[port][3] < -INPUT_BUTTON_AXIS_THRESHOLD) ? analogjoy[port][3] : 0; retroJsState[port][OSD_ANALOG_RIGHT_POSITIVE_Y] = (analogjoy[port][3] > INPUT_BUTTON_AXIS_THRESHOLD) ? analogjoy[port][3] : 0; - - /* Only poll X-Y device if selected by its core option */ - if(options.mouse_device != RETRO_DEVICE_NONE) - { - if (options.mouse_device == RETRO_DEVICE_POINTER) - { - bool pointer_pressed = input_cb(port, RETRO_DEVICE_POINTER, 0, RETRO_DEVICE_ID_POINTER_PRESSED); - retroJsState[port][OSD_MOUSE_BUTTON_1] = pointer_pressed; - mouse_x[port] = pointer_pressed ? get_pointer_delta(input_cb(port, RETRO_DEVICE_POINTER, 0, RETRO_DEVICE_ID_POINTER_X), &prev_pointer_x) : 0; - mouse_y[port] = pointer_pressed ? get_pointer_delta(input_cb(port, RETRO_DEVICE_POINTER, 0, RETRO_DEVICE_ID_POINTER_Y), &prev_pointer_y) : 0; - } - } } /* poll libretro keyboard abstraction */ @@ -2312,8 +2294,9 @@ void osd_xy_device_read(int player, int *deltax, int *deltay) if (options.mouse_device == RETRO_DEVICE_POINTER) { - *deltax = mouse_x[player]; /* temp use of cache */ - *deltay = mouse_y[player]; + bool pointer_pressed = input_cb(player, RETRO_DEVICE_POINTER, 0, RETRO_DEVICE_ID_POINTER_PRESSED); + *deltax = pointer_pressed ? get_pointer_delta(input_cb(player, RETRO_DEVICE_POINTER, 0, RETRO_DEVICE_ID_POINTER_X), &prev_pointer_x) : 0; + *deltay = pointer_pressed ? get_pointer_delta(input_cb(player, RETRO_DEVICE_POINTER, 0, RETRO_DEVICE_ID_POINTER_Y), &prev_pointer_y) : 0; } else if (options.mouse_device == RETRO_DEVICE_MOUSE) From ae48e93c9440dad89c05a74d4e313c32e230faea Mon Sep 17 00:00:00 2001 From: mahoneyt944 <49591133+mahoneyt944@users.noreply.github.com> Date: Thu, 10 Jun 2021 06:28:34 -0400 Subject: [PATCH 14/28] osd_is_joy_pressed --- src/mame2003/mame2003.c | 39 +++++++++++++++++++++++++-------------- 1 file changed, 25 insertions(+), 14 deletions(-) diff --git a/src/mame2003/mame2003.c b/src/mame2003/mame2003.c index 6c8125225..9ae3301d0 100644 --- a/src/mame2003/mame2003.c +++ b/src/mame2003/mame2003.c @@ -2110,7 +2110,31 @@ int osd_is_joy_pressed(int joycode) /*log_cb(RETRO_LOG_DEBUG, "MAME is polling joysticks -- joycode: %i player_number: %i osd_code: %i\n", joycode, player_number, osd_code);*/ - if (options.mouse_device == RETRO_DEVICE_LIGHTGUN) + if (options.mouse_device == RETRO_DEVICE_POINTER) + { + retro_code = get_retromouse_code(osd_code); + if(retro_code != INT_MAX) + { +#ifdef __ANDROID__ + if(port > 0) return 0; +#endif + return input_cb(player, RETRO_DEVICE_POINTER, 0, RETRO_DEVICE_ID_POINTER_PRESSED); + } + } + + else if (options.mouse_device == RETRO_DEVICE_MOUSE) + { + retro_code = get_retromouse_code(osd_code); + if(retro_code != INT_MAX) + { +#ifdef __ANDROID__ + if(port > 0) return 0; +#endif + return input_cb(player, RETRO_DEVICE_MOUSE, 0, retro_code); + } + } + + else if (options.mouse_device == RETRO_DEVICE_LIGHTGUN) { retro_code = get_retrogun_code(osd_code); if(retro_code != INT_MAX) @@ -2131,19 +2155,6 @@ int osd_is_joy_pressed(int joycode) } } - if (options.mouse_device == RETRO_DEVICE_MOUSE || options.mouse_device == RETRO_DEVICE_POINTER) - { - retro_code = get_retromouse_code(osd_code); - if(retro_code != INT_MAX) - { - -#ifdef __ANDROID__ - if(port > 0) return 0; -#endif - - /*non-cached mouse and pointer input polling to be added here */ - } - } /*** Use the cached input states ***/ return retroJsState[player_number-1][osd_code]; From b3bd8e44c90bf4032334f67b163889e67bf20107 Mon Sep 17 00:00:00 2001 From: mahoneyt944 <49591133+mahoneyt944@users.noreply.github.com> Date: Thu, 10 Jun 2021 06:33:42 -0400 Subject: [PATCH 15/28] port --- src/mame2003/mame2003.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/mame2003/mame2003.c b/src/mame2003/mame2003.c index 9ae3301d0..5210d8591 100644 --- a/src/mame2003/mame2003.c +++ b/src/mame2003/mame2003.c @@ -2118,7 +2118,7 @@ int osd_is_joy_pressed(int joycode) #ifdef __ANDROID__ if(port > 0) return 0; #endif - return input_cb(player, RETRO_DEVICE_POINTER, 0, RETRO_DEVICE_ID_POINTER_PRESSED); + return input_cb(port, RETRO_DEVICE_POINTER, 0, RETRO_DEVICE_ID_POINTER_PRESSED); } } @@ -2130,7 +2130,7 @@ int osd_is_joy_pressed(int joycode) #ifdef __ANDROID__ if(port > 0) return 0; #endif - return input_cb(player, RETRO_DEVICE_MOUSE, 0, retro_code); + return input_cb(port, RETRO_DEVICE_MOUSE, 0, retro_code); } } From f90f025634dc68b1ccef594f35a532b21ab4c024 Mon Sep 17 00:00:00 2001 From: mahoneyt944 <49591133+mahoneyt944@users.noreply.github.com> Date: Thu, 10 Jun 2021 07:52:35 -0400 Subject: [PATCH 16/28] Port --- src/mame2003/mame2003.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/mame2003/mame2003.c b/src/mame2003/mame2003.c index 5210d8591..e427a741a 100644 --- a/src/mame2003/mame2003.c +++ b/src/mame2003/mame2003.c @@ -2157,7 +2157,7 @@ int osd_is_joy_pressed(int joycode) /*** Use the cached input states ***/ - return retroJsState[player_number-1][osd_code]; + return retroJsState[port][osd_code]; } From 6790df47e1734d2e8368b07d091c3fc7f537d8e1 Mon Sep 17 00:00:00 2001 From: mahoneyt944 <49591133+mahoneyt944@users.noreply.github.com> Date: Thu, 10 Jun 2021 08:32:32 -0400 Subject: [PATCH 17/28] Pointer can only use left mouse click. --- src/mame2003/mame2003.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/mame2003/mame2003.c b/src/mame2003/mame2003.c index e427a741a..6ff6c8cdd 100644 --- a/src/mame2003/mame2003.c +++ b/src/mame2003/mame2003.c @@ -2113,7 +2113,7 @@ int osd_is_joy_pressed(int joycode) if (options.mouse_device == RETRO_DEVICE_POINTER) { retro_code = get_retromouse_code(osd_code); - if(retro_code != INT_MAX) + if(retro_code == RETRO_DEVICE_ID_MOUSE_LEFT) { #ifdef __ANDROID__ if(port > 0) return 0; From 1524c85f5ee69a44bdc9266167520bcfbd789b15 Mon Sep 17 00:00:00 2001 From: mahoneyt944 <49591133+mahoneyt944@users.noreply.github.com> Date: Thu, 10 Jun 2021 09:13:44 -0400 Subject: [PATCH 18/28] Standard retropad --- src/mame2003/mame2003.c | 25 +++++++------------------ 1 file changed, 7 insertions(+), 18 deletions(-) diff --git a/src/mame2003/mame2003.c b/src/mame2003/mame2003.c index 6ff6c8cdd..d1b204191 100644 --- a/src/mame2003/mame2003.c +++ b/src/mame2003/mame2003.c @@ -1240,24 +1240,6 @@ void retro_run (void) if(device_type == RETRO_DEVICE_NONE) continue; - /* Standard retropad */ - retroJsState[port][OSD_JOYPAD_B] = input_cb(port, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_B); - retroJsState[port][OSD_JOYPAD_Y] = input_cb(port, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_Y); - retroJsState[port][OSD_JOYPAD_SELECT] = input_cb(port, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_SELECT); - retroJsState[port][OSD_JOYPAD_START] = input_cb(port, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_START); - retroJsState[port][OSD_JOYPAD_UP] = input_cb(port, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_UP); - retroJsState[port][OSD_JOYPAD_DOWN] = input_cb(port, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_DOWN); - retroJsState[port][OSD_JOYPAD_LEFT] = input_cb(port, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_LEFT); - retroJsState[port][OSD_JOYPAD_RIGHT] = input_cb(port, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_RIGHT); - retroJsState[port][OSD_JOYPAD_A] = input_cb(port, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_A); - retroJsState[port][OSD_JOYPAD_X] = input_cb(port, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_X); - retroJsState[port][OSD_JOYPAD_L] = input_cb(port, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_L); - retroJsState[port][OSD_JOYPAD_R] = input_cb(port, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_R); - retroJsState[port][OSD_JOYPAD_L2] = input_cb(port, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_L2); - retroJsState[port][OSD_JOYPAD_R2] = input_cb(port, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_R2); - retroJsState[port][OSD_JOYPAD_L3] = input_cb(port, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_L3); - retroJsState[port][OSD_JOYPAD_R3] = input_cb(port, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_R3); - /* Analog joystick - read as analog axis and rescale for MAME value range */ analogjoy[port][0] = analog_deadzone_rescale( input_cb(port, RETRO_DEVICE_ANALOG, RETRO_DEVICE_INDEX_ANALOG_LEFT, RETRO_DEVICE_ID_ANALOG_X) ); analogjoy[port][1] = analog_deadzone_rescale( input_cb(port, RETRO_DEVICE_ANALOG, RETRO_DEVICE_INDEX_ANALOG_LEFT, RETRO_DEVICE_ID_ANALOG_Y) ); @@ -2155,6 +2137,13 @@ int osd_is_joy_pressed(int joycode) } } + /* Standard retropad */ + retro_code = get_retropad_code(osd_code); + if (retro_code != INT_MAX) + { + return input_cb(port, RETRO_DEVICE_JOYPAD, 0, retro_code); + } + /*** Use the cached input states ***/ return retroJsState[port][osd_code]; From c4cbb1c00a2a649bc89788f16008a5388b6818e0 Mon Sep 17 00:00:00 2001 From: mahoneyt944 <49591133+mahoneyt944@users.noreply.github.com> Date: Thu, 10 Jun 2021 10:08:44 -0400 Subject: [PATCH 19/28] Revert --- src/mame2003/mame2003.c | 25 ++++++++++++++++++------- 1 file changed, 18 insertions(+), 7 deletions(-) diff --git a/src/mame2003/mame2003.c b/src/mame2003/mame2003.c index d1b204191..6ff6c8cdd 100644 --- a/src/mame2003/mame2003.c +++ b/src/mame2003/mame2003.c @@ -1240,6 +1240,24 @@ void retro_run (void) if(device_type == RETRO_DEVICE_NONE) continue; + /* Standard retropad */ + retroJsState[port][OSD_JOYPAD_B] = input_cb(port, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_B); + retroJsState[port][OSD_JOYPAD_Y] = input_cb(port, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_Y); + retroJsState[port][OSD_JOYPAD_SELECT] = input_cb(port, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_SELECT); + retroJsState[port][OSD_JOYPAD_START] = input_cb(port, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_START); + retroJsState[port][OSD_JOYPAD_UP] = input_cb(port, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_UP); + retroJsState[port][OSD_JOYPAD_DOWN] = input_cb(port, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_DOWN); + retroJsState[port][OSD_JOYPAD_LEFT] = input_cb(port, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_LEFT); + retroJsState[port][OSD_JOYPAD_RIGHT] = input_cb(port, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_RIGHT); + retroJsState[port][OSD_JOYPAD_A] = input_cb(port, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_A); + retroJsState[port][OSD_JOYPAD_X] = input_cb(port, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_X); + retroJsState[port][OSD_JOYPAD_L] = input_cb(port, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_L); + retroJsState[port][OSD_JOYPAD_R] = input_cb(port, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_R); + retroJsState[port][OSD_JOYPAD_L2] = input_cb(port, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_L2); + retroJsState[port][OSD_JOYPAD_R2] = input_cb(port, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_R2); + retroJsState[port][OSD_JOYPAD_L3] = input_cb(port, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_L3); + retroJsState[port][OSD_JOYPAD_R3] = input_cb(port, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_R3); + /* Analog joystick - read as analog axis and rescale for MAME value range */ analogjoy[port][0] = analog_deadzone_rescale( input_cb(port, RETRO_DEVICE_ANALOG, RETRO_DEVICE_INDEX_ANALOG_LEFT, RETRO_DEVICE_ID_ANALOG_X) ); analogjoy[port][1] = analog_deadzone_rescale( input_cb(port, RETRO_DEVICE_ANALOG, RETRO_DEVICE_INDEX_ANALOG_LEFT, RETRO_DEVICE_ID_ANALOG_Y) ); @@ -2137,13 +2155,6 @@ int osd_is_joy_pressed(int joycode) } } - /* Standard retropad */ - retro_code = get_retropad_code(osd_code); - if (retro_code != INT_MAX) - { - return input_cb(port, RETRO_DEVICE_JOYPAD, 0, retro_code); - } - /*** Use the cached input states ***/ return retroJsState[port][osd_code]; From 2657e28af4d05a75ad0cc10b769d0c8772223b26 Mon Sep 17 00:00:00 2001 From: mahoneyt944 <49591133+mahoneyt944@users.noreply.github.com> Date: Thu, 10 Jun 2021 11:44:02 -0400 Subject: [PATCH 20/28] Star --- src/mame2003/mame2003.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/mame2003/mame2003.h b/src/mame2003/mame2003.h index 9b87f3821..07e1f1d19 100644 --- a/src/mame2003/mame2003.h +++ b/src/mame2003/mame2003.h @@ -401,7 +401,7 @@ void osd_joystick_end_calibration(void); ******************************************************************************/ -/* TO DO: notes */ +/*** TO DO: notes ***/ void osd_xy_device_read(int player, int *deltax, int *deltay); From 25a3ed900fb4f0b09b1cc52f1d6d372bc4bbdd36 Mon Sep 17 00:00:00 2001 From: mahoneyt944 <49591133+mahoneyt944@users.noreply.github.com> Date: Thu, 10 Jun 2021 16:48:59 -0400 Subject: [PATCH 21/28] Standard pad take 2 --- src/mame2003/mame2003.c | 27 ++++++++------------------- 1 file changed, 8 insertions(+), 19 deletions(-) diff --git a/src/mame2003/mame2003.c b/src/mame2003/mame2003.c index 6ff6c8cdd..14d23dcf8 100644 --- a/src/mame2003/mame2003.c +++ b/src/mame2003/mame2003.c @@ -1207,12 +1207,13 @@ void retro_run (void) int port = 0; const struct KeyboardInfo *thisInput; bool updated = false; + poll_cb(); + if (running == 0) /* first time through the loop */ { running = 1; log_cb(RETRO_LOG_DEBUG, LOGPRE "Entering retro_run() for the first time.\n"); } - poll_cb(); if (environ_cb(RETRO_ENVIRONMENT_GET_VARIABLE_UPDATE, &updated) && updated) update_variables(false); @@ -1240,24 +1241,6 @@ void retro_run (void) if(device_type == RETRO_DEVICE_NONE) continue; - /* Standard retropad */ - retroJsState[port][OSD_JOYPAD_B] = input_cb(port, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_B); - retroJsState[port][OSD_JOYPAD_Y] = input_cb(port, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_Y); - retroJsState[port][OSD_JOYPAD_SELECT] = input_cb(port, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_SELECT); - retroJsState[port][OSD_JOYPAD_START] = input_cb(port, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_START); - retroJsState[port][OSD_JOYPAD_UP] = input_cb(port, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_UP); - retroJsState[port][OSD_JOYPAD_DOWN] = input_cb(port, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_DOWN); - retroJsState[port][OSD_JOYPAD_LEFT] = input_cb(port, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_LEFT); - retroJsState[port][OSD_JOYPAD_RIGHT] = input_cb(port, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_RIGHT); - retroJsState[port][OSD_JOYPAD_A] = input_cb(port, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_A); - retroJsState[port][OSD_JOYPAD_X] = input_cb(port, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_X); - retroJsState[port][OSD_JOYPAD_L] = input_cb(port, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_L); - retroJsState[port][OSD_JOYPAD_R] = input_cb(port, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_R); - retroJsState[port][OSD_JOYPAD_L2] = input_cb(port, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_L2); - retroJsState[port][OSD_JOYPAD_R2] = input_cb(port, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_R2); - retroJsState[port][OSD_JOYPAD_L3] = input_cb(port, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_L3); - retroJsState[port][OSD_JOYPAD_R3] = input_cb(port, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_R3); - /* Analog joystick - read as analog axis and rescale for MAME value range */ analogjoy[port][0] = analog_deadzone_rescale( input_cb(port, RETRO_DEVICE_ANALOG, RETRO_DEVICE_INDEX_ANALOG_LEFT, RETRO_DEVICE_ID_ANALOG_X) ); analogjoy[port][1] = analog_deadzone_rescale( input_cb(port, RETRO_DEVICE_ANALOG, RETRO_DEVICE_INDEX_ANALOG_LEFT, RETRO_DEVICE_ID_ANALOG_Y) ); @@ -2102,6 +2085,7 @@ const struct JoystickInfo *osd_get_joy_list(void) int osd_is_joy_pressed(int joycode) { if (options.input_interface == RETRO_DEVICE_KEYBOARD) return 0; /* disregard joystick input */ + if (!running) return 0; /* polling must be completed in retro_run */ unsigned player_number = calc_player_number(joycode); unsigned port = player_number - 1; @@ -2155,6 +2139,11 @@ int osd_is_joy_pressed(int joycode) } } + /* Standard retropad */ + retro_code = get_retropad_code(osd_code); + if (retro_code != INT_MAX) + return = input_cb(port, RETRO_DEVICE_JOYPAD, 0, retro_code); + /*** Use the cached input states ***/ return retroJsState[port][osd_code]; From ef0e49c78e47ffbfc9b5c98938075ef8917c8a39 Mon Sep 17 00:00:00 2001 From: mahoneyt944 <49591133+mahoneyt944@users.noreply.github.com> Date: Thu, 10 Jun 2021 16:51:51 -0400 Subject: [PATCH 22/28] Fix --- src/mame2003/mame2003.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/mame2003/mame2003.c b/src/mame2003/mame2003.c index 14d23dcf8..c99133ee3 100644 --- a/src/mame2003/mame2003.c +++ b/src/mame2003/mame2003.c @@ -2142,7 +2142,7 @@ int osd_is_joy_pressed(int joycode) /* Standard retropad */ retro_code = get_retropad_code(osd_code); if (retro_code != INT_MAX) - return = input_cb(port, RETRO_DEVICE_JOYPAD, 0, retro_code); + return input_cb(port, RETRO_DEVICE_JOYPAD, 0, retro_code); /*** Use the cached input states ***/ From 5b451c0f136a4974cd3cc2c85f2d52c99964b03a Mon Sep 17 00:00:00 2001 From: mahoneyt944 <49591133+mahoneyt944@users.noreply.github.com> Date: Thu, 10 Jun 2021 19:00:05 -0400 Subject: [PATCH 23/28] Prioritize standard retropad first --- src/mame2003/mame2003.c | 31 ++++++++++++------------------- 1 file changed, 12 insertions(+), 19 deletions(-) diff --git a/src/mame2003/mame2003.c b/src/mame2003/mame2003.c index c99133ee3..841f8c061 100644 --- a/src/mame2003/mame2003.c +++ b/src/mame2003/mame2003.c @@ -2094,19 +2094,14 @@ int osd_is_joy_pressed(int joycode) /*log_cb(RETRO_LOG_DEBUG, "MAME is polling joysticks -- joycode: %i player_number: %i osd_code: %i\n", joycode, player_number, osd_code);*/ - if (options.mouse_device == RETRO_DEVICE_POINTER) - { - retro_code = get_retromouse_code(osd_code); - if(retro_code == RETRO_DEVICE_ID_MOUSE_LEFT) - { -#ifdef __ANDROID__ - if(port > 0) return 0; -#endif - return input_cb(port, RETRO_DEVICE_POINTER, 0, RETRO_DEVICE_ID_POINTER_PRESSED); - } - } - else if (options.mouse_device == RETRO_DEVICE_MOUSE) + /* standard retropad states */ + retro_code = get_retropad_code(osd_code); + if (retro_code != INT_MAX) + return input_cb(port, RETRO_DEVICE_JOYPAD, 0, retro_code); + + /* pointer, mouse, or lightgun states if selected by core option */ + if (options.mouse_device == RETRO_DEVICE_POINTER || options.mouse_device == RETRO_DEVICE_MOUSE) { retro_code = get_retromouse_code(osd_code); if(retro_code != INT_MAX) @@ -2114,7 +2109,10 @@ int osd_is_joy_pressed(int joycode) #ifdef __ANDROID__ if(port > 0) return 0; #endif - return input_cb(port, RETRO_DEVICE_MOUSE, 0, retro_code); + if(options.mouse_device == RETRO_DEVICE_MOUSE) + return input_cb(port, RETRO_DEVICE_MOUSE, 0, retro_code); + if (options.mouse_device == RETRO_DEVICE_POINTER && retro_code == RETRO_DEVICE_ID_MOUSE_LEFT) + return input_cb(port, RETRO_DEVICE_POINTER, 0, RETRO_DEVICE_ID_POINTER_PRESSED); } } @@ -2139,13 +2137,8 @@ int osd_is_joy_pressed(int joycode) } } - /* Standard retropad */ - retro_code = get_retropad_code(osd_code); - if (retro_code != INT_MAX) - return input_cb(port, RETRO_DEVICE_JOYPAD, 0, retro_code); - - /*** Use the cached input states ***/ + /* Use the cached input states */ return retroJsState[port][osd_code]; } From 748bd708e6c4bc0531464fe49f472afa3746982c Mon Sep 17 00:00:00 2001 From: mahoneyt944 <49591133+mahoneyt944@users.noreply.github.com> Date: Thu, 10 Jun 2021 19:11:30 -0400 Subject: [PATCH 24/28] Clean up --- src/mame2003/mame2003.c | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/src/mame2003/mame2003.c b/src/mame2003/mame2003.c index 841f8c061..71321ef35 100644 --- a/src/mame2003/mame2003.c +++ b/src/mame2003/mame2003.c @@ -2094,7 +2094,6 @@ int osd_is_joy_pressed(int joycode) /*log_cb(RETRO_LOG_DEBUG, "MAME is polling joysticks -- joycode: %i player_number: %i osd_code: %i\n", joycode, player_number, osd_code);*/ - /* standard retropad states */ retro_code = get_retropad_code(osd_code); if (retro_code != INT_MAX) @@ -2126,18 +2125,13 @@ int osd_is_joy_pressed(int joycode) #endif if(retro_code == RETRO_DEVICE_ID_LIGHTGUN_TRIGGER) { - /*log_cb(RETRO_LOG_DEBUG, "MAME is polling a trigger -- joycode: %i player_number: %i osd_code: %i\n", joycode, player_number, osd_code);*/ if(input_cb(port, RETRO_DEVICE_LIGHTGUN, 0, RETRO_DEVICE_ID_LIGHTGUN_RELOAD)) - { - /*log_cb(RETRO_LOG_DEBUG, "Trigger true\n", joycode, player_number, osd_code);*/ - return 1; /* lightgun reload hack, report trigger as being pressed no matter what */ - } + return 1; /* lightgun reload hack, report trigger as being pressed */ } return input_cb(port, RETRO_DEVICE_LIGHTGUN, 0, retro_code); } } - /* Use the cached input states */ return retroJsState[port][osd_code]; } From fa2abe6ae5babb00db539b16639c4f327a42087d Mon Sep 17 00:00:00 2001 From: mahoneyt944 <49591133+mahoneyt944@users.noreply.github.com> Date: Thu, 10 Jun 2021 19:24:59 -0400 Subject: [PATCH 25/28] Spacing --- src/mame2003/mame2003.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/mame2003/mame2003.c b/src/mame2003/mame2003.c index 71321ef35..3c1ba2455 100644 --- a/src/mame2003/mame2003.c +++ b/src/mame2003/mame2003.c @@ -2103,12 +2103,12 @@ int osd_is_joy_pressed(int joycode) if (options.mouse_device == RETRO_DEVICE_POINTER || options.mouse_device == RETRO_DEVICE_MOUSE) { retro_code = get_retromouse_code(osd_code); - if(retro_code != INT_MAX) + if (retro_code != INT_MAX) { #ifdef __ANDROID__ - if(port > 0) return 0; + if (port > 0) return 0; #endif - if(options.mouse_device == RETRO_DEVICE_MOUSE) + if (options.mouse_device == RETRO_DEVICE_MOUSE) return input_cb(port, RETRO_DEVICE_MOUSE, 0, retro_code); if (options.mouse_device == RETRO_DEVICE_POINTER && retro_code == RETRO_DEVICE_ID_MOUSE_LEFT) return input_cb(port, RETRO_DEVICE_POINTER, 0, RETRO_DEVICE_ID_POINTER_PRESSED); @@ -2118,14 +2118,14 @@ int osd_is_joy_pressed(int joycode) else if (options.mouse_device == RETRO_DEVICE_LIGHTGUN) { retro_code = get_retrogun_code(osd_code); - if(retro_code != INT_MAX) + if (retro_code != INT_MAX) { #ifdef __ANDROID__ - if(port > 0) return 0; + if (port > 0) return 0; #endif - if(retro_code == RETRO_DEVICE_ID_LIGHTGUN_TRIGGER) + if (retro_code == RETRO_DEVICE_ID_LIGHTGUN_TRIGGER) { - if(input_cb(port, RETRO_DEVICE_LIGHTGUN, 0, RETRO_DEVICE_ID_LIGHTGUN_RELOAD)) + if (input_cb(port, RETRO_DEVICE_LIGHTGUN, 0, RETRO_DEVICE_ID_LIGHTGUN_RELOAD)) return 1; /* lightgun reload hack, report trigger as being pressed */ } return input_cb(port, RETRO_DEVICE_LIGHTGUN, 0, retro_code); From 6d8f3c357cdeb156e7dfc7c4ec0bf62268ffc5a6 Mon Sep 17 00:00:00 2001 From: mahoneyt944 <49591133+mahoneyt944@users.noreply.github.com> Date: Fri, 11 Jun 2021 00:48:08 -0400 Subject: [PATCH 26/28] Key no cache --- src/mame2003/mame2003.c | 21 ++++----------------- 1 file changed, 4 insertions(+), 17 deletions(-) diff --git a/src/mame2003/mame2003.c b/src/mame2003/mame2003.c index 3c1ba2455..57c98e8e4 100644 --- a/src/mame2003/mame2003.c +++ b/src/mame2003/mame2003.c @@ -45,7 +45,6 @@ struct ipd *default_inputs; /* pointer the array of structs with default MAME i /* data structures to store and translate keyboard state */ const struct KeyboardInfo retroKeys[]; /* MAME data structure keymapping */ -int retroKeyState[RETROK_LAST] = {0}; /* initialise to zero, polled in retro_run */ /* data structures for joystick/retropad state */ int retroJsState[MAX_PLAYER_COUNT][OSD_INPUT_CODES_PER_PLAYER]= {{0}}; /* initialise to zero, polled in retro_run */ @@ -1205,7 +1204,6 @@ int16_t get_pointer_delta(int16_t coord, int16_t *prev_coord) void retro_run (void) { int port = 0; - const struct KeyboardInfo *thisInput; bool updated = false; poll_cb(); @@ -1218,9 +1216,6 @@ void retro_run (void) if (environ_cb(RETRO_ENVIRONMENT_GET_VARIABLE_UPDATE, &updated) && updated) update_variables(false); - /* retroJS */ - /* A combination of the non-keyboard input types into an abstracted MAME joystick */ - /* begin by blanking the old values */ for(port = 0; port < MAX_PLAYER_COUNT; port++) { @@ -1260,14 +1255,6 @@ void retro_run (void) retroJsState[port][OSD_ANALOG_RIGHT_POSITIVE_Y] = (analogjoy[port][3] > INPUT_BUTTON_AXIS_THRESHOLD) ? analogjoy[port][3] : 0; } - /* poll libretro keyboard abstraction */ - thisInput = retroKeys; - while(thisInput->name) - { - retroKeyState[thisInput->code] = input_cb(0, RETRO_DEVICE_KEYBOARD, 0, thisInput->code); - thisInput ++; - } - mame_frame(); } @@ -2350,11 +2337,11 @@ const struct KeyboardInfo *osd_get_key_list(void) int osd_is_key_pressed(int keycode) { - if (options.input_interface == RETRO_DEVICE_JOYPAD) - return 0; /* do not return keyboard input if the core option is set to retropad/joystick only */ + if(!running) return 0; /* input callback has not yet been polled */ + if(options.input_interface == RETRO_DEVICE_JOYPAD) return 0; /* core option is set to retropad/joystick only */ - if (keycode < RETROK_LAST && keycode >= 0) - return retroKeyState[keycode]; + if(keycode < RETROK_LAST && keycode >= 0) + return input_cb(0, RETRO_DEVICE_KEYBOARD, 0, keycode); log_cb(RETRO_LOG_WARN, LOGPRE "Invalid OSD keycode received: %i\n", keycode); /* this should not happen when keycodes are properly registered with MAME */ return 0; From 464bc77783f97f6636bd41eb6eed5d31c60dd1c3 Mon Sep 17 00:00:00 2001 From: mahoneyt944 <49591133+mahoneyt944@users.noreply.github.com> Date: Fri, 11 Jun 2021 01:06:28 -0400 Subject: [PATCH 27/28] Retro_running --- src/mame2003/mame2003.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/src/mame2003/mame2003.c b/src/mame2003/mame2003.c index 57c98e8e4..b0989f86c 100644 --- a/src/mame2003/mame2003.c +++ b/src/mame2003/mame2003.c @@ -29,7 +29,7 @@ static const struct GameDriver *game_driver; -int running = 0; +int retro_running = 0; int gotFrame; static float delta_samples; int samples_per_frame = 0; @@ -1205,11 +1205,11 @@ void retro_run (void) { int port = 0; bool updated = false; - poll_cb(); + poll_cb(); /* execute input callback */ - if (running == 0) /* first time through the loop */ + if (retro_running == 0) /* first time through the loop */ { - running = 1; + retro_running = 1; log_cb(RETRO_LOG_DEBUG, LOGPRE "Entering retro_run() for the first time.\n"); } @@ -2071,8 +2071,8 @@ const struct JoystickInfo *osd_get_joy_list(void) */ int osd_is_joy_pressed(int joycode) { + if (!retro_running) return 0; /* input callback has not yet been polled */ if (options.input_interface == RETRO_DEVICE_KEYBOARD) return 0; /* disregard joystick input */ - if (!running) return 0; /* polling must be completed in retro_run */ unsigned player_number = calc_player_number(joycode); unsigned port = player_number - 1; @@ -2337,10 +2337,10 @@ const struct KeyboardInfo *osd_get_key_list(void) int osd_is_key_pressed(int keycode) { - if(!running) return 0; /* input callback has not yet been polled */ - if(options.input_interface == RETRO_DEVICE_JOYPAD) return 0; /* core option is set to retropad/joystick only */ + if (!retro_running) return 0; /* input callback has not yet been polled */ + if (options.input_interface == RETRO_DEVICE_JOYPAD) return 0; /* core option is set to retropad/joystick only */ - if(keycode < RETROK_LAST && keycode >= 0) + if (keycode < RETROK_LAST && keycode >= 0) return input_cb(0, RETRO_DEVICE_KEYBOARD, 0, keycode); log_cb(RETRO_LOG_WARN, LOGPRE "Invalid OSD keycode received: %i\n", keycode); /* this should not happen when keycodes are properly registered with MAME */ From 7f9846444d7fa040e3e26e9656479e607b3952ce Mon Sep 17 00:00:00 2001 From: mahoneyt944 <49591133+mahoneyt944@users.noreply.github.com> Date: Fri, 11 Jun 2021 01:34:18 -0400 Subject: [PATCH 28/28] Spaces --- src/mame2003/mame2003.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/mame2003/mame2003.c b/src/mame2003/mame2003.c index b0989f86c..2dc271eb7 100644 --- a/src/mame2003/mame2003.c +++ b/src/mame2003/mame2003.c @@ -427,9 +427,9 @@ static void update_variables(bool first_time) options.input_interface = RETRO_DEVICE_JOYPAD; else if(strcmp(var.value, "keyboard") == 0) options.input_interface = RETRO_DEVICE_KEYBOARD; - else - options.input_interface = RETRO_DEVICE_KEYBOARD + RETRO_DEVICE_JOYPAD; - break; + else + options.input_interface = RETRO_DEVICE_KEYBOARD + RETRO_DEVICE_JOYPAD; + break; case OPT_4WAY: if( (strcmp(var.value, "enabled") == 0) && (options.content_flags[CONTENT_JOYSTICK_DIRECTIONS] == 4) )