Merge remote-tracking branch 'upstream/master'

This commit is contained in:
radius 2015-04-09 16:20:09 -05:00
commit 62146221b4
70 changed files with 1593 additions and 867 deletions

View File

@ -10,6 +10,7 @@ endif
ifeq ($(HAVE_DYLIB), 1)
DEFINES += -DHAVE_DYLIB
JOYCONFIG_LIBS += $(DYLIB_LIB)
endif
ifeq ($(SCALER_NO_SIMD), 1)
@ -122,6 +123,7 @@ OBJ += frontend/frontend.o \
configuration.o \
settings_list.o \
settings.o \
dylib.o \
dynamic.o \
dynamic_dummy.o \
libretro-common/queues/message_queue.o \
@ -382,7 +384,7 @@ endif
ifeq ($(HAVE_X11), 1)
OBJ += input/drivers/x11_input.o \
gfx/drivers_wm/x11_common.o \
gfx/common/x11_common.o \
input/drivers_keyboard/keyboard_event_x11.o
LIBS += $(X11_LIBS) $(XEXT_LIBS) $(XF86VM_LIBS) $(XINERAMA_LIBS)
DEFINES += $(X11_CFLAGS) $(XEXT_CFLAGS) $(XF86VM_CFLAGS) $(XINERAMA_CFLAGS)
@ -427,7 +429,7 @@ endif
ifeq ($(HAVE_OPENGL), 1)
DEFINES += -DHAVE_OPENGL -DHAVE_GLSL
OBJ += gfx/drivers/gl.o \
gfx/gl_common.o \
gfx/drivers/gl_common.o \
gfx/video_context_driver.o \
gfx/drivers_context/gfx_null_ctx.o \
gfx/drivers_font/gl_raster_font.o \
@ -709,8 +711,7 @@ endif
ifneq ($(findstring Win32,$(OS)),)
OBJ += media/rarch.o \
input/drivers_keyboard/keyboard_event_win32.o \
gfx/drivers_wm/win32_common.o \
gfx/drivers_wm/win32_dwm_common.o \
gfx/common/win32_common.o \
frontend/drivers/platform_win32.o
endif
@ -729,5 +730,4 @@ endif
# Joyconfig binary
JOYCONFIG_OBJ += tools/retroarch-joyconfig-griffin.o
JOYCONFIG_OBJ += tools/retroarch-joyconfig-griffin.o

View File

@ -1,6 +1,6 @@
TARGET := retroarch_3ds
OBJS :=
OBJS += gfx/drivers/ctr_blit.o griffin/griffin.o
OBJS += gfx/drivers/ctr_sprite.o griffin/griffin.o
#NO_SMDH = 1
DEBUG = 0
@ -39,8 +39,8 @@ CFLAGS += -I. -Ideps/zlib -Ideps/7zip -Ilibretro-common/include
CFLAGS += -DRARCH_INTERNAL -DRARCH_CONSOLE -DSINC_LOWEST_QUALITY
CFLAGS += -DHAVE_GRIFFIN=1 -DHAVE_FILTERS_BUILTIN -DHAVE_MENU -DHAVE_RGUI
CFLAGS += -DHAVE_ZLIB -DWANT_ZLIB
#-DHAVE_LIBRETRO_MANAGEMENT -DWANT_RPNG -DHAVE_BUILTIN_AUTOCONFIG -DHAVE_FILTERS_BUILTIN -DHAVE_7ZIP
CFLAGS += -DHAVE_ZLIB -DWANT_ZLIB -DHAVE_BUILTIN_AUTOCONFIG
#-DHAVE_LIBRETRO_MANAGEMENT -DWANT_RPNG -DHAVE_7ZIP
CXXFLAGS := $(CFLAGS) -fno-rtti -fno-exceptions -std=gnu++11
@ -136,9 +136,11 @@ LD := $(CXX)
3dsxtool $< $@ $(_3DSXFLAGS)
#---------------------------------------------------------------------------------
%.elf:
%.elf: .FORCE
@echo linking $(notdir $@)
$(LD) $(LDFLAGS) $(OBJS) $(LIBDIRS) $(LIBS) -o $@
$(NM) -CSn $@ > $(notdir $*.lst)
.PHONY: .FORCE

View File

@ -39,12 +39,12 @@ extern char** apple_argv;
extern id<RetroArch_Platform> apple_platform;
// main.m
/* main.m */
extern void apple_run_core(int argc, char **argv);
extern void apple_start_iteration(void);
extern void apple_stop_iteration(void);
// utility.m
/* utility.m */
extern void apple_display_alert(const char *message, const char *title);
@interface RANumberFormatter : NSNumberFormatter
@ -55,7 +55,6 @@ extern void apple_display_alert(const char *message, const char *title);
- (id)initWithSetting:(const rarch_setting_t*)setting;
@end
//
#define BOXSTRING(x) [NSString stringWithUTF8String:x]
#define BOXINT(x) [NSNumber numberWithInt:x]
#define BOXUINT(x) [NSNumber numberWithUnsignedInt:x]

View File

