Gameport backend work

This commit is contained in:
Jasmine Iwanek
2024-11-30 15:26:06 -05:00
parent de488fe779
commit e96c6579ba
4 changed files with 95 additions and 9 deletions

View File

@@ -8,8 +8,6 @@
*
* Implementation of a generic Game Port.
*
*
*
* Authors: Miran Grca, <mgrca8@gmail.com>
* Sarah Walker, <https://pcem-emulator.co.uk/>
* RichardG, <richardg867@gmail.com>
@@ -18,7 +16,7 @@
* Copyright 2016-2022 Miran Grca.
* Copyright 2008-2018 Sarah Walker.
* Copyright 2021 RichardG.
* Copyright 2021-2024 Jasmine Iwanek.
* Copyright 2021-2025 Jasmine Iwanek.
*/
#include <stdio.h>
#include <stdint.h>
@@ -35,6 +33,12 @@
#include <86box/gameport.h>
#include <86box/plat_unused.h>
device_t game_ports[GAMEPORT_MAX];
typedef struct {
const device_t *device;
} GAMEPORT;
typedef struct g_axis_t {
pc_timer_t timer;
int axis_nr;
@@ -733,3 +737,63 @@ const device_t gameport_sio_1io_device = {
.force_redraw = NULL,
.config = NULL
};
static const GAMEPORT gameports[] = {
{ &device_none },
{ &device_internal },
{ &gameport_device },
{ &gameport_208_device },
{ &gameport_pnp_device },
{ &gameport_tm_acm_device },
{ NULL }
// clang-format on
};
/* UI */
int
gameport_available(int port)
{
if (gameports[port].device)
return (device_available(gameports[port].device));
return 1;
}
/* UI */
const device_t *
gameports_getdevice(int port)
{
return (gameports[port].device);
}
/* UI */
int
gameport_has_config(int port)
{
if (!gameports[port].device)
return 0;
return (device_has_config(gameports[port].device) ? 1 : 0);
}
/* UI */
const char *
gameport_get_internal_name(int port)
{
return device_get_internal_name(gameports[port].device);
}
/* UI */
int
gameport_get_from_internal_name(const char *str)
{
int c = 0;
while (gameports[c].device != NULL) {
if (!strcmp(gameports[c].device->internal_name, str))
return c;
c++;
}
return 0;
}