diff --git a/Makefile b/Makefile index 58212f2bec..7121691591 100644 --- a/Makefile +++ b/Makefile @@ -2,7 +2,8 @@ include config.mk TARGET = retroarch tools/retroarch-joyconfig tools/retrolaunch/retrolaunch -OBJ = retroarch.o \ +OBJ = frontend/frontend.o \ + retroarch.o \ file.o \ file_path.o \ hash.o \ diff --git a/Makefile.ngc b/Makefile.ngc index 4b8c0c7c63..4f240161d3 100644 --- a/Makefile.ngc +++ b/Makefile.ngc @@ -4,6 +4,8 @@ DEBUG = 0 HAVE_LOGGER = 1 HAVE_FILE_LOGGER = 0 PERF_TEST = 0 +WHOLE_ARCHIVE_LINK = 0 +BIG_STACK = 0 PC_DEVELOPMENT_IP_ADDRESS = "192.168.1.7" PC_DEVELOPMENT_UDP_PORT = 3490 @@ -32,8 +34,15 @@ LIBDIRS := -L$(DEVKITPRO)/libogc/lib/cube -L. MACHDEP := -DGEKKO -DHW_DOL -mogc -mcpu=750 -meabi -mhard-float CFLAGS += -Wall -std=gnu99 $(MACHDEP) $(INCLUDE) -LDFLAGS := $(MACHDEP) -Wl,-Map,$(notdir $(ELF_TARGET)).map -T gx/ld/ogc.ld -LIBS := -lfat -lretro_ngc -logc +ifeq ($(WHOLE_ARCHIVE_LINK), 1) + WHOLE_START := -Wl,--whole-archive + WHOLE_END := -Wl,--no-whole-archive +endif +LDFLAGS := $(MACHDEP) -Wl,-Map,$(notdir $(ELF_TARGET)).map +ifeq ($(BIG_STACK), 1) + LDFLAGS += -T gx/ld/ogc.ld +endif +LIBS := -lfat $(WHOLE_START) -lretro_ngc $(WHOLE_END) -logc OBJ = console/griffin/griffin.o @@ -53,7 +62,7 @@ CFLAGS += -DHAVE_FILE_LOGGER CFLAGS += -Iconsole/logger endif -CFLAGS += -std=gnu99 -DHAVE_DEFAULT_RETROPAD_INPUT -DHAVE_RMENU -DHAVE_RGUI -DRARCH_CONSOLE -DGEKKO -DHAVE_ZLIB -DWANT_MINIZ -DHAVE_RARCH_MAIN_WRAP -DHAVE_GRIFFIN=1 -DHAVE_SCREENSHOTS -DPACKAGE_VERSION=\"$(RARCH_VERSION)\" -Dmain=rarch_main -Wno-char-subscripts +CFLAGS += -std=gnu99 -DHAVE_DEFAULT_RETROPAD_INPUT -DHAVE_RMENU -DHAVE_RGUI -DRARCH_CONSOLE -DGEKKO -DHAVE_ZLIB -DWANT_MINIZ -DHAVE_RARCH_MAIN_WRAP -DHAVE_RARCH_MAIN_IMPLEMENTATION -DHAVE_GRIFFIN=1 -DHAVE_SCREENSHOTS -DPACKAGE_VERSION=\"$(RARCH_VERSION)\" -Wno-char-subscripts ifeq ($(DEBUG), 1) CFLAGS += -O0 -g diff --git a/Makefile.ps3 b/Makefile.ps3 index 94261a2931..3e803e5ced 100644 --- a/Makefile.ps3 +++ b/Makefile.ps3 @@ -109,7 +109,7 @@ PPU_LDLIBS = $(FONT_LIBS) $(GL_LIBS) $(WHOLE_START) -lretro_ps3 $(WHOLE_END) -l PPU_RANLIB = $(CELL_SDK)/host-win32/ppu/bin/ppu-lv2-ranlib.exe -DEFINES += -DHAVE_DEFAULT_RETROPAD_INPUT -DHAVE_RMENU -DHAVE_THREADS -DHAVE_RMENU_GUI -DRARCH_CONSOLE -DHAVE_OPENGL -DHAVE_HEADSET -DHAVE_VID_CONTEXT -DHAVE_OPENGLES -DHAVE_OPENGLES1 -DHAVE_PSGL -DHAVE_CG -DHAVE_CG_RUNTIME_COMPILER -DHAVE_FILEBROWSER -DHAVE_FBO -DHAVE_RARCH_MAIN_WRAP -DHAVE_SYSMODULES -DHAVE_SYSUTILS -DHAVE_RARCH_EXEC -DHAVE_LIBRETRO_MANAGEMENT -DHAVE_RSOUND -DHAVE_ZLIB -DWANT_MINIZ -DHAVE_SINC -DSINC_LOWER_QUALITY -D__CELLOS_LV2__ -DHAVE_NETPLAY=1 -DHAVE_SOCKET_LEGACY=1 -DHAVE_OSKUTIL -DHAVE_MOUSE -DHAVE_GRIFFIN=1 -DHAVE_MULTIMAN=1 -DPACKAGE_VERSION=\"$(RARCH_VERSION)\" -Dmain=rarch_main -DPC_DEVELOPMENT_IP_ADDRESS=\"$(PC_DEVELOPMENT_IP_ADDRESS)\" -DPC_DEVELOPMENT_UDP_PORT=$(PC_DEVELOPMENT_UDP_PORT) +DEFINES += -DHAVE_DEFAULT_RETROPAD_INPUT -DHAVE_RMENU -DHAVE_THREADS -DHAVE_RMENU_GUI -DRARCH_CONSOLE -DHAVE_OPENGL -DHAVE_HEADSET -DHAVE_VID_CONTEXT -DHAVE_OPENGLES -DHAVE_OPENGLES1 -DHAVE_PSGL -DHAVE_CG -DHAVE_CG_RUNTIME_COMPILER -DHAVE_FILEBROWSER -DHAVE_FBO -DHAVE_RARCH_MAIN_WRAP -DHAVE_RARCH_MAIN_IMPLEMENTATION -DHAVE_SYSMODULES -DHAVE_SYSUTILS -DHAVE_RARCH_EXEC -DHAVE_LIBRETRO_MANAGEMENT -DHAVE_RSOUND -DHAVE_ZLIB -DWANT_MINIZ -DHAVE_SINC -DSINC_LOWER_QUALITY -D__CELLOS_LV2__ -DHAVE_NETPLAY=1 -DHAVE_SOCKET_LEGACY=1 -DHAVE_OSKUTIL -DHAVE_MOUSE -DHAVE_GRIFFIN=1 -DHAVE_MULTIMAN=1 -DPACKAGE_VERSION=\"$(RARCH_VERSION)\" -DPC_DEVELOPMENT_IP_ADDRESS=\"$(PC_DEVELOPMENT_IP_ADDRESS)\" -DPC_DEVELOPMENT_UDP_PORT=$(PC_DEVELOPMENT_UDP_PORT) ifeq ($(DEBUG), 1) PPU_OPTIMIZE_LV := -O0 -g diff --git a/Makefile.psl1ght b/Makefile.psl1ght index 06215f4200..4c53fade57 100644 --- a/Makefile.psl1ght +++ b/Makefile.psl1ght @@ -92,7 +92,7 @@ endif RSXGL_DEFINES = -D__RSX__ -DGL3_PROTOTYPES -SHARED_FLAGS := -DHAVE_FILEBROWSER $(RSXGL_DEFINES) -DHAVE_OPENGL -DHAVE_EGL -DHAVE_OPENGL_MODERN -DHAVE_GLSL -DHAVE_VID_CONTEXT -DHAVE_FBO -DHAVE_MOUSE -DHAVE_DEFAULT_RETROPAD_INPUT -DRARCH_CONSOLE -DHAVE_ZLIB -DWANT_MINIZ -DHAVE_RARCH_MAIN_WRAP -DHAVE_SYSMODULES -DHAVE_SYSUTILS -DHAVE_GRIFFIN=1 -DHAVE_NETPLAY=1 -DHAVE_SOCKET_LEGACY=1 -DPACKAGE_VERSION=\"0.9.8\" -Dmain=rarch_main -DPC_DEVELOPMENT_IP_ADDRESS=\"$(PC_DEVELOPMENT_IP_ADDRESS)\" -DPC_DEVELOPMENT_UDP_PORT=$(PC_DEVELOPMENT_UDP_PORT) -Wno-char-subscripts +SHARED_FLAGS := -DHAVE_FILEBROWSER $(RSXGL_DEFINES) -DHAVE_OPENGL -DHAVE_EGL -DHAVE_OPENGL_MODERN -DHAVE_GLSL -DHAVE_VID_CONTEXT -DHAVE_FBO -DHAVE_MOUSE -DHAVE_DEFAULT_RETROPAD_INPUT -DRARCH_CONSOLE -DHAVE_ZLIB -DWANT_MINIZ -DHAVE_RARCH_MAIN_WRAP -DHAVE_RARCH_MAIN_IMPLEMENTATION -DHAVE_SYSMODULES -DHAVE_SYSUTILS -DHAVE_GRIFFIN=1 -DHAVE_NETPLAY=1 -DHAVE_SOCKET_LEGACY=1 -DPACKAGE_VERSION=\"0.9.8\" -DPC_DEVELOPMENT_IP_ADDRESS=\"$(PC_DEVELOPMENT_IP_ADDRESS)\" -DPC_DEVELOPMENT_UDP_PORT=$(PC_DEVELOPMENT_UDP_PORT) -Wno-char-subscripts CFLAGS += -std=gnu99 $(SHARED_FLAGS) CXXFLAGS += $(SHARED_FLAGS) diff --git a/Makefile.psp1 b/Makefile.psp1 index 9861005cd6..71592ead1e 100644 --- a/Makefile.psp1 +++ b/Makefile.psp1 @@ -8,7 +8,7 @@ INCDIR = CFLAGS = -O2 -G0 -g -std=gnu99 -ffast-math ASFLAGS = $(CFLAGS) -RARCH_DEFINES = -DPSP -DHAVE_DEFAULT_RETROPAD_INPUT -DHAVE_FILEBROWSER -DHAVE_RARCH_MAIN_WRAP -DHAVE_LIBRETRO_MANAGEMENT -DHAVE_ZLIB -DWANT_MINIZ -DHAVE_GRIFFIN=1 -DPACKAGE_VERSION=\"$(RARCH_VERSION)\" -Dmain=rarch_main -DHAVE_NULLVIDEO -DHAVE_NULLAUDIO -DHAVE_RMENU +RARCH_DEFINES = -DPSP -DHAVE_DEFAULT_RETROPAD_INPUT -DHAVE_FILEBROWSER -DHAVE_RARCH_MAIN_WRAP -DHAVE_RARCH_MAIN_IMPLEMENTATION -DHAVE_LIBRETRO_MANAGEMENT -DHAVE_ZLIB -DWANT_MINIZ -DHAVE_GRIFFIN=1 -DPACKAGE_VERSION=\"$(RARCH_VERSION)\" -DHAVE_NULLVIDEO -DHAVE_NULLAUDIO -DHAVE_RMENU ifeq ($(HAVE_FILE_LOGGER), 1) CFLAGS += -DHAVE_FILE_LOGGER diff --git a/Makefile.wii b/Makefile.wii index d90446e342..02661b225a 100644 --- a/Makefile.wii +++ b/Makefile.wii @@ -4,7 +4,8 @@ DEBUG = 0 HAVE_LOGGER = 0 HAVE_FILE_LOGGER = 0 PERF_TEST = 0 -WHOLE_ARCHIVE_LINK = 0 +WHOLE_ARCHIVE_LINK = 0 +BIG_STACK = 0 PC_DEVELOPMENT_IP_ADDRESS = "192.168.1.100" PC_DEVELOPMENT_UDP_PORT = 3490 @@ -36,10 +37,13 @@ LIBDIRS := -L$(DEVKITPRO)/libogc/lib/wii -L. MACHDEP := -DGEKKO -DHW_RVL -mrvl -mcpu=750 -meabi -mhard-float CFLAGS += -Wall -std=gnu99 $(MACHDEP) $(INCLUDE) ifeq ($(WHOLE_ARCHIVE_LINK), 1) -WHOLE_START := -Wl,--whole-archive -WHOLE_END := -Wl,--no-whole-archive + WHOLE_START := -Wl,--whole-archive + WHOLE_END := -Wl,--no-whole-archive +endif +LDFLAGS := $(MACHDEP) -Wl,-Map,$(notdir $(ELF_TARGET)).map,-wrap,malloc,-wrap,free,-wrap,memalign,-wrap,calloc,-wrap,realloc,-wrap,strdup,-wrap,strndup,-wrap,malloc_usable_size +ifeq ($(BIG_STACK), 1) + LDFLAGS += -T gx/ld/rvl.ld endif -LDFLAGS := $(MACHDEP) -Wl,-Map,$(notdir $(ELF_TARGET)).map,-wrap,malloc,-wrap,free,-wrap,memalign,-wrap,calloc,-wrap,realloc,-wrap,strdup,-wrap,strndup,-wrap,malloc_usable_size -T gx/ld/rvl.ld LIBS := -lfat $(WHOLE_START) -lretro_wii $(WHOLE_END) -logc $(LDFLAGS_WIIUSE) -lbte APP_BOOTER_DIR = wii/app_booter @@ -61,7 +65,7 @@ CFLAGS += -Iconsole/logger endif -CFLAGS += -std=gnu99 -DHAVE_SINC -DSINC_LOWER_QUALITY -DHAVE_DEFAULT_RETROPAD_INPUT -DHAVE_RGUI -DRARCH_CONSOLE -DHAVE_LIBRETRO_MANAGEMENT -DHAVE_RARCH_EXEC -DHAVE_RMENU -DGEKKO -DHAVE_ZLIB -DWANT_MINIZ -DHAVE_RARCH_MAIN_WRAP -DHAVE_GRIFFIN=1 -DHAVE_SCREENSHOTS -DPACKAGE_VERSION=\"$(RARCH_VERSION)\" -Dmain=rarch_main -Wno-char-subscripts +CFLAGS += -std=gnu99 -DHAVE_SINC -DSINC_LOWER_QUALITY -DHAVE_DEFAULT_RETROPAD_INPUT -DHAVE_RGUI -DRARCH_CONSOLE -DHAVE_LIBRETRO_MANAGEMENT -DHAVE_RARCH_EXEC -DHAVE_RMENU -DGEKKO -DHAVE_ZLIB -DWANT_MINIZ -DHAVE_RARCH_MAIN_WRAP -DHAVE_RARCH_MAIN_IMPLEMENTATION -DHAVE_GRIFFIN=1 -DHAVE_SCREENSHOTS -DPACKAGE_VERSION=\"$(RARCH_VERSION)\" -Wno-char-subscripts ifeq ($(DEBUG), 1) CFLAGS += -O0 -g -DDEBUG diff --git a/Makefile.win b/Makefile.win index a038dece6a..846edc39c4 100644 --- a/Makefile.win +++ b/Makefile.win @@ -1,7 +1,8 @@ TARGET = retroarch.exe JTARGET = tools/retroarch-joyconfig.exe -OBJ = retroarch.o \ +OBJ = frontend/frontend.o \ + retroarch.o \ file.o \ file_path.o \ driver.o \ diff --git a/Makefile.xenon b/Makefile.xenon index 9557ab0b93..0121aac8f6 100644 --- a/Makefile.xenon +++ b/Makefile.xenon @@ -16,7 +16,7 @@ INCDIRS = -I. -I$(DEVKITXENON)/usr/include OBJ = console/griffin/griffin.o LIBS = -lretro_xenon360 -lxenon -lm -lc -DEFINES = -std=gnu99 -DPACKAGE_VERSION=\"$(RARCH_VERSION)\" -DRARCH_CONSOLE -DHAVE_THREADS -DHAVE_GETOPT_LONG=1 -DHAVE_GRIFFIN -Dmain=rarch_main +DEFINES = -std=gnu99 -DPACKAGE_VERSION=\"$(RARCH_VERSION)\" -DRARCH_CONSOLE -DHAVE_THREADS -DHAVE_GETOPT_LONG=1 -DHAVE_GRIFFIN DEFINES += -maltivec -mhard-float -m32 -mpowerpc64 -mcpu=cell -mtune=cell -fno-pic -g -Wall -DXENON $(INCDIRS) -Wno-char-subscripts DEFINES += -u read -u _start -u exc_base diff --git a/android/native/jni/input_android.c b/android/native/jni/input_android.c index 9cd31572da..91943a4315 100644 --- a/android/native/jni/input_android.c +++ b/android/native/jni/input_android.c @@ -16,6 +16,7 @@ #include #include +#include #include "input_autodetect.h" #include "../../../frontend/frontend_android.h" #include "../../../input/input_common.h" @@ -25,14 +26,16 @@ #define MAX_TOUCH 16 -#define PRESSED_UP(x, y) ((-0.80f > y) && (x >= -1.00f)) -#define PRESSED_DOWN(x, y) ((0.80f < y) && (y <= 1.00f)) -#define PRESSED_LEFT(x, y) ((-0.80f > x) && (x >= -1.00f)) -#define PRESSED_RIGHT(x, y) ((0.80f < x) && (x <= 1.00f)) +#define PRESSED_UP(x, y) ((y <= dzone_min)) +#define PRESSED_DOWN(x, y) ((y >= dzone_max)) +#define PRESSED_LEFT(x, y) ((x <= dzone_min)) +#define PRESSED_RIGHT(x, y) ((x >= dzone_max)) static unsigned pads_connected; static int state_device_ids[MAX_PADS]; static uint64_t state[MAX_PADS]; +uint64_t keycode_lut[LAST_KEYCODE]; +dpad_values_t dpad_state[MAX_PADS]; struct input_pointer { @@ -43,218 +46,392 @@ struct input_pointer static struct input_pointer pointer[MAX_TOUCH]; static unsigned pointer_count; -static void *android_input_init(void) +enum { - pads_connected = 0; + AXIS_X = 0, + AXIS_Y = 1, + AXIS_Z = 11, + AXIS_RZ = 14 +}; - input_autodetect_init(); +extern float AMotionEvent_getAxisValue( + const AInputEvent* motion_event, int32_t axis, size_t pointer_index); - for(unsigned player = 0; player < 4; player++) - for(unsigned i = 0; i < RARCH_FIRST_META_KEY; i++) - { - g_settings.input.binds[player][i].id = i; - g_settings.input.binds[player][i].joykey = 0; - } +static typeof(AMotionEvent_getAxisValue) *p_AMotionEvent_getAxisValue; - for(int player = 0; player < 4; player++) - { - g_settings.input.binds[player][RETRO_DEVICE_ID_JOYPAD_B].joykey = (1ULL << RETRO_DEVICE_ID_JOYPAD_B); - g_settings.input.binds[player][RETRO_DEVICE_ID_JOYPAD_Y].joykey = (1ULL << RETRO_DEVICE_ID_JOYPAD_Y); - g_settings.input.binds[player][RETRO_DEVICE_ID_JOYPAD_SELECT].joykey = (1ULL << RETRO_DEVICE_ID_JOYPAD_SELECT); - g_settings.input.binds[player][RETRO_DEVICE_ID_JOYPAD_START].joykey = (1ULL << RETRO_DEVICE_ID_JOYPAD_START); - g_settings.input.binds[player][RETRO_DEVICE_ID_JOYPAD_UP].joykey = (1ULL << RETRO_DEVICE_ID_JOYPAD_UP); - g_settings.input.binds[player][RETRO_DEVICE_ID_JOYPAD_DOWN].joykey = (1ULL << RETRO_DEVICE_ID_JOYPAD_DOWN); - g_settings.input.binds[player][RETRO_DEVICE_ID_JOYPAD_LEFT].joykey = (1ULL << RETRO_DEVICE_ID_JOYPAD_LEFT); - g_settings.input.binds[player][RETRO_DEVICE_ID_JOYPAD_RIGHT].joykey = (1ULL << RETRO_DEVICE_ID_JOYPAD_RIGHT); - g_settings.input.binds[player][RETRO_DEVICE_ID_JOYPAD_A].joykey = (1ULL << RETRO_DEVICE_ID_JOYPAD_A); - g_settings.input.binds[player][RETRO_DEVICE_ID_JOYPAD_X].joykey = (1ULL << RETRO_DEVICE_ID_JOYPAD_X); - g_settings.input.binds[player][RETRO_DEVICE_ID_JOYPAD_L].joykey = (1ULL << RETRO_DEVICE_ID_JOYPAD_L); - g_settings.input.binds[player][RETRO_DEVICE_ID_JOYPAD_R].joykey = (1ULL << RETRO_DEVICE_ID_JOYPAD_R); - g_settings.input.binds[player][RETRO_DEVICE_ID_JOYPAD_L2].joykey = (1ULL << RETRO_DEVICE_ID_JOYPAD_L2); - g_settings.input.binds[player][RETRO_DEVICE_ID_JOYPAD_R2].joykey = (1ULL << RETRO_DEVICE_ID_JOYPAD_R2); - g_settings.input.binds[player][RETRO_DEVICE_ID_JOYPAD_L3].joykey = (1ULL << RETRO_DEVICE_ID_JOYPAD_L3); - g_settings.input.binds[player][RETRO_DEVICE_ID_JOYPAD_R3].joykey = (1ULL << RETRO_DEVICE_ID_JOYPAD_R3); - } - g_settings.input.dpad_emulation[0] = DPAD_EMULATION_LSTICK; - return (void*)-1; +#define AMotionEvent_getAxisValue (*p_AMotionEvent_getAxisValue) + +float getAxis(AInputEvent *event, int stick, int axis, int pointer) +{ + int axis_arg[2][2] = {{AXIS_X, AXIS_Y}, {AXIS_Z, AXIS_RZ}}; + return AMotionEvent_getAxisValue(event, axis_arg[stick][axis], pointer); } -static void android_input_poll(void *data) +/** + * Process the next main command. + */ +void engine_handle_cmd(void) { - (void)data; + struct android_app *android_app = (struct android_app*)g_android; + int8_t cmd; - RARCH_PERFORMANCE_INIT(input_poll); - RARCH_PERFORMANCE_START(input_poll); + if (read(android_app->msgread, &cmd, sizeof(cmd)) != sizeof(cmd)) + cmd = -1; + switch (cmd) + { + case APP_CMD_INPUT_CHANGED: + RARCH_LOG("APP_CMD_INPUT_CHANGED\n"); + + pthread_mutex_lock(&android_app->mutex); + + if (android_app->inputQueue != NULL) + AInputQueue_detachLooper(android_app->inputQueue); + + android_app->inputQueue = android_app->pendingInputQueue; + + if (android_app->inputQueue != NULL) + { + RARCH_LOG("Attaching input queue to looper"); + AInputQueue_attachLooper(android_app->inputQueue, + android_app->looper, LOOPER_ID_INPUT, NULL, + NULL); + } + + pthread_cond_broadcast(&android_app->cond); + pthread_mutex_unlock(&android_app->mutex); + + break; + + case APP_CMD_INIT_WINDOW: + RARCH_LOG("engine_handle_cmd: APP_CMD_INIT_WINDOW.\n"); + + pthread_mutex_lock(&android_app->mutex); + android_app->window = android_app->pendingWindow; + pthread_cond_broadcast(&android_app->cond); + pthread_mutex_unlock(&android_app->mutex); + + if (g_extern.lifecycle_state & (1ULL << RARCH_PAUSE_TOGGLE)) + init_drivers(); + break; + + case APP_CMD_RESUME: + RARCH_LOG("engine_handle_cmd: APP_CMD_RESUME.\n"); + + pthread_mutex_lock(&android_app->mutex); + android_app->activityState = cmd; + pthread_cond_broadcast(&android_app->cond); + pthread_mutex_unlock(&android_app->mutex); + break; + + case APP_CMD_START: + RARCH_LOG("engine_handle_cmd: APP_CMD_START.\n"); + + pthread_mutex_lock(&android_app->mutex); + android_app->activityState = cmd; + pthread_cond_broadcast(&android_app->cond); + pthread_mutex_unlock(&android_app->mutex); + break; + + case APP_CMD_PAUSE: + RARCH_LOG("engine_handle_cmd: APP_CMD_PAUSE.\n"); + + pthread_mutex_lock(&android_app->mutex); + android_app->activityState = cmd; + pthread_cond_broadcast(&android_app->cond); + pthread_mutex_unlock(&android_app->mutex); + + if (!(g_extern.lifecycle_state & (1ULL << RARCH_QUIT_KEY))) + { + RARCH_LOG("Pausing RetroArch.\n"); + g_extern.lifecycle_state |= (1ULL << RARCH_PAUSE_TOGGLE); + } + break; + + case APP_CMD_STOP: + RARCH_LOG("engine_handle_cmd: APP_CMD_STOP.\n"); + + pthread_mutex_lock(&android_app->mutex); + android_app->activityState = cmd; + pthread_cond_broadcast(&android_app->cond); + pthread_mutex_unlock(&android_app->mutex); + break; + + case APP_CMD_CONFIG_CHANGED: + RARCH_LOG("engine_handle_cmd: APP_CMD_CONFIG_CHANGED.\n"); + break; + + case APP_CMD_TERM_WINDOW: + RARCH_LOG("engine_handle_cmd: APP_CMD_TERM_WINDOW.\n"); + + pthread_mutex_lock(&android_app->mutex); + + /* The window is being hidden or closed, clean it up. */ + /* terminate display/EGL context here */ + if (g_extern.lifecycle_state & (1ULL << RARCH_PAUSE_TOGGLE)) + uninit_drivers(); + else + RARCH_WARN("Window is terminated outside PAUSED state.\n"); + + android_app->window = NULL; + pthread_cond_broadcast(&android_app->cond); + pthread_mutex_unlock(&android_app->mutex); + break; + + case APP_CMD_GAINED_FOCUS: + RARCH_LOG("engine_handle_cmd: APP_CMD_GAINED_FOCUS.\n"); + + g_extern.lifecycle_state &= ~(1ULL << RARCH_PAUSE_TOGGLE); + break; + + case APP_CMD_LOST_FOCUS: + RARCH_LOG("engine_handle_cmd: APP_CMD_LOST_FOCUS.\n"); + break; + + case APP_CMD_DESTROY: + RARCH_LOG("engine_handle_cmd: APP_CMD_DESTROY\n"); + g_extern.lifecycle_state |= (1ULL << RARCH_QUIT_KEY); + break; + } +} + +static inline void engine_handle_input(void) +{ bool debug_enable = g_settings.input.debug_enable; - struct android_app* android_app = (struct android_app*)g_android; + struct android_app *android_app = (struct android_app*)g_android; uint64_t *lifecycle_state = &g_extern.lifecycle_state; + AInputEvent* event = NULL; *lifecycle_state &= ~((1ULL << RARCH_RESET) | (1ULL << RARCH_REWIND) | (1ULL << RARCH_FAST_FORWARD_KEY) | (1ULL << RARCH_FAST_FORWARD_HOLD_KEY) | (1ULL << RARCH_MUTE) | (1ULL << RARCH_SAVE_STATE_KEY) | (1ULL << RARCH_LOAD_STATE_KEY) | (1ULL << RARCH_STATE_SLOT_PLUS) | (1ULL << RARCH_STATE_SLOT_MINUS)); // Read all pending events. - while (AInputQueue_hasEvents(android_app->inputQueue) > 0) + while (AInputQueue_hasEvents(android_app->inputQueue)) { - AInputEvent* event = NULL; - if (AInputQueue_getEvent(android_app->inputQueue, &event) < 0) - break; - - bool long_msg_enable = false; - int32_t handled = 1; - int action = 0; - char msg[128]; - msg[0] = 0; - - int source = AInputEvent_getSource(event); - int id = AInputEvent_getDeviceId(event); - if (id == zeus_second_id) - id = zeus_id; - int keycode = AKeyEvent_getKeyCode(event); - - int type_event = AInputEvent_getType(event); - int state_id = -1; - - if (source & (AINPUT_SOURCE_TOUCHSCREEN | AINPUT_SOURCE_MOUSE | AINPUT_SOURCE_TOUCHPAD)) - state_id = 0; // touch overlay is always player 1 - else + if (AInputQueue_getEvent(android_app->inputQueue, &event) >= 0) { - for (unsigned i = 0; i < pads_connected; i++) - if (state_device_ids[i] == id) - state_id = i; - } + bool long_msg_enable = false; + int32_t handled = 1; + int action = 0; + char msg[128]; + int source, id, keycode, type_event, state_id; + //int predispatched; - if (state_id < 0) - { - state_id = pads_connected; - state_device_ids[pads_connected++] = id; + msg[0] = 0; + //predispatched =AInputQueue_preDispatchEvent(android_app->inputQueue,event); - input_autodetect_setup(android_app, msg, sizeof(msg), state_id, id, source); - long_msg_enable = true; - } + //if (predispatched) + //continue; - if (keycode == AKEYCODE_BACK) - { - uint8_t unpacked = (keycode_lut[AKEYCODE_BACK] >> ((state_id+1) << 3)) - 1; - uint64_t input_state = (1ULL << unpacked); + source = AInputEvent_getSource(event); + id = AInputEvent_getDeviceId(event); + if (id == zeus_second_id) + id = zeus_id; + keycode = AKeyEvent_getKeyCode(event); - if (type_event == AINPUT_EVENT_TYPE_KEY && input_state < (1ULL << RARCH_FIRST_META_KEY) - && input_state > 0) - { - } + type_event = AInputEvent_getType(event); + state_id = -1; + + if (source & (AINPUT_SOURCE_TOUCHSCREEN | AINPUT_SOURCE_MOUSE | AINPUT_SOURCE_TOUCHPAD)) + state_id = 0; // touch overlay is always player 1 else { - int meta = AKeyEvent_getMetaState(event); - if (!(meta & AMETA_ALT_ON)) + for (unsigned i = 0; i < pads_connected; i++) + if (state_device_ids[i] == id) + state_id = i; + } + + if (state_id < 0) + { + state_id = pads_connected; + state_device_ids[pads_connected++] = id; + + input_autodetect_setup(android_app, msg, sizeof(msg), state_id, id, source); + long_msg_enable = true; + } + + if (keycode == AKEYCODE_BACK) + { + uint8_t unpacked = (keycode_lut[AKEYCODE_BACK] >> ((state_id+1) << 3)) - 1; + uint64_t input_state = (1ULL << unpacked); + + if (g_extern.lifecycle_mode_state & (1ULL << MODE_INPUT_XPERIA_PLAY_HACK)) + { + int meta = AKeyEvent_getMetaState(event); + if (!(meta & AMETA_ALT_ON)) + { + *lifecycle_state |= (1ULL << RARCH_QUIT_KEY); + AInputQueue_finishEvent(android_app->inputQueue, event, handled); + break; + } + } + else if (type_event == AINPUT_EVENT_TYPE_KEY && input_state < (1ULL << RARCH_FIRST_META_KEY) + && input_state > 0) + { + } + else { *lifecycle_state |= (1ULL << RARCH_QUIT_KEY); AInputQueue_finishEvent(android_app->inputQueue, event, handled); break; } } - } - if (type_event == AINPUT_EVENT_TYPE_MOTION) - { - float x = 0.0f; - float y = 0.0f; - action = AMotionEvent_getAction(event); - size_t motion_pointer = action >> AMOTION_EVENT_ACTION_POINTER_INDEX_SHIFT; - action &= AMOTION_EVENT_ACTION_MASK; - - if (source & ~(AINPUT_SOURCE_TOUCHSCREEN | AINPUT_SOURCE_MOUSE)) + if (type_event == AINPUT_EVENT_TYPE_MOTION) { - if (g_settings.input.dpad_emulation[state_id] != DPAD_EMULATION_NONE) - { - uint64_t *state_cur = &state[state_id]; - x = AMotionEvent_getX(event, motion_pointer); - y = AMotionEvent_getY(event, motion_pointer); - *state_cur &= ~((1ULL << RETRO_DEVICE_ID_JOYPAD_LEFT) | (1ULL << RETRO_DEVICE_ID_JOYPAD_RIGHT) | - (1ULL << RETRO_DEVICE_ID_JOYPAD_UP) | (1ULL << RETRO_DEVICE_ID_JOYPAD_DOWN)); - *state_cur |= PRESSED_LEFT(x, y) ? (1ULL << RETRO_DEVICE_ID_JOYPAD_LEFT) : 0; - *state_cur |= PRESSED_RIGHT(x, y) ? (1ULL << RETRO_DEVICE_ID_JOYPAD_RIGHT) : 0; - *state_cur |= PRESSED_UP(x, y) ? (1ULL << RETRO_DEVICE_ID_JOYPAD_UP) : 0; - *state_cur |= PRESSED_DOWN(x, y) ? (1ULL << RETRO_DEVICE_ID_JOYPAD_DOWN) : 0; - } - } - else - { - bool keyup = (action == AMOTION_EVENT_ACTION_UP || - action == AMOTION_EVENT_ACTION_CANCEL || action == AMOTION_EVENT_ACTION_POINTER_UP) || - (source == AINPUT_SOURCE_MOUSE && action != AMOTION_EVENT_ACTION_DOWN); + float x = 0.0f; + float y = 0.0f; + action = AMotionEvent_getAction(event); + size_t motion_pointer = action >> AMOTION_EVENT_ACTION_POINTER_INDEX_SHIFT; + action &= AMOTION_EVENT_ACTION_MASK; - if (keyup && motion_pointer < MAX_TOUCH) + if (source & ~(AINPUT_SOURCE_TOUCHSCREEN | AINPUT_SOURCE_MOUSE)) { - memmove(pointer + motion_pointer, pointer + motion_pointer + 1, (MAX_TOUCH - motion_pointer - 1) * sizeof(struct input_pointer)); - if (pointer_count > 0) - pointer_count--; + if (g_settings.input.dpad_emulation[state_id] != DPAD_EMULATION_NONE) + { + uint64_t *state_cur = &state[state_id]; + float dzone_min = dpad_state[state_id].dzone_min; + float dzone_max = dpad_state[state_id].dzone_max; + x = AMotionEvent_getX(event, motion_pointer); + y = AMotionEvent_getY(event, motion_pointer); + //float axis = AMotionEvent_getAxisValue(event, AXIS_Z, motion_pointer); + //RARCH_LOG("axis: %.2f\n", axis); + *state_cur &= ~((1ULL << RETRO_DEVICE_ID_JOYPAD_LEFT) | (1ULL << RETRO_DEVICE_ID_JOYPAD_RIGHT) | + (1ULL << RETRO_DEVICE_ID_JOYPAD_UP) | (1ULL << RETRO_DEVICE_ID_JOYPAD_DOWN)); + *state_cur |= PRESSED_LEFT(x, y) ? (1ULL << RETRO_DEVICE_ID_JOYPAD_LEFT) : 0; + *state_cur |= PRESSED_RIGHT(x, y) ? (1ULL << RETRO_DEVICE_ID_JOYPAD_RIGHT) : 0; + *state_cur |= PRESSED_UP(x, y) ? (1ULL << RETRO_DEVICE_ID_JOYPAD_UP) : 0; + *state_cur |= PRESSED_DOWN(x, y) ? (1ULL << RETRO_DEVICE_ID_JOYPAD_DOWN) : 0; + } } else { - int pointer_max = min(AMotionEvent_getPointerCount(event), MAX_TOUCH); - for (motion_pointer = 0; motion_pointer < pointer_max; motion_pointer++) + bool keyup = (action == AMOTION_EVENT_ACTION_UP || + action == AMOTION_EVENT_ACTION_CANCEL || action == AMOTION_EVENT_ACTION_POINTER_UP) || + (source == AINPUT_SOURCE_MOUSE && action != AMOTION_EVENT_ACTION_DOWN); + + if (keyup && motion_pointer < MAX_TOUCH) { - x = AMotionEvent_getX(event, motion_pointer); - y = AMotionEvent_getY(event, motion_pointer); + memmove(pointer + motion_pointer, pointer + motion_pointer + 1, (MAX_TOUCH - motion_pointer - 1) * sizeof(struct input_pointer)); + if (pointer_count > 0) + pointer_count--; + } + else + { + int pointer_max = min(AMotionEvent_getPointerCount(event), MAX_TOUCH); + for (motion_pointer = 0; motion_pointer < pointer_max; motion_pointer++) + { + x = AMotionEvent_getX(event, motion_pointer); + y = AMotionEvent_getY(event, motion_pointer); - input_translate_coord_viewport(x, y, - &pointer[motion_pointer].x, &pointer[motion_pointer].y, - &pointer[motion_pointer].full_x, &pointer[motion_pointer].full_y); + input_translate_coord_viewport(x, y, + &pointer[motion_pointer].x, &pointer[motion_pointer].y, + &pointer[motion_pointer].full_x, &pointer[motion_pointer].full_y); - pointer_count = max(pointer_count, motion_pointer + 1); + pointer_count = max(pointer_count, motion_pointer + 1); + } } } + + if (debug_enable) + snprintf(msg, sizeof(msg), "Pad %d : x = %.2f, y = %.2f, src %d.\n", state_id, x, y, source); } - - if (debug_enable) - snprintf(msg, sizeof(msg), "Pad %d : x = %.2f, y = %.2f, src %d.\n", state_id, x, y, source); - } - else if (type_event == AINPUT_EVENT_TYPE_KEY) - { - if (debug_enable) - snprintf(msg, sizeof(msg), "Pad %d : %d, ac = %d, src = %d.\n", state_id, keycode, action, source); - - /* Hack - we have to decrease the unpacked value by 1 - * because we 'added' 1 to each entry in the LUT - - * RETRO_DEVICE_ID_JOYPAD_B is 0 - */ - uint8_t unpacked = (keycode_lut[keycode] >> ((state_id+1) << 3)) - 1; - uint64_t input_state = (1ULL << unpacked); - int action = AKeyEvent_getAction(event); - uint64_t *key = NULL; - - if(input_state < (1ULL << RARCH_FIRST_META_KEY)) - key = &state[state_id]; - else if(input_state) - key = &g_extern.lifecycle_state; - - if(key != NULL) + else if (type_event == AINPUT_EVENT_TYPE_KEY) { - if (action == AKEY_EVENT_ACTION_UP) - *key &= ~(input_state); - else if (action == AKEY_EVENT_ACTION_DOWN) - *key |= input_state; + if (debug_enable) + snprintf(msg, sizeof(msg), "Pad %d : %d, ac = %d, src = %d.\n", state_id, keycode, action, source); + + /* Hack - we have to decrease the unpacked value by 1 + * because we 'added' 1 to each entry in the LUT - + * RETRO_DEVICE_ID_JOYPAD_B is 0 + */ + uint8_t unpacked = (keycode_lut[keycode] >> ((state_id+1) << 3)) - 1; + uint64_t input_state = (1ULL << unpacked); + int action = AKeyEvent_getAction(event); + uint64_t *key = NULL; + + if(input_state < (1ULL << RARCH_FIRST_META_KEY)) + key = &state[state_id]; + else if(input_state) + key = &g_extern.lifecycle_state; + + if(key != NULL) + { + if (action == AKEY_EVENT_ACTION_UP) + *key &= ~(input_state); + else if (action == AKEY_EVENT_ACTION_DOWN) + *key |= input_state; + } + + if((keycode == AKEYCODE_VOLUME_UP || keycode == AKEYCODE_VOLUME_DOWN) && keycode_lut[keycode] == 0) + handled = 0; } - if((keycode == AKEYCODE_VOLUME_UP || keycode == AKEYCODE_VOLUME_DOWN) && keycode_lut[keycode] == 0) - handled = 0; + if (msg[0] != 0) + msg_queue_push(g_extern.msg_queue, msg, 0, long_msg_enable ? 180 : 30); + + AInputQueue_finishEvent(android_app->inputQueue, event, handled); + } + } +} + +// Handle all events. If our activity is in pause state, block until we're unpaused. +void android_handle_events(void) +{ + int ident; + while ((ident = ALooper_pollAll((input_key_pressed_func(RARCH_PAUSE_TOGGLE)) ? -1 : 0, + NULL, NULL, NULL)) >= 0) + { + if (ident == LOOPER_ID_MAIN) + engine_handle_cmd(); + else if (!input_key_pressed_func(RARCH_PAUSE_TOGGLE)) + engine_handle_input(); + } +} + +static void *android_input_init(void) +{ + unsigned i, j; + pads_connected = 0; + + input_autodetect_init(); + + for(i = 0; i < MAX_PADS; i++) + { + for(j = 0; j < RARCH_FIRST_META_KEY; j++) + { + g_settings.input.binds[i][j].id = i; + g_settings.input.binds[i][j].joykey = 0; } - if (msg[0] != 0) - msg_queue_push(g_extern.msg_queue, msg, 0, long_msg_enable ? 180 : 30); + g_settings.input.binds[i][RETRO_DEVICE_ID_JOYPAD_B].joykey = (1ULL << RETRO_DEVICE_ID_JOYPAD_B); + g_settings.input.binds[i][RETRO_DEVICE_ID_JOYPAD_Y].joykey = (1ULL << RETRO_DEVICE_ID_JOYPAD_Y); + g_settings.input.binds[i][RETRO_DEVICE_ID_JOYPAD_SELECT].joykey = (1ULL << RETRO_DEVICE_ID_JOYPAD_SELECT); + g_settings.input.binds[i][RETRO_DEVICE_ID_JOYPAD_START].joykey = (1ULL << RETRO_DEVICE_ID_JOYPAD_START); + g_settings.input.binds[i][RETRO_DEVICE_ID_JOYPAD_UP].joykey = (1ULL << RETRO_DEVICE_ID_JOYPAD_UP); + g_settings.input.binds[i][RETRO_DEVICE_ID_JOYPAD_DOWN].joykey = (1ULL << RETRO_DEVICE_ID_JOYPAD_DOWN); + g_settings.input.binds[i][RETRO_DEVICE_ID_JOYPAD_LEFT].joykey = (1ULL << RETRO_DEVICE_ID_JOYPAD_LEFT); + g_settings.input.binds[i][RETRO_DEVICE_ID_JOYPAD_RIGHT].joykey = (1ULL << RETRO_DEVICE_ID_JOYPAD_RIGHT); + g_settings.input.binds[i][RETRO_DEVICE_ID_JOYPAD_A].joykey = (1ULL << RETRO_DEVICE_ID_JOYPAD_A); + g_settings.input.binds[i][RETRO_DEVICE_ID_JOYPAD_X].joykey = (1ULL << RETRO_DEVICE_ID_JOYPAD_X); + g_settings.input.binds[i][RETRO_DEVICE_ID_JOYPAD_L].joykey = (1ULL << RETRO_DEVICE_ID_JOYPAD_L); + g_settings.input.binds[i][RETRO_DEVICE_ID_JOYPAD_R].joykey = (1ULL << RETRO_DEVICE_ID_JOYPAD_R); + g_settings.input.binds[i][RETRO_DEVICE_ID_JOYPAD_L2].joykey = (1ULL << RETRO_DEVICE_ID_JOYPAD_L2); + g_settings.input.binds[i][RETRO_DEVICE_ID_JOYPAD_R2].joykey = (1ULL << RETRO_DEVICE_ID_JOYPAD_R2); + g_settings.input.binds[i][RETRO_DEVICE_ID_JOYPAD_L3].joykey = (1ULL << RETRO_DEVICE_ID_JOYPAD_L3); + g_settings.input.binds[i][RETRO_DEVICE_ID_JOYPAD_R3].joykey = (1ULL << RETRO_DEVICE_ID_JOYPAD_R3); - AInputQueue_finishEvent(android_app->inputQueue, event, handled); + dpad_state[i].dzone_min = -0.99f; + dpad_state[i].dzone_max = 0.99f; } + g_settings.input.dpad_emulation[0] = DPAD_EMULATION_LSTICK; -#if 0 - { - char msg[64]; - snprintf(msg, sizeof(msg), "Pointers: %u", pointer_count); - msg_queue_clear(g_extern.msg_queue); - msg_queue_push(g_extern.msg_queue, msg, 0, 30); - } -#endif + //p_AMotionEvent_getAxisValue = dlsym(RTLD_DEFAULT, "AMotionEvent_getAxisValue"); - RARCH_PERFORMANCE_STOP(input_poll); + return (void*)-1; +} + +static void android_input_poll(void *data) +{ } static int16_t android_input_state(void *data, const struct retro_keybind **binds, unsigned port, unsigned device, unsigned index, unsigned id) diff --git a/android/native/jni/input_autodetect.c b/android/native/jni/input_autodetect.c index 6591fc0744..e7a6ca0a90 100644 --- a/android/native/jni/input_autodetect.c +++ b/android/native/jni/input_autodetect.c @@ -18,9 +18,7 @@ #include "jni_macros.h" #include "input_autodetect.h" -uint64_t keycode_lut[LAST_KEYCODE]; - -bool volume_enable; +extern dpad_values_t dpad_state[MAX_PADS]; static void input_autodetect_get_device_name(void *data, char *buf, size_t size, int id) { @@ -77,7 +75,6 @@ void input_autodetect_init (void) for(j = 0; j < LAST_KEYCODE; j++) keycode_lut[j] = 0; - volume_enable = true; if (g_settings.input.autodetect_enable) return; @@ -210,6 +207,9 @@ void input_autodetect_setup (void *data, char *msg, size_t sizeof_msg, unsigned } else if (strstr(name_buf, "TTT THT Arcade console 2P USB Play")) { + dpad_state[id].dzone_min = -2.00f; + dpad_state[id].dzone_max = 1.00f; + /* same as Rumblepad 2 - merge? */ keycode_lut[AKEYCODE_BUTTON_1] |= ((RETRO_DEVICE_ID_JOYPAD_Y+1) << shift); keycode_lut[AKEYCODE_BUTTON_2] |= ((RETRO_DEVICE_ID_JOYPAD_B+1) << shift); @@ -222,8 +222,11 @@ void input_autodetect_setup (void *data, char *msg, size_t sizeof_msg, unsigned keycode_lut[AKEYCODE_BUTTON_9] |= ((RETRO_DEVICE_ID_JOYPAD_SELECT+1) << shift); keycode_lut[AKEYCODE_BUTTON_10] |= ((RETRO_DEVICE_ID_JOYPAD_START+1) << shift); - /* unsure about pad 2 still */ - shift = 8 + ((port + 1) * 8); + /* TODO - unsure about pad 2 still */ + keycode_lut[AKEYCODE_BUTTON_Z] |= ((RETRO_DEVICE_ID_JOYPAD_UP+1) << shift); + keycode_lut[AKEYCODE_BUTTON_Y] |= ((RETRO_DEVICE_ID_JOYPAD_DOWN+1) << shift); + keycode_lut[AKEYCODE_BUTTON_C] |= ((RETRO_DEVICE_ID_JOYPAD_LEFT+1) << shift); + keycode_lut[AKEYCODE_BUTTON_X] |= ((RETRO_DEVICE_ID_JOYPAD_RIGHT+1) << shift); keycode_lut[AKEYCODE_BUTTON_11] |= ((RETRO_DEVICE_ID_JOYPAD_Y+1) << shift); keycode_lut[AKEYCODE_BUTTON_12] |= ((RETRO_DEVICE_ID_JOYPAD_B+1) << shift); @@ -236,6 +239,20 @@ void input_autodetect_setup (void *data, char *msg, size_t sizeof_msg, unsigned keycode_lut[AKEYCODE_BUTTON_C] |= ((RETRO_DEVICE_ID_JOYPAD_SELECT+1) << shift); keycode_lut[AKEYCODE_BUTTON_X] |= ((RETRO_DEVICE_ID_JOYPAD_START+1) << shift); } + else if (strstr(name_buf, "TOMMO NEOGEOX Arcade Stick")) + { + /* TODO - Start/select */ + keycode_lut[AKEYCODE_DPAD_UP] |= ((RETRO_DEVICE_ID_JOYPAD_UP+1) << shift); + keycode_lut[AKEYCODE_DPAD_DOWN] |= ((RETRO_DEVICE_ID_JOYPAD_DOWN+1) << shift); + keycode_lut[AKEYCODE_DPAD_LEFT] |= ((RETRO_DEVICE_ID_JOYPAD_LEFT+1) << shift); + keycode_lut[AKEYCODE_DPAD_RIGHT] |= ((RETRO_DEVICE_ID_JOYPAD_RIGHT+1) << shift); + keycode_lut[AKEYCODE_BUTTON_A] |= ((RETRO_DEVICE_ID_JOYPAD_B+1) << shift); + keycode_lut[AKEYCODE_BUTTON_B] |= ((RETRO_DEVICE_ID_JOYPAD_A+1) << shift); + keycode_lut[AKEYCODE_BUTTON_X] |= ((RETRO_DEVICE_ID_JOYPAD_Y+1) << shift); + keycode_lut[AKEYCODE_BUTTON_C] |= ((RETRO_DEVICE_ID_JOYPAD_X+1) << shift); + //keycode_lut[AKEYCODE_BUTTON_R2] |= ((RETRO_DEVICE_ID_JOYPAD_START+1) << shift); + //keycode_lut[AKEYCODE_BUTTON_R2] |= ((RETRO_DEVICE_ID_JOYPAD_SELECT+1) << shift); + } else if (strstr(name_buf, "MadCatz")) { if (strstr(name_buf, "PC USB Wired Stick")) @@ -299,6 +316,9 @@ void input_autodetect_setup (void *data, char *msg, size_t sizeof_msg, unsigned else if (strstr(name_buf, "HuiJia USB GamePad") || strstr(name_buf, "Smartjoy Family Super Smartjoy 2")) { + dpad_state[id].dzone_min = -1.00f; + dpad_state[id].dzone_max = 1.00f; + keycode_lut[AKEYCODE_BUTTON_3] |= ((RETRO_DEVICE_ID_JOYPAD_B+1) << shift); keycode_lut[AKEYCODE_BUTTON_4] |= ((RETRO_DEVICE_ID_JOYPAD_Y+1) << shift); @@ -527,6 +547,11 @@ void input_autodetect_setup (void *data, char *msg, size_t sizeof_msg, unsigned else if (strstr(name_buf, "USB,2-axis 8-button gamepad") || strstr(name_buf, "BUFFALO BGC-FC801")) { + if (strstr(name_buf, "BUFFALO BGC-FC801")) + { + dpad_state[id].dzone_min = -1.00f; + dpad_state[id].dzone_max = 1.00f; + } keycode_lut[AKEYCODE_BUTTON_1] |= ((RETRO_DEVICE_ID_JOYPAD_A+1) << shift); keycode_lut[AKEYCODE_BUTTON_2] |= ((RETRO_DEVICE_ID_JOYPAD_B+1) << shift); keycode_lut[AKEYCODE_BUTTON_3] |= ((RETRO_DEVICE_ID_JOYPAD_X+1) << shift); @@ -650,6 +675,7 @@ void input_autodetect_setup (void *data, char *msg, size_t sizeof_msg, unsigned } else if (strstr(name_buf, "keypad-zeus") || (strstr(name_buf, "keypad-game-zeus"))) { + g_extern.lifecycle_mode_state |= (1ULL << MODE_INPUT_XPERIA_PLAY_HACK); /* Xperia Play */ /* X/o/square/triangle/R1/L1/D-pad */ keycode_lut[AKEYCODE_DPAD_CENTER] |= ((RETRO_DEVICE_ID_JOYPAD_B+1) << shift); @@ -665,7 +691,6 @@ void input_autodetect_setup (void *data, char *msg, size_t sizeof_msg, unsigned /* Xperia Play */ /* Start/select */ - volume_enable = false; /* TODO: menu button */ /* Menu : 82 */ @@ -815,7 +840,6 @@ void input_autodetect_setup (void *data, char *msg, size_t sizeof_msg, unsigned //player 2 shift += 8; - volume_enable = false; keycode_lut[AKEYCODE_I] |= ((RETRO_DEVICE_ID_JOYPAD_UP+1) << shift); keycode_lut[AKEYCODE_K] |= ((RETRO_DEVICE_ID_JOYPAD_DOWN+1) << shift); keycode_lut[AKEYCODE_J] |= ((RETRO_DEVICE_ID_JOYPAD_LEFT+1) << shift); diff --git a/android/native/jni/input_autodetect.h b/android/native/jni/input_autodetect.h index ce96d6393d..5ca7a3cb43 100644 --- a/android/native/jni/input_autodetect.h +++ b/android/native/jni/input_autodetect.h @@ -65,6 +65,12 @@ enum { #define LAST_KEYCODE AKEYCODE_ASSIST +typedef struct +{ + float dzone_min; + float dzone_max; +} dpad_values_t; + extern uint64_t keycode_lut[LAST_KEYCODE]; extern bool volume_enable; extern int zeus_id; diff --git a/android/phoenix/assets/libretro_cores.cfg b/android/phoenix/assets/libretro_cores.cfg index 559b8ce895..f1de8dacc0 100644 --- a/android/phoenix/assets/libretro_cores.cfg +++ b/android/phoenix/assets/libretro_cores.cfg @@ -13,3 +13,4 @@ libretro_nestopia = "Nestopia (Nintendo NES)" libretro_pcsx_rearmed-neon = "PCSX-reARMed (PlayStation1) [NEON]" libretro_pcsx_rearmed = "PCSX-reARMed (PlayStation1)" libretro_nxengine = "NXEngine (Cave Story/Doukutsu Monogatari)" +libretro_tyrquake = "TyrQuake (Quake 1)" diff --git a/android/phoenix/res/xml/prefs.xml b/android/phoenix/res/xml/prefs.xml index d9a77dcbb3..7b1f2ba936 100644 --- a/android/phoenix/res/xml/prefs.xml +++ b/android/phoenix/res/xml/prefs.xml @@ -36,20 +36,20 @@ - + diff --git a/android/phoenix/src/org/retroarch/browser/RetroArch.java b/android/phoenix/src/org/retroarch/browser/RetroArch.java index ad360f0da7..53cc797b03 100644 --- a/android/phoenix/src/org/retroarch/browser/RetroArch.java +++ b/android/phoenix/src/org/retroarch/browser/RetroArch.java @@ -307,11 +307,7 @@ public class RetroArch extends Activity implements startActivity(i); } }) - .setNegativeButton("No", new DialogInterface.OnClickListener() { - @Override - public void onClick(DialogInterface dialog, int which) { - } - }); + .setNegativeButton("No", null); alert.show(); } } @@ -349,8 +345,10 @@ public class RetroArch extends Activity implements return internal + File.separator + "retroarch.cfg"; else if (external != null && new File(internal + File.separator + "retroarch.cfg").canWrite()) return external + File.separator + "retroarch.cfg"; - else + else if (getCacheDir() != null && getCacheDir().getAbsolutePath() != null) return getCacheDir().getAbsolutePath() + File.separator + "retroarch.cfg"; + else // emergency fallback, all else failed + return "/mnt/sd/retroarch.cfg"; } private void updateConfigFile() { @@ -359,16 +357,16 @@ public class RetroArch extends Activity implements config.setBoolean("audio_enable", prefs.getBoolean("audio_enable", true)); config.setBoolean("video_smooth", prefs.getBoolean("video_smooth", true)); config.setBoolean("video_allow_rotate", prefs.getBoolean("video_allow_rotate", true)); - config.setBoolean("savestate_auto_load", prefs.getBoolean("savestate_auto_load", false)); + config.setBoolean("savestate_auto_load", prefs.getBoolean("savestate_auto_load", true)); config.setBoolean("savestate_auto_save", prefs.getBoolean("savestate_auto_save", false)); config.setBoolean("rewind_enable", prefs.getBoolean("rewind_enable", false)); config.setBoolean("video_vsync", prefs.getBoolean("video_vsync", true)); config.setBoolean("input_autodetect_enable", prefs.getBoolean("input_autodetect_enable", true)); config.setBoolean("input_debug_enable", prefs.getBoolean("input_debug_enable", false)); - config.setInt("input_autodetect_icade_profile_pad1", prefs.getInt("input_autodetect_icade_profile_pad1", 0)); - config.setInt("input_autodetect_icade_profile_pad2", prefs.getInt("input_autodetect_icade_profile_pad2", 0)); - config.setInt("input_autodetect_icade_profile_pad3", prefs.getInt("input_autodetect_icade_profile_pad3", 0)); - config.setInt("input_autodetect_icade_profile_pad4", prefs.getInt("input_autodetect_icade_profile_pad4", 0)); + config.setInt("input_autodetect_icade_profile_pad1", Integer.valueOf(prefs.getString("input_autodetect_icade_profile_pad1", "0"))); + config.setInt("input_autodetect_icade_profile_pad2", Integer.valueOf(prefs.getString("input_autodetect_icade_profile_pad2", "0"))); + config.setInt("input_autodetect_icade_profile_pad3", Integer.valueOf(prefs.getString("input_autodetect_icade_profile_pad3", "0"))); + config.setInt("input_autodetect_icade_profile_pad4", Integer.valueOf(prefs.getString("input_autodetect_icade_profile_pad4", "0"))); config.setDouble("video_refresh_rate", getRefreshRate()); config.setBoolean("video_threaded", prefs.getBoolean("video_threaded", false)); diff --git a/audio/test/main.c b/audio/test/main.c index 531efd80cd..51a80f9817 100644 --- a/audio/test/main.c +++ b/audio/test/main.c @@ -23,17 +23,25 @@ int main(int argc, char *argv[]) { + srand(time(NULL)); int16_t input_i[1024]; int16_t output_i[1024 * 8]; float input_f[1024]; float output_f[1024 * 8]; - if (argc != 3) + double ratio_max_deviation = 0.0; + + if (argc < 3 || argc > 4) { - fprintf(stderr, "Usage: %s (max ratio: 8.0)\n", argv[0]); + fprintf(stderr, "Usage: %s [ratio deviation] (max ratio: 8.0)\n", argv[0]); return 1; } + else if (argc == 4) + { + ratio_max_deviation = fabs(strtod(argv[3], NULL)); + fprintf(stderr, "Ratio deviation: %.4f.\n", ratio_max_deviation); + } double in_rate = strtod(argv[1], NULL); double out_rate = strtod(argv[2], NULL); @@ -58,13 +66,16 @@ int main(int argc, char *argv[]) if (fread(input_i, sizeof(int16_t), 1024, stdin) != 1024) break; + double uniform = (2.0 * rand()) / RAND_MAX - 1.0; + double rate_mod = 1.0 + ratio_max_deviation * uniform; + audio_convert_s16_to_float(input_f, input_i, 1024, 1.0f); struct resampler_data data = { .data_in = input_f, .data_out = output_f, .input_frames = sizeof(input_f) / (2 * sizeof(float)), - .ratio = ratio, + .ratio = ratio * rate_mod, }; rarch_resampler_process(resampler, re, &data); diff --git a/audio/test/test-rate-control.sh b/audio/test/test-rate-control.sh new file mode 100755 index 0000000000..add3f38b59 --- /dev/null +++ b/audio/test/test-rate-control.sh @@ -0,0 +1,3 @@ +#!/bin/sh + +ffmpeg -i "$1" -f s16le - | ./test-sinc-highest 44100 48000 $3 | ffmpeg -y -ar 48000 -f s16le -ac 2 -i - "$2" diff --git a/audio/utils.c b/audio/utils.c index 16cd4cbc32..650504da34 100644 --- a/audio/utils.c +++ b/audio/utils.c @@ -47,7 +47,7 @@ void audio_convert_float_to_s16_C(int16_t *out, void audio_convert_s16_to_float_SSE2(float *out, const int16_t *in, size_t samples, float gain) { - float fgain = gain / (0x7fff * 0x10000); + float fgain = gain / UINT32_C(0x80000000); __m128 factor = _mm_set1_ps(fgain); size_t i; for (i = 0; i + 8 <= samples; i += 8, in += 8, out += 8) @@ -73,7 +73,7 @@ void audio_convert_s16_to_float_SSE2(float *out, void audio_convert_float_to_s16_SSE2(int16_t *out, const float *in, size_t samples) { - __m128 factor = _mm_set1_ps((float)0x7fff); + __m128 factor = _mm_set1_ps((float)0x8000); size_t i; for (i = 0; i + 8 <= samples; i += 8, in += 8, out += 8) { diff --git a/conf/config_file.c b/conf/config_file.c index f1cff5d6e4..ced76f2b5e 100644 --- a/conf/config_file.c +++ b/conf/config_file.c @@ -110,12 +110,13 @@ static char *extract_value(char *line, bool is_value) line++; char *save; + char *tok; // We have a full string. Read until next ". if (*line == '"') { line++; - char *tok = strtok_r(line, "\"", &save); + tok = strtok_r(line, "\"", &save); if (!tok) return NULL; return strdup(tok); @@ -124,7 +125,7 @@ static char *extract_value(char *line, bool is_value) return NULL; else // We don't have that... Read till next space. { - char *tok = strtok_r(line, " \n\t\f\r\v", &save); + tok = strtok_r(line, " \n\t\f\r\v", &save); if (tok) return strdup(tok); else diff --git a/config.def.h b/config.def.h index 527111a24f..3bbcfee926 100644 --- a/config.def.h +++ b/config.def.h @@ -166,7 +166,7 @@ enum #if defined(XENON) || defined(_XBOX360) || defined(__CELLOS_LV2__) #define DEFAULT_ASPECT_RATIO 1.7778f -#elif defined(_XBOX1) || defined(GEKKO) || defined(ANDROID) +#elif defined(_XBOX1) || defined(GEKKO) || defined(ANDROID) || defined(__BLACKBERRY_QNX__) #define DEFAULT_ASPECT_RATIO 1.3333f #else #define DEFAULT_ASPECT_RATIO -1.0f diff --git a/console/griffin/griffin.c b/console/griffin/griffin.c index b66d5101e5..20d3fbfe21 100644 --- a/console/griffin/griffin.c +++ b/console/griffin/griffin.c @@ -106,6 +106,8 @@ VIDEO CONTEXT #include "../../gfx/context/xdk_ctx.c" #elif defined(ANDROID) #include "../../gfx/context/androidegl_ctx.c" +#elif defined(__BLACKBERRY_QNX__) +#include "../../gfx/context/bbqnx_ctx.c" #endif #endif @@ -134,7 +136,7 @@ VIDEO IMAGE #include "../../ps3/image.c" #elif defined(_XBOX1) #include "../../xdk/image.c" -#elif defined(ANDROID) +#elif defined(ANDROID) || defined(__BLACKBERRY_QNX__) #include "../../gfx/image.c" #include "../../gfx/rpng/rpng.c" #endif @@ -194,11 +196,11 @@ FONTS #if defined(HAVE_OPENGL) || defined(HAVE_D3D8) || defined(HAVE_D3D9) -#ifdef HAVE_FREETYPE +#if defined(HAVE_FREETYPE) #include "../../gfx/fonts/freetype.c" #endif -#ifndef DONT_HAVE_BITMAPFONTS +#if !defined(DONT_HAVE_BITMAPFONTS) #include "../../gfx/fonts/fonts.c" #include "../../gfx/fonts/bitmapfont.c" #endif @@ -315,6 +317,10 @@ AUDIO #include "../../audio/opensl.c" #endif +#ifdef HAVE_AL +#include "../../audio/openal.c" +#endif + #if defined(HAVE_NULLAUDIO) #include "../../audio/null.c" #endif @@ -377,10 +383,16 @@ MAIN #include "../../frontend/frontend_xenon.c" #elif defined(RARCH_CONSOLE) || defined(PSP) #include "../../frontend/frontend_console.c" +#elif defined(__BLACKBERRY_QNX__) +#include "../../frontend/frontend_bbqnx.c" #elif defined(ANDROID) #include "../../frontend/frontend_android.c" #endif +#ifndef ANDROID +#include "../../frontend/frontend.c" +#endif + /*============================================================ RETROARCH ============================================================ */ diff --git a/console/rarch_console.h b/console/rarch_console.h index a0894af09d..1bc43d0cc4 100644 --- a/console/rarch_console.h +++ b/console/rarch_console.h @@ -17,34 +17,6 @@ #ifndef CONSOLE_EXT_H__ #define CONSOLE_EXT_H__ -#define EXT_IMAGES "png|PNG|jpg|JPG|JPEG|jpeg" -#define EXT_SHADERS "cg|CG" -#define EXT_CGP_PRESETS "cgp|CGP" -#define EXT_INPUT_PRESETS "cfg|CFG" - -enum { - MENU_ITEM_LOAD_STATE = 0, - MENU_ITEM_SAVE_STATE, - MENU_ITEM_KEEP_ASPECT_RATIO, - MENU_ITEM_OVERSCAN_AMOUNT, - MENU_ITEM_ORIENTATION, -#ifdef HAVE_FBO - MENU_ITEM_SCALE_FACTOR, -#endif - MENU_ITEM_RESIZE_MODE, - MENU_ITEM_FRAME_ADVANCE, - MENU_ITEM_SCREENSHOT_MODE, - MENU_ITEM_RESET, - MENU_ITEM_RETURN_TO_GAME, - MENU_ITEM_RETURN_TO_MENU, - MENU_ITEM_CHANGE_LIBRETRO, -#ifdef HAVE_MULTIMAN - MENU_ITEM_RETURN_TO_MULTIMAN, -#endif - MENU_ITEM_QUIT_RARCH, - MENU_ITEM_LAST -}; - enum { SOUND_MODE_NORMAL, diff --git a/console/rgl/include/RGL/Utils.h b/console/rgl/include/RGL/Utils.h index 0ba86526c1..02300b6a7e 100644 --- a/console/rgl/include/RGL/Utils.h +++ b/console/rgl/include/RGL/Utils.h @@ -10,27 +10,17 @@ extern "C" { #endif #ifndef MSVC - // MAX that works with side effects. Just in case. -#define MAX(A,B) ({ \ - __typeof__(A) At=(A); \ - __typeof__(B) Bt=(B); \ - At>Bt?At:Bt; }) - -#define MIN(A,B) ({ \ - __typeof__(A) At=(A); \ - __typeof__(B) Bt=(B); \ - At(B)?(A):(B)) -#define MIN(A,B) ((A)<(B)?(A):(B)) #define RGL_LIKELY(COND) (COND) #define RGL_UNLIKELY(COND) (COND) #endif +#define MAX(A,B) ((A)>(B)?(A):(B)) +#define MIN(A,B) ((A)<(B)?(A):(B)) + #define _RGL_FLOAT_AS_UINT(x) ({union {float f; unsigned int i;} u; u.f=(x); u.i;}) static inline float rglClampf( const float value ) diff --git a/console/rgl/src/rgl_cg.cpp b/console/rgl/src/rgl_cg.cpp index 93d8c3d231..73aa995927 100644 --- a/console/rgl/src/rgl_cg.cpp +++ b/console/rgl/src/rgl_cg.cpp @@ -7049,9 +7049,7 @@ static unsigned int stringTableAddUnique( std::vector &stringTable, const return ret; } -template static size_t array_size(std::vector &array); template static void array_push(char* ¶meterOffset, std::vector &array); -inline static uint32_t swap16(const uint32_t v); static unsigned short getFlags(CGenum var, CGenum dir, int no, bool is_referenced, bool is_shared, int paramIndex); ////////////////////////////////////////////////////////////////////////////// @@ -7091,6 +7089,11 @@ int convertNvToElfFromFile(const char *sourceFile, int endianness, int constTabl return -1; } +static inline uint32_t swap16(const uint32_t v) +{ + return (v>>16) | (v<<16); +} + int convertNvToElfFromMemory(const void *sourceData, size_t size, int endianness, int constTableOffset, void **binaryShader, int *binarySize, std::vector &stringTable, std::vector &defaultValues) { @@ -7201,7 +7204,8 @@ int convertNvToElfFromMemory(const void *sourceData, size_t size, int endianness { int size = (int)nvbr->ucode_size()/sizeof(uint32_t); buffer = new uint32_t[size]; - for (int i=0;iucode_size()/sizeof(uint32_t); buffer = new uint32_t[size]; - for (int i=0;i static size_t array_size(std::vector &array) -{ - return (unsigned int)array.size()*sizeof(array[0]); -} - template static void array_push(char* ¶meterOffset, std::vector &array) { size_t dataSize = array.size()*sizeof(array[0]); @@ -8221,10 +8217,6 @@ template static void array_push(char* ¶meterOffset, std::vector< parameterOffset += dataSize; } -uint32_t inline static swap16(const uint32_t v) -{ - return (v>>16) | (v<<16); -} unsigned short getFlags(CGenum var, CGenum dir, int no, bool is_referenced, bool is_shared, int paramIndex) { diff --git a/dist-scripts/ngc-cores.sh b/dist-scripts/ngc-cores.sh index e9eb06f5da..62b3139774 100755 --- a/dist-scripts/ngc-cores.sh +++ b/dist-scripts/ngc-cores.sh @@ -5,12 +5,15 @@ make -C ../ -f Makefile.ngc clean || exit 1 for f in *_ngc.a ; do name=`echo "$f" | sed 's/\(_libretro\|\)_ngc.a$//'` whole_archive= + big_stack= if [ $name = "nxengine" ] ; then whole_archive="WHOLE_ARCHIVE_LINK=1" - echo $name yes + fi + if [ $name = "tyrquake" ] ; then + big_stack="BIG_STACK=1" fi cp -f "$f" ../libretro_ngc.a - make -C ../ -f Makefile.ngc $whole_archive -j3 || exit 1 + make -C ../ -f Makefile.ngc $whole_archive $big_stack -j3 || exit 1 mv -f ../retroarch_ngc.dol ../ngc/pkg/$name.dol rm -f ../retroarch_ngc.dol ../retroarch_ngc.elf ../retroarch_ngc.elf.map done diff --git a/dist-scripts/wii-cores.sh b/dist-scripts/wii-cores.sh index cc0ed766cf..0d90919069 100755 --- a/dist-scripts/wii-cores.sh +++ b/dist-scripts/wii-cores.sh @@ -9,12 +9,15 @@ make -C ../ -f Makefile.wii.salamander pkg || exit 1 for f in *_wii.a ; do name=`echo "$f" | sed 's/\(_libretro\|\)_wii.a$//'` whole_archive= + big_stack= if [ $name = "nxengine" ] ; then whole_archive="WHOLE_ARCHIVE_LINK=1" - echo $name yes + fi + if [ $name = "tyrquake" ] ; then + big_stack="BIG_STACK=1" fi cp -f "$f" ../libretro_wii.a - make -C ../ -f Makefile.wii $whole_archive -j3 || exit 1 + make -C ../ -f Makefile.wii $whole_archive $big_stack -j3 || exit 1 mv -f ../retroarch_wii.dol ../wii/pkg/$name.dol rm -f ../retroarch_wii.dol ../retroarch_wii.elf ../retroarch_wii.elf.map done diff --git a/docs/retroarch.1 b/docs/retroarch.1 index 2be97c71f7..4f7661c38d 100644 --- a/docs/retroarch.1 +++ b/docs/retroarch.1 @@ -73,7 +73,7 @@ When loading a rom from stdin, the path must be a full path, however. If a config cannot be found when using directory path, the default config path will be used instead. .IP -Unix-like systems will look in $XDG_CONFIG_HOME/retroarch/retroarch.cfg first. Then it will try $HOME/.retroarch.cfg. Last, it will try /etc/retroarch.cfg. If no configuration is found, default settings will be assumed. A configuration file does not need to define every possible option, only those that should be overridden. +Unix-like systems will look in $XDG_CONFIG_HOME/retroarch/retroarch.cfg first. If $XDG_CONFIG_HOME is not defined, it is assumed to be $HOME/.config as per specification. Then it will try $HOME/.retroarch.cfg. Last, it will try /etc/retroarch.cfg. If no configuration is found, default settings will be assumed. A configuration file does not need to define every possible option, only those that should be overridden. .IP Windows will look in retroarch.cfg in same folder where retroarch.exe resides. diff --git a/driver_funcs.h b/driver_funcs.h index d6f776e679..c2cadb3526 100644 --- a/driver_funcs.h +++ b/driver_funcs.h @@ -18,17 +18,17 @@ #ifndef _RARCH_DRIVER_FUNCS_H #define _RARCH_DRIVER_FUNCS_H -#if !defined(HAVE_GRIFFIN) || defined(ANDROID) /* Normal */ +#define audio_init_func(device, rate, latency) driver.audio->init(device, rate, latency) +#define audio_write_func(buf, size) driver.audio->write(driver.audio_data, buf, size) +#define audio_stop_func() driver.audio->stop(driver.audio_data) +#define audio_start_func() driver.audio->start(driver.audio_data) +#define audio_set_nonblock_state_func(state) driver.audio->set_nonblock_state(driver.audio_data, state) +#define audio_free_func() driver.audio->free(driver.audio_data) +#define audio_use_float_func() driver.audio->use_float(driver.audio_data) +#define audio_write_avail_func() driver.audio->write_avail(driver.audio_data) +#define audio_buffer_size_func() driver.audio->buffer_size(driver.audio_data) -#define audio_init_func(device, rate, latency) driver.audio->init(device, rate, latency) -#define audio_write_func(buf, size) driver.audio->write(driver.audio_data, buf, size) -#define audio_stop_func() driver.audio->stop(driver.audio_data) -#define audio_start_func() driver.audio->start(driver.audio_data) -#define audio_set_nonblock_state_func(state) driver.audio->set_nonblock_state(driver.audio_data, state) -#define audio_free_func() driver.audio->free(driver.audio_data) -#define audio_use_float_func() driver.audio->use_float(driver.audio_data) -#define audio_write_avail_func() driver.audio->write_avail(driver.audio_data) -#define audio_buffer_size_func() driver.audio->buffer_size(driver.audio_data) +#if !defined(RARCH_CONSOLE) /* Normal */ #define video_init_func(video_info, input, input_data) \ driver.video->init(video_info, input, input_data) @@ -69,34 +69,8 @@ static inline bool input_key_pressed_func(int key) return ret; } -#else /* for Griffin */ - -#if !defined(HAVE_RSOUND) && defined(HAVE_SL) - -#define audio_init_func(device, rate, latency) sl_init(device, rate, latency) -#define audio_write_func(buf, size) sl_write(driver.audio_data, buf, size) -#define audio_stop_func() sl_stop(driver.audio_data) -#define audio_start_func() sl_start(driver.audio_data) -#define audio_set_nonblock_state_func(state) sl_set_nonblock_state(driver.audio_data, state) -#define audio_free_func() sl_free(driver.audio_data) -#define audio_use_float_func() driver.audio->use_float(driver.audio_data) -#define audio_write_avail_func() sl_write_avail(driver.audio_data) -#define audio_buffer_size_func() (BUFFER_SIZE * ((sl_t*)driver.audio_data)->buf_count) - #else -#define audio_init_func(device, rate, latency) driver.audio->init(device, rate, latency) -#define audio_write_func(buf, size) driver.audio->write(driver.audio_data, buf, size) -#define audio_stop_func() driver.audio->stop(driver.audio_data) -#define audio_start_func() driver.audio->start(driver.audio_data) -#define audio_set_nonblock_state_func(state) driver.audio->set_nonblock_state(driver.audio_data, state) -#define audio_free_func() driver.audio->free(driver.audio_data) -#define audio_use_float_func() driver.audio->use_float(driver.audio_data) -#define audio_write_avail_func() driver.audio->write_avail(driver.audio_data) -#define audio_buffer_size_func() driver.audio->buffer_size(driver.audio_data) - -#endif - /*============================================================ VIDEO ============================================================ */ diff --git a/file_path.c b/file_path.c index 8bc72c36c2..38600c2921 100644 --- a/file_path.c +++ b/file_path.c @@ -22,7 +22,7 @@ #include "compat/strl.h" #include "compat/posix_string.h" -#if defined(__CELLOS_LV2__) && !defined(__PSL1GHT__) +#if defined(__CELLOS_LV2__) && !defined(__PSL1GHT__) || defined(__BLACKBERRY_QNX__) #include //stat() is defined here #define S_ISDIR(x) (x & CELL_FS_S_IFDIR) #endif diff --git a/frontend/frontend.c b/frontend/frontend.c new file mode 100644 index 0000000000..25774c5e2c --- /dev/null +++ b/frontend/frontend.c @@ -0,0 +1,46 @@ +/* RetroArch - A frontend for libretro. + * Copyright (C) 2010-2013 - Hans-Kristian Arntzen + * Copyright (C) 2011-2013 - 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 . + */ + +#include "../general.h" + +#ifdef __APPLE__ +#include "SDL.h" +// OSX seems to really need -lSDLmain, +// so we include SDL.h here so it can hack our main. +// We want to use -mconsole in Win32, so we need main(). +#endif + +int main(int argc, char *argv[]) +{ +#ifdef HAVE_RARCH_MAIN_IMPLEMENTATION + // Consoles use the higher level API. + return rarch_main(argc, argv); +#else + int init_ret; + if ((init_ret = rarch_main_init(argc, argv))) return init_ret; + rarch_init_msg_queue(); + while ((g_extern.is_paused && !g_extern.is_oneshot) ? rarch_main_idle_iterate() : rarch_main_iterate()); + rarch_main_deinit(); + rarch_deinit_msg_queue(); + +#ifdef PERF_TEST + rarch_perf_log(); +#endif + + rarch_main_clear_state(); + return 0; +#endif +} diff --git a/frontend/frontend_android.c b/frontend/frontend_android.c index cee92d11dc..6c7e39ba12 100644 --- a/frontend/frontend_android.c +++ b/frontend/frontend_android.c @@ -57,149 +57,14 @@ static void print_cur_config (void *data) AConfiguration_getUiModeNight(android_app->config)); } -/** - * Process the next main command. - */ -void engine_handle_cmd (void *data, int32_t cmd) -{ - struct android_app *android_app = (struct android_app*)data; - - switch (cmd) - { - case APP_CMD_INPUT_CHANGED: - RARCH_LOG("APP_CMD_INPUT_CHANGED\n"); - - pthread_mutex_lock(&android_app->mutex); - - if (android_app->inputQueue != NULL) - AInputQueue_detachLooper(android_app->inputQueue); - - android_app->inputQueue = android_app->pendingInputQueue; - - if (android_app->inputQueue != NULL) - { - RARCH_LOG("Attaching input queue to looper"); - AInputQueue_attachLooper(android_app->inputQueue, - android_app->looper, LOOPER_ID_INPUT, NULL, - NULL); - } - - pthread_cond_broadcast(&android_app->cond); - pthread_mutex_unlock(&android_app->mutex); - - break; - - case APP_CMD_INIT_WINDOW: - RARCH_LOG("engine_handle_cmd: APP_CMD_INIT_WINDOW.\n"); - - pthread_mutex_lock(&android_app->mutex); - android_app->window = android_app->pendingWindow; - pthread_cond_broadcast(&android_app->cond); - pthread_mutex_unlock(&android_app->mutex); - break; - - case APP_CMD_RESUME: - RARCH_LOG("engine_handle_cmd: APP_CMD_RESUME.\n"); - - pthread_mutex_lock(&android_app->mutex); - android_app->activityState = cmd; - pthread_cond_broadcast(&android_app->cond); - pthread_mutex_unlock(&android_app->mutex); - break; - - case APP_CMD_START: - RARCH_LOG("engine_handle_cmd: APP_CMD_START.\n"); - - pthread_mutex_lock(&android_app->mutex); - android_app->activityState = cmd; - pthread_cond_broadcast(&android_app->cond); - pthread_mutex_unlock(&android_app->mutex); - break; - - case APP_CMD_PAUSE: - RARCH_LOG("engine_handle_cmd: APP_CMD_PAUSE.\n"); - - pthread_mutex_lock(&android_app->mutex); - android_app->activityState = cmd; - pthread_cond_broadcast(&android_app->cond); - pthread_mutex_unlock(&android_app->mutex); - - if (!(g_extern.lifecycle_state & (1ULL << RARCH_QUIT_KEY))) - { - RARCH_LOG("Pausing RetroArch.\n"); - g_extern.lifecycle_state |= (1ULL << RARCH_PAUSE_TOGGLE); - } - break; - - case APP_CMD_STOP: - RARCH_LOG("engine_handle_cmd: APP_CMD_STOP.\n"); - - pthread_mutex_lock(&android_app->mutex); - android_app->activityState = cmd; - pthread_cond_broadcast(&android_app->cond); - pthread_mutex_unlock(&android_app->mutex); - break; - - case APP_CMD_CONFIG_CHANGED: - RARCH_LOG("engine_handle_cmd: APP_CMD_CONFIG_CHANGED.\n"); - break; - - case APP_CMD_TERM_WINDOW: - RARCH_LOG("engine_handle_cmd: APP_CMD_TERM_WINDOW.\n"); - - pthread_mutex_lock(&android_app->mutex); - - /* The window is being hidden or closed, clean it up. */ - /* terminate display/EGL context here */ - if (g_extern.lifecycle_state & (1ULL << RARCH_PAUSE_TOGGLE)) - uninit_drivers(); - else - RARCH_WARN("Window is terminated outside PAUSED state.\n"); - - android_app->window = NULL; - pthread_cond_broadcast(&android_app->cond); - pthread_mutex_unlock(&android_app->mutex); - break; - - case APP_CMD_GAINED_FOCUS: - RARCH_LOG("engine_handle_cmd: APP_CMD_GAINED_FOCUS.\n"); - - g_extern.lifecycle_state &= ~(1ULL << RARCH_PAUSE_TOGGLE); - break; - - case APP_CMD_LOST_FOCUS: - RARCH_LOG("engine_handle_cmd: APP_CMD_LOST_FOCUS.\n"); - break; - - case APP_CMD_DESTROY: - RARCH_LOG("engine_handle_cmd: APP_CMD_DESTROY\n"); - g_extern.lifecycle_state |= (1ULL << RARCH_QUIT_KEY); - break; - } -} - #define MAX_ARGS 32 static bool android_run_events (void *data) { - struct android_app *android_app = (struct android_app*)data; int id = ALooper_pollOnce(-1, NULL, NULL, NULL); if (id == LOOPER_ID_MAIN) - { - int8_t cmd; - - if (read(android_app->msgread, &cmd, sizeof(cmd)) != sizeof(cmd)) - cmd = -1; - - engine_handle_cmd(android_app, cmd); - - if (cmd == APP_CMD_INIT_WINDOW) - { - if (g_extern.lifecycle_state & (1ULL << RARCH_PAUSE_TOGGLE)) - init_drivers(); - } - } + engine_handle_cmd(); // Check if we are exiting. if (g_extern.lifecycle_state & (1ULL << RARCH_QUIT_KEY)) @@ -351,9 +216,11 @@ static void *android_app_entry(void *data) { RARCH_LOG("RetroArch started.\n"); - while ((input_key_pressed_func(RARCH_PAUSE_TOGGLE)) ? - android_run_events(android_app) : - rarch_main_iterate()); + // Main loop + do + { + android_handle_events(); + } while (rarch_main_iterate()); RARCH_LOG("RetroArch stopped.\n"); } diff --git a/frontend/frontend_android.h b/frontend/frontend_android.h index 16e6f21f9f..71d87e237c 100644 --- a/frontend/frontend_android.h +++ b/frontend/frontend_android.h @@ -154,8 +154,9 @@ enum { }; int8_t android_app_read_cmd (void *data); -extern void engine_app_read_cmd (void *data); -extern void engine_handle_cmd (void *data, int32_t cmd); +extern void engine_app_read_cmd(void); +extern void engine_handle_cmd(void); +extern void android_handle_events(void); extern struct android_app *g_android; diff --git a/frontend/frontend_bbqnx.c b/frontend/frontend_bbqnx.c new file mode 100644 index 0000000000..47d2200cb9 --- /dev/null +++ b/frontend/frontend_bbqnx.c @@ -0,0 +1,92 @@ +/* RetroArch - A frontend for libretro. + * Copyright (C) 2010-2013 - Hans-Kristian Arntzen + * Copyright (C) 2011-2013 - 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 . + */ + +#include +#include +#include +#include + +#include +#include +#include +#include +#include + +#include "../playbook/src/bbutil.h" + +screen_context_t screen_ctx; + +int rarch_main(int argc, char *argv[]) +{ + //Initialize bps + bps_initialize(); + + RARCH_LOG("Initializing screen context\n"); + + // Create a screen context that will be used to create an EGL surface to receive libscreen events + screen_create_context(&screen_ctx, 0); + + if (screen_request_events(screen_ctx) != BPS_SUCCESS) + { + RARCH_ERR("screen_request_events failed.\n"); + goto error; + } + + if (navigator_request_events(0) != BPS_SUCCESS) + { + RARCH_ERR("navigator_request_events failed.\n"); + goto error; + } + + if (navigator_rotation_lock(false) != BPS_SUCCESS) + { + RARCH_ERR("navigator_location_lock failed.\n"); + goto error; + } + + rarch_main_clear_state(); + + g_extern.verbose = true; + + int init_ret; + struct rarch_main_wrap args = {0}; + + args.verbose = g_extern.verbose; + args.sram_path = NULL; + args.state_path = NULL; + args.rom_path = "/accounts/1000/shared/documents/roms/test.rom"; + args.libretro_path = "/accounts/1000/appdata/com.RetroArch.testDev_m_RetroArch181dafc7/app/native/lib/test.so"; + args.config_path = "/accounts/1000/appdata/com.RetroArch.testDev_m_RetroArch181dafc7/app/native/retroarch.cfg"; + + if ((init_ret = rarch_main_init_wrap(&args))) + { + return init_ret; + } + rarch_init_msg_queue(); + while ((g_extern.is_paused && !g_extern.is_oneshot) ? rarch_main_idle_iterate() : rarch_main_iterate()); + rarch_main_deinit(); + rarch_deinit_msg_queue(); + +#ifdef PERF_TEST + rarch_perf_log(); +#endif + +error: + screen_stop_events(screen_ctx); + bps_shutdown(); + + return 0; +} diff --git a/frontend/frontend_console.c b/frontend/frontend_console.c index dc818f4eb7..cbb2674930 100644 --- a/frontend/frontend_console.c +++ b/frontend/frontend_console.c @@ -219,7 +219,7 @@ static void uninit_console_drivers(void) } } -int main(int argc, char *argv[]) +int rarch_main(int argc, char *argv[]) { system_init(); diff --git a/frontend/menu/rmenu.c b/frontend/menu/rmenu.c index 144ea4c453..53c8f2f1a5 100644 --- a/frontend/menu/rmenu.c +++ b/frontend/menu/rmenu.c @@ -41,6 +41,33 @@ #include "../../driver.h" #include "../../general.h" +#define EXT_IMAGES "png|PNG|jpg|JPG|JPEG|jpeg" +#define EXT_SHADERS "cg|CG" +#define EXT_CGP_PRESETS "cgp|CGP" +#define EXT_INPUT_PRESETS "cfg|CFG" + +enum { + MENU_ITEM_LOAD_STATE = 0, + MENU_ITEM_SAVE_STATE, + MENU_ITEM_KEEP_ASPECT_RATIO, + MENU_ITEM_OVERSCAN_AMOUNT, + MENU_ITEM_ORIENTATION, +#ifdef HAVE_FBO + MENU_ITEM_SCALE_FACTOR, +#endif + MENU_ITEM_RESIZE_MODE, + MENU_ITEM_FRAME_ADVANCE, + MENU_ITEM_SCREENSHOT_MODE, + MENU_ITEM_RESET, + MENU_ITEM_RETURN_TO_GAME, + MENU_ITEM_RETURN_TO_MENU, + MENU_ITEM_CHANGE_LIBRETRO, +#ifdef HAVE_MULTIMAN + MENU_ITEM_RETURN_TO_MULTIMAN, +#endif + MENU_ITEM_QUIT_RARCH, + MENU_ITEM_LAST +}; static rmenu_state_t rmenu_state; diff --git a/general.h b/general.h index 044ff55e54..2a44f45d69 100644 --- a/general.h +++ b/general.h @@ -67,7 +67,7 @@ #endif // Wii and PSL1GHT - for usleep (among others) -#if defined(GEKKO) || defined(__PSL1GHT__) +#if defined(GEKKO) || defined(__PSL1GHT__) || defined(__BLACKBERRY_QNX__) #include #endif @@ -134,6 +134,9 @@ enum menu_enums MODE_EXTLAUNCH_MULTIMAN, MODE_EXIT, MODE_EXITSPAWN, +#ifdef ANDROID + MODE_INPUT_XPERIA_PLAY_HACK, +#endif MODE_VIDEO_TRIPLE_BUFFERING_ENABLE, MODE_VIDEO_FLICKER_FILTER_ENABLE, MODE_VIDEO_SOFT_FILTER_ENABLE, @@ -155,6 +158,7 @@ struct settings struct { char driver[32]; + char gl_context[32]; float xscale; float yscale; bool fullscreen; @@ -644,6 +648,7 @@ void rarch_init_system_info(void); int rarch_main(int argc, char *argv[]); int rarch_main_init_wrap(const struct rarch_main_wrap *args); int rarch_main_init(int argc, char *argv[]); +bool rarch_main_idle_iterate(void); bool rarch_main_iterate(void); void rarch_main_deinit(void); void rarch_render_cached_frame(void); @@ -759,7 +764,7 @@ static inline void rarch_sleep(unsigned msec) Sleep(msec); #elif defined(XENON) udelay(1000 * msec); -#elif defined(GEKKO) || defined(__PSL1GHT__) +#elif defined(GEKKO) || defined(__PSL1GHT__) || defined(__BLACKBERRY_QNX__) usleep(1000 * msec); #else struct timespec tv = {0}; diff --git a/gfx/context/androidegl_ctx.c b/gfx/context/androidegl_ctx.c index ce0e76633d..8ad0e45c4d 100644 --- a/gfx/context/androidegl_ctx.c +++ b/gfx/context/androidegl_ctx.c @@ -172,8 +172,6 @@ static void gfx_ctx_check_window(bool *quit, { (void)frame_count; - struct android_app *android_app = (struct android_app*)g_android; - *quit = false; unsigned new_width, new_height; @@ -185,21 +183,6 @@ static void gfx_ctx_check_window(bool *quit, *resize = true; } - RARCH_PERFORMANCE_INIT(alooper_pollonce); - RARCH_PERFORMANCE_START(alooper_pollonce); - - while (ALooper_pollOnce(0, NULL, NULL, NULL) == LOOPER_ID_MAIN) - { - int8_t cmd; - - if (read(android_app->msgread, &cmd, sizeof(cmd)) != sizeof(cmd)) - cmd = -1; - - engine_handle_cmd(android_app, cmd); - } - - RARCH_PERFORMANCE_STOP(alooper_pollonce); - // Check if we are exiting. if (g_extern.lifecycle_state & (1ULL << RARCH_QUIT_KEY)) *quit = true; diff --git a/gfx/context/bbqnx_ctx.c b/gfx/context/bbqnx_ctx.c new file mode 100644 index 0000000000..3995540ca5 --- /dev/null +++ b/gfx/context/bbqnx_ctx.c @@ -0,0 +1,404 @@ +/* RetroArch - A frontend for libretro. + * Copyright (C) 2010-2013 - Hans-Kristian Arntzen + * Copyright (C) 2011-2013 - 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 . + */ + +#include "../../driver.h" +#include "../../general.h" +#include "../gfx_common.h" +#include "../gl_common.h" + +#include +#include +#include +#include +#include +#include + +#include "../image.h" + +#include "../fonts/gl_font.h" +#include + +#ifdef HAVE_GLSL +#include "../shader_glsl.h" +#endif + +#define WINDOW_BUFFERS 2 + +static EGLContext g_egl_ctx; +static EGLSurface g_egl_surf; +static EGLDisplay g_egl_dpy; +static EGLConfig egl_config; +static bool g_resize; + +extern screen_context_t screen_ctx; +static screen_window_t screen_win; +static screen_display_t screen_disp; + +GLfloat _angle; + +static enum gfx_ctx_api g_api; + +static void gfx_ctx_set_swap_interval(unsigned interval) +{ + RARCH_LOG("gfx_ctx_set_swap_interval(%d).\n", interval); + eglSwapInterval(g_egl_dpy, interval); +} + +static void gfx_ctx_destroy(void) +{ + RARCH_LOG("gfx_ctx_destroy().\n"); + eglMakeCurrent(g_egl_dpy, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT); + eglDestroyContext(g_egl_dpy, g_egl_ctx); + eglDestroySurface(g_egl_dpy, g_egl_surf); + screen_destroy_window(screen_win); + screen_destroy_context(screen_ctx); + eglTerminate(g_egl_dpy); + eglReleaseThread(); + + g_egl_dpy = EGL_NO_DISPLAY; + g_egl_surf = EGL_NO_SURFACE; + g_egl_ctx = EGL_NO_CONTEXT; + egl_config = 0; + g_resize = false; +} + +static void gfx_ctx_get_video_size(unsigned *width, unsigned *height) +{ + if (g_egl_dpy) + { + EGLint gl_width, gl_height; + eglQuerySurface(g_egl_dpy, g_egl_surf, EGL_WIDTH, &gl_width); + eglQuerySurface(g_egl_dpy, g_egl_surf, EGL_HEIGHT, &gl_height); + *width = gl_width; + *height = gl_height; + } + else + { + *width = 0; + *height = 0; + } +} + +static bool gfx_ctx_init(void) +{ + const EGLint attribs[] = { + EGL_RENDERABLE_TYPE, EGL_OPENGL_ES2_BIT, + EGL_SURFACE_TYPE, EGL_WINDOW_BIT, + EGL_BLUE_SIZE, 8, + EGL_GREEN_SIZE, 8, + EGL_RED_SIZE, 8, + EGL_NONE + }; + EGLint num_config; + EGLint egl_version_major, egl_version_minor; + int format = SCREEN_FORMAT_RGBX8888; + + EGLint context_attributes[] = { + EGL_CONTEXT_CLIENT_VERSION, 2, + EGL_NONE + }; + int usage; + + usage = SCREEN_USAGE_OPENGL_ES2 | SCREEN_USAGE_ROTATION; + + RARCH_LOG("Initializing context\n"); + + if ((g_egl_dpy = eglGetDisplay(EGL_DEFAULT_DISPLAY)) == EGL_NO_DISPLAY) + { + RARCH_ERR("eglGetDisplay failed.\n"); + goto error; + } + + if (!eglInitialize(g_egl_dpy, &egl_version_major, &egl_version_minor)) + { + RARCH_ERR("eglInitialize failed.\n"); + goto error; + } + + if (!eglBindAPI(EGL_OPENGL_ES_API)) + { + RARCH_ERR("eglBindAPI failed.\n"); + goto error; + } + + RARCH_LOG("[BLACKBERRY QNX/EGL]: EGL version: %d.%d\n", egl_version_major, egl_version_minor); + + if (!eglChooseConfig(g_egl_dpy, attribs, &egl_config, 1, &num_config)) + { + RARCH_ERR("eglChooseConfig failed.\n"); + goto error; + } + + if ((g_egl_ctx = eglCreateContext(g_egl_dpy, egl_config, 0, context_attributes)) == EGL_NO_CONTEXT) + { + RARCH_ERR("eglCreateContext failed.\n"); + goto error; + } + + if (screen_create_window(&screen_win, screen_ctx)) + { + RARCH_ERR("screen_create_window failed:.\n"); + goto error; + } + + if (screen_set_window_property_iv(screen_win, SCREEN_PROPERTY_FORMAT, &format)) + { + RARCH_ERR("screen_set_window_property_iv [SCREEN_PROPERTY_FORMAT] failed.\n"); + goto error; + } + + if (screen_set_window_property_iv(screen_win, SCREEN_PROPERTY_USAGE, &usage)) + { + RARCH_ERR("screen_set_window_property_iv [SCREEN_PROPERTY_USAGE] failed.\n"); + goto error; + } + + if (screen_get_window_property_pv(screen_win, SCREEN_PROPERTY_DISPLAY, (void **)&screen_disp)) + { + RARCH_ERR("screen_get_window_property_pv [SCREEN_PROPERTY_DISPLAY] failed.\n"); + goto error; + } + + int screen_resolution[2]; + + if (screen_get_display_property_iv(screen_disp, SCREEN_PROPERTY_SIZE, screen_resolution)) + { + RARCH_ERR("screen_get_window_property_iv [SCREEN_PROPERTY_SIZE] failed.\n"); + goto error; + } + + int angle = atoi(getenv("ORIENTATION")); + + screen_display_mode_t screen_mode; + if (screen_get_display_property_pv(screen_disp, SCREEN_PROPERTY_MODE, (void**)&screen_mode)) + { + RARCH_ERR("screen_get_display_property_pv [SCREEN_PROPERTY_MODE] failed.\n"); + goto error; + } + + int size[2]; + if (screen_get_window_property_iv(screen_win, SCREEN_PROPERTY_BUFFER_SIZE, size)) { + RARCH_ERR("screen_get_window_property_iv [SCREEN_PROPERTY_BUFFER_SIZE] failed.\n"); + goto error; + } + + int buffer_size[2] = {size[0], size[1]}; + + if ((angle == 0) || (angle == 180)) { + if (((screen_mode.width > screen_mode.height) && (size[0] < size[1])) || + ((screen_mode.width < screen_mode.height) && (size[0] > size[1]))) { + buffer_size[1] = size[0]; + buffer_size[0] = size[1]; + } + } else if ((angle == 90) || (angle == 270)){ + if (((screen_mode.width > screen_mode.height) && (size[0] > size[1])) || + ((screen_mode.width < screen_mode.height && size[0] < size[1]))) { + buffer_size[1] = size[0]; + buffer_size[0] = size[1]; + } + } else { + RARCH_ERR("Navigator returned an unexpected orientation angle.\n"); + goto error; + } + + if (screen_set_window_property_iv(screen_win, SCREEN_PROPERTY_BUFFER_SIZE, buffer_size)) + { + RARCH_ERR("screen_set_window_property_iv [SCREEN_PROPERTY_BUFFER_SIZE] failed.\n"); + goto error; + } + + if (screen_set_window_property_iv(screen_win, SCREEN_PROPERTY_ROTATION, &angle)) + { + RARCH_ERR("screen_set_window_property_iv [SCREEN_PROPERTY_ROTATION] failed.\n"); + goto error; + } + + if (screen_create_window_buffers(screen_win, WINDOW_BUFFERS)) + { + RARCH_ERR("screen_create_window_buffers failed.\n"); + goto error; + } + + if (!(g_egl_surf = eglCreateWindowSurface(g_egl_dpy, egl_config, screen_win, 0))) + { + RARCH_ERR("eglCreateWindowSurface failed.\n"); + goto error; + } + + + if (!eglMakeCurrent(g_egl_dpy, g_egl_surf, g_egl_surf, g_egl_ctx)) + { + RARCH_ERR("eglMakeCurrent failed.\n"); + goto error; + } + + return true; + +error: + RARCH_ERR("EGL error: %d.\n", eglGetError()); + gfx_ctx_destroy(); + return false; +} + +static void gfx_ctx_swap_buffers(void) +{ + eglSwapBuffers(g_egl_dpy, g_egl_surf); +} + +static void gfx_ctx_check_window(bool *quit, + bool *resize, unsigned *width, unsigned *height, unsigned frame_count) +{ + (void)frame_count; + //Request and process all available BPS events + bps_event_t *event = NULL; + + bps_get_event(&event, 0); + + *quit = false; + + unsigned new_width, new_height; + gfx_ctx_get_video_size(&new_width, &new_height); + if (new_width != *width || new_height != *height) + { + *width = new_width; + *height = new_height; + *resize = true; + } + + if (event) + { + int domain = bps_event_get_domain(event); + + if (domain == screen_get_domain()) + { + screen_event_t screen_event = screen_event_get_event(event); + int screen_val; + screen_get_event_property_iv(screen_event, SCREEN_PROPERTY_TYPE, &screen_val); + switch (screen_val) { + + case SCREEN_EVENT_MTOUCH_TOUCH: + case SCREEN_EVENT_MTOUCH_MOVE: + case SCREEN_EVENT_MTOUCH_RELEASE: + + break; + } + } + else if ((domain == navigator_get_domain()) && (NAVIGATOR_EXIT == bps_event_get_code(event))) + g_extern.lifecycle_state |= (1ULL << RARCH_QUIT_KEY); + } + + // Check if we are exiting. + if (g_extern.lifecycle_state & (1ULL << RARCH_QUIT_KEY)) + *quit = true; +} + +static void gfx_ctx_set_resize(unsigned width, unsigned height) +{ + (void)width; + (void)height; +} + +static void gfx_ctx_update_window_title(bool reset) +{ + if (reset) + gfx_window_title_reset(); + + char buf[128]; +#if 0 + if (gfx_get_fps(buf, sizeof(buf), false)) + RARCH_LOG("%s.\n", buf); +#else + gfx_get_fps(buf, sizeof(buf), false); +#endif +} + +static bool gfx_ctx_set_video_mode( + unsigned width, unsigned height, + bool fullscreen) +{ + (void)width; + (void)height; + (void)fullscreen; + return true; +} + + +static void gfx_ctx_input_driver(const input_driver_t **input, void **input_data) +{ + *input = NULL; + *input_data = NULL; +} + +static unsigned gfx_ctx_get_resolution_width(unsigned resolution_id) +{ + int gl_width; + eglQuerySurface(g_egl_dpy, g_egl_surf, EGL_WIDTH, &gl_width); + + return gl_width; +} + +static gfx_ctx_proc_t gfx_ctx_get_proc_address(const char *symbol) +{ + rarch_assert(sizeof(void*) == sizeof(void (*)(void))); + gfx_ctx_proc_t ret; + + void *sym__ = eglGetProcAddress(symbol); + memcpy(&ret, &sym__, sizeof(void*)); + + return ret; +} + +static bool gfx_ctx_bind_api(enum gfx_ctx_api api) +{ + g_api = api; + return api == GFX_CTX_OPENGL_ES_API; +} + +static bool gfx_ctx_has_focus(void) +{ + return true; +} + +static bool gfx_ctx_init_egl_image_buffer(const video_info_t *video) +{ + return false; +} + +static bool gfx_ctx_write_egl_image(const void *frame, unsigned width, unsigned height, unsigned pitch, bool rgb32, unsigned index, void **image_handle) +{ + return false; +} + +const gfx_ctx_driver_t gfx_ctx_bbqnx = { + gfx_ctx_init, + gfx_ctx_destroy, + gfx_ctx_bind_api, + gfx_ctx_set_swap_interval, + gfx_ctx_set_video_mode, + gfx_ctx_get_video_size, + NULL, + gfx_ctx_update_window_title, + gfx_ctx_check_window, + gfx_ctx_set_resize, + gfx_ctx_has_focus, + gfx_ctx_swap_buffers, + gfx_ctx_input_driver, + NULL, + gfx_ctx_init_egl_image_buffer, + gfx_ctx_write_egl_image, + NULL, + "blackberry_qnx", +}; diff --git a/gfx/context/drm_egl_ctx.c b/gfx/context/drm_egl_ctx.c index 6172dcb10b..0fd295240f 100644 --- a/gfx/context/drm_egl_ctx.c +++ b/gfx/context/drm_egl_ctx.c @@ -630,6 +630,6 @@ const gfx_ctx_driver_t gfx_ctx_drm_egl = { gfx_ctx_init_egl_image_buffer, gfx_ctx_write_egl_image, NULL, - "drm-egl", + "kms-egl", }; diff --git a/gfx/context/glx_ctx.c b/gfx/context/glx_ctx.c index c181dcf8fa..88d2ea3e4d 100644 --- a/gfx/context/glx_ctx.c +++ b/gfx/context/glx_ctx.c @@ -50,108 +50,6 @@ static bool g_is_double; static int (*g_pglSwapInterval)(int); -struct key_bind -{ - unsigned x; - enum retro_key sk; -}; - -static unsigned keysym_lut[RETROK_LAST]; - -static const struct key_bind lut_binds[] = { - { XK_Left, RETROK_LEFT }, - { XK_Right, RETROK_RIGHT }, - { XK_Up, RETROK_UP }, - { XK_Down, RETROK_DOWN }, - { XK_Return, RETROK_RETURN }, - { XK_Tab, RETROK_TAB }, - { XK_Insert, RETROK_INSERT }, - { XK_Home, RETROK_HOME }, - { XK_End, RETROK_END }, - { XK_Page_Up, RETROK_PAGEUP }, - { XK_Page_Down, RETROK_PAGEDOWN }, - { XK_Delete, RETROK_DELETE }, - { XK_Shift_R, RETROK_RSHIFT }, - { XK_Shift_L, RETROK_LSHIFT }, - { XK_Control_L, RETROK_LCTRL }, - { XK_Alt_L, RETROK_LALT }, - { XK_space, RETROK_SPACE }, - { XK_Escape, RETROK_ESCAPE }, - { XK_BackSpace, RETROK_BACKSPACE }, - { XK_KP_Enter, RETROK_KP_ENTER }, - { XK_KP_Add, RETROK_KP_PLUS }, - { XK_KP_Subtract, RETROK_KP_MINUS }, - { XK_KP_Multiply, RETROK_KP_MULTIPLY }, - { XK_KP_Divide, RETROK_KP_DIVIDE }, - { XK_grave, RETROK_BACKQUOTE }, - { XK_Pause, RETROK_PAUSE }, - { XK_KP_0, RETROK_KP0 }, - { XK_KP_1, RETROK_KP1 }, - { XK_KP_2, RETROK_KP2 }, - { XK_KP_3, RETROK_KP3 }, - { XK_KP_4, RETROK_KP4 }, - { XK_KP_5, RETROK_KP5 }, - { XK_KP_6, RETROK_KP6 }, - { XK_KP_7, RETROK_KP7 }, - { XK_KP_8, RETROK_KP8 }, - { XK_KP_9, RETROK_KP9 }, - { XK_0, RETROK_0 }, - { XK_1, RETROK_1 }, - { XK_2, RETROK_2 }, - { XK_3, RETROK_3 }, - { XK_4, RETROK_4 }, - { XK_5, RETROK_5 }, - { XK_6, RETROK_6 }, - { XK_7, RETROK_7 }, - { XK_8, RETROK_8 }, - { XK_9, RETROK_9 }, - { XK_F1, RETROK_F1 }, - { XK_F2, RETROK_F2 }, - { XK_F3, RETROK_F3 }, - { XK_F4, RETROK_F4 }, - { XK_F5, RETROK_F5 }, - { XK_F6, RETROK_F6 }, - { XK_F7, RETROK_F7 }, - { XK_F8, RETROK_F8 }, - { XK_F9, RETROK_F9 }, - { XK_F10, RETROK_F10 }, - { XK_F11, RETROK_F11 }, - { XK_F12, RETROK_F12 }, - { XK_a, RETROK_a }, - { XK_b, RETROK_b }, - { XK_c, RETROK_c }, - { XK_d, RETROK_d }, - { XK_e, RETROK_e }, - { XK_f, RETROK_f }, - { XK_g, RETROK_g }, - { XK_h, RETROK_h }, - { XK_i, RETROK_i }, - { XK_j, RETROK_j }, - { XK_k, RETROK_k }, - { XK_l, RETROK_l }, - { XK_m, RETROK_m }, - { XK_n, RETROK_n }, - { XK_o, RETROK_o }, - { XK_p, RETROK_p }, - { XK_q, RETROK_q }, - { XK_r, RETROK_r }, - { XK_s, RETROK_s }, - { XK_t, RETROK_t }, - { XK_u, RETROK_u }, - { XK_v, RETROK_v }, - { XK_w, RETROK_w }, - { XK_x, RETROK_x }, - { XK_y, RETROK_y }, - { XK_z, RETROK_z }, -}; - -static void init_lut(void) -{ - memset(keysym_lut, 0, sizeof(keysym_lut)); - for (unsigned i = 0; i < sizeof(lut_binds) / sizeof(lut_binds[0]); i++) - keysym_lut[lut_binds[i].sk] = lut_binds[i].x; -} - static void sighandler(int sig) { (void)sig; @@ -165,6 +63,13 @@ static Bool glx_wait_notify(Display *d, XEvent *e, char *arg) return e->type == MapNotify && e->xmap.window == g_win; } +static int nul_handler(Display *dpy, XErrorEvent *event) +{ + (void)dpy; + (void)event; + return 0; +} + static void gfx_ctx_get_video_size(unsigned *width, unsigned *height); static void gfx_ctx_destroy(void); @@ -299,11 +204,8 @@ static bool gfx_ctx_init(void) }; GLXFBConfig *fbcs = NULL; - g_quit = 0; - init_lut(); - g_dpy = XOpenDisplay(NULL); if (!g_dpy) goto error; @@ -440,8 +342,6 @@ static bool gfx_ctx_set_video_mode( XEvent event; XIfEvent(g_dpy, &event, glx_wait_notify, NULL); - XSetInputFocus(g_dpy, g_win, RevertToNone, CurrentTime); - g_ctx = glXCreateNewContext(g_dpy, g_fbc, GLX_RGBA_TYPE, 0, True); if (!g_ctx) { @@ -461,20 +361,34 @@ static bool gfx_ctx_set_video_mode( g_is_double = val; if (g_is_double) { + const char *swap_func = NULL; + g_pglSwapInterval = (int (*)(int))glXGetProcAddress((const GLubyte*)"glXSwapIntervalMESA"); + if (g_pglSwapInterval) + swap_func = "glXSwapIntervalMESA"; + if (!g_pglSwapInterval) - g_pglSwapInterval = (int (*)(int))glXGetProcAddress((const GLubyte*)"glXSwapInterval"); - if (!g_pglSwapInterval) - g_pglSwapInterval = (int (*)(int))glXGetProcAddress((const GLubyte*)"glXSwapIntervalMESA"); - if (!g_pglSwapInterval) + { g_pglSwapInterval = (int (*)(int))glXGetProcAddress((const GLubyte*)"glXSwapIntervalSGI"); + if (g_pglSwapInterval) + swap_func = "glXSwapIntervalSGI"; + } + if (!g_pglSwapInterval) RARCH_WARN("[GLX]: Cannot find swap interval call.\n"); + else + RARCH_LOG("[GLX]: Found swap function: %s.\n", swap_func); } else RARCH_WARN("[GLX]: Context is not double buffered!.\n"); gfx_ctx_swap_interval(g_interval); + // This can blow up on some drivers. It's not fatal, so override errors for this call. + int (*old_handler)(Display*, XErrorEvent*) = XSetErrorHandler(nul_handler); + XSetInputFocus(g_dpy, g_win, RevertToNone, CurrentTime); + XSync(g_dpy, False); + XSetErrorHandler(old_handler); + XFree(vi); g_has_focus = true; g_inited = true; @@ -548,6 +462,7 @@ static void gfx_ctx_destroy(void) } g_inited = false; + g_pglSwapInterval = NULL; } static void gfx_ctx_input_driver(const input_driver_t **input, void **input_data) diff --git a/gfx/context/xegl_ctx.c b/gfx/context/xegl_ctx.c index 85b8b7d591..07184dde0e 100644 --- a/gfx/context/xegl_ctx.c +++ b/gfx/context/xegl_ctx.c @@ -64,6 +64,13 @@ static Bool egl_wait_notify(Display *d, XEvent *e, char *arg) return e->type == MapNotify && e->xmap.window == g_win; } +static int nul_handler(Display *dpy, XErrorEvent *event) +{ + (void)dpy; + (void)event; + return 0; +} + static void gfx_ctx_get_video_size(unsigned *width, unsigned *height); static void gfx_ctx_destroy(void); @@ -369,7 +376,7 @@ static bool gfx_ctx_set_video_mode( if (true_full) { - RARCH_LOG("[GLX]: Using true fullscreen.\n"); + RARCH_LOG("[X/EGL]: Using true fullscreen.\n"); XMapRaised(g_dpy, g_win); } else if (fullscreen) // We attempted true fullscreen, but failed. Attempt using windowed fullscreen. @@ -393,7 +400,6 @@ static bool gfx_ctx_set_video_mode( XEvent event; XIfEvent(g_dpy, &event, egl_wait_notify, NULL); - XSetInputFocus(g_dpy, g_win, RevertToNone, CurrentTime); g_quit_atom = XInternAtom(g_dpy, "WM_DELETE_WINDOW", False); if (g_quit_atom) @@ -401,6 +407,12 @@ static bool gfx_ctx_set_video_mode( gfx_ctx_swap_interval(g_interval); + // This can blow up on some drivers. It's not fatal, so override errors for this call. + int (*old_handler)(Display*, XErrorEvent*) = XSetErrorHandler(nul_handler); + XSetInputFocus(g_dpy, g_win, RevertToNone, CurrentTime); + XSync(g_dpy, False); + XSetErrorHandler(old_handler); + XFree(vi); g_has_focus = true; g_inited = true; @@ -455,7 +467,7 @@ static void gfx_ctx_destroy(void) g_screen = x11_get_xinerama_monitor(g_dpy, x, y, target.width, target.height); - RARCH_LOG("[GLX]: Saved monitor #%u.\n", g_screen); + RARCH_LOG("[X/EGL]: Saved monitor #%u.\n", g_screen); #endif XUnmapWindow(g_dpy, g_win); diff --git a/gfx/gfx_context.c b/gfx/gfx_context.c index 0b43698fb2..628705142c 100644 --- a/gfx/gfx_context.c +++ b/gfx/gfx_context.c @@ -48,6 +48,9 @@ static const gfx_ctx_driver_t *gfx_ctx_drivers[] = { #if defined(ANDROID) &gfx_ctx_android, #endif +#if defined(__BLACKBERRY_QNX__) + &gfx_ctx_bbqnx, +#endif #if defined(IOS) &gfx_ctx_ios, #endif diff --git a/gfx/gfx_context.h b/gfx/gfx_context.h index 55f2be318e..d236e0b957 100644 --- a/gfx/gfx_context.h +++ b/gfx/gfx_context.h @@ -136,6 +136,7 @@ extern const gfx_ctx_driver_t gfx_ctx_ps3; extern const gfx_ctx_driver_t gfx_ctx_xdk; extern const gfx_ctx_driver_t gfx_ctx_wgl; extern const gfx_ctx_driver_t gfx_ctx_videocore; +extern const gfx_ctx_driver_t gfx_ctx_bbqnx; extern const gfx_ctx_driver_t gfx_ctx_ios; const gfx_ctx_driver_t *gfx_ctx_find_driver(const char *ident); // Finds driver with ident. Does not initialize. diff --git a/gfx/gl.c b/gfx/gl.c index 4a6256ccb2..b5be966612 100644 --- a/gfx/gl.c +++ b/gfx/gl.c @@ -1051,16 +1051,22 @@ static void gl_init_textures_data(void *data) static inline void gl_copy_frame(void *data, const void *frame, unsigned width, unsigned height, unsigned pitch) { gl_t *gl = (gl_t*)data; + size_t buffer_addr = gl->tex_w * gl->tex_h * gl->tex_index * gl->base_size; size_t buffer_stride = gl->tex_w * gl->base_size; const uint8_t *frame_copy = frame; size_t frame_copy_size = width * gl->base_size; - uint8_t *buffer = (uint8_t*)glMapBuffer(GL_TEXTURE_REFERENCE_BUFFER_SCE, GL_WRITE_ONLY) + buffer_addr; - for (unsigned h = 0; h < height; h++, buffer += buffer_stride, frame_copy += pitch) - memcpy(buffer, frame_copy, frame_copy_size); + for (unsigned h = 0; h < height; h++) + { + glBufferSubData(GL_TEXTURE_REFERENCE_BUFFER_SCE, + buffer_addr, + frame_copy_size, + frame_copy); - glUnmapBuffer(GL_TEXTURE_REFERENCE_BUFFER_SCE); + frame_copy += pitch; + buffer_addr += buffer_stride; + } } static void gl_init_textures(void *data, const video_info_t *video) @@ -1579,6 +1585,45 @@ static void gl_init_pbo_readback(void *data) #endif } +static const gfx_ctx_driver_t *gl_get_context(void) +{ +#ifdef HAVE_OPENGLES + enum gfx_ctx_api api = GFX_CTX_OPENGL_ES_API; + const char *api_name = "OpenGL ES"; +#else + enum gfx_ctx_api api = GFX_CTX_OPENGL_API; + const char *api_name = "OpenGL"; +#endif + + if (*g_settings.video.gl_context) + { + const gfx_ctx_driver_t *ctx = gfx_ctx_find_driver(g_settings.video.gl_context); + if (ctx) + { + if (!ctx->bind_api(api)) + { + RARCH_ERR("Failed to bind API %s to context %s.\n", api_name, g_settings.video.gl_context); + return NULL; + } + + if (!ctx->init()) + { + RARCH_ERR("Failed to init GL context: %s.\n", ctx->ident); + return NULL; + } + } + else + { + RARCH_ERR("Didn't find GL context: %s.\n", g_settings.video.gl_context); + return NULL; + } + + return ctx; + } + else + return gfx_ctx_init_first(api); +} + static void *gl_init(const video_info_t *video, const input_driver_t **input, void **input_data) { #ifdef _WIN32 @@ -1599,11 +1644,7 @@ static void *gl_init(const video_info_t *video, const input_driver_t **input, vo if (!gl) return NULL; -#ifdef HAVE_OPENGLES - gl->ctx_driver = gfx_ctx_init_first(GFX_CTX_OPENGL_ES_API); -#else - gl->ctx_driver = gfx_ctx_init_first(GFX_CTX_OPENGL_API); -#endif + gl->ctx_driver = gl_get_context(); if (!gl->ctx_driver) { free(gl); diff --git a/gx/ld/ogc.ld b/gx/ld/ogc.ld index 0086209667..d6d06bc2ce 100644 --- a/gx/ld/ogc.ld +++ b/gx/ld/ogc.ld @@ -257,7 +257,7 @@ SECTIONS } __isIPL = 0; -__stack_addr = (__bss_start + SIZEOF(.bss) + 0x40000 + 7) & (-8); +__stack_addr = (__bss_start + SIZEOF(.bss) + 0x80000 + 7) & (-8); __stack_end = (__bss_start + SIZEOF(.bss)); __intrstack_addr = (__stack_addr + 0x4000); __intrstack_end = (__stack_addr); diff --git a/gx/ld/rvl.ld b/gx/ld/rvl.ld index 7a9867c2f4..e790eec2db 100644 --- a/gx/ld/rvl.ld +++ b/gx/ld/rvl.ld @@ -268,7 +268,7 @@ SECTIONS } __isIPL = 0; -__stack_addr = (__bss_start + SIZEOF(.bss) + 0x40000 + 7) & (-8); +__stack_addr = (__bss_start + SIZEOF(.bss) + 0x80000 + 7) & (-8); __stack_end = (__bss_start + SIZEOF(.bss)); __intrstack_addr = (__stack_addr + 0x4000); __intrstack_end = (__stack_addr); diff --git a/input/overlay.c b/input/overlay.c index b14fdcb0ff..e3575fed95 100644 --- a/input/overlay.c +++ b/input/overlay.c @@ -40,6 +40,9 @@ struct overlay_desc float range_x, range_y; uint64_t key_mask; + + unsigned next_index; + char next_index_name[64]; }; struct overlay @@ -58,6 +61,8 @@ struct overlay float center_x, center_y; bool full_screen; + + char name[64]; }; struct input_overlay @@ -72,6 +77,8 @@ struct input_overlay const struct overlay *active; size_t index; size_t size; + + unsigned next_index; }; static void input_overlay_scale(struct overlay *overlay, float scale) @@ -154,6 +161,13 @@ static bool input_overlay_load_desc(config_file_t *conf, struct overlay_desc *de for (const char *tmp = strtok_r(key, "|", &save); tmp; tmp = strtok_r(NULL, "|", &save)) desc->key_mask |= UINT64_C(1) << input_str_to_bind(tmp); + if (desc->key_mask & (UINT64_C(1) << RARCH_OVERLAY_NEXT)) + { + char overlay_target_key[64]; + snprintf(overlay_target_key, sizeof(overlay_target_key), "overlay%u_desc%u_next_target", ol_index, desc_index); + config_get_array(conf, overlay_target_key, desc->next_index_name, sizeof(desc->next_index_name)); + } + desc->x = strtod(x, NULL) / width; desc->y = strtod(y, NULL) / height; @@ -181,6 +195,7 @@ static bool input_overlay_load_overlay(config_file_t *conf, const char *config_p struct overlay *overlay, unsigned index) { char overlay_path_key[64]; + char overlay_name_key[64]; char overlay_path[PATH_MAX]; char overlay_resolved_path[PATH_MAX]; @@ -191,6 +206,9 @@ static bool input_overlay_load_overlay(config_file_t *conf, const char *config_p return false; } + snprintf(overlay_name_key, sizeof(overlay_name_key), "overlay%u_name", index); + config_get_array(conf, overlay_name_key, overlay->name, sizeof(overlay->name)); + fill_pathname_resolve_relative(overlay_resolved_path, config_path, overlay_path, sizeof(overlay_resolved_path)); @@ -272,6 +290,42 @@ static bool input_overlay_load_overlay(config_file_t *conf, const char *config_p return true; } +static ssize_t input_overlay_find_index(const struct overlay *ol, const char *name, size_t size) +{ + for (size_t i = 0; i < size; i++) + { + if (strcmp(ol[i].name, name) == 0) + return i; + } + + return -1; +} + +static bool input_overlay_resolve_targets(struct overlay *ol, size_t index, size_t size) +{ + struct overlay *current = &ol[index]; + + for (size_t i = 0; i < current->size; i++) + { + const char *next = current->descs[i].next_index_name; + if (*next) + { + ssize_t index = input_overlay_find_index(ol, next, size); + if (index < 0) + { + RARCH_ERR("[Overlay]: Couldn't find overlay called: \"%s\".\n", next); + return false; + } + + current->descs[i].next_index = index; + } + else + current->descs[i].next_index = (index + 1) % size; + } + + return true; +} + static bool input_overlay_load_overlays(input_overlay_t *ol, const char *path) { bool ret = true; @@ -315,6 +369,16 @@ static bool input_overlay_load_overlays(input_overlay_t *ol, const char *path) } } + for (size_t i = 0; i < ol->size; i++) + { + if (!input_overlay_resolve_targets(ol->overlays, i, ol->size)) + { + RARCH_ERR("[Overlay]: Failed to resolve next targets.\n"); + ret = false; + goto end; + } + } + end: config_file_free(conf); return ret; @@ -353,6 +417,7 @@ input_overlay_t *input_overlay_new(const char *overlay) input_overlay_set_alpha_mod(ol, g_settings.input.overlay_opacity); input_overlay_set_scale_factor(ol, 1.0f); + ol->next_index = (ol->index + 1) % ol->size; return ol; @@ -410,7 +475,13 @@ uint64_t input_overlay_poll(input_overlay_t *ol, int16_t norm_x, int16_t norm_y) for (size_t i = 0; i < ol->active->size; i++) { if (inside_hitbox(&ol->active->descs[i], x, y)) - state |= ol->active->descs[i].key_mask; + { + uint64_t mask = ol->active->descs[i].key_mask; + state |= mask; + + if (mask & (UINT64_C(1) << RARCH_OVERLAY_NEXT)) + ol->next_index = ol->active->descs[i].next_index; + } } if (!state) @@ -428,7 +499,7 @@ void input_overlay_poll_clear(input_overlay_t *ol) void input_overlay_next(input_overlay_t *ol) { - ol->index = (ol->index + 1) % ol->size; + ol->index = ol->next_index; ol->active = &ol->overlays[ol->index]; ol->iface->load(ol->iface_data, ol->active->image, ol->active->width, ol->active->height); @@ -436,6 +507,7 @@ void input_overlay_next(input_overlay_t *ol) ol->active->mod_x, ol->active->mod_y, ol->active->mod_w, ol->active->mod_h); ol->iface->full_screen(ol->iface_data, ol->active->full_screen); ol->blocked = true; + ol->next_index = (ol->index + 1) % ol->size; } bool input_overlay_full_screen(input_overlay_t *ol) diff --git a/msvc/RetroArch-360/RetroArch-360.vcxproj b/msvc/RetroArch-360/RetroArch-360.vcxproj index 80e161774d..d6f3a6ba16 100644 --- a/msvc/RetroArch-360/RetroArch-360.vcxproj +++ b/msvc/RetroArch-360/RetroArch-360.vcxproj @@ -113,7 +113,7 @@ true false MultiThreadedDebug - _DEBUG;_XBOX;HAVE_XINPUT2;PACKAGE_VERSION="0.9.8.4";%(PreprocessorDefinitions);HAVE_DEFAULT_RETROPAD_INPUT;_CRT_SECURE_NO_WARNINGS;main=rarch_main;RARCH_CONSOLE;HAVE_RMENU;HAVE_FILEBROWSER;HAVE_NETPLAY;HAVE_SOCKET_LEGACY;HAVE_ZLIB;HAVE_RARCH_MAIN_WRAP;HAVE_RARCH_EXEC;HAVE_LIBRETRO_MANAGEMENT;D3DCOMPILE_USEVOIDS;HAVE_GRIFFIN;HAVE_HLSL;HAVE_VID_CONTEXT;HAVE_D3D9;_XBOX360;HAVE_FBO;HAVE_SCREENSHOTS;WANT_MINIZ;HAVE_SINC;SINC_LOWER_QUALITY;HAVE_XAUDIO + _DEBUG;_XBOX;HAVE_XINPUT2;PACKAGE_VERSION="0.9.8.4";%(PreprocessorDefinitions);HAVE_DEFAULT_RETROPAD_INPUT;_CRT_SECURE_NO_WARNINGS;HAVE_RARCH_MAIN_IMPLEMENTATION;RARCH_CONSOLE;HAVE_RMENU;HAVE_FILEBROWSER;HAVE_NETPLAY;HAVE_SOCKET_LEGACY;HAVE_ZLIB;HAVE_RARCH_MAIN_WRAP;HAVE_RARCH_EXEC;HAVE_LIBRETRO_MANAGEMENT;D3DCOMPILE_USEVOIDS;HAVE_GRIFFIN;HAVE_HLSL;HAVE_VID_CONTEXT;HAVE_D3D9;_XBOX360;HAVE_FBO;HAVE_SCREENSHOTS;WANT_MINIZ;HAVE_SINC;SINC_LOWER_QUALITY;HAVE_XAUDIO Callcap @@ -151,7 +151,7 @@ AnalyzeOnly false MultiThreadedDebug - _DEBUG;_XBOX;%(PreprocessorDefinitions);HAVE_XINPUT2;PACKAGE_VERSION="0.9.8.4";HAVE_DEFAULT_RETROPAD_INPUT;_CRT_SECURE_NO_WARNINGS;main=rarch_main;HAVE_FILEBROWSER;RARCH_CONSOLE;HAVE_RMENU;HAVE_ZLIB;HAVE_RARCH_MAIN_WRAP;HAVE_RARCH_EXEC;HAVE_LIBRETRO_MANAGEMENT;D3DCOMPILE_USEVOIDS;HAVE_GRIFFIN;HAVE_HLSL;HAVE_VID_CONTEXT;HAVE_D3D9;_XBOX360;HAVE_FBO;HAVE_SCREENSHOTS;WANT_MINIZ;HAVE_SINC;SINC_LOWER_QUALITY + _DEBUG;_XBOX;%(PreprocessorDefinitions);HAVE_XINPUT2;PACKAGE_VERSION="0.9.8.4";HAVE_DEFAULT_RETROPAD_INPUT;_CRT_SECURE_NO_WARNINGS;HAVE_RARCH_MAIN_IMPLEMENTATION;HAVE_FILEBROWSER;RARCH_CONSOLE;HAVE_RMENU;HAVE_ZLIB;HAVE_RARCH_MAIN_WRAP;HAVE_RARCH_EXEC;HAVE_LIBRETRO_MANAGEMENT;D3DCOMPILE_USEVOIDS;HAVE_GRIFFIN;HAVE_HLSL;HAVE_VID_CONTEXT;HAVE_D3D9;_XBOX360;HAVE_FBO;HAVE_SCREENSHOTS;WANT_MINIZ;HAVE_SINC;SINC_LOWER_QUALITY Callcap @@ -190,7 +190,7 @@ Size false MultiThreaded - NDEBUG;_XBOX;PROFILE;%(PreprocessorDefinitions);HAVE_XINPUT2;PACKAGE_VERSION="0.9.8.4";HAVE_DEFAULT_RETROPAD_INPUT;_CRT_SECURE_NO_WARNINGS;RARCH_CONSOLE;HAVE_RMENU;main=rarch_main;HAVE_FILEBROWSER;HAVE_ZLIB;HAVE_RARCH_MAIN_WRAP;HAVE_RARCH_EXEC;HAVE_LIBRETRO_MANAGEMENT;D3DCOMPILE_USEVOIDS;HAVE_GRIFFIN;HAVE_HLSL;HAVE_VID_CONTEXT;HAVE_D3D9;_XBOX360;HAVE_FBO;HAVE_SCREENSHOTS;WANT_MINIZ;HAVE_SINC;SINC_LOWER_QUALITY;HAVE_XAUDIO + NDEBUG;_XBOX;PROFILE;%(PreprocessorDefinitions);HAVE_XINPUT2;PACKAGE_VERSION="0.9.8.4";HAVE_DEFAULT_RETROPAD_INPUT;_CRT_SECURE_NO_WARNINGS;RARCH_CONSOLE;HAVE_RMENU;HAVE_RARCH_MAIN_IMPLEMENTATION;HAVE_FILEBROWSER;HAVE_ZLIB;HAVE_RARCH_MAIN_WRAP;HAVE_RARCH_EXEC;HAVE_LIBRETRO_MANAGEMENT;D3DCOMPILE_USEVOIDS;HAVE_GRIFFIN;HAVE_HLSL;HAVE_VID_CONTEXT;HAVE_D3D9;_XBOX360;HAVE_FBO;HAVE_SCREENSHOTS;WANT_MINIZ;HAVE_SINC;SINC_LOWER_QUALITY;HAVE_XAUDIO Callcap @@ -234,7 +234,7 @@ Size false MultiThreaded - NDEBUG;_XBOX;PROFILE;FASTCAP;%(PreprocessorDefinitions);HAVE_XINPUT2;PACKAGE_VERSION="0.9.8.4";HAVE_DEFAULT_RETROPAD_INPUT;_CRT_SECURE_NO_WARNINGS;main=rarch_main;HAVE_FILEBROWSER;HAVE_ZLIB;HAVE_RARCH_MAIN_WRAP;HAVE_RARCH_EXEC;HAVE_LIBRETRO_MANAGEMENT;D3DCOMPILE_USEVOIDS;HAVE_GRIFFIN;HAVE_HLSL;HAVE_VID_CONTEXT;HAVE_D3D9;_XBOX360;HAVE_FBO;HAVE_SCREENSHOTS;WANT_MINIZ;HAVE_SINC;SINC_LOWER_QUALITY;HAVE_RMENU;HAVE_XAUDIO + NDEBUG;_XBOX;PROFILE;FASTCAP;%(PreprocessorDefinitions);HAVE_XINPUT2;PACKAGE_VERSION="0.9.8.4";HAVE_DEFAULT_RETROPAD_INPUT;_CRT_SECURE_NO_WARNINGS;HAVE_RARCH_MAIN_IMPLEMENTATION;HAVE_FILEBROWSER;HAVE_ZLIB;HAVE_RARCH_MAIN_WRAP;HAVE_RARCH_EXEC;HAVE_LIBRETRO_MANAGEMENT;D3DCOMPILE_USEVOIDS;HAVE_GRIFFIN;HAVE_HLSL;HAVE_VID_CONTEXT;HAVE_D3D9;_XBOX360;HAVE_FBO;HAVE_SCREENSHOTS;WANT_MINIZ;HAVE_SINC;SINC_LOWER_QUALITY;HAVE_RMENU;HAVE_XAUDIO true @@ -275,7 +275,7 @@ false false MultiThreaded - NDEBUG;_XBOX;%(PreprocessorDefinitions);HAVE_XINPUT2;PACKAGE_VERSION="0.9.8.4";_CRT_SECURE_NO_WARNINGS;HAVE_DEFAULT_RETROPAD_INPUT;main=rarch_main;RARCH_CONSOLE=1;HAVE_FILEBROWSER;HAVE_NETPLAY;HAVE_SOCKET_LEGACY;HAVE_ZLIB;HAVE_RARCH_MAIN_WRAP;HAVE_RARCH_EXEC;HAVE_LIBRETRO_MANAGEMENT;D3DCOMPILE_USEVOIDS;HAVE_GRIFFIN;HAVE_HLSL;HAVE_VID_CONTEXT;HAVE_D3D9;_XBOX360;HAVE_FBO;HAVE_SCREENSHOTS;WANT_MINIZ;HAVE_SINC;SINC_LOWER_QUALITY;HAVE_RMENU;HAVE_XAUDIO + NDEBUG;_XBOX;%(PreprocessorDefinitions);HAVE_XINPUT2;PACKAGE_VERSION="0.9.8.4";_CRT_SECURE_NO_WARNINGS;HAVE_DEFAULT_RETROPAD_INPUT;HAVE_RARCH_MAIN_IMPLEMENTATION;RARCH_CONSOLE=1;HAVE_FILEBROWSER;HAVE_NETPLAY;HAVE_SOCKET_LEGACY;HAVE_ZLIB;HAVE_RARCH_MAIN_WRAP;HAVE_RARCH_EXEC;HAVE_LIBRETRO_MANAGEMENT;D3DCOMPILE_USEVOIDS;HAVE_GRIFFIN;HAVE_HLSL;HAVE_VID_CONTEXT;HAVE_D3D9;_XBOX360;HAVE_FBO;HAVE_SCREENSHOTS;WANT_MINIZ;HAVE_SINC;SINC_LOWER_QUALITY;HAVE_RMENU;HAVE_XAUDIO true @@ -316,7 +316,7 @@ false false MultiThreaded - NDEBUG;_XBOX;LTCG;%(PreprocessorDefinitions);HAVE_XINPUT2;PACKAGE_VERSION="0.9.8.4";_CRT_SECURE_NO_WARNINGS;HAVE_DEFAULT_RETROPAD_INPUT;RARCH_CONSOLE;HAVE_RMENU;main=rarch_main;HAVE_FILEBROWSER;HAVE_NETPLAY;HAVE_SOCKET_LEGACY;HAVE_ZLIB;HAVE_RARCH_MAIN_WRAP;HAVE_RARCH_EXEC;HAVE_LIBRETRO_MANAGEMENT;D3DCOMPILE_USEVOIDS;HAVE_GRIFFIN;HAVE_HLSL;HAVE_VID_CONTEXT;HAVE_D3D9;_XBOX360;HAVE_FBO;HAVE_SCREENSHOTS;WANT_MINIZ;HAVE_SINC;SINC_LOWER_QUALITY;HAVE_XAUDIO + NDEBUG;_XBOX;LTCG;%(PreprocessorDefinitions);HAVE_XINPUT2;PACKAGE_VERSION="0.9.8.4";_CRT_SECURE_NO_WARNINGS;HAVE_DEFAULT_RETROPAD_INPUT;RARCH_CONSOLE;HAVE_RMENU;HAVE_RARCH_MAIN_IMPLEMENTATION;HAVE_FILEBROWSER;HAVE_NETPLAY;HAVE_SOCKET_LEGACY;HAVE_ZLIB;HAVE_RARCH_MAIN_WRAP;HAVE_RARCH_EXEC;HAVE_LIBRETRO_MANAGEMENT;D3DCOMPILE_USEVOIDS;HAVE_GRIFFIN;HAVE_HLSL;HAVE_VID_CONTEXT;HAVE_D3D9;_XBOX360;HAVE_FBO;HAVE_SCREENSHOTS;WANT_MINIZ;HAVE_SINC;SINC_LOWER_QUALITY;HAVE_XAUDIO true diff --git a/msvc/RetroArch-Xbox1/RetroArch-Xbox1.vcproj b/msvc/RetroArch-Xbox1/RetroArch-Xbox1.vcproj index 89e3dcbb97..ee6c918db2 100644 --- a/msvc/RetroArch-Xbox1/RetroArch-Xbox1.vcproj +++ b/msvc/RetroArch-Xbox1/RetroArch-Xbox1.vcproj @@ -22,7 +22,7 @@ Optimization="3" OptimizeForProcessor="2" AdditionalIncludeDirectories=""$(SolutionDir)\msvc-stdint";"$(SolutionDir)\msvc-71"" - PreprocessorDefinitions="_DEBUG;_XBOX;_XBOX1;HAVE_RMENU;HAVE_RMENU_GUI;RARCH_CONSOLE;HAVE_XINPUT_XBOX1;PACKAGE_VERSION=\"0.9.8.4\";__STDC_CONSTANT_MACROS;HAVE_ZLIB;HAVE_GRIFFIN;HAVE_RARCH_MAIN_WRAP;HAVE_LIBRETRO_MANAGEMENT;HAVE_RARCH_EXEC;HAVE_DEFAULT_RETROPAD_INPUT;HAVE_VID_CONTEXT;HAVE_DSOUND;HAVE_D3D8;HAVE_FILEBROWSER;WANT_MINIZ;HAVE_SINC;SINC_LOWER_QUALITY" + PreprocessorDefinitions="_DEBUG;_XBOX;_XBOX1;HAVE_RMENU;HAVE_RMENU_GUI;RARCH_CONSOLE;HAVE_XINPUT_XBOX1;PACKAGE_VERSION=\"0.9.8.4\";__STDC_CONSTANT_MACROS;HAVE_ZLIB;HAVE_GRIFFIN;HAVE_RARCH_MAIN_WRAP;HAVE_RARCH_MAIN_IMPLEMENTATION;HAVE_LIBRETRO_MANAGEMENT;HAVE_RARCH_EXEC;HAVE_DEFAULT_RETROPAD_INPUT;HAVE_VID_CONTEXT;HAVE_DSOUND;HAVE_D3D8;HAVE_FILEBROWSER;WANT_MINIZ;HAVE_SINC;SINC_LOWER_QUALITY" MinimalRebuild="TRUE" BasicRuntimeChecks="0" RuntimeLibrary="1" @@ -72,7 +72,7 @@ OmitFramePointers="TRUE" OptimizeForProcessor="2" AdditionalIncludeDirectories=""$(SolutionDir)\msvc-stdint";"$(SolutionDir)\msvc-71"" - PreprocessorDefinitions="NDEBUG;_XBOX;_XBOX1;HAVE_RMENU;HAVE_RMENU_GUI;RARCH_CONSOLE;HAVE_XINPUT_XBOX1;PACKAGE_VERSION=\"0.9.8.4\";__STDC_CONSTANT_MACROS;HAVE_ZLIB;PROFILE;HAVE_GRIFFIN;HAVE_RARCH_MAIN_WRAP;HAVE_LIBRETRO_MANAGEMENT;HAVE_RARCH_EXEC;HAVE_DEFAULT_RETROPAD_INPUT;HAVE_VID_CONTEXT;HAVE_DSOUND;HAVE_D3D8;HAVE_FILEBROWSER;WANT_MINIZ;HAVE_SINC;SINC_LOWER_QUALITY" + PreprocessorDefinitions="NDEBUG;_XBOX;_XBOX1;HAVE_RMENU;HAVE_RMENU_GUI;RARCH_CONSOLE;HAVE_XINPUT_XBOX1;PACKAGE_VERSION=\"0.9.8.4\";__STDC_CONSTANT_MACROS;HAVE_ZLIB;PROFILE;HAVE_GRIFFIN;HAVE_RARCH_MAIN_WRAP;HAVE_RARCH_MAIN_IMPLEMENTATION;HAVE_LIBRETRO_MANAGEMENT;HAVE_RARCH_EXEC;HAVE_DEFAULT_RETROPAD_INPUT;HAVE_VID_CONTEXT;HAVE_DSOUND;HAVE_D3D8;HAVE_FILEBROWSER;WANT_MINIZ;HAVE_SINC;SINC_LOWER_QUALITY" StringPooling="TRUE" RuntimeLibrary="0" BufferSecurityCheck="TRUE" @@ -127,7 +127,7 @@ OmitFramePointers="TRUE" OptimizeForProcessor="2" AdditionalIncludeDirectories=""$(SolutionDir)\msvc-stdint";"$(SolutionDir)\msvc-71"" - PreprocessorDefinitions="NDEBUG;_XBOX;_XBOX1;HAVE_RMENU;HAVE_RMENU_GUI;RARCH_CONSOLE;HAVE_XINPUT_XBOX1;PACKAGE_VERSION=\"0.9.8.4\";__STDC_CONSTANT_MACROS;HAVE_ZLIB;PROFILE;FASTCAP;HAVE_GRIFFIN;HAVE_RARCH_MAIN_WRAP;HAVE_LIBRETRO_MANAGEMENT;HAVE_RARCH_EXEC;HAVE_DEFAULT_RETROPAD_INPUT;HAVE_VID_CONTEXT;HAVE_DSOUND;HAVE_D3D8;HAVE_FILEBROWSER;WANT_MINIZ;HAVE_SINC;SINC_LOWER_QUALITY" + PreprocessorDefinitions="NDEBUG;_XBOX;_XBOX1;HAVE_RMENU;HAVE_RMENU_GUI;RARCH_CONSOLE;HAVE_XINPUT_XBOX1;PACKAGE_VERSION=\"0.9.8.4\";__STDC_CONSTANT_MACROS;HAVE_ZLIB;PROFILE;FASTCAP;HAVE_GRIFFIN;HAVE_RARCH_MAIN_WRAP;HAVE_RARCH_MAIN_IMPLEMENTATION;HAVE_LIBRETRO_MANAGEMENT;HAVE_RARCH_EXEC;HAVE_DEFAULT_RETROPAD_INPUT;HAVE_VID_CONTEXT;HAVE_DSOUND;HAVE_D3D8;HAVE_FILEBROWSER;WANT_MINIZ;HAVE_SINC;SINC_LOWER_QUALITY" StringPooling="TRUE" RuntimeLibrary="0" BufferSecurityCheck="TRUE" @@ -188,7 +188,7 @@ EnableFiberSafeOptimizations="TRUE" OptimizeForProcessor="2" AdditionalIncludeDirectories=""$(SolutionDir)\msvc-stdint";"$(SolutionDir)\msvc-71"" - PreprocessorDefinitions="NDEBUG;_XBOX;_XBOX1;HAVE_RMENU;HAVE_RMENU_GUI;RARCH_CONSOLE;HAVE_XINPUT_XBOX1;PACKAGE_VERSION=\"0.9.8.4\";__STDC_CONSTANT_MACROS;HAVE_ZLIB;HAVE_GRIFFIN;inline=_inline;HAVE_RARCH_MAIN_WRAP;HAVE_LIBRETRO_MANAGEMENT;HAVE_RARCH_EXEC;HAVE_DEFAULT_RETROPAD_INPUT;HAVE_VID_CONTEXT;HAVE_DSOUND;HAVE_D3D8;HAVE_FILEBROWSER;WANT_MINIZ;HAVE_SINC;SINC_LOWER_QUALITY" + PreprocessorDefinitions="NDEBUG;_XBOX;_XBOX1;HAVE_RMENU;HAVE_RMENU_GUI;RARCH_CONSOLE;HAVE_XINPUT_XBOX1;PACKAGE_VERSION=\"0.9.8.4\";__STDC_CONSTANT_MACROS;HAVE_ZLIB;HAVE_GRIFFIN;inline=_inline;HAVE_RARCH_MAIN_WRAP;HAVE_RARCH_MAIN_IMPLEMENTATION;HAVE_LIBRETRO_MANAGEMENT;HAVE_RARCH_EXEC;HAVE_DEFAULT_RETROPAD_INPUT;HAVE_VID_CONTEXT;HAVE_DSOUND;HAVE_D3D8;HAVE_FILEBROWSER;WANT_MINIZ;HAVE_SINC;SINC_LOWER_QUALITY" StringPooling="TRUE" RuntimeLibrary="0" BufferSecurityCheck="TRUE" @@ -241,7 +241,7 @@ OmitFramePointers="TRUE" OptimizeForProcessor="2" AdditionalIncludeDirectories=""$(SolutionDir)\msvc-stdint";"$(SolutionDir)\msvc-71"" - PreprocessorDefinitions="NDEBUG;_XBOX;_XBOX1;HAVE_RMENU;HAVE_RMENU_GUI;RARCH_CONSOLE;HAVE_XINPUT_XBOX1;PACKAGE_VERSION=\"0.9.8.4\";__STDC_CONSTANT_MACROS;HAVE_ZLIB;LTCG;HAVE_GRIFFIN;HAVE_RARCH_MAIN_WRAP;HAVE_LIBRETRO_MANAGEMENT;HAVE_RARCH_EXEC;HAVE_DEFAULT_RETROPAD_INPUT;HAVE_VID_CONTEXT;HAVE_DSOUND;HAVE_D3D8;HAVE_FILEBROWSER;WANT_MINIZ;HAVE_SINC;SINC_LOWER_QUALITY" + PreprocessorDefinitions="NDEBUG;_XBOX;_XBOX1;HAVE_RMENU;HAVE_RMENU_GUI;RARCH_CONSOLE;HAVE_XINPUT_XBOX1;PACKAGE_VERSION=\"0.9.8.4\";__STDC_CONSTANT_MACROS;HAVE_ZLIB;LTCG;HAVE_GRIFFIN;HAVE_RARCH_MAIN_WRAP;HAVE_RARCH_MAIN_IMPLEMENTATION;HAVE_LIBRETRO_MANAGEMENT;HAVE_RARCH_EXEC;HAVE_DEFAULT_RETROPAD_INPUT;HAVE_VID_CONTEXT;HAVE_DSOUND;HAVE_D3D8;HAVE_FILEBROWSER;WANT_MINIZ;HAVE_SINC;SINC_LOWER_QUALITY" StringPooling="TRUE" RuntimeLibrary="0" BufferSecurityCheck="TRUE" diff --git a/msvc/msvc-2010/RetroArch-msvc2010.vcxproj b/msvc/msvc-2010/RetroArch-msvc2010.vcxproj index 40e35b3f1a..ba02e5f378 100644 --- a/msvc/msvc-2010/RetroArch-msvc2010.vcxproj +++ b/msvc/msvc-2010/RetroArch-msvc2010.vcxproj @@ -254,6 +254,8 @@ + + @@ -274,4 +276,4 @@ - \ No newline at end of file + diff --git a/msvc/msvc_compat.h b/msvc/msvc_compat.h index eaa693e435..22bb32d261 100644 --- a/msvc/msvc_compat.h +++ b/msvc/msvc_compat.h @@ -35,6 +35,8 @@ typedef int ssize_t; #define strtoull _strtoui64 #undef strcasecmp #define strcasecmp _stricmp +#undef strncasecmp +#define strncasecmp _strnicmp // Disable some of the annoying warnings. #pragma warning(disable : 4800) diff --git a/performance.c b/performance.c index efcca85193..b557c22e21 100644 --- a/performance.c +++ b/performance.c @@ -31,11 +31,17 @@ #endif #elif defined(_XBOX360) #include -#elif defined(_POSIX_MONOTONIC_CLOCK) || defined(ANDROID) +#elif defined(_POSIX_MONOTONIC_CLOCK) || defined(ANDROID) || defined(__QNX__) // POSIX_MONOTONIC_CLOCK is not being defined in Android headers despite support being present. #include #endif +#ifdef __QNX__ +#ifndef CLOCK_MONOTONIC +#define CLOCK_MONOTONIC 2 +#endif +#endif + #if defined(__PSL1GHT__) #include #elif defined(__CELLOS_LV2__) @@ -85,7 +91,7 @@ rarch_perf_tick_t rarch_get_perf_counter(void) __asm mov time_tmp.HighPart, edx; time = time_tmp.QuadPart; -#elif defined(__linux__) +#elif defined(__linux__) || defined(__QNX__) struct timespec tv; if (clock_gettime(CLOCK_MONOTONIC, &tv) == 0) time = (rarch_perf_tick_t)tv.tv_sec * 1000000000 + (rarch_perf_tick_t)tv.tv_nsec; @@ -134,7 +140,7 @@ rarch_time_t rarch_get_time_usec(void) clock_get_time(cclock, &mts); mach_port_deallocate(mach_task_self(), cclock); return mts.tv_sec * INT64_C(1000000) + (mts.tv_nsec + 500) / 1000; -#elif defined(_POSIX_MONOTONIC_CLOCK) || defined(ANDROID) +#elif defined(_POSIX_MONOTONIC_CLOCK) || defined(__QNX__) || defined(ANDROID) struct timespec tv; if (clock_gettime(CLOCK_MONOTONIC, &tv) < 0) return 0; @@ -218,6 +224,9 @@ void rarch_get_cpu_features(struct rarch_cpu_features *cpu) if (cpu_flags & ANDROID_CPU_ARM_FEATURE_NEON) cpu->simd |= RARCH_SIMD_NEON; + RARCH_LOG("[CPUID]: NEON: %u\n", !!(cpu->simd & RARCH_SIMD_NEON)); +#elif defined(__BLACKBERRY_QNX__) + cpu->simd |= RARCH_SIMD_NEON; RARCH_LOG("[CPUID]: NEON: %u\n", !!(cpu->simd & RARCH_SIMD_NEON)); #elif defined(__CELLOS_LV2__) cpu->simd |= RARCH_SIMD_VMX; diff --git a/playbook/.cproject b/playbook/.cproject new file mode 100644 index 0000000000..570b741058 --- /dev/null +++ b/playbook/.cproject @@ -0,0 +1,854 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/playbook/.project b/playbook/.project new file mode 100644 index 0000000000..5d9c1e70f8 --- /dev/null +++ b/playbook/.project @@ -0,0 +1,93 @@ + + + RetroArch + + + + + + org.eclipse.cdt.managedbuilder.core.genmakebuilder + clean,full,incremental, + + + ?name? + + + + org.eclipse.cdt.make.core.append_environment + true + + + org.eclipse.cdt.make.core.buildArguments + + + + org.eclipse.cdt.make.core.buildCommand + make + + + org.eclipse.cdt.make.core.buildLocation + ${workspace_loc:/CubeRotate/Device-Release} + + + org.eclipse.cdt.make.core.contents + org.eclipse.cdt.make.core.activeConfigSettings + + + org.eclipse.cdt.make.core.enableAutoBuild + false + + + org.eclipse.cdt.make.core.enableCleanBuild + true + + + org.eclipse.cdt.make.core.enableFullBuild + true + + + org.eclipse.cdt.make.core.stopOnError + true + + + org.eclipse.cdt.make.core.useDefaultBuildCmd + true + + + + + org.eclipse.cdt.managedbuilder.core.ScannerConfigBuilder + full,incremental, + + + + + com.qnx.tools.bbt.xml.core.bbtXMLValidationBuilder + + + + + + org.eclipse.cdt.core.cnature + org.eclipse.cdt.managedbuilder.core.managedBuildNature + org.eclipse.cdt.managedbuilder.core.ScannerConfigNature + com.qnx.tools.ide.bbt.core.bbtnature + + + + src/griffin.c + 1 + PARENT-1-PROJECT_LOC/console/griffin/griffin.c + + + src/sinc_neon.S + 1 + PARENT-1-PROJECT_LOC/audio/sinc_neon.S + + + src/utils_neon.S + 1 + PARENT-1-PROJECT_LOC/audio/utils_neon.S + + + diff --git a/playbook/.settings/org.eclipse.cdt.codan.core.prefs b/playbook/.settings/org.eclipse.cdt.codan.core.prefs new file mode 100644 index 0000000000..59043abc64 --- /dev/null +++ b/playbook/.settings/org.eclipse.cdt.codan.core.prefs @@ -0,0 +1,66 @@ +#Sun Feb 24 21:20:16 CET 2013 +eclipse.preferences.version=1 +org.eclipse.cdt.codan.checkers.errnoreturn=Warning +org.eclipse.cdt.codan.checkers.errnoreturn.params={implicit\=>false} +org.eclipse.cdt.codan.checkers.errreturnvalue=Error +org.eclipse.cdt.codan.checkers.errreturnvalue.params={} +org.eclipse.cdt.codan.checkers.noreturn=Error +org.eclipse.cdt.codan.checkers.noreturn.params={implicit\=>false} +org.eclipse.cdt.codan.internal.checkers.AbstractClassCreation=-Error +org.eclipse.cdt.codan.internal.checkers.AbstractClassCreation.params={launchModes\=>{RUN_ON_FULL_BUILD\=>false,RUN_ON_INC_BUILD\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true}} +org.eclipse.cdt.codan.internal.checkers.AmbiguousProblem=-Error +org.eclipse.cdt.codan.internal.checkers.AmbiguousProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>false,RUN_ON_INC_BUILD\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true}} +org.eclipse.cdt.codan.internal.checkers.AssignmentInConditionProblem=Warning +org.eclipse.cdt.codan.internal.checkers.AssignmentInConditionProblem.params={} +org.eclipse.cdt.codan.internal.checkers.AssignmentToItselfProblem=Error +org.eclipse.cdt.codan.internal.checkers.AssignmentToItselfProblem.params={} +org.eclipse.cdt.codan.internal.checkers.CaseBreakProblem=Warning +org.eclipse.cdt.codan.internal.checkers.CaseBreakProblem.params={no_break_comment\=>"no break",last_case_param\=>true,empty_case_param\=>false} +org.eclipse.cdt.codan.internal.checkers.CatchByReference=Warning +org.eclipse.cdt.codan.internal.checkers.CatchByReference.params={unknown\=>false,exceptions\=>()} +org.eclipse.cdt.codan.internal.checkers.CircularReferenceProblem=-Error +org.eclipse.cdt.codan.internal.checkers.CircularReferenceProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>false,RUN_ON_INC_BUILD\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true}} +org.eclipse.cdt.codan.internal.checkers.FieldResolutionProblem=-Error +org.eclipse.cdt.codan.internal.checkers.FieldResolutionProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>false,RUN_ON_INC_BUILD\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true}} +org.eclipse.cdt.codan.internal.checkers.FunctionResolutionProblem=-Error +org.eclipse.cdt.codan.internal.checkers.FunctionResolutionProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>false,RUN_ON_INC_BUILD\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true}} +org.eclipse.cdt.codan.internal.checkers.InvalidArguments=-Error +org.eclipse.cdt.codan.internal.checkers.InvalidArguments.params={launchModes\=>{RUN_ON_FULL_BUILD\=>false,RUN_ON_INC_BUILD\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true}} +org.eclipse.cdt.codan.internal.checkers.InvalidTemplateArgumentsProblem=-Error +org.eclipse.cdt.codan.internal.checkers.InvalidTemplateArgumentsProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>false,RUN_ON_INC_BUILD\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true}} +org.eclipse.cdt.codan.internal.checkers.LabelStatementNotFoundProblem=-Error +org.eclipse.cdt.codan.internal.checkers.LabelStatementNotFoundProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>false,RUN_ON_INC_BUILD\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true}} +org.eclipse.cdt.codan.internal.checkers.MemberDeclarationNotFoundProblem=-Error +org.eclipse.cdt.codan.internal.checkers.MemberDeclarationNotFoundProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>false,RUN_ON_INC_BUILD\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true}} +org.eclipse.cdt.codan.internal.checkers.MethodResolutionProblem=-Error +org.eclipse.cdt.codan.internal.checkers.MethodResolutionProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>false,RUN_ON_INC_BUILD\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true}} +org.eclipse.cdt.codan.internal.checkers.NamingConventionFunctionChecker=-Info +org.eclipse.cdt.codan.internal.checkers.NamingConventionFunctionChecker.params={pattern\=>"^[a-z]",macro\=>true,exceptions\=>()} +org.eclipse.cdt.codan.internal.checkers.NonVirtualDestructorProblem=Warning +org.eclipse.cdt.codan.internal.checkers.NonVirtualDestructorProblem.params={} +org.eclipse.cdt.codan.internal.checkers.OverloadProblem=-Error +org.eclipse.cdt.codan.internal.checkers.OverloadProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>false,RUN_ON_INC_BUILD\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true}} +org.eclipse.cdt.codan.internal.checkers.RedeclarationProblem=-Error +org.eclipse.cdt.codan.internal.checkers.RedeclarationProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>false,RUN_ON_INC_BUILD\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true}} +org.eclipse.cdt.codan.internal.checkers.RedefinitionProblem=-Error +org.eclipse.cdt.codan.internal.checkers.RedefinitionProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>false,RUN_ON_INC_BUILD\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true}} +org.eclipse.cdt.codan.internal.checkers.ReturnStyleProblem=-Warning +org.eclipse.cdt.codan.internal.checkers.ReturnStyleProblem.params={} +org.eclipse.cdt.codan.internal.checkers.ScanfFormatStringSecurityProblem=-Warning +org.eclipse.cdt.codan.internal.checkers.ScanfFormatStringSecurityProblem.params={} +org.eclipse.cdt.codan.internal.checkers.StatementHasNoEffectProblem=Warning +org.eclipse.cdt.codan.internal.checkers.StatementHasNoEffectProblem.params={macro\=>true,exceptions\=>()} +org.eclipse.cdt.codan.internal.checkers.SuggestedParenthesisProblem=Warning +org.eclipse.cdt.codan.internal.checkers.SuggestedParenthesisProblem.params={paramNot\=>false} +org.eclipse.cdt.codan.internal.checkers.SuspiciousSemicolonProblem=Warning +org.eclipse.cdt.codan.internal.checkers.SuspiciousSemicolonProblem.params={else\=>false,afterelse\=>false} +org.eclipse.cdt.codan.internal.checkers.TypeResolutionProblem=-Error +org.eclipse.cdt.codan.internal.checkers.TypeResolutionProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>false,RUN_ON_INC_BUILD\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true}} +org.eclipse.cdt.codan.internal.checkers.UnusedFunctionDeclarationProblem=Warning +org.eclipse.cdt.codan.internal.checkers.UnusedFunctionDeclarationProblem.params={macro\=>true} +org.eclipse.cdt.codan.internal.checkers.UnusedStaticFunctionProblem=Warning +org.eclipse.cdt.codan.internal.checkers.UnusedStaticFunctionProblem.params={macro\=>true} +org.eclipse.cdt.codan.internal.checkers.UnusedVariableDeclarationProblem=Warning +org.eclipse.cdt.codan.internal.checkers.UnusedVariableDeclarationProblem.params={macro\=>true,exceptions\=>("@(\#)","$Id")} +org.eclipse.cdt.codan.internal.checkers.VariableResolutionProblem=-Error +org.eclipse.cdt.codan.internal.checkers.VariableResolutionProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>false,RUN_ON_INC_BUILD\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true}} diff --git a/playbook/bar-descriptor.xml b/playbook/bar-descriptor.xml new file mode 100644 index 0000000000..a7efdace67 --- /dev/null +++ b/playbook/bar-descriptor.xml @@ -0,0 +1,110 @@ + + + + + + + com.RetroArch + + + RetroArch + + + 1.0.0 + + + 1 + + + "v0.9.8.4" + + + Multi-emulator/multi-game system application + + + + + + Example Inc. + + + + + + none + false + + + + core.games + icon.png + retroarch.cfg + lib/test.so + + + + + armle-v7 + RetroArch + + + armle-v7 + RetroArch + + + armle-v7 + RetroArch + + + armle-v7 + RetroArch + + + x86 + RetroArch + + + x86 + RetroArch + + + x86 + RetroArch + + + + + icon.png + + + + + + + run_native + + + access_shared + + + + + + + + + + + + + diff --git a/playbook/icon.png b/playbook/icon.png new file mode 100644 index 0000000000..a113106a99 Binary files /dev/null and b/playbook/icon.png differ diff --git a/playbook/src/bbutil.c b/playbook/src/bbutil.c new file mode 100644 index 0000000000..014441214e --- /dev/null +++ b/playbook/src/bbutil.c @@ -0,0 +1,1006 @@ +/* + * Copyright (c) 2011-2012 Research In Motion Limited. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "bbutil.h" + +#include + +#include +#include FT_FREETYPE_H + +#include "png.h" + +EGLDisplay egl_disp; +EGLSurface egl_surf; + +static EGLConfig egl_conf; +static EGLContext egl_ctx; + +static screen_context_t screen_ctx; +static screen_window_t screen_win; +static screen_display_t screen_disp; +static int nbuffers = 2; +static int initialized = 0; + +static GLuint text_rendering_program; +static int text_program_initialized = 0; +static GLint positionLoc; +static GLint texcoordLoc; +static GLint textureLoc; +static GLint colorLoc; + +struct font_t { + unsigned int font_texture; + float pt; + float advance[128]; + float width[128]; + float height[128]; + float tex_x1[128]; + float tex_x2[128]; + float tex_y1[128]; + float tex_y2[128]; + float offset_x[128]; + float offset_y[128]; + int initialized; +}; + + +static void +bbutil_egl_perror(const char *msg) { + static const char *errmsg[] = { + "function succeeded", + "EGL is not initialized, or could not be initialized, for the specified display", + "cannot access a requested resource", + "failed to allocate resources for the requested operation", + "an unrecognized attribute or attribute value was passed in an attribute list", + "an EGLConfig argument does not name a valid EGLConfig", + "an EGLContext argument does not name a valid EGLContext", + "the current surface of the calling thread is no longer valid", + "an EGLDisplay argument does not name a valid EGLDisplay", + "arguments are inconsistent", + "an EGLNativePixmapType argument does not refer to a valid native pixmap", + "an EGLNativeWindowType argument does not refer to a valid native window", + "one or more argument values are invalid", + "an EGLSurface argument does not name a valid surface configured for rendering", + "a power management event has occurred", + "unknown error code" + }; + + int message_index = eglGetError() - EGL_SUCCESS; + + if (message_index < 0 || message_index > 14) + message_index = 15; + + fprintf(stderr, "%s: %s\n", msg, errmsg[message_index]); +} + +int +bbutil_init_egl(screen_context_t ctx) { + int usage; + int format = SCREEN_FORMAT_RGBX8888; + EGLint interval = 1; + int rc, num_configs; + + EGLint attrib_list[]= { EGL_RED_SIZE, 8, + EGL_GREEN_SIZE, 8, + EGL_BLUE_SIZE, 8, + EGL_SURFACE_TYPE, EGL_WINDOW_BIT, + EGL_RENDERABLE_TYPE, 0, + EGL_NONE}; + + usage = SCREEN_USAGE_OPENGL_ES2 | SCREEN_USAGE_ROTATION; + attrib_list[9] = EGL_OPENGL_ES2_BIT; + EGLint attributes[] = { EGL_CONTEXT_CLIENT_VERSION, 2, EGL_NONE }; + + //Simple egl initialization + screen_ctx = ctx; + + egl_disp = eglGetDisplay(EGL_DEFAULT_DISPLAY); + if (egl_disp == EGL_NO_DISPLAY) { + bbutil_egl_perror("eglGetDisplay"); + bbutil_terminate(); + return EXIT_FAILURE; + } + + rc = eglInitialize(egl_disp, NULL, NULL); + if (rc != EGL_TRUE) { + bbutil_egl_perror("eglInitialize"); + bbutil_terminate(); + return EXIT_FAILURE; + } + + rc = eglBindAPI(EGL_OPENGL_ES_API); + + if (rc != EGL_TRUE) { + bbutil_egl_perror("eglBindApi"); + bbutil_terminate(); + return EXIT_FAILURE; + } + + if(!eglChooseConfig(egl_disp, attrib_list, &egl_conf, 1, &num_configs)) { + bbutil_terminate(); + return EXIT_FAILURE; + } + + egl_ctx = eglCreateContext(egl_disp, egl_conf, EGL_NO_CONTEXT, attributes); + + if (egl_ctx == EGL_NO_CONTEXT) { + bbutil_egl_perror("eglCreateContext"); + bbutil_terminate(); + return EXIT_FAILURE; + } + + rc = screen_create_window(&screen_win, screen_ctx); + if (rc) { + perror("screen_create_window"); + bbutil_terminate(); + return EXIT_FAILURE; + } + + rc = screen_set_window_property_iv(screen_win, SCREEN_PROPERTY_FORMAT, &format); + if (rc) { + perror("screen_set_window_property_iv(SCREEN_PROPERTY_FORMAT)"); + bbutil_terminate(); + return EXIT_FAILURE; + } + + rc = screen_set_window_property_iv(screen_win, SCREEN_PROPERTY_USAGE, &usage); + if (rc) { + perror("screen_set_window_property_iv(SCREEN_PROPERTY_USAGE)"); + bbutil_terminate(); + return EXIT_FAILURE; + } + + rc = screen_get_window_property_pv(screen_win, SCREEN_PROPERTY_DISPLAY, (void **)&screen_disp); + if (rc) { + perror("screen_get_window_property_pv"); + bbutil_terminate(); + return EXIT_FAILURE; + } + + int screen_resolution[2]; + + rc = screen_get_display_property_iv(screen_disp, SCREEN_PROPERTY_SIZE, screen_resolution); + if (rc) { + perror("screen_get_display_property_iv"); + bbutil_terminate(); + return EXIT_FAILURE; + } + + int angle = atoi(getenv("ORIENTATION")); + + screen_display_mode_t screen_mode; + rc = screen_get_display_property_pv(screen_disp, SCREEN_PROPERTY_MODE, (void**)&screen_mode); + if (rc) { + perror("screen_get_display_property_pv"); + bbutil_terminate(); + return EXIT_FAILURE; + } + + int size[2]; + rc = screen_get_window_property_iv(screen_win, SCREEN_PROPERTY_BUFFER_SIZE, size); + if (rc) { + perror("screen_get_window_property_iv"); + bbutil_terminate(); + return EXIT_FAILURE; + } + + int buffer_size[2] = {size[0], size[1]}; + + if ((angle == 0) || (angle == 180)) { + if (((screen_mode.width > screen_mode.height) && (size[0] < size[1])) || + ((screen_mode.width < screen_mode.height) && (size[0] > size[1]))) { + buffer_size[1] = size[0]; + buffer_size[0] = size[1]; + } + } else if ((angle == 90) || (angle == 270)){ + if (((screen_mode.width > screen_mode.height) && (size[0] > size[1])) || + ((screen_mode.width < screen_mode.height && size[0] < size[1]))) { + buffer_size[1] = size[0]; + buffer_size[0] = size[1]; + } + } else { + fprintf(stderr, "Navigator returned an unexpected orientation angle.\n"); + bbutil_terminate(); + return EXIT_FAILURE; + } + + rc = screen_set_window_property_iv(screen_win, SCREEN_PROPERTY_BUFFER_SIZE, buffer_size); + if (rc) { + perror("screen_set_window_property_iv"); + bbutil_terminate(); + return EXIT_FAILURE; + } + + rc = screen_set_window_property_iv(screen_win, SCREEN_PROPERTY_ROTATION, &angle); + if (rc) { + perror("screen_set_window_property_iv"); + bbutil_terminate(); + return EXIT_FAILURE; + } + + rc = screen_create_window_buffers(screen_win, nbuffers); + if (rc) { + perror("screen_create_window_buffers"); + bbutil_terminate(); + return EXIT_FAILURE; + } + + egl_surf = eglCreateWindowSurface(egl_disp, egl_conf, screen_win, NULL); + if (egl_surf == EGL_NO_SURFACE) { + bbutil_egl_perror("eglCreateWindowSurface"); + bbutil_terminate(); + return EXIT_FAILURE; + } + + rc = eglMakeCurrent(egl_disp, egl_surf, egl_surf, egl_ctx); + if (rc != EGL_TRUE) { + bbutil_egl_perror("eglMakeCurrent"); + bbutil_terminate(); + return EXIT_FAILURE; + } + + rc = eglSwapInterval(egl_disp, interval); + if (rc != EGL_TRUE) { + bbutil_egl_perror("eglSwapInterval"); + bbutil_terminate(); + return EXIT_FAILURE; + } + + initialized = 1; + + return EXIT_SUCCESS; +} + +void +bbutil_terminate() { + //Typical EGL cleanup + if (egl_disp != EGL_NO_DISPLAY) { + eglMakeCurrent(egl_disp, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT); + if (egl_surf != EGL_NO_SURFACE) { + eglDestroySurface(egl_disp, egl_surf); + egl_surf = EGL_NO_SURFACE; + } + if (egl_ctx != EGL_NO_CONTEXT) { + eglDestroyContext(egl_disp, egl_ctx); + egl_ctx = EGL_NO_CONTEXT; + } + if (screen_win != NULL) { + screen_destroy_window(screen_win); + screen_win = NULL; + } + eglTerminate(egl_disp); + egl_disp = EGL_NO_DISPLAY; + } + eglReleaseThread(); + + initialized = 0; +} + +void +bbutil_swap() { + int rc = eglSwapBuffers(egl_disp, egl_surf); + if (rc != EGL_TRUE) { + bbutil_egl_perror("eglSwapBuffers"); + } +} + +/* Finds the next power of 2 */ +static inline int +nextp2(int x) +{ + int val = 1; + while(val < x) val <<= 1; + return val; +} + +font_t* bbutil_load_font(const char* path, int point_size, int dpi) { + FT_Library library; + FT_Face face; + int c; + int i, j; + font_t* font; + + if (!initialized) { + fprintf(stderr, "EGL has not been initialized\n"); + return NULL; + } + + if (!path){ + fprintf(stderr, "Invalid path to font file\n"); + return NULL; + } + + if(FT_Init_FreeType(&library)) { + fprintf(stderr, "Error loading Freetype library\n"); + return NULL; + } + if (FT_New_Face(library, path,0,&face)) { + fprintf(stderr, "Error loading font %s\n", path); + return NULL; + } + + if(FT_Set_Char_Size ( face, point_size * 64, point_size * 64, dpi, dpi)) { + fprintf(stderr, "Error initializing character parameters\n"); + return NULL; + } + + font = (font_t*) malloc(sizeof(font_t)); + + if (!font) { + fprintf(stderr, "Unable to allocate memory for font structure\n"); + return NULL; + } + + font->initialized = 0; + font->pt = point_size; + + glGenTextures(1, &(font->font_texture)); + + //Let each glyph reside in 32x32 section of the font texture + int segment_size_x = 0, segment_size_y = 0; + int num_segments_x = 16; + int num_segments_y = 8; + + FT_GlyphSlot slot; + FT_Bitmap bmp; + int glyph_width, glyph_height; + + //First calculate the max width and height of a character in a passed font + for(c = 0; c < 128; c++) { + if(FT_Load_Char(face, c, FT_LOAD_RENDER)) { + fprintf(stderr, "FT_Load_Char failed\n"); + free(font); + return NULL; + } + + slot = face->glyph; + bmp = slot->bitmap; + + glyph_width = bmp.width; + glyph_height = bmp.rows; + + if (glyph_width > segment_size_x) { + segment_size_x = glyph_width; + } + + if (glyph_height > segment_size_y) { + segment_size_y = glyph_height; + } + } + + int font_tex_width = nextp2(num_segments_x * segment_size_x); + int font_tex_height = nextp2(num_segments_y * segment_size_y); + + int bitmap_offset_x = 0, bitmap_offset_y = 0; + + GLubyte* font_texture_data = (GLubyte*) calloc(2 * font_tex_width * font_tex_height, sizeof(GLubyte)); + + if (!font_texture_data) { + fprintf(stderr, "Failed to allocate memory for font texture\n"); + free(font); + return NULL; + } + + // Fill font texture bitmap with individual bmp data and record appropriate size, texture coordinates and offsets for every glyph + for(c = 0; c < 128; c++) { + if(FT_Load_Char(face, c, FT_LOAD_RENDER)) { + fprintf(stderr, "FT_Load_Char failed\n"); + free(font); + return NULL; + } + + slot = face->glyph; + bmp = slot->bitmap; + + glyph_width = bmp.width; + glyph_height = bmp.rows; + + div_t temp = div(c, num_segments_x); + + bitmap_offset_x = segment_size_x * temp.rem; + bitmap_offset_y = segment_size_y * temp.quot; + + for (j = 0; j < glyph_height; j++) { + for (i = 0; i < glyph_width; i++) { + font_texture_data[2 * ((bitmap_offset_x + i) + (j + bitmap_offset_y) * font_tex_width) + 0] = + font_texture_data[2 * ((bitmap_offset_x + i) + (j + bitmap_offset_y) * font_tex_width) + 1] = + (i >= bmp.width || j >= bmp.rows)? 0 : bmp.buffer[i + bmp.width * j]; + } + } + + font->advance[c] = (float)(slot->advance.x >> 6); + font->tex_x1[c] = (float)bitmap_offset_x / (float) font_tex_width; + font->tex_x2[c] = (float)(bitmap_offset_x + bmp.width) / (float)font_tex_width; + font->tex_y1[c] = (float)bitmap_offset_y / (float) font_tex_height; + font->tex_y2[c] = (float)(bitmap_offset_y + bmp.rows) / (float)font_tex_height; + font->width[c] = bmp.width; + font->height[c] = bmp.rows; + font->offset_x[c] = (float)slot->bitmap_left; + font->offset_y[c] = (float)((slot->metrics.horiBearingY-face->glyph->metrics.height) >> 6); + } + + glBindTexture(GL_TEXTURE_2D, font->font_texture); + glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,GL_LINEAR); + glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,GL_LINEAR); + + glTexImage2D(GL_TEXTURE_2D, 0, GL_LUMINANCE_ALPHA, font_tex_width, font_tex_height, 0, GL_LUMINANCE_ALPHA , GL_UNSIGNED_BYTE, font_texture_data); + + free(font_texture_data); + + FT_Done_Face(face); + FT_Done_FreeType(library); + + font->initialized = 1; + return font; +} + +void bbutil_render_text(font_t* font, const char* msg, float x, float y, float r, float g, float b, float a) { + int i, c; + GLfloat *vertices; + GLfloat *texture_coords; + GLshort* indices; + + float pen_x = 0.0f; + + if (!font) { + fprintf(stderr, "Font must not be null\n"); + return; + } + + if (!font->initialized) { + fprintf(stderr, "Font has not been loaded\n"); + return; + } + + if (!msg) { + return; + } + + const int msg_len = strlen(msg); + + vertices = (GLfloat*) malloc(sizeof(GLfloat) * 8 * msg_len); + texture_coords = (GLfloat*) malloc(sizeof(GLfloat) * 8 * msg_len); + + indices = (GLshort*) malloc(sizeof(GLfloat) * 6 * msg_len); + + for(i = 0; i < msg_len; ++i) { + c = msg[i]; + + vertices[8 * i + 0] = x + pen_x + font->offset_x[c]; + vertices[8 * i + 1] = y + font->offset_y[c]; + vertices[8 * i + 2] = vertices[8 * i + 0] + font->width[c]; + vertices[8 * i + 3] = vertices[8 * i + 1]; + vertices[8 * i + 4] = vertices[8 * i + 0]; + vertices[8 * i + 5] = vertices[8 * i + 1] + font->height[c]; + vertices[8 * i + 6] = vertices[8 * i + 2]; + vertices[8 * i + 7] = vertices[8 * i + 5]; + + texture_coords[8 * i + 0] = font->tex_x1[c]; + texture_coords[8 * i + 1] = font->tex_y2[c]; + texture_coords[8 * i + 2] = font->tex_x2[c]; + texture_coords[8 * i + 3] = font->tex_y2[c]; + texture_coords[8 * i + 4] = font->tex_x1[c]; + texture_coords[8 * i + 5] = font->tex_y1[c]; + texture_coords[8 * i + 6] = font->tex_x2[c]; + texture_coords[8 * i + 7] = font->tex_y1[c]; + + indices[i * 6 + 0] = 4 * i + 0; + indices[i * 6 + 1] = 4 * i + 1; + indices[i * 6 + 2] = 4 * i + 2; + indices[i * 6 + 3] = 4 * i + 2; + indices[i * 6 + 4] = 4 * i + 1; + indices[i * 6 + 5] = 4 * i + 3; + + //Assume we are only working with typewriter fonts + pen_x += font->advance[c]; + } + + if (!text_program_initialized) { + GLint status; + + // Create shaders if this hasn't been done already + const char* v_source = + "precision mediump float;" + "attribute vec2 a_position;" + "attribute vec2 a_texcoord;" + "varying vec2 v_texcoord;" + "void main()" + "{" + " gl_Position = vec4(a_position, 0.0, 1.0);" + " v_texcoord = a_texcoord;" + "}"; + + const char* f_source = + "precision lowp float;" + "varying vec2 v_texcoord;" + "uniform sampler2D u_font_texture;" + "uniform vec4 u_col;" + "void main()" + "{" + " vec4 temp = texture2D(u_font_texture, v_texcoord);" + " gl_FragColor = u_col * temp;" + "}"; + + // Compile the vertex shader + GLuint vs = glCreateShader(GL_VERTEX_SHADER); + + if (!vs) { + fprintf(stderr, "Failed to create vertex shader: %d\n", glGetError()); + return; + } else { + glShaderSource(vs, 1, &v_source, 0); + glCompileShader(vs); + glGetShaderiv(vs, GL_COMPILE_STATUS, &status); + if (GL_FALSE == status) { + GLchar log[256]; + glGetShaderInfoLog(vs, 256, NULL, log); + + fprintf(stderr, "Failed to compile vertex shader: %s\n", log); + + glDeleteShader(vs); + } + } + + // Compile the fragment shader + GLuint fs = glCreateShader(GL_FRAGMENT_SHADER); + + if (!fs) { + fprintf(stderr, "Failed to create fragment shader: %d\n", glGetError()); + return; + } else { + glShaderSource(fs, 1, &f_source, 0); + glCompileShader(fs); + glGetShaderiv(fs, GL_COMPILE_STATUS, &status); + if (GL_FALSE == status) { + GLchar log[256]; + glGetShaderInfoLog(fs, 256, NULL, log); + + fprintf(stderr, "Failed to compile fragment shader: %s\n", log); + + glDeleteShader(vs); + glDeleteShader(fs); + + return; + } + } + + // Create and link the program + text_rendering_program = glCreateProgram(); + if (text_rendering_program) + { + glAttachShader(text_rendering_program, vs); + glAttachShader(text_rendering_program, fs); + glLinkProgram(text_rendering_program); + + glGetProgramiv(text_rendering_program, GL_LINK_STATUS, &status); + if (status == GL_FALSE) { + GLchar log[256]; + glGetProgramInfoLog(fs, 256, NULL, log); + + fprintf(stderr, "Failed to link text rendering shader program: %s\n", log); + + glDeleteProgram(text_rendering_program); + text_rendering_program = 0; + + return; + } + } else { + fprintf(stderr, "Failed to create a shader program\n"); + + glDeleteShader(vs); + glDeleteShader(fs); + return; + } + + // We don't need the shaders anymore - the program is enough + glDeleteShader(fs); + glDeleteShader(vs); + + glUseProgram(text_rendering_program); + + // Store the locations of the shader variables we need later + positionLoc = glGetAttribLocation(text_rendering_program, "a_position"); + texcoordLoc = glGetAttribLocation(text_rendering_program, "a_texcoord"); + textureLoc = glGetUniformLocation(text_rendering_program, "u_font_texture"); + colorLoc = glGetUniformLocation(text_rendering_program, "u_col"); + + text_program_initialized = 1; + } + + glEnable(GL_BLEND); + + //Map text coordinates from (0...surface width, 0...surface height) to (-1...1, -1...1) + //this make our vertex shader very simple and also works irrespective of orientation changes + EGLint surface_width, surface_height; + + eglQuerySurface(egl_disp, egl_surf, EGL_WIDTH, &surface_width); + eglQuerySurface(egl_disp, egl_surf, EGL_HEIGHT, &surface_height); + + for(i = 0; i < 4 * msg_len; ++i) { + vertices[2 * i + 0] = 2 * vertices[2 * i + 0] / surface_width - 1.0f; + vertices[2 * i + 1] = 2 * vertices[2 * i + 1] / surface_height - 1.0f; + } + + //Render text + glUseProgram(text_rendering_program); + + glBlendFunc(GL_ONE, GL_ONE_MINUS_SRC_ALPHA); + + glBindBuffer(GL_ARRAY_BUFFER, 0); + + glActiveTexture(GL_TEXTURE0); + glBindTexture(GL_TEXTURE_2D, font->font_texture); + glUniform1i(textureLoc, 0); + + glUniform4f(colorLoc, r, g, b, a); + + glEnableVertexAttribArray(positionLoc); + glVertexAttribPointer(positionLoc, 2, GL_FLOAT, GL_FALSE, 0, vertices); + + glEnableVertexAttribArray(texcoordLoc); + glVertexAttribPointer(texcoordLoc, 2, GL_FLOAT, GL_FALSE, 0, texture_coords); + + //Draw the string + glDrawElements(GL_TRIANGLES, 6 * msg_len, GL_UNSIGNED_SHORT, indices); + + glDisableVertexAttribArray(positionLoc); + glDisableVertexAttribArray(texcoordLoc); + + free(vertices); + free(texture_coords); + free(indices); +} + +void bbutil_destroy_font(font_t* font) { + if (!font) { + return; + } + + glDeleteTextures(1, &(font->font_texture)); + + free(font); +} + +void bbutil_measure_text(font_t* font, const char* msg, float* width, float* height) { + int i, c; + + if (!msg) { + return; + } + + const int msg_len =strlen(msg); + + if (width) { + //Width of a text rectangle is a sum advances for every glyph in a string + *width = 0.0f; + + for(i = 0; i < msg_len; ++i) { + c = msg[i]; + *width += font->advance[c]; + } + } + + if (height) { + //Height of a text rectangle is a high of a tallest glyph in a string + *height = 0.0f; + + for(i = 0; i < msg_len; ++i) { + c = msg[i]; + + if (*height < font->height[c]) { + *height = font->height[c]; + } + } + } +} + +int bbutil_load_texture(const char* filename, int* width, int* height, float* tex_x, float* tex_y, unsigned int *tex) { + int i; + GLuint format; + //header for testing if it is a png + png_byte header[8]; + + if (!tex) { + return EXIT_FAILURE; + } + + //open file as binary + FILE *fp = fopen(filename, "rb"); + if (!fp) { + return EXIT_FAILURE; + } + + //read the header + fread(header, 1, 8, fp); + + //test if png + int is_png = !png_sig_cmp(header, 0, 8); + if (!is_png) { + fclose(fp); + return EXIT_FAILURE; + } + + //create png struct + png_structp png_ptr = png_create_read_struct(PNG_LIBPNG_VER_STRING, NULL, NULL, NULL); + if (!png_ptr) { + fclose(fp); + return EXIT_FAILURE; + } + + //create png info struct + png_infop info_ptr = png_create_info_struct(png_ptr); + if (!info_ptr) { + png_destroy_read_struct(&png_ptr, (png_infopp) NULL, (png_infopp) NULL); + fclose(fp); + return EXIT_FAILURE; + } + + //create png info struct + png_infop end_info = png_create_info_struct(png_ptr); + if (!end_info) { + png_destroy_read_struct(&png_ptr, &info_ptr, (png_infopp) NULL); + fclose(fp); + return EXIT_FAILURE; + } + + //setup error handling (required without using custom error handlers above) + if (setjmp(png_jmpbuf(png_ptr))) { + png_destroy_read_struct(&png_ptr, &info_ptr, &end_info); + fclose(fp); + return EXIT_FAILURE; + } + + //init png reading + png_init_io(png_ptr, fp); + + //let libpng know you already read the first 8 bytes + png_set_sig_bytes(png_ptr, 8); + + // read all the info up to the image data + png_read_info(png_ptr, info_ptr); + + //variables to pass to get info + int bit_depth, color_type; + png_uint_32 image_width, image_height; + + // get info about png + png_get_IHDR(png_ptr, info_ptr, &image_width, &image_height, &bit_depth, &color_type, NULL, NULL, NULL); + + switch (color_type) + { + case PNG_COLOR_TYPE_RGBA: + format = GL_RGBA; + break; + case PNG_COLOR_TYPE_RGB: + format = GL_RGB; + break; + default: + fprintf(stderr,"Unsupported PNG color type (%d) for texture: %s", (int)color_type, filename); + fclose(fp); + png_destroy_read_struct(&png_ptr, &info_ptr, &end_info); + return NULL; + } + + // Update the png info struct. + png_read_update_info(png_ptr, info_ptr); + + // Row size in bytes. + int rowbytes = png_get_rowbytes(png_ptr, info_ptr); + + // Allocate the image_data as a big block, to be given to opengl + png_byte *image_data = (png_byte*) malloc(sizeof(png_byte) * rowbytes * image_height); + + if (!image_data) { + //clean up memory and close stuff + png_destroy_read_struct(&png_ptr, &info_ptr, &end_info); + fclose(fp); + return EXIT_FAILURE; + } + + //row_pointers is for pointing to image_data for reading the png with libpng + png_bytep *row_pointers = (png_bytep*) malloc(sizeof(png_bytep) * image_height); + if (!row_pointers) { + //clean up memory and close stuff + png_destroy_read_struct(&png_ptr, &info_ptr, &end_info); + free(image_data); + fclose(fp); + return EXIT_FAILURE; + } + + // set the individual row_pointers to point at the correct offsets of image_data + for (i = 0; i < image_height; i++) { + row_pointers[image_height - 1 - i] = image_data + i * rowbytes; + } + + //read the png into image_data through row_pointers + png_read_image(png_ptr, row_pointers); + + int tex_width, tex_height; + + tex_width = nextp2(image_width); + tex_height = nextp2(image_height); + + glGenTextures(1, tex); + glBindTexture(GL_TEXTURE_2D, (*tex)); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); + + glPixelStorei(GL_UNPACK_ALIGNMENT, 1); + + if ((tex_width != image_width) || (tex_height != image_height) ) { + glTexImage2D(GL_TEXTURE_2D, 0, format, tex_width, tex_height, 0, format, GL_UNSIGNED_BYTE, NULL); + glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, image_width, image_height, format, GL_UNSIGNED_BYTE, image_data); + } else { + glTexImage2D(GL_TEXTURE_2D, 0, format, tex_width, tex_height, 0, format, GL_UNSIGNED_BYTE, image_data); + } + + GLint err = glGetError(); + + //clean up memory and close stuff + png_destroy_read_struct(&png_ptr, &info_ptr, &end_info); + free(image_data); + free(row_pointers); + fclose(fp); + + if (err == 0) { + //Return physical with and height of texture if pointers are not null + if(width) { + *width = image_width; + } + if (height) { + *height = image_height; + } + //Return modified texture coordinates if pointers are not null + if(tex_x) { + *tex_x = ((float) image_width - 0.5f) / ((float)tex_width); + } + if(tex_y) { + *tex_y = ((float) image_height - 0.5f) / ((float)tex_height); + } + return EXIT_SUCCESS; + } else { + fprintf(stderr, "GL error %i \n", err); + return EXIT_FAILURE; + } +} + +int bbutil_calculate_dpi(screen_context_t ctx) { + int rc; + int screen_phys_size[2]; + + rc = screen_get_display_property_iv(screen_disp, SCREEN_PROPERTY_PHYSICAL_SIZE, screen_phys_size); + if (rc) { + perror("screen_get_display_property_iv"); + bbutil_terminate(); + return EXIT_FAILURE; + } + + //Simulator will return 0,0 for physical size of the screen, so use 170 as default dpi + if ((screen_phys_size[0] == 0) && (screen_phys_size[1] == 0)) { + return 170; + } else { + int screen_resolution[2]; + rc = screen_get_display_property_iv(screen_disp, SCREEN_PROPERTY_SIZE, screen_resolution); + if (rc) { + perror("screen_get_display_property_iv"); + bbutil_terminate(); + return EXIT_FAILURE; + } + double diagonal_pixels = sqrt(screen_resolution[0] * screen_resolution[0] + screen_resolution[1] * screen_resolution[1]); + double diagonal_inches = 0.0393700787 * sqrt(screen_phys_size[0] * screen_phys_size[0] + screen_phys_size[1] * screen_phys_size[1]); + return (int)(diagonal_pixels / diagonal_inches + 0.5); + + } +} + +int bbutil_rotate_screen_surface(int angle) { + int rc, rotation, skip = 1, temp;; + EGLint interval = 1; + int size[2]; + + if ((angle != 0) && (angle != 90) && (angle != 180) && (angle != 270)) { + fprintf(stderr, "Invalid angle\n"); + return EXIT_FAILURE; + } + + rc = screen_get_window_property_iv(screen_win, SCREEN_PROPERTY_ROTATION, &rotation); + if (rc) { + perror("screen_set_window_property_iv"); + return EXIT_FAILURE; + } + + rc = screen_get_window_property_iv(screen_win, SCREEN_PROPERTY_BUFFER_SIZE, size); + if (rc) { + perror("screen_set_window_property_iv"); + return EXIT_FAILURE; + } + + switch (angle - rotation) { + case -270: + case -90: + case 90: + case 270: + temp = size[0]; + size[0] = size[1]; + size[1] = temp; + skip = 0; + break; + } + + if (!skip) { + rc = eglMakeCurrent(egl_disp, NULL, NULL, NULL); + if (rc != EGL_TRUE) { + bbutil_egl_perror("eglMakeCurrent"); + return EXIT_FAILURE; + } + + rc = eglDestroySurface(egl_disp, egl_surf); + if (rc != EGL_TRUE) { + bbutil_egl_perror("eglMakeCurrent"); + return EXIT_FAILURE; + } + + rc = screen_set_window_property_iv(screen_win, SCREEN_PROPERTY_SOURCE_SIZE, size); + if (rc) { + perror("screen_set_window_property_iv"); + return EXIT_FAILURE; + } + + rc = screen_set_window_property_iv(screen_win, SCREEN_PROPERTY_BUFFER_SIZE, size); + if (rc) { + perror("screen_set_window_property_iv"); + return EXIT_FAILURE; + } + egl_surf = eglCreateWindowSurface(egl_disp, egl_conf, screen_win, NULL); + if (egl_surf == EGL_NO_SURFACE) { + bbutil_egl_perror("eglCreateWindowSurface"); + return EXIT_FAILURE; + } + + rc = eglMakeCurrent(egl_disp, egl_surf, egl_surf, egl_ctx); + if (rc != EGL_TRUE) { + bbutil_egl_perror("eglMakeCurrent"); + return EXIT_FAILURE; + } + + rc = eglSwapInterval(egl_disp, interval); + if (rc != EGL_TRUE) { + bbutil_egl_perror("eglSwapInterval"); + return EXIT_FAILURE; + } + } + + rc = screen_set_window_property_iv(screen_win, SCREEN_PROPERTY_ROTATION, &angle); + if (rc) { + perror("screen_set_window_property_iv"); + return EXIT_FAILURE; + } + + return EXIT_SUCCESS; +} diff --git a/playbook/src/bbutil.h b/playbook/src/bbutil.h new file mode 100644 index 0000000000..a8362f91e2 --- /dev/null +++ b/playbook/src/bbutil.h @@ -0,0 +1,132 @@ +/* + * Copyright (c) 2011-2012 Research In Motion Limited. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef _UTILITY_H_INCLUDED +#define _UTILITY_H_INCLUDED + +#include +#include +#include + +extern EGLDisplay egl_disp; +extern EGLSurface egl_surf; + +typedef struct font_t font_t; + +#define BBUTIL_DEFAULT_FONT "/usr/fonts/font_repository/monotype/arial.ttf" + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * Initializes EGL + * + * @param libscreen context that will be used for EGL setup + * @return EXIT_SUCCESS if initialization succeeded otherwise EXIT_FAILURE + */ +int bbutil_init_egl(screen_context_t ctx); + +/** + * Terminates EGL + */ +void bbutil_terminate(); + +/** + * Swaps default bbutil window surface to the screen + */ +void bbutil_swap(); + +/** + * Loads the font from the specified font file. + * NOTE: should be called after a successful return from bbutil_init() or bbutil_init_egl() call + * @param font_file string indicating the absolute path of the font file + * @param point_size used for glyph generation + * @param dpi used for glyph generation + * @return pointer to font_t structure on success or NULL on failure + */ +font_t* bbutil_load_font(const char* font_file, int point_size, int dpi); + +/** + * Destroys the passed font + * @param font to be destroyed + */ +void bbutil_destroy_font(font_t* font); + +/** + * Renders the specified message using current font starting from the specified + * bottom left coordinates. + * NOTE: must be called after a successful return from bbutil_init() or bbutil_init_egl() call + + * + * @param font to use for rendering + * @param msg the message to display + * @param x, y position of the bottom-left corner of text string in world coordinate space + * @param rgba color for the text to render with + */ +void bbutil_render_text(font_t* font, const char* msg, float x, float y, float r, float g, float b, float a); + +/** + * Returns the non-scaled width and height of a string + * NOTE: must be called after a successful return from bbutil_init() or bbutil_init_egl() call + + * + * @param font to use for measurement of a string size + * @param msg the message to get the size of + * @param return pointer for width of a string + * @param return pointer for height of a string + */ +void bbutil_measure_text(font_t* font, const char* msg, float* width, float* height); + +/** + * Creates and loads a texture from a png file + * NOTE: must be called after a successful return from bbutil_init() or bbutil_init_egl() call + + * + * @param filename path to texture png + * @param return width of texture + * @param return height of texture + * @param return gl texture handle + * @return EXIT_SUCCESS if texture loading succeeded otherwise EXIT_FAILURE + */ + +int bbutil_load_texture(const char* filename, int* width, int* height, float* tex_x, float* tex_y, unsigned int* tex); + +/** + * Returns dpi for a given screen + + * + * @param ctx path libscreen context that corresponds to display of interest + * @return dpi for a given screen + */ + +int bbutil_calculate_dpi(screen_context_t ctx); + +/** + * Rotates the screen to a given angle + + * + * @param angle to rotate screen surface to, must by 0, 90, 180, or 270 + * @return EXIT_SUCCESS if texture loading succeeded otherwise EXIT_FAILURE + */ + +int bbutil_rotate_screen_surface(int angle); + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/retroarch.c b/retroarch.c index 26739487e0..dc3345e5d2 100644 --- a/retroarch.c +++ b/retroarch.c @@ -46,13 +46,6 @@ #include "msvc/msvc_compat.h" #endif -#if defined(__APPLE__) && !defined(IOS) -#include "SDL.h" -// OSX seems to really need -lSDLmain, -// so we include SDL.h here so it can hack our main. -// We want to use -mconsole in Win32, so we need main(). -#endif - #if defined(RARCH_CONSOLE) && !defined(RARCH_PERFORMANCE_MODE) #define RARCH_PERFORMANCE_MODE #endif @@ -576,10 +569,8 @@ static int16_t input_state(unsigned port, unsigned device, unsigned index, unsig #ifdef _WIN32 #define RARCH_DEFAULT_CONF_PATH_STR "\n\t\tDefaults to retroarch.cfg in same directory as retroarch.exe." -#elif defined(__APPLE__) -#define RARCH_DEFAULT_CONF_PATH_STR " Defaults to $HOME/.retroarch.cfg." #else -#define RARCH_DEFAULT_CONF_PATH_STR " Defaults to $XDG_CONFIG_HOME/retroarch/retroarch.cfg,\n\t\tor $HOME/.retroarch.cfg, if $XDG_CONFIG_HOME is not defined." +#define RARCH_DEFAULT_CONF_PATH_STR "\n\t\tBy default looks for config in $XDG_CONFIG_HOME/retroarch/retroarch.cfg,\n\t\t$HOME/.config/retroarch/retroarch.cfg,\n\t\tand $HOME/.retroarch.cfg." #endif #include "config.features.h" @@ -646,7 +637,10 @@ static void print_compiler(FILE *file) static void print_help(void) { puts("==================================================================="); +#ifndef __BLACKBERRY_QNX__ + /* To get around error 'too many decimal points in number - expected ')' before numeric constant */ puts("RetroArch: Frontend for libretro -- v" PACKAGE_VERSION " --"); +#endif print_compiler(stdout); puts("==================================================================="); puts("Usage: retroarch [rom file] [options...]"); @@ -2781,12 +2775,6 @@ error: return 1; } -static inline bool rarch_main_paused(void) -{ - return g_extern.is_paused && !g_extern.is_oneshot; -} - - bool rarch_main_iterate(void) { #ifdef HAVE_DYLIB @@ -2928,6 +2916,7 @@ void rarch_main_deinit(void) } #define MAX_ARGS 32 + int rarch_main_init_wrap(const struct rarch_main_wrap *args) { if (g_extern.main_is_init) @@ -2987,46 +2976,18 @@ int rarch_main_init_wrap(const struct rarch_main_wrap *args) return ret; } -#ifndef HAVE_RARCH_MAIN_WRAP -static bool rarch_main_idle_iterate(void) +bool rarch_main_idle_iterate(void) { #ifdef HAVE_COMMAND if (driver.command) rarch_cmd_pre_frame(driver.command); #endif - if (input_key_pressed_func(RARCH_QUIT_KEY) || - !video_alive_func()) + if (input_key_pressed_func(RARCH_QUIT_KEY) || !video_alive_func()) return false; do_state_checks(); - input_poll(); rarch_sleep(10); return true; } - - -int rarch_main(int argc, char *argv[]) -{ - int init_ret; - if ((init_ret = rarch_main_init(argc, argv))) return init_ret; - rarch_init_msg_queue(); - while (rarch_main_paused() ? rarch_main_idle_iterate() : rarch_main_iterate()); - rarch_main_deinit(); - rarch_deinit_msg_queue(); - -#ifdef PERF_TEST - rarch_perf_log(); -#endif - - rarch_main_clear_state(); - return 0; -} - -// Consoles use the higher level API. -int main(int argc, char *argv[]) -{ - return rarch_main(argc, argv); -} -#endif diff --git a/retroarch.cfg b/retroarch.cfg index 22248ce2cf..9285288f0b 100644 --- a/retroarch.cfg +++ b/retroarch.cfg @@ -40,6 +40,11 @@ # Video driver to use. "gl", "xvideo", "sdl" # video_driver = "gl" +# Which OpenGL context implementation to use. +# Possible ones for desktop are: glx, x-egl, kms-egl, sdl-gl, wgl. +# By default, tries to use first suitable driver. +# video_gl_context = + # Windowed xscale and yscale # (Real x res: base_size * xscale * aspect_ratio, real y res: base_size * yscale) # video_xscale = 3.0 diff --git a/settings.c b/settings.c index 7ed5bbf3f4..731e99e0b7 100644 --- a/settings.c +++ b/settings.c @@ -331,36 +331,37 @@ static config_file_t *open_default_config_file(void) conf = config_file_new(conf_path); } } -#elif defined(__APPLE__) - char conf_path[PATH_MAX]; - const char *home = getenv("HOME"); - if (home) - { - snprintf(conf_path, sizeof(conf_path), "%s/.retroarch.cfg", home); - conf = config_file_new(conf_path); - } - if (!conf) - conf = config_file_new("/etc/retroarch.cfg"); #elif !defined(__CELLOS_LV2__) && !defined(_XBOX) char conf_path[PATH_MAX]; - const char *xdg = getenv("XDG_CONFIG_HOME"); - if (!xdg) - RARCH_WARN("XDG_CONFIG_HOME is not defined. Will look for config in $HOME/.retroarch.cfg ...\n"); - + const char *xdg = getenv("XDG_CONFIG_HOME"); const char *home = getenv("HOME"); + + // XDG_CONFIG_HOME falls back to $HOME/.config. if (xdg) - { snprintf(conf_path, sizeof(conf_path), "%s/retroarch/retroarch.cfg", xdg); + else if (home) + snprintf(conf_path, sizeof(conf_path), "%s/.config/retroarch/retroarch.cfg", home); + + if (xdg || home) + { + RARCH_LOG("Looking for config in: \"%s\".\n", conf_path); conf = config_file_new(conf_path); } - else if (home) + + // Fallback to $HOME/.retroarch.cfg. + if (!conf && home) { snprintf(conf_path, sizeof(conf_path), "%s/.retroarch.cfg", home); + RARCH_LOG("Looking for config in: \"%s\".\n", conf_path); conf = config_file_new(conf_path); } - // Try this as a last chance... + + // Try this as a last chance ... if (!conf) + { conf = config_file_new("/etc/retroarch.cfg"); + RARCH_LOG("Looking for config in: \"/etc/retroarch.cfg\".\n"); + } #endif return conf; @@ -650,6 +651,7 @@ bool config_load_file(const char *path) CONFIG_GET_STRING(audio.resampler, "audio_resampler"); CONFIG_GET_STRING(video.driver, "video_driver"); + CONFIG_GET_STRING(video.gl_context, "video_gl_context"); CONFIG_GET_STRING(audio.driver, "audio_driver"); CONFIG_GET_PATH(audio.dsp_plugin, "audio_dsp_plugin"); CONFIG_GET_STRING(input.driver, "input_driver"); diff --git a/tools/retrolaunch/launch.conf b/tools/retrolaunch/launch.conf index dbc9c2f490..29f6fce918 100644 --- a/tools/retrolaunch/launch.conf +++ b/tools/retrolaunch/launch.conf @@ -1,243 +1,249 @@ -# PS1 Dualanalog Games ; - -"ps1.007 Racing*" mednafen-psx dualanalog ; -"ps1.007 - The World Is Not Enough*" mednafen-psx dualanalog ; -"ps1.007 - Tomorrow Never Dies*" mednafen-psx dualanalog ; -"ps1.40 Winks*" mednafen-psx dualanalog ; -"ps1.Ace Combat*" mednafen-psx dualanalog ; -"ps1.Aces of the Air*" mednafen-psx dualanalog ; -"ps1.Action Bass*" mednafen-psx dualanalog ; -"ps1.Action Man - Operation Extreme*" mednafen-psx dualanalog ; -"ps1.Advanced V.G. 2*" mednafen-psx dualanalog ; -"ps1.Aironauts*" mednafen-psx dualanalog ; -"ps1.Air Race Championship*" mednafen-psx dualanalog ; -"ps1.Akuji - The Heartless*" mednafen-psx dualanalog ; -"ps1.Alfred Chicken*" mednafen-psx dualanalog ; -"ps1.Alien la Resurrection*" mednafen-psx dualanalog ; -"ps1.Alien Resurrection*" mednafen-psx dualanalog ; -"ps1.Alone In The Dark - The New Nightmare*" mednafen-psx dualanalog ; -"ps1.Alundra 2*" mednafen-psx dualanalog ; -"ps1.Amazing Virtual Sea Monkeys*" mednafen-psx dualanalog ; -"ps1.Animorphs - Shattered Reality*" mednafen-psx dualanalog ; -"ps1.Ape Escape*" mednafen-psx dualanalog ; -"ps1.Apocalypse*" mednafen-psx dualanalog ; -"ps1.Aqua GT*" mednafen-psx dualanalog ; -"ps1.Armored Core - Master of Arena*" mednafen-psx dualanalog ; -"ps1.Armorines - Project Swarm*" mednafen-psx dualanalog ; -"ps1.Army Men 3D*" mednafen-psx dualanalog ; -"ps1.Army Men - Air Attack 2*" mednafen-psx dualanalog ; -"ps1.Army Men - Air Attack*" mednafen-psx dualanalog ; -"ps1.Army Men - Green Rouge*" mednafen-psx dualanalog ; -"ps1.Army Men - Sarge's Heroes 2*" mednafen-psx dualanalog ; -"ps1.Army Men - Sarge's Heroes*" mednafen-psx dualanalog ; -"ps1.Army Men - World War*" mednafen-psx dualanalog ; -"ps1.Assault Retribution*" mednafen-psx dualanalog ; -"ps1.Asterix - Mega Madness*" mednafen-psx dualanalog ; -"ps1.Asteroids*" mednafen-psx dualanalog ; -"ps1.Barbie Explorer" mednafen-psx dualanalog ; -"ps1.Barbie - Gotta Have Games" mednafen-psx dualanalog ; -"ps1.Batman Beyond - Return of the Joker" mednafen-psx dualanalog ; -"ps1.Batman & Robin" mednafen-psx dualanalog ; -"ps1.Beatmania" mednafen-psx dualanalog ; -"ps1.Beat Planet Music" mednafen-psx dualanalog ; -"ps1.Beyblade" mednafen-psx dualanalog ; -"ps1.Big Bass Fishing" mednafen-psx dualanalog ; -"ps1.BioHazard - Director's Cut - Dual Shock*" mednafen-psx dualanalog ; -"ps1.Bishi Bashi Special" mednafen-psx dualanalog ; -"ps1.Blade" mednafen-psx dualanalog ; -"ps1.Blasto!" mednafen-psx dualanalog ; -"ps1.Blast Radius" mednafen-psx dualanalog ; -"ps1.Block Kuzushi" mednafen-psx dualanalog ; -"ps1.Block Wars" mednafen-psx dualanalog ; -"ps1.Bloody Roar 2*" mednafen-psx dualanalog ; -"ps1.Bob the Builder - Can We Fix It" mednafen-psx dualanalog ; -"ps1.Boombots" mednafen-psx dualanalog ; -"ps1.Bratz" mednafen-psx dualanalog ; -"ps1.Brave Fencer Musashi*" mednafen-psx dualanalog ; -"ps1.Breakout" mednafen-psx dualanalog ; -"ps1.Buggy" mednafen-psx dualanalog ; -"ps1.Bugs Bunny - Lost in Time*" mednafen-psx dualanalog ; -"ps1.Bugs Bunny & Taz - Time Busters" mednafen-psx dualanalog ; -"ps1.C-12 - The Final Resistance" mednafen-psx dualanalog ; -"ps1.Captain Commando" mednafen-psx dualanalog ; -"ps1.Cardinal Syn*" mednafen-psx dualanalog ; -"ps1.Carmageddon*" mednafen-psx dualanalog ; -"ps1.Casper - Friends Around The World" mednafen-psx dualanalog ; -"ps1.Chaos Break" mednafen-psx dualanalog ; -"ps1.Chicken Run" mednafen-psx dualanalog ; -"ps1.Chippoke Ralph no Daibouken (Adventure of Little Ralph)" mednafen-psx dualanalog ; -"ps1.Chocobo Racing" mednafen-psx dualanalog ; -"ps1.Chrono Cross*" pcsxr dualanalog ; -"ps1.Colin Mc[rR]ae*" mednafen-psx dualanalog ; -"ps1.Colony Wars*" mednafen-psx dualanalog ; -"ps1.Cosmowarrior Rei" mednafen-psx dualanalog ; -"ps1.Cowboy Bebop" mednafen-psx dualanalog ; -"ps1.Crash Bandicoot 2*" mednafen-psx dualanalog ; -"ps1.Crash Bandicoot 3*" mednafen-psx dualanalog ; -"ps1.Crash Bandicoot Carnival - Crash Bash*" mednafen-psx dualanalog ; -"ps1.Crash Bash Demo" mednafen-psx dualanalog ; -"ps1.Crash Bash" mednafen-psx dualanalog ; -"ps1.Crash Bash" mednafen-psx dualanalog ; -"ps1.Crash Bash & Spyro - Year of the Dragon Demo" mednafen-psx dualanalog ; -"ps1.Crash Team Racing*" mednafen-psx dualanalog multitap ; -"ps1.Crisis Beat" mednafen-psx dualanalog ; -"ps1.Croc 2*" mednafen-psx dualanalog ; -"ps1.Croc - Legend of the Gobbos" mednafen-psx dualanalog ; -"ps1.C - The Contra Adventure" mednafen-psx dualanalog ; -"ps1.CT Special Forces" mednafen-psx dualanalog ; -"ps1.CyberTiger Golf" mednafen-psx dualanalog ; -"ps1.Fighting Force*" mednafen-psx dualanalog ; -"ps1.Future Cop*" mednafen-psx dualanalog ; -"ps1.Legacy of Kain - Soul Reaver*" pcsxr dualanalog ; -"ps1.Saru! Get You!*" mednafen-psx dualanalog ; -"ps1.Simple Characters 2000 Series #02 - Afro Inu - The Puzzle*" mednafen-psx dualanalog ; -"ps1.Soul Reaver - Legacy of Kain*" mednafen-psx dualanalog ; -"ps1.Spyro the Dragon*"" mednafen-psx dualanalog ; -"ps1.Spyro - Year of the Dragon*" mednafen-psx dualanalog ; -"ps1.Vagrant Story*" mednafen-psx dualanalog ; - -"ps1.Earthworm Jim 2" pcsxr ; -"ps1.Mickey's Wild Adventures" pcsxr ; - -# SNES BSNES Performance ; -"snes. - -"ps1.Earthworm Jim 2" pcsxr ; -"ps1.Mickey's Wild Adventures" pcsxr ; - -# SNES BSNES Performance ; -"snes.Psycho Dream*" bsnes-performance ; - -# SNES Multitap Games ; - -"snes.Bakukyuu Renpatsu!! Super B-Daman*" snes9x multitap ; -"snes.Bakutou Dochers - Bumps-jima wa Oosawagi*" snes9x multitap ; -"snes.Barkley Shut Up and Jam!*" snes9x multitap ; -"snes.Barkley Shut Up and Jam!*" snes9x multitap ; -"snes.Battle Cross*" snes9x multitap ; -"snes.Battle Jockey*" snes9x multitap ; -"snes.Bill Walsh College Football*" snes9x multitap ; -"snes.Capcom's Soccer Shootout*" snes9x multitap ; -"snes.College Slam*" snes9x multitap ; -"snes.Crystal Beans From Dungeon Explorer*" snes9x multitap ; -"snes.Dragon - The Bruce Lee Story*" snes9x multitap ; -"snes.Dream Basketball - Dunk and Hoop*" snes9x multitap ; -"snes.Dynamic Stadium*" snes9x multitap ; -"snes.ESPN National Hockey Night*" snes9x multitap ; -"snes.FIFA 98*" snes9x multitap ; -"snes.FIFA International Soccer*" snes9x multitap ; -"snes.FIFA Soccer 96*" snes9x multitap ; -"snes.FIFA Soccer 97*" snes9x multitap ; -"snes.Final Set*" snes9x multitap ; -"snes.Fire Striker*" snes9x multitap ; -"snes.From TV Animation Slam Dunk - SD Heat Up!!*" snes9x multitap ; -"snes.Go! Go! Dodge League*" snes9x multitap ; -"snes.Hammerlock Wrestling*" snes9x multitap ; -"snes.Hat Trick Hero 2*" snes9x multitap ; -"snes.Head-On Soccer*" snes9x multitap ; -"snes.Hebereke no Oishii Puzzle ha Irimasenka*" snes9x multitap ; -"snes.Human Grand Prix III - F1 Triple Battle*" snes9x multitap ; -"snes.Human Grand Prix IV - F1 Dream Battle*" snes9x multitap ; -"snes.Hungry Dinosaurs*" snes9x multitap ; -"snes.International Superstar Soccer Deluxe*" snes9x multitap ; -"snes.J.League Excite Stage '94*" snes9x multitap ; -"snes.J.League Excite Stage '95*" snes9x multitap ; -"snes.J.League Excite Stage '96*" snes9x multitap ; -"snes.J.League Super Soccer '95*" snes9x multitap ; -"snes.J.League Super Soccer*" snes9x multitap ; -"snes.JWP Joshi Pro Wrestling - Pure Wrestle Queens*" snes9x multitap ; -"snes.Jikkyou Power Pro Wrestling '96*" snes9x multitap ; -"snes.Jimmy Connors Pro Tennis Tour*" snes9x multitap ; -"snes.Kunio-kun no Dodge Ball dayo Zenin Shuugou!*" snes9x multitap ; -"snes.Looney Tunes Basketball*" snes9x multitap ; -"snes.Madden NFL '94*" snes9x multitap ; -"snes.Madden NFL '95*" snes9x multitap ; -"snes.Madden NFL '96*" snes9x multitap ; -"snes.Madden NFL '97*" snes9x multitap ; -"snes.Madden NFL '98*" snes9x multitap ; -"snes.Micro Machines 2 - Turbo Tournament*" snes9x multitap ; -"snes.Micro Machines*" snes9x multitap ; -"snes.Mizuki Shigeru no Youkai Hyakkiyakou*" snes9x multitap ; -"snes.Multi Play Volleyball*" snes9x multitap ; -"snes.NBA Give 'N Go*" snes9x multitap ; -"snes.NBA Hang Time*" snes9x multitap ; -"snes.NBA Jam - Tournament Edition*" snes9x multitap ; -"snes.NBA Jam*" snes9x multitap ; -"snes.NBA Live 95*" snes9x multitap ; -"snes.NBA Live 96*" snes9x multitap ; -"snes.NBA Live 97*" snes9x multitap ; -"snes.NBA Live 98*" snes9x multitap ; -"snes.NCAA Final Four Basketball*" snes9x multitap ; -"snes.NCAA Football*" snes9x multitap ; -"snes.NFL Quarterback Club 96*" snes9x multitap ; -"snes.NFL Quarterback Club*" snes9x multitap ; -"snes.NHL '94*" snes9x multitap ; -"snes.NHL '98*" snes9x multitap ; -"snes.NHL Pro Hockey '94*" snes9x multitap ; -"snes.Natsume Championship Wrestling*" snes9x multitap ; -"snes.Peace Keepers, The*" snes9x multitap ; -"snes.Pieces*" snes9x multitap ; -"snes.Rap Jam - Volume One*" snes9x multitap ; -"snes.Saturday Night Slam Masters*" snes9x multitap ; -"snes.Secret of Mana*" snes9x multitap ; -"snes.Shin Nippon Pro Wrestling '94 - Battlefield in Tokyo Dome*" snes9x multitap ; -"snes.Shin Nippon Pro Wrestling - Chou Senshi in Tokyo Dome*" snes9x multitap ; -"snes.Shin Nippon Pro Wrestling Kounin '95 - Tokyo Dome Battle 7*" snes9x multitap ; -"snes.Smash Tennis*" snes9x multitap ; -"snes.Sporting News, The - Power Baseball*" snes9x multitap ; -"snes.Sterling Sharpe End 2 End*" snes9x multitap ; -"snes.Street Hockey '95*" snes9x multitap ; -"snes.Street Racer*" snes9x multitap ; -"snes.Sugoi Hebereke*" snes9x multitap ; -"snes.Sugoro Quest++ Dicenics*" snes9x multitap ; -"snes.Super Bomberman - Panic Bomber W*" snes9x multitap ; -"snes.Super Bomberman 2*" snes9x multitap ; -"snes.Super Bomberman 3*" snes9x multitap ; -"snes.Super Bomberman 4*" snes9x multitap ; -"snes.Super Bomberman 5*" snes9x multitap ; -"snes.Super Bomberman*" snes9x multitap ; -"snes.Super Fire Pro Wrestling - Queen's Special*" snes9x multitap ; -"snes.Super Fire Pro Wrestling Special*" snes9x multitap ; -"snes.Super Fire Pro Wrestling X Premium*" snes9x multitap ; -"snes.Super Fire Pro Wrestling X*" snes9x multitap ; -"snes.Super Formation Soccer 94 - World Cup Final Data*" snes9x multitap ; -"snes.Super Formation Soccer 94*" snes9x multitap ; -"snes.Super Formation Soccer 95 della Serie A - UCC Xaqua*" snes9x multitap ; -"snes.Super Formation Soccer 95 della Serie A*" snes9x multitap ; -"snes.Super Formation Soccer 96*" snes9x multitap ; -"snes.Super Formation Soccer II*" snes9x multitap ; -"snes.Super Ice Hockey*" snes9x multitap ; -"snes.Super Kyousouba - Kaze no Sylphid*" snes9x multitap ; -"snes.Super Power League*" snes9x multitap ; -"snes.Super Tekkyuu Fight!*" snes9x multitap ; -"snes.Super Tetris 3*" snes9x multitap ; -"snes.Syndicate*" snes9x multitap ; -"snes.Tenryu Genichiro no Pro Wrestling Revolution*" snes9x multitap ; -"snes.Tiny Toon Adventures - Wild & Wacky Sports*" snes9x multitap ; -"snes.Top Gear 3000*" snes9x multitap ; -"snes.Turbo Toons*" snes9x multitap ; -"snes.Virtual Soccer*" snes9x multitap ; -"snes.Vs. Collection*" snes9x multitap ; -"snes.WWF Raw*" snes9x multitap ; -"snes.Yuujin no Furi Furi Girls*" snes9x multitap ; -"snes.Zero 4 Champ RR-Z*" snes9x multitap ; -"snes.Zero 4 Champ RR*" snes9x multitap ; - -# Defaults ; - -"gba.*" vba ; -"gbc.*" gambatte ; -"gb.*" gambatte ; -"gg.*" genplus ; -"nes.*" fceu ; -"pcecd.*" mednafen-pce-fast ; -"pce.*" mednafen-pce-fast ; -"ps1.*" mednafen-psx ; -"wswan.*" mednafen-wswan ; -"a26.*" stella ; -"scd.*" genplus ; -"sg1000.*" genplus ; -"smd.*" genplus ; -"sms.*" genplus ; -"snes.*" snes9x ; -"nds.*" desmume ; +# PS1 Gamepad Games ; + +"ps1....Iru!*" mednafen-psx gamepad ; + +# PS1 Dualanalog Games ; + +"ps1.007 - Demain ne Meurt Jamais" mednafen-psx dualanalog ; +"ps1.007 - Le Monde Ne Suffit Pas" mednafen-psx dualanalog ; +"ps1.007 Racing*" mednafen-psx dualanalog ; +"ps1.007 - The World Is Not Enough*" mednafen-psx dualanalog ; +"ps1.007 - Tomorrow Never Dies*" mednafen-psx dualanalog ; +"ps1.40 Winks*" mednafen-psx dualanalog ; +"ps1.Ace Combat*" mednafen-psx dualanalog ; +"ps1.Aces of the Air*" mednafen-psx dualanalog ; +"ps1.Action Bass*" mednafen-psx dualanalog ; +"ps1.Action Man - Operation Extreme*" mednafen-psx dualanalog ; +"ps1.Advanced V.G. 2*" mednafen-psx dualanalog ; +"ps1.Aironauts*" mednafen-psx dualanalog ; +"ps1.Air Race Championship*" mednafen-psx dualanalog ; +"ps1.Akuji - The Heartless*" mednafen-psx dualanalog ; +"ps1.Alfred Chicken*" mednafen-psx dualanalog ; +"ps1.Alien la Resurrection*" mednafen-psx dualanalog ; +"ps1.Alien Resurrection*" mednafen-psx dualanalog ; +"ps1.Alone In The Dark - The New Nightmare*" mednafen-psx dualanalog ; +"ps1.Alundra 2*" mednafen-psx dualanalog ; +"ps1.Amazing Virtual Sea Monkeys*" mednafen-psx dualanalog ; +"ps1.Animorphs - Shattered Reality*" mednafen-psx dualanalog ; +"ps1.Ape Escape*" mednafen-psx dualanalog ; +"ps1.Apocalypse*" mednafen-psx dualanalog ; +"ps1.Aqua GT*" mednafen-psx dualanalog ; +"ps1.Armored Core - Master of Arena*" mednafen-psx dualanalog ; +"ps1.Armorines - Project Swarm*" mednafen-psx dualanalog ; +"ps1.Army Men 3D*" mednafen-psx dualanalog ; +"ps1.Army Men - Air Attack 2*" mednafen-psx dualanalog ; +"ps1.Army Men - Air Attack*" mednafen-psx dualanalog ; +"ps1.Army Men - Green Rouge*" mednafen-psx dualanalog ; +"ps1.Army Men - Sarge's Heroes 2*" mednafen-psx dualanalog ; +"ps1.Army Men - Sarge's Heroes*" mednafen-psx dualanalog ; +"ps1.Army Men - World War*" mednafen-psx dualanalog ; +"ps1.Assault Retribution*" mednafen-psx dualanalog ; +"ps1.Asterix - Mega Madness*" mednafen-psx dualanalog ; +"ps1.Asteroids*" mednafen-psx dualanalog ; +"ps1.Barbie Explorer" mednafen-psx dualanalog ; +"ps1.Barbie - Gotta Have Games" mednafen-psx dualanalog ; +"ps1.Batman Beyond - Return of the Joker" mednafen-psx dualanalog ; +"ps1.Batman & Robin" mednafen-psx dualanalog ; +"ps1.Beatmania" mednafen-psx dualanalog ; +"ps1.Beat Planet Music" mednafen-psx dualanalog ; +"ps1.Beyblade" mednafen-psx dualanalog ; +"ps1.Big Bass Fishing" mednafen-psx dualanalog ; +"ps1.BioHazard - Director's Cut - Dual Shock*" mednafen-psx dualanalog ; +"ps1.Bishi Bashi Special" mednafen-psx dualanalog ; +"ps1.Blade" mednafen-psx dualanalog ; +"ps1.Blasto!" mednafen-psx dualanalog ; +"ps1.Blast Radius" mednafen-psx dualanalog ; +"ps1.Block Kuzushi" mednafen-psx dualanalog ; +"ps1.Block Wars" mednafen-psx dualanalog ; +"ps1.Bloody Roar 2*" mednafen-psx dualanalog ; +"ps1.Bob the Builder - Can We Fix It" mednafen-psx dualanalog ; +"ps1.Boombots" mednafen-psx dualanalog ; +"ps1.Bratz" mednafen-psx dualanalog ; +"ps1.Brave Fencer Musashi*" mednafen-psx dualanalog ; +"ps1.Breakout" mednafen-psx dualanalog ; +"ps1.Buggy" mednafen-psx dualanalog ; +"ps1.Bugs Bunny - Lost in Time*" mednafen-psx dualanalog ; +"ps1.Bugs Bunny & Taz - Time Busters" mednafen-psx dualanalog ; +"ps1.C-12 - The Final Resistance" mednafen-psx dualanalog ; +"ps1.Captain Commando" mednafen-psx dualanalog ; +"ps1.Cardinal Syn*" mednafen-psx dualanalog ; +"ps1.Carmageddon*" mednafen-psx dualanalog ; +"ps1.Casper - Friends Around The World" mednafen-psx dualanalog ; +"ps1.Chaos Break" mednafen-psx dualanalog ; +"ps1.Chicken Run" mednafen-psx dualanalog ; +"ps1.Chippoke Ralph no Daibouken (Adventure of Little Ralph)" mednafen-psx dualanalog ; +"ps1.Chocobo Racing" mednafen-psx dualanalog ; +"ps1.Chrono Cross*" pcsxr dualanalog ; +"ps1.Colin Mc[rR]ae*" mednafen-psx dualanalog ; +"ps1.Colony Wars*" mednafen-psx dualanalog ; +"ps1.Cosmowarrior Rei" mednafen-psx dualanalog ; +"ps1.Cowboy Bebop" mednafen-psx dualanalog ; +"ps1.Crash Bandicoot 2*" mednafen-psx dualanalog ; +"ps1.Crash Bandicoot 3*" mednafen-psx dualanalog ; +"ps1.Crash Bandicoot Carnival - Crash Bash*" mednafen-psx dualanalog ; +"ps1.Crash Bash Demo" mednafen-psx dualanalog ; +"ps1.Crash Bash" mednafen-psx dualanalog ; +"ps1.Crash Bash" mednafen-psx dualanalog ; +"ps1.Crash Bash & Spyro - Year of the Dragon Demo" mednafen-psx dualanalog ; +"ps1.Crash Team Racing*" mednafen-psx dualanalog multitap ; +"ps1.Crisis Beat" mednafen-psx dualanalog ; +"ps1.Croc 2*" mednafen-psx dualanalog ; +"ps1.Croc - Legend of the Gobbos" mednafen-psx dualanalog ; +"ps1.C - The Contra Adventure" mednafen-psx dualanalog ; +"ps1.CT Special Forces" mednafen-psx dualanalog ; +"ps1.CyberTiger Golf" mednafen-psx dualanalog ; +"ps1.Fighting Force*" mednafen-psx dualanalog ; +"ps1.Future Cop*" mednafen-psx dualanalog ; +"ps1.Legacy of Kain - Soul Reaver*" pcsxr dualanalog ; +"ps1.Saru! Get You!*" mednafen-psx dualanalog ; +"ps1.Simple Characters 2000 Series #02 - Afro Inu - The Puzzle*" mednafen-psx dualanalog ; +"ps1.Soul Reaver - Legacy of Kain*" mednafen-psx dualanalog ; +"ps1.Spyro the Dragon*"" mednafen-psx dualanalog ; +"ps1.Spyro - Year of the Dragon*" mednafen-psx dualanalog ; +"ps1.Vagrant Story*" mednafen-psx dualanalog ; + +"ps1.Earthworm Jim 2" pcsxr ; +"ps1.Mickey's Wild Adventures" pcsxr ; + +# SNES BSNES Performance ; +"snes. + +"ps1.Earthworm Jim 2" pcsxr ; +"ps1.Mickey's Wild Adventures" pcsxr ; + +# SNES BSNES Performance ; +"snes.Psycho Dream*" bsnes-performance ; + +# SNES Multitap Games ; + +"snes.Bakukyuu Renpatsu!! Super B-Daman*" snes9x multitap ; +"snes.Bakutou Dochers - Bumps-jima wa Oosawagi*" snes9x multitap ; +"snes.Barkley Shut Up and Jam!*" snes9x multitap ; +"snes.Barkley Shut Up and Jam!*" snes9x multitap ; +"snes.Battle Cross*" snes9x multitap ; +"snes.Battle Jockey*" snes9x multitap ; +"snes.Bill Walsh College Football*" snes9x multitap ; +"snes.Capcom's Soccer Shootout*" snes9x multitap ; +"snes.College Slam*" snes9x multitap ; +"snes.Crystal Beans From Dungeon Explorer*" snes9x multitap ; +"snes.Dragon - The Bruce Lee Story*" snes9x multitap ; +"snes.Dream Basketball - Dunk and Hoop*" snes9x multitap ; +"snes.Dynamic Stadium*" snes9x multitap ; +"snes.ESPN National Hockey Night*" snes9x multitap ; +"snes.FIFA 98*" snes9x multitap ; +"snes.FIFA International Soccer*" snes9x multitap ; +"snes.FIFA Soccer 96*" snes9x multitap ; +"snes.FIFA Soccer 97*" snes9x multitap ; +"snes.Final Set*" snes9x multitap ; +"snes.Fire Striker*" snes9x multitap ; +"snes.From TV Animation Slam Dunk - SD Heat Up!!*" snes9x multitap ; +"snes.Go! Go! Dodge League*" snes9x multitap ; +"snes.Hammerlock Wrestling*" snes9x multitap ; +"snes.Hat Trick Hero 2*" snes9x multitap ; +"snes.Head-On Soccer*" snes9x multitap ; +"snes.Hebereke no Oishii Puzzle ha Irimasenka*" snes9x multitap ; +"snes.Human Grand Prix III - F1 Triple Battle*" snes9x multitap ; +"snes.Human Grand Prix IV - F1 Dream Battle*" snes9x multitap ; +"snes.Hungry Dinosaurs*" snes9x multitap ; +"snes.International Superstar Soccer Deluxe*" snes9x multitap ; +"snes.J.League Excite Stage '94*" snes9x multitap ; +"snes.J.League Excite Stage '95*" snes9x multitap ; +"snes.J.League Excite Stage '96*" snes9x multitap ; +"snes.J.League Super Soccer '95*" snes9x multitap ; +"snes.J.League Super Soccer*" snes9x multitap ; +"snes.JWP Joshi Pro Wrestling - Pure Wrestle Queens*" snes9x multitap ; +"snes.Jikkyou Power Pro Wrestling '96*" snes9x multitap ; +"snes.Jimmy Connors Pro Tennis Tour*" snes9x multitap ; +"snes.Kunio-kun no Dodge Ball dayo Zenin Shuugou!*" snes9x multitap ; +"snes.Looney Tunes Basketball*" snes9x multitap ; +"snes.Madden NFL '94*" snes9x multitap ; +"snes.Madden NFL '95*" snes9x multitap ; +"snes.Madden NFL '96*" snes9x multitap ; +"snes.Madden NFL '97*" snes9x multitap ; +"snes.Madden NFL '98*" snes9x multitap ; +"snes.Micro Machines 2 - Turbo Tournament*" snes9x multitap ; +"snes.Micro Machines*" snes9x multitap ; +"snes.Mizuki Shigeru no Youkai Hyakkiyakou*" snes9x multitap ; +"snes.Multi Play Volleyball*" snes9x multitap ; +"snes.NBA Give 'N Go*" snes9x multitap ; +"snes.NBA Hang Time*" snes9x multitap ; +"snes.NBA Jam - Tournament Edition*" snes9x multitap ; +"snes.NBA Jam*" snes9x multitap ; +"snes.NBA Live 95*" snes9x multitap ; +"snes.NBA Live 96*" snes9x multitap ; +"snes.NBA Live 97*" snes9x multitap ; +"snes.NBA Live 98*" snes9x multitap ; +"snes.NCAA Final Four Basketball*" snes9x multitap ; +"snes.NCAA Football*" snes9x multitap ; +"snes.NFL Quarterback Club 96*" snes9x multitap ; +"snes.NFL Quarterback Club*" snes9x multitap ; +"snes.NHL '94*" snes9x multitap ; +"snes.NHL '98*" snes9x multitap ; +"snes.NHL Pro Hockey '94*" snes9x multitap ; +"snes.Natsume Championship Wrestling*" snes9x multitap ; +"snes.Peace Keepers, The*" snes9x multitap ; +"snes.Pieces*" snes9x multitap ; +"snes.Rap Jam - Volume One*" snes9x multitap ; +"snes.Saturday Night Slam Masters*" snes9x multitap ; +"snes.Secret of Mana*" snes9x multitap ; +"snes.Shin Nippon Pro Wrestling '94 - Battlefield in Tokyo Dome*" snes9x multitap ; +"snes.Shin Nippon Pro Wrestling - Chou Senshi in Tokyo Dome*" snes9x multitap ; +"snes.Shin Nippon Pro Wrestling Kounin '95 - Tokyo Dome Battle 7*" snes9x multitap ; +"snes.Smash Tennis*" snes9x multitap ; +"snes.Sporting News, The - Power Baseball*" snes9x multitap ; +"snes.Sterling Sharpe End 2 End*" snes9x multitap ; +"snes.Street Hockey '95*" snes9x multitap ; +"snes.Street Racer*" snes9x multitap ; +"snes.Sugoi Hebereke*" snes9x multitap ; +"snes.Sugoro Quest++ Dicenics*" snes9x multitap ; +"snes.Super Bomberman - Panic Bomber W*" snes9x multitap ; +"snes.Super Bomberman 2*" snes9x multitap ; +"snes.Super Bomberman 3*" snes9x multitap ; +"snes.Super Bomberman 4*" snes9x multitap ; +"snes.Super Bomberman 5*" snes9x multitap ; +"snes.Super Bomberman*" snes9x multitap ; +"snes.Super Fire Pro Wrestling - Queen's Special*" snes9x multitap ; +"snes.Super Fire Pro Wrestling Special*" snes9x multitap ; +"snes.Super Fire Pro Wrestling X Premium*" snes9x multitap ; +"snes.Super Fire Pro Wrestling X*" snes9x multitap ; +"snes.Super Formation Soccer 94 - World Cup Final Data*" snes9x multitap ; +"snes.Super Formation Soccer 94*" snes9x multitap ; +"snes.Super Formation Soccer 95 della Serie A - UCC Xaqua*" snes9x multitap ; +"snes.Super Formation Soccer 95 della Serie A*" snes9x multitap ; +"snes.Super Formation Soccer 96*" snes9x multitap ; +"snes.Super Formation Soccer II*" snes9x multitap ; +"snes.Super Ice Hockey*" snes9x multitap ; +"snes.Super Kyousouba - Kaze no Sylphid*" snes9x multitap ; +"snes.Super Power League*" snes9x multitap ; +"snes.Super Tekkyuu Fight!*" snes9x multitap ; +"snes.Super Tetris 3*" snes9x multitap ; +"snes.Syndicate*" snes9x multitap ; +"snes.Tenryu Genichiro no Pro Wrestling Revolution*" snes9x multitap ; +"snes.Tiny Toon Adventures - Wild & Wacky Sports*" snes9x multitap ; +"snes.Top Gear 3000*" snes9x multitap ; +"snes.Turbo Toons*" snes9x multitap ; +"snes.Virtual Soccer*" snes9x multitap ; +"snes.Vs. Collection*" snes9x multitap ; +"snes.WWF Raw*" snes9x multitap ; +"snes.Yuujin no Furi Furi Girls*" snes9x multitap ; +"snes.Zero 4 Champ RR-Z*" snes9x multitap ; +"snes.Zero 4 Champ RR*" snes9x multitap ; + +# Defaults ; + +"gba.*" vba ; +"gbc.*" gambatte ; +"gb.*" gambatte ; +"gg.*" genplus ; +"nes.*" fceu ; +"pcecd.*" mednafen-pce-fast ; +"pce.*" mednafen-pce-fast ; +"ps1.*" mednafen-psx ; +"wswan.*" mednafen-wswan ; +"a26.*" stella ; +"scd.*" genplus ; +"sg1000.*" genplus ; +"smd.*" genplus ; +"sms.*" genplus ; +"snes.*" snes9x ; +"nds.*" desmume ;