mirror of
https://github.com/libretro/RetroArch
synced 2025-02-06 00:39:53 +00:00
(net retropad core) Cleanups
This commit is contained in:
parent
0ce63a3f94
commit
091aa7d8a6
@ -111,26 +111,23 @@ static struct descriptor *descriptors[] = {
|
|||||||
|
|
||||||
void NETRETROPAD_CORE_PREFIX(retro_init)(void)
|
void NETRETROPAD_CORE_PREFIX(retro_init)(void)
|
||||||
{
|
{
|
||||||
struct descriptor *desc;
|
|
||||||
int size;
|
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
frame_buf = (uint16_t*)calloc(320 * 240, sizeof(uint16_t));
|
frame_buf = (uint16_t*)calloc(320 * 240, sizeof(uint16_t));
|
||||||
|
|
||||||
if (frame_buf)
|
if (frame_buf)
|
||||||
{
|
{
|
||||||
|
unsigned rle, runs, count;
|
||||||
uint16_t *pixel = frame_buf + 49 * 320 + 32;
|
uint16_t *pixel = frame_buf + 49 * 320 + 32;
|
||||||
|
|
||||||
for (unsigned rle = 0; rle < sizeof(body); )
|
for (rle = 0; rle < sizeof(body); )
|
||||||
{
|
{
|
||||||
uint16_t color = 0;
|
uint16_t color = 0;
|
||||||
|
|
||||||
for (unsigned runs = body[rle++]; runs > 0; runs--)
|
for (runs = body[rle++]; runs > 0; runs--)
|
||||||
{
|
|
||||||
for (unsigned count = body[rle++]; count > 0; count--)
|
|
||||||
{
|
{
|
||||||
|
for (count = body[rle++]; count > 0; count--)
|
||||||
*pixel++ = color;
|
*pixel++ = color;
|
||||||
}
|
|
||||||
|
|
||||||
color = 0x4208 - color;
|
color = 0x4208 - color;
|
||||||
}
|
}
|
||||||
@ -140,9 +137,10 @@ void NETRETROPAD_CORE_PREFIX(retro_init)(void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Allocate descriptor values */
|
/* Allocate descriptor values */
|
||||||
for (i = 0; i < ARRAY_SIZE(descriptors); i++) {
|
for (i = 0; i < ARRAY_SIZE(descriptors); i++)
|
||||||
desc = descriptors[i];
|
{
|
||||||
size = DESC_NUM_PORTS(desc) * DESC_NUM_INDICES(desc) * DESC_NUM_IDS(desc);
|
struct descriptor *desc = descriptors[i];
|
||||||
|
int size = DESC_NUM_PORTS(desc) * DESC_NUM_INDICES(desc) * DESC_NUM_IDS(desc);
|
||||||
descriptors[i]->value = (uint16_t*)calloc(size, sizeof(uint16_t));
|
descriptors[i]->value = (uint16_t*)calloc(size, sizeof(uint16_t));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -159,7 +157,8 @@ void NETRETROPAD_CORE_PREFIX(retro_deinit)(void)
|
|||||||
frame_buf = NULL;
|
frame_buf = NULL;
|
||||||
|
|
||||||
/* Free descriptor values */
|
/* Free descriptor values */
|
||||||
for (i = 0; i < ARRAY_SIZE(descriptors); i++) {
|
for (i = 0; i < ARRAY_SIZE(descriptors); i++)
|
||||||
|
{
|
||||||
free(descriptors[i]->value);
|
free(descriptors[i]->value);
|
||||||
descriptors[i]->value = NULL;
|
descriptors[i]->value = NULL;
|
||||||
}
|
}
|
||||||
@ -202,36 +201,39 @@ void NETRETROPAD_CORE_PREFIX(retro_get_system_av_info)(
|
|||||||
|
|
||||||
static void retropad_update_input(void)
|
static void retropad_update_input(void)
|
||||||
{
|
{
|
||||||
struct descriptor *desc;
|
|
||||||
struct remote_joypad_message msg;
|
|
||||||
uint16_t state;
|
|
||||||
uint16_t old;
|
|
||||||
int offset;
|
|
||||||
int port;
|
|
||||||
int index;
|
|
||||||
int id;
|
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
/* Poll input */
|
/* Poll input */
|
||||||
NETRETROPAD_CORE_PREFIX(input_poll_cb)();
|
NETRETROPAD_CORE_PREFIX(input_poll_cb)();
|
||||||
|
|
||||||
/* Parse descriptors */
|
/* Parse descriptors */
|
||||||
for (i = 0; i < ARRAY_SIZE(descriptors); i++) {
|
for (i = 0; i < ARRAY_SIZE(descriptors); i++)
|
||||||
|
{
|
||||||
|
int port;
|
||||||
/* Get current descriptor */
|
/* Get current descriptor */
|
||||||
desc = descriptors[i];
|
struct descriptor *desc = descriptors[i];
|
||||||
|
|
||||||
/* Go through range of ports/indices/IDs */
|
/* Go through range of ports/indices/IDs */
|
||||||
for (port = desc->port_min; port <= desc->port_max; port++)
|
for (port = desc->port_min; port <= desc->port_max; port++)
|
||||||
|
{
|
||||||
|
int index;
|
||||||
|
|
||||||
for (index = desc->index_min; index <= desc->index_max; index++)
|
for (index = desc->index_min; index <= desc->index_max; index++)
|
||||||
for (id = desc->id_min; id <= desc->id_max; id++) {
|
{
|
||||||
|
int id;
|
||||||
|
|
||||||
|
for (id = desc->id_min; id <= desc->id_max; id++)
|
||||||
|
{
|
||||||
|
struct remote_joypad_message msg;
|
||||||
|
|
||||||
/* Compute offset into array */
|
/* Compute offset into array */
|
||||||
offset = DESC_OFFSET(desc, port, index, id);
|
int offset = DESC_OFFSET(desc, port, index, id);
|
||||||
|
|
||||||
/* Get old state */
|
/* Get old state */
|
||||||
old = desc->value[offset];
|
uint16_t old = desc->value[offset];
|
||||||
|
|
||||||
/* Get new state */
|
/* Get new state */
|
||||||
state = NETRETROPAD_CORE_PREFIX(input_state_cb)(
|
uint16_t state = NETRETROPAD_CORE_PREFIX(input_state_cb)(
|
||||||
port,
|
port,
|
||||||
desc->device,
|
desc->device,
|
||||||
index,
|
index,
|
||||||
@ -250,11 +252,14 @@ static void retropad_update_input(void)
|
|||||||
msg.index = index;
|
msg.index = index;
|
||||||
msg.id = id;
|
msg.id = id;
|
||||||
msg.state = state;
|
msg.state = state;
|
||||||
|
|
||||||
if (sendto(s, (char*)&msg, sizeof(msg), 0, (struct sockaddr *)&si_other, sizeof(si_other)) == -1)
|
if (sendto(s, (char*)&msg, sizeof(msg), 0, (struct sockaddr *)&si_other, sizeof(si_other)) == -1)
|
||||||
NETRETROPAD_CORE_PREFIX(log_cb)(RETRO_LOG_INFO, "Error sending data!\n");
|
NETRETROPAD_CORE_PREFIX(log_cb)(RETRO_LOG_INFO, "Error sending data!\n");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void NETRETROPAD_CORE_PREFIX(retro_set_environment)(retro_environment_t cb)
|
void NETRETROPAD_CORE_PREFIX(retro_set_environment)(retro_environment_t cb)
|
||||||
{
|
{
|
||||||
|
Loading…
x
Reference in New Issue
Block a user