@ -24,6 +24,7 @@
#include "../../general.h"
#include "../../runloop.h"
#include "../../frontend/frontend.h"
#include "../../gfx/video_context_driver.h"
#ifndef __has_feature
/* Compatibility with non-Clang compilers. */
@ -213,7 +214,7 @@ static RAGameView* g_instance;
#include "../../gfx/video_viewport.h"
#include "../../gfx/video_monitor.h"
#include "../../gfx/video_context_driver.h"
#include "../../gfx/gl_common.h"
#include "../../gfx/drivers/gl_common.h"
#include "../../runloop.h"
//#define HAVE_NSOPENGL
@ -273,7 +274,7 @@ void apple_bind_game_view_fbo(void)
static RAScreen* get_chosen_screen(void)
{
#if defined(OSX) && !defined(MAC_OS_X_VERSION_10_6)
return [NSScreen mainScreen];
return [RAScreen mainScreen];
#else
settings_t *settings = config_get_ptr();
if (settings->video.monitor_index >= RAScreen.screens.count)
@ -502,6 +503,53 @@ static void apple_gfx_ctx_update_window_title(void *data)
rarch_main_msg_queue_push(buf_fps, 1, 1, false);
}
static bool apple_gfx_ctx_get_metrics(void *data, enum display_metric_types type,
float *value)
{
#ifdef OSX
RAScreen *screen = [RAScreen mainScreen];
NSDictionary *description = [screen deviceDescription];
NSSize display_pixel_size = [[description objectForKey:NSDeviceSize] sizeValue];
CGSize display_physical_size = CGDisplayScreenSize(
[[description objectForKey:@"NSScreenNumber"] unsignedIntValue]);
float display_width = display_pixel_size.width;
float display_height = display_pixel_size.height;
float physical_width = display_physical_size.width;
float physical_height = display_physical_size.height;
#elif defined(IOS)
float scale = apple_gfx_ctx_get_native_scale();
CGRect screen_rect = [[UIScreen mainScreen] bounds];
float display_width = screen_rect.size.width;
float display_height = screen_rect.size.height;
float physical_width = screen_rect.size.width * scale;
float physical_height = screen_rect.size.height * scale;
#endif
(void)display_height;
switch (type)
{
case DISPLAY_METRIC_MM_WIDTH:
*value = physical_width;
break;
case DISPLAY_METRIC_MM_HEIGHT:
*value = physical_height;
break;
case DISPLAY_METRIC_DPI:
/* 25.4 mm in an inch. */
*value = (display_width/ physical_width) * 25.4f;
break;
case DISPLAY_METRIC_NONE:
default:
*value = 0;
return false;
}
return true;
}
static bool apple_gfx_ctx_has_focus(void *data)
{
(void)data;
@ -614,6 +662,7 @@ const gfx_ctx_driver_t gfx_ctx_apple = {
NULL, /* get_video_output_size */
NULL, /* get_video_output_prev */
NULL, /* get_video_output_next */
apple_gfx_ctx_get_metrics,
NULL,
apple_gfx_ctx_update_window_title,
apple_gfx_ctx_check_window,

View File

@ -20,25 +20,13 @@
#endif
#include <retro_inline.h>
#include <retro_miscellaneous.h>
#include <rthreads/rthreads.h>
#ifdef _XBOX
#define DSERR_BUFFERLOST MAKE_DSHRESULT(150)
#define DSERR_INVALIDPARAM E_INVALIDARG
#define DSERR_PRIOLEVELNEEDED MAKE_DSHRESULT(70)
// Send the audio signal (stereo, without attenuation) to all existing speakers
static DSMIXBINVOLUMEPAIR dsmbvp[8] = {
{ DSMIXBIN_FRONT_LEFT, DSBVOLUME_MAX },
{ DSMIXBIN_FRONT_RIGHT, DSBVOLUME_MAX },
{ DSMIXBIN_FRONT_CENTER, DSBVOLUME_MAX },
{ DSMIXBIN_FRONT_CENTER, DSBVOLUME_MAX },
{ DSMIXBIN_BACK_LEFT, DSBVOLUME_MAX },
{ DSMIXBIN_BACK_RIGHT, DSBVOLUME_MAX },
{ DSMIXBIN_LOW_FREQUENCY, DSBVOLUME_MAX },
{ DSMIXBIN_LOW_FREQUENCY, DSBVOLUME_MAX },
};
static DSMIXBINS dsmb;
#endif
#include "../../driver.h"
@ -65,8 +53,8 @@ typedef struct dsound
fifo_buffer_t *buffer;
CRITICAL_SECTION crit;
HANDLE event;
HANDLE thread;
HANDLE event;
sthread_t *thread;
unsigned buffer_size;
@ -147,7 +135,7 @@ static INLINE void release_region(dsound_t *ds, const struct audio_lock *region)
IDirectSoundBuffer_Unlock(ds->dsb, region->chunk1, region->size1, region->chunk2, region->size2);
}
static DWORD CALLBACK dsound_thread(PVOID data)
static void dsound_thread(void *data)
{
DWORD write_ptr;
dsound_t *ds = (dsound_t*)data;
@ -174,25 +162,27 @@ static DWORD CALLBACK dsound_thread(PVOID data)
/* No space to write, or we don't have data in our fifo,
* but we can wait some time before it underruns ... */
Sleep(1);
/* We could opt for using the notification interface,
* but it is not guaranteed to work, so use high
* priority sleeping patterns.
*/
rarch_sleep(1);
continue;
}
else if (fifo_avail < CHUNK_SIZE)
if (!grab_region(ds, write_ptr, &region))
{
ds->thread_alive = false;
SetEvent(ds->event);
break;
}
if (fifo_avail < CHUNK_SIZE)
{
/* Got space to write, but nothing in FIFO (underrun),
* fill block with silence. */
if (!grab_region(ds, write_ptr, &region))
{
ds->thread_alive = false;
SetEvent(ds->event);
break;
}
memset(region.chunk1, 0, region.size1);
memset(region.chunk2, 0, region.size2);
@ -203,13 +193,6 @@ static DWORD CALLBACK dsound_thread(PVOID data)
{
/* All is good. Pull from it and notify FIFO. */
if (!grab_region(ds, write_ptr, &region))
{
ds->thread_alive = false;
SetEvent(ds->event);
break;
}
EnterCriticalSection(&ds->crit);
if (region.chunk1)
fifo_read(ds->buffer, region.chunk1, region.size1);
@ -233,8 +216,8 @@ static void dsound_stop_thread(dsound_t *ds)
return;
ds->thread_alive = false;
WaitForSingleObject(ds->thread, INFINITE);
CloseHandle(ds->thread);
sthread_join(ds->thread);
ds->thread = NULL;
}
@ -243,8 +226,8 @@ static bool dsound_start_thread(dsound_t *ds)
if (!ds->thread)
{
ds->thread_alive = true;
ds->thread = CreateThread(NULL, 0, dsound_thread, ds, 0, NULL);
if (ds->thread == NULL)
ds->thread = sthread_create(dsound_thread, ds);
if (!ds->thread)
return false;
}
@ -275,8 +258,7 @@ static void dsound_free(void *data)
if (ds->thread)
{
ds->thread_alive = false;
WaitForSingleObject(ds->thread, INFINITE);
CloseHandle(ds->thread);
sthread_join(ds->thread);
}
DeleteCriticalSection(&ds->crit);
@ -320,10 +302,10 @@ static BOOL CALLBACK enumerate_cb(LPGUID guid, LPCSTR desc, LPCSTR module, LPVOI
static void *dsound_init(const char *device, unsigned rate, unsigned latency)
{
WAVEFORMATEX wfx = {0};
DSBUFFERDESC bufdesc = {0};
WAVEFORMATEX wfx = {0};
DSBUFFERDESC bufdesc = {0};
struct dsound_dev dev = {0};
dsound_t *ds = (dsound_t*)calloc(1, sizeof(*ds));
dsound_t *ds = (dsound_t*)calloc(1, sizeof(*ds));
if (!ds)
goto error;
@ -346,30 +328,29 @@ static void *dsound_init(const char *device, unsigned rate, unsigned latency)
goto error;
#endif
wfx.wFormatTag = WAVE_FORMAT_PCM;
wfx.nChannels = 2;
wfx.nSamplesPerSec = rate;
wfx.wBitsPerSample = 16;
wfx.nBlockAlign = 2 * sizeof(int16_t);
wfx.nAvgBytesPerSec = rate * 2 * sizeof(int16_t);
wfx.wFormatTag = WAVE_FORMAT_PCM;
wfx.nChannels = 2;
wfx.nSamplesPerSec = rate;
wfx.wBitsPerSample = 16;
wfx.nBlockAlign = 2 * sizeof(int16_t);
wfx.nAvgBytesPerSec = rate * 2 * sizeof(int16_t);
ds->buffer_size = (latency * wfx.nAvgBytesPerSec) / 1000;
ds->buffer_size /= CHUNK_SIZE;
ds->buffer_size *= CHUNK_SIZE;
ds->buffer_size = (latency * wfx.nAvgBytesPerSec) / 1000;
ds->buffer_size /= CHUNK_SIZE;
ds->buffer_size *= CHUNK_SIZE;
if (ds->buffer_size < 4 * CHUNK_SIZE)
ds->buffer_size = 4 * CHUNK_SIZE;
ds->buffer_size = 4 * CHUNK_SIZE;
RARCH_LOG("[DirectSound]: Setting buffer size of %u bytes\n", ds->buffer_size);
RARCH_LOG("[DirectSound]: Latency = %u ms\n", (unsigned)((1000 * ds->buffer_size) / wfx.nAvgBytesPerSec));
bufdesc.dwSize = sizeof(DSBUFFERDESC);
#ifdef _XBOX
bufdesc.dwFlags = 0;
#else
bufdesc.dwFlags = DSBCAPS_GETCURRENTPOSITION2 | DSBCAPS_GLOBALFOCUS;
bufdesc.dwSize = sizeof(DSBUFFERDESC);
bufdesc.dwFlags = 0;
#ifndef _XBOX
bufdesc.dwFlags = DSBCAPS_GETCURRENTPOSITION2 | DSBCAPS_GLOBALFOCUS;
#endif
bufdesc.dwBufferBytes = ds->buffer_size;
bufdesc.lpwfxFormat = &wfx;
bufdesc.lpwfxFormat = &wfx;
ds->event = CreateEvent(NULL, false, false, NULL);
if (!ds->event)
@ -420,7 +401,8 @@ static bool dsound_start(void *data)
if (!dsound_start_thread(ds))
return false;
ds->is_paused = (IDirectSoundBuffer_Play(ds->dsb, 0, 0, DSBPLAY_LOOPING) == DS_OK) ? false : true;
ds->is_paused = (IDirectSoundBuffer_Play(
ds->dsb, 0, 0, DSBPLAY_LOOPING) == DS_OK) ? false : true;
return (ds->is_paused) ? false : true;
}
@ -461,8 +443,8 @@ static ssize_t dsound_write(void *data, const void *buf_, size_t size)
fifo_write(ds->buffer, buf, avail);
LeaveCriticalSection(&ds->crit);
buf += avail;
size -= avail;
buf += avail;
size -= avail;
written += avail;
if (ds->nonblock || !ds->thread_alive)

View File

@ -191,7 +191,7 @@ static size_t oss_buffer_size(void *data)
if (ioctl(*fd, SNDCTL_DSP_GETOSPACE, &info) < 0)
{
RARCH_ERR("SNDCTL_DSP_GETOSPACE failed ...\n");
return 1; // Return something non-zero to avoid SIGFPE.
return 1; /* Return something non-zero to avoid SIGFPE. */
}
return info.fragsize * info.fragstotal;

View File

@ -71,16 +71,14 @@ static int audioMainLoop(SceSize args, void* argp)
static void *psp_audio_init(const char *device,
unsigned rate, unsigned latency)
{
psp1_audio_t* psp;
(void)device;
(void)latency;
psp = (psp1_audio_t*)calloc(1, sizeof(psp1_audio_t));
psp1_audio_t *psp = (psp1_audio_t*)calloc(1, sizeof(psp1_audio_t));
if (!psp)
return NULL;
(void)device;
(void)latency;
/* Cache aligned, not necessary but helpful. */
psp->buffer = (uint32_t*)
memalign(64, AUDIO_BUFFER_SIZE * sizeof(uint32_t));
@ -164,10 +162,10 @@ static bool psp_audio_alive(void *data)
static bool psp_audio_stop(void *data)
{
SceKernelThreadRunStatus runStatus;
SceUInt timeout = 100000;
SceUInt timeout = 100000;
psp1_audio_t* psp = (psp1_audio_t*)data;
runStatus.size = sizeof(SceKernelThreadRunStatus);
runStatus.size = sizeof(SceKernelThreadRunStatus);
if (sceKernelReferThreadRunStatus(
psp->thread, &runStatus) < 0) /* Error */
@ -186,7 +184,7 @@ static bool psp_audio_start(void *data)
SceKernelThreadRunStatus runStatus;
psp1_audio_t* psp = (psp1_audio_t*)data;
runStatus.size = sizeof(SceKernelThreadRunStatus);
runStatus.size = sizeof(SceKernelThreadRunStatus);
if (sceKernelReferThreadRunStatus(
psp->thread, &runStatus) < 0) /* Error */

View File

@ -101,14 +101,14 @@ static void xaudio2_enumerate_devices(xaudio2_t *xa)
static void xaudio2_set_wavefmt(WAVEFORMATEX *wfx,
unsigned channels, unsigned samplerate)
{
wfx->wFormatTag = WAVE_FORMAT_IEEE_FLOAT;
wfx->nBlockAlign = channels * sizeof(float);
wfx->wBitsPerSample = sizeof(float) * 8;
wfx->wFormatTag = WAVE_FORMAT_IEEE_FLOAT;
wfx->nBlockAlign = channels * sizeof(float);
wfx->wBitsPerSample = sizeof(float) * 8;
wfx->nChannels = channels;
wfx->nSamplesPerSec = samplerate;
wfx->nChannels = channels;
wfx->nSamplesPerSec = samplerate;
wfx->nAvgBytesPerSec = wfx->nSamplesPerSec * wfx->nBlockAlign;
wfx->cbSize = 0;
wfx->cbSize = 0;
}
static void xaudio2_free(xaudio2_t *handle)
@ -161,12 +161,12 @@ static xaudio2_t *xaudio2_new(unsigned samplerate, unsigned channels,
handle)))
goto error;
handle->hEvent = CreateEvent(0, FALSE, FALSE, 0);
handle->hEvent = CreateEvent(0, FALSE, FALSE, 0);
if (!handle->hEvent)
goto error;
handle->bufsize = size / MAX_BUFFERS;
handle->buf = (uint8_t*)calloc(1, handle->bufsize * MAX_BUFFERS);
handle->buf = (uint8_t*)calloc(1, handle->bufsize * MAX_BUFFERS);
if (!handle->buf)
goto error;
@ -192,7 +192,7 @@ static size_t xaudio2_write(xaudio2_t *handle, const void *buf, size_t bytes_)
while (bytes)
{
unsigned need = min(bytes, handle->bufsize - handle->bufptr);
unsigned need = min(bytes, handle->bufsize - handle->bufptr);
memcpy(handle->buf + handle->write_buffer * handle->bufsize + handle->bufptr,
buffer, need);

View File

@ -192,6 +192,7 @@ typedef struct driver
const frontend_ctx_driver_t *frontend_ctx;
const audio_driver_t *audio;
const video_driver_t *video;
const void *video_context;
const input_driver_t *input;
const camera_driver_t *camera;
const location_driver_t *location;

100
dylib.c Normal file
View File

@ -0,0 +1,100 @@
/* RetroArch - A frontend for libretro.
* Copyright (C) 2010-2014 - Hans-Kristian Arntzen
* Copyright (C) 2011-2015 - Daniel De Matteis
*
* RetroArch is free software: you can redistribute it and/or modify it under the terms
* of the GNU General Public License as published by the Free Software Found-
* ation, either version 3 of the License, or (at your option) any later version.
*
* RetroArch is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
* PURPOSE. See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along with RetroArch.
* If not, see <http://www.gnu.org/licenses/>.
*/
#include "dynamic.h"
#include "general.h"
#ifdef NEED_DYNAMIC
#ifdef _WIN32
#include <windows.h>
#else
#include <dlfcn.h>
#endif
/**
* dylib_load:
* @path : Path to libretro core library.
*
* Platform independent dylib loading.
*
* Returns: library handle on success, otherwise NULL.
**/
dylib_t dylib_load(const char *path)
{
#ifdef _WIN32
dylib_t lib = LoadLibrary(path);
if (!lib)
RARCH_ERR("Failed to load library, error code: 0x%x\n",
(unsigned)GetLastError());
return lib;
#else
dylib_t lib = dlopen(path, RTLD_LAZY);
if (!lib)
RARCH_ERR("dylib_load() failed: \"%s\".\n", dlerror());
return lib;
#endif
}
function_t dylib_proc(dylib_t lib, const char *proc)
{
function_t sym;
void *ptr_sym = NULL;
(void)ptr_sym;
#ifdef _WIN32
sym = (function_t)GetProcAddress(lib ?
(HMODULE)lib : GetModuleHandle(NULL), proc);
#else
if (lib)
ptr_sym = dlsym(lib, proc);
else
{
void *handle = dlopen(NULL, RTLD_LAZY);
if (handle)
{
ptr_sym = dlsym(handle, proc);
dlclose(handle);
}
}
/* Dirty hack to workaround the non-legality of
* (void*) -> fn-pointer casts. */
memcpy(&sym, &ptr_sym, sizeof(void*));
#endif
return sym;
}
/**
* dylib_close:
* @lib : Library handle.
*
* Frees library handle.
**/
void dylib_close(dylib_t lib)
{
#ifdef _WIN32
FreeLibrary((HMODULE)lib);
#else
#ifndef NO_DLCLOSE
dlclose(lib);
#endif
#endif
}
#endif

View File

@ -496,80 +496,6 @@ void uninit_libretro_sym(void)
retro_perf_clear();
}
#ifdef NEED_DYNAMIC
/**
* dylib_load:
* @path : Path to libretro core library.
*
* Platform independent dylib loading.
*
* Returns: library handle on success, otherwise NULL.
**/
dylib_t dylib_load(const char *path)
{
#ifdef _WIN32
dylib_t lib = LoadLibrary(path);
if (!lib)
RARCH_ERR("Failed to load library, error code: 0x%x\n",
(unsigned)GetLastError());
return lib;
#else
dylib_t lib = dlopen(path, RTLD_LAZY);
if (!lib)
RARCH_ERR("dylib_load() failed: \"%s\".\n", dlerror());
return lib;
#endif
}
function_t dylib_proc(dylib_t lib, const char *proc)
{
function_t sym;
void *ptr_sym = NULL;
(void)ptr_sym;
#ifdef _WIN32
sym = (function_t)GetProcAddress(lib ?
(HMODULE)lib : GetModuleHandle(NULL), proc);
#else
if (lib)
ptr_sym = dlsym(lib, proc);
else
{
void *handle = dlopen(NULL, RTLD_LAZY);
if (handle)
{
ptr_sym = dlsym(handle, proc);
dlclose(handle);
}
}
/* Dirty hack to workaround the non-legality of
* (void*) -> fn-pointer casts. */
memcpy(&sym, &ptr_sym, sizeof(void*));
#endif
return sym;
}
/**
* dylib_close:
* @lib : Library handle.
*
* Frees library handle.
**/
void dylib_close(dylib_t lib)
{
#ifdef _WIN32
FreeLibrary((HMODULE)lib);
#else
#ifndef NO_DLCLOSE
dlclose(lib);
#endif
#endif
}
#endif
static void rarch_log_libretro(enum retro_log_level level,
const char *fmt, ...)
{

View File

@ -59,14 +59,16 @@ struct android_app
jmethodID getPendingIntentIME;
};
enum {
enum
{
LOOPER_ID_MAIN = 1,
LOOPER_ID_INPUT = 2,
LOOPER_ID_USER = 3,
LOOPER_ID_INPUT_MSG = 4,
LOOPER_ID_INPUT,
LOOPER_ID_USER,
LOOPER_ID_INPUT_MSG,
};
enum {
enum
{
APP_CMD_INPUT_CHANGED,
/**
* Command from main thread: a new ANativeWindow is ready for use. Upon

View File

@ -145,7 +145,7 @@ static int exit_callback(int arg1, int arg2, void *common)
return 0;
}
int callback_thread(SceSize args, void *argp)
static int callback_thread(SceSize args, void *argp)
{
int cbid = sceKernelCreateCallback("Exit callback", exit_callback, NULL);
sceKernelRegisterExitCallback(cbid);
@ -184,8 +184,6 @@ static void frontend_psp_init(void *data)
#endif
}
static void frontend_psp_exec(const char *path, bool should_load_game)
{
#if defined(HAVE_KERNEL_PRX) || defined(IS_SALAMANDER)

View File

@ -19,12 +19,84 @@
#endif
#include <retro_miscellaneous.h>
#include "../frontend_driver.h"
#include "../../dynamic.h"
#include "../../general.h"
#include <stdint.h>
#include <boolean.h>
#include <stddef.h>
#include <string.h>
#if defined(_WIN32) && !defined(_XBOX)
/* We only load this library once, so we let it be
* unloaded at application shutdown, since unloading
* it early seems to cause issues on some systems.
*/
static dylib_t dwmlib;
static bool dwm_composition_disabled;
static void gfx_dwm_shutdown(void)
{
if (dwmlib)
dylib_close(dwmlib);
dwmlib = NULL;
}
static bool gfx_init_dwm(void)
{
static bool inited = false;
if (inited)
return true;
dwmlib = dylib_load("dwmapi.dll");
if (!dwmlib)
{
RARCH_LOG("Did not find dwmapi.dll.\n");
return false;
}
atexit(gfx_dwm_shutdown);
HRESULT (WINAPI *mmcss)(BOOL) =
(HRESULT (WINAPI*)(BOOL))dylib_proc(dwmlib, "DwmEnableMMCSS");
if (mmcss)
{
RARCH_LOG("Setting multimedia scheduling for DWM.\n");
mmcss(TRUE);
}
inited = true;
return true;
}
static void gfx_set_dwm(void)
{
HRESULT ret;
settings_t *settings = config_get_ptr();
if (!gfx_init_dwm())
return;
if (settings->video.disable_composition == dwm_composition_disabled)
return;
HRESULT (WINAPI *composition_enable)(UINT) =
(HRESULT (WINAPI*)(UINT))dylib_proc(dwmlib, "DwmEnableComposition");
if (!composition_enable)
{
RARCH_ERR("Did not find DwmEnableComposition ...\n");
return;
}
ret = composition_enable(!settings->video.disable_composition);
if (FAILED(ret))
RARCH_ERR("Failed to set composition state ...\n");
dwm_composition_disabled = settings->video.disable_composition;
}
#endif
static void frontend_win32_get_os(char *name, size_t sizeof_name, int *major, int *minor)
{
uint32_t version = GetVersion();
@ -35,14 +107,22 @@ static void frontend_win32_get_os(char *name, size_t sizeof_name, int *major, in
static void frontend_win32_init(void *data)
{
char os_version[PATH_MAX_LENGTH];
int major, minor;
(void)data;
frontend_win32_get_os(os_version, sizeof(os_version), &major, &minor);
typedef BOOL (WINAPI *isProcessDPIAwareProc)();
typedef BOOL (WINAPI *setProcessDPIAwareProc)();
HMODULE handle = GetModuleHandle(TEXT("User32.dll"));
isProcessDPIAwareProc isDPIAwareProc = (isProcessDPIAwareProc)dylib_proc(handle, "IsProcessDPIAware");
setProcessDPIAwareProc setDPIAwareProc = (setProcessDPIAwareProc)dylib_proc(handle, "SetProcessDPIAware");
if (isDPIAwareProc)
{
if (!isDPIAwareProc())
{
if (setDPIAwareProc)
setDPIAwareProc();
}
}
gfx_set_dwm();
}
const frontend_ctx_driver_t frontend_ctx_win32 = {

View File

@ -13,26 +13,29 @@
* If not, see <http://www.gnu.org/licenses/>.
*/
#include "../../general.h"
#include "win32_common.h"
#if !defined(_XBOX) && defined(_WIN32)
#ifndef _WIN32_WINNT
#define _WIN32_WINNT 0x0500 //_WIN32_WINNT_WIN2K
#endif
#include "../../driver.h"
#include "../../general.h"
#include "win32_common.h"
#include <windows.h>
#include <commdlg.h>
#include <string.h>
#if !defined(_XBOX) && defined(_WIN32)
#include "../../retroarch.h"
#ifdef HAVE_OPENGL
#include "win32_shader_dlg.h"
#include "../drivers_wm/win32_shader_dlg.h"
#endif
static bool win32_browser(HWND owner, char *filename, const char *extensions,
const char *title, const char *initial_dir)
static bool win32_browser(
HWND owner,
char *filename,
const char *extensions,
const char *title,
const char *initial_dir)
{
OPENFILENAME ofn;
@ -177,3 +180,39 @@ LRESULT win32_menu_loop(HWND owner, WPARAM wparam)
return 0L;
}
#endif
bool win32_get_metrics(void *data,
enum display_metric_types type, float *value)
{
#ifdef _XBOX
return false;
#else
HDC monitor = GetDC(NULL);
int pixels_x = GetDeviceCaps(monitor, HORZRES);
int pixels_y = GetDeviceCaps(monitor, VERTRES);
int physical_width = GetDeviceCaps(monitor, HORZSIZE);
int physical_height = GetDeviceCaps(monitor, VERTSIZE);
ReleaseDC(NULL, monitor);
switch (type)
{
case DISPLAY_METRIC_MM_WIDTH:
*value = physical_width;
break;
case DISPLAY_METRIC_MM_HEIGHT:
*value = physical_height;
break;
case DISPLAY_METRIC_DPI:
/* 25.4 mm in an inch. */
*value = 254 * pixels_x / physical_width / 10;
break;
case DISPLAY_METRIC_NONE:
default:
*value = 0;
return false;
}
return true;
#endif
}

View File

@ -17,6 +17,11 @@
#ifndef WIN32_COMMON_H__
#define WIN32_COMMON_H__
#include <string.h>
#include <boolean.h>
#include "../../driver.h"
#include "../video_context_driver.h"
#ifdef __cplusplus
extern "C" {
#endif
@ -24,7 +29,7 @@ extern "C" {
#ifndef _XBOX
#define WIN32_LEAN_AND_MEAN
#include <windows.h>
#include "win32_resource.h"
#include "../drivers_wm/win32_resource.h"
LRESULT win32_handle_keyboard_event(HWND hwnd, UINT message,
WPARAM wparam, LPARAM lparam);
@ -32,6 +37,9 @@ LRESULT win32_handle_keyboard_event(HWND hwnd, UINT message,
LRESULT win32_menu_loop(HWND handle, WPARAM wparam);
#endif
bool win32_get_metrics(void *data,
enum display_metric_types type, float *value);
#ifdef __cplusplus
}
#endif

View File

@ -329,3 +329,38 @@ void x11_destroy_input_context(XIM *xim, XIC *xic)
*xim = NULL;
}
}
bool x11_get_metrics(void *data,
enum display_metric_types type, float *value)
{
int pixels_x, pixels_y, physical_width, physical_height;
unsigned screen_no = 0;
Display *dpy = (Display*)XOpenDisplay(NULL);
pixels_x = DisplayWidth(dpy, screen_no);
pixels_y = DisplayHeight(dpy, screen_no);
physical_width = DisplayWidthMM(dpy, screen_no);
physical_height = DisplayHeightMM(dpy, screen_no);
(void)pixels_y;
XCloseDisplay(dpy);
switch (type)
{
case DISPLAY_METRIC_MM_WIDTH:
*value = (float)physical_width;
break;
case DISPLAY_METRIC_MM_HEIGHT:
*value = (float)physical_height;
break;
case DISPLAY_METRIC_DPI:
*value = ((((float)pixels_x) * 25.4) / ((float)physical_width));
break;
case DISPLAY_METRIC_NONE:
default:
*value = 0;
return false;
}
return true;
}

View File

@ -21,6 +21,8 @@
#include "../../config.h"
#endif
#include "../video_context_driver.h"
#include <X11/Xlib.h>
#include <X11/Xutil.h>
#include <X11/extensions/xf86vmode.h>
@ -53,5 +55,8 @@ bool x11_create_input_context(Display *dpy, Window win, XIM *xim, XIC *xic);
void x11_destroy_input_context(XIM *xim, XIC *xic);
void x11_handle_key_event(XEvent *event, XIC ic, bool filter);
bool x11_get_metrics(void *data,
enum display_metric_types type, float *value);
#endif

View File

@ -26,9 +26,8 @@
#include "../../runloop.h"
#include "render_chain_driver.h"
#include "../common/win32_common.h"
#ifndef _XBOX
#include "../drivers_wm/win32_common.h"
#include "../drivers_wm/win32_dwm_common.h"
#define HAVE_MONITOR
#define HAVE_WINDOW
@ -323,26 +322,28 @@ static void d3d_calculate_rect(d3d_video_t *d3d,
static void d3d_set_nonblock_state(void *data, bool state)
{
d3d_video_t *d3d = (d3d_video_t*)data;
d3d_video_t *d3d = (d3d_video_t*)data;
const gfx_ctx_driver_t *ctx = gfx_ctx_get_ptr();
if (!d3d)
return;
d3d->video_info.vsync = !state;
if (d3d->ctx_driver && d3d->ctx_driver->swap_interval)
d3d->ctx_driver->swap_interval(d3d, state ? 0 : 1);
if (ctx && ctx->swap_interval)
ctx->swap_interval(d3d, state ? 0 : 1);
}
static bool d3d_alive(void *data)
{
d3d_video_t *d3d = (d3d_video_t*)data;
bool quit = false;
bool resize = false;
runloop_t *runloop = rarch_main_get_ptr();
d3d_video_t *d3d = (d3d_video_t*)data;
bool quit = false;
bool resize = false;
runloop_t *runloop = rarch_main_get_ptr();
const gfx_ctx_driver_t *ctx = gfx_ctx_get_ptr();
if (d3d->ctx_driver && d3d->ctx_driver->check_window)
d3d->ctx_driver->check_window(d3d, &quit, &resize,
if (ctx && ctx->check_window)
ctx->check_window(d3d, &quit, &resize,
&d3d->screen_width, &d3d->screen_height, runloop->frames.video.count);
if (quit)
@ -355,25 +356,26 @@ static bool d3d_alive(void *data)
static bool d3d_focus(void *data)
{
d3d_video_t *d3d = (d3d_video_t*)data;
if (d3d && d3d->ctx_driver && d3d->ctx_driver->has_focus)
return d3d->ctx_driver->has_focus(d3d);
return false;
return gfx_ctx_focus(data);
}
static bool d3d_suppress_screensaver(void *data, bool enable)
{
d3d_video_t *d3d = (d3d_video_t*)data;
if (d3d && d3d->ctx_driver && d3d->ctx_driver->suppress_screensaver)
return d3d->ctx_driver->suppress_screensaver(d3d, enable);
d3d_video_t *d3d = (d3d_video_t*)data;
const gfx_ctx_driver_t *ctx = gfx_ctx_get_ptr();
if (d3d && ctx && ctx->suppress_screensaver)
return ctx->suppress_screensaver(d3d, enable);
return false;
}
static bool d3d_has_windowed(void *data)
{
d3d_video_t *d3d = (d3d_video_t*)data;
if (d3d && d3d->ctx_driver && d3d->ctx_driver->has_windowed)
return d3d->ctx_driver->has_windowed(d3d);
d3d_video_t *d3d = (d3d_video_t*)data;
const gfx_ctx_driver_t *ctx = gfx_ctx_get_ptr();
if (d3d && ctx && ctx->has_windowed)
return ctx->has_windowed(d3d);
return true;
}
@ -438,13 +440,11 @@ static bool d3d_construct(d3d_video_t *d3d,
void **input_data)
{
unsigned full_x, full_y;
driver_t *driver = driver_get_ptr();
settings_t *settings = config_get_ptr();
driver_t *driver = driver_get_ptr();
settings_t *settings = config_get_ptr();
const gfx_ctx_driver_t *ctx = gfx_ctx_get_ptr();
d3d->should_resize = false;
#ifndef _XBOX
gfx_set_dwm();
#endif
#if defined(HAVE_MENU)
if (d3d->menu)
@ -497,8 +497,8 @@ static bool d3d_construct(d3d_video_t *d3d,
(int)(mon_rect.right - mon_rect.left),
(int)(mon_rect.bottom - mon_rect.top));
#else
if (d3d->ctx_driver && d3d->ctx_driver->get_video_size)
d3d->ctx_driver->get_video_size(d3d, &full_x, &full_y);
if (ctx && ctx->get_video_size)
ctx->get_video_size(d3d, &full_x, &full_y);
#endif
d3d->screen_width = info->fullscreen ? full_x : info->width;
d3d->screen_height = info->fullscreen ? full_y : info->height;
@ -537,8 +537,8 @@ static bool d3d_construct(d3d_video_t *d3d,
#endif
#endif
if (d3d && d3d->ctx_driver && d3d->ctx_driver->show_mouse)
d3d->ctx_driver->show_mouse(d3d, !info->fullscreen
if (d3d && ctx && ctx->show_mouse)
ctx->show_mouse(d3d, !info->fullscreen
#ifdef HAVE_OVERLAY
|| d3d->overlays_enabled
#endif
@ -583,9 +583,8 @@ static bool d3d_construct(d3d_video_t *d3d,
if (!d3d_initialize(d3d, &d3d->video_info))
return false;
if (input && input_data &&
d3d->ctx_driver && d3d->ctx_driver->input_driver)
d3d->ctx_driver->input_driver(d3d, input, input_data);
if (input && input_data && ctx && ctx->input_driver)
ctx->input_driver(d3d, input, input_data);
RARCH_LOG("[D3D]: Init complete.\n");
return true;
@ -616,10 +615,11 @@ static void d3d_set_rotation(void *data, unsigned rot)
static void d3d_show_mouse(void *data, bool state)
{
d3d_video_t *d3d = (d3d_video_t*)data;
d3d_video_t *d3d = (d3d_video_t*)data;
const gfx_ctx_driver_t *ctx = gfx_ctx_get_ptr();
if (d3d && d3d->ctx_driver && d3d->ctx_driver->show_mouse)
d3d->ctx_driver->show_mouse(d3d, state);
if (d3d && ctx && ctx->show_mouse)
ctx->show_mouse(d3d, state);
}
static const gfx_ctx_driver_t *d3d_get_context(void *data)
@ -644,8 +644,9 @@ static const gfx_ctx_driver_t *d3d_get_context(void *data)
static void *d3d_init(const video_info_t *info,
const input_driver_t **input, void **input_data)
{
d3d_video_t *vid = NULL;
driver_t *driver = driver_get_ptr();
d3d_video_t *vid = NULL;
driver_t *driver = driver_get_ptr();
const gfx_ctx_driver_t *ctx = NULL;
#ifdef _XBOX
if (driver->video_data)
@ -676,8 +677,8 @@ static void *d3d_init(const video_info_t *info,
if (!vid)
goto error;
vid->ctx_driver = d3d_get_context(vid);
if (!vid->ctx_driver)
ctx = d3d_get_context(vid);
if (!ctx)
goto error;
/* Default values */
@ -694,6 +695,8 @@ static void *d3d_init(const video_info_t *info,
vid->menu = NULL;
#endif
driver->video_context = ctx;
if (!d3d_construct(vid, info, input, input_data))
{
RARCH_ERR("[D3D]: Failed to init D3D.\n");
@ -710,12 +713,15 @@ static void *d3d_init(const video_info_t *info,
error:
if (vid)
free(vid);
if (driver)
driver->video_context = NULL;
return NULL;
}
static void d3d_free(void *data)
{
d3d_video_t *d3d = (d3d_video_t*)data;
d3d_video_t *d3d = (d3d_video_t*)data;
const gfx_ctx_driver_t *ctx = gfx_ctx_get_ptr();
if (!d3d)
return;
@ -726,9 +732,9 @@ static void d3d_free(void *data)
#endif
#ifdef _XBOX
if (d3d->ctx_driver && d3d->ctx_driver->destroy)
d3d->ctx_driver->destroy(d3d);
d3d->ctx_driver = NULL;
if (ctx && ctx->destroy)
ctx->destroy(d3d);
ctx = NULL;
#else
#ifdef HAVE_MENU
@ -1434,7 +1440,8 @@ static bool d3d_overlay_load(void *data,
static void d3d_overlay_enable(void *data, bool state)
{
unsigned i;
d3d_video_t *d3d = (d3d_video_t*)data;
d3d_video_t *d3d = (d3d_video_t*)data;
const gfx_ctx_driver_t *ctx = gfx_ctx_get_ptr();
if (!d3d)
return;
@ -1442,8 +1449,8 @@ static void d3d_overlay_enable(void *data, bool state)
for (i = 0; i < d3d->overlays.size(); i++)
d3d->overlays_enabled = state;
if (d3d && d3d->ctx_driver && d3d->ctx_driver->show_mouse)
d3d->ctx_driver->show_mouse(d3d, state);
if (d3d && ctx && ctx->show_mouse)
ctx->show_mouse(d3d, state);
}
static void d3d_overlay_full_screen(void *data, bool enable)
@ -1492,6 +1499,7 @@ static bool d3d_frame(void *data, const void *frame,
settings_t *settings = config_get_ptr();
global_t *global = global_get_ptr();
const font_renderer_t *font_ctx = d3d ? (const font_renderer_t*)d3d->font_driver : NULL;
const gfx_ctx_driver_t *ctx = gfx_ctx_get_ptr();
(void)i;
@ -1605,11 +1613,10 @@ static bool d3d_frame(void *data, const void *frame,
RARCH_PERFORMANCE_STOP(d3d_frame);
if (d3d && d3d->ctx_driver && d3d->ctx_driver->update_window_title)
d3d->ctx_driver->update_window_title(d3d);
if (d3d && ctx && ctx->update_window_title)
ctx->update_window_title(d3d);
if (d3d && d3d->ctx_driver && d3d->ctx_driver->swap_buffers)
d3d->ctx_driver->swap_buffers(d3d);
gfx_ctx_swap_buffers(d3d);
return true;
}

View File

@ -97,7 +97,6 @@ typedef struct d3d_video
{
const void *font_driver;
void *font_handle;
const gfx_ctx_driver_t *ctx_driver;
bool should_resize;
bool quitting;

View File

@ -17,7 +17,7 @@
#ifndef _D3D_WRAPPER_H
#define _D3D_WRAPPER_H
#include "../drivers_wm/win32_common.h"
#include "../common/win32_common.h"
#include "d3d_defines.h"
void d3d_swap(void *data, LPDIRECT3DDEVICE dev);

View File

@ -1,33 +0,0 @@
.const c20, 0.0, 1.0, 0.0, 1.0
; .in v0, vertex
; .in v1, texCoord
.out o0, result.position, 0xF
.out o1, result.color, 0xF
.out o2, result.texcoord0, 0x3
; .uniform c0, c0, vertexScale
; .uniform c1, c1, textureScale
.vsh vmain, end_vmain
;code
vmain:
mul r0, c0, v0 (0x0)
add o0, c20, r0 (0x1)
mov o0, c20 (0x2)
mov o1, c20 (0x3)
mul r0, c1, v1 (0x4)
add o2, c20, r0 (0x5)
nop
end
end_vmain:
;operand descriptors
.opdesc xyz_, xyzw, yxzw ; 0x0
.opdesc xyz_, yyzw, xyzw ; 0x1
.opdesc ___w, xyzw, xyzw ; 0x2
.opdesc xyzw, wwww, wwww ; 0x3
.opdesc xyzw, xyzw, xyzw ; 0x4
.opdesc xyzw, xyzw, xyzw ; 0x5

View File

@ -18,7 +18,7 @@
#include <string.h>
#include <malloc.h>
#include "ctr_gu.h"
#include "ctr_blit_shader_shbin.h"
#include "ctr_sprite_shader_shbin.h"
#include "../../general.h"
#include "../../driver.h"
@ -26,15 +26,26 @@
#include "../video_monitor.h"
#include "retroarch.h"
#include "performance.h"
#include "retro_inline.h"
#define CTR_TOP_FRAMEBUFFER_WIDTH 400
#define CTR_TOP_FRAMEBUFFER_HEIGHT 240
#define CTR_GPU_FRAMEBUFFER ((void*)0x1F119400)
#define CTR_GPU_DEPTHBUFFER ((void*)0x1F370800)
typedef struct
{
s16 x, y, z;
float v;
float u;
float y;
float x;
} ctr_scale_vector_t;
typedef struct
{
s16 x0, y0, x1, y1;
s16 u, v;
} ctr_vertex_t;
@ -48,7 +59,7 @@ typedef struct ctr_video
void* texture_swizzled;
int texture_width;
int texture_height;
float texture_scale[4];
ctr_scale_vector_t scale_vector;
ctr_vertex_t* frame_coords;
}menu;
@ -59,8 +70,7 @@ typedef struct ctr_video
int texture_width;
int texture_height;
float vertex_scale[4];
float texture_scale[4];
ctr_scale_vector_t scale_vector;
ctr_vertex_t* frame_coords;
DVLB_s* dvlb;
@ -73,49 +83,14 @@ typedef struct ctr_video
unsigned rotation;
} ctr_video_t;
#define PRINTFPOS(X,Y) "\x1b["#X";"#Y"H"
#define PRINTFPOS_STR(X,Y) "\x1b["X";"Y"H"
static void ctr_set_frame_coords(ctr_vertex_t* v, int x0, int y0, int x1, int y1, int w, int h)
static INLINE void ctr_set_scale_vector(ctr_scale_vector_t* vec,
int viewport_width, int viewport_height,
int texture_width, int texture_height)
{
v[0].x = x0;
v[0].y = y0;
v[0].z = -1;
v[0].u = 0;
v[0].v = 0;
v[1].x = x1;
v[1].y = y0;
v[1].z = -1;
v[1].u = w;
v[1].v = 0;
v[2].x = x1;
v[2].y = y1;
v[2].z = -1;
v[2].u = w;
v[2].v = h;
v[3].x = x0;
v[3].y = y0;
v[3].z = -1;
v[3].u = 0;
v[3].v = 0;
v[4].x = x1;
v[4].y = y1;
v[4].z = -1;
v[4].u = w;
v[4].v = h;
v[5].x = x0;
v[5].y = y1;
v[5].z = -1;
v[5].u = 0;
v[5].v = h;
vec->x = -2.0 / viewport_width;
vec->y = -2.0 / viewport_height;
vec->u = 1.0 / texture_width;
vec->v = -1.0 / texture_height;
}
static void* ctr_init(const video_info_t* video,
@ -143,9 +118,14 @@ static void* ctr_init(const video_info_t* video,
ctr->texture_swizzled =
linearMemAlign(ctr->texture_width * ctr->texture_height * sizeof(uint32_t), 128);
ctr->frame_coords = linearAlloc(6 * sizeof(ctr_vertex_t));
ctr_set_frame_coords(ctr->frame_coords, 0, 0, CTR_TOP_FRAMEBUFFER_WIDTH, CTR_TOP_FRAMEBUFFER_HEIGHT,
CTR_TOP_FRAMEBUFFER_WIDTH, CTR_TOP_FRAMEBUFFER_HEIGHT);
ctr->frame_coords = linearAlloc(sizeof(ctr_vertex_t));
ctr->frame_coords->x0 = 0;
ctr->frame_coords->y0 = 0;
ctr->frame_coords->x1 = CTR_TOP_FRAMEBUFFER_WIDTH;
ctr->frame_coords->y1 = CTR_TOP_FRAMEBUFFER_HEIGHT;
ctr->frame_coords->u = CTR_TOP_FRAMEBUFFER_WIDTH;
ctr->frame_coords->v = CTR_TOP_FRAMEBUFFER_HEIGHT;
GSPGPU_FlushDataCache(NULL, (u8*)ctr->frame_coords, sizeof(ctr_vertex_t));
ctr->menu.texture_width = 512;
ctr->menu.texture_height = 512;
@ -154,97 +134,27 @@ static void* ctr_init(const video_info_t* video,
ctr->menu.texture_swizzled =
linearMemAlign(ctr->texture_width * ctr->texture_height * sizeof(uint16_t), 128);
ctr->menu.frame_coords = linearAlloc(6 * sizeof(ctr_vertex_t));
ctr_set_frame_coords(ctr->menu.frame_coords, 40, 0, CTR_TOP_FRAMEBUFFER_WIDTH - 40, CTR_TOP_FRAMEBUFFER_HEIGHT ,
CTR_TOP_FRAMEBUFFER_WIDTH - 80, CTR_TOP_FRAMEBUFFER_HEIGHT);
ctr->menu.frame_coords = linearAlloc(sizeof(ctr_vertex_t));
ctr->menu.frame_coords->x0 = 40;
ctr->menu.frame_coords->y0 = 0;
ctr->menu.frame_coords->x1 = CTR_TOP_FRAMEBUFFER_WIDTH - 40;
ctr->menu.frame_coords->y1 = CTR_TOP_FRAMEBUFFER_HEIGHT;
ctr->menu.frame_coords->u = CTR_TOP_FRAMEBUFFER_WIDTH - 80;
ctr->menu.frame_coords->v = CTR_TOP_FRAMEBUFFER_HEIGHT;
GSPGPU_FlushDataCache(NULL, (u8*)ctr->menu.frame_coords, sizeof(ctr_vertex_t));
ctr_set_scale_vector(&ctr->scale_vector,
CTR_TOP_FRAMEBUFFER_WIDTH, CTR_TOP_FRAMEBUFFER_HEIGHT,
ctr->texture_width, ctr->texture_height);
ctr_set_scale_vector(&ctr->menu.scale_vector,
CTR_TOP_FRAMEBUFFER_WIDTH, CTR_TOP_FRAMEBUFFER_HEIGHT,
ctr->menu.texture_width, ctr->menu.texture_height);
ctr->vertex_scale[0] = 1.0;
ctr->vertex_scale[1] = 1.0;
ctr->vertex_scale[2] = -2.0 / CTR_TOP_FRAMEBUFFER_WIDTH;
ctr->vertex_scale[3] = -2.0 / CTR_TOP_FRAMEBUFFER_HEIGHT;
ctr->texture_scale[0] = 1.0;
ctr->texture_scale[1] = 1.0;
ctr->texture_scale[2] = -1.0 / ctr->texture_height;
ctr->texture_scale[3] = 1.0 / ctr->texture_width;
ctr->menu.texture_scale[0] = 1.0;
ctr->menu.texture_scale[1] = 1.0;
ctr->menu.texture_scale[2] = -1.0 / ctr->texture_height;
ctr->menu.texture_scale[3] = 1.0 / ctr->texture_width;
ctr->dvlb = DVLB_ParseFile((u32*)ctr_blit_shader_shbin, ctr_blit_shader_shbin_size);
shaderProgramInit(&ctr->shader);
shaderProgramSetVsh(&ctr->shader, &ctr->dvlb->DVLE[0]);
ctr->dvlb = DVLB_ParseFile((u32*)ctr_sprite_shader_shbin, ctr_sprite_shader_shbin_size);
ctrGuSetVshGsh(&ctr->shader, ctr->dvlb, 2, 2);
shaderProgramUse(&ctr->shader);
GPUCMD_Finalize();
GPUCMD_FlushAndRun(NULL);
gspWaitForEvent(GSPEVENT_P3D, false);
if (input && input_data)
{
ctrinput = input_ctr.init();
*input = ctrinput ? &input_ctr : NULL;
*input_data = ctrinput;
}
return ctr;
}
static bool ctr_frame(void* data, const void* frame,
unsigned width, unsigned height, unsigned pitch, const char* msg)
{
ctr_video_t* ctr = (ctr_video_t*)data;
settings_t* settings = config_get_ptr();
static uint64_t currentTick,lastTick;
static float fps = 0.0;
static int total_frames = 0;
static int frames = 0;
if (!width || !height)
{
gspWaitForEvent(GSPEVENT_VBlank0, true);
return true;
}
if(!aptMainLoop())
{
rarch_main_command(RARCH_CMD_QUIT);
return true;
}
extern bool select_pressed;
if (select_pressed)
{
rarch_main_command(RARCH_CMD_QUIT);
return true;
}
frames++;
currentTick = osGetTime();
uint32_t diff = currentTick - lastTick;
if(diff > 1000)
{
fps = (float)frames * (1000.0 / diff);
lastTick = currentTick;
frames = 0;
}
printf("fps: %8.4f frames: %i\r", fps, total_frames++);
fflush(stdout);
GPUCMD_SetBufferOffset(0);
ctrGuSetVertexShaderFloatUniform(0, ctr->vertex_scale, 1);
GPU_SetViewport(VIRT_TO_PHYS(CTR_GPU_DEPTHBUFFER),
VIRT_TO_PHYS(CTR_GPU_FRAMEBUFFER),
0, 0, CTR_TOP_FRAMEBUFFER_HEIGHT, CTR_TOP_FRAMEBUFFER_WIDTH);
@ -286,6 +196,78 @@ static bool ctr_frame(void* data, const void* frame,
GPU_SetTexEnv(4, GPU_PREVIOUS,GPU_PREVIOUS, 0, 0, 0, 0, 0);
GPU_SetTexEnv(5, GPU_PREVIOUS,GPU_PREVIOUS, 0, 0, 0, 0, 0);
ctrGuSetAttributeBuffers(2,
VIRT_TO_PHYS(ctr->menu.frame_coords),
CTRGU_ATTRIBFMT(GPU_SHORT, 4) << 0 |
CTRGU_ATTRIBFMT(GPU_SHORT, 2) << 4,
sizeof(ctr_vertex_t));
GPUCMD_Finalize();
GPUCMD_FlushAndRun(NULL);
gspWaitForEvent(GSPEVENT_P3D, false);
if (input && input_data)
{
ctrinput = input_ctr.init();
*input = ctrinput ? &input_ctr : NULL;
*input_data = ctrinput;
}
return ctr;
}
//#define gspWaitForEvent(...)
static bool ctr_frame(void* data, const void* frame,
unsigned width, unsigned height, unsigned pitch, const char* msg)
{
ctr_video_t* ctr = (ctr_video_t*)data;
settings_t* settings = config_get_ptr();
static uint64_t currentTick,lastTick;
static float fps = 0.0;
static int total_frames = 0;
static int frames = 0;
RARCH_PERFORMANCE_INIT(ctrframe_f);
RARCH_PERFORMANCE_START(ctrframe_f);
if (!width || !height)
{
gspWaitForEvent(GSPEVENT_VBlank0, true);
goto end;
}
if(!aptMainLoop())
{
rarch_main_command(RARCH_CMD_QUIT);
goto end;
}
extern bool select_pressed;
if (select_pressed)
{
rarch_main_command(RARCH_CMD_QUIT);
goto end;
}
frames++;
currentTick = osGetTime();
uint32_t diff = currentTick - lastTick;
if(diff > 1000)
{
fps = (float)frames * (1000.0 / diff);
lastTick = currentTick;
frames = 0;
}
printf("fps: %8.4f frames: %i\r", fps, total_frames++);
fflush(stdout);
/* enable this to profile the core without video output */
#if 0
if (!ctr->menu_texture_enable)
goto end;
#endif
GPUCMD_SetBufferOffset(0);
if(frame)
{
@ -316,20 +298,13 @@ static bool ctr_frame(void* data, const void* frame,
GPU_TEXTURE_WRAP_S(GPU_CLAMP_TO_EDGE) | GPU_TEXTURE_WRAP_T(GPU_CLAMP_TO_EDGE),
GPU_RGB565);
ctr->frame_coords->u = width;
ctr->frame_coords->v = height;
GSPGPU_FlushDataCache(NULL, (u8*)ctr->frame_coords, sizeof(ctr_vertex_t));
ctr_set_frame_coords(ctr->frame_coords, 0, 0, CTR_TOP_FRAMEBUFFER_WIDTH, CTR_TOP_FRAMEBUFFER_HEIGHT,
width, height);
GSPGPU_FlushDataCache(NULL, (u8*)ctr->frame_coords,
6 * sizeof(ctr_vertex_t));
ctrGuSetAttributeBuffers(2,
VIRT_TO_PHYS(ctr->frame_coords),
CTRGU_ATTRIBFMT(GPU_SHORT, 3) << 0 |
CTRGU_ATTRIBFMT(GPU_SHORT, 2) << 4,
sizeof(ctr_vertex_t));
ctrGuSetVertexShaderFloatUniform(1, ctr->texture_scale, 1);
GPU_DrawArray(GPU_TRIANGLES, 6);
ctrGuSetAttributeBuffersAddress(VIRT_TO_PHYS(ctr->frame_coords));
ctrGuSetVertexShaderFloatUniform(0, (float*)&ctr->scale_vector, 1);
GPU_DrawArray(GPU_UNKPRIM, 1);
}
@ -352,24 +327,12 @@ static bool ctr_frame(void* data, const void* frame,
GPU_RGBA4);
GSPGPU_FlushDataCache(NULL, (u8*)ctr->menu.frame_coords,
6 * sizeof(ctr_vertex_t));
ctrGuSetAttributeBuffers(2,
VIRT_TO_PHYS(ctr->menu.frame_coords),
CTRGU_ATTRIBFMT(GPU_SHORT, 3) << 0 |
CTRGU_ATTRIBFMT(GPU_SHORT, 2) << 4,
sizeof(ctr_vertex_t));
ctrGuSetVertexShaderFloatUniform(1, ctr->menu.texture_scale, 1);
GPU_DrawArray(GPU_TRIANGLES, 6);
ctrGuSetAttributeBuffersAddress(VIRT_TO_PHYS(ctr->menu.frame_coords));
ctrGuSetVertexShaderFloatUniform(1, (float*)&ctr->menu.scale_vector, 1);
GPU_DrawArray(GPU_UNKPRIM, 1);
}
GPU_FinishDrawing();
GPUCMD_Finalize();
GPUCMD_FlushAndRun(NULL);
gspWaitForEvent(GSPEVENT_P3D, false);
@ -391,6 +354,8 @@ static bool ctr_frame(void* data, const void* frame,
// if (ctr->vsync)
// gspWaitForEvent(GSPEVENT_VBlank0, true);
end:
RARCH_PERFORMANCE_STOP(ctrframe_f);
return true;
}
@ -471,6 +436,14 @@ static void ctr_set_texture_frame(void* data, const void* frame, bool rgb32,
dst += ctr->menu.texture_width;
src += width;
}
ctr->menu.frame_coords->x0 = (CTR_TOP_FRAMEBUFFER_WIDTH - width) / 2;
ctr->menu.frame_coords->y0 = (CTR_TOP_FRAMEBUFFER_HEIGHT - height) / 2;
ctr->menu.frame_coords->x1 = ctr->menu.frame_coords->x0 + width;
ctr->menu.frame_coords->y1 = ctr->menu.frame_coords->y0 + height;
ctr->menu.frame_coords->u = width;
ctr->menu.frame_coords->v = height;
GSPGPU_FlushDataCache(NULL, (u8*)ctr->menu.frame_coords, sizeof(ctr_vertex_t));
}
static void ctr_set_texture_enable(void* data, bool state, bool full_screen)

View File

@ -13,11 +13,14 @@
* If not, see <http://www.gnu.org/licenses/>.
*/
/* this file contains mostly modified functions from the ctrulib sdk */
#ifndef CTR_GU_H
#define CTR_GU_H
#include <3ds.h>
#include <stdint.h>
#include <string.h>
#include <retro_inline.h>
#define VIRT_TO_PHYS(vaddr) \
@ -176,4 +179,20 @@ static INLINE void ctrGuSetAttributeBuffers(u32 total_attributes,
GPUCMD_AddIncrementalWrites(GPUREG_VSH_ATTRIBUTES_PERMUTATION_LOW, ((u32[]){0x76543210, 0xBA98}), 2);
}
__attribute__((always_inline))
static INLINE void ctrGuSetAttributeBuffersAddress(u32* baseAddress)
{
GPUCMD_AddWrite(GPUREG_ATTRIBBUFFERS_LOC, ((u32)baseAddress)>>3);
}
__attribute__((always_inline))
static INLINE void ctrGuSetVshGsh(shaderProgram_s* sp, DVLB_s* dvlb, u32 vsh_output_count, u32 gsh_input_count)
{
dvlb->DVLE[0].outmapData[0] = vsh_output_count;
dvlb->DVLE[0].outmapMask = (1 << vsh_output_count) - 1;
shaderProgramInit(sp);
shaderProgramSetVsh(sp, &dvlb->DVLE[0]);
shaderProgramSetGsh(sp, &dvlb->DVLE[1], gsh_input_count);
}
#endif // CTR_GU_H

View File

@ -0,0 +1,86 @@
.const c20, 1.0, 1.0, 1.0, 1.0
.const c21, 0.0, 0.0, 0.0, 0.0
.const c22, 0.0, 1.0, 0.0, 1.0
.const c23, 0.0, 0.0, -1.0, 1.0
; .in v0, x0,y0,x1,y1
; .in v1, tex_w,tex_h
.out o0, result.position, 0xF
.out o1, result.color, 0xF
.out o2, result.texcoord0, 0x3
; .uniform c0, c0, scale_vector
.vsh main_vsh, endmain_vsh
.gsh main_gsh, endmain_gsh
main_vsh:
mul r0, c0, v0 (0x1)
add o0, c20, r0 (0x0)
mul r1, c0, v1 (0x2)
mov r1, c21 (0x3)
add o1, c22, r1 (0x0)
nop
end
endmain_vsh:
main_gsh:
setemit vtx0, false, false
mov o0, v0 (0x3)
mov o0, c23 (0x2)
mov o1, c20 (0x0)
mov o2, v1 (0x0)
emit
setemit vtx1, false, false
mov o0, v0 (0x4)
mov o0, v0 (0x8)
mov o0, c23 (0x2)
mov o1, c20 (0x0)
mov o2, v1 (0x7)
mov o2, v1 (0x9)
emit
setemit vtx2, true, true
mov o0, v0 (0x6)
mov o0, c23 (0x2)
mov o1, c20 (0x0)
mov o2, v1 (0xB)
emit
setemit vtx1, true, false
mov o0, v0 (0x7)
mov o0, v0 (0x5)
mov o0, c23 (0x2)
mov o1, c20 (0x0)
mov o2, v1 (0x4)
mov o2, v1 (0xA)
emit
nop
end
endmain_gsh:
; operand descriptors
.opdesc xyzw, xyzw, xyzw ; 0x0
.opdesc xyzw, yxyx, yxwz ; 0x1
.opdesc __zw, zwzw, xyxy ; 0x2
.opdesc xy__, xyzw, xyzw ; 0x3
.opdesc x___, xyzw, xyzw ; 0x4
.opdesc _y__, xyzw, xyzw ; 0x5
.opdesc xy__, zwzw, zwzw ; 0x6
.opdesc x___, zwzw, zwzw ; 0x7
.opdesc _y__, zwzw, zwzw ; 0x8
.opdesc _yzw, xyxy, xyxy ; 0x9
.opdesc _yzw, zwzw, zwzw ; 0xA
.opdesc xyzw, zwzw, zwzw ; 0xB

View File

@ -38,7 +38,7 @@
#include "config.h"
#endif
#include "../gl_common.h"
#include "gl_common.h"
#include "../font_driver.h"
#include "../video_viewport.h"
#include "../video_pixel_converter.h"
@ -54,7 +54,6 @@
#endif
#if defined(_WIN32) && !defined(_XBOX)
#include "../drivers_wm/win32_dwm_common.h"
#include "../drivers_wm/win32_shader_dlg.h"
#endif
@ -777,8 +776,7 @@ void gl_set_viewport(gl_t *gl, unsigned width,
settings_t *settings = config_get_ptr();
global_t *global = global_get_ptr();
if (gl->ctx_driver->translate_aspect)
device_aspect = gl->ctx_driver->translate_aspect(gl, width, height);
gfx_ctx_translate_aspect(gl, &device_aspect, width, height);
if (settings->video.scale_integer && !force_full)
{
@ -875,10 +873,7 @@ static void gl_set_rotation(void *data, unsigned rotation)
static void gl_set_video_mode(void *data, unsigned width, unsigned height,
bool fullscreen)
{
gl_t *gl = (gl_t*)data;
if (gl && gl->ctx_driver && gl->ctx_driver->set_video_mode)
gl->ctx_driver->set_video_mode(gl, width, height, fullscreen);
gfx_ctx_set_video_mode(data, width, height, fullscreen);
}
#ifdef HAVE_FBO
@ -1193,11 +1188,15 @@ static void gl_init_textures_data(gl_t *gl)
static void gl_init_textures(gl_t *gl, const video_info_t *video)
{
unsigned i;
const gfx_ctx_driver_t *ctx = gfx_ctx_get_ptr();
(void)ctx;
#if defined(HAVE_EGL) && defined(HAVE_OPENGLES2)
// Use regular textures if we use HW render.
gl->egl_images = !gl->hw_render_use && gl_check_eglimage_proc() &&
gl->ctx_driver->init_egl_image_buffer
&& gl->ctx_driver->init_egl_image_buffer(gl, video);
ctx && ctx->init_egl_image_buffer
&& ctx->init_egl_image_buffer(gl, video);
#else
(void)video;
#endif
@ -1274,6 +1273,7 @@ static void gl_init_textures(gl_t *gl, const video_info_t *video)
static INLINE void gl_copy_frame(gl_t *gl, const void *frame,
unsigned width, unsigned height, unsigned pitch)
{
RARCH_PERFORMANCE_INIT(copy_frame);
RARCH_PERFORMANCE_START(copy_frame);
#if defined(HAVE_OPENGLES2)
@ -1281,7 +1281,8 @@ static INLINE void gl_copy_frame(gl_t *gl, const void *frame,
if (gl->egl_images)
{
EGLImageKHR img = 0;
bool new_egl = gl->ctx_driver->write_egl_image(gl,
const gfx_ctx_driver_t *ctx = gfx_ctx_get_ptr();
bool new_egl = ctx && ctx->write_egl_image(gl,
frame, width, height, pitch, (gl->base_size == 4),
gl->tex_index, &img);
@ -1476,10 +1477,11 @@ static bool gl_frame(void *data, const void *frame,
unsigned width, unsigned height, unsigned pitch, const char *msg)
{
const struct font_renderer *font_driver = NULL;
gl_t *gl = (gl_t*)data;
runloop_t *runloop = rarch_main_get_ptr();
driver_t *driver = driver_get_ptr();
settings_t *settings = config_get_ptr();
gl_t *gl = (gl_t*)data;
runloop_t *runloop = rarch_main_get_ptr();
driver_t *driver = driver_get_ptr();
settings_t *settings = config_get_ptr();
const gfx_ctx_driver_t *ctx = gfx_ctx_get_ptr();
RARCH_PERFORMANCE_INIT(frame_run);
RARCH_PERFORMANCE_START(frame_run);
@ -1513,7 +1515,7 @@ static bool gl_frame(void *data, const void *frame,
if (gl->should_resize)
{
gl->should_resize = false;
gl->ctx_driver->set_resize(gl, gl->win_width, gl->win_height);
ctx->set_resize(gl, gl->win_width, gl->win_height);
#ifdef HAVE_FBO
if (gl->fbo_inited)
@ -1619,7 +1621,7 @@ static bool gl_frame(void *data, const void *frame,
gl_render_overlay(gl);
#endif
gl->ctx_driver->update_window_title(gl);
ctx->update_window_title(gl);
RARCH_PERFORMANCE_STOP(frame_run);
@ -1662,11 +1664,11 @@ static bool gl_frame(void *data, const void *frame,
!driver->nonblock_state && !runloop->is_slowmotion
&& !runloop->is_paused)
{
gl->ctx_driver->swap_buffers(gl);
gfx_ctx_swap_buffers(gl);
glClear(GL_COLOR_BUFFER_BIT);
}
gl->ctx_driver->swap_buffers(gl);
gfx_ctx_swap_buffers(gl);
#ifdef HAVE_GL_SYNC
if (settings->video.hard_sync && gl->have_sync)
@ -1726,6 +1728,7 @@ static void gl_free(void *data)
{
gl_t *gl = (gl_t*)data;
const struct font_renderer *font_driver = NULL;
const gfx_ctx_driver_t *ctx = gfx_ctx_get_ptr();
if (!gl)
return;
@ -1796,7 +1799,7 @@ static void gl_free(void *data)
}
#endif
gl->ctx_driver->destroy(gl);
ctx->destroy(gl);
free(gl->empty_buf);
free(gl->conv_buffer);
@ -1805,8 +1808,9 @@ static void gl_free(void *data)
static void gl_set_nonblock_state(void *data, bool state)
{
gl_t *gl = (gl_t*)data;
settings_t *settings = config_get_ptr();
gl_t *gl = (gl_t*)data;
settings_t *settings = config_get_ptr();
const gfx_ctx_driver_t *ctx = gfx_ctx_get_ptr();
if (!gl)
return;
@ -1814,7 +1818,7 @@ static void gl_set_nonblock_state(void *data, bool state)
RARCH_LOG("[GL]: VSync => %s\n", state ? "off" : "on");
context_bind_hw_render(gl, false);
gl->ctx_driver->swap_interval(gl,
ctx->swap_interval(gl,
state ? 0 : settings->video.swap_interval);
context_bind_hw_render(gl, true);
}
@ -2224,9 +2228,7 @@ static void *gl_init(const video_info_t *video, const input_driver_t **input, vo
struct retro_hw_render_callback *hw_render = NULL;
settings_t *settings = config_get_ptr();
global_t *global = global_get_ptr();
#ifdef _WIN32
gfx_set_dwm();
#endif
driver_t *driver = driver_get_ptr();
gl = (gl_t*)calloc(1, sizeof(gl_t));
if (!gl)
@ -2239,15 +2241,15 @@ static void *gl_init(const video_info_t *video, const input_driver_t **input, vo
return NULL;
}
gl->ctx_driver = ctx_driver;
gl->video_info = *video;
driver->video_context = ctx_driver;
gl->video_info = *video;
RARCH_LOG("Found GL context: %s\n", gl->ctx_driver->ident);
RARCH_LOG("Found GL context: %s\n", ctx_driver->ident);
gl->ctx_driver->get_video_size(gl, &gl->full_x, &gl->full_y);
ctx_driver->get_video_size(gl, &gl->full_x, &gl->full_y);
RARCH_LOG("Detecting screen resolution %ux%u.\n", gl->full_x, gl->full_y);
gl->ctx_driver->swap_interval(gl,
ctx_driver->swap_interval(gl,
video->vsync ? settings->video.swap_interval : 0);
win_width = video->width;
@ -2259,7 +2261,7 @@ static void *gl_init(const video_info_t *video, const input_driver_t **input, vo
win_height = gl->full_y;
}
if (!gl->ctx_driver->set_video_mode(gl, win_width, win_height, video->fullscreen))
if (!ctx_driver->set_video_mode(gl, win_width, win_height, video->fullscreen))
{
free(gl);
return NULL;
@ -2276,7 +2278,7 @@ static void *gl_init(const video_info_t *video, const input_driver_t **input, vo
RARCH_LOG("[GL]: Version: %s.\n", version);
#ifndef RARCH_CONSOLE
rglgen_resolve_symbols(gl->ctx_driver->get_proc_address);
rglgen_resolve_symbols(ctx_driver->get_proc_address);
#endif
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
@ -2284,7 +2286,7 @@ static void *gl_init(const video_info_t *video, const input_driver_t **input, vo
if (!resolve_extensions(gl))
{
gl->ctx_driver->destroy(gl);
ctx_driver->destroy(gl);
free(gl);
return NULL;
}
@ -2297,7 +2299,7 @@ static void *gl_init(const video_info_t *video, const input_driver_t **input, vo
gl->fullscreen = video->fullscreen;
/* Get real known video size, which might have been altered by context. */
gl->ctx_driver->get_video_size(gl, &gl->win_width, &gl->win_height);
ctx_driver->get_video_size(gl, &gl->win_width, &gl->win_height);
RARCH_LOG("GL: Using resolution %ux%u\n", gl->win_width, gl->win_height);
if (gl->full_x || gl->full_y)
@ -2333,7 +2335,7 @@ static void *gl_init(const video_info_t *video, const input_driver_t **input, vo
gl->white_color_ptr = white_color;
#ifdef HAVE_GLSL
gl_glsl_set_get_proc_address(gl->ctx_driver->get_proc_address);
gl_glsl_set_get_proc_address(ctx_driver->get_proc_address);
gl_glsl_set_context_type(gl->core_context,
hw_render->version_major, hw_render->version_minor);
#endif
@ -2349,7 +2351,7 @@ static void *gl_init(const video_info_t *video, const input_driver_t **input, vo
if (!gl_shader_init(gl))
{
RARCH_ERR("[GL]: Shader initialization failed.\n");
gl->ctx_driver->destroy(gl);
ctx_driver->destroy(gl);
free(gl);
return NULL;
}
@ -2412,7 +2414,7 @@ static void *gl_init(const video_info_t *video, const input_driver_t **input, vo
if (!gl->conv_buffer)
{
gl->ctx_driver->destroy(gl);
ctx_driver->destroy(gl);
free(gl);
return NULL;
}
@ -2427,14 +2429,14 @@ static void *gl_init(const video_info_t *video, const input_driver_t **input, vo
if (gl->hw_render_use &&
!gl_init_hw_render(gl, gl->tex_w, gl->tex_h))
{
gl->ctx_driver->destroy(gl);
ctx_driver->destroy(gl);
free(gl);
return NULL;
}
#endif
if (input && input_data)
gl->ctx_driver->input_driver(gl, input, input_data);
ctx_driver->input_driver(gl, input, input_data);
if (settings->video.font_enable)
{
@ -2450,7 +2452,7 @@ static void *gl_init(const video_info_t *video, const input_driver_t **input, vo
if (!gl_check_error())
{
gl->ctx_driver->destroy(gl);
ctx_driver->destroy(gl);
free(gl);
return NULL;
}
@ -2464,11 +2466,12 @@ static bool gl_alive(void *data)
bool quit = false, resize = false;
gl_t *gl = (gl_t*)data;
runloop_t *runloop = rarch_main_get_ptr();
const gfx_ctx_driver_t *ctx = gfx_ctx_get_ptr();
if (!gl)
return false;
gl->ctx_driver->check_window(gl, &quit,
ctx->check_window(gl, &quit,
&resize, &gl->win_width, &gl->win_height,
runloop->frames.video.count);
@ -2482,28 +2485,26 @@ static bool gl_alive(void *data)
static bool gl_focus(void *data)
{
gl_t *gl = (gl_t*)data;
if (!gl)
return false;
return gl->ctx_driver->has_focus(gl);
return gfx_ctx_focus(data);
}
static bool gl_suppress_screensaver(void *data, bool enable)
{
gl_t *gl = (gl_t*)data;
const gfx_ctx_driver_t *ctx = gfx_ctx_get_ptr();
if (gl && gl->ctx_driver)
return gl->ctx_driver->suppress_screensaver(gl, enable);
if (gl && ctx)
return ctx->suppress_screensaver(gl, enable);
return false;
}
static bool gl_has_windowed(void *data)
{
gl_t *gl = (gl_t*)data;
const gfx_ctx_driver_t *ctx = gfx_ctx_get_ptr();
if (gl && gl->ctx_driver)
return gl->ctx_driver->has_windowed(gl);
if (gl && ctx)
return ctx->has_windowed(gl);
return true;
}
@ -2971,14 +2972,15 @@ static void gl_overlay_vertex_geom(void *data,
static void gl_overlay_enable(void *data, bool state)
{
gl_t *gl = (gl_t*)data;
const gfx_ctx_driver_t *ctx = gfx_ctx_get_ptr();
if (!gl)
return;
gl->overlay_enable = state;
if (gl->ctx_driver->show_mouse && gl->fullscreen)
gl->ctx_driver->show_mouse(gl, state);
if (ctx->show_mouse && gl->fullscreen)
ctx->show_mouse(gl, state);
}
static void gl_overlay_full_screen(void *data, bool enable)
@ -3070,9 +3072,9 @@ static uintptr_t gl_get_current_framebuffer(void *data)
static retro_proc_address_t gl_get_proc_address(void *data, const char *sym)
{
gl_t *gl = (gl_t*)data;
const gfx_ctx_driver_t *ctx = gfx_ctx_get_ptr();
return gl->ctx_driver->get_proc_address(sym);
return ctx->get_proc_address(sym);
}
static void gl_set_aspect_ratio(void *data, unsigned aspect_ratio_idx)
@ -3178,9 +3180,10 @@ static void gl_set_osd_msg(void *data, const char *msg,
static void gl_show_mouse(void *data, bool state)
{
gl_t *gl = (gl_t*)data;
const gfx_ctx_driver_t *ctx = gfx_ctx_get_ptr();
if (gl && gl->ctx_driver->show_mouse)
gl->ctx_driver->show_mouse(gl, state);
if (gl && ctx->show_mouse)
ctx->show_mouse(gl, state);
}
static struct video_shader *gl_get_current_shader(void *data)
@ -3192,25 +3195,28 @@ static struct video_shader *gl_get_current_shader(void *data)
static void gl_get_video_output_size(void *data, unsigned *width, unsigned *height)
{
gl_t *gl = (gl_t*)data;
const gfx_ctx_driver_t *ctx = gfx_ctx_get_ptr();
if (gl && gl->ctx_driver->get_video_output_size)
gl->ctx_driver->get_video_output_size(gl, width, height);
if (ctx->get_video_output_size)
ctx->get_video_output_size(gl, width, height);
}
static void gl_get_video_output_prev(void *data)
{
gl_t *gl = (gl_t*)data;
const gfx_ctx_driver_t *ctx = gfx_ctx_get_ptr();
if (gl && gl->ctx_driver->get_video_output_prev)
gl->ctx_driver->get_video_output_prev(gl);
if (ctx->get_video_output_prev)
ctx->get_video_output_prev(gl);
}
static void gl_get_video_output_next(void *data)
{
gl_t *gl = (gl_t*)data;
const gfx_ctx_driver_t *ctx = gfx_ctx_get_ptr();
if (gl && gl->ctx_driver->get_video_output_next)
gl->ctx_driver->get_video_output_next(gl);
if (ctx->get_video_output_next)
ctx->get_video_output_next(gl);
}

View File

@ -17,16 +17,17 @@
#ifndef __GL_COMMON_H
#define __GL_COMMON_H
#include "../general.h"
#include "font_renderer_driver.h"
#include "../../general.h"
#include "../font_renderer_driver.h"
#include <gfx/math/matrix_4x4.h>
#include <gfx/scaler/scaler.h>
#include <formats/image.h>
#include "video_shader_driver.h"
#include "../video_context_driver.h"
#include "../video_shader_driver.h"
#include <retro_inline.h>
#ifdef HAVE_CONFIG_H
#include "../config.h"
#include "../../config.h"
#endif
#include <string.h>
@ -244,7 +245,6 @@ struct gl_font_renderer;
typedef struct gl
{
const gfx_ctx_driver_t *ctx_driver;
const shader_backend_t *shader;
bool vsync;
@ -366,11 +366,12 @@ typedef struct gl
static INLINE void context_bind_hw_render(gl_t *gl, bool enable)
{
const gfx_ctx_driver_t *ctx = gfx_ctx_get_ptr();
if (!gl)
return;
if (gl->shared_context_use && gl->ctx_driver->bind_hw_render)
gl->ctx_driver->bind_hw_render(gl, enable);
if (gl->shared_context_use && ctx->bind_hw_render)
ctx->bind_hw_render(gl, enable);
}
static INLINE bool gl_check_error(void)

View File

@ -31,11 +31,7 @@
#include "../font_renderer_driver.h"
#ifdef HAVE_X11
#include "../drivers_wm/x11_common.h"
#endif
#if defined(_WIN32) && !defined(_XBOX)
#include "../drivers_wm/win32_dwm_common.h"
#include "../common/x11_common.h"
#endif
#ifdef HAVE_CONFIG_H
@ -376,10 +372,6 @@ static void *sdl2_gfx_init(const video_info_t *video, const input_driver_t **inp
unsigned flags;
settings_t *settings = config_get_ptr();
#ifdef _WIN32
gfx_set_dwm();
#endif
#ifdef HAVE_X11
XInitThreads();
#endif

View File

@ -27,11 +27,7 @@
#include "../font_renderer_driver.h"
#ifdef HAVE_X11
#include "../drivers_wm/x11_common.h"
#endif
#if defined(_WIN32) && !defined(_XBOX)
#include "../drivers_context/win32_dwm_common.h"
#include "../common/x11_common.h"
#endif
#ifdef HAVE_CONFIG_H
@ -250,10 +246,6 @@ static void *sdl_gfx_init(const video_info_t *video, const input_driver_t **inpu
sdl_video_t *vid = NULL;
settings_t *settings = config_get_ptr();
#ifdef _WIN32
gfx_set_dwm();
#endif
#ifdef HAVE_X11
XInitThreads();
#endif

View File

@ -34,7 +34,6 @@
typedef struct
{
const gfx_ctx_driver_t *driver;
uint32_t mScreenWidth;
uint32_t mScreenHeight;
bool should_resize;
@ -68,8 +67,11 @@ static PFNVGCREATEEGLIMAGETARGETKHRPROC pvgCreateEGLImageTargetKHR;
static void vg_set_nonblock_state(void *data, bool state)
{
vg_t *vg = (vg_t*)data;
vg->driver->swap_interval(vg, state ? 0 : 1);
vg_t *vg = (vg_t*)data;
const gfx_ctx_driver_t *ctx = gfx_ctx_get_ptr();
if (ctx)
ctx->swap_interval(vg, state ? 0 : 1);
}
static INLINE bool vg_query_extension(const char *ext)
@ -85,26 +87,27 @@ static INLINE bool vg_query_extension(const char *ext)
static void *vg_init(const video_info_t *video, const input_driver_t **input, void **input_data)
{
VGfloat clearColor[4] = {0, 0, 0, 1};
settings_t *settings = config_get_ptr();
vg_t *vg = (vg_t*)calloc(1, sizeof(vg_t));
settings_t *settings = config_get_ptr();
driver_t *driver = driver_get_ptr();
const gfx_ctx_driver_t *ctx = NULL;
vg_t *vg = (vg_t*)calloc(1, sizeof(vg_t));
if (!vg)
return NULL;
goto error;
vg->driver = gfx_ctx_init_first(vg, settings->video.context_driver,
ctx = gfx_ctx_init_first(vg, settings->video.context_driver,
GFX_CTX_OPENVG_API, 0, 0, false);
if (!vg->driver)
{
free(vg);
return NULL;
}
if (!ctx)
goto error;
vg->driver->get_video_size(vg, &vg->mScreenWidth, &vg->mScreenHeight);
driver->video_context = ctx;
ctx->get_video_size(vg, &vg->mScreenWidth, &vg->mScreenHeight);
RARCH_LOG("Detecting screen resolution %ux%u.\n", vg->mScreenWidth, vg->mScreenHeight);
vg->driver->swap_interval(vg, video->vsync ? 1 : 0);
vg->driver->update_window_title(vg);
ctx->swap_interval(vg, video->vsync ? 1 : 0);
ctx->update_window_title(vg);
vg->mTexType = video->rgb32 ? VG_sXRGB_8888 : VG_sRGB_565;
vg->mKeepAspect = video->force_aspect;
@ -117,18 +120,15 @@ static void *vg_init(const video_info_t *video, const input_driver_t **input, vo
win_height = vg->mScreenHeight;
}
if (!vg->driver->set_video_mode(vg, win_width, win_height, video->fullscreen))
{
free(vg);
return NULL;
}
if (!ctx->set_video_mode(vg, win_width, win_height, video->fullscreen))
goto error;
vg->driver->get_video_size(vg, &vg->mScreenWidth, &vg->mScreenHeight);
ctx->get_video_size(vg, &vg->mScreenWidth, &vg->mScreenHeight);
RARCH_LOG("Verified window resolution %ux%u.\n", vg->mScreenWidth, vg->mScreenHeight);
vg->should_resize = true;
if (vg->driver->translate_aspect)
vg->mScreenAspect = vg->driver->translate_aspect(vg, vg->mScreenWidth, vg->mScreenHeight);
if (ctx->translate_aspect)
vg->mScreenAspect = ctx->translate_aspect(vg, vg->mScreenWidth, vg->mScreenHeight);
else
vg->mScreenAspect = (float)vg->mScreenWidth / vg->mScreenHeight;
@ -139,7 +139,7 @@ static void *vg_init(const video_info_t *video, const input_driver_t **input, vo
video->smooth ? VG_IMAGE_QUALITY_BETTER : VG_IMAGE_QUALITY_NONANTIALIASED);
vg_set_nonblock_state(vg, !video->vsync);
vg->driver->input_driver(vg, input, input_data);
ctx->input_driver(vg, input, input_data);
if (settings->video.font_enable && font_renderer_create_default(&vg->font_driver, &vg->mFontRenderer,
*settings->video.font_path ? settings->video.font_path : NULL, settings->video.font_size))
@ -165,9 +165,9 @@ static void *vg_init(const video_info_t *video, const input_driver_t **input, vo
}
}
if (vg_query_extension("KHR_EGL_image") && vg->driver->init_egl_image_buffer(vg, video))
if (vg_query_extension("KHR_EGL_image") && ctx->init_egl_image_buffer(vg, video))
{
pvgCreateEGLImageTargetKHR = (PFNVGCREATEEGLIMAGETARGETKHRPROC)vg->driver->get_proc_address("vgCreateEGLImageTargetKHR");
pvgCreateEGLImageTargetKHR = (PFNVGCREATEEGLIMAGETARGETKHRPROC)ctx->get_proc_address("vgCreateEGLImageTargetKHR");
if (pvgCreateEGLImageTargetKHR)
{
@ -183,11 +183,19 @@ static void *vg_init(const video_info_t *video, const input_driver_t **input, vo
#endif
return vg;
error:
if (vg)
free(vg);
if (driver)
driver->video_context = NULL;
return NULL;
}
static void vg_free(void *data)
{
vg_t *vg = (vg_t*)data;
vg_t *vg = (vg_t*)data;
const gfx_ctx_driver_t *ctx = gfx_ctx_get_ptr();
if (!vg)
return;
@ -202,7 +210,7 @@ static void vg_free(void *data)
vgDestroyPaint(vg->mPaintBg);
}
vg->driver->destroy(vg);
ctx->destroy(vg);
free(vg);
}
@ -343,7 +351,10 @@ static void vg_copy_frame(void *data, const void *frame, unsigned width, unsigne
if (vg->mEglImageBuf)
{
EGLImageKHR img = 0;
bool new_egl = vg->driver->write_egl_image(vg, frame, width, height, pitch, (vg->mTexType == VG_sXRGB_8888), 0, &img);
const gfx_ctx_driver_t *ctx = gfx_ctx_get_ptr();
bool new_egl = ctx->write_egl_image(vg,
frame, width, height, pitch, (vg->mTexType == VG_sXRGB_8888), 0, &img);
rarch_assert(img != EGL_NO_IMAGE_KHR);
if (new_egl)
@ -368,7 +379,8 @@ static bool vg_frame(void *data, const void *frame, unsigned width, unsigned hei
{
RARCH_PERFORMANCE_INIT(vg_fr);
RARCH_PERFORMANCE_START(vg_fr);
vg_t *vg = (vg_t*)data;
vg_t *vg = (vg_t*)data;
const gfx_ctx_driver_t *ctx = gfx_ctx_get_ptr();
if (width != vg->mRenderWidth || height != vg->mRenderHeight || vg->should_resize)
{
@ -401,10 +413,10 @@ static bool vg_frame(void *data, const void *frame, unsigned width, unsigned hei
vg_draw_message(vg, msg);
#endif
vg->driver->update_window_title(vg);
ctx->update_window_title(vg);
RARCH_PERFORMANCE_STOP(vg_fr);
vg->driver->swap_buffers(vg);
ctx->swap_buffers(vg);
return true;
}
@ -412,10 +424,11 @@ static bool vg_frame(void *data, const void *frame, unsigned width, unsigned hei
static bool vg_alive(void *data)
{
bool quit;
vg_t *vg = (vg_t*)data;
runloop_t *runloop = rarch_main_get_ptr();
vg_t *vg = (vg_t*)data;
runloop_t *runloop = rarch_main_get_ptr();
const gfx_ctx_driver_t *ctx = gfx_ctx_get_ptr();
vg->driver->check_window(vg, &quit,
ctx->check_window(vg, &quit,
&vg->should_resize, &vg->mScreenWidth, &vg->mScreenHeight,
runloop->frames.video.count);
return !quit;
@ -423,25 +436,30 @@ static bool vg_alive(void *data)
static bool vg_focus(void *data)
{
vg_t *vg = (vg_t*)data;
if (vg && vg->driver)
return vg->driver->has_focus(vg);
vg_t *vg = (vg_t*)data;
const gfx_ctx_driver_t *ctx = gfx_ctx_get_ptr();
if (vg && ctx)
return ctx->has_focus(vg);
return false;
}
static bool vg_suppress_screensaver(void *data, bool enable)
{
vg_t *vg = (vg_t*)data;
if (vg && vg->driver)
return vg->driver->suppress_screensaver(vg, enable);
vg_t *vg = (vg_t*)data;
const gfx_ctx_driver_t *ctx = gfx_ctx_get_ptr();
if (vg && ctx)
return ctx->suppress_screensaver(vg, enable);
return false;
}
static bool vg_has_windowed(void *data)
{
vg_t *vg = (vg_t*)data;
if (vg && vg->driver)
return vg->driver->has_windowed(vg);
vg_t *vg = (vg_t*)data;
const gfx_ctx_driver_t *ctx = gfx_ctx_get_ptr();
if (vg && ctx)
return ctx->has_windowed(vg);
return true;
}

View File

@ -24,7 +24,7 @@
#include "../font_renderer_driver.h"
#include <retro_inline.h>
#include "../drivers_wm/x11_common.h"
#include "../common/x11_common.h"
#include <X11/Xlib.h>
#include <X11/Xutil.h>
@ -674,45 +674,46 @@ static void xv_render_msg(xv_t *xv, const char *msg,
for (; *msg; msg++)
{
int base_x, base_y, glyph_width, glyph_height, max_width, max_height;
const uint8_t *src = NULL;
uint8_t *out = NULL;
const uint8_t *src = NULL;
uint8_t *out = NULL;
const struct font_glyph *glyph = xv->font_driver->get_glyph(xv->font, (uint8_t)*msg);
if (!glyph)
continue;
/* Make sure we always start on the correct boundary so the indices are correct. */
base_x = (msg_base_x + glyph->draw_offset_x + 1) & ~1;
base_y = msg_base_y + glyph->draw_offset_y;
base_x = (msg_base_x + glyph->draw_offset_x + 1) & ~1;
base_y = msg_base_y + glyph->draw_offset_y;
glyph_width = glyph->width;
glyph_height = glyph->height;
glyph_width = glyph->width;
glyph_height = glyph->height;
src = atlas->buffer + glyph->atlas_offset_x + glyph->atlas_offset_y * atlas->width;
src = atlas->buffer + glyph->atlas_offset_x +
glyph->atlas_offset_y * atlas->width;
if (base_x < 0)
{
src -= base_x;
glyph_width += base_x;
src -= base_x;
glyph_width += base_x;
base_x = 0;
}
if (base_y < 0)
{
src -= base_y * (int)atlas->width;
src -= base_y * (int)atlas->width;
glyph_height += base_y;
base_y = 0;
}
max_width = width - base_x;
max_height = height - base_y;
max_width = width - base_x;
max_height = height - base_y;
if (max_width <= 0 || max_height <= 0)
continue;
if (glyph_width > max_width)
glyph_width = max_width;
glyph_width = max_width;
if (glyph_height > max_height)
glyph_height = max_height;
glyph_height = max_height;
out = (uint8_t*)xv->image->data + base_y * pitch + (base_x << 1);
@ -726,11 +727,10 @@ static void xv_render_msg(xv_t *xv, const char *msg,
int out_x = x << 1;
alpha[0] = src[x + 0];
alpha[1] = 0;
if (x + 1 < glyph_width)
alpha[1] = src[x + 1];
else
alpha[1] = 0;
/* Blended alpha for the sub-sampled U/V channels. */
alpha_sub = (alpha[0] + alpha[1]) >> 1;
@ -772,7 +772,7 @@ static bool xv_frame(void *data, const void *frame, unsigned width,
xv->render_func(xv, frame, width, height, pitch);
calc_out_rect(xv->keep_aspect, &xv->vp, target.width, target.height);
xv->vp.full_width = target.width;
xv->vp.full_width = target.width;
xv->vp.full_height = target.height;
if (msg)

View File

@ -18,7 +18,7 @@
#include "../../general.h"
#include "../../runloop.h"
#include "../video_monitor.h"
#include "../gl_common.h"
#include "../drivers/gl_common.h"
#include <EGL/egl.h>
@ -382,6 +382,93 @@ static void android_gfx_ctx_bind_hw_render(void *data, bool enable)
android->g_egl_hw_ctx : android->g_egl_ctx);
}
#define ANDROID_DENSITY_LOW 120
#define ANDROID_DENSITY_MEDIUM 160
#define ANDROID_DENSITY_TV 213
#define ANDROID_DENSITY_XHIGH 320
#define ANDROID_DENSITY_XXHIGH 480
#define ANDROID_DENSITY_XXXHIGH 640
static bool android_gfx_ctx_get_metrics(void *data,
enum display_metric_types type, float *value)
{
jclass metrics_class;
jobject metrics;
jmethodID getMetrics;
struct android_app *android_app = (struct android_app*)g_android;
JNIEnv *env = (JNIEnv*)jni_thread_getenv();
GET_METHOD_ID(env, getMetrics, android_app->activity, "getMetrics", "()Landroid/util/DisplayMetrics;");
if (!getMetrics)
goto error;
CALL_OBJ_STATIC_METHOD(env, metrics, android_app->activity, getMetrics);
GET_OBJECT_CLASS(env, metrics_class, metrics);
/* Density */
float density = (*env)->GetFloatField(env, metrics, (*env)->GetFieldID(env, metrics_class, "density", "F"));
float scaled_density = (*env)->GetFloatField(env, metrics, (*env)->GetFieldID(env, metrics_class, "scaledDensity", "F"));
int density_dpi = (*env)->GetIntField(env, metrics, (*env)->GetFieldID(env, metrics_class, "densityDpi", "I"));
/* Size */
int width_pixels = (*env)->GetIntField(env, metrics, (*env)->GetFieldID(env, metrics_class, "widthPixels", "I"));
int height_pixels = (*env)->GetIntField(env, metrics, (*env)->GetFieldID(env, metrics_class, "heightPixels", "I"));
/* DPI */
/* Apparently xdpi and ydpi can't be trusted to be implemented correctly, so don't try to rely on it...
*
* https://groups.google.com/forum/#!topic/android-developers/QjUlaRohRPI
*
* "The xdpi and ydpi are supposed to be the real DPI of the screen... though as you've seen,
* many devices don't set it correctly. :( This is our fault, it isn't actually used anywhere
* in the platform, so people don't realize they have a bad value, and we haven't had a CTS
* test to try to make sure it is sane (it's not clear how that test should work). Worse, we
* shipping the original Droid with a graphics driver that reports the wrong value here...
* in fact that reported that same damnable 96."
*
* Unfortunately, I don't have a good solution if you want to get the real exactly screen dots per inch.
* One thing you could do is compare xdpi/ydpi with densityDpi and if they are significantly
* far apart, assume the values are bad and just fall back on densityDpi as an approximation.
*
* Be careful on this, because a correctly working device may have densityDpi fairly different
* than the real dpi -- for example the Samsung TAB uses high density even though its screen's
* really density is a fair amount lower than 240."
*/
float xdpi = (*env)->GetFloatField(env, metrics, (*env)->GetFieldID(env, metrics_class, "xdpi", "F"));
float ydpi = (*env)->GetFloatField(env, metrics, (*env)->GetFieldID(env, metrics_class, "ydpi", "F"));
(void)width_pixels;
(void)height_pixels;
(void)scaled_density;
(void)density;
(void)density_dpi;
switch (type)
{
case DISPLAY_METRIC_MM_WIDTH:
/* can't guarantee this to be accurate - so return false anyway. */
*value = xdpi;
return false;
case DISPLAY_METRIC_MM_HEIGHT:
/* can't guarantee this to be accurate - so return false anyway. */
*value = ydpi;
return false;
case DISPLAY_METRIC_DPI:
/* just go with quantized DPI. */
*value = density_dpi;
break;
case DISPLAY_METRIC_NONE:
default:
*value = 0;
return false;
}
return true;
error:
return false;
}
const gfx_ctx_driver_t gfx_ctx_android = {
android_gfx_ctx_init,
android_gfx_ctx_destroy,
@ -392,6 +479,7 @@ const gfx_ctx_driver_t gfx_ctx_android = {
NULL, /* get_video_output_size */
NULL, /* get_video_output_prev */
NULL, /* get_video_output_next */
android_gfx_ctx_get_metrics,
NULL,
android_gfx_ctx_update_window_title,
android_gfx_ctx_check_window,

View File

@ -18,7 +18,7 @@
#include "../../general.h"
#include "../../runloop.h"
#include "../video_monitor.h"
#include "../gl_common.h"
#include "../drivers/gl_common.h"
#include <EGL/egl.h>
#include <bps/screen.h>
@ -453,6 +453,7 @@ const gfx_ctx_driver_t gfx_ctx_bbqnx = {
NULL, /* get_video_output_size */
NULL, /* get_video_output_prev */
NULL, /* get_video_output_next */
NULL, /* get_metrics */
NULL,
gfx_ctx_qnx_update_window_title,
gfx_ctx_qnx_check_window,

View File

@ -16,7 +16,7 @@
*/
#include "../d3d/d3d.h"
#include "../drivers_wm/win32_common.h"
#include "../common/win32_common.h"
#include "../../runloop.h"
#include "../video_monitor.h"
@ -492,6 +492,12 @@ static void gfx_ctx_d3d_swap_interval(void *data, unsigned interval)
#endif
}
static bool gfx_ctx_d3d_get_metrics(void *data,
enum display_metric_types type, float *value)
{
return win32_get_metrics(data, type, value);
}
const gfx_ctx_driver_t gfx_ctx_d3d = {
gfx_ctx_d3d_init,
gfx_ctx_d3d_destroy,
@ -502,6 +508,7 @@ const gfx_ctx_driver_t gfx_ctx_d3d = {
NULL, /* get_video_output_size */
NULL, /* get_video_output_prev */
NULL, /* get_video_output_next */
gfx_ctx_d3d_get_metrics,
NULL,
gfx_ctx_d3d_update_title,
gfx_ctx_d3d_check_window,

View File

@ -20,7 +20,7 @@
#include "../../driver.h"
#include "../../runloop.h"
#include "../gl_common.h"
#include "../drivers/gl_common.h"
#include "../video_monitor.h"
#include <file/dir_list.h>
@ -935,6 +935,8 @@ static bool gfx_ctx_drm_egl_bind_api(void *data,
default:
return false;
}
return false;
}
static void gfx_ctx_drm_egl_bind_hw_render(void *data, bool enable)
@ -970,6 +972,7 @@ const gfx_ctx_driver_t gfx_ctx_drm_egl = {
NULL, /* get_video_output_size */
NULL, /* get_video_output_prev */
NULL, /* get_video_output_next */
NULL, /* get_metrics */
NULL,
gfx_ctx_drm_egl_update_window_title,
gfx_ctx_drm_egl_check_window,

View File

@ -17,7 +17,7 @@
#include "../../driver.h"
#include "../../runloop.h"
#include "../video_context_driver.h"
#include "../gl_common.h"
#include "../drivers/gl_common.h"
#include "../video_monitor.h"
#ifdef HAVE_CONFIG_H
@ -309,6 +309,7 @@ const gfx_ctx_driver_t gfx_ctx_emscripten = {
NULL, /* get_video_output_size */
NULL, /* get_video_output_prev */
NULL, /* get_video_output_next */
NULL, /* get_metrics */
NULL,
gfx_ctx_emscripten_translate_aspect,
gfx_ctx_emscripten_update_window_title,

View File

@ -143,6 +143,7 @@ const gfx_ctx_driver_t gfx_ctx_null = {
NULL, /* get_video_output_size */
NULL, /* get_video_output_prev */
NULL, /* get_video_output_next */
NULL, /* get_metrics */
NULL,
gfx_ctx_null_update_window_title,
gfx_ctx_null_check_window,

View File

@ -16,9 +16,9 @@
#include "../../driver.h"
#include "../../runloop.h"
#include "../gl_common.h"
#include "../drivers/gl_common.h"
#include "../video_monitor.h"
#include "../drivers_wm/x11_common.h"
#include "../common/x11_common.h"
#include <signal.h>
#include <stdint.h>
@ -786,6 +786,12 @@ static void gfx_ctx_glx_bind_hw_render(void *data, bool enable)
glx->g_glx_win, enable ? glx->g_hw_ctx : glx->g_ctx);
}
static bool gfx_ctx_glx_get_metrics(void *data,
enum display_metric_types type, float *value)
{
return x11_get_metrics(data, type, value);
}
const gfx_ctx_driver_t gfx_ctx_glx = {
gfx_ctx_glx_init,
gfx_ctx_glx_destroy,
@ -796,6 +802,7 @@ const gfx_ctx_driver_t gfx_ctx_glx = {
NULL, /* get_video_output_size */
NULL, /* get_video_output_prev */
NULL, /* get_video_output_next */
gfx_ctx_glx_get_metrics,
NULL,
gfx_ctx_glx_update_window_title,
gfx_ctx_glx_check_window,

View File

@ -17,7 +17,7 @@
#include "../../general.h"
#include "../../runloop.h"
#include "../video_monitor.h"
#include "../gl_common.h"
#include "../drivers/gl_common.h"
#include <EGL/egl.h>
#include <signal.h>
@ -321,6 +321,7 @@ const gfx_ctx_driver_t gfx_ctx_mali_fbdev = {
NULL, /* get_video_output_size */
NULL, /* get_video_output_prev */
NULL, /* get_video_output_next */
NULL, /* get_metrics */
NULL,
gfx_ctx_mali_fbdev_update_window_title,
gfx_ctx_mali_fbdev_check_window,

View File

@ -36,7 +36,7 @@
#include "config.h"
#endif
#include "../gl_common.h"
#include "../drivers/gl_common.h"
#include "../video_context_driver.h"
@ -388,6 +388,7 @@ const gfx_ctx_driver_t gfx_ctx_ps3 = {
NULL, /* get_video_output_size */
NULL, /* get_video_output_prev */
NULL, /* get_video_output_next */
NULL, /* get_metrics */
NULL,
gfx_ctx_ps3_update_window_title,
gfx_ctx_ps3_check_window,

View File

@ -16,7 +16,7 @@
#include "../../driver.h"
#include "../../runloop.h"
#include "../gl_common.h"
#include "../drivers/gl_common.h"
#include "../video_monitor.h"
#include "SDL.h"
@ -436,6 +436,7 @@ const gfx_ctx_driver_t gfx_ctx_sdl_gl =
NULL, /* get_video_output_size */
NULL, /* get_video_output_prev */
NULL, /* get_video_output_next */
NULL, /* get_metrics */
NULL, /* translate_aspect */
sdl_ctx_update_window_title,
sdl_ctx_check_window,

View File

@ -17,7 +17,7 @@
#include "../../driver.h"
#include "../../runloop.h"
#include "../video_context_driver.h"
#include "../gl_common.h"
#include "../drivers/gl_common.h"
#include "../video_monitor.h"
#include <retro_inline.h>
@ -136,25 +136,26 @@ static void gfx_ctx_vc_get_video_size(void *data,
settings_t *settings = config_get_ptr();
(void)data;
// Use dispmanx upscaling if fullscreen_x and fullscreen_y are set.
/* Use dispmanx upscaling if
* fullscreen_x and fullscreen_y are set. */
if (settings->video.fullscreen_x != 0 &&
settings->video.fullscreen_y != 0)
{
// Keep input and output aspect ratio equal.
// There are other aspect ratio settings which can be used to stretch video output.
// --------------------------------------------------------------------------------
// Calculate source and destination aspect ratios.
/* Keep input and output aspect ratio equal.
* There are other aspect ratio settings
* which can be used to stretch video output. */
/* Calculate source and destination aspect ratios. */
float srcAspect = (float)settings->video.fullscreen_x / (float)settings->video.fullscreen_y;
float dstAspect = (float)g_fb_width / (float)g_fb_height;
// If source and destination aspect ratios are not equal correct source width.
/* If source and destination aspect ratios are not equal correct source width. */
if (srcAspect != dstAspect)
{
*width = (unsigned)(settings->video.fullscreen_y * dstAspect);
}
else
{
*width = settings->video.fullscreen_x;
}
*height = settings->video.fullscreen_y;
}
else
@ -246,17 +247,18 @@ static bool gfx_ctx_vc_init(void *data)
src_rect.x = 0;
src_rect.y = 0;
// Use dispmanx upscaling if fullscreen_x and fullscreen_y are set.
/* Use dispmanx upscaling if fullscreen_x
* and fullscreen_y are set. */
if (settings->video.fullscreen_x != 0 &&
settings->video.fullscreen_y != 0)
{
// Keep input and output aspect ratio equal.
// There are other aspect ratio settings which can be used to stretch video output.
// --------------------------------------------------------------------------------
// Calculate source and destination aspect ratios.
/* Keep input and output aspect ratio equal.
* There are other aspect ratio settings which can be used to stretch video output. */
/* Calculate source and destination aspect ratios. */
float srcAspect = (float)settings->video.fullscreen_x / (float)settings->video.fullscreen_y;
float dstAspect = (float)g_fb_width / (float)g_fb_height;
// If source and destination aspect ratios are not equal correct source width.
/* If source and destination aspect ratios are not equal correct source width. */
if (srcAspect != dstAspect)
src_rect.width = (unsigned)(settings->video.fullscreen_y * dstAspect) << 16;
else
@ -283,17 +285,21 @@ static bool gfx_ctx_vc_init(void *data)
&src_rect, DISPMANX_PROTECTION_NONE, &alpha, 0 /*clamp*/, DISPMANX_NO_ROTATE);
nativewindow.element = dispman_element;
// Use dispmanx upscaling if fullscreen_x and fullscreen_y are set.
/* Use dispmanx upscaling if fullscreen_x and fullscreen_y are set. */
if (settings->video.fullscreen_x != 0 &&
settings->video.fullscreen_y != 0)
{
// Keep input and output aspect ratio equal.
// There are other aspect ratio settings which can be used to stretch video output.
// --------------------------------------------------------------------------------
// Calculate source and destination aspect ratios.
/* Keep input and output aspect ratio equal.
* There are other aspect ratio settings which
* can be used to stretch video output. */
/* Calculate source and destination aspect ratios. */
float srcAspect = (float)settings->video.fullscreen_x / (float)settings->video.fullscreen_y;
float dstAspect = (float)g_fb_width / (float)g_fb_height;
// If source and destination aspect ratios are not equal correct source width.
/* If source and destination aspect ratios are not equal correct source width. */
if (srcAspect != dstAspect)
nativewindow.width = (unsigned)(settings->video.fullscreen_y * dstAspect);
else
@ -637,6 +643,7 @@ const gfx_ctx_driver_t gfx_ctx_videocore = {
NULL, /* get_video_output_size */
NULL, /* get_video_output_prev */
NULL, /* get_video_output_next */
NULL, /* get_metrics */
gfx_ctx_vc_translate_aspect,
gfx_ctx_vc_update_window_title,
gfx_ctx_vc_check_window,

View File

@ -18,7 +18,7 @@
#include "../../general.h"
#include "../../runloop.h"
#include "../video_monitor.h"
#include "../gl_common.h"
#include "../drivers/gl_common.h"
#include <EGL/egl.h>
#include <signal.h>
@ -304,6 +304,7 @@ const gfx_ctx_driver_t gfx_ctx_vivante_fbdev = {
NULL, /* get_video_output_size */
NULL, /* get_video_output_prev */
NULL, /* get_video_output_next */
NULL, /* get_metrics */
NULL,
gfx_ctx_vivante_update_window_title,
gfx_ctx_vivante_check_window,

View File

@ -18,7 +18,7 @@
#include "../../general.h"
#include "../../runloop.h"
#include "../video_monitor.h"
#include "../gl_common.h"
#include "../drivers/gl_common.h"
#include <wayland-client.h>
#include <wayland-egl.h>
@ -898,6 +898,7 @@ const gfx_ctx_driver_t gfx_ctx_wayland = {
NULL, /* get_video_output_size */
NULL, /* get_video_output_prev */
NULL, /* get_video_output_next */
NULL, /* get_metrics */
NULL,
gfx_ctx_wl_update_window_title,
gfx_ctx_wl_check_window,

View File

@ -24,9 +24,9 @@
#include "../../driver.h"
#include "../../runloop.h"
#include "../video_context_driver.h"
#include "../gl_common.h"
#include "../drivers/gl_common.h"
#include "../video_monitor.h"
#include "../drivers_wm/win32_common.h"
#include "../common/win32_common.h"
#include "../drivers_wm/win32_shader_dlg.h"
#include <windows.h>
#include <commdlg.h>
@ -111,7 +111,7 @@ static void create_gl_context(HWND hwnd)
bool debug = global->system.hw_render_callback.debug_context;
#ifdef _WIN32
dll_handle = LoadLibrary("OpenGL32.dll");
dll_handle = (HINSTANCE)dylib_load("OpenGL32.dll");
#endif
g_hdc = GetDC(hwnd);
@ -664,6 +664,12 @@ static gfx_ctx_proc_t gfx_ctx_wgl_get_proc_address(const char *symbol)
return (gfx_ctx_proc_t)GetProcAddress(dll_handle, symbol);
}
static bool gfx_ctx_wgl_get_metrics(void *data,
enum display_metric_types type, float *value)
{
return win32_get_metrics(data, type, value);
}
static bool gfx_ctx_wgl_bind_api(void *data,
enum gfx_ctx_api api, unsigned major, unsigned minor)
{
@ -699,6 +705,7 @@ const gfx_ctx_driver_t gfx_ctx_wgl = {
NULL, /* get_video_output_size */
NULL, /* get_video_output_prev */
NULL, /* get_video_output_next */
gfx_ctx_wgl_get_metrics,
NULL,
gfx_ctx_wgl_update_window_title,
gfx_ctx_wgl_check_window,

View File

@ -20,9 +20,9 @@
#include "../../driver.h"
#include "../../runloop.h"
#include "../gl_common.h"
#include "../drivers/gl_common.h"
#include "../video_monitor.h"
#include "../drivers_wm/x11_common.h"
#include "../common/x11_common.h"
#include <signal.h>
#include <stdint.h>
@ -808,6 +808,12 @@ static void gfx_ctx_xegl_bind_hw_render(void *data, bool enable)
g_egl_surf, enable ? g_egl_hw_ctx : g_egl_ctx);
}
static bool gfx_ctx_xegl_get_metrics(void *data,
enum display_metric_types type, float *value)
{
return x11_get_metrics(data, type, value);
}
const gfx_ctx_driver_t gfx_ctx_x_egl = {
gfx_ctx_xegl_init,
gfx_ctx_xegl_destroy,
@ -818,6 +824,7 @@ const gfx_ctx_driver_t gfx_ctx_x_egl = {
NULL, /* get_video_output_size */
NULL, /* get_video_output_prev */
NULL, /* get_video_output_next */
gfx_ctx_xegl_get_metrics,
NULL,
gfx_ctx_xegl_update_window_title,
gfx_ctx_xegl_check_window,

View File

@ -14,7 +14,7 @@
* If not, see <http://www.gnu.org/licenses/>.
*/
#include "../gl_common.h"
#include "../drivers/gl_common.h"
#include "../font_driver.h"
#include "../video_shader_driver.h"

View File

@ -15,7 +15,7 @@
*/
#include "../font_renderer_driver.h"
#include "../gl_common.h"
#include "../drivers/gl_common.h"
#include "../font_driver.h"
#if defined(SN_TARGET_PSP2)

View File

@ -25,7 +25,7 @@
#include <Cg/cg.h>
#ifdef HAVE_OPENGL
#include "../gl_common.h"
#include "../drivers/gl_common.h"
#include <Cg/cgGL.h>
#endif

View File

@ -30,7 +30,7 @@
#include <stdlib.h>
#ifdef HAVE_OPENGL
#include "../gl_common.h"
#include "../drivers/gl_common.h"
#endif
#ifdef HAVE_OPENGLES2

View File

@ -28,7 +28,7 @@
#endif
#ifdef HAVE_OPENGL
#include "../gl_common.h"
#include "../drivers/gl_common.h"
#endif
#include "../video_shader_driver.h"

View File

@ -1,90 +0,0 @@
/* RetroArch - A frontend for libretro.
* Copyright (C) 2010-2014 - Hans-Kristian Arntzen
* Copyright (C) 2011-2015 - Daniel De Matteis
*
* RetroArch is free software: you can redistribute it and/or modify it under the terms
* of the GNU General Public License as published by the Free Software Found-
* ation, either version 3 of the License, or (at your option) any later version.
*
* RetroArch is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
* PURPOSE. See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along with RetroArch.
* If not, see <http://www.gnu.org/licenses/>.
*/
#include "win32_dwm_common.h"
#include "../../general.h"
#if defined(_WIN32) && !defined(_XBOX)
#include <windows.h>
#include "../../dynamic.h"
/* We only load this library once, so we let it be
* unloaded at application shutdown, since unloading
* it early seems to cause issues on some systems.
*/
static dylib_t dwmlib;
static bool dwm_composition_disabled;
static void gfx_dwm_shutdown(void)
{
if (dwmlib)
dylib_close(dwmlib);
dwmlib = NULL;
}
static bool gfx_init_dwm(void)
{
static bool inited = false;
if (inited)
return true;
dwmlib = dylib_load("dwmapi.dll");
if (!dwmlib)
{
RARCH_LOG("Did not find dwmapi.dll.\n");
return false;
}
atexit(gfx_dwm_shutdown);
HRESULT (WINAPI *mmcss)(BOOL) =
(HRESULT (WINAPI*)(BOOL))dylib_proc(dwmlib, "DwmEnableMMCSS");
if (mmcss)
{
RARCH_LOG("Setting multimedia scheduling for DWM.\n");
mmcss(TRUE);
}
inited = true;
return true;
}
void gfx_set_dwm(void)
{
HRESULT ret;
settings_t *settings = config_get_ptr();
if (!gfx_init_dwm())
return;
if (settings->video.disable_composition == dwm_composition_disabled)
return;
HRESULT (WINAPI *composition_enable)(UINT) =
(HRESULT (WINAPI*)(UINT))dylib_proc(dwmlib, "DwmEnableComposition");
if (!composition_enable)
{
RARCH_ERR("Did not find DwmEnableComposition ...\n");
return;
}
ret = composition_enable(!settings->video.disable_composition);
if (FAILED(ret))
RARCH_ERR("Failed to set composition state ...\n");
dwm_composition_disabled = settings->video.disable_composition;
}
#endif

View File

@ -28,9 +28,9 @@
#include "../../driver.h"
#include "../../runloop.h"
#include "../video_context_driver.h"
#include "../gl_common.h"
#include "../drivers/gl_common.h"
#include "../video_monitor.h"
#include "win32_common.h"
#include "../common/win32_common.h"
#include "win32_shader_dlg.h"
#include <windows.h>
#include <commdlg.h>

View File

@ -73,6 +73,60 @@ static const gfx_ctx_driver_t *gfx_ctx_drivers[] = {
NULL
};
const gfx_ctx_driver_t *gfx_ctx_get_ptr(void)
{
driver_t *driver = driver_get_ptr();
if (!driver)
return NULL;
return (const gfx_ctx_driver_t*)driver->video_context;
}
void gfx_ctx_swap_buffers(void *data)
{
const gfx_ctx_driver_t *ctx = gfx_ctx_get_ptr();
if (ctx->swap_buffers)
ctx->swap_buffers(data);
}
bool gfx_ctx_focus(void *data)
{
const gfx_ctx_driver_t *ctx = gfx_ctx_get_ptr();
if (data && ctx && ctx->has_focus)
return ctx->has_focus(data);
return false;
}
void gfx_ctx_set_video_mode(void *data,
unsigned width, unsigned height,
bool fullscreen)
{
const gfx_ctx_driver_t *ctx = gfx_ctx_get_ptr();
if (ctx && ctx->set_video_mode)
ctx->set_video_mode(data, width, height, fullscreen);
}
void gfx_ctx_translate_aspect(void *data, float *aspect,
unsigned width, unsigned height)
{
const gfx_ctx_driver_t *ctx = gfx_ctx_get_ptr();
if (ctx && ctx->translate_aspect)
*aspect = ctx->translate_aspect(data, width, height);
}
bool gfx_ctx_get_metrics(enum display_metric_types type, float *value)
{
driver_t *driver = driver_get_ptr();
const gfx_ctx_driver_t *ctx = gfx_ctx_get_ptr();
if (!ctx || !driver)
return false;
return ctx->get_metrics(driver->video_context_data, type,
value);
}
/**
* find_gfx_ctx_driver_index:
* @ident : Identifier of resampler driver to find.

View File

@ -40,6 +40,14 @@ enum gfx_ctx_api
GFX_CTX_DIRECT3D9_API,
GFX_CTX_OPENVG_API
};
enum display_metric_types
{
DISPLAY_METRIC_NONE = 0,
DISPLAY_METRIC_MM_WIDTH,
DISPLAY_METRIC_MM_HEIGHT,
DISPLAY_METRIC_DPI,
};
typedef void (*gfx_ctx_proc_t)(void);
@ -76,6 +84,9 @@ typedef struct gfx_ctx_driver
void (*get_video_output_next)(void*);
bool (*get_metrics)(void *data, enum display_metric_types type,
float *value);
/* Translates a window size to an aspect ratio.
* In most cases this will be just width / height, but
* some contexts will better know which actual aspect ratio is used.
@ -189,6 +200,21 @@ void find_next_context_driver(void);
**/
void find_prev_gfx_context_driver(void);
const gfx_ctx_driver_t *gfx_ctx_get_ptr(void);
bool gfx_ctx_get_metrics(enum display_metric_types type, float *value);
void gfx_ctx_translate_aspect(void *data, float *aspect,
unsigned width, unsigned height);
void gfx_ctx_set_video_mode(void *data,
unsigned width, unsigned height,
bool fullscreen);
void gfx_ctx_swap_buffers(void *data);
bool gfx_ctx_focus(void *data);
#ifdef __cplusplus
}
#endif

View File

@ -20,7 +20,7 @@
#include "video_thread_wrapper.h"
#ifdef HAVE_OPENGL
#include "gl_common.h"
#include "drivers/gl_common.h"
static void video_texture_png_load_gl(struct texture_image *ti,
enum texture_filter_type filter_type,

View File

@ -86,9 +86,8 @@ CHEATS
/*============================================================
UI COMMON CONTEXT
============================================================ */
#if defined(_WIN32) && !defined(_XBOX)
#include "../gfx/drivers_wm/win32_common.c"
#include "../gfx/drivers_wm/win32_dwm_common.c"
#if defined(_WIN32)
#include "../gfx/common/win32_common.c"
#endif
/*============================================================
@ -135,7 +134,7 @@ VIDEO CONTEXT
#endif
#ifdef HAVE_X11
#include "../gfx/drivers_wm/x11_common.c"
#include "../gfx/common/x11_common.c"
#endif
@ -206,7 +205,7 @@ VIDEO DRIVER
#ifdef HAVE_OPENGL
#include "../gfx/drivers/gl.c"
#include "../gfx/gl_common.c"
#include "../gfx/drivers/gl_common.c"
#ifndef HAVE_PSGL
#include "../libretro-common/glsym/rglgen.c"
@ -562,6 +561,7 @@ FILTERS
/*============================================================
DYNAMIC
============================================================ */
#include "../dylib.c"
#include "../dynamic.c"
#include "../dynamic_dummy.c"
#include "../gfx/video_filter.c"

View File

@ -1 +1,49 @@
/* RetroArch - A frontend for libretro.
* Copyright (C) 2011-2015 - Daniel De Matteis
* Copyright (C) 2014-2015 - Ali Bouhlel
*
* RetroArch is free software: you can redistribute it and/or modify it under the terms
* of the GNU General Public License as published by the Free Software Found-
* ation, either version 3 of the License, or (at your option) any later version.
*
* RetroArch is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
* PURPOSE. See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along with RetroArch.
* If not, see <http://www.gnu.org/licenses/>.
*/
#include "builtin.h"
#define CTRINPUT_DEFAULT_BINDS \
DECL_BTN(a, 8) \
DECL_BTN(b, 0) \
DECL_BTN(x, 9) \
DECL_BTN(y, 1) \
DECL_BTN(start, 3) \
DECL_BTN(select, 2) \
DECL_BTN(up, 4) \
DECL_BTN(down, 5) \
DECL_BTN(left, 6) \
DECL_BTN(right, 7) \
DECL_BTN(l, 10) \
DECL_BTN(r, 11) \
DECL_BTN(l2, 12) \
DECL_BTN(r2, 13) \
DECL_AXIS(l_x_plus, +0) \
DECL_AXIS(l_x_minus, -0) \
DECL_AXIS(l_y_plus, +1) \
DECL_AXIS(l_y_minus, -1) \
DECL_AXIS(r_x_plus, +2) \
DECL_AXIS(r_x_minus, -2) \
DECL_AXIS(r_y_plus, -3) \
DECL_AXIS(r_y_minus, +3)
const char* const input_builtin_autoconfs[] =
{
DECL_AUTOCONF_DEVICE("3DS Controller", "ctr", CTRINPUT_DEFAULT_BINDS),
NULL
};

View File

@ -13,68 +13,35 @@
* If not, see <http://www.gnu.org/licenses/>.
*/
#include "3ds.h"
#include <stdint.h>
#include <stdlib.h>
#include "../../general.h"
#include "../../driver.h"
#include "retroarch.h"
#include "../../libretro.h"
#include "../../general.h"
#include "../input_common.h"
#include "../input_joypad.h"
static uint32_t kDown;
static int16_t pad_state;
#define MAX_PADS 1
static void *ctr_input_init(void)
typedef struct ctr_input
{
return (void*)-1;
}
const rarch_joypad_driver_t *joypad;
} ctr_input_t;
static void ctr_input_poll(void *data)
{
(void)data;
global_t *global = global_get_ptr();
uint64_t *lifecycle_state = (uint64_t*)&global->lifecycle_state;
hidScanInput();
kDown = hidKeysHeld();
pad_state = 0;
pad_state |= (kDown & KEY_DLEFT) ? (1ULL << RETRO_DEVICE_ID_JOYPAD_LEFT) : 0;
pad_state |= (kDown & KEY_DDOWN) ? (1ULL << RETRO_DEVICE_ID_JOYPAD_DOWN) : 0;
pad_state |= (kDown & KEY_DRIGHT) ? (1ULL << RETRO_DEVICE_ID_JOYPAD_RIGHT) : 0;
pad_state |= (kDown & KEY_DUP) ? (1ULL << RETRO_DEVICE_ID_JOYPAD_UP) : 0;
pad_state |= (kDown & KEY_START) ? (1ULL << RETRO_DEVICE_ID_JOYPAD_START) : 0;
pad_state |= (kDown & KEY_SELECT) ? (1ULL << RETRO_DEVICE_ID_JOYPAD_SELECT) : 0;
pad_state |= (kDown & KEY_X) ? (1ULL << RETRO_DEVICE_ID_JOYPAD_X) : 0;
pad_state |= (kDown & KEY_Y) ? (1ULL << RETRO_DEVICE_ID_JOYPAD_Y) : 0;
pad_state |= (kDown & KEY_B) ? (1ULL << RETRO_DEVICE_ID_JOYPAD_B) : 0;
pad_state |= (kDown & KEY_A) ? (1ULL << RETRO_DEVICE_ID_JOYPAD_A) : 0;
pad_state |= (kDown & KEY_R) ? (1ULL << RETRO_DEVICE_ID_JOYPAD_R) : 0;
pad_state |= (kDown & KEY_L) ? (1ULL << RETRO_DEVICE_ID_JOYPAD_L) : 0;
*lifecycle_state &= ~((1ULL << RARCH_MENU_TOGGLE));
if(kDown & KEY_TOUCH)
*lifecycle_state |= (1ULL << RARCH_MENU_TOGGLE);
/* panic button */
if((kDown & KEY_START) &&
(kDown & KEY_SELECT) &&
(kDown & KEY_L) &&
(kDown & KEY_R))
rarch_main_command(RARCH_CMD_QUIT);
{
ctr_input_t *ctr = (ctr_input_t*)data;
if (ctr->joypad)
ctr->joypad->poll();
}
static int16_t ctr_input_state(void *data,
const struct retro_keybind **retro_keybinds, unsigned port,
unsigned device, unsigned idx, unsigned id)
static int16_t ctr_input_state(void *data, const struct retro_keybind **binds,
unsigned port, unsigned device,
unsigned idx, unsigned id)
{
(void)data;
(void)retro_keybinds;
(void)port;
(void)device;
(void)idx;
(void)id;
ctr_input_t *ctr = (ctr_input_t*)data;
if (port > 0)
return 0;
@ -82,42 +49,59 @@ static int16_t ctr_input_state(void *data,
switch (device)
{
case RETRO_DEVICE_JOYPAD:
return pad_state;
return input_joypad_pressed(ctr->joypad, port, binds[port], id);
case RETRO_DEVICE_ANALOG:
return 0;
return input_joypad_analog(ctr->joypad, port, idx, id, binds[port]);
}
return 0;
}
static bool ctr_input_key_pressed(void *data, int key)
{
(void)data;
global_t *global = global_get_ptr();
return (global->lifecycle_state & (1ULL << key))||
(pad_state & (1ULL << key));
}
static void ctr_input_free_input(void *data)
{
(void)data;
ctr_input_t *ctr = (ctr_input_t*)data;
if (ctr && ctr->joypad)
ctr->joypad->destroy();
free(data);
}
static void* ctr_input_initialize(void)
{
settings_t *settings = config_get_ptr();
ctr_input_t *ctr = (ctr_input_t*)calloc(1, sizeof(*ctr));
if (!ctr)
return NULL;
ctr->joypad = input_joypad_init_driver(settings->input.joypad_driver);
return ctr;
}
static bool ctr_input_key_pressed(void *data, int key)
{
settings_t *settings = config_get_ptr();
global_t *global = global_get_ptr();
ctr_input_t *ctr = (ctr_input_t*)data;
return (global->lifecycle_state & (1ULL << key)) ||
input_joypad_pressed(ctr->joypad, 0, settings->input.binds[0], key);
}
static uint64_t ctr_input_get_capabilities(void *data)
{
uint64_t caps = 0;
(void)data;
caps |= (1 << RETRO_DEVICE_JOYPAD);
return caps;
return (1 << RETRO_DEVICE_JOYPAD) | (1 << RETRO_DEVICE_ANALOG);
}
static bool ctr_input_set_sensor_state(void *data,
unsigned port, enum retro_sensor_action action, unsigned event_rate)
static const rarch_joypad_driver_t *ctr_input_get_joypad_driver(void *data)
{
return false;
ctr_input_t *ctr = (ctr_input_t*)data;
if (ctr)
return ctr->joypad;
return NULL;
}
static void ctr_input_grab_mouse(void *data, bool state)
@ -138,15 +122,16 @@ static bool ctr_input_set_rumble(void *data, unsigned port,
}
input_driver_t input_ctr = {
ctr_input_init,
ctr_input_initialize,
ctr_input_poll,
ctr_input_state,
ctr_input_key_pressed,
ctr_input_free_input,
ctr_input_set_sensor_state,
NULL,
NULL,
ctr_input_get_capabilities,
"ctr",
ctr_input_grab_mouse,
ctr_input_set_rumble,
ctr_input_get_joypad_driver,
};

View File

@ -1,7 +1,6 @@
/* RetroArch - A frontend for libretro.
* Copyright (C) 2010-2014 - Hans-Kristian Arntzen
* Copyright (C) 2011-2015 - Daniel De Matteis
*
* Copyright (C) 2013-2014 - Jason Fetters
*
* 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.
@ -14,23 +13,14 @@
* If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef __WIN32_DWM_COMMON_H
#define __WIN32_DWM_COMMON_H
#ifndef __APPLE_RARCH_GAMECONTROLLER_H__
#define __APPLE_RARCH_GAMECONTROLLER_H__
#ifdef __cplusplus
extern "C" {
#endif
#include "../../input/connect/joypad_connection.h"
#include <stddef.h>
#include <stdint.h>
#include <boolean.h>
joypad_connection_t *slots;
#ifdef _WIN32
void gfx_set_dwm(void);
#endif
#ifdef __cplusplus
}
#endif
void apple_gamecontroller_init(void);
void apple_gamecontroller_poll_all(void);
#endif

178
input/drivers_hid/mfi_hid.m Normal file
View File

@ -0,0 +1,178 @@
/* RetroArch - A frontend for libretro.
* Copyright (C) 2013-2014 - Jason Fetters
*
* RetroArch is free software: you can redistribute it and/or modify it under the terms
* of the GNU General Public License as published by the Free Software Found-
* ation, either version 3 of the License, or (at your option) any later version.
*
* RetroArch is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
* PURPOSE. See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along with RetroArch.
* If not, see <http://www.gnu.org/licenses/>.
*/
#include <AvailabilityMacros.h>
#import <GameController/GameController.h>
#include "mfi_hid.h"
#include "../../input/drivers/apple_input.h"
enum
{
GCCONTROLLER_PLAYER_INDEX_UNSET = -1,
};
static BOOL apple_gamecontroller_available(void)
{
if (get_ios_version_major() <= 6)
return false;
/* by checking for extern symbols defined by the framework, we can check for its
* existence at runtime. This is the Apple endorsed way of dealing with this */
#ifdef __IPHONE_7_0
return (&GCControllerDidConnectNotification && &GCControllerDidDisconnectNotification);
#else
return false;
#endif
}
static void apple_gamecontroller_poll(GCController *controller)
{
uint32_t slot, pause;
driver_t *driver = driver_get_ptr();
apple_input_data_t *apple = (apple_input_data_t*)driver->input_data;
if (!apple || !controller || controller.playerIndex == MAX_USERS)
return;
slot = (uint32_t)controller.playerIndex;
/* retain the start (pause) value */
pause = apple->buttons[slot] & (1 << RETRO_DEVICE_ID_JOYPAD_START);
apple->buttons[slot] = 0;
memset(apple->axes[slot], 0, sizeof(apple->axes[0]));
apple->buttons[slot] |= pause;
if (controller.extendedGamepad)
{
GCExtendedGamepad *gp = (GCExtendedGamepad *)controller.extendedGamepad;
apple->buttons[slot] |= gp.dpad.up.pressed ? (1 << RETRO_DEVICE_ID_JOYPAD_UP) : 0;
apple->buttons[slot] |= gp.dpad.down.pressed ? (1 << RETRO_DEVICE_ID_JOYPAD_DOWN) : 0;
apple->buttons[slot] |= gp.dpad.left.pressed ? (1 << RETRO_DEVICE_ID_JOYPAD_LEFT) : 0;
apple->buttons[slot] |= gp.dpad.right.pressed ? (1 << RETRO_DEVICE_ID_JOYPAD_RIGHT) : 0;
apple->buttons[slot] |= gp.buttonA.pressed ? (1 << RETRO_DEVICE_ID_JOYPAD_B) : 0;
apple->buttons[slot] |= gp.buttonB.pressed ? (1 << RETRO_DEVICE_ID_JOYPAD_A) : 0;
apple->buttons[slot] |= gp.buttonX.pressed ? (1 << RETRO_DEVICE_ID_JOYPAD_Y) : 0;
apple->buttons[slot] |= gp.buttonY.pressed ? (1 << RETRO_DEVICE_ID_JOYPAD_X) : 0;
apple->buttons[slot] |= gp.leftShoulder.pressed ? (1 << RETRO_DEVICE_ID_JOYPAD_L) : 0;
apple->buttons[slot] |= gp.rightShoulder.pressed ? (1 << RETRO_DEVICE_ID_JOYPAD_R) : 0;
apple->buttons[slot] |= gp.leftTrigger.pressed ? (1 << RETRO_DEVICE_ID_JOYPAD_L2) : 0;
apple->buttons[slot] |= gp.rightTrigger.pressed ? (1 << RETRO_DEVICE_ID_JOYPAD_R2) : 0;
apple->axes[slot][0] = gp.leftThumbstick.xAxis.value * 32767.0f;
apple->axes[slot][1] = gp.leftThumbstick.yAxis.value * 32767.0f;
apple->axes[slot][2] = gp.rightThumbstick.xAxis.value * 32767.0f;
apple->axes[slot][3] = gp.rightThumbstick.yAxis.value * 32767.0f;
}
else if (controller.gamepad)
{
GCGamepad *gp = (GCGamepad *)controller.gamepad;
apple->buttons[slot] |= gp.dpad.up.pressed ? (1 << RETRO_DEVICE_ID_JOYPAD_UP) : 0;
apple->buttons[slot] |= gp.dpad.down.pressed ? (1 << RETRO_DEVICE_ID_JOYPAD_DOWN) : 0;
apple->buttons[slot] |= gp.dpad.left.pressed ? (1 << RETRO_DEVICE_ID_JOYPAD_LEFT) : 0;
apple->buttons[slot] |= gp.dpad.right.pressed ? (1 << RETRO_DEVICE_ID_JOYPAD_RIGHT) : 0;
apple->buttons[slot] |= gp.buttonA.pressed ? (1 << RETRO_DEVICE_ID_JOYPAD_B) : 0;
apple->buttons[slot] |= gp.buttonB.pressed ? (1 << RETRO_DEVICE_ID_JOYPAD_A) : 0;
apple->buttons[slot] |= gp.buttonX.pressed ? (1 << RETRO_DEVICE_ID_JOYPAD_Y) : 0;
apple->buttons[slot] |= gp.buttonY.pressed ? (1 << RETRO_DEVICE_ID_JOYPAD_X) : 0;
apple->buttons[slot] |= gp.leftShoulder.pressed ? (1 << RETRO_DEVICE_ID_JOYPAD_L) : 0;
apple->buttons[slot] |= gp.rightShoulder.pressed ? (1 << RETRO_DEVICE_ID_JOYPAD_R) : 0;
}
}
void apple_gamecontroller_poll_all(void)
{
if (!apple_gamecontroller_available())
return;
for (GCController *controller in [GCController controllers])
apple_gamecontroller_poll(controller);
}
static void apple_gamecontroller_register(GCGamepad *gamepad)
{
driver_t *driver = driver_get_ptr();
apple_input_data_t *apple = (apple_input_data_t*)driver->input_data;
gamepad.valueChangedHandler = ^(GCGamepad *updateGamepad, GCControllerElement *element) {
apple_gamecontroller_poll(updateGamepad.controller);
};
gamepad.controller.controllerPausedHandler = ^(GCController *controller) {
uint32_t slot = (uint32_t)controller.playerIndex;
apple->buttons[slot] |= (1 << RETRO_DEVICE_ID_JOYPAD_START);
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.1 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
apple->buttons[slot] &= ~(1 << RETRO_DEVICE_ID_JOYPAD_START);
});
};
}
static int32_t apple_joypad_connect_gcapi(joypad_connection_t *joyconn)
{
int pad = pad_connection_find_vacant_pad(joyconn);
if (pad >= 0 && pad < MAX_USERS)
{
joypad_connection_t *s = (joypad_connection_t*)&joyconn[pad];
if (s)
s->connected = true;
}
return pad;
}
static void apple_gamecontroller_connect(GCController *controller)
{
int32_t slot = apple_joypad_connect_gcapi(slots);
controller.playerIndex = (slot >= 0 && slot < MAX_USERS) ? slot : GCCONTROLLER_PLAYER_INDEX_UNSET;
if (controller.playerIndex == GCControllerPlayerIndexUnset)
return;
apple_gamecontroller_register(controller.gamepad);
}
static void apple_gamecontroller_disconnect(GCController* controller)
{
unsigned pad = (uint32_t)controller.playerIndex;
if (pad == GCCONTROLLER_PLAYER_INDEX_UNSET)
return;
pad_connection_pad_deinit(&slots[pad], pad);
}
void apple_gamecontroller_init(void)
{
if (!apple_gamecontroller_available())
return;
#ifdef __IPHONE_7_0
[[NSNotificationCenter defaultCenter] addObserverForName:GCControllerDidConnectNotification
object:nil
queue:[NSOperationQueue mainQueue]
usingBlock:^(NSNotification *note) {
apple_gamecontroller_connect([note object]);
}];
[[NSNotificationCenter defaultCenter] addObserverForName:GCControllerDidDisconnectNotification
object:nil
queue:[NSOperationQueue mainQueue]
usingBlock:^(NSNotification *note) {
apple_gamecontroller_disconnect([note object]);
} ];
#endif
}

View File

@ -1,7 +1,6 @@
/* RetroArch - A frontend for libretro.
* Copyright (C) 2010-2014 - Hans-Kristian Arntzen
* Copyright (C) 2011-2015 - Daniel De Matteis
* Copyright (C) 2013-2014 - CatalystG
* Copyright (C) 2014-2015 - Ali Bouhlel
*
* 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-
@ -15,43 +14,164 @@
* If not, see <http://www.gnu.org/licenses/>.
*/
#include <stdint.h>
#include <stddef.h>
#include <boolean.h>
#include "../input_joypad_driver.h"
#include "../input_autodetect.h"
#include "../../general.h"
#include "../../driver.h"
#include "../../configuration.h"
#include "../../retroarch.h"
#include "string.h"
#include "3ds.h"
#ifndef MAX_PADS
#define MAX_PADS 1
#endif
static uint64_t pad_state;
static int16_t analog_state[1][2][2];
static const char *ctr_joypad_name(unsigned pad)
{
return "ctr";
return "3DS Controller";
}
static void ctr_joypad_autodetect_add(unsigned autoconf_pad)
{
settings_t *settings = config_get_ptr();
autoconfig_params_t params = {{0}};
strlcpy(settings->input.device_names[autoconf_pad],
ctr_joypad_name(autoconf_pad),
sizeof(settings->input.device_names[autoconf_pad]));
/* TODO - implement VID/PID? */
params.idx = autoconf_pad;
strlcpy(params.name, ctr_joypad_name(autoconf_pad), sizeof(params.name));
strlcpy(params.driver, ctr_joypad.ident, sizeof(params.driver));
input_config_autoconfigure_joypad(&params);
}
static bool ctr_joypad_init(void)
{
ctr_joypad_autodetect_add(0);
return true;
}
static bool ctr_joypad_button(unsigned port_num, uint16_t joykey)
{
return false;
if (port_num >= MAX_PADS)
return false;
return (pad_state & (1ULL << joykey));
}
static uint64_t ctr_joypad_get_buttons(unsigned port_num)
{
return 0;
return pad_state;
}
static int16_t ctr_joypad_axis(unsigned port_num, uint32_t joyaxis)
{
return 0;
int val = 0;
int axis = -1;
bool is_neg = false;
bool is_pos = false;
if (joyaxis == AXIS_NONE || port_num >= MAX_PADS)
return 0;
if (AXIS_NEG_GET(joyaxis) < 4)
{
axis = AXIS_NEG_GET(joyaxis);
is_neg = true;
}
else if (AXIS_POS_GET(joyaxis) < 4)
{
axis = AXIS_POS_GET(joyaxis);
is_pos = true;
}
switch (axis)
{
case 0:
val = analog_state[port_num][0][0];
break;
case 1:
val = analog_state[port_num][0][1];
break;
case 2:
val = analog_state[port_num][1][0];
break;
case 3:
val = analog_state[port_num][1][1];
break;
}
if (is_neg && val > 0)
val = 0;
else if (is_pos && val < 0)
val = 0;
return val;
}
static void ctr_joypad_poll(void)
{
int32_t ret;
uint32_t state_tmp;
circlePosition state_tmp_analog;
global_t *global = global_get_ptr();
uint64_t *lifecycle_state = (uint64_t*)&global->lifecycle_state;
hidScanInput();
state_tmp = hidKeysHeld();
hidCircleRead(&state_tmp_analog);
analog_state[0][0][0] = analog_state[0][0][1] =
analog_state[0][1][0] = analog_state[0][1][1] = 0;
pad_state = 0;
pad_state |= (state_tmp & KEY_DLEFT) ? (1ULL << RETRO_DEVICE_ID_JOYPAD_LEFT) : 0;
pad_state |= (state_tmp & KEY_DDOWN) ? (1ULL << RETRO_DEVICE_ID_JOYPAD_DOWN) : 0;
pad_state |= (state_tmp & KEY_DRIGHT) ? (1ULL << RETRO_DEVICE_ID_JOYPAD_RIGHT) : 0;
pad_state |= (state_tmp & KEY_DUP) ? (1ULL << RETRO_DEVICE_ID_JOYPAD_UP) : 0;
pad_state |= (state_tmp & KEY_START) ? (1ULL << RETRO_DEVICE_ID_JOYPAD_START) : 0;
pad_state |= (state_tmp & KEY_SELECT) ? (1ULL << RETRO_DEVICE_ID_JOYPAD_SELECT) : 0;
pad_state |= (state_tmp & KEY_X) ? (1ULL << RETRO_DEVICE_ID_JOYPAD_X) : 0;
pad_state |= (state_tmp & KEY_Y) ? (1ULL << RETRO_DEVICE_ID_JOYPAD_Y) : 0;
pad_state |= (state_tmp & KEY_B) ? (1ULL << RETRO_DEVICE_ID_JOYPAD_B) : 0;
pad_state |= (state_tmp & KEY_A) ? (1ULL << RETRO_DEVICE_ID_JOYPAD_A) : 0;
pad_state |= (state_tmp & KEY_R) ? (1ULL << RETRO_DEVICE_ID_JOYPAD_R) : 0;
pad_state |= (state_tmp & KEY_L) ? (1ULL << RETRO_DEVICE_ID_JOYPAD_L) : 0;
analog_state[0][RETRO_DEVICE_INDEX_ANALOG_LEFT] [RETRO_DEVICE_ID_ANALOG_X] = (state_tmp_analog.dx * 200);
analog_state[0][RETRO_DEVICE_INDEX_ANALOG_LEFT] [RETRO_DEVICE_ID_ANALOG_Y] = -(state_tmp_analog.dy * 200);
for (int i = 0; i < 2; i++)
for (int j = 0; j < 2; j++)
if (analog_state[0][i][j] == -0x8000)
analog_state[0][i][j] = -0x7fff;
*lifecycle_state &= ~((1ULL << RARCH_MENU_TOGGLE));
if(state_tmp & KEY_TOUCH)
*lifecycle_state |= (1ULL << RARCH_MENU_TOGGLE);
/* panic button */
if((state_tmp & KEY_START) &&
(state_tmp & KEY_SELECT) &&
(state_tmp & KEY_L) &&
(state_tmp & KEY_R))
rarch_main_command(RARCH_CMD_QUIT);
}
static bool ctr_joypad_query_pad(unsigned pad)
{
return true;
/* FIXME */
return pad < MAX_USERS && pad_state;
}

View File

@ -24,6 +24,7 @@
#include "../input_autodetect.h"
#include "../input_common.h"
#include "../../dynamic.h"
#include "../../general.h"
#include <boolean.h>
@ -103,7 +104,7 @@ extern bool g_xinput_block_pads;
/* For xinput1_n.dll */
static HINSTANCE g_xinput_dll;
/* Function pointer, to be assigned with GetProcAddress */
/* Function pointer, to be assigned with dylib_proc */
typedef uint32_t (__stdcall *XInputGetStateEx_t)(uint32_t, XINPUT_STATE*);
static XInputGetStateEx_t g_XInputGetStateEx;
@ -164,15 +165,15 @@ static bool xinput_joypad_init(void)
* wrapper DLL (such as x360ce); support these by checking
* the working directory first.
*
* No need to check for existance as we will be checking LoadLibrary's
* No need to check for existance as we will be checking dylib_load's
* success anyway.
*/
/* Using dylib_* complicates building joyconfig. */
g_xinput_dll = LoadLibrary("xinput1_4.dll");
g_xinput_dll = (HINSTANCE)dylib_load("xinput1_4.dll");
if (!g_xinput_dll)
{
g_xinput_dll = LoadLibrary("xinput1_3.dll");
g_xinput_dll = (HINSTANCE)dylib_load("xinput1_3.dll");
version = "1.3";
}
@ -187,7 +188,7 @@ static bool xinput_joypad_init(void)
/* If we get here then an xinput DLL is correctly loaded.
* First try to load ordinal 100 (XInputGetStateEx).
*/
g_XInputGetStateEx = (XInputGetStateEx_t) GetProcAddress(g_xinput_dll, (const char*)100);
g_XInputGetStateEx = (XInputGetStateEx_t)dylib_proc(g_xinput_dll, (const char*)100);
g_xinput_guide_button_supported = true;
if (!g_XInputGetStateEx)
@ -196,22 +197,22 @@ static bool xinput_joypad_init(void)
* XInputGetState, at the cost of losing guide button support.
*/
g_xinput_guide_button_supported = false;
g_XInputGetStateEx = (XInputGetStateEx_t) GetProcAddress(g_xinput_dll, "XInputGetState");
g_XInputGetStateEx = (XInputGetStateEx_t)dylib_proc(g_xinput_dll, "XInputGetState");
if (!g_XInputGetStateEx)
{
RARCH_ERR("Failed to init XInput: DLL is invalid or corrupt.\n");
FreeLibrary(g_xinput_dll);
dylib_close(g_xinput_dll);
return false; /* DLL was loaded but did not contain the correct function. */
}
RARCH_WARN("XInput: No guide button support.\n");
}
g_XInputSetState = (XInputSetState_t) GetProcAddress(g_xinput_dll, "XInputSetState");
g_XInputSetState = (XInputSetState_t)dylib_proc(g_xinput_dll, "XInputSetState");
if (!g_XInputSetState)
{
RARCH_ERR("Failed to init XInput: DLL is invalid or corrupt.\n");
FreeLibrary(g_xinput_dll);
dylib_close(g_xinput_dll);
return false; /* DLL was loaded but did not contain the correct function. */
}
@ -279,13 +280,14 @@ static void xinput_joypad_destroy(void)
for (i = 0; i < 4; ++i)
memset(&g_xinput_states[i], 0, sizeof(xinput_joypad_state));
FreeLibrary(g_xinput_dll);
dylib_close(g_xinput_dll);
g_xinput_dll = NULL;
g_XInputGetStateEx = NULL;
g_XInputSetState = NULL;
g_xinput_dll = NULL;
g_XInputGetStateEx = NULL;
g_XInputSetState = NULL;
dinput_joypad.destroy();
g_xinput_block_pads = false;
}

View File

@ -16,7 +16,7 @@
#include "../../general.h"
#include "../keyboard_line.h"
#include "../../gfx/drivers_wm/win32_common.h"
#include "../../gfx/common/win32_common.h"
#include "../input_common.h"
#include "../input_keymaps.h"

View File

@ -24,7 +24,7 @@
#include "../menu.h"
#include <file/file_path.h>
#include "../../gfx/gl_common.h"
#include "../../gfx/drivers/gl_common.h"
#include "../../gfx/font_driver.h"
#include "../../gfx/video_texture.h"
#include <compat/posix_string.h>
@ -54,10 +54,10 @@ typedef struct glui_handle
static int glui_entry_iterate(unsigned action)
{
const char *label = NULL;
const char *label = NULL;
menu_file_list_cbs_t *cbs = NULL;
menu_handle_t *menu = menu_driver_get_ptr();
runloop_t *runloop = rarch_main_get_ptr();
menu_handle_t *menu = menu_driver_get_ptr();
runloop_t *runloop = rarch_main_get_ptr();
if (!menu || !runloop)
return -1;
@ -84,8 +84,6 @@ static void glui_blit_line(gl_t *gl, float x, float y, const char *message, uint
{
struct font_params params = {0};
/* gl_set_viewport(gl, gl->win_width, gl->win_height, false, false); */
params.x = x / gl->win_width;
params.y = 1.0f - y / gl->win_height;
params.scale = 1.0;

View File

@ -66,9 +66,9 @@ static bool menu_texture_inited =false;
static int rmenu_entry_iterate(unsigned action)
{
const char *label = NULL;
const char *label = NULL;
menu_file_list_cbs_t *cbs = NULL;
menu_handle_t *menu = menu_driver_get_ptr();
menu_handle_t *menu = menu_driver_get_ptr();
if (!menu)
return -1;
@ -261,9 +261,6 @@ static void rmenu_render(void)
snprintf(message, sizeof(message), "%c %s",
selected ? '>' : ' ', entry_title_buf);
#if 0
blit_line(x, y, message, selected);
#endif
font_parms.x = POSITION_EDGE_MIN + POSITION_OFFSET;
font_parms.y = POSITION_EDGE_MIN + POSITION_RENDER_OFFSET
+ (POSITION_OFFSET * j);

View File

@ -25,7 +25,7 @@
#include <file/file_path.h>
#include "../../gfx/video_thread_wrapper.h"
#include "../../gfx/gl_common.h"
#include "../../gfx/drivers/gl_common.h"
#include "../../gfx/font_driver.h"
#include "../../gfx/video_texture.h"
#include <compat/posix_string.h>
@ -400,8 +400,6 @@ static void xmb_draw_text(gl_t *gl, xmb_handle_t *xmb, const char *str, float x,
|| y < -xmb->icon.size || y > gl->win_height + xmb->icon.size)
return;
/* gl_set_viewport(gl, gl->win_width, gl->win_height, false, false); */
params.x = x / gl->win_width;
params.y = 1.0f - y / gl->win_height;

View File

@ -196,7 +196,7 @@ retro_perf_tick_t rarch_get_perf_counter(void)
#elif defined(PSP)
sceRtcGetCurrentTick(&time_ticks);
#elif defined(_3DS)
time_ticks = osGetTime();
time_ticks = svcGetSystemTick();
#elif defined(__mips__)
struct timeval tv;
gettimeofday(&tv,NULL);

View File

@ -16,6 +16,8 @@
#include "retroarch-joyconfig.c"
#include "../dylib.c"
#if defined(__linux) && !defined(ANDROID)
#include "../input/drivers/linuxraw_input.c"
#include "../input/drivers_joypad/linuxraw_joypad.c"