mirror of
https://github.com/libretro/beetle-psx-libretro.git
synced 2024-11-27 02:40:31 +00:00
Implement input bitmasks
This commit is contained in:
parent
1e5a0df455
commit
90bf41a456
22
input.cpp
22
input.cpp
@ -697,7 +697,7 @@ void input_handle_lightgun( INPUT_DATA *p_input, int iplayer, retro_input_state_
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void input_update( retro_input_state_t input_state_cb )
|
void input_update(bool libretro_supports_bitmasks, retro_input_state_t input_state_cb )
|
||||||
{
|
{
|
||||||
// For each player (logical controller)
|
// For each player (logical controller)
|
||||||
for ( unsigned iplayer = 0; iplayer < players; ++iplayer )
|
for ( unsigned iplayer = 0; iplayer < players; ++iplayer )
|
||||||
@ -719,11 +719,21 @@ void input_update( retro_input_state_t input_state_cb )
|
|||||||
|
|
||||||
// Use fixed lookup table to map RetroPad inputs to PlayStation input bitmap.
|
// Use fixed lookup table to map RetroPad inputs to PlayStation input bitmap.
|
||||||
p_input->buttons = 0;
|
p_input->buttons = 0;
|
||||||
for ( unsigned i = 0; i < INPUT_MAP_CONTROLLER_SIZE; i++ )
|
if (libretro_supports_bitmasks)
|
||||||
{
|
{
|
||||||
p_input->buttons |=
|
int16_t ret = input_state_cb(iplayer, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_MASK);
|
||||||
input_state_cb( iplayer, RETRO_DEVICE_JOYPAD, 0, input_map_controller[ i ] )
|
for ( unsigned i = 0; i < INPUT_MAP_CONTROLLER_SIZE; i++ )
|
||||||
? ( 1 << i ) : 0;
|
p_input->buttons |= (ret & (1 << input_map_controller[ i ] ))
|
||||||
|
? ( 1 << i ) : 0;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
for ( unsigned i = 0; i < INPUT_MAP_CONTROLLER_SIZE; i++ )
|
||||||
|
{
|
||||||
|
p_input->buttons |=
|
||||||
|
input_state_cb( iplayer, RETRO_DEVICE_JOYPAD, 0, input_map_controller[ i ] )
|
||||||
|
? ( 1 << i ) : 0;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
@ -743,10 +753,8 @@ void input_update( retro_input_state_t input_state_cb )
|
|||||||
if ( input_state_cb( iplayer, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_A ) ||
|
if ( input_state_cb( iplayer, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_A ) ||
|
||||||
input_state_cb( iplayer, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_L ) ||
|
input_state_cb( iplayer, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_L ) ||
|
||||||
input_state_cb( iplayer, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_R ) )
|
input_state_cb( iplayer, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_R ) )
|
||||||
{
|
|
||||||
// Guncon 'A'
|
// Guncon 'A'
|
||||||
p_input->u8[ 4 ] |= 0x2;
|
p_input->u8[ 4 ] |= 0x2;
|
||||||
}
|
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
5
input.h
5
input.h
@ -1,7 +1,8 @@
|
|||||||
#ifndef __INPUT_H__
|
#ifndef __INPUT_H__
|
||||||
#define __INPUT_H__
|
#define __INPUT_H__
|
||||||
|
|
||||||
#include "libretro.h"
|
#include <boolean.h>
|
||||||
|
#include <libretro.h>
|
||||||
#include "mednafen/psx/frontio.h"
|
#include "mednafen/psx/frontio.h"
|
||||||
|
|
||||||
// These input routines tell libretro about PlayStation peripherals
|
// These input routines tell libretro about PlayStation peripherals
|
||||||
@ -28,7 +29,7 @@ extern void input_set_player_count( unsigned players );
|
|||||||
|
|
||||||
extern unsigned input_get_player_count();
|
extern unsigned input_get_player_count();
|
||||||
|
|
||||||
extern void input_update( retro_input_state_t input_state_cb );
|
void input_update(bool supports_bitmasks, retro_input_state_t input_state_cb );
|
||||||
|
|
||||||
enum
|
enum
|
||||||
{
|
{
|
||||||
|
@ -32,6 +32,8 @@
|
|||||||
extern bool FastSaveStates;
|
extern bool FastSaveStates;
|
||||||
const int DEFAULT_STATE_SIZE = 16 * 1024 * 1024;
|
const int DEFAULT_STATE_SIZE = 16 * 1024 * 1024;
|
||||||
|
|
||||||
|
static bool libretro_supports_bitmasks = false;
|
||||||
|
|
||||||
struct retro_perf_callback perf_cb;
|
struct retro_perf_callback perf_cb;
|
||||||
retro_get_cpu_features_t perf_get_cpu_features_cb = NULL;
|
retro_get_cpu_features_t perf_get_cpu_features_cb = NULL;
|
||||||
retro_log_printf_t log_cb;
|
retro_log_printf_t log_cb;
|
||||||
@ -2632,6 +2634,9 @@ void retro_init(void)
|
|||||||
setting_initial_scanline_pal = 0;
|
setting_initial_scanline_pal = 0;
|
||||||
setting_last_scanline_pal = 287;
|
setting_last_scanline_pal = 287;
|
||||||
|
|
||||||
|
if (environ_cb(RETRO_ENVIRONMENT_GET_INPUT_BITMASKS, NULL))
|
||||||
|
libretro_supports_bitmasks = true;
|
||||||
|
|
||||||
check_system_specs();
|
check_system_specs();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -3644,7 +3649,7 @@ void retro_run(void)
|
|||||||
|
|
||||||
input_poll_cb();
|
input_poll_cb();
|
||||||
|
|
||||||
input_update( input_state_cb );
|
input_update(libretro_supports_bitmasks, input_state_cb );
|
||||||
|
|
||||||
static int32 rects[MEDNAFEN_CORE_GEOMETRY_MAX_H];
|
static int32 rects[MEDNAFEN_CORE_GEOMETRY_MAX_H];
|
||||||
rects[0] = ~0;
|
rects[0] = ~0;
|
||||||
@ -3915,6 +3920,8 @@ void retro_deinit(void)
|
|||||||
MEDNAFEN_CORE_NAME, (double)audio_frames / video_frames);
|
MEDNAFEN_CORE_NAME, (double)audio_frames / video_frames);
|
||||||
log_cb(RETRO_LOG_INFO, "[%s]: Estimated FPS: %.5f\n",
|
log_cb(RETRO_LOG_INFO, "[%s]: Estimated FPS: %.5f\n",
|
||||||
MEDNAFEN_CORE_NAME, (double)video_frames * 44100 / audio_frames);
|
MEDNAFEN_CORE_NAME, (double)video_frames * 44100 / audio_frames);
|
||||||
|
|
||||||
|
libretro_supports_bitmasks = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned retro_get_region(void)
|
unsigned retro_get_region(void)
|
||||||
|
Loading…
Reference in New Issue
Block a user