mirror of
https://github.com/RaySollium99/picodrive.git
synced 2025-09-05 07:17:45 -04:00
libretro, add input bitmask support
This commit is contained in:
parent
8b48f9d483
commit
b106e5c72b
1 changed files with 22 additions and 6 deletions
|
@ -16,9 +16,9 @@
|
|||
#include <string.h>
|
||||
#ifndef _WIN32
|
||||
#ifndef NO_MMAP
|
||||
#if defined __SWITCH__
|
||||
#ifdef __SWITCH__
|
||||
#include "switch/mman.h"
|
||||
#elif ! defined NO_MMAP
|
||||
#else
|
||||
#include <sys/mman.h>
|
||||
#endif
|
||||
#endif
|
||||
|
@ -706,6 +706,8 @@ void lprintf(const char *fmt, ...)
|
|||
}
|
||||
|
||||
/* libretro */
|
||||
bool libretro_supports_bitmasks = false;
|
||||
|
||||
void retro_set_environment(retro_environment_t cb)
|
||||
{
|
||||
#ifdef USE_LIBRETRO_VFS
|
||||
|
@ -1638,6 +1640,7 @@ void retro_run(void)
|
|||
bool updated = false;
|
||||
int pad, i;
|
||||
static void *buff;
|
||||
int16_t input;
|
||||
|
||||
PicoIn.skipFrame = 0;
|
||||
|
||||
|
@ -1647,10 +1650,18 @@ void retro_run(void)
|
|||
input_poll_cb();
|
||||
|
||||
PicoIn.pad[0] = PicoIn.pad[1] = 0;
|
||||
for (pad = 0; pad < 2; pad++)
|
||||
for (pad = 0; pad < 2; pad++) {
|
||||
if (libretro_supports_bitmasks) {
|
||||
input = input_state_cb(pad, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_MASK);
|
||||
for (i = 0; i < RETRO_PICO_MAP_LEN; i++)
|
||||
if (input & (1 << i))
|
||||
PicoIn.pad[pad] |= retro_pico_map[i];
|
||||
} else {
|
||||
for (i = 0; i < RETRO_PICO_MAP_LEN; i++)
|
||||
if (input_state_cb(pad, RETRO_DEVICE_JOYPAD, 0, i))
|
||||
PicoIn.pad[pad] |= retro_pico_map[i];
|
||||
}
|
||||
}
|
||||
|
||||
if (PicoPatches)
|
||||
PicoPatchApply();
|
||||
|
@ -1785,6 +1796,9 @@ void retro_init(void)
|
|||
|
||||
environ_cb(RETRO_ENVIRONMENT_SET_DISK_CONTROL_INTERFACE, &disk_control);
|
||||
|
||||
if (environ_cb(RETRO_ENVIRONMENT_GET_INPUT_BITMASKS, NULL))
|
||||
libretro_supports_bitmasks = true;
|
||||
|
||||
#ifdef _3DS
|
||||
ctr_svchack_successful = ctr_svchack_init();
|
||||
check_rosalina();
|
||||
|
@ -1853,4 +1867,6 @@ void retro_deinit(void)
|
|||
#endif
|
||||
vout_buf = NULL;
|
||||
PicoExit();
|
||||
|
||||
libretro_supports_bitmasks = false;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue