1
0
mirror of https://github.com/libretro/RetroArch synced 2024-07-03 08:48:42 +00:00

add some copyright on files I contributed considerably just in case

This commit is contained in:
radius 2019-06-16 13:32:27 -05:00 committed by twinaphex
parent c46ba7f63b
commit d865c5e4a6
24 changed files with 351 additions and 15 deletions

View File

@ -1,3 +1,18 @@
/* RetroArch - A frontend for libretro.
* Copyright (C) 2015-2016 - Andre Leiradella
*
* RetroArch is free software: you can redistribute it and/or modify it under the terms
* of the GNU General Public License as published by the Free Software Found-
* ation, either version 3 of the License, or (at your option) any later version.
*
* RetroArch is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
* PURPOSE. See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along with RetroArch.
* If not, see <http://www.gnu.org/licenses/>.
*/
#include <file/file_path.h>
#include <string/stdstring.h>

View File

@ -1,6 +1,6 @@
/* RetroArch - A frontend for libretro.
* Copyright (C) 2011-2017 - Daniel De Matteis
* Copyright (C) 2015-2017 - Andres Suarez
* Copyright (C) 2015-2017 - Andrés Suarez
* Copyright (C) 2016-2019 - Brad Parker
*
* RetroArch is free software: you can redistribute it and/or modify it under the terms

View File

@ -2,7 +2,7 @@
* Copyright (C) 2010-2014 - Hans-Kristian Arntzen
* Copyright (C) 2011-2017 - Daniel De Matteis
* Copyright (C) 2014-2017 - Jean-André Santoni
* Copyright (C) 2015-2017 - Andrés Suárez
* Copyright (C) 2015-2019 - Andrés Suárez
* Copyright (C) 2016-2019 - Brad Parker
*
* RetroArch is free software: you can redistribute it and/or modify it under the terms

View File

@ -1,5 +1,5 @@
/* RetroArch - A frontend for libretro.
* Copyright (C) 2018 - Andrés Suárez
* Copyright (C) 2018-2019 - Andrés Suárez
*
* RetroArch is free software: you can redistribute it and/or modify it under the terms
* of the GNU General Public License as published by the Free Software Found-

View File

@ -1,5 +1,5 @@
/* RetroArch - A frontend for libretro.
* Copyright (C) 2018 - Andrés Suárez
* Copyright (C) 2018-2019 - Andrés Suárez
*
* RetroArch is free software: you can redistribute it and/or modify it under the terms
* of the GNU General Public License as published by the Free Software Found-

View File

@ -3,7 +3,7 @@
* Copyright (C) 2011-2017 - Daniel De Matteis
* Copyright (C) 2012-2015 - Jason Fetters
* Copyright (C) 2012-2015 - Michael Lelli
* Copyright (C) 2015-2017 - Andrés Suárez
* Copyright (C) 2016-2019 - Andrés Suárez
*
* RetroArch is free software: you can redistribute it and/or modify it under the terms
* of the GNU General Public License as published by the Free Software Found-

View File

@ -1,6 +1,7 @@
/* RetroArch - A frontend for libretro.
* Copyright (C) 2011-2017 - Daniel De Matteis
* Copyright (C) 2016-2019 - Brad Parker
* Copyright (C) 2018-2019 - Andrés Suárez
*
* RetroArch is free software: you can redistribute it and/or modify it under the terms
* of the GNU General Public License as published by the Free Software Found-

View File

@ -1,7 +1,7 @@
/* RetroArch - A frontend for libretro.
* Copyright (C) 2010-2014 - Hans-Kristian Arntzen
* Copyright (C) 2011-2017 - Daniel De Matteis
* Copyright (C) 2016-2017 - Andrés Suárez
* Copyright (C) 2016-2019 - Andrés Suárez
*
* RetroArch is free software: you can redistribute it and/or modify it under the terms
* of the GNU General Public License as published by the Free Software Found-

View File

@ -1,7 +1,7 @@
/* RetroArch - A frontend for libretro.
* Copyright (C) 2010-2014 - Hans-Kristian Arntzen
* Copyright (C) 2011-2017 - Daniel De Matteis
* Copyright (C) 2016-2017 - Andrés Suárez
* Copyright (C) 2016-2019 - Andrés Suárez
*
* RetroArch is free software: you can redistribute it and/or modify it under the terms
* of the GNU General Public License as published by the Free Software Found-

View File

@ -1,6 +1,6 @@
/* RetroArch - A frontend for libretro.
* Copyright (C) 2011-2017 - Daniel De Matteis
* Copyright (C) 2016-2017 - Andrés Suárez
* Copyright (C) 2016-2019 - Andrés Suárez
*
* RetroArch is free software: you can redistribute it and/or modify it under the terms
* of the GNU General Public License as published by the Free Software Found-

View File

@ -1,6 +1,6 @@
/* RetroArch - A frontend for libretro.
* Copyright (C) 2011-2017 - Daniel De Matteis
* Copyright (C) 2016-2017 - Andrés Suárez
* Copyright (C) 2016-2019 - Andrés Suárez
*
* RetroArch is free software: you can redistribute it and/or modify it under the terms
* of the GNU General Public License as published by the Free Software Found-

265
input/input_remote.c Normal file
View File

@ -0,0 +1,265 @@
/* RetroArch - A frontend for libretro.
* Copyright (C) 2010-2014 - Hans-Kristian Arntzen
* Copyright (C) 2011-2017 - Daniel De Matteis
* Copyright (C) 2017-2019 - Andrés Suárez
*
* RetroArch is free software: you can redistribute it and/or modify it under the terms
* of the GNU General Public License as published by the Free Software Found-
* ation, either version 3 of the License, or (at your option) any later version.
*
* RetroArch is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
* PURPOSE. See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along with RetroArch.
* If not, see <http://www.gnu.org/licenses/>.
*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#ifdef _WIN32
#include <direct.h>
#else
#include <unistd.h>
#endif
#include <compat/strl.h>
#include <compat/posix_string.h>
#include <file/file_path.h>
#include <retro_miscellaneous.h>
#include <libretro.h>
#include <net/net_compat.h>
#include <net/net_socket.h>
#ifdef HAVE_CONFIG_H
#include "../config.h"
#endif
#include "input_remote.h"
#include "../configuration.h"
#include "../msg_hash.h"
#include "../verbosity.h"
#define DEFAULT_NETWORK_GAMEPAD_PORT 55400
#define UDP_FRAME_PACKETS 16
struct remote_message
{
uint16_t state;
int port;
int device;
int index;
int id;
};
struct input_remote
{
bool state[RARCH_BIND_LIST_END];
#if defined(HAVE_NETWORKING) && defined(HAVE_NETWORKGAMEPAD)
int net_fd[MAX_USERS];
#endif
};
typedef struct input_remote_state
{
/* Left X, Left Y, Right X, Right Y */
int16_t analog[4][MAX_USERS];
/* This is a bitmask of (1 << key_bind_id). */
uint64_t buttons[MAX_USERS];
} input_remote_state_t;
static input_remote_state_t remote_st_ptr;
static input_remote_state_t *input_remote_get_state_ptr(void)
{
return &remote_st_ptr;
}
#if defined(HAVE_NETWORKING) && defined(HAVE_NETWORKGAMEPAD)
static bool input_remote_init_network(input_remote_t *handle,
uint16_t port, unsigned user)
{
int fd;
struct addrinfo *res = NULL;
port = port + user;
if (!network_init())
return false;
RARCH_LOG("Bringing up remote interface on port %hu.\n",
(unsigned short)port);
fd = socket_init((void**)&res, port, NULL, SOCKET_TYPE_DATAGRAM);
if (fd < 0)
goto error;
handle->net_fd[user] = fd;
if (!socket_nonblock(handle->net_fd[user]))
goto error;
if (!socket_bind(handle->net_fd[user], res))
{
RARCH_ERR("%s\n", msg_hash_to_str(MSG_FAILED_TO_BIND_SOCKET));
goto error;
}
freeaddrinfo_retro(res);
return true;
error:
if (res)
freeaddrinfo_retro(res);
return false;
}
#endif
input_remote_t *input_remote_new(uint16_t port, unsigned max_users)
{
unsigned user;
#if defined(HAVE_NETWORKING) && defined(HAVE_NETWORKGAMEPAD)
settings_t *settings = config_get_ptr();
#endif
input_remote_t *handle = (input_remote_t*)
calloc(1, sizeof(*handle));
if (!handle)
return NULL;
(void)port;
#if defined(HAVE_NETWORKING) && defined(HAVE_NETWORKGAMEPAD)
for(user = 0; user < max_users; user ++)
{
handle->net_fd[user] = -1;
if(settings->bools.network_remote_enable_user[user])
if (!input_remote_init_network(handle, port, user))
goto error;
}
#endif
return handle;
#if defined(HAVE_NETWORKING) && defined(HAVE_NETWORKGAMEPAD)
error:
input_remote_free(handle, max_users);
return NULL;
#endif
}
void input_remote_free(input_remote_t *handle, unsigned max_users)
{
unsigned user;
#if defined(HAVE_NETWORKING) && defined(HAVE_NETWORKGAMEPAD)
for(user = 0; user < max_users; user ++)
socket_close(handle->net_fd[user]);
#endif
free(handle);
}
#if defined(HAVE_NETWORKING) && defined(HAVE_NETWORKGAMEPAD)
static void input_remote_parse_packet(struct remote_message *msg, unsigned user)
{
input_remote_state_t *input_state = input_remote_get_state_ptr();
/* Parse message */
switch (msg->device)
{
case RETRO_DEVICE_JOYPAD:
input_state->buttons[user] &= ~(1 << msg->id);
if (msg->state)
input_state->buttons[user] |= 1 << msg->id;
break;
case RETRO_DEVICE_ANALOG:
input_state->analog[msg->index * 2 + msg->id][user] = msg->state;
break;
}
}
#endif
void input_remote_state(
int16_t *ret,
unsigned port,
unsigned device,
unsigned idx,
unsigned id)
{
switch (device)
{
case RETRO_DEVICE_JOYPAD:
if (input_remote_key_pressed(id, port))
*ret |= 1;
break;
case RETRO_DEVICE_ANALOG:
{
unsigned base = 0;
input_remote_state_t *input_state = input_remote_get_state_ptr();
if (!input_state)
return;
if (idx == RETRO_DEVICE_INDEX_ANALOG_RIGHT)
base = 2;
if (id == RETRO_DEVICE_ID_ANALOG_Y)
base += 1;
if (input_state && input_state->analog[base][port])
*ret = input_state->analog[base][port];
}
break;
}
}
bool input_remote_key_pressed(int key, unsigned port)
{
input_remote_state_t *input_state = input_remote_get_state_ptr();
if (!input_state)
return false;
return (input_state->buttons[port] & (UINT64_C(1) << key));
}
void input_remote_poll(input_remote_t *handle, unsigned max_users)
{
unsigned user;
settings_t *settings = config_get_ptr();
input_remote_state_t *input_state = input_remote_get_state_ptr();
for(user = 0; user < max_users; user++)
{
if (settings->bools.network_remote_enable_user[user])
{
#if defined(HAVE_NETWORKING) && defined(HAVE_NETWORKGAMEPAD)
struct remote_message msg;
ssize_t ret;
fd_set fds;
if (handle->net_fd[user] < 0)
return;
FD_ZERO(&fds);
FD_SET(handle->net_fd[user], &fds);
ret = recvfrom(handle->net_fd[user], (char*)&msg,
sizeof(msg), 0, NULL, NULL);
if (ret == sizeof(msg))
input_remote_parse_packet(&msg, user);
else if ((ret != -1) || ((errno != EAGAIN) && (errno != ENOENT)))
#endif
{
input_state->buttons[user] = 0;
input_state->analog[0][user] = 0;
input_state->analog[1][user] = 0;
input_state->analog[2][user] = 0;
input_state->analog[3][user] = 0;
}
}
}
}

