mirror of
https://github.com/libretro/RetroArch
synced 2025-03-01 07:13:35 +00:00
add input polling code
This commit is contained in:
parent
d5e56c7561
commit
fe9700ebda
@ -462,8 +462,8 @@ void input_poll(void)
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_NETWORK_GAMEPAD
|
||||
/*if (driver->remote)
|
||||
rarch_remote_poll(driver->remote);*/
|
||||
if (driver->remote)
|
||||
rarch_remote_poll(driver->remote);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
35
remote.c
35
remote.c
@ -37,7 +37,7 @@
|
||||
#include "verbosity.h"
|
||||
|
||||
#define DEFAULT_NETWORK_GAMEPAD_PORT 55400
|
||||
#define STDIN_BUF_SIZE 4096
|
||||
#define UDP_FRAME_PACKETS 16
|
||||
|
||||
struct rarch_remote
|
||||
{
|
||||
@ -49,6 +49,8 @@ struct rarch_remote
|
||||
bool state[RARCH_BIND_LIST_END];
|
||||
};
|
||||
|
||||
uint16_t state[MAX_USERS];
|
||||
|
||||
#if defined(HAVE_NETWORK_GAMEPAD) && defined(HAVE_NETPLAY)
|
||||
static bool remote_init_network(rarch_remote_t *handle, uint16_t port, unsigned user)
|
||||
{
|
||||
@ -158,5 +160,36 @@ bool rarch_remote_get(rarch_remote_t *handle, unsigned id)
|
||||
return id < RARCH_BIND_LIST_END && handle->state[id];
|
||||
}
|
||||
|
||||
static void parse_packet(char *buffer, unsigned size, unsigned user)
|
||||
{
|
||||
/* todo implement parsing of input_state from the packet */
|
||||
|
||||
}
|
||||
|
||||
void rarch_remote_poll(rarch_remote_t *handle)
|
||||
{
|
||||
settings_t *settings = config_get_ptr();
|
||||
|
||||
for(int user=0; user < settings->input.max_users; user++)
|
||||
{
|
||||
if (settings->network_remote_enable_user[user])
|
||||
{
|
||||
|
||||
fd_set fds;
|
||||
struct timeval tmp_tv = {0};
|
||||
if (handle->net_fd[user] < 0)
|
||||
return;
|
||||
FD_ZERO(&fds);
|
||||
FD_SET(handle->net_fd[user], &fds);
|
||||
|
||||
char buf[1024];
|
||||
ssize_t ret = recvfrom(handle->net_fd[user], buf,
|
||||
sizeof(buf) - 1, 0, NULL, NULL);
|
||||
if (ret > 0)
|
||||
parse_packet(buf, sizeof(buf), user);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user