mirror of
https://github.com/libretro/libretro-samples.git
synced 2024-06-16 11:17:33 -04:00
Add input/button_test
This commit is contained in:
parent
d89fdda287
commit
5f6a8d2404
145
input/button_test/Makefile
Normal file
145
input/button_test/Makefile
Normal file
|
@ -0,0 +1,145 @@
|
|||
STATIC_LINKING := 0
|
||||
AR := ar
|
||||
|
||||
ifeq ($(platform),)
|
||||
platform = unix
|
||||
ifeq ($(shell uname -a),)
|
||||
platform = win
|
||||
else ifneq ($(findstring MINGW,$(shell uname -a)),)
|
||||
platform = win
|
||||
else ifneq ($(findstring Darwin,$(shell uname -a)),)
|
||||
platform = osx
|
||||
else ifneq ($(findstring win,$(shell uname -a)),)
|
||||
platform = win
|
||||
endif
|
||||
endif
|
||||
|
||||
# system platform
|
||||
system_platform = unix
|
||||
ifeq ($(shell uname -a),)
|
||||
EXE_EXT = .exe
|
||||
system_platform = win
|
||||
else ifneq ($(findstring Darwin,$(shell uname -a)),)
|
||||
system_platform = osx
|
||||
arch = intel
|
||||
ifeq ($(shell uname -p),powerpc)
|
||||
arch = ppc
|
||||
endif
|
||||
else ifneq ($(findstring MINGW,$(shell uname -a)),)
|
||||
system_platform = win
|
||||
endif
|
||||
|
||||
TARGET_NAME := button_test
|
||||
LIBM = -lm
|
||||
|
||||
ifeq ($(ARCHFLAGS),)
|
||||
ifeq ($(archs),ppc)
|
||||
ARCHFLAGS = -arch ppc -arch ppc64
|
||||
else
|
||||
ARCHFLAGS = -arch i386 -arch x86_64
|
||||
endif
|
||||
endif
|
||||
|
||||
ifeq ($(platform), osx)
|
||||
ifndef ($(NOUNIVERSAL))
|
||||
CFLAGS += $(ARCHFLAGS)
|
||||
LFLAGS += $(ARCHFLAGS)
|
||||
endif
|
||||
endif
|
||||
|
||||
ifeq ($(STATIC_LINKING), 1)
|
||||
EXT := a
|
||||
endif
|
||||
|
||||
ifeq ($(platform), unix)
|
||||
EXT ?= so
|
||||
TARGET := $(TARGET_NAME)_libretro.$(EXT)
|
||||
fpic := -fPIC
|
||||
SHARED := -shared -Wl,--version-script=link.T -Wl,--no-undefined
|
||||
else ifeq ($(platform), linux-portable)
|
||||
TARGET := $(TARGET_NAME)_libretro.$(EXT)
|
||||
fpic := -fPIC -nostdlib
|
||||
SHARED := -shared -Wl,--version-script=link.T
|
||||
LIBM :=
|
||||
else ifneq (,$(findstring osx,$(platform)))
|
||||
TARGET := $(TARGET_NAME)_libretro.dylib
|
||||
fpic := -fPIC
|
||||
SHARED := -dynamiclib
|
||||
else ifneq (,$(findstring ios,$(platform)))
|
||||
TARGET := $(TARGET_NAME)_libretro_ios.dylib
|
||||
fpic := -fPIC
|
||||
SHARED := -dynamiclib
|
||||
|
||||
ifeq ($(IOSSDK),)
|
||||
IOSSDK := $(shell xcodebuild -version -sdk iphoneos Path)
|
||||
endif
|
||||
|
||||
DEFINES := -DIOS
|
||||
CC = cc -arch armv7 -isysroot $(IOSSDK)
|
||||
ifeq ($(platform),ios9)
|
||||
CC += -miphoneos-version-min=8.0
|
||||
CFLAGS += -miphoneos-version-min=8.0
|
||||
else
|
||||
CC += -miphoneos-version-min=5.0
|
||||
CFLAGS += -miphoneos-version-min=5.0
|
||||
endif
|
||||
else ifneq (,$(findstring qnx,$(platform)))
|
||||
TARGET := $(TARGET_NAME)_libretro_qnx.so
|
||||
fpic := -fPIC
|
||||
SHARED := -shared -Wl,--version-script=link.T -Wl,--no-undefined
|
||||
else ifeq ($(platform), emscripten)
|
||||
TARGET := $(TARGET_NAME)_libretro_emscripten.bc
|
||||
fpic := -fPIC
|
||||
SHARED := -shared -Wl,--version-script=link.T -Wl,--no-undefined
|
||||
else ifeq ($(platform), vita)
|
||||
TARGET := $(TARGET_NAME)_vita.a
|
||||
CC = arm-vita-eabi-gcc
|
||||
AR = arm-vita-eabi-ar
|
||||
CFLAGS += -Wl,-q -O3
|
||||
STATIC_LINKING = 1
|
||||
else
|
||||
CC = gcc
|
||||
TARGET := $(TARGET_NAME)_libretro.dll
|
||||
SHARED := -shared -static-libgcc -static-libstdc++ -s -Wl,--version-script=link.T -Wl,--no-undefined
|
||||
endif
|
||||
|
||||
|
||||
LDFLAGS += $(LIBM)
|
||||
|
||||
ifeq ($(platform), win)
|
||||
LDFLAGS += -lws2_32
|
||||
endif
|
||||
|
||||
ifeq ($(DEBUG), 1)
|
||||
CFLAGS += -O0 -g
|
||||
else
|
||||
CFLAGS += -O3
|
||||
endif
|
||||
|
||||
OBJECTS := libretro.o
|
||||
|
||||
CFLAGS += -pedantic $(fpic)
|
||||
|
||||
ifneq (,$(findstring qnx,$(platform)))
|
||||
CFLAGS += -Wc,-std=c99
|
||||
else
|
||||
CFLAGS += -std=gnu99
|
||||
endif
|
||||
|
||||
all: $(TARGET)
|
||||
|
||||
$(TARGET): $(OBJECTS)
|
||||
ifeq ($(STATIC_LINKING), 1)
|
||||
$(AR) rcs $@ $(OBJECTS)
|
||||
else
|
||||
$(CC) $(fpic) $(SHARED) $(INCLUDES) -o $@ $(OBJECTS) $(LDFLAGS)
|
||||
endif
|
||||
|
||||
%.o: %.c
|
||||
$(CC) $(CFLAGS) -c -o $@ $<
|
||||
|
||||
clean:
|
||||
rm -f $(OBJECTS) $(TARGET)
|
||||
|
||||
.PHONY: clean
|
||||
|
11
input/button_test/README.md
Normal file
11
input/button_test/README.md
Normal file
|
@ -0,0 +1,11 @@
|
|||
# buttontest
|
||||
A libretro core showing a graphic image of the Retropad gamepad. Pressing the buttons on the physical pad will
|
||||
highlight the buttons onscreen.
|
||||
|
||||
## Programming language
|
||||
C
|
||||
|
||||
## Building
|
||||
To compile, you will need a C compiler and assorted toolchain installed.
|
||||
|
||||
make
|
1
input/button_test/internal_cores.h
Normal file
1
input/button_test/internal_cores.h
Normal file
|
@ -0,0 +1 @@
|
|||
#include "../internal_cores.h"
|
25
input/button_test/jni/Android.mk
Normal file
25
input/button_test/jni/Android.mk
Normal file
|
@ -0,0 +1,25 @@
|
|||
LOCAL_PATH := $(call my-dir)
|
||||
|
||||
include $(CLEAR_VARS)
|
||||
|
||||
APP_DIR := ../../src
|
||||
|
||||
LOCAL_MODULE := retro
|
||||
|
||||
ifeq ($(TARGET_ARCH),arm)
|
||||
LOCAL_CFLAGS += -DANDROID_ARM
|
||||
endif
|
||||
|
||||
ifeq ($(TARGET_ARCH),x86)
|
||||
LOCAL_CFLAGS += -DANDROID_X86
|
||||
endif
|
||||
|
||||
ifeq ($(TARGET_ARCH),mips)
|
||||
LOCAL_CFLAGS += -DANDROID_MIPS -D__mips__ -D__MIPSEL__
|
||||
endif
|
||||
|
||||
LOCAL_SRC_FILES += ../libretro-test.c
|
||||
LOCAL_CFLAGS += -O3 -std=gnu99 -ffast-math -funroll-loops
|
||||
|
||||
|
||||
include $(BUILD_SHARED_LIBRARY)
|
1
input/button_test/jni/Application.mk
Normal file
1
input/button_test/jni/Application.mk
Normal file
|
@ -0,0 +1 @@
|
|||
APP_ABI := all
|
397
input/button_test/libretro.c
Normal file
397
input/button_test/libretro.c
Normal file
|
@ -0,0 +1,397 @@
|
|||
#include <stdio.h>
|
||||
#include <stdint.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdarg.h>
|
||||
#include <string.h>
|
||||
#include <math.h>
|
||||
|
||||
#include "retro_miscellaneous.h"
|
||||
|
||||
#include "libretro.h"
|
||||
|
||||
#ifdef RARCH_INTERNAL
|
||||
#include "internal_cores.h"
|
||||
#define NETRETROPAD_CORE_PREFIX(s) libretro_netretropad_##s
|
||||
#else
|
||||
#define NETRETROPAD_CORE_PREFIX(s) s
|
||||
#endif
|
||||
|
||||
#include "remotepad.h"
|
||||
|
||||
#define DESC_NUM_PORTS(desc) ((desc)->port_max - (desc)->port_min + 1)
|
||||
#define DESC_NUM_INDICES(desc) ((desc)->index_max - (desc)->index_min + 1)
|
||||
#define DESC_NUM_IDS(desc) ((desc)->id_max - (desc)->id_min + 1)
|
||||
|
||||
#define DESC_OFFSET(desc, port, index, id) ( \
|
||||
port * ((desc)->index_max - (desc)->index_min + 1) * ((desc)->id_max - (desc)->id_min + 1) + \
|
||||
index * ((desc)->id_max - (desc)->id_min + 1) + \
|
||||
id \
|
||||
)
|
||||
|
||||
struct descriptor {
|
||||
int device;
|
||||
int port_min;
|
||||
int port_max;
|
||||
int index_min;
|
||||
int index_max;
|
||||
int id_min;
|
||||
int id_max;
|
||||
uint16_t *value;
|
||||
};
|
||||
|
||||
struct remote_joypad_message {
|
||||
int port;
|
||||
int device;
|
||||
int index;
|
||||
int id;
|
||||
uint16_t state;
|
||||
};
|
||||
|
||||
static struct retro_log_callback logger;
|
||||
|
||||
static retro_log_printf_t NETRETROPAD_CORE_PREFIX(log_cb);
|
||||
static retro_video_refresh_t NETRETROPAD_CORE_PREFIX(video_cb);
|
||||
static retro_audio_sample_t NETRETROPAD_CORE_PREFIX(audio_cb);
|
||||
static retro_audio_sample_batch_t NETRETROPAD_CORE_PREFIX(audio_batch_cb);
|
||||
static retro_environment_t NETRETROPAD_CORE_PREFIX(environ_cb);
|
||||
static retro_input_poll_t NETRETROPAD_CORE_PREFIX(input_poll_cb);
|
||||
static retro_input_state_t NETRETROPAD_CORE_PREFIX(input_state_cb);
|
||||
|
||||
static uint16_t *frame_buf;
|
||||
|
||||
static struct descriptor joypad = {
|
||||
.device = RETRO_DEVICE_JOYPAD,
|
||||
.port_min = 0,
|
||||
.port_max = 0,
|
||||
.index_min = 0,
|
||||
.index_max = 0,
|
||||
.id_min = RETRO_DEVICE_ID_JOYPAD_B,
|
||||
.id_max = RETRO_DEVICE_ID_JOYPAD_R3
|
||||
};
|
||||
|
||||
static struct descriptor analog = {
|
||||
.device = RETRO_DEVICE_ANALOG,
|
||||
.port_min = 0,
|
||||
.port_max = 0,
|
||||
.index_min = RETRO_DEVICE_INDEX_ANALOG_LEFT,
|
||||
.index_max = RETRO_DEVICE_INDEX_ANALOG_RIGHT,
|
||||
.id_min = RETRO_DEVICE_ID_ANALOG_X,
|
||||
.id_max = RETRO_DEVICE_ID_ANALOG_Y
|
||||
};
|
||||
|
||||
static struct descriptor *descriptors[] = {
|
||||
&joypad,
|
||||
&analog
|
||||
};
|
||||
|
||||
void NETRETROPAD_CORE_PREFIX(retro_init)(void)
|
||||
{
|
||||
struct descriptor *desc;
|
||||
int size;
|
||||
int i;
|
||||
|
||||
frame_buf = (uint16_t*)calloc(320 * 240, sizeof(uint16_t));
|
||||
|
||||
if (frame_buf)
|
||||
{
|
||||
uint16_t *pixel = frame_buf + 49 * 320 + 32;
|
||||
|
||||
for (unsigned rle = 0; rle < sizeof(body); )
|
||||
{
|
||||
uint16_t color = 0;
|
||||
|
||||
for (unsigned runs = body[rle++]; runs > 0; runs--)
|
||||
{
|
||||
for (unsigned count = body[rle++]; count > 0; count--)
|
||||
{
|
||||
*pixel++ = color;
|
||||
}
|
||||
|
||||
color = 0x4208 - color;
|
||||
}
|
||||
|
||||
pixel += 65;
|
||||
}
|
||||
}
|
||||
|
||||
/* Allocate descriptor values */
|
||||
for (i = 0; i < ARRAY_SIZE(descriptors); i++) {
|
||||
desc = descriptors[i];
|
||||
size = DESC_NUM_PORTS(desc) * DESC_NUM_INDICES(desc) * DESC_NUM_IDS(desc);
|
||||
descriptors[i]->value = (uint16_t*)calloc(size, sizeof(uint16_t));
|
||||
}
|
||||
}
|
||||
|
||||
void NETRETROPAD_CORE_PREFIX(retro_deinit)(void)
|
||||
{
|
||||
int i;
|
||||
|
||||
if (frame_buf)
|
||||
free(frame_buf);
|
||||
frame_buf = NULL;
|
||||
|
||||
/* Free descriptor values */
|
||||
for (i = 0; i < ARRAY_SIZE(descriptors); i++) {
|
||||
free(descriptors[i]->value);
|
||||
descriptors[i]->value = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
unsigned NETRETROPAD_CORE_PREFIX(retro_api_version)(void)
|
||||
{
|
||||
return RETRO_API_VERSION;
|
||||
}
|
||||
|
||||
void NETRETROPAD_CORE_PREFIX(retro_set_controller_port_device)(
|
||||
unsigned port, unsigned device)
|
||||
{
|
||||
(void)port;
|
||||
(void)device;
|
||||
}
|
||||
|
||||
void NETRETROPAD_CORE_PREFIX(retro_get_system_info)(
|
||||
struct retro_system_info *info)
|
||||
{
|
||||
memset(info, 0, sizeof(*info));
|
||||
info->library_name = "RetroPad Remote";
|
||||
info->library_version = "0.01";
|
||||
info->need_fullpath = false;
|
||||
info->valid_extensions = ""; /* Nothing. */
|
||||
}
|
||||
|
||||
void NETRETROPAD_CORE_PREFIX(retro_get_system_av_info)(
|
||||
struct retro_system_av_info *info)
|
||||
{
|
||||
info->timing.fps = 60.0;
|
||||
info->timing.sample_rate = 30000.0;
|
||||
|
||||
info->geometry.base_width = 320;
|
||||
info->geometry.base_height = 240;
|
||||
info->geometry.max_width = 320;
|
||||
info->geometry.max_height = 240;
|
||||
info->geometry.aspect_ratio = 4.0 / 3.0;
|
||||
}
|
||||
|
||||
void NETRETROPAD_CORE_PREFIX(retro_set_environment)(retro_environment_t cb)
|
||||
{
|
||||
static const struct retro_variable vars[] = {
|
||||
{ NULL, NULL },
|
||||
};
|
||||
enum retro_pixel_format fmt = RETRO_PIXEL_FORMAT_RGB565;
|
||||
cb(RETRO_ENVIRONMENT_SET_VARIABLES, (void*)vars);
|
||||
|
||||
|
||||
NETRETROPAD_CORE_PREFIX(environ_cb) = cb;
|
||||
bool no_content = true;
|
||||
cb(RETRO_ENVIRONMENT_SET_SUPPORT_NO_GAME, &no_content);
|
||||
|
||||
NETRETROPAD_CORE_PREFIX(environ_cb)(RETRO_ENVIRONMENT_SET_PIXEL_FORMAT, &fmt);
|
||||
|
||||
if (cb(RETRO_ENVIRONMENT_GET_LOG_INTERFACE, &logger))
|
||||
NETRETROPAD_CORE_PREFIX(log_cb) = logger.log;
|
||||
}
|
||||
|
||||
static void netretropad_check_variables(void)
|
||||
{
|
||||
}
|
||||
|
||||
void NETRETROPAD_CORE_PREFIX(retro_set_audio_sample)(retro_audio_sample_t cb)
|
||||
{
|
||||
NETRETROPAD_CORE_PREFIX(audio_cb) = cb;
|
||||
}
|
||||
|
||||
void NETRETROPAD_CORE_PREFIX(retro_set_audio_sample_batch)(
|
||||
retro_audio_sample_batch_t cb)
|
||||
{
|
||||
NETRETROPAD_CORE_PREFIX(audio_batch_cb) = cb;
|
||||
}
|
||||
|
||||
void NETRETROPAD_CORE_PREFIX(retro_set_input_poll)(retro_input_poll_t cb)
|
||||
{
|
||||
NETRETROPAD_CORE_PREFIX(input_poll_cb) = cb;
|
||||
}
|
||||
|
||||
void NETRETROPAD_CORE_PREFIX(retro_set_input_state)(retro_input_state_t cb)
|
||||
{
|
||||
NETRETROPAD_CORE_PREFIX(input_state_cb) = cb;
|
||||
}
|
||||
|
||||
void NETRETROPAD_CORE_PREFIX(retro_set_video_refresh)(retro_video_refresh_t cb)
|
||||
{
|
||||
NETRETROPAD_CORE_PREFIX(video_cb) = cb;
|
||||
}
|
||||
|
||||
void NETRETROPAD_CORE_PREFIX(retro_reset)(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;
|
||||
|
||||
/* Poll input */
|
||||
NETRETROPAD_CORE_PREFIX(input_poll_cb)();
|
||||
|
||||
/* Parse descriptors */
|
||||
for (i = 0; i < ARRAY_SIZE(descriptors); i++) {
|
||||
/* Get current descriptor */
|
||||
desc = descriptors[i];
|
||||
|
||||
/* Go through range of ports/indices/IDs */
|
||||
for (port = desc->port_min; port <= desc->port_max; port++)
|
||||
for (index = desc->index_min; index <= desc->index_max; index++)
|
||||
for (id = desc->id_min; id <= desc->id_max; id++) {
|
||||
/* Compute offset into array */
|
||||
offset = DESC_OFFSET(desc, port, index, id);
|
||||
|
||||
/* Get old state */
|
||||
old = desc->value[offset];
|
||||
|
||||
/* Get new state */
|
||||
state = NETRETROPAD_CORE_PREFIX(input_state_cb)(
|
||||
port,
|
||||
desc->device,
|
||||
index,
|
||||
id);
|
||||
|
||||
/* Continue if state is unchanged */
|
||||
if (state == old)
|
||||
continue;
|
||||
|
||||
/* Update state */
|
||||
desc->value[offset] = state;
|
||||
|
||||
/* Attempt to send updated state */
|
||||
msg.port = port;
|
||||
msg.device = desc->device;
|
||||
msg.index = index;
|
||||
msg.id = id;
|
||||
msg.state = state;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void NETRETROPAD_CORE_PREFIX(retro_run)(void)
|
||||
{
|
||||
unsigned rle, runs;
|
||||
uint16_t *pixel = NULL;
|
||||
unsigned input_state = 0;
|
||||
int offset;
|
||||
int i;
|
||||
|
||||
/* Update input states and send them if needed */
|
||||
retropad_update_input();
|
||||
|
||||
/* Combine RetroPad input states into one value */
|
||||
for (i = joypad.id_min; i <= joypad.id_max; i++) {
|
||||
offset = DESC_OFFSET(&joypad, 0, 0, i);
|
||||
if (joypad.value[offset])
|
||||
input_state |= 1 << i;
|
||||
}
|
||||
|
||||
pixel = frame_buf + 49 * 320 + 32;
|
||||
|
||||
for (rle = 0; rle < sizeof(retropad_buttons); )
|
||||
{
|
||||
char paint = 0;
|
||||
|
||||
for (runs = retropad_buttons[rle++]; runs > 0; runs--)
|
||||
{
|
||||
unsigned button = paint ? 1 << retropad_buttons[rle++] : 0;
|
||||
|
||||
if (paint)
|
||||
{
|
||||
unsigned count;
|
||||
uint16_t color = (input_state & button) ? 0x0500 : 0xffff;
|
||||
|
||||
for (count = retropad_buttons[rle++]; count > 0; count--)
|
||||
*pixel++ = color;
|
||||
}
|
||||
else
|
||||
pixel += retropad_buttons[rle++];
|
||||
|
||||
paint = !paint;
|
||||
}
|
||||
|
||||
pixel += 65;
|
||||
}
|
||||
|
||||
|
||||
NETRETROPAD_CORE_PREFIX(video_cb)(frame_buf, 320, 240, 640);
|
||||
|
||||
retro_sleep(4);
|
||||
}
|
||||
|
||||
bool NETRETROPAD_CORE_PREFIX(retro_load_game)(const struct retro_game_info *info)
|
||||
{
|
||||
netretropad_check_variables();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void NETRETROPAD_CORE_PREFIX(retro_unload_game)(void)
|
||||
{}
|
||||
|
||||
unsigned NETRETROPAD_CORE_PREFIX(retro_get_region)(void)
|
||||
{
|
||||
return RETRO_REGION_NTSC;
|
||||
}
|
||||
|
||||
bool NETRETROPAD_CORE_PREFIX(retro_load_game_special)(unsigned type,
|
||||
const struct retro_game_info *info, size_t num)
|
||||
{
|
||||
(void)type;
|
||||
(void)info;
|
||||
(void)num;
|
||||
return false;
|
||||
}
|
||||
|
||||
size_t NETRETROPAD_CORE_PREFIX(retro_serialize_size)(void)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
bool NETRETROPAD_CORE_PREFIX(retro_serialize)(void *data, size_t size)
|
||||
{
|
||||
(void)data;
|
||||
(void)size;
|
||||
return false;
|
||||
}
|
||||
|
||||
bool NETRETROPAD_CORE_PREFIX(retro_unserialize)(const void *data,
|
||||
size_t size)
|
||||
{
|
||||
(void)data;
|
||||
(void)size;
|
||||
return false;
|
||||
}
|
||||
|
||||
void *NETRETROPAD_CORE_PREFIX(retro_get_memory_data)(unsigned id)
|
||||
{
|
||||
(void)id;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
size_t NETRETROPAD_CORE_PREFIX(retro_get_memory_size)(unsigned id)
|
||||
{
|
||||
(void)id;
|
||||
return 0;
|
||||
}
|
||||
|
||||
void NETRETROPAD_CORE_PREFIX(retro_cheat_reset)(void)
|
||||
{}
|
||||
|
||||
void NETRETROPAD_CORE_PREFIX(retro_cheat_set)(unsigned idx,
|
||||
bool enabled, const char *code)
|
||||
{
|
||||
(void)idx;
|
||||
(void)enabled;
|
||||
(void)code;
|
||||
}
|
2129
input/button_test/libretro.h
Normal file
2129
input/button_test/libretro.h
Normal file
File diff suppressed because it is too large
Load diff
5
input/button_test/link.T
Normal file
5
input/button_test/link.T
Normal file
|
@ -0,0 +1,5 @@
|
|||
{
|
||||
global: retro_*;
|
||||
local: *;
|
||||
};
|
||||
|
300
input/button_test/remotepad.h
Normal file
300
input/button_test/remotepad.h
Normal file
|
@ -0,0 +1,300 @@
|
|||
#ifndef REMOTEPAD_H
|
||||
#define REMOTEPAD_H
|
||||
|
||||
static uint8_t body[] =
|
||||
{
|
||||
/* 0 */ 3, 38, 13, 204,
|
||||
/* 1 */ 3, 35, 21, 199,
|
||||
/* 2 */ 3, 33, 26, 196,
|
||||
/* 3 */ 3, 32, 28, 195,
|
||||
/* 4 */ 3, 32, 29, 194,
|
||||
/* 5 */ 5, 31, 31, 133, 28, 32,
|
||||
/* 6 */ 5, 31, 31, 133, 31, 29,
|
||||
/* 7 */ 5, 31, 31, 133, 31, 29,
|
||||
/* 8 */ 5, 31, 31, 132, 32, 29,
|
||||
/* 9 */ 5, 31, 31, 132, 32, 29,
|
||||
/* 10 */ 5, 30, 32, 132, 32, 29,
|
||||
/* 11 */ 5, 28, 35, 129, 35, 28,
|
||||
/* 12 */ 5, 27, 37, 127, 37, 27,
|
||||
/* 13 */ 5, 26, 39, 125, 39, 26,
|
||||
/* 14 */ 5, 25, 41, 123, 41, 25,
|
||||
/* 15 */ 5, 25, 41, 123, 42, 24,
|
||||
/* 16 */ 5, 24, 43, 121, 43, 24,
|
||||
/* 17 */ 5, 24, 43, 121, 44, 23,
|
||||
/* 18 */ 5, 23, 45, 120, 44, 23,
|
||||
/* 19 */ 5, 23, 45, 119, 45, 23,
|
||||
/* 20 */ 5, 23, 45, 119, 46, 22,
|
||||
/* 21 */ 5, 23, 46, 118, 46, 22,
|
||||
/* 22 */ 5, 22, 47, 118, 46, 22,
|
||||
/* 23 */ 5, 22, 47, 117, 47, 22,
|
||||
/* 24 */ 5, 22, 47, 117, 48, 21,
|
||||
/* 25 */ 5, 22, 48, 115, 49, 21,
|
||||
/* 26 */ 5, 22, 49, 112, 51, 21,
|
||||
/* 27 */ 5, 22, 51, 110, 51, 21,
|
||||
/* 28 */ 5, 21, 53, 107, 53, 21,
|
||||
/* 29 */ 3, 20, 215, 20,
|
||||
/* 30 */ 3, 19, 217, 19,
|
||||
/* 31 */ 3, 18, 219, 18,
|
||||
/* 32 */ 3, 17, 221, 17,
|
||||
/* 33 */ 3, 16, 223, 16,
|
||||
/* 34 */ 3, 16, 223, 16,
|
||||
/* 35 */ 3, 15, 225, 15,
|
||||
/* 36 */ 3, 14, 227, 14,
|
||||
/* 37 */ 3, 14, 227, 14,
|
||||
/* 38 */ 3, 13, 229, 13,
|
||||
/* 39 */ 3, 13, 229, 13,
|
||||
/* 40 */ 3, 12, 231, 12,
|
||||
/* 41 */ 3, 12, 231, 12,
|
||||
/* 42 */ 3, 11, 233, 11,
|
||||
/* 43 */ 3, 11, 233, 11,
|
||||
/* 44 */ 3, 10, 235, 10,
|
||||
/* 45 */ 3, 10, 235, 10,
|
||||
/* 46 */ 3, 9, 237, 9,
|
||||
/* 47 */ 3, 9, 237, 9,
|
||||
/* 48 */ 3, 9, 237, 9,
|
||||
/* 49 */ 3, 8, 239, 8,
|
||||
/* 50 */ 3, 7, 241, 7,
|
||||
/* 51 */ 3, 7, 241, 7,
|
||||
/* 52 */ 3, 7, 241, 7,
|
||||
/* 53 */ 3, 7, 241, 7,
|
||||
/* 54 */ 3, 6, 243, 6,
|
||||
/* 55 */ 3, 6, 243, 6,
|
||||
/* 56 */ 3, 6, 243, 6,
|
||||
/* 57 */ 3, 5, 245, 5,
|
||||
/* 58 */ 3, 5, 245, 5,
|
||||
/* 59 */ 3, 5, 245, 5,
|
||||
/* 60 */ 3, 5, 245, 5,
|
||||
/* 61 */ 3, 4, 247, 4,
|
||||
/* 62 */ 3, 4, 247, 4,
|
||||
/* 63 */ 3, 4, 247, 4,
|
||||
/* 64 */ 3, 4, 247, 4,
|
||||
/* 65 */ 3, 4, 247, 4,
|
||||
/* 66 */ 3, 4, 247, 4,
|
||||
/* 67 */ 3, 3, 248, 4,
|
||||
/* 68 */ 3, 3, 249, 3,
|
||||
/* 69 */ 3, 3, 249, 3,
|
||||
/* 70 */ 3, 3, 249, 3,
|
||||
/* 71 */ 3, 3, 249, 3,
|
||||
/* 72 */ 3, 3, 249, 3,
|
||||
/* 73 */ 3, 3, 249, 3,
|
||||
/* 74 */ 3, 3, 249, 3,
|
||||
/* 75 */ 3, 3, 249, 3,
|
||||
/* 76 */ 3, 3, 249, 3,
|
||||
/* 77 */ 3, 2, 251, 2,
|
||||
/* 78 */ 3, 2, 251, 2,
|
||||
/* 79 */ 3, 2, 251, 2,
|
||||
/* 80 */ 3, 2, 251, 2,
|
||||
/* 81 */ 3, 2, 251, 2,
|
||||
/* 82 */ 3, 2, 251, 2,
|
||||
/* 83 */ 3, 2, 251, 2,
|
||||
/* 84 */ 3, 2, 251, 2,
|
||||
/* 85 */ 3, 2, 251, 2,
|
||||
/* 86 */ 3, 1, 253, 1,
|
||||
/* 87 */ 3, 1, 253, 1,
|
||||
/* 88 */ 3, 1, 253, 1,
|
||||
/* 89 */ 3, 1, 253, 1,
|
||||
/* 90 */ 3, 1, 253, 1,
|
||||
/* 91 */ 3, 1, 253, 1,
|
||||
/* 92 */ 3, 1, 253, 1,
|
||||
/* 93 */ 3, 1, 253, 1,
|
||||
/* 94 */ 3, 1, 253, 1,
|
||||
/* 95 */ 3, 1, 253, 1,
|
||||
/* 96 */ 3, 1, 253, 1,
|
||||
/* 97 */ 3, 1, 253, 1,
|
||||
/* 98 */ 3, 1, 253, 1,
|
||||
/* 99 */ 3, 1, 253, 1,
|
||||
/* 100 */ 3, 1, 253, 1,
|
||||
/* 101 */ 2, 0, 255,
|
||||
/* 102 */ 2, 0, 255,
|
||||
/* 103 */ 2, 0, 255,
|
||||
/* 104 */ 2, 0, 255,
|
||||
/* 105 */ 2, 0, 255,
|
||||
/* 106 */ 2, 0, 255,
|
||||
/* 107 */ 2, 0, 255,
|
||||
/* 108 */ 2, 0, 255,
|
||||
/* 109 */ 2, 0, 255,
|
||||
/* 110 */ 2, 0, 255,
|
||||
/* 111 */ 2, 0, 255,
|
||||
/* 112 */ 3, 1, 253, 1,
|
||||
/* 113 */ 3, 1, 253, 1,
|
||||
/* 114 */ 3, 1, 253, 1,
|
||||
/* 115 */ 3, 1, 253, 1,
|
||||
/* 116 */ 5, 1, 113, 28, 112, 1,
|
||||
/* 117 */ 5, 2, 112, 28, 111, 2,
|
||||
/* 118 */ 5, 2, 112, 28, 111, 2,
|
||||
/* 119 */ 5, 2, 112, 28, 111, 2,
|
||||
/* 120 */ 5, 3, 111, 28, 110, 3,
|
||||
/* 121 */ 5, 3, 111, 28, 110, 3,
|
||||
/* 122 */ 9, 4, 53, 2, 55, 28, 55, 1, 53, 4,
|
||||
/* 123 */ 9, 4, 52, 3, 54, 30, 53, 3, 52, 4,
|
||||
/* 124 */ 9, 5, 50, 5, 53, 30, 53, 4, 50, 5,
|
||||
/* 125 */ 9, 5, 49, 6, 53, 30, 53, 5, 49, 5,
|
||||
/* 126 */ 9, 6, 47, 8, 51, 32, 51, 8, 46, 6,
|
||||
/* 127 */ 9, 7, 44, 10, 51, 32, 51, 9, 44, 7,
|
||||
/* 128 */ 9, 8, 42, 12, 49, 34, 49, 11, 42, 8,
|
||||
/* 129 */ 9, 9, 40, 13, 49, 34, 49, 12, 40, 9,
|
||||
/* 130 */ 9, 10, 37, 16, 47, 36, 47, 15, 37, 10,
|
||||
/* 131 */ 9, 11, 35, 18, 45, 38, 45, 17, 35, 11,
|
||||
/* 132 */ 9, 12, 32, 20, 44, 40, 44, 19, 32, 12,
|
||||
/* 133 */ 9, 13, 30, 22, 42, 42, 42, 22, 29, 13,
|
||||
/* 134 */ 9, 14, 27, 25, 40, 44, 40, 25, 25, 15,
|
||||
/* 135 */ 9, 16, 22, 30, 37, 46, 37, 29, 21, 17,
|
||||
/* 136 */ 11, 19, 16, 34, 35, 48, 35, 32, 1, 1, 14, 20,
|
||||
/* 137 */ 7, 24, 6, 40, 32, 52, 32, 69,
|
||||
/* 138 */ 5, 72, 28, 56, 28, 71,
|
||||
/* 139 */ 5, 74, 24, 60, 24, 73,
|
||||
/* 140 */ 5, 77, 18, 66, 18, 76,
|
||||
/* 141 */ 5, 81, 10, 74, 10, 80,
|
||||
};
|
||||
|
||||
/* sizeof( body ) = 721 */
|
||||
|
||||
static uint8_t retropad_buttons[] =
|
||||
{
|
||||
/* 0 */ 5, 38, 12, 13, 154, 13, 13, 37,
|
||||
/* 1 */ 5, 35, 12, 21, 144, 13, 21, 34,
|
||||
/* 2 */ 5, 33, 12, 26, 138, 13, 26, 32,
|
||||
/* 3 */ 5, 32, 12, 28, 136, 13, 28, 31,
|
||||
/* 4 */ 5, 32, 12, 29, 134, 13, 30, 30,
|
||||
/* 5 */ 5, 31, 12, 31, 133, 13, 30, 30,
|
||||
/* 6 */ 5, 31, 12, 31, 133, 13, 30, 30,
|
||||
/* 7 */ 9, 31, 12, 2, 23, 12, 6, 133, 13, 5, 24, 13, 1, 30,
|
||||
/* 8 */ 5, 60, 12, 1, 134, 13, 1, 59,
|
||||
/* 9 */ 1, 255,
|
||||
/* 10 */ 1, 255,
|
||||
/* 11 */ 1, 255,
|
||||
/* 12 */ 5, 39, 10, 13, 152, 11, 14, 37,
|
||||
/* 13 */ 5, 34, 10, 24, 141, 11, 24, 32,
|
||||
/* 14 */ 5, 31, 10, 29, 136, 11, 29, 30,
|
||||
/* 15 */ 5, 30, 10, 31, 134, 11, 32, 28,
|
||||
/* 16 */ 5, 29, 10, 33, 133, 11, 32, 28,
|
||||
/* 17 */ 5, 29, 10, 33, 133, 11, 32, 28,
|
||||
/* 18 */ 5, 29, 10, 33, 133, 11, 32, 28,
|
||||
/* 19 */ 5, 29, 10, 33, 133, 11, 32, 28,
|
||||
/* 20 */ 5, 29, 10, 33, 133, 11, 32, 28,
|
||||
/* 21 */ 9, 29, 10, 7, 19, 10, 7, 133, 11, 7, 18, 11, 7, 28,
|
||||
/* 22 */ 9, 29, 10, 2, 29, 10, 2, 133, 11, 1, 29, 11, 2, 28,
|
||||
/* 23 */ 1, 255,
|
||||
/* 24 */ 1, 255,
|
||||
/* 25 */ 1, 255,
|
||||
/* 26 */ 1, 255,
|
||||
/* 27 */ 1, 255,
|
||||
/* 28 */ 1, 255,
|
||||
/* 29 */ 1, 255,
|
||||
/* 30 */ 1, 255,
|
||||
/* 31 */ 1, 255,
|
||||
/* 32 */ 1, 255,
|
||||
/* 33 */ 1, 255,
|
||||
/* 34 */ 1, 255,
|
||||
/* 35 */ 1, 255,
|
||||
/* 36 */ 1, 255,
|
||||
/* 37 */ 1, 255,
|
||||
/* 38 */ 1, 255,
|
||||
/* 39 */ 1, 255,
|
||||
/* 40 */ 1, 255,
|
||||
/* 41 */ 1, 255,
|
||||
/* 42 */ 1, 255,
|
||||
/* 43 */ 1, 255,
|
||||
/* 44 */ 1, 255,
|
||||
/* 45 */ 1, 255,
|
||||
/* 46 */ 1, 255,
|
||||
/* 47 */ 1, 255,
|
||||
/* 48 */ 1, 255,
|
||||
/* 49 */ 1, 255,
|
||||
/* 50 */ 1, 255,
|
||||
/* 51 */ 1, 255,
|
||||
/* 52 */ 1, 255,
|
||||
/* 53 */ 1, 255,
|
||||
/* 54 */ 1, 255,
|
||||
/* 55 */ 1, 255,
|
||||
/* 56 */ 1, 255,
|
||||
/* 57 */ 3, 207, 9, 6, 42,
|
||||
/* 58 */ 3, 205, 9, 10, 40,
|
||||
/* 59 */ 3, 204, 9, 13, 38,
|
||||
/* 60 */ 3, 203, 9, 15, 37,
|
||||
/* 61 */ 3, 202, 9, 16, 37,
|
||||
/* 62 */ 3, 202, 9, 17, 36,
|
||||
/* 63 */ 5, 39, 4, 13, 149, 9, 18, 36,
|
||||
/* 64 */ 5, 39, 4, 13, 149, 9, 18, 36,
|
||||
/* 65 */ 5, 39, 4, 13, 149, 9, 18, 36,
|
||||
/* 66 */ 5, 39, 4, 13, 149, 9, 18, 36,
|
||||
/* 67 */ 5, 39, 4, 13, 150, 9, 17, 36,
|
||||
/* 68 */ 5, 39, 4, 13, 150, 9, 17, 36,
|
||||
/* 69 */ 5, 39, 4, 13, 151, 9, 15, 37,
|
||||
/* 70 */ 5, 39, 4, 13, 151, 9, 14, 38,
|
||||
/* 71 */ 5, 40, 4, 12, 153, 9, 11, 39,
|
||||
/* 72 */ 5, 41, 4, 10, 156, 9, 7, 41,
|
||||
/* 73 */ 3, 42, 4, 8, 205,
|
||||
/* 74 */ 3, 43, 4, 6, 206,
|
||||
/* 75 */ 7, 44, 4, 4, 139, 1, 3, 41, 8, 3, 21,
|
||||
/* 76 */ 11, 24, 6, 11, 10, 4, 2, 9, 7, 11, 117, 1, 9, 35, 8, 9, 18,
|
||||
/* 77 */ 9, 24, 6, 12, 19, 7, 12, 115, 1, 12, 33, 8, 12, 16,
|
||||
/* 78 */ 13, 24, 6, 13, 17, 7, 13, 30, 2, 14, 35, 3, 13, 22, 1, 14, 30, 8, 15, 15,
|
||||
/* 79 */ 13, 24, 6, 14, 15, 7, 14, 30, 2, 14, 34, 3, 14, 21, 1, 16, 29, 8, 16, 14,
|
||||
/* 80 */ 13, 24, 6, 15, 13, 7, 15, 30, 2, 14, 34, 3, 14, 21, 1, 17, 27, 8, 17, 14,
|
||||
/* 81 */ 13, 24, 6, 16, 11, 7, 16, 30, 2, 14, 34, 3, 14, 20, 1, 18, 27, 8, 18, 13,
|
||||
/* 82 */ 13, 24, 6, 16, 12, 7, 15, 30, 2, 14, 34, 3, 14, 20, 1, 18, 27, 8, 18, 13,
|
||||
/* 83 */ 13, 24, 6, 15, 14, 7, 14, 30, 2, 14, 34, 3, 14, 20, 1, 18, 26, 8, 19, 13,
|
||||
/* 84 */ 13, 24, 6, 14, 16, 7, 13, 30, 2, 14, 34, 3, 14, 20, 1, 18, 27, 8, 18, 13,
|
||||
/* 85 */ 9, 24, 6, 13, 18, 7, 12, 112, 1, 18, 27, 8, 17, 14,
|
||||
/* 86 */ 9, 24, 6, 12, 20, 7, 11, 113, 1, 17, 27, 8, 17, 14,
|
||||
/* 87 */ 13, 24, 6, 11, 10, 5, 1, 11, 7, 10, 57, 16, 8, 48, 1, 16, 29, 8, 16, 14,
|
||||
/* 88 */ 9, 44, 5, 3, 75, 16, 12, 47, 1, 14, 31, 8, 14, 15,
|
||||
/* 89 */ 9, 43, 5, 5, 73, 16, 14, 47, 1, 12, 33, 8, 12, 16,
|
||||
/* 90 */ 9, 42, 5, 7, 71, 16, 16, 48, 1, 9, 35, 8, 9, 18,
|
||||
/* 91 */ 5, 41, 5, 9, 70, 16, 16, 119,
|
||||
/* 92 */ 5, 40, 5, 11, 68, 16, 18, 118,
|
||||
/* 93 */ 7, 39, 5, 13, 67, 16, 18, 70, 0, 7, 41,
|
||||
/* 94 */ 7, 39, 5, 13, 67, 16, 18, 68, 0, 11, 39,
|
||||
/* 95 */ 7, 39, 5, 13, 67, 16, 18, 67, 0, 13, 38,
|
||||
/* 96 */ 7, 39, 5, 13, 67, 16, 18, 66, 0, 15, 37,
|
||||
/* 97 */ 7, 39, 5, 13, 67, 16, 17, 66, 0, 17, 36,
|
||||
/* 98 */ 7, 39, 5, 13, 68, 16, 16, 66, 0, 17, 36,
|
||||
/* 99 */ 7, 39, 5, 13, 68, 16, 15, 66, 0, 18, 36,
|
||||
/* 100 */ 7, 39, 5, 13, 69, 16, 13, 67, 0, 18, 36,
|
||||
/* 101 */ 5, 123, 16, 10, 68, 0, 18, 36,
|
||||
/* 102 */ 5, 125, 16, 5, 71, 0, 18, 36,
|
||||
/* 103 */ 3, 202, 0, 17, 36,
|
||||
/* 104 */ 7, 82, 14, 9, 75, 15, 8, 28, 0, 17, 36,
|
||||
/* 105 */ 7, 79, 14, 15, 69, 15, 14, 26, 0, 15, 37,
|
||||
/* 106 */ 7, 77, 14, 19, 65, 15, 18, 25, 0, 13, 38,
|
||||
/* 107 */ 7, 76, 14, 21, 62, 15, 22, 24, 0, 11, 39,
|
||||
/* 108 */ 7, 75, 14, 23, 60, 15, 24, 25, 0, 7, 41,
|
||||
/* 109 */ 5, 74, 14, 25, 58, 15, 26, 72,
|
||||
/* 110 */ 5, 73, 14, 27, 56, 15, 28, 71,
|
||||
/* 111 */ 5, 72, 14, 29, 55, 15, 28, 71,
|
||||
/* 112 */ 5, 71, 14, 31, 53, 15, 30, 70,
|
||||
/* 113 */ 5, 71, 14, 31, 52, 15, 32, 69,
|
||||
/* 114 */ 5, 70, 14, 33, 51, 15, 32, 69,
|
||||
/* 115 */ 5, 70, 14, 33, 50, 15, 34, 68,
|
||||
/* 116 */ 5, 70, 14, 33, 50, 15, 34, 68,
|
||||
/* 117 */ 5, 69, 14, 35, 49, 15, 34, 68,
|
||||
/* 118 */ 5, 69, 14, 35, 49, 15, 34, 68,
|
||||
/* 119 */ 5, 69, 14, 35, 49, 15, 34, 68,
|
||||
/* 120 */ 5, 69, 14, 35, 48, 15, 36, 67,
|
||||
/* 121 */ 5, 69, 14, 35, 48, 15, 36, 67,
|
||||
/* 122 */ 5, 69, 14, 35, 48, 15, 36, 67,
|
||||
/* 123 */ 5, 69, 14, 35, 49, 15, 34, 68,
|
||||
/* 124 */ 5, 69, 14, 35, 49, 15, 34, 68,
|
||||
/* 125 */ 5, 69, 14, 35, 49, 15, 34, 68,
|
||||
/* 126 */ 5, 70, 14, 33, 50, 15, 34, 68,
|
||||
/* 127 */ 5, 70, 14, 33, 50, 15, 34, 68,
|
||||
/* 128 */ 5, 70, 14, 33, 51, 15, 32, 69,
|
||||
/* 129 */ 5, 71, 14, 31, 52, 15, 32, 69,
|
||||
/* 130 */ 5, 71, 14, 31, 53, 15, 30, 70,
|
||||
/* 131 */ 5, 72, 14, 29, 55, 15, 28, 71,
|
||||
/* 132 */ 5, 73, 14, 27, 56, 15, 28, 71,
|
||||
/* 133 */ 5, 74, 14, 25, 58, 15, 26, 72,
|
||||
/* 134 */ 5, 75, 14, 23, 60, 15, 24, 73,
|
||||
/* 135 */ 5, 76, 14, 21, 62, 15, 22, 74,
|
||||
/* 136 */ 5, 77, 14, 19, 65, 15, 18, 76,
|
||||
/* 137 */ 5, 79, 14, 15, 69, 15, 14, 78,
|
||||
/* 138 */ 5, 82, 14, 9, 75, 15, 8, 81,
|
||||
/* 139 */ 1, 255,
|
||||
/* 140 */ 1, 255,
|
||||
/* 141 */ 1, 255,
|
||||
};
|
||||
|
||||
/* sizeof( buttons ) = 1070 */
|
||||
|
||||
#endif /* REMOTEPAD_H */
|
39
input/button_test/retro_inline.h
Normal file
39
input/button_test/retro_inline.h
Normal file
|
@ -0,0 +1,39 @@
|
|||
/* Copyright (C) 2010-2016 The RetroArch team
|
||||
*
|
||||
* ---------------------------------------------------------------------------------------
|
||||
* The following license statement only applies to this file (retro_inline.h).
|
||||
* ---------------------------------------------------------------------------------------
|
||||
*
|
||||
* Permission is hereby granted, free of charge,
|
||||
* to any person obtaining a copy of this software and associated documentation files (the "Software"),
|
||||
* to deal in the Software without restriction, including without limitation the rights to
|
||||
* use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software,
|
||||
* and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
|
||||
* INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
||||
* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
||||
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
#ifndef __LIBRETRO_SDK_INLINE_H
|
||||
#define __LIBRETRO_SDK_INLINE_H
|
||||
|
||||
#ifndef INLINE
|
||||
|
||||
#if defined(_WIN32) || defined(__INTEL_COMPILER)
|
||||
#define INLINE __inline
|
||||
#elif defined(__STDC_VERSION__) && __STDC_VERSION__>=199901L
|
||||
#define INLINE inline
|
||||
#elif defined(__GNUC__)
|
||||
#define INLINE __inline__
|
||||
#else
|
||||
#define INLINE
|
||||
#endif
|
||||
|
||||
#endif
|
||||
#endif
|
194
input/button_test/retro_miscellaneous.h
Normal file
194
input/button_test/retro_miscellaneous.h
Normal file
|
@ -0,0 +1,194 @@
|
|||
/* Copyright (C) 2010-2016 The RetroArch team
|
||||
*
|
||||
* ---------------------------------------------------------------------------------------
|
||||
* The following license statement only applies to this file (retro_miscellaneous.h).
|
||||
* ---------------------------------------------------------------------------------------
|
||||
*
|
||||
* Permission is hereby granted, free of charge,
|
||||
* to any person obtaining a copy of this software and associated documentation files (the "Software"),
|
||||
* to deal in the Software without restriction, including without limitation the rights to
|
||||
* use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software,
|
||||
* and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
|
||||
* INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
||||
* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
||||
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
#ifndef __RARCH_MISCELLANEOUS_H
|
||||
#define __RARCH_MISCELLANEOUS_H
|
||||
|
||||
#include <stdint.h>
|
||||
#include <math.h>
|
||||
|
||||
#if defined(__CELLOS_LV2__) && !defined(__PSL1GHT__)
|
||||
#include <sys/timer.h>
|
||||
#elif defined(XENON)
|
||||
#include <time/time.h>
|
||||
#elif defined(GEKKO) || defined(__PSL1GHT__) || defined(__QNX__)
|
||||
#include <unistd.h>
|
||||
#elif defined(PSP)
|
||||
#include <pspthreadman.h>
|
||||
#elif defined(VITA)
|
||||
#include <psp2/kernel/threadmgr.h>
|
||||
#elif defined(_3DS)
|
||||
#include <3ds.h>
|
||||
#else
|
||||
#include <time.h>
|
||||
#endif
|
||||
|
||||
#if defined(_WIN32) && !defined(_XBOX)
|
||||
#define WIN32_LEAN_AND_MEAN
|
||||
#include <windows.h>
|
||||
#elif defined(_WIN32) && defined(_XBOX)
|
||||
#include <Xtl.h>
|
||||
#endif
|
||||
|
||||
#include <limits.h>
|
||||
#include <math.h>
|
||||
|
||||
#ifdef _MSC_VER
|
||||
#include <compat/msvc.h>
|
||||
#endif
|
||||
#include "retro_inline.h"
|
||||
|
||||
#ifndef PATH_MAX_LENGTH
|
||||
#if defined(_XBOX1) || defined(_3DS) || defined(PSP) || defined(GEKKO)
|
||||
#define PATH_MAX_LENGTH 512
|
||||
#else
|
||||
#define PATH_MAX_LENGTH 4096
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifndef M_PI
|
||||
#define M_PI 3.14159265358979323846264338327
|
||||
#endif
|
||||
|
||||
#ifndef MAX
|
||||
#define MAX(a, b) ((a) > (b) ? (a) : (b))
|
||||
#endif
|
||||
|
||||
#ifndef MIN
|
||||
#define MIN(a, b) ((a) < (b) ? (a) : (b))
|
||||
#endif
|
||||
|
||||
#define ARRAY_SIZE(a) (sizeof(a) / sizeof((a)[0]))
|
||||
#define RARCH_SCALE_BASE 256
|
||||
|
||||
/**
|
||||
* retro_sleep:
|
||||
* @msec : amount in milliseconds to sleep
|
||||
*
|
||||
* Sleeps for a specified amount of milliseconds (@msec).
|
||||
**/
|
||||
static INLINE void retro_sleep(unsigned msec)
|
||||
{
|
||||
#if defined(__CELLOS_LV2__) && !defined(__PSL1GHT__)
|
||||
sys_timer_usleep(1000 * msec);
|
||||
#elif defined(PSP) || defined(VITA)
|
||||
sceKernelDelayThread(1000 * msec);
|
||||
#elif defined(_3DS)
|
||||
svcSleepThread(1000000 * (s64)msec);
|
||||
#elif defined(_WIN32)
|
||||
Sleep(msec);
|
||||
#elif defined(XENON)
|
||||
udelay(1000 * msec);
|
||||
#elif defined(GEKKO) || defined(__PSL1GHT__) || defined(__QNX__)
|
||||
usleep(1000 * msec);
|
||||
#else
|
||||
struct timespec tv = {0};
|
||||
tv.tv_sec = msec / 1000;
|
||||
tv.tv_nsec = (msec % 1000) * 1000000;
|
||||
nanosleep(&tv, NULL);
|
||||
#endif
|
||||
}
|
||||
|
||||
/**
|
||||
* next_pow2:
|
||||
* @v : initial value
|
||||
*
|
||||
* Get next power of 2 value based on initial value.
|
||||
*
|
||||
* Returns: next power of 2 value (derived from @v).
|
||||
**/
|
||||
static INLINE uint32_t next_pow2(uint32_t v)
|
||||
{
|
||||
v--;
|
||||
v |= v >> 1;
|
||||
v |= v >> 2;
|
||||
v |= v >> 4;
|
||||
v |= v >> 8;
|
||||
v |= v >> 16;
|
||||
v++;
|
||||
return v;
|
||||
}
|
||||
|
||||
/**
|
||||
* prev_pow2:
|
||||
* @v : initial value
|
||||
*
|
||||
* Get previous power of 2 value based on initial value.
|
||||
*
|
||||
* Returns: previous power of 2 value (derived from @v).
|
||||
**/
|
||||
static INLINE uint32_t prev_pow2(uint32_t v)
|
||||
{
|
||||
v |= v >> 1;
|
||||
v |= v >> 2;
|
||||
v |= v >> 4;
|
||||
v |= v >> 8;
|
||||
v |= v >> 16;
|
||||
return v - (v >> 1);
|
||||
}
|
||||
|
||||
/**
|
||||
* db_to_gain:
|
||||
* @db : Decibels.
|
||||
*
|
||||
* Converts decibels to voltage gain.
|
||||
*
|
||||
* Returns: voltage gain value.
|
||||
**/
|
||||
static INLINE float db_to_gain(float db)
|
||||
{
|
||||
return powf(10.0f, db / 20.0f);
|
||||
}
|
||||
|
||||
/* Helper macros and struct to keep track of many booleans.
|
||||
* To check for multiple bits, use &&, not &.
|
||||
* For OR, | can be used. */
|
||||
typedef struct
|
||||
{
|
||||
uint32_t data[8];
|
||||
} retro_bits_t;
|
||||
|
||||
#define BIT_SET(a, bit) ((a)[(bit) >> 3] |= (1 << ((bit) & 7)))
|
||||
#define BIT_CLEAR(a, bit) ((a)[(bit) >> 3] &= ~(1 << ((bit) & 7)))
|
||||
#define BIT_GET(a, bit) ((a)[(bit) >> 3] & (1 << ((bit) & 7)))
|
||||
|
||||
#define BIT16_SET(a, bit) ((a) |= (1 << ((bit) & 15)))
|
||||
#define BIT16_CLEAR(a, bit) ((a) &= ~(1 << ((bit) & 15)))
|
||||
#define BIT16_GET(a, bit) (!!((a) & (1 << ((bit) & 15))))
|
||||
#define BIT16_CLEAR_ALL(a) ((a) = 0)
|
||||
|
||||
#define BIT32_SET(a, bit) ((a) |= (1 << ((bit) & 31)))
|
||||
#define BIT32_CLEAR(a, bit) ((a) &= ~(1 << ((bit) & 31)))
|
||||
#define BIT32_GET(a, bit) (!!((a) & (1 << ((bit) & 31))))
|
||||
#define BIT32_CLEAR_ALL(a) ((a) = 0)
|
||||
|
||||
#define BIT64_SET(a, bit) ((a) |= (UINT64_C(1) << ((bit) & 63)))
|
||||
#define BIT64_CLEAR(a, bit) ((a) &= ~(UINT64_C(1) << ((bit) & 63)))
|
||||
#define BIT64_GET(a, bit) (!!((a) & (UINT64_C(1) << ((bit) & 63))))
|
||||
#define BIT64_CLEAR_ALL(a) ((a) = 0)
|
||||
|
||||
#define BIT128_SET(a, bit) ((a).data[(bit) >> 5] |= (1 << ((bit) & 31))
|
||||
#define BIT128_CLEAR(a, bit) ((a).data[(bit) >> 5] &= ~(1 << ((bit) & 31)))
|
||||
#define BIT128_GET(a, bit) ((a).data[(bit) >> 5] & (1 << ((bit) & 31)))
|
||||
#define BIT128_CLEAR_ALL(a) memset(&(a), 0, sizeof(a));
|
||||
|
||||
#endif
|
Loading…
Reference in a new issue