51
input/input_remote.h Normal file
View File

@ -0,0 +1,51 @@
/* RetroArch - A frontend for libretro.
* Copyright (C) 2010-2014 - Hans-Kristian Arntzen
* Copyright (C) 2011-2017 - Daniel De Matteis
* Copyright (C) 2017-2019 - Andrés Suárez
*
* RetroArch is free software: you can redistribute it and/or modify it under the terms
* of the GNU General Public License as published by the Free Software Found-
* ation, either version 3 of the License, or (at your option) any later version.
*
* RetroArch is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
* PURPOSE. See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along with RetroArch.
* If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef INPUT_REMOTE_H__
#define INPUT_REMOTE_H__
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include <stdint.h>
#include <boolean.h>
#include <retro_common_api.h>
RETRO_BEGIN_DECLS
typedef struct input_remote input_remote_t;
input_remote_t *input_remote_new(uint16_t port, unsigned max_users);
void input_remote_free(input_remote_t *handle, unsigned max_users);
void input_remote_poll(input_remote_t *handle, unsigned max_users);
bool input_remote_key_pressed(int key, unsigned port);
void input_remote_state(
int16_t *ret,
unsigned port,
unsigned device,
unsigned idx,
unsigned id);
RETRO_END_DECLS
#endif

View File

@ -1,7 +1,7 @@
/* RetroArch - A frontend for libretro.
* Copyright (C) 2011-2017 - Daniel De Matteis
* Copyright (C) 2016-2019 - Brad Parker
* Copyright (C) 2015-2017 - Andrés Suárez
* Copyright (C) 2016-2019 - Andrés Suárez
*
* RetroArch is free software: you can redistribute it and/or modify it under the terms
* of the GNU General Public License as published by the Free Software Found-

View File

@ -1,7 +1,7 @@
/* RetroArch - A frontend for libretro.
* Copyright (C) 2011-2017 - Daniel De Matteis
* Copyright (C) 2014-2017 - Jean-André Santoni
* Copyright (C) 2015-2017 - Andrés Suárez
* Copyright (C) 2016-2019 - Andrés Suárez
* Copyright (C) 2016-2019 - Brad Parker
*
* RetroArch is free software: you can redistribute it and/or modify it under the terms

View File

@ -1,7 +1,7 @@
/* RetroArch - A frontend for libretro.
* Copyright (C) 2011-2017 - Daniel De Matteis
* Copyright (C) 2014-2017 - Jean-André Santoni
* Copyright (C) 2015-2017 - Andrés Suárez
* Copyright (C) 2016-2019 - Andrés Suárez
* Copyright (C) 2016-2019 - Brad Parker
*
* RetroArch is free software: you can redistribute it and/or modify it under the terms

View File

@ -1,5 +1,6 @@
/* RetroArch - A frontend for libretro.
* Copyright (C) 2011-2017 - Daniel De Matteis
* Copyright (C) 2017-2019 - Andrés Suárez
*
* RetroArch is free software: you can redistribute it and/or modify it under the terms
* of the GNU General Public License as published by the Free Software Found-

View File

@ -1,5 +1,6 @@
/* RetroArch - A frontend for libretro.
* Copyright (C) 2011-2017 - Daniel De Matteis
* Copyright (C) 2017-2019 - Andrés Suárez
*
* RetroArch is free software: you can redistribute it and/or modify it under the terms
* of the GNU General Public License as published by the Free Software Found-

View File

@ -1,6 +1,7 @@
/* RetroArch - A frontend for libretro.
* Copyright (C) 2010-2014 - Hans-Kristian Arntzen
* Copyright (C) 2011-2017 - Daniel De Matteis
* Copyright (C) 2017-2019 - Andrés Suárez
*
* RetroArch is free software: you can redistribute it and/or modify it under the terms
* of the GNU General Public License as published by the Free Software Found-

View File

@ -2,7 +2,6 @@
* Copyright (C) 2010-2014 - Hans-Kristian Arntzen
* Copyright (C) 2011-2017 - Daniel De Matteis
* Copyright (C) 2012-2015 - Michael Lelli
* Copyright (C) 2015-2017 - Andrés Suárez
* Copyright (C) 2014-2017 - Jean-André Santoni
* Copyright (C) 2016-2019 - Brad Parker
*

View File

@ -2,6 +2,7 @@
* Copyright (C) 2010-2014 - Hans-Kristian Arntzen
* Copyright (C) 2011-2017 - Daniel De Matteis
* Copyright (C) 2016-2019 - Brad Parker
* Copyright (C) 2016-2019 - Andrés Suárez
*
* RetroArch is free software: you can redistribute it and/or modify it under the terms
* of the GNU General Public License as published by the Free Software Found-

View File

@ -1,6 +1,7 @@
/* RetroArch - A frontend for libretro.
* Copyright (C) 2011-2017 - Daniel De Matteis
* Copyright (C) 2016-2019 - Brad Parker
* Copyright (C) 2016-2019 - Andrés Suárez
*
* RetroArch is free software: you can redistribute it and/or modify it under the terms
* of the GNU General Public License as published by the Free Software Found-

View File

@ -1,6 +1,6 @@
/* RetroArch - A frontend for libretro.
* Copyright (C) 2017 - Jean-André Santoni
* Copyright (C) 2017 - Andrés Suárez
* Copyright (C) 2017-2019 - Andrés Suárez
*
* RetroArch is free software: you can redistribute it and/or modify it under the terms
* of the GNU General Public License as published by the Free Software Found-

View File

@ -1,6 +1,6 @@
/* RetroArch - A frontend for libretro.
* Copyright (C) 2016-2017 - Jean-André Santoni
* Copyright (C) 2017 - Andrés Suárez
* Copyright (C) 2016-2019 - Andrés Suárez
*
* RetroArch is free software: you can redistribute it and/or modify it under the terms
* of the GNU General Public License as published by the Free Software Found-