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