mirror of
https://github.com/libretro/RetroArch
synced 2025-02-20 06:40:18 +00:00
Split off input_context code into separate file
This commit is contained in:
parent
6f9be38a04
commit
a4065ae34d
5
Makefile
5
Makefile
@ -124,6 +124,11 @@ $(OBJDIR)/tools/udev_joypad.o: input/udev_joypad.c
|
||||
@$(if $(Q), $(shell echo echo CC $<),)
|
||||
$(Q)$(CC) $(CFLAGS) $(DEFINES) -MMD -DIS_JOYCONFIG -c -o $@ $<
|
||||
|
||||
$(OBJDIR)/tools/input_context_joyconfig.o: input/input_context.c
|
||||
@mkdir -p $(dir $@)
|
||||
@$(if $(Q), $(shell echo echo CC $<),)
|
||||
$(Q)$(CC) $(CFLAGS) $(DEFINES) -MMD -DIS_JOYCONFIG -c -o $@ $<
|
||||
|
||||
$(OBJDIR)/tools/input_common_joyconfig.o: input/input_common.c
|
||||
@mkdir -p $(dir $@)
|
||||
@$(if $(Q), $(shell echo echo CC $<),)
|
||||
|
@ -111,6 +111,7 @@ OBJ += frontend/frontend.o \
|
||||
gfx/gfx_common.o \
|
||||
gfx/fonts/bitmapfont.o \
|
||||
input/input_autodetect.o \
|
||||
input/input_context.o \
|
||||
input/input_common.o \
|
||||
input/keyboard_line.o \
|
||||
input/overlay.o \
|
||||
@ -636,4 +637,5 @@ JOYCONFIG_OBJ += tools/retroarch-joyconfig.o \
|
||||
libretro-sdk/file/file_path.o \
|
||||
libretro-sdk/string/string_list.o \
|
||||
libretro-sdk/compat/compat.o \
|
||||
tools/input_context_joyconfig.o \
|
||||
tools/input_common_joyconfig.o
|
||||
|
@ -281,6 +281,7 @@ FONTS
|
||||
INPUT
|
||||
============================================================ */
|
||||
#include "../input/input_autodetect.c"
|
||||
#include "../input/input_context.c"
|
||||
#include "../input/input_common.c"
|
||||
#include "../input/keyboard_line.c"
|
||||
|
||||
|
@ -49,89 +49,6 @@
|
||||
#endif
|
||||
|
||||
|
||||
rarch_joypad_driver_t *joypad_drivers[] = {
|
||||
#ifdef __CELLOS_LV2__
|
||||
&ps3_joypad,
|
||||
#endif
|
||||
#ifdef HAVE_WINXINPUT
|
||||
&winxinput_joypad,
|
||||
#endif
|
||||
#ifdef GEKKO
|
||||
&gx_joypad,
|
||||
#endif
|
||||
#ifdef _XBOX
|
||||
&xdk_joypad,
|
||||
#endif
|
||||
#ifdef PSP
|
||||
&psp_joypad,
|
||||
#endif
|
||||
#ifdef HAVE_DINPUT
|
||||
&dinput_joypad,
|
||||
#endif
|
||||
#ifdef HAVE_UDEV
|
||||
&udev_joypad,
|
||||
#endif
|
||||
#if defined(__linux) && !defined(ANDROID)
|
||||
&linuxraw_joypad,
|
||||
#endif
|
||||
#ifdef HAVE_PARPORT
|
||||
&parport_joypad,
|
||||
#endif
|
||||
#ifdef ANDROID
|
||||
&android_joypad,
|
||||
#endif
|
||||
#if defined(HAVE_SDL) || defined(HAVE_SDL2)
|
||||
&sdl_joypad,
|
||||
#endif
|
||||
#ifdef __MACH__
|
||||
#ifdef HAVE_HID
|
||||
&apple_hid_joypad,
|
||||
#endif
|
||||
#ifdef IOS
|
||||
&apple_ios_joypad,
|
||||
#endif
|
||||
#endif
|
||||
#ifdef __QNX__
|
||||
&qnx_joypad,
|
||||
#endif
|
||||
NULL,
|
||||
};
|
||||
|
||||
const rarch_joypad_driver_t *input_joypad_init_driver(const char *ident)
|
||||
{
|
||||
unsigned i;
|
||||
if (!ident || !*ident)
|
||||
return input_joypad_init_first();
|
||||
|
||||
for (i = 0; joypad_drivers[i]; i++)
|
||||
{
|
||||
if (strcmp(ident, joypad_drivers[i]->ident) == 0
|
||||
&& joypad_drivers[i]->init())
|
||||
{
|
||||
RARCH_LOG("Found joypad driver: \"%s\".\n",
|
||||
joypad_drivers[i]->ident);
|
||||
return joypad_drivers[i];
|
||||
}
|
||||
}
|
||||
|
||||
return input_joypad_init_first();
|
||||
}
|
||||
|
||||
const rarch_joypad_driver_t *input_joypad_init_first(void)
|
||||
{
|
||||
unsigned i;
|
||||
for (i = 0; joypad_drivers[i]; i++)
|
||||
{
|
||||
if (joypad_drivers[i]->init())
|
||||
{
|
||||
RARCH_LOG("Found joypad driver: \"%s\".\n",
|
||||
joypad_drivers[i]->ident);
|
||||
return joypad_drivers[i];
|
||||
}
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
const char *input_joypad_name(const rarch_joypad_driver_t *drv,
|
||||
unsigned joypad)
|
||||
|
@ -17,6 +17,7 @@
|
||||
#define INPUT_COMMON_H__
|
||||
|
||||
#include "input_autodetect.h"
|
||||
#include "input_context.h"
|
||||
#include "../driver.h"
|
||||
#include <file/config_file.h>
|
||||
#include "../general.h"
|
||||
@ -55,23 +56,6 @@ static inline void input_conv_analog_id_to_bind_id(unsigned idx, unsigned ident,
|
||||
}
|
||||
}
|
||||
|
||||
#if 0
|
||||
static inline bool get_bit(const uint8_t *buf, unsigned bit)
|
||||
{
|
||||
return buf[bit >> 3] & (1 << (bit & 7));
|
||||
}
|
||||
|
||||
static inline void clear_bit(uint8_t *buf, unsigned bit)
|
||||
{
|
||||
buf[bit >> 3] &= ~(1 << (bit & 7));
|
||||
}
|
||||
|
||||
static inline void set_bit(uint8_t *buf, unsigned bit)
|
||||
{
|
||||
buf[bit >> 3] |= 1 << (bit & 7);
|
||||
}
|
||||
#endif
|
||||
|
||||
bool input_translate_coord_viewport(int mouse_x, int mouse_y,
|
||||
int16_t *res_x, int16_t *res_y, int16_t *res_screen_x,
|
||||
int16_t *res_screen_y);
|
||||
@ -85,26 +69,6 @@ enum back_button_enums
|
||||
};
|
||||
#endif
|
||||
|
||||
struct rarch_joypad_driver
|
||||
{
|
||||
bool (*init)(void);
|
||||
bool (*query_pad)(unsigned);
|
||||
void (*destroy)(void);
|
||||
bool (*button)(unsigned, uint16_t);
|
||||
int16_t (*axis)(unsigned, uint32_t);
|
||||
void (*poll)(void);
|
||||
bool (*set_rumble)(unsigned, enum retro_rumble_effect, uint16_t);
|
||||
const char *(*name)(unsigned);
|
||||
|
||||
const char *ident;
|
||||
};
|
||||
|
||||
/* If ident points to NULL or a zero-length string,
|
||||
* equivalent to calling input_joypad_init_first(). */
|
||||
const rarch_joypad_driver_t *input_joypad_init_driver(const char *ident);
|
||||
|
||||
const rarch_joypad_driver_t *input_joypad_init_first(void);
|
||||
|
||||
bool input_joypad_pressed(const rarch_joypad_driver_t *driver,
|
||||
unsigned port, const struct retro_keybind *binds, unsigned key);
|
||||
|
||||
@ -127,21 +91,6 @@ bool input_joypad_hat_raw(const rarch_joypad_driver_t *driver,
|
||||
const char *input_joypad_name(const rarch_joypad_driver_t *driver,
|
||||
unsigned joypad);
|
||||
|
||||
extern rarch_joypad_driver_t dinput_joypad;
|
||||
extern rarch_joypad_driver_t linuxraw_joypad;
|
||||
extern rarch_joypad_driver_t parport_joypad;
|
||||
extern rarch_joypad_driver_t udev_joypad;
|
||||
extern rarch_joypad_driver_t winxinput_joypad;
|
||||
extern rarch_joypad_driver_t sdl_joypad;
|
||||
extern rarch_joypad_driver_t ps3_joypad;
|
||||
extern rarch_joypad_driver_t psp_joypad;
|
||||
extern rarch_joypad_driver_t xdk_joypad;
|
||||
extern rarch_joypad_driver_t gx_joypad;
|
||||
extern rarch_joypad_driver_t apple_hid_joypad;
|
||||
extern rarch_joypad_driver_t apple_ios_joypad;
|
||||
extern rarch_joypad_driver_t android_joypad;
|
||||
extern rarch_joypad_driver_t qnx_joypad;
|
||||
|
||||
struct rarch_key_map
|
||||
{
|
||||
unsigned sym;
|
||||
|
104
input/input_context.c
Normal file
104
input/input_context.c
Normal file
@ -0,0 +1,104 @@
|
||||
/* RetroArch - A frontend for libretro.
|
||||
* Copyright (C) 2010-2014 - Hans-Kristian Arntzen
|
||||
* Copyright (C) 2011-2014 - Daniel De Matteis
|
||||
*
|
||||
* 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 "input_context.h"
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
#include "../general.h"
|
||||
|
||||
rarch_joypad_driver_t *joypad_drivers[] = {
|
||||
#ifdef __CELLOS_LV2__
|
||||
&ps3_joypad,
|
||||
#endif
|
||||
#ifdef HAVE_WINXINPUT
|
||||
&winxinput_joypad,
|
||||
#endif
|
||||
#ifdef GEKKO
|
||||
&gx_joypad,
|
||||
#endif
|
||||
#ifdef _XBOX
|
||||
&xdk_joypad,
|
||||
#endif
|
||||
#ifdef PSP
|
||||
&psp_joypad,
|
||||
#endif
|
||||
#ifdef HAVE_DINPUT
|
||||
&dinput_joypad,
|
||||
#endif
|
||||
#ifdef HAVE_UDEV
|
||||
&udev_joypad,
|
||||
#endif
|
||||
#if defined(__linux) && !defined(ANDROID)
|
||||
&linuxraw_joypad,
|
||||
#endif
|
||||
#ifdef HAVE_PARPORT
|
||||
&parport_joypad,
|
||||
#endif
|
||||
#ifdef ANDROID
|
||||
&android_joypad,
|
||||
#endif
|
||||
#if defined(HAVE_SDL) || defined(HAVE_SDL2)
|
||||
&sdl_joypad,
|
||||
#endif
|
||||
#ifdef __MACH__
|
||||
#ifdef HAVE_HID
|
||||
&apple_hid_joypad,
|
||||
#endif
|
||||
#ifdef IOS
|
||||
&apple_ios_joypad,
|
||||
#endif
|
||||
#endif
|
||||
#ifdef __QNX__
|
||||
&qnx_joypad,
|
||||
#endif
|
||||
NULL,
|
||||
};
|
||||
|
||||
const rarch_joypad_driver_t *input_joypad_init_driver(const char *ident)
|
||||
{
|
||||
unsigned i;
|
||||
if (!ident || !*ident)
|
||||
return input_joypad_init_first();
|
||||
|
||||
for (i = 0; joypad_drivers[i]; i++)
|
||||
{
|
||||
if (strcmp(ident, joypad_drivers[i]->ident) == 0
|
||||
&& joypad_drivers[i]->init())
|
||||
{
|
||||
RARCH_LOG("Found joypad driver: \"%s\".\n",
|
||||
joypad_drivers[i]->ident);
|
||||
return joypad_drivers[i];
|
||||
}
|
||||
}
|
||||
|
||||
return input_joypad_init_first();
|
||||
}
|
||||
|
||||
const rarch_joypad_driver_t *input_joypad_init_first(void)
|
||||
{
|
||||
unsigned i;
|
||||
for (i = 0; joypad_drivers[i]; i++)
|
||||
{
|
||||
if (joypad_drivers[i]->init())
|
||||
{
|
||||
RARCH_LOG("Found joypad driver: \"%s\".\n",
|
||||
joypad_drivers[i]->ident);
|
||||
return joypad_drivers[i];
|
||||
}
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
69
input/input_context.h
Normal file
69
input/input_context.h
Normal file
@ -0,0 +1,69 @@
|
||||
/* RetroArch - A frontend for libretro.
|
||||
* Copyright (C) 2010-2014 - Hans-Kristian Arntzen
|
||||
* Copyright (C) 2011-2014 - Daniel De Matteis
|
||||
*
|
||||
* 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_CONTEXT_H__
|
||||
#define INPUT_CONTEXT_H__
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include <stdint.h>
|
||||
#include <boolean.h>
|
||||
|
||||
typedef struct rarch_joypad_driver rarch_joypad_driver_t;
|
||||
enum retro_rumble_effect;
|
||||
|
||||
struct rarch_joypad_driver
|
||||
{
|
||||
bool (*init)(void);
|
||||
bool (*query_pad)(unsigned);
|
||||
void (*destroy)(void);
|
||||
bool (*button)(unsigned, uint16_t);
|
||||
int16_t (*axis)(unsigned, uint32_t);
|
||||
void (*poll)(void);
|
||||
bool (*set_rumble)(unsigned, enum retro_rumble_effect, uint16_t);
|
||||
const char *(*name)(unsigned);
|
||||
|
||||
const char *ident;
|
||||
};
|
||||
|
||||
/* If ident points to NULL or a zero-length string,
|
||||
* equivalent to calling input_joypad_init_first(). */
|
||||
const rarch_joypad_driver_t *input_joypad_init_driver(const char *ident);
|
||||
|
||||
const rarch_joypad_driver_t *input_joypad_init_first(void);
|
||||
|
||||
extern rarch_joypad_driver_t dinput_joypad;
|
||||
extern rarch_joypad_driver_t linuxraw_joypad;
|
||||
extern rarch_joypad_driver_t parport_joypad;
|
||||
extern rarch_joypad_driver_t udev_joypad;
|
||||
extern rarch_joypad_driver_t winxinput_joypad;
|
||||
extern rarch_joypad_driver_t sdl_joypad;
|
||||
extern rarch_joypad_driver_t ps3_joypad;
|
||||
extern rarch_joypad_driver_t psp_joypad;
|
||||
extern rarch_joypad_driver_t xdk_joypad;
|
||||
extern rarch_joypad_driver_t gx_joypad;
|
||||
extern rarch_joypad_driver_t apple_hid_joypad;
|
||||
extern rarch_joypad_driver_t apple_ios_joypad;
|
||||
extern rarch_joypad_driver_t android_joypad;
|
||||
extern rarch_joypad_driver_t qnx_joypad;
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
Loading…
x
Reference in New Issue
Block a user