From 0ac6fee02a38ccb01d802d1af63db075d2d635c6 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Sat, 10 Jan 2015 16:46:58 +0100 Subject: [PATCH 001/156] (Fonts) Cleanups; declare variables at top of functions --- gfx/fonts/bitmapfont.c | 18 +- gfx/fonts/coretext.c | 308 ++++++++++++++++++-------------- gfx/fonts/d3d_font.c | 1 + gfx/fonts/d3d_w32_font.cpp | 49 +++--- gfx/fonts/fonts.c | 2 + gfx/fonts/freetype.c | 11 +- gfx/fonts/gl_raster_font.c | 79 +++++---- gfx/fonts/ps_libdbgfont.c | 6 +- gfx/fonts/xdk1_xfonts.c | 2 +- gfx/fonts/xdk360_fonts.cpp | 348 +++++++++++++++++++------------------ 10 files changed, 464 insertions(+), 360 deletions(-) diff --git a/gfx/fonts/bitmapfont.c b/gfx/fonts/bitmapfont.c index de1a3b8fc6..b301518ecd 100644 --- a/gfx/fonts/bitmapfont.c +++ b/gfx/fonts/bitmapfont.c @@ -35,6 +35,8 @@ typedef struct bm_renderer static const struct font_atlas *font_renderer_bmp_get_atlas(void *data) { bm_renderer_t *handle = (bm_renderer_t*)data; + if (!handle) + return NULL; return &handle->atlas; } @@ -42,6 +44,8 @@ static const struct font_glyph *font_renderer_bmp_get_glyph( void *data, uint32_t code) { bm_renderer_t *handle = (bm_renderer_t*)data; + if (!handle) + return NULL; return code < ATLAS_SIZE ? &handle->glyphs[code] : NULL; } @@ -57,11 +61,11 @@ static void char_to_texture(bm_renderer_t *handle, uint8_t letter, for (x = 0; x < FONT_WIDTH; x++) { unsigned font_pixel = x + y * FONT_WIDTH; - uint8_t rem = 1 << (font_pixel & 7); - unsigned offset = font_pixel >> 3; - uint8_t col = (bitmap_bin[FONT_OFFSET(letter) + offset] & rem) ? 0xff : 0; + uint8_t rem = 1 << (font_pixel & 7); + unsigned offset = font_pixel >> 3; + uint8_t col = (bitmap_bin[FONT_OFFSET(letter) + offset] & rem) ? 0xff : 0; + uint8_t *dst = target; - uint8_t *dst = target; dst += x * handle->scale_factor; dst += y * handle->scale_factor * handle->atlas.width; @@ -74,13 +78,14 @@ static void char_to_texture(bm_renderer_t *handle, uint8_t letter, static void *font_renderer_bmp_init(const char *font_path, float font_size) { - (void)font_path; unsigned i; - bm_renderer_t *handle = (bm_renderer_t*)calloc(1, sizeof(*handle)); + if (!handle) return NULL; + (void)font_path; + handle->scale_factor = (unsigned)roundf(font_size / FONT_HEIGHT); if (!handle->scale_factor) handle->scale_factor = 1; @@ -93,6 +98,7 @@ static void *font_renderer_bmp_init(const char *font_path, float font_size) { unsigned x = (i % ATLAS_COLS) * handle->scale_factor * FONT_WIDTH; unsigned y = (i / ATLAS_COLS) * handle->scale_factor * FONT_HEIGHT; + char_to_texture(handle, i, x, y); handle->glyphs[i].width = FONT_WIDTH * handle->scale_factor; diff --git a/gfx/fonts/coretext.c b/gfx/fonts/coretext.c index a52521abfa..cfb0e7785e 100644 --- a/gfx/fonts/coretext.c +++ b/gfx/fonts/coretext.c @@ -40,19 +40,27 @@ typedef struct coretext_renderer static const struct font_atlas *font_renderer_ct_get_atlas(void *data) { font_renderer_t *handle = (font_renderer_t*)data; + if (!handle) + return NULL; return &handle->atlas; } static const struct font_glyph *font_renderer_ct_get_glyph(void *data, uint32_t code) { - font_renderer_t *handle = (font_renderer_t*)data; - struct font_glyph *result = code < CT_ATLAS_SIZE ? &handle->glyphs[code] : NULL; - return result; + struct font_glyph *result = NULL; + font_renderer_t *handle = (font_renderer_t*)data; + + if (!handle) + return NULL; + if (code >= CT_ATLAS_SIZE) + return NULL; + return &handle->glyphs[code]; } static void font_renderer_ct_free(void *data) { font_renderer_t *handle = (font_renderer_t*)data; + if (!handle) return; @@ -62,170 +70,218 @@ static void font_renderer_ct_free(void *data) static bool font_renderer_create_atlas(CTFontRef face, font_renderer_t *handle) { - unsigned i; - bool ret = true; + int max_width, max_height; + unsigned i; + size_t bytesPerRow; + CGGlyph glyphs[CT_ATLAS_SIZE]; + CGRect bounds[CT_ATLAS_SIZE]; + CGSize advances[CT_ATLAS_SIZE]; + CGFloat ascent, descent; + CGContextRef offscreen; + CFStringRef keys[] = { kCTFontAttributeName }; + CFDictionaryRef attr; + void *bitmapData = NULL; + bool ret = true; + size_t bitsPerComponent = 8; + UniChar characters[CT_ATLAS_SIZE] = {0}; + CFTypeRef values[] = { face }; - UniChar characters[CT_ATLAS_SIZE] = {0}; - for (i = 0; i < CT_ATLAS_SIZE; i++) { - characters[i] = (UniChar)i; - } + for (i = 0; i < CT_ATLAS_SIZE; i++) + characters[i] = (UniChar)i; - CGGlyph glyphs[CT_ATLAS_SIZE]; - CTFontGetGlyphsForCharacters(face, characters, glyphs, CT_ATLAS_SIZE); + CTFontGetGlyphsForCharacters(face, characters, glyphs, CT_ATLAS_SIZE); - CGRect bounds[CT_ATLAS_SIZE]; - CTFontGetBoundingRectsForGlyphs(face, kCTFontDefaultOrientation, - glyphs, bounds, CT_ATLAS_SIZE); + CTFontGetBoundingRectsForGlyphs(face, kCTFontDefaultOrientation, + glyphs, bounds, CT_ATLAS_SIZE); - CGSize advances[CT_ATLAS_SIZE]; - CTFontGetAdvancesForGlyphs(face, kCTFontDefaultOrientation, - glyphs, advances, CT_ATLAS_SIZE); + CTFontGetAdvancesForGlyphs(face, kCTFontDefaultOrientation, + glyphs, advances, CT_ATLAS_SIZE); - CGFloat ascent = CTFontGetAscent( face ); - CGFloat descent = CTFontGetDescent( face ); + ascent = CTFontGetAscent(face); + descent = CTFontGetDescent(face); - int max_width = 0; - int max_height = 0; - for (i = 0; i < CT_ATLAS_SIZE; i++) { - struct font_glyph *glyph = &handle->glyphs[i]; - int origin_x = ceil(bounds[i].origin.x); - int origin_y = ceil(bounds[i].origin.y); + max_width = 0; + max_height = 0; - glyph->draw_offset_x = 0; - glyph->draw_offset_y = -1 * (ascent - descent); - glyph->width = ceil(bounds[i].size.width); - glyph->height = ceil(bounds[i].size.height); - glyph->advance_x = ceil(advances[i].width); - glyph->advance_y = ceil(advances[i].height); + for (i = 0; i < CT_ATLAS_SIZE; i++) + { + int origin_x, origin_y; + struct font_glyph *glyph = &handle->glyphs[i]; - max_width = max(max_width, (origin_x + glyph->width)); - max_height = max(max_height, (origin_y + glyph->height)); - } - max_height = max(max_height, ceil(ascent+descent)); + if (!glyph) + continue; - handle->atlas.width = max_width * CT_ATLAS_COLS; - handle->atlas.height = max_height * CT_ATLAS_ROWS; + origin_x = ceil(bounds[i].origin.x); + origin_y = ceil(bounds[i].origin.y); - handle->atlas.buffer = (uint8_t*) - calloc(handle->atlas.width * handle->atlas.height, 1); + glyph->draw_offset_x = 0; + glyph->draw_offset_y = -1 * (ascent - descent); + glyph->width = ceil(bounds[i].size.width); + glyph->height = ceil(bounds[i].size.height); + glyph->advance_x = ceil(advances[i].width); + glyph->advance_y = ceil(advances[i].height); - if (!handle->atlas.buffer) { - ret = false; - goto end; - } + max_width = max(max_width, (origin_x + glyph->width)); + max_height = max(max_height, (origin_y + glyph->height)); + } - size_t bitsPerComponent = 8; - size_t bytesPerRow = max_width; - void *bitmapData = calloc(max_height, bytesPerRow); - CGContextRef offscreen = - CGBitmapContextCreate(bitmapData, max_width, max_height, - bitsPerComponent, bytesPerRow, NULL, kCGImageAlphaOnly); - CGContextSetTextMatrix(offscreen, CGAffineTransformIdentity); + max_height = max(max_height, ceil(ascent+descent)); - CFStringRef keys[] = { kCTFontAttributeName }; - CFTypeRef values[] = { face }; - CFDictionaryRef attr = - CFDictionaryCreate(NULL, (const void **)&keys, (const void **)&values, - sizeof(keys) / sizeof(keys[0]), - &kCFTypeDictionaryKeyCallBacks, - &kCFTypeDictionaryValueCallBacks); - - for (i = 0; i < CT_ATLAS_SIZE; i++) { - struct font_glyph *glyph = &handle->glyphs[i]; + handle->atlas.width = max_width * CT_ATLAS_COLS; + handle->atlas.height = max_height * CT_ATLAS_ROWS; - glyph->width = max_width; - glyph->height = max_height; + handle->atlas.buffer = (uint8_t*) + calloc(handle->atlas.width * handle->atlas.height, 1); - unsigned offset_x = (i % CT_ATLAS_COLS) * max_width; - unsigned offset_y = (i / CT_ATLAS_COLS) * max_height; + if (!handle->atlas.buffer) + { + ret = false; + goto end; + } - glyph->atlas_offset_x = offset_x; - glyph->atlas_offset_y = offset_y; + bytesPerRow = max_width; + bitmapData = calloc(max_height, bytesPerRow); + offscreen = CGBitmapContextCreate(bitmapData, max_width, max_height, + bitsPerComponent, bytesPerRow, NULL, kCGImageAlphaOnly); - char glyph_cstr[2]; - glyph_cstr[0] = i; - glyph_cstr[1] = 0; - CFStringRef glyph_cfstr = - CFStringCreateWithCString( NULL, glyph_cstr, kCFStringEncodingASCII ); - CFAttributedStringRef attrString = - CFAttributedStringCreate(NULL, glyph_cfstr, attr); - CFRelease(glyph_cfstr), glyph_cfstr = NULL; - CTLineRef line = CTLineCreateWithAttributedString(attrString); - CFRelease(attrString), attrString = NULL; + CGContextSetTextMatrix(offscreen, CGAffineTransformIdentity); - memset( bitmapData, 0, max_height * bytesPerRow ); - CGContextSetTextPosition(offscreen, 0, descent); - CTLineDraw(line, offscreen); - CGContextFlush( offscreen ); + attr = CFDictionaryCreate(NULL, (const void **)&keys, (const void **)&values, + sizeof(keys) / sizeof(keys[0]), &kCFTypeDictionaryKeyCallBacks, + &kCFTypeDictionaryValueCallBacks); - CFRelease( line ), line = NULL; + for (i = 0; i < CT_ATLAS_SIZE; i++) + { + char glyph_cstr[2]; + const uint8_t *src; + uint8_t *dst; + unsigned offset_x, offset_y, r, c; + CFStringRef glyph_cfstr; + CFAttributedStringRef attrString; + CTLineRef line; + struct font_glyph *glyph = &handle->glyphs[i]; + + if (!glyph) + continue; - uint8_t *dst = (uint8_t*)handle->atlas.buffer; + glyph->width = max_width; + glyph->height = max_height; - const uint8_t *src = (const uint8_t*)bitmapData; - for (unsigned r = 0; r < max_height; r++ ) { - for (unsigned c = 0; c < max_width; c++) { - unsigned src_idx = r * bytesPerRow + c; - unsigned dest_idx = - (r + offset_y) * (CT_ATLAS_COLS * max_width) + (c + offset_x); - uint8_t v = src[src_idx]; - dst[dest_idx] = v; + offset_x = (i % CT_ATLAS_COLS) * max_width; + offset_y = (i / CT_ATLAS_COLS) * max_height; + + glyph->atlas_offset_x = offset_x; + glyph->atlas_offset_y = offset_y; + + glyph_cstr[0] = i; + glyph_cstr[1] = 0; + glyph_cfstr = CFStringCreateWithCString( + NULL, glyph_cstr, kCFStringEncodingASCII ); + attrString = + CFAttributedStringCreate(NULL, glyph_cfstr, attr); + CFRelease(glyph_cfstr); + glyph_cfstr = NULL; + line = CTLineCreateWithAttributedString(attrString); + CFRelease(attrString); + attrString = NULL; + + memset( bitmapData, 0, max_height * bytesPerRow ); + CGContextSetTextPosition(offscreen, 0, descent); + CTLineDraw(line, offscreen); + CGContextFlush( offscreen ); + + CFRelease( line ); + line = NULL; + + dst = (uint8_t*)handle->atlas.buffer; + src = (const uint8_t*)bitmapData; + + for (r = 0; r < max_height; r++ ) + { + for (c = 0; c < max_width; c++) + { + unsigned src_idx = r * bytesPerRow + c; + unsigned dest_idx = + (r + offset_y) * (CT_ATLAS_COLS * max_width) + (c + offset_x); + uint8_t v = src[src_idx]; + + dst[dest_idx] = v; + } } - } - } + } - CFRelease(attr), attr = NULL; - CGContextRelease(offscreen), offscreen = NULL; - free(bitmapData); + CFRelease(attr); + CGContextRelease(offscreen); - end: - return ret; + attr = NULL; + offscreen = NULL; + free(bitmapData); + +end: + return ret; } static void *font_renderer_ct_init(const char *font_path, float font_size) { - char err = 0; - CFStringRef cf_font_path = NULL; - CTFontRef face = NULL; + char err = 0; + CFStringRef cf_font_path = NULL; + CTFontRef face = NULL; + font_renderer_t *handle = (font_renderer_t*) + calloc(1, sizeof(*handle)); - font_renderer_t *handle = (font_renderer_t*) - calloc(1, sizeof(*handle)); + if (!handle) + { + err = 1; + goto error; + } - if (!handle) { - err = 1; goto error; - } + cf_font_path = CFStringCreateWithCString(NULL, font_path, kCFStringEncodingASCII); + if (!cf_font_path) + { + err = 1; + goto error; + } + face = CTFontCreateWithName(cf_font_path, font_size, NULL); - cf_font_path = CFStringCreateWithCString( NULL, font_path, kCFStringEncodingASCII ); - if ( ! cf_font_path ) { - err = 1; goto error; - } - face = CTFontCreateWithName( cf_font_path, font_size, NULL ); - if ( ! face ) { - err = 1; goto error; - } - if (! font_renderer_create_atlas(face, handle)) { - err = 1; goto error; - } + if (!face) + { + err = 1; + goto error; + } - error: - if ( err ) { - font_renderer_ct_free(handle); - handle = NULL; - } + if (!font_renderer_create_atlas(face, handle)) + { + err = 1; + goto error; + } - if ( cf_font_path ) { - CFRelease( cf_font_path ), cf_font_path = NULL ; } - if ( face ) { - CFRelease(face), face = NULL; } +error: + if (err) + { + font_renderer_ct_free(handle); + handle = NULL; + } - return handle; + if (cf_font_path) + { + CFRelease(cf_font_path); + cf_font_path = NULL; + } + if (face) + { + CFRelease(face); + face = NULL; + } + + return handle; } /* We can't tell if a font is going to be there until we actually initialize CoreText and the best way to get fonts is by name, not by path. */ static const char *default_font = "Verdana"; + static const char *font_renderer_ct_get_default_font(void) { return default_font; diff --git a/gfx/fonts/d3d_font.c b/gfx/fonts/d3d_font.c index 9921b0c693..1601191679 100644 --- a/gfx/fonts/d3d_font.c +++ b/gfx/fonts/d3d_font.c @@ -31,6 +31,7 @@ const d3d_font_renderer_t *d3d_font_init_first(void *data, const char *font_path, unsigned font_size) { unsigned i; + for (i = 0; i < ARRAY_SIZE(d3d_font_backends); i++) { if (d3d_font_backends[i]->init(data, font_path, font_size)) diff --git a/gfx/fonts/d3d_w32_font.cpp b/gfx/fonts/d3d_w32_font.cpp index 80bf83d663..4771d631de 100644 --- a/gfx/fonts/d3d_w32_font.cpp +++ b/gfx/fonts/d3d_w32_font.cpp @@ -24,8 +24,7 @@ static LPD3DXFONT d3d_font; static bool d3dfonts_w32_init_font(void *data, const char *font_path, unsigned font_size) { - (void)font_path; - + uint32_t r, g, b; d3d_video_t *d3d = (d3d_video_t*)data; D3DXFONT_DESC desc = { static_cast(font_size), 0, 400, 0, @@ -36,9 +35,12 @@ static bool d3dfonts_w32_init_font(void *data, "Verdana" // Hardcode ftl :( }; - uint32_t r = static_cast(g_settings.video.msg_color_r * 255) & 0xff; - uint32_t g = static_cast(g_settings.video.msg_color_g * 255) & 0xff; - uint32_t b = static_cast(g_settings.video.msg_color_b * 255) & 0xff; + (void)font_path; + + r = static_cast(g_settings.video.msg_color_r * 255) & 0xff; + g = static_cast(g_settings.video.msg_color_g * 255) & 0xff; + b = static_cast(g_settings.video.msg_color_b * 255) & 0xff; + d3d->font_color = D3DCOLOR_XRGB(r, g, b); return SUCCEEDED(D3DXCreateFontIndirect(d3d->dev, &desc, &d3d_font)); @@ -47,6 +49,7 @@ static bool d3dfonts_w32_init_font(void *data, static void d3dfonts_w32_deinit_font(void *data) { (void)data; + if (d3d_font) d3d_font->Release(); d3d_font = NULL; @@ -57,24 +60,28 @@ static void d3dfonts_w32_render_msg(void *data, const char *msg, { d3d_video_t *d3d = (d3d_video_t*)data; - if (msg && SUCCEEDED(d3d->dev->BeginScene())) - { - d3d_font->DrawTextA(NULL, - msg, - -1, - &d3d->font_rect_shifted, - DT_LEFT, - ((d3d->font_color >> 2) & 0x3f3f3f) | 0xff000000); + if (!d3d) + return; + if (!msg) + return; + if (!(SUCCEEDED(d3d->dev->BeginScene()))) + return; - d3d_font->DrawTextA(NULL, - msg, - -1, - &d3d->font_rect, - DT_LEFT, - d3d->font_color | 0xff000000); + d3d_font->DrawTextA(NULL, + msg, + -1, + &d3d->font_rect_shifted, + DT_LEFT, + ((d3d->font_color >> 2) & 0x3f3f3f) | 0xff000000); - d3d->dev->EndScene(); - } + d3d_font->DrawTextA(NULL, + msg, + -1, + &d3d->font_rect, + DT_LEFT, + d3d->font_color | 0xff000000); + + d3d->dev->EndScene(); } d3d_font_renderer_t d3d_win32_font = { diff --git a/gfx/fonts/fonts.c b/gfx/fonts/fonts.c index 4fcda15cad..d804fabfdd 100644 --- a/gfx/fonts/fonts.c +++ b/gfx/fonts/fonts.c @@ -37,9 +37,11 @@ bool font_renderer_create_default( const char *font_path, unsigned font_size) { unsigned i; + for (i = 0; font_backends[i]; i++) { const char *path = font_path; + if (!path) path = font_backends[i]->get_default_font(); if (!path) diff --git a/gfx/fonts/freetype.c b/gfx/fonts/freetype.c index dae531ba4a..7ed8cb8b6c 100644 --- a/gfx/fonts/freetype.c +++ b/gfx/fonts/freetype.c @@ -40,6 +40,8 @@ typedef struct freetype_renderer static const struct font_atlas *font_renderer_ft_get_atlas(void *data) { font_renderer_t *handle = (font_renderer_t*)data; + if (!handle) + return NULL; return &handle->atlas; } @@ -47,6 +49,8 @@ static const struct font_glyph *font_renderer_ft_get_glyph( void *data, uint32_t code) { font_renderer_t *handle = (font_renderer_t*)data; + if (!handle) + return NULL; return code < ATLAS_SIZE ? &handle->glyphs[code] : NULL; } @@ -80,6 +84,9 @@ static bool font_renderer_create_atlas(font_renderer_t *handle) { struct font_glyph *glyph = &handle->glyphs[i]; + if (!glyph) + continue; + if (FT_Load_Char(handle->face, i, FT_LOAD_RENDER)) { ret = false; @@ -124,7 +131,7 @@ static bool font_renderer_create_atlas(font_renderer_t *handle) for (i = 0; i < ATLAS_SIZE; i++) { unsigned r, c; - uint8_t *dst = NULL; + uint8_t *dst = NULL; unsigned offset_x = (i % ATLAS_COLS) * max_width; unsigned offset_y = (i / ATLAS_COLS) * max_height; @@ -137,6 +144,7 @@ static bool font_renderer_create_atlas(font_renderer_t *handle) if (buffer[i]) { const uint8_t *src = (const uint8_t*)buffer[i]; + for (r = 0; r < handle->glyphs[i].height; r++, dst += handle->atlas.width, src += pitches[i]) for (c = 0; c < handle->glyphs[i].width; c++) @@ -208,6 +216,7 @@ static const char *font_paths[] = { static const char *font_renderer_ft_get_default_font(void) { size_t i; + for (i = 0; i < ARRAY_SIZE(font_paths); i++) { if (path_file_exists(font_paths[i])) diff --git a/gfx/fonts/gl_raster_font.c b/gfx/fonts/gl_raster_font.c index 2c44a65b1e..72ce08d671 100644 --- a/gfx/fonts/gl_raster_font.c +++ b/gfx/fonts/gl_raster_font.c @@ -44,7 +44,11 @@ typedef struct static void *gl_raster_font_init_font(void *gl_data, const char *font_path, float font_size) { + unsigned width, height; + uint8_t *tmp_buffer; + const struct font_atlas *atlas = NULL; gl_raster_t *font = (gl_raster_t*)calloc(1, sizeof(*font)); + if (!font) return NULL; @@ -65,10 +69,10 @@ static void *gl_raster_font_init_font(void *gl_data, glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); - const struct font_atlas *atlas = font->font_driver->get_atlas(font->font_data); + atlas = font->font_driver->get_atlas(font->font_data); - unsigned width = next_pow2(atlas->width); - unsigned height = next_pow2(atlas->height); + width = next_pow2(atlas->width); + height = next_pow2(atlas->height); /* Ideally, we'd use single component textures, but the * difference in ways to do that between core GL and GLES/legacy GL @@ -76,12 +80,14 @@ static void *gl_raster_font_init_font(void *gl_data, glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, width, height, 0, GL_RGBA, GL_UNSIGNED_BYTE, NULL); - uint8_t *tmp_buffer = (uint8_t*)malloc(atlas->width * atlas->height * 4); + tmp_buffer = (uint8_t*)malloc(atlas->width * atlas->height * 4); + if (tmp_buffer) { unsigned i; - uint8_t *dst = tmp_buffer; + uint8_t *dst = tmp_buffer; const uint8_t *src = atlas->buffer; + for (i = 0; i < atlas->width * atlas->height; i++) { *dst++ = 0xff; @@ -89,6 +95,7 @@ static void *gl_raster_font_init_font(void *gl_data, *dst++ = 0xff; *dst++ = *src++; } + glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, atlas->width, atlas->height, GL_RGBA, GL_UNSIGNED_BYTE, tmp_buffer); free(tmp_buffer); @@ -118,27 +125,28 @@ static void gl_raster_font_free_font(void *data) static void render_message(gl_raster_t *font, const char *msg, GLfloat scale, const GLfloat color[4], GLfloat pos_x, GLfloat pos_y) { - unsigned i; + int x, y, delta_x, delta_y; + float inv_tex_size_x, inv_tex_size_y, inv_win_width, inv_win_height; + unsigned i, msg_len_full, msg_len; + GLfloat font_tex_coords[2 * 6 * MAX_MSG_LEN_CHUNK]; + GLfloat font_vertex[2 * 6 * MAX_MSG_LEN_CHUNK]; + GLfloat font_color[4 * 6 * MAX_MSG_LEN_CHUNK]; gl_t *gl = font->gl; glBindTexture(GL_TEXTURE_2D, font->tex); - GLfloat font_tex_coords[2 * 6 * MAX_MSG_LEN_CHUNK]; - GLfloat font_vertex[2 * 6 * MAX_MSG_LEN_CHUNK]; - GLfloat font_color[4 * 6 * MAX_MSG_LEN_CHUNK]; + msg_len_full = strlen(msg); + msg_len = min(msg_len_full, MAX_MSG_LEN_CHUNK); - unsigned msg_len_full = strlen(msg); - unsigned msg_len = min(msg_len_full, MAX_MSG_LEN_CHUNK); + x = roundf(pos_x * gl->vp.width); + y = roundf(pos_y * gl->vp.height); + delta_x = 0; + delta_y = 0; - int x = roundf(pos_x * gl->vp.width); - int y = roundf(pos_y * gl->vp.height); - int delta_x = 0; - int delta_y = 0; - - float inv_tex_size_x = 1.0f / font->tex_width; - float inv_tex_size_y = 1.0f / font->tex_height; - float inv_win_width = 1.0f / font->gl->vp.width; - float inv_win_height = 1.0f / font->gl->vp.height; + inv_tex_size_x = 1.0f / font->tex_width; + inv_tex_size_y = 1.0f / font->tex_height; + inv_win_width = 1.0f / font->gl->vp.width; + inv_win_height = 1.0f / font->gl->vp.height; while (msg_len_full) { @@ -148,19 +156,20 @@ static void render_message(gl_raster_t *font, const char *msg, GLfloat scale, for (i = 0; i < msg_len; i++) { - const struct font_glyph *gly = + int off_x, off_y, tex_x, tex_y, width, height; + const struct font_glyph *glyph = font->font_driver->get_glyph(font->font_data, (uint8_t)msg[i]); - if (!gly) - gly = font->font_driver->get_glyph(font->font_data, '?'); /* Do something smarter here ... */ - if (!gly) + if (!glyph) + glyph = font->font_driver->get_glyph(font->font_data, '?'); /* Do something smarter here ... */ + if (!glyph) continue; - int off_x = gly->draw_offset_x; - int off_y = gly->draw_offset_y; - int tex_x = gly->atlas_offset_x; - int tex_y = gly->atlas_offset_y; - int width = gly->width; - int height = gly->height; + off_x = glyph->draw_offset_x; + off_y = glyph->draw_offset_y; + tex_x = glyph->atlas_offset_x; + tex_y = glyph->atlas_offset_y; + width = glyph->width; + height = glyph->height; emit(0, 0, 1); /* Bottom-left */ emit(1, 1, 1); /* Bottom-right */ @@ -171,8 +180,8 @@ static void render_message(gl_raster_t *font, const char *msg, GLfloat scale, emit(5, 1, 1); /* Bottom-right */ #undef emit - delta_x += gly->advance_x; - delta_y -= gly->advance_y; + delta_x += glyph->advance_x; + delta_y -= glyph->advance_y; } gl->coords.tex_coord = font_tex_coords; @@ -203,12 +212,13 @@ static void gl_raster_font_render_msg(void *data, const char *msg, GLfloat color[4], color_dark[4]; int drop_x, drop_y; bool full_screen; - + gl_t *gl = NULL; gl_raster_t *font = (gl_raster_t*)data; + if (!font) return; - gl_t *gl = font->gl; + gl = font->gl; if (params) { @@ -276,7 +286,6 @@ static const struct font_glyph *gl_raster_font_get_glyph( if (!font) return NULL; - return font->font_driver->get_glyph((void*)font->font_driver, code); } diff --git a/gfx/fonts/ps_libdbgfont.c b/gfx/fonts/ps_libdbgfont.c index fcfb0b773b..0db89fa7c3 100644 --- a/gfx/fonts/ps_libdbgfont.c +++ b/gfx/fonts/ps_libdbgfont.c @@ -35,9 +35,10 @@ static void *libdbg_font_init_font(void *gl_data, const char *font_path, float font_size) { + gl_t *gl = (gl_t*)gl_data; + (void)font_path; (void)font_size; - gl_t *gl = (gl_t*)gl_data; DbgFontConfig cfg; #if defined(SN_TARGET_PSP2) @@ -63,10 +64,11 @@ static void libdbg_font_deinit_font(void *data) static void libdbg_font_render_msg(void *data, const char *msg, const struct font_params *params) { - (void)data; float x, y, scale; unsigned color; + (void)data; + if (params) { x = params->x; diff --git a/gfx/fonts/xdk1_xfonts.c b/gfx/fonts/xdk1_xfonts.c index e6b8719415..67d5f36c7b 100644 --- a/gfx/fonts/xdk1_xfonts.c +++ b/gfx/fonts/xdk1_xfonts.c @@ -47,7 +47,7 @@ static void xfonts_render_msg(void *data, const char *msg, const struct font_params *params) { d3d_video_t *d3d = (d3d_video_t*)data; - wchar_t str[PATH_MAX]; + wchar_t str[PATH_MAX_LENGTH]; float x, y; if (params) diff --git a/gfx/fonts/xdk360_fonts.cpp b/gfx/fonts/xdk360_fonts.cpp index 89efdf8e69..15e05f17a9 100644 --- a/gfx/fonts/xdk360_fonts.cpp +++ b/gfx/fonts/xdk360_fonts.cpp @@ -25,25 +25,25 @@ typedef struct GLYPH_ATTR { - unsigned short tu1, tv1, tu2, tv2; // Texture coordinates for the image - short wOffset; // Pixel offset for glyph start - short wWidth; // Pixel width of the glyph - short wAdvance; // Pixels to advance after the glyph + unsigned short tu1, tv1, tu2, tv2; /* Texture coordinates for the image. */ + short wOffset; /* Pixel offset for glyph start. */ + short wWidth; /* Pixel width of the glyph. */ + short wAdvance; /* Pixels to advance after the glyph. */ unsigned short wMask; } GLYPH_ATTR; typedef struct { unsigned long m_dwSavedState; - unsigned long m_cMaxGlyph; // Number of entries in the translator table - unsigned long m_dwNumGlyphs; // Number of valid glyphs - float m_fFontHeight; // Height of the font strike in pixels - float m_fFontTopPadding; // Padding above the strike zone - float m_fFontBottomPadding; // Padding below the strike zone - float m_fFontYAdvance; // Number of pixels to move the cursor for a line feed - wchar_t * m_TranslatorTable; // ASCII to glyph lookup table + unsigned long m_cMaxGlyph; /* Number of entries in the translator table. */ + unsigned long m_dwNumGlyphs; /* Number of valid glyphs. */ + float m_fFontHeight; /* Height of the font strike in pixels. */ + float m_fFontTopPadding; /* Padding above the strike zone. */ + float m_fFontBottomPadding; /* Padding below the strike zone. */ + float m_fFontYAdvance; /* Number of pixels to move the cursor for a line feed. */ + wchar_t * m_TranslatorTable; /* ASCII to glyph lookup table. */ D3DTexture* m_pFontTexture; - const GLYPH_ATTR* m_Glyphs; // Array of glyphs + const GLYPH_ATTR* m_Glyphs; /* Array of glyphs. */ } xdk360_video_font_t; static xdk360_video_font_t m_Font; @@ -53,18 +53,18 @@ static PackedResource m_xprResource; #define FONTFILEVERSION 5 typedef struct { - unsigned long m_dwFileVersion; // Version of the font file (Must match FONTFILEVERSION) - float m_fFontHeight; // Height of the font strike in pixels - float m_fFontTopPadding; // Padding above the strike zone - float m_fFontBottomPadding; // Padding below the strike zone - float m_fFontYAdvance; // Number of pixels to move the cursor for a line feed - unsigned short m_cMaxGlyph; // Number of font characters (Should be an odd number to maintain DWORD Alignment) - wchar_t m_TranslatorTable[1]; // ASCII to Glyph lookup table, NOTE: It's m_cMaxGlyph+1 in size. + unsigned long m_dwFileVersion; /* Version of the font file (Must match FONTFILEVERSION). */ + float m_fFontHeight; /* Height of the font strike in pixels. */ + float m_fFontTopPadding; /* Padding above the strike zone. */ + float m_fFontBottomPadding; /* Padding below the strike zone. */ + float m_fFontYAdvance; /* Number of pixels to move the cursor for a line feed. */ + unsigned short m_cMaxGlyph; /* Number of font characters (Should be an odd number to maintain DWORD Alignment). */ + wchar_t m_TranslatorTable[1]; /* ASCII to Glyph lookup table, NOTE: It's m_cMaxGlyph+1 in size. */ } FontFileHeaderImage_t; typedef struct { - unsigned long m_dwNumGlyphs; // Size of font strike array (First entry is the unknown glyph) - GLYPH_ATTR m_Glyphs[1]; // Array of font strike uv's etc... NOTE: It's m_dwNumGlyphs in size + unsigned long m_dwNumGlyphs; /* Size of font strike array (First entry is the unknown glyph). */ + GLYPH_ATTR m_Glyphs[1]; /* Array of font strike uv's etc... NOTE: It's m_dwNumGlyphs in size. */ } FontFileStrikesImage_t; static const char g_strFontShader[] = @@ -113,80 +113,82 @@ static HRESULT xdk360_video_font_create_shaders( d3d_video_t *d3d = (d3d_video_t*)data; LPDIRECT3DDEVICE d3dr = d3d->dev; - if (!s_FontLocals.m_pFontVertexDecl) - { - do - { - static const D3DVERTEXELEMENT9 decl[] = - { - { 0, 0, D3DDECLTYPE_FLOAT2, D3DDECLMETHOD_DEFAULT, D3DDECLUSAGE_POSITION, 0 }, - { 0, 8, D3DDECLTYPE_USHORT2, D3DDECLMETHOD_DEFAULT, D3DDECLUSAGE_TEXCOORD, 0 }, - { 0, 12, D3DDECLTYPE_D3DCOLOR, D3DDECLMETHOD_DEFAULT, D3DDECLUSAGE_TEXCOORD, 1 }, - D3DDECL_END() - }; - - - hr = d3dr->CreateVertexDeclaration( decl, &s_FontLocals.m_pFontVertexDecl ); - - if (hr >= 0) - { - ID3DXBuffer* pShaderCode; - - hr = D3DXCompileShader( g_strFontShader, sizeof(g_strFontShader)-1 , - NULL, NULL, "main_vertex", "vs.2.0", 0,&pShaderCode, NULL, NULL ); - - if (hr >= 0) - { - hr = d3dr->CreateVertexShader( ( unsigned long * )pShaderCode->GetBufferPointer(), - &s_FontLocals.m_pFontVertexShader ); - pShaderCode->Release(); - - if (hr >= 0) - { - hr = D3DXCompileShader( g_strFontShader, sizeof(g_strFontShader)-1 , - NULL, NULL, "main_fragment", "ps.2.0", 0,&pShaderCode, NULL, NULL ); - - if (hr >= 0) - { - hr = d3dr->CreatePixelShader((DWORD*)pShaderCode->GetBufferPointer(), - &s_FontLocals.m_pFontPixelShader ); - pShaderCode->Release(); - - if (hr >= 0) - { - hr = 0; - break; - } - } - s_FontLocals.m_pFontVertexShader->Release(); - } - - s_FontLocals.m_pFontVertexShader = NULL; - } - - s_FontLocals.m_pFontVertexDecl->Release(); - } - s_FontLocals.m_pFontVertexDecl = NULL; - }while (0); - } - else + if (s_FontLocals.m_pFontVertexDecl) { s_FontLocals.m_pFontVertexDecl->AddRef(); s_FontLocals.m_pFontVertexShader->AddRef(); s_FontLocals.m_pFontPixelShader->AddRef(); - hr = 0; + return 0; } + + do + { + static const D3DVERTEXELEMENT9 decl[] = + { + { 0, 0, D3DDECLTYPE_FLOAT2, D3DDECLMETHOD_DEFAULT, D3DDECLUSAGE_POSITION, 0 }, + { 0, 8, D3DDECLTYPE_USHORT2, D3DDECLMETHOD_DEFAULT, D3DDECLUSAGE_TEXCOORD, 0 }, + { 0, 12, D3DDECLTYPE_D3DCOLOR, D3DDECLMETHOD_DEFAULT, D3DDECLUSAGE_TEXCOORD, 1 }, + D3DDECL_END() + }; + + + hr = d3dr->CreateVertexDeclaration( decl, &s_FontLocals.m_pFontVertexDecl ); + + if (hr >= 0) + { + ID3DXBuffer* pShaderCode; + + hr = D3DXCompileShader( g_strFontShader, sizeof(g_strFontShader)-1 , + NULL, NULL, "main_vertex", "vs.2.0", 0,&pShaderCode, NULL, NULL ); + + if (hr >= 0) + { + hr = d3dr->CreateVertexShader( ( unsigned long * )pShaderCode->GetBufferPointer(), + &s_FontLocals.m_pFontVertexShader ); + pShaderCode->Release(); + + if (hr >= 0) + { + hr = D3DXCompileShader( g_strFontShader, sizeof(g_strFontShader)-1 , + NULL, NULL, "main_fragment", "ps.2.0", 0,&pShaderCode, NULL, NULL ); + + if (hr >= 0) + { + hr = d3dr->CreatePixelShader((DWORD*)pShaderCode->GetBufferPointer(), + &s_FontLocals.m_pFontPixelShader ); + pShaderCode->Release(); + + if (hr >= 0) + { + hr = 0; + break; + } + } + s_FontLocals.m_pFontVertexShader->Release(); + } + + s_FontLocals.m_pFontVertexShader = NULL; + } + + s_FontLocals.m_pFontVertexDecl->Release(); + } + s_FontLocals.m_pFontVertexDecl = NULL; + }while(0); + return hr; } static bool xdk360_init_font(void *data, const char *font_path, unsigned font_size) { - (void)font_size; + unsigned long dwFileVersion; + const void *pFontData = NULL; + D3DTexture *pFontTexture = NULL; + const unsigned char * pData = NULL; + xdk360_video_font_t *font = &m_Font; + d3d_video_t *d3d = (d3d_video_t*)data; - // Create the font - xdk360_video_font_t *font = &m_Font; - d3d_video_t *d3d = (d3d_video_t*)data; + (void)font_size; font->m_pFontTexture = NULL; font->m_dwNumGlyphs = 0L; @@ -194,44 +196,41 @@ static bool xdk360_init_font(void *data, font->m_cMaxGlyph = 0; font->m_TranslatorTable = NULL; - // Create the font + /* Create the font. */ if (FAILED( m_xprResource.Create(font_path))) goto error; - D3DTexture *pFontTexture = m_xprResource.GetTexture( "FontTexture" ); - const void *pFontData = m_xprResource.GetData( "FontData"); + pFontTexture = m_xprResource.GetTexture( "FontTexture" ); + pFontData = m_xprResource.GetData( "FontData"); - // Save a copy of the texture - font->m_pFontTexture = pFontTexture; + /* Save a copy of the texture. */ + font->m_pFontTexture = pFontTexture; - // Check version of file (to make sure it matches up with the FontMaker tool) - const unsigned char * pData = (const unsigned char*)pFontData; - unsigned long dwFileVersion = ((const FontFileHeaderImage_t *)pData)->m_dwFileVersion; + /* Check version of file (to make sure it matches up with the FontMaker tool). */ + pData = (const unsigned char*)pFontData; + dwFileVersion = ((const FontFileHeaderImage_t *)pData)->m_dwFileVersion; - if (dwFileVersion == FONTFILEVERSION) + if (dwFileVersion != FONTFILEVERSION) { - font->m_fFontHeight = ((const FontFileHeaderImage_t *)pData)->m_fFontHeight; - font->m_fFontTopPadding = ((const FontFileHeaderImage_t *)pData)->m_fFontTopPadding; - font->m_fFontBottomPadding = ((const FontFileHeaderImage_t *)pData)->m_fFontBottomPadding; - font->m_fFontYAdvance = ((const FontFileHeaderImage_t *)pData)->m_fFontYAdvance; - - // Point to the translator string which immediately follows the 4 floats - font->m_cMaxGlyph = ((const FontFileHeaderImage_t *)pData)->m_cMaxGlyph; - - font->m_TranslatorTable = const_cast((const FontFileHeaderImage_t *)pData)->m_TranslatorTable; - - pData += CALCFONTFILEHEADERSIZE( font->m_cMaxGlyph + 1 ); - - // Read the glyph attributes from the file - font->m_dwNumGlyphs = ((const FontFileStrikesImage_t *)pData)->m_dwNumGlyphs; - font->m_Glyphs = ((const FontFileStrikesImage_t *)pData)->m_Glyphs; - } - else - { - RARCH_ERR( "Incorrect version number on font file.\n" ); + RARCH_ERR("Incorrect version number on font file.\n"); goto error; } + font->m_fFontHeight = ((const FontFileHeaderImage_t *)pData)->m_fFontHeight; + font->m_fFontTopPadding = ((const FontFileHeaderImage_t *)pData)->m_fFontTopPadding; + font->m_fFontBottomPadding = ((const FontFileHeaderImage_t *)pData)->m_fFontBottomPadding; + font->m_fFontYAdvance = ((const FontFileHeaderImage_t *)pData)->m_fFontYAdvance; + + /* Point to the translator string which immediately follows the 4 floats. */ + font->m_cMaxGlyph = ((const FontFileHeaderImage_t *)pData)->m_cMaxGlyph; + font->m_TranslatorTable = const_cast((const FontFileHeaderImage_t *)pData)->m_TranslatorTable; + + pData += CALCFONTFILEHEADERSIZE( font->m_cMaxGlyph + 1 ); + + /* Read the glyph attributes from the file. */ + font->m_dwNumGlyphs = ((const FontFileStrikesImage_t *)pData)->m_dwNumGlyphs; + font->m_Glyphs = ((const FontFileStrikesImage_t *)pData)->m_Glyphs; + /* Create the vertex and pixel shaders for rendering the font */ if (FAILED(xdk360_video_font_create_shaders(d3d, font))) { @@ -287,22 +286,22 @@ static void xdk360_render_msg_post(xdk360_video_font_t * font, void *video_data) static void xdk360_render_msg_pre(xdk360_video_font_t * font, void *video_data) { + float vTexScale[4]; + D3DSURFACE_DESC TextureDesc; d3d_video_t *d3d = (d3d_video_t*)video_data; LPDIRECT3DDEVICE d3dr = d3d->dev; - // Save state + /* Save state. */ d3dr->GetRenderState( D3DRS_VIEWPORTENABLE, &font->m_dwSavedState ); - // Set the texture scaling factor as a vertex shader constant - D3DSURFACE_DESC TextureDesc; + /* Set the texture scaling factor as a vertex shader constant. */ D3DTexture_GetLevelDesc(font->m_pFontTexture, 0, &TextureDesc); // Get the description - // Set render state + /* Set render state. */ d3d_set_texture(d3dr, 0, font->m_pFontTexture); - // Read the TextureDesc here to ensure no load/hit/store from GetLevelDesc() - float vTexScale[4]; - vTexScale[0] = 1.0f / TextureDesc.Width; // LHS due to int->float conversion + /* Read the TextureDesc here to ensure no load/hit/store from GetLevelDesc(). */ + vTexScale[0] = 1.0f / TextureDesc.Width; /* LHS due to int->float conversion. */ vTexScale[1] = 1.0f / TextureDesc.Height; vTexScale[2] = 0.0f; vTexScale[3] = 0.0f; @@ -312,93 +311,102 @@ static void xdk360_render_msg_pre(xdk360_video_font_t * font, void *video_data) d3d_set_vertex_shader(d3dr, 0, s_FontLocals.m_pFontVertexShader); d3dr->SetPixelShader(s_FontLocals.m_pFontPixelShader); - // Set the texture scaling factor as a vertex shader constant - // Call here to avoid load hit store from writing to vTexScale above + /* Set the texture scaling factor as a vertex shader constant. + * Call here to avoid load hit store from writing to vTexScale above + */ d3dr->SetVertexShaderConstantF( 2, vTexScale, 1 ); } static void xdk360_draw_text(xdk360_video_font_t *font, void *video_data, float x, float y, const wchar_t * strText) { - d3d_video_t *d3d = (d3d_video_t*)video_data; + unsigned long dwNumChars; + volatile float *pVertex; + float vColor[4], m_fCursorX, m_fCursorY; + d3d_video_t *d3d = (d3d_video_t*)video_data; LPDIRECT3DDEVICE d3dr = d3d->dev; - // Set the color as a vertex shader constant - float vColor[4]; + /* Set the color as a vertex shader constant. */ vColor[0] = ( ( 0xffffffff & 0x00ff0000 ) >> 16L ) / 255.0f; vColor[1] = ( ( 0xffffffff & 0x0000ff00 ) >> 8L ) / 255.0f; vColor[2] = ( ( 0xffffffff & 0x000000ff ) >> 0L ) / 255.0f; vColor[3] = ( ( 0xffffffff & 0xff000000 ) >> 24L ) / 255.0f; - // Perform the actual storing of the color constant here to prevent - // a load-hit-store by inserting work between the store and the use of - // the vColor array. + /* Perform the actual storing of the color constant here to prevent + * a load-hit-store by inserting work between the store and the use of + * the vColor array. */ d3dr->SetVertexShaderConstantF( 1, vColor, 1 ); - float m_fCursorX = floorf(x); - float m_fCursorY = floorf(y); + m_fCursorX = floorf(x); + m_fCursorY = floorf(y); - // Adjust for padding + /* Adjust for padding. */ y -= font->m_fFontTopPadding; - // Begin drawing the vertices + /* Begin drawing the vertices + * Declared as volatile to force writing in ascending + * address order. + * + * It prevents out of sequence writing in write combined + * memory. + */ - // Declared as volatile to force writing in ascending - // address order. It prevents out of sequence writing in write combined - // memory. - - volatile float * pVertex; - - unsigned long dwNumChars = wcslen(strText); + dwNumChars = wcslen(strText); d3dr->BeginVertices(D3DPT_QUADLIST, 4 * dwNumChars, sizeof(XMFLOAT4), (void**)&pVertex); - // Draw four vertices for each glyph + /* Draw four vertices for each glyph. */ while (*strText) { - // Get the current letter in the string - wchar_t letter = *strText++; + float fOffset, fAdvance, fWidth, fHeight; + unsigned long tu1, tu2, tv1, tv2; + const GLYPH_ATTR *pGlyph; + wchar_t letter = *strText++; /* Get the current letter in the string */ + /* Handle the newline character. */ if (letter == L'\n') { - // Handle the newline character m_fCursorX = x; m_fCursorY += font->m_fFontYAdvance * FONT_SCALE(d3d); continue; } - // Translate unprintable characters - const GLYPH_ATTR *pGlyph; - + /* Translate unprintable characters. */ if (letter <= font->m_cMaxGlyph) pGlyph = &font->m_Glyphs[font->m_TranslatorTable[letter]]; else pGlyph = &font->m_Glyphs[0]; - float fOffset = FONT_SCALE(d3d) * (float)pGlyph->wOffset; - float fAdvance = FONT_SCALE(d3d) * (float)pGlyph->wAdvance; - float fWidth = FONT_SCALE(d3d) * (float)pGlyph->wWidth; - float fHeight = FONT_SCALE(d3d) * font->m_fFontHeight; + fOffset = FONT_SCALE(d3d) * (float)pGlyph->wOffset; + fAdvance = FONT_SCALE(d3d) * (float)pGlyph->wAdvance; + fWidth = FONT_SCALE(d3d) * (float)pGlyph->wWidth; + fHeight = FONT_SCALE(d3d) * font->m_fFontHeight; m_fCursorX += fOffset; - // Add the vertices to draw this glyph + /* Add the vertices to draw this glyph. */ - unsigned long tu1 = pGlyph->tu1; // Convert shorts to 32 bit longs for in register merging - unsigned long tv1 = pGlyph->tv1; - unsigned long tu2 = pGlyph->tu2; - unsigned long tv2 = pGlyph->tv2; + /* Convert shorts to 32 bit longs for in register merging */ + tu1 = pGlyph->tu1; + tv1 = pGlyph->tv1; + tu2 = pGlyph->tu2; + tv2 = pGlyph->tv2; - // NOTE: The vertexes are 2 floats for the screen coordinates, - // followed by two USHORTS for the u/vs of the character, - // terminated with the ARGB 32 bit color. - // This makes for 16 bytes per vertex data (Easier to read) - // Second NOTE: The uvs are merged and written using a DWORD due - // to the write combining hardware being only able to handle 32, - // 64 and 128 writes. Never store to write combined memory with - // 8 or 16 bit instructions. You've been warned. + /* NOTE: The vertexes are 2 floats for the screen coordinates, + * followed by two USHORTS for the u/vs of the character, + * terminated with the ARGB 32 bit color. + * + * This makes for 16 bytes per vertex data (Easier to read) + * + * Second NOTE: The U/V coordinates are merged and written + * using a DWORD due to the write combining hardware + * being only able to handle 32, 64 and 128 writes. + * + * Never store to write combined memory with 8 or 16bit + * instructions. You've been warned. + */ - // Setup the vertex/screen coordinates + /* Setup the vertex/screen coordinates */ pVertex[0] = m_fCursorX; pVertex[1] = m_fCursorY; @@ -425,11 +433,15 @@ static void xdk360_draw_text(xdk360_video_font_t *font, void *video_data, dwNumChars--; } - // Since we allocated vertex data space based on the string length, we now need to - // add some dummy verts for any skipped characters (like newlines, etc.) + /* Since we allocated vertex data space + * based on the string length, we now need to + * add some dummy verts for any skipped + * characters (like newlines, etc.) + */ while (dwNumChars) { - for (unsigned i = 0; i < 16; i++) + unsigned i; + for (i = 0; i < 16; i++) pVertex[i] = 0; pVertex += 16; @@ -442,10 +454,10 @@ static void xdk360_draw_text(xdk360_video_font_t *font, void *video_data, static void xdk360_render_msg(void *data, const char *str_msg, const struct font_params *params) { - d3d_video_t *d3d = (d3d_video_t*)data; - xdk360_video_font_t *font = &m_Font; - wchar_t msg[PATH_MAX]; float x, y; + wchar_t msg[PATH_MAX_LENGTH]; + d3d_video_t *d3d = (d3d_video_t*)data; + xdk360_video_font_t *font = &m_Font; if (params) { From 5f5000a1bdfc9af513fdc73af4caf0895ec33bdb Mon Sep 17 00:00:00 2001 From: Twinaphex Date: Sat, 10 Jan 2015 16:47:38 +0100 Subject: [PATCH 002/156] (CoreText) remove unused variable --- gfx/fonts/coretext.c | 1 - 1 file changed, 1 deletion(-) diff --git a/gfx/fonts/coretext.c b/gfx/fonts/coretext.c index cfb0e7785e..d7a671b120 100644 --- a/gfx/fonts/coretext.c +++ b/gfx/fonts/coretext.c @@ -47,7 +47,6 @@ static const struct font_atlas *font_renderer_ct_get_atlas(void *data) static const struct font_glyph *font_renderer_ct_get_glyph(void *data, uint32_t code) { - struct font_glyph *result = NULL; font_renderer_t *handle = (font_renderer_t*)data; if (!handle) From 16a686345fcb9b35f77cc36f409f5ae65e7a37fa Mon Sep 17 00:00:00 2001 From: Twinaphex Date: Sat, 10 Jan 2015 16:49:10 +0100 Subject: [PATCH 003/156] (iOS) Buildfix --- apple/iOS/menu.m | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apple/iOS/menu.m b/apple/iOS/menu.m index c0f90d7485..004bd71d73 100644 --- a/apple/iOS/menu.m +++ b/apple/iOS/menu.m @@ -717,7 +717,7 @@ static void RunActionSheet(const char* title, const struct string_list* items, U - (void)menuBack { - apply_deferred_settings(); + menu_apply_deferred_settings(); menu_list_pop_stack(driver.menu->menu_list); [self menuRefresh]; [self reloadData]; From 4bdb26e2a14555fe0fb4e355be240209f5f159b6 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Sat, 10 Jan 2015 16:52:06 +0100 Subject: [PATCH 004/156] (MSVC) Buildfix --- gfx/gl.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gfx/gl.c b/gfx/gl.c index c9cf5fedb8..7f24ab0c82 100644 --- a/gfx/gl.c +++ b/gfx/gl.c @@ -2679,7 +2679,7 @@ static bool gl_read_viewport(void *data, uint8_t *buffer) return false; } #else - ptr = glMapBuffer(GL_PIXEL_PACK_BUFFER, GL_READ_ONLY); + ptr = (const uint8_t*)glMapBuffer(GL_PIXEL_PACK_BUFFER, GL_READ_ONLY); if (!ptr) { RARCH_ERR("[GL]: Failed to map pixel unpack buffer.\n"); From 2f195b96cdc76afbc88df546e9d2c9f3f5ecf4aa Mon Sep 17 00:00:00 2001 From: twinaphex Date: Sat, 10 Jan 2015 17:51:00 +0100 Subject: [PATCH 005/156] (Gfx context) Cleanups in gfx context drivers --- gfx/context/androidegl_ctx.c | 91 +++++++++++++++---------- gfx/context/bbqnx_ctx.c | 115 +++++++++++++++++++------------- gfx/context/d3d_ctx.cpp | 35 +++++++--- gfx/context/drm_egl_ctx.c | 23 ++++--- gfx/context/emscriptenegl_ctx.c | 61 ++++++++++------- gfx/context/glx_ctx.c | 25 ++++--- gfx/context/mali_fbdev_ctx.c | 67 ++++++++++--------- gfx/context/ps3_ctx.c | 62 ++++++++++------- gfx/context/sdl_gl_ctx.c | 21 +++--- gfx/context/vc_egl_ctx.c | 81 +++++++++++++--------- gfx/context/vivante_fbdev_ctx.c | 75 ++++++++++++--------- gfx/context/wayland_ctx.c | 30 ++++++--- gfx/context/wgl_ctx.c | 78 ++++++++++++++-------- gfx/context/xegl_ctx.c | 103 ++++++++++++++++++---------- 14 files changed, 530 insertions(+), 337 deletions(-) diff --git a/gfx/context/androidegl_ctx.c b/gfx/context/androidegl_ctx.c index d97368f641..7644e1f573 100644 --- a/gfx/context/androidegl_ctx.c +++ b/gfx/context/androidegl_ctx.c @@ -44,8 +44,10 @@ static void android_gfx_ctx_set_swap_interval(void *data, unsigned interval) driver.video_context_data; (void)data; - if (android) - eglSwapInterval(android->g_egl_dpy, interval); + if (!android) + return; + + eglSwapInterval(android->g_egl_dpy, interval); } static void android_gfx_ctx_destroy_resources(gfx_ctx_android_data_t *android) @@ -98,30 +100,35 @@ static void android_gfx_ctx_destroy(void *data) static void android_gfx_ctx_get_video_size(void *data, unsigned *width, unsigned *height) { + EGLint gl_width, gl_height; gfx_ctx_android_data_t *android = (gfx_ctx_android_data_t*) driver.video_context_data; - (void)data; *width = 0; *height = 0; - if (android && android->g_egl_dpy) - { - EGLint gl_width, gl_height; + if (!android) + return; + if (!android->g_egl_dpy) + return; - eglQuerySurface(android->g_egl_dpy, - android->g_egl_surf, EGL_WIDTH, &gl_width); - eglQuerySurface(android->g_egl_dpy, - android->g_egl_surf, EGL_HEIGHT, &gl_height); - *width = gl_width; - *height = gl_height; - } + eglQuerySurface(android->g_egl_dpy, + android->g_egl_surf, EGL_WIDTH, &gl_width); + eglQuerySurface(android->g_egl_dpy, + android->g_egl_surf, EGL_HEIGHT, &gl_height); + *width = gl_width; + *height = gl_height; } static bool android_gfx_ctx_init(void *data) { int var; - struct android_app *android_app = (struct android_app*)g_android; + EGLint num_config, egl_version_major, egl_version_minor; + EGLint format; + EGLint context_attributes[] = { + EGL_CONTEXT_CLIENT_VERSION, g_es3 ? 3 : 2, + EGL_NONE + }; const EGLint attribs[] = { EGL_RENDERABLE_TYPE, EGL_OPENGL_ES2_BIT, EGL_SURFACE_TYPE, EGL_WINDOW_BIT, @@ -131,16 +138,15 @@ static bool android_gfx_ctx_init(void *data) EGL_ALPHA_SIZE, 8, EGL_NONE }; - EGLint num_config; - EGLint egl_version_major, egl_version_minor; - EGLint format; + struct android_app *android_app = NULL; + gfx_ctx_android_data_t *android = NULL; + + android_app = (struct android_app*)g_android; + + if (!android_app) + return false; - EGLint context_attributes[] = { - EGL_CONTEXT_CLIENT_VERSION, g_es3 ? 3 : 2, - EGL_NONE - }; - - gfx_ctx_android_data_t *android = (gfx_ctx_android_data_t*) + android = (gfx_ctx_android_data_t*) calloc(1, sizeof(gfx_ctx_android_data_t)); if (!android) @@ -149,6 +155,7 @@ static bool android_gfx_ctx_init(void *data) RARCH_LOG("Android EGL: GLES version = %d.\n", g_es3 ? 3 : 2); android->g_egl_dpy = eglGetDisplay(EGL_DEFAULT_DISPLAY); + if (!android->g_egl_dpy) { RARCH_ERR("[Android/EGL]: Couldn't get EGL display.\n"); @@ -224,7 +231,8 @@ static void android_gfx_ctx_swap_buffers(void *data) (void)data; - eglSwapBuffers(android->g_egl_dpy, android->g_egl_surf); + if (android) + eglSwapBuffers(android->g_egl_dpy, android->g_egl_surf); } static void android_gfx_ctx_check_window(void *data, bool *quit, @@ -237,6 +245,7 @@ static void android_gfx_ctx_check_window(void *data, bool *quit, *quit = false; android_gfx_ctx_get_video_size(data, &new_width, &new_height); + if (new_width != *width || new_height != *height) { *width = new_width; @@ -264,10 +273,11 @@ static void android_gfx_ctx_update_window_title(void *data) (void)data; - gfx_get_fps(buf, sizeof(buf), fps_draw ? buf_fps : NULL, sizeof(buf_fps)); + if (!fps_draw) + return; - if (fps_draw) - msg_queue_push(g_extern.msg_queue, buf_fps, 1, 1); + gfx_get_fps(buf, sizeof(buf), fps_draw ? buf_fps : NULL, sizeof(buf_fps)); + msg_queue_push(g_extern.msg_queue, buf_fps, 1, 1); } static bool android_gfx_ctx_set_video_mode(void *data, @@ -284,8 +294,10 @@ static bool android_gfx_ctx_set_video_mode(void *data, static void android_gfx_ctx_input_driver(void *data, const input_driver_t **input, void **input_data) { - (void)data; void *androidinput = input_android.init(); + + (void)data; + *input = androidinput ? &input_android : NULL; *input_data = androidinput; } @@ -293,10 +305,12 @@ static void android_gfx_ctx_input_driver(void *data, static gfx_ctx_proc_t android_gfx_ctx_get_proc_address( const char *symbol) { - rarch_assert(sizeof(void*) == sizeof(void (*)(void))); gfx_ctx_proc_t ret; + void *sym__ = NULL; - void *sym__ = eglGetProcAddress(symbol); + rarch_assert(sizeof(void*) == sizeof(void (*)(void))); + + sym__ = eglGetProcAddress(symbol); memcpy(&ret, &sym__, sizeof(void*)); return ret; @@ -305,9 +319,10 @@ static gfx_ctx_proc_t android_gfx_ctx_get_proc_address( static bool android_gfx_ctx_bind_api(void *data, enum gfx_ctx_api api, unsigned major, unsigned minor) { + unsigned version = major * 100 + minor; + (void)data; - unsigned version = major * 100 + minor; if (version > 300) return false; if (version < 300) @@ -341,12 +356,14 @@ static void android_gfx_ctx_bind_hw_render(void *data, bool enable) android->g_use_hw_ctx = enable; - if (android->g_egl_dpy && android->g_egl_surf) - eglMakeCurrent( - android->g_egl_dpy, - android->g_egl_surf, - android->g_egl_surf, - enable ? android->g_egl_hw_ctx : android->g_egl_ctx); + if (!android->g_egl_dpy) + return; + if (!android->g_egl_surf) + return; + + eglMakeCurrent(android->g_egl_dpy, android->g_egl_surf, + android->g_egl_surf, enable ? + android->g_egl_hw_ctx : android->g_egl_ctx); } const gfx_ctx_driver_t gfx_ctx_android = { diff --git a/gfx/context/bbqnx_ctx.c b/gfx/context/bbqnx_ctx.c index 9544400cc0..68835f5b71 100644 --- a/gfx/context/bbqnx_ctx.c +++ b/gfx/context/bbqnx_ctx.c @@ -90,24 +90,41 @@ static void gfx_ctx_qnx_destroy(void *data) static void gfx_ctx_qnx_get_video_size(void *data, unsigned *width, unsigned *height) { + EGLint gl_width, gl_height; + (void)data; - if (g_egl_dpy) - { - EGLint gl_width, gl_height; - eglQuerySurface(g_egl_dpy, g_egl_surf, EGL_WIDTH, &gl_width); - eglQuerySurface(g_egl_dpy, g_egl_surf, EGL_HEIGHT, &gl_height); - *width = gl_width; - *height = gl_height; - } - else - { - *width = 0; - *height = 0; - } + + *width = 0; + *height = 0; + + if (!g_egl_dpy) + return; + + eglQuerySurface(g_egl_dpy, g_egl_surf, EGL_WIDTH, &gl_width); + eglQuerySurface(g_egl_dpy, g_egl_surf, EGL_HEIGHT, &gl_height); + *width = gl_width; + *height = gl_height; } static bool gfx_ctx_qnx_init(void *data) { + EGLint num_config; + EGLint egl_version_major, egl_version_minor; + EGLint context_attributes[] = { + EGL_CONTEXT_CLIENT_VERSION, 2, + EGL_NONE + }; + const EGLint attribs[] = { + EGL_RENDERABLE_TYPE, EGL_OPENGL_ES2_BIT, + EGL_SURFACE_TYPE, EGL_WINDOW_BIT, + EGL_BLUE_SIZE, 8, + EGL_GREEN_SIZE, 8, + EGL_RED_SIZE, 8, + EGL_NONE + }; + int angle, size[2]; + int usage, format = SCREEN_FORMAT_RGBX8888; + /* Create a screen context that will be used to * create an EGL surface to receive libscreen events */ @@ -135,24 +152,6 @@ static bool gfx_ctx_qnx_init(void *data) } } - const EGLint attribs[] = { - EGL_RENDERABLE_TYPE, EGL_OPENGL_ES2_BIT, - EGL_SURFACE_TYPE, EGL_WINDOW_BIT, - EGL_BLUE_SIZE, 8, - EGL_GREEN_SIZE, 8, - EGL_RED_SIZE, 8, - EGL_NONE - }; - EGLint num_config; - EGLint egl_version_major, egl_version_minor; - int format = SCREEN_FORMAT_RGBX8888; - - EGLint context_attributes[] = { - EGL_CONTEXT_CLIENT_VERSION, 2, - EGL_NONE - }; - int usage; - usage = SCREEN_USAGE_OPENGL_ES2 | SCREEN_USAGE_ROTATION; RARCH_LOG("Initializing context\n"); @@ -231,7 +230,7 @@ static bool gfx_ctx_qnx_init(void *data) } #ifndef HAVE_BB10 - int angle = atoi(getenv("ORIENTATION")); + angle = atoi(getenv("ORIENTATION")); screen_display_mode_t screen_mode; if (screen_get_display_property_pv(screen_disp, SCREEN_PROPERTY_MODE, (void**)&screen_mode)) @@ -240,7 +239,6 @@ static bool gfx_ctx_qnx_init(void *data) goto error; } - int size[2]; if (screen_get_window_property_iv(screen_win, SCREEN_PROPERTY_BUFFER_SIZE, size)) { RARCH_ERR("screen_get_window_property_iv [SCREEN_PROPERTY_BUFFER_SIZE] failed.\n"); @@ -249,19 +247,26 @@ static bool gfx_ctx_qnx_init(void *data) int buffer_size[2] = {size[0], size[1]}; - if ((angle == 0) || (angle == 180)) { + if ((angle == 0) || (angle == 180)) + { if (((screen_mode.width > screen_mode.height) && (size[0] < size[1])) || - ((screen_mode.width < screen_mode.height) && (size[0] > size[1]))) { + ((screen_mode.width < screen_mode.height) && (size[0] > size[1]))) + { buffer_size[1] = size[0]; buffer_size[0] = size[1]; } - } else if ((angle == 90) || (angle == 270)){ + } + else if ((angle == 90) || (angle == 270)) + { if (((screen_mode.width > screen_mode.height) && (size[0] > size[1])) || - ((screen_mode.width < screen_mode.height && size[0] < size[1]))) { + ((screen_mode.width < screen_mode.height && size[0] < size[1]))) + { buffer_size[1] = size[0]; buffer_size[0] = size[1]; } - } else { + } + else + { RARCH_ERR("Navigator returned an unexpected orientation angle.\n"); goto error; } @@ -318,12 +323,13 @@ static void gfx_ctx_qnx_swap_buffers(void *data) static void gfx_ctx_qnx_check_window(void *data, bool *quit, bool *resize, unsigned *width, unsigned *height, unsigned frame_count) { + unsigned new_width, new_height; + (void)data; (void)frame_count; *quit = false; - unsigned new_width, new_height; gfx_ctx_qnx_get_video_size(data, &new_width, &new_height); if (new_width != *width || new_height != *height) { @@ -346,13 +352,16 @@ static void gfx_ctx_qnx_set_resize(void *data, unsigned width, unsigned height) static void gfx_ctx_qnx_update_window_title(void *data) { - (void)data; char buf[128], buf_fps[128]; bool fps_draw = g_settings.fps_show; - gfx_get_fps(buf, sizeof(buf), fps_draw ? buf_fps : NULL, sizeof(buf_fps)); - if (fps_draw) - msg_queue_push(g_extern.msg_queue, buf_fps, 1, 1); + (void)data; + + if (!fps_draw) + return; + + gfx_get_fps(buf, sizeof(buf), fps_draw ? buf_fps : NULL, sizeof(buf_fps)); + msg_queue_push(g_extern.msg_queue, buf_fps, 1, 1); } static bool gfx_ctx_qnx_set_video_mode(void *data, @@ -377,10 +386,12 @@ static void gfx_ctx_qnx_input_driver(void *data, static gfx_ctx_proc_t gfx_ctx_qnx_get_proc_address(const char *symbol) { - rarch_assert(sizeof(void*) == sizeof(void (*)(void))); gfx_ctx_proc_t ret; + void *sym__; - void *sym__ = eglGetProcAddress(symbol); + rarch_assert(sizeof(void*) == sizeof(void (*)(void))); + + sym__ = eglGetProcAddress(symbol); memcpy(&ret, &sym__, sizeof(void*)); return ret; @@ -392,7 +403,9 @@ static bool gfx_ctx_qnx_bind_api(void *data, (void)data; (void)major; (void)minor; + g_api = api; + return api == GFX_CTX_OPENGL_ES_API; } @@ -411,10 +424,16 @@ static bool gfx_ctx_qnx_has_windowed(void *data) static void gfx_qnx_ctx_bind_hw_render(void *data, bool enable) { (void)data; + g_use_hw_ctx = enable; - if (g_egl_dpy && g_egl_surf) - eglMakeCurrent(g_egl_dpy, g_egl_surf, - g_egl_surf, enable ? g_egl_hw_ctx : g_egl_ctx); + + if (!g_egl_dpy) + return; + if (!g_egl_surf) + return; + + eglMakeCurrent(g_egl_dpy, g_egl_surf, + g_egl_surf, enable ? g_egl_hw_ctx : g_egl_ctx); } const gfx_ctx_driver_t gfx_ctx_bbqnx = { diff --git a/gfx/context/d3d_ctx.cpp b/gfx/context/d3d_ctx.cpp index a80a53e7b5..e452e1e2f9 100644 --- a/gfx/context/d3d_ctx.cpp +++ b/gfx/context/d3d_ctx.cpp @@ -48,16 +48,17 @@ extern bool d3d_restore(d3d_video_t *data); static void d3d_resize(void *data, unsigned new_width, unsigned new_height) { - (void)data; - d3d_video_t *d3d = (d3d_video_t*)curD3D; + d3d_video_t *d3d = (d3d_video_t*)curD3D; LPDIRECT3DDEVICE d3dr = (LPDIRECT3DDEVICE)d3d->dev; + if (!d3dr) return; - RARCH_LOG("[D3D]: Resize %ux%u.\n", new_width, new_height); + (void)data; if (new_width != d3d->video_info.width || new_height != d3d->video_info.height) { + RARCH_LOG("[D3D]: Resize %ux%u.\n", new_width, new_height); d3d->video_info.width = d3d->screen_width = new_width; d3d->video_info.height = d3d->screen_height = new_height; d3d_restore(d3d); @@ -103,7 +104,7 @@ LRESULT CALLBACK WindowProc(HWND hWnd, UINT message, static void gfx_ctx_d3d_swap_buffers(void *data) { - d3d_video_t *d3d = (d3d_video_t*)data; + d3d_video_t *d3d = (d3d_video_t*)data; LPDIRECT3DDEVICE d3dr = (LPDIRECT3DDEVICE)d3d->dev; d3d_swap(d3d, d3dr); @@ -143,6 +144,7 @@ static void gfx_ctx_d3d_update_title(void *data) static void gfx_ctx_d3d_show_mouse(void *data, bool state) { (void)data; + #ifdef HAVE_WINDOW if (state) while (ShowCursor(TRUE) < 0); @@ -154,6 +156,7 @@ static void gfx_ctx_d3d_show_mouse(void *data, bool state) void d3d_make_d3dpp(void *data, const video_info_t *info, D3DPRESENT_PARAMETERS *d3dpp) { d3d_video_t *d3d = (d3d_video_t*)data; + memset(d3dpp, 0, sizeof(*d3dpp)); #ifdef _XBOX @@ -201,6 +204,7 @@ void d3d_make_d3dpp(void *data, const video_info_t *info, D3DPRESENT_PARAMETERS { #ifdef _XBOX unsigned width, height; + width = 0; height = 0; @@ -266,8 +270,10 @@ void d3d_make_d3dpp(void *data, const video_info_t *info, D3DPRESENT_PARAMETERS static void gfx_ctx_d3d_check_window(void *data, bool *quit, bool *resize, unsigned *width, unsigned *height, unsigned frame_count) { - (void)data; d3d_video_t *d3d = (d3d_video_t*)data; + + (void)data; + *quit = false; *resize = false; @@ -297,12 +303,15 @@ static HANDLE GetFocus(void) static bool gfx_ctx_d3d_has_focus(void *data) { d3d_video_t *d3d = (d3d_video_t*)data; + if (!d3d) + return false; return GetFocus() == d3d->hWnd; } static bool gfx_ctx_d3d_has_windowed(void *data) { (void)data; + #ifdef _XBOX return false; #else @@ -317,6 +326,7 @@ static bool gfx_ctx_d3d_bind_api(void *data, (void)major; (void)minor; (void)api; + #if defined(_XBOX1) return api == GFX_CTX_DIRECT3D8_API; #else @@ -328,7 +338,9 @@ static bool gfx_ctx_d3d_bind_api(void *data, static bool gfx_ctx_d3d_init(void *data) { (void)data; + d3d_quit = false; + return true; } @@ -356,11 +368,13 @@ static void gfx_ctx_d3d_get_video_size(void *data, unsigned *width, unsigned *height) { d3d_video_t *d3d = (d3d_video_t*)data; + #ifdef _XBOX (void)width; (void)height; #if defined(_XBOX360) XVIDEO_MODE video_mode; + XGetVideoMode(&video_mode); *width = video_mode.dwDisplayWidth; @@ -387,11 +401,12 @@ static void gfx_ctx_d3d_get_video_size(void *data, *width = 640; *height = 480; - // Only valid in PAL mode, not valid for HDTV modes! + widescreen_mode = false; + + /* Only valid in PAL mode, not valid for HDTV modes! */ + if(XGetVideoStandard() == XC_VIDEO_STANDARD_PAL_I) { - widescreen_mode = false; - /* Check for 16:9 mode (PAL REGION) */ if(video_mode & XC_VIDEO_FLAGS_WIDESCREEN) { @@ -406,8 +421,6 @@ static void gfx_ctx_d3d_get_video_size(void *data, } else { - widescreen_mode = false; - /* Check for 16:9 mode (NTSC REGIONS) */ if(video_mode & XC_VIDEO_FLAGS_WIDESCREEN) { @@ -447,7 +460,7 @@ static void gfx_ctx_d3d_get_video_size(void *data, static void gfx_ctx_d3d_swap_interval(void *data, unsigned interval) { - d3d_video_t *d3d = (d3d_video_t*)data; + d3d_video_t *d3d = (d3d_video_t*)data; #ifdef _XBOX LPDIRECT3DDEVICE d3dr = (LPDIRECT3DDEVICE)d3d->dev; unsigned d3d_interval = interval ? diff --git a/gfx/context/drm_egl_ctx.c b/gfx/context/drm_egl_ctx.c index 46294dcaf8..50c8235b42 100644 --- a/gfx/context/drm_egl_ctx.c +++ b/gfx/context/drm_egl_ctx.c @@ -264,14 +264,16 @@ static void gfx_ctx_drm_egl_set_resize(void *data, static void gfx_ctx_drm_egl_update_window_title(void *data) { - (void)data; char buf[128], buf_fps[128]; bool fps_draw = g_settings.fps_show; - gfx_get_fps(buf, sizeof(buf), fps_draw ? buf_fps : NULL, sizeof(buf_fps)); + (void)data; - if (fps_draw) - msg_queue_push(g_extern.msg_queue, buf_fps, 1, 1); + if (!fps_draw) + return; + + gfx_get_fps(buf, sizeof(buf), fps_draw ? buf_fps : NULL, sizeof(buf_fps)); + msg_queue_push(g_extern.msg_queue, buf_fps, 1, 1); } static void gfx_ctx_drm_egl_get_video_size(void *data, unsigned *width, unsigned *height) @@ -929,10 +931,15 @@ static void gfx_ctx_drm_egl_bind_hw_render(void *data, bool enable) (void)data; drm->g_use_hw_ctx = enable; - if (drm->g_egl_dpy && drm->g_egl_surf) - eglMakeCurrent(drm->g_egl_dpy, drm->g_egl_surf, - drm->g_egl_surf, - enable ? drm->g_egl_hw_ctx : drm->g_egl_ctx); + + if (!drm->g_egl_dpy) + return; + if (!drm->g_egl_surf) + return; + + eglMakeCurrent(drm->g_egl_dpy, drm->g_egl_surf, + drm->g_egl_surf, + enable ? drm->g_egl_hw_ctx : drm->g_egl_ctx); } const gfx_ctx_driver_t gfx_ctx_drm_egl = { diff --git a/gfx/context/emscriptenegl_ctx.c b/gfx/context/emscriptenegl_ctx.c index 0500a467c6..374c285840 100644 --- a/gfx/context/emscriptenegl_ctx.c +++ b/gfx/context/emscriptenegl_ctx.c @@ -50,9 +50,10 @@ static void gfx_ctx_emscripten_swap_interval(void *data, unsigned interval) static void gfx_ctx_emscripten_check_window(void *data, bool *quit, bool *resize, unsigned *width, unsigned *height, unsigned frame_count) { + int iWidth, iHeight, isFullscreen; + (void)data; (void)frame_count; - int iWidth, iHeight, isFullscreen; emscripten_get_canvas_size(&iWidth, &iHeight, &isFullscreen); *width = (unsigned) iWidth; @@ -84,13 +85,16 @@ static void gfx_ctx_emscripten_set_resize(void *data, static void gfx_ctx_emscripten_update_window_title(void *data) { - (void)data; char buf[128], buf_fps[128]; bool fps_draw = g_settings.fps_show; - gfx_get_fps(buf, sizeof(buf), fps_draw ? buf_fps : NULL, sizeof(buf_fps)); - if (fps_draw) - msg_queue_push(g_extern.msg_queue, buf_fps, 1, 1); + (void)data; + + if (!fps_draw) + return; + + gfx_get_fps(buf, sizeof(buf), fps_draw ? buf_fps : NULL, sizeof(buf_fps)); + msg_queue_push(g_extern.msg_queue, buf_fps, 1, 1); } static void gfx_ctx_emscripten_get_video_size(void *data, @@ -105,19 +109,7 @@ static void gfx_ctx_emscripten_destroy(void *data); static bool gfx_ctx_emscripten_init(void *data) { - (void)data; - EGLint width; - EGLint height; - - RARCH_LOG("[EMSCRIPTEN/EGL]: Initializing...\n"); - if (g_inited) - { - RARCH_LOG("[EMSCRIPTEN/EGL]: Attempted to re-initialize driver.\n"); - return true; - } - - EGLint num_config; - + EGLint width, height, num_config; static const EGLint attribute_list[] = { EGL_RED_SIZE, 8, @@ -127,13 +119,22 @@ static bool gfx_ctx_emscripten_init(void *data) EGL_SURFACE_TYPE, EGL_WINDOW_BIT, EGL_NONE }; - static const EGLint context_attributes[] = { EGL_CONTEXT_CLIENT_VERSION, 2, EGL_NONE }; + (void)data; + + RARCH_LOG("[EMSCRIPTEN/EGL]: Initializing...\n"); + + if (g_inited) + { + RARCH_LOG("[EMSCRIPTEN/EGL]: Attempted to re-initialize driver.\n"); + return true; + } + /* Get an EGL display connection. */ g_egl_dpy = eglGetDisplay(EGL_DEFAULT_DISPLAY); if (!g_egl_dpy) @@ -179,6 +180,7 @@ static bool gfx_ctx_emscripten_set_video_mode(void *data, bool fullscreen) { (void)data; + if (g_inited) return false; @@ -192,6 +194,7 @@ static bool gfx_ctx_emscripten_bind_api(void *data, (void)data; (void)major; (void)minor; + switch (api) { case GFX_CTX_OPENGL_ES_API: @@ -204,6 +207,7 @@ static bool gfx_ctx_emscripten_bind_api(void *data, static void gfx_ctx_emscripten_destroy(void *data) { (void)data; + if (g_egl_dpy) { eglMakeCurrent(g_egl_dpy, EGL_NO_SURFACE, @@ -228,27 +232,32 @@ static void gfx_ctx_emscripten_destroy(void *data) static void gfx_ctx_emscripten_input_driver(void *data, const input_driver_t **input, void **input_data) { + void *rwebinput = NULL; + (void)data; + *input = NULL; - void *rwebinput = input_rwebinput.init(); + rwebinput = input_rwebinput.init(); - if (rwebinput) - { - *input = &input_rwebinput; - *input_data = rwebinput; - } + if (!rwebinput) + return; + + *input = &input_rwebinput; + *input_data = rwebinput; } static bool gfx_ctx_emscripten_has_focus(void *data) { (void)data; + return g_inited; } static bool gfx_ctx_emscripten_has_windowed(void *data) { (void)data; + /* TODO -verify. */ return true; } @@ -262,6 +271,7 @@ static float gfx_ctx_emscripten_translate_aspect(void *data, unsigned width, unsigned height) { (void)data; + return (float)width / height; } @@ -269,6 +279,7 @@ static bool gfx_ctx_emscripten_init_egl_image_buffer(void *data, const video_info_t *video) { (void)data; + return false; } diff --git a/gfx/context/glx_ctx.c b/gfx/context/glx_ctx.c index b9777e07ac..1e468afb2f 100644 --- a/gfx/context/glx_ctx.c +++ b/gfx/context/glx_ctx.c @@ -190,16 +190,20 @@ static void gfx_ctx_glx_set_resize(void *data, static void gfx_ctx_glx_update_window_title(void *data) { - (void)data; char buf[128], buf_fps[128]; + gfx_ctx_glx_data_t *glx = NULL; bool fps_draw = g_settings.fps_show; - gfx_ctx_glx_data_t *glx = (gfx_ctx_glx_data_t*)driver.video_context_data; + + (void)data; + + glx = (gfx_ctx_glx_data_t*)driver.video_context_data; if (gfx_get_fps(buf, sizeof(buf), fps_draw ? buf_fps : NULL, sizeof(buf_fps))) XStoreName(glx->g_dpy, glx->g_win, buf); - if (fps_draw) - msg_queue_push(g_extern.msg_queue, buf_fps, 1, 1); + if (!fps_draw) + return; + msg_queue_push(g_extern.msg_queue, buf_fps, 1, 1); } static void gfx_ctx_glx_get_video_size(void *data, @@ -705,12 +709,13 @@ static void gfx_ctx_glx_bind_hw_render(void *data, bool enable) glx->g_use_hw_ctx = enable; - if (glx->g_dpy && glx->g_glx_win) - { - //RARCH_LOG("[GLX]: Binding context (%s): %p\n", enable ? "RetroArch" : "HW render", enable ? (void*)g_hw_ctx : (void*)g_ctx); - glXMakeContextCurrent(glx->g_dpy, glx->g_glx_win, - glx->g_glx_win, enable ? glx->g_hw_ctx : glx->g_ctx); - } + if (!glx->g_dpy) + return; + if (!glx->g_glx_win) + return; + + glXMakeContextCurrent(glx->g_dpy, glx->g_glx_win, + glx->g_glx_win, enable ? glx->g_hw_ctx : glx->g_ctx); } const gfx_ctx_driver_t gfx_ctx_glx = { diff --git a/gfx/context/mali_fbdev_ctx.c b/gfx/context/mali_fbdev_ctx.c index b777ecfd55..7f23014cf2 100644 --- a/gfx/context/mali_fbdev_ctx.c +++ b/gfx/context/mali_fbdev_ctx.c @@ -91,29 +91,23 @@ static void gfx_ctx_mali_fbdev_get_video_size(void *data, unsigned *width, unsigned *height) { (void)data; + + *width = 0; + *height = 0; + if (g_egl_dpy != EGL_NO_DISPLAY && g_egl_surf != EGL_NO_SURFACE) { *width = g_width; *height = g_height; } - else - { - *width = 0; - *height = 0; - } } static bool gfx_ctx_mali_fbdev_init(void *data) { - (void)data; - - struct sigaction sa = {{0}}; - sa.sa_handler = sighandler; - sa.sa_flags = SA_RESTART; - sigemptyset(&sa.sa_mask); - sigaction(SIGINT, &sa, NULL); - sigaction(SIGTERM, &sa, NULL); + EGLint num_config; + EGLint egl_version_major, egl_version_minor; + EGLint format; static const EGLint attribs[] = { EGL_RENDERABLE_TYPE, EGL_OPENGL_ES2_BIT, EGL_SURFACE_TYPE, EGL_WINDOW_BIT, @@ -123,12 +117,17 @@ static bool gfx_ctx_mali_fbdev_init(void *data) EGL_ALPHA_SIZE, 8, EGL_NONE }; - EGLint num_config; - EGLint egl_version_major, egl_version_minor; - EGLint format; - + struct sigaction sa = {{0}}; - //Disable cursor blinking so it's not visible in RetroArch + sa.sa_handler = sighandler; + sa.sa_flags = SA_RESTART; + sigemptyset(&sa.sa_mask); + sigaction(SIGINT, &sa, NULL); + sigaction(SIGTERM, &sa, NULL); + + (void)data; + + /* Disable cursor blinking so it's not visible in RetroArch. */ system("setterm -cursor off"); RARCH_LOG("[Mali fbdev]: Initializing context\n"); @@ -165,16 +164,19 @@ error: static void gfx_ctx_mali_fbdev_swap_buffers(void *data) { (void)data; + eglSwapBuffers(g_egl_dpy, g_egl_surf); } static void gfx_ctx_mali_fbdev_check_window(void *data, bool *quit, bool *resize, unsigned *width, unsigned *height, unsigned frame_count) { + unsigned new_width, new_height; + (void)frame_count; - unsigned new_width, new_height; gfx_ctx_mali_fbdev_get_video_size(data, &new_width, &new_height); + if (new_width != *width || new_height != *height) { *width = new_width; @@ -195,13 +197,16 @@ static void gfx_ctx_mali_fbdev_set_resize(void *data, static void gfx_ctx_mali_fbdev_update_window_title(void *data) { - (void)data; char buf[128], buf_fps[128]; bool fps_draw = g_settings.fps_show; - gfx_get_fps(buf, sizeof(buf), fps_draw ? buf_fps : NULL, sizeof(buf_fps)); - if (fps_draw) - msg_queue_push(g_extern.msg_queue, buf_fps, 1, 1); + (void)data; + + if (!fps_draw) + return; + + gfx_get_fps(buf, sizeof(buf), fps_draw ? buf_fps : NULL, sizeof(buf_fps)); + msg_queue_push(g_extern.msg_queue, buf_fps, 1, 1); } static bool gfx_ctx_mali_fbdev_set_video_mode(void *data, @@ -209,7 +214,12 @@ static bool gfx_ctx_mali_fbdev_set_video_mode(void *data, bool fullscreen) { struct fb_var_screeninfo vinfo; + static const EGLint attribs[] = { + EGL_CONTEXT_CLIENT_VERSION, 2, /* Use version 2, even for GLES3. */ + EGL_NONE + }; int fb = open("/dev/fb0", O_RDWR, 0); + if (ioctl(fb, FBIOGET_VSCREENINFO, &vinfo) < 0) { RARCH_ERR("Error obtainig framebuffer info.\n"); @@ -226,11 +236,6 @@ static bool gfx_ctx_mali_fbdev_set_video_mode(void *data, native_window.width = vinfo.xres; native_window.height = vinfo.yres; - static const EGLint attribs[] = { - EGL_CONTEXT_CLIENT_VERSION, 2, /* Use version 2, even for GLES3. */ - EGL_NONE - }; - if ((g_egl_surf = eglCreateWindowSurface(g_egl_dpy, g_config, &native_window, 0)) == EGL_NO_SURFACE) { RARCH_ERR("eglCreateWindowSurface failed.\n"); @@ -267,10 +272,12 @@ static void gfx_ctx_mali_fbdev_input_driver(void *data, static gfx_ctx_proc_t gfx_ctx_mali_fbdev_get_proc_address(const char *symbol) { - rarch_assert(sizeof(void*) == sizeof(void (*)(void))); gfx_ctx_proc_t ret; + void *sym__; - void *sym__ = eglGetProcAddress(symbol); + rarch_assert(sizeof(void*) == sizeof(void (*)(void))); + + sym__ = eglGetProcAddress(symbol); memcpy(&ret, &sym__, sizeof(void*)); return ret; diff --git a/gfx/context/ps3_ctx.c b/gfx/context/ps3_ctx.c index 2578d40c67..d106e2cf3f 100644 --- a/gfx/context/ps3_ctx.c +++ b/gfx/context/ps3_ctx.c @@ -65,8 +65,10 @@ static unsigned gfx_ctx_ps3_get_resolution_height(unsigned resolution_id) static float gfx_ctx_ps3_get_aspect_ratio(void *data) { - (void)data; CellVideoOutState videoState; + + (void)data; + cellVideoOutGetState(CELL_VIDEO_OUT_PRIMARY, 0, &videoState); switch (videoState.displayMode.aspect) @@ -82,15 +84,10 @@ static float gfx_ctx_ps3_get_aspect_ratio(void *data) static void gfx_ctx_ps3_get_available_resolutions(void) { + unsigned i; bool defaultresolution; uint32_t resolution_count; uint16_t num_videomodes; - - if (g_extern.console.screen.resolutions.check) - return; - - defaultresolution = true; - uint32_t videomode[] = { CELL_VIDEO_OUT_RESOLUTION_480, CELL_VIDEO_OUT_RESOLUTION_576, @@ -102,10 +99,16 @@ static void gfx_ctx_ps3_get_available_resolutions(void) CELL_VIDEO_OUT_RESOLUTION_1080 }; + if (g_extern.console.screen.resolutions.check) + return; + + defaultresolution = true; + num_videomodes = sizeof(videomode) / sizeof(uint32_t); resolution_count = 0; - for (unsigned i = 0; i < num_videomodes; i++) + + for (i = 0; i < num_videomodes; i++) { if (cellVideoOutGetResolutionAvailability(CELL_VIDEO_OUT_PRIMARY, videomode[i], CELL_VIDEO_OUT_ASPECT_AUTO, 0)) @@ -115,7 +118,7 @@ static void gfx_ctx_ps3_get_available_resolutions(void) g_extern.console.screen.resolutions.list = malloc(resolution_count * sizeof(uint32_t)); g_extern.console.screen.resolutions.count = 0; - for (unsigned i = 0; i < num_videomodes; i++) + for (i = 0; i < num_videomodes; i++) { if (cellVideoOutGetResolutionAvailability(CELL_VIDEO_OUT_PRIMARY, videomode[i], CELL_VIDEO_OUT_ASPECT_AUTO, 0)) @@ -142,15 +145,19 @@ static void gfx_ctx_ps3_get_available_resolutions(void) static void gfx_ctx_ps3_set_swap_interval(void *data, unsigned interval) { gfx_ctx_ps3_data_t *ps3 = (gfx_ctx_ps3_data_t*)driver.video_context_data; + (void)data; + #if defined(HAVE_PSGL) - if (ps3 && ps3->gl_context) - { - if (interval) - glEnable(GL_VSYNC_SCE); - else - glDisable(GL_VSYNC_SCE); - } + if (!ps3) + return; + if (!ps3->gl_context) + return; + + if (interval) + glEnable(GL_VSYNC_SCE); + else + glDisable(GL_VSYNC_SCE); #endif } @@ -158,10 +165,10 @@ static void gfx_ctx_ps3_check_window(void *data, bool *quit, bool *resize, unsigned *width, unsigned *height, unsigned frame_count) { gl_t *gl = data; + *quit = false; *resize = false; - if (gl->quitting) *quit = true; @@ -203,18 +210,22 @@ static void gfx_ctx_ps3_update_window_title(void *data) (void)data; char buf[128], buf_fps[128]; bool fps_draw = g_settings.fps_show; + + if (!fps_draw) + return; + gfx_get_fps(buf, sizeof(buf), fps_draw ? buf_fps : NULL, sizeof(buf_fps)); - - if (fps_draw) - msg_queue_push(g_extern.msg_queue, buf_fps, 1, 1); + msg_queue_push(g_extern.msg_queue, buf_fps, 1, 1); } static void gfx_ctx_ps3_get_video_size(void *data, unsigned *width, unsigned *height) { gfx_ctx_ps3_data_t *ps3 = (gfx_ctx_ps3_data_t*)driver.video_context_data; + (void)data; + #if defined(HAVE_PSGL) if (ps3) psglGetDeviceDimensions(ps3->gl_device, width, height); @@ -223,11 +234,11 @@ static void gfx_ctx_ps3_get_video_size(void *data, static bool gfx_ctx_ps3_init(void *data) { - (void)data; - gfx_ctx_ps3_data_t *ps3 = (gfx_ctx_ps3_data_t*) calloc(1, sizeof(gfx_ctx_ps3_data_t)); + (void)data; + if (!ps3) return false; @@ -333,8 +344,12 @@ static void gfx_ctx_ps3_destroy(void *data) static void gfx_ctx_ps3_input_driver(void *data, const input_driver_t **input, void **input_data) { + void *ps3input = NULL; + (void)data; - void *ps3input = input_ps3.init(); + + ps3input = input_ps3.init(); + *input = ps3input ? &input_ps3 : NULL; *input_data = ps3input; } @@ -345,6 +360,7 @@ static bool gfx_ctx_ps3_bind_api(void *data, (void)data; (void)major; (void)minor; + return api == GFX_CTX_OPENGL_API || GFX_CTX_OPENGL_ES_API; } diff --git a/gfx/context/sdl_gl_ctx.c b/gfx/context/sdl_gl_ctx.c index e037ab7143..979bacc080 100644 --- a/gfx/context/sdl_gl_ctx.c +++ b/gfx/context/sdl_gl_ctx.c @@ -68,9 +68,11 @@ static void sdl_ctx_destroy_resources(gfx_ctx_sdl_data_t *sdl) static bool sdl_ctx_init(void *data) { + gfx_ctx_sdl_data_t *sdl; + (void)data; - gfx_ctx_sdl_data_t *sdl = (gfx_ctx_sdl_data_t*) + sdl = (gfx_ctx_sdl_data_t*) calloc(1, sizeof(gfx_ctx_sdl_data_t)); if (!sdl) @@ -93,7 +95,6 @@ static bool sdl_ctx_init(void *data) driver.video_context_data = sdl; - return true; error: @@ -127,13 +128,15 @@ static void sdl_ctx_destroy(void *data) static bool sdl_ctx_bind_api(void *data, enum gfx_ctx_api api, unsigned major, unsigned minor) { + unsigned profile; + (void)data; #ifdef HAVE_SDL2 if (api != GFX_CTX_OPENGL_API && api != GFX_CTX_OPENGL_ES_API) return false; - unsigned profile = SDL_GL_CONTEXT_PROFILE_COMPATIBILITY; + profile = SDL_GL_CONTEXT_PROFILE_COMPATIBILITY; if (api == GFX_CTX_OPENGL_ES_API) profile = SDL_GL_CONTEXT_PROFILE_ES; @@ -195,6 +198,7 @@ static bool sdl_ctx_set_video_mode(void *data, unsigned width, unsigned height, else { unsigned display = g_settings.video.monitor_index; + sdl->g_win = SDL_CreateWindow("", SDL_WINDOWPOS_UNDEFINED_DISPLAY(display), SDL_WINDOWPOS_UNDEFINED_DISPLAY(display), width, height, SDL_WINDOW_OPENGL | fsflag); @@ -271,8 +275,8 @@ static void sdl_ctx_get_video_size(void *data, static void sdl_ctx_update_window_title(void *data) { - gfx_ctx_sdl_data_t *sdl = (gfx_ctx_sdl_data_t*)driver.video_context_data; char buf[128], buf_fps[128]; + gfx_ctx_sdl_data_t *sdl = (gfx_ctx_sdl_data_t*)driver.video_context_data; bool fps_draw = g_settings.fps_show; if (!sdl) @@ -289,18 +293,16 @@ static void sdl_ctx_update_window_title(void *data) if (fps_draw) msg_queue_push(g_extern.msg_queue, buf_fps, 1, 1); - - (void)data; } static void sdl_ctx_check_window(void *data, bool *quit, bool *resize,unsigned *width, unsigned *height, unsigned frame_count) { + SDL_Event event; gfx_ctx_sdl_data_t *sdl = (gfx_ctx_sdl_data_t*)driver.video_context_data; (void)data; - SDL_Event event; SDL_PumpEvents(); #ifdef HAVE_SDL2 @@ -357,14 +359,15 @@ static void sdl_ctx_set_resize(void *data, unsigned width, unsigned height) static bool sdl_ctx_has_focus(void *data) { + unsigned flags; (void)data; #ifdef HAVE_SDL2 gfx_ctx_sdl_data_t *sdl = (gfx_ctx_sdl_data_t*)driver.video_context_data; - unsigned flags = (SDL_WINDOW_INPUT_FOCUS | SDL_WINDOW_MOUSE_FOCUS); + flags = (SDL_WINDOW_INPUT_FOCUS | SDL_WINDOW_MOUSE_FOCUS); return (SDL_GetWindowFlags(sdl->g_win) & flags) == flags; #else - unsigned flags = (SDL_APPINPUTFOCUS | SDL_APPACTIVE); + flags = (SDL_APPINPUTFOCUS | SDL_APPACTIVE); return (SDL_GetAppState() & flags) == flags; #endif } diff --git a/gfx/context/vc_egl_ctx.c b/gfx/context/vc_egl_ctx.c index a58cb27dfd..c3b2c3c60b 100644 --- a/gfx/context/vc_egl_ctx.c +++ b/gfx/context/vc_egl_ctx.c @@ -117,25 +117,31 @@ static void gfx_ctx_vc_set_resize(void *data, unsigned width, unsigned height) static void gfx_ctx_vc_update_window_title(void *data) { - (void)data; char buf[128], buf_fps[128]; bool fps_draw = g_settings.fps_show; - gfx_get_fps(buf, sizeof(buf), fps_draw ? buf_fps : NULL, sizeof(buf_fps)); - if (fps_draw) - msg_queue_push(g_extern.msg_queue, buf_fps, 1, 1); + (void)data; + + if (!fps_draw) + return; + + gfx_get_fps(buf, sizeof(buf), fps_draw ? buf_fps : NULL, sizeof(buf_fps)); + msg_queue_push(g_extern.msg_queue, buf_fps, 1, 1); } static void gfx_ctx_vc_get_video_size(void *data, unsigned *width, unsigned *height) { (void)data; + if (g_settings.video.fullscreen_x != 0 && - g_settings.video.fullscreen_y != 0) { + g_settings.video.fullscreen_y != 0) + { *width = g_settings.video.fullscreen_x; *height = g_settings.video.fullscreen_y; } - else { + else + { *width = g_fb_width; *height = g_fb_height; } @@ -145,13 +151,6 @@ static void gfx_ctx_vc_destroy(void *data); static bool gfx_ctx_vc_init(void *data) { - RARCH_LOG("[VC/EGL]: Initializing...\n"); - if (g_inited) - { - RARCH_ERR("[VC/EGL]: Attempted to re-initialize driver.\n"); - return false; - } - EGLint num_config; static EGL_DISPMANX_WINDOW_T nativewindow; @@ -178,6 +177,13 @@ static bool gfx_ctx_vc_init(void *data) EGL_NONE }; + RARCH_LOG("[VC/EGL]: Initializing...\n"); + if (g_inited) + { + RARCH_ERR("[VC/EGL]: Attempted to re-initialize driver.\n"); + return false; + } + bcm_host_init(); /* Get an EGL display connection. */ @@ -221,15 +227,19 @@ static bool gfx_ctx_vc_init(void *data) src_rect.x = 0; src_rect.y = 0; + if (g_settings.video.fullscreen_x != 0 && - g_settings.video.fullscreen_y != 0) { + g_settings.video.fullscreen_y != 0) + { src_rect.width = g_settings.video.fullscreen_x << 16; src_rect.height = g_settings.video.fullscreen_y << 16; } - else { + else + { src_rect.width = g_fb_width << 16; src_rect.height = g_fb_height << 16; } + dispman_display = vc_dispmanx_display_open(0 /* LCD */); vc_dispmanx_display_get_info(dispman_display, &dispman_modeinfo); dispman_update = vc_dispmanx_update_start(0); @@ -245,11 +255,13 @@ static bool gfx_ctx_vc_init(void *data) nativewindow.element = dispman_element; if (g_settings.video.fullscreen_x != 0 && - g_settings.video.fullscreen_y != 0) { + g_settings.video.fullscreen_y != 0) + { nativewindow.width = g_settings.video.fullscreen_x; nativewindow.height = g_settings.video.fullscreen_y; } - else { + else + { nativewindow.width = g_fb_width; nativewindow.height = g_fb_height; } @@ -274,10 +286,11 @@ static bool gfx_ctx_vc_set_video_mode(void *data, unsigned width, unsigned height, bool fullscreen) { + struct sigaction sa = {{0}}; + if (g_inited) return false; - struct sigaction sa = {{0}}; sa.sa_handler = sighandler; sa.sa_flags = SA_RESTART; sigemptyset(&sa.sa_mask); @@ -287,6 +300,7 @@ static bool gfx_ctx_vc_set_video_mode(void *data, gfx_ctx_vc_swap_interval(data, g_interval); g_inited = true; + return true; } @@ -296,7 +310,9 @@ static bool gfx_ctx_vc_bind_api(void *data, (void)data; (void)major; (void)minor; + g_api = api; + switch (api) { case GFX_CTX_OPENGL_API: @@ -314,6 +330,7 @@ static void gfx_ctx_vc_destroy(void *data) { (void)data; unsigned i; + if (g_egl_dpy) { for (i = 0; i < MAX_EGLIMAGE_TEXTURES; i++) @@ -431,6 +448,14 @@ static float gfx_ctx_vc_translate_aspect(void *data, static bool gfx_ctx_vc_init_egl_image_buffer(void *data, const video_info_t *video) { + EGLBoolean result; + EGLint pbufsurface_list[] = + { + EGL_WIDTH, g_egl_res, + EGL_HEIGHT, g_egl_res, + EGL_NONE + }; + /* Don't bother, we just use VGImages for our EGLImage anyway. */ if (g_api == GFX_CTX_OPENVG_API) return false; @@ -446,15 +471,6 @@ static bool gfx_ctx_vc_init_egl_image_buffer(void *data, g_egl_res = video->input_scale * RARCH_SCALE_BASE; - EGLint pbufsurface_list[] = - { - EGL_WIDTH, g_egl_res, - EGL_HEIGHT, g_egl_res, - EGL_NONE - }; - - EGLBoolean result; - eglBindAPI(EGL_OPENVG_API); g_pbuff_surf = eglCreatePbufferSurface(g_egl_dpy, g_config, pbufsurface_list); if (g_pbuff_surf == EGL_NO_SURFACE) @@ -552,11 +568,16 @@ static bool gfx_ctx_vc_write_egl_image(void *data, const void *frame, unsigned w static void gfx_ctx_vc_bind_hw_render(void *data, bool enable) { (void)data; + g_use_hw_ctx = enable; - if (g_egl_dpy && g_egl_surf) - eglMakeCurrent(g_egl_dpy, g_egl_surf, - g_egl_surf, enable ? g_egl_hw_ctx : g_egl_ctx); + if (!g_egl_dpy) + return; + if (!g_egl_surf) + return; + + eglMakeCurrent(g_egl_dpy, g_egl_surf, + g_egl_surf, enable ? g_egl_hw_ctx : g_egl_ctx); } const gfx_ctx_driver_t gfx_ctx_videocore = { diff --git a/gfx/context/vivante_fbdev_ctx.c b/gfx/context/vivante_fbdev_ctx.c index 7fb841deda..cb7ca3ebc1 100644 --- a/gfx/context/vivante_fbdev_ctx.c +++ b/gfx/context/vivante_fbdev_ctx.c @@ -39,8 +39,11 @@ static void sighandler(int sig) static void gfx_ctx_vivante_set_swap_interval(void *data, unsigned interval) { (void)data; - if (g_egl_dpy) - eglSwapInterval(g_egl_dpy, interval); + + if (!g_egl_dpy) + return; + + eglSwapInterval(g_egl_dpy, interval); } static void gfx_ctx_vivante_destroy(void *data) @@ -75,32 +78,27 @@ static void gfx_ctx_vivante_get_video_size(void *data, unsigned *width, unsigned *height) { (void)data; + + *width = 0; + *height = 0; + if (g_egl_dpy != EGL_NO_DISPLAY && g_egl_surf != EGL_NO_SURFACE) { EGLint gl_width, gl_height; + eglQuerySurface(g_egl_dpy, g_egl_surf, EGL_WIDTH, &gl_width); eglQuerySurface(g_egl_dpy, g_egl_surf, EGL_HEIGHT, &gl_height); *width = gl_width; *height = gl_height; } - else - { - *width = 0; - *height = 0; - } } static bool gfx_ctx_vivante_init(void *data) { - (void)data; - + EGLint num_config; + EGLint egl_version_major, egl_version_minor; + EGLint format; struct sigaction sa = {{0}}; - sa.sa_handler = sighandler; - sa.sa_flags = SA_RESTART; - sigemptyset(&sa.sa_mask); - sigaction(SIGINT, &sa, NULL); - sigaction(SIGTERM, &sa, NULL); - static const EGLint attribs[] = { #if 0 EGL_RENDERABLE_TYPE, EGL_OPENGL_ES2_BIT, @@ -113,9 +111,14 @@ static bool gfx_ctx_vivante_init(void *data) EGL_SAMPLES, 0, EGL_NONE }; - EGLint num_config; - EGLint egl_version_major, egl_version_minor; - EGLint format; + + (void)data; + + sa.sa_handler = sighandler; + sa.sa_flags = SA_RESTART; + sigemptyset(&sa.sa_mask); + sigaction(SIGINT, &sa, NULL); + sigaction(SIGTERM, &sa, NULL); RARCH_LOG("[Vivante fbdev]: Initializing context\n"); @@ -134,7 +137,6 @@ static bool gfx_ctx_vivante_init(void *data) RARCH_LOG("[Vivante fbdev]: EGL version: %d.%d\n", egl_version_major, egl_version_minor); - if (!eglChooseConfig(g_egl_dpy, attribs, &g_config, 1, &num_config)) { RARCH_ERR("[Vivante fbdev]: eglChooseConfig failed.\n"); @@ -158,10 +160,12 @@ static void gfx_ctx_vivante_swap_buffers(void *data) static void gfx_ctx_vivante_check_window(void *data, bool *quit, bool *resize, unsigned *width, unsigned *height, unsigned frame_count) { + unsigned new_width, new_height; + (void)frame_count; - unsigned new_width, new_height; gfx_ctx_vivante_get_video_size(data, &new_width, &new_height); + if (new_width != *width || new_height != *height) { *width = new_width; @@ -182,19 +186,28 @@ static void gfx_ctx_vivante_set_resize(void *data, static void gfx_ctx_vivante_update_window_title(void *data) { - (void)data; char buf[128], buf_fps[128]; bool fps_draw = g_settings.fps_show; - gfx_get_fps(buf, sizeof(buf), fps_draw ? buf_fps : NULL, sizeof(buf_fps)); - if (fps_draw) - msg_queue_push(g_extern.msg_queue, buf_fps, 1, 1); + (void)data; + + if (!fps_draw) + return; + + gfx_get_fps(buf, sizeof(buf), fps_draw ? buf_fps : NULL, sizeof(buf_fps)); + msg_queue_push(g_extern.msg_queue, buf_fps, 1, 1); } static bool gfx_ctx_vivante_set_video_mode(void *data, unsigned width, unsigned height, bool fullscreen) { + EGLNativeWindowType window; + static const EGLint attribs[] = { + EGL_CONTEXT_CLIENT_VERSION, 2, /* Use version 2, even for GLES3. */ + EGL_NONE + }; + /* Pick some arbitrary default. */ if (!width || !fullscreen) width = 1280; @@ -204,13 +217,9 @@ static bool gfx_ctx_vivante_set_video_mode(void *data, g_width = width; g_height = height; - static const EGLint attribs[] = { - EGL_CONTEXT_CLIENT_VERSION, 2, /* Use version 2, even for GLES3. */ - EGL_NONE - }; - - EGLNativeWindowType window = fbCreateWindow(fbGetDisplayByIndex(0), 0, 0, 0, 0); + window = fbCreateWindow(fbGetDisplayByIndex(0), 0, 0, 0, 0); g_egl_surf = eglCreateWindowSurface(g_egl_dpy, g_config, window, 0); + if (g_egl_surf == EGL_NO_SURFACE) { RARCH_ERR("eglCreateWindowSurface failed.\n"); @@ -248,10 +257,12 @@ static void gfx_ctx_vivante_input_driver(void *data, static gfx_ctx_proc_t gfx_ctx_vivante_get_proc_address(const char *symbol) { - rarch_assert(sizeof(void*) == sizeof(void (*)(void))); gfx_ctx_proc_t ret; + void *sym__; - void *sym__ = eglGetProcAddress(symbol); + rarch_assert(sizeof(void*) == sizeof(void (*)(void))); + + sym__ = eglGetProcAddress(symbol); memcpy(&ret, &sym__, sizeof(void*)); return ret; diff --git a/gfx/context/wayland_ctx.c b/gfx/context/wayland_ctx.c index 6e5bb2c8d9..a38885ae7f 100644 --- a/gfx/context/wayland_ctx.c +++ b/gfx/context/wayland_ctx.c @@ -206,6 +206,7 @@ static void egl_report_error(void) { EGLint error = eglGetError(); const char *str = NULL; + switch (error) { case EGL_SUCCESS: @@ -286,11 +287,15 @@ static void gfx_ctx_wl_check_window(void *data, bool *quit, bool *resize, unsigned *width, unsigned *height, unsigned frame_count) { + unsigned new_width, new_height; + (void)frame_count; flush_wayland_fd(); - unsigned new_width = *width, new_height = *height; + new_width = *width; + new_height = *height; + gfx_ctx_wl_get_video_size(data, &new_width, &new_height); if (new_width != *width || new_height != *height) @@ -331,9 +336,11 @@ static void gfx_ctx_wl_update_window_title(void *data) driver.video_context_data; (void)data; + if (gfx_get_fps(buf, sizeof(buf), fps_draw ? buf_fps : NULL, sizeof(buf_fps))) wl_shell_surface_set_title(wl->g_shell_surf, buf); + if (fps_draw) msg_queue_push(g_extern.msg_queue, buf_fps, 1, 1); } @@ -363,8 +370,6 @@ static void gfx_ctx_wl_get_video_size(void *data, static bool gfx_ctx_wl_init(void *data) { - (void)data; - static const EGLint egl_attribs_gl[] = { WL_EGL_ATTRIBS_BASE, EGL_RENDERABLE_TYPE, EGL_OPENGL_BIT, @@ -398,6 +403,8 @@ static bool gfx_ctx_wl_init(void *data) gfx_ctx_wayland_data_t *wl = (gfx_ctx_wayland_data_t*) calloc(1, sizeof(gfx_ctx_wayland_data_t)); + (void)data; + if (!wl) return false; @@ -478,7 +485,6 @@ static bool gfx_ctx_wl_init(void *data) goto error; } - return true; error: @@ -556,11 +562,11 @@ static EGLint *egl_fill_attribs(EGLint *attr) static void gfx_ctx_wl_destroy(void *data) { - (void)data; - gfx_ctx_wayland_data_t *wl = (gfx_ctx_wayland_data_t*) driver.video_context_data; + (void)data; + if (!wl) return; @@ -673,9 +679,11 @@ static bool gfx_ctx_wl_bind_api(void *data, enum gfx_ctx_api api, unsigned major, unsigned minor) { (void)data; + g_major = major; g_minor = minor; g_api = api; + switch (api) { case GFX_CTX_OPENGL_API: @@ -706,9 +714,13 @@ static void gfx_ctx_wl_bind_hw_render(void *data, bool enable) wl->g_use_hw_ctx = enable; - if (wl->g_egl_dpy && wl->g_egl_surf) - eglMakeCurrent(wl->g_egl_dpy, wl->g_egl_surf, wl->g_egl_surf, - enable ? wl->g_egl_hw_ctx : wl->g_egl_ctx); + if (!wl->g_egl_dpy) + return; + if (!wl->g_egl_surf) + return; + + eglMakeCurrent(wl->g_egl_dpy, wl->g_egl_surf, wl->g_egl_surf, + enable ? wl->g_egl_hw_ctx : wl->g_egl_ctx); } static void keyboard_handle_keymap(void* data, diff --git a/gfx/context/wgl_ctx.c b/gfx/context/wgl_ctx.c index 895ef2df09..a434583bce 100644 --- a/gfx/context/wgl_ctx.c +++ b/gfx/context/wgl_ctx.c @@ -101,17 +101,23 @@ static void setup_pixel_format(HDC hdc) static void create_gl_context(HWND hwnd) { + bool core_context; + bool debug = g_extern.system.hw_render_callback.debug_context; + g_hdc = GetDC(hwnd); setup_pixel_format(g_hdc); #ifdef GL_DEBUG - bool debug = true; -#else - bool debug = g_extern.system.hw_render_callback.debug_context; + debug = true; #endif - bool core_context = (g_major * 1000 + g_minor) >= 3001; + core_context = (g_major * 1000 + g_minor) >= 3001; - if (!g_hrc) + if (g_hrc) + { + RARCH_LOG("[WGL]: Using cached GL context.\n"); + driver.video_cache_context_ack = true; + } + else { g_hrc = wglCreateContext(g_hdc); @@ -131,11 +137,6 @@ static void create_gl_context(HWND hwnd) g_quit = true; } } - else - { - RARCH_LOG("[WGL]: Using cached GL context.\n"); - driver.video_cache_context_ack = true; - } if (g_hrc) { @@ -280,21 +281,24 @@ static void gfx_ctx_wgl_swap_interval(void *data, unsigned interval) (void)data; g_interval = interval; - if (g_hrc && p_swap_interval) - { - RARCH_LOG("[WGL]: wglSwapInterval(%u)\n", g_interval); - if (!p_swap_interval(g_interval)) - RARCH_WARN("[WGL]: wglSwapInterval() failed.\n"); - } + if (!g_hrc) + return; + if (!p_swap_interval) + return; + + RARCH_LOG("[WGL]: wglSwapInterval(%u)\n", g_interval); + if (!p_swap_interval(g_interval)) + RARCH_WARN("[WGL]: wglSwapInterval() failed.\n"); } static void gfx_ctx_wgl_check_window(void *data, bool *quit, bool *resize, unsigned *width, unsigned *height, unsigned frame_count) { + MSG msg; + (void)data; (void)frame_count; - MSG msg; while (PeekMessage(&msg, g_hwnd, 0, 0, PM_REMOVE)) { TranslateMessage(&msg); @@ -302,6 +306,7 @@ static void gfx_ctx_wgl_check_window(void *data, bool *quit, } *quit = g_quit; + if (g_resized) { *resize = true; @@ -327,9 +332,11 @@ static void gfx_ctx_wgl_set_resize(void *data, static void gfx_ctx_wgl_update_window_title(void *data) { - (void)data; char buf[128], buf_fps[128]; bool fps_draw = g_settings.fps_show; + + (void)data; + if (gfx_get_fps(buf, sizeof(buf), fps_draw ? buf_fps : NULL, sizeof(buf_fps))) SetWindowText(g_hwnd, buf); @@ -340,6 +347,7 @@ static void gfx_ctx_wgl_update_window_title(void *data) static void gfx_ctx_wgl_get_video_size(void *data, unsigned *width, unsigned *height) { (void)data; + if (!g_hwnd) { HMONITOR hm_to_use = NULL; @@ -366,7 +374,10 @@ static BOOL CALLBACK monitor_enum_proc(HMONITOR hMonitor, static bool gfx_ctx_wgl_init(void *data) { + WNDCLASSEX wndclass = {0}; + (void)data; + if (g_inited) return false; @@ -376,7 +387,6 @@ static bool gfx_ctx_wgl_init(void *data) g_num_mons = 0; EnumDisplayMonitors(NULL, NULL, monitor_enum_proc, 0); - WNDCLASSEX wndclass = {0}; wndclass.cbSize = sizeof(wndclass); wndclass.style = CS_HREDRAW | CS_VREDRAW | CS_OWNDC; wndclass.lpfnWndProc = WndProc; @@ -396,6 +406,7 @@ static bool gfx_ctx_wgl_init(void *data) static bool set_fullscreen(unsigned width, unsigned height, char *dev_name) { DEVMODE devmode; + memset(&devmode, 0, sizeof(devmode)); devmode.dmSize = sizeof(DEVMODE); devmode.dmPelsWidth = width; @@ -416,11 +427,13 @@ static void show_cursor(bool show) static void monitor_info(MONITORINFOEX *mon, HMONITOR *hm_to_use) { + unsigned fs_monitor; + if (!g_last_hm) g_last_hm = MonitorFromWindow(GetDesktopWindow(), MONITOR_DEFAULTTONEAREST); *hm_to_use = g_last_hm; - unsigned fs_monitor = g_settings.video.monitor_index; + fs_monitor = g_settings.video.monitor_index; if (fs_monitor && fs_monitor <= g_num_mons && g_all_hms[fs_monitor - 1]) *hm_to_use = g_all_hms[fs_monitor - 1]; @@ -434,18 +447,21 @@ static bool gfx_ctx_wgl_set_video_mode(void *data, bool fullscreen) { DWORD style; - RECT rect = {0}; - - HMONITOR hm_to_use = NULL; + MSG msg; + RECT mon_rect; MONITORINFOEX current_mon; + bool windowed_full; + RECT rect = {0}; + HMONITOR hm_to_use = NULL; monitor_info(¤t_mon, &hm_to_use); - RECT mon_rect = current_mon.rcMonitor; + mon_rect = current_mon.rcMonitor; g_resize_width = width; g_resize_height = height; - bool windowed_full = g_settings.video.windowed_fullscreen; + windowed_full = g_settings.video.windowed_fullscreen; + if (fullscreen) { if (windowed_full) @@ -461,7 +477,7 @@ static bool gfx_ctx_wgl_set_video_mode(void *data, if (!set_fullscreen(width, height, current_mon.szDevice)) goto error; - // display settings might have changed, get new coordinates + /* Display settings might have changed, get new coordinates. */ GetMonitorInfo(hm_to_use, (MONITORINFO*)¤t_mon); mon_rect = current_mon.rcMonitor; g_restore_desktop = true; @@ -496,8 +512,7 @@ static bool gfx_ctx_wgl_set_video_mode(void *data, show_cursor(!fullscreen); - // Wait until GL context is created (or failed to do so ...) - MSG msg; + /* Wait until GL context is created (or failed to do so ...) */ while (!g_inited && !g_quit && GetMessage(&msg, g_hwnd, 0, 0)) { TranslateMessage(&msg); @@ -525,6 +540,7 @@ error: static void gfx_ctx_wgl_destroy(void *data) { (void)data; + if (g_hrc) { glFinish(); @@ -573,7 +589,9 @@ static void gfx_ctx_wgl_input_driver(void *data, const input_driver_t **input, void **input_data) { (void)data; + dinput_wgl = input_dinput.init(); + *input = dinput_wgl ? &input_dinput : NULL; *input_data = dinput_wgl; } @@ -581,6 +599,7 @@ static void gfx_ctx_wgl_input_driver(void *data, static bool gfx_ctx_wgl_has_focus(void *data) { (void)data; + if (!g_inited) return false; @@ -603,8 +622,10 @@ static bool gfx_ctx_wgl_bind_api(void *data, enum gfx_ctx_api api, unsigned major, unsigned minor) { (void)data; + g_major = major; g_minor = minor; + return api == GFX_CTX_OPENGL_API; } @@ -617,6 +638,7 @@ static void gfx_ctx_wgl_show_mouse(void *data, bool state) static void gfx_ctx_wgl_bind_hw_render(void *data, bool enable) { g_use_hw_ctx = enable; + if (g_hdc) wglMakeCurrent(g_hdc, enable ? g_hw_hrc : g_hrc); } diff --git a/gfx/context/xegl_ctx.c b/gfx/context/xegl_ctx.c index 5a1b99a52a..46b7e3d77c 100644 --- a/gfx/context/xegl_ctx.c +++ b/gfx/context/xegl_ctx.c @@ -122,23 +122,29 @@ static void gfx_ctx_xegl_swap_interval(void *data, unsigned interval) { (void)data; g_interval = interval; - if (g_egl_dpy && eglGetCurrentContext()) + + if (!g_egl_dpy) + return; + if (!(eglGetCurrentContext())) + return; + + RARCH_LOG("[X/EGL]: eglSwapInterval(%u)\n", g_interval); + if (!eglSwapInterval(g_egl_dpy, g_interval)) { - RARCH_LOG("[X/EGL]: eglSwapInterval(%u)\n", g_interval); - if (!eglSwapInterval(g_egl_dpy, g_interval)) - { - RARCH_ERR("[X/EGL]: eglSwapInterval() failed.\n"); - egl_report_error(); - } + RARCH_ERR("[X/EGL]: eglSwapInterval() failed.\n"); + egl_report_error(); } } static void gfx_ctx_xegl_check_window(void *data, bool *quit, bool *resize, unsigned *width, unsigned *height, unsigned frame_count) { + XEvent event; + unsigned new_width = *width; + unsigned new_height = *height; + (void)frame_count; - unsigned new_width = *width, new_height = *height; gfx_ctx_xegl_get_video_size(data, &new_width, &new_height); if (new_width != *width || new_height != *height) @@ -148,12 +154,13 @@ static void gfx_ctx_xegl_check_window(void *data, bool *quit, *height = new_height; } - XEvent event; while (XPending(g_dpy)) { + bool filter; + /* Can get events from older windows. Check this. */ XNextEvent(g_dpy, &event); - bool filter = XFilterEvent(&event, g_win); + filter = XFilterEvent(&event, g_win); switch (event.type) { @@ -204,9 +211,11 @@ static void gfx_ctx_xegl_set_resize(void *data, static void gfx_ctx_xegl_update_window_title(void *data) { - (void)data; char buf[128], buf_fps[128]; bool fps_draw = g_settings.fps_show; + + (void)data; + if (gfx_get_fps(buf, sizeof(buf), fps_draw ? buf_fps : NULL, sizeof(buf_fps))) XStoreName(g_dpy, g_win, buf); @@ -219,6 +228,7 @@ static void gfx_ctx_xegl_get_video_size(void *data, unsigned *width, unsigned *height) { (void)data; + if (!g_dpy || g_win == None) { Display *dpy = XOpenDisplay(NULL); @@ -255,11 +265,6 @@ static void gfx_ctx_xegl_get_video_size(void *data, static bool gfx_ctx_xegl_init(void *data) { - if (g_inited) - return false; - - XInitThreads(); - static const EGLint egl_attribs_gl[] = { XEGL_ATTRIBS_BASE, EGL_RENDERABLE_TYPE, EGL_OPENGL_BIT, @@ -287,6 +292,12 @@ static bool gfx_ctx_xegl_init(void *data) }; const EGLint *attrib_ptr; + + if (g_inited) + return false; + + XInitThreads(); + switch (g_api) { case GFX_CTX_OPENGL_API: @@ -365,10 +376,10 @@ static EGLint *egl_fill_attribs(EGLint *attr) { unsigned version = g_major * 1000 + g_minor; bool core = version >= 3001; -#ifdef GL_DEBUG - bool debug = true; -#else bool debug = g_extern.system.hw_render_callback.debug_context; + +#ifdef GL_DEBUG + debug = true; #endif if (core) @@ -424,35 +435,37 @@ static bool gfx_ctx_xegl_set_video_mode(void *data, unsigned width, unsigned height, bool fullscreen) { + EGLint egl_attribs[16]; + EGLint *attr; + EGLint vid, num_visuals; + bool windowed_full; + bool true_full = false; + int x_off = 0; + int y_off = 0; struct sigaction sa = {{0}}; + XVisualInfo temp = {0}; + XSetWindowAttributes swa = {0}; + XVisualInfo *vi = NULL; + sa.sa_handler = sighandler; sa.sa_flags = SA_RESTART; sigemptyset(&sa.sa_mask); sigaction(SIGINT, &sa, NULL); sigaction(SIGTERM, &sa, NULL); - XVisualInfo temp = {0}; - XSetWindowAttributes swa = {0}; - XVisualInfo *vi = NULL; - bool windowed_full = g_settings.video.windowed_fullscreen; - bool true_full = false; - int x_off = 0; - int y_off = 0; + windowed_full = g_settings.video.windowed_fullscreen; + true_full = false; int (*old_handler)(Display*, XErrorEvent*) = NULL; - EGLint egl_attribs[16]; - EGLint *attr = egl_attribs; - + attr = egl_attribs; attr = egl_fill_attribs(attr); - EGLint vid; if (!eglGetConfigAttrib(g_egl_dpy, g_config, EGL_NATIVE_VISUAL_ID, &vid)) goto error; temp.visualid = vid; - EGLint num_visuals; vi = XGetVisualInfo(g_dpy, VisualIDMask, &temp, &num_visuals); if (!vi) goto error; @@ -481,6 +494,7 @@ static bool gfx_ctx_xegl_set_video_mode(void *data, { unsigned new_width = width; unsigned new_height = height; + if (x11_get_xinerama_coord(g_dpy, g_screen, &x_off, &y_off, &new_width, &new_height)) RARCH_LOG("[X/EGL]: Using Xinerama on screen #%u.\n", g_screen); else @@ -507,6 +521,7 @@ static bool gfx_ctx_xegl_set_video_mode(void *data, attr != egl_attribs ? egl_attribs : NULL); RARCH_LOG("[X/EGL]: Created context: %p.\n", (void*)g_egl_ctx); + if (g_egl_ctx == EGL_NO_CONTEXT) goto error; @@ -609,7 +624,9 @@ error: static void gfx_ctx_xegl_destroy(void *data) { (void)data; + x11_destroy_input_context(&g_xim, &g_xic); + if (g_egl_dpy) { if (g_egl_ctx) @@ -677,20 +694,25 @@ static void gfx_ctx_xegl_destroy(void *data) static void gfx_ctx_xegl_input_driver(void *data, const input_driver_t **input, void **input_data) { + void *xinput; + (void)data; - void *xinput = input_x.init(); + xinput = input_x.init(); + *input = xinput ? &input_x : NULL; *input_data = xinput; } static bool gfx_ctx_xegl_has_focus(void *data) { + Window win; + int rev; + (void)data; + if (!g_inited) return false; - Window win; - int rev; XGetInputFocus(g_dpy, &win, &rev); return (win == g_win && g_has_focus) || g_true_full; @@ -713,9 +735,11 @@ static bool gfx_ctx_xegl_bind_api(void *data, enum gfx_ctx_api api, unsigned major, unsigned minor) { (void)data; + g_major = major; g_minor = minor; g_api = api; + switch (api) { case GFX_CTX_OPENGL_API: @@ -747,9 +771,14 @@ static void gfx_ctx_xegl_bind_hw_render(void *data, bool enable) { (void)data; g_use_hw_ctx = enable; - if (g_egl_dpy && g_egl_surf) - eglMakeCurrent(g_egl_dpy, g_egl_surf, - g_egl_surf, enable ? g_egl_hw_ctx : g_egl_ctx); + + if (!g_egl_dpy) + return; + if (!g_egl_surf) + return; + + eglMakeCurrent(g_egl_dpy, g_egl_surf, + g_egl_surf, enable ? g_egl_hw_ctx : g_egl_ctx); } const gfx_ctx_driver_t gfx_ctx_x_egl = { From 7f30aee0936b15abaaf205c84c378206bba0d6cc Mon Sep 17 00:00:00 2001 From: twinaphex Date: Sat, 10 Jan 2015 18:23:07 +0100 Subject: [PATCH 006/156] Start documenting gfx_common.c --- gfx/gfx_common.c | 28 +++++++++++++++++++++++++--- gfx/gfx_common.h | 38 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 63 insertions(+), 3 deletions(-) diff --git a/gfx/gfx_common.c b/gfx/gfx_common.c index 24b8ce815c..193667f4b9 100644 --- a/gfx/gfx_common.c +++ b/gfx/gfx_common.c @@ -151,6 +151,17 @@ void gfx_set_dwm(void) } #endif +/** + * gfx_scale_integer: + * @vp : Viewport handle + * @width : Width. + * @height : Height. + * @aspect_ratio : Aspect ratio (in float). + * @keep_aspect : Preserve aspect ratio? + * + * Gets new viewport scaling dimensions based on + * scaled integer aspect ratio. + **/ void gfx_scale_integer(struct rarch_viewport *vp, unsigned width, unsigned height, float aspect_ratio, bool keep_aspect) { @@ -169,11 +180,10 @@ void gfx_scale_integer(struct rarch_viewport *vp, unsigned width, } else { - unsigned base_height, base_width; - + unsigned base_width; /* Use system reported sizes as these define the * geometry for the "normal" case. */ - base_height = g_extern.system.av_info.geometry.base_height; + unsigned base_height = g_extern.system.av_info.geometry.base_height; if (base_height == 0) base_height = 1; @@ -248,6 +258,13 @@ char rotation_lut[4][32] = "270 deg" }; +/** + * gfx_set_square_pixel_viewport: + * @width : Width. + * @height : Height. + * + * Sets viewport to square pixel aspect ratio based on @width and @height. + **/ void gfx_set_square_pixel_viewport(unsigned width, unsigned height) { unsigned len, highest, i, aspect_x, aspect_y; @@ -272,6 +289,11 @@ void gfx_set_square_pixel_viewport(unsigned width, unsigned height) aspectratio_lut[ASPECT_RATIO_SQUARE].value = (float)aspect_x / aspect_y; } +/** + * gfx_set_core_viewport: + * + * Sets viewport to aspect ratio set by core A/V info. + **/ void gfx_set_core_viewport(void) { const struct retro_game_geometry *geom = diff --git a/gfx/gfx_common.h b/gfx/gfx_common.h index 084d7e0d62..8b2a19e11e 100644 --- a/gfx/gfx_common.h +++ b/gfx/gfx_common.h @@ -31,6 +31,19 @@ extern "C" { #include "../config.h" #endif +/** + * gfx_get_fps: + * @buf : string suitable for Window title + * @size : size of buffer. + * @buf_fps : string of raw FPS only (optional). + * @size_fps : size of raw FPS buffer. + * + * Get the amount of frames per seconds. + * + * Returns: true if framerate per seconds could be obtained, + * otherwise false. + * + **/ bool gfx_get_fps(char *buf, size_t size, char *buf_fps, size_t size_fps); @@ -38,6 +51,17 @@ bool gfx_get_fps(char *buf, size_t size, void gfx_set_dwm(void); #endif +/** + * gfx_scale_integer: + * @vp : Viewport handle + * @width : Width. + * @height : Height. + * @aspect_ratio : Aspect ratio (in float). + * @keep_aspect : Preserve aspect ratio? + * + * Gets new viewport scaling dimensions based on + * scaled integer aspect ratio. + **/ void gfx_scale_integer(struct rarch_viewport *vp, unsigned win_width, unsigned win_height, float aspect_ratio, bool keep_aspect); @@ -106,8 +130,22 @@ struct aspect_ratio_elem extern struct aspect_ratio_elem aspectratio_lut[ASPECT_RATIO_END]; +/** + * gfx_set_square_pixel_viewport: + * @width : Width. + * @height : Height. + * + * Sets viewport to square pixel aspect ratio based on @width and @height. + **/ void gfx_set_square_pixel_viewport(unsigned width, unsigned height); + +/** + * gfx_set_core_viewport: + * + * Sets viewport to aspect ratio set by core A/V info. + **/ void gfx_set_core_viewport(void); + void gfx_set_config_viewport(void); #ifdef __cplusplus From 878d1f06471ccfd5c917154507fa6f260bfdc49d Mon Sep 17 00:00:00 2001 From: twinaphex Date: Sat, 10 Jan 2015 18:55:37 +0100 Subject: [PATCH 007/156] Some cleanups in video_thread_wrapper.c --- gfx/video_thread_wrapper.c | 55 ++++++++++++++++++++++++++------------ 1 file changed, 38 insertions(+), 17 deletions(-) diff --git a/gfx/video_thread_wrapper.c b/gfx/video_thread_wrapper.c index 2abb54ec7e..c744649424 100644 --- a/gfx/video_thread_wrapper.c +++ b/gfx/video_thread_wrapper.c @@ -93,6 +93,8 @@ static void thread_loop(void *data) { bool ret = false; bool updated = false; + enum thread_cmd send_cmd; + slock_lock(thr->lock); while (thr->send_cmd == CMD_NONE && !thr->frame.updated) scond_wait(thr->cond_thread, thr->lock); @@ -102,7 +104,7 @@ static void thread_loop(void *data) /* To avoid race condition where send_cmd is updated * right after the switch is checked. */ - enum thread_cmd send_cmd = thr->send_cmd; + send_cmd = thr->send_cmd; slock_unlock(thr->lock); switch (send_cmd) @@ -134,7 +136,9 @@ static void thread_loop(void *data) case CMD_READ_VIEWPORT: { struct rarch_viewport vp = {0}; + thr->driver->viewport_info(thr->driver_data, &vp); + if (memcmp(&vp, &thr->read_vp, sizeof(vp)) == 0) { /* We can read safely @@ -532,6 +536,7 @@ static bool thread_init(thread_video_t *thr, const video_info_t *info, thr->thread = sthread_create(thread_loop, thr); if (!thr->thread) return false; + thread_send_cmd(thr, CMD_INIT); thread_wait_reply(thr, CMD_INIT); @@ -546,6 +551,9 @@ static bool thread_set_shader(void *data, { thread_video_t *thr = (thread_video_t*)data; + if (!thr) + return false; + thr->cmd_data.set_shader.type = type; thr->cmd_data.set_shader.path = path; thread_send_cmd(thr, CMD_SET_SHADER); @@ -558,6 +566,9 @@ static void thread_set_rotation(void *data, unsigned rotation) { thread_video_t *thr = (thread_video_t*)data; + if (!thr) + return; + thr->cmd_data.i = rotation; thread_send_cmd(thr, CMD_SET_ROTATION); thread_wait_reply(thr, CMD_SET_ROTATION); @@ -571,6 +582,10 @@ static void thread_set_rotation(void *data, unsigned rotation) static void thread_viewport_info(void *data, struct rarch_viewport *vp) { thread_video_t *thr = (thread_video_t*)data; + + if (!thr) + return; + slock_lock(thr->lock); *vp = thr->vp; @@ -582,6 +597,8 @@ static void thread_viewport_info(void *data, struct rarch_viewport *vp) static bool thread_read_viewport(void *data, uint8_t *buffer) { thread_video_t *thr = (thread_video_t*)data; + if (!thr) + return false; thr->cmd_data.v = buffer; thread_send_cmd(thr, CMD_READ_VIEWPORT); @@ -622,6 +639,9 @@ static void thread_free(void *data) static void thread_overlay_enable(void *data, bool state) { thread_video_t *thr = (thread_video_t*)data; + + if (!thr) + return; thr->cmd_data.b = state; thread_send_cmd(thr, CMD_OVERLAY_ENABLE); thread_wait_reply(thr, CMD_OVERLAY_ENABLE); @@ -645,6 +665,8 @@ static void thread_overlay_tex_geom(void *data, { thread_video_t *thr = (thread_video_t*)data; + if (!thr) + return; thr->cmd_data.rect.index = idx; thr->cmd_data.rect.x = x; thr->cmd_data.rect.y = y; @@ -659,6 +681,8 @@ static void thread_overlay_vertex_geom(void *data, { thread_video_t *thr = (thread_video_t*)data; + if (!thr) + return; thr->cmd_data.rect.index = idx; thr->cmd_data.rect.x = x; thr->cmd_data.rect.y = y; @@ -682,6 +706,8 @@ static void thread_overlay_set_alpha(void *data, unsigned idx, float mod) { thread_video_t *thr = (thread_video_t*)data; + if (!thr) + return; slock_lock(thr->alpha_lock); thr->alpha_mod[idx] = mod; thr->alpha_update = true; @@ -711,6 +737,9 @@ static void thread_get_overlay_interface(void *data, static void thread_set_filtering(void *data, unsigned idx, bool smooth) { thread_video_t *thr = (thread_video_t*)data; + + if (!thr) + return; thr->cmd_data.filtering.index = idx; thr->cmd_data.filtering.smooth = smooth; thread_send_cmd(thr, CMD_POKE_SET_FILTERING); @@ -720,6 +749,9 @@ static void thread_set_filtering(void *data, unsigned idx, bool smooth) static void thread_set_aspect_ratio(void *data, unsigned aspectratio_idx) { thread_video_t *thr = (thread_video_t*)data; + + if (!thr) + return; thr->cmd_data.i = aspectratio_idx; thread_send_cmd(thr, CMD_POKE_SET_ASPECT_RATIO); thread_wait_reply(thr, CMD_POKE_SET_ASPECT_RATIO); @@ -772,24 +804,13 @@ static void thread_set_osd_msg(void *data, const char *msg, { thread_video_t *thr = (thread_video_t*)data; + if (!thr) + return; + /* TODO : find a way to determine if the calling * thread is the driver thread or not. */ -#if 0 - if (thr->frame.within_thread) -#endif - { - if (thr->poke && thr->poke->set_osd_msg) - thr->poke->set_osd_msg(thr->driver_data, msg, params, font); - } -#if 0 - else - { - strncpy(thr->cmd_data.osd_message.msg, msg, sizeof(thr->cmd_data.osd_message.msg)); - thr->cmd_data.osd_message.params = *params; - thread_send_cmd(thr, CMD_POKE_SET_OSD_MSG); - thread_wait_reply(thr, CMD_POKE_SET_OSD_MSG); - } -#endif + if (thr->poke && thr->poke->set_osd_msg) + thr->poke->set_osd_msg(thr->driver_data, msg, params, font); } static void thread_apply_state_changes(void *data) From 0be5b52ad012abba82681f57fe4024b1f6d9c9f7 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Sat, 10 Jan 2015 19:40:57 +0100 Subject: [PATCH 008/156] Get rid of some tertiary conditionals and move conditional inside dsp conditional block --- libretro_version_1.c | 99 +++++++++++++++++++++++++------------------- 1 file changed, 57 insertions(+), 42 deletions(-) diff --git a/libretro_version_1.c b/libretro_version_1.c index 096688ca1c..2a01c7f32b 100644 --- a/libretro_version_1.c +++ b/libretro_version_1.c @@ -186,6 +186,9 @@ static bool audio_flush(const int16_t *data, size_t samples) g_extern.audio_data.volume_gain); RARCH_PERFORMANCE_STOP(audio_convert_s16); + src_data.data_in = g_extern.audio_data.data; + src_data.input_frames = samples >> 1; + dsp_data.input = g_extern.audio_data.data; dsp_data.input_frames = samples >> 1; @@ -195,12 +198,13 @@ static bool audio_flush(const int16_t *data, size_t samples) RARCH_PERFORMANCE_START(audio_dsp); rarch_dsp_filter_process(g_extern.audio_data.dsp, &dsp_data); RARCH_PERFORMANCE_STOP(audio_dsp); - } - src_data.data_in = dsp_data.output ? - dsp_data.output : g_extern.audio_data.data; - src_data.input_frames = dsp_data.output ? - dsp_data.output_frames : (samples >> 1); + if (dsp_data.output) + { + src_data.data_in = dsp_data.output; + src_data.input_frames = dsp_data.output_frames; + } + } src_data.data_out = g_extern.audio_data.outsamples; @@ -428,16 +432,24 @@ static int16_t input_state(unsigned port, unsigned device, switch (device) { case RETRO_DEVICE_JOYPAD: - res |= driver.overlay_state.buttons & (UINT64_C(1) << id) ? 1 : 0; + if (driver.overlay_state.buttons & (UINT64_C(1) << id)) + res |= 1; break; case RETRO_DEVICE_KEYBOARD: if (id < RETROK_LAST) - res |= OVERLAY_GET_KEY(&driver.overlay_state, id) ? 1 : 0; + { + if (OVERLAY_GET_KEY(&driver.overlay_state, id)) + res |= 1; + } break; case RETRO_DEVICE_ANALOG: { - unsigned base = (idx == RETRO_DEVICE_INDEX_ANALOG_RIGHT) ? 2 : 0; - base += (id == RETRO_DEVICE_ID_ANALOG_Y) ? 1 : 0; + unsigned base = 0; + + if (idx == RETRO_DEVICE_INDEX_ANALOG_RIGHT) + base = 2; + if (id == RETRO_DEVICE_ID_ANALOG_Y) + base += 1; if (driver.overlay_state.analog[base]) res = driver.overlay_state.analog[base]; } @@ -488,12 +500,12 @@ static inline void input_poll_overlay(void) RETRO_DEVICE_ID_POINTER_PRESSED); i++) { + input_overlay_state_t polled_data; int16_t x = driver.input->input_state(driver.input_data, NULL, 0, device, i, RETRO_DEVICE_ID_POINTER_X); int16_t y = driver.input->input_state(driver.input_data, NULL, 0, device, i, RETRO_DEVICE_ID_POINTER_Y); - input_overlay_state_t polled_data; input_overlay_poll(driver.overlay, &polled_data, x, y); driver.overlay_state.buttons |= polled_data.buttons; @@ -510,18 +522,21 @@ static inline void input_poll_overlay(void) polled = true; } - key_mod |= (OVERLAY_GET_KEY(&driver.overlay_state, RETROK_LSHIFT) || - OVERLAY_GET_KEY(&driver.overlay_state, RETROK_RSHIFT)) ? - RETROKMOD_SHIFT : 0; - key_mod |= (OVERLAY_GET_KEY(&driver.overlay_state, RETROK_LCTRL) || - OVERLAY_GET_KEY(&driver.overlay_state, RETROK_RCTRL)) ? - RETROKMOD_CTRL : 0; - key_mod |= (OVERLAY_GET_KEY(&driver.overlay_state, RETROK_LALT) || - OVERLAY_GET_KEY(&driver.overlay_state, RETROK_RALT)) ? - RETROKMOD_ALT : 0; - key_mod |= (OVERLAY_GET_KEY(&driver.overlay_state, RETROK_LMETA) || - OVERLAY_GET_KEY(&driver.overlay_state, RETROK_RMETA)) ? - RETROKMOD_META : 0; + if (OVERLAY_GET_KEY(&driver.overlay_state, RETROK_LSHIFT) || + OVERLAY_GET_KEY(&driver.overlay_state, RETROK_RSHIFT)) + key_mod |= RETROKMOD_SHIFT; + + if (OVERLAY_GET_KEY(&driver.overlay_state, RETROK_LCTRL) || + OVERLAY_GET_KEY(&driver.overlay_state, RETROK_RCTRL)) + key_mod |= RETROKMOD_CTRL; + + if (OVERLAY_GET_KEY(&driver.overlay_state, RETROK_LALT) || + OVERLAY_GET_KEY(&driver.overlay_state, RETROK_RALT)) + key_mod |= RETROKMOD_ALT; + + if (OVERLAY_GET_KEY(&driver.overlay_state, RETROK_LMETA) || + OVERLAY_GET_KEY(&driver.overlay_state, RETROK_RMETA)) + key_mod |= RETROKMOD_META; /* CAPSLOCK SCROLLOCK NUMLOCK */ for (i = 0; i < ARRAY_SIZE(driver.overlay_state.keys); i++) @@ -545,10 +560,10 @@ static inline void input_poll_overlay(void) unsigned bind_plus = RARCH_ANALOG_LEFT_X_PLUS + 2 * j; unsigned bind_minus = bind_plus + 1; - driver.overlay_state.analog[j] += (driver.overlay_state.buttons & - (1ULL << bind_plus)) ? 0x7fff : 0; - driver.overlay_state.analog[j] -= (driver.overlay_state.buttons & - (1ULL << bind_minus)) ? 0x7fff : 0; + if (driver.overlay_state.buttons & (1ULL << bind_plus)) + driver.overlay_state.analog[j] += 0x7fff; + if (driver.overlay_state.buttons & (1ULL << bind_minus)) + driver.overlay_state.analog[j] -= 0x7fff; } } @@ -559,23 +574,23 @@ static inline void input_poll_overlay(void) case ANALOG_DPAD_LSTICK: case ANALOG_DPAD_RSTICK: { - unsigned analog_base = g_settings.input.analog_dpad_mode[0] == - ANALOG_DPAD_LSTICK ? 0 : 2; - float analog_x = (float)driver.overlay_state.analog[analog_base + 0] / 0x7fff; - float analog_y = (float)driver.overlay_state.analog[analog_base + 1] / 0x7fff; + float analog_x, analog_y; + unsigned analog_base = 2; - driver.overlay_state.buttons |= - (analog_x <= -g_settings.input.axis_threshold) ? - (1ULL << RETRO_DEVICE_ID_JOYPAD_LEFT) : 0; - driver.overlay_state.buttons |= - (analog_x >= g_settings.input.axis_threshold) ? - (1ULL << RETRO_DEVICE_ID_JOYPAD_RIGHT) : 0; - driver.overlay_state.buttons |= - (analog_y <= -g_settings.input.axis_threshold) ? - (1ULL << RETRO_DEVICE_ID_JOYPAD_UP) : 0; - driver.overlay_state.buttons |= - (analog_y >= g_settings.input.axis_threshold) ? - (1ULL << RETRO_DEVICE_ID_JOYPAD_DOWN) : 0; + if (g_settings.input.analog_dpad_mode[0] == ANALOG_DPAD_LSTICK) + analog_base = 0; + + analog_x = (float)driver.overlay_state.analog[analog_base + 0] / 0x7fff; + analog_y = (float)driver.overlay_state.analog[analog_base + 1] / 0x7fff; + + if (analog_x <= -g_settings.input.axis_threshold) + driver.overlay_state.buttons |= (1ULL << RETRO_DEVICE_ID_JOYPAD_LEFT); + if (analog_x >= g_settings.input.axis_threshold) + driver.overlay_state.buttons |= (1ULL << RETRO_DEVICE_ID_JOYPAD_RIGHT); + if (analog_y <= -g_settings.input.axis_threshold) + driver.overlay_state.buttons |= (1ULL << RETRO_DEVICE_ID_JOYPAD_UP); + if (analog_y >= g_settings.input.axis_threshold) + driver.overlay_state.buttons |= (1ULL << RETRO_DEVICE_ID_JOYPAD_DOWN); break; } From c6b6a068593c40fc5033c3cfaa639fe8ebd1eaea Mon Sep 17 00:00:00 2001 From: twinaphex Date: Sat, 10 Jan 2015 19:55:47 +0100 Subject: [PATCH 009/156] (udev_joypad.c) Declare variables at top --- input/udev_joypad.c | 29 ++++++++++++++++++++--------- 1 file changed, 20 insertions(+), 9 deletions(-) diff --git a/input/udev_joypad.c b/input/udev_joypad.c index 6bcb9d1320..0a4aa1e328 100644 --- a/input/udev_joypad.c +++ b/input/udev_joypad.c @@ -192,6 +192,8 @@ end: static bool udev_set_rumble(unsigned i, enum retro_rumble_effect effect, uint16_t strength) { + int old_effect; + uint16_t old_strength; struct udev_joypad *pad = (struct udev_joypad*)&udev_pads[i]; if (pad->fd < 0) @@ -199,24 +201,31 @@ static bool udev_set_rumble(unsigned i, enum retro_rumble_effect effect, uint16_ if (pad->num_effects < 2) return false; - uint16_t old_strength = pad->strength[effect]; + old_strength = pad->strength[effect]; if (old_strength == strength) return true; - int old_effect = pad->has_set_ff[effect] ? pad->effects[effect] : -1; + old_effect = pad->has_set_ff[effect] ? pad->effects[effect] : -1; if (strength && strength != pad->configured_strength[effect]) { /* Create new or update old playing state. */ struct ff_effect e; + memset(&e, 0, sizeof(e)); e.type = FF_RUMBLE; e.id = old_effect; + switch (effect) { - case RETRO_RUMBLE_STRONG: e.u.rumble.strong_magnitude = strength; break; - case RETRO_RUMBLE_WEAK: e.u.rumble.weak_magnitude = strength; break; - default: return false; + case RETRO_RUMBLE_STRONG: + e.u.rumble.strong_magnitude = strength; + break; + case RETRO_RUMBLE_WEAK: + e.u.rumble.weak_magnitude = strength; + break; + default: + return false; } if (ioctl(pad->fd, EVIOCSFF, &e) < 0) @@ -240,6 +249,7 @@ static bool udev_set_rumble(unsigned i, enum retro_rumble_effect effect, uint16_ play.type = EV_FF; play.code = pad->effects[effect]; play.value = !!strength; + if (write(pad->fd, &play, sizeof(play)) < (ssize_t)sizeof(play)) { RARCH_ERR("[udev]: Failed to play rumble effect #%u on pad #%u.\n", @@ -267,13 +277,13 @@ static void udev_joypad_poll(void) static int open_joystick(const char *path) { - int fd = open(path, O_RDWR | O_NONBLOCK); - if (fd < 0) - return fd; - unsigned long evbit[NBITS(EV_MAX)] = {0}; unsigned long keybit[NBITS(KEY_MAX)] = {0}; unsigned long absbit[NBITS(ABS_MAX)] = {0}; + int fd = open(path, O_RDWR | O_NONBLOCK); + + if (fd < 0) + return fd; if ((ioctl(fd, EVIOCGBIT(0, sizeof(evbit)), evbit) < 0) || (ioctl(fd, EVIOCGBIT(EV_KEY, sizeof(keybit)), keybit) < 0) || @@ -294,6 +304,7 @@ error: static int find_vacant_pad(void) { unsigned i; + for (i = 0; i < MAX_USERS; i++) if (udev_pads[i].fd < 0) return i; From b4b81bd74088b3c8e3fe0b98c8fc598d9f828b20 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Sat, 10 Jan 2015 20:10:45 +0100 Subject: [PATCH 010/156] Split up input_common.c into two files - input_joypad.c and input_common.c --- Makefile.common | 1 + griffin/griffin.c | 1 + input/android_input.c | 1 + input/apple_input.c | 1 + input/dinput.c | 1 + input/input_common.c | 155 ------------------------ input/input_common.h | 58 +-------- input/input_joypad.c | 180 ++++++++++++++++++++++++++++ input/input_joypad.h | 83 +++++++++++++ input/linuxraw_input.c | 1 + input/sdl_input.c | 1 + input/udev_input.c | 1 + input/x11_input.c | 1 + menu/menu_input_line_cb.c | 1 + tools/retroarch-joyconfig-griffin.c | 1 + tools/retroarch-joyconfig.c | 1 + 16 files changed, 279 insertions(+), 209 deletions(-) create mode 100644 input/input_joypad.c create mode 100644 input/input_joypad.h diff --git a/Makefile.common b/Makefile.common index 66ef85993d..349aaf8ec6 100644 --- a/Makefile.common +++ b/Makefile.common @@ -110,6 +110,7 @@ OBJ += frontend/frontend.o \ gfx/fonts/bitmapfont.o \ input/input_autodetect.o \ input/input_context.o \ + input/input_joypad.o \ input/input_common.o \ input/input_keymaps.o \ input/keyboard_line.o \ diff --git a/griffin/griffin.c b/griffin/griffin.c index d0bc9a99f8..1fdab314d9 100644 --- a/griffin/griffin.c +++ b/griffin/griffin.c @@ -282,6 +282,7 @@ INPUT ============================================================ */ #include "../input/input_autodetect.c" #include "../input/input_context.c" +#include "../input/input_joypad.c" #include "../input/input_common.c" #include "../input/input_keymaps.c" #include "../input/keyboard_line.c" diff --git a/input/android_input.c b/input/android_input.c index e6ac6835aa..b4afd0671e 100644 --- a/input/android_input.c +++ b/input/android_input.c @@ -22,6 +22,7 @@ #include "../frontend/platform/platform_android.h" #include "input_autodetect.h" #include "input_common.h" +#include "input_joypad.h" #include "../performance.h" #include "../general.h" #include "../driver.h" diff --git a/input/apple_input.c b/input/apple_input.c index e693e9ab5f..e5bb98edb1 100644 --- a/input/apple_input.c +++ b/input/apple_input.c @@ -18,6 +18,7 @@ #include #include "input_common.h" +#include "input_joypad.h" #include "input_keymaps.h" #include "apple_input.h" #include "../general.h" diff --git a/input/dinput.c b/input/dinput.c index 1f1feed923..ca1657da12 100644 --- a/input/dinput.c +++ b/input/dinput.c @@ -26,6 +26,7 @@ #include #include "input_autodetect.h" #include "input_common.h" +#include "input_joypad.h" #include "input_keymaps.h" #include "retroarch_logger.h" #include diff --git a/input/input_common.c b/input/input_common.c index d085652ac2..0c05cd8573 100644 --- a/input/input_common.c +++ b/input/input_common.c @@ -24,161 +24,6 @@ #include "../config.h" #endif -const char *input_joypad_name(const rarch_joypad_driver_t *drv, - unsigned joypad) -{ - if (!drv) - return NULL; - return drv->name(joypad); -} - -bool input_joypad_set_rumble(const rarch_joypad_driver_t *drv, - unsigned port, enum retro_rumble_effect effect, uint16_t strength) -{ - unsigned joy_idx = g_settings.input.joypad_map[port]; - - if (!drv || !drv->set_rumble) - return false; - - if (joy_idx >= MAX_USERS) - return false; - - return drv->set_rumble(joy_idx, effect, strength); -} - -static bool input_joypad_is_pressed( - const rarch_joypad_driver_t *drv, - unsigned port, - const struct retro_keybind *binds, - unsigned key) -{ - const struct retro_keybind *auto_binds; - float scaled_axis; - int16_t axis; - uint32_t joyaxis; - uint64_t joykey; - unsigned joy_idx = g_settings.input.joypad_map[port]; - - if (joy_idx >= MAX_USERS) - return false; - - /* Auto-binds are per joypad, not per user. */ - auto_binds = g_settings.input.autoconf_binds[joy_idx]; - - joykey = binds[key].joykey; - if (joykey == NO_BTN) - joykey = auto_binds[key].joykey; - - if (drv->button(joy_idx, (uint16_t)joykey)) - return true; - - joyaxis = binds[key].joyaxis; - if (joyaxis == AXIS_NONE) - joyaxis = auto_binds[key].joyaxis; - - axis = drv->axis(joy_idx, joyaxis); - scaled_axis = (float)abs(axis) / 0x8000; - return scaled_axis > g_settings.input.axis_threshold; -} - -bool input_joypad_pressed(const rarch_joypad_driver_t *drv, - unsigned port, const struct retro_keybind *binds, unsigned key) -{ - if (!drv) - return false; - - if (!binds[key].valid) - return false; - - if (input_joypad_is_pressed(drv, port, binds, key)) - return true; - - return false; -} - -int16_t input_joypad_analog(const rarch_joypad_driver_t *drv, - unsigned port, unsigned idx, unsigned ident, - const struct retro_keybind *binds) -{ - uint32_t axis_minus, axis_plus; - uint64_t key_minus, key_plus; - int16_t pressed_minus, pressed_plus, res; - unsigned ident_minus = 0, ident_plus = 0; - int16_t digital_left = 0, digital_right = 0; - const struct retro_keybind *auto_binds = NULL; - const struct retro_keybind *bind_minus = NULL; - const struct retro_keybind *bind_plus = NULL; - unsigned joy_idx = g_settings.input.joypad_map[port]; - - if (!drv) - return 0; - - if (joy_idx >= MAX_USERS) - return 0; - - /* Auto-binds are per joypad, not per user. */ - auto_binds = g_settings.input.autoconf_binds[joy_idx]; - - input_conv_analog_id_to_bind_id(idx, ident, &ident_minus, &ident_plus); - - bind_minus = &binds[ident_minus]; - bind_plus = &binds[ident_plus]; - if (!bind_minus->valid || !bind_plus->valid) - return 0; - - axis_minus = bind_minus->joyaxis; - axis_plus = bind_plus->joyaxis; - if (axis_minus == AXIS_NONE) - axis_minus = auto_binds[ident_minus].joyaxis; - if (axis_plus == AXIS_NONE) - axis_plus = auto_binds[ident_plus].joyaxis; - - pressed_minus = abs(drv->axis(joy_idx, axis_minus)); - pressed_plus = abs(drv->axis(joy_idx, axis_plus)); - res = pressed_plus - pressed_minus; - - if (res != 0) - return res; - - key_minus = bind_minus->joykey; - key_plus = bind_plus->joykey; - if (key_minus == NO_BTN) - key_minus = auto_binds[ident_minus].joykey; - if (key_plus == NO_BTN) - key_plus = auto_binds[ident_plus].joykey; - - if (drv->button(joy_idx, (uint16_t)key_minus)) - digital_left = -0x7fff; - if (drv->button(joy_idx, (uint16_t)key_plus)) - digital_right = 0x7fff; - return digital_right + digital_left; -} - -int16_t input_joypad_axis_raw(const rarch_joypad_driver_t *drv, - unsigned joypad, unsigned axis) -{ - if (!drv) - return 0; - return drv->axis(joypad, AXIS_POS(axis)) + - drv->axis(joypad, AXIS_NEG(axis)); -} - -bool input_joypad_button_raw(const rarch_joypad_driver_t *drv, - unsigned joypad, unsigned button) -{ - if (!drv) - return false; - return drv->button(joypad, button); -} - -bool input_joypad_hat_raw(const rarch_joypad_driver_t *drv, - unsigned joypad, unsigned hat_dir, unsigned hat) -{ - if (!drv) - return false; - return drv->button(joypad, HAT_MAP(hat, hat_dir)); -} - bool input_translate_coord_viewport(int mouse_x, int mouse_y, int16_t *res_x, int16_t *res_y, int16_t *res_screen_x, int16_t *res_screen_y) diff --git a/input/input_common.h b/input/input_common.h index 641763c43f..3a2d6b84f5 100644 --- a/input/input_common.h +++ b/input/input_common.h @@ -26,62 +26,8 @@ extern "C" { #include #include "../driver.h" - typedef uint64_t retro_input_t ; -static inline void input_conv_analog_id_to_bind_id(unsigned idx, unsigned ident, - unsigned *ident_minus, unsigned *ident_plus) -{ - switch ((idx << 1) | ident) - { - case (RETRO_DEVICE_INDEX_ANALOG_LEFT << 1) | RETRO_DEVICE_ID_ANALOG_X: - *ident_minus = RARCH_ANALOG_LEFT_X_MINUS; - *ident_plus = RARCH_ANALOG_LEFT_X_PLUS; - break; - - case (RETRO_DEVICE_INDEX_ANALOG_LEFT << 1) | RETRO_DEVICE_ID_ANALOG_Y: - *ident_minus = RARCH_ANALOG_LEFT_Y_MINUS; - *ident_plus = RARCH_ANALOG_LEFT_Y_PLUS; - break; - - case (RETRO_DEVICE_INDEX_ANALOG_RIGHT << 1) | RETRO_DEVICE_ID_ANALOG_X: - *ident_minus = RARCH_ANALOG_RIGHT_X_MINUS; - *ident_plus = RARCH_ANALOG_RIGHT_X_PLUS; - break; - - case (RETRO_DEVICE_INDEX_ANALOG_RIGHT << 1) | RETRO_DEVICE_ID_ANALOG_Y: - *ident_minus = RARCH_ANALOG_RIGHT_Y_MINUS; - *ident_plus = RARCH_ANALOG_RIGHT_Y_PLUS; - break; - } -} - -bool input_translate_coord_viewport(int mouse_x, int mouse_y, - int16_t *res_x, int16_t *res_y, int16_t *res_screen_x, - int16_t *res_screen_y); - -bool input_joypad_pressed(const rarch_joypad_driver_t *driver, - unsigned port, const struct retro_keybind *binds, unsigned key); - -int16_t input_joypad_analog(const rarch_joypad_driver_t *driver, - unsigned port, unsigned idx, unsigned ident, - const struct retro_keybind *binds); - -bool input_joypad_set_rumble(const rarch_joypad_driver_t *driver, - unsigned port, enum retro_rumble_effect effect, uint16_t strength); - -int16_t input_joypad_axis_raw(const rarch_joypad_driver_t *driver, - unsigned joypad, unsigned axis); - -bool input_joypad_button_raw(const rarch_joypad_driver_t *driver, - unsigned joypad, unsigned button); - -bool input_joypad_hat_raw(const rarch_joypad_driver_t *driver, - unsigned joypad, unsigned hat_dir, unsigned hat); - -const char *input_joypad_name(const rarch_joypad_driver_t *driver, - unsigned joypad); - /* Input config. */ struct input_bind_map { @@ -101,6 +47,10 @@ struct input_bind_map extern const struct input_bind_map input_config_bind_map[]; +bool input_translate_coord_viewport(int mouse_x, int mouse_y, + int16_t *res_x, int16_t *res_y, int16_t *res_screen_x, + int16_t *res_screen_y); + /* auto_bind can be NULL. */ void input_get_bind_string(char *buf, const struct retro_keybind *bind, const struct retro_keybind *auto_bind, size_t size); diff --git a/input/input_joypad.c b/input/input_joypad.c new file mode 100644 index 0000000000..81d24d4ade --- /dev/null +++ b/input/input_joypad.c @@ -0,0 +1,180 @@ +/* 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 . + */ + +#include "input_joypad.h" +#include +#include +#include + +#include "../general.h" +#ifdef HAVE_CONFIG_H +#include "../config.h" +#endif + +const char *input_joypad_name(const rarch_joypad_driver_t *drv, + unsigned joypad) +{ + if (!drv) + return NULL; + return drv->name(joypad); +} + +bool input_joypad_set_rumble(const rarch_joypad_driver_t *drv, + unsigned port, enum retro_rumble_effect effect, uint16_t strength) +{ + unsigned joy_idx = g_settings.input.joypad_map[port]; + + if (!drv || !drv->set_rumble) + return false; + + if (joy_idx >= MAX_USERS) + return false; + + return drv->set_rumble(joy_idx, effect, strength); +} + +static bool input_joypad_is_pressed( + const rarch_joypad_driver_t *drv, + unsigned port, + const struct retro_keybind *binds, + unsigned key) +{ + const struct retro_keybind *auto_binds; + float scaled_axis; + int16_t axis; + uint32_t joyaxis; + uint64_t joykey; + unsigned joy_idx = g_settings.input.joypad_map[port]; + + if (joy_idx >= MAX_USERS) + return false; + + /* Auto-binds are per joypad, not per user. */ + auto_binds = g_settings.input.autoconf_binds[joy_idx]; + + joykey = binds[key].joykey; + if (joykey == NO_BTN) + joykey = auto_binds[key].joykey; + + if (drv->button(joy_idx, (uint16_t)joykey)) + return true; + + joyaxis = binds[key].joyaxis; + if (joyaxis == AXIS_NONE) + joyaxis = auto_binds[key].joyaxis; + + axis = drv->axis(joy_idx, joyaxis); + scaled_axis = (float)abs(axis) / 0x8000; + return scaled_axis > g_settings.input.axis_threshold; +} + +bool input_joypad_pressed(const rarch_joypad_driver_t *drv, + unsigned port, const struct retro_keybind *binds, unsigned key) +{ + if (!drv) + return false; + + if (!binds[key].valid) + return false; + + if (input_joypad_is_pressed(drv, port, binds, key)) + return true; + + return false; +} + +int16_t input_joypad_analog(const rarch_joypad_driver_t *drv, + unsigned port, unsigned idx, unsigned ident, + const struct retro_keybind *binds) +{ + uint32_t axis_minus, axis_plus; + uint64_t key_minus, key_plus; + int16_t pressed_minus, pressed_plus, res; + unsigned ident_minus = 0, ident_plus = 0; + int16_t digital_left = 0, digital_right = 0; + const struct retro_keybind *auto_binds = NULL; + const struct retro_keybind *bind_minus = NULL; + const struct retro_keybind *bind_plus = NULL; + unsigned joy_idx = g_settings.input.joypad_map[port]; + + if (!drv) + return 0; + + if (joy_idx >= MAX_USERS) + return 0; + + /* Auto-binds are per joypad, not per user. */ + auto_binds = g_settings.input.autoconf_binds[joy_idx]; + + input_conv_analog_id_to_bind_id(idx, ident, &ident_minus, &ident_plus); + + bind_minus = &binds[ident_minus]; + bind_plus = &binds[ident_plus]; + if (!bind_minus->valid || !bind_plus->valid) + return 0; + + axis_minus = bind_minus->joyaxis; + axis_plus = bind_plus->joyaxis; + if (axis_minus == AXIS_NONE) + axis_minus = auto_binds[ident_minus].joyaxis; + if (axis_plus == AXIS_NONE) + axis_plus = auto_binds[ident_plus].joyaxis; + + pressed_minus = abs(drv->axis(joy_idx, axis_minus)); + pressed_plus = abs(drv->axis(joy_idx, axis_plus)); + res = pressed_plus - pressed_minus; + + if (res != 0) + return res; + + key_minus = bind_minus->joykey; + key_plus = bind_plus->joykey; + if (key_minus == NO_BTN) + key_minus = auto_binds[ident_minus].joykey; + if (key_plus == NO_BTN) + key_plus = auto_binds[ident_plus].joykey; + + if (drv->button(joy_idx, (uint16_t)key_minus)) + digital_left = -0x7fff; + if (drv->button(joy_idx, (uint16_t)key_plus)) + digital_right = 0x7fff; + return digital_right + digital_left; +} + +int16_t input_joypad_axis_raw(const rarch_joypad_driver_t *drv, + unsigned joypad, unsigned axis) +{ + if (!drv) + return 0; + return drv->axis(joypad, AXIS_POS(axis)) + + drv->axis(joypad, AXIS_NEG(axis)); +} + +bool input_joypad_button_raw(const rarch_joypad_driver_t *drv, + unsigned joypad, unsigned button) +{ + if (!drv) + return false; + return drv->button(joypad, button); +} + +bool input_joypad_hat_raw(const rarch_joypad_driver_t *drv, + unsigned joypad, unsigned hat_dir, unsigned hat) +{ + if (!drv) + return false; + return drv->button(joypad, HAT_MAP(hat, hat_dir)); +} diff --git a/input/input_joypad.h b/input/input_joypad.h new file mode 100644 index 0000000000..d9212531d0 --- /dev/null +++ b/input/input_joypad.h @@ -0,0 +1,83 @@ +/* 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 . + */ + +#ifndef INPUT_JOYPAD_H__ +#define INPUT_JOYPAD_H__ + +#ifdef __cplusplus +extern "C" { +#endif + +#include "input_context.h" +#include +#include +#include "../driver.h" + +static inline void input_conv_analog_id_to_bind_id(unsigned idx, unsigned ident, + unsigned *ident_minus, unsigned *ident_plus) +{ + switch ((idx << 1) | ident) + { + case (RETRO_DEVICE_INDEX_ANALOG_LEFT << 1) | RETRO_DEVICE_ID_ANALOG_X: + *ident_minus = RARCH_ANALOG_LEFT_X_MINUS; + *ident_plus = RARCH_ANALOG_LEFT_X_PLUS; + break; + + case (RETRO_DEVICE_INDEX_ANALOG_LEFT << 1) | RETRO_DEVICE_ID_ANALOG_Y: + *ident_minus = RARCH_ANALOG_LEFT_Y_MINUS; + *ident_plus = RARCH_ANALOG_LEFT_Y_PLUS; + break; + + case (RETRO_DEVICE_INDEX_ANALOG_RIGHT << 1) | RETRO_DEVICE_ID_ANALOG_X: + *ident_minus = RARCH_ANALOG_RIGHT_X_MINUS; + *ident_plus = RARCH_ANALOG_RIGHT_X_PLUS; + break; + + case (RETRO_DEVICE_INDEX_ANALOG_RIGHT << 1) | RETRO_DEVICE_ID_ANALOG_Y: + *ident_minus = RARCH_ANALOG_RIGHT_Y_MINUS; + *ident_plus = RARCH_ANALOG_RIGHT_Y_PLUS; + break; + } +} + +bool input_joypad_pressed(const rarch_joypad_driver_t *driver, + unsigned port, const struct retro_keybind *binds, unsigned key); + +int16_t input_joypad_analog(const rarch_joypad_driver_t *driver, + unsigned port, unsigned idx, unsigned ident, + const struct retro_keybind *binds); + +bool input_joypad_set_rumble(const rarch_joypad_driver_t *driver, + unsigned port, enum retro_rumble_effect effect, uint16_t strength); + +int16_t input_joypad_axis_raw(const rarch_joypad_driver_t *driver, + unsigned joypad, unsigned axis); + +bool input_joypad_button_raw(const rarch_joypad_driver_t *driver, + unsigned joypad, unsigned button); + +bool input_joypad_hat_raw(const rarch_joypad_driver_t *driver, + unsigned joypad, unsigned hat_dir, unsigned hat); + +const char *input_joypad_name(const rarch_joypad_driver_t *driver, + unsigned joypad); + +#ifdef __cplusplus +} +#endif + +#endif + diff --git a/input/linuxraw_input.c b/input/linuxraw_input.c index a08f8f5e71..83f7a4c8e6 100644 --- a/input/linuxraw_input.c +++ b/input/linuxraw_input.c @@ -25,6 +25,7 @@ #include "../general.h" #include "input_keymaps.h" #include "input_common.h" +#include "input_joypad.h" static long oldKbmd = 0xffff; static struct termios oldTerm, newTerm; diff --git a/input/sdl_input.c b/input/sdl_input.c index 1e251e4af7..8a6db243e0 100644 --- a/input/sdl_input.c +++ b/input/sdl_input.c @@ -25,6 +25,7 @@ #include "../libretro.h" #include "input_autodetect.h" #include "input_common.h" +#include "input_joypad.h" #include "input_keymaps.h" #include "keyboard_line.h" diff --git a/input/udev_input.c b/input/udev_input.c index 4fb1b5285d..5322203cf8 100644 --- a/input/udev_input.c +++ b/input/udev_input.c @@ -14,6 +14,7 @@ */ #include "input_common.h" +#include "input_joypad.h" #include "input_keymaps.h" #include "../general.h" #include diff --git a/input/x11_input.c b/input/x11_input.c index 4935253b9c..d0deeb0486 100644 --- a/input/x11_input.c +++ b/input/x11_input.c @@ -14,6 +14,7 @@ */ #include "input_common.h" +#include "input_joypad.h" #include "input_keymaps.h" #include "../driver.h" diff --git a/menu/menu_input_line_cb.c b/menu/menu_input_line_cb.c index f48a5079c5..cbd7ed9007 100644 --- a/menu/menu_input_line_cb.c +++ b/menu/menu_input_line_cb.c @@ -30,6 +30,7 @@ #include "menu_shader.h" #include "../performance.h" #include "../settings_data.h" +#include "../input/input_joypad.h" void menu_key_start_line(void *data, const char *label, const char *label_setting, unsigned type, unsigned idx, diff --git a/tools/retroarch-joyconfig-griffin.c b/tools/retroarch-joyconfig-griffin.c index 6dd31d33e8..9f3e0f0e5f 100644 --- a/tools/retroarch-joyconfig-griffin.c +++ b/tools/retroarch-joyconfig-griffin.c @@ -50,6 +50,7 @@ #include "../input/nullinput_joypad.c" #include "../input/input_context.c" +#include "../input/input_joypad.c" #include "../input/input_common.c" #include "../input/input_keymaps.c" diff --git a/tools/retroarch-joyconfig.c b/tools/retroarch-joyconfig.c index faa4a86ca2..7b32c7eee1 100644 --- a/tools/retroarch-joyconfig.c +++ b/tools/retroarch-joyconfig.c @@ -24,6 +24,7 @@ #include #include #include "../input/input_common.h" +#include "../input/input_joypad.h" #include "../general.h" #include From 293319c89033a3ba1ad7425aa6ad571e2dca32f2 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Sat, 10 Jan 2015 20:11:57 +0100 Subject: [PATCH 011/156] Less header includes in input_joypad.h --- input/input_joypad.h | 2 -- 1 file changed, 2 deletions(-) diff --git a/input/input_joypad.h b/input/input_joypad.h index d9212531d0..d3aa5a88e4 100644 --- a/input/input_joypad.h +++ b/input/input_joypad.h @@ -21,8 +21,6 @@ extern "C" { #endif -#include "input_context.h" -#include #include #include "../driver.h" From 34bf60cf518ca7f7312d62a9aea6fa42b53d6f75 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Sat, 10 Jan 2015 20:34:37 +0100 Subject: [PATCH 012/156] Start documenting input_joypad.c --- input/input_joypad.c | 89 +++++++++++++++++++++++++++++++++++--------- input/input_joypad.h | 52 ++++++++++++++++++++++++-- 2 files changed, 120 insertions(+), 21 deletions(-) diff --git a/input/input_joypad.c b/input/input_joypad.c index 81d24d4ade..10fbd4d510 100644 --- a/input/input_joypad.c +++ b/input/input_joypad.c @@ -24,12 +24,21 @@ #include "../config.h" #endif +/** + * input_joypad_name: + * @drv : Joypad driver handle. + * @port : Joystick number. + * + * Gets name of the joystick (@port). + * + * Returns: name of joystick #port. + **/ const char *input_joypad_name(const rarch_joypad_driver_t *drv, - unsigned joypad) + unsigned port) { if (!drv) return NULL; - return drv->name(joypad); + return drv->name(port); } bool input_joypad_set_rumble(const rarch_joypad_driver_t *drv, @@ -46,6 +55,19 @@ bool input_joypad_set_rumble(const rarch_joypad_driver_t *drv, return drv->set_rumble(joy_idx, effect, strength); } +/** + * input_joypad_is_pressed: + * @drv : Joypad driver handle. + * @port : User number. + * @binds : Binds of user. + * @key : Identifier of key. + * + * Checks if key (@key) was being pressed by user + * with number @port with provided keybinds (@binds). + * + * Returns: true (1) if key was pressed, otherwise + * false (0). + **/ static bool input_joypad_is_pressed( const rarch_joypad_driver_t *drv, unsigned port, @@ -81,19 +103,26 @@ static bool input_joypad_is_pressed( return scaled_axis > g_settings.input.axis_threshold; } +/** + * input_joypad_pressed: + * @drv : Joypad driver handle. + * @port : User number. + * @binds : Binds of user. + * @key : Identifier of key. + * + * Checks if key (@key) was being pressed by user + * with number @port with provided keybinds (@binds). + * + * Returns: true (1) if key was pressed, otherwise + * false (0). + **/ bool input_joypad_pressed(const rarch_joypad_driver_t *drv, unsigned port, const struct retro_keybind *binds, unsigned key) { - if (!drv) + if (!drv || !binds[key].valid || + !input_joypad_is_pressed(drv, port, binds, key)) return false; - - if (!binds[key].valid) - return false; - - if (input_joypad_is_pressed(drv, port, binds, key)) - return true; - - return false; + return true; } int16_t input_joypad_analog(const rarch_joypad_driver_t *drv, @@ -154,27 +183,51 @@ int16_t input_joypad_analog(const rarch_joypad_driver_t *drv, return digital_right + digital_left; } +/** + * input_joypad_axis_raw: + * @drv : Joypad driver handle. + * @port : Joystick number. + * @axis : Identifier of axis. + * + * Checks if axis (@axis) was being pressed by user + * with joystick number @port. + * + * Returns: true (1) if axis was pressed, otherwise + * false (0). + **/ int16_t input_joypad_axis_raw(const rarch_joypad_driver_t *drv, - unsigned joypad, unsigned axis) + unsigned port, unsigned axis) { if (!drv) return 0; - return drv->axis(joypad, AXIS_POS(axis)) + - drv->axis(joypad, AXIS_NEG(axis)); + return drv->axis(port, AXIS_POS(axis)) + + drv->axis(port, AXIS_NEG(axis)); } +/** + * input_joypad_button_raw: + * @drv : Joypad driver handle. + * @port : Joystick number. + * @button : Identifier of key. + * + * Checks if key (@button) was being pressed by user + * with joystick number @port. + * + * Returns: true (1) if key was pressed, otherwise + * false (0). + **/ bool input_joypad_button_raw(const rarch_joypad_driver_t *drv, - unsigned joypad, unsigned button) + unsigned port, unsigned button) { if (!drv) return false; - return drv->button(joypad, button); + return drv->button(port, button); } bool input_joypad_hat_raw(const rarch_joypad_driver_t *drv, - unsigned joypad, unsigned hat_dir, unsigned hat) + unsigned port, unsigned hat_dir, unsigned hat) { if (!drv) return false; - return drv->button(joypad, HAT_MAP(hat, hat_dir)); + return drv->button(port, HAT_MAP(hat, hat_dir)); } diff --git a/input/input_joypad.h b/input/input_joypad.h index d3aa5a88e4..b696c636e6 100644 --- a/input/input_joypad.h +++ b/input/input_joypad.h @@ -51,6 +51,19 @@ static inline void input_conv_analog_id_to_bind_id(unsigned idx, unsigned ident, } } +/** + * input_joypad_pressed: + * @drv : Joypad driver handle. + * @port : User number. + * @binds : Binds of user. + * @key : Identifier of key. + * + * Checks if key (@key) was being pressed by user + * with number @port with provided keybinds (@binds). + * + * Returns: true (1) if key was pressed, otherwise + * false (0). + **/ bool input_joypad_pressed(const rarch_joypad_driver_t *driver, unsigned port, const struct retro_keybind *binds, unsigned key); @@ -61,17 +74,50 @@ int16_t input_joypad_analog(const rarch_joypad_driver_t *driver, bool input_joypad_set_rumble(const rarch_joypad_driver_t *driver, unsigned port, enum retro_rumble_effect effect, uint16_t strength); +/** + * input_joypad_axis_raw: + * @drv : Joypad driver handle. + * @port : Joystick number. + * @axis : Identifier of axis. + * + * Checks if axis (@axis) was being pressed by user + * with joystick number @port. + * + * Returns: true (1) if axis was pressed, otherwise + * false (0). + **/ int16_t input_joypad_axis_raw(const rarch_joypad_driver_t *driver, - unsigned joypad, unsigned axis); + unsigned port, unsigned axis); +/** + * input_joypad_button_raw: + * @drv : Joypad driver handle. + * @port : Joystick number. + * @button : Identifier of key. + * + * Checks if key (@button) was being pressed by user + * with joystick number @port. + * + * Returns: true (1) if key was pressed, otherwise + * false (0). + **/ bool input_joypad_button_raw(const rarch_joypad_driver_t *driver, - unsigned joypad, unsigned button); + unsigned port, unsigned button); bool input_joypad_hat_raw(const rarch_joypad_driver_t *driver, unsigned joypad, unsigned hat_dir, unsigned hat); +/** + * input_joypad_name: + * @drv : Joypad driver handle. + * @port : Joystick number. + * + * Gets name of the joystick (@port). + * + * Returns: name of joystick #port. + **/ const char *input_joypad_name(const rarch_joypad_driver_t *driver, - unsigned joypad); + unsigned port); #ifdef __cplusplus } From e707c401c86839e1b7df0c485f95e24ebd8b78ad Mon Sep 17 00:00:00 2001 From: twinaphex Date: Sat, 10 Jan 2015 20:48:26 +0100 Subject: [PATCH 013/156] More documentation for input/input_joypad.c --- input/input_joypad.c | 30 +++++++++++++++++++++++++++++ input/input_joypad.h | 46 ++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 76 insertions(+) diff --git a/input/input_joypad.c b/input/input_joypad.c index 10fbd4d510..ae8f1081e4 100644 --- a/input/input_joypad.c +++ b/input/input_joypad.c @@ -41,6 +41,17 @@ const char *input_joypad_name(const rarch_joypad_driver_t *drv, return drv->name(port); } +/** + * input_joypad_set_rumble: + * @drv : Joypad driver handle. + * @port : User number. + * @effect : Rumble effect to set. + * @strength : Strength of rumble effect. + * + * Sets rumble effect @effect with strength @strength. + * + * Returns: true (1) if successful, otherwise false (0). + **/ bool input_joypad_set_rumble(const rarch_joypad_driver_t *drv, unsigned port, enum retro_rumble_effect effect, uint16_t strength) { @@ -125,6 +136,25 @@ bool input_joypad_pressed(const rarch_joypad_driver_t *drv, return true; } +/** + * input_joypad_analog: + * @drv : Joypad driver handle. + * @port : User number. + * @idx : Analog key index. + * E.g.: + * - RETRO_DEVICE_INDEX_ANALOG_LEFT + * - RETRO_DEVICE_INDEX_ANALOG_RIGHT + * @ident : Analog key identifier. + * E.g.: + * - RETRO_DEVICE_ID_ANALOG_X + * - RETRO_DEVICE_ID_ANALOG_Y + * @binds : Binds of user. + * + * Gets analog value of analog key identifiers @idx and @ident + * from user with number @port with provided keybinds (@binds). + * + * Returns: analog value on success, otherwise 0. + **/ int16_t input_joypad_analog(const rarch_joypad_driver_t *drv, unsigned port, unsigned idx, unsigned ident, const struct retro_keybind *binds) diff --git a/input/input_joypad.h b/input/input_joypad.h index b696c636e6..f2d670c9f3 100644 --- a/input/input_joypad.h +++ b/input/input_joypad.h @@ -24,6 +24,22 @@ extern "C" { #include #include "../driver.h" +/** + * input_conv_analog_id_to_bind_id: + * @idx : Analog key index. + * E.g.: + * - RETRO_DEVICE_INDEX_ANALOG_LEFT + * - RETRO_DEVICE_INDEX_ANALOG_RIGHT + * @ident : Analog key identifier. + * E.g.: + * - RETRO_DEVICE_ID_ANALOG_X + * - RETRO_DEVICE_ID_ANALOG_Y + * @ident_minus : Bind ID minus, will be set by function. + * @ident_plus : Bind ID plus, will be set by function. + * + * Takes as input analog key identifiers and converts + * them to corresponding bind IDs @ident_minus and @ident_plus. + **/ static inline void input_conv_analog_id_to_bind_id(unsigned idx, unsigned ident, unsigned *ident_minus, unsigned *ident_plus) { @@ -67,10 +83,40 @@ static inline void input_conv_analog_id_to_bind_id(unsigned idx, unsigned ident, bool input_joypad_pressed(const rarch_joypad_driver_t *driver, unsigned port, const struct retro_keybind *binds, unsigned key); +/** + * input_joypad_analog: + * @drv : Joypad driver handle. + * @port : User number. + * @idx : Analog key index. + * E.g.: + * - RETRO_DEVICE_INDEX_ANALOG_LEFT + * - RETRO_DEVICE_INDEX_ANALOG_RIGHT + * @ident : Analog key identifier. + * E.g.: + * - RETRO_DEVICE_ID_ANALOG_X + * - RETRO_DEVICE_ID_ANALOG_Y + * @binds : Binds of user. + * + * Gets analog value of analog key identifiers @idx and @ident + * from user with number @port with provided keybinds (@binds). + * + * Returns: analog value on success, otherwise 0. + **/ int16_t input_joypad_analog(const rarch_joypad_driver_t *driver, unsigned port, unsigned idx, unsigned ident, const struct retro_keybind *binds); +/** + * input_joypad_set_rumble: + * @drv : Joypad driver handle. + * @port : User number. + * @effect : Rumble effect to set. + * @strength : Strength of rumble effect. + * + * Sets rumble effect @effect with strength @strength. + * + * Returns: true (1) if successful, otherwise false (0). + **/ bool input_joypad_set_rumble(const rarch_joypad_driver_t *driver, unsigned port, enum retro_rumble_effect effect, uint16_t strength); From 75b6ed954569c9e47399c33b0bc1e1a8a1ca7bb0 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Sat, 10 Jan 2015 21:17:34 +0100 Subject: [PATCH 014/156] Some more documentation for input_common.c --- input/input_common.c | 95 +++++++++++++++++++++++++------------------- input/input_common.h | 15 ++++++- 2 files changed, 68 insertions(+), 42 deletions(-) diff --git a/input/input_common.c b/input/input_common.c index 0c05cd8573..550886c5e0 100644 --- a/input/input_common.c +++ b/input/input_common.c @@ -24,44 +24,6 @@ #include "../config.h" #endif -bool input_translate_coord_viewport(int mouse_x, int mouse_y, - int16_t *res_x, int16_t *res_y, int16_t *res_screen_x, - int16_t *res_screen_y) -{ - int scaled_screen_x, scaled_screen_y, scaled_x, scaled_y; - struct rarch_viewport vp = {0}; - bool have_viewport_info = driver.video && driver.video->viewport_info; - - if (!have_viewport_info) - return false; - - driver.video->viewport_info(driver.video_data, &vp); - - scaled_screen_x = (2 * mouse_x * 0x7fff) / (int)vp.full_width - 0x7fff; - scaled_screen_y = (2 * mouse_y * 0x7fff) / (int)vp.full_height - 0x7fff; - if (scaled_screen_x < -0x7fff || scaled_screen_x > 0x7fff) - scaled_screen_x = -0x8000; /* OOB */ - if (scaled_screen_y < -0x7fff || scaled_screen_y > 0x7fff) - scaled_screen_y = -0x8000; /* OOB */ - - mouse_x -= vp.x; - mouse_y -= vp.y; - - scaled_x = (2 * mouse_x * 0x7fff) / (int)vp.width - 0x7fff; - scaled_y = (2 * mouse_y * 0x7fff) / (int)vp.height - 0x7fff; - if (scaled_x < -0x7fff || scaled_x > 0x7fff) - scaled_x = -0x8000; /* OOB */ - if (scaled_y < -0x7fff || scaled_y > 0x7fff) - scaled_y = -0x8000; /* OOB */ - - *res_x = scaled_x; - *res_y = scaled_y; - *res_screen_x = scaled_screen_x; - *res_screen_y = scaled_screen_y; - - return true; -} - static const char *bind_user_prefix[MAX_USERS] = { "input_player1", "input_player2", @@ -140,13 +102,50 @@ const struct input_bind_map input_config_bind_map[RARCH_BIND_LIST_END_NULL] = { DECLARE_META_BIND(2, overlay_next, RARCH_OVERLAY_NEXT, "Overlay next"), DECLARE_META_BIND(2, disk_eject_toggle, RARCH_DISK_EJECT_TOGGLE, "Disk eject toggle"), DECLARE_META_BIND(2, disk_next, RARCH_DISK_NEXT, "Disk next"), - DECLARE_META_BIND(2, disk_prev, RARCH_DISK_NEXT, "Disk prev"), + DECLARE_META_BIND(2, disk_prev, RARCH_DISK_NEXT, "Disk prev"), DECLARE_META_BIND(2, grab_mouse_toggle, RARCH_GRAB_MOUSE_TOGGLE, "Grab mouse toggle"), #ifdef HAVE_MENU DECLARE_META_BIND(1, menu_toggle, RARCH_MENU_TOGGLE, "Menu toggle"), #endif }; +bool input_translate_coord_viewport(int mouse_x, int mouse_y, + int16_t *res_x, int16_t *res_y, int16_t *res_screen_x, + int16_t *res_screen_y) +{ + int scaled_screen_x, scaled_screen_y, scaled_x, scaled_y; + struct rarch_viewport vp = {0}; + bool have_viewport_info = driver.video && driver.video->viewport_info; + + if (!have_viewport_info) + return false; + + driver.video->viewport_info(driver.video_data, &vp); + + scaled_screen_x = (2 * mouse_x * 0x7fff) / (int)vp.full_width - 0x7fff; + scaled_screen_y = (2 * mouse_y * 0x7fff) / (int)vp.full_height - 0x7fff; + if (scaled_screen_x < -0x7fff || scaled_screen_x > 0x7fff) + scaled_screen_x = -0x8000; /* OOB */ + if (scaled_screen_y < -0x7fff || scaled_screen_y > 0x7fff) + scaled_screen_y = -0x8000; /* OOB */ + + mouse_x -= vp.x; + mouse_y -= vp.y; + + scaled_x = (2 * mouse_x * 0x7fff) / (int)vp.width - 0x7fff; + scaled_y = (2 * mouse_y * 0x7fff) / (int)vp.height - 0x7fff; + if (scaled_x < -0x7fff || scaled_x > 0x7fff) + scaled_x = -0x8000; /* OOB */ + if (scaled_y < -0x7fff || scaled_y > 0x7fff) + scaled_y = -0x8000; /* OOB */ + + *res_x = scaled_x; + *res_y = scaled_y; + *res_screen_x = scaled_screen_x; + *res_screen_y = scaled_screen_y; + + return true; +} void input_config_parse_key(config_file_t *conf, const char *prefix, const char *btn, @@ -169,6 +168,14 @@ const char *input_config_get_prefix(unsigned user, bool meta) return NULL; } +/** + * input_translate_str_to_bind_id: + * @str : String to translate to bind ID. + * + * Translate string representation to bind ID. + * + * Returns: Bind ID value on success, otherwise RARCH_BIND_LIST_END on not found. + **/ unsigned input_translate_str_to_bind_id(const char *str) { unsigned i; @@ -182,6 +189,7 @@ static void parse_hat(struct retro_keybind *bind, const char *str) { char *dir = NULL; uint16_t hat_dir = 0, hat; + if (!bind || !str) return; @@ -258,7 +266,7 @@ void input_config_parse_joy_axis(config_file_t *conf, const char *prefix, bind->joyaxis = AXIS_NEG(i_axis); } - /* Ensure that d-pad emulation doesn't screw this over. */ + /* Ensure that D-pad emulation doesn't screw this over. */ bind->orig_joyaxis = bind->joyaxis; } @@ -384,7 +392,12 @@ void input_push_analog_dpad(struct retro_keybind *binds, unsigned mode) } } -/* Restore binds temporarily overridden by input_push_analog_dpad. */ +/** + * input_pop_analog_dpad: + * @binds : Binds to modify. + * + * Restores binds temporarily overridden by input_push_analog_dpad(). + **/ void input_pop_analog_dpad(struct retro_keybind *binds) { unsigned i; diff --git a/input/input_common.h b/input/input_common.h index 3a2d6b84f5..ad977f5a61 100644 --- a/input/input_common.h +++ b/input/input_common.h @@ -60,7 +60,14 @@ enum retro_key input_translate_str_to_rk(const char *str); const char *input_config_get_prefix(unsigned user, bool meta); -/* Returns RARCH_BIND_LIST_END on not found. */ +/** + * input_translate_str_to_bind_id: + * @str : String to translate to bind ID. + * + * Translate string representation to bind ID. + * + * Returns: Bind ID value on success, otherwise RARCH_BIND_LIST_END on not found. + **/ unsigned input_translate_str_to_bind_id(const char *str); void input_config_parse_key(config_file_t *conf, @@ -75,6 +82,12 @@ void input_config_parse_joy_axis(config_file_t *conf, const char *prefix, void input_push_analog_dpad(struct retro_keybind *binds, unsigned mode); +/** + * input_pop_analog_dpad: + * @binds : Binds to modify. + * + * Restores binds temporarily overridden by input_push_analog_dpad(). + **/ void input_pop_analog_dpad(struct retro_keybind *binds); #ifdef __cplusplus From d6169e6ddc5601603827b0a1822d05274a9fd3a7 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Sat, 10 Jan 2015 21:47:30 +0100 Subject: [PATCH 015/156] Add more documentation to runloop.c --- runloop.c | 54 +++++++++++++++++++++++++++++++++++++++--------------- 1 file changed, 39 insertions(+), 15 deletions(-) diff --git a/runloop.c b/runloop.c index a343f6b7ed..618b32b4f5 100644 --- a/runloop.c +++ b/runloop.c @@ -397,6 +397,17 @@ static bool check_movie(void) return check_movie_record(); } +/** + * check_shader_dir: + * @pressed_next : was next shader key pressed? + * @pressed_previous : was previous shader key pressed? + * + * Checks if any one of the shader keys has been pressed for this frame: + * a) Next shader index. + * b) Previous shader index. + * + * Will also immediately apply the shader. + **/ static void check_shader_dir(bool pressed_next, bool pressed_prev) { char msg[PATH_MAX_LENGTH]; @@ -588,6 +599,11 @@ static inline int time_to_exit(retro_input_t input) return 0; } +/** + * update_frame_time: + * + * Updates frame timing if frame timing callback is in use by the core. + **/ static void update_frame_time(void) { retro_time_t curr_time = rarch_get_time_usec(); @@ -623,30 +639,38 @@ static void do_state_check_menu_toggle(void) } #endif +/** + * limit_frame_time: + * + * Limit frame time if fast forward ratio throttle is enabled. + **/ static void limit_frame_time(void) { - retro_time_t current = rarch_get_time_usec(); - retro_time_t target = 0, to_sleep_ms = 0; - double effective_fps = g_extern.system.av_info.timing.fps + double effective_fps, mft_f; + retro_time_t current, target = 0, to_sleep_ms = 0; + + current = rarch_get_time_usec(); + effective_fps = g_extern.system.av_info.timing.fps * g_settings.fastforward_ratio; - double mft_f = 1000000.0f / effective_fps; + mft_f = 1000000.0f / effective_fps; g_extern.frame_limit.minimum_frame_time = (retro_time_t) roundf(mft_f); - target = g_extern.frame_limit.last_frame_time + - g_extern.frame_limit.minimum_frame_time; - to_sleep_ms = (target - current) / 1000; + target = g_extern.frame_limit.last_frame_time + + g_extern.frame_limit.minimum_frame_time; + to_sleep_ms = (target - current) / 1000; - if (to_sleep_ms > 0) + if (to_sleep_ms <= 0) { - rarch_sleep((unsigned int)to_sleep_ms); - - /* Combat jitter a bit. */ - g_extern.frame_limit.last_frame_time += - g_extern.frame_limit.minimum_frame_time; - } - else g_extern.frame_limit.last_frame_time = rarch_get_time_usec(); + return; + } + + rarch_sleep((unsigned int)to_sleep_ms); + + /* Combat jitter a bit. */ + g_extern.frame_limit.last_frame_time += + g_extern.frame_limit.minimum_frame_time; } static void check_block_hotkey(bool enable_hotkey) From 49120c06c99dcb28a3c6d4ed0a9577743f41b2e3 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Sat, 10 Jan 2015 22:31:14 +0100 Subject: [PATCH 016/156] Push analog pad for every user --- runloop.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/runloop.c b/runloop.c index 618b32b4f5..a77f15ae13 100644 --- a/runloop.c +++ b/runloop.c @@ -741,12 +741,10 @@ static inline retro_input_t input_keys_pressed(void) check_block_hotkey(driver.input->key_pressed(driver.input_data, RARCH_ENABLE_HOTKEY)); - input_push_analog_dpad((struct retro_keybind*)binds[0], - (g_settings.input.analog_dpad_mode[0] == ANALOG_DPAD_NONE) ? - ANALOG_DPAD_LSTICK : g_settings.input.analog_dpad_mode[0]); - for (i = 0; i < g_settings.input.max_users; i++) { + input_push_analog_dpad(g_settings.input.binds[i], + g_settings.input.analog_dpad_mode[i]); input_push_analog_dpad(g_settings.input.autoconf_binds[i], g_settings.input.analog_dpad_mode[i]); @@ -755,7 +753,7 @@ static inline retro_input_t input_keys_pressed(void) else g_extern.turbo_frame_enable[i] = driver.input->input_state(driver.input_data, binds, i, - RETRO_DEVICE_JOYPAD, 0, RARCH_TURBO_ENABLE); + RETRO_DEVICE_JOYPAD, 0, RARCH_TURBO_ENABLE); } for (key = 0; key < RARCH_BIND_LIST_END; key++) @@ -780,9 +778,11 @@ static inline retro_input_t input_keys_pressed(void) ret |= (1ULL << key); } - input_pop_analog_dpad((struct retro_keybind*)binds[0]); for (i = 0; i < g_settings.input.max_users; i++) + { + input_pop_analog_dpad(g_settings.input.binds[i]); input_pop_analog_dpad(g_settings.input.autoconf_binds[i]); + } return ret; } From f87590b355e6a3384995cd0a7314071b10384d22 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Sat, 10 Jan 2015 22:38:58 +0100 Subject: [PATCH 017/156] Remap only IDs between 0 and 16 for now. Fixes some button combo issues with FBA. --- libretro_version_1.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/libretro_version_1.c b/libretro_version_1.c index 2a01c7f32b..299747ff79 100644 --- a/libretro_version_1.c +++ b/libretro_version_1.c @@ -418,7 +418,10 @@ static int16_t input_state(unsigned port, unsigned device, } if (g_settings.input.remap_binds_enable) - id = g_settings.input.remap_ids[port][id]; + { + if (id >= 0 && id < RARCH_FIRST_CUSTOM_BIND) + id = g_settings.input.remap_ids[port][id]; + } if (!driver.block_libretro_input) { From 73d4622b54505fa0cbe8ad4246242570f889bada Mon Sep 17 00:00:00 2001 From: twinaphex Date: Sat, 10 Jan 2015 22:51:03 +0100 Subject: [PATCH 018/156] Create pre_state_checks --- menu/menu.c | 7 ----- runloop.c | 82 +++++++++++++++++++++++++++++++++++------------------ 2 files changed, 54 insertions(+), 35 deletions(-) diff --git a/menu/menu.c b/menu/menu.c index 89a0e82117..a23b534598 100644 --- a/menu/menu.c +++ b/menu/menu.c @@ -432,13 +432,6 @@ int menu_iterate(retro_input_t input, if (!driver.menu) return -1; - if (BIT64_GET(trigger_input, RARCH_OVERLAY_NEXT)) - rarch_main_command(RARCH_CMD_OVERLAY_NEXT); - if (BIT64_GET(trigger_input, RARCH_FULLSCREEN_TOGGLE_KEY)) - rarch_main_command(RARCH_CMD_FULLSCREEN_TOGGLE); - if (BIT64_GET(trigger_input, RARCH_GRAB_MOUSE_TOGGLE)) - rarch_main_command(RARCH_CMD_GRAB_MOUSE_TOGGLE); - driver.retro_ctx.poll_cb(); if (input & input_repeat) diff --git a/runloop.c b/runloop.c index a77f15ae13..0d1cdce7a3 100644 --- a/runloop.c +++ b/runloop.c @@ -472,6 +472,58 @@ static void check_cheats(retro_input_t trigger_input) cheat_manager_toggle(g_extern.cheat); } +#ifdef HAVE_MENU +static void do_state_check_menu_toggle(void) +{ + if (g_extern.is_menu) + { + if (g_extern.main_is_init && !g_extern.libretro_dummy) + rarch_main_set_state(RARCH_ACTION_STATE_MENU_RUNNING_FINISHED); + return; + } + + rarch_main_set_state(RARCH_ACTION_STATE_MENU_RUNNING); +} +#endif + +/** + * do_pre_state_checks: + * @input : input sample for this frame + * @old_input : input sample of the previous frame + * @trigger_input : difference' input sample - difference + * between 'input' and 'old_input' + * + * Checks for state changes in this frame. + * + * Unlike do_state_checks(), this is performed for both + * the menu and the regular loop. + * + * Returns: 0. + **/ +static int do_pre_state_checks( + retro_input_t input, retro_input_t old_input, + retro_input_t trigger_input) +{ + if (BIT64_GET(trigger_input, RARCH_OVERLAY_NEXT)) + rarch_main_command(RARCH_CMD_OVERLAY_NEXT); + + if (!g_extern.is_paused || g_extern.is_menu) + { + if (BIT64_GET(trigger_input, RARCH_FULLSCREEN_TOGGLE_KEY)) + rarch_main_command(RARCH_CMD_FULLSCREEN_TOGGLE); + } + + if (BIT64_GET(trigger_input, RARCH_GRAB_MOUSE_TOGGLE)) + rarch_main_command(RARCH_CMD_GRAB_MOUSE_TOGGLE); + +#ifdef HAVE_MENU + if (check_enter_menu_func(trigger_input) || (g_extern.libretro_dummy)) + do_state_check_menu_toggle(); +#endif + + return 0; +} + /** * do_state_checks: * @input : input sample for this frame @@ -498,18 +550,6 @@ static int do_state_checks( else if (BIT64_GET(input, RARCH_VOLUME_DOWN)) set_volume(-0.5f); - if (BIT64_GET(trigger_input, RARCH_GRAB_MOUSE_TOGGLE)) - rarch_main_command(RARCH_CMD_GRAB_MOUSE_TOGGLE); - - if (BIT64_GET(trigger_input, RARCH_OVERLAY_NEXT)) - rarch_main_command(RARCH_CMD_OVERLAY_NEXT); - - if (!g_extern.is_paused) - { - if (BIT64_GET(trigger_input, RARCH_FULLSCREEN_TOGGLE_KEY)) - rarch_main_command(RARCH_CMD_FULLSCREEN_TOGGLE); - } - #ifdef HAVE_NETPLAY if (driver.netplay_data) { @@ -625,19 +665,6 @@ static void update_frame_time(void) g_extern.system.frame_time.callback(delta); } -#ifdef HAVE_MENU -static void do_state_check_menu_toggle(void) -{ - if (g_extern.is_menu) - { - if (g_extern.main_is_init && !g_extern.libretro_dummy) - rarch_main_set_state(RARCH_ACTION_STATE_MENU_RUNNING_FINISHED); - return; - } - - rarch_main_set_state(RARCH_ACTION_STATE_MENU_RUNNING); -} -#endif /** * limit_frame_time: @@ -837,10 +864,9 @@ int rarch_main_iterate(void) if (g_extern.system.frame_time.callback) update_frame_time(); -#ifdef HAVE_MENU - if (check_enter_menu_func(trigger_input) || (g_extern.libretro_dummy)) - do_state_check_menu_toggle(); + do_pre_state_checks(input, old_input, trigger_input); +#ifdef HAVE_MENU if (g_extern.is_menu) { if (menu_iterate(input, old_input, trigger_input) == -1) From 2c0ad226cc7dbabbf381c899a2f4a77625d9f9a5 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Sat, 10 Jan 2015 23:23:01 +0100 Subject: [PATCH 019/156] Add documentation to retroarch.c --- retroarch.c | 56 ++++++++++++++++++++++++++++++++++++++++++++--------- retroarch.h | 45 ++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 92 insertions(+), 9 deletions(-) diff --git a/retroarch.c b/retroarch.c index 0eadeab615..73b65157af 100644 --- a/retroarch.c +++ b/retroarch.c @@ -367,7 +367,11 @@ static void init_recording(void) } } - +/** + * rarch_render_cached_frame: + * + * Renders the current video frame. + **/ void rarch_render_cached_frame(void) { void *recording = driver.recording_data; @@ -1588,6 +1592,12 @@ static void main_state(unsigned cmd) RARCH_LOG("%s\n", msg); } +/** + * rarch_disk_control_append_image: + * @path : Path to disk image. + * + * Appends disk image to disk image list. + **/ void rarch_disk_control_append_image(const char *path) { char msg[PATH_MAX_LENGTH]; @@ -1629,6 +1639,15 @@ void rarch_disk_control_append_image(const char *path) rarch_disk_control_set_eject(false, false); } +/** + * rarch_disk_control_set_eject: + * @new_state : Eject or close the virtual drive tray. + * false (0) : Close + * true (1) : Eject + * @print_log : Show message onscreen. + * + * Ejects/closes of the virtual drive tray. + **/ void rarch_disk_control_set_eject(bool new_state, bool print_log) { char msg[PATH_MAX_LENGTH]; @@ -1667,7 +1686,13 @@ void rarch_disk_control_set_eject(bool new_state, bool print_log) } } -void rarch_disk_control_set_index(unsigned next_idx) +/** + * rarch_disk_control_set_index: + * @index : Index of disk to set as current. + * + * Sets current disk to @index. + **/ +void rarch_disk_control_set_index(unsigned index) { char msg[PATH_MAX_LENGTH]; unsigned num_disks; @@ -1682,19 +1707,19 @@ void rarch_disk_control_set_index(unsigned next_idx) num_disks = control->get_num_images(); - if (control->set_image_index(next_idx)) + if (control->set_image_index(index)) { - if (next_idx < num_disks) + if (index < num_disks) snprintf(msg, sizeof(msg), "Setting disk %u of %u in tray.", - next_idx + 1, num_disks); + index + 1, num_disks); else strlcpy(msg, "Removed disk from tray.", sizeof(msg)); } else { - if (next_idx < num_disks) + if (index < num_disks) snprintf(msg, sizeof(msg), "Failed to set disk %u of %u.", - next_idx + 1, num_disks); + index + 1, num_disks); else strlcpy(msg, "Failed to remove disk from tray.", sizeof(msg)); error = true; @@ -2954,12 +2979,25 @@ int rarch_defer_core(core_info_list_t *core_info, const char *dir, return 0; } -/* Quite intrusive and error prone. +/** + * rarch_replace_config: + * @path : Path to config file to replace + * current config file with. + * + * Replaces currently loaded configuration file with + * another one. Will load a dummy core to flush state + * properly. + * + * Quite intrusive and error prone. * Likely to have lots of small bugs. * Cleanly exit the main loop to ensure that all the tiny details * get set properly. * - * This should mitigate most of the smaller bugs. */ + * This should mitigate most of the smaller bugs. + * + * Returns: true (1) if successful, false (0) if @path was the + * same as the current config file. + **/ bool rarch_replace_config(const char *path) { diff --git a/retroarch.h b/retroarch.h index 058cf818ba..4e64bc6fef 100644 --- a/retroarch.h +++ b/retroarch.h @@ -51,17 +51,62 @@ void rarch_main_init_wrap(const struct rarch_main_wrap *args, void rarch_main_deinit(void); +/** + * rarch_render_cached_frame: + * + * Renders the current video frame. + **/ void rarch_render_cached_frame(void); +/** + * rarch_disk_control_set_eject: + * @new_state : Eject or close the virtual drive tray. + * false (0) : Close + * true (1) : Eject + * @print_log : Show message onscreen. + * + * Ejects/closes of the virtual drive tray. + **/ void rarch_disk_control_set_eject(bool state, bool log); +/** + * rarch_disk_control_set_index: + * @index : Index of disk to set as current. + * + * Sets current disk to @index. + **/ void rarch_disk_control_set_index(unsigned index); +/** + * rarch_disk_control_append_image: + * @path : Path to disk image. + * + * Appends disk image to disk image list. + **/ void rarch_disk_control_append_image(const char *path); void rarch_recording_dump_frame(const void *data, unsigned width, unsigned height, size_t pitch); +/** + * rarch_replace_config: + * @path : Path to config file to replace + * current config file with. + * + * Replaces currently loaded configuration file with + * another one. Will load a dummy core to flush state + * properly. + * + * Quite intrusive and error prone. + * Likely to have lots of small bugs. + * Cleanly exit the main loop to ensure that all the tiny details + * get set properly. + * + * This should mitigate most of the smaller bugs. + * + * Returns: true (1) if successful, false (0) if @path was the + * same as the current config file. + **/ bool rarch_replace_config(const char *path); void rarch_playlist_load_content(content_playlist_t *playlist, From 9afaaa0ccc88f1cbfa366b6d0f68acebf8e7325e Mon Sep 17 00:00:00 2001 From: twinaphex Date: Sat, 10 Jan 2015 23:45:14 +0100 Subject: [PATCH 020/156] (menu/disp) Declare variables at top of functions --- menu/disp/glui.c | 110 ++++++++++++++++++------------------- menu/disp/rgui.c | 35 +++++++++--- menu/disp/xmb.c | 140 ++++++++++++++++++++++++++++------------------- 3 files changed, 165 insertions(+), 120 deletions(-) diff --git a/menu/disp/glui.c b/menu/disp/glui.c index 67dfdbcc97..dbe3ce887f 100644 --- a/menu/disp/glui.c +++ b/menu/disp/glui.c @@ -41,6 +41,7 @@ typedef struct glui_handle static void glui_blit_line(float x, float y, const char *message, bool green) { + struct font_params params = {0}; gl_t *gl = (gl_t*)driver_video_resolve(NULL); if (!driver.menu || !gl) @@ -48,7 +49,6 @@ static void glui_blit_line(float x, float y, const char *message, bool green) gl_set_viewport(gl, gl->win_width, gl->win_height, false, false); - struct font_params params = {0}; params.x = x / gl->win_width; params.y = 1.0f - y / gl->win_height; @@ -65,6 +65,20 @@ static void glui_blit_line(float x, float y, const char *message, bool green) static void glui_render_background(bool force_transparency) { + static const GLfloat vertex[] = { + 0, 0, + 1, 0, + 0, 1, + 1, 1, + }; + + static const GLfloat tex_coord[] = { + 0, 1, + 1, 1, + 0, 0, + 1, 0, + }; + struct gl_coords coords; float alpha = 0.75f; gl_t *gl = NULL; glui_handle_t *glui = NULL; @@ -98,24 +112,9 @@ static void glui_render_background(bool force_transparency) glViewport(0, 0, gl->win_width, gl->win_height); - static const GLfloat vertex[] = { - 0, 0, - 1, 0, - 0, 1, - 1, 1, - }; - - static const GLfloat tex_coord[] = { - 0, 1, - 1, 1, - 0, 0, - 1, 0, - }; - - struct gl_coords coords; - coords.vertices = 4; - coords.vertex = vertex; - coords.tex_coord = tex_coord; + coords.vertices = 4; + coords.vertex = vertex; + coords.tex_coord = tex_coord; coords.lut_tex_coord = tex_coord; if ((g_settings.menu.pause_libretro @@ -145,31 +144,6 @@ static void glui_render_background(bool force_transparency) static void glui_draw_cursor(float x, float y) { - gl_t *gl = NULL; - glui_handle_t *glui = NULL; - - if (!driver.menu) - return; - - glui = (glui_handle_t*)driver.menu->userdata; - - if (!glui) - return; - - GLfloat color[] = { - 1.0f, 1.0f, 1.0f, 1.0f, - 1.0f, 1.0f, 1.0f, 1.0f, - 1.0f, 1.0f, 1.0f, 1.0f, - 1.0f, 1.0f, 1.0f, 1.0f, - }; - - gl = (gl_t*)driver_video_resolve(NULL); - - if (!gl) - return; - - glViewport(x - 5, gl->win_height - y, 11, 11); - static const GLfloat vertex[] = { 0, 0, 1, 0, @@ -183,11 +157,34 @@ static void glui_draw_cursor(float x, float y) 0, 0, 1, 0, }; - + GLfloat color[] = { + 1.0f, 1.0f, 1.0f, 1.0f, + 1.0f, 1.0f, 1.0f, 1.0f, + 1.0f, 1.0f, 1.0f, 1.0f, + 1.0f, 1.0f, 1.0f, 1.0f, + }; struct gl_coords coords; - coords.vertices = 4; - coords.vertex = vertex; - coords.tex_coord = tex_coord; + gl_t *gl = NULL; + glui_handle_t *glui = NULL; + + if (!driver.menu) + return; + + glui = (glui_handle_t*)driver.menu->userdata; + + if (!glui) + return; + + gl = (gl_t*)driver_video_resolve(NULL); + + if (!gl) + return; + + glViewport(x - 5, gl->win_height - y, 11, 11); + + coords.vertices = 4; + coords.vertex = vertex; + coords.tex_coord = tex_coord; coords.lut_tex_coord = tex_coord; coords.color = color; @@ -272,6 +269,8 @@ static void glui_frame(void) size_t end; gl_t *gl = (gl_t*)driver_video_resolve(NULL); glui_handle_t *glui = NULL; + const char *core_name = NULL; + const char *core_version = NULL; if (!driver.menu || !gl) return; @@ -288,8 +287,8 @@ static void glui_frame(void) glui->line_height = g_settings.video.font_size * 4 / 3; glui->glyph_width = glui->line_height / 2; - glui->margin = gl->win_width / 20 ; - glui->term_width = (gl->win_width - glui->margin * 2) / glui->glyph_width; + glui->margin = gl->win_width / 20 ; + glui->term_width = (gl->win_width - glui->margin * 2) / glui->glyph_width; glui->term_height = (gl->win_height - glui->margin * 2) / glui->line_height - 2; driver.menu->mouse.ptr = (driver.menu->mouse.y - glui->margin) / @@ -324,13 +323,13 @@ static void glui_frame(void) glui_blit_line(glui->margin * 2, glui->margin + glui->line_height, title_buf, true); - const char *core_name = g_extern.menu.info.library_name; + core_name = g_extern.menu.info.library_name; if (!core_name) core_name = g_extern.system.info.library_name; if (!core_name) core_name = "No Core"; - const char *core_version = g_extern.menu.info.library_version; + core_version = g_extern.menu.info.library_version; if (!core_version) core_version = g_extern.system.info.library_version; if (!core_version) @@ -427,10 +426,9 @@ static void glui_init_core_info(void *data) core_info_list_free(g_extern.core_info); g_extern.core_info = NULL; + if (*g_settings.libretro_directory) - { g_extern.core_info = core_info_list_new(g_settings.libretro_directory); - } } static void glui_update_core_info(void *data) @@ -490,14 +488,14 @@ static void glui_free(void *data) static GLuint glui_png_texture_load_(const char * file_name) { + GLuint texture = 0; + struct texture_image ti = {0}; if (! path_file_exists(file_name)) return 0; - struct texture_image ti = {0}; texture_image_load(&ti, file_name); /* Generate the OpenGL texture object */ - GLuint texture = 0; glGenTextures(1, &texture); glBindTexture(GL_TEXTURE_2D, texture); glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, ti.width, ti.height, 0, diff --git a/menu/disp/rgui.c b/menu/disp/rgui.c index 0fb408b0b5..34fc8df343 100644 --- a/menu/disp/rgui.c +++ b/menu/disp/rgui.c @@ -45,6 +45,10 @@ typedef struct rgui_handle static void rgui_copy_glyph(uint8_t *glyph, const uint8_t *buf) { int y, x; + + if (!glyph) + return; + for (y = 0; y < FONT_HEIGHT; y++) { for (x = 0; x < FONT_WIDTH; x++) @@ -65,9 +69,12 @@ static void rgui_copy_glyph(uint8_t *glyph, const uint8_t *buf) static uint16_t gray_filler(unsigned x, unsigned y) { + unsigned col; + x >>= 1; y >>= 1; - unsigned col = ((x + y) & 1) + 1; + col = ((x + y) & 1) + 1; + #if defined(GEKKO) || defined(PSP) return (6 << 12) | (col << 8) | (col << 4) | (col << 0); #else @@ -77,9 +84,11 @@ static uint16_t gray_filler(unsigned x, unsigned y) static uint16_t green_filler(unsigned x, unsigned y) { + unsigned col; + x >>= 1; y >>= 1; - unsigned col = ((x + y) & 1) + 1; + col = ((x + y) & 1) + 1; #if defined(GEKKO) || defined(PSP) return (6 << 12) | (col << 8) | (col << 5) | (col << 0); #else @@ -107,6 +116,10 @@ static void color_rect(uint16_t *buf, unsigned pitch, uint16_t color) { unsigned j, i; + + if (!buf) + return; + for (j = y; j < y + height; j++) for (i = x; i < x + width; i++) if (i < driver.menu->width && j < driver.menu->height) @@ -200,6 +213,9 @@ static void rgui_render_background(void *data) { rgui_handle_t *rgui = (rgui_handle_t*)data; + if (!rgui) + return; + fill_rect(rgui->frame_buf, rgui->frame_buf_pitch, 0, 0, driver.menu->width, driver.menu->height, gray_filler); @@ -248,7 +264,7 @@ static void rgui_render_messagebox(const char *message) for (i = 0; i < list->size; i++) { unsigned line_width; - char *msg = list->elems[i].data; + char *msg = list->elems[i].data; unsigned msglen = strlen(msg); if (msglen > RGUI_TERM_WIDTH) @@ -297,11 +313,12 @@ static void rgui_render_messagebox(const char *message) static void rgui_blit_cursor(void* data) { - int16_t x, y; rgui_handle_t *rgui = (rgui_handle_t*)data; + int16_t x = driver.menu->mouse.x; + int16_t y = driver.menu->mouse.y; - x = driver.menu->mouse.x; - y = driver.menu->mouse.y; + if (!rgui) + return; color_rect(rgui->frame_buf, rgui->frame_buf_pitch, x, y-5, 1, 11, 0xFFFF); @@ -317,6 +334,8 @@ static void rgui_render(void) const char *dir = NULL; const char *label = NULL; rgui_handle_t *rgui = NULL; + const char *core_name = NULL; + const char *core_version = NULL; if (driver.menu->need_refresh && g_extern.is_menu @@ -361,13 +380,13 @@ static void rgui_render(void) g_extern.frame_count / RGUI_TERM_START_X, title, true); blit_line(RGUI_TERM_START_X + RGUI_TERM_START_X, RGUI_TERM_START_X, title_buf, true); - const char *core_name = g_extern.menu.info.library_name; + core_name = g_extern.menu.info.library_name; if (!core_name) core_name = g_extern.system.info.library_name; if (!core_name) core_name = "No Core"; - const char *core_version = g_extern.menu.info.library_version; + core_version = g_extern.menu.info.library_version; if (!core_version) core_version = g_extern.system.info.library_version; if (!core_version) diff --git a/menu/disp/xmb.c b/menu/disp/xmb.c index 9c562b853b..f3aad6ae68 100644 --- a/menu/disp/xmb.c +++ b/menu/disp/xmb.c @@ -237,6 +237,7 @@ static void xmb_draw_icon(GLuint texture, float x, float y, static void xmb_draw_text(const char *str, float x, float y, float scale_factor, float alpha) { + gl_t *gl; uint8_t a8 = 0; struct font_params params = {0}; xmb_handle_t *xmb = (xmb_handle_t*)driver.menu->userdata; @@ -250,7 +251,7 @@ static void xmb_draw_text(const char *str, float x, if (a8 == 0) return; - gl_t *gl = (gl_t*)driver_video_resolve(NULL); + gl = (gl_t*)driver_video_resolve(NULL); if (!gl) return; @@ -276,9 +277,24 @@ static void xmb_draw_text(const char *str, float x, static void xmb_render_background(bool force_transparency) { - float alpha = 0.75f; - gl_t *gl = NULL; - xmb_handle_t *xmb = NULL; + static const GLfloat vertex[] = { + 0, 0, + 1, 0, + 0, 1, + 1, 1, + }; + + static const GLfloat tex_coord[] = { + 0, 1, + 1, 1, + 0, 0, + 1, 0, + }; + + float alpha = 0.75f; + gl_t *gl = NULL; + xmb_handle_t *xmb = NULL; + struct gl_coords coords; if (!driver.menu) return; @@ -312,21 +328,7 @@ static void xmb_render_background(bool force_transparency) glViewport(0, 0, gl->win_width, gl->win_height); - static const GLfloat vertex[] = { - 0, 0, - 1, 0, - 0, 1, - 1, 1, - }; - static const GLfloat tex_coord[] = { - 0, 1, - 1, 1, - 0, 0, - 1, 0, - }; - - struct gl_coords coords; coords.vertices = 4; coords.vertex = vertex; coords.tex_coord = tex_coord; @@ -359,8 +361,6 @@ static void xmb_render_background(bool force_transparency) static void xmb_get_message(const char *message) { - size_t i; - (void)i; xmb_handle_t *xmb = (xmb_handle_t*)driver.menu->userdata; if (!xmb || !message || !*message) @@ -371,24 +371,27 @@ static void xmb_get_message(const char *message) static void xmb_render_messagebox(const char *message) { + int x, y; unsigned i; + struct string_list *list = NULL; gl_t *gl = (gl_t*)driver_video_resolve(NULL); xmb_handle_t *xmb = (xmb_handle_t*)driver.menu->userdata; if (!gl || !xmb) return; - struct string_list *list = string_split(message, "\n"); + list = string_split(message, "\n"); if (!list) return; + if (list->elems == 0) { string_list_free(list); return; } - int x = gl->win_width / 2 - strlen(list->elems[0].data) * xmb->font_size / 4; - int y = gl->win_height / 2 - list->size * xmb->font_size / 2; + x = gl->win_width / 2 - strlen(list->elems[0].data) * xmb->font_size / 4; + y = gl->win_height / 2 - list->size * xmb->font_size / 2; for (i = 0; i < list->size; i++) { @@ -456,10 +459,16 @@ static void xmb_list_open_old(file_list_t *list, int dir, size_t current) for (i = 0; i < file_list_get_size(list); i++) { - xmb_node_t *node = NULL; - node = (xmb_node_t*)file_list_get_userdata_at_offset(list, i); - float ia = i == current ? xmb->i_active_alpha : 0; - if (dir == -1) ia = 0; + float ia = 0; + xmb_node_t *node = (xmb_node_t*)file_list_get_userdata_at_offset(list, i); + + if (!node) + continue; + + if (i == current) + ia = xmb->i_active_alpha; + if (dir == -1) + ia = 0; add_tween(XMB_DELAY, ia, &node->alpha, &inOutQuad, NULL); add_tween(XMB_DELAY, 0, &node->label_alpha, &inOutQuad, NULL); //if (i == current) @@ -479,6 +488,7 @@ static void xmb_list_open_new(file_list_t *list, int dir, size_t current) for (i = 0; i < file_list_get_size(list); i++) { + float iy = 0; xmb_node_t *node = (xmb_node_t*)file_list_get_userdata_at_offset(list, i); if (!xmb) @@ -492,8 +502,6 @@ static void xmb_list_open_new(file_list_t *list, int dir, size_t current) //else // node->x = xmb->icon_size*dir; - float iy = 0; - if (i < current) if (xmb->depth > 1) iy = xmb->vspacing * (i - (int)current + xmb->above_subitem_offset); @@ -512,12 +520,13 @@ static void xmb_list_open_new(file_list_t *list, int dir, size_t current) } for (i = 0; i < file_list_get_size(list); i++) { + float ia; xmb_node_t *node = (xmb_node_t*)file_list_get_userdata_at_offset(list, i); if (!xmb) continue; - float ia = i == current ? xmb->i_active_alpha : xmb->i_passive_alpha; + ia = (i == current) ? xmb->i_active_alpha : xmb->i_passive_alpha; add_tween(XMB_DELAY, ia, &node->alpha, &inOutQuad, NULL); add_tween(XMB_DELAY, ia, &node->label_alpha, &inOutQuad, NULL); add_tween(XMB_DELAY, 0, &node->x, &inOutQuad, NULL); @@ -647,6 +656,7 @@ static void xmb_list_switch_new(file_list_t *list, int dir, size_t current) for (i = 0; i < file_list_get_size(list); i++) { + float ia = 0.5; xmb_node_t *node = (xmb_node_t*)file_list_get_userdata_at_offset(list, i); if (!xmb) @@ -656,7 +666,8 @@ static void xmb_list_switch_new(file_list_t *list, int dir, size_t current) node->alpha = 0; node->label_alpha = 0; - float ia = (i == current) ? 1.0 : 0.5; + if (i == current) + ia = 1.0; add_tween(XMB_DELAY, ia, &node->alpha, &inOutQuad, NULL); add_tween(XMB_DELAY, ia, &node->label_alpha, &inOutQuad, NULL); add_tween(XMB_DELAY, 0, &node->x, &inOutQuad, NULL); @@ -716,13 +727,14 @@ static void xmb_populate_entries(void *data, const char *path, for (j = 0; j < xmb->num_categories; j++) { + float ia, iz; xmb_node_t *node = j ? xmb_node_for_core(j-1) : &xmb->settings_node; if (!node) continue; - float ia = j == xmb->active_category ? xmb->c_active_alpha : xmb->c_passive_alpha; - float iz = j == xmb->active_category ? xmb->c_active_zoom : xmb->c_passive_zoom; + ia = (j == xmb->active_category) ? xmb->c_active_alpha : xmb->c_passive_alpha; + iz = (j == xmb->active_category) ? xmb->c_active_zoom : xmb->c_passive_zoom; add_tween(XMB_DELAY, ia, &node->alpha, &inOutQuad, NULL); add_tween(XMB_DELAY, iz, &node->zoom, &inOutQuad, NULL); } @@ -745,13 +757,14 @@ static void xmb_populate_entries(void *data, const char *path, for (j = 0; j < xmb->num_categories; j++) { + float ia; xmb_node_t *node = j ? xmb_node_for_core(j-1) : &xmb->settings_node; if (!node) continue; - float ia = j == xmb->active_category ? xmb->c_active_alpha - : xmb->depth <= 1 ? xmb->c_passive_alpha : 0; + ia = (j == xmb->active_category) ? xmb->c_active_alpha + : (xmb->depth <= 1) ? xmb->c_passive_alpha : 0; add_tween(XMB_DELAY, ia, &node->alpha, &inOutQuad, NULL); } @@ -777,6 +790,7 @@ static void xmb_draw_items(file_list_t *list, file_list_t *stack, const char *dir = NULL; const char *label = NULL; unsigned menu_type = 0; + xmb_node_t *core_node = NULL; size_t end = file_list_get_size(list); xmb_handle_t *xmb = (xmb_handle_t*)driver.menu->userdata; @@ -785,8 +799,8 @@ static void xmb_draw_items(file_list_t *list, file_list_t *stack, file_list_get_last(stack, &dir, &label, &menu_type); - xmb_node_t *core_node = xmb->active_category ? - xmb_node_for_core(cat_selection_ptr - 1) : NULL; + if (xmb->active_category) + core_node = xmb_node_for_core(cat_selection_ptr - 1); for (i = 0; i < end; i++) { @@ -841,7 +855,7 @@ static void xmb_draw_items(file_list_t *list, file_list_t *stack, icon = xmb->textures[XMB_TEXTURE_RELOAD].id; break; case MENU_SETTING_ACTION: - icon = xmb->depth == 3 ? + icon = (xmb->depth == 3) ? xmb->textures[XMB_TEXTURE_SUBSETTING].id : xmb->textures[XMB_TEXTURE_SETTING].id; break; @@ -914,6 +928,8 @@ static void xmb_frame(void) { int i, depth; char title_msg[64]; + const char *core_name = NULL; + const char *core_version = NULL; xmb_handle_t *xmb = (xmb_handle_t*)driver.menu->userdata; gl_t *gl = (gl_t*)driver_video_resolve(NULL); @@ -927,7 +943,8 @@ static void xmb_frame(void) xmb_render_background(false); - const char *core_name = g_extern.menu.info.library_name; + core_name = g_extern.menu.info.library_name; + if (!core_name) core_name = g_extern.system.info.library_name; if (!core_name) @@ -936,7 +953,8 @@ static void xmb_frame(void) xmb_draw_text( xmb->title, xmb->title_margin_left, xmb->title_margin_top, 1, 1); - const char *core_version = g_extern.menu.info.library_version; + core_version = g_extern.menu.info.library_version; + if (!core_version) core_version = g_extern.system.info.library_version; if (!core_version) @@ -1026,9 +1044,7 @@ static void xmb_init_core_info(void *data) core_info_list_free(g_extern.core_info); g_extern.core_info = NULL; if (*g_settings.libretro_directory) - { g_extern.core_info = core_info_list_new(g_settings.libretro_directory); - } } static void xmb_update_core_info(void *data) @@ -1041,6 +1057,7 @@ static void *xmb_init(void) menu_handle_t *menu = NULL; xmb_handle_t *xmb = NULL; const video_driver_t *video_driver = NULL; + float scale_factor = 1; gl_t *gl = (gl_t*)driver_video_resolve(&video_driver); if (video_driver != &video_gl || !gl) @@ -1091,13 +1108,18 @@ static void *xmb_init(void) xmb->active_item_factor = 3.0; xmb->under_item_offset = 5.0; - float scale_factor = 1; - if (gl->win_width >= 3840) scale_factor = 2.0; - else if (gl->win_width >= 2560) scale_factor = 1.5; - else if (gl->win_width >= 1920) scale_factor = 1.0; - else if (gl->win_width >= 1280) scale_factor = 0.75; - else if (gl->win_width >= 640) scale_factor = 0.5; - else if (gl->win_width >= 320) scale_factor = 0.25; + if (gl->win_width >= 3840) + scale_factor = 2.0; + else if (gl->win_width >= 2560) + scale_factor = 1.5; + else if (gl->win_width >= 1920) + scale_factor = 1.0; + else if (gl->win_width >= 1280) + scale_factor = 0.75; + else if (gl->win_width >= 640) + scale_factor = 0.5; + else if (gl->win_width >= 320) + scale_factor = 0.25; strlcpy(xmb->icon_dir, "256", sizeof(xmb->icon_dir)); @@ -1166,6 +1188,8 @@ static void xmb_context_reset(void *data) fontpath[PATH_MAX_LENGTH], core_id[PATH_MAX_LENGTH], texturepath[PATH_MAX_LENGTH], content_texturepath[PATH_MAX_LENGTH]; + core_info_t* info = NULL; + core_info_list_t* info_list = NULL; gl_t *gl = NULL; xmb_handle_t *xmb = NULL; menu_handle_t *menu = (menu_handle_t*)data; @@ -1241,8 +1265,7 @@ static void xmb_context_reset(void *data) xmb->settings_node.alpha = xmb->c_active_alpha; xmb->settings_node.zoom = xmb->c_active_zoom; - core_info_list_t* info_list = (core_info_list_t*)g_extern.core_info; - core_info_t* info = NULL; + info_list = (core_info_list_t*)g_extern.core_info; if (!info_list) return; @@ -1290,8 +1313,9 @@ static void xmb_navigation_clear(void *data, bool pending_push) { (void)data; - if (!pending_push) - xmb_selection_pointer_changed(); + if (pending_push) + return; + xmb_selection_pointer_changed(); } static void xmb_navigation_decrement(void *data) @@ -1342,7 +1366,9 @@ static void xmb_navigation_ascend_alphabet(void *data, size_t *unused) static void xmb_list_insert(void *data, const char *path, const char *unused, size_t list_size) { + float iy; int current = 0, i = list_size; + xmb_node_t *node = NULL; xmb_handle_t *xmb = (xmb_handle_t*)driver.menu->userdata; file_list_t *list = (file_list_t*)data; @@ -1357,14 +1383,14 @@ static void xmb_list_insert(void *data, return; } - xmb_node_t *node = (xmb_node_t*)list->list[i].userdata; + node = (xmb_node_t*)list->list[i].userdata; if (!node) return; current = driver.menu->selection_ptr; - float iy = (i < current) ? xmb->vspacing * + iy = (i < current) ? xmb->vspacing * (i - current + xmb->above_item_offset) : xmb->vspacing * (i - current + xmb->under_item_offset); @@ -1398,6 +1424,7 @@ static void xmb_list_clear(void *data) static void xmb_list_cache(bool horizontal, unsigned action) { + size_t stack_size; xmb_handle_t *xmb = (xmb_handle_t*)driver.menu->userdata; if (!xmb) @@ -1413,7 +1440,8 @@ static void xmb_list_cache(bool horizontal, unsigned action) xmb->cat_selection_ptr_old = driver.menu->cat_selection_ptr; driver.menu->cat_selection_ptr += action == MENU_ACTION_LEFT ? -1 : 1; - size_t stack_size = driver.menu->menu_list->menu_stack->size; + stack_size = driver.menu->menu_list->menu_stack->size; + if (driver.menu->cat_selection_ptr == 0) { strlcpy(driver.menu->menu_list->menu_stack->list[stack_size-1].label, "Main Menu", PATH_MAX_LENGTH); From 5e85c874ab19fcf281a17e8dc03810db5e5d2ac4 Mon Sep 17 00:00:00 2001 From: Twinaphex Date: Sat, 10 Jan 2015 23:49:47 +0100 Subject: [PATCH 021/156] (Remapping) Simplify conditional and silence warning on OSX --- libretro_version_1.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libretro_version_1.c b/libretro_version_1.c index 299747ff79..5aba5db776 100644 --- a/libretro_version_1.c +++ b/libretro_version_1.c @@ -419,7 +419,7 @@ static int16_t input_state(unsigned port, unsigned device, if (g_settings.input.remap_binds_enable) { - if (id >= 0 && id < RARCH_FIRST_CUSTOM_BIND) + if (id < RARCH_FIRST_CUSTOM_BIND) id = g_settings.input.remap_ids[port][id]; } From d7f36af446722ac4d5d71cb489930b1c32f25f11 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Sun, 11 Jan 2015 00:07:59 +0100 Subject: [PATCH 022/156] Move stuff around --- input/android_input.c | 16 ++-- input/android_input_joypad.c | 9 +-- input/apple_joypad_hid.c | 19 ++--- input/input_common.c | 22 ++++++ input/input_common.h | 1 + input/input_context.c | 147 ----------------------------------- input/input_keymaps.c | 126 ++++++++++++++++++++++++++++++ 7 files changed, 173 insertions(+), 167 deletions(-) diff --git a/input/android_input.c b/input/android_input.c index b4afd0671e..e2a160a3bc 100644 --- a/input/android_input.c +++ b/input/android_input.c @@ -158,6 +158,7 @@ static bool android_input_lookup_name_gingerbread(char *buf, jclass class; jmethodID method, getName; jobject device, name; + const char *str = NULL; JNIEnv *env = (JNIEnv*)jni_thread_getenv(); if (!env) @@ -197,7 +198,7 @@ static bool android_input_lookup_name_gingerbread(char *buf, buf[0] = '\0'; - const char *str = (*env)->GetStringUTFChars(env, name, 0); + str = (*env)->GetStringUTFChars(env, name, 0); if (str) strlcpy(buf, str, size); (*env)->ReleaseStringUTFChars(env, name, str); @@ -215,6 +216,7 @@ static bool android_input_lookup_name_post_gingerbread(char *buf, jclass class; jmethodID method, getName, getVendorId, getProductId; jobject device, name; + const char *str = NULL; JNIEnv *env = (JNIEnv*)jni_thread_getenv(); if (!env) @@ -254,7 +256,7 @@ static bool android_input_lookup_name_post_gingerbread(char *buf, buf[0] = '\0'; - const char *str = (*env)->GetStringUTFChars(env, name, 0); + str = (*env)->GetStringUTFChars(env, name, 0); if (str) strlcpy(buf, str, size); (*env)->ReleaseStringUTFChars(env, name, str); @@ -297,6 +299,7 @@ static void *android_input_init(void) { int32_t major, minor, bugfix; android_input_t *android = (android_input_t*)calloc(1, sizeof(*android)); + if (!android) return NULL; @@ -349,6 +352,7 @@ static inline int android_input_poll_event_type_motion( { float x, y; int pointer_max = min(AMotionEvent_getPointerCount(event), MAX_TOUCH); + for (motion_pointer = 0; motion_pointer < pointer_max; motion_pointer++) { x = AMotionEvent_getX(event, motion_pointer); @@ -619,7 +623,7 @@ static void android_input_poll(void *data) { int ident; struct android_app *android_app = (struct android_app*)g_android; - android_input_t *android = (android_input_t*)data; + android_input_t *android = (android_input_t*)data; while ((ident = ALooper_pollAll((driver.input->key_pressed(driver.input_data, RARCH_PAUSE_TOGGLE)) @@ -841,9 +845,9 @@ static float android_input_get_sensor_input(void *data, static const rarch_joypad_driver_t *android_input_get_joypad_driver(void *data) { android_input_t *android = (android_input_t*)data; - if (android) - return android->joypad; - return NULL; + if (!android) + return NULL; + return android->joypad; } input_driver_t input_android = { diff --git a/input/android_input_joypad.c b/input/android_input_joypad.c index e3f3fe2675..78b1df61c1 100644 --- a/input/android_input_joypad.c +++ b/input/android_input_joypad.c @@ -89,15 +89,14 @@ static bool android_joypad_button(unsigned port, uint16_t joykey) static int16_t android_joypad_axis(unsigned port, uint32_t joyaxis) { - android_input_t *android = (android_input_t*)driver.input_data; - if (!android || joyaxis == AXIS_NONE || port >= MAX_PADS) - return 0; - int val = 0; - int axis = -1; bool is_neg = false; bool is_pos = false; + android_input_t *android = (android_input_t*)driver.input_data; + + if (!android || joyaxis == AXIS_NONE || port >= MAX_PADS) + return 0; if (AXIS_NEG_GET(joyaxis) < MAX_AXIS) { diff --git a/input/apple_joypad_hid.c b/input/apple_joypad_hid.c index 36d02a79ee..e8c5574d5e 100644 --- a/input/apple_joypad_hid.c +++ b/input/apple_joypad_hid.c @@ -147,15 +147,17 @@ static void hid_device_report(void* context, IOReturn result, void *sender, { struct pad_connection* connection = (struct pad_connection*)context; - if (connection) - pad_connection_packet(&slots[connection->slot], connection->slot, - connection->data, reportLength + 1); + if (!connection) + return; + + pad_connection_packet(&slots[connection->slot], connection->slot, + connection->data, reportLength + 1); } static void add_device(void* context, IOReturn result, void* sender, IOHIDDeviceRef device) { - char device_name[PATH_MAX]; + char device_name[PATH_MAX_LENGTH]; CFStringRef device_name_ref; CFNumberRef vendorID, productID; struct pad_connection* connection = (struct pad_connection*) @@ -208,13 +210,11 @@ static void add_device(void* context, IOReturn result, static void append_matching_dictionary(CFMutableArrayRef array, uint32_t page, uint32_t use) { - CFNumberRef pagen, usen; - CFMutableDictionaryRef matcher; - - matcher = CFDictionaryCreateMutable(kCFAllocatorDefault, 0, + CFNumberRef usen; + CFMutableDictionaryRef matcher = CFDictionaryCreateMutable(kCFAllocatorDefault, 0, &kCFTypeDictionaryKeyCallBacks, &kCFTypeDictionaryValueCallBacks); + CFNumberRef pagen = CFNumberCreate(kCFAllocatorDefault, kCFNumberIntType, &page); - pagen = CFNumberCreate(kCFAllocatorDefault, kCFNumberIntType, &page); CFDictionarySetValue(matcher, CFSTR(kIOHIDDeviceUsagePageKey), pagen); CFRelease(pagen); @@ -286,6 +286,7 @@ static bool apple_joypad_button(unsigned port, uint16_t joykey) { apple_input_data_t *apple = (apple_input_data_t*)driver.input_data; uint32_t buttons = pad_connection_get_buttons(&slots[port], port); + if (!apple || joykey == NO_BTN) return false; diff --git a/input/input_common.c b/input/input_common.c index 550886c5e0..798df1dcc1 100644 --- a/input/input_common.c +++ b/input/input_common.c @@ -15,6 +15,7 @@ */ #include "input_common.h" +#include "input_keymaps.h" #include #include #include @@ -168,6 +169,27 @@ const char *input_config_get_prefix(unsigned user, bool meta) return NULL; } +static enum retro_key find_rk_bind(const char *str) +{ + size_t i; + + for (i = 0; input_config_key_map[i].str; i++) + { + if (strcasecmp(input_config_key_map[i].str, str) == 0) + return input_config_key_map[i].key; + } + + RARCH_WARN("Key name %s not found.\n", str); + return RETROK_UNKNOWN; +} + +enum retro_key input_translate_str_to_rk(const char *str) +{ + if (strlen(str) == 1 && isalpha(*str)) + return (enum retro_key)(RETROK_a + (tolower(*str) - (int)'a')); + return find_rk_bind(str); +} + /** * input_translate_str_to_bind_id: * @str : String to translate to bind ID. diff --git a/input/input_common.h b/input/input_common.h index ad977f5a61..983b171a75 100644 --- a/input/input_common.h +++ b/input/input_common.h @@ -56,6 +56,7 @@ void input_get_bind_string(char *buf, const struct retro_keybind *bind, const struct retro_keybind *auto_bind, size_t size); void input_translate_rk_to_str(enum retro_key key, char *buf, size_t size); + enum retro_key input_translate_str_to_rk(const char *str); const char *input_config_get_prefix(unsigned user, bool meta); diff --git a/input/input_context.c b/input/input_context.c index 22870afffc..47be0e30a8 100644 --- a/input/input_context.c +++ b/input/input_context.c @@ -105,153 +105,6 @@ const char* config_get_joypad_driver_options(void) return options; } -const struct input_key_map input_config_key_map[] = { - { "left", RETROK_LEFT }, - { "right", RETROK_RIGHT }, - { "up", RETROK_UP }, - { "down", RETROK_DOWN }, - { "enter", RETROK_RETURN }, - { "kp_enter", RETROK_KP_ENTER }, - { "tab", RETROK_TAB }, - { "insert", RETROK_INSERT }, - { "del", RETROK_DELETE }, - { "end", RETROK_END }, - { "home", RETROK_HOME }, - { "rshift", RETROK_RSHIFT }, - { "shift", RETROK_LSHIFT }, - { "ctrl", RETROK_LCTRL }, - { "alt", RETROK_LALT }, - { "space", RETROK_SPACE }, - { "escape", RETROK_ESCAPE }, - { "add", RETROK_KP_PLUS }, - { "subtract", RETROK_KP_MINUS }, - { "kp_plus", RETROK_KP_PLUS }, - { "kp_minus", RETROK_KP_MINUS }, - { "f1", RETROK_F1 }, - { "f2", RETROK_F2 }, - { "f3", RETROK_F3 }, - { "f4", RETROK_F4 }, - { "f5", RETROK_F5 }, - { "f6", RETROK_F6 }, - { "f7", RETROK_F7 }, - { "f8", RETROK_F8 }, - { "f9", RETROK_F9 }, - { "f10", RETROK_F10 }, - { "f11", RETROK_F11 }, - { "f12", RETROK_F12 }, - { "num0", RETROK_0 }, - { "num1", RETROK_1 }, - { "num2", RETROK_2 }, - { "num3", RETROK_3 }, - { "num4", RETROK_4 }, - { "num5", RETROK_5 }, - { "num6", RETROK_6 }, - { "num7", RETROK_7 }, - { "num8", RETROK_8 }, - { "num9", RETROK_9 }, - { "pageup", RETROK_PAGEUP }, - { "pagedown", RETROK_PAGEDOWN }, - { "keypad0", RETROK_KP0 }, - { "keypad1", RETROK_KP1 }, - { "keypad2", RETROK_KP2 }, - { "keypad3", RETROK_KP3 }, - { "keypad4", RETROK_KP4 }, - { "keypad5", RETROK_KP5 }, - { "keypad6", RETROK_KP6 }, - { "keypad7", RETROK_KP7 }, - { "keypad8", RETROK_KP8 }, - { "keypad9", RETROK_KP9 }, - { "period", RETROK_PERIOD }, - { "capslock", RETROK_CAPSLOCK }, - { "numlock", RETROK_NUMLOCK }, - { "backspace", RETROK_BACKSPACE }, - { "multiply", RETROK_KP_MULTIPLY }, - { "divide", RETROK_KP_DIVIDE }, - { "print_screen", RETROK_PRINT }, - { "scroll_lock", RETROK_SCROLLOCK }, - { "tilde", RETROK_BACKQUOTE }, - { "backquote", RETROK_BACKQUOTE }, - { "pause", RETROK_PAUSE }, - - /* Keys that weren't mappable before */ - { "quote", RETROK_QUOTE }, - { "comma", RETROK_COMMA }, - { "minus", RETROK_MINUS }, - { "slash", RETROK_SLASH }, - { "semicolon", RETROK_SEMICOLON }, - { "equals", RETROK_EQUALS }, - { "leftbracket", RETROK_LEFTBRACKET }, - { "backslash", RETROK_BACKSLASH }, - { "rightbracket", RETROK_RIGHTBRACKET }, - { "kp_period", RETROK_KP_PERIOD }, - { "kp_equals", RETROK_KP_EQUALS }, - { "rctrl", RETROK_RCTRL }, - { "ralt", RETROK_RALT }, - - /* Keys not referenced in any keyboard mapping - * (except perhaps rarch_key_map_apple_hid) */ - { "caret", RETROK_CARET }, - { "underscore", RETROK_UNDERSCORE }, - { "exclaim", RETROK_EXCLAIM }, - { "quotedbl", RETROK_QUOTEDBL }, - { "hash", RETROK_HASH }, - { "dollar", RETROK_DOLLAR }, - { "ampersand", RETROK_AMPERSAND }, - { "leftparen", RETROK_LEFTPAREN }, - { "rightparen", RETROK_RIGHTPAREN }, - { "asterisk", RETROK_ASTERISK }, - { "plus", RETROK_PLUS }, - { "colon", RETROK_COLON }, - { "less", RETROK_LESS }, - { "greater", RETROK_GREATER }, - { "question", RETROK_QUESTION }, - { "at", RETROK_AT }, - - { "f13", RETROK_F13 }, - { "f14", RETROK_F14 }, - { "f15", RETROK_F15 }, - - { "rmeta", RETROK_RMETA }, - { "lmeta", RETROK_LMETA }, - { "lsuper", RETROK_LSUPER }, - { "rsuper", RETROK_RSUPER }, - { "mode", RETROK_MODE }, - { "compose", RETROK_COMPOSE }, - - { "help", RETROK_HELP }, - { "sysreq", RETROK_SYSREQ }, - { "break", RETROK_BREAK }, - { "menu", RETROK_MENU }, - { "power", RETROK_POWER }, - { "euro", RETROK_EURO }, - { "undo", RETROK_UNDO }, - { "clear", RETROK_CLEAR }, - - { "nul", RETROK_UNKNOWN }, - { NULL, RETROK_UNKNOWN }, -}; - -static enum retro_key find_rk_bind(const char *str) -{ - size_t i; - - for (i = 0; input_config_key_map[i].str; i++) - { - if (strcasecmp(input_config_key_map[i].str, str) == 0) - return input_config_key_map[i].key; - } - - RARCH_WARN("Key name %s not found.\n", str); - return RETROK_UNKNOWN; -} - -enum retro_key input_translate_str_to_rk(const char *str) -{ - if (strlen(str) == 1 && isalpha(*str)) - return (enum retro_key)(RETROK_a + (tolower(*str) - (int)'a')); - return find_rk_bind(str); -} - /** * input_joypad_init_driver: * @ident : identifier of driver to initialize. diff --git a/input/input_keymaps.c b/input/input_keymaps.c index 41797230b1..273e415bc2 100644 --- a/input/input_keymaps.c +++ b/input/input_keymaps.c @@ -47,6 +47,132 @@ #include #endif +const struct input_key_map input_config_key_map[] = { + { "left", RETROK_LEFT }, + { "right", RETROK_RIGHT }, + { "up", RETROK_UP }, + { "down", RETROK_DOWN }, + { "enter", RETROK_RETURN }, + { "kp_enter", RETROK_KP_ENTER }, + { "tab", RETROK_TAB }, + { "insert", RETROK_INSERT }, + { "del", RETROK_DELETE }, + { "end", RETROK_END }, + { "home", RETROK_HOME }, + { "rshift", RETROK_RSHIFT }, + { "shift", RETROK_LSHIFT }, + { "ctrl", RETROK_LCTRL }, + { "alt", RETROK_LALT }, + { "space", RETROK_SPACE }, + { "escape", RETROK_ESCAPE }, + { "add", RETROK_KP_PLUS }, + { "subtract", RETROK_KP_MINUS }, + { "kp_plus", RETROK_KP_PLUS }, + { "kp_minus", RETROK_KP_MINUS }, + { "f1", RETROK_F1 }, + { "f2", RETROK_F2 }, + { "f3", RETROK_F3 }, + { "f4", RETROK_F4 }, + { "f5", RETROK_F5 }, + { "f6", RETROK_F6 }, + { "f7", RETROK_F7 }, + { "f8", RETROK_F8 }, + { "f9", RETROK_F9 }, + { "f10", RETROK_F10 }, + { "f11", RETROK_F11 }, + { "f12", RETROK_F12 }, + { "num0", RETROK_0 }, + { "num1", RETROK_1 }, + { "num2", RETROK_2 }, + { "num3", RETROK_3 }, + { "num4", RETROK_4 }, + { "num5", RETROK_5 }, + { "num6", RETROK_6 }, + { "num7", RETROK_7 }, + { "num8", RETROK_8 }, + { "num9", RETROK_9 }, + { "pageup", RETROK_PAGEUP }, + { "pagedown", RETROK_PAGEDOWN }, + { "keypad0", RETROK_KP0 }, + { "keypad1", RETROK_KP1 }, + { "keypad2", RETROK_KP2 }, + { "keypad3", RETROK_KP3 }, + { "keypad4", RETROK_KP4 }, + { "keypad5", RETROK_KP5 }, + { "keypad6", RETROK_KP6 }, + { "keypad7", RETROK_KP7 }, + { "keypad8", RETROK_KP8 }, + { "keypad9", RETROK_KP9 }, + { "period", RETROK_PERIOD }, + { "capslock", RETROK_CAPSLOCK }, + { "numlock", RETROK_NUMLOCK }, + { "backspace", RETROK_BACKSPACE }, + { "multiply", RETROK_KP_MULTIPLY }, + { "divide", RETROK_KP_DIVIDE }, + { "print_screen", RETROK_PRINT }, + { "scroll_lock", RETROK_SCROLLOCK }, + { "tilde", RETROK_BACKQUOTE }, + { "backquote", RETROK_BACKQUOTE }, + { "pause", RETROK_PAUSE }, + + /* Keys that weren't mappable before */ + { "quote", RETROK_QUOTE }, + { "comma", RETROK_COMMA }, + { "minus", RETROK_MINUS }, + { "slash", RETROK_SLASH }, + { "semicolon", RETROK_SEMICOLON }, + { "equals", RETROK_EQUALS }, + { "leftbracket", RETROK_LEFTBRACKET }, + { "backslash", RETROK_BACKSLASH }, + { "rightbracket", RETROK_RIGHTBRACKET }, + { "kp_period", RETROK_KP_PERIOD }, + { "kp_equals", RETROK_KP_EQUALS }, + { "rctrl", RETROK_RCTRL }, + { "ralt", RETROK_RALT }, + + /* Keys not referenced in any keyboard mapping + * (except perhaps rarch_key_map_apple_hid) */ + { "caret", RETROK_CARET }, + { "underscore", RETROK_UNDERSCORE }, + { "exclaim", RETROK_EXCLAIM }, + { "quotedbl", RETROK_QUOTEDBL }, + { "hash", RETROK_HASH }, + { "dollar", RETROK_DOLLAR }, + { "ampersand", RETROK_AMPERSAND }, + { "leftparen", RETROK_LEFTPAREN }, + { "rightparen", RETROK_RIGHTPAREN }, + { "asterisk", RETROK_ASTERISK }, + { "plus", RETROK_PLUS }, + { "colon", RETROK_COLON }, + { "less", RETROK_LESS }, + { "greater", RETROK_GREATER }, + { "question", RETROK_QUESTION }, + { "at", RETROK_AT }, + + { "f13", RETROK_F13 }, + { "f14", RETROK_F14 }, + { "f15", RETROK_F15 }, + + { "rmeta", RETROK_RMETA }, + { "lmeta", RETROK_LMETA }, + { "lsuper", RETROK_LSUPER }, + { "rsuper", RETROK_RSUPER }, + { "mode", RETROK_MODE }, + { "compose", RETROK_COMPOSE }, + + { "help", RETROK_HELP }, + { "sysreq", RETROK_SYSREQ }, + { "break", RETROK_BREAK }, + { "menu", RETROK_MENU }, + { "power", RETROK_POWER }, + { "euro", RETROK_EURO }, + { "undo", RETROK_UNDO }, + { "clear", RETROK_CLEAR }, + + { "nul", RETROK_UNKNOWN }, + { NULL, RETROK_UNKNOWN }, +}; + #ifdef HAVE_X11 const struct rarch_key_map rarch_key_map_x11[] = { { XK_BackSpace, RETROK_BACKSPACE }, From 89902c3339b0555b7d2d8d970c1404fbb77a0e03 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Sun, 11 Jan 2015 00:10:32 +0100 Subject: [PATCH 023/156] Remove unneeded header include in input_common.h --- input/input_common.h | 1 - 1 file changed, 1 deletion(-) diff --git a/input/input_common.h b/input/input_common.h index 983b171a75..7ca96518e3 100644 --- a/input/input_common.h +++ b/input/input_common.h @@ -21,7 +21,6 @@ extern "C" { #endif -#include "input_context.h" #include #include #include "../driver.h" From 10c042f1dc3437cae44e7766dc389b10d3e529f9 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Sun, 11 Jan 2015 01:29:19 +0100 Subject: [PATCH 024/156] Some simplifications in Windows input drivers --- input/dinput.c | 176 +++++++++++++++++++++++---------------- input/gx_input.c | 6 +- input/linuxraw_input.c | 62 ++++++++------ input/linuxraw_joypad.c | 40 ++++++--- input/winxinput_joypad.c | 114 ++++++++++++++----------- 5 files changed, 238 insertions(+), 160 deletions(-) diff --git a/input/dinput.c b/input/dinput.c index ca1657da12..a7b972e2e9 100644 --- a/input/dinput.c +++ b/input/dinput.c @@ -72,11 +72,11 @@ static struct dinput_joypad g_pads[MAX_USERS]; static void dinput_destroy_context(void) { - if (g_ctx) - { - IDirectInput8_Release(g_ctx); - g_ctx = NULL; - } + if (!g_ctx) + return; + + IDirectInput8_Release(g_ctx); + g_ctx = NULL; } static bool dinput_init_context(void) @@ -106,13 +106,15 @@ static bool dinput_init_context(void) static void *dinput_init(void) { + struct dinput_input *di = NULL; + if (!dinput_init_context()) { RARCH_ERR("Failed to start DirectInput driver.\n"); return NULL; } - struct dinput_input *di = (struct dinput_input*)calloc(1, sizeof(*di)); + di = (struct dinput_input*)calloc(1, sizeof(*di)); if (!di) return NULL; @@ -217,10 +219,11 @@ static void dinput_poll(void *data) static bool dinput_keyboard_pressed(struct dinput_input *di, unsigned key) { + unsigned sym; if (key >= RETROK_LAST) return false; - unsigned sym = input_translate_rk_to_keysym((enum retro_key)key); + sym = input_translate_rk_to_keysym((enum retro_key)key); return di->state[sym] & 0x80; } @@ -228,10 +231,10 @@ static bool dinput_is_pressed(struct dinput_input *di, const struct retro_keybind *binds, unsigned port, unsigned id) { + const struct retro_keybind *bind = &binds[id]; if (id >= RARCH_BIND_LIST_END) return false; - const struct retro_keybind *bind = &binds[id]; return dinput_keyboard_pressed(di, bind->key) || input_joypad_pressed(di->joypad, port, binds, id); } @@ -240,19 +243,23 @@ static int16_t dinput_pressed_analog(struct dinput_input *di, const struct retro_keybind *binds, unsigned idx, unsigned id) { - unsigned id_minus = 0; - unsigned id_plus = 0; + const struct retro_keybind *bind_minus, *bind_plus; + int16_t pressed_minus = 0, pressed_plus = 0; + unsigned id_minus = 0, id_plus = 0; + input_conv_analog_id_to_bind_id(idx, id, &id_minus, &id_plus); - const struct retro_keybind *bind_minus = &binds[id_minus]; - const struct retro_keybind *bind_plus = &binds[id_plus]; + bind_minus = &binds[id_minus]; + bind_plus = &binds[id_plus]; + if (!bind_minus->valid || !bind_plus->valid) return 0; - int16_t pressed_minus = - dinput_keyboard_pressed(di, bind_minus->key) ? -0x7fff : 0; - int16_t pressed_plus = - dinput_keyboard_pressed(di, bind_plus->key) ? 0x7fff : 0; + if (dinput_keyboard_pressed(di, bind_minus->key)) + pressed_minus = -0x7fff; + if (dinput_keyboard_pressed(di, bind_plus->key)) + pressed_plus = 0x7fff; + return pressed_plus + pressed_minus; } @@ -311,9 +318,12 @@ static int16_t dinput_mouse_state(struct dinput_input *di, unsigned id) static int16_t dinput_pointer_state(struct dinput_input *di, unsigned idx, unsigned id, bool screen) { + bool pointer_down, valid, inside; + int x, y; int16_t res_x = 0, res_y = 0, res_screen_x = 0, res_screen_y = 0; unsigned num = 0; struct pointer_status *check_pos = di->pointer_head.next; + while (check_pos && num < idx) { num++; @@ -322,11 +332,11 @@ static int16_t dinput_pointer_state(struct dinput_input *di, if (!check_pos && idx > 0) /* idx = 0 has mouse fallback. */ return 0; - int x = check_pos ? check_pos->pointer_x : di->mouse_x; - int y = check_pos ? check_pos->pointer_y : di->mouse_y; - bool pointer_down = check_pos ? true : di->mouse_l; + x = check_pos ? check_pos->pointer_x : di->mouse_x; + y = check_pos ? check_pos->pointer_y : di->mouse_y; + pointer_down = check_pos ? true : di->mouse_l; - bool valid = input_translate_coord_viewport(x, y, + valid = input_translate_coord_viewport(x, y, &res_x, &res_y, &res_screen_x, &res_screen_y); if (!valid) @@ -338,7 +348,7 @@ static int16_t dinput_pointer_state(struct dinput_input *di, res_y = res_screen_y; } - bool inside = (res_x >= -0x7fff) && (res_y >= -0x7fff); + inside = (res_x >= -0x7fff) && (res_y >= -0x7fff); if (!inside) return 0; @@ -388,22 +398,25 @@ static int16_t dinput_input_state(void *data, case RETRO_DEVICE_LIGHTGUN: return dinput_lightgun_state(di, id); - - default: - return 0; } + + return 0; } -/* these are defined in later SDKs, thus ifdeffed. */ +/* These are defined in later SDKs, thus ifdeffed. */ + #ifndef WM_POINTERUPDATE #define WM_POINTERUPDATE 0x0245 #endif + #ifndef WM_POINTERDOWN #define WM_POINTERDOWN 0x0246 #endif + #ifndef WM_POINTERUP #define WM_POINTERUP 0x0247 #endif + #ifndef GET_POINTERID_WPARAM #define GET_POINTERID_WPARAM(wParam) (LOWORD(wParam)) #endif @@ -412,6 +425,7 @@ static int16_t dinput_input_state(void *data, void dinput_pointer_store_pos(struct pointer_status *pointer, WPARAM lParam) { POINT point; + point.x = GET_X_LPARAM(lParam); point.y = GET_Y_LPARAM(lParam); ScreenToClient((HWND)driver.video_window, &point); @@ -422,8 +436,11 @@ void dinput_pointer_store_pos(struct pointer_status *pointer, WPARAM lParam) void dinput_add_pointer(struct dinput_input *di, struct pointer_status *new_pointer) { + struct pointer_status *insert_pos = NULL; + new_pointer->next = NULL; - struct pointer_status *insert_pos = &di->pointer_head; + insert_pos = &di->pointer_head; + while (insert_pos->next) insert_pos = insert_pos->next; insert_pos->next = new_pointer; @@ -432,11 +449,13 @@ void dinput_add_pointer(struct dinput_input *di, void dinput_delete_pointer(struct dinput_input *di, int pointer_id) { struct pointer_status *check_pos = &di->pointer_head; + while (check_pos && check_pos->next) { if (check_pos->next->pointer_id == pointer_id) { struct pointer_status *to_delete = check_pos->next; + check_pos->next = check_pos->next->next; free(to_delete); } @@ -448,6 +467,7 @@ struct pointer_status *dinput_find_pointer(struct dinput_input *di, int pointer_id) { struct pointer_status *check_pos = di->pointer_head.next; + while (check_pos) { if (check_pos->pointer_id == pointer_id) @@ -460,9 +480,11 @@ struct pointer_status *dinput_find_pointer(struct dinput_input *di, void dinput_clear_pointers(struct dinput_input *di) { struct pointer_status *pointer = &di->pointer_head; + while (pointer->next) { struct pointer_status *del = pointer->next; + pointer->next = pointer->next->next; free(del); } @@ -475,11 +497,11 @@ bool dinput_handle_message(void *dinput, UINT message, WPARAM wParam, LPARAM lPa { struct dinput_input *di = (struct dinput_input *)dinput; /* WM_POINTERDOWN : Arrives for each new touch event - * with a new ID - add to list. + * with a new ID - add to list. * WM_POINTERUP : Arrives once the pointer is no - * longer down - remove from list. + * longer down - remove from list. * WM_POINTERUPDATE : arrives for both pressed and - * hovering pointers - ignore hovering + * hovering pointers - ignore hovering */ switch (message) @@ -488,6 +510,7 @@ bool dinput_handle_message(void *dinput, UINT message, WPARAM wParam, LPARAM lPa { struct pointer_status *new_pointer = (struct pointer_status *)malloc(sizeof(struct pointer_status)); + if (!new_pointer) { RARCH_ERR("dinput_handle_message: pointer allocation in WM_POINTERDOWN failed.\n"); @@ -555,6 +578,7 @@ static void dinput_free(void *data) static void dinput_grab_mouse(void *data, bool state) { struct dinput_input *di = (struct dinput_input*)data; + IDirectInputDevice8_Unacquire(di->mouse); IDirectInputDevice8_SetCooperativeLevel(di->mouse, (HWND)driver.video_window, @@ -568,12 +592,16 @@ static bool dinput_set_rumble(void *data, unsigned port, enum retro_rumble_effect effect, uint16_t strength) { struct dinput_input *di = (struct dinput_input*)data; + if (!di) + return false; return input_joypad_set_rumble(di->joypad, port, effect, strength); } static const rarch_joypad_driver_t *dinput_get_joypad_driver(void *data) { struct dinput_input *di = (struct dinput_input*)data; + if (!di) + return false; return di->joypad; } @@ -641,9 +669,9 @@ static void dinput_joypad_destroy(void) static BOOL CALLBACK enum_axes_cb( const DIDEVICEOBJECTINSTANCE *inst, void *p) { + DIPROPRANGE range; LPDIRECTINPUTDEVICE8 joypad = (LPDIRECTINPUTDEVICE8)p; - DIPROPRANGE range; memset(&range, 0, sizeof(range)); range.diph.dwSize = sizeof(DIPROPRANGE); range.diph.dwHeaderSize = sizeof(DIPROPHEADER); @@ -657,17 +685,16 @@ static BOOL CALLBACK enum_axes_cb( } static const GUID common_xinput_guids[] = { - {MAKELONG(0x28DE, 0x11FF),0x0000,0x0000,{0x00,0x00,0x50,0x49,0x44,0x56,0x49,0x44}}, // valve streaming pad - {MAKELONG(0x045E, 0x02A1),0x0000,0x0000,{0x00,0x00,0x50,0x49,0x44,0x56,0x49,0x44}}, // wired 360 pad - {MAKELONG(0x045E, 0x028E),0x0000,0x0000,{0x00,0x00,0x50,0x49,0x44,0x56,0x49,0x44}} // wireless 360 pad + {MAKELONG(0x28DE, 0x11FF),0x0000,0x0000,{0x00,0x00,0x50,0x49,0x44,0x56,0x49,0x44}}, /* Valve streaming pad */ + {MAKELONG(0x045E, 0x02A1),0x0000,0x0000,{0x00,0x00,0x50,0x49,0x44,0x56,0x49,0x44}}, /* Wired 360 pad */ + {MAKELONG(0x045E, 0x028E),0x0000,0x0000,{0x00,0x00,0x50,0x49,0x44,0x56,0x49,0x44}} /* wireless 360 pad */ }; /* Based on SDL2's implementation. */ static bool guid_is_xinput_device(const GUID* product_guid) { + unsigned i, num_raw_devs = 0; PRAWINPUTDEVICELIST raw_devs = NULL; - unsigned num_raw_devs = 0; - unsigned i; /* Check for well known XInput device GUIDs, * thereby removing the need for the IG_ check. @@ -711,6 +738,7 @@ static bool guid_is_xinput_device(const GUID* product_guid) UINT nameSize = sizeof(devName); rdi.cbSize = sizeof (rdi); + if ((raw_devs[i].dwType == RIM_TYPEHID) && (GetRawInputDeviceInfoA(raw_devs[i].hDevice, RIDI_DEVICEINFO, &rdi, &rdiSize) != ((UINT)-1)) && (MAKELONG(rdi.hid.dwVendorId, rdi.hid.dwProductId) == ((LONG)product_guid->Data1)) && @@ -735,11 +763,15 @@ static unsigned g_last_xinput_pad_idx; static BOOL CALLBACK enum_joypad_cb(const DIDEVICEINSTANCE *inst, void *p) { + bool is_xinput_pad; + LPDIRECTINPUTDEVICE8 *pad = NULL; + (void)p; + if (g_joypad_cnt == MAX_USERS) return DIENUM_STOP; - LPDIRECTINPUTDEVICE8 *pad = &g_pads[g_joypad_cnt].joypad; + pad = &g_pads[g_joypad_cnt].joypad; #ifdef __cplusplus if (FAILED(IDirectInput8_CreateDevice( @@ -754,10 +786,10 @@ static BOOL CALLBACK enum_joypad_cb(const DIDEVICEINSTANCE *inst, void *p) #ifdef HAVE_WINXINPUT #if 0 - bool is_xinput_pad = g_xinput_block_pads + is_xinput_pad = g_xinput_block_pads && name_is_xinput_pad(inst->tszProductName); #endif - bool is_xinput_pad = g_xinput_block_pads + is_xinput_pad = g_xinput_block_pads && guid_is_xinput_device(&inst->guidProduct); if (is_xinput_pad) @@ -796,6 +828,7 @@ enum_iteration_done: static bool dinput_joypad_init(void) { unsigned i; + if (!dinput_init_context()) return false; @@ -816,27 +849,29 @@ static bool dinput_joypad_init(void) static bool dinput_joypad_button(unsigned port_num, uint16_t joykey) { + const struct dinput_joypad *pad = NULL; + if (joykey == NO_BTN) return false; - const struct dinput_joypad *pad = &g_pads[port_num]; + pad = &g_pads[port_num]; if (!pad->joypad) return false; - // Check hat. + /* Check hat. */ if (GET_HAT_DIR(joykey)) { - unsigned hat = GET_HAT(joykey); - + unsigned pov; + unsigned hat = GET_HAT(joykey); unsigned elems = sizeof(pad->joy_state.rgdwPOV) / sizeof(pad->joy_state.rgdwPOV[0]); if (hat >= elems) return false; - unsigned pov = pad->joy_state.rgdwPOV[hat]; + pov = pad->joy_state.rgdwPOV[hat]; - // Magic numbers I'm not sure where originate from. + /* Magic numbers I'm not sure where originate from. */ if (pov < 36000) { switch (GET_HAT_DIR(joykey)) @@ -868,19 +903,19 @@ static bool dinput_joypad_button(unsigned port_num, uint16_t joykey) static int16_t dinput_joypad_axis(unsigned port_num, uint32_t joyaxis) { - if (joyaxis == AXIS_NONE) - return 0; - - const struct dinput_joypad *pad = &g_pads[port_num]; - if (!pad->joypad) - return 0; - + const struct dinput_joypad *pad = NULL; int val = 0; - int axis = -1; bool is_neg = false; bool is_pos = false; + if (joyaxis == AXIS_NONE) + return 0; + + pad = &g_pads[port_num]; + if (!pad->joypad) + return 0; + if (AXIS_NEG_GET(joyaxis) <= 5) { axis = AXIS_NEG_GET(joyaxis); @@ -928,30 +963,31 @@ static void dinput_joypad_poll(void) for (i = 0; i < MAX_USERS; i++) { struct dinput_joypad *pad = &g_pads[i]; + bool polled = g_xinput_pad_indexes[i] < 0; - if (pad->joypad && g_xinput_pad_indexes[i] < 0) + if (!pad || !pad->joypad || !polled) + continue; + + memset(&pad->joy_state, 0, sizeof(pad->joy_state)); + + if (FAILED(IDirectInputDevice8_Poll(pad->joypad))) { - memset(&pad->joy_state, 0, sizeof(pad->joy_state)); - - if (FAILED(IDirectInputDevice8_Poll(pad->joypad))) + if (FAILED(IDirectInputDevice8_Acquire(pad->joypad))) { - if (FAILED(IDirectInputDevice8_Acquire(pad->joypad))) - { - memset(&pad->joy_state, 0, sizeof(DIJOYSTATE2)); - continue; - } - - /* If this fails, something *really* bad must have happened. */ - if (FAILED(IDirectInputDevice8_Poll(pad->joypad))) - { - memset(&pad->joy_state, 0, sizeof(DIJOYSTATE2)); - continue; - } + memset(&pad->joy_state, 0, sizeof(DIJOYSTATE2)); + continue; } - IDirectInputDevice8_GetDeviceState(pad->joypad, - sizeof(DIJOYSTATE2), &pad->joy_state); + /* If this fails, something *really* bad must have happened. */ + if (FAILED(IDirectInputDevice8_Poll(pad->joypad))) + { + memset(&pad->joy_state, 0, sizeof(DIJOYSTATE2)); + continue; + } } + + IDirectInputDevice8_GetDeviceState(pad->joypad, + sizeof(DIJOYSTATE2), &pad->joy_state); } } diff --git a/input/gx_input.c b/input/gx_input.c index 88c3c78fa5..9017510101 100644 --- a/input/gx_input.c +++ b/input/gx_input.c @@ -104,9 +104,9 @@ static uint64_t gx_input_get_capabilities(void *data) static const rarch_joypad_driver_t *gx_input_get_joypad_driver(void *data) { gx_input_t *gx = (gx_input_t*)data; - if (gx) - return gx->joypad; - return NULL; + if (!gx) + return NULL; + return gx->joypad; } input_driver_t input_gx = { diff --git a/input/linuxraw_input.c b/input/linuxraw_input.c index 83f7a4c8e6..1855f07764 100644 --- a/input/linuxraw_input.c +++ b/input/linuxraw_input.c @@ -57,7 +57,10 @@ static void linuxraw_exitGracefully(int sig) static void *linuxraw_input_init(void) { - // only work on terminals + linuxraw_input_t *linuxraw; + struct sigaction sa; + + /* Only work on terminals. */ if (!isatty(0)) return NULL; @@ -67,7 +70,7 @@ static void *linuxraw_input_init(void) return NULL; } - linuxraw_input_t *linuxraw = (linuxraw_input_t*)calloc(1, sizeof(*linuxraw)); + linuxraw = (linuxraw_input_t*)calloc(1, sizeof(*linuxraw)); if (!linuxraw) return NULL; @@ -96,7 +99,6 @@ static void *linuxraw_input_init(void) return NULL; } - struct sigaction sa; sa.sa_handler = linuxraw_exitGracefully; sa.sa_flags = SA_RESTART | SA_RESETHAND; sigemptyset(&sa.sa_mask); @@ -118,6 +120,7 @@ static void *linuxraw_input_init(void) /* We need to disable use of stdin command interface if * stdin is supposed to be used for input. */ driver.stdin_claimed = true; + return linuxraw; } @@ -130,32 +133,37 @@ static bool linuxraw_key_pressed(linuxraw_input_t *linuxraw, int key) static bool linuxraw_is_pressed(linuxraw_input_t *linuxraw, const struct retro_keybind *binds, unsigned id) { - if (id < RARCH_BIND_LIST_END) - { - const struct retro_keybind *bind = &binds[id]; - if (bind) - return bind->valid && linuxraw_key_pressed(linuxraw, binds[id].key); - } - return false; + const struct retro_keybind *bind = &binds[id]; + + if (id >= RARCH_BIND_LIST_END) + return false; + if (!bind) + return false; + + return bind->valid && linuxraw_key_pressed(linuxraw, binds[id].key); } static int16_t linuxraw_analog_pressed(linuxraw_input_t *linuxraw, const struct retro_keybind *binds, unsigned idx, unsigned id) { + int16_t pressed_minus = 0, pressed_plus = 0; unsigned id_minus = 0; unsigned id_plus = 0; input_conv_analog_id_to_bind_id(idx, id, &id_minus, &id_plus); - int16_t pressed_minus = linuxraw_is_pressed(linuxraw, - binds, id_minus) ? -0x7fff : 0; - int16_t pressed_plus = linuxraw_is_pressed(linuxraw, - binds, id_plus) ? 0x7fff : 0; + if (linuxraw_is_pressed(linuxraw, binds, id_minus)) + pressed_minus = -0x7fff; + if (linuxraw_is_pressed(linuxraw, binds, id_plus)) + pressed_plus = 0x7fff; + return pressed_plus + pressed_minus; } static bool linuxraw_bind_button_pressed(void *data, int key) { linuxraw_input_t *linuxraw = (linuxraw_input_t*)data; + if (!linuxraw) + return false; return linuxraw_is_pressed(linuxraw, g_settings.input.binds[0], key) || input_joypad_pressed(linuxraw->joypad, 0, g_settings.input.binds[0], key); } @@ -178,10 +186,9 @@ static int16_t linuxraw_input_state(void *data, if (!ret) ret = input_joypad_analog(linuxraw->joypad, port, idx, id, binds[port]); return ret; - - default: - return 0; } + + return 0; } static void linuxraw_input_free(void *data) @@ -202,31 +209,33 @@ static bool linuxraw_set_rumble(void *data, unsigned port, enum retro_rumble_effect effect, uint16_t strength) { linuxraw_input_t *linuxraw = (linuxraw_input_t*)data; - if (linuxraw) - return input_joypad_set_rumble(linuxraw->joypad, port, effect, strength); - return false; + if (!linuxraw) + return false; + return input_joypad_set_rumble(linuxraw->joypad, port, effect, strength); } static const rarch_joypad_driver_t *linuxraw_get_joypad_driver(void *data) { linuxraw_input_t *linuxraw = (linuxraw_input_t*)data; - if (linuxraw) - return linuxraw->joypad; - return NULL; + if (!linuxraw) + return false; + return linuxraw->joypad; } static void linuxraw_input_poll(void *data) { - linuxraw_input_t *linuxraw = (linuxraw_input_t*)data; uint8_t c; uint16_t t; + linuxraw_input_t *linuxraw = (linuxraw_input_t*)data; while (read(STDIN_FILENO, &c, 1) > 0) { + bool pressed; + if (c == KEY_C && (linuxraw->state[KEY_LEFTCTRL] || linuxraw->state[KEY_RIGHTCTRL])) kill(getpid(), SIGINT); - bool pressed = !(c & 0x80); + pressed = !(c & 0x80); c &= ~0x80; // ignore extended scancodes @@ -242,9 +251,10 @@ static void linuxraw_input_poll(void *data) static uint64_t linuxraw_get_capabilities(void *data) { - (void)data; uint64_t caps = 0; + (void)data; + caps |= (1 << RETRO_DEVICE_JOYPAD); caps |= (1 << RETRO_DEVICE_ANALOG); diff --git a/input/linuxraw_joypad.c b/input/linuxraw_joypad.c index 86c9fd630e..a7d3ddd5d7 100644 --- a/input/linuxraw_joypad.c +++ b/input/linuxraw_joypad.c @@ -48,6 +48,7 @@ static bool g_hotplug; static void poll_pad(struct linuxraw_joypad *pad) { struct js_event event; + while (read(pad->fd, &event, sizeof(event)) == (ssize_t)sizeof(event)) { unsigned type = event.type & ~JS_EVENT_INIT; @@ -120,21 +121,26 @@ static void handle_plugged_pad(void) int i, rc; size_t event_size = sizeof(struct inotify_event) + NAME_MAX + 1; uint8_t *event_buf = (uint8_t*)calloc(1, event_size); + if (!event_buf) return; while ((rc = read(g_notify, event_buf, event_size)) >= 0) { struct inotify_event *event = NULL; - // Can read multiple events in one read() call. + + /* Can read multiple events in one read() call. */ + for (i = 0; i < rc; i += event->len + sizeof(struct inotify_event)) { + unsigned idx; + event = (struct inotify_event*)&event_buf[i]; if (strstr(event->name, "js") != event->name) continue; - unsigned idx = strtoul(event->name + 2, NULL, 0); + idx = strtoul(event->name + 2, NULL, 0); if (idx >= MAX_USERS) continue; @@ -165,9 +171,10 @@ static void handle_plugged_pad(void) // Sometimes, device will be created before acess to it is established. else if (event->mask & (IN_CREATE | IN_ATTRIB)) { + bool ret; char path[PATH_MAX]; snprintf(path, sizeof(path), "/dev/input/%s", event->name); - bool ret = linuxraw_joypad_init_pad(path, &linuxraw_pads[idx]); + ret = linuxraw_joypad_init_pad(path, &linuxraw_pads[idx]); if (*linuxraw_pads[idx].ident && ret) /* TODO - implement VID/PID? */ @@ -207,17 +214,22 @@ static void linuxraw_joypad_setup_notify(void) static bool linuxraw_joypad_init(void) { unsigned i; + g_epoll = epoll_create(MAX_USERS + 1); if (g_epoll < 0) return false; for (i = 0; i < MAX_USERS; i++) { + char path[PATH_MAX]; struct linuxraw_joypad *pad = (struct linuxraw_joypad*)&linuxraw_pads[i]; + + if (!pad) + continue; + pad->fd = -1; pad->ident = g_settings.input.device_names[i]; - char path[PATH_MAX]; snprintf(path, sizeof(path), "/dev/input/js%u", i); /* TODO - implement VID/PID? */ @@ -233,9 +245,10 @@ static bool linuxraw_joypad_init(void) g_notify = inotify_init(); if (g_notify >= 0) { + struct epoll_event event; + linuxraw_joypad_setup_notify(); - struct epoll_event event; event.events = EPOLLIN; event.data.ptr = NULL; epoll_ctl(g_epoll, EPOLL_CTL_ADD, g_notify, &event); @@ -249,6 +262,7 @@ static bool linuxraw_joypad_init(void) static void linuxraw_joypad_destroy(void) { unsigned i; + for (i = 0; i < MAX_USERS; i++) { if (linuxraw_pads[i].fd >= 0) @@ -256,6 +270,7 @@ static void linuxraw_joypad_destroy(void) } memset(linuxraw_pads, 0, sizeof(linuxraw_pads)); + for (i = 0; i < MAX_USERS; i++) linuxraw_pads[i].fd = -1; @@ -273,26 +288,27 @@ static void linuxraw_joypad_destroy(void) static bool linuxraw_joypad_button(unsigned port, uint16_t joykey) { const struct linuxraw_joypad *pad = (const struct linuxraw_joypad*)&linuxraw_pads[port]; - if (pad) - return joykey < NUM_BUTTONS && BIT32_GET(pad->buttons, joykey); - return false; + if (!pad) + return false; + return joykey < NUM_BUTTONS && BIT32_GET(pad->buttons, joykey); } static int16_t linuxraw_joypad_axis(unsigned port, uint32_t joyaxis) { + int16_t val = 0; + const struct linuxraw_joypad *pad = NULL; + if (joyaxis == AXIS_NONE) return 0; - const struct linuxraw_joypad *pad = (const struct linuxraw_joypad*) - &linuxraw_pads[port]; + pad = (const struct linuxraw_joypad*)&linuxraw_pads[port]; - int16_t val = 0; if (AXIS_NEG_GET(joyaxis) < NUM_AXES) { val = pad->axes[AXIS_NEG_GET(joyaxis)]; if (val > 0) val = 0; - // Kernel returns values in range [-0x7fff, 0x7fff]. + /* Kernel returns values in range [-0x7fff, 0x7fff]. */ } else if (AXIS_POS_GET(joyaxis) < NUM_AXES) { diff --git a/input/winxinput_joypad.c b/input/winxinput_joypad.c index 0e3b3cd10b..48d7421c99 100644 --- a/input/winxinput_joypad.c +++ b/input/winxinput_joypad.c @@ -30,8 +30,9 @@ #include #include -// Check the definitions do not already exist. -// Official and mingw xinput headers have different include guards +/* Check if the definitions do not already exist. + * Official and mingw xinput headers have different include guards. + */ #if ((!_XINPUT_H_) && (!__WINE_XINPUT_H)) #define XINPUT_GAMEPAD_DPAD_UP 0x0001 @@ -74,7 +75,7 @@ typedef struct #endif -// Guide constant is not officially documented +/* Guide constant is not officially documented. */ #define XINPUT_GAMEPAD_GUIDE 0x0400 #ifndef ERROR_DEVICE_NOT_CONNECTED @@ -85,25 +86,28 @@ typedef struct #error Cannot compile xinput without dinput. #endif -// Due to 360 pads showing up under both XI and DI, and since we are going -// to have to pass through unhandled joypad numbers to DI, a slightly ugly -// hack is required here. dinput_joypad_init will fill this. -// For each pad index, the appropriate entry will be set to -1 if it is not -// a 360 pad, or the correct XInput user number (0..3 inclusive) if it is. +/* Due to 360 pads showing up under both XInput and DirectInput, + * and since we are going to have to pass through unhandled + * joypad numbers to DirectInput, a slightly ugly + * hack is required here. dinput_joypad_init will fill this. + * + * For each pad index, the appropriate entry will be set to -1 if it is not + * a 360 pad, or the correct XInput user number (0..3 inclusive) if it is. + */ extern int g_xinput_pad_indexes[MAX_USERS]; extern bool g_xinput_block_pads; -// For xinput1_n.dll +/* For xinput1_n.dll */ static HINSTANCE g_winxinput_dll; -// Function pointer, to be assigned with GetProcAddress +/* Function pointer, to be assigned with GetProcAddress */ typedef uint32_t (__stdcall *XInputGetStateEx_t)(uint32_t, XINPUT_STATE*); static XInputGetStateEx_t g_XInputGetStateEx; typedef uint32_t (__stdcall *XInputSetState_t)(uint32_t, XINPUT_VIBRATION*); static XInputSetState_t g_XInputSetState; -// Guide button may or may not be available +/* Guide button may or may not be available */ static bool g_winxinput_guide_button_supported; typedef struct @@ -121,8 +125,9 @@ static inline int pad_index_to_xuser_index(unsigned pad) return g_xinput_pad_indexes[pad]; } -// Generic "XInput" instead of "Xbox 360", because there are -// some other non-xbox third party PC controllers. +/* Generic "XInput" instead of "Xbox 360", because there are + * some other non-xbox third party PC controllers. + */ static const char* const XBOX_CONTROLLER_NAMES[4] = { "XInput Controller (User 1)", @@ -137,26 +142,30 @@ const char* winxinput_joypad_name (unsigned pad) if (xuser < 0) return dinput_joypad.name(pad); - // TODO: Different name if disconnected? + /* TODO: Different name if disconnected? */ return XBOX_CONTROLLER_NAMES[xuser]; } static bool winxinput_joypad_init(void) { unsigned i, autoconf_pad; + XINPUT_STATE dummy_state; + const char *version = "1.4"; + g_winxinput_dll = NULL; - // Find the correct path to load the DLL from. - // Usually this will be from the system directory, - // but occasionally a user may wish to use a third-party - // wrapper DLL (such as x360ce); support these by checking - // the working directory first. + /* Find the correct path to load the DLL from. + * Usually this will be from the system directory, + * but occasionally a user may wish to use a third-party + * 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 + * success anyway. + */ - // No need to check for existance as we will be checking LoadLibrary's - // success anyway. - - const char *version = "1.4"; - g_winxinput_dll = LoadLibrary("xinput1_4.dll"); // Using dylib_* complicates building joyconfig. + /* Using dylib_* complicates building joyconfig. */ + g_winxinput_dll = LoadLibrary("xinput1_4.dll"); if (!g_winxinput_dll) { g_winxinput_dll = LoadLibrary("xinput1_3.dll"); @@ -171,22 +180,25 @@ static bool winxinput_joypad_init(void) RARCH_LOG("Found XInput v%s.\n", version); - // If we get here then an xinput DLL is correctly loaded. - // First try to load ordinal 100 (XInputGetStateEx). + /* If we get here then an xinput DLL is correctly loaded. + * First try to load ordinal 100 (XInputGetStateEx). + */ g_XInputGetStateEx = (XInputGetStateEx_t) GetProcAddress(g_winxinput_dll, (const char*)100); g_winxinput_guide_button_supported = true; if (!g_XInputGetStateEx) { - // no ordinal 100. (Presumably a wrapper.) Load the ordinary - // XInputGetState, at the cost of losing guide button support. + /* no ordinal 100. (Presumably a wrapper.) Load the ordinary + * XInputGetState, at the cost of losing guide button support. + */ g_winxinput_guide_button_supported = false; g_XInputGetStateEx = (XInputGetStateEx_t) GetProcAddress(g_winxinput_dll, "XInputGetState"); + if (!g_XInputGetStateEx) { RARCH_ERR("Failed to init XInput: DLL is invalid or corrupt.\n"); FreeLibrary(g_winxinput_dll); - return false; // DLL was loaded but did not contain the correct function. + return false; /* DLL was loaded but did not contain the correct function. */ } RARCH_WARN("XInput: No guide button support.\n"); } @@ -196,15 +208,14 @@ static bool winxinput_joypad_init(void) { RARCH_ERR("Failed to init XInput: DLL is invalid or corrupt.\n"); FreeLibrary(g_winxinput_dll); - return false; // DLL was loaded but did not contain the correct function. + return false; /* DLL was loaded but did not contain the correct function. */ } - // Zero out the states + /* Zero out the states. */ for (i = 0; i < 4; ++i) memset(&g_winxinput_states[i], 0, sizeof(winxinput_joypad_state)); - // Do a dummy poll to check which controllers are connected. - XINPUT_STATE dummy_state; + /* Do a dummy poll to check which controllers are connected. */ for (i = 0; i < 4; ++i) { g_winxinput_states[i].connected = !(g_XInputGetStateEx(i, &dummy_state) == ERROR_DEVICE_NOT_CONNECTED); @@ -220,8 +231,8 @@ static bool winxinput_joypad_init(void) g_xinput_block_pads = true; - // We're going to have to be buddies with dinput if we want to be able - // to use XI and non-XI controllers together. + /* We're going to have to be buddies with dinput if we want to be able + * to use XInput and non-XInput controllers together. */ if (!dinput_joypad.init()) { g_xinput_block_pads = false; @@ -262,6 +273,7 @@ static void winxinput_joypad_destroy(void) memset(&g_winxinput_states[i], 0, sizeof(winxinput_joypad_state)); FreeLibrary(g_winxinput_dll); + g_winxinput_dll = NULL; g_XInputGetStateEx = NULL; g_XInputSetState = NULL; @@ -270,9 +282,9 @@ static void winxinput_joypad_destroy(void) g_xinput_block_pads = false; } -// Buttons are provided by XInput as bits of a uint16. -// Map from rarch button index (0..10) to a mask to bitwise-& the buttons against. -// dpad is handled seperately. +/* Buttons are provided by XInput as bits of a uint16. + * Map from rarch button index (0..10) to a mask to bitwise-& the buttons against. + * dpad is handled seperately. */ static const uint16_t button_index_to_bitmap_code[] = { XINPUT_GAMEPAD_A, XINPUT_GAMEPAD_B, @@ -289,17 +301,20 @@ static const uint16_t button_index_to_bitmap_code[] = { static bool winxinput_joypad_button (unsigned port_num, uint16_t joykey) { + uint16_t btn_word; + int xuser; + if (joykey == NO_BTN) return false; - int xuser = pad_index_to_xuser_index(port_num); + xuser = pad_index_to_xuser_index(port_num); if (xuser == -1) return dinput_joypad.button(port_num, joykey); if (!(g_winxinput_states[xuser].connected)) return false; - uint16_t btn_word = g_winxinput_states[xuser].xstate.Gamepad.wButtons; + btn_word = g_winxinput_states[xuser].xstate.Gamepad.wButtons; if (GET_HAT_DIR(joykey)) { @@ -329,10 +344,17 @@ static bool winxinput_joypad_button (unsigned port_num, uint16_t joykey) static int16_t winxinput_joypad_axis (unsigned port_num, uint32_t joyaxis) { + int xuser; + int16_t val = 0; + int axis = -1; + + bool is_neg = false; + bool is_pos = false; + if (joyaxis == AXIS_NONE) return 0; - int xuser = pad_index_to_xuser_index(port_num); + xuser = pad_index_to_xuser_index(port_num); if (xuser == -1) return dinput_joypad.axis(port_num, joyaxis); @@ -340,12 +362,6 @@ static int16_t winxinput_joypad_axis (unsigned port_num, uint32_t joyaxis) if (!(g_winxinput_states[xuser].connected)) return 0; - int16_t val = 0; - int axis = -1; - - bool is_neg = false; - bool is_pos = false; - /* triggers (axes 4,5) cannot be negative */ if (AXIS_NEG_GET(joyaxis) <= 3) { @@ -397,6 +413,7 @@ static int16_t winxinput_joypad_axis (unsigned port_num, uint32_t joyaxis) static void winxinput_joypad_poll(void) { unsigned i; + for (i = 0; i < 4; ++i) { if (g_winxinput_states[i].connected) @@ -404,9 +421,7 @@ static void winxinput_joypad_poll(void) if (g_XInputGetStateEx(i, &(g_winxinput_states[i].xstate)) == ERROR_DEVICE_NOT_CONNECTED) - { g_winxinput_states[i].connected = false; - } } } @@ -417,6 +432,7 @@ static bool winxinput_joypad_rumble(unsigned pad, enum retro_rumble_effect effect, uint16_t strength) { int xuser = pad_index_to_xuser_index(pad); + if (xuser == -1) { if (dinput_joypad.set_rumble) From adf36239447f2584b990e61ff67402ce57d6bbbc Mon Sep 17 00:00:00 2001 From: twinaphex Date: Sun, 11 Jan 2015 01:34:08 +0100 Subject: [PATCH 025/156] Move some enums to retroarch.h --- general.h | 101 +-------------------------------------------- menu/menu_action.c | 1 + retroarch.h | 99 ++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 102 insertions(+), 99 deletions(-) diff --git a/general.h b/general.h index 1225336fa5..5dddfb0c0f 100644 --- a/general.h +++ b/general.h @@ -80,106 +80,9 @@ extern "C" { #endif +#ifndef MAX_USERS #define MAX_USERS 16 - -enum basic_event -{ - RARCH_CMD_NONE = 0, - RARCH_CMD_RESET, - RARCH_CMD_LOAD_CONTENT, - RARCH_CMD_LOAD_CONTENT_PERSIST, - RARCH_CMD_LOAD_CORE, - RARCH_CMD_LOAD_STATE, - RARCH_CMD_SAVE_STATE, - RARCH_CMD_TAKE_SCREENSHOT, - RARCH_CMD_PREPARE_DUMMY, - RARCH_CMD_QUIT, - RARCH_CMD_REINIT, - RARCH_CMD_REWIND_DEINIT, - RARCH_CMD_REWIND_INIT, - RARCH_CMD_REWIND_TOGGLE, - RARCH_CMD_AUTOSAVE_DEINIT, - RARCH_CMD_AUTOSAVE_INIT, - RARCH_CMD_AUTOSAVE_STATE, - RARCH_CMD_AUDIO_STOP, - RARCH_CMD_AUDIO_START, - RARCH_CMD_AUDIO_MUTE_TOGGLE, - RARCH_CMD_OVERLAY_INIT, - RARCH_CMD_OVERLAY_DEINIT, - RARCH_CMD_OVERLAY_SET_SCALE_FACTOR, - RARCH_CMD_OVERLAY_SET_ALPHA_MOD, - RARCH_CMD_OVERLAY_NEXT, - RARCH_CMD_DSP_FILTER_INIT, - RARCH_CMD_DSP_FILTER_DEINIT, - RARCH_CMD_GPU_RECORD_DEINIT, - RARCH_CMD_RECORD_INIT, - RARCH_CMD_RECORD_DEINIT, - RARCH_CMD_HISTORY_DEINIT, - RARCH_CMD_HISTORY_INIT, - RARCH_CMD_CORE_INFO_DEINIT, - RARCH_CMD_CORE_INFO_INIT, - RARCH_CMD_CORE_DEINIT, - RARCH_CMD_CORE_INIT, - RARCH_CMD_AUDIO_SET_BLOCKING_STATE, - RARCH_CMD_AUDIO_SET_NONBLOCKING_STATE, - RARCH_CMD_VIDEO_APPLY_STATE_CHANGES, - RARCH_CMD_VIDEO_SET_BLOCKING_STATE, - RARCH_CMD_VIDEO_SET_NONBLOCKING_STATE, - RARCH_CMD_VIDEO_SET_ASPECT_RATIO, - RARCH_CMD_RESET_CONTEXT, - RARCH_CMD_RESTART_RETROARCH, - RARCH_CMD_QUIT_RETROARCH, - RARCH_CMD_RESUME, - RARCH_CMD_PAUSE_TOGGLE, - RARCH_CMD_UNPAUSE, - RARCH_CMD_PAUSE, - RARCH_CMD_PAUSE_CHECKS, - RARCH_CMD_MENU_SAVE_CONFIG, - RARCH_CMD_MENU_PAUSE_LIBRETRO, - RARCH_CMD_MENU_TOGGLE, - RARCH_CMD_SHADERS_APPLY_CHANGES, - RARCH_CMD_SHADER_DIR_INIT, - RARCH_CMD_SHADER_DIR_DEINIT, - RARCH_CMD_CONTROLLERS_INIT, - RARCH_CMD_SAVEFILES, - RARCH_CMD_SAVEFILES_INIT, - RARCH_CMD_SAVEFILES_DEINIT, - RARCH_CMD_MSG_QUEUE_INIT, - RARCH_CMD_MSG_QUEUE_DEINIT, - RARCH_CMD_CHEATS_INIT, - RARCH_CMD_CHEATS_DEINIT, - RARCH_CMD_NETPLAY_INIT, - RARCH_CMD_NETPLAY_DEINIT, - RARCH_CMD_NETPLAY_FLIP_PLAYERS, - RARCH_CMD_BSV_MOVIE_INIT, - RARCH_CMD_BSV_MOVIE_DEINIT, - RARCH_CMD_COMMAND_INIT, - RARCH_CMD_COMMAND_DEINIT, - RARCH_CMD_DRIVERS_DEINIT, - RARCH_CMD_DRIVERS_INIT, - RARCH_CMD_AUDIO_REINIT, - RARCH_CMD_RESIZE_WINDOWED_SCALE, - RARCH_CMD_TEMPORARY_CONTENT_DEINIT, - RARCH_CMD_SUBSYSTEM_FULLPATHS_DEINIT, - RARCH_CMD_LOG_FILE_DEINIT, - RARCH_CMD_DISK_EJECT_TOGGLE, - RARCH_CMD_DISK_NEXT, - RARCH_CMD_DISK_PREV, - RARCH_CMD_RUMBLE_STOP, - RARCH_CMD_GRAB_MOUSE_TOGGLE, - RARCH_CMD_FULLSCREEN_TOGGLE, - RARCH_CMD_PERFCNT_REPORT_FRONTEND_LOG, -}; - -enum action_state -{ - RARCH_ACTION_STATE_NONE = 0, - RARCH_ACTION_STATE_LOAD_CONTENT, - RARCH_ACTION_STATE_MENU_RUNNING, - RARCH_ACTION_STATE_MENU_RUNNING_FINISHED, - RARCH_ACTION_STATE_QUIT, - RARCH_ACTION_STATE_FORCE_QUIT, -}; +#endif enum sound_mode_enums { diff --git a/menu/menu_action.c b/menu/menu_action.c index 0c1e35684d..cfa452c507 100644 --- a/menu/menu_action.c +++ b/menu/menu_action.c @@ -16,6 +16,7 @@ #include "menu_action.h" #include "menu_entries.h" +#include "../retroarch.h" static int setting_extra_handler(rarch_setting_t *setting) { diff --git a/retroarch.h b/retroarch.h index 4e64bc6fef..211a6c2bf4 100644 --- a/retroarch.h +++ b/retroarch.h @@ -23,6 +23,105 @@ extern "C" { #endif +enum basic_event +{ + RARCH_CMD_NONE = 0, + RARCH_CMD_RESET, + RARCH_CMD_LOAD_CONTENT, + RARCH_CMD_LOAD_CONTENT_PERSIST, + RARCH_CMD_LOAD_CORE, + RARCH_CMD_LOAD_STATE, + RARCH_CMD_SAVE_STATE, + RARCH_CMD_TAKE_SCREENSHOT, + RARCH_CMD_PREPARE_DUMMY, + RARCH_CMD_QUIT, + RARCH_CMD_REINIT, + RARCH_CMD_REWIND_DEINIT, + RARCH_CMD_REWIND_INIT, + RARCH_CMD_REWIND_TOGGLE, + RARCH_CMD_AUTOSAVE_DEINIT, + RARCH_CMD_AUTOSAVE_INIT, + RARCH_CMD_AUTOSAVE_STATE, + RARCH_CMD_AUDIO_STOP, + RARCH_CMD_AUDIO_START, + RARCH_CMD_AUDIO_MUTE_TOGGLE, + RARCH_CMD_OVERLAY_INIT, + RARCH_CMD_OVERLAY_DEINIT, + RARCH_CMD_OVERLAY_SET_SCALE_FACTOR, + RARCH_CMD_OVERLAY_SET_ALPHA_MOD, + RARCH_CMD_OVERLAY_NEXT, + RARCH_CMD_DSP_FILTER_INIT, + RARCH_CMD_DSP_FILTER_DEINIT, + RARCH_CMD_GPU_RECORD_DEINIT, + RARCH_CMD_RECORD_INIT, + RARCH_CMD_RECORD_DEINIT, + RARCH_CMD_HISTORY_DEINIT, + RARCH_CMD_HISTORY_INIT, + RARCH_CMD_CORE_INFO_DEINIT, + RARCH_CMD_CORE_INFO_INIT, + RARCH_CMD_CORE_DEINIT, + RARCH_CMD_CORE_INIT, + RARCH_CMD_AUDIO_SET_BLOCKING_STATE, + RARCH_CMD_AUDIO_SET_NONBLOCKING_STATE, + RARCH_CMD_VIDEO_APPLY_STATE_CHANGES, + RARCH_CMD_VIDEO_SET_BLOCKING_STATE, + RARCH_CMD_VIDEO_SET_NONBLOCKING_STATE, + RARCH_CMD_VIDEO_SET_ASPECT_RATIO, + RARCH_CMD_RESET_CONTEXT, + RARCH_CMD_RESTART_RETROARCH, + RARCH_CMD_QUIT_RETROARCH, + RARCH_CMD_RESUME, + RARCH_CMD_PAUSE_TOGGLE, + RARCH_CMD_UNPAUSE, + RARCH_CMD_PAUSE, + RARCH_CMD_PAUSE_CHECKS, + RARCH_CMD_MENU_SAVE_CONFIG, + RARCH_CMD_MENU_PAUSE_LIBRETRO, + RARCH_CMD_MENU_TOGGLE, + RARCH_CMD_SHADERS_APPLY_CHANGES, + RARCH_CMD_SHADER_DIR_INIT, + RARCH_CMD_SHADER_DIR_DEINIT, + RARCH_CMD_CONTROLLERS_INIT, + RARCH_CMD_SAVEFILES, + RARCH_CMD_SAVEFILES_INIT, + RARCH_CMD_SAVEFILES_DEINIT, + RARCH_CMD_MSG_QUEUE_INIT, + RARCH_CMD_MSG_QUEUE_DEINIT, + RARCH_CMD_CHEATS_INIT, + RARCH_CMD_CHEATS_DEINIT, + RARCH_CMD_NETPLAY_INIT, + RARCH_CMD_NETPLAY_DEINIT, + RARCH_CMD_NETPLAY_FLIP_PLAYERS, + RARCH_CMD_BSV_MOVIE_INIT, + RARCH_CMD_BSV_MOVIE_DEINIT, + RARCH_CMD_COMMAND_INIT, + RARCH_CMD_COMMAND_DEINIT, + RARCH_CMD_DRIVERS_DEINIT, + RARCH_CMD_DRIVERS_INIT, + RARCH_CMD_AUDIO_REINIT, + RARCH_CMD_RESIZE_WINDOWED_SCALE, + RARCH_CMD_TEMPORARY_CONTENT_DEINIT, + RARCH_CMD_SUBSYSTEM_FULLPATHS_DEINIT, + RARCH_CMD_LOG_FILE_DEINIT, + RARCH_CMD_DISK_EJECT_TOGGLE, + RARCH_CMD_DISK_NEXT, + RARCH_CMD_DISK_PREV, + RARCH_CMD_RUMBLE_STOP, + RARCH_CMD_GRAB_MOUSE_TOGGLE, + RARCH_CMD_FULLSCREEN_TOGGLE, + RARCH_CMD_PERFCNT_REPORT_FRONTEND_LOG, +}; + +enum action_state +{ + RARCH_ACTION_STATE_NONE = 0, + RARCH_ACTION_STATE_LOAD_CONTENT, + RARCH_ACTION_STATE_MENU_RUNNING, + RARCH_ACTION_STATE_MENU_RUNNING_FINISHED, + RARCH_ACTION_STATE_QUIT, + RARCH_ACTION_STATE_FORCE_QUIT, +}; + struct rarch_main_wrap { const char *content_path; From bdd7f9c96cb75a6205625cccd5e1a38b03f6df0b Mon Sep 17 00:00:00 2001 From: twinaphex Date: Sun, 11 Jan 2015 02:21:18 +0100 Subject: [PATCH 026/156] (retroarch.c) Document more --- retroarch.c | 220 ++++++++++++++++++++++++++++++++++++++++------------ retroarch.h | 108 ++++++++++++++++++++++++++ 2 files changed, 277 insertions(+), 51 deletions(-) diff --git a/retroarch.c b/retroarch.c index 73b65157af..6626a2fa7e 100644 --- a/retroarch.c +++ b/retroarch.c @@ -126,15 +126,20 @@ static bool take_screenshot_raw(void) width, height, -pitch, false); } -static void take_screenshot(void) +/** + * take_screenshot: + * + * Returns: true (1) if successful, otherwise false (0). + **/ +static bool take_screenshot(void) { bool viewport_read = false; - bool ret = false; + bool ret = true; const char *msg = NULL; /* No way to infer screenshot directory. */ if ((!*g_settings.screenshot_directory) && (!*g_extern.basename)) - return; + return false; viewport_read = (g_settings.video.gpu_screenshot || g_extern.system.hw_render_callback.context_type @@ -180,6 +185,8 @@ static void take_screenshot(void) if (g_extern.is_paused) rarch_render_cached_frame(); + + return ret; } void rarch_recording_dump_frame(const void *data, unsigned width, @@ -245,25 +252,32 @@ void rarch_recording_dump_frame(const void *data, unsigned width, driver.recording->push_video(driver.recording_data, &ffemu_data); } -static void init_recording(void) +/** + * init_recording: + * + * Initializes recording. + * + * Returns: true (1) if successful, otherwise false (0). + **/ +static bool init_recording(void) { struct ffemu_params params = {0}; const struct retro_system_av_info *info = &g_extern.system.av_info; if (!g_extern.recording_enable) - return; + return false; if (g_extern.libretro_dummy) { RARCH_WARN(RETRO_LOG_INIT_RECORDING_SKIPPED); - return; + return false; } if (!g_settings.video.gpu_record && g_extern.system.hw_render_callback.context_type) { RARCH_WARN("Libretro core is hardware rendered. Must use post-shaded recording as well.\n"); - return; + return false; } RARCH_LOG("Custom timing given: FPS: %.4f, Sample rate: %.4f\n", @@ -288,6 +302,7 @@ static void init_recording(void) if (g_settings.video.gpu_record && driver.video->read_viewport) { struct rarch_viewport vp = {0}; + if (driver.video && driver.video->viewport_info) driver.video->viewport_info(driver.video_data, &vp); @@ -295,7 +310,7 @@ static void init_recording(void) { RARCH_ERR("Failed to get viewport information from video driver. " "Cannot start recording ...\n"); - return; + return false; } params.out_width = vp.width; @@ -320,7 +335,7 @@ static void init_recording(void) if (!g_extern.record_gpu_buffer) { RARCH_ERR("Failed to allocate GPU record buffer.\n"); - return; + return false; } } else @@ -364,7 +379,11 @@ static void init_recording(void) { RARCH_ERR(RETRO_LOG_INIT_RECORDING_FAILED); rarch_main_command(RARCH_CMD_GPU_RECORD_DEINIT); + + return false; } + + return true; } /** @@ -435,6 +454,11 @@ static void print_features(void) } #undef _PSUPP +/** + * print_compiler: + * + * Prints compiler that was used for compiling RetroArch. + **/ static void print_compiler(FILE *file) { fprintf(file, "\nCompiler: "); @@ -462,6 +486,11 @@ static void print_compiler(FILE *file) fprintf(file, "Built: %s\n", __DATE__); } +/** + * print_help: + * + * Prints help message explaining RetroArch's commandline switches. + **/ static void print_help(void) { puts("==================================================================="); @@ -650,6 +679,14 @@ static void set_paths(const char *path) sizeof(g_settings.system_directory)); } +/** + * parse_input: + * @argc : Count of (commandline) arguments. + * @argv : (Commandline) arguments. + * + * Parses (commandline) arguments passed to RetroArch. + * + **/ static void parse_input(int argc, char *argv[]) { g_extern.libretro_no_content = false; @@ -1048,6 +1085,11 @@ static void parse_input(int argc, char *argv[]) sizeof(g_extern.savestate_dir)); } +/** + * init_controllers: + * + * Initialize libretro controllers. + **/ static void init_controllers(void) { unsigned i; @@ -1223,17 +1265,27 @@ static void init_movie(void) #define RARCH_DEFAULT_PORT 55435 #ifdef HAVE_NETPLAY -static void init_netplay(void) +/** + * init_netplay: + * + * Initializes netplay. + * + * If netplay is already initialized, will return false (0). + * + * Returns: true (1) if successful, otherwise false (0). + **/ + +static bool init_netplay(void) { struct retro_callbacks cbs = {0}; if (!g_extern.netplay_enable) - return; + return false; if (g_extern.bsv.movie_start_playback) { RARCH_WARN(RETRO_LOG_MOVIE_STARTED_INIT_NETPLAY_FAILED); - return; + return false; } retro_set_default_callbacks(&cbs); @@ -1252,16 +1304,17 @@ static void init_netplay(void) g_extern.netplay_sync_frames, &cbs, g_extern.netplay_is_spectate, g_settings.username); - if (!driver.netplay_data) - { - g_extern.netplay_is_client = false; - RARCH_WARN(RETRO_LOG_INIT_NETPLAY_FAILED); + if (driver.netplay_data) + return true; - if (g_extern.msg_queue) - msg_queue_push(g_extern.msg_queue, - RETRO_MSG_INIT_NETPLAY_FAILED, - 0, 180); - } + g_extern.netplay_is_client = false; + RARCH_WARN(RETRO_LOG_INIT_NETPLAY_FAILED); + + if (g_extern.msg_queue) + msg_queue_push(g_extern.msg_queue, + RETRO_MSG_INIT_NETPLAY_FAILED, + 0, 180); + return false; } #endif @@ -1318,6 +1371,7 @@ static void init_autosave(void) static void deinit_autosave(void) { unsigned i; + for (i = 0; i < g_extern.num_autosave; i++) autosave_free(g_extern.autosave[i]); @@ -1356,7 +1410,9 @@ static void set_savestate_auto_index(void) for (i = 0; i < dir_list->size; i++) { + unsigned idx; char elem_base[PATH_MAX_LENGTH]; + const char *end = NULL; const char *dir_elem = dir_list->elems[i].data; fill_pathname_base(elem_base, dir_elem, sizeof(elem_base)); @@ -1364,10 +1420,11 @@ static void set_savestate_auto_index(void) if (strstr(elem_base, state_base) != elem_base) continue; - const char *end = dir_elem + strlen(dir_elem); - while ((end > dir_elem) && isdigit(end[-1])) end--; + end = dir_elem + strlen(dir_elem); + while ((end > dir_elem) && isdigit(end[-1])) + end--; - unsigned idx = strtoul(end, NULL, 0); + idx = strtoul(end, NULL, 0); if (idx > max_idx) max_idx = idx; } @@ -1859,6 +1916,7 @@ static void init_system_info(void) { struct retro_system_info *info = (struct retro_system_info*) &g_extern.system.info; + pretro_get_system_info(info); if (!info->library_name) @@ -1884,12 +1942,19 @@ static void verify_api_version(void) { /* TODO - when libretro v2 gets added, allow for switching * between libretro version backend dynamically. */ + RARCH_LOG("Version of libretro API: %u\n", pretro_api_version()); RARCH_LOG("Compiled against API: %u\n", RETRO_API_VERSION); + if (pretro_api_version() != RETRO_API_VERSION) RARCH_WARN(RETRO_LOG_LIBRETRO_ABI_BREAK); } +#define FAIL_CPU(simd_type) do { \ + RARCH_ERR(simd_type " code is compiled in, but CPU does not support this feature. Cannot continue.\n"); \ + rarch_fail(1, "validate_cpu_features()"); \ +} while(0) + /* Make sure we haven't compiled for something we cannot run. * Ideally, code would get swapped out depending on CPU support, * but this will do for now. @@ -1899,11 +1964,6 @@ static void validate_cpu_features(void) uint64_t cpu = rarch_get_cpu_features(); (void)cpu; -#define FAIL_CPU(simd_type) do { \ - RARCH_ERR(simd_type " code is compiled in, but CPU does not support this feature. Cannot continue.\n"); \ - rarch_fail(1, "validate_cpu_features()"); \ -} while(0) - #ifdef __SSE__ if (!(cpu & RETRO_SIMD_SSE)) FAIL_CPU("SSE"); @@ -1970,6 +2030,15 @@ static bool init_core(void) return true; } +/** + * rarch_main_init: + * @argc : Count of (commandline) arguments. + * @argv : (Commandline) arguments. + * + * Initializes RetroArch. + * + * Returns: 0 on success, otherwise 1 if there was an error. + **/ int rarch_main_init(int argc, char *argv[]) { int sjlj_ret; @@ -2026,6 +2095,15 @@ error: return 1; } +/** + * rarch_main_init_wrap: + * @args : Input arguments. + * @argc : Count of arguments. + * @argv : Arguments. + * + * Generates an @argc and @argv pair based on @args + * of type rarch_main_wrap. + **/ void rarch_main_init_wrap(const struct rarch_main_wrap *args, int *argc, char **argv) { @@ -2154,9 +2232,14 @@ void rarch_main_set_state(unsigned cmd) } } -/* Save a new configuration to a file. Filename is based - * on heuristics to avoid typing. */ - +/** + * save_core_config: + * + * Saves a new (core) configuration to a file. Filename is based + * on heuristics to avoid typing. + * + * Returns: true (1) on success, otherwise false (0). + **/ static bool save_core_config(void) { bool ret = false; @@ -2190,6 +2273,7 @@ static bool save_core_config(void) for (i = 0; i < 16; i++) { char tmp[64]; + fill_pathname_base(config_name, g_settings.libretro, sizeof(config_name)); path_remove_extension(config_name); @@ -2243,6 +2327,14 @@ static bool save_core_config(void) return ret; } +/** + * rarch_main_command: + * @cmd : Command index. + * + * Performs RetroArch command with index @cmd. + * + * Returns: true (1) on success, otherwise false (0). + **/ bool rarch_main_command(unsigned cmd) { unsigned i = 0; @@ -2328,7 +2420,8 @@ bool rarch_main_command(unsigned cmd) main_state(cmd); break; case RARCH_CMD_TAKE_SCREENSHOT: - take_screenshot(); + if (!take_screenshot()) + return false; break; case RARCH_CMD_PREPARE_DUMMY: *g_extern.fullpath = '\0'; @@ -2506,7 +2599,8 @@ bool rarch_main_command(unsigned cmd) break; case RARCH_CMD_RECORD_INIT: rarch_main_command(RARCH_CMD_HISTORY_DEINIT); - init_recording(); + if (!init_recording()) + return false; break; case RARCH_CMD_HISTORY_DEINIT: if (g_defaults.history) @@ -2741,7 +2835,7 @@ bool rarch_main_command(unsigned cmd) case RARCH_CMD_NETPLAY_INIT: rarch_main_command(RARCH_CMD_NETPLAY_DEINIT); #ifdef HAVE_NETPLAY - init_netplay(); + return init_netplay(); #endif break; case RARCH_CMD_NETPLAY_FLIP_PLAYERS: @@ -2885,6 +2979,11 @@ bool rarch_main_command(unsigned cmd) return true; } +/** + * rarch_main_deinit: + * + * Deinitializes RetroArch. + **/ void rarch_main_deinit(void) { rarch_main_command(RARCH_CMD_NETPLAY_DEINIT); @@ -2911,6 +3010,13 @@ void rarch_main_deinit(void) g_extern.main_is_init = false; } +/** + * rarch_playlist_load_content: + * @playlist : Playlist handle. + * @idx : Index in playlist. + * + * Initializes core and loads content based on playlist entry. + **/ void rarch_playlist_load_content(content_playlist_t *playlist, unsigned idx) { @@ -2929,9 +3035,22 @@ void rarch_playlist_load_content(content_playlist_t *playlist, rarch_main_command(RARCH_CMD_LOAD_CORE); } -/* When selection is presented back, returns 0. - * If it can make a decision right now, returns -1. */ - +/** + * rarch_defer_core: + * @core_info : Core info list handle. + * @dir : Directory. Gets joined with @path. + * @path : Path. Gets joined with @dir. + * @menu_label : Label identifier of menu setting. + * @deferred_path : Deferred core path. Will be filled in + * by function. + * @sizeof_deferred_path : Size of @deferred_path. + * + * Gets deferred core. + * + * Returns: 0 if there are multiple deferred cores and a + * selection needs to be made from a list, otherwise + * returns -1 and fills in @deferred_path with path to core. + **/ int rarch_defer_core(core_info_list_t *core_info, const char *dir, const char *path, const char *menu_label, char *deferred_path, size_t sizeof_deferred_path) @@ -2962,21 +3081,20 @@ int rarch_defer_core(core_info_list_t *core_info, const char *dir, supported = 1; } else - { strlcpy(new_core_path, info->path, sizeof(new_core_path)); - } - /* Can make a decision right now. */ - if (supported == 1) - { - strlcpy(g_extern.fullpath, deferred_path, - sizeof(g_extern.fullpath)); - if (path_file_exists(new_core_path)) - strlcpy(g_settings.libretro, new_core_path, - sizeof(g_settings.libretro)); - return -1; - } - return 0; + /* There are multiple deferred cores and a + * selection needs to be made from a list, return 0. */ + if (supported != 1) + return 0; + + strlcpy(g_extern.fullpath, deferred_path, + sizeof(g_extern.fullpath)); + + if (path_file_exists(new_core_path)) + strlcpy(g_settings.libretro, new_core_path, + sizeof(g_settings.libretro)); + return -1; } /** diff --git a/retroarch.h b/retroarch.h index 211a6c2bf4..a63d009e64 100644 --- a/retroarch.h +++ b/retroarch.h @@ -26,36 +26,60 @@ extern "C" { enum basic_event { RARCH_CMD_NONE = 0, + /* Resets RetroArch. */ RARCH_CMD_RESET, + /* Loads content file. */ RARCH_CMD_LOAD_CONTENT, RARCH_CMD_LOAD_CONTENT_PERSIST, RARCH_CMD_LOAD_CORE, RARCH_CMD_LOAD_STATE, RARCH_CMD_SAVE_STATE, + /* Takes screenshot. */ RARCH_CMD_TAKE_SCREENSHOT, + /* Initializes dummy core. */ RARCH_CMD_PREPARE_DUMMY, + /* Quits RetroArch. */ RARCH_CMD_QUIT, + /* Reinitialize all drivers. */ RARCH_CMD_REINIT, + /* Deinitialize rewind. */ RARCH_CMD_REWIND_DEINIT, + /* Initializes rewind. */ RARCH_CMD_REWIND_INIT, + /* Toggles rewind. */ RARCH_CMD_REWIND_TOGGLE, + /* Deinitializes autosave. */ RARCH_CMD_AUTOSAVE_DEINIT, + /* Initializes autosave. */ RARCH_CMD_AUTOSAVE_INIT, RARCH_CMD_AUTOSAVE_STATE, + /* Stops audio. */ RARCH_CMD_AUDIO_STOP, + /* Starts audio. */ RARCH_CMD_AUDIO_START, + /* Mutes audio. */ RARCH_CMD_AUDIO_MUTE_TOGGLE, + /* Initializes overlay. */ RARCH_CMD_OVERLAY_INIT, + /* Deinitializes overlay. */ RARCH_CMD_OVERLAY_DEINIT, RARCH_CMD_OVERLAY_SET_SCALE_FACTOR, RARCH_CMD_OVERLAY_SET_ALPHA_MOD, + /* Cycle to next overlay. */ RARCH_CMD_OVERLAY_NEXT, + /* Initializes graphics filter. */ RARCH_CMD_DSP_FILTER_INIT, + /* Deinitializes graphics filter. */ RARCH_CMD_DSP_FILTER_DEINIT, + /* Deinitializes GPU recoring. */ RARCH_CMD_GPU_RECORD_DEINIT, + /* Initializes recording system. */ RARCH_CMD_RECORD_INIT, + /* Deinitializes recording system. */ RARCH_CMD_RECORD_DEINIT, + /* Deinitializes history playlist. */ RARCH_CMD_HISTORY_DEINIT, + /* Initializes history playlist. */ RARCH_CMD_HISTORY_INIT, RARCH_CMD_CORE_INFO_DEINIT, RARCH_CMD_CORE_INFO_INIT, @@ -66,21 +90,33 @@ enum basic_event RARCH_CMD_VIDEO_APPLY_STATE_CHANGES, RARCH_CMD_VIDEO_SET_BLOCKING_STATE, RARCH_CMD_VIDEO_SET_NONBLOCKING_STATE, + /* Sets current aspect ratio index. */ RARCH_CMD_VIDEO_SET_ASPECT_RATIO, RARCH_CMD_RESET_CONTEXT, + /* Restarts RetroArch. */ RARCH_CMD_RESTART_RETROARCH, + /* Force-quit RetroArch. */ RARCH_CMD_QUIT_RETROARCH, + /* Resume RetroArch when in menu. */ RARCH_CMD_RESUME, + /* Toggles pause. */ RARCH_CMD_PAUSE_TOGGLE, + /* Pauses RetroArch. */ RARCH_CMD_UNPAUSE, + /* Unpauses retroArch. */ RARCH_CMD_PAUSE, RARCH_CMD_PAUSE_CHECKS, RARCH_CMD_MENU_SAVE_CONFIG, RARCH_CMD_MENU_PAUSE_LIBRETRO, + /* Toggles menu on/off. */ RARCH_CMD_MENU_TOGGLE, + /* Applies shader changes. */ RARCH_CMD_SHADERS_APPLY_CHANGES, + /* Initializes shader directory. */ RARCH_CMD_SHADER_DIR_INIT, + /* Deinitializes shader directory. */ RARCH_CMD_SHADER_DIR_DEINIT, + /* Initializes controllers. */ RARCH_CMD_CONTROLLERS_INIT, RARCH_CMD_SAVEFILES, RARCH_CMD_SAVEFILES_INIT, @@ -89,25 +125,43 @@ enum basic_event RARCH_CMD_MSG_QUEUE_DEINIT, RARCH_CMD_CHEATS_INIT, RARCH_CMD_CHEATS_DEINIT, + /* Initializes netplay system. */ RARCH_CMD_NETPLAY_INIT, + /* Deinitializes netplay system. */ RARCH_CMD_NETPLAY_DEINIT, + /* Flip netplay players. */ RARCH_CMD_NETPLAY_FLIP_PLAYERS, + /* Initializes BSV movie. */ RARCH_CMD_BSV_MOVIE_INIT, + /* Deinitializes BSV movie. */ RARCH_CMD_BSV_MOVIE_DEINIT, + /* Initializes command interface. */ RARCH_CMD_COMMAND_INIT, + /* Deinitialize command interface. */ RARCH_CMD_COMMAND_DEINIT, + /* Deinitializes drivers. */ RARCH_CMD_DRIVERS_DEINIT, + /* Initializes drivers. */ RARCH_CMD_DRIVERS_INIT, + /* Reinitializes audio driver. */ RARCH_CMD_AUDIO_REINIT, + /* Resizes windowed scale. Will reinitialize video driver. */ RARCH_CMD_RESIZE_WINDOWED_SCALE, + /* Deinitializes temporary content. */ RARCH_CMD_TEMPORARY_CONTENT_DEINIT, RARCH_CMD_SUBSYSTEM_FULLPATHS_DEINIT, RARCH_CMD_LOG_FILE_DEINIT, + /* Toggles disk eject. */ RARCH_CMD_DISK_EJECT_TOGGLE, + /* Cycle to next disk. */ RARCH_CMD_DISK_NEXT, + /* Cycle to previous disk. */ RARCH_CMD_DISK_PREV, + /* Stops rumbling. */ RARCH_CMD_RUMBLE_STOP, + /* Toggles mouse grab. */ RARCH_CMD_GRAB_MOUSE_TOGGLE, + /* Toggles fullscreen mode. */ RARCH_CMD_FULLSCREEN_TOGGLE, RARCH_CMD_PERFCNT_REPORT_FRONTEND_LOG, }; @@ -141,13 +195,44 @@ void rarch_main_state_free(void); void rarch_main_set_state(unsigned action); +/** + * rarch_main_command: + * @cmd : Command index. + * + * Performs RetroArch command with index @cmd. + * + * Returns: true (1) on success, otherwise false (0). + **/ bool rarch_main_command(unsigned action); +/** + * rarch_main_init: + * @argc : Count of (commandline) arguments. + * @argv : (Commandline) arguments. + * + * Initializes RetroArch. + * + * Returns: 0 on success, otherwise 1 if there was an error. + **/ int rarch_main_init(int argc, char *argv[]); +/** + * rarch_main_init_wrap: + * @args : Input arguments. + * @argc : Count of arguments. + * @argv : Arguments. + * + * Generates an @argc and @argv pair based on @args + * of type rarch_main_wrap. + **/ void rarch_main_init_wrap(const struct rarch_main_wrap *args, int *argc, char **argv); +/** + * rarch_main_deinit: + * + * Deinitializes RetroArch. + **/ void rarch_main_deinit(void); /** @@ -208,9 +293,32 @@ void rarch_recording_dump_frame(const void *data, unsigned width, **/ bool rarch_replace_config(const char *path); +/** + * rarch_playlist_load_content: + * @playlist : Playlist handle. + * @idx : Index in playlist. + * + * Initializes core and loads content based on playlist entry. + **/ void rarch_playlist_load_content(content_playlist_t *playlist, unsigned index); +/** + * rarch_defer_core: + * @core_info : Core info list handle. + * @dir : Directory. Gets joined with @path. + * @path : Path. Gets joined with @dir. + * @menu_label : Label identifier of menu setting. + * @deferred_path : Deferred core path. Will be filled in + * by function. + * @sizeof_deferred_path : Size of @deferred_path. + * + * Gets deferred core. + * + * Returns: 0 if there are multiple deferred cores and a + * selection needs to be made from a list, otherwise + * returns -1 and fills in @deferred_path with path to core. + **/ int rarch_defer_core(core_info_list_t *data, const char *dir, const char *path, const char *menu_label, char *deferred_path, size_t sizeof_deferred_path); From def2f6cb96721fb08b391517ca1bc9413305d360 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Sun, 11 Jan 2015 05:29:32 +0100 Subject: [PATCH 027/156] Update documentation settings.c --- settings.c | 205 ++++++++++++++++++++++++++++++++++++----------------- settings.h | 64 ++++++++++++++++- 2 files changed, 203 insertions(+), 66 deletions(-) diff --git a/settings.c b/settings.c index cff63bec72..bcc806ae1d 100644 --- a/settings.c +++ b/settings.c @@ -33,6 +33,13 @@ struct settings g_settings; struct global g_extern; struct defaults g_defaults; +/** + * config_get_default_audio: + * + * Gets default audio driver. + * + * Returns: Default audio driver. + **/ const char *config_get_default_audio(void) { switch (AUDIO_DEFAULT_DRIVER) @@ -82,6 +89,13 @@ const char *config_get_default_audio(void) return "null"; } +/** + * config_get_default_audio_resampler: + * + * Gets default audio resampler driver. + * + * Returns: Default audio resampler driver. + **/ const char *config_get_default_audio_resampler(void) { switch (AUDIO_DEFAULT_RESAMPLER_DRIVER) @@ -99,6 +113,13 @@ const char *config_get_default_audio_resampler(void) return "null"; } +/** + * config_get_default_video: + * + * Gets default video driver. + * + * Returns: Default video driver. + **/ const char *config_get_default_video(void) { switch (VIDEO_DEFAULT_DRIVER) @@ -137,6 +158,13 @@ const char *config_get_default_video(void) return "null"; } +/** + * config_get_default_input: + * + * Gets default input driver. + * + * Returns: Default input driver. + **/ const char *config_get_default_input(void) { switch (INPUT_DEFAULT_DRIVER) @@ -180,6 +208,13 @@ const char *config_get_default_input(void) return "null"; } +/** + * config_get_default_joypad: + * + * Gets default input joypad driver. + * + * Returns: Default input joypad driver. + **/ const char *config_get_default_joypad(void) { switch (JOYPAD_DEFAULT_DRIVER) @@ -222,6 +257,13 @@ const char *config_get_default_joypad(void) } #ifdef HAVE_MENU +/** + * config_get_default_menu: + * + * Gets default menu driver. + * + * Returns: Default menu driver. + **/ const char *config_get_default_menu(void) { switch (MENU_DEFAULT_DRIVER) @@ -248,6 +290,13 @@ const char *config_get_default_menu(void) } #endif +/** + * config_get_default_osk: + * + * Gets default OSK driver. + * + * Returns: Default OSK driver. + **/ const char *config_get_default_osk(void) { switch (OSK_DEFAULT_DRIVER) @@ -261,6 +310,13 @@ const char *config_get_default_osk(void) return "null"; } +/** + * config_get_default_camera: + * + * Gets default camera driver. + * + * Returns: Default camera driver. + **/ const char *config_get_default_camera(void) { switch (CAMERA_DEFAULT_DRIVER) @@ -280,6 +336,13 @@ const char *config_get_default_camera(void) return "null"; } +/** + * config_get_default_location: + * + * Gets default location driver. + * + * Returns: Default location driver. + **/ const char *config_get_default_location(void) { switch (LOCATION_DEFAULT_DRIVER) @@ -295,6 +358,11 @@ const char *config_get_default_location(void) return "null"; } +/** + * config_set_defaults: + * + * Set 'default' configuration values. + **/ static void config_set_defaults(void) { unsigned i, j; @@ -642,8 +710,13 @@ static void config_set_defaults(void) g_extern.block_config_read = default_block_config_read; } -static void parse_config_file(void); - +/** + * open_default_config_file + * + * Open a default config file. Platform-specific. + * + * Returns: handle to config file if found, otherwise NULL. + **/ static config_file_t *open_default_config_file(void) { config_file_t *conf = NULL; @@ -837,7 +910,68 @@ static config_file_t *open_default_config_file(void) return conf; } -static void config_read_keybinds_conf(config_file_t *conf); +static void read_keybinds_keyboard(config_file_t *conf, unsigned user, + unsigned idx, struct retro_keybind *bind) +{ + if (input_config_bind_map[idx].valid && input_config_bind_map[idx].base) + { + const char *prefix = input_config_get_prefix(user, + input_config_bind_map[idx].meta); + if (prefix) + input_config_parse_key(conf, prefix, + input_config_bind_map[idx].base, bind); + } +} + +static void read_keybinds_button(config_file_t *conf, unsigned user, + unsigned idx, struct retro_keybind *bind) +{ + if (input_config_bind_map[idx].valid && input_config_bind_map[idx].base) + { + const char *prefix = input_config_get_prefix(user, + input_config_bind_map[idx].meta); + if (prefix) + input_config_parse_joy_button(conf, prefix, + input_config_bind_map[idx].base, bind); + } +} + +static void read_keybinds_axis(config_file_t *conf, unsigned user, + unsigned idx, struct retro_keybind *bind) +{ + if (input_config_bind_map[idx].valid && input_config_bind_map[idx].base) + { + const char *prefix = input_config_get_prefix(user, + input_config_bind_map[idx].meta); + if (prefix) + input_config_parse_joy_axis(conf, prefix, + input_config_bind_map[idx].base, bind); + } +} + +static void read_keybinds_user(config_file_t *conf, unsigned user) +{ + unsigned i; + for (i = 0; input_config_bind_map[i].valid; i++) + { + struct retro_keybind *bind = (struct retro_keybind*) + &g_settings.input.binds[user][i]; + + if (!bind->valid) + continue; + + read_keybinds_keyboard(conf, user, i, bind); + read_keybinds_button(conf, user, i, bind); + read_keybinds_axis(conf, user, i, bind); + } +} + +static void config_read_keybinds_conf(config_file_t *conf) +{ + unsigned i; + for (i = 0; i < MAX_USERS; i++) + read_keybinds_user(conf, i); +} /* Also dumps inherited values, useful for logging. */ @@ -1379,68 +1513,6 @@ static void parse_config_file(void) } -static void read_keybinds_keyboard(config_file_t *conf, unsigned user, - unsigned idx, struct retro_keybind *bind) -{ - if (input_config_bind_map[idx].valid && input_config_bind_map[idx].base) - { - const char *prefix = input_config_get_prefix(user, - input_config_bind_map[idx].meta); - if (prefix) - input_config_parse_key(conf, prefix, - input_config_bind_map[idx].base, bind); - } -} - -static void read_keybinds_button(config_file_t *conf, unsigned user, - unsigned idx, struct retro_keybind *bind) -{ - if (input_config_bind_map[idx].valid && input_config_bind_map[idx].base) - { - const char *prefix = input_config_get_prefix(user, - input_config_bind_map[idx].meta); - if (prefix) - input_config_parse_joy_button(conf, prefix, - input_config_bind_map[idx].base, bind); - } -} - -static void read_keybinds_axis(config_file_t *conf, unsigned user, - unsigned idx, struct retro_keybind *bind) -{ - if (input_config_bind_map[idx].valid && input_config_bind_map[idx].base) - { - const char *prefix = input_config_get_prefix(user, - input_config_bind_map[idx].meta); - if (prefix) - input_config_parse_joy_axis(conf, prefix, - input_config_bind_map[idx].base, bind); - } -} - -static void read_keybinds_user(config_file_t *conf, unsigned user) -{ - unsigned i; - for (i = 0; input_config_bind_map[i].valid; i++) - { - struct retro_keybind *bind = (struct retro_keybind*) - &g_settings.input.binds[user][i]; - - if (!bind->valid) - continue; - - read_keybinds_keyboard(conf, user, i, bind); - read_keybinds_button(conf, user, i, bind); - read_keybinds_axis(conf, user, i, bind); - } -} - -static void config_read_keybinds_conf(config_file_t *conf) -{ - unsigned i; - for (i = 0; i < MAX_USERS; i++) - read_keybinds_user(conf, i); -} #if 0 static bool config_read_keybinds(const char *path) @@ -1574,10 +1646,12 @@ static void save_keybind(config_file_t *conf, const char *prefix, static void save_keybinds_user(config_file_t *conf, unsigned user) { unsigned i = 0; + for (i = 0; input_config_bind_map[i].valid; i++) { const char *prefix = input_config_get_prefix(user, input_config_bind_map[i].meta); + if (prefix) save_keybind(conf, prefix, input_config_bind_map[i].base, &g_settings.input.binds[user][i]); @@ -1864,6 +1938,7 @@ bool config_save_file(const char *path) for (i = 0; i < MAX_USERS; i++) { char cfg[64]; + snprintf(cfg, sizeof(cfg), "input_device_p%u", i + 1); config_set_int(conf, cfg, g_settings.input.device[i]); snprintf(cfg, sizeof(cfg), "input_player%u_joypad_index", i + 1); diff --git a/settings.h b/settings.h index b2ee254323..d44f153800 100644 --- a/settings.h +++ b/settings.h @@ -21,24 +21,86 @@ extern "C" { #endif - +/** + * config_get_default_camera: + * + * Gets default camera driver. + * + * Returns: Default camera driver. + **/ const char *config_get_default_camera(void); +/** + * config_get_default_location: + * + * Gets default location driver. + * + * Returns: Default location driver. + **/ const char *config_get_default_location(void); +/** + * config_get_default_osk: + * + * Gets default OSK driver. + * + * Returns: Default OSK driver. + **/ const char *config_get_default_osk(void); +/** + * config_get_default_video: + * + * Gets default video driver. + * + * Returns: Default video driver. + **/ const char *config_get_default_video(void); +/** + * config_get_default_audio: + * + * Gets default audio driver. + * + * Returns: Default audio driver. + **/ const char *config_get_default_audio(void); +/** + * config_get_default_audio_resampler: + * + * Gets default audio resampler driver. + * + * Returns: Default audio resampler driver. + **/ const char *config_get_default_audio_resampler(void); +/** + * config_get_default_input: + * + * Gets default input driver. + * + * Returns: Default input driver. + **/ const char *config_get_default_input(void); +/** + * config_get_default_joypad: + * + * Gets default input joypad driver. + * + * Returns: Default input joypad driver. + **/ const char *config_get_default_joypad(void); #ifdef HAVE_MENU +/** + * config_get_default_menu: + * + * Gets default menu driver. + * + * Returns: Default menu driver. + **/ const char *config_get_default_menu(void); #endif From 1463d5e7dc8d3b065d2b54734651aa12909190b9 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Sun, 11 Jan 2015 05:35:47 +0100 Subject: [PATCH 028/156] Move message queue to libretro-sdk --- Makefile.common | 2 +- general.h | 2 +- griffin/griffin.c | 2 +- .../include/queues/message_queue.h | 35 +++++++++++-------- .../queues/message_queue.c | 2 +- menu/disp/rmenu_xui.cpp | 1 - netplay.c | 2 +- tools/retroarch-joyconfig-griffin.c | 2 +- 8 files changed, 26 insertions(+), 22 deletions(-) rename message_queue.h => libretro-sdk/include/queues/message_queue.h (51%) rename message_queue.c => libretro-sdk/queues/message_queue.c (99%) diff --git a/Makefile.common b/Makefile.common index 349aaf8ec6..567632830c 100644 --- a/Makefile.common +++ b/Makefile.common @@ -104,7 +104,7 @@ OBJ += frontend/frontend.o \ settings_data.o \ dynamic.o \ dynamic_dummy.o \ - message_queue.o \ + libretro-sdk/queues/message_queue.o \ rewind.o \ gfx/gfx_common.o \ gfx/fonts/bitmapfont.o \ diff --git a/general.h b/general.h index 5dddfb0c0f..5e71731ffb 100644 --- a/general.h +++ b/general.h @@ -22,7 +22,7 @@ #include #include #include "driver.h" -#include "message_queue.h" +#include #include "rewind.h" #include "movie.h" #include "autosave.h" diff --git a/griffin/griffin.c b/griffin/griffin.c index 1fdab314d9..34125cb53b 100644 --- a/griffin/griffin.c +++ b/griffin/griffin.c @@ -555,7 +555,7 @@ FILE /*============================================================ MESSAGE ============================================================ */ -#include "../message_queue.c" +#include "../libretro-sdk/queues/message_queue.c" /*============================================================ PATCH diff --git a/message_queue.h b/libretro-sdk/include/queues/message_queue.h similarity index 51% rename from message_queue.h rename to libretro-sdk/include/queues/message_queue.h index 3d7bc538e9..560bb488e7 100644 --- a/message_queue.h +++ b/libretro-sdk/include/queues/message_queue.h @@ -1,22 +1,27 @@ -/* 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. +/* Copyright (C) 2010-2015 The RetroArch team * - * 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. + * --------------------------------------------------------------------------------------- + * The following license statement only applies to this file (boolean.h). + * --------------------------------------------------------------------------------------- * - * You should have received a copy of the GNU General Public License along with RetroArch. - * If not, see . + * Permission is hereby granted, free of charge, + * to any person obtaining a copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation the rights to + * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, + * and to permit persons to whom the Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, + * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. + * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, + * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ - -#ifndef __RARCH_MSG_QUEUE_H -#define __RARCH_MSG_QUEUE_H +#ifndef __LIBRETRO_SDK_MSG_QUEUE_H +#define __LIBRETRO_SDK_MSG_QUEUE_H #include diff --git a/message_queue.c b/libretro-sdk/queues/message_queue.c similarity index 99% rename from message_queue.c rename to libretro-sdk/queues/message_queue.c index e3314934c5..18320ac70e 100644 --- a/message_queue.c +++ b/libretro-sdk/queues/message_queue.c @@ -17,7 +17,7 @@ #include #include #include -#include "message_queue.h" +#include #include struct queue_elem diff --git a/menu/disp/rmenu_xui.cpp b/menu/disp/rmenu_xui.cpp index 4b5a757af8..af187809df 100644 --- a/menu/disp/rmenu_xui.cpp +++ b/menu/disp/rmenu_xui.cpp @@ -28,7 +28,6 @@ #include "../../gfx/gfx_context.h" #include "../../settings_data.h" -#include "../../message_queue.h" #include "../../general.h" #include "../../gfx/d3d/d3d.h" diff --git a/netplay.c b/netplay.c index 0046722e47..e5b38ec62d 100644 --- a/netplay.c +++ b/netplay.c @@ -23,7 +23,7 @@ #include "general.h" #include "autosave.h" #include "dynamic.h" -#include "message_queue.h" +#include #include #include diff --git a/tools/retroarch-joyconfig-griffin.c b/tools/retroarch-joyconfig-griffin.c index 9f3e0f0e5f..1414ce7901 100644 --- a/tools/retroarch-joyconfig-griffin.c +++ b/tools/retroarch-joyconfig-griffin.c @@ -54,4 +54,4 @@ #include "../input/input_common.c" #include "../input/input_keymaps.c" -#include "../message_queue.c" +#include "../libretro-sdk/queues/message_queue.c" From 751f2b7403264e0cb2b29fc93783c7b41ebcc2d7 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Sun, 11 Jan 2015 05:43:10 +0100 Subject: [PATCH 029/156] (SDK) Move fifo_buffer.c to libretro SDK --- Makefile.common | 2 +- audio/alsathread.c | 2 +- audio/audio_thread_wrapper.c | 2 +- audio/coreaudio.c | 2 +- audio/dsound.c | 2 +- audio/ps3_audio.c | 2 +- audio/rsound.c | 2 +- audio/rsound.h | 2 +- audio/sdl_audio.c | 2 +- fifo_buffer.h | 54 ----------------- griffin/griffin.c | 2 +- libretro-sdk/include/queues/fifo_buffer.h | 60 +++++++++++++++++++ .../queues/fifo_buffer.c | 36 ++++++----- libretro-sdk/queues/message_queue.c | 30 ++++++---- record/ffmpeg.c | 2 +- 15 files changed, 111 insertions(+), 91 deletions(-) delete mode 100644 fifo_buffer.h create mode 100644 libretro-sdk/include/queues/fifo_buffer.h rename fifo_buffer.c => libretro-sdk/queues/fifo_buffer.c (56%) diff --git a/Makefile.common b/Makefile.common index 567632830c..ff53d6e711 100644 --- a/Makefile.common +++ b/Makefile.common @@ -116,7 +116,7 @@ OBJ += frontend/frontend.o \ input/keyboard_line.o \ input/overlay.o \ patch.o \ - fifo_buffer.o \ + libretro-sdk/queues/fifo_buffer.o \ core_options.o \ libretro-sdk/compat/compat.o \ cheats.o \ diff --git a/audio/alsathread.c b/audio/alsathread.c index ef7f92ae00..bdcb91caec 100644 --- a/audio/alsathread.c +++ b/audio/alsathread.c @@ -20,7 +20,7 @@ #include #include "../general.h" #include -#include "../fifo_buffer.h" +#include #define TRY_ALSA(x) if (x < 0) { \ goto error; \ diff --git a/audio/audio_thread_wrapper.c b/audio/audio_thread_wrapper.c index ac5dbde9a0..00927f57fc 100644 --- a/audio/audio_thread_wrapper.c +++ b/audio/audio_thread_wrapper.c @@ -18,7 +18,7 @@ #include #include "../general.h" #include "../performance.h" -#include "../fifo_buffer.h" +#include #include #include diff --git a/audio/coreaudio.c b/audio/coreaudio.c index 95208bc66a..21e968a860 100644 --- a/audio/coreaudio.c +++ b/audio/coreaudio.c @@ -17,7 +17,7 @@ #include "../driver.h" #include "../general.h" -#include "../fifo_buffer.h" +#include #include #include #include diff --git a/audio/dsound.c b/audio/dsound.c index 83d65b97de..ace28c8321 100644 --- a/audio/dsound.c +++ b/audio/dsound.c @@ -52,7 +52,7 @@ static DSMIXBINS dsmb; #include #endif #include -#include "../fifo_buffer.h" +#include #include "../general.h" typedef struct dsound diff --git a/audio/ps3_audio.c b/audio/ps3_audio.c index 3d12e5be4d..082c5f100e 100644 --- a/audio/ps3_audio.c +++ b/audio/ps3_audio.c @@ -19,7 +19,7 @@ #include #include -#include "../fifo_buffer.h" +#include #include "../ps3/sdk_defines.h" diff --git a/audio/rsound.c b/audio/rsound.c index c05bacefe4..9b49e9f67f 100644 --- a/audio/rsound.c +++ b/audio/rsound.c @@ -17,7 +17,7 @@ #include "../driver.h" #include #include "rsound.h" -#include "../fifo_buffer.h" +#include #include #include diff --git a/audio/rsound.h b/audio/rsound.h index 70d7827e11..5395c137aa 100644 --- a/audio/rsound.h +++ b/audio/rsound.h @@ -30,7 +30,7 @@ extern "C" { #include #include -#include "../fifo_buffer.h" +#include #ifdef _WIN32 #define RSD_DEFAULT_HOST "127.0.0.1" // Stupid Windows. diff --git a/audio/sdl_audio.c b/audio/sdl_audio.c index 530dd83c26..5c1a89ad4c 100644 --- a/audio/sdl_audio.c +++ b/audio/sdl_audio.c @@ -26,7 +26,7 @@ #include #include "../general.h" -#include "../fifo_buffer.h" +#include typedef struct sdl_audio { diff --git a/fifo_buffer.h b/fifo_buffer.h deleted file mode 100644 index 01a0c6848c..0000000000 --- a/fifo_buffer.h +++ /dev/null @@ -1,54 +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 . - */ - -#ifndef __FIFO_BUFFER_H -#define __FIFO_BUFFER_H - -#include -#include - -#ifdef __cplusplus -extern "C" { -#endif - -struct fifo_buffer -{ - uint8_t *buffer; - size_t bufsize; - size_t first; - size_t end; -}; - -typedef struct fifo_buffer fifo_buffer_t; - -fifo_buffer_t *fifo_new(size_t size); - -void fifo_write(fifo_buffer_t *buffer, const void *in_buf, size_t size); - -void fifo_read(fifo_buffer_t *buffer, void *in_buf, size_t size); - -void fifo_free(fifo_buffer_t *buffer); - -size_t fifo_read_avail(fifo_buffer_t *buffer); - -size_t fifo_write_avail(fifo_buffer_t *buffer); - -#ifdef __cplusplus -} -#endif - -#endif - diff --git a/griffin/griffin.c b/griffin/griffin.c index 34125cb53b..7822deff29 100644 --- a/griffin/griffin.c +++ b/griffin/griffin.c @@ -405,7 +405,7 @@ STATE TRACKER /*============================================================ FIFO BUFFER ============================================================ */ -#include "../fifo_buffer.c" +#include "../libretro-sdk/queues/fifo_buffer.c" /*============================================================ AUDIO RESAMPLER diff --git a/libretro-sdk/include/queues/fifo_buffer.h b/libretro-sdk/include/queues/fifo_buffer.h new file mode 100644 index 0000000000..1e4e06a29f --- /dev/null +++ b/libretro-sdk/include/queues/fifo_buffer.h @@ -0,0 +1,60 @@ +/* Copyright (C) 2010-2015 The RetroArch team + * + * --------------------------------------------------------------------------------------- + * The following license statement only applies to this file (boolean.h). + * --------------------------------------------------------------------------------------- + * + * Permission is hereby granted, free of charge, + * to any person obtaining a copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation the rights to + * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, + * and to permit persons to whom the Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, + * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. + * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, + * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + +#ifndef __LIBRETRO_SDK_FIFO_BUFFER_H +#define __LIBRETRO_SDK_FIFO_BUFFER_H + +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +struct fifo_buffer +{ + uint8_t *buffer; + size_t bufsize; + size_t first; + size_t end; +}; + +typedef struct fifo_buffer fifo_buffer_t; + +fifo_buffer_t *fifo_new(size_t size); + +void fifo_write(fifo_buffer_t *buffer, const void *in_buf, size_t size); + +void fifo_read(fifo_buffer_t *buffer, void *in_buf, size_t size); + +void fifo_free(fifo_buffer_t *buffer); + +size_t fifo_read_avail(fifo_buffer_t *buffer); + +size_t fifo_write_avail(fifo_buffer_t *buffer); + +#ifdef __cplusplus +} +#endif + +#endif + diff --git a/fifo_buffer.c b/libretro-sdk/queues/fifo_buffer.c similarity index 56% rename from fifo_buffer.c rename to libretro-sdk/queues/fifo_buffer.c index 06e3411ca1..10c3bf2c51 100644 --- a/fifo_buffer.c +++ b/libretro-sdk/queues/fifo_buffer.c @@ -1,27 +1,35 @@ -/* 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. +/* Copyright (C) 2010-2015 The RetroArch team * - * 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. + * --------------------------------------------------------------------------------------- + * The following license statement only applies to this file (rthreads.c). + * --------------------------------------------------------------------------------------- * - * You should have received a copy of the GNU General Public License along with RetroArch. - * If not, see . + * Permission is hereby granted, free of charge, + * to any person obtaining a copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation the rights to + * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, + * and to permit persons to whom the Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, + * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. + * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, + * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ + #include #include -#include "fifo_buffer.h" +#include fifo_buffer_t *fifo_new(size_t size) { fifo_buffer_t *buf = (fifo_buffer_t*)calloc(1, sizeof(*buf)); + if (!buf) return NULL; @@ -38,7 +46,7 @@ fifo_buffer_t *fifo_new(size_t size) void fifo_free(fifo_buffer_t *buffer) { - if(!buffer) + if (!buffer) return; free(buffer->buffer); diff --git a/libretro-sdk/queues/message_queue.c b/libretro-sdk/queues/message_queue.c index 18320ac70e..3a4bec77c7 100644 --- a/libretro-sdk/queues/message_queue.c +++ b/libretro-sdk/queues/message_queue.c @@ -1,17 +1,23 @@ -/* 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. +/* Copyright (C) 2010-2015 The RetroArch team * - * 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. + * --------------------------------------------------------------------------------------- + * The following license statement only applies to this file (rthreads.c). + * --------------------------------------------------------------------------------------- * - * You should have received a copy of the GNU General Public License along with RetroArch. - * If not, see . + * Permission is hereby granted, free of charge, + * to any person obtaining a copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation the rights to + * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, + * and to permit persons to whom the Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, + * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. + * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, + * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ #include diff --git a/record/ffmpeg.c b/record/ffmpeg.c index 7aa939d242..8cd58ecd2d 100644 --- a/record/ffmpeg.c +++ b/record/ffmpeg.c @@ -44,7 +44,7 @@ extern "C" { #include #include #include -#include "../fifo_buffer.h" +#include #include #include "../general.h" #include From 22ccfc7db7368fc97c49dea14574d4bf35e3d8bb Mon Sep 17 00:00:00 2001 From: twinaphex Date: Sun, 11 Jan 2015 06:14:13 +0100 Subject: [PATCH 030/156] (menu.c) Cleanups --- menu/menu.c | 132 +++++++++++++++++++++++++++------------------------- 1 file changed, 68 insertions(+), 64 deletions(-) diff --git a/menu/menu.c b/menu/menu.c index a23b534598..9df07f3806 100644 --- a/menu/menu.c +++ b/menu/menu.c @@ -299,6 +299,9 @@ void menu_free(void *data) void menu_ticker_line(char *buf, size_t len, unsigned idx, const char *str, bool selected) { + unsigned ticker_period, phase, phase_left_stop; + unsigned phase_left_moving, phase_right_stop; + unsigned left_offset, right_offset; size_t str_len = strlen(str); if (str_len <= len) @@ -314,33 +317,31 @@ void menu_ticker_line(char *buf, size_t len, unsigned idx, return; } - { - /* Wrap long strings in options with some kind of ticker line. */ - unsigned ticker_period = 2 * (str_len - len) + 4; - unsigned phase = idx % ticker_period; + /* Wrap long strings in options with some kind of ticker line. */ + ticker_period = 2 * (str_len - len) + 4; + phase = idx % ticker_period; - unsigned phase_left_stop = 2; - unsigned phase_left_moving = phase_left_stop + (str_len - len); - unsigned phase_right_stop = phase_left_moving + 2; + phase_left_stop = 2; + phase_left_moving = phase_left_stop + (str_len - len); + phase_right_stop = phase_left_moving + 2; - unsigned left_offset = phase - phase_left_stop; - unsigned right_offset = (str_len - len) - (phase - phase_right_stop); + left_offset = phase - phase_left_stop; + right_offset = (str_len - len) - (phase - phase_right_stop); - /* Ticker period: - * [Wait at left (2 ticks), - * Progress to right(type_len - w), - * Wait at right (2 ticks), - * Progress to left]. - */ - if (phase < phase_left_stop) - strlcpy(buf, str, len + 1); - else if (phase < phase_left_moving) - strlcpy(buf, str + left_offset, len + 1); - else if (phase < phase_right_stop) - strlcpy(buf, str + str_len - len, len + 1); - else - strlcpy(buf, str + right_offset, len + 1); - } + /* Ticker period: + * [Wait at left (2 ticks), + * Progress to right(type_len - w), + * Wait at right (2 ticks), + * Progress to left]. + */ + if (phase < phase_left_stop) + strlcpy(buf, str, len + 1); + else if (phase < phase_left_moving) + strlcpy(buf, str + left_offset, len + 1); + else if (phase < phase_right_stop) + strlcpy(buf, str + str_len - len, len + 1); + else + strlcpy(buf, str + right_offset, len + 1); } void menu_apply_deferred_settings(void) @@ -357,48 +358,51 @@ void menu_apply_deferred_settings(void) for (; setting->type != ST_NONE; setting++) { - if ((setting->type < ST_GROUP) && (setting->flags & SD_FLAG_IS_DEFERRED)) + if (setting->type >= ST_GROUP) + continue; + + if (!(setting->flags & SD_FLAG_IS_DEFERRED)) + continue; + + switch (setting->type) { - switch (setting->type) - { - case ST_BOOL: - if (*setting->value.boolean != setting->original_value.boolean) - { - setting->original_value.boolean = *setting->value.boolean; - setting->deferred_handler(setting); - } - break; - case ST_INT: - if (*setting->value.integer != setting->original_value.integer) - { - setting->original_value.integer = *setting->value.integer; - setting->deferred_handler(setting); - } - break; - case ST_UINT: - if (*setting->value.unsigned_integer != setting->original_value.unsigned_integer) - { - setting->original_value.unsigned_integer = *setting->value.unsigned_integer; - setting->deferred_handler(setting); - } - break; - case ST_FLOAT: - if (*setting->value.fraction != setting->original_value.fraction) - { - setting->original_value.fraction = *setting->value.fraction; - setting->deferred_handler(setting); - } - break; - case ST_PATH: - case ST_DIR: - case ST_STRING: - case ST_BIND: - /* always run the deferred write handler */ + case ST_BOOL: + if (*setting->value.boolean != setting->original_value.boolean) + { + setting->original_value.boolean = *setting->value.boolean; setting->deferred_handler(setting); - break; - default: - break; - } + } + break; + case ST_INT: + if (*setting->value.integer != setting->original_value.integer) + { + setting->original_value.integer = *setting->value.integer; + setting->deferred_handler(setting); + } + break; + case ST_UINT: + if (*setting->value.unsigned_integer != setting->original_value.unsigned_integer) + { + setting->original_value.unsigned_integer = *setting->value.unsigned_integer; + setting->deferred_handler(setting); + } + break; + case ST_FLOAT: + if (*setting->value.fraction != setting->original_value.fraction) + { + setting->original_value.fraction = *setting->value.fraction; + setting->deferred_handler(setting); + } + break; + case ST_PATH: + case ST_DIR: + case ST_STRING: + case ST_BIND: + /* Always run the deferred write handler */ + setting->deferred_handler(setting); + break; + default: + break; } } } From 7f0ccae0d7c01dc6f882ad226ef75cf2b8b31739 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Sun, 11 Jan 2015 06:24:44 +0100 Subject: [PATCH 031/156] Rename menu_input_line_cb.c to menu_input.c --- Makefile.common | 2 +- griffin/griffin.c | 2 +- menu/backend/menu_common_backend.c | 2 +- menu/menu.h | 2 +- menu/menu_entries_cbs.c | 2 +- menu/{menu_input_line_cb.c => menu_input.c} | 2 +- menu/{menu_input_line_cb.h => menu_input.h} | 0 retroarch.c | 2 +- settings_data.c | 2 +- 9 files changed, 8 insertions(+), 8 deletions(-) rename menu/{menu_input_line_cb.c => menu_input.c} (99%) rename menu/{menu_input_line_cb.h => menu_input.h} (100%) diff --git a/Makefile.common b/Makefile.common index ff53d6e711..7d0a62bafd 100644 --- a/Makefile.common +++ b/Makefile.common @@ -288,7 +288,7 @@ endif ifeq ($(HAVE_MENU_COMMON), 1) OBJ += menu/backend/menu_common_backend.o \ - menu/menu_input_line_cb.o \ + menu/menu_input.o \ menu/menu.o \ menu/menu_common_list.o \ menu/menu_navigation.o \ diff --git a/griffin/griffin.c b/griffin/griffin.c index 7822deff29..4d1de1e2a4 100644 --- a/griffin/griffin.c +++ b/griffin/griffin.c @@ -662,7 +662,7 @@ PLAYLISTS MENU ============================================================ */ #ifdef HAVE_MENU -#include "../menu/menu_input_line_cb.c" +#include "../menu/menu_input.c" #include "../menu/menu.c" #include "../menu/menu_common_list.c" #include "../menu/menu_action.c" diff --git a/menu/backend/menu_common_backend.c b/menu/backend/menu_common_backend.c index 8176ae9eed..dd827aa7a7 100644 --- a/menu/backend/menu_common_backend.c +++ b/menu/backend/menu_common_backend.c @@ -22,7 +22,7 @@ #include #include "menu_backend.h" #include "../menu_entries.h" -#include "../menu_input_line_cb.h" +#include "../menu_input.h" #include "../../input/input_autodetect.h" #include "../../retroarch.h" diff --git a/menu/menu.h b/menu/menu.h index 51abe47361..174c702ed5 100644 --- a/menu/menu.h +++ b/menu/menu.h @@ -27,7 +27,7 @@ #include "menu_navigation.h" #include "../../core_info.h" #include "../../playlist.h" -#include "menu_input_line_cb.h" +#include "menu_input.h" #include "../../gfx/shader/shader_context.h" #ifdef HAVE_RGUI diff --git a/menu/menu_entries_cbs.c b/menu/menu_entries_cbs.c index daf3459635..48a8c1d3c7 100644 --- a/menu/menu_entries_cbs.c +++ b/menu/menu_entries_cbs.c @@ -17,7 +17,7 @@ #include "menu.h" #include "menu_entries_cbs.h" #include "menu_action.h" -#include "menu_input_line_cb.h" +#include "menu_input.h" #include "menu_entries.h" #include "menu_shader.h" diff --git a/menu/menu_input_line_cb.c b/menu/menu_input.c similarity index 99% rename from menu/menu_input_line_cb.c rename to menu/menu_input.c index cbd7ed9007..f374e93558 100644 --- a/menu/menu_input_line_cb.c +++ b/menu/menu_input.c @@ -24,7 +24,7 @@ #include #include #include -#include "menu_input_line_cb.h" +#include "menu_input.h" #include "menu.h" #include "menu_action.h" #include "menu_shader.h" diff --git a/menu/menu_input_line_cb.h b/menu/menu_input.h similarity index 100% rename from menu/menu_input_line_cb.h rename to menu/menu_input.h diff --git a/retroarch.c b/retroarch.c index 6626a2fa7e..72be631799 100644 --- a/retroarch.c +++ b/retroarch.c @@ -43,7 +43,7 @@ #ifdef HAVE_MENU #include "menu/menu.h" #include "menu/menu_shader.h" -#include "menu/menu_input_line_cb.h" +#include "menu/menu_input.h" #endif #ifdef HAVE_NETPLAY diff --git a/settings_data.c b/settings_data.c index 61f13de013..ee972f5e36 100644 --- a/settings_data.c +++ b/settings_data.c @@ -39,7 +39,7 @@ #ifdef HAVE_MENU #include "menu/menu_list.h" #include "menu/menu_entries.h" -#include "menu/menu_input_line_cb.h" +#include "menu/menu_input.h" #include "menu/menu_shader.h" #endif From 5dea7263e549e0be9ac143c29b94f1449eac620c Mon Sep 17 00:00:00 2001 From: twinaphex Date: Sun, 11 Jan 2015 06:34:32 +0100 Subject: [PATCH 032/156] (menu_input.c) Cleanups --- menu/menu_input.c | 46 +++++++++++++++++++++++++--------------------- 1 file changed, 25 insertions(+), 21 deletions(-) diff --git a/menu/menu_input.c b/menu/menu_input.c index f374e93558..84776acb53 100644 --- a/menu/menu_input.c +++ b/menu/menu_input.c @@ -173,18 +173,20 @@ void menu_poll_bind_state(struct menu_bind_state *state) { for (b = 0; b < MENU_MAX_BUTTONS; b++) state->state[i].buttons[b] = input_joypad_button_raw(joypad, i, b); + for (a = 0; a < MENU_MAX_AXES; a++) state->state[i].axes[a] = input_joypad_axis_raw(joypad, i, a); + for (h = 0; h < MENU_MAX_HATS; h++) { - state->state[i].hats[h] |= - input_joypad_hat_raw(joypad, i, HAT_UP_MASK, h) ? HAT_UP_MASK : 0; - state->state[i].hats[h] |= - input_joypad_hat_raw(joypad, i, HAT_DOWN_MASK, h) ? HAT_DOWN_MASK : 0; - state->state[i].hats[h] |= - input_joypad_hat_raw(joypad, i, HAT_LEFT_MASK, h) ? HAT_LEFT_MASK : 0; - state->state[i].hats[h] |= - input_joypad_hat_raw(joypad, i, HAT_RIGHT_MASK, h) ? HAT_RIGHT_MASK : 0; + if (input_joypad_hat_raw(joypad, i, HAT_UP_MASK, h)) + state->state[i].hats[h] |= HAT_UP_MASK; + if (input_joypad_hat_raw(joypad, i, HAT_DOWN_MASK, h)) + state->state[i].hats[h] |= HAT_DOWN_MASK; + if (input_joypad_hat_raw(joypad, i, HAT_LEFT_MASK, h)) + state->state[i].hats[h] |= HAT_LEFT_MASK; + if (input_joypad_hat_raw(joypad, i, HAT_RIGHT_MASK, h)) + state->state[i].hats[h] |= HAT_RIGHT_MASK; } } } @@ -223,12 +225,14 @@ static bool menu_poll_find_trigger_pad(struct menu_bind_state *state, for (b = 0; b < MENU_MAX_BUTTONS; b++) { - if (n->buttons[b] && !o->buttons[b]) - { - state->target->joykey = b; - state->target->joyaxis = AXIS_NONE; - return true; - } + bool iterate = n->buttons[b] && !o->buttons[b]; + + if (!iterate) + continue; + + state->target->joykey = b; + state->target->joyaxis = AXIS_NONE; + return true; } /* Axes are a bit tricky ... */ @@ -292,13 +296,13 @@ bool menu_poll_find_trigger(struct menu_bind_state *state, for (i = 0; i < g_settings.input.max_users; i++) { - if (menu_poll_find_trigger_pad(state, new_state, i)) - { - /* Update the joypad mapping automatically. - * More friendly that way. */ - g_settings.input.joypad_map[state->user] = i; - return true; - } + if (!menu_poll_find_trigger_pad(state, new_state, i)) + continue; + + /* Update the joypad mapping automatically. + * More friendly that way. */ + g_settings.input.joypad_map[state->user] = i; + return true; } return false; } From 9a39abfbf0c37e2da82e9de2d970431b1dddbe41 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Sun, 11 Jan 2015 06:42:53 +0100 Subject: [PATCH 033/156] Rename menu_input.c functions so that they are all in menu_input_* namespace --- menu/menu_entries_cbs.c | 8 ++++---- menu/menu_input.c | 42 +++++++++++++++++++++-------------------- menu/menu_input.h | 18 +++++++++--------- retroarch.c | 2 +- settings_data.c | 20 ++++++++++---------- 5 files changed, 46 insertions(+), 44 deletions(-) diff --git a/menu/menu_entries_cbs.c b/menu/menu_entries_cbs.c index 48a8c1d3c7..da7ce21b59 100644 --- a/menu/menu_entries_cbs.c +++ b/menu/menu_entries_cbs.c @@ -166,8 +166,8 @@ static int action_ok_load_state(const char *path, static int action_ok_cheat(const char *path, const char *label, unsigned type, size_t idx) { - menu_key_start_line(driver.menu, "Input Cheat", - label, type, idx, st_cheat_callback); + menu_input_key_start_line(driver.menu, "Input Cheat", + label, type, idx, menu_input_st_cheat_callback); return 0; } @@ -384,8 +384,8 @@ static int action_ok_shader_preset_save_as(const char *path, if (!driver.menu) return -1; - menu_key_start_line(driver.menu, "Preset Filename", - label, type, idx, st_string_callback); + menu_input_key_start_line(driver.menu, "Preset Filename", + label, type, idx, menu_input_st_string_callback); return 0; } diff --git a/menu/menu_input.c b/menu/menu_input.c index 84776acb53..ac58e3e74c 100644 --- a/menu/menu_input.c +++ b/menu/menu_input.c @@ -32,7 +32,7 @@ #include "../settings_data.h" #include "../input/input_joypad.h" -void menu_key_start_line(void *data, const char *label, +void menu_input_key_start_line(void *data, const char *label, const char *label_setting, unsigned type, unsigned idx, input_keyboard_line_complete_t cb) { @@ -49,7 +49,7 @@ void menu_key_start_line(void *data, const char *label, menu->keyboard.buffer = input_keyboard_start_line(menu, cb); } -static void menu_key_end_line(void *data) +static void menu_input_key_end_line(void *data) { menu_handle_t *menu = (menu_handle_t*)data; @@ -64,7 +64,7 @@ static void menu_key_end_line(void *data) driver.flushing_input = true; } -static void menu_search_callback(void *userdata, const char *str) +static void menu_input_search_callback(void *userdata, const char *str) { size_t idx; menu_handle_t *menu = (menu_handle_t*)userdata; @@ -72,10 +72,10 @@ static void menu_search_callback(void *userdata, const char *str) if (str && *str && file_list_search(menu->menu_list->selection_buf, str, &idx)) menu_navigation_set(menu, idx, true); - menu_key_end_line(menu); + menu_input_key_end_line(menu); } -void st_uint_callback(void *userdata, const char *str) +void menu_input_st_uint_callback(void *userdata, const char *str) { menu_handle_t *menu = (menu_handle_t*)userdata; rarch_setting_t *current_setting = NULL; @@ -87,10 +87,10 @@ void st_uint_callback(void *userdata, const char *str) menu->list_settings, menu->keyboard.label_setting))) *current_setting->value.unsigned_integer = strtoul(str, NULL, 0); } - menu_key_end_line(menu); + menu_input_key_end_line(menu); } -void st_string_callback(void *userdata, const char *str) +void menu_input_st_string_callback(void *userdata, const char *str) { menu_handle_t *menu = (menu_handle_t*)userdata; rarch_setting_t *current_setting = NULL; @@ -107,10 +107,11 @@ void st_string_callback(void *userdata, const char *str) menu_shader_manager_save_preset(str, false); } } - menu_key_end_line(menu); + + menu_input_key_end_line(menu); } -void st_cheat_callback(void *userdata, const char *str) +void menu_input_st_cheat_callback(void *userdata, const char *str) { menu_handle_t *menu = (menu_handle_t*)userdata; cheat_manager_t *cheat = g_extern.cheat; @@ -123,10 +124,11 @@ void st_cheat_callback(void *userdata, const char *str) cheat->cheats[cheat_index].code = strdup(str); cheat->cheats[cheat_index].state = true; } - menu_key_end_line(menu); + + menu_input_key_end_line(menu); } -void menu_key_event(bool down, unsigned keycode, +void menu_input_key_event(bool down, unsigned keycode, uint32_t character, uint16_t mod) { if (!driver.menu) @@ -141,11 +143,11 @@ void menu_key_event(bool down, unsigned keycode, driver.menu->keyboard.display = true; driver.menu->keyboard.label = "Search: "; driver.menu->keyboard.buffer = - input_keyboard_start_line(driver.menu, menu_search_callback); + input_keyboard_start_line(driver.menu, menu_input_search_callback); } } -void menu_poll_bind_state(struct menu_bind_state *state) +void menu_input_poll_bind_state(struct menu_bind_state *state) { unsigned i, b, a, h; const rarch_joypad_driver_t *joypad = NULL; @@ -191,7 +193,7 @@ void menu_poll_bind_state(struct menu_bind_state *state) } } -void menu_poll_bind_get_rested_axes(struct menu_bind_state *state) +void menu_input_poll_bind_get_rested_axes(struct menu_bind_state *state) { unsigned i, a; const rarch_joypad_driver_t *joypad = NULL; @@ -214,7 +216,7 @@ void menu_poll_bind_get_rested_axes(struct menu_bind_state *state) input_joypad_axis_raw(joypad, i, a); } -static bool menu_poll_find_trigger_pad(struct menu_bind_state *state, +static bool menu_input_poll_find_trigger_pad(struct menu_bind_state *state, struct menu_bind_state *new_state, unsigned p) { unsigned a, b, h; @@ -286,7 +288,7 @@ static bool menu_poll_find_trigger_pad(struct menu_bind_state *state, return false; } -bool menu_poll_find_trigger(struct menu_bind_state *state, +bool menu_input_poll_find_trigger(struct menu_bind_state *state, struct menu_bind_state *new_state) { unsigned i; @@ -296,7 +298,7 @@ bool menu_poll_find_trigger(struct menu_bind_state *state, for (i = 0; i < g_settings.input.max_users; i++) { - if (!menu_poll_find_trigger_pad(state, new_state, i)) + if (!menu_input_poll_find_trigger_pad(state, new_state, i)) continue; /* Update the joypad mapping automatically. @@ -307,7 +309,7 @@ bool menu_poll_find_trigger(struct menu_bind_state *state, return false; } -bool menu_custom_bind_keyboard_cb(void *data, unsigned code) +bool menu_input_custom_bind_keyboard_cb(void *data, unsigned code) { menu_handle_t *menu = (menu_handle_t*)data; @@ -342,10 +344,10 @@ int menu_input_bind_iterate(void *data) driver.menu_ctx->render_messagebox(msg); driver.block_input = true; - menu_poll_bind_state(&binds); + menu_input_poll_bind_state(&binds); if ((binds.skip && !menu->binds.skip) || - menu_poll_find_trigger(&menu->binds, &binds)) + menu_input_poll_find_trigger(&menu->binds, &binds)) { driver.block_input = false; diff --git a/menu/menu_input.h b/menu/menu_input.h index c2c1accf0a..fc3b90b5cf 100644 --- a/menu/menu_input.h +++ b/menu/menu_input.h @@ -24,27 +24,27 @@ extern "C" { #endif -void menu_key_event(bool down, unsigned keycode, uint32_t character, +void menu_input_key_event(bool down, unsigned keycode, uint32_t character, uint16_t key_modifiers); -void menu_key_start_line(void *data, const char *label, +void menu_input_key_start_line(void *data, const char *label, const char *label_setting, unsigned type, unsigned idx, input_keyboard_line_complete_t cb); -void st_uint_callback(void *userdata, const char *str); +void menu_input_st_uint_callback(void *userdata, const char *str); -void st_string_callback(void *userdata, const char *str); +void menu_input_st_string_callback(void *userdata, const char *str); -void st_cheat_callback(void *userdata, const char *str); +void menu_input_st_cheat_callback(void *userdata, const char *str); -void menu_poll_bind_get_rested_axes(struct menu_bind_state *state); +void menu_input_poll_bind_get_rested_axes(struct menu_bind_state *state); -void menu_poll_bind_state(struct menu_bind_state *state); +void menu_input_poll_bind_state(struct menu_bind_state *state); -bool menu_poll_find_trigger(struct menu_bind_state *state, +bool menu_input_poll_find_trigger(struct menu_bind_state *state, struct menu_bind_state *new_state); -bool menu_custom_bind_keyboard_cb(void *data, unsigned code); +bool menu_input_custom_bind_keyboard_cb(void *data, unsigned code); int menu_input_bind_iterate(void *data); diff --git a/retroarch.c b/retroarch.c index 72be631799..cfcf46c68e 100644 --- a/retroarch.c +++ b/retroarch.c @@ -2180,7 +2180,7 @@ void rarch_main_set_state(unsigned cmd) * We'll use this later for something ... * FIXME: This should probably be moved to menu_common somehow. */ g_extern.frontend_key_event = g_extern.system.key_event; - g_extern.system.key_event = menu_key_event; + g_extern.system.key_event = menu_input_key_event; driver.menu->need_refresh = true; g_extern.system.frame_time_last = 0; diff --git a/settings_data.c b/settings_data.c index ee972f5e36..d4f7e54480 100644 --- a/settings_data.c +++ b/settings_data.c @@ -927,12 +927,12 @@ static int setting_data_action_ok_bind_all(void *data, unsigned action) rarch_get_time_usec() + MENU_KEYBOARD_BIND_TIMEOUT_SECONDS * 1000000; input_keyboard_wait_keys(driver.menu, - menu_custom_bind_keyboard_cb); + menu_input_custom_bind_keyboard_cb); } else { - menu_poll_bind_get_rested_axes(&driver.menu->binds); - menu_poll_bind_state(&driver.menu->binds); + menu_input_poll_bind_get_rested_axes(&driver.menu->binds); + menu_input_poll_bind_state(&driver.menu->binds); } return 0; } @@ -1067,8 +1067,8 @@ static int setting_data_uint_action_ok_linefeed(void *data, unsigned action) if (!setting) return -1; - menu_key_start_line(driver.menu, setting->short_description, - setting->name, 0, 0, st_uint_callback); + menu_input_key_start_line(driver.menu, setting->short_description, + setting->name, 0, 0, menu_input_st_uint_callback); return 0; } @@ -1119,12 +1119,12 @@ static int setting_data_bind_action_ok(void *data, unsigned action) driver.menu->binds.timeout_end = rarch_get_time_usec() + MENU_KEYBOARD_BIND_TIMEOUT_SECONDS * 1000000; input_keyboard_wait_keys(driver.menu, - menu_custom_bind_keyboard_cb); + menu_input_custom_bind_keyboard_cb); } else { - menu_poll_bind_get_rested_axes(&driver.menu->binds); - menu_poll_bind_state(&driver.menu->binds); + menu_input_poll_bind_get_rested_axes(&driver.menu->binds); + menu_input_poll_bind_state(&driver.menu->binds); } return 0; @@ -1138,8 +1138,8 @@ static int setting_data_string_action_ok_allow_input(void *data, if (!setting || !driver.menu) return -1; - menu_key_start_line(driver.menu, setting->short_description, - setting->name, 0, 0, st_string_callback); + menu_input_key_start_line(driver.menu, setting->short_description, + setting->name, 0, 0, menu_input_st_string_callback); return 0; } From 16b7ca63c387a708a928c65055b3dae2116487c2 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Sun, 11 Jan 2015 06:51:43 +0100 Subject: [PATCH 034/156] (platform_apple.c) Some cleanups --- frontend/platform/platform_apple.c | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/frontend/platform/platform_apple.c b/frontend/platform/platform_apple.c index b3f1676eb2..1bd337c510 100644 --- a/frontend/platform/platform_apple.c +++ b/frontend/platform/platform_apple.c @@ -106,24 +106,24 @@ static void do_iteration(void) void apple_start_iteration(void) { - if (iterate_observer == NULL) - { - iterate_observer = + if (iterate_observer) + return; + + iterate_observer = CFRunLoopObserverCreate(0, kCFRunLoopBeforeWaiting, - true, 0, (CFRunLoopObserverCallBack)do_iteration, 0); - CFRunLoopAddObserver(CFRunLoopGetMain(), iterate_observer, - kCFRunLoopCommonModes); - } + true, 0, (CFRunLoopObserverCallBack)do_iteration, 0); + CFRunLoopAddObserver(CFRunLoopGetMain(), iterate_observer, + kCFRunLoopCommonModes); } void apple_stop_iteration(void) { - if (iterate_observer != NULL) - { - CFRunLoopObserverInvalidate(iterate_observer); - CFRelease(iterate_observer); - iterate_observer = NULL; - } + if (!iterate_observer) + return; + + CFRunLoopObserverInvalidate(iterate_observer); + CFRelease(iterate_observer); + iterate_observer = NULL; } static void frontend_apple_get_environment_settings(int *argc, char *argv[], From 44e2504cd79a642b3e0eaf392f9c83438c1be63d Mon Sep 17 00:00:00 2001 From: twinaphex Date: Sun, 11 Jan 2015 06:57:35 +0100 Subject: [PATCH 035/156] Some cleanups --- frontend/frontend_context.c | 2 ++ frontend/platform/platform_android.c | 36 +++++++++++++++---------- frontend/platform/platform_emscripten.c | 10 +++---- 3 files changed, 29 insertions(+), 19 deletions(-) diff --git a/frontend/frontend_context.c b/frontend/frontend_context.c index a36e2c80b2..b84f233602 100644 --- a/frontend/frontend_context.c +++ b/frontend/frontend_context.c @@ -58,6 +58,7 @@ static const frontend_ctx_driver_t *frontend_ctx_drivers[] = { const frontend_ctx_driver_t *frontend_ctx_find_driver(const char *ident) { unsigned i; + for (i = 0; frontend_ctx_drivers[i]; i++) { if (strcmp(frontend_ctx_drivers[i]->ident, ident) == 0) @@ -77,6 +78,7 @@ const frontend_ctx_driver_t *frontend_ctx_find_driver(const char *ident) const frontend_ctx_driver_t *frontend_ctx_init_first(void) { unsigned i; + for (i = 0; frontend_ctx_drivers[i]; i++) return frontend_ctx_drivers[i]; diff --git a/frontend/platform/platform_android.c b/frontend/platform/platform_android.c index 8eb92fdbc1..25706ec7b5 100644 --- a/frontend/platform/platform_android.c +++ b/frontend/platform/platform_android.c @@ -36,8 +36,8 @@ extern void android_app_entry(void *args); void engine_handle_cmd(void *data) { - struct android_app *android_app = (struct android_app*)g_android; int8_t cmd; + struct android_app *android_app = (struct android_app*)g_android; if (read(android_app->msgread, &cmd, sizeof(cmd)) != sizeof(cmd)) cmd = -1; @@ -175,8 +175,10 @@ static void android_app_set_input(void *data, AInputQueue* inputQueue) slock_lock(android_app->mutex); android_app->pendingInputQueue = inputQueue; android_app_write_cmd(android_app, APP_CMD_INPUT_CHANGED); + while (android_app->inputQueue != android_app->pendingInputQueue) scond_wait(android_app->cond, android_app->mutex); + slock_unlock(android_app->mutex); } @@ -524,16 +526,17 @@ static void frontend_android_get_environment_settings(int *argc, android_app->getIntent); RARCH_LOG("Checking arguments passed from intent ...\n"); - // Config file + /* Config file. */ CALL_OBJ_METHOD_PARAM(env, jstr, obj, android_app->getStringExtra, (*env)->NewStringUTF(env, "CONFIGFILE")); if (android_app->getStringExtra && jstr) { + const char *argv = NULL; static char config_path[PATH_MAX_LENGTH]; *config_path = '\0'; - const char *argv = (*env)->GetStringUTFChars(env, jstr, 0); + argv = (*env)->GetStringUTFChars(env, jstr, 0); if (argv && *argv) strlcpy(config_path, argv, sizeof(config_path)); @@ -544,7 +547,7 @@ static void frontend_android_get_environment_settings(int *argc, args->config_path = config_path; } - // Current IME + /* Current IME. */ CALL_OBJ_METHOD_PARAM(env, jstr, obj, android_app->getStringExtra, (*env)->NewStringUTF(env, "IME")); @@ -570,16 +573,17 @@ static void frontend_android_get_environment_settings(int *argc, RARCH_LOG("USED: [%s].\n", used ? "true" : "false"); } - // LIBRETRO + /* LIBRETRO. */ CALL_OBJ_METHOD_PARAM(env, jstr, obj, android_app->getStringExtra, (*env)->NewStringUTF(env, "LIBRETRO")); if (android_app->getStringExtra && jstr) { + const char *argv = NULL; static char core_path[PATH_MAX_LENGTH]; - *core_path = '\0'; - const char *argv = (*env)->GetStringUTFChars(env, jstr, 0); + *core_path = '\0'; + argv = (*env)->GetStringUTFChars(env, jstr, 0); if (argv && *argv) strlcpy(core_path, argv, sizeof(core_path)); (*env)->ReleaseStringUTFChars(env, jstr, argv); @@ -589,16 +593,17 @@ static void frontend_android_get_environment_settings(int *argc, args->libretro_path = core_path; } - // Content + /* Content. */ CALL_OBJ_METHOD_PARAM(env, jstr, obj, android_app->getStringExtra, (*env)->NewStringUTF(env, "ROM")); if (android_app->getStringExtra && jstr) { + const char *argv = NULL; static char path[PATH_MAX_LENGTH]; - *path = '\0'; - const char *argv = (*env)->GetStringUTFChars(env, jstr, 0); + *path = '\0'; + argv = (*env)->GetStringUTFChars(env, jstr, 0); if (argv && *argv) strlcpy(path, argv, sizeof(path)); @@ -612,16 +617,17 @@ static void frontend_android_get_environment_settings(int *argc, } } - // Content + /* Content. */ CALL_OBJ_METHOD_PARAM(env, jstr, obj, android_app->getStringExtra, (*env)->NewStringUTF(env, "DATADIR")); if (android_app->getStringExtra && jstr) { + const char *argv = NULL; static char path[PATH_MAX_LENGTH]; - *path = '\0'; - const char *argv = (*env)->GetStringUTFChars(env, jstr, 0); + *path = '\0'; + argv = (*env)->GetStringUTFChars(env, jstr, 0); if (argv && *argv) strlcpy(path, argv, sizeof(path)); @@ -745,6 +751,7 @@ static void frontend_android_init(void *data) static void frontend_android_deinit(void *data) { + JNIEnv *env; struct android_app *android_app = (struct android_app*)data; if (!android_app) @@ -753,7 +760,8 @@ static void frontend_android_deinit(void *data) RARCH_LOG("Deinitializing RetroArch ...\n"); android_app->activityState = APP_CMD_DEAD; - JNIEnv *env = jni_thread_getenv(); + env = jni_thread_getenv(); + if (env && android_app->onRetroArchExit) CALL_VOID_METHOD(env, android_app->activity->clazz, android_app->onRetroArchExit); diff --git a/frontend/platform/platform_emscripten.c b/frontend/platform/platform_emscripten.c index 3caee29bf5..bafaed31ac 100644 --- a/frontend/platform/platform_emscripten.c +++ b/frontend/platform/platform_emscripten.c @@ -25,11 +25,11 @@ static void emscripten_mainloop(void) { int ret = main_entry_decide(0, NULL, NULL); - if (ret == -1) - { - main_exit(NULL); - exit(0); - } + if (ret != -1) + return; + + main_exit(NULL); + exit(0); } int main(int argc, char *argv[]) From 935c02bf2d071971df3a17fa00e320351a94fd30 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Sun, 11 Jan 2015 07:37:02 +0100 Subject: [PATCH 036/156] (core_info.c) Some simplifications --- core_info.c | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/core_info.c b/core_info.c index 00ed897f60..e32d283d5c 100644 --- a/core_info.c +++ b/core_info.c @@ -446,7 +446,12 @@ static core_info_t *find_core_info(core_info_list_t *list, for (i = 0; i < list->count; i++) { core_info_t *info = (core_info_t*)&list->list[i]; - if (info && info->path && !strcmp(info->path, core)) + + if (!info) + continue; + if (!info->path) + continue; + if (!strcmp(info->path, core)) return info; } @@ -479,12 +484,12 @@ void core_info_list_update_missing_firmware(core_info_list_t *core_info_list, for (i = 0; i < info->firmware_count; i++) { - if (info->firmware[i].path) - { - fill_pathname_join(path, systemdir, - info->firmware[i].path, sizeof(path)); - info->firmware[i].missing = !path_file_exists(path); - } + if (!info->firmware[i].path) + continue; + + fill_pathname_join(path, systemdir, + info->firmware[i].path, sizeof(path)); + info->firmware[i].missing = !path_file_exists(path); } } From a53d50bd5a5acacba7426f9697117eea80c97711 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Sun, 11 Jan 2015 07:48:02 +0100 Subject: [PATCH 037/156] (retroarch.h) Update documentation --- retroarch.h | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/retroarch.h b/retroarch.h index a63d009e64..e5b354c73e 100644 --- a/retroarch.h +++ b/retroarch.h @@ -31,6 +31,7 @@ enum basic_event /* Loads content file. */ RARCH_CMD_LOAD_CONTENT, RARCH_CMD_LOAD_CONTENT_PERSIST, + /* Loads core. */ RARCH_CMD_LOAD_CORE, RARCH_CMD_LOAD_STATE, RARCH_CMD_SAVE_STATE, @@ -63,7 +64,9 @@ enum basic_event RARCH_CMD_OVERLAY_INIT, /* Deinitializes overlay. */ RARCH_CMD_OVERLAY_DEINIT, + /* Sets current scale factor for overlay. */ RARCH_CMD_OVERLAY_SET_SCALE_FACTOR, + /* Sets current alpha modulation for overlay. */ RARCH_CMD_OVERLAY_SET_ALPHA_MOD, /* Cycle to next overlay. */ RARCH_CMD_OVERLAY_NEXT, @@ -81,14 +84,23 @@ enum basic_event RARCH_CMD_HISTORY_DEINIT, /* Initializes history playlist. */ RARCH_CMD_HISTORY_INIT, + /* Deinitializes core information. */ RARCH_CMD_CORE_INFO_DEINIT, + /* Initializes core information. */ RARCH_CMD_CORE_INFO_INIT, + /* Deinitializes core. */ RARCH_CMD_CORE_DEINIT, + /* Initializes core. */ RARCH_CMD_CORE_INIT, + /* Set audio blocking state. */ RARCH_CMD_AUDIO_SET_BLOCKING_STATE, + /* Set audio nonblocking state. */ RARCH_CMD_AUDIO_SET_NONBLOCKING_STATE, + /* Apply video state changes. */ RARCH_CMD_VIDEO_APPLY_STATE_CHANGES, + /* Set video blocking state. */ RARCH_CMD_VIDEO_SET_BLOCKING_STATE, + /* Set video nonblocking state. */ RARCH_CMD_VIDEO_SET_NONBLOCKING_STATE, /* Sets current aspect ratio index. */ RARCH_CMD_VIDEO_SET_ASPECT_RATIO, @@ -119,11 +131,17 @@ enum basic_event /* Initializes controllers. */ RARCH_CMD_CONTROLLERS_INIT, RARCH_CMD_SAVEFILES, + /* Initializes savefiles. */ RARCH_CMD_SAVEFILES_INIT, + /* Deinitializes savefiles. */ RARCH_CMD_SAVEFILES_DEINIT, + /* Initializes message queue. */ RARCH_CMD_MSG_QUEUE_INIT, + /* Deinitializes message queue. */ RARCH_CMD_MSG_QUEUE_DEINIT, + /* Initializes cheats. */ RARCH_CMD_CHEATS_INIT, + /* Deinitializes cheats. */ RARCH_CMD_CHEATS_DEINIT, /* Initializes netplay system. */ RARCH_CMD_NETPLAY_INIT, From 9f8c96daa18cf3bc61a16ad5a34848472498b29a Mon Sep 17 00:00:00 2001 From: twinaphex Date: Sun, 11 Jan 2015 15:47:39 +0100 Subject: [PATCH 038/156] Remove unused struct --- driver.h | 6 ------ 1 file changed, 6 deletions(-) diff --git a/driver.h b/driver.h index b6f07a5708..f678d9a660 100644 --- a/driver.h +++ b/driver.h @@ -157,12 +157,6 @@ struct retro_keybind char joyaxis_label[256]; }; -struct platform_bind -{ - uint64_t joykey; - char desc[64]; -}; - typedef struct video_info { unsigned width; From 140130dc373da8409e3f699607821a3b0ccebe6d Mon Sep 17 00:00:00 2001 From: twinaphex Date: Sun, 11 Jan 2015 15:53:31 +0100 Subject: [PATCH 039/156] Merge rarch_compr_file_path.c into file_extract.c --- Makefile.common | 1 - file_extract.c | 71 +++++++++++++++++++++ file_extract.h | 8 +++ griffin/griffin.c | 1 - rarch_compr_file_path.c | 136 ---------------------------------------- rarch_compr_file_path.h | 27 -------- 6 files changed, 79 insertions(+), 165 deletions(-) delete mode 100644 rarch_compr_file_path.c delete mode 100644 rarch_compr_file_path.h diff --git a/Makefile.common b/Makefile.common index 7d0a62bafd..e1a44fb81b 100644 --- a/Makefile.common +++ b/Makefile.common @@ -96,7 +96,6 @@ OBJ += frontend/frontend.o \ libretro-sdk/string/string_list.o \ file_ops.o \ libretro-sdk/file/file_path.o \ - rarch_compr_file_path.o \ hash.o \ driver.o \ settings.o \ diff --git a/file_extract.c b/file_extract.c index cc540c6b67..c35fa1e1a5 100644 --- a/file_extract.c +++ b/file_extract.c @@ -504,3 +504,74 @@ struct string_list *zlib_get_file_list(const char *path) return list; } +#ifdef HAVE_COMPRESSION +/* Generic compressed file loader. + * Extracts to buf, unless optional_filename != 0 + * Then extracts to optional_filename and leaves buf alone. + */ +long read_compressed_file(const char * path, void **buf, + const char* optional_filename) +{ + char archive_path[PATH_MAX_LENGTH], *archive_found = NULL; + + /* Safety check. + * If optional_filename and optional_filename exists, we simply return 0, + * hoping that optional_filename is the same as requested. + */ + if (optional_filename) + if(path_file_exists(optional_filename)) + return 0; + + //We split carchive path and relative path: + strlcpy(archive_path,path,sizeof(archive_path)); + archive_found = (char*)strchr(archive_path,'#'); + rarch_assert(archive_found != NULL); + + //We assure that there is something after the '#' symbol + if (strlen(archive_found) <= 1) + { + /* + * This error condition happens for example, when + * path = /path/to/file.7z, or + * path = /path/to/file.7z# + */ + RARCH_ERR("Could not extract image path and carchive path from " + "path: %s.\n", path); + return -1; + } + + //We split the string in two, by putting a \0, where the hash was: + *archive_found = '\0'; + archive_found+=1; + + + const char* file_ext = path_get_extension(archive_path); +#ifdef HAVE_7ZIP + if (strcasecmp(file_ext,"7z") == 0) + return read_7zip_file(archive_path,archive_found,buf,optional_filename); +#endif +#ifdef HAVE_ZLIB + if (strcasecmp(file_ext,"zip") == 0) + return read_zip_file(archive_path,archive_found,buf,optional_filename); +#endif + return -1; +} +#endif + +struct string_list *compressed_file_list_new(const char *path, + const char* ext) +{ +#ifdef HAVE_COMPRESSION + const char* file_ext = path_get_extension(path); +#ifdef HAVE_7ZIP + if (strcasecmp(file_ext,"7z") == 0) + return compressed_7zip_file_list_new(path,ext); +#endif +#ifdef HAVE_ZLIB + if (strcasecmp(file_ext,"zip") == 0) + return compressed_zip_file_list_new(path,ext); +#endif + +#endif + return NULL; +} diff --git a/file_extract.h b/file_extract.h index d09135cd97..e19d11dd28 100644 --- a/file_extract.h +++ b/file_extract.h @@ -21,6 +21,14 @@ #include #include +#ifdef HAVE_7ZIP +#include "decompress/7zip_support.h" +#endif + +#ifdef HAVE_ZLIB +#include "decompress/zip_support.h" +#endif + /* Returns true when parsing should continue. False to stop. */ typedef bool (*zlib_file_cb)(const char *name, const uint8_t *cdata, unsigned cmode, uint32_t csize, uint32_t size, diff --git a/griffin/griffin.c b/griffin/griffin.c index 4d1de1e2a4..c3a4baa2e3 100644 --- a/griffin/griffin.c +++ b/griffin/griffin.c @@ -549,7 +549,6 @@ FILE #include "../libretro-sdk/file/dir_list.c" #include "../libretro-sdk/string/string_list.c" #include "../file_ops.c" -#include "../rarch_compr_file_path.c" #include "../libretro-sdk/file/file_list.c" /*============================================================ diff --git a/rarch_compr_file_path.c b/rarch_compr_file_path.c deleted file mode 100644 index c7d575904b..0000000000 --- a/rarch_compr_file_path.c +++ /dev/null @@ -1,136 +0,0 @@ -/* RetroArch - A frontend for libretro. - * Copyright (C) 2014-2015 - Timo Strunks - * 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 . - */ - -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include "rarch_compr_file_path.h" - -#ifdef __HAIKU__ -#include -#endif - -#if (defined(__CELLOS_LV2__) && !defined(__PSL1GHT__)) || defined(__QNX__) || defined(PSP) -#include /* stat() is defined here */ -#endif - -#if defined(__CELLOS_LV2__) - -#ifndef S_ISDIR -#define S_ISDIR(x) (x & 0040000) -#endif - -#endif - -#if defined(_WIN32) -#ifdef _MSC_VER -#define setmode _setmode -#endif -#ifdef _XBOX -#include -#define INVALID_FILE_ATTRIBUTES -1 -#else -#include -#include -#include -#include -#endif -#else -#include -#include -#include -#include -#endif - - -/* Generic compressed file loader. - * Extracts to buf, unless optional_filename != 0 - * Then extracts to optional_filename and leaves buf alone. - */ -#ifdef HAVE_COMPRESSION -long read_compressed_file(const char * path, void **buf, - const char* optional_filename) -{ - char archive_path[PATH_MAX_LENGTH], *archive_found = NULL; - - /* Safety check. - * If optional_filename and optional_filename exists, we simply return 0, - * hoping that optional_filename is the same as requested. - */ - if (optional_filename) - if(path_file_exists(optional_filename)) - return 0; - - //We split carchive path and relative path: - strlcpy(archive_path,path,sizeof(archive_path)); - archive_found = (char*)strchr(archive_path,'#'); - rarch_assert(archive_found != NULL); - - //We assure that there is something after the '#' symbol - if (strlen(archive_found) <= 1) - { - /* - * This error condition happens for example, when - * path = /path/to/file.7z, or - * path = /path/to/file.7z# - */ - RARCH_ERR("Could not extract image path and carchive path from " - "path: %s.\n", path); - return -1; - } - - //We split the string in two, by putting a \0, where the hash was: - *archive_found = '\0'; - archive_found+=1; - - - const char* file_ext = path_get_extension(archive_path); -#ifdef HAVE_7ZIP - if (strcasecmp(file_ext,"7z") == 0) - return read_7zip_file(archive_path,archive_found,buf,optional_filename); -#endif -#ifdef HAVE_ZLIB - if (strcasecmp(file_ext,"zip") == 0) - return read_zip_file(archive_path,archive_found,buf,optional_filename); -#endif - return -1; -} -#endif - -struct string_list *compressed_file_list_new(const char *path, - const char* ext) -{ -#ifdef HAVE_COMPRESSION - const char* file_ext = path_get_extension(path); -#ifdef HAVE_7ZIP - if (strcasecmp(file_ext,"7z") == 0) - return compressed_7zip_file_list_new(path,ext); -#endif -#ifdef HAVE_ZLIB - if (strcasecmp(file_ext,"zip") == 0) - return compressed_zip_file_list_new(path,ext); -#endif - -#endif - return NULL; -} diff --git a/rarch_compr_file_path.h b/rarch_compr_file_path.h deleted file mode 100644 index 629cfa2122..0000000000 --- a/rarch_compr_file_path.h +++ /dev/null @@ -1,27 +0,0 @@ -/* RetroArch - A frontend for libretro. - * Copyright (C) 2014-2015 - Timo Strunks - * 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 . - */ - -#ifndef _RARCH_COMPR_FILE_PATH_H -#define _RARCH_COMPR_FILE_PATH_H - -#ifdef HAVE_7ZIP -#include "decompress/7zip_support.h" -#endif -#ifdef HAVE_ZLIB -#include "decompress/zip_support.h" -#endif - -#endif From 38a451b55b1737c3f9c4452c5588d398d2d93d51 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Sun, 11 Jan 2015 15:55:02 +0100 Subject: [PATCH 040/156] Fix 'statement is unreachable' warning --- retroarch.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/retroarch.c b/retroarch.c index cfcf46c68e..224ef1a1f9 100644 --- a/retroarch.c +++ b/retroarch.c @@ -2835,7 +2835,8 @@ bool rarch_main_command(unsigned cmd) case RARCH_CMD_NETPLAY_INIT: rarch_main_command(RARCH_CMD_NETPLAY_DEINIT); #ifdef HAVE_NETPLAY - return init_netplay(); + if (!init_netplay()) + return false; #endif break; case RARCH_CMD_NETPLAY_FLIP_PLAYERS: From 457ad74aee4c97a00dced311c7b21cb698133659 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Sun, 11 Jan 2015 15:55:31 +0100 Subject: [PATCH 041/156] RARCH_CMD_FLIP_USERS - return false when netplay handle is NULL --- retroarch.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/retroarch.c b/retroarch.c index 224ef1a1f9..7d4b63bec3 100644 --- a/retroarch.c +++ b/retroarch.c @@ -2843,8 +2843,9 @@ bool rarch_main_command(unsigned cmd) #ifdef HAVE_NETPLAY { netplay_t *netplay = (netplay_t*)driver.netplay_data; - if (netplay) - netplay_flip_users(netplay); + if (!netplay) + return false; + netplay_flip_users(netplay); } #endif break; From ca498675e76b57ffef35e85e3b60092c460c0304 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Sun, 11 Jan 2015 16:16:26 +0100 Subject: [PATCH 042/156] Simplify retroarch_logger.h --- Makefile.ps3.salamander | 2 +- logger/salamander_logger_override.h | 77 ----------------------------- retroarch_logger.h | 49 +++++++++--------- 3 files changed, 28 insertions(+), 100 deletions(-) delete mode 100644 logger/salamander_logger_override.h diff --git a/Makefile.ps3.salamander b/Makefile.ps3.salamander index 2c37b89f03..a23216b302 100644 --- a/Makefile.ps3.salamander +++ b/Makefile.ps3.salamander @@ -18,7 +18,7 @@ endif STRIP = $(CELL_SDK)/host-win32/ppu/bin/ppu-lv2-strip.exe -PPU_CFLAGS += -I. -Ilibretro-sdk/include -D__CELLOS_LV2__ -DIS_SALAMANDER -DRARCH_CONSOLE -DHAVE_SYSUTILS -DHAVE_SYSMODULES -DHAVE_RARCH_EXEC -DRARCH_INTERNAL +PPU_CFLAGS += -I. -Ilibretro-sdk/include -D__CELLOS_LV2__ -DIS_SALAMANDER -DRARCH_CONSOLE -DHAVE_SYSUTILS -DHAVE_SYSMODULES -DHAVE_RARCH_EXEC PPU_SRCS = frontend/frontend_salamander.c frontend/frontend_context.c frontend/platform/platform_ps3.c frontend/platform/platform_null.c libretro-sdk/file/file_path.c libretro-sdk/file/dir_list.c libretro-sdk/string/string_list.c libretro-sdk/compat/compat.c libretro-sdk/file/config_file.c ifeq ($(HAVE_LOGGER), 1) diff --git a/logger/salamander_logger_override.h b/logger/salamander_logger_override.h deleted file mode 100644 index b3feb52daf..0000000000 --- a/logger/salamander_logger_override.h +++ /dev/null @@ -1,77 +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 . - */ - -#ifndef __SALAMANDER_LOGGER_H -#define __SALAMANDER_LOGGER_H - -#include - -#define LOG_FILE (stderr) - -#ifndef RARCH_LOG -#define RARCH_LOG(...) do { \ - fprintf(LOG_FILE, "RetroArch Salamander: " __VA_ARGS__); \ - fflush(LOG_FILE); \ - } while (0) -#endif - -#ifndef RARCH_LOG_V -#define RARCH_LOG_V(tag, fmt, vp) do { \ - fprintf(LOG_FILE, "RetroArch Salamander: " tag); \ - vfprintf(LOG_FILE, fmt, vp); \ - fflush(LOG_FILE); \ - } while(0) -#endif - -#ifndef RARCH_LOG_OUTPUT -#define RARCH_LOG_OUTPUT(...) RARCH_LOG(__VA_ARGS__) -#endif - -#ifndef RARCH_LOG_OUTPUT_V -#define RARCH_LOG_OUTPUT_V(tag, fmt, vp) RARCH_LOG_V(tag, fmt, vp) -#endif - -#ifndef RARCH_ERR -#define RARCH_ERR(...) do { \ - fprintf(LOG_FILE, "RetroArch Salamander [ERROR] :: " __VA_ARGS__); \ - fflush(LOG_FILE); \ - } while (0) -#endif - -#ifndef RARCH_ERR_V -#define RARCH_ERR_V(tag, fmt, vp) do { \ - fprintf(LOG_FILE, "RetroArch Salamander [ERROR] :: " tag); \ - vfprintf(LOG_FILE, fmt, vp); \ - fflush(LOG_FILE); \ - } while (0) -#endif - -#ifndef RARCH_WARN -#define RARCH_WARN(...) do { \ - fprintf(LOG_FILE, "RetroArch Salamander [WARN] :: " __VA_ARGS__); \ - fflush(LOG_FILE); \ - } while (0) -#endif - -#ifndef RARCH_WARN_V -#define RARCH_WARN_V(tag, fmt, vp) do { \ - fprintf(LOG_FILE, "RetroArch Salamander [WARN] :: " tag); \ - vfprintf(LOG_FILE, fmt, vp); \ - fflush(LOG_FILE); \ - } while (0) -#endif - -#endif diff --git a/retroarch_logger.h b/retroarch_logger.h index 2763a45258..de23737f2d 100644 --- a/retroarch_logger.h +++ b/retroarch_logger.h @@ -20,38 +20,42 @@ #include #include -#if defined(RARCH_DUMMY_LOG) -#define LOG_FILE (stderr) -#elif defined(HAVE_FILE_LOGGER) && defined(RARCH_INTERNAL) +#if defined(HAVE_FILE_LOGGER) && defined(RARCH_INTERNAL) #define LOG_FILE (g_extern.log_file) #else #define LOG_FILE (stderr) #endif -#if defined(RARCH_CONSOLE) && defined(HAVE_LOGGER) +#if defined(IS_SALAMANDER) +#define PROGRAM_NAME "RetroArch Salamander" +#elif defined(RARCH_INTERNAL) +#define PROGRAM_NAME "RetroArch" +#else +#define PROGRAM_NAME "N/A" +#endif + +#if defined(RARCH_INTERNAL) +#define RARCH_LOG_VERBOSE g_extern.verbosity +#else +#define RARCH_LOG_VERBOSE (true) +#endif + +#if defined(RARCH_CONSOLE) && defined(HAVE_LOGGER) && defined(RARCH_INTERNAL) #include -#elif defined(IOS) +#elif defined(IOS) && defined(RARCH_INTERNAL) #include "logger/ios_logger_override.h" -#elif defined(_XBOX1) +#elif defined(_XBOX1) && defined(RARCH_INTERNAL) #include "logger/xdk1_logger_override.h" -#elif defined(IS_SALAMANDER) -#include "logger/salamander_logger_override.h" -#elif defined(ANDROID) && defined(HAVE_LOGGER) +#elif defined(ANDROID) && defined(HAVE_LOGGER) && defined(RARCH_INTERNAL) #include "logger/android_logger_override.h" #else -#if defined(RARCH_DUMMY_LOG) || !defined(RARCH_INTERNAL) -#define RARCH_LOG_VERBOSE (true) -#else -#define RARCH_LOG_VERBOSE g_extern.verbosity -#endif - #ifndef RARCH_LOG #undef RARCH_LOG_V #define RARCH_LOG(...) do { \ if (RARCH_LOG_VERBOSE) \ { \ - fprintf(LOG_FILE, "RetroArch: %s: ", __FUNCTION__); \ + fprintf(LOG_FILE, "%s: %s: ", PROGRAM_NAME, __FUNCTION__); \ fprintf(LOG_FILE, __VA_ARGS__); \ fflush(LOG_FILE); \ } \ @@ -59,7 +63,7 @@ #define RARCH_LOG_V(tag, fmt, vp) do { \ if (RARCH_LOG_VERBOSE) \ { \ - fprintf(LOG_FILE, "RetroArch: %s: ", __FUNCTION__); \ + fprintf(LOG_FILE, "%s: %s: ", PROGRAM_NAME, __FUNCTION__); \ fprintf(LOG_FILE, tag);\ vfprintf(LOG_FILE, fmt, vp); \ fflush(LOG_FILE); \ @@ -75,7 +79,7 @@ fflush(LOG_FILE); \ } while (0) #define RARCH_LOG_OUTPUT_V(tag, fmt, vp) do { \ - fprintf(LOG_FILE, "RetroArch: %s: ", __FUNCTION__); \ + fprintf(LOG_FILE, "%s: %s: ", PROGRAM_NAME, __FUNCTION__); \ fprintf(LOG_FILE, tag); \ vfprintf(LOG_FILE, fmt, vp); \ fflush(LOG_FILE); \ @@ -85,12 +89,12 @@ #ifndef RARCH_ERR #undef RARCH_ERR_V #define RARCH_ERR(...) do { \ - fprintf(LOG_FILE, "RetroArch [ERROR] :: %s :: ", __FUNCTION__); \ + fprintf(LOG_FILE, "%s [ERROR] :: %s :: ", PROGRAM_NAME, __FUNCTION__); \ fprintf(LOG_FILE, __VA_ARGS__); \ fflush(LOG_FILE); \ } while (0) #define RARCH_ERR_V(tag, fmt, vp) do { \ - fprintf(LOG_FILE, "RetroArch [ERROR] :: %s :: ", __FUNCTION__); \ + fprintf(LOG_FILE, "%s [ERROR] :: %s :: ", PROGRAM_NAME, __FUNCTION__); \ fprintf(LOG_FILE, tag); \ vfprintf(LOG_FILE, fmt, vp); \ fflush(LOG_FILE); \ @@ -100,12 +104,12 @@ #ifndef RARCH_WARN #undef RARCH_WARN_V #define RARCH_WARN(...) do { \ - fprintf(LOG_FILE, "RetroArch [WARN] :: %s :: ", __FUNCTION__); \ + fprintf(LOG_FILE, "%s [WARN] :: %s :: ", PROGRAM_NAME, __FUNCTION__); \ fprintf(LOG_FILE, __VA_ARGS__); \ fflush(LOG_FILE); \ } while (0) #define RARCH_WARN_V(tag, fmt, vp) do { \ - fprintf(LOG_FILE, "RetroArch [WARN] :: %s :: ", __FUNCTION__); \ + fprintf(LOG_FILE, "%s [WARN] :: %s :: ", PROGRAM_NAME, __FUNCTION__); \ fprintf(LOG_FILE, tag); \ vfprintf(LOG_FILE, fmt, vp); \ fflush(LOG_FILE); \ @@ -113,5 +117,6 @@ #endif #endif + #endif From 0a2e7afe27a043053b1576d63c1a336989985996 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Sun, 11 Jan 2015 16:38:20 +0100 Subject: [PATCH 043/156] Move read_compressed_file to file_ops.c --- file_extract.c | 54 ---------------------------------------------- file_ops.c | 58 ++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 58 insertions(+), 54 deletions(-) diff --git a/file_extract.c b/file_extract.c index c35fa1e1a5..d426733c16 100644 --- a/file_extract.c +++ b/file_extract.c @@ -504,60 +504,6 @@ struct string_list *zlib_get_file_list(const char *path) return list; } -#ifdef HAVE_COMPRESSION -/* Generic compressed file loader. - * Extracts to buf, unless optional_filename != 0 - * Then extracts to optional_filename and leaves buf alone. - */ -long read_compressed_file(const char * path, void **buf, - const char* optional_filename) -{ - char archive_path[PATH_MAX_LENGTH], *archive_found = NULL; - - /* Safety check. - * If optional_filename and optional_filename exists, we simply return 0, - * hoping that optional_filename is the same as requested. - */ - if (optional_filename) - if(path_file_exists(optional_filename)) - return 0; - - //We split carchive path and relative path: - strlcpy(archive_path,path,sizeof(archive_path)); - archive_found = (char*)strchr(archive_path,'#'); - rarch_assert(archive_found != NULL); - - //We assure that there is something after the '#' symbol - if (strlen(archive_found) <= 1) - { - /* - * This error condition happens for example, when - * path = /path/to/file.7z, or - * path = /path/to/file.7z# - */ - RARCH_ERR("Could not extract image path and carchive path from " - "path: %s.\n", path); - return -1; - } - - //We split the string in two, by putting a \0, where the hash was: - *archive_found = '\0'; - archive_found+=1; - - - const char* file_ext = path_get_extension(archive_path); -#ifdef HAVE_7ZIP - if (strcasecmp(file_ext,"7z") == 0) - return read_7zip_file(archive_path,archive_found,buf,optional_filename); -#endif -#ifdef HAVE_ZLIB - if (strcasecmp(file_ext,"zip") == 0) - return read_zip_file(archive_path,archive_found,buf,optional_filename); -#endif - return -1; -} -#endif - struct string_list *compressed_file_list_new(const char *path, const char* ext) { diff --git a/file_ops.c b/file_ops.c index 6aba0cbe0b..5c9bebf0dd 100644 --- a/file_ops.c +++ b/file_ops.c @@ -25,6 +25,10 @@ #include #include +#ifdef HAVE_COMPRESSION +#include "file_extract.h" +#endif + #ifdef __HAIKU__ #include #endif @@ -152,6 +156,60 @@ error: return -1; } +#ifdef HAVE_COMPRESSION +/* Generic compressed file loader. + * Extracts to buf, unless optional_filename != 0 + * Then extracts to optional_filename and leaves buf alone. + */ +long read_compressed_file(const char * path, void **buf, + const char* optional_filename) +{ + const char* file_ext; + char archive_path[PATH_MAX_LENGTH], *archive_found = NULL; + + /* Safety check. + * If optional_filename and optional_filename exists, we simply return 0, + * hoping that optional_filename is the same as requested. + */ + if (optional_filename) + if(path_file_exists(optional_filename)) + return 0; + + //We split carchive path and relative path: + strlcpy(archive_path,path,sizeof(archive_path)); + archive_found = (char*)strchr(archive_path,'#'); + rarch_assert(archive_found != NULL); + + //We assure that there is something after the '#' symbol + if (strlen(archive_found) <= 1) + { + /* + * This error condition happens for example, when + * path = /path/to/file.7z, or + * path = /path/to/file.7z# + */ + RARCH_ERR("Could not extract image path and carchive path from " + "path: %s.\n", path); + return -1; + } + + /* We split the string in two, by putting a \0, where the hash was: */ + *archive_found = '\0'; + archive_found+=1; + + file_ext = path_get_extension(archive_path); +#ifdef HAVE_7ZIP + if (strcasecmp(file_ext,"7z") == 0) + return read_7zip_file(archive_path,archive_found,buf,optional_filename); +#endif +#ifdef HAVE_ZLIB + if (strcasecmp(file_ext,"zip") == 0) + return read_zip_file(archive_path,archive_found,buf,optional_filename); +#endif + return -1; +} +#endif + /** * read_file: * @path : path to file. From 90a32b022d3ccc4f8bee92d1c90dc40e7accbb8c Mon Sep 17 00:00:00 2001 From: twinaphex Date: Sun, 11 Jan 2015 17:10:14 +0100 Subject: [PATCH 044/156] Slight refinement to main_entry_decide --- frontend/frontend.c | 23 ++++++++++------------- frontend/frontend.h | 3 +-- 2 files changed, 11 insertions(+), 15 deletions(-) diff --git a/frontend/frontend.c b/frontend/frontend.c index f937cbf92e..a73dc13c8e 100644 --- a/frontend/frontend.c +++ b/frontend/frontend.c @@ -55,26 +55,23 @@ * * Runs RetroArch for one frame. * - * Returns: -1 upon exiting, 0 if we want to - * iterate to the next frame. + * Returns: 0 on success, -1 upon exiting. **/ int main_entry_decide(signature(), args_type() args) { - int ret = rarch_main_iterate(); + if (rarch_main_iterate() == 0) + return 0; - if (ret == -1) + if (g_extern.core_shutdown_initiated + && g_settings.load_dummy_on_core_shutdown) { - if (g_extern.core_shutdown_initiated - && g_settings.load_dummy_on_core_shutdown) - { - /* Load dummy core instead of exiting RetroArch completely. */ - rarch_main_command(RARCH_CMD_PREPARE_DUMMY); - g_extern.core_shutdown_initiated = false; - return 0; - } + /* Load dummy core instead of exiting RetroArch completely. */ + rarch_main_command(RARCH_CMD_PREPARE_DUMMY); + g_extern.core_shutdown_initiated = false; + return 0; } - return ret; + return -1; } /** diff --git a/frontend/frontend.h b/frontend/frontend.h index 5679133f86..e8fd744526 100644 --- a/frontend/frontend.h +++ b/frontend/frontend.h @@ -80,8 +80,7 @@ bool main_load_content(int argc, char **argv, * * Runs RetroArch for one frame. * - * Returns: -1 upon exiting, 0 if we want to - * iterate to the next frame. + * Returns: 0 on success, -1 upon exiting. **/ int main_entry_decide(signature(), args_type() args); From b53e8f64373f64898b2b878d06aa5e1899c2475d Mon Sep 17 00:00:00 2001 From: twinaphex Date: Sun, 11 Jan 2015 17:33:05 +0100 Subject: [PATCH 045/156] Create rarch_main_iterate_quit --- frontend/frontend.c | 14 +------------- runloop.c | 45 ++++++++++++++++++++++++++++++++++++++++----- 2 files changed, 41 insertions(+), 18 deletions(-) diff --git a/frontend/frontend.c b/frontend/frontend.c index a73dc13c8e..c371146625 100644 --- a/frontend/frontend.c +++ b/frontend/frontend.c @@ -59,19 +59,7 @@ **/ int main_entry_decide(signature(), args_type() args) { - if (rarch_main_iterate() == 0) - return 0; - - if (g_extern.core_shutdown_initiated - && g_settings.load_dummy_on_core_shutdown) - { - /* Load dummy core instead of exiting RetroArch completely. */ - rarch_main_command(RARCH_CMD_PREPARE_DUMMY); - g_extern.core_shutdown_initiated = false; - return 0; - } - - return -1; + return rarch_main_iterate(); } /** diff --git a/runloop.c b/runloop.c index 0d1cdce7a3..01d18e7a51 100644 --- a/runloop.c +++ b/runloop.c @@ -834,12 +834,39 @@ static bool input_flush(retro_input_t *input) return true; } +/** + * rarch_main_load_dummy_core: + * + * Quits out of RetroArch main loop. + * + * On special case, loads dummy core + * instead of exiting RetroArch completely. + * Aborts core shutdown if invoked. + * + * Returns: -1 if we are about to quit, otherwise 0. + **/ +static int rarch_main_iterate_quit(void) +{ + if (g_extern.core_shutdown_initiated + && g_settings.load_dummy_on_core_shutdown) + { + if (!rarch_main_command(RARCH_CMD_PREPARE_DUMMY)) + return -1; + + g_extern.core_shutdown_initiated = false; + + return 0; + } + + return -1; +} + /** * rarch_main_iterate: * * Run Libretro core in RetroArch for one frame. * - * Returns: 0 on successful run, 1 if we have to wait until button input in order + * Returns: 0 on success, 1 if we have to wait until button input in order * to wake up the loop, -1 if we forcibly quit out of the RetroArch iteration loop. **/ int rarch_main_iterate(void) @@ -850,7 +877,6 @@ int rarch_main_iterate(void) static retro_input_t last_input = 0; retro_input_t old_input = last_input; retro_input_t input = input_keys_pressed(); - last_input = input; if (driver.flushing_input) @@ -859,7 +885,10 @@ int rarch_main_iterate(void) trigger_input = input & ~old_input; if (time_to_exit(input)) - return -1; + { + ret = -1; + goto quit; + } if (g_extern.system.frame_time.callback) update_frame_time(); @@ -881,7 +910,8 @@ int rarch_main_iterate(void) if (g_extern.exec) { g_extern.exec = false; - return -1; + ret = -1; + goto quit; } if (do_state_checks(input, old_input, trigger_input)) @@ -890,7 +920,8 @@ int rarch_main_iterate(void) driver.retro_ctx.poll_cb(); rarch_sleep(10); - return 1; + ret = 1; + goto quit; } #if defined(HAVE_THREADS) @@ -952,5 +983,9 @@ success: if (g_settings.fastforward_ratio_throttle_enable) limit_frame_time(); +quit: + if (ret == -1) + return rarch_main_iterate_quit(); + return ret; } From fae8a8d8d71ee7589ef237964a28cf1f3c0247ae Mon Sep 17 00:00:00 2001 From: twinaphex Date: Sun, 11 Jan 2015 17:48:21 +0100 Subject: [PATCH 046/156] Remove main_entry_decide --- frontend/frontend.c | 14 +------------- frontend/frontend.h | 9 --------- frontend/platform/platform_apple.c | 2 +- frontend/platform/platform_emscripten.c | 4 +--- 4 files changed, 3 insertions(+), 26 deletions(-) diff --git a/frontend/frontend.c b/frontend/frontend.c index c371146625..0e212550d8 100644 --- a/frontend/frontend.c +++ b/frontend/frontend.c @@ -50,18 +50,6 @@ #define MAX_ARGS 32 -/** - * main_entry_decide: - * - * Runs RetroArch for one frame. - * - * Returns: 0 on success, -1 upon exiting. - **/ -int main_entry_decide(signature(), args_type() args) -{ - return rarch_main_iterate(); -} - /** * main_exit_save_config: * @@ -307,7 +295,7 @@ returntype main_entry(signature()) } #if defined(HAVE_MAIN_LOOP) - while (main_entry_decide(signature_expand(), args) != -1); + while (rarch_main_iterate() != -1); main_exit(args); #endif diff --git a/frontend/frontend.h b/frontend/frontend.h index e8fd744526..312d9ef85c 100644 --- a/frontend/frontend.h +++ b/frontend/frontend.h @@ -75,15 +75,6 @@ bool main_load_content(int argc, char **argv, args_type() args, environment_get_t environ_get, process_args_t process_args); -/** - * main_entry_decide: - * - * Runs RetroArch for one frame. - * - * Returns: 0 on success, -1 upon exiting. - **/ -int main_entry_decide(signature(), args_type() args); - #ifdef __cplusplus } #endif diff --git a/frontend/platform/platform_apple.c b/frontend/platform/platform_apple.c index 1bd337c510..d7045c4532 100644 --- a/frontend/platform/platform_apple.c +++ b/frontend/platform/platform_apple.c @@ -34,7 +34,7 @@ static CFRunLoopObserverRef iterate_observer = NULL; static void do_iteration(void) { - int ret = main_entry_decide(0, NULL, NULL); + int ret = rarch_main_iterate(); if (ret == -1) { diff --git a/frontend/platform/platform_emscripten.c b/frontend/platform/platform_emscripten.c index bafaed31ac..30e68d92b4 100644 --- a/frontend/platform/platform_emscripten.c +++ b/frontend/platform/platform_emscripten.c @@ -23,9 +23,7 @@ static void emscripten_mainloop(void) { - int ret = main_entry_decide(0, NULL, NULL); - - if (ret != -1) + if (rarch_main_iterate() != -1) return; main_exit(NULL); From 8f41438410bca83b76173424c8aa3d003aa460c9 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Sun, 11 Jan 2015 18:00:50 +0100 Subject: [PATCH 047/156] Some minor changes to rarch_main_iterate --- runloop.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/runloop.c b/runloop.c index 01d18e7a51..90c1fcaf4b 100644 --- a/runloop.c +++ b/runloop.c @@ -984,8 +984,8 @@ success: limit_frame_time(); quit: - if (ret == -1) - return rarch_main_iterate_quit(); + if (ret != -1) + return ret; - return ret; + return rarch_main_iterate_quit(); } From 7198d658bbe3568abc801f3605efbbe7250c1e58 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Sun, 11 Jan 2015 18:04:42 +0100 Subject: [PATCH 048/156] Some control flow changes in rarch_main_iterate --- runloop.c | 17 ++++------------- 1 file changed, 4 insertions(+), 13 deletions(-) diff --git a/runloop.c b/runloop.c index 90c1fcaf4b..d33a7a36c1 100644 --- a/runloop.c +++ b/runloop.c @@ -885,10 +885,7 @@ int rarch_main_iterate(void) trigger_input = input & ~old_input; if (time_to_exit(input)) - { - ret = -1; - goto quit; - } + return rarch_main_iterate_quit(); if (g_extern.system.frame_time.callback) update_frame_time(); @@ -910,8 +907,7 @@ int rarch_main_iterate(void) if (g_extern.exec) { g_extern.exec = false; - ret = -1; - goto quit; + return rarch_main_iterate_quit(); } if (do_state_checks(input, old_input, trigger_input)) @@ -920,8 +916,7 @@ int rarch_main_iterate(void) driver.retro_ctx.poll_cb(); rarch_sleep(10); - ret = 1; - goto quit; + return 1; } #if defined(HAVE_THREADS) @@ -983,9 +978,5 @@ success: if (g_settings.fastforward_ratio_throttle_enable) limit_frame_time(); -quit: - if (ret != -1) - return ret; - - return rarch_main_iterate_quit(); + return ret; } From 5c798e6994f43d8c5c56f1c49485ec376ff5596a Mon Sep 17 00:00:00 2001 From: twinaphex Date: Sun, 11 Jan 2015 18:26:59 +0100 Subject: [PATCH 049/156] Move some defines to frontend.h --- frontend/frontend.h | 19 +++++++++++++++++++ frontend/frontend_context.h | 19 ------------------- 2 files changed, 19 insertions(+), 19 deletions(-) diff --git a/frontend/frontend.h b/frontend/frontend.h index 312d9ef85c..f4ce3b044b 100644 --- a/frontend/frontend.h +++ b/frontend/frontend.h @@ -22,6 +22,25 @@ #include #include +#if defined(ANDROID) +#include "platform/platform_android.h" +#define main_entry android_app_entry +#define args_type() struct android_app* +#define signature() void* data +#define signature_expand() data +#define returntype void +#else +#if defined(__APPLE__) || defined(HAVE_BB10) || defined(EMSCRIPTEN) +#define main_entry rarch_main +#else +#define main_entry main +#endif +#define args_type() void* +#define signature() int argc, char *argv[] +#define signature_expand() argc, argv +#define returntype int +#endif + #ifdef __cplusplus extern "C" { #endif diff --git a/frontend/frontend_context.h b/frontend/frontend_context.h index 095f072179..20c301537c 100644 --- a/frontend/frontend_context.h +++ b/frontend/frontend_context.h @@ -24,25 +24,6 @@ #include "../config.h" #endif -#if defined(ANDROID) -#include "platform/platform_android.h" -#define main_entry android_app_entry -#define args_type() struct android_app* -#define signature() void* data -#define signature_expand() data -#define returntype void -#else -#if defined(__APPLE__) || defined(HAVE_BB10) || defined(EMSCRIPTEN) -#define main_entry rarch_main -#else -#define main_entry main -#endif -#define args_type() void* -#define signature() int argc, char *argv[] -#define signature_expand() argc, argv -#define returntype int -#endif - #ifdef __cplusplus extern "C" { #endif From 3419a1846c818d17a4b65a94124d360a61a0e0eb Mon Sep 17 00:00:00 2001 From: twinaphex Date: Sun, 11 Jan 2015 18:30:56 +0100 Subject: [PATCH 050/156] menu_shader.c - cleanups --- menu/menu_shader.c | 61 ++++++++++++++++++++++++---------------------- 1 file changed, 32 insertions(+), 29 deletions(-) diff --git a/menu/menu_shader.c b/menu/menu_shader.c index 67c5a69990..b05306a3a4 100644 --- a/menu/menu_shader.c +++ b/menu/menu_shader.c @@ -123,43 +123,46 @@ void menu_shader_manager_set_preset(struct gfx_shader *shader, unsigned type, const char *preset_path) { #ifdef HAVE_SHADER_MANAGER - RARCH_LOG("Setting Menu shader: %s.\n", preset_path ? preset_path : "N/A (stock)"); + config_file_t *conf = NULL; + g_settings.video.shader_enable = false; - if (driver.video->set_shader && driver.video->set_shader(driver.video_data, + if (!driver.video->set_shader) + return; + if (!driver.video->set_shader(driver.video_data, (enum rarch_shader_type)type, preset_path)) + return; + + /* Makes sure that we use Menu Preset shader on driver reinit. + * Only do this when the cgp actually works to avoid potential errors. */ + strlcpy(g_settings.video.shader_path, preset_path ? preset_path : "", + sizeof(g_settings.video.shader_path)); + g_settings.video.shader_enable = true; + + if (!preset_path) + return; + if (!shader) + return; + + /* Load stored Preset into menu on success. + * Used when a preset is directly loaded. + * No point in updating when the Preset was + * created from the menu itself. */ + conf = config_file_new(preset_path); + + if (conf) { - config_file_t *conf = NULL; + RARCH_LOG("Setting Menu shader: %s.\n", preset_path ? preset_path : "N/A (stock)"); - /* Makes sure that we use Menu Preset shader on driver reinit. - * Only do this when the cgp actually works to avoid potential errors. */ - strlcpy(g_settings.video.shader_path, preset_path ? preset_path : "", - sizeof(g_settings.video.shader_path)); - g_settings.video.shader_enable = true; - - if (!preset_path) - return; - if (!shader) - return; - - /* Load stored Preset into menu on success. - * Used when a preset is directly loaded. - * No point in updating when the Preset was - * created from the menu itself. */ - conf = config_file_new(preset_path); - - if (conf) + if (gfx_shader_read_conf_cgp(conf, shader)) { - if (gfx_shader_read_conf_cgp(conf, shader)) - { - gfx_shader_resolve_relative(shader, preset_path); - gfx_shader_resolve_parameters(conf, shader); - } - config_file_free(conf); + gfx_shader_resolve_relative(shader, preset_path); + gfx_shader_resolve_parameters(conf, shader); } - - driver.menu->need_refresh = true; + config_file_free(conf); } + + driver.menu->need_refresh = true; #endif } From 0747591af6f33b67b954087a3f7e1dc4bbf3434c Mon Sep 17 00:00:00 2001 From: twinaphex Date: Sun, 11 Jan 2015 18:32:16 +0100 Subject: [PATCH 051/156] Some more cleanups in menu_shader.c --- menu/menu_shader.c | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/menu/menu_shader.c b/menu/menu_shader.c index b05306a3a4..e9ad91825a 100644 --- a/menu/menu_shader.c +++ b/menu/menu_shader.c @@ -150,17 +150,17 @@ void menu_shader_manager_set_preset(struct gfx_shader *shader, * created from the menu itself. */ conf = config_file_new(preset_path); - if (conf) - { - RARCH_LOG("Setting Menu shader: %s.\n", preset_path ? preset_path : "N/A (stock)"); + if (!conf) + return; - if (gfx_shader_read_conf_cgp(conf, shader)) - { - gfx_shader_resolve_relative(shader, preset_path); - gfx_shader_resolve_parameters(conf, shader); - } - config_file_free(conf); + RARCH_LOG("Setting Menu shader: %s.\n", preset_path ? preset_path : "N/A (stock)"); + + if (gfx_shader_read_conf_cgp(conf, shader)) + { + gfx_shader_resolve_relative(shader, preset_path); + gfx_shader_resolve_parameters(conf, shader); } + config_file_free(conf); driver.menu->need_refresh = true; #endif From 45814696a6c228197b3e1cb579bbd0f53dcc6cde Mon Sep 17 00:00:00 2001 From: twinaphex Date: Sun, 11 Jan 2015 18:43:18 +0100 Subject: [PATCH 052/156] menu_entries.c - some cleanups and documentation --- menu/menu_entries.c | 120 ++++++++++++++++++++++++++++++-------------- menu/menu_entries.h | 8 +++ 2 files changed, 89 insertions(+), 39 deletions(-) diff --git a/menu/menu_entries.c b/menu/menu_entries.c index be689459cd..a31fe46121 100644 --- a/menu/menu_entries.c +++ b/menu/menu_entries.c @@ -38,25 +38,44 @@ void menu_entries_refresh(file_list_t *list) menu_navigation_clear(driver.menu, true); } -static inline bool entries_list_elem_is_dir(file_list_t *buf, +/** + * menu_entries_list_elem_is_dir: + * @list : File list handle. + * @offset : Offset index of element. + * + * Is the current entry at offset @offset a directory? + * + * Returns: true (1) if entry is a directory, otherwise false (0). + **/ +static inline bool menu_entries_list_elem_is_dir(file_list_t *list, unsigned offset) { const char *path = NULL; const char *label = NULL; unsigned type = 0; - menu_list_get_at_offset(buf, offset, &path, &label, &type); + menu_list_get_at_offset(list, offset, &path, &label, &type); return type != MENU_FILE_PLAIN; } -static inline int entries_list_get_first_char(file_list_t *buf, - unsigned offset) +/** + * menu_entries_list_get_first_char: + * @list : File list handle. + * @offset : Offset index of element. + * + * Gets the first character of an element in the + * file list. + * + * Returns: first character of element in file list. + **/ +static inline int menu_entries_list_get_first_char( + file_list_t *list, unsigned offset) { int ret; const char *path = NULL; - menu_list_get_alt_at_offset(buf, offset, &path); + menu_list_get_alt_at_offset(list, offset, &path); ret = tolower(*path); /* "Normalize" non-alphabetical entries so they @@ -83,13 +102,13 @@ void menu_entries_build_scroll_indices(file_list_t *list) driver.menu->scroll_indices[driver.menu->scroll_indices_size++] = 0; - current = entries_list_get_first_char(list, 0); - current_is_dir = entries_list_elem_is_dir(list, 0); + current = menu_entries_list_get_first_char(list, 0); + current_is_dir = menu_entries_list_elem_is_dir(list, 0); for (i = 1; i < list->size; i++) { - int first = entries_list_get_first_char(list, i); - bool is_dir = entries_list_elem_is_dir(list, i); + int first = menu_entries_list_get_first_char(list, i); + bool is_dir = menu_entries_list_elem_is_dir(list, i); if ((current_is_dir && !is_dir) || (first > current)) driver.menu->scroll_indices[driver.menu->scroll_indices_size++] = i; @@ -109,21 +128,19 @@ int menu_entries_setting_set_flags(rarch_setting_t *setting) if (setting->flags & SD_FLAG_IS_DRIVER) return MENU_SETTING_DRIVER; - else + + switch (setting->type) { - switch (setting->type) - { - case ST_ACTION: - return MENU_SETTING_ACTION; - case ST_PATH: - return MENU_FILE_PATH; - case ST_GROUP: - return MENU_SETTING_GROUP; - case ST_SUB_GROUP: - return MENU_SETTING_SUBGROUP; - default: - break; - } + case ST_ACTION: + return MENU_SETTING_ACTION; + case ST_PATH: + return MENU_FILE_PATH; + case ST_GROUP: + return MENU_SETTING_GROUP; + case ST_SUB_GROUP: + return MENU_SETTING_SUBGROUP; + default: + break; } return 0; @@ -165,9 +182,10 @@ int menu_entries_push_main_menu_list(menu_handle_t *menu, return 0; } -static void content_list_push(void *data, core_info_t *info, const char* path) +static void menu_entries_content_list_push( + void *data, core_info_t *info, const char* path) { - int num_items, j; + int num_items = 0, j; struct string_list *list = NULL; file_list_t *flist = (file_list_t*)data; @@ -178,12 +196,13 @@ static void content_list_push(void *data, core_info_t *info, const char* path) dir_list_sort(list, true); - num_items = list ? list->size : 0; + if (list) + num_items = list->size; for (j = 0; j < num_items; j++) { if (list->elems[j].attr.i == RARCH_DIRECTORY) - content_list_push(flist, info, list->elems[j].data); + menu_entries_content_list_push(flist, info, list->elems[j].data); else menu_list_push( flist, @@ -217,7 +236,7 @@ int menu_entries_push_horizontal_menu_list(menu_handle_t *menu, return -1; if (!info->supports_no_game) - content_list_push(list, info, g_settings.content_directory); + menu_entries_content_list_push(list, info, g_settings.content_directory); else menu_list_push( list, @@ -236,7 +255,15 @@ int menu_entries_push_horizontal_menu_list(menu_handle_t *menu, return 0; } -static void parse_drive_list(file_list_t *list) +/** + * menu_entries_parse_drive_list: + * @list : File list handle. + * + * Generates default directory drive list. + * Platform-specific. + * + **/ +static void menu_entries_parse_drive_list(file_list_t *list) { size_t i = 0; @@ -322,31 +349,35 @@ static void parse_drive_list(file_list_t *list) #endif } -int menu_entries_parse_list(file_list_t *list, file_list_t *menu_list, +int menu_entries_parse_list( + file_list_t *list, file_list_t *menu_list, const char *dir, const char *label, unsigned type, unsigned default_type_plain, const char *exts, rarch_setting_t *setting) { + int device; size_t i, list_size; bool path_is_compressed, push_dir; struct string_list *str_list = NULL; + (void)device; + menu_list_clear(list); if (!*dir) { - parse_drive_list(list); + menu_entries_parse_drive_list(list); if (driver.menu_ctx && driver.menu_ctx->populate_entries) driver.menu_ctx->populate_entries(driver.menu, dir, label, type); return 0; } #if defined(GEKKO) && defined(HW_RVL) LWP_MutexLock(gx_device_mutex); - int dev = gx_get_device_from_path(dir); + device = gx_get_device_from_path(dir); - if (dev != -1 && !gx_devices[dev].mounted && - gx_devices[dev].interface->isInserted()) - fatMountSimple(gx_devices[dev].name, gx_devices[dev].interface); + if (device != -1 && !gx_devices[device].mounted && + gx_devices[device].interface->isInserted()) + fatMountSimple(gx_devices[device].name, gx_devices[device].interface); LWP_MutexUnlock(gx_device_mutex); #endif @@ -357,7 +388,9 @@ int menu_entries_parse_list(file_list_t *list, file_list_t *menu_list, if (path_is_compressed) str_list = compressed_file_list_new(dir,exts); else - str_list = dir_list_new(dir, g_settings.menu.navigation.browser.filter.supported_extensions_enable ? exts : NULL, true); + str_list = dir_list_new(dir, + g_settings.menu.navigation.browser.filter.supported_extensions_enable + ? exts : NULL, true); if (!str_list) return -1; @@ -452,6 +485,7 @@ int menu_entries_parse_list(file_list_t *list, file_list_t *menu_list, const char *path = NULL; menu_list_get_at_offset(list, i, &path, NULL, &type); + if (type != MENU_FILE_CORE) continue; @@ -492,12 +526,20 @@ int menu_entries_deferred_push(file_list_t *list, file_list_t *menu_list) cbs = (menu_file_list_cbs_t*) menu_list_get_last_stack_actiondata(driver.menu->menu_list); - if (cbs->action_deferred_push) - return cbs->action_deferred_push(list, menu_list, path, label, type); + if (!cbs->action_deferred_push) + return 0; - return 0; + return cbs->action_deferred_push(list, menu_list, path, label, type); } +/** + * menu_entries_init: + * @menu : Menu handle. + * + * Creates and initializes menu entries. + * + * Returns: true (1) if successful, otherwise false (0). + **/ bool menu_entries_init(menu_handle_t *menu) { if (!menu) diff --git a/menu/menu_entries.h b/menu/menu_entries.h index d6831a733c..e1e49768c9 100644 --- a/menu/menu_entries.h +++ b/menu/menu_entries.h @@ -33,6 +33,14 @@ int menu_entries_parse_list(file_list_t *list, file_list_t *menu_list, int menu_entries_deferred_push(file_list_t *list, file_list_t *menu_list); +/** + * menu_entries_init: + * @menu : Menu handle. + * + * Creates and initializes menu entries. + * + * Returns: true (1) if successful, otherwise false (0). + **/ bool menu_entries_init(menu_handle_t *menu); void menu_entries_refresh(file_list_t *list); From 7168f995692a4ff9ae29d5e6c91031417c1150b2 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Sun, 11 Jan 2015 18:47:56 +0100 Subject: [PATCH 053/156] menu_entries.c - cleanups --- menu/menu_entries.c | 27 +++++++++++++-------------- 1 file changed, 13 insertions(+), 14 deletions(-) diff --git a/menu/menu_entries.c b/menu/menu_entries.c index a31fe46121..b44eaf28f6 100644 --- a/menu/menu_entries.c +++ b/menu/menu_entries.c @@ -50,9 +50,9 @@ void menu_entries_refresh(file_list_t *list) static inline bool menu_entries_list_elem_is_dir(file_list_t *list, unsigned offset) { - const char *path = NULL; + const char *path = NULL; const char *label = NULL; - unsigned type = 0; + unsigned type = 0; menu_list_get_at_offset(list, offset, &path, &label, &type); @@ -183,36 +183,35 @@ int menu_entries_push_main_menu_list(menu_handle_t *menu, } static void menu_entries_content_list_push( - void *data, core_info_t *info, const char* path) + file_list_t *list, core_info_t *info, const char* path) { int num_items = 0, j; - struct string_list *list = NULL; - file_list_t *flist = (file_list_t*)data; + struct string_list *str_list = NULL; if (!info) return; - list = (struct string_list*)dir_list_new(path, info->supported_extensions, true); + str_list = (struct string_list*)dir_list_new(path, info->supported_extensions, true); - dir_list_sort(list, true); + dir_list_sort(str_list, true); - if (list) - num_items = list->size; + if (str_list) + num_items = str_list->size; for (j = 0; j < num_items; j++) { - if (list->elems[j].attr.i == RARCH_DIRECTORY) - menu_entries_content_list_push(flist, info, list->elems[j].data); + if (str_list->elems[j].attr.i == RARCH_DIRECTORY) + menu_entries_content_list_push(list, info, str_list->elems[j].data); else menu_list_push( - flist, - path_basename(list->elems[j].data), + list, + path_basename(str_list->elems[j].data), "content_actions", MENU_FILE_CONTENTLIST_ENTRY, 0); } - string_list_free(list); + string_list_free(str_list); } int menu_entries_push_horizontal_menu_list(menu_handle_t *menu, From 1980fa065f09cc0fb00b5c6c44ade69801e0d954 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Sun, 11 Jan 2015 18:51:28 +0100 Subject: [PATCH 054/156] Move menu_action_t enum to menu_input.h --- menu/menu.h | 19 ------------------- menu/menu_input.h | 19 +++++++++++++++++++ 2 files changed, 19 insertions(+), 19 deletions(-) diff --git a/menu/menu.h b/menu/menu.h index 174c702ed5..762748aaf9 100644 --- a/menu/menu.h +++ b/menu/menu.h @@ -94,25 +94,6 @@ typedef enum MENU_FILE_TYPE_T_LAST, } menu_file_type_t; -typedef enum -{ - MENU_ACTION_UP, - MENU_ACTION_DOWN, - MENU_ACTION_LEFT, - MENU_ACTION_RIGHT, - MENU_ACTION_OK, - MENU_ACTION_Y, - MENU_ACTION_CANCEL, - MENU_ACTION_REFRESH, - MENU_ACTION_SELECT, - MENU_ACTION_START, - MENU_ACTION_MESSAGE, - MENU_ACTION_SCROLL_DOWN, - MENU_ACTION_SCROLL_UP, - MENU_ACTION_TOGGLE, - MENU_ACTION_NOOP -} menu_action_t; - typedef enum { MENU_SETTINGS_VIDEO_RESOLUTION = MENU_FILE_TYPE_T_LAST + 1, diff --git a/menu/menu_input.h b/menu/menu_input.h index fc3b90b5cf..d974e9be69 100644 --- a/menu/menu_input.h +++ b/menu/menu_input.h @@ -24,6 +24,25 @@ extern "C" { #endif +typedef enum +{ + MENU_ACTION_UP, + MENU_ACTION_DOWN, + MENU_ACTION_LEFT, + MENU_ACTION_RIGHT, + MENU_ACTION_OK, + MENU_ACTION_Y, + MENU_ACTION_CANCEL, + MENU_ACTION_REFRESH, + MENU_ACTION_SELECT, + MENU_ACTION_START, + MENU_ACTION_MESSAGE, + MENU_ACTION_SCROLL_DOWN, + MENU_ACTION_SCROLL_UP, + MENU_ACTION_TOGGLE, + MENU_ACTION_NOOP +} menu_action_t; + void menu_input_key_event(bool down, unsigned keycode, uint32_t character, uint16_t key_modifiers); From 59e6cce3569101ccf5882fb99d0fa03b435c3207 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Sun, 11 Jan 2015 19:21:03 +0100 Subject: [PATCH 055/156] Cleanups in zip_support.c --- decompress/zip_support.c | 132 ++++++++++++++++++++++----------------- 1 file changed, 75 insertions(+), 57 deletions(-) diff --git a/decompress/zip_support.c b/decompress/zip_support.c index 6f44e9b381..df903997c0 100644 --- a/decompress/zip_support.c +++ b/decompress/zip_support.c @@ -44,9 +44,12 @@ int read_zip_file(const char * archive_path, const char *relative_path, void **buf, const char* optional_outfile) { + uLong i; + unz_global_info global_info; ssize_t bytes_read = -1; bool finished_reading = false; unzFile *zipfile = (unzFile*)unzOpen( archive_path ); + if (!zipfile) { RARCH_ERR("Could not open ZIP file %s.\n",archive_path); @@ -54,24 +57,23 @@ int read_zip_file(const char * archive_path, } /* Get info about the zip file */ - unz_global_info global_info; - if ( unzGetGlobalInfo( zipfile, &global_info ) != UNZ_OK ) + if (unzGetGlobalInfo(zipfile, &global_info) != UNZ_OK) { RARCH_ERR("Could not get global ZIP file info of %s." "Could be only a GZIP file without the ZIP part.\n", archive_path); - unzClose( zipfile ); + unzClose(zipfile); return -1; } - /* Loop to extract all files */ - uLong i; for ( i = 0; i < global_info.number_entry; ++i ) { /* Get info about current file. */ unz_file_info file_info; char filename[PATH_MAX_LENGTH]; - if ( unzGetCurrentFileInfo( + char last_char = ' '; + + if (unzGetCurrentFileInfo( zipfile, &file_info, filename, @@ -80,12 +82,11 @@ int read_zip_file(const char * archive_path, { RARCH_ERR("Could not read file info in ZIP %s.\n", archive_path); - unzClose( zipfile ); + unzClose(zipfile); return -1; } /* Check if this entry is a directory or file. */ - char last_char = ' '; last_char = filename[strlen(filename)-1]; if ( last_char == '/' || last_char == '\\' ) { @@ -94,11 +95,11 @@ int read_zip_file(const char * archive_path, else if (strcmp(filename,relative_path) == 0) { /* We found the correct file in the zip, now extract it to *buf */ - if ( unzOpenCurrentFile( zipfile ) != UNZ_OK ) + if (unzOpenCurrentFile(zipfile) != UNZ_OK ) { RARCH_ERR("The file %s in %s could not be read.\n", relative_path, archive_path); - unzClose( zipfile ); + unzClose(zipfile); return -1; } @@ -109,26 +110,30 @@ int read_zip_file(const char * archive_path, if (outsink == NULL) { RARCH_ERR("Could not open outfilepath %s.\n", optional_outfile); - unzCloseCurrentFile( zipfile ); - unzClose( zipfile ); + unzCloseCurrentFile(zipfile); + unzClose(zipfile); return -1; } bytes_read = 0; do { - bytes_read = unzReadCurrentFile( zipfile, read_buffer, + ssize_t fwrite_bytes; + + bytes_read = unzReadCurrentFile(zipfile, read_buffer, RARCH_ZIP_SUPPORT_BUFFER_SIZE_MAX ); - ssize_t fwrite_bytes = fwrite(read_buffer,1,bytes_read,outsink); - if (fwrite_bytes != bytes_read) - { - /* couldn't write all bytes */ - RARCH_ERR("Error writing to %s.\n",optional_outfile); - fclose(outsink); - unzCloseCurrentFile( zipfile ); - unzClose( zipfile ); - return -1; - } - } while(bytes_read > 0) ; + fwrite_bytes = fwrite(read_buffer,1,bytes_read,outsink); + + if (fwrite_bytes == bytes_read) + continue; + + /* couldn't write all bytes */ + RARCH_ERR("Error writing to %s.\n",optional_outfile); + fclose(outsink); + unzCloseCurrentFile(zipfile); + unzClose(zipfile); + return -1; + }while(bytes_read > 0); + fclose(outsink); } else @@ -136,7 +141,8 @@ int read_zip_file(const char * archive_path, /* Allocate outbuffer */ *buf = malloc(file_info.uncompressed_size + 1 ); - bytes_read = unzReadCurrentFile( zipfile, *buf, file_info.uncompressed_size ); + bytes_read = unzReadCurrentFile(zipfile, *buf, file_info.uncompressed_size); + if (bytes_read != (ssize_t)file_info.uncompressed_size) { RARCH_ERR( @@ -144,42 +150,53 @@ int read_zip_file(const char * archive_path, (unsigned int) file_info.uncompressed_size, (int)bytes_read, relative_path, archive_path); free(*buf); - unzCloseCurrentFile( zipfile ); - unzClose( zipfile ); + unzCloseCurrentFile(zipfile); + unzClose(zipfile); + return -1; } ((char*)(*buf))[file_info.uncompressed_size] = '\0'; } finished_reading = true; } - unzCloseCurrentFile( zipfile ); + + unzCloseCurrentFile(zipfile); + if (finished_reading) break; - if ( ( i+1 ) < global_info.number_entry ) + if ((i + 1) < global_info.number_entry) { - if ( unzGoToNextFile( zipfile ) != UNZ_OK ) - { - RARCH_ERR( - "Could not iterate to next file in %s. ZIP file might be corrupt.\n", - archive_path ); - unzClose( zipfile ); - return -1; - } + if (unzGoToNextFile(zipfile) == UNZ_OK) + continue; + + RARCH_ERR( + "Could not iterate to next file in %s. ZIP file might be corrupt.\n", + archive_path ); + unzClose(zipfile); + return -1; } } - unzClose( zipfile ); + + unzClose(zipfile); + if(!finished_reading) { RARCH_ERR("File %s not found in %s\n", relative_path, archive_path); return -1; } + return bytes_read; } struct string_list *compressed_zip_file_list_new(const char *path, const char* ext) { + uLong i; + unz_global_info global_info; + unzFile *zipfile = NULL; + ssize_t bytes_read = -1; + bool finished_reading = false; struct string_list *ext_list = NULL; struct string_list *list = string_list_new(); @@ -189,10 +206,7 @@ struct string_list *compressed_zip_file_list_new(const char *path, if (ext) ext_list = string_split(ext, "|"); - - ssize_t bytes_read = -1; - bool finished_reading = false; - unzFile *zipfile = (unzFile*)unzOpen( path ); + zipfile = (unzFile*)unzOpen( path ); (void)finished_reading; (void)bytes_read; @@ -206,42 +220,41 @@ struct string_list *compressed_zip_file_list_new(const char *path, } /* Get info about the zip file */ - unz_global_info global_info; - if ( unzGetGlobalInfo( zipfile, &global_info ) != UNZ_OK ) + if (unzGetGlobalInfo(zipfile, &global_info) != UNZ_OK) { RARCH_ERR("Could not get global zipfile info of %s." "Could be only a GZIP file without the ZIP part.\n", path); - unzClose( zipfile ); + unzClose(zipfile); string_list_free(list); string_list_free(ext_list); return NULL; } - /* Loop to extract all files */ - uLong i; for ( i = 0; i < global_info.number_entry; ++i ) { /* Get info about current file. */ unz_file_info file_info; char filename[PATH_MAX_LENGTH]; - if ( unzGetCurrentFileInfo( + char last_char = ' '; + + if (unzGetCurrentFileInfo( zipfile, &file_info, filename, PATH_MAX_LENGTH, - NULL, 0, NULL, 0 ) != UNZ_OK ) + NULL, 0, NULL, 0 ) != UNZ_OK) { RARCH_ERR("Could not read file info in ZIP %s.\n", path); - unzClose( zipfile ); + unzClose(zipfile); string_list_free(list); string_list_free(ext_list); return NULL; } /* Check if this entry is a directory or file. */ - char last_char = ' '; last_char = filename[strlen(filename)-1]; + if ( last_char == '/' || last_char == '\\' ) { /* We skip directories */ @@ -251,6 +264,7 @@ struct string_list *compressed_zip_file_list_new(const char *path, const char *file_ext = path_get_extension(filename); bool supported_by_core = false; union string_list_elem_attr attr; + if (string_list_find_elem_prefix(ext_list, ".", file_ext)) supported_by_core = true; @@ -260,26 +274,30 @@ struct string_list *compressed_zip_file_list_new(const char *path, if (!string_list_append(list, filename, attr)) { RARCH_ERR("Could not append item to string list.\n"); - unzCloseCurrentFile( zipfile ); + unzCloseCurrentFile(zipfile); break; } } } - unzCloseCurrentFile( zipfile ); - if ( ( i+1 ) < global_info.number_entry ) + + unzCloseCurrentFile(zipfile); + + if ((i + 1) < global_info.number_entry) { - if ( unzGoToNextFile( zipfile ) != UNZ_OK ) + if (unzGoToNextFile(zipfile) != UNZ_OK ) { RARCH_ERR( "Could not iterate to next file in %s. ZIP file might be corrupt.\n",path ); - unzClose( zipfile ); + unzClose(zipfile); string_list_free(list); string_list_free(ext_list); return NULL; } } } - unzClose( zipfile ); + + unzClose(zipfile); + return list; } From fa4a0de222bed7fd936a5a267e66514b50b1e0cf Mon Sep 17 00:00:00 2001 From: twinaphex Date: Sun, 11 Jan 2015 19:31:34 +0100 Subject: [PATCH 056/156] Cleanups in gfx_get_fps --- gfx/gfx_common.c | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/gfx/gfx_common.c b/gfx/gfx_common.c index 193667f4b9..bd7645098c 100644 --- a/gfx/gfx_common.c +++ b/gfx/gfx_common.c @@ -39,15 +39,17 @@ **/ bool gfx_get_fps(char *buf, size_t size, char *buf_fps, size_t size_fps) { + retro_time_t new_time; static retro_time_t curr_time; static retro_time_t fps_time; static float last_fps; - bool ret = false; *buf = '\0'; - retro_time_t new_time = rarch_get_time_usec(); + new_time = rarch_get_time_usec(); + if (g_extern.frame_count) { + bool ret = false; unsigned write_index = g_extern.measure_data.frame_time_samples_count++ & (MEASURE_FRAME_TIME_SAMPLES_COUNT - 1); @@ -68,17 +70,16 @@ bool gfx_get_fps(char *buf, size_t size, char *buf_fps, size_t size_fps) if (buf_fps) snprintf(buf_fps, size_fps, "FPS: %6.1f || Frames: %u", last_fps, g_extern.frame_count); - } - else - { - curr_time = fps_time = new_time; - strlcpy(buf, g_extern.title_buf, size); - if (buf_fps) - strlcpy(buf_fps, "N/A", size_fps); - ret = true; + + return ret; } - return ret; + curr_time = fps_time = new_time; + strlcpy(buf, g_extern.title_buf, size); + if (buf_fps) + strlcpy(buf_fps, "N/A", size_fps); + + return true; } #if defined(_WIN32) && !defined(_XBOX) From 72f5e9a7163fc0be020ed8c2a3cad6ca93b0000d Mon Sep 17 00:00:00 2001 From: twinaphex Date: Sun, 11 Jan 2015 19:52:02 +0100 Subject: [PATCH 057/156] Small cleanups --- gfx/gl.c | 37 ++++++++++++++++++++----------------- gfx/shader/shader_gl_cg.c | 1 + gfx/shader/shader_glsl.c | 16 ++++++++-------- 3 files changed, 29 insertions(+), 25 deletions(-) diff --git a/gfx/gl.c b/gfx/gl.c index 7f24ab0c82..0982297a72 100644 --- a/gfx/gl.c +++ b/gfx/gl.c @@ -847,8 +847,8 @@ void gl_set_viewport(gl_t *gl, unsigned width, } else { - gl->vp.x = gl->vp.y = 0; - gl->vp.width = width; + gl->vp.x = gl->vp.y = 0; + gl->vp.width = width; gl->vp.height = height; } @@ -1249,12 +1249,12 @@ static void gl_init_textures(gl_t *gl, const video_info_t *video) gl->tex_w * gl->base_size, gl->tex_w * gl->tex_h * i * gl->base_size); #else - if (!gl->egl_images) - { - glTexImage2D(GL_TEXTURE_2D, - 0, internal_fmt, gl->tex_w, gl->tex_h, 0, texture_type, - texture_fmt, gl->empty_buf ? gl->empty_buf : NULL); - } + if (gl->egl_images) + continue; + + glTexImage2D(GL_TEXTURE_2D, + 0, internal_fmt, gl->tex_w, gl->tex_h, 0, texture_type, + texture_fmt, gl->empty_buf ? gl->empty_buf : NULL); #endif } glBindTexture(GL_TEXTURE_2D, gl->texture[gl->tex_index]); @@ -1914,8 +1914,10 @@ static bool resolve_extensions(gl_t *gl) const char *ext = (const char*)glGetString(GL_EXTENSIONS); if (ext) { + size_t i; struct string_list *list = string_split(ext, " "); - for (size_t i = 0; i < list->size; i++) + + for (i = 0; i < list->size; i++) RARCH_LOG("\t%s\n", list->elems[i].data); string_list_free(list); } @@ -2368,6 +2370,7 @@ static void *gl_init(const video_info_t *video, const input_driver_t **input, vo #if !defined(HAVE_PSGL) gl->conv_buffer = calloc(sizeof(uint32_t), gl->tex_w * gl->tex_h); + if (!gl->conv_buffer) { gl->ctx_driver->destroy(gl); @@ -2489,14 +2492,14 @@ static void gl_update_tex_filter_frame(gl_t *gl) gl->wrap_mode = wrap_mode; for (i = 0; i < gl->textures; i++) { - if (gl->texture[i]) - { - glBindTexture(GL_TEXTURE_2D, gl->texture[i]); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, gl->wrap_mode); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, gl->wrap_mode); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, gl->tex_mag_filter); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, gl->tex_min_filter); - } + if (!gl->texture[i]) + continue; + + glBindTexture(GL_TEXTURE_2D, gl->texture[i]); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, gl->wrap_mode); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, gl->wrap_mode); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, gl->tex_mag_filter); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, gl->tex_min_filter); } glBindTexture(GL_TEXTURE_2D, gl->texture[gl->tex_index]); diff --git a/gfx/shader/shader_gl_cg.c b/gfx/shader/shader_gl_cg.c index 65e33e488d..48b8c57994 100644 --- a/gfx/shader/shader_gl_cg.c +++ b/gfx/shader/shader_gl_cg.c @@ -332,6 +332,7 @@ static void gl_cg_set_params(void *data, unsigned width, unsigned height, CGparameter vparam = cgGetNamedParameter( cg->prg[cg->active_idx].vprg, cg->cg_shader->lut[i].id); + if (vparam) { cgGLSetTextureParameter(vparam, cg->lut_textures[i]); diff --git a/gfx/shader/shader_glsl.c b/gfx/shader/shader_glsl.c index 0bf4f5c099..4666c8cdab 100644 --- a/gfx/shader/shader_glsl.c +++ b/gfx/shader/shader_glsl.c @@ -986,14 +986,14 @@ static void gl_glsl_set_params(void *data, unsigned width, unsigned height, for (i = 0; i < glsl->glsl_shader->luts; i++) { - if (uni->lut_texture[i] >= 0) - { - /* Have to rebind as HW render could override this. */ - glActiveTexture(GL_TEXTURE0 + texunit); - glBindTexture(GL_TEXTURE_2D, glsl->gl_teximage[i]); - glUniform1i(uni->lut_texture[i], texunit); - texunit++; - } + if (uni->lut_texture[i] < 0) + continue; + + /* Have to rebind as HW render could override this. */ + glActiveTexture(GL_TEXTURE0 + texunit); + glBindTexture(GL_TEXTURE_2D, glsl->gl_teximage[i]); + glUniform1i(uni->lut_texture[i], texunit); + texunit++; } /* Set original texture. */ From 33291c348670a615e0f53ae50ed75ac5d7637176 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Sun, 11 Jan 2015 19:59:59 +0100 Subject: [PATCH 058/156] Start documenting shader_parse.c --- gfx/shader/shader_parse.c | 87 ++++++++++++++++++++++++++++++++------- gfx/shader/shader_parse.h | 9 ++++ 2 files changed, 80 insertions(+), 16 deletions(-) diff --git a/gfx/shader/shader_parse.c b/gfx/shader/shader_parse.c index 81adaaedc3..0c316670e0 100644 --- a/gfx/shader/shader_parse.c +++ b/gfx/shader/shader_parse.c @@ -23,6 +23,14 @@ #include #include "../../general.h" +/** + * wrap_mode_to_str: + * @type : Wrap type. + * + * Translates wrap mode to human-readable string identifier. + * + * Returns: human-readable string identifier of wrap mode. + **/ static const char *wrap_mode_to_str(enum gfx_wrap_type type) { switch (type) @@ -40,6 +48,14 @@ static const char *wrap_mode_to_str(enum gfx_wrap_type type) } } +/** + * wrap_str_to_mode: + * @type : Wrap type in human-readable string format. + * + * Translates wrap mode from human-readable string to enum mode value. + * + * Returns: enum mode value of wrap type. + **/ static enum gfx_wrap_type wrap_str_to_mode(const char *wrap_mode) { if (strcmp(wrap_mode, "clamp_to_border") == 0) @@ -56,7 +72,16 @@ static enum gfx_wrap_type wrap_str_to_mode(const char *wrap_mode) return RARCH_WRAP_DEFAULT; } -/* CGP */ +/** + * shader_parse_pass: + * @conf : Preset file to read from. + * @pass : Shader passes handle. + * @i : Index of shader pass. + * + * Parses shader pass from preset file. + * + * Returns: true (1) if successful, otherwise false (0). + **/ static bool shader_parse_pass(config_file_t *conf, struct gfx_shader_pass *pass, unsigned i) { char shader_name[64], filter_name_buf[64], wrap_name_buf[64], wrap_mode[64]; @@ -218,6 +243,15 @@ static bool shader_parse_pass(config_file_t *conf, struct gfx_shader_pass *pass, return true; } +/** + * shader_parse_textures: + * @conf : Preset file to read from. + * @shader : Shader pass handle. + * + * Parses shader textures. + * + * Returns: true (1) if successful, otherwise false (0). + **/ static bool shader_parse_textures(config_file_t *conf, struct gfx_shader *shader) { @@ -268,7 +302,17 @@ static bool shader_parse_textures(config_file_t *conf, return true; } -static struct gfx_shader_parameter *find_parameter( +/** + * shader_parse_find_parameter: + * @params : Shader parameter handle. + * @num_params : Number of shader params in @params. + * @id : Identifier to search for. + * + * Finds a shader parameter with identifier @id in @params.. + * + * Returns: handle to shader parameter if successful, otherwise NULL. + **/ +static struct gfx_shader_parameter *shader_parse_find_parameter( struct gfx_shader_parameter *params, unsigned num_params, const char *id) { unsigned i; @@ -278,9 +322,19 @@ static struct gfx_shader_parameter *find_parameter( if (!strcmp(params[i].id, id)) return ¶ms[i]; } + return NULL; } +/** + * gfx_shader_resolve_parameters: + * @conf : Preset file to read from. + * @shader : Shader passes handle. + * + * Resolves all shader parameters belonging to shaders. + * + * Returns: true (1) if successful, otherwise false (0). + **/ bool gfx_shader_resolve_parameters(config_file_t *conf, struct gfx_shader *shader) { @@ -292,6 +346,7 @@ bool gfx_shader_resolve_parameters(config_file_t *conf, &shader->parameters[shader->num_parameters]; /* Find all parameters in our shaders. */ + for (i = 0; i < shader->passes; i++) { char line[4096]; @@ -308,22 +363,22 @@ bool gfx_shader_resolve_parameters(config_file_t *conf, param->id, param->desc, ¶m->initial, ¶m->minimum, ¶m->maximum, ¶m->step); - if (ret >= 5) - { - param->id[63] = '\0'; - param->desc[63] = '\0'; + if (ret < 5) + continue; - if (ret == 5) - param->step = 0.1f * (param->maximum - param->minimum); + param->id[63] = '\0'; + param->desc[63] = '\0'; - RARCH_LOG("Found #pragma parameter %s (%s) %f %f %f %f\n", - param->desc, param->id, param->initial, - param->minimum, param->maximum, param->step); - param->current = param->initial; + if (ret == 5) + param->step = 0.1f * (param->maximum - param->minimum); - shader->num_parameters++; - param++; - } + RARCH_LOG("Found #pragma parameter %s (%s) %f %f %f %f\n", + param->desc, param->id, param->initial, + param->minimum, param->maximum, param->step); + param->current = param->initial; + + shader->num_parameters++; + param++; } fclose(file); @@ -344,7 +399,7 @@ bool gfx_shader_resolve_parameters(config_file_t *conf, id = strtok_r(NULL, ";", &save)) { struct gfx_shader_parameter *parameter = (struct gfx_shader_parameter*) - find_parameter(shader->parameters, shader->num_parameters, id); + shader_parsefind_parameter(shader->parameters, shader->num_parameters, id); if (!parameter) { diff --git a/gfx/shader/shader_parse.h b/gfx/shader/shader_parse.h index df1d7768eb..76bae97e6f 100644 --- a/gfx/shader/shader_parse.h +++ b/gfx/shader/shader_parse.h @@ -161,6 +161,15 @@ void gfx_shader_write_conf_cgp(config_file_t *conf, void gfx_shader_resolve_relative(struct gfx_shader *shader, const char *ref_path); +/** + * gfx_shader_resolve_parameters: + * @conf : Preset file to read from. + * @shader : Shader passes handle. + * + * Resolves all shader parameters belonging to shaders. + * + * Returns: true (1) if successful, otherwise false (0). + **/ bool gfx_shader_resolve_parameters(config_file_t *conf, struct gfx_shader *shader); From 78992901565e3efe999fe0d71f756b8e8d3a54f2 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Sun, 11 Jan 2015 20:10:01 +0100 Subject: [PATCH 059/156] (shader_parse.c) Some more documentation --- gfx/shader/shader_parse.c | 24 ++++++++++++++++++++++-- gfx/shader/shader_parse.h | 19 +++++++++++++++++++ 2 files changed, 41 insertions(+), 2 deletions(-) diff --git a/gfx/shader/shader_parse.c b/gfx/shader/shader_parse.c index 0c316670e0..afe084a629 100644 --- a/gfx/shader/shader_parse.c +++ b/gfx/shader/shader_parse.c @@ -384,9 +384,9 @@ bool gfx_shader_resolve_parameters(config_file_t *conf, fclose(file); } - /* Read in parameters which override the defaults. */ if (conf) { + /* Read in parameters which override the defaults. */ char parameters[4096]; const char *id; char *save = NULL; @@ -399,7 +399,7 @@ bool gfx_shader_resolve_parameters(config_file_t *conf, id = strtok_r(NULL, ";", &save)) { struct gfx_shader_parameter *parameter = (struct gfx_shader_parameter*) - shader_parsefind_parameter(shader->parameters, shader->num_parameters, id); + shader_parse_find_parameter(shader->parameters, shader->num_parameters, id); if (!parameter) { @@ -775,10 +775,22 @@ void gfx_shader_write_conf_cgp(config_file_t *conf, } } +/** + * gfx_shader_parse_type: + * @path : Shader path. + * @fallback : Fallback shader type in case no + * type could be found. + * + * Parses type of shader. + * + * Returns: value of shader type on success, otherwise will return + * user-supplied @fallback value. + **/ enum rarch_shader_type gfx_shader_parse_type(const char *path, enum rarch_shader_type fallback) { const char *ext = NULL; + if (!path) return fallback; @@ -792,6 +804,14 @@ enum rarch_shader_type gfx_shader_parse_type(const char *path, return fallback; } +/** + * gfx_shader_resolve_relative: + * @shader : Shader pass handle. + * @ref_path : Relative shader path. + * + * Resolves relative shader path (@ref_path) into absolute + * shader paths. + **/ void gfx_shader_resolve_relative(struct gfx_shader *shader, const char *ref_path) { diff --git a/gfx/shader/shader_parse.h b/gfx/shader/shader_parse.h index 76bae97e6f..d18e9bd113 100644 --- a/gfx/shader/shader_parse.h +++ b/gfx/shader/shader_parse.h @@ -158,6 +158,14 @@ bool gfx_shader_read_conf_cgp(config_file_t *conf, void gfx_shader_write_conf_cgp(config_file_t *conf, struct gfx_shader *shader); +/** + * gfx_shader_resolve_relative: + * @shader : Shader pass handle. + * @ref_path : Relative shader path. + * + * Resolves relative shader path (@ref_path) into absolute + * shader paths. + **/ void gfx_shader_resolve_relative(struct gfx_shader *shader, const char *ref_path); @@ -173,6 +181,17 @@ void gfx_shader_resolve_relative(struct gfx_shader *shader, bool gfx_shader_resolve_parameters(config_file_t *conf, struct gfx_shader *shader); +/** + * gfx_shader_parse_type: + * @path : Shader path. + * @fallback : Fallback shader type in case no + * type could be found. + * + * Parses type of shader. + * + * Returns: value of shader type on success, otherwise will return + * user-supplied @fallback value. + **/ enum rarch_shader_type gfx_shader_parse_type(const char *path, enum rarch_shader_type fallback); From b243f64554d51dfacd4890ff138756f8f6a21132 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Sun, 11 Jan 2015 20:17:45 +0100 Subject: [PATCH 060/156] (shader_parse.c) More documentation --- gfx/shader/shader_parse.c | 47 +++++++++++++++++++++++++++++++++++++-- gfx/shader/shader_parse.h | 18 +++++++++++++++ 2 files changed, 63 insertions(+), 2 deletions(-) diff --git a/gfx/shader/shader_parse.c b/gfx/shader/shader_parse.c index afe084a629..27ed5be10b 100644 --- a/gfx/shader/shader_parse.c +++ b/gfx/shader/shader_parse.c @@ -415,6 +415,15 @@ bool gfx_shader_resolve_parameters(config_file_t *conf, return true; } +/** + * shader_parse_imports: + * @conf : Preset file to read from. + * @shader : Shader passes handle. + * + * Resolves import parameters belonging to shaders. + * + * Returns: true (1) if successful, otherwise false (0). + **/ static bool shader_parse_imports(config_file_t *conf, struct gfx_shader *shader) { @@ -471,6 +480,7 @@ static bool shader_parse_imports(config_file_t *conf, if (var->type != RARCH_STATE_PYTHON) { unsigned input_slot = 0; + if (config_get_uint(conf, input_slot_buf, &input_slot)) { switch (input_slot) @@ -514,6 +524,16 @@ static bool shader_parse_imports(config_file_t *conf, return true; } +/** + * gfx_shader_read_conf_cgp: + * @conf : Preset file to read from. + * @shader : Shader passes handle. + * + * Loads preset file and all associated state (passes, + * textures, imports, etc). + * + * Returns: true (1) if successful, otherwise false (0). + **/ bool gfx_shader_read_conf_cgp(config_file_t *conf, struct gfx_shader *shader) { unsigned shaders, i; @@ -598,7 +618,15 @@ static void shader_write_fbo(config_file_t *conf, shader_write_scale_dim(conf, "y", fbo->type_y, fbo->scale_y, fbo->abs_y, i); } -static const char *import_semantic_to_string(enum state_tracker_type type) +/** + * import_semantic_to_string: + * @type : Import semantic type from state tracker. + * + * Translates import semantic to human-readable string identifier. + * + * Returns: human-readable string identifier of import semantic. + **/ +static const char *import_semantic_to_str(enum state_tracker_type type) { switch (type) { @@ -620,6 +648,13 @@ static const char *import_semantic_to_string(enum state_tracker_type type) } } +/** + * shader_write_variable: + * @conf : Preset file to read from. + * @info : State tracker uniform info handle. + * + * Writes variable to shader preset file. + **/ static void shader_write_variable(config_file_t *conf, const struct state_tracker_uniform_info *info) { @@ -634,7 +669,7 @@ static void shader_write_variable(config_file_t *conf, snprintf(equal_buf, sizeof(equal_buf), "%s_equal", id); config_set_string(conf, semantic_buf, - import_semantic_to_string(info->type)); + import_semantic_to_str(info->type)); config_set_hex(conf, mask_buf, info->mask); config_set_hex(conf, equal_buf, info->equal); @@ -657,6 +692,14 @@ static void shader_write_variable(config_file_t *conf, } } +/** + * gfx_shader_write_conf_cgp: + * @conf : Preset file to read from. + * @shader : Shader passes handle. + * + * Saves preset and all associated state (passes, + * textures, imports, etc) to disk. + **/ void gfx_shader_write_conf_cgp(config_file_t *conf, struct gfx_shader *shader) { diff --git a/gfx/shader/shader_parse.h b/gfx/shader/shader_parse.h index d18e9bd113..c4b97f44fe 100644 --- a/gfx/shader/shader_parse.h +++ b/gfx/shader/shader_parse.h @@ -152,9 +152,27 @@ struct gfx_shader char script_class[512]; }; +/** + * gfx_shader_read_conf_cgp: + * @conf : Preset file to read from. + * @shader : Shader passes handle. + * + * Loads preset file and all associated state (passes, + * textures, imports, etc). + * + * Returns: true (1) if successful, otherwise false (0). + **/ bool gfx_shader_read_conf_cgp(config_file_t *conf, struct gfx_shader *shader); +/** + * gfx_shader_write_conf_cgp: + * @conf : Preset file to read from. + * @shader : Shader passes handle. + * + * Saves preset and all associated state (passes, + * textures, imports, etc) to disk. + **/ void gfx_shader_write_conf_cgp(config_file_t *conf, struct gfx_shader *shader); From f259b56d5f1c8671acdfc6719d16ecf751a9720f Mon Sep 17 00:00:00 2001 From: twinaphex Date: Sun, 11 Jan 2015 20:20:34 +0100 Subject: [PATCH 061/156] Document shader_context.c --- gfx/gfx_context.c | 2 +- gfx/shader/shader_context.c | 17 ++++++++++++++++- gfx/shader/shader_context.h | 15 +++++++++++++++ 3 files changed, 32 insertions(+), 2 deletions(-) diff --git a/gfx/gfx_context.c b/gfx/gfx_context.c index 7d99292cc0..ec0413afc7 100644 --- a/gfx/gfx_context.c +++ b/gfx/gfx_context.c @@ -179,7 +179,7 @@ static const gfx_ctx_driver_t *gfx_ctx_init(void *data, * @hw_render_ctx : Request a graphics context driver capable of * hardware rendering? * - * Finds first suitable graphics context driver and initializes. + * Finds graphics context driver and initializes. * * Returns: graphics context driver if found, otherwise NULL. **/ diff --git a/gfx/shader/shader_context.c b/gfx/shader/shader_context.c index 1d58f16f02..bef65b6cce 100644 --- a/gfx/shader/shader_context.c +++ b/gfx/shader/shader_context.c @@ -35,19 +35,34 @@ static const shader_backend_t *shader_ctx_drivers[] = { NULL }; +/** + * shader_ctx_find_driver: + * @ident : Identifier of shader context driver to find. + * + * Finds shader context driver and initializes. + * + * Returns: shader context driver if found, otherwise NULL. + **/ const shader_backend_t *shader_ctx_find_driver(const char *ident) { unsigned i; for (i = 0; shader_ctx_drivers[i]; i++) { - if (strcmp(shader_ctx_drivers[i]->ident, ident) == 0) + if (!strcmp(shader_ctx_drivers[i]->ident, ident)) return shader_ctx_drivers[i]; } return NULL; } +/** + * shader_ctx_init_first: + * + * Finds first suitable shader context driver and initializes. + * + * Returns: shader context driver if found, otherwise NULL. + **/ const shader_backend_t *shader_ctx_init_first(void) { unsigned i; diff --git a/gfx/shader/shader_context.h b/gfx/shader/shader_context.h index b9237694ba..dccf93b339 100644 --- a/gfx/shader/shader_context.h +++ b/gfx/shader/shader_context.h @@ -84,8 +84,23 @@ extern const shader_backend_t shader_null_backend; #endif +/** + * shader_ctx_find_driver: + * @ident : Identifier of shader context driver to find. + * + * Finds shader context driver and initializes. + * + * Returns: shader context driver if found, otherwise NULL. + **/ const shader_backend_t *shader_ctx_find_driver(const char *ident); +/** + * shader_ctx_init_first: + * + * Finds first suitable shader context driver and initializes. + * + * Returns: shader context driver if found, otherwise NULL. + **/ const shader_backend_t *shader_ctx_init_first(void); #endif From 9ddf9b01cb75cdcc55c85408e625041ac4012b26 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Sun, 11 Jan 2015 21:51:18 +0100 Subject: [PATCH 062/156] (video_thread_wrapper.c) Document video_thread_wrapper.c --- gfx/video_thread_wrapper.c | 26 +++++++++++++++++++++++ gfx/video_thread_wrapper.h | 42 ++++++++++++++++++++++++++++++-------- 2 files changed, 59 insertions(+), 9 deletions(-) diff --git a/gfx/video_thread_wrapper.c b/gfx/video_thread_wrapper.c index c744649424..9ae95cc977 100644 --- a/gfx/video_thread_wrapper.c +++ b/gfx/video_thread_wrapper.c @@ -910,6 +910,20 @@ static void thread_set_callbacks(thread_video_t *thr, thr->video_thread.poke_interface = NULL; } +/** + * rarch_threaded_video_init: + * @out_driver : Output video driver + * @out_data : Output video data + * @input : Input input driver + * @input_data : Input input data + * @driver : Input Video driver + * @info : Video info handle. + * + * Creates, initializes and starts a video driver in a new thread. + * Access to video driver will be mediated through this driver. + * + * Returns: true (1) if successful, otherwise false (0). + **/ bool rarch_threaded_video_init(const video_driver_t **out_driver, void **out_data, const input_driver_t **input, void **input_data, const video_driver_t *drv, const video_info_t *info) @@ -926,6 +940,18 @@ bool rarch_threaded_video_init(const video_driver_t **out_driver, return thread_init(thr, info, input, input_data); } +/** + * rarch_threaded_video_resolve: + * @drv : Found driver. + * + * Gets the underlying video driver associated with the + * threaded video wrapper. Sets @drv to the found + * video driver. + * + * Returns: Video driver data of the video driver associated + * with the threaded wrapper (if successful). If not successful, + * NULL. + **/ void *rarch_threaded_video_resolve(const video_driver_t **drv) { const thread_video_t *thr = (const thread_video_t*)driver.video_data; diff --git a/gfx/video_thread_wrapper.h b/gfx/video_thread_wrapper.h index 057a361024..6f53f2d406 100644 --- a/gfx/video_thread_wrapper.h +++ b/gfx/video_thread_wrapper.h @@ -23,15 +23,6 @@ #include #include "fonts/gl_font.h" -/* Starts a video driver in a new thread. - * Access to video driver will be mediated through this driver. */ -bool rarch_threaded_video_init( - const video_driver_t **out_driver, void **out_data, - const input_driver_t **input, void **input_data, - const video_driver_t *driver, const video_info_t *info); - -void *rarch_threaded_video_resolve(const video_driver_t **drv); - enum thread_cmd { CMD_NONE = 0, @@ -195,5 +186,38 @@ typedef struct thread_video } thread_video_t; +/** + * rarch_threaded_video_init: + * @out_driver : Output video driver + * @out_data : Output video data + * @input : Input input driver + * @input_data : Input input data + * @driver : Input Video driver + * @info : Video info handle. + * + * Creates, initializes and starts a video driver in a new thread. + * Access to video driver will be mediated through this driver. + * + * Returns: true (1) if successful, otherwise false (0). + **/ +bool rarch_threaded_video_init( + const video_driver_t **out_driver, void **out_data, + const input_driver_t **input, void **input_data, + const video_driver_t *driver, const video_info_t *info); + +/** + * rarch_threaded_video_resolve: + * @drv : Found driver. + * + * Gets the underlying video driver associated with the + * threaded video wrapper. Sets @drv to the found + * video driver. + * + * Returns: Video driver data of the video driver associated + * with the threaded wrapper (if successful). If not successful, + * NULL. + **/ +void *rarch_threaded_video_resolve(const video_driver_t **drv); + #endif From 9215ef7067ba7fb377d77f312b1a92dbe37879db Mon Sep 17 00:00:00 2001 From: twinaphex Date: Sun, 11 Jan 2015 21:57:30 +0100 Subject: [PATCH 063/156] (gfx/video_thread_wrapper.c) Minor cleanup --- gfx/video_thread_wrapper.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/gfx/video_thread_wrapper.c b/gfx/video_thread_wrapper.c index 9ae95cc977..a69cc39cef 100644 --- a/gfx/video_thread_wrapper.c +++ b/gfx/video_thread_wrapper.c @@ -161,15 +161,14 @@ static void thread_loop(void *data) thr->cmd_data.b = ret; thr->frame.within_thread = false; - thread_reply(thr, CMD_READ_VIEWPORT); } else { /* Viewport dimensions changed right after main * thread read the async value. Cannot read safely. */ thr->cmd_data.b = false; - thread_reply(thr, CMD_READ_VIEWPORT); } + thread_reply(thr, CMD_READ_VIEWPORT); break; } From e5e80ba8a4ab9a8e8a25060f722077ebbc5d8d08 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Sun, 11 Jan 2015 22:39:50 +0100 Subject: [PATCH 064/156] Start documenting state_tracker.c --- gfx/state_tracker.c | 36 +++++++++++++++++++++++++++++++++--- gfx/state_tracker.h | 27 +++++++++++++++++++++++++++ 2 files changed, 60 insertions(+), 3 deletions(-) diff --git a/gfx/state_tracker.c b/gfx/state_tracker.c index 7c364cf4a3..02b5d3c5f1 100644 --- a/gfx/state_tracker.c +++ b/gfx/state_tracker.c @@ -61,6 +61,14 @@ struct state_tracker #endif }; +/** + * state_tracker_init: + * @info : State tracker info handle. + * + * Creates and initializes graphics state tracker. + * + * Returns: new state tracker handle if successful, otherwise NULL. + **/ state_tracker_t* state_tracker_init(const struct state_tracker_info *info) { unsigned i; @@ -144,6 +152,12 @@ state_tracker_t* state_tracker_init(const struct state_tracker_info *info) return tracker; } +/** + * state_tracker_free: + * @tracker : State tracker handle. + * + * Frees a state tracker handle. + **/ void state_tracker_free(state_tracker_t *tracker) { if (tracker) @@ -233,8 +247,12 @@ static void update_element( } } -/* Updates 16-bit input in same format as libretro API itself. */ - +/** + * update_input: + * @tracker : State tracker handle. + * + * Updates 16-bit input in same format as libretro API itself. + **/ static void update_input(state_tracker_t *tracker) { unsigned i; @@ -293,6 +311,19 @@ static void update_input(state_tracker_t *tracker) tracker->input_state[i] = state[i]; } +/** + * state_get_uniform: + * @tracker : State tracker handle. + * @uniforms : State tracker uniforms. + * @elem : Amount of uniform elements. + * @frame_count : Frame count. + * + * Calls update_input(), and updates each uniform + * element accordingly. + * + * Returns: Amount of state elements (either equal to @elem + * or equal to @tracker->info_eleme). + **/ unsigned state_get_uniform(state_tracker_t *tracker, struct state_tracker_uniform *uniforms, unsigned elem, unsigned frame_count) @@ -309,4 +340,3 @@ unsigned state_get_uniform(state_tracker_t *tracker, return elems; } - diff --git a/gfx/state_tracker.h b/gfx/state_tracker.h index 22065d30da..4b47ceb5bd 100644 --- a/gfx/state_tracker.h +++ b/gfx/state_tracker.h @@ -78,10 +78,37 @@ struct state_tracker_uniform typedef struct state_tracker state_tracker_t; +/** + * state_tracker_init: + * @info : State tracker info handle. + * + * Creates and initializes graphics state tracker. + * + * Returns: new state tracker handle if successful, otherwise NULL. + **/ state_tracker_t* state_tracker_init(const struct state_tracker_info *info); +/** + * state_tracker_free: + * @tracker : State tracker handle. + * + * Frees a state tracker handle. + **/ void state_tracker_free(state_tracker_t *tracker); +/** + * state_get_uniform: + * @tracker : State tracker handle. + * @uniforms : State tracker uniforms. + * @elem : Amount of uniform elements. + * @frame_count : Frame count. + * + * Calls update_input(), and updates each uniform + * element accordingly. + * + * Returns: Amount of state elements (either equal to @elem + * or equal to @tracker->info_eleme). + **/ unsigned state_get_uniform(state_tracker_t *tracker, struct state_tracker_uniform *uniforms, unsigned elem, unsigned frame_count); From 41fbfe3e551ba1946791c915ff972387009bceef Mon Sep 17 00:00:00 2001 From: twinaphex Date: Mon, 12 Jan 2015 02:15:35 +0100 Subject: [PATCH 065/156] (state_tracker.c) Namespace changes --- gfx/d3d/render_chain_cg.h | 2 +- gfx/shader/shader_gl_cg.c | 2 +- gfx/shader/shader_glsl.c | 2 +- gfx/state_tracker.c | 38 ++++++++++++++++++++------------------ gfx/state_tracker.h | 4 ++-- 5 files changed, 25 insertions(+), 23 deletions(-) diff --git a/gfx/d3d/render_chain_cg.h b/gfx/d3d/render_chain_cg.h index 3665d37f88..951fc00aec 100644 --- a/gfx/d3d/render_chain_cg.h +++ b/gfx/d3d/render_chain_cg.h @@ -221,7 +221,7 @@ void renderchain_bind_tracker(void *data, Pass *pass, unsigned pass_index) return; if (pass_index == 1) - chain->uniform_cnt = state_get_uniform(chain->tracker, + chain->uniform_cnt = state_tracker_get_uniform(chain->tracker, chain->uniform_info, MAX_VARIABLES, chain->frame_count); for (unsigned i = 0; i < chain->uniform_cnt; i++) diff --git a/gfx/shader/shader_gl_cg.c b/gfx/shader/shader_gl_cg.c index 48b8c57994..20a63e392b 100644 --- a/gfx/shader/shader_gl_cg.c +++ b/gfx/shader/shader_gl_cg.c @@ -391,7 +391,7 @@ static void gl_cg_set_params(void *data, unsigned width, unsigned height, static unsigned cnt = 0; if (cg->active_idx == 1) - cnt = state_get_uniform(cg->state_tracker, tracker_info, + cnt = state_tracker_get_uniform(cg->state_tracker, tracker_info, MAX_VARIABLES, frame_count); for (i = 0; i < cnt; i++) diff --git a/gfx/shader/shader_glsl.c b/gfx/shader/shader_glsl.c index 4666c8cdab..89b6032533 100644 --- a/gfx/shader/shader_glsl.c +++ b/gfx/shader/shader_glsl.c @@ -1115,7 +1115,7 @@ static void gl_glsl_set_params(void *data, unsigned width, unsigned height, static unsigned cnt = 0; if (glsl->glsl_active_index == 1) - cnt = state_get_uniform(glsl->gl_state_tracker, state_info, + cnt = state_tracker_get_uniform(glsl->gl_state_tracker, state_info, GFX_MAX_VARIABLES, frame_count); for (i = 0; i < cnt; i++) diff --git a/gfx/state_tracker.c b/gfx/state_tracker.c index 02b5d3c5f1..66def8253e 100644 --- a/gfx/state_tracker.c +++ b/gfx/state_tracker.c @@ -171,7 +171,8 @@ void state_tracker_free(state_tracker_t *tracker) free(tracker); } -static inline uint16_t fetch(const struct state_tracker_internal *info) +static inline uint16_t state_tracker_fetch( + const struct state_tracker_internal *info) { uint16_t val = info->ptr[info->addr]; @@ -186,7 +187,7 @@ static inline uint16_t fetch(const struct state_tracker_internal *info) return val; } -static void update_element( +static void state_tracker_update_element( struct state_tracker_uniform *uniform, struct state_tracker_internal *info, unsigned frame_count) @@ -196,40 +197,40 @@ static void update_element( switch (info->type) { case RARCH_STATE_CAPTURE: - uniform->value = fetch(info); + uniform->value = state_tracker_fetch(info); break; case RARCH_STATE_CAPTURE_PREV: - if (info->prev[0] != fetch(info)) + if (info->prev[0] != state_tracker_fetch(info)) { info->prev[1] = info->prev[0]; - info->prev[0] = fetch(info); + info->prev[0] = state_tracker_fetch(info); } uniform->value = info->prev[1]; break; case RARCH_STATE_TRANSITION: - if (info->old_value != fetch(info)) + if (info->old_value != state_tracker_fetch(info)) { - info->old_value = fetch(info); + info->old_value = state_tracker_fetch(info); info->frame_count = frame_count; } uniform->value = info->frame_count; break; case RARCH_STATE_TRANSITION_COUNT: - if (info->old_value != fetch(info)) + if (info->old_value != state_tracker_fetch(info)) { - info->old_value = fetch(info); + info->old_value = state_tracker_fetch(info); info->transition_count++; } uniform->value = info->transition_count; break; case RARCH_STATE_TRANSITION_PREV: - if (info->old_value != fetch(info)) + if (info->old_value != state_tracker_fetch(info)) { - info->old_value = fetch(info); + info->old_value = state_tracker_fetch(info); info->frame_count_prev = info->frame_count; info->frame_count = frame_count; } @@ -248,12 +249,12 @@ static void update_element( } /** - * update_input: + * state_tracker_update_input: * @tracker : State tracker handle. * * Updates 16-bit input in same format as libretro API itself. **/ -static void update_input(state_tracker_t *tracker) +static void state_tracker_update_input(state_tracker_t *tracker) { unsigned i; uint16_t state[2] = {0}; @@ -312,19 +313,19 @@ static void update_input(state_tracker_t *tracker) } /** - * state_get_uniform: + * state_tracker_get_uniform: * @tracker : State tracker handle. * @uniforms : State tracker uniforms. * @elem : Amount of uniform elements. * @frame_count : Frame count. * - * Calls update_input(), and updates each uniform + * Calls state_tracker_update_input(), and updates each uniform * element accordingly. * * Returns: Amount of state elements (either equal to @elem * or equal to @tracker->info_eleme). **/ -unsigned state_get_uniform(state_tracker_t *tracker, +unsigned state_tracker_get_uniform(state_tracker_t *tracker, struct state_tracker_uniform *uniforms, unsigned elem, unsigned frame_count) { @@ -333,10 +334,11 @@ unsigned state_get_uniform(state_tracker_t *tracker, if (tracker->info_elem < elem) elems = tracker->info_elem; - update_input(tracker); + state_tracker_update_input(tracker); for (i = 0; i < elems; i++) - update_element(&uniforms[i], &tracker->info[i], frame_count); + state_tracker_update_element( + &uniforms[i], &tracker->info[i], frame_count); return elems; } diff --git a/gfx/state_tracker.h b/gfx/state_tracker.h index 4b47ceb5bd..e02e400fde 100644 --- a/gfx/state_tracker.h +++ b/gfx/state_tracker.h @@ -97,7 +97,7 @@ state_tracker_t* state_tracker_init(const struct state_tracker_info *info); void state_tracker_free(state_tracker_t *tracker); /** - * state_get_uniform: + * state_tracker_get_uniform: * @tracker : State tracker handle. * @uniforms : State tracker uniforms. * @elem : Amount of uniform elements. @@ -109,7 +109,7 @@ void state_tracker_free(state_tracker_t *tracker); * Returns: Amount of state elements (either equal to @elem * or equal to @tracker->info_eleme). **/ -unsigned state_get_uniform(state_tracker_t *tracker, +unsigned state_tracker_get_uniform(state_tracker_t *tracker, struct state_tracker_uniform *uniforms, unsigned elem, unsigned frame_count); From b61ae369f7f20a84eb6ca2e272b56b518811551c Mon Sep 17 00:00:00 2001 From: twinaphex Date: Mon, 12 Jan 2015 02:52:52 +0100 Subject: [PATCH 066/156] (input_keymaps.c) Namespace changes and documentation --- apple/OSX/settings.m | 2 +- apple/iOS/menu.m | 2 +- input/apple_input.c | 6 +-- input/dinput.c | 11 ++++-- input/input_common.c | 2 +- input/input_common.h | 1 - input/input_keymaps.c | 63 ++++++++++++++++++++++++------- input/input_keymaps.h | 43 +++++++++++++++++++-- input/keyboard_event_apple.c | 5 ++- input/keyboard_event_win32.c | 22 +++++++---- input/keyboard_event_x11.c | 24 ++++++++---- input/keyboard_event_xkb.c | 3 +- input/linuxraw_input.c | 9 ++--- input/rwebinput_input.c | 60 +++++++++++++++++------------ input/sdl_input.c | 73 ++++++++++++++++++++++-------------- input/udev_input.c | 14 +++---- input/x11_input.c | 42 ++++++++++++++------- settings.c | 3 +- 18 files changed, 258 insertions(+), 127 deletions(-) diff --git a/apple/OSX/settings.m b/apple/OSX/settings.m index 62865589fb..5dc2884ba2 100644 --- a/apple/OSX/settings.m +++ b/apple/OSX/settings.m @@ -72,7 +72,7 @@ static void* const associated_name_tag = (void*)&associated_name_tag; int32_t idx = self.setting->index ? self.setting->index - 1 : 0; if ((value = apple_input_find_any_key())) - BINDFOR(*[self setting]).key = input_translate_keysym_to_rk(value); + BINDFOR(*[self setting]).key = input_keymaps_translate_keysym_to_rk(value); else if ((value = apple_input_find_any_button(idx)) >= 0) BINDFOR(*[self setting]).joykey = value; else if ((value = apple_input_find_any_axis(idx))) diff --git a/apple/iOS/menu.m b/apple/iOS/menu.m index 004bd71d73..1a6b5e7f0e 100644 --- a/apple/iOS/menu.m +++ b/apple/iOS/menu.m @@ -558,7 +558,7 @@ static void RunActionSheet(const char* title, const struct string_list* items, U idx = self.setting->index - 1; if ((value = apple_input_find_any_key())) - BINDFOR(*self.setting).key = input_translate_keysym_to_rk(value); + BINDFOR(*self.setting).key = input_keymaps_translate_keysym_to_rk(value); else if ((value = apple_input_find_any_button(idx)) >= 0) BINDFOR(*self.setting).joykey = value; else if ((value = apple_input_find_any_axis(idx))) diff --git a/input/apple_input.c b/input/apple_input.c index e5bb98edb1..39304352fe 100644 --- a/input/apple_input.c +++ b/input/apple_input.c @@ -217,7 +217,7 @@ static int16_t apple_input_is_pressed(apple_input_data_t *apple, unsigned port_n if (id < RARCH_BIND_LIST_END) { const struct retro_keybind *bind = &binds[id]; - unsigned bit = input_translate_rk_to_keysym(bind->key); + unsigned bit = input_keymaps_translate_rk_to_keysym(bind->key); return bind->valid && apple->key_state[bit]; } return 0; @@ -231,7 +231,7 @@ static void *apple_input_init(void) if (!apple) return NULL; - input_init_keyboard_lut(rarch_key_map_apple_hid); + input_keymaps_init_keyboard_lut(rarch_key_map_apple_hid); apple->joypad = input_joypad_init_driver(g_settings.input.joypad_driver); @@ -329,7 +329,7 @@ static int16_t apple_input_state(void *data, idx, id, binds[port]); case RETRO_DEVICE_KEYBOARD: { - unsigned bit = input_translate_rk_to_keysym((enum retro_key)id); + unsigned bit = input_keymaps_translate_rk_to_keysym((enum retro_key)id); return (id < RETROK_LAST) && apple->key_state[bit]; } case RETRO_DEVICE_MOUSE: diff --git a/input/dinput.c b/input/dinput.c index a7b972e2e9..082d8385d4 100644 --- a/input/dinput.c +++ b/input/dinput.c @@ -159,7 +159,7 @@ static void *dinput_init(void) IDirectInputDevice8_Acquire(di->mouse); } - input_init_keyboard_lut(rarch_key_map_dinput); + input_keymaps_init_keyboard_lut(rarch_key_map_dinput); di->joypad = input_joypad_init_driver(g_settings.input.joypad_driver); return di; @@ -220,10 +220,11 @@ static void dinput_poll(void *data) static bool dinput_keyboard_pressed(struct dinput_input *di, unsigned key) { unsigned sym; + if (key >= RETROK_LAST) return false; - sym = input_translate_rk_to_keysym((enum retro_key)key); + sym = input_keymaps_translate_rk_to_keysym((enum retro_key)key); return di->state[sym] & 0x80; } @@ -258,7 +259,7 @@ static int16_t dinput_pressed_analog(struct dinput_input *di, if (dinput_keyboard_pressed(di, bind_minus->key)) pressed_minus = -0x7fff; if (dinput_keyboard_pressed(di, bind_plus->key)) - pressed_plus = 0x7fff; + pressed_plus = 0x7fff; return pressed_plus + pressed_minus; } @@ -370,8 +371,8 @@ static int16_t dinput_input_state(void *data, const struct retro_keybind **binds, unsigned port, unsigned device, unsigned idx, unsigned id) { - struct dinput_input *di = (struct dinput_input*)data; int16_t ret; + struct dinput_input *di = (struct dinput_input*)data; switch (device) { @@ -474,6 +475,7 @@ struct pointer_status *dinput_find_pointer(struct dinput_input *di, break; check_pos = check_pos->next; } + return check_pos; } @@ -646,6 +648,7 @@ bool g_xinput_block_pads; static void dinput_joypad_destroy(void) { unsigned i; + for (i = 0; i < MAX_USERS; i++) { if (g_pads[i].joypad) diff --git a/input/input_common.c b/input/input_common.c index 798df1dcc1..b7e795c9c4 100644 --- a/input/input_common.c +++ b/input/input_common.c @@ -378,7 +378,7 @@ void input_get_bind_string(char *buf, const struct retro_keybind *bind, input_get_bind_string_joyaxis(buf, "Auto: ", auto_bind, size); #ifndef RARCH_CONSOLE - input_translate_rk_to_str(bind->key, key, sizeof(key)); + input_keymaps_translate_rk_to_str(bind->key, key, sizeof(key)); if (!strcmp(key, "nul")) *key = '\0'; diff --git a/input/input_common.h b/input/input_common.h index 7ca96518e3..f119d266af 100644 --- a/input/input_common.h +++ b/input/input_common.h @@ -54,7 +54,6 @@ bool input_translate_coord_viewport(int mouse_x, int mouse_y, void input_get_bind_string(char *buf, const struct retro_keybind *bind, const struct retro_keybind *auto_bind, size_t size); -void input_translate_rk_to_str(enum retro_key key, char *buf, size_t size); enum retro_key input_translate_str_to_rk(const char *str); diff --git a/input/input_keymaps.c b/input/input_keymaps.c index 273e415bc2..3f9801c72c 100644 --- a/input/input_keymaps.c +++ b/input/input_keymaps.c @@ -999,16 +999,33 @@ const struct rarch_key_map rarch_key_map_apple_hid[] = { static enum retro_key rarch_keysym_lut[RETROK_LAST]; -void input_init_keyboard_lut(const struct rarch_key_map *map) +/** + * input_keymaps_init_keyboard_lut: + * @map : Keyboard map. + * + * Initializes and sets the keyboard layout to a keyboard map (@map). + **/ +void input_keymaps_init_keyboard_lut(const struct rarch_key_map *map) { memset(rarch_keysym_lut, 0, sizeof(rarch_keysym_lut)); + for (; map->rk != RETROK_UNKNOWN; map++) rarch_keysym_lut[map->rk] = (enum retro_key)map->sym; } -enum retro_key input_translate_keysym_to_rk(unsigned sym) +/** + * input_keymaps_translate_keysym_to_rk: + * @sym : Key symbol. + * + * Translates a key symbol from the keyboard layout table + * to an associated retro key identifier. + * + * Returns: Retro key identifier. + **/ +enum retro_key input_keymaps_translate_keysym_to_rk(unsigned sym) { unsigned i; + for (i = 0; i < ARRAY_SIZE(rarch_keysym_lut); i++) { if (rarch_keysym_lut[i] == sym) @@ -1018,8 +1035,19 @@ enum retro_key input_translate_keysym_to_rk(unsigned sym) return RETROK_UNKNOWN; } -void input_translate_rk_to_str(enum retro_key key, char *buf, size_t size) +/** + * input_keymaps_translate_rk_to_str: + * @key : Retro key identifier. + * @buf : Buffer. + * @size : Size of @buf. + * + * Translates a retro key identifier to a human-readable + * identifier string. + **/ +void input_keymaps_translate_rk_to_str(enum retro_key key, char *buf, size_t size) { + unsigned i; + rarch_assert(size >= 2); *buf = '\0'; @@ -1027,22 +1055,29 @@ void input_translate_rk_to_str(enum retro_key key, char *buf, size_t size) { buf[0] = (key - RETROK_a) + 'a'; buf[1] = '\0'; + return; } - else + + for (i = 0; input_config_key_map[i].str; i++) { - unsigned i; - for (i = 0; input_config_key_map[i].str; i++) - { - if (input_config_key_map[i].key == key) - { - strlcpy(buf, input_config_key_map[i].str, size); - break; - } - } + if (input_config_key_map[i].key != key) + continue; + + strlcpy(buf, input_config_key_map[i].str, size); + break; } } -unsigned input_translate_rk_to_keysym(enum retro_key key) +/** + * input_keymaps_translate_rk_to_keysym: + * @key : Retro key identifier + * + * Translates a retro key identifier to a key symbol + * from the keyboard layout table. + * + * Returns: key symbol from the keyboard layout table. + **/ +unsigned input_keymaps_translate_rk_to_keysym(enum retro_key key) { return rarch_keysym_lut[key]; } diff --git a/input/input_keymaps.h b/input/input_keymaps.h index a54e967612..ee88f597f6 100644 --- a/input/input_keymaps.h +++ b/input/input_keymaps.h @@ -46,9 +46,46 @@ extern const struct rarch_key_map rarch_key_map_rwebinput[]; extern const struct rarch_key_map rarch_key_map_linux[]; extern const struct rarch_key_map rarch_key_map_apple_hid[]; -void input_init_keyboard_lut(const struct rarch_key_map *map); -enum retro_key input_translate_keysym_to_rk(unsigned sym); -unsigned input_translate_rk_to_keysym(enum retro_key key); +/** + * input_keymaps_init_keyboard_lut: + * @map : Keyboard map. + * + * Initializes and sets the keyboard layout to a keyboard map (@map). + **/ +void input_keymaps_init_keyboard_lut(const struct rarch_key_map *map); + +/** + * input_keymaps_translate_keysym_to_rk: + * @sym : Key symbol. + * + * Translates a key symbol from the keyboard layout table + * to an associated retro key identifier. + * + * Returns: Retro key identifier. + **/ +enum retro_key input_keymaps_translate_keysym_to_rk(unsigned sym); + +/** + * input_keymaps_translate_rk_to_keysym: + * @key : Retro key identifier + * + * Translates a retro key identifier to a key symbol + * from the keyboard layout table. + * + * Returns: key symbol from the keyboard layout table. + **/ +unsigned input_keymaps_translate_rk_to_keysym(enum retro_key key); + +/** + * input_keymaps_translate_rk_to_str: + * @key : Retro key identifier. + * @buf : Buffer. + * @size : Size of @buf. + * + * Translates a retro key identifier to a human-readable + * identifier string. + **/ +void input_keymaps_translate_rk_to_str(enum retro_key key, char *buf, size_t size); #ifdef __cplusplus } diff --git a/input/keyboard_event_apple.c b/input/keyboard_event_apple.c index bfd75f7399..5beaa66a9f 100644 --- a/input/keyboard_event_apple.c +++ b/input/keyboard_event_apple.c @@ -72,7 +72,8 @@ static bool handle_small_keyboard(unsigned* code, bool down) if (!map_initialized) { - for (int i = 0; mapping_def[i].orig; i ++) + int i; + for (i = 0; mapping_def[i].orig; i ++) mapping[mapping_def[i].orig] = mapping_def[i].mod; map_initialized = true; } @@ -157,5 +158,5 @@ void apple_input_keyboard_event(bool down, apple->key_state[code] = down; input_keyboard_event(down, - input_translate_keysym_to_rk(code), character, (enum retro_mod)mod); + input_keymaps_translate_keysym_to_rk(code), character, (enum retro_mod)mod); } diff --git a/input/keyboard_event_win32.c b/input/keyboard_event_win32.c index 7701710016..d8dfd72a99 100644 --- a/input/keyboard_event_win32.c +++ b/input/keyboard_event_win32.c @@ -24,15 +24,21 @@ LRESULT win32_handle_keyboard_event(HWND hwnd, UINT message, WPARAM wparam, LPARAM lparam) { unsigned scancode = (lparam >> 16) & 0xff; - unsigned keycode = input_translate_keysym_to_rk(scancode); + unsigned keycode = input_keymaps_translate_keysym_to_rk(scancode); uint16_t mod = 0; - mod |= (GetKeyState(VK_SHIFT) & 0x80) ? RETROKMOD_SHIFT : 0; - mod |= (GetKeyState(VK_CONTROL) & 0x80) ? RETROKMOD_CTRL : 0; - mod |= (GetKeyState(VK_MENU) & 0x80) ? RETROKMOD_ALT : 0; - mod |= (GetKeyState(VK_CAPITAL) & 0x81) ? RETROKMOD_CAPSLOCK : 0; - mod |= (GetKeyState(VK_SCROLL) & 0x81) ? RETROKMOD_SCROLLOCK : 0; - mod |= ((GetKeyState(VK_LWIN) | GetKeyState(VK_RWIN)) & 0x80) ? - RETROKMOD_META : 0; + + if (GetKeyState(VK_SHIFT) & 0x80) + mod |= RETROKMOD_SHIFT; + if (GetKeyState(VK_CONTROL) & 0x80) + mod |= RETROKMOD_CTRL; + if (GetKeyState(VK_MENU) & 0x80) + mod |= RETROKMOD_ALT; + if (GetKeyState(VK_CAPITAL) & 0x81) + mod |= RETROKMOD_CAPSLOCK; + if (GetKeyState(VK_SCROLL) & 0x81) + mod |= RETROKMOD_SCROLLOCK; + if ((GetKeyState(VK_LWIN) | GetKeyState(VK_RWIN)) & 0x80) + mod |= RETROKMOD_META; switch (message) { diff --git a/input/keyboard_event_x11.c b/input/keyboard_event_x11.c index 3d497d2c66..836fc0965a 100644 --- a/input/keyboard_event_x11.c +++ b/input/keyboard_event_x11.c @@ -77,11 +77,13 @@ static size_t conv_utf8_utf32(uint32_t *out, void x11_handle_key_event(XEvent *event, XIC ic, bool filter) { int i; + unsigned state; + uint16_t mod = 0; char keybuf[32] = {0}; uint32_t chars[32] = {0}; bool down = event->type == KeyPress; - unsigned key = input_translate_keysym_to_rk(XLookupKeysym(&event->xkey, 0)); + unsigned key = input_keymaps_translate_keysym_to_rk(XLookupKeysym(&event->xkey, 0)); int num = 0; if (down && !filter) @@ -107,15 +109,21 @@ void x11_handle_key_event(XEvent *event, XIC ic, bool filter) #endif } - unsigned state = event->xkey.state; - uint16_t mod = 0; - mod |= (state & ShiftMask) ? RETROKMOD_SHIFT : 0; - mod |= (state & LockMask) ? RETROKMOD_CAPSLOCK : 0; - mod |= (state & ControlMask) ? RETROKMOD_CTRL : 0; - mod |= (state & Mod1Mask) ? RETROKMOD_ALT : 0; - mod |= (state & Mod4Mask) ? RETROKMOD_META : 0; + state = event->xkey.state; + + if (state & ShiftMask) + mod |= RETROKMOD_SHIFT; + if (state & LockMask) + mod |= RETROKMOD_CAPSLOCK; + if (state & ControlMask) + mod |= RETROKMOD_CTRL; + if (state & Mod1Mask) + mod |= RETROKMOD_ALT; + if (state & Mod4Mask) + mod |= RETROKMOD_META; input_keyboard_event(down, key, chars[0], mod); + for (i = 1; i < num; i++) input_keyboard_event(down, RETROK_UNKNOWN, chars[i], mod); } diff --git a/input/keyboard_event_xkb.c b/input/keyboard_event_xkb.c index c46cc0b0c8..60436ea407 100644 --- a/input/keyboard_event_xkb.c +++ b/input/keyboard_event_xkb.c @@ -60,8 +60,9 @@ void handle_xkb( (enum xkb_state_component)((XKB_STATE_MODS_EFFECTIVE) > 0)) ? *map_bit : 0; } - input_keyboard_event(value, input_translate_keysym_to_rk(code), + input_keyboard_event(value, input_keymaps_translate_keysym_to_rk(code), num_syms ? xkb_keysym_to_utf32(syms[0]) : 0, mod); + for (i = 1; i < num_syms; i++) input_keyboard_event(value, RETROK_UNKNOWN, xkb_keysym_to_utf32(syms[i]), mod); } diff --git a/input/linuxraw_input.c b/input/linuxraw_input.c index 1855f07764..a1064aa493 100644 --- a/input/linuxraw_input.c +++ b/input/linuxraw_input.c @@ -115,7 +115,7 @@ static void *linuxraw_input_init(void) atexit(linuxraw_resetKbmd); linuxraw->joypad = input_joypad_init_driver(g_settings.input.joypad_driver); - input_init_keyboard_lut(rarch_key_map_linux); + input_keymaps_init_keyboard_lut(rarch_key_map_linux); /* We need to disable use of stdin command interface if * stdin is supposed to be used for input. */ @@ -126,7 +126,7 @@ static void *linuxraw_input_init(void) static bool linuxraw_key_pressed(linuxraw_input_t *linuxraw, int key) { - unsigned sym = input_translate_rk_to_keysym((enum retro_key)key); + unsigned sym = input_keymaps_translate_rk_to_keysym((enum retro_key)key); return linuxraw->state[sym]; } @@ -149,6 +149,7 @@ static int16_t linuxraw_analog_pressed(linuxraw_input_t *linuxraw, int16_t pressed_minus = 0, pressed_plus = 0; unsigned id_minus = 0; unsigned id_plus = 0; + input_conv_analog_id_to_bind_id(idx, id, &id_minus, &id_plus); if (linuxraw_is_pressed(linuxraw, binds, id_minus)) @@ -162,8 +163,6 @@ static int16_t linuxraw_analog_pressed(linuxraw_input_t *linuxraw, static bool linuxraw_bind_button_pressed(void *data, int key) { linuxraw_input_t *linuxraw = (linuxraw_input_t*)data; - if (!linuxraw) - return false; return linuxraw_is_pressed(linuxraw, g_settings.input.binds[0], key) || input_joypad_pressed(linuxraw->joypad, 0, g_settings.input.binds[0], key); } @@ -172,8 +171,8 @@ static int16_t linuxraw_input_state(void *data, const struct retro_keybind **binds, unsigned port, unsigned device, unsigned idx, unsigned id) { - linuxraw_input_t *linuxraw = (linuxraw_input_t*)data; int16_t ret; + linuxraw_input_t *linuxraw = (linuxraw_input_t*)data; switch (device) { diff --git a/input/rwebinput_input.c b/input/rwebinput_input.c index d4a0bea1e0..605506e746 100644 --- a/input/rwebinput_input.c +++ b/input/rwebinput_input.c @@ -46,18 +46,22 @@ static void *rwebinput_input_init(void) return NULL; } - input_init_keyboard_lut(rarch_key_map_rwebinput); + input_keymaps_init_keyboard_lut(rarch_key_map_rwebinput); return rwebinput; } static bool rwebinput_key_pressed(rwebinput_input_t *rwebinput, int key) { + unsigned sym; + bool ret; + if (key >= RETROK_LAST) return false; - unsigned sym = input_translate_rk_to_keysym((enum retro_key)key); - bool ret = rwebinput->state.keys[sym >> 3] & (1 << (sym & 7)); + sym = input_keymaps_translate_rk_to_keysym((enum retro_key)key); + ret = rwebinput->state.keys[sym >> 3] & (1 << (sym & 7)); + return ret; } @@ -68,8 +72,8 @@ static bool rwebinput_is_pressed(rwebinput_input_t *rwebinput, const struct retr const struct retro_keybind *bind = &binds[id]; return bind->valid && rwebinput_key_pressed(rwebinput, binds[id].key); } - else - return false; + + return false; } static bool rwebinput_bind_button_pressed(void *data, int key) @@ -90,20 +94,25 @@ static int16_t rwebinput_mouse_state(rwebinput_input_t *rwebinput, unsigned id) return rwebinput->state.mouse_l; case RETRO_DEVICE_ID_MOUSE_RIGHT: return rwebinput->state.mouse_r; - default: - return 0; } + + return 0; } static int16_t rwebinput_analog_pressed(rwebinput_input_t *rwebinput, const struct retro_keybind *binds, unsigned idx, unsigned id) { + int16_t pressed_minus = 0, pressed_plus = 0; unsigned id_minus = 0; unsigned id_plus = 0; + input_conv_analog_id_to_bind_id(idx, id, &id_minus, &id_plus); - int16_t pressed_minus = rwebinput_is_pressed(rwebinput, binds, id_minus) ? -0x7fff : 0; - int16_t pressed_plus = rwebinput_is_pressed(rwebinput, binds, id_plus) ? 0x7fff : 0; + if (rwebinput_is_pressed(rwebinput, binds, id_minus)) + pressed_minus = -0x7fff; + if (rwebinput_is_pressed(rwebinput, binds, id_plus)) + pressed_plus = 0x7fff; + return pressed_plus + pressed_minus; } @@ -125,10 +134,9 @@ static int16_t rwebinput_input_state(void *data, const struct retro_keybind **bi case RETRO_DEVICE_MOUSE: return rwebinput_mouse_state(rwebinput, id); - - default: - return 0; } + + return 0; } static void rwebinput_input_free(void *data) @@ -146,23 +154,25 @@ static void rwebinput_input_free(void *data) static void rwebinput_input_poll(void *data) { + unsigned i; rwebinput_input_t *rwebinput = (rwebinput_input_t*)data; + rwebinput_state_t *state = RWebInputPoll(rwebinput->context); - rwebinput_state_t *state = RWebInputPoll(rwebinput->context); - - // get new keys - for (unsigned i = 0; i < 32; i++) + /* Get new keys. */ + for (i = 0; i < 32; i++) { - if (state->keys[i] != rwebinput->state.keys[i]) + unsigned k; + uint8_t diff; + + if (state->keys[i] == rwebinput->state.keys[i]) + continue; + + diff = state->keys[i] ^ rwebinput->state.keys[i]; + + for (k = 0; diff; diff >>= 1, k++) { - uint8_t diff = state->keys[i] ^ rwebinput->state.keys[i]; - for (unsigned k = 0; diff; diff >>= 1, k++) - { - if (diff & 1) - { - input_keyboard_event((state->keys[i] & (1 << k)) != 0, input_translate_keysym_to_rk(i * 8 + k), 0, 0); - } - } + if (diff & 1) + input_keyboard_event((state->keys[i] & (1 << k)) != 0, input_keymaps_translate_keysym_to_rk(i * 8 + k), 0, 0); } } diff --git a/input/sdl_input.c b/input/sdl_input.c index 8a6db243e0..264ac6b261 100644 --- a/input/sdl_input.c +++ b/input/sdl_input.c @@ -40,7 +40,7 @@ typedef struct sdl_input static void *sdl_input_init(void) { - input_init_keyboard_lut(rarch_key_map_sdl); + input_keymaps_init_keyboard_lut(rarch_key_map_sdl); sdl_input_t *sdl = (sdl_input_t*)calloc(1, sizeof(*sdl)); if (!sdl) return NULL; @@ -53,13 +53,15 @@ static void *sdl_input_init(void) static bool sdl_key_pressed(int key) { + int num_keys; + const uint8_t *keymap; + unsigned sym; + if (key >= RETROK_LAST) return false; - unsigned sym = input_translate_rk_to_keysym((enum retro_key)key); + sym = input_keymaps_translate_rk_to_keysym((enum retro_key)key); - int num_keys; - const uint8_t *keymap; #if HAVE_SDL2 sym = SDL_GetScancodeFromKey(sym); keymap = SDL_GetKeyboardState(&num_keys); @@ -83,12 +85,17 @@ static bool sdl_is_pressed(sdl_input_t *sdl, unsigned port_num, const struct ret static int16_t sdl_analog_pressed(sdl_input_t *sdl, const struct retro_keybind *binds, unsigned idx, unsigned id) { + int16_t pressed_minus = 0, pressed_plus = 0; unsigned id_minus = 0; unsigned id_plus = 0; + input_conv_analog_id_to_bind_id(idx, id, &id_minus, &id_plus); - int16_t pressed_minus = sdl_key_pressed(binds[id_minus].key) ? -0x7fff : 0; - int16_t pressed_plus = sdl_key_pressed(binds[id_plus].key) ? 0x7fff : 0; + if (sdl_key_pressed(binds[id_minus].key)) + pressed_minus = -0x7fff; + if (sdl_key_pressed(binds[id_plus].key)) + pressed_plus = 0x7fff; + return pressed_plus + pressed_minus; } @@ -141,19 +148,21 @@ static int16_t sdl_mouse_device_state(sdl_input_t *sdl, unsigned id) return sdl->mouse_y; case RETRO_DEVICE_ID_MOUSE_MIDDLE: return sdl->mouse_m; - default: - return 0; } + + return 0; } static int16_t sdl_pointer_device_state(sdl_input_t *sdl, unsigned idx, unsigned id, bool screen) { + bool valid, inside; + int16_t res_x = 0, res_y = 0, res_screen_x = 0, res_screen_y = 0; + if (idx != 0) return 0; - int16_t res_x = 0, res_y = 0, res_screen_x = 0, res_screen_y = 0; - bool valid = input_translate_coord_viewport(sdl->mouse_abs_x, sdl->mouse_abs_y, + valid = input_translate_coord_viewport(sdl->mouse_abs_x, sdl->mouse_abs_y, &res_x, &res_y, &res_screen_x, &res_screen_y); if (!valid) @@ -165,7 +174,7 @@ static int16_t sdl_pointer_device_state(sdl_input_t *sdl, res_y = res_screen_y; } - bool inside = (res_x >= -0x7fff) && (res_y >= -0x7fff); + inside = (res_x >= -0x7fff) && (res_y >= -0x7fff); if (!inside) return 0; @@ -178,9 +187,9 @@ static int16_t sdl_pointer_device_state(sdl_input_t *sdl, return res_y; case RETRO_DEVICE_ID_POINTER_PRESSED: return sdl->mouse_l; - default: - return 0; } + + return 0; } static int16_t sdl_lightgun_device_state(sdl_input_t *sdl, unsigned id) @@ -201,15 +210,16 @@ static int16_t sdl_lightgun_device_state(sdl_input_t *sdl, unsigned id) return sdl->mouse_m && sdl->mouse_r; case RETRO_DEVICE_ID_LIGHTGUN_PAUSE: return sdl->mouse_m && sdl->mouse_l; - default: - return 0; } + + return 0; } static int16_t sdl_input_state(void *data_, const struct retro_keybind **binds, unsigned port, unsigned device, unsigned idx, unsigned id) { sdl_input_t *data = (sdl_input_t*)data_; + switch (device) { case RETRO_DEVICE_JOYPAD: @@ -232,10 +242,12 @@ static int16_t sdl_input_state(void *data_, const struct retro_keybind **binds, static void sdl_input_free(void *data) { + sdl_input_t *sdl = (sdl_input_t*)data; + if (!data) return; - // Flush out all pending events. + /* Flush out all pending events. */ #ifdef HAVE_SDL2 SDL_FlushEvents(SDL_FIRSTEVENT, SDL_LASTEVENT); #else @@ -243,8 +255,6 @@ static void sdl_input_free(void *data) while (SDL_PollEvent(&event)); #endif - sdl_input_t *sdl = (sdl_input_t*)data; - if (sdl->joypad) sdl->joypad->destroy(); @@ -254,17 +264,17 @@ static void sdl_input_free(void *data) #ifdef HAVE_SDL2 static void sdl_grab_mouse(void *data, bool state) { + struct temp{ + SDL_Window *w; + }; sdl_input_t *sdl = (sdl_input_t*)data; - if (driver.video == &video_sdl2) - { - /* first member of sdl2_video_t is the window */ - struct temp{ - SDL_Window *w; - }; - SDL_SetWindowGrab(((struct temp*)driver.video_data)->w, - state ? SDL_TRUE : SDL_FALSE); - } + if (driver.video != &video_sdl2) + return; + + /* First member of sdl2_video_t is the window */ + SDL_SetWindowGrab(((struct temp*)driver.video_data)->w, + state ? SDL_TRUE : SDL_FALSE); } #endif @@ -272,6 +282,8 @@ static bool sdl_set_rumble(void *data, unsigned port, enum retro_rumble_effect effect, uint16_t strength) { sdl_input_t *sdl = (sdl_input_t*)data; + if (!sdl) + return false; return input_joypad_set_rumble(sdl->joypad, port, effect, strength); } @@ -284,7 +296,9 @@ static const rarch_joypad_driver_t *sdl_get_joypad_driver(void *data) static void sdl_poll_mouse(sdl_input_t *sdl) { Uint8 btn = SDL_GetRelativeMouseState(&sdl->mouse_x, &sdl->mouse_y); + SDL_GetMouseState(&sdl->mouse_abs_x, &sdl->mouse_abs_y); + sdl->mouse_l = SDL_BUTTON(SDL_BUTTON_LEFT) & btn ? 1 : 0; sdl->mouse_r = SDL_BUTTON(SDL_BUTTON_RIGHT) & btn ? 1 : 0; sdl->mouse_m = SDL_BUTTON(SDL_BUTTON_MIDDLE) & btn ? 1 : 0; @@ -296,9 +310,10 @@ static void sdl_poll_mouse(sdl_input_t *sdl) static void sdl_input_poll(void *data) { - SDL_PumpEvents(); sdl_input_t *sdl = (sdl_input_t*)data; + SDL_PumpEvents(); + if (sdl->joypad) sdl->joypad->poll(); sdl_poll_mouse(sdl); @@ -313,7 +328,7 @@ static void sdl_input_poll(void *data) if (event.type == SDL_KEYDOWN || event.type == SDL_KEYUP) { uint16_t mod = 0; - unsigned code = input_translate_keysym_to_rk(event.key.keysym.sym); + unsigned code = input_keymaps_translate_keysym_to_rk(event.key.keysym.sym); if (event.key.keysym.mod & KMOD_SHIFT) mod |= RETROKMOD_SHIFT; diff --git a/input/udev_input.c b/input/udev_input.c index 5322203cf8..59c5b98802 100644 --- a/input/udev_input.c +++ b/input/udev_input.c @@ -486,7 +486,7 @@ static bool udev_input_is_pressed(udev_input_t *udev, const struct retro_keybind if (id < RARCH_BIND_LIST_END) { const struct retro_keybind *bind = &binds[id]; - unsigned bit = input_translate_rk_to_keysym(binds[id].key); + unsigned bit = input_keymaps_translate_rk_to_keysym(binds[id].key); return bind->valid && BIT_GET(udev->key_state, bit); } return false; @@ -512,8 +512,8 @@ static int16_t udev_analog_pressed(udev_input_t *udev, static int16_t udev_input_state(void *data, const struct retro_keybind **binds, unsigned port, unsigned device, unsigned idx, unsigned id) { - udev_input_t *udev = (udev_input_t*)data; int16_t ret; + udev_input_t *udev = (udev_input_t*)data; switch (device) { @@ -529,7 +529,7 @@ static int16_t udev_input_state(void *data, const struct retro_keybind **binds, case RETRO_DEVICE_KEYBOARD: { - unsigned bit = input_translate_rk_to_keysym((enum retro_key)id); + unsigned bit = input_keymaps_translate_rk_to_keysym((enum retro_key)id); return id < RETROK_LAST && BIT_GET(udev->key_state, bit); } case RETRO_DEVICE_MOUSE: @@ -603,19 +603,19 @@ static bool open_devices(udev_input_t *udev, const char *type, device_handle_cb udev_enumerate_add_match_property(enumerate, type, "1"); udev_enumerate_scan_devices(enumerate); devs = udev_enumerate_get_list_entry(enumerate); + for (item = devs; item; item = udev_list_entry_get_next(item)) { - const char *name = udev_list_entry_get_name(item); + const char *name = udev_list_entry_get_name(item); /* Get the filename of the /sys entry for the device * and create a udev_device object (dev) representing it. */ struct udev_device *dev = udev_device_new_from_syspath(udev->udev, name); const char *devnode = udev_device_get_devnode(dev); - int fd = devnode ? open(devnode, O_RDONLY | O_NONBLOCK) : -1; - if (devnode) { + int fd = open(devnode, O_RDONLY | O_NONBLOCK); RARCH_LOG("[udev] Adding device %s as type %s.\n", devnode, type); if (!add_device(udev, devnode, cb)) RARCH_ERR("[udev] Failed to open device: %s (%s).\n", devnode, strerror(errno)); @@ -802,7 +802,7 @@ static void *udev_input_init(void) RARCH_WARN("[udev]: Couldn't open any keyboard, mouse or touchpad. Are permissions set correctly for /dev/input/event*?\n"); udev->joypad = input_joypad_init_driver(g_settings.input.joypad_driver); - input_init_keyboard_lut(rarch_key_map_linux); + input_keymaps_init_keyboard_lut(rarch_key_map_linux); disable_terminal_input(); return udev; diff --git a/input/x11_input.c b/input/x11_input.c index d0deeb0486..2a5854de5f 100644 --- a/input/x11_input.c +++ b/input/x11_input.c @@ -60,19 +60,23 @@ static void *x_input_init(void) x11->win = (Window)driver.video_window; x11->joypad = input_joypad_init_driver(g_settings.input.joypad_driver); - input_init_keyboard_lut(rarch_key_map_x11); + input_keymaps_init_keyboard_lut(rarch_key_map_x11); return x11; } static bool x_key_pressed(x11_input_t *x11, int key) { + unsigned sym; + int keycode; + bool ret; + if (key >= RETROK_LAST) return false; - unsigned sym = input_translate_rk_to_keysym((enum retro_key)key); - int keycode = XKeysymToKeycode(x11->display, sym); - bool ret = x11->state[keycode >> 3] & (1 << (keycode & 7)); + sym = input_keymaps_translate_rk_to_keysym((enum retro_key)key); + keycode = XKeysymToKeycode(x11->display, sym); + ret = x11->state[keycode >> 3] & (1 << (keycode & 7)); return ret; } @@ -90,18 +94,25 @@ static bool x_is_pressed(x11_input_t *x11, static int16_t x_pressed_analog(x11_input_t *x11, const struct retro_keybind *binds, unsigned idx, unsigned id) { + int16_t pressed_minus = 0, pressed_plus = 0; unsigned id_minus = 0; unsigned id_plus = 0; + input_conv_analog_id_to_bind_id(idx, id, &id_minus, &id_plus); - int16_t pressed_minus = x_is_pressed(x11, binds, id_minus) ? -0x7fff : 0; - int16_t pressed_plus = x_is_pressed(x11, binds, id_plus) ? 0x7fff : 0; + if (x_is_pressed(x11, binds, id_minus)) + pressed_minus = -0x7fff; + if (x_is_pressed(x11, binds, id_plus)) + pressed_plus = 0x7fff; + return pressed_plus + pressed_minus; } static bool x_bind_button_pressed(void *data, int key) { x11_input_t *x11 = (x11_input_t*)data; + if (!x11) + return false; return x_is_pressed(x11, g_settings.input.binds[0], key) || input_joypad_pressed(x11->joypad, 0, g_settings.input.binds[0], key); } @@ -132,11 +143,13 @@ static int16_t x_mouse_state(x11_input_t *x11, unsigned id) static int16_t x_pointer_state(x11_input_t *x11, unsigned idx, unsigned id, bool screen) { + int16_t res_x = 0, res_y = 0, res_screen_x = 0, res_screen_y = 0; + bool valid, inside; + if (idx != 0) return 0; - int16_t res_x = 0, res_y = 0, res_screen_x = 0, res_screen_y = 0; - bool valid = input_translate_coord_viewport(x11->mouse_x, x11->mouse_y, + valid = input_translate_coord_viewport(x11->mouse_x, x11->mouse_y, &res_x, &res_y, &res_screen_x, &res_screen_y); if (!valid) @@ -148,7 +161,7 @@ static int16_t x_pointer_state(x11_input_t *x11, res_y = res_screen_y; } - bool inside = (res_x >= -0x7fff) && (res_y >= -0x7fff); + inside = (res_x >= -0x7fff) && (res_y >= -0x7fff); if (!inside) return 0; @@ -184,17 +197,17 @@ static int16_t x_lightgun_state(x11_input_t *x11, unsigned id) return x11->mouse_m && x11->mouse_r; case RETRO_DEVICE_ID_LIGHTGUN_PAUSE: return x11->mouse_m && x11->mouse_l; - default: - return 0; } + + return 0; } static int16_t x_input_state(void *data, const struct retro_keybind **binds, unsigned port, unsigned device, unsigned idx, unsigned id) { - x11_input_t *x11 = (x11_input_t*)data; int16_t ret; + x11_input_t *x11 = (x11_input_t*)data; switch (device) { @@ -304,13 +317,16 @@ static void x_input_poll(void *data) static void x_grab_mouse(void *data, bool state) { x11_input_t *x11 = (x11_input_t*)data; - x11->grab_mouse = state; + if (x11) + x11->grab_mouse = state; } static bool x_set_rumble(void *data, unsigned port, enum retro_rumble_effect effect, uint16_t strength) { x11_input_t *x11 = (x11_input_t*)data; + if (!x11) + return false; return input_joypad_set_rumble(x11->joypad, port, effect, strength); } diff --git a/settings.c b/settings.c index bcc806ae1d..ac0248f6ea 100644 --- a/settings.c +++ b/settings.c @@ -21,6 +21,7 @@ #include "config.def.h" #include #include "input/input_common.h" +#include "input/input_keymaps.h" #include "settings.h" #ifdef HAVE_CONFIG_H @@ -1535,7 +1536,7 @@ static void save_keybind_key(config_file_t *conf, const char *prefix, char key[64], btn[64]; snprintf(key, sizeof(key), "%s_%s", prefix, base); - input_translate_rk_to_str(bind->key, btn, sizeof(btn)); + input_keymaps_translate_rk_to_str(bind->key, btn, sizeof(btn)); config_set_string(conf, key, btn); } From b86022ed15541934f3ab431b5e33ab7b9742d1ed Mon Sep 17 00:00:00 2001 From: twinaphex Date: Mon, 12 Jan 2015 03:13:03 +0100 Subject: [PATCH 067/156] input/keyboard_line.c - Document --- input/apple_keycode.h | 2 +- input/input_autodetect.c | 4 +- input/keyboard_line.c | 83 +++++++++++++++++++++++++++++++++++++-- input/keyboard_line.h | 85 +++++++++++++++++++++++++++++++++++----- 4 files changed, 159 insertions(+), 15 deletions(-) diff --git a/input/apple_keycode.h b/input/apple_keycode.h index 7d1ffb935e..4ca31391d5 100644 --- a/input/apple_keycode.h +++ b/input/apple_keycode.h @@ -156,7 +156,7 @@ enum KEY_RightGUI = 231 }; -#include "input_common.h" // < For rarch_key_map +#include "input_common.h" struct apple_key_name_map_entry { diff --git a/input/input_autodetect.c b/input/input_autodetect.c index 6df388fe95..5712d6d68b 100644 --- a/input/input_autodetect.c +++ b/input/input_autodetect.c @@ -59,7 +59,9 @@ static bool input_try_autoconfigure_joypad_from_conf(config_file_t *conf, snprintf(ident_idx, sizeof(ident_idx), "%s_p%u", ident, idx); - //RARCH_LOG("ident_idx: %s\n", ident_idx); +#if 0 + RARCH_LOG("ident_idx: %s\n", ident_idx); +#endif cond_found_idx = !strcmp(ident_idx, name); cond_found_general = !strcmp(ident, name) && !strcmp(drv, input_driver); diff --git a/input/keyboard_line.c b/input/keyboard_line.c index 21b8308468..98b0d90a03 100644 --- a/input/keyboard_line.c +++ b/input/keyboard_line.c @@ -28,10 +28,20 @@ struct input_keyboard_line size_t ptr; size_t size; + /** Line complete callback. + * Calls back after return is pressed with the completed line. + * Line can be NULL. + **/ input_keyboard_line_complete_t cb; void *userdata; }; +/** + * input_keyboard_line_free: + * @state : Input keyboard line handle. + * + * Frees input keyboard line handle. + **/ void input_keyboard_line_free(input_keyboard_line_t *state) { if (!state) @@ -41,6 +51,17 @@ void input_keyboard_line_free(input_keyboard_line_t *state) free(state); } +/** + * input_keyboard_line_new: + * @userdata : Userdata. + * @cb : Callback function. + * + * Creates and initializes input keyboard line handle. + * Also sets callback function for keyboard line handle + * to provided callback @cb. + * + * Returns: keyboard handle on success, otherwise NULL. + **/ input_keyboard_line_t *input_keyboard_line_new(void *userdata, input_keyboard_line_complete_t cb) { @@ -54,12 +75,22 @@ input_keyboard_line_t *input_keyboard_line_new(void *userdata, return state; } +/** + * input_keyboard_line_event: + * @state : Input keyboard line handle. + * @character : Inputted character. + * + * Called on every keyboard character event. + * + * Returns: true (1) on success, otherwise false (0). + **/ bool input_keyboard_line_event( input_keyboard_line_t *state, uint32_t character) { + char c = character >= 128 ? '?' : character; /* Treat extended chars as ? as we cannot support * printable characters for unicode stuff. */ - char c = character >= 128 ? '?' : character; + if (c == '\r' || c == '\n') { state->cb(state->userdata, state->buffer); @@ -76,10 +107,10 @@ bool input_keyboard_line_event( state->size--; } } - - /* Handle left/right here when suitable */ else if (isprint(c)) { + /* Handle left/right here when suitable */ + char *newbuf = (char*)realloc(state->buffer, state->size + 2); if (!newbuf) return false; @@ -97,6 +128,18 @@ bool input_keyboard_line_event( return false; } +/** + * input_keyboard_line_get_buffer: + * @state : Input keyboard line handle. + * + * Gets the underlying buffer of the keyboard line. + * + * The underlying buffer can be reallocated at any time + * (or be NULL), but the pointer to it remains constant + * throughout the objects lifetime. + * + * Returns: pointer to string. + **/ const char **input_keyboard_line_get_buffer( const input_keyboard_line_t *state) { @@ -106,8 +149,19 @@ const char **input_keyboard_line_get_buffer( static input_keyboard_line_t *g_keyboard_line; static input_keyboard_press_t g_keyboard_press_cb; + static void *g_keyboard_press_data; +/** + * input_keyboard_start_line: + * @userdata : Userdata. + * @cb : Line complete callback function. + * + * Sets function pointer for keyboard line handle. + * + * Returns: underlying buffer returned by + * input_keyboard_line_get_buffer(). + **/ const char **input_keyboard_start_line(void *userdata, input_keyboard_line_complete_t cb) { @@ -122,6 +176,14 @@ const char **input_keyboard_start_line(void *userdata, return input_keyboard_line_get_buffer(g_keyboard_line); } +/** + * input_keyboard_wait_keys: + * @userdata : Userdata. + * @cb : Callback function. + * + * Waits for keys to be pressed (used for binding keys in the menu). + * Callback returns false when all polling is done. + **/ void input_keyboard_wait_keys(void *userdata, input_keyboard_press_t cb) { g_keyboard_press_cb = cb; @@ -131,6 +193,11 @@ void input_keyboard_wait_keys(void *userdata, input_keyboard_press_t cb) driver.block_input = true; } +/** + * input_keyboard_wait_keys_cancel: + * + * Cancels function callback set by input_keyboard_wait_keys(). + **/ void input_keyboard_wait_keys_cancel(void) { g_keyboard_press_cb = NULL; @@ -138,6 +205,16 @@ void input_keyboard_wait_keys_cancel(void) driver.block_input = false; } +/** + * input_keyboard_event: + * @down : Keycode was pressed down? + * @code : Keycode. + * @character : Character inputted. + * @mod : TODO/FIXME: ??? + * + * Keyboard event utils. Called by drivers when keyboard events are fired. + * This interfaces with the global driver struct and libretro callbacks. + **/ void input_keyboard_event(bool down, unsigned code, uint32_t character, uint16_t mod) { diff --git a/input/keyboard_line.h b/input/keyboard_line.h index 90cbea36d9..022de3edc9 100644 --- a/input/keyboard_line.h +++ b/input/keyboard_line.h @@ -28,40 +28,105 @@ extern "C" { /* Keyboard line reader. Handles textual input in a direct fashion. */ typedef struct input_keyboard_line input_keyboard_line_t; -/* Calls back after return is pressed with the completed line. - * line can be NULL. */ +/** Line complete callback. + * Calls back after return is pressed with the completed line. + * Line can be NULL. + **/ typedef void (*input_keyboard_line_complete_t)(void *userdata, const char *line); typedef bool (*input_keyboard_press_t)(void *userdata, unsigned code); +/** + * input_keyboard_line_new: + * @userdata : Userdata. + * @cb : Callback function. + * + * Creates and initializes input keyboard line handle. + * Also sets callback function for keyboard line handle + * to provided callback @cb. + * + * Returns: keyboard handle on success, otherwise NULL. + **/ input_keyboard_line_t *input_keyboard_line_new(void *userdata, input_keyboard_line_complete_t cb); -/* Called on every keyboard character event. */ +/** + * input_keyboard_line_event: + * @state : Input keyboard line handle. + * @character : Inputted character. + * + * Called on every keyboard character event. + * + * Returns: true (1) on success, otherwise false (0). + **/ bool input_keyboard_line_event(input_keyboard_line_t *state, uint32_t character); -/* Returns pointer to string. The underlying buffer can be reallocated at - * any time (or be NULL), but the pointer to it remains constant - * throughout the objects lifetime. */ +/** + * input_keyboard_line_get_buffer: + * @state : Input keyboard line handle. + * + * Gets the underlying buffer of the keyboard line. + * + * The underlying buffer can be reallocated at any time + * (or be NULL), but the pointer to it remains constant + * throughout the objects lifetime. + * + * Returns: pointer to string. + **/ const char **input_keyboard_line_get_buffer( const input_keyboard_line_t *state); +/** + * input_keyboard_line_free: + * @state : Input keyboard line handle. + * + * Frees input keyboard line handle. + **/ void input_keyboard_line_free(input_keyboard_line_t *state); -/* Keyboard event utils. Called by drivers when keyboard events are fired. - * This interfaces with the global driver struct and libretro callbacks. */ +/** + * input_keyboard_event: + * @down : Keycode was pressed down? + * @code : Keycode. + * @character : Character inputted. + * @mod : TODO/FIXME: ??? + * + * Keyboard event utils. Called by drivers when keyboard events are fired. + * This interfaces with the global driver struct and libretro callbacks. + **/ void input_keyboard_event(bool down, unsigned code, uint32_t character, uint16_t mod); +/** + * input_keyboard_start_line: + * @userdata : Userdata. + * @cb : Line complete callback function. + * + * Sets function pointer for keyboard line handle. + * + * Returns: underlying buffer returned by + * input_keyboard_line_get_buffer(). + **/ const char **input_keyboard_start_line(void *userdata, input_keyboard_line_complete_t cb); -/* Wait for keys to be pressed (used for binding keys in the menu). - * Callback returns false when all polling is done. */ +/** + * input_keyboard_wait_keys: + * @userdata : Userdata. + * @cb : Callback function. + * + * Waits for keys to be pressed (used for binding keys in the menu). + * Callback returns false when all polling is done. + **/ void input_keyboard_wait_keys(void *userdata, input_keyboard_press_t cb); +/** + * input_keyboard_wait_keys_cancel: + * + * Cancels function callback set by input_keyboard_wait_keys(). + **/ void input_keyboard_wait_keys_cancel(void); #ifdef __cplusplus From cef086988d270868e66a29752c0c8728950d13e7 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Mon, 12 Jan 2015 03:20:21 +0100 Subject: [PATCH 068/156] Documents descend_alphabet/ascend_alphabet --- menu/menu_navigation.c | 22 ++++++++++++++++++++++ menu/menu_navigation.h | 22 ++++++++++++++++++++++ 2 files changed, 44 insertions(+) diff --git a/menu/menu_navigation.c b/menu/menu_navigation.c index cbde42f1a2..14d2907f6a 100644 --- a/menu/menu_navigation.c +++ b/menu/menu_navigation.c @@ -95,6 +95,17 @@ void menu_navigation_set_last(menu_handle_t *menu) driver.menu_ctx->navigation_set_last(menu); } +/** + * menu_navigation_descend_alphabet: + * @menu : menu handle + * @ptr_out : Amount of indices to 'scroll' to get + * to the next entry. + * + * Descends alphabet. + * E.g.: + * If navigation points to an entry called 'Beta', + * navigation pointer will be set to an entry called 'Alpha'. + **/ void menu_navigation_descend_alphabet(menu_handle_t *menu, size_t *ptr_out) { size_t i = 0; @@ -116,6 +127,17 @@ void menu_navigation_descend_alphabet(menu_handle_t *menu, size_t *ptr_out) driver.menu_ctx->navigation_descend_alphabet(menu, ptr_out); } +/** + * menu_navigation_ascends_alphabet: + * @menu : menu handle + * @ptr_out : Amount of indices to 'scroll' to get + * to the next entry. + * + * Ascends alphabet. + * E.g.: + * If navigation points to an entry called 'Alpha', + * navigation pointer will be set to an entry called 'Beta'. + **/ void menu_navigation_ascend_alphabet(menu_handle_t *menu, size_t *ptr_out) { size_t i = 0; diff --git a/menu/menu_navigation.h b/menu/menu_navigation.h index ce39214742..5222a46154 100644 --- a/menu/menu_navigation.h +++ b/menu/menu_navigation.h @@ -66,8 +66,30 @@ void menu_navigation_set(menu_handle_t *menu, size_t i, bool scroll); **/ void menu_navigation_set_last(menu_handle_t *menu); +/** + * menu_navigation_descend_alphabet: + * @menu : menu handle + * @ptr_out : Amount of indices to 'scroll' to get + * to the next entry. + * + * Descends alphabet. + * E.g.: + * If navigation points to an entry called 'Beta', + * navigation pointer will be set to an entry called 'Alpha'. + **/ void menu_navigation_descend_alphabet(menu_handle_t *menu, size_t *ptr_out); +/** + * menu_navigation_ascends_alphabet: + * @menu : menu handle + * @ptr_out : Amount of indices to 'scroll' to get + * to the next entry. + * + * Ascends alphabet. + * E.g.: + * If navigation points to an entry called 'Alpha', + * navigation pointer will be set to an entry called 'Beta'. + **/ void menu_navigation_ascend_alphabet(menu_handle_t *menu, size_t *ptr_out); #ifdef __cplusplus From a17788a1f8c1cfde821f192e7f104c2f6d222d83 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Mon, 12 Jan 2015 03:31:02 +0100 Subject: [PATCH 069/156] Enable LEFT/RIGHT on Load Content (History). --- menu/menu_entries_cbs.c | 3 ++- menu/menu_list.c | 4 +++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/menu/menu_entries_cbs.c b/menu/menu_entries_cbs.c index da7ce21b59..ff94c3aef4 100644 --- a/menu/menu_entries_cbs.c +++ b/menu/menu_entries_cbs.c @@ -1097,7 +1097,7 @@ static int action_toggle_save_state(unsigned type, const char *label, switch (action) { case MENU_ACTION_LEFT: - // Slot -1 is (auto) slot. + /* Slot -1 is (auto) slot. */ if (g_settings.state_slot >= 0) g_settings.state_slot--; break; @@ -2754,6 +2754,7 @@ static void menu_entries_cbs_init_bind_toggle(menu_file_list_cbs_t *cbs, case MENU_FILE_AUDIOFILTER: case MENU_FILE_CONFIG: case MENU_FILE_USE_DIRECTORY: + case MENU_FILE_PLAYLIST_ENTRY: cbs->action_toggle = action_toggle_scroll; break; case MENU_FILE_CONTENTLIST_ENTRY: diff --git a/menu/menu_list.c b/menu/menu_list.c index c89c2c3dc5..ef604d8298 100644 --- a/menu/menu_list.c +++ b/menu/menu_list.c @@ -117,7 +117,7 @@ void *menu_list_get_last_stack_actiondata(const menu_list_t *list) { if (!list) return NULL; - return file_list_get_last_actiondata(list->menu_stack); + return file_list_get_last_actiondata(list->menu_stack); } void menu_list_flush_stack(menu_list_t *list, @@ -132,6 +132,7 @@ void menu_list_flush_stack(menu_list_t *list, driver.menu->need_refresh = true; file_list_get_last(list->menu_stack, &path, &label, &type); + while (type != final_type) { menu_list_pop(list->menu_stack, &driver.menu->selection_ptr); @@ -151,6 +152,7 @@ void menu_list_flush_stack_by_needle(menu_list_t *list, driver.menu->need_refresh = true; file_list_get_last(list->menu_stack, &path, &label, &type); + while (strcmp(needle, label) != 0) { menu_list_pop(list->menu_stack, &driver.menu->selection_ptr); From 2dadadab56a8b6071cef83d0a6a958d708702998 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Mon, 12 Jan 2015 03:50:54 +0100 Subject: [PATCH 070/156] ffemu.c - Document --- record/ffemu.c | 34 ++++++++++++++++++++++++++++------ record/ffemu.h | 20 ++++++++++++++++++++ 2 files changed, 48 insertions(+), 6 deletions(-) diff --git a/record/ffemu.c b/record/ffemu.c index 744043d341..0d92125a1f 100644 --- a/record/ffemu.c +++ b/record/ffemu.c @@ -30,9 +30,19 @@ static const ffemu_backend_t *ffemu_backends[] = { NULL, }; +/** + * ffemu_find_backend: + * @ident : Identifier of driver to find. + * + * Finds a recording driver with the name @ident. + * + * Returns: recording driver handle if successful, otherwise + * NULL. + **/ const ffemu_backend_t *ffemu_find_backend(const char *ident) { unsigned i; + for (i = 0; ffemu_backends[i]; i++) { if (!strcmp(ffemu_backends[i]->ident, ident)) @@ -42,19 +52,31 @@ const ffemu_backend_t *ffemu_find_backend(const char *ident) return NULL; } +/** + * gfx_ctx_init_first: + * @backend : Recording backend handle. + * @data : Recording data handle. + * @params : Recording info parameters. + * + * Finds first suitable recording context driver and initializes. + * + * Returns: true (1) if successful, otherwise false (0). + **/ bool ffemu_init_first(const ffemu_backend_t **backend, void **data, const struct ffemu_params *params) { unsigned i; + for (i = 0; ffemu_backends[i]; i++) { void *handle = ffemu_backends[i]->init(params); - if (handle) - { - *backend = ffemu_backends[i]; - *data = handle; - return true; - } + + if (!handle) + continue; + + *backend = ffemu_backends[i]; + *data = handle; + return true; } return false; diff --git a/record/ffemu.h b/record/ffemu.h index 8844d8838e..bcf2021dcc 100644 --- a/record/ffemu.h +++ b/record/ffemu.h @@ -93,7 +93,27 @@ typedef struct ffemu_backend extern const ffemu_backend_t ffemu_ffmpeg; +/** + * ffemu_find_backend: + * @ident : Identifier of driver to find. + * + * Finds a recording driver with the name @ident. + * + * Returns: recording driver handle if successful, otherwise + * NULL. + **/ const ffemu_backend_t *ffemu_find_backend(const char *ident); + +/** + * gfx_ctx_init_first: + * @backend : Recording backend handle. + * @data : Recording data handle. + * @params : Recording info parameters. + * + * Finds first suitable recording context driver and initializes. + * + * Returns: true (1) if successful, otherwise false (0). + **/ bool ffemu_init_first(const ffemu_backend_t **backend, void **data, const struct ffemu_params *params); From 5f611f727069151a3e834e98560a6ab45b30d1fd Mon Sep 17 00:00:00 2001 From: twinaphex Date: Mon, 12 Jan 2015 04:19:57 +0100 Subject: [PATCH 071/156] More documentation for input_common.c --- core_info.c | 35 ++++++++++++++++++++++------------- gfx/gfx_context.h | 2 ++ gfx/gx/gx_gfx.h | 2 +- input/apple_input.c | 2 +- input/input_common.c | 36 ++++++++++++++++++++++++++++++++++++ input/input_common.h | 34 +++++++++++++++++++++++++++++++++- 6 files changed, 95 insertions(+), 16 deletions(-) diff --git a/core_info.c b/core_info.c index e32d283d5c..8c91fa957d 100644 --- a/core_info.c +++ b/core_info.c @@ -37,8 +37,9 @@ static void core_info_list_resolve_all_extensions( for (i = 0; i < core_info_list->count; i++) { - all_ext_len += core_info_list->list[i].supported_extensions ? - (strlen(core_info_list->list[i].supported_extensions) + 2) : 0; + if (core_info_list->list[i].supported_extensions) + all_ext_len += + (strlen(core_info_list->list[i].supported_extensions) + 2); } if (all_ext_len) @@ -48,12 +49,12 @@ static void core_info_list_resolve_all_extensions( { for (i = 0; i < core_info_list->count; i++) { - if (core_info_list->list[i].supported_extensions) - { - strlcat(core_info_list->all_ext, - core_info_list->list[i].supported_extensions, all_ext_len); - strlcat(core_info_list->all_ext, "|", all_ext_len); - } + if (!core_info_list->list[i].supported_extensions) + continue; + + strlcat(core_info_list->all_ext, + core_info_list->list[i].supported_extensions, all_ext_len); + strlcat(core_info_list->all_ext, "|", all_ext_len); } } } @@ -333,7 +334,12 @@ bool core_info_list_get_by_id(core_info_list_t *core_info_list, { core_info_t *info = (core_info_t*)&core_info_list->list[i]; - if (info && info->path && strcmp(core_id, info->path) == 0) + if (!info) + continue; + if (!info->path) + continue; + + if (!strcmp(core_id, info->path)) { *out_info = *info; return true; @@ -421,12 +427,15 @@ void core_info_list_get_supported_cores(core_info_list_t *core_info_list, if (!core) continue; - if (!core_info_does_support_file(core, path) + if (core_info_does_support_file(core, path)) + continue; + #ifdef HAVE_ZLIB - && !core_info_does_support_any_file(core, list) + if (core_info_does_support_any_file(core, list)) + continue; #endif - ) - break; + + break; } #ifdef HAVE_ZLIB diff --git a/gfx/gfx_context.h b/gfx/gfx_context.h index fc74ff3773..795225fb98 100644 --- a/gfx/gfx_context.h +++ b/gfx/gfx_context.h @@ -28,7 +28,9 @@ extern "C" { #endif +#ifndef MAX_EGLIMAGE_TEXTURES #define MAX_EGLIMAGE_TEXTURES 32 +#endif enum gfx_ctx_api { diff --git a/gfx/gx/gx_gfx.h b/gfx/gx/gx_gfx.h index 2b7b47e325..1604b79995 100644 --- a/gfx/gx/gx_gfx.h +++ b/gfx/gx/gx_gfx.h @@ -32,7 +32,7 @@ typedef struct gx_video bool keep_aspect; bool double_strike; bool rgb32; - uint32_t *menu_data; // FIXME: Should be const uint16_t*. + uint32_t *menu_data; /* FIXME: Should be const uint16_t*. */ bool menu_texture_enable; rarch_viewport_t vp; unsigned scale; diff --git a/input/apple_input.c b/input/apple_input.c index 39304352fe..1166e8f98c 100644 --- a/input/apple_input.c +++ b/input/apple_input.c @@ -185,7 +185,7 @@ int32_t apple_input_find_any_button(uint32_t port) BIT32_SET(buttons, apple->icade_buttons); if (buttons) - for (i = 0; i != 32; i ++) + for (i = 0; i < 32; i++) if (buttons & (1 << i)) return i; diff --git a/input/input_common.c b/input/input_common.c index b7e795c9c4..964434b7e3 100644 --- a/input/input_common.c +++ b/input/input_common.c @@ -110,6 +110,21 @@ const struct input_bind_map input_config_bind_map[RARCH_BIND_LIST_END_NULL] = { #endif }; +/** + * input_translate_coord_viewport: + * @mouse_x : Pointer X coordinate. + * @mouse_y : Pointer Y coordinate. + * @res_x : Scaled X coordinate. + * @res_y : Scaled Y coordinate. + * @res_screen_x : Scaled screen X coordinate. + * @res_screen_y : Scaled screen Y coordinate. + * + * Translates pointer [X,Y] coordinates into scaled screen + * coordinates based on viewport info. + * + * Returns: true (1) if successful, false if video driver doesn't support + * viewport info. + **/ bool input_translate_coord_viewport(int mouse_x, int mouse_y, int16_t *res_x, int16_t *res_y, int16_t *res_screen_x, int16_t *res_screen_y) @@ -183,6 +198,14 @@ static enum retro_key find_rk_bind(const char *str) return RETROK_UNKNOWN; } +/** + * input_translate_str_to_rk: + * @str : String to translate to key ID. + * + * Translates tring representation to key identifier. + * + * Returns: key identifier. + **/ enum retro_key input_translate_str_to_rk(const char *str) { if (strlen(str) == 1 && isalpha(*str)) @@ -201,6 +224,7 @@ enum retro_key input_translate_str_to_rk(const char *str) unsigned input_translate_str_to_bind_id(const char *str) { unsigned i; + for (i = 0; input_config_bind_map[i].valid; i++) if (!strcmp(str, input_config_bind_map[i].base)) return i; @@ -303,6 +327,7 @@ static void input_get_bind_string_joykey(char *buf, const char *prefix, if (GET_HAT_DIR(bind->joykey)) { const char *dir; + switch (GET_HAT_DIR(bind->joykey)) { case HAT_UP_MASK: @@ -388,6 +413,16 @@ void input_get_bind_string(char *buf, const struct retro_keybind *bind, } #endif +/** + * input_push_analog_dpad: + * @binds : Binds to modify. + * @mode : Which analog stick to bind D-Pad to. + * E.g: + * ANALOG_DPAD_LSTICK + * ANALOG_DPAD_RSTICK + * + * Push analog to D-Pad mappings to binds. + **/ void input_push_analog_dpad(struct retro_keybind *binds, unsigned mode) { unsigned i, j; @@ -423,6 +458,7 @@ void input_push_analog_dpad(struct retro_keybind *binds, unsigned mode) void input_pop_analog_dpad(struct retro_keybind *binds) { unsigned i; + for (i = RETRO_DEVICE_ID_JOYPAD_UP; i <= RETRO_DEVICE_ID_JOYPAD_RIGHT; i++) binds[i].joyaxis = binds[i].orig_joyaxis; } diff --git a/input/input_common.h b/input/input_common.h index f119d266af..f80ee90cd6 100644 --- a/input/input_common.h +++ b/input/input_common.h @@ -46,6 +46,21 @@ struct input_bind_map extern const struct input_bind_map input_config_bind_map[]; +/** + * input_translate_coord_viewport: + * @mouse_x : Pointer X coordinate. + * @mouse_y : Pointer Y coordinate. + * @res_x : Scaled X coordinate. + * @res_y : Scaled Y coordinate. + * @res_screen_x : Scaled screen X coordinate. + * @res_screen_y : Scaled screen Y coordinate. + * + * Translates pointer [X,Y] coordinates into scaled screen + * coordinates based on viewport info. + * + * Returns: true (1) if successful, false if video driver doesn't support + * viewport info. + **/ bool input_translate_coord_viewport(int mouse_x, int mouse_y, int16_t *res_x, int16_t *res_y, int16_t *res_screen_x, int16_t *res_screen_y); @@ -54,7 +69,14 @@ bool input_translate_coord_viewport(int mouse_x, int mouse_y, void input_get_bind_string(char *buf, const struct retro_keybind *bind, const struct retro_keybind *auto_bind, size_t size); - +/** + * input_translate_str_to_rk: + * @str : String to translate to key ID. + * + * Translates tring representation to key identifier. + * + * Returns: key identifier. + **/ enum retro_key input_translate_str_to_rk(const char *str); const char *input_config_get_prefix(unsigned user, bool meta); @@ -79,6 +101,16 @@ void input_config_parse_joy_button(config_file_t *conf, const char *prefix, void input_config_parse_joy_axis(config_file_t *conf, const char *prefix, const char *axis, struct retro_keybind *bind); +/** + * input_push_analog_dpad: + * @binds : Binds to modify. + * @mode : Which analog stick to bind D-Pad to. + * E.g: + * ANALOG_DPAD_LSTICK + * ANALOG_DPAD_RSTICK + * + * Push analog to D-Pad mappings to binds. + **/ void input_push_analog_dpad(struct retro_keybind *binds, unsigned mode); /** From 1753430d686a64b40d4a3b2fadde4897ca0f1538 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Mon, 12 Jan 2015 05:05:56 +0100 Subject: [PATCH 072/156] MOve audio drivers to audio/drivers --- Makefile.common | 28 ++--- audio/{ => drivers}/alsa.c | 4 +- audio/{ => drivers}/alsa_qsa.c | 4 +- audio/{ => drivers}/alsathread.c | 10 +- audio/{ => drivers}/coreaudio.c | 50 ++++++--- audio/{ => drivers}/dsound.c | 147 ++++++++++++++++----------- audio/{ => drivers}/gx_audio.c | 41 ++++---- audio/{ => drivers}/jack.c | 65 ++++++------ audio/{ => drivers}/nullaudio.c | 4 +- audio/{ => drivers}/openal.c | 46 +++++---- audio/{ => drivers}/opensl.c | 42 ++++---- audio/{ => drivers}/oss.c | 24 +++-- audio/{ => drivers}/ps3_audio.c | 28 ++--- audio/{ => drivers}/psp1_audio.c | 24 +++-- audio/{ => drivers}/pulse.c | 104 +++++++++++-------- audio/{ => drivers}/roar.c | 25 +++-- audio/{ => drivers}/rwebaudio.c | 10 +- audio/{ => drivers}/sdl_audio.c | 69 ++++++++----- audio/{ => drivers}/xaudio.c | 42 ++++---- audio/{ => drivers}/xenon360_audio.c | 21 ++-- gfx/context/x11_common.c | 13 ++- griffin/griffin.c | 28 ++--- 22 files changed, 481 insertions(+), 348 deletions(-) rename audio/{ => drivers}/alsa.c (99%) rename audio/{ => drivers}/alsa_qsa.c (99%) rename audio/{ => drivers}/alsathread.c (98%) rename audio/{ => drivers}/coreaudio.c (93%) rename audio/{ => drivers}/dsound.c (85%) rename audio/{ => drivers}/gx_audio.c (90%) rename audio/{ => drivers}/jack.c (89%) rename audio/{ => drivers}/nullaudio.c (97%) rename audio/{ => drivers}/openal.c (91%) rename audio/{ => drivers}/opensl.c (93%) rename audio/{ => drivers}/oss.c (93%) rename audio/{ => drivers}/ps3_audio.c (96%) rename audio/{ => drivers}/psp1_audio.c (95%) rename audio/{ => drivers}/pulse.c (88%) rename audio/{ => drivers}/roar.c (95%) rename audio/{ => drivers}/rwebaudio.c (93%) rename audio/{ => drivers}/sdl_audio.c (80%) rename audio/{ => drivers}/xaudio.c (86%) rename audio/{ => drivers}/xenon360_audio.c (93%) diff --git a/Makefile.common b/Makefile.common index e1a44fb81b..2036cb7b8a 100644 --- a/Makefile.common +++ b/Makefile.common @@ -141,7 +141,7 @@ OBJ += frontend/frontend.o \ location/nulllocation.o \ camera/nullcamera.o \ gfx/nullgfx.o \ - audio/nullaudio.o \ + audio/drivers/nullaudio.o \ input/nullinput.o \ input/nullinput_joypad.o \ input/osk/nullosk.o \ @@ -173,39 +173,39 @@ endif ifeq ($(HAVE_EMSCRIPTEN), 1) OBJ += frontend/platform/platform_emscripten.o \ input/rwebinput_input.o \ - audio/rwebaudio.o \ + audio/drivers/rwebaudio.o \ camera/rwebcam.o endif # Audio # ifeq ($(HAVE_COREAUDIO), 1) - OBJ += audio/coreaudio.o + OBJ += audio/drivers/coreaudio.o LIBS += -framework CoreServices -framework CoreAudio -framework AudioUnit endif ifeq ($(HAVE_OSS), 1) - OBJ += audio/oss.o + OBJ += audio/drivers/oss.o endif ifeq ($(HAVE_OSS_BSD), 1) - OBJ += audio/oss.o + OBJ += audio/drivers/oss.o endif ifeq ($(HAVE_ALSA), 1) - OBJ += audio/alsa.o audio/alsathread.o + OBJ += audio/drivers/alsa.o audio/drivers/alsathread.o LIBS += $(ALSA_LIBS) DEFINES += $(ALSA_CFLAGS) endif ifeq ($(HAVE_ROAR), 1) - OBJ += audio/roar.o + OBJ += audio/drivers/roar.o LIBS += $(ROAR_LIBS) DEFINES += $(ROAR_CFLAGS) endif ifeq ($(HAVE_AL), 1) - OBJ += audio/openal.o + OBJ += audio/drivers/openal.o ifeq ($(OSX),1) LIBS += -framework OpenAL else @@ -214,13 +214,13 @@ ifeq ($(HAVE_AL), 1) endif ifeq ($(HAVE_JACK),1) - OBJ += audio/jack.o + OBJ += audio/drivers/jack.o LIBS += $(JACK_LIBS) DEFINES += $(JACK_CFLAGS) endif ifeq ($(HAVE_PULSE), 1) - OBJ += audio/pulse.o + OBJ += audio/drivers/pulse.o LIBS += $(PULSE_LIBS) DEFINES += $(PULSE_CFLAGS) endif @@ -236,13 +236,13 @@ ifeq ($(HAVE_RSOUND), 1) endif ifeq ($(HAVE_DSOUND), 1) - OBJ += audio/dsound.o + OBJ += audio/drivers/dsound.o DEFINES += -DHAVE_DSOUND LIBS += -ldxguid -ldsound endif ifeq ($(HAVE_XAUDIO), 1) - OBJ += audio/xaudio.o audio/xaudio-c/xaudio-c.o + OBJ += audio/drivers/xaudio.o audio/xaudio-c/xaudio-c.o DEFINES += -DHAVE_XAUDIO LIBS += -lole32 endif @@ -449,7 +449,7 @@ ifeq ($(HAVE_SDL2), 1) endif ifeq ($(HAVE_SDL), 1) - OBJ += gfx/sdl_gfx.o input/sdl_input.o input/sdl_joypad.o audio/sdl_audio.o + OBJ += gfx/sdl_gfx.o input/sdl_input.o input/sdl_joypad.o audio/drivers/sdl_audio.o ifeq ($(HAVE_OPENGL), 1) OBJ += gfx/context/sdl_gl_ctx.o @@ -461,7 +461,7 @@ ifeq ($(HAVE_SDL), 1) endif ifeq ($(HAVE_SDL2), 1) - OBJ += gfx/sdl2_gfx.o input/sdl_input.o input/sdl_joypad.o audio/sdl_audio.o + OBJ += gfx/sdl2_gfx.o input/sdl_input.o input/sdl_joypad.o audio/drivers/sdl_audio.o ifeq ($(HAVE_OPENGL), 1) OBJ += gfx/context/sdl_gl_ctx.o diff --git a/audio/alsa.c b/audio/drivers/alsa.c similarity index 99% rename from audio/alsa.c rename to audio/drivers/alsa.c index da60885209..fa98672166 100644 --- a/audio/alsa.c +++ b/audio/drivers/alsa.c @@ -14,10 +14,10 @@ */ -#include "../driver.h" +#include "../../driver.h" #include #include -#include "../general.h" +#include "../../general.h" #define TRY_ALSA(x) if (x < 0) { \ goto error; \ diff --git a/audio/alsa_qsa.c b/audio/drivers/alsa_qsa.c similarity index 99% rename from audio/alsa_qsa.c rename to audio/drivers/alsa_qsa.c index 3d5fe60752..6fb522bbde 100644 --- a/audio/alsa_qsa.c +++ b/audio/drivers/alsa_qsa.c @@ -14,8 +14,8 @@ * If not, see . */ -#include "../general.h" -#include "../driver.h" +#include "../../general.h" +#include "../../driver.h" #define ALSA_PCM_NEW_HW_PARAMS_API #define ALSA_PCM_NEW_SW_PARAMS_API diff --git a/audio/alsathread.c b/audio/drivers/alsathread.c similarity index 98% rename from audio/alsathread.c rename to audio/drivers/alsathread.c index bdcb91caec..359603a219 100644 --- a/audio/alsathread.c +++ b/audio/drivers/alsathread.c @@ -15,10 +15,10 @@ */ -#include "../driver.h" +#include "../../driver.h" #include #include -#include "../general.h" +#include "../../general.h" #include #include @@ -284,9 +284,9 @@ static ssize_t alsa_thread_write(void *data, const void *buf, size_t size) static bool alsa_thread_alive(void *data) { alsa_thread_t *alsa = (alsa_thread_t*)data; - if (alsa) - return !alsa->is_paused; - return false; + if (!alsa) + return false; + return !alsa->is_paused; } static bool alsa_thread_stop(void *data) diff --git a/audio/coreaudio.c b/audio/drivers/coreaudio.c similarity index 93% rename from audio/coreaudio.c rename to audio/drivers/coreaudio.c index 21e968a860..84e09ae8db 100644 --- a/audio/coreaudio.c +++ b/audio/drivers/coreaudio.c @@ -14,9 +14,8 @@ * If not, see . */ - -#include "../driver.h" -#include "../general.h" +#include "../../driver.h" +#include "../../general.h" #include #include #include @@ -55,6 +54,7 @@ static bool g_interrupted; static void coreaudio_free(void *data) { coreaudio_t *dev = (coreaudio_t*)data; + if (!dev) return; @@ -82,7 +82,10 @@ static OSStatus audio_write_cb(void *userdata, const AudioTimeStamp *time_stamp, UInt32 bus_number, UInt32 number_frames, AudioBufferList *io_data) { + void *outbuf; + unsigned write_avail; coreaudio_t *dev = (coreaudio_t*)userdata; + (void)time_stamp; (void)bus_number; (void)number_frames; @@ -92,10 +95,11 @@ static OSStatus audio_write_cb(void *userdata, if (io_data->mNumberBuffers != 1) return noErr; - unsigned write_avail = io_data->mBuffers[0].mDataByteSize; - void *outbuf = io_data->mBuffers[0].mData; + write_avail = io_data->mBuffers[0].mDataByteSize; + outbuf = io_data->mBuffers[0].mData; pthread_mutex_lock(&dev->lock); + if (fifo_read_avail(dev->buffer) < write_avail) { *action_flags = kAudioUnitRenderAction_OutputIsSilence; @@ -119,6 +123,8 @@ static OSStatus audio_write_cb(void *userdata, #ifdef OSX static void choose_output_device(coreaudio_t *dev, const char* device) { + unsigned i; + AudioDeviceID *devices; AudioObjectPropertyAddress propaddr = { kAudioHardwarePropertyDevices, @@ -126,14 +132,14 @@ static void choose_output_device(coreaudio_t *dev, const char* device) kAudioObjectPropertyElementMaster }; - UInt32 size = 0; + UInt32 size = 0, deviceCount; if (AudioObjectGetPropertyDataSize(kAudioObjectSystemObject, &propaddr, 0, 0, &size) != noErr) return; - UInt32 deviceCount = size / sizeof(AudioDeviceID); - AudioDeviceID *devices = malloc(size); + deviceCount = size / sizeof(AudioDeviceID); + devices = (AudioDeviceID*)malloc(size); if (!devices || AudioObjectGetPropertyData(kAudioObjectSystemObject, &propaddr, 0, 0, &size, devices) != noErr) @@ -143,7 +149,7 @@ static void choose_output_device(coreaudio_t *dev, const char* device) propaddr.mSelector = kAudioDevicePropertyDeviceName; size = 1024; - for (unsigned i = 0; i < deviceCount; i ++) + for (i = 0; i < deviceCount; i ++) { char device_name[1024]; device_name[0] = 0; @@ -174,6 +180,10 @@ static void coreaudio_interrupt_listener(void *data, UInt32 interrupt_state) static void *coreaudio_init(const char *device, unsigned rate, unsigned latency) { + static bool session_initialized = false; + UInt32 i_size; + + (void)session_initialized; (void)device; coreaudio_t *dev = (coreaudio_t*)calloc(1, sizeof(*dev)); @@ -184,7 +194,6 @@ static void *coreaudio_init(const char *device, pthread_cond_init(&dev->cond, NULL); #ifdef IOS - static bool session_initialized = false; if (!session_initialized) { session_initialized = true; @@ -249,7 +258,7 @@ static void *coreaudio_init(const char *device, goto error; /* Check returned audio format. */ - UInt32 i_size = sizeof(real_desc);; + i_size = sizeof(real_desc);; if (AudioUnitGetProperty(dev->dev, kAudioUnitProperty_StreamFormat, kAudioUnitScope_Input, 0, &real_desc, &i_size) != noErr) goto error; @@ -333,9 +342,11 @@ static ssize_t coreaudio_write(void *data, const void *buf_, size_t size) while (!g_interrupted && size > 0) { + size_t write_avail; + pthread_mutex_lock(&dev->lock); - size_t write_avail = fifo_write_avail(dev->buffer); + write_avail = fifo_write_avail(dev->buffer); if (write_avail > size) write_avail = size; @@ -374,14 +385,16 @@ static void coreaudio_set_nonblock_state(void *data, bool state) static bool coreaudio_alive(void *data) { coreaudio_t *dev = (coreaudio_t*)data; - if (dev) - return !dev->is_paused; - return false; + if (!dev) + return false; + return !dev->is_paused; } static bool coreaudio_stop(void *data) { coreaudio_t *dev = (coreaudio_t*)data; + if (!dev) + return false; dev->is_paused = (AudioOutputUnitStop(dev->dev) == noErr) ? true : false; return dev->is_paused ? true : false; } @@ -389,6 +402,8 @@ static bool coreaudio_stop(void *data) static bool coreaudio_start(void *data) { coreaudio_t *dev = (coreaudio_t*)data; + if (!dev) + return false; dev->is_paused = (AudioOutputUnitStart(dev->dev) == noErr) ? false : true; return dev->is_paused ? false : true; } @@ -401,10 +416,13 @@ static bool coreaudio_use_float(void *data) static size_t coreaudio_write_avail(void *data) { + size_t avail; coreaudio_t *dev = (coreaudio_t*)data; + pthread_mutex_lock(&dev->lock); - size_t avail = fifo_write_avail(dev->buffer); + avail = fifo_write_avail(dev->buffer); pthread_mutex_unlock(&dev->lock); + return avail; } diff --git a/audio/dsound.c b/audio/drivers/dsound.c similarity index 85% rename from audio/dsound.c rename to audio/drivers/dsound.c index ace28c8321..f30c0bad7e 100644 --- a/audio/dsound.c +++ b/audio/drivers/dsound.c @@ -39,7 +39,7 @@ static DSMIXBINVOLUMEPAIR dsmbvp[8] = { static DSMIXBINS dsmb; #endif -#include "../driver.h" +#include "../../driver.h" #include #include #include @@ -53,7 +53,7 @@ static DSMIXBINS dsmb; #endif #include #include -#include "../general.h" +#include "../../general.h" typedef struct dsound { @@ -93,21 +93,25 @@ struct audio_lock DWORD size2; }; -static inline bool grab_region(dsound_t *ds, DWORD write_ptr, struct audio_lock *region) +static inline bool grab_region(dsound_t *ds, DWORD write_ptr, + struct audio_lock *region) { - HRESULT res = IDirectSoundBuffer_Lock(ds->dsb, write_ptr, CHUNK_SIZE, ®ion->chunk1, ®ion->size1, ®ion->chunk2, ®ion->size2, 0); + const char *err; + HRESULT res = IDirectSoundBuffer_Lock(ds->dsb, write_ptr, CHUNK_SIZE, + ®ion->chunk1, ®ion->size1, ®ion->chunk2, ®ion->size2, 0); + if (res == DSERR_BUFFERLOST) { res = IDirectSoundBuffer_Restore(ds->dsb); if (res != DS_OK) return false; - res = IDirectSoundBuffer_Lock(ds->dsb, write_ptr, CHUNK_SIZE, ®ion->chunk1, ®ion->size1, ®ion->chunk2, ®ion->size2, 0); + res = IDirectSoundBuffer_Lock(ds->dsb, write_ptr, CHUNK_SIZE, + ®ion->chunk1, ®ion->size1, ®ion->chunk2, ®ion->size2, 0); if (res != DS_OK) return false; } - const char *err; switch (res) { case DSERR_BUFFERLOST: @@ -143,34 +147,43 @@ static inline void release_region(dsound_t *ds, const struct audio_lock *region) static DWORD CALLBACK dsound_thread(PVOID data) { + DWORD write_ptr; dsound_t *ds = (dsound_t*)data; + SetThreadPriority(GetCurrentThread(), THREAD_PRIORITY_TIME_CRITICAL); - DWORD write_ptr; get_positions(ds, NULL, &write_ptr); write_ptr = (write_ptr + ds->buffer_size / 2) % ds->buffer_size; while (ds->thread_alive) { - DWORD read_ptr; + struct audio_lock region; + DWORD read_ptr, avail, fifo_avail; get_positions(ds, &read_ptr, NULL); - DWORD avail = write_avail(read_ptr, write_ptr, ds->buffer_size); + avail = write_avail(read_ptr, write_ptr, ds->buffer_size); EnterCriticalSection(&ds->crit); - DWORD fifo_avail = fifo_read_avail(ds->buffer); + fifo_avail = fifo_read_avail(ds->buffer); LeaveCriticalSection(&ds->crit); - // No space to write, or we don't have data in our fifo, but we can wait some time before it underruns ... if (avail < CHUNK_SIZE || ((fifo_avail < CHUNK_SIZE) && (avail < ds->buffer_size / 2))) { + /* 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. :( + + /* We could opt for using the notification interface, + * but it is not guaranteed to work, so use high + * priority sleeping patterns. + */ } - else if (fifo_avail < CHUNK_SIZE) // Got space to write, but nothing in FIFO (underrun), fill block with silence. + else if (fifo_avail < CHUNK_SIZE) { - struct audio_lock region; + /* Got space to write, but nothing in FIFO (underrun), + * fill block with silence. */ + if (!grab_region(ds, write_ptr, ®ion)) { ds->thread_alive = false; @@ -184,9 +197,10 @@ static DWORD CALLBACK dsound_thread(PVOID data) release_region(ds, ®ion); write_ptr = (write_ptr + region.size1 + region.size2) % ds->buffer_size; } - else // All is good. Pull from it and notify FIFO :D + else { - struct audio_lock region; + /* All is good. Pull from it and notify FIFO. */ + if (!grab_region(ds, write_ptr, ®ion)) { ds->thread_alive = false; @@ -213,13 +227,13 @@ static DWORD CALLBACK dsound_thread(PVOID data) static void dsound_stop_thread(dsound_t *ds) { - if (ds->thread) - { - ds->thread_alive = false; - WaitForSingleObject(ds->thread, INFINITE); - CloseHandle(ds->thread); - ds->thread = NULL; - } + if (!ds->thread) + return; + + ds->thread_alive = false; + WaitForSingleObject(ds->thread, INFINITE); + CloseHandle(ds->thread); + ds->thread = NULL; } static bool dsound_start_thread(dsound_t *ds) @@ -237,11 +251,12 @@ static bool dsound_start_thread(dsound_t *ds) static void dsound_clear_buffer(dsound_t *ds) { - IDirectSoundBuffer_SetCurrentPosition(ds->dsb, 0); void *ptr; DWORD size; + IDirectSoundBuffer_SetCurrentPosition(ds->dsb, 0); - if (IDirectSoundBuffer_Lock(ds->dsb, 0, 0, &ptr, &size, NULL, NULL, DSBLOCK_ENTIREBUFFER) == DS_OK) + if (IDirectSoundBuffer_Lock(ds->dsb, 0, 0, &ptr, &size, + NULL, NULL, DSBLOCK_ENTIREBUFFER) == DS_OK) { memset(ptr, 0, size); IDirectSoundBuffer_Unlock(ds->dsb, ptr, size, NULL, 0); @@ -251,34 +266,35 @@ static void dsound_clear_buffer(dsound_t *ds) static void dsound_free(void *data) { dsound_t *ds = (dsound_t*)data; - if (ds) + + if (!ds) + return; + + if (ds->thread) { - if (ds->thread) - { - ds->thread_alive = false; - WaitForSingleObject(ds->thread, INFINITE); - CloseHandle(ds->thread); - } - - DeleteCriticalSection(&ds->crit); - - if (ds->dsb) - { - IDirectSoundBuffer_Stop(ds->dsb); - IDirectSoundBuffer_Release(ds->dsb); - } - - if (ds->ds) - IDirectSound_Release(ds->ds); - - if (ds->event) - CloseHandle(ds->event); - - if (ds->buffer) - fifo_free(ds->buffer); - - free(ds); + ds->thread_alive = false; + WaitForSingleObject(ds->thread, INFINITE); + CloseHandle(ds->thread); } + + DeleteCriticalSection(&ds->crit); + + if (ds->dsb) + { + IDirectSoundBuffer_Stop(ds->dsb); + IDirectSoundBuffer_Release(ds->dsb); + } + + if (ds->ds) + IDirectSound_Release(ds->ds); + + if (ds->event) + CloseHandle(ds->event); + + if (ds->buffer) + fifo_free(ds->buffer); + + free(ds); } struct dsound_dev @@ -291,7 +307,9 @@ struct dsound_dev static BOOL CALLBACK enumerate_cb(LPGUID guid, LPCSTR desc, LPCSTR module, LPVOID context) { struct dsound_dev *dev = (struct dsound_dev*)context; + RARCH_LOG("\t%u: %s\n", dev->total_count, desc); + if (dev->device == dev->total_count) dev->guid = guid; dev->total_count++; @@ -303,8 +321,8 @@ static void *dsound_init(const char *device, unsigned rate, unsigned latency) WAVEFORMATEX wfx = {0}; DSBUFFERDESC bufdesc = {0}; struct dsound_dev dev = {0}; - dsound_t *ds = (dsound_t*)calloc(1, sizeof(*ds)); + if (!ds) goto error; @@ -384,14 +402,17 @@ error: static bool dsound_stop(void *data) { dsound_t *ds = (dsound_t*)data; + dsound_stop_thread(ds); ds->is_paused = (IDirectSoundBuffer_Stop(ds->dsb) == DS_OK) ? true : false; + return (ds->is_paused) ? true : false; } static bool dsound_start(void *data) { dsound_t *ds = (dsound_t*)data; + dsound_clear_buffer(ds); if (!dsound_start_thread(ds)) @@ -404,30 +425,34 @@ static bool dsound_start(void *data) static bool dsound_alive(void *data) { dsound_t *ds = (dsound_t*)data; - if (ds) - return !ds->is_paused; - return false; + + if (!ds) + return false; + return !ds->is_paused; } static void dsound_set_nonblock_state(void *data, bool state) { dsound_t *ds = (dsound_t*)data; - ds->nonblock = state; + if (ds) + ds->nonblock = state; } static ssize_t dsound_write(void *data, const void *buf_, size_t size) { + size_t written = 0; dsound_t *ds = (dsound_t*)data; const uint8_t *buf = (const uint8_t*)buf_; if (!ds->thread_alive) return -1; - size_t written = 0; while (size > 0) { + size_t avail; + EnterCriticalSection(&ds->crit); - size_t avail = fifo_write_avail(ds->buffer); + avail = fifo_write_avail(ds->buffer); if (avail > size) avail = size; @@ -450,9 +475,11 @@ static ssize_t dsound_write(void *data, const void *buf_, size_t size) static size_t dsound_write_avail(void *data) { + size_t avail; dsound_t *ds = (dsound_t*)data; + EnterCriticalSection(&ds->crit); - size_t avail = fifo_write_avail(ds->buffer); + avail = fifo_write_avail(ds->buffer); LeaveCriticalSection(&ds->crit); return avail; } diff --git a/audio/gx_audio.c b/audio/drivers/gx_audio.c similarity index 90% rename from audio/gx_audio.c rename to audio/drivers/gx_audio.c index 7f99831da9..af2f30a3d0 100644 --- a/audio/gx_audio.c +++ b/audio/drivers/gx_audio.c @@ -14,7 +14,7 @@ * If not, see . */ -#include "../driver.h" +#include "../../driver.h" #include #include #include "../general.h" @@ -27,7 +27,7 @@ #include #endif -#include "../gfx/gx/sdk_defines.h" +#include "../../gfx/gx/sdk_defines.h" #define CHUNK_FRAMES 64 #define CHUNK_SIZE (CHUNK_FRAMES * sizeof(uint32_t)) @@ -63,20 +63,20 @@ static void dma_callback(void) { gx_audio_t *wa = (gx_audio_t*)gx_audio_data; - if (!stop_audio) - { - /* Erase last chunk to avoid repeating audio. */ - memset(wa->data[wa->dma_busy], 0, CHUNK_SIZE); + if (stop_audio) + return; - wa->dma_busy = wa->dma_next; - wa->dma_next = (wa->dma_next + 1) & (BLOCKS - 1); + /* Erase last chunk to avoid repeating audio. */ + memset(wa->data[wa->dma_busy], 0, CHUNK_SIZE); - DCFlushRange(wa->data[wa->dma_next], CHUNK_SIZE); + wa->dma_busy = wa->dma_next; + wa->dma_next = (wa->dma_next + 1) & (BLOCKS - 1); - AIInitDMA((uint32_t)wa->data[wa->dma_next], CHUNK_SIZE); + DCFlushRange(wa->data[wa->dma_next], CHUNK_SIZE); - OSSignalCond(wa->cond); - } + AIInitDMA((uint32_t)wa->data[wa->dma_next], CHUNK_SIZE); + + OSSignalCond(wa->cond); } static void *gx_audio_init(const char *device, @@ -135,6 +135,7 @@ static ssize_t gx_audio_write(void *data, const void *buf_, size_t size) while (frames) { size_t to_write = CHUNK_FRAMES - wa->write_ptr; + if (frames < to_write) to_write = frames; @@ -178,15 +179,17 @@ static void gx_audio_set_nonblock_state(void *data, bool state) { gx_audio_t *wa = (gx_audio_t*)data; - if (!wa) - return; - - wa->nonblock = state; + if (wa) + wa->nonblock = state; } static bool gx_audio_start(void *data) { gx_audio_t *wa = (gx_audio_t*)data; + + if (!wa) + return false; + AIStartDMA(); wa->is_paused = false; return true; @@ -195,9 +198,9 @@ static bool gx_audio_start(void *data) static bool gx_audio_alive(void *data) { gx_audio_t *wa = (gx_audio_t*)data; - if (wa) - return !wa->is_paused; - return false; + if (!wa) + return false; + return !wa->is_paused; } static void gx_audio_free(void *data) diff --git a/audio/jack.c b/audio/drivers/jack.c similarity index 89% rename from audio/jack.c rename to audio/drivers/jack.c index 4f63f40c0c..63228b1cd2 100644 --- a/audio/jack.c +++ b/audio/drivers/jack.c @@ -14,9 +14,9 @@ */ -#include "../driver.h" +#include "../../driver.h" #include -#include "../general.h" +#include "../../general.h" #include #include @@ -46,18 +46,18 @@ typedef struct jack static int process_cb(jack_nframes_t nframes, void *data) { int i; - jack_nframes_t f; + jack_nframes_t f, avail[2], min_avail; jack_t *jd = (jack_t*)data; + if (nframes <= 0) { pthread_cond_signal(&jd->cond); return 0; } - jack_nframes_t avail[2]; avail[0] = jack_ringbuffer_read_space(jd->buffer[0]); avail[1] = jack_ringbuffer_read_space(jd->buffer[1]); - jack_nframes_t min_avail = ((avail[0] < avail[1]) ? avail[0] : avail[1]) / sizeof(jack_default_audio_sample_t); + min_avail = ((avail[0] < avail[1]) ? avail[0] : avail[1]) / sizeof(jack_default_audio_sample_t); if (min_avail > nframes) min_avail = nframes; @@ -69,9 +69,7 @@ static int process_cb(jack_nframes_t nframes, void *data) jack_ringbuffer_read(jd->buffer[i], (char*)out, min_avail * sizeof(jack_default_audio_sample_t)); for (f = min_avail; f < nframes; f++) - { out[f] = 0.0f; - } } pthread_cond_signal(&jd->cond); return 0; @@ -80,6 +78,10 @@ static int process_cb(jack_nframes_t nframes, void *data) static void shutdown_cb(void *data) { jack_t *jd = (jack_t*)data; + + if (!jd) + return; + jd->shutdown = true; pthread_cond_signal(&jd->cond); } @@ -88,8 +90,8 @@ static int parse_ports(char **dest_ports, const char **jports) { int i; char *save; - const char *con = strtok_r(g_settings.audio.device, ",", &save); int parsed = 0; + const char *con = strtok_r(g_settings.audio.device, ",", &save); if (con) dest_ports[parsed++] = strdup(con); @@ -105,11 +107,10 @@ static int parse_ports(char **dest_ports, const char **jports) static size_t find_buffersize(jack_t *jd, int latency) { - int i; + int i, buffer_frames, min_buffer_frames, jack_latency = 0; + jack_latency_range_t range; int frames = latency * g_settings.audio.out_rate / 1000; - jack_latency_range_t range; - int jack_latency = 0; for (i = 0; i < 2; i++) { jack_port_get_latency_range(jd->ports[i], JackPlaybackLatency, &range); @@ -119,8 +120,9 @@ static size_t find_buffersize(jack_t *jd, int latency) RARCH_LOG("JACK: Jack latency is %d frames.\n", jack_latency); - int buffer_frames = frames - jack_latency; - int min_buffer_frames = jack_get_buffer_size(jd->client) * 2; + buffer_frames = frames - jack_latency; + min_buffer_frames = jack_get_buffer_size(jd->client) * 2; + RARCH_LOG("JACK: Minimum buffer size is %d frames.\n", min_buffer_frames); if (buffer_frames < min_buffer_frames) @@ -132,17 +134,17 @@ static size_t find_buffersize(jack_t *jd, int latency) static void *ja_init(const char *device, unsigned rate, unsigned latency) { int i; + const char **jports = NULL; + char *dest_ports[2]; + size_t bufsize = 0; + int parsed = 0; jack_t *jd = (jack_t*)calloc(1, sizeof(jack_t)); + if (!jd) return NULL; pthread_cond_init(&jd->cond, NULL); pthread_mutex_init(&jd->cond_lock, NULL); - - const char **jports = NULL; - char *dest_ports[2]; - size_t bufsize = 0; - int parsed = 0; jd->client = jack_client_open("RetroArch", JackNullOption, NULL); if (jd->client == NULL) @@ -214,12 +216,12 @@ error: static size_t write_buffer(jack_t *jd, const float *buf, size_t size) { int i; - size_t j; + size_t j, frames, written = 0; jack_default_audio_sample_t out_deinterleaved_buffer[2][AUDIO_CHUNK_SIZE_NONBLOCKING * AUDIO_MAX_RATIO]; - size_t frames = FRAMES(size); + frames = FRAMES(size); - // Avoid buffer overflow if a DSP plugin generated a huge number of frames + /* Avoid buffer overflow if a DSP plugin generated a huge number of frames. */ if (frames > AUDIO_CHUNK_SIZE_NONBLOCKING * AUDIO_MAX_RATIO) frames = AUDIO_CHUNK_SIZE_NONBLOCKING * AUDIO_MAX_RATIO; @@ -227,21 +229,19 @@ static size_t write_buffer(jack_t *jd, const float *buf, size_t size) for (j = 0; j < frames; j++) out_deinterleaved_buffer[i][j] = buf[j * 2 + i]; - size_t written = 0; while (written < frames) { + size_t avail[2], min_avail, write_frames; if (jd->shutdown) return 0; - size_t avail[2] = { - jack_ringbuffer_write_space(jd->buffer[0]), - jack_ringbuffer_write_space(jd->buffer[1]), - }; + avail[0] = jack_ringbuffer_write_space(jd->buffer[0]); + avail[1] = jack_ringbuffer_write_space(jd->buffer[1]); - size_t min_avail = avail[0] < avail[1] ? avail[0] : avail[1]; + min_avail = avail[0] < avail[1] ? avail[0] : avail[1]; min_avail /= sizeof(float); - size_t write_frames = frames - written > min_avail ? min_avail : frames - written; + write_frames = frames - written > min_avail ? min_avail : frames - written; if (write_frames > 0) { @@ -284,15 +284,16 @@ static bool ja_stop(void *data) static bool ja_alive(void *data) { jack_t *jd = (jack_t*)data; - if (jd) - return !jd->is_paused; - return false; + if (!jd) + return false; + return !jd->is_paused; } static void ja_set_nonblock_state(void *data, bool state) { jack_t *jd = (jack_t*)data; - jd->nonblock = state; + if (jd) + jd->nonblock = state; } static bool ja_start(void *data) diff --git a/audio/nullaudio.c b/audio/drivers/nullaudio.c similarity index 97% rename from audio/nullaudio.c rename to audio/drivers/nullaudio.c index 5ead09c472..84a87f4f81 100644 --- a/audio/nullaudio.c +++ b/audio/drivers/nullaudio.c @@ -13,8 +13,8 @@ * If not, see . */ -#include "../general.h" -#include "../driver.h" +#include "../../general.h" +#include "../../driver.h" static void *null_audio_init(const char *device, unsigned rate, unsigned latency) { diff --git a/audio/openal.c b/audio/drivers/openal.c similarity index 91% rename from audio/openal.c rename to audio/drivers/openal.c index dd1ab31837..49bc5399fa 100644 --- a/audio/openal.c +++ b/audio/drivers/openal.c @@ -13,8 +13,8 @@ * If not, see . */ -#include "../driver.h" -#include "../general.h" +#include "../../driver.h" +#include "../../general.h" #ifdef __APPLE__ #include @@ -56,6 +56,7 @@ typedef struct al static void al_free(void *data) { al_t *al = (al_t*)data; + if (!al) return; @@ -78,24 +79,27 @@ static void al_free(void *data) static void *al_init(const char *device, unsigned rate, unsigned latency) { + al_t *al; + (void)device; - al_t *al = (al_t*)calloc(1, sizeof(al_t)); + + al = (al_t*)calloc(1, sizeof(al_t)); if (!al) return NULL; al->handle = alcOpenDevice(NULL); - if (al->handle == NULL) + if (!al->handle) goto error; al->ctx = alcCreateContext(al->handle, NULL); - if (al->ctx == NULL) + if (!al->ctx) goto error; alcMakeContextCurrent(al->ctx); al->rate = rate; - // We already use one buffer for tmpbuf. + /* We already use one buffer for tmpbuf. */ al->num_buffers = (latency * rate * 2 * sizeof(int16_t)) / (1000 * BUFSIZE) - 1; if (al->num_buffers < 2) al->num_buffers = 2; @@ -126,14 +130,12 @@ static bool al_unqueue_buffers(al_t *al) alGetSourcei(al->source, AL_BUFFERS_PROCESSED, &val); - if (val > 0) - { - alSourceUnqueueBuffers(al->source, val, &al->res_buf[al->res_ptr]); - al->res_ptr += val; - return true; - } + if (val <= 0) + return false; - return false; + alSourceUnqueueBuffers(al->source, val, &al->res_buf[al->res_ptr]); + al->res_ptr += val; + return true; } static bool al_get_buffer(al_t *al, ALuint *buffer) @@ -169,11 +171,14 @@ static ssize_t al_write(void *data, const void *buf_, size_t size) { al_t *al = (al_t*)data; const uint8_t *buf = (const uint8_t*)buf_; - size_t written = 0; + while (size) { + ALint val; + ALuint buffer; size_t rc = al_fill_internal_buf(al, buf, size); + written += rc; buf += rc; size -= rc; @@ -181,7 +186,6 @@ static ssize_t al_write(void *data, const void *buf_, size_t size) if (al->tmpbuf_ptr != BUFSIZE) break; - ALuint buffer; if (!al_get_buffer(al, &buffer)) break; @@ -191,7 +195,6 @@ static ssize_t al_write(void *data, const void *buf_, size_t size) if (alGetError() != AL_NO_ERROR) return -1; - ALint val; alGetSourcei(al->source, AL_SOURCE_STATE, &val); if (val != AL_PLAYING) alSourcePlay(al->source); @@ -214,15 +217,16 @@ static bool al_stop(void *data) static bool al_alive(void *data) { al_t *al = (al_t*)data; - if (al) - return !al->is_paused; - return false; + if (!al) + return false; + return !al->is_paused; } static void al_set_nonblock_state(void *data, bool state) { al_t *al = (al_t*)data; - al->nonblock = state; + if (al) + al->nonblock = state; } static bool al_start(void *data) @@ -243,7 +247,7 @@ static size_t al_write_avail(void *data) static size_t al_buffer_size(void *data) { al_t *al = (al_t*)data; - return (al->num_buffers + 1) * BUFSIZE; // Also got tmpbuf. + return (al->num_buffers + 1) * BUFSIZE; /* Also got tmpbuf. */ } static bool al_use_float(void *data) diff --git a/audio/opensl.c b/audio/drivers/opensl.c similarity index 93% rename from audio/opensl.c rename to audio/drivers/opensl.c index b14d2eabf8..76292016f3 100644 --- a/audio/opensl.c +++ b/audio/drivers/opensl.c @@ -14,8 +14,8 @@ * If not, see . */ -#include "../driver.h" -#include "../general.h" +#include "../../driver.h" +#include "../../general.h" #include #include @@ -23,7 +23,7 @@ #include #endif -// Helper macros, COM-style! +/* Helper macros, COM-style. */ #define SLObjectItf_Realize(a, ...) ((*(a))->Realize(a, __VA_ARGS__)) #define SLObjectItf_GetInterface(a, ...) ((*(a))->GetInterface(a, __VA_ARGS__)) #define SLObjectItf_Destroy(a) ((*(a))->Destroy((a))) @@ -100,20 +100,23 @@ static void sl_free(void *data) static void *sl_init(const char *device, unsigned rate, unsigned latency) { unsigned i; - (void)device; - + SLInterfaceID id; + SLboolean req; + SLresult res; + sl_t *sl; SLDataFormat_PCM fmt_pcm = {0}; SLDataSource audio_src = {0}; SLDataSink audio_sink = {0}; - SLDataLocator_AndroidSimpleBufferQueue loc_bufq = {0}; SLDataLocator_OutputMix loc_outmix = {0}; - SLInterfaceID id = SL_IID_ANDROIDSIMPLEBUFFERQUEUE; - SLboolean req = SL_BOOLEAN_TRUE; + (void)device; - SLresult res = 0; - sl_t *sl = (sl_t*)calloc(1, sizeof(sl_t)); + id = SL_IID_ANDROIDSIMPLEBUFFERQUEUE; + req = SL_BOOLEAN_TRUE; + + res = 0; + sl = (sl_t*)calloc(1, sizeof(sl_t)); if (!sl) goto error; @@ -154,7 +157,7 @@ static void *sl_init(const char *device, unsigned rate, unsigned latency) fmt_pcm.bitsPerSample = 16; fmt_pcm.containerSize = 16; fmt_pcm.channelMask = SL_SPEAKER_FRONT_LEFT | SL_SPEAKER_FRONT_RIGHT; - fmt_pcm.endianness = SL_BYTEORDER_LITTLEENDIAN; // Android only. + fmt_pcm.endianness = SL_BYTEORDER_LITTLEENDIAN; /* Android only. */ audio_src.pLocator = &loc_bufq; audio_src.pFormat = &fmt_pcm; @@ -180,7 +183,7 @@ static void *sl_init(const char *device, unsigned rate, unsigned latency) (*sl->buffer_queue)->RegisterCallback(sl->buffer_queue, opensl_callback, sl); - // Enqueue a bit to get stuff rolling. + /* Enqueue a bit to get stuff rolling. */ sl->buffered_blocks = sl->buf_count; sl->buffer_index = 0; for (i = 0; i < sl->buf_count; i++) @@ -207,15 +210,16 @@ static bool sl_stop(void *data) static bool sl_alive(void *data) { sl_t *sl = (sl_t*)data; - if (sl) - return !sl->is_paused; - return false; + if (!sl) + return false; + return !sl->is_paused; } static void sl_set_nonblock_state(void *data, bool state) { sl_t *sl = (sl_t*)data; - sl->nonblock = state; + if (sl) + sl->nonblock = state; } static bool sl_start(void *data) @@ -229,12 +233,13 @@ static bool sl_start(void *data) static ssize_t sl_write(void *data, const void *buf_, size_t size) { sl_t *sl = (sl_t*)data; - size_t written = 0; const uint8_t *buf = (const uint8_t*)buf_; while (size) { + size_t avail_write; + if (sl->nonblock) { if (sl->buffered_blocks == sl->buf_count) @@ -248,7 +253,8 @@ static ssize_t sl_write(void *data, const void *buf_, size_t size) slock_unlock(sl->lock); } - size_t avail_write = min(sl->buf_size - sl->buffer_ptr, size); + avail_write = min(sl->buf_size - sl->buffer_ptr, size); + if (avail_write) { memcpy(sl->buffer[sl->buffer_index] + sl->buffer_ptr, buf, avail_write); diff --git a/audio/oss.c b/audio/drivers/oss.c similarity index 93% rename from audio/oss.c rename to audio/drivers/oss.c index 00c5e9e09d..7ba2baaf65 100644 --- a/audio/oss.c +++ b/audio/drivers/oss.c @@ -17,8 +17,8 @@ #include "config.h" #endif -#include "driver.h" -#include "general.h" +#include "../../driver.h" +#include "../../general.h" #include #ifdef HAVE_OSS_BSD @@ -43,7 +43,9 @@ static bool oss_is_paused; static void *oss_init(const char *device, unsigned rate, unsigned latency) { + int frags, frag, channels, format, new_rate; int *fd = (int*)calloc(1, sizeof(int)); + if (fd == NULL) return NULL; @@ -59,15 +61,14 @@ static void *oss_init(const char *device, unsigned rate, unsigned latency) return NULL; } - int frags = (latency * rate * 4) / (1000 * (1 << 10)); - int frag = (frags << 16) | 10; + frags = (latency * rate * 4) / (1000 * (1 << 10)); + frag = (frags << 16) | 10; if (ioctl(*fd, SNDCTL_DSP_SETFRAGMENT, &frag) < 0) RARCH_WARN("Cannot set fragment sizes. Latency might not be as expected ...\n"); - int channels = 2; - int format = is_little_endian() ? - AFMT_S16_LE : AFMT_S16_BE; + channels = 2; + format = is_little_endian() ? AFMT_S16_LE : AFMT_S16_BE; if (ioctl(*fd, SNDCTL_DSP_CHANNELS, &channels) < 0) { @@ -85,7 +86,8 @@ static void *oss_init(const char *device, unsigned rate, unsigned latency) return NULL; } - int new_rate = rate; + new_rate = rate; + if (ioctl(*fd, SNDCTL_DSP_SPEED, &new_rate) < 0) { close(*fd); @@ -105,12 +107,12 @@ static void *oss_init(const char *device, unsigned rate, unsigned latency) static ssize_t oss_write(void *data, const void *buf, size_t size) { + ssize_t ret; int *fd = (int*)data; if (size == 0) return 0; - ssize_t ret; if ((ret = write(*fd, buf, size)) < 0) { if (errno == EAGAIN && (fcntl(*fd, F_GETFL) & O_NONBLOCK)) @@ -125,6 +127,7 @@ static ssize_t oss_write(void *data, const void *buf, size_t size) static bool oss_stop(void *data) { int *fd = (int*)data; + ioctl(*fd, SNDCTL_DSP_RESET, 0); oss_is_paused = true; return true; @@ -145,8 +148,9 @@ static bool oss_alive(void *data) static void oss_set_nonblock_state(void *data, bool state) { - int *fd = (int*)data; int rc; + int *fd = (int*)data; + if (state) rc = fcntl(*fd, F_SETFL, fcntl(*fd, F_GETFL) | O_NONBLOCK); else diff --git a/audio/ps3_audio.c b/audio/drivers/ps3_audio.c similarity index 96% rename from audio/ps3_audio.c rename to audio/drivers/ps3_audio.c index 082c5f100e..60fe4a1da1 100644 --- a/audio/ps3_audio.c +++ b/audio/drivers/ps3_audio.c @@ -46,17 +46,16 @@ static void event_loop(void *data) static void event_loop(uint64_t data) #endif { - ps3_audio_t *aud = data; + float out_tmp[CELL_AUDIO_BLOCK_SAMPLES * AUDIO_CHANNELS] + __attribute__((aligned(16))); sys_event_queue_t id; sys_ipc_key_t key; sys_event_t event; + ps3_audio_t *aud = data; cellAudioCreateNotifyEventQueue(&id, &key); cellAudioSetNotifyEventQueue(key); - float out_tmp[CELL_AUDIO_BLOCK_SAMPLES * AUDIO_CHANNELS] - __attribute__((aligned(16))); - while (!aud->quit_thread) { sys_event_queue_receive(id, &event, SYS_NO_TIMEOUT); @@ -80,16 +79,19 @@ static void event_loop(uint64_t data) static void *ps3_audio_init(const char *device, unsigned rate, unsigned latency) { + CellAudioPortParam params; + ps3_audio_t *data; + (void)latency; (void)device; (void)rate; - ps3_audio_t *data = calloc(1, sizeof(*data)); + data = calloc(1, sizeof(*data)); if (!data) return NULL; - CellAudioPortParam params; cellAudioInit(); + params.numChannels = AUDIO_CHANNELS; params.numBlocks = AUDIO_BLOCKS; #ifdef HAVE_HEADSET @@ -151,15 +153,14 @@ static ssize_t ps3_audio_write(void *data, const void *buf, size_t size) if (fifo_write_avail(aud->buffer) < size) return 0; } - else - { - while (fifo_write_avail(aud->buffer) < size) - sys_lwcond_wait(&aud->cond, 0); - } + + while (fifo_write_avail(aud->buffer) < size) + sys_lwcond_wait(&aud->cond, 0); sys_lwmutex_lock(&aud->lock, SYS_NO_TIMEOUT); fifo_write(aud->buffer, buf, size); sys_lwmutex_unlock(&aud->lock); + return size; } @@ -188,13 +189,16 @@ static bool ps3_audio_start(void *data) static bool ps3_audio_alive(void *data) { ps3_audio_t *aud = data; + if (!aud) + return false; return aud->started; } static void ps3_audio_set_nonblock_state(void *data, bool toggle) { ps3_audio_t *aud = data; - aud->nonblocking = toggle; + if (aud) + aud->nonblocking = toggle; } static void ps3_audio_free(void *data) diff --git a/audio/psp1_audio.c b/audio/drivers/psp1_audio.c similarity index 95% rename from audio/psp1_audio.c rename to audio/drivers/psp1_audio.c index b009e2a2c2..1edd85bb9f 100644 --- a/audio/psp1_audio.c +++ b/audio/drivers/psp1_audio.c @@ -15,8 +15,8 @@ * If not, see . */ -#include "../general.h" -#include "../driver.h" +#include "../../general.h" +#include "../../driver.h" #include #include @@ -71,10 +71,12 @@ 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; - psp1_audio_t* psp = (psp1_audio_t*)calloc(1, sizeof(psp1_audio_t)); + psp = (psp1_audio_t*)calloc(1, sizeof(psp1_audio_t)); if (!psp) return NULL; @@ -103,12 +105,13 @@ static void *psp_audio_init(const char *device, static void psp_audio_free(void *data) { + SceUInt timeout = 100000; psp1_audio_t* psp = (psp1_audio_t*)data; if(!psp) return; - psp->running = false; - SceUInt timeout = 100000; + psp->running = false; + sceKernelWaitThreadEnd(psp->thread, &timeout); sceKernelDeleteThread(psp->thread); @@ -153,14 +156,15 @@ static ssize_t psp_audio_write(void *data, const void *buf, size_t size) static bool psp_audio_alive(void *data) { psp1_audio_t* psp = (psp1_audio_t*)data; - if (psp) - return psp->running; - return false; + if (!psp) + return false; + return psp->running; } static bool psp_audio_stop(void *data) { SceKernelThreadRunStatus runStatus; + SceUInt timeout = 100000; psp1_audio_t* psp = (psp1_audio_t*)data; runStatus.size = sizeof(SceKernelThreadRunStatus); @@ -172,7 +176,6 @@ static bool psp_audio_stop(void *data) return false; psp->running = false; - SceUInt timeout = 100000; sceKernelWaitThreadEnd(psp->thread, &timeout); return true; @@ -201,7 +204,8 @@ static bool psp_audio_start(void *data) static void psp_audio_set_nonblock_state(void *data, bool toggle) { psp1_audio_t* psp = (psp1_audio_t*)data; - psp->nonblocking = toggle; + if (psp) + psp->nonblocking = toggle; } static bool psp_audio_use_float(void *data) diff --git a/audio/pulse.c b/audio/drivers/pulse.c similarity index 88% rename from audio/pulse.c rename to audio/drivers/pulse.c index 102a298e48..dd7e1e9289 100644 --- a/audio/pulse.c +++ b/audio/drivers/pulse.c @@ -14,8 +14,8 @@ */ -#include "driver.h" -#include "general.h" +#include "../../driver.h" +#include "../../general.h" #include #include #include @@ -35,28 +35,29 @@ typedef struct static void pulse_free(void *data) { pa_t *pa = (pa_t*)data; - if (pa) + + if (!pa) + return; + + if (pa->mainloop) + pa_threaded_mainloop_stop(pa->mainloop); + + if (pa->stream) { - if (pa->mainloop) - pa_threaded_mainloop_stop(pa->mainloop); - - if (pa->stream) - { - pa_stream_disconnect(pa->stream); - pa_stream_unref(pa->stream); - } - - if (pa->context) - { - pa_context_disconnect(pa->context); - pa_context_unref(pa->context); - } - - if (pa->mainloop) - pa_threaded_mainloop_free(pa->mainloop); - - free(pa); + pa_stream_disconnect(pa->stream); + pa_stream_unref(pa->stream); } + + if (pa->context) + { + pa_context_disconnect(pa->context); + pa_context_unref(pa->context); + } + + if (pa->mainloop) + pa_threaded_mainloop_free(pa->mainloop); + + free(pa); } static void stream_success_cb(pa_stream *s, int success, void *data) @@ -70,6 +71,7 @@ static void stream_success_cb(pa_stream *s, int success, void *data) static void context_state_cb(pa_context *c, void *data) { pa_t *pa = (pa_t*)data; + switch (pa_context_get_state(c)) { case PA_CONTEXT_READY: @@ -85,6 +87,7 @@ static void context_state_cb(pa_context *c, void *data) static void stream_state_cb(pa_stream *s, void *data) { pa_t *pa = (pa_t*)data; + switch (pa_stream_get_state(s)) { case PA_STREAM_READY: @@ -99,23 +102,29 @@ static void stream_state_cb(pa_stream *s, void *data) static void stream_request_cb(pa_stream *s, size_t length, void *data) { + pa_t *pa = (pa_t*)data; + (void)length; (void)s; - pa_t *pa = (pa_t*)data; + pa_threaded_mainloop_signal(pa->mainloop, 0); } static void stream_latency_update_cb(pa_stream *s, void *data) { - (void)s; pa_t *pa = (pa_t*)data; + + (void)s; + pa_threaded_mainloop_signal(pa->mainloop, 0); } static void underrun_update_cb(pa_stream *s, void *data) { - (void)s; pa_t *pa = (pa_t*)data; + + (void)s; + RARCH_LOG("[PulseAudio]: Underrun (Buffer: %u, Writable size: %u).\n", (unsigned)pa->buffer_size, (unsigned)pa_stream_writable_size(pa->stream)); @@ -133,11 +142,14 @@ static void buffer_attr_cb(pa_stream *s, void *data) static void *pulse_init(const char *device, unsigned rate, unsigned latency) { - const pa_buffer_attr *server_attr = NULL; pa_sample_spec spec; - memset(&spec, 0, sizeof(spec)); + pa_t *pa; pa_buffer_attr buffer_attr = {0}; - pa_t *pa = (pa_t*)calloc(1, sizeof(*pa)); + const pa_buffer_attr *server_attr = NULL; + + memset(&spec, 0, sizeof(spec)); + + pa = (pa_t*)calloc(1, sizeof(*pa)); if (!pa) goto error; @@ -217,13 +229,13 @@ static ssize_t pulse_write(void *data, const void *buf_, size_t size) { pa_t *pa = (pa_t*)data; const uint8_t *buf = (const uint8_t*)buf_; - size_t written = 0; pa_threaded_mainloop_lock(pa->mainloop); while (size) { size_t writable = pa_stream_writable_size(pa->stream); + writable = min(size, writable); if (writable) @@ -246,13 +258,16 @@ static ssize_t pulse_write(void *data, const void *buf_, size_t size) static bool pulse_stop(void *data) { - RARCH_LOG("[PulseAudio]: Pausing.\n"); + bool ret; pa_t *pa = (pa_t*)data; - pa->success = true; // In case of spurious wakeup. Not critical. + + RARCH_LOG("[PulseAudio]: Pausing.\n"); + + pa->success = true; /* In case of spurious wakeup. Not critical. */ pa_threaded_mainloop_lock(pa->mainloop); pa_stream_cork(pa->stream, true, stream_success_cb, pa); pa_threaded_mainloop_wait(pa->mainloop); - bool ret = pa->success; + ret = pa->success; pa_threaded_mainloop_unlock(pa->mainloop); pa->is_paused = true; return ret; @@ -261,20 +276,24 @@ static bool pulse_stop(void *data) static bool pulse_alive(void *data) { pa_t *pa = (pa_t*)data; - if (pa) - return !pa->is_paused; - return false; + + if (!pa) + return false; + return !pa->is_paused; } static bool pulse_start(void *data) { - RARCH_LOG("[PulseAudio]: Unpausing.\n"); + bool ret; pa_t *pa = (pa_t*)data; - pa->success = true; // In case of spurious wakeup. Not critical. + + RARCH_LOG("[PulseAudio]: Unpausing.\n"); + + pa->success = true; /* In case of spurious wakeup. Not critical. */ pa_threaded_mainloop_lock(pa->mainloop); pa_stream_cork(pa->stream, false, stream_success_cb, pa); pa_threaded_mainloop_wait(pa->mainloop); - bool ret = pa->success; + ret = pa->success; pa_threaded_mainloop_unlock(pa->mainloop); pa->is_paused = false; return ret; @@ -283,7 +302,8 @@ static bool pulse_start(void *data) static void pulse_set_nonblock_state(void *data, bool state) { pa_t *pa = (pa_t*)data; - pa->nonblock = state; + if (pa) + pa->nonblock = state; } static bool pulse_use_float(void *data) @@ -294,10 +314,12 @@ static bool pulse_use_float(void *data) static size_t pulse_write_avail(void *data) { + size_t length; pa_t *pa = (pa_t*)data; + pa_threaded_mainloop_lock(pa->mainloop); - size_t length = pa_stream_writable_size(pa->stream); - g_extern.audio_data.driver_buffer_size = pa->buffer_size; // Can change spuriously. + length = pa_stream_writable_size(pa->stream); + g_extern.audio_data.driver_buffer_size = pa->buffer_size; /* Can change spuriously. */ pa_threaded_mainloop_unlock(pa->mainloop); return length; } diff --git a/audio/roar.c b/audio/drivers/roar.c similarity index 95% rename from audio/roar.c rename to audio/drivers/roar.c index ccbf734589..54d10c7e67 100644 --- a/audio/roar.c +++ b/audio/drivers/roar.c @@ -14,13 +14,13 @@ */ -#include "driver.h" +#include "../../driver.h" #include #include #include #include #include -#include "general.h" +#include "../../general.h" typedef struct { @@ -30,13 +30,15 @@ typedef struct static void *ra_init(const char *device, unsigned rate, unsigned latency) { - (void)latency; int err; + roar_vs_t *vss; roar_t *roar = (roar_t*)calloc(1, sizeof(roar_t)); - if (roar == NULL) + + if (!roar) return NULL; - roar_vs_t *vss; + (void)latency; + if ((vss = roar_vs_new_simple(device, "RetroArch", rate, 2, ROAR_CODEC_PCM_S, 16, ROAR_DIR_PLAY, &err)) == NULL) { RARCH_ERR("RoarAudio: \"%s\"\n", roar_vs_strerr(err)); @@ -52,17 +54,18 @@ static void *ra_init(const char *device, unsigned rate, unsigned latency) static ssize_t ra_write(void *data, const void *buf, size_t size) { - roar_t *roar = (roar_t*)data; + int err; ssize_t rc; + size_t written = 0; + roar_t *roar = (roar_t*)data; if (size == 0) return 0; - int err; - size_t written = 0; while (written < size) { size_t write_amt = size - written; + if ((rc = roar_vs_write(roar->vss, (const char*)buf + written, write_amt, &err)) < (ssize_t)write_amt) { if (roar->nonblocking) @@ -87,9 +90,9 @@ static bool ra_stop(void *data) static bool ra_alive(void *data) { roar_t *roar = (roar_t*)data; - if (roar) - return !roar->is_paused; - return false; + if (!roar) + return false; + return !roar->is_paused; } static void ra_set_nonblock_state(void *data, bool state) diff --git a/audio/rwebaudio.c b/audio/drivers/rwebaudio.c similarity index 93% rename from audio/rwebaudio.c rename to audio/drivers/rwebaudio.c index 824ae76e60..e3b9cef65e 100644 --- a/audio/rwebaudio.c +++ b/audio/drivers/rwebaudio.c @@ -13,10 +13,10 @@ * If not, see . */ -#include "../driver.h" -#include "../general.h" +#include "../../driver.h" +#include "../../general.h" -#include "../emscripten/RWebAudio.h" +#include "../../emscripten/RWebAudio.h" static bool rwebaudio_is_paused; @@ -27,9 +27,11 @@ static void rwebaudio_free(void *data) static void *rwebaudio_init(const char *device, unsigned rate, unsigned latency) { + void *data; (void)device; (void)rate; - void *data = RWebAudioInit(latency); + data = RWebAudioInit(latency); + if (data) g_settings.audio.out_rate = RWebAudioSampleRate(); return data; diff --git a/audio/sdl_audio.c b/audio/drivers/sdl_audio.c similarity index 80% rename from audio/sdl_audio.c rename to audio/drivers/sdl_audio.c index 5c1a89ad4c..ba2cca7cb6 100644 --- a/audio/sdl_audio.c +++ b/audio/drivers/sdl_audio.c @@ -14,7 +14,7 @@ */ -#include "../driver.h" +#include "../../driver.h" #include #include #include @@ -25,7 +25,7 @@ #include "SDL_audio.h" #include -#include "../general.h" +#include "../../general.h" #include typedef struct sdl_audio @@ -41,26 +41,36 @@ typedef struct sdl_audio static void sdl_audio_cb(void *data, Uint8 *stream, int len) { sdl_audio_t *sdl = (sdl_audio_t*)data; - size_t avail = fifo_read_avail(sdl->buffer); size_t write_size = len > (int)avail ? avail : len; + fifo_read(sdl->buffer, stream, write_size); scond_signal(sdl->cond); - // If underrun, fill rest with silence. + /* If underrun, fill rest with silence. */ memset(stream + write_size, 0, len - write_size); } static inline int find_num_frames(int rate, int latency) { int frames = (rate * latency) / 1000; - // SDL only likes 2^n sized buffers. + + /* SDL only likes 2^n sized buffers. */ + return next_pow2(frames); } -static void *sdl_audio_init(const char *device, unsigned rate, unsigned latency) +static void *sdl_audio_init(const char *device, + unsigned rate, unsigned latency) { + int frames; + size_t bufsize; + void *tmp; + SDL_AudioSpec out; + SDL_AudioSpec spec = {0}; + sdl_audio_t *sdl = NULL; (void)device; + if (SDL_WasInit(0) == 0) { if (SDL_Init(SDL_INIT_AUDIO) < 0) @@ -69,14 +79,16 @@ static void *sdl_audio_init(const char *device, unsigned rate, unsigned latency) else if (SDL_InitSubSystem(SDL_INIT_AUDIO) < 0) return NULL; - sdl_audio_t *sdl = (sdl_audio_t*)calloc(1, sizeof(*sdl)); + sdl = (sdl_audio_t*)calloc(1, sizeof(*sdl)); if (!sdl) return NULL; - // We have to buffer up some data ourselves, so we let SDL carry approx half of the latency. SDL double buffers audio and we do as well. - int frames = find_num_frames(rate, latency / 4); + /* We have to buffer up some data ourselves, so we let SDL + * carry approximately half of the latency. + * + * SDL double buffers audio and we do as well. */ + frames = find_num_frames(rate, latency / 4); - SDL_AudioSpec spec = {0}; spec.freq = rate; spec.format = AUDIO_S16SYS; spec.channels = 2; @@ -84,8 +96,6 @@ static void *sdl_audio_init(const char *device, unsigned rate, unsigned latency) spec.callback = sdl_audio_cb; spec.userdata = sdl; - SDL_AudioSpec out; - if (SDL_OpenAudio(&spec, &out) < 0) { RARCH_ERR("Failed to open SDL audio: %s\n", SDL_GetError()); @@ -97,12 +107,14 @@ static void *sdl_audio_init(const char *device, unsigned rate, unsigned latency) sdl->lock = slock_new(); sdl->cond = scond_new(); - RARCH_LOG("SDL audio: Requested %u ms latency, got %d ms\n", latency, (int)(out.samples * 4 * 1000 / g_settings.audio.out_rate)); + RARCH_LOG("SDL audio: Requested %u ms latency, got %d ms\n", + latency, (int)(out.samples * 4 * 1000 / g_settings.audio.out_rate)); - // Create a buffer twice as big as needed and prefill the buffer. - size_t bufsize = out.samples * 4 * sizeof(int16_t); - void *tmp = calloc(1, bufsize); + /* Create a buffer twice as big as needed and prefill the buffer. */ + bufsize = out.samples * 4 * sizeof(int16_t); + tmp = calloc(1, bufsize); sdl->buffer = fifo_new(bufsize); + if (tmp) { fifo_write(sdl->buffer, tmp, bufsize); @@ -115,14 +127,16 @@ static void *sdl_audio_init(const char *device, unsigned rate, unsigned latency) static ssize_t sdl_audio_write(void *data, const void *buf, size_t size) { + ssize_t ret = 0; sdl_audio_t *sdl = (sdl_audio_t*)data; - ssize_t ret = 0; if (sdl->nonblock) { + size_t avail, write_amt; + SDL_LockAudio(); - size_t avail = fifo_write_avail(sdl->buffer); - size_t write_amt = avail > size ? size : avail; + avail = fifo_write_avail(sdl->buffer); + write_amt = avail > size ? size : avail; fifo_write(sdl->buffer, buf, write_amt); SDL_UnlockAudio(); ret = write_amt; @@ -130,10 +144,13 @@ static ssize_t sdl_audio_write(void *data, const void *buf, size_t size) else { size_t written = 0; + while (written < size) { + size_t avail; + SDL_LockAudio(); - size_t avail = fifo_write_avail(sdl->buffer); + avail = fifo_write_avail(sdl->buffer); if (avail == 0) { @@ -167,9 +184,9 @@ static bool sdl_audio_stop(void *data) static bool sdl_audio_alive(void *data) { sdl_audio_t *sdl = (sdl_audio_t*)data; - if (sdl) - return !sdl->is_paused; - return false; + if (!sdl) + return false; + return !sdl->is_paused; } static bool sdl_audio_start(void *data) @@ -184,15 +201,17 @@ static bool sdl_audio_start(void *data) static void sdl_audio_set_nonblock_state(void *data, bool state) { sdl_audio_t *sdl = (sdl_audio_t*)data; - sdl->nonblock = state; + if (sdl) + sdl->nonblock = state; } static void sdl_audio_free(void *data) { + sdl_audio_t *sdl = (sdl_audio_t*)data; + SDL_CloseAudio(); SDL_QuitSubSystem(SDL_INIT_AUDIO); - sdl_audio_t *sdl = (sdl_audio_t*)data; if (sdl) { fifo_free(sdl->buffer); diff --git a/audio/xaudio.c b/audio/drivers/xaudio.c similarity index 86% rename from audio/xaudio.c rename to audio/drivers/xaudio.c index 451eca3aef..630e4e646d 100644 --- a/audio/xaudio.c +++ b/audio/drivers/xaudio.c @@ -14,10 +14,10 @@ * If not, see . */ -#include "../driver.h" +#include "../../driver.h" #include -#include "xaudio-c/xaudio-c.h" -#include "../general.h" +#include "../xaudio-c/xaudio-c.h" +#include "../../general.h" typedef struct { @@ -29,21 +29,24 @@ typedef struct static void *xa_init(const char *device, unsigned rate, unsigned latency) { + size_t bufsize; + xa_t *xa; + unsigned device_index = 0; + if (latency < 8) - latency = 8; // Do not allow shenanigans. + latency = 8; /* Do not allow shenanigans. */ xa_t *xa = (xa_t*)calloc(1, sizeof(*xa)); if (!xa) return NULL; - size_t bufsize = latency * rate / 1000; + bufsize = latency * rate / 1000; RARCH_LOG("XAudio2: Requesting %u ms latency, using %d ms latency.\n", latency, (int)bufsize * 1000 / rate); xa->bufsize = bufsize * 2 * sizeof(float); - unsigned device_index = 0; if (device) device_index = strtoul(device, NULL, 0); @@ -63,17 +66,20 @@ static void *xa_init(const char *device, unsigned rate, unsigned latency) static ssize_t xa_write(void *data, const void *buf, size_t size) { + size_t ret; xa_t *xa = (xa_t*)data; + if (xa->nonblock) { size_t avail = xaudio2_write_avail(xa->xa); + if (avail == 0) return 0; if (avail < size) size = avail; } - size_t ret = xaudio2_write(xa->xa, buf, size); + ret = xaudio2_write(xa->xa, buf, size); if (ret == 0 && size > 0) return -1; return ret; @@ -89,15 +95,16 @@ static bool xa_stop(void *data) static bool xa_alive(void *data) { xa_t *xa = (xa_t*)data; - if (xa) - return !xa->is_paused; - return false; + if (!xa) + return false; + return !xa->is_paused; } static void xa_set_nonblock_state(void *data, bool state) { xa_t *xa = (xa_t*)data; - xa->nonblock = state; + if (xa) + xa->nonblock = state; } static bool xa_start(void *data) @@ -116,12 +123,13 @@ static bool xa_use_float(void *data) static void xa_free(void *data) { xa_t *xa = (xa_t*)data; - if (xa) - { - if (xa->xa) - xaudio2_free(xa->xa); - free(xa); - } + + if (!xa) + return; + + if (xa->xa) + xaudio2_free(xa->xa); + free(xa); } static size_t xa_write_avail(void *data) diff --git a/audio/xenon360_audio.c b/audio/drivers/xenon360_audio.c similarity index 93% rename from audio/xenon360_audio.c rename to audio/drivers/xenon360_audio.c index d66d0b36ab..9e8d4b1336 100644 --- a/audio/xenon360_audio.c +++ b/audio/drivers/xenon360_audio.c @@ -14,10 +14,10 @@ * If not, see . */ -#include "../driver.h" +#include "../../driver.h" #include #include -#include "../general.h" +#include "../../general.h" #include @@ -35,6 +35,7 @@ static void *xenon360_audio_init(const char *device, unsigned rate, unsigned latency) { static bool inited = false; + if (!inited) { xenon_sound_init(); @@ -53,12 +54,11 @@ static inline uint32_t bswap_32(uint32_t val) static ssize_t xenon360_audio_write(void *data, const void *buf, size_t size) { + size_t written = 0, i; + const uint32_t *in_buf = buf; xenon_audio_t *xa = data; - size_t written = 0; - - const uint32_t *in_buf = buf; - for (size_t i = 0; i < (size >> 2); i++) + for (i = 0; i < (size >> 2); i++) xa->buffer[i] = bswap_32(in_buf[i]); if (!xa->nonblock) @@ -95,15 +95,16 @@ static bool xenon360_audio_stop(void *data) static bool xenon360_audio_alive(void *data) { xenon_audio_t *xa = data; - if (xa) - return !xa->is_paused; - return false; + if (!xa) + return false; + return !xa->is_paused; } static void xenon360_audio_set_nonblock_state(void *data, bool state) { xenon_audio_t *xa = data; - xa->nonblock = state; + if (xa) + xa->nonblock = state; } static bool xenon360_audio_start(void *data) diff --git a/gfx/context/x11_common.c b/gfx/context/x11_common.c index a2ee7228a9..65c2741054 100644 --- a/gfx/context/x11_common.c +++ b/gfx/context/x11_common.c @@ -57,11 +57,13 @@ void x11_show_mouse(Display *dpy, Window win, bool state) static Atom XA_NET_WM_STATE; static Atom XA_NET_WM_STATE_FULLSCREEN; static Atom XA_NET_MOVERESIZE_WINDOW; + #define XA_INIT(x) XA##x = XInternAtom(dpy, #x, False) #define _NET_WM_STATE_ADD 1 #define MOVERESIZE_GRAVITY_CENTER 5 #define MOVERESIZE_X_SHIFT 8 #define MOVERESIZE_Y_SHIFT 9 + void x11_windowed_fullscreen(Display *dpy, Window win) { XA_INIT(_NET_WM_STATE); @@ -82,7 +84,8 @@ void x11_windowed_fullscreen(Display *dpy, Window win) &xev); } -// Try to be nice to tiling WMs if possible. +/* Try to be nice to tiling WMs if possible. */ + void x11_move_window(Display *dpy, Window win, int x, int y, unsigned width, unsigned height) { @@ -108,7 +111,7 @@ static void x11_set_window_class(Display *dpy, Window win) { XClassHint hint = {0}; - hint.res_name = (char*)"retroarch"; // Broken header. + hint.res_name = (char*)"retroarch"; /* Broken header. */ hint.res_class = (char*)"retroarch"; XSetClassHint(dpy, win, &hint); } @@ -266,10 +269,12 @@ unsigned x11_get_xinerama_monitor(Display *dpy, int x, int y, int len_x = min_rx - max_lx; int len_y = min_by - max_ty; - if (len_x < 0 || len_y < 0) // The whole window is outside the screen. + + if (len_x < 0 || len_y < 0) /* The whole window is outside the screen. */ continue; area = len_x * len_y; + if (area > largest_area) { monitor = i; @@ -285,6 +290,7 @@ unsigned x11_get_xinerama_monitor(Display *dpy, int x, int y, bool x11_create_input_context(Display *dpy, Window win, XIM *xim, XIC *xic) { *xim = XOpenIM(dpy, NULL, NULL, NULL); + if (!*xim) { RARCH_ERR("[X11]: Failed to open input method.\n"); @@ -293,6 +299,7 @@ bool x11_create_input_context(Display *dpy, Window win, XIM *xim, XIC *xic) *xic = XCreateIC(*xim, XNInputStyle, XIMPreeditNothing | XIMStatusNothing, XNClientWindow, win, NULL); + if (!*xic) { RARCH_ERR("[X11]: Failed to create input context.\n"); diff --git a/griffin/griffin.c b/griffin/griffin.c index c3a4baa2e3..2af1e2e39b 100644 --- a/griffin/griffin.c +++ b/griffin/griffin.c @@ -451,48 +451,48 @@ RSOUND AUDIO ============================================================ */ #if defined(__CELLOS_LV2__) -#include "../audio/ps3_audio.c" +#include "../audio/drivers/ps3_audio.c" #elif defined(XENON) -#include "../audio/xenon360_audio.c" +#include "../audio/drivers/xenon360_audio.c" #elif defined(GEKKO) -#include "../audio/gx_audio.c" +#include "../audio/drivers/gx_audio.c" #elif defined(EMSCRIPTEN) -#include "../audio/rwebaudio.c" +#include "../audio/drivers/rwebaudio.c" #elif defined(PSP) -#include "../audio/psp1_audio.c" +#include "../audio/drivers/psp1_audio.c" #endif #ifdef HAVE_XAUDIO -#include "../audio/xaudio.c" +#include "../audio/drivers/xaudio.c" #include "../audio/xaudio-c/xaudio-c.cpp" #endif #ifdef HAVE_DSOUND -#include "../audio/dsound.c" +#include "../audio/drivers/dsound.c" #endif #ifdef HAVE_SL -#include "../audio/opensl.c" +#include "../audio/drivers/opensl.c" #endif #ifdef HAVE_ALSA #ifdef __QNX__ -#include "../audio/alsa_qsa.c" +#include "../audio/drivers/alsa_qsa.c" #else -#include "../audio/alsa.c" -#include "../audio/alsathread.c" +#include "../audio/drivers/alsa.c" +#include "../audio/drivers/alsathread.c" #endif #endif #ifdef HAVE_AL -#include "../audio/openal.c" +#include "../audio/drivers/openal.c" #endif #ifdef HAVE_COREAUDIO -#include "../audio/coreaudio.c" +#include "../audio/drivers/coreaudio.c" #endif -#include "../audio/nullaudio.c" +#include "../audio/drivers/nullaudio.c" /*============================================================ DRIVERS From 371e3ebdd733f5df9279aaeebee60a6e2656de8d Mon Sep 17 00:00:00 2001 From: twinaphex Date: Mon, 12 Jan 2015 05:37:52 +0100 Subject: [PATCH 073/156] Document more of driver.c --- driver.c | 70 ++++++++++++++++++++++++++++++++++++++++++++++++++++---- driver.h | 54 ++++++++++++++++++++++++++++++++++++++++++- 2 files changed, 119 insertions(+), 5 deletions(-) diff --git a/driver.c b/driver.c index 471af8d427..5c9345b582 100644 --- a/driver.c +++ b/driver.c @@ -1055,6 +1055,14 @@ static void find_input_driver(void) } } +/** + * init_drivers_pre: + * + * Attempts to find a default driver for + * all driver types. + * + * Should be run before init_drivers(). + **/ void init_drivers_pre(void) { find_audio_driver(); @@ -1114,6 +1122,12 @@ static void adjust_system_rates(void) } } +/** + * driver_set_monitor_refresh_rate: + * @hz : New refresh rate for monitor. + * + * Sets monitor refresh rate to new value. + **/ void driver_set_monitor_refresh_rate(float hz) { char msg[PATH_MAX_LENGTH]; @@ -1129,12 +1143,22 @@ void driver_set_monitor_refresh_rate(float hz) (double)g_settings.audio.out_rate / g_extern.audio_data.in_rate; } -void driver_set_nonblock_state(bool nonblock) +/** + * driver_set_nonblock_state: + * @enable : Enable nonblock state? + * + * Sets audio and video drivers to nonblock state. + * + * If @enable is false, sets blocking state for both + * audio and video drivers instead. + **/ +void driver_set_nonblock_state(bool enable) { /* Only apply non-block-state for video if we're using vsync. */ if (driver.video_active && driver.video_data) { - bool video_nonblock = nonblock; + bool video_nonblock = enable; + if (!g_settings.video.vsync || g_extern.system.force_nonblock) video_nonblock = true; driver.video->set_nonblock_state(driver.video_data, video_nonblock); @@ -1142,9 +1166,9 @@ void driver_set_nonblock_state(bool nonblock) if (driver.audio_active && driver.audio_data) driver.audio->set_nonblock_state(driver.audio_data, - g_settings.audio.sync ? nonblock : true); + g_settings.audio.sync ? enable : true); - g_extern.audio_data.chunk_size = nonblock ? + g_extern.audio_data.chunk_size = enable ? g_extern.audio_data.nonblock_chunk_size : g_extern.audio_data.block_chunk_size; } @@ -1448,6 +1472,7 @@ static void init_video_filter(enum retro_pixel_format colfmt) struct retro_game_geometry *geom = NULL; deinit_video_filter(); + if (!*g_settings.video.softfilter_plugin) return; @@ -1689,6 +1714,13 @@ static void init_video_input(void) } +/** + * init_drivers: + * @flags : Bitmask of drivers to initialize. + * + * Initializes drivers. + * @flags determines which drivers get initialized. + **/ void init_drivers(int flags) { if (flags & DRIVER_VIDEO) @@ -1758,6 +1790,11 @@ void init_drivers(int flags) } } +/** + * compute_monitor_fps_statistics: + * + * Computes monitor FPS statistics. + **/ static void compute_monitor_fps_statistics(void) { double avg_fps = 0.0, stddev = 0.0; @@ -1785,6 +1822,12 @@ static void compute_monitor_fps_statistics(void) } } +/** + * compute_audio_buffer_statistics: + * + * Computes audio buffer statistics. + * + **/ static void compute_audio_buffer_statistics(void) { unsigned i, low_water_size, high_water_size, avg, stddev; @@ -1888,6 +1931,13 @@ static void uninit_video_input(void) compute_monitor_fps_statistics(); } +/** + * uninit_drivers: + * @flags : Bitmask of drivers to deinitialize. + * + * Deinitializes drivers. + * @flags determines which drivers get deinitialized. + **/ void uninit_drivers(int flags) { if (flags & DRIVER_AUDIO) @@ -1947,6 +1997,18 @@ void uninit_drivers(int flags) } +/** + * driver_monitor_fps_statistics + * @refresh_rate : Monitor refresh rate. + * @deviation : Deviation from measured refresh rate. + * @sample_points : Amount of sampled points. + * + * Gets the monitor FPS statistics based on the current + * runtime. + * + * Returns: true (1) on success, false (0) if threaded + * video mode is enabled and/or three are less than 2 frame time samples. + **/ bool driver_monitor_fps_statistics(double *refresh_rate, double *deviation, unsigned *sample_points) { diff --git a/driver.h b/driver.h index f678d9a660..e43577b0e6 100644 --- a/driver.h +++ b/driver.h @@ -390,7 +390,10 @@ typedef struct video_driver bool (*set_shader)(void *data, enum rarch_shader_type type, const char *path); + /* Frees driver. */ void (*free)(void *data); + + /* Human-readable identifier. */ const char *ident; void (*set_rotation)(void *data, unsigned rotation); @@ -553,10 +556,32 @@ typedef struct driver const char *current_msg; } driver_t; +/** + * init_drivers: + * @flags : Bitmask of drivers to initialize. + * + * Initializes drivers. + * @flags determines which drivers get initialized. + **/ void init_drivers(int flags); +/** + * init_drivers_pre: + * + * Attempts to find a default driver for + * all driver types. + * + * Should be run before init_drivers(). + **/ void init_drivers_pre(void); +/** + * uninit_drivers: + * @flags : Bitmask of drivers to deinitialize. + * + * Deinitializes drivers. + * @flags determines which drivers get deinitialized. + **/ void uninit_drivers(int flags); /** @@ -602,12 +627,39 @@ void find_prev_resampler_driver(void); **/ void find_next_resampler_driver(void); +/** + * driver_set_monitor_refresh_rate: + * @hz : New refresh rate for monitor. + * + * Sets monitor refresh rate to new value. + **/ void driver_set_monitor_refresh_rate(float hz); +/** + * driver_monitor_fps_statistics + * @refresh_rate : Monitor refresh rate. + * @deviation : Deviation from measured refresh rate. + * @sample_points : Amount of sampled points. + * + * Gets the monitor FPS statistics based on the current + * runtime. + * + * Returns: true (1) on success, false (0) if threaded + * video mode is enabled and/or three are less than 2 frame time samples. + **/ bool driver_monitor_fps_statistics(double *refresh_rate, double *deviation, unsigned *sample_points); -void driver_set_nonblock_state(bool nonblock); +/** + * driver_set_nonblock_state: + * @enable : Enable nonblock state? + * + * Sets audio and video drivers to nonblock state. + * + * If @enable is false, sets blocking state for both + * audio and video drivers instead. + **/ +void driver_set_nonblock_state(bool enable); /** * driver_get_current_framebuffer: From badb29942b9b152800aa33543423034fd4e949b5 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Mon, 12 Jan 2015 05:59:11 +0100 Subject: [PATCH 074/156] Add monitor FPS enable option --- driver.c | 10 +++++++--- driver.h | 7 +++++-- general.h | 1 + gfx/context/androidegl_ctx.c | 7 ++++--- gfx/context/bbqnx_ctx.c | 7 ++++--- gfx/context/d3d_ctx.cpp | 6 +++--- gfx/context/drm_egl_ctx.c | 7 ++++--- gfx/context/emscriptenegl_ctx.c | 7 ++++--- gfx/context/glx_ctx.c | 10 ++++------ gfx/context/mali_fbdev_ctx.c | 7 ++++--- gfx/context/ps3_ctx.c | 8 ++++---- gfx/context/sdl_gl_ctx.c | 7 +++---- gfx/context/vc_egl_ctx.c | 7 ++++--- gfx/context/vivante_fbdev_ctx.c | 7 ++++--- gfx/context/wayland_ctx.c | 8 ++++---- gfx/context/wgl_ctx.c | 7 +++---- gfx/context/xegl_ctx.c | 7 +++---- settings.c | 2 ++ settings_data.c | 11 +++++++++++ 19 files changed, 78 insertions(+), 55 deletions(-) diff --git a/driver.c b/driver.c index 5c9345b582..5efef8f072 100644 --- a/driver.c +++ b/driver.c @@ -2006,8 +2006,11 @@ void uninit_drivers(int flags) * Gets the monitor FPS statistics based on the current * runtime. * - * Returns: true (1) on success, false (0) if threaded - * video mode is enabled and/or three are less than 2 frame time samples. + * Returns: true (1) on success. + * false (0) if: + * a) threaded video mode is enabled + * b) less than 2 frame time samples. + * c) FPS monitor enable is off. **/ bool driver_monitor_fps_statistics(double *refresh_rate, double *deviation, unsigned *sample_points) @@ -2017,7 +2020,8 @@ bool driver_monitor_fps_statistics(double *refresh_rate, unsigned samples = min(MEASURE_FRAME_TIME_SAMPLES_COUNT, g_extern.measure_data.frame_time_samples_count); - if (g_settings.video.threaded || (samples < 2)) + if (!g_settings.fps_monitor_enable || + g_settings.video.threaded || (samples < 2)) return false; /* Measure statistics on frame time (microsecs), *not* FPS. */ diff --git a/driver.h b/driver.h index e43577b0e6..930f3036a7 100644 --- a/driver.h +++ b/driver.h @@ -644,8 +644,11 @@ void driver_set_monitor_refresh_rate(float hz); * Gets the monitor FPS statistics based on the current * runtime. * - * Returns: true (1) on success, false (0) if threaded - * video mode is enabled and/or three are less than 2 frame time samples. + * Returns: true (1) on success. + * false (0) if: + * a) threaded video mode is enabled + * b) less than 2 frame time samples. + * c) FPS monitor enable is off. **/ bool driver_monitor_fps_statistics(double *refresh_rate, double *deviation, unsigned *sample_points); diff --git a/general.h b/general.h index 5e71731ffb..11b5063ad8 100644 --- a/general.h +++ b/general.h @@ -355,6 +355,7 @@ struct settings bool menu_show_start_screen; #endif bool fps_show; + bool fps_monitor_enable; bool load_dummy_on_core_shutdown; bool core_specific_config; diff --git a/gfx/context/androidegl_ctx.c b/gfx/context/androidegl_ctx.c index 7644e1f573..639c1837b5 100644 --- a/gfx/context/androidegl_ctx.c +++ b/gfx/context/androidegl_ctx.c @@ -269,15 +269,16 @@ static void android_gfx_ctx_set_resize(void *data, static void android_gfx_ctx_update_window_title(void *data) { char buf[128], buf_fps[128]; - bool fps_draw = g_settings.fps_show; + bool fps_draw = g_settings.fps_show || g_settings.fps_monitor_enable; (void)data; if (!fps_draw) return; - gfx_get_fps(buf, sizeof(buf), fps_draw ? buf_fps : NULL, sizeof(buf_fps)); - msg_queue_push(g_extern.msg_queue, buf_fps, 1, 1); + gfx_get_fps(buf, sizeof(buf), g_settings.fps_show ? buf_fps : NULL, sizeof(buf_fps)); + if (g_settings.fps_show) + msg_queue_push(g_extern.msg_queue, buf_fps, 1, 1); } static bool android_gfx_ctx_set_video_mode(void *data, diff --git a/gfx/context/bbqnx_ctx.c b/gfx/context/bbqnx_ctx.c index 68835f5b71..373649128f 100644 --- a/gfx/context/bbqnx_ctx.c +++ b/gfx/context/bbqnx_ctx.c @@ -353,15 +353,16 @@ static void gfx_ctx_qnx_set_resize(void *data, unsigned width, unsigned height) static void gfx_ctx_qnx_update_window_title(void *data) { char buf[128], buf_fps[128]; - bool fps_draw = g_settings.fps_show; + bool fps_draw = g_settings.fps_show || g_settings.fps_monitor_enable; (void)data; if (!fps_draw) return; - gfx_get_fps(buf, sizeof(buf), fps_draw ? buf_fps : NULL, sizeof(buf_fps)); - msg_queue_push(g_extern.msg_queue, buf_fps, 1, 1); + gfx_get_fps(buf, sizeof(buf), g_settings.fps_show ? buf_fps : NULL, sizeof(buf_fps)); + if (g_settings.fps_show) + msg_queue_push(g_extern.msg_queue, buf_fps, 1, 1); } static bool gfx_ctx_qnx_set_video_mode(void *data, diff --git a/gfx/context/d3d_ctx.cpp b/gfx/context/d3d_ctx.cpp index e452e1e2f9..2b1287b5b6 100644 --- a/gfx/context/d3d_ctx.cpp +++ b/gfx/context/d3d_ctx.cpp @@ -114,16 +114,16 @@ static void gfx_ctx_d3d_update_title(void *data) { d3d_video_t *d3d = (d3d_video_t*)data; char buf[128], buffer_fps[128]; - bool fps_draw = g_settings.fps_show; + bool fps_draw = g_settings.fps_show || g_settings.fps_monitor_enable; - if (gfx_get_fps(buf, sizeof(buf), fps_draw ? buffer_fps : NULL, sizeof(buffer_fps))) + if (gfx_get_fps(buf, sizeof(buf), g_settings.fps_show ? buffer_fps : NULL, sizeof(buffer_fps))) { #ifndef _XBOX SetWindowText(d3d->hWnd, buf); #endif } - if (fps_draw) + if (g_settings.fps_show) { #ifdef _XBOX char mem[128]; diff --git a/gfx/context/drm_egl_ctx.c b/gfx/context/drm_egl_ctx.c index 50c8235b42..8ae17257f3 100644 --- a/gfx/context/drm_egl_ctx.c +++ b/gfx/context/drm_egl_ctx.c @@ -265,15 +265,16 @@ static void gfx_ctx_drm_egl_set_resize(void *data, static void gfx_ctx_drm_egl_update_window_title(void *data) { char buf[128], buf_fps[128]; - bool fps_draw = g_settings.fps_show; + bool fps_draw = g_settings.fps_show || g_settings.fps_monitor_enable; (void)data; if (!fps_draw) return; - gfx_get_fps(buf, sizeof(buf), fps_draw ? buf_fps : NULL, sizeof(buf_fps)); - msg_queue_push(g_extern.msg_queue, buf_fps, 1, 1); + gfx_get_fps(buf, sizeof(buf), g_settings.fps_show ? buf_fps : NULL, sizeof(buf_fps)); + if (g_settings.fps_show) + msg_queue_push(g_extern.msg_queue, buf_fps, 1, 1); } static void gfx_ctx_drm_egl_get_video_size(void *data, unsigned *width, unsigned *height) diff --git a/gfx/context/emscriptenegl_ctx.c b/gfx/context/emscriptenegl_ctx.c index 374c285840..321bf13eed 100644 --- a/gfx/context/emscriptenegl_ctx.c +++ b/gfx/context/emscriptenegl_ctx.c @@ -86,15 +86,16 @@ static void gfx_ctx_emscripten_set_resize(void *data, static void gfx_ctx_emscripten_update_window_title(void *data) { char buf[128], buf_fps[128]; - bool fps_draw = g_settings.fps_show; + bool fps_draw = g_settings.fps_show || g_settings.fps_monitor_enable; (void)data; if (!fps_draw) return; - gfx_get_fps(buf, sizeof(buf), fps_draw ? buf_fps : NULL, sizeof(buf_fps)); - msg_queue_push(g_extern.msg_queue, buf_fps, 1, 1); + gfx_get_fps(buf, sizeof(buf), g_settings.fps_show ? buf_fps : NULL, sizeof(buf_fps)); + if (g_settings.fps_show) + msg_queue_push(g_extern.msg_queue, buf_fps, 1, 1); } static void gfx_ctx_emscripten_get_video_size(void *data, diff --git a/gfx/context/glx_ctx.c b/gfx/context/glx_ctx.c index 1e468afb2f..b2644f2a45 100644 --- a/gfx/context/glx_ctx.c +++ b/gfx/context/glx_ctx.c @@ -192,18 +192,16 @@ static void gfx_ctx_glx_update_window_title(void *data) { char buf[128], buf_fps[128]; gfx_ctx_glx_data_t *glx = NULL; - bool fps_draw = g_settings.fps_show; + bool fps_draw = g_settings.fps_show || g_settings.fps_monitor_enable; (void)data; glx = (gfx_ctx_glx_data_t*)driver.video_context_data; - if (gfx_get_fps(buf, sizeof(buf), fps_draw ? buf_fps : NULL, sizeof(buf_fps))) + if (gfx_get_fps(buf, sizeof(buf), g_settings.fps_show ? buf_fps : NULL, sizeof(buf_fps))) XStoreName(glx->g_dpy, glx->g_win, buf); - - if (!fps_draw) - return; - msg_queue_push(g_extern.msg_queue, buf_fps, 1, 1); + if (g_settings.fps_show) + msg_queue_push(g_extern.msg_queue, buf_fps, 1, 1); } static void gfx_ctx_glx_get_video_size(void *data, diff --git a/gfx/context/mali_fbdev_ctx.c b/gfx/context/mali_fbdev_ctx.c index 7f23014cf2..752e932c66 100644 --- a/gfx/context/mali_fbdev_ctx.c +++ b/gfx/context/mali_fbdev_ctx.c @@ -198,15 +198,16 @@ static void gfx_ctx_mali_fbdev_set_resize(void *data, static void gfx_ctx_mali_fbdev_update_window_title(void *data) { char buf[128], buf_fps[128]; - bool fps_draw = g_settings.fps_show; + bool fps_draw = g_settings.fps_show || g_settings.fps_monitor_enable; (void)data; if (!fps_draw) return; - gfx_get_fps(buf, sizeof(buf), fps_draw ? buf_fps : NULL, sizeof(buf_fps)); - msg_queue_push(g_extern.msg_queue, buf_fps, 1, 1); + gfx_get_fps(buf, sizeof(buf), g_settings.fps_show ? buf_fps : NULL, sizeof(buf_fps)); + if (g_settings.fps_show) + msg_queue_push(g_extern.msg_queue, buf_fps, 1, 1); } static bool gfx_ctx_mali_fbdev_set_video_mode(void *data, diff --git a/gfx/context/ps3_ctx.c b/gfx/context/ps3_ctx.c index d106e2cf3f..7c36996147 100644 --- a/gfx/context/ps3_ctx.c +++ b/gfx/context/ps3_ctx.c @@ -209,14 +209,14 @@ static void gfx_ctx_ps3_update_window_title(void *data) { (void)data; char buf[128], buf_fps[128]; - bool fps_draw = g_settings.fps_show; + bool fps_draw = g_settings.fps_show || g_settings.fps_monitor_enable; if (!fps_draw) return; - gfx_get_fps(buf, sizeof(buf), fps_draw - ? buf_fps : NULL, sizeof(buf_fps)); - msg_queue_push(g_extern.msg_queue, buf_fps, 1, 1); + gfx_get_fps(buf, sizeof(buf), g_settings.fps_show ? buf_fps : NULL, sizeof(buf_fps)); + if (g_settings.fps_show) + msg_queue_push(g_extern.msg_queue, buf_fps, 1, 1); } static void gfx_ctx_ps3_get_video_size(void *data, diff --git a/gfx/context/sdl_gl_ctx.c b/gfx/context/sdl_gl_ctx.c index 979bacc080..536ba41f3e 100644 --- a/gfx/context/sdl_gl_ctx.c +++ b/gfx/context/sdl_gl_ctx.c @@ -277,12 +277,12 @@ static void sdl_ctx_update_window_title(void *data) { char buf[128], buf_fps[128]; gfx_ctx_sdl_data_t *sdl = (gfx_ctx_sdl_data_t*)driver.video_context_data; - bool fps_draw = g_settings.fps_show; + bool fps_draw = g_settings.fps_show || g_settings.fps_monitor_enable; if (!sdl) return; - if (gfx_get_fps(buf, sizeof(buf), fps_draw ? buf_fps : NULL, sizeof(buf_fps))) + if (gfx_get_fps(buf, sizeof(buf), g_settings.fps_show ? buf_fps : NULL, sizeof(buf_fps))) { #ifdef HAVE_SDL2 SDL_SetWindowTitle(sdl->g_win, buf); @@ -290,8 +290,7 @@ static void sdl_ctx_update_window_title(void *data) SDL_WM_SetCaption(buf, NULL); #endif } - - if (fps_draw) + if (g_settings.fps_show) msg_queue_push(g_extern.msg_queue, buf_fps, 1, 1); } diff --git a/gfx/context/vc_egl_ctx.c b/gfx/context/vc_egl_ctx.c index c3b2c3c60b..8f68ad235f 100644 --- a/gfx/context/vc_egl_ctx.c +++ b/gfx/context/vc_egl_ctx.c @@ -118,15 +118,16 @@ static void gfx_ctx_vc_set_resize(void *data, unsigned width, unsigned height) static void gfx_ctx_vc_update_window_title(void *data) { char buf[128], buf_fps[128]; - bool fps_draw = g_settings.fps_show; + bool fps_draw = g_settings.fps_show || g_settings.fps_monitor_enable; (void)data; if (!fps_draw) return; - gfx_get_fps(buf, sizeof(buf), fps_draw ? buf_fps : NULL, sizeof(buf_fps)); - msg_queue_push(g_extern.msg_queue, buf_fps, 1, 1); + gfx_get_fps(buf, sizeof(buf), g_settings.fps_show ? buf_fps : NULL, sizeof(buf_fps)); + if (g_settings.fps_show) + msg_queue_push(g_extern.msg_queue, buf_fps, 1, 1); } static void gfx_ctx_vc_get_video_size(void *data, diff --git a/gfx/context/vivante_fbdev_ctx.c b/gfx/context/vivante_fbdev_ctx.c index cb7ca3ebc1..5e3b4b86eb 100644 --- a/gfx/context/vivante_fbdev_ctx.c +++ b/gfx/context/vivante_fbdev_ctx.c @@ -187,15 +187,16 @@ static void gfx_ctx_vivante_set_resize(void *data, static void gfx_ctx_vivante_update_window_title(void *data) { char buf[128], buf_fps[128]; - bool fps_draw = g_settings.fps_show; + bool fps_draw = g_settings.fps_show || g_settings.fps_monitor_enable; (void)data; if (!fps_draw) return; - gfx_get_fps(buf, sizeof(buf), fps_draw ? buf_fps : NULL, sizeof(buf_fps)); - msg_queue_push(g_extern.msg_queue, buf_fps, 1, 1); + gfx_get_fps(buf, sizeof(buf), g_settings.fps_show ? buf_fps : NULL, sizeof(buf_fps)); + if (g_settings.fps_show) + msg_queue_push(g_extern.msg_queue, buf_fps, 1, 1); } static bool gfx_ctx_vivante_set_video_mode(void *data, diff --git a/gfx/context/wayland_ctx.c b/gfx/context/wayland_ctx.c index a38885ae7f..0d4d92618c 100644 --- a/gfx/context/wayland_ctx.c +++ b/gfx/context/wayland_ctx.c @@ -331,17 +331,17 @@ static void gfx_ctx_wl_set_resize(void *data, unsigned width, unsigned height) static void gfx_ctx_wl_update_window_title(void *data) { char buf[128], buf_fps[128]; - bool fps_draw = g_settings.fps_show; + bool fps_draw = g_settings.fps_show || g_settings.fps_monitor_enable; gfx_ctx_wayland_data_t *wl = (gfx_ctx_wayland_data_t*) driver.video_context_data; (void)data; - if (gfx_get_fps(buf, sizeof(buf), - fps_draw ? buf_fps : NULL, sizeof(buf_fps))) + if (gfx_get_fps(buf, sizeof(buf), g_settings.fps_show ? + buf_fps : NULL, sizeof(buf_fps))) wl_shell_surface_set_title(wl->g_shell_surf, buf); - if (fps_draw) + if (g_settings.fps_show) msg_queue_push(g_extern.msg_queue, buf_fps, 1, 1); } diff --git a/gfx/context/wgl_ctx.c b/gfx/context/wgl_ctx.c index a434583bce..bc4a71e7f5 100644 --- a/gfx/context/wgl_ctx.c +++ b/gfx/context/wgl_ctx.c @@ -333,14 +333,13 @@ static void gfx_ctx_wgl_set_resize(void *data, static void gfx_ctx_wgl_update_window_title(void *data) { char buf[128], buf_fps[128]; - bool fps_draw = g_settings.fps_show; + bool fps_draw = g_settings.fps_show || g_settings.fps_monitor_enable; (void)data; - if (gfx_get_fps(buf, sizeof(buf), fps_draw ? buf_fps : NULL, sizeof(buf_fps))) + if (gfx_get_fps(buf, sizeof(buf), g_settings.fps_show ? buf_fps : NULL, sizeof(buf_fps))) SetWindowText(g_hwnd, buf); - - if (fps_draw) + if (g_settings.fps_show) msg_queue_push(g_extern.msg_queue, buf_fps, 1, 1); } diff --git a/gfx/context/xegl_ctx.c b/gfx/context/xegl_ctx.c index 46b7e3d77c..3e24f0feb7 100644 --- a/gfx/context/xegl_ctx.c +++ b/gfx/context/xegl_ctx.c @@ -212,15 +212,14 @@ static void gfx_ctx_xegl_set_resize(void *data, static void gfx_ctx_xegl_update_window_title(void *data) { char buf[128], buf_fps[128]; - bool fps_draw = g_settings.fps_show; + bool fps_draw = g_settings.fps_show || g_settings.fps_monitor_enable; (void)data; if (gfx_get_fps(buf, sizeof(buf), - fps_draw ? buf_fps : NULL, sizeof(buf_fps))) + g_settings.fps_show ? buf_fps : NULL, sizeof(buf_fps))) XStoreName(g_dpy, g_win, buf); - - if (fps_draw) + if (g_settings.fps_show) msg_queue_push(g_extern.msg_queue, buf_fps, 1, 1); } diff --git a/settings.c b/settings.c index ac0248f6ea..702c91021f 100644 --- a/settings.c +++ b/settings.c @@ -1242,6 +1242,7 @@ static bool config_load_file(const char *path, bool set_defaults) } CONFIG_GET_BOOL(fps_show, "fps_show"); + CONFIG_GET_BOOL(fps_monitor_enable, "fps_monitor_enable"); CONFIG_GET_BOOL(load_dummy_on_core_shutdown, "load_dummy_on_core_shutdown"); CONFIG_GET_PATH(libretro_info_path, "libretro_info_path"); @@ -1723,6 +1724,7 @@ bool config_save_file(const char *path) config_set_bool(conf, "load_dummy_on_core_shutdown", g_settings.load_dummy_on_core_shutdown); config_set_bool(conf, "fps_show", g_settings.fps_show); + config_set_bool(conf, "fps_monitor_enable", g_settings.fps_monitor_enable); config_set_path(conf, "libretro_path", g_settings.libretro); config_set_path(conf, "libretro_directory", g_settings.libretro_directory); config_set_path(conf, "libretro_info_path", g_settings.libretro_info_path); diff --git a/settings_data.c b/settings_data.c index d4f7e54480..fee0b86835 100644 --- a/settings_data.c +++ b/settings_data.c @@ -4013,6 +4013,17 @@ static bool setting_data_append_list_video_options( general_read_handler); settings_list_current_add_range(list, list_info, 0, 0, 0.001, true, false); + CONFIG_BOOL(g_settings.fps_monitor_enable, + "fps_monitor_enable", + "Monitor FPS Enable", + true, + "OFF", + "ON", + group_info.name, + subgroup_info.name, + general_write_handler, + general_read_handler); + CONFIG_FLOAT( g_settings.video.refresh_rate, "video_refresh_rate_auto", From 76ad6cc344e4fe5e6586c04a8baf417a3076e9b7 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Mon, 12 Jan 2015 06:16:52 +0100 Subject: [PATCH 075/156] Move input drivers to input/drivers --- Makefile.common | 18 +-- griffin/griffin.c | 28 ++-- input/apple_keycode.h | 169 ------------------------- input/{ => drivers}/android_input.c | 14 +- input/{ => drivers}/apple_input.c | 10 +- input/{ => drivers}/apple_input.h | 4 +- input/{ => drivers}/dinput.c | 12 +- input/{ => drivers}/gx_input.c | 4 +- input/{ => drivers}/linuxraw_input.c | 10 +- input/{ => drivers}/nullinput.c | 4 +- input/{ => drivers}/ps3_input.c | 8 +- input/{ => drivers}/psp_input.c | 12 +- input/{ => drivers}/qnx_input.c | 6 +- input/{ => drivers}/rwebinput_input.c | 14 +- input/{ => drivers}/sdl_input.c | 18 +-- input/{ => drivers}/udev_input.c | 10 +- input/{ => drivers}/x11_input.c | 10 +- input/{ => drivers}/xdk_xinput_input.c | 6 +- input/{ => drivers}/xenon360_input.c | 4 +- tools/retroarch-joyconfig-griffin.c | 6 +- 20 files changed, 99 insertions(+), 268 deletions(-) delete mode 100644 input/apple_keycode.h rename input/{ => drivers}/android_input.c (99%) rename input/{ => drivers}/apple_input.c (98%) rename input/{ => drivers}/apple_input.h (96%) rename input/{ => drivers}/dinput.c (99%) rename input/{ => drivers}/gx_input.c (98%) rename input/{ => drivers}/linuxraw_input.c (98%) rename input/{ => drivers}/nullinput.c (97%) rename input/{ => drivers}/ps3_input.c (98%) rename input/{ => drivers}/psp_input.c (93%) rename input/{ => drivers}/qnx_input.c (99%) rename input/{ => drivers}/rwebinput_input.c (96%) rename input/{ => drivers}/sdl_input.c (97%) rename input/{ => drivers}/udev_input.c (99%) rename input/{ => drivers}/x11_input.c (98%) rename input/{ => drivers}/xdk_xinput_input.c (97%) rename input/{ => drivers}/xenon360_input.c (98%) diff --git a/Makefile.common b/Makefile.common index 2036cb7b8a..17d19f0ba4 100644 --- a/Makefile.common +++ b/Makefile.common @@ -62,7 +62,7 @@ endif ifneq ($(findstring Linux,$(OS)),) LIBS += -lrt JOYCONFIG_LIBS += -lrt - OBJ += input/linuxraw_input.o input/linuxraw_joypad.o + OBJ += input/drivers/linuxraw_input.o input/linuxraw_joypad.o endif ifeq ($(findstring Haiku,$(OS)),) @@ -142,7 +142,7 @@ OBJ += frontend/frontend.o \ camera/nullcamera.o \ gfx/nullgfx.o \ audio/drivers/nullaudio.o \ - input/nullinput.o \ + input/drivers/nullinput.o \ input/nullinput_joypad.o \ input/osk/nullosk.o \ playlist.o \ @@ -172,7 +172,7 @@ endif ifeq ($(HAVE_EMSCRIPTEN), 1) OBJ += frontend/platform/platform_emscripten.o \ - input/rwebinput_input.o \ + input/drivers/rwebinput_input.o \ audio/drivers/rwebaudio.o \ camera/rwebcam.o endif @@ -320,7 +320,7 @@ endif #Input ifeq ($(HAVE_WAYLAND), 1) - #OBJ += input/wayland.o + #OBJ += input/drivers/wayland.o DEFINES += $(WAYLAND_CFLAGS) LIBS += $(WAYLAND_LIBS) endif @@ -328,7 +328,7 @@ endif ifeq ($(HAVE_DINPUT), 1) LIBS += -ldinput8 -ldxguid -lole32 DEFINES += -DHAVE_DINPUT - OBJ += input/dinput.o + OBJ += input/drivers/dinput.o JOYCONFIG_LIBS += -ldinput8 -ldxguid -lole32 endif @@ -339,7 +339,7 @@ ifeq ($(HAVE_WINXINPUT), 1) endif ifeq ($(HAVE_X11), 1) - OBJ += input/x11_input.o gfx/context/x11_common.o input/keyboard_event_x11.o + OBJ += input/drivers/x11_input.o gfx/context/x11_common.o input/keyboard_event_x11.o LIBS += $(X11_LIBS) $(XEXT_LIBS) $(XF86VM_LIBS) $(XINERAMA_LIBS) DEFINES += $(X11_CFLAGS) $(XEXT_CFLAGS) $(XF86VM_CFLAGS) $(XINERAMA_CFLAGS) endif @@ -354,7 +354,7 @@ ifeq ($(HAVE_UDEV), 1) DEFINES += $(UDEV_CFLAGS) LIBS += $(UDEV_LIBS) JOYCONFIG_LIBS += $(UDEV_LIBS) - OBJ += input/udev_input.o input/udev_joypad.o + OBJ += input/drivers/udev_input.o input/udev_joypad.o endif ifeq ($(HAVE_PARPORT), 1) @@ -449,7 +449,7 @@ ifeq ($(HAVE_SDL2), 1) endif ifeq ($(HAVE_SDL), 1) - OBJ += gfx/sdl_gfx.o input/sdl_input.o input/sdl_joypad.o audio/drivers/sdl_audio.o + OBJ += gfx/sdl_gfx.o input/drivers/sdl_input.o input/sdl_joypad.o audio/drivers/sdl_audio.o ifeq ($(HAVE_OPENGL), 1) OBJ += gfx/context/sdl_gl_ctx.o @@ -461,7 +461,7 @@ ifeq ($(HAVE_SDL), 1) endif ifeq ($(HAVE_SDL2), 1) - OBJ += gfx/sdl2_gfx.o input/sdl_input.o input/sdl_joypad.o audio/drivers/sdl_audio.o + OBJ += gfx/sdl2_gfx.o input/drivers/sdl_input.o input/sdl_joypad.o audio/drivers/sdl_audio.o ifeq ($(HAVE_OPENGL), 1) OBJ += gfx/context/sdl_gl_ctx.o diff --git a/griffin/griffin.c b/griffin/griffin.c index 2af1e2e39b..b053b88a91 100644 --- a/griffin/griffin.c +++ b/griffin/griffin.c @@ -292,38 +292,38 @@ INPUT #endif #if defined(__CELLOS_LV2__) -#include "../input/ps3_input.c" +#include "../input/drivers/ps3_input.c" #include "../input/ps3_input_joypad.c" #include "../input/autoconf/builtin_ps3.c" #elif defined(SN_TARGET_PSP2) || defined(PSP) -#include "../input/psp_input.c" +#include "../input/drivers/psp_input.c" #include "../input/psp_input_joypad.c" #include "../input/autoconf/builtin_psp.c" #elif defined(GEKKO) #ifdef HAVE_LIBSICKSAXIS #include "../input/gx_input_sicksaxis.c" #endif -#include "../input/gx_input.c" +#include "../input/drivers/gx_input.c" #include "../input/gx_input_joypad.c" #include "../input/autoconf/builtin_gx.c" #elif defined(_XBOX) -#include "../input/xdk_xinput_input.c" +#include "../input/drivers/xdk_xinput_input.c" #include "../input/xdk_xinput_input_joypad.c" #include "../input/autoconf/builtin_xdk.c" #elif defined(_WIN32) #include "../input/autoconf/builtin_win.c" #elif defined(XENON) -#include "../input/xenon360_input.c" +#include "../input/drivers/xenon360_input.c" #elif defined(ANDROID) -#include "../input/android_input.c" +#include "../input/drivers/android_input.c" #include "../input/android_input_joypad.c" #elif defined(__APPLE__) -#include "../input/apple_input.c" +#include "../input/drivers/apple_input.c" #elif defined(__QNX__) -#include "../input/qnx_input.c" +#include "../input/drivers/qnx_input.c" #include "../input/qnx_input_joypad.c" #elif defined(EMSCRIPTEN) -#include "../input/rwebinput_input.c" +#include "../input/drivers/rwebinput_input.c" #endif #if defined(__APPLE__) @@ -343,7 +343,7 @@ INPUT #endif #ifdef HAVE_DINPUT -#include "../input/dinput.c" +#include "../input/drivers/dinput.c" #endif #ifdef HAVE_WINXINPUT @@ -357,20 +357,20 @@ INPUT #include "../input/osk/nullosk.c" #if defined(__linux__) && !defined(ANDROID) -#include "../input/linuxraw_input.c" +#include "../input/drivers/linuxraw_input.c" #include "../input/linuxraw_joypad.c" #endif #ifdef HAVE_X11 -#include "../input/x11_input.c" +#include "../input/drivers/x11_input.c" #endif #ifdef HAVE_UDEV -#include "../input/udev_input.c" +#include "../input/drivers/udev_input.c" #include "../input/udev_joypad.c" #endif -#include "../input/nullinput.c" +#include "../input/drivers/nullinput.c" #include "../input/nullinput_joypad.c" /*============================================================ diff --git a/input/apple_keycode.h b/input/apple_keycode.h deleted file mode 100644 index 4ca31391d5..0000000000 --- a/input/apple_keycode.h +++ /dev/null @@ -1,169 +0,0 @@ -/* -Taken from https://github.com/depp/keycode, distributed with the following license: - -Copyright 2011-2012 Dietrich Epp -All rights reserved. - -Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions are -met: - - 1. Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. - - 2. Redistributions in binary form must reproduce the above - copyright notice, this list of conditions and the following - disclaimer in the documentation and/or other materials provided - with the distribution. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - -/* This file is automatically generated by keycode.py. */ -#ifndef KEYCODE_KEYCODE_H -#define KEYCODE_KEYCODE_H - -enum -{ - KEY_A = 4, - KEY_B = 5, - KEY_C = 6, - KEY_D = 7, - KEY_E = 8, - KEY_F = 9, - KEY_G = 10, - KEY_H = 11, - KEY_I = 12, - KEY_J = 13, - KEY_K = 14, - KEY_L = 15, - KEY_M = 16, - KEY_N = 17, - KEY_O = 18, - KEY_P = 19, - KEY_Q = 20, - KEY_R = 21, - KEY_S = 22, - KEY_T = 23, - KEY_U = 24, - KEY_V = 25, - KEY_W = 26, - KEY_X = 27, - KEY_Y = 28, - KEY_Z = 29, - KEY_1 = 30, - KEY_2 = 31, - KEY_3 = 32, - KEY_4 = 33, - KEY_5 = 34, - KEY_6 = 35, - KEY_7 = 36, - KEY_8 = 37, - KEY_9 = 38, - KEY_0 = 39, - KEY_Enter = 40, - KEY_Escape = 41, - KEY_Delete = 42, - KEY_Tab = 43, - KEY_Space = 44, - KEY_Minus = 45, - KEY_Equals = 46, - KEY_LeftBracket = 47, - KEY_RightBracket = 48, - KEY_Backslash = 49, - KEY_Semicolon = 51, - KEY_Quote = 52, - KEY_Grave = 53, - KEY_Comma = 54, - KEY_Period = 55, - KEY_Slash = 56, - KEY_CapsLock = 57, - KEY_F1 = 58, - KEY_F2 = 59, - KEY_F3 = 60, - KEY_F4 = 61, - KEY_F5 = 62, - KEY_F6 = 63, - KEY_F7 = 64, - KEY_F8 = 65, - KEY_F9 = 66, - KEY_F10 = 67, - KEY_F11 = 68, - KEY_F12 = 69, - KEY_PrintScreen = 70, - KEY_ScrollLock = 71, - KEY_Pause = 72, - KEY_Insert = 73, - KEY_Home = 74, - KEY_PageUp = 75, - KEY_DeleteForward = 76, - KEY_End = 77, - KEY_PageDown = 78, - KEY_Right = 79, - KEY_Left = 80, - KEY_Down = 81, - KEY_Up = 82, - KP_NumLock = 83, - KP_Divide = 84, - KP_Multiply = 85, - KP_Subtract = 86, - KP_Add = 87, - KP_Enter = 88, - KP_1 = 89, - KP_2 = 90, - KP_3 = 91, - KP_4 = 92, - KP_5 = 93, - KP_6 = 94, - KP_7 = 95, - KP_8 = 96, - KP_9 = 97, - KP_0 = 98, - KP_Point = 99, - KEY_NonUSBackslash = 100, - KP_Equals = 103, - KEY_F13 = 104, - KEY_F14 = 105, - KEY_F15 = 106, - KEY_F16 = 107, - KEY_F17 = 108, - KEY_F18 = 109, - KEY_F19 = 110, - KEY_F20 = 111, - KEY_F21 = 112, - KEY_F22 = 113, - KEY_F23 = 114, - KEY_F24 = 115, - KEY_Help = 117, - KEY_Menu = 118, - KEY_LeftControl = 224, - KEY_LeftShift = 225, - KEY_LeftAlt = 226, - KEY_LeftGUI = 227, - KEY_RightControl = 228, - KEY_RightShift = 229, - KEY_RightAlt = 230, - KEY_RightGUI = 231 -}; - -#include "input_common.h" - -struct apple_key_name_map_entry -{ - const char* const keyname; - const uint32_t hid_id; -}; - -extern const struct apple_key_name_map_entry apple_key_name_map[]; - -#endif diff --git a/input/android_input.c b/input/drivers/android_input.c similarity index 99% rename from input/android_input.c rename to input/drivers/android_input.c index e2a160a3bc..919de556ab 100644 --- a/input/android_input.c +++ b/input/drivers/android_input.c @@ -19,13 +19,13 @@ #include #include #include -#include "../frontend/platform/platform_android.h" -#include "input_autodetect.h" -#include "input_common.h" -#include "input_joypad.h" -#include "../performance.h" -#include "../general.h" -#include "../driver.h" +#include "../../frontend/platform/platform_android.h" +#include "../input_autodetect.h" +#include "../input_common.h" +#include "../input_joypad.h" +#include "../../performance.h" +#include "../../general.h" +#include "../../driver.h" #define MAX_TOUCH 16 #define MAX_PADS 8 diff --git a/input/apple_input.c b/input/drivers/apple_input.c similarity index 98% rename from input/apple_input.c rename to input/drivers/apple_input.c index 1166e8f98c..7e234118b6 100644 --- a/input/apple_input.c +++ b/input/drivers/apple_input.c @@ -17,12 +17,12 @@ #include #include -#include "input_common.h" -#include "input_joypad.h" -#include "input_keymaps.h" +#include "../input_common.h" +#include "../input_joypad.h" +#include "../input_keymaps.h" #include "apple_input.h" -#include "../general.h" -#include "../driver.h" +#include "../../general.h" +#include "../../driver.h" #include "apple_keycode.h" diff --git a/input/apple_input.h b/input/drivers/apple_input.h similarity index 96% rename from input/apple_input.h rename to input/drivers/apple_input.h index c513c88fc4..47902c779a 100644 --- a/input/apple_input.h +++ b/input/drivers/apple_input.h @@ -17,8 +17,8 @@ #ifndef __APPLE_RARCH_INPUT_H__ #define __APPLE_RARCH_INPUT_H__ -#include "../general.h" -#include "connect/joypad_connection.h" +#include "../../general.h" +#include "../connect/joypad_connection.h" /* Input responder */ #define MAX_TOUCHES 16 diff --git a/input/dinput.c b/input/drivers/dinput.c similarity index 99% rename from input/dinput.c rename to input/drivers/dinput.c index 082d8385d4..2419a19758 100644 --- a/input/dinput.c +++ b/input/drivers/dinput.c @@ -22,13 +22,13 @@ #define DIRECTINPUT_VERSION 0x0800 #include -#include "../general.h" +#include "../../general.h" #include -#include "input_autodetect.h" -#include "input_common.h" -#include "input_joypad.h" -#include "input_keymaps.h" -#include "retroarch_logger.h" +#include "../input_autodetect.h" +#include "../input_common.h" +#include "../input_joypad.h" +#include "../input_keymaps.h" +#include "../../retroarch_logger.h" #include #include #include diff --git a/input/gx_input.c b/input/drivers/gx_input.c similarity index 98% rename from input/gx_input.c rename to input/drivers/gx_input.c index 9017510101..b1b1f62a99 100644 --- a/input/gx_input.c +++ b/input/drivers/gx_input.c @@ -23,8 +23,8 @@ #define M_PI 3.14159265358979323846264338327 #endif -#include "../driver.h" -#include "../libretro.h" +#include "../../driver.h" +#include "../../libretro.h" #include #ifndef MAX_PADS diff --git a/input/linuxraw_input.c b/input/drivers/linuxraw_input.c similarity index 98% rename from input/linuxraw_input.c rename to input/drivers/linuxraw_input.c index a1064aa493..59c57a2181 100644 --- a/input/linuxraw_input.c +++ b/input/drivers/linuxraw_input.c @@ -14,7 +14,7 @@ * If not, see . */ -#include "../driver.h" +#include "../../driver.h" #include #include @@ -22,10 +22,10 @@ #include #include #include -#include "../general.h" -#include "input_keymaps.h" -#include "input_common.h" -#include "input_joypad.h" +#include "../../general.h" +#include "../input_keymaps.h" +#include "../input_common.h" +#include "../input_joypad.h" static long oldKbmd = 0xffff; static struct termios oldTerm, newTerm; diff --git a/input/nullinput.c b/input/drivers/nullinput.c similarity index 97% rename from input/nullinput.c rename to input/drivers/nullinput.c index 28d44311c5..9f9f0dd154 100644 --- a/input/nullinput.c +++ b/input/drivers/nullinput.c @@ -14,8 +14,8 @@ * If not, see . */ -#include "../general.h" -#include "../driver.h" +#include "../../general.h" +#include "../../driver.h" static void *nullinput_input_init(void) { diff --git a/input/ps3_input.c b/input/drivers/ps3_input.c similarity index 98% rename from input/ps3_input.c rename to input/drivers/ps3_input.c index b93f12805b..9fe8b6e3bc 100644 --- a/input/ps3_input.c +++ b/input/drivers/ps3_input.c @@ -20,11 +20,11 @@ #include #include -#include "../ps3/sdk_defines.h" +#include "../../ps3/sdk_defines.h" -#include "../driver.h" -#include "../libretro.h" -#include "../general.h" +#include "../../driver.h" +#include "../../libretro.h" +#include "../../general.h" #ifdef HAVE_MOUSE #ifndef __PSL1GHT__ diff --git a/input/psp_input.c b/input/drivers/psp_input.c similarity index 93% rename from input/psp_input.c rename to input/drivers/psp_input.c index f14e4fc8a4..9c24b21159 100644 --- a/input/psp_input.c +++ b/input/drivers/psp_input.c @@ -25,14 +25,14 @@ #include #endif -#include "../gfx/psp/sdk_defines.h" +#include "../../gfx/psp/sdk_defines.h" -#include "../driver.h" -#include "../libretro.h" -#include "../general.h" -#include "input_common.h" +#include "../../driver.h" +#include "../../libretro.h" +#include "../../general.h" +#include "../input_common.h" #ifdef HAVE_KERNEL_PRX -#include "../psp1/kernel_functions.h" +#include "../../psp1/kernel_functions.h" #endif #define MAX_PADS 1 diff --git a/input/qnx_input.c b/input/drivers/qnx_input.c similarity index 99% rename from input/qnx_input.c rename to input/drivers/qnx_input.c index 3f92031118..a76c5ec792 100644 --- a/input/qnx_input.c +++ b/input/drivers/qnx_input.c @@ -15,13 +15,13 @@ * If not, see . */ -#include "../general.h" -#include "../driver.h" +#include "../../general.h" +#include "../../driver.h" #include #include #include #include -#Include "input_autodetect.h" +#include "../input_autodetect.h" #define MAX_PADS 8 diff --git a/input/rwebinput_input.c b/input/drivers/rwebinput_input.c similarity index 96% rename from input/rwebinput_input.c rename to input/drivers/rwebinput_input.c index 605506e746..c5499519c0 100644 --- a/input/rwebinput_input.c +++ b/input/drivers/rwebinput_input.c @@ -13,17 +13,17 @@ * If not, see . */ -#include "input_autodetect.h" -#include "input_common.h" -#include "input_keymaps.h" +#include "../input_autodetect.h" +#include "../input_common.h" +#include "../input_keymaps.h" -#include "../driver.h" +#include "../../driver.h" #include -#include "../general.h" -#include "keyboard_line.h" +#include "../../general.h" +#include "../keyboard_line.h" -#include "../emscripten/RWebInput.h" +#include "../../emscripten/RWebInput.h" static bool uninited = false; diff --git a/input/sdl_input.c b/input/drivers/sdl_input.c similarity index 97% rename from input/sdl_input.c rename to input/drivers/sdl_input.c index 264ac6b261..0fd3301da3 100644 --- a/input/sdl_input.c +++ b/input/drivers/sdl_input.c @@ -14,20 +14,20 @@ * If not, see . */ -#include "../driver.h" +#include "../../driver.h" #include "SDL.h" -#include "../gfx/gfx_context.h" +#include "../../gfx/gfx_context.h" #include -#include "../general.h" +#include "../../general.h" #include #include -#include "../libretro.h" -#include "input_autodetect.h" -#include "input_common.h" -#include "input_joypad.h" -#include "input_keymaps.h" -#include "keyboard_line.h" +#include "../../libretro.h" +#include "../input_autodetect.h" +#include "../input_common.h" +#include "../input_joypad.h" +#include "../input_keymaps.h" +#include "../keyboard_line.h" typedef struct sdl_input { diff --git a/input/udev_input.c b/input/drivers/udev_input.c similarity index 99% rename from input/udev_input.c rename to input/drivers/udev_input.c index 59c5b98802..a1e225f5a0 100644 --- a/input/udev_input.c +++ b/input/drivers/udev_input.c @@ -13,10 +13,10 @@ * If not, see . */ -#include "input_common.h" -#include "input_joypad.h" -#include "input_keymaps.h" -#include "../general.h" +#include "../input_common.h" +#include "../input_joypad.h" +#include "../input_keymaps.h" +#include "../../general.h" #include #include #include @@ -36,7 +36,7 @@ #include #ifdef HAVE_CONFIG_H -#include "../config.h" +#include "../../config.h" #endif /* Need libxkbcommon to translate raw evdev events to characters diff --git a/input/x11_input.c b/input/drivers/x11_input.c similarity index 98% rename from input/x11_input.c rename to input/drivers/x11_input.c index 2a5854de5f..9476eea967 100644 --- a/input/x11_input.c +++ b/input/drivers/x11_input.c @@ -13,14 +13,14 @@ * If not, see . */ -#include "input_common.h" -#include "input_joypad.h" -#include "input_keymaps.h" +#include "../input_common.h" +#include "../input_joypad.h" +#include "../input_keymaps.h" -#include "../driver.h" +#include "../../driver.h" #include -#include "../general.h" +#include "../../general.h" #include #include diff --git a/input/xdk_xinput_input.c b/input/drivers/xdk_xinput_input.c similarity index 97% rename from input/xdk_xinput_input.c rename to input/drivers/xdk_xinput_input.c index 5db1b5ca59..8b4e8f326f 100644 --- a/input/xdk_xinput_input.c +++ b/input/drivers/xdk_xinput_input.c @@ -21,9 +21,9 @@ #include #endif -#include "../driver.h" -#include "../general.h" -#include "../libretro.h" +#include "../../driver.h" +#include "../../general.h" +#include "../../libretro.h" #define MAX_PADS 4 diff --git a/input/xenon360_input.c b/input/drivers/xenon360_input.c similarity index 98% rename from input/xenon360_input.c rename to input/drivers/xenon360_input.c index 43e075bb0f..4580506efe 100644 --- a/input/xenon360_input.c +++ b/input/drivers/xenon360_input.c @@ -18,8 +18,8 @@ #include #include -#include "../driver.h" -#include "../libretro.h" +#include "../../driver.h" +#include "../../libretro.h" #include #include diff --git a/tools/retroarch-joyconfig-griffin.c b/tools/retroarch-joyconfig-griffin.c index 1414ce7901..f653d14c14 100644 --- a/tools/retroarch-joyconfig-griffin.c +++ b/tools/retroarch-joyconfig-griffin.c @@ -17,12 +17,12 @@ #include "retroarch-joyconfig.c" #if defined(__linux) && !defined(ANDROID) -#include "../input/linuxraw_input.c" +#include "../input/drivers/linuxraw_input.c" #include "../input/linuxraw_joypad.c" #endif #if defined(HAVE_DINPUT) -#include "../input/dinput.c" +#include "../input/drivers/dinput.c" #endif #if defined(HAVE_WINXINPUT) @@ -46,7 +46,7 @@ #include "../libretro-sdk/string/string_list.c" #include "../libretro-sdk/compat/compat.c" -#include "../input/nullinput.c" +#include "../input/drivers/nullinput.c" #include "../input/nullinput_joypad.c" #include "../input/input_context.c" From dd7d37d49bd294c06bafbfd5ff00034f311419d6 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Mon, 12 Jan 2015 06:18:22 +0100 Subject: [PATCH 076/156] Add input/drivers/apple_keycode.h --- input/drivers/apple_keycode.h | 169 ++++++++++++++++++++++++++++++++++ 1 file changed, 169 insertions(+) create mode 100644 input/drivers/apple_keycode.h diff --git a/input/drivers/apple_keycode.h b/input/drivers/apple_keycode.h new file mode 100644 index 0000000000..4ca31391d5 --- /dev/null +++ b/input/drivers/apple_keycode.h @@ -0,0 +1,169 @@ +/* +Taken from https://github.com/depp/keycode, distributed with the following license: + +Copyright 2011-2012 Dietrich Epp +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are +met: + + 1. Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + + 2. Redistributions in binary form must reproduce the above + copyright notice, this list of conditions and the following + disclaimer in the documentation and/or other materials provided + with the distribution. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +*/ + +/* This file is automatically generated by keycode.py. */ +#ifndef KEYCODE_KEYCODE_H +#define KEYCODE_KEYCODE_H + +enum +{ + KEY_A = 4, + KEY_B = 5, + KEY_C = 6, + KEY_D = 7, + KEY_E = 8, + KEY_F = 9, + KEY_G = 10, + KEY_H = 11, + KEY_I = 12, + KEY_J = 13, + KEY_K = 14, + KEY_L = 15, + KEY_M = 16, + KEY_N = 17, + KEY_O = 18, + KEY_P = 19, + KEY_Q = 20, + KEY_R = 21, + KEY_S = 22, + KEY_T = 23, + KEY_U = 24, + KEY_V = 25, + KEY_W = 26, + KEY_X = 27, + KEY_Y = 28, + KEY_Z = 29, + KEY_1 = 30, + KEY_2 = 31, + KEY_3 = 32, + KEY_4 = 33, + KEY_5 = 34, + KEY_6 = 35, + KEY_7 = 36, + KEY_8 = 37, + KEY_9 = 38, + KEY_0 = 39, + KEY_Enter = 40, + KEY_Escape = 41, + KEY_Delete = 42, + KEY_Tab = 43, + KEY_Space = 44, + KEY_Minus = 45, + KEY_Equals = 46, + KEY_LeftBracket = 47, + KEY_RightBracket = 48, + KEY_Backslash = 49, + KEY_Semicolon = 51, + KEY_Quote = 52, + KEY_Grave = 53, + KEY_Comma = 54, + KEY_Period = 55, + KEY_Slash = 56, + KEY_CapsLock = 57, + KEY_F1 = 58, + KEY_F2 = 59, + KEY_F3 = 60, + KEY_F4 = 61, + KEY_F5 = 62, + KEY_F6 = 63, + KEY_F7 = 64, + KEY_F8 = 65, + KEY_F9 = 66, + KEY_F10 = 67, + KEY_F11 = 68, + KEY_F12 = 69, + KEY_PrintScreen = 70, + KEY_ScrollLock = 71, + KEY_Pause = 72, + KEY_Insert = 73, + KEY_Home = 74, + KEY_PageUp = 75, + KEY_DeleteForward = 76, + KEY_End = 77, + KEY_PageDown = 78, + KEY_Right = 79, + KEY_Left = 80, + KEY_Down = 81, + KEY_Up = 82, + KP_NumLock = 83, + KP_Divide = 84, + KP_Multiply = 85, + KP_Subtract = 86, + KP_Add = 87, + KP_Enter = 88, + KP_1 = 89, + KP_2 = 90, + KP_3 = 91, + KP_4 = 92, + KP_5 = 93, + KP_6 = 94, + KP_7 = 95, + KP_8 = 96, + KP_9 = 97, + KP_0 = 98, + KP_Point = 99, + KEY_NonUSBackslash = 100, + KP_Equals = 103, + KEY_F13 = 104, + KEY_F14 = 105, + KEY_F15 = 106, + KEY_F16 = 107, + KEY_F17 = 108, + KEY_F18 = 109, + KEY_F19 = 110, + KEY_F20 = 111, + KEY_F21 = 112, + KEY_F22 = 113, + KEY_F23 = 114, + KEY_F24 = 115, + KEY_Help = 117, + KEY_Menu = 118, + KEY_LeftControl = 224, + KEY_LeftShift = 225, + KEY_LeftAlt = 226, + KEY_LeftGUI = 227, + KEY_RightControl = 228, + KEY_RightShift = 229, + KEY_RightAlt = 230, + KEY_RightGUI = 231 +}; + +#include "input_common.h" + +struct apple_key_name_map_entry +{ + const char* const keyname; + const uint32_t hid_id; +}; + +extern const struct apple_key_name_map_entry apple_key_name_map[]; + +#endif From 814651406459476fe9e340db4332d8c062b65c65 Mon Sep 17 00:00:00 2001 From: Twinaphex Date: Mon, 12 Jan 2015 06:20:19 +0100 Subject: [PATCH 077/156] (Apple) Build fixes --- apple/OSX/platform.m | 2 +- apple/OSX/settings.m | 2 +- apple/common/apple_gamecontroller.m | 2 +- apple/iOS/menu.m | 2 +- apple/iOS/platform.m | 2 +- input/apple_joypad_hid.c | 2 +- input/apple_joypad_ios.c | 2 +- input/drivers/apple_keycode.h | 2 +- input/input_keymaps.c | 2 +- input/keyboard_event_apple.c | 4 ++-- 10 files changed, 11 insertions(+), 11 deletions(-) diff --git a/apple/OSX/platform.m b/apple/OSX/platform.m index 3e92909530..f1e781d7be 100644 --- a/apple/OSX/platform.m +++ b/apple/OSX/platform.m @@ -19,7 +19,7 @@ #include #import "../common/RetroArch_Apple.h" -#include "../../input/apple_input.h" +#include "../../input/drivers/apple_input.h" #include "../../frontend/frontend.h" #include "../../menu/menu.h" #include "../../retroarch.h" diff --git a/apple/OSX/settings.m b/apple/OSX/settings.m index 5dc2884ba2..4288ee0d2f 100644 --- a/apple/OSX/settings.m +++ b/apple/OSX/settings.m @@ -17,7 +17,7 @@ #import #import "../common/RetroArch_Apple.h" #include "../../settings_data.h" -#include "../../input/apple_input.h" +#include "../../input/drivers/apple_input.h" #include "../../driver.h" #include "../../input/input_common.h" diff --git a/apple/common/apple_gamecontroller.m b/apple/common/apple_gamecontroller.m index fc94a4bcdd..eefed22215 100644 --- a/apple/common/apple_gamecontroller.m +++ b/apple/common/apple_gamecontroller.m @@ -17,7 +17,7 @@ #include "RetroArch_Apple.h" #import #include "apple_gamecontroller.h" -#include "../../input/apple_input.h" +#include "../../input/drivers/apple_input.h" static BOOL apple_gamecontroller_available(void) { diff --git a/apple/iOS/menu.m b/apple/iOS/menu.m index 1a6b5e7f0e..8e718757a7 100644 --- a/apple/iOS/menu.m +++ b/apple/iOS/menu.m @@ -18,7 +18,7 @@ #include "../common/RetroArch_Apple.h" #include "../../input/input_common.h" #include "../../input/input_keymaps.h" -#include "../../input/apple_input.h" +#include "../../input/drivers/apple_input.h" #include #include "menu.h" diff --git a/apple/iOS/platform.m b/apple/iOS/platform.m index 26d69520c6..3a02decdb8 100644 --- a/apple/iOS/platform.m +++ b/apple/iOS/platform.m @@ -17,7 +17,7 @@ #include #include "../common/RetroArch_Apple.h" -#include "../../input/apple_input.h" +#include "../../input/drivers/apple_input.h" #include "../../settings_data.h" #include "../common/apple_gamecontroller.h" #include "menu.h" diff --git a/input/apple_joypad_hid.c b/input/apple_joypad_hid.c index e8c5574d5e..c9e2eedbae 100644 --- a/input/apple_joypad_hid.c +++ b/input/apple_joypad_hid.c @@ -16,7 +16,7 @@ #include #include -#include "apple_input.h" +#include "drivers/apple_input.h" #include "input_autodetect.h" #include "input_common.h" #include "../general.h" diff --git a/input/apple_joypad_ios.c b/input/apple_joypad_ios.c index 01611fae8b..41e95b94b7 100644 --- a/input/apple_joypad_ios.c +++ b/input/apple_joypad_ios.c @@ -14,7 +14,7 @@ * If not, see . */ -#include "apple_input.h" +#include "drivers/apple_input.h" #include "input_autodetect.h" #include "input_common.h" #include "../general.h" diff --git a/input/drivers/apple_keycode.h b/input/drivers/apple_keycode.h index 4ca31391d5..92655fd5fa 100644 --- a/input/drivers/apple_keycode.h +++ b/input/drivers/apple_keycode.h @@ -156,7 +156,7 @@ enum KEY_RightGUI = 231 }; -#include "input_common.h" +#include "../input_common.h" struct apple_key_name_map_entry { diff --git a/input/input_keymaps.c b/input/input_keymaps.c index 3f9801c72c..061f9a5154 100644 --- a/input/input_keymaps.c +++ b/input/input_keymaps.c @@ -39,7 +39,7 @@ #endif #ifdef __APPLE__ -#include "apple_keycode.h" +#include "drivers/apple_keycode.h" #endif #ifdef __linux diff --git a/input/keyboard_event_apple.c b/input/keyboard_event_apple.c index 5beaa66a9f..9564029c2e 100644 --- a/input/keyboard_event_apple.c +++ b/input/keyboard_event_apple.c @@ -19,11 +19,11 @@ #include "input_common.h" #include "input_keymaps.h" -#include "apple_input.h" +#include "drivers/apple_input.h" #include "../general.h" #include "../driver.h" -#include "apple_keycode.h" +#include "drivers/apple_keycode.h" #if defined(IOS) #define HIDKEY(X) X From 2d66cdc3e7f32ceb13fe81e38c1a2ae76ff5d252 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Mon, 12 Jan 2015 06:28:39 +0100 Subject: [PATCH 078/156] Move joypad drivers to input/drivers_joypad --- Makefile.common | 14 +++++----- audio/drivers/gx_audio.c | 2 +- griffin/griffin.c | 26 +++++++++---------- .../android_input_joypad.c | 0 input/{ => drivers_joypad}/apple_joypad_hid.c | 8 +++--- input/{ => drivers_joypad}/apple_joypad_ios.c | 18 ++++++------- input/{ => drivers_joypad}/gx_input_joypad.c | 2 +- .../{ => drivers_joypad}/gx_input_sicksaxis.c | 0 .../{ => drivers_joypad}/gx_input_sicksaxis.h | 0 input/{ => drivers_joypad}/linuxraw_joypad.c | 6 ++--- input/{ => drivers_joypad}/nullinput_joypad.c | 2 +- input/{ => drivers_joypad}/parport_joypad.c | 6 ++--- input/{ => drivers_joypad}/ps3_input_joypad.c | 2 +- input/{ => drivers_joypad}/psp_input_joypad.c | 2 +- input/{ => drivers_joypad}/qnx_input_joypad.c | 2 +- input/{ => drivers_joypad}/sdl_joypad.c | 6 ++--- input/{ => drivers_joypad}/udev_joypad.c | 6 ++--- input/{ => drivers_joypad}/winxinput_joypad.c | 6 ++--- .../xdk_xinput_input_joypad.c | 2 +- tools/retroarch-joyconfig-griffin.c | 12 ++++----- 20 files changed, 61 insertions(+), 61 deletions(-) rename input/{ => drivers_joypad}/android_input_joypad.c (100%) rename input/{ => drivers_joypad}/apple_joypad_hid.c (98%) rename input/{ => drivers_joypad}/apple_joypad_ios.c (88%) rename input/{ => drivers_joypad}/gx_input_joypad.c (99%) rename input/{ => drivers_joypad}/gx_input_sicksaxis.c (100%) rename input/{ => drivers_joypad}/gx_input_sicksaxis.h (100%) rename input/{ => drivers_joypad}/linuxraw_joypad.c (99%) rename input/{ => drivers_joypad}/nullinput_joypad.c (98%) rename input/{ => drivers_joypad}/parport_joypad.c (99%) rename input/{ => drivers_joypad}/ps3_input_joypad.c (99%) rename input/{ => drivers_joypad}/psp_input_joypad.c (99%) rename input/{ => drivers_joypad}/qnx_input_joypad.c (98%) rename input/{ => drivers_joypad}/sdl_joypad.c (99%) rename input/{ => drivers_joypad}/udev_joypad.c (99%) rename input/{ => drivers_joypad}/winxinput_joypad.c (99%) rename input/{ => drivers_joypad}/xdk_xinput_input_joypad.c (99%) diff --git a/Makefile.common b/Makefile.common index 17d19f0ba4..d376983d73 100644 --- a/Makefile.common +++ b/Makefile.common @@ -62,7 +62,7 @@ endif ifneq ($(findstring Linux,$(OS)),) LIBS += -lrt JOYCONFIG_LIBS += -lrt - OBJ += input/drivers/linuxraw_input.o input/linuxraw_joypad.o + OBJ += input/drivers/linuxraw_input.o input/drivers_joypad/linuxraw_joypad.o endif ifeq ($(findstring Haiku,$(OS)),) @@ -143,7 +143,7 @@ OBJ += frontend/frontend.o \ gfx/nullgfx.o \ audio/drivers/nullaudio.o \ input/drivers/nullinput.o \ - input/nullinput_joypad.o \ + input/drivers_joypad/nullinput_joypad.o \ input/osk/nullosk.o \ playlist.o \ movie.o \ @@ -334,7 +334,7 @@ endif ifeq ($(HAVE_WINXINPUT), 1) DEFINES += -DHAVE_WINXINPUT -DHAVE_BUILTIN_AUTOCONFIG - OBJ += input/winxinput_joypad.o \ + OBJ += input/drivers_joypad/winxinput_joypad.o \ input/autoconf/builtin_win.o endif @@ -354,11 +354,11 @@ ifeq ($(HAVE_UDEV), 1) DEFINES += $(UDEV_CFLAGS) LIBS += $(UDEV_LIBS) JOYCONFIG_LIBS += $(UDEV_LIBS) - OBJ += input/drivers/udev_input.o input/udev_joypad.o + OBJ += input/drivers/udev_input.o input/drivers_joypad/udev_joypad.o endif ifeq ($(HAVE_PARPORT), 1) - OBJ += input/parport_joypad.o + OBJ += input/drivers_joypad/parport_joypad.o endif # Video @@ -449,7 +449,7 @@ ifeq ($(HAVE_SDL2), 1) endif ifeq ($(HAVE_SDL), 1) - OBJ += gfx/sdl_gfx.o input/drivers/sdl_input.o input/sdl_joypad.o audio/drivers/sdl_audio.o + OBJ += gfx/sdl_gfx.o input/drivers/sdl_input.o input/drivers_joypad/sdl_joypad.o audio/drivers/sdl_audio.o ifeq ($(HAVE_OPENGL), 1) OBJ += gfx/context/sdl_gl_ctx.o @@ -461,7 +461,7 @@ ifeq ($(HAVE_SDL), 1) endif ifeq ($(HAVE_SDL2), 1) - OBJ += gfx/sdl2_gfx.o input/drivers/sdl_input.o input/sdl_joypad.o audio/drivers/sdl_audio.o + OBJ += gfx/sdl2_gfx.o input/drivers/sdl_input.o input/drivers_joypad/sdl_joypad.o audio/drivers/sdl_audio.o ifeq ($(HAVE_OPENGL), 1) OBJ += gfx/context/sdl_gl_ctx.o diff --git a/audio/drivers/gx_audio.c b/audio/drivers/gx_audio.c index af2f30a3d0..24da783d1c 100644 --- a/audio/drivers/gx_audio.c +++ b/audio/drivers/gx_audio.c @@ -17,7 +17,7 @@ #include "../../driver.h" #include #include -#include "../general.h" +#include "../../general.h" #include #ifdef GEKKO diff --git a/griffin/griffin.c b/griffin/griffin.c index b053b88a91..e99360894c 100644 --- a/griffin/griffin.c +++ b/griffin/griffin.c @@ -293,22 +293,22 @@ INPUT #if defined(__CELLOS_LV2__) #include "../input/drivers/ps3_input.c" -#include "../input/ps3_input_joypad.c" +#include "../input/drivers_joypad/ps3_input_joypad.c" #include "../input/autoconf/builtin_ps3.c" #elif defined(SN_TARGET_PSP2) || defined(PSP) #include "../input/drivers/psp_input.c" -#include "../input/psp_input_joypad.c" +#include "../input/drivers_joypad/psp_input_joypad.c" #include "../input/autoconf/builtin_psp.c" #elif defined(GEKKO) #ifdef HAVE_LIBSICKSAXIS -#include "../input/gx_input_sicksaxis.c" +#include "../input/drivers_joypad/gx_input_sicksaxis.c" #endif #include "../input/drivers/gx_input.c" -#include "../input/gx_input_joypad.c" +#include "../input/drivers_joypad/gx_input_joypad.c" #include "../input/autoconf/builtin_gx.c" #elif defined(_XBOX) #include "../input/drivers/xdk_xinput_input.c" -#include "../input/xdk_xinput_input_joypad.c" +#include "../input/drivers_joypad/xdk_xinput_input_joypad.c" #include "../input/autoconf/builtin_xdk.c" #elif defined(_WIN32) #include "../input/autoconf/builtin_win.c" @@ -316,12 +316,12 @@ INPUT #include "../input/drivers/xenon360_input.c" #elif defined(ANDROID) #include "../input/drivers/android_input.c" -#include "../input/android_input_joypad.c" +#include "../input/drivers_joypad/android_input_joypad.c" #elif defined(__APPLE__) #include "../input/drivers/apple_input.c" #elif defined(__QNX__) #include "../input/drivers/qnx_input.c" -#include "../input/qnx_input_joypad.c" +#include "../input/drivers_joypad/qnx_input_joypad.c" #elif defined(EMSCRIPTEN) #include "../input/drivers/rwebinput_input.c" #endif @@ -333,11 +333,11 @@ INPUT #include "../input/connect/connect_wii.c" #ifdef HAVE_HID -#include "../input/apple_joypad_hid.c" +#include "../input/drivers_joypad/apple_joypad_hid.c" #endif #ifdef IOS -#include "../input/apple_joypad_ios.c" +#include "../input/drivers_joypad/apple_joypad_ios.c" #endif #endif @@ -347,7 +347,7 @@ INPUT #endif #ifdef HAVE_WINXINPUT -#include "../input/winxinput_joypad.c" +#include "../input/drivers_joypad/winxinput_joypad.c" #endif #if defined(__CELLOS_LV2__) @@ -358,7 +358,7 @@ INPUT #if defined(__linux__) && !defined(ANDROID) #include "../input/drivers/linuxraw_input.c" -#include "../input/linuxraw_joypad.c" +#include "../input/drivers_joypad/linuxraw_joypad.c" #endif #ifdef HAVE_X11 @@ -367,11 +367,11 @@ INPUT #ifdef HAVE_UDEV #include "../input/drivers/udev_input.c" -#include "../input/udev_joypad.c" +#include "../input/drivers_joypad/udev_joypad.c" #endif #include "../input/drivers/nullinput.c" -#include "../input/nullinput_joypad.c" +#include "../input/drivers_joypad/nullinput_joypad.c" /*============================================================ KEYBOARD EVENT diff --git a/input/android_input_joypad.c b/input/drivers_joypad/android_input_joypad.c similarity index 100% rename from input/android_input_joypad.c rename to input/drivers_joypad/android_input_joypad.c diff --git a/input/apple_joypad_hid.c b/input/drivers_joypad/apple_joypad_hid.c similarity index 98% rename from input/apple_joypad_hid.c rename to input/drivers_joypad/apple_joypad_hid.c index c9e2eedbae..dce1ab63cb 100644 --- a/input/apple_joypad_hid.c +++ b/input/drivers_joypad/apple_joypad_hid.c @@ -16,10 +16,10 @@ #include #include -#include "drivers/apple_input.h" -#include "input_autodetect.h" -#include "input_common.h" -#include "../general.h" +#include "../drivers/apple_input.h" +#include "../input_autodetect.h" +#include "../input_common.h" +#include "../../general.h" struct pad_connection { diff --git a/input/apple_joypad_ios.c b/input/drivers_joypad/apple_joypad_ios.c similarity index 88% rename from input/apple_joypad_ios.c rename to input/drivers_joypad/apple_joypad_ios.c index 41e95b94b7..1e156f6625 100644 --- a/input/apple_joypad_ios.c +++ b/input/drivers_joypad/apple_joypad_ios.c @@ -14,16 +14,16 @@ * If not, see . */ -#include "drivers/apple_input.h" -#include "input_autodetect.h" -#include "input_common.h" -#include "../general.h" -#include "../apple/common/apple_gamecontroller.h" +#include "../drivers/apple_input.h" +#include "../input_autodetect.h" +#include "../input_common.h" +#include "../../general.h" +#include "../../apple/common/apple_gamecontroller.h" -#include "../apple/iOS/bluetooth/btdynamic.c" -#include "../apple/iOS/bluetooth/btpad.c" -#include "../apple/iOS/bluetooth/btpad_queue.c" -#include "connect/joypad_connection.h" +#include "../../apple/iOS/bluetooth/btdynamic.c" +#include "../../apple/iOS/bluetooth/btpad.c" +#include "../../apple/iOS/bluetooth/btpad_queue.c" +#include "../connect/joypad_connection.h" joypad_connection_t *slots; diff --git a/input/gx_input_joypad.c b/input/drivers_joypad/gx_input_joypad.c similarity index 99% rename from input/gx_input_joypad.c rename to input/drivers_joypad/gx_input_joypad.c index 0695f44784..48fb13fa98 100644 --- a/input/gx_input_joypad.c +++ b/input/drivers_joypad/gx_input_joypad.c @@ -15,7 +15,7 @@ * If not, see . */ -#include "input_autodetect.h" +#include "../input_autodetect.h" #ifdef HW_RVL #include #include diff --git a/input/gx_input_sicksaxis.c b/input/drivers_joypad/gx_input_sicksaxis.c similarity index 100% rename from input/gx_input_sicksaxis.c rename to input/drivers_joypad/gx_input_sicksaxis.c diff --git a/input/gx_input_sicksaxis.h b/input/drivers_joypad/gx_input_sicksaxis.h similarity index 100% rename from input/gx_input_sicksaxis.h rename to input/drivers_joypad/gx_input_sicksaxis.h diff --git a/input/linuxraw_joypad.c b/input/drivers_joypad/linuxraw_joypad.c similarity index 99% rename from input/linuxraw_joypad.c rename to input/drivers_joypad/linuxraw_joypad.c index a7d3ddd5d7..62759f7ebe 100644 --- a/input/linuxraw_joypad.c +++ b/input/drivers_joypad/linuxraw_joypad.c @@ -14,9 +14,9 @@ * If not, see . */ -#include "input_autodetect.h" -#include "input_common.h" -#include "../general.h" +#include "../input_autodetect.h" +#include "../input_common.h" +#include "../../general.h" #include #include #include diff --git a/input/nullinput_joypad.c b/input/drivers_joypad/nullinput_joypad.c similarity index 98% rename from input/nullinput_joypad.c rename to input/drivers_joypad/nullinput_joypad.c index dab608af74..472c8c000f 100644 --- a/input/nullinput_joypad.c +++ b/input/drivers_joypad/nullinput_joypad.c @@ -18,7 +18,7 @@ #include #include #include -#include "input_context.h" +#include "../input_context.h" static const char *null_joypad_name(unsigned pad) { diff --git a/input/parport_joypad.c b/input/drivers_joypad/parport_joypad.c similarity index 99% rename from input/parport_joypad.c rename to input/drivers_joypad/parport_joypad.c index 8d7a316d42..45f1681e66 100644 --- a/input/parport_joypad.c +++ b/input/drivers_joypad/parport_joypad.c @@ -13,9 +13,9 @@ * If not, see . */ -#include "input_autodetect.h" -#include "input_common.h" -#include "../general.h" +#include "../input_autodetect.h" +#include "../input_common.h" +#include "../../general.h" #include #include #include diff --git a/input/ps3_input_joypad.c b/input/drivers_joypad/ps3_input_joypad.c similarity index 99% rename from input/ps3_input_joypad.c rename to input/drivers_joypad/ps3_input_joypad.c index 66b75950aa..ea82a9f10a 100644 --- a/input/ps3_input_joypad.c +++ b/input/drivers_joypad/ps3_input_joypad.c @@ -14,7 +14,7 @@ * If not, see . */ -#include "input_autodetect.h" +#include "../input_autodetect.h" static uint64_t pad_state[MAX_PADS]; static int16_t analog_state[MAX_PADS][2][2]; diff --git a/input/psp_input_joypad.c b/input/drivers_joypad/psp_input_joypad.c similarity index 99% rename from input/psp_input_joypad.c rename to input/drivers_joypad/psp_input_joypad.c index 141b4e3cd9..a705e8cfb1 100644 --- a/input/psp_input_joypad.c +++ b/input/drivers_joypad/psp_input_joypad.c @@ -14,7 +14,7 @@ * If not, see . */ -#include "input_autodetect.h" +#include "../input_autodetect.h" static uint64_t pad_state; static int16_t analog_state[1][2][2]; diff --git a/input/qnx_input_joypad.c b/input/drivers_joypad/qnx_input_joypad.c similarity index 98% rename from input/qnx_input_joypad.c rename to input/drivers_joypad/qnx_input_joypad.c index 8b9319d8b9..e19c6ade47 100644 --- a/input/qnx_input_joypad.c +++ b/input/drivers_joypad/qnx_input_joypad.c @@ -15,7 +15,7 @@ * If not, see . */ -#include "input_autodetect.h" +#include "../input_autodetect.h" static const char *qnx_joypad_name(unsigned pad) { diff --git a/input/sdl_joypad.c b/input/drivers_joypad/sdl_joypad.c similarity index 99% rename from input/sdl_joypad.c rename to input/drivers_joypad/sdl_joypad.c index 3374912393..d1e3c765a1 100644 --- a/input/sdl_joypad.c +++ b/input/drivers_joypad/sdl_joypad.c @@ -14,10 +14,10 @@ * If not, see . */ -#include "input_autodetect.h" -#include "input_common.h" +#include "../input_autodetect.h" +#include "../input_common.h" #include "SDL.h" -#include "../general.h" +#include "../../general.h" typedef struct _sdl_joypad { diff --git a/input/udev_joypad.c b/input/drivers_joypad/udev_joypad.c similarity index 99% rename from input/udev_joypad.c rename to input/drivers_joypad/udev_joypad.c index 0a4aa1e328..288074b6cc 100644 --- a/input/udev_joypad.c +++ b/input/drivers_joypad/udev_joypad.c @@ -13,9 +13,9 @@ * If not, see . */ -#include "input_autodetect.h" -#include "input_common.h" -#include "../general.h" +#include "../input_autodetect.h" +#include "../input_common.h" +#include "../../general.h" #include #include #include diff --git a/input/winxinput_joypad.c b/input/drivers_joypad/winxinput_joypad.c similarity index 99% rename from input/winxinput_joypad.c rename to input/drivers_joypad/winxinput_joypad.c index 48d7421c99..789c739cf7 100644 --- a/input/winxinput_joypad.c +++ b/input/drivers_joypad/winxinput_joypad.c @@ -20,10 +20,10 @@ // Some wrappers for other controllers also simulate xinput (as it is easier to implement) // so this may be useful for those also. -#include "input_autodetect.h" -#include "input_common.h" +#include "../input_autodetect.h" +#include "../input_common.h" -#include "../general.h" +#include "../../general.h" #include #include diff --git a/input/xdk_xinput_input_joypad.c b/input/drivers_joypad/xdk_xinput_input_joypad.c similarity index 99% rename from input/xdk_xinput_input_joypad.c rename to input/drivers_joypad/xdk_xinput_input_joypad.c index 77afc5c98c..6caee605fc 100644 --- a/input/xdk_xinput_input_joypad.c +++ b/input/drivers_joypad/xdk_xinput_input_joypad.c @@ -14,7 +14,7 @@ * If not, see . */ -#include "input_autodetect.h" +#include "../input_autodetect.h" static uint64_t pad_state[MAX_PADS]; static int16_t analog_state[MAX_PADS][2][2]; diff --git a/tools/retroarch-joyconfig-griffin.c b/tools/retroarch-joyconfig-griffin.c index f653d14c14..a55b82ed1e 100644 --- a/tools/retroarch-joyconfig-griffin.c +++ b/tools/retroarch-joyconfig-griffin.c @@ -18,7 +18,7 @@ #if defined(__linux) && !defined(ANDROID) #include "../input/drivers/linuxraw_input.c" -#include "../input/linuxraw_joypad.c" +#include "../input/drivers_joypad/linuxraw_joypad.c" #endif #if defined(HAVE_DINPUT) @@ -26,19 +26,19 @@ #endif #if defined(HAVE_WINXINPUT) -#include "../input/winxinput_joypad.c" +#include "../input/drivers_joypad/winxinput_joypad.c" #endif #if defined(HAVE_UDEV) -#include "../input/udev_joypad.c" +#include "../input/drivers_joypad/udev_joypad.c" #endif #if defined(HAVE_PARPORT) -#include "../input/parport_joypad.c" +#include "../input/drivers_joypad/parport_joypad.c" #endif #if defined(HAVE_SDL) || defined(HAVE_SDL2) -#include "../input/sdl_joypad.c" +#include "../input/drivers_joypad/sdl_joypad.c" #endif #include "../libretro-sdk/file/config_file.c" @@ -47,7 +47,7 @@ #include "../libretro-sdk/compat/compat.c" #include "../input/drivers/nullinput.c" -#include "../input/nullinput_joypad.c" +#include "../input/drivers_joypad/nullinput_joypad.c" #include "../input/input_context.c" #include "../input/input_joypad.c" From a002208f59669cc8e65a397371094db9ae3e7153 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Mon, 12 Jan 2015 06:45:12 +0100 Subject: [PATCH 079/156] Start moving graphics driver to gfx/drivers --- Makefile.common | 16 +-- gfx/{ => drivers}/exynos_gfx.c | 8 +- gfx/{ => drivers}/gl.c | 22 ++-- gfx/{ => drivers}/nullgfx.c | 4 +- gfx/{ => drivers}/omap_gfx.c | 12 +- gfx/{ => drivers}/sdl2_gfx.c | 14 +-- gfx/{ => drivers}/sdl_gfx.c | 12 +- gfx/{ => drivers}/vg.c | 16 +-- gfx/{ => drivers}/xenon360_gfx.c | 4 +- gfx/{ => drivers}/xvideo.c | 208 +++++++++++++++++++------------ griffin/griffin.c | 14 +-- 11 files changed, 189 insertions(+), 141 deletions(-) rename gfx/{ => drivers}/exynos_gfx.c (99%) rename gfx/{ => drivers}/gl.c (99%) rename gfx/{ => drivers}/nullgfx.c (98%) rename gfx/{ => drivers}/omap_gfx.c (99%) rename gfx/{ => drivers}/sdl2_gfx.c (98%) rename gfx/{ => drivers}/sdl_gfx.c (98%) rename gfx/{ => drivers}/vg.c (98%) rename gfx/{ => drivers}/xenon360_gfx.c (99%) rename gfx/{ => drivers}/xvideo.c (81%) diff --git a/Makefile.common b/Makefile.common index d376983d73..3d2d0d6546 100644 --- a/Makefile.common +++ b/Makefile.common @@ -140,7 +140,7 @@ OBJ += frontend/frontend.o \ audio/resamplers/cc_resampler.o \ location/nulllocation.o \ camera/nullcamera.o \ - gfx/nullgfx.o \ + gfx/drivers/nullgfx.o \ audio/drivers/nullaudio.o \ input/drivers/nullinput.o \ input/drivers_joypad/nullinput_joypad.o \ @@ -365,7 +365,7 @@ endif # ifeq ($(HAVE_OPENGL), 1) DEFINES += -DHAVE_OPENGL -DHAVE_GLSL - OBJ += gfx/gl.o \ + OBJ += gfx/drivers/gl.o \ gfx/gl_common.o \ gfx/gfx_context.o \ gfx/context/gfx_null_ctx.o \ @@ -449,7 +449,7 @@ ifeq ($(HAVE_SDL2), 1) endif ifeq ($(HAVE_SDL), 1) - OBJ += gfx/sdl_gfx.o input/drivers/sdl_input.o input/drivers_joypad/sdl_joypad.o audio/drivers/sdl_audio.o + OBJ += gfx/drivers/sdl_gfx.o input/drivers/sdl_input.o input/drivers_joypad/sdl_joypad.o audio/drivers/sdl_audio.o ifeq ($(HAVE_OPENGL), 1) OBJ += gfx/context/sdl_gl_ctx.o @@ -461,7 +461,7 @@ ifeq ($(HAVE_SDL), 1) endif ifeq ($(HAVE_SDL2), 1) - OBJ += gfx/sdl2_gfx.o input/drivers/sdl_input.o input/drivers_joypad/sdl_joypad.o audio/drivers/sdl_audio.o + OBJ += gfx/drivers/sdl2_gfx.o input/drivers/sdl_input.o input/drivers_joypad/sdl_joypad.o audio/drivers/sdl_audio.o ifeq ($(HAVE_OPENGL), 1) OBJ += gfx/context/sdl_gl_ctx.o @@ -474,23 +474,23 @@ ifeq ($(HAVE_SDL2), 1) endif ifeq ($(HAVE_OMAP), 1) - OBJ += gfx/omap_gfx.o + OBJ += gfx/drivers/omap_gfx.o endif ifeq ($(HAVE_EXYNOS), 1) - OBJ += gfx/exynos_gfx.o mem/neon/memcpy-neon.o + OBJ += gfx/drivers/exynos_gfx.o mem/neon/memcpy-neon.o LIBS += $(DRM_LIBS) $(EXYNOS_LIBS) DEFINES += $(DRM_CFLAGS) $(EXYNOS_CFLAGS) endif ifeq ($(HAVE_VG), 1) - OBJ += gfx/vg.o libretro-sdk/gfx/math/matrix_3x3.o + OBJ += gfx/drivers/vg.o libretro-sdk/gfx/math/matrix_3x3.o DEFINES += $(VG_CFLAGS) LIBS += $(VG_LIBS) endif ifeq ($(HAVE_XVIDEO), 1) - OBJ += gfx/xvideo.o + OBJ += gfx/drivers/xvideo.o LIBS += $(XVIDEO_LIBS) DEFINES += $(XVIDEO_CFLAGS) endif diff --git a/gfx/exynos_gfx.c b/gfx/drivers/exynos_gfx.c similarity index 99% rename from gfx/exynos_gfx.c rename to gfx/drivers/exynos_gfx.c index d7fb4778d8..934ecbb61a 100644 --- a/gfx/exynos_gfx.c +++ b/gfx/drivers/exynos_gfx.c @@ -30,10 +30,10 @@ #include -#include "../general.h" -#include "../retroarch.h" -#include "gfx_common.h" -#include "fonts/fonts.h" +#include "../../general.h" +#include "../../retroarch.h" +#include "../gfx_common.h" +#include "../fonts/fonts.h" /* TODO: Honor these properties: vsync, menu rotation, menu alpha, aspect ratio change */ diff --git a/gfx/gl.c b/gfx/drivers/gl.c similarity index 99% rename from gfx/gl.c rename to gfx/drivers/gl.c index 0982297a72..eaf7ec362c 100644 --- a/gfx/gl.c +++ b/gfx/drivers/gl.c @@ -19,37 +19,37 @@ #pragma comment(lib, "opengl32") #endif -#include "../driver.h" -#include "../performance.h" +#include "../../driver.h" +#include "../../performance.h" #include -#include "image/image.h" +#include "../image/image.h" #include -#include "../libretro.h" +#include "../../libretro.h" #include #include -#include "../general.h" -#include "../retroarch.h" +#include "../../general.h" +#include "../../retroarch.h" #include #ifdef HAVE_CONFIG_H #include "config.h" #endif -#include "gl_common.h" -#include "gfx_common.h" -#include "gfx_context.h" +#include "../gl_common.h" +#include "../gfx_common.h" +#include "../gfx_context.h" #include #ifdef HAVE_GLSL -#include "shader/shader_glsl.h" +#include "../shader/shader_glsl.h" #endif #ifdef GL_DEBUG #include #endif -#include "shader/shader_context.h" +#include "../shader/shader_context.h" /* Used for the last pass when rendering to the back buffer. */ static const GLfloat vertexes_flipped[] = { diff --git a/gfx/nullgfx.c b/gfx/drivers/nullgfx.c similarity index 98% rename from gfx/nullgfx.c rename to gfx/drivers/nullgfx.c index ab54737be9..8978b1500d 100644 --- a/gfx/nullgfx.c +++ b/gfx/drivers/nullgfx.c @@ -14,8 +14,8 @@ * If not, see . */ -#include "../general.h" -#include "../driver.h" +#include "../../general.h" +#include "../../driver.h" static void *null_gfx_init(const video_info_t *video, const input_driver_t **input, void **input_data) diff --git a/gfx/omap_gfx.c b/gfx/drivers/omap_gfx.c similarity index 99% rename from gfx/omap_gfx.c rename to gfx/drivers/omap_gfx.c index e9fb32fae4..d5194d3485 100644 --- a/gfx/omap_gfx.c +++ b/gfx/drivers/omap_gfx.c @@ -14,15 +14,15 @@ * If not, see . */ -#include "../driver.h" +#include "../../driver.h" #include #include -#include "../general.h" -#include "../retroarch.h" +#include "../../general.h" +#include "../../retroarch.h" #include -#include "gfx_common.h" -#include "gfx_context.h" -#include "fonts/fonts.h" +#include "../gfx_common.h" +#include "../gfx_context.h" +#include "../fonts/fonts.h" #include #include diff --git a/gfx/sdl2_gfx.c b/gfx/drivers/sdl2_gfx.c similarity index 98% rename from gfx/sdl2_gfx.c rename to gfx/drivers/sdl2_gfx.c index 7df4d44b43..4ed2ba13c0 100644 --- a/gfx/sdl2_gfx.c +++ b/gfx/drivers/sdl2_gfx.c @@ -16,18 +16,18 @@ #include "SDL.h" #include "SDL_syswm.h" -#include "../driver.h" +#include "../../driver.h" #include #include -#include "../general.h" -#include "../retroarch.h" +#include "../../general.h" +#include "../../retroarch.h" #include -#include "gfx_common.h" -#include "gfx_context.h" -#include "fonts/fonts.h" +#include "../gfx_common.h" +#include "../gfx_context.h" +#include "../fonts/fonts.h" #ifdef HAVE_X11 -#include "context/x11_common.h" +#include "../context/x11_common.h" #endif #ifdef HAVE_CONFIG_H diff --git a/gfx/sdl_gfx.c b/gfx/drivers/sdl_gfx.c similarity index 98% rename from gfx/sdl_gfx.c rename to gfx/drivers/sdl_gfx.c index 3238178ac5..e9ed6ac3c9 100644 --- a/gfx/sdl_gfx.c +++ b/gfx/drivers/sdl_gfx.c @@ -15,17 +15,17 @@ */ #include "SDL.h" -#include "../driver.h" +#include "../../driver.h" #include #include -#include "../general.h" +#include "../../general.h" #include -#include "gfx_common.h" -#include "gfx_context.h" -#include "fonts/fonts.h" +#include "../gfx_common.h" +#include "../gfx_context.h" +#include "../fonts/fonts.h" #ifdef HAVE_X11 -#include "context/x11_common.h" +#include "../context/x11_common.h" #endif #ifdef HAVE_CONFIG_H diff --git a/gfx/vg.c b/gfx/drivers/vg.c similarity index 98% rename from gfx/vg.c rename to gfx/drivers/vg.c index a5fab56b20..ce7cb3402d 100644 --- a/gfx/vg.c +++ b/gfx/drivers/vg.c @@ -19,15 +19,15 @@ #include #include #include -#include "gfx_context.h" +#include "../gfx_context.h" #include -#include "../libretro.h" -#include "../general.h" -#include "../retroarch.h" -#include "../driver.h" -#include "../performance.h" -#include "fonts/fonts.h" -#include "../content.h" +#include "../../libretro.h" +#include "../../general.h" +#include "../../retroarch.h" +#include "../../driver.h" +#include "../../performance.h" +#include "../fonts/fonts.h" +#include "../../content.h" typedef struct { diff --git a/gfx/xenon360_gfx.c b/gfx/drivers/xenon360_gfx.c similarity index 99% rename from gfx/xenon360_gfx.c rename to gfx/drivers/xenon360_gfx.c index ef95e5c7bd..004e0eb43f 100644 --- a/gfx/xenon360_gfx.c +++ b/gfx/drivers/xenon360_gfx.c @@ -22,8 +22,8 @@ #include #include -#include "driver.h" -#include "general.h" +#include "../../driver.h" +#include "../../general.h" #ifdef HAVE_CONFIG_H #include "config.h" diff --git a/gfx/xvideo.c b/gfx/drivers/xvideo.c similarity index 81% rename from gfx/xvideo.c rename to gfx/drivers/xvideo.c index 2ec0ed6328..54dbffcee4 100644 --- a/gfx/xvideo.c +++ b/gfx/drivers/xvideo.c @@ -13,16 +13,16 @@ * If not, see . */ -#include "driver.h" -#include "general.h" +#include "../../driver.h" +#include "../../general.h" #include #include #include #include -#include "gfx_common.h" -#include "fonts/fonts.h" +#include "../gfx_common.h" +#include "../fonts/fonts.h" -#include "context/x11_common.h" +#include "../context/x11_common.h" #include #include @@ -33,7 +33,7 @@ #include #include -// Adapted from bSNES and MPlayer source. +/* Adapted from bSNES and MPlayer source. */ typedef struct xv { @@ -114,11 +114,11 @@ static void init_yuv_tables(xv_t *xv) for (i = 0; i < 0x10000; i++) { - // Extract RGB565 color data from i + /* Extract RGB565 color data from i */ unsigned r = (i >> 11) & 0x1f, g = (i >> 5) & 0x3f, b = (i >> 0) & 0x1f; - r = (r << 3) | (r >> 2); // R5->R8 - g = (g << 2) | (g >> 4); // G6->G8 - b = (b << 3) | (b >> 2); // B5->B8 + r = (r << 3) | (r >> 2); /* R5->R8 */ + g = (g << 2) | (g >> 4); /* G6->G8 */ + b = (b << 3) | (b >> 2); /* B5->B8 */ calculate_yuv(&xv->ytable[i], &xv->utable[i], &xv->vtable[i], r, g, b); } @@ -129,13 +129,16 @@ static void xv_init_font(xv_t *xv, const char *font_path, unsigned font_size) if (!g_settings.video.font_enable) return; - if (font_renderer_create_default(&xv->font_driver, &xv->font, *g_settings.video.font_path ? g_settings.video.font_path : NULL, g_settings.video.font_size)) + if (font_renderer_create_default(&xv->font_driver, + &xv->font, *g_settings.video.font_path + ? g_settings.video.font_path : NULL, g_settings.video.font_size)) { - int r = g_settings.video.msg_color_r * 255; + int r, g, b; + r = g_settings.video.msg_color_r * 255; r = (r < 0 ? 0 : (r > 255 ? 255 : r)); - int g = g_settings.video.msg_color_g * 255; + g = g_settings.video.msg_color_g * 255; g = (g < 0 ? 0 : (g > 255 ? 255 : g)); - int b = g_settings.video.msg_color_b * 255; + b = g_settings.video.msg_color_b * 255; b = (b < 0 ? 0 : (b > 255 ? 255 : b)); calculate_yuv(&xv->font_y, &xv->font_u, &xv->font_v, @@ -145,8 +148,10 @@ static void xv_init_font(xv_t *xv, const char *font_path, unsigned font_size) RARCH_LOG("Could not initialize fonts.\n"); } -// We render @ 2x scale to combat chroma downsampling. Also makes fonts more bearable :) -static void render16_yuy2(xv_t *xv, const void *input_, unsigned width, unsigned height, unsigned pitch) +/* We render @ 2x scale to combat chroma downsampling. + * Also makes fonts more bearable. */ +static void render16_yuy2(xv_t *xv, const void *input_, + unsigned width, unsigned height, unsigned pitch) { unsigned x, y; const uint16_t *input = (const uint16_t*)input_; @@ -163,6 +168,7 @@ static void render16_yuy2(xv_t *xv, const void *input_, unsigned width, unsigned uint8_t v = xv->vtable[p]; unsigned img_width = xv->width << 1; + output[0] = output[img_width] = y0; output[1] = output[img_width + 1] = u; output[2] = output[img_width + 2] = y0; @@ -175,7 +181,8 @@ static void render16_yuy2(xv_t *xv, const void *input_, unsigned width, unsigned } } -static void render16_uyvy(xv_t *xv, const void *input_, unsigned width, unsigned height, unsigned pitch) +static void render16_uyvy(xv_t *xv, const void *input_, + unsigned width, unsigned height, unsigned pitch) { unsigned x, y; const uint16_t *input = (const uint16_t*)input_; @@ -192,6 +199,7 @@ static void render16_uyvy(xv_t *xv, const void *input_, unsigned width, unsigned uint8_t v = xv->vtable[p]; unsigned img_width = xv->width << 1; + output[0] = output[img_width] = u; output[1] = output[img_width + 1] = y0; output[2] = output[img_width + 2] = v; @@ -204,7 +212,8 @@ static void render16_uyvy(xv_t *xv, const void *input_, unsigned width, unsigned } } -static void render32_yuy2(xv_t *xv, const void *input_, unsigned width, unsigned height, unsigned pitch) +static void render32_yuy2(xv_t *xv, const void *input_, + unsigned width, unsigned height, unsigned pitch) { unsigned x, y; const uint32_t *input = (const uint32_t*)input_; @@ -214,14 +223,16 @@ static void render32_yuy2(xv_t *xv, const void *input_, unsigned width, unsigned { for (x = 0; x < width; x++) { + uint8_t y0, u, v; + unsigned img_width; uint32_t p = *input++; - p = ((p >> 8) & 0xf800) | ((p >> 5) & 0x07e0) | ((p >> 3) & 0x1f); // ARGB -> RGB16 + p = ((p >> 8) & 0xf800) | ((p >> 5) & 0x07e0) | ((p >> 3) & 0x1f); /* ARGB -> RGB16 */ - uint8_t y0 = xv->ytable[p]; - uint8_t u = xv->utable[p]; - uint8_t v = xv->vtable[p]; + y0 = xv->ytable[p]; + u = xv->utable[p]; + v = xv->vtable[p]; - unsigned img_width = xv->width << 1; + img_width = xv->width << 1; output[0] = output[img_width] = y0; output[1] = output[img_width + 1] = u; output[2] = output[img_width + 2] = y0; @@ -234,7 +245,8 @@ static void render32_yuy2(xv_t *xv, const void *input_, unsigned width, unsigned } } -static void render32_uyvy(xv_t *xv, const void *input_, unsigned width, unsigned height, unsigned pitch) +static void render32_uyvy(xv_t *xv, const void *input_, + unsigned width, unsigned height, unsigned pitch) { unsigned x, y; const uint32_t *input = (const uint32_t*)input_; @@ -244,14 +256,16 @@ static void render32_uyvy(xv_t *xv, const void *input_, unsigned width, unsigned { for (x = 0; x < width; x++) { + uint8_t y0, u, v; + unsigned img_width; uint32_t p = *input++; - p = ((p >> 8) & 0xf800) | ((p >> 5) & 0x07e0) | ((p >> 3) & 0x1f); // ARGB -> RGB16 + p = ((p >> 8) & 0xf800) | ((p >> 5) & 0x07e0) | ((p >> 3) & 0x1f); /* ARGB -> RGB16 */ - uint8_t y0 = xv->ytable[p]; - uint8_t u = xv->utable[p]; - uint8_t v = xv->vtable[p]; + y0 = xv->ytable[p]; + u = xv->utable[p]; + v = xv->vtable[p]; - unsigned img_width = xv->width << 1; + img_width = xv->width << 1; output[0] = output[img_width] = u; output[1] = output[img_width + 1] = y0; output[2] = output[img_width + 2] = v; @@ -295,12 +309,14 @@ static const struct format_desc formats[] = { }, }; -static bool adaptor_set_format(xv_t *xv, Display *dpy, XvPortID port, const video_info_t *video) +static bool adaptor_set_format(xv_t *xv, Display *dpy, + XvPortID port, const video_info_t *video) { int i; unsigned j; int format_count; XvImageFormatValues *format = XvListImageFormats(xv->display, port, &format_count); + if (!format) return false; @@ -333,7 +349,8 @@ static bool adaptor_set_format(xv_t *xv, Display *dpy, XvPortID port, const vide return false; } -static void calc_out_rect(bool keep_aspect, struct rarch_viewport *vp, unsigned vp_width, unsigned vp_height) +static void calc_out_rect(bool keep_aspect, struct rarch_viewport *vp, + unsigned vp_width, unsigned vp_height) { vp->full_width = vp_width; vp->full_height = vp_height; @@ -353,8 +370,10 @@ static void calc_out_rect(bool keep_aspect, struct rarch_viewport *vp, unsigned float desired_aspect = g_extern.system.aspect_ratio; float device_aspect = (float)vp_width / vp_height; - // If the aspect ratios of screen and desired aspect ratio are sufficiently equal (floating point stuff), - // assume they are actually equal. + /* If the aspect ratios of screen and desired aspect ratio + * are sufficiently equal (floating point stuff), + * assume they are actually equal. + */ if (fabs(device_aspect - desired_aspect) < 0.0001) { vp->x = 0; vp->y = 0; @@ -380,16 +399,10 @@ static void calc_out_rect(bool keep_aspect, struct rarch_viewport *vp, unsigned } } -static void *xv_init(const video_info_t *video, const input_driver_t **input, void **input_data) +static void *xv_init(const video_info_t *video, + const input_driver_t **input, void **input_data) { - xv_t *xv = (xv_t*)calloc(1, sizeof(*xv)); - if (!xv) - return NULL; - - XInitThreads(); - unsigned i; - xv->display = XOpenDisplay(NULL); struct sigaction sa; unsigned adaptor_count = 0; int visualmatches = 0; @@ -400,7 +413,15 @@ static void *xv_init(const video_info_t *video, const input_driver_t **input, vo void *xinput = NULL; XVisualInfo *visualinfo = NULL; XVisualInfo visualtemplate = {0}; - const struct retro_game_geometry *geom = &g_extern.system.av_info.geometry; + const struct retro_game_geometry *geom = NULL; + xv_t *xv = (xv_t*)calloc(1, sizeof(*xv)); + if (!xv) + return NULL; + + XInitThreads(); + + xv->display = XOpenDisplay(NULL); + geom = &g_extern.system.av_info.geometry; if (!XShmQueryExtension(xv->display)) { @@ -410,17 +431,25 @@ static void *xv_init(const video_info_t *video, const input_driver_t **input, vo xv->keep_aspect = video->force_aspect; - // Find an appropriate Xv port. + /* Find an appropriate Xv port. */ xv->port = 0; XvAdaptorInfo *adaptor_info; - XvQueryAdaptors(xv->display, DefaultRootWindow(xv->display), &adaptor_count, &adaptor_info); + XvQueryAdaptors(xv->display, + DefaultRootWindow(xv->display), &adaptor_count, &adaptor_info); + for (i = 0; i < adaptor_count; i++) { - // Find adaptor that supports both input (memory->drawable) and image (drawable->screen) masks. - if (adaptor_info[i].num_formats < 1) continue; - if (!(adaptor_info[i].type & XvInputMask)) continue; - if (!(adaptor_info[i].type & XvImageMask)) continue; - if (!adaptor_set_format(xv, xv->display, adaptor_info[i].base_id, video)) continue; + /* Find adaptor that supports both input (memory->drawable) + * and image (drawable->screen) masks. */ + + if (adaptor_info[i].num_formats < 1) + continue; + if (!(adaptor_info[i].type & XvInputMask)) + continue; + if (!(adaptor_info[i].type & XvImageMask)) + continue; + if (!adaptor_set_format(xv, xv->display, adaptor_info[i].base_id, video)) + continue; xv->port = adaptor_info[i].base_id; xv->depth = adaptor_info[i].formats->depth; @@ -441,7 +470,9 @@ static void *xv_init(const video_info_t *video, const input_driver_t **input, vo visualtemplate.screen = DefaultScreen(xv->display); visualtemplate.depth = xv->depth; visualtemplate.visual = 0; - visualinfo = XGetVisualInfo(xv->display, VisualIDMask | VisualScreenMask | VisualDepthMask, &visualtemplate, &visualmatches); + visualinfo = XGetVisualInfo(xv->display, VisualIDMask | + VisualScreenMask | VisualDepthMask, &visualtemplate, &visualmatches); + if (visualmatches < 1 || !visualinfo->visual) { if (visualinfo) XFree(visualinfo); @@ -449,10 +480,13 @@ static void *xv_init(const video_info_t *video, const input_driver_t **input, vo goto error; } - xv->colormap = XCreateColormap(xv->display, DefaultRootWindow(xv->display), visualinfo->visual, AllocNone); + xv->colormap = XCreateColormap(xv->display, + DefaultRootWindow(xv->display), visualinfo->visual, AllocNone); + attributes.colormap = xv->colormap; attributes.border_pixel = 0; - attributes.event_mask = StructureNotifyMask | KeyPressMask | KeyReleaseMask | DestroyNotify | ClientMessage; + attributes.event_mask = StructureNotifyMask | KeyPressMask | + KeyReleaseMask | DestroyNotify | ClientMessage; width = video->fullscreen ? ((video->width == 0) ? geom->base_width : video->width) : video->width; height = video->fullscreen ? ((video->height == 0) ? geom->base_height : video->height) : video->height; @@ -479,14 +513,17 @@ static void *xv_init(const video_info_t *video, const input_driver_t **input, vo xv->gc = XCreateGC(xv->display, xv->window, 0, 0); - // Set colorkey to auto paint, so that Xv video output is always visible + /* Set colorkey to auto paint, so that Xv video output is always visible. */ atom = XInternAtom(xv->display, "XV_AUTOPAINT_COLORKEY", true); - if (atom != None) XvSetPortAttribute(xv->display, xv->port, atom, 1); + if (atom != None) + XvSetPortAttribute(xv->display, xv->port, atom, 1); xv->width = geom->max_width; xv->height = geom->max_height; - xv->image = XvShmCreateImage(xv->display, xv->port, xv->fourcc, NULL, xv->width, xv->height, &xv->shminfo); + xv->image = XvShmCreateImage(xv->display, xv->port, xv->fourcc, + NULL, xv->width, xv->height, &xv->shminfo); + if (!xv->image) { RARCH_ERR("XVideo: XShmCreateImage failed.\n"); @@ -556,7 +593,7 @@ error: static bool check_resize(xv_t *xv, unsigned width, unsigned height) { - // We render @ 2x scale to combat chroma downsampling. + /* We render @ 2x scale to combat chroma downsampling. */ if (xv->width != (width << 1) || xv->height != (height << 1)) { xv->width = width << 1; @@ -599,9 +636,10 @@ static bool check_resize(xv_t *xv, unsigned width, unsigned height) return true; } -// TODO: Is there some way to render directly like GL? :( -// Hacky C code is hacky :D Yay. -static void xv_render_msg(xv_t *xv, const char *msg, unsigned width, unsigned height) +/* TODO: Is there some way to render directly like GL? + * Hacky C code is hacky. */ +static void xv_render_msg(xv_t *xv, const char *msg, + unsigned width, unsigned height) { if (!xv->font) return; @@ -618,21 +656,25 @@ static void xv_render_msg(xv_t *xv, const char *msg, unsigned width, unsigned he unsigned chroma_u_index = xv->chroma_u_index; unsigned chroma_v_index = xv->chroma_v_index; - unsigned pitch = width << 1; // YUV formats used are 16 bpp. + unsigned pitch = width << 1; /* YUV formats used are 16 bpp. */ 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 struct font_glyph *glyph = xv->font_driver->get_glyph(xv->font, (uint8_t)*msg); if (!glyph) continue; - int base_x = (msg_base_x + glyph->draw_offset_x + 1) & ~1; // Make sure we always start on the correct boundary so the indices are correct. - int base_y = msg_base_y + glyph->draw_offset_y; + /* 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; - int glyph_width = glyph->width; - int glyph_height = glyph->height; + glyph_width = glyph->width; + glyph_height = glyph->height; - const uint8_t *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) { @@ -648,8 +690,8 @@ static void xv_render_msg(xv_t *xv, const char *msg, unsigned width, unsigned he base_y = 0; } - int max_width = width - base_x; - int max_height = height - base_y; + max_width = width - base_x; + max_height = height - base_y; if (max_width <= 0 || max_height <= 0) continue; @@ -659,16 +701,17 @@ static void xv_render_msg(xv_t *xv, const char *msg, unsigned width, unsigned he if (glyph_height > max_height) glyph_height = max_height; - uint8_t *out = (uint8_t*)xv->image->data + base_y * pitch + (base_x << 1); + out = (uint8_t*)xv->image->data + base_y * pitch + (base_x << 1); for (y = 0; y < glyph_height; y++, src += atlas->width, out += pitch) { - // 2 input pixels => 4 bytes (2Y, 1U, 1V). + /* 2 input pixels => 4 bytes (2Y, 1U, 1V). */ + for (x = 0; x < glyph_width; x += 2) { + unsigned alpha[2], alpha_sub, blended; int out_x = x << 1; - unsigned alpha[2]; alpha[0] = src[x + 0]; if (x + 1 < glyph_width) @@ -676,7 +719,8 @@ static void xv_render_msg(xv_t *xv, const char *msg, unsigned width, unsigned he else alpha[1] = 0; - unsigned alpha_sub = (alpha[0] + alpha[1]) >> 1; // Blended alpha for the sub-sampled U/V channels. + /* Blended alpha for the sub-sampled U/V channels. */ + alpha_sub = (alpha[0] + alpha[1]) >> 1; for (i = 0; i < 2; i++) { @@ -684,8 +728,8 @@ static void xv_render_msg(xv_t *xv, const char *msg, unsigned width, unsigned he out[out_x + luma_index[i]] = blended; } - // Blend chroma channels - unsigned blended = (xv->font_u * alpha_sub + ((256 - alpha_sub) * out[out_x + chroma_u_index])) >> 8; + /* Blend chroma channels */ + blended = (xv->font_u * alpha_sub + ((256 - alpha_sub) * out[out_x + chroma_u_index])) >> 8; out[out_x + chroma_u_index] = blended; blended = (xv->font_v * alpha_sub + ((256 - alpha_sub) * out[out_x + chroma_v_index])) >> 8; @@ -698,17 +742,19 @@ static void xv_render_msg(xv_t *xv, const char *msg, unsigned width, unsigned he } } -static bool xv_frame(void *data, const void *frame, unsigned width, unsigned height, unsigned pitch, const char *msg) +static bool xv_frame(void *data, const void *frame, unsigned width, + unsigned height, unsigned pitch, const char *msg) { + char buf[128]; + XWindowAttributes target; + xv_t *xv = (xv_t*)data; + if (!frame) return true; - xv_t *xv = (xv_t*)data; - if (!check_resize(xv, width, height)) return false; - XWindowAttributes target; XGetWindowAttributes(xv->display, xv->window, &target); xv->render_func(xv, frame, width, height, pitch); @@ -725,7 +771,6 @@ static bool xv_frame(void *data, const void *frame, unsigned width, unsigned hei true); XSync(xv->display, False); - char buf[128]; if (gfx_get_fps(buf, sizeof(buf), NULL, 0)) XStoreName(xv->display, xv->window, buf); @@ -735,13 +780,14 @@ static bool xv_frame(void *data, const void *frame, unsigned width, unsigned hei static bool xv_alive(void *data) { + XEvent event; xv_t *xv = (xv_t*)data; - XEvent event; while (XPending(xv->display)) { + bool filter; XNextEvent(xv->display, &event); - bool filter = XFilterEvent(&event, xv->window); + filter = XFilterEvent(&event, xv->window); switch (event.type) { @@ -774,6 +820,8 @@ static bool xv_alive(void *data) static bool xv_focus(void *data) { xv_t *xv = (xv_t*)data; + if (!xv) + return false; return xv->focus; } diff --git a/griffin/griffin.c b/griffin/griffin.c index e99360894c..3a841d8530 100644 --- a/griffin/griffin.c +++ b/griffin/griffin.c @@ -182,13 +182,13 @@ VIDEO DRIVER #endif #ifdef HAVE_VG -#include "../gfx/vg.c" +#include "../gfx/drivers/vg.c" #include "../libretro-sdk/gfx/math/matrix_3x3.c" #endif #ifdef HAVE_OMAP -#include "../gfx/omap_gfx.c" -#include "../gfx/fbdev.c" +#include "../gfx/drivers/omap_gfx.c" +#include "../gfx/drivers/fbdev.c" #endif #include "../gfx/gfx_common.c" @@ -198,7 +198,7 @@ VIDEO DRIVER #endif #ifdef HAVE_OPENGL -#include "../gfx/gl.c" +#include "../gfx/drivers/gl.c" #include "../gfx/gl_common.c" #ifndef HAVE_PSGL @@ -213,7 +213,7 @@ VIDEO DRIVER #endif #ifdef HAVE_XVIDEO -#include "../gfx/xvideo.c" +#include "../gfx/drivers/xvideo.c" #endif #if defined(_XBOX) || defined(HAVE_WIN32_D3D9) @@ -229,10 +229,10 @@ VIDEO DRIVER #elif defined(PSP) #include "../gfx/psp/psp1_gfx.c" #elif defined(XENON) -#include "../gfx/xenon360_gfx.c" +#include "../gfx/drivers/xenon360_gfx.c" #endif -#include "../gfx/nullgfx.c" +#include "../gfx/drivers/nullgfx.c" /*============================================================ FONTS From 1fe99148b58756c019d793e6675b2a8409ff2813 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Mon, 12 Jan 2015 06:45:49 +0100 Subject: [PATCH 080/156] (Griffin) Update --- griffin/griffin.c | 1 - 1 file changed, 1 deletion(-) diff --git a/griffin/griffin.c b/griffin/griffin.c index 3a841d8530..35a67190f8 100644 --- a/griffin/griffin.c +++ b/griffin/griffin.c @@ -188,7 +188,6 @@ VIDEO DRIVER #ifdef HAVE_OMAP #include "../gfx/drivers/omap_gfx.c" -#include "../gfx/drivers/fbdev.c" #endif #include "../gfx/gfx_common.c" From 98f35db95c549175bea5007ee111b254361f57ac Mon Sep 17 00:00:00 2001 From: twinaphex Date: Mon, 12 Jan 2015 06:51:57 +0100 Subject: [PATCH 081/156] (PSP) Build fixes and rename sdk_defines.h --- Makefile.psp1.salamander | 2 +- audio/drivers/gx_audio.c | 2 +- frontend/platform/platform_gx.c | 2 +- frontend/platform/platform_psp.c | 8 +- gfx/gx/gx_gfx.c | 2 +- gfx/gx/{sdk_defines.h => gx_sdk_defines.h} | 0 gfx/psp/psp1_gfx.c | 2 +- gfx/psp/sdk_defines.h | 96 ---------------------- input/drivers/psp_input.c | 2 +- 9 files changed, 12 insertions(+), 104 deletions(-) rename gfx/gx/{sdk_defines.h => gx_sdk_defines.h} (100%) delete mode 100644 gfx/psp/sdk_defines.h diff --git a/Makefile.psp1.salamander b/Makefile.psp1.salamander index ff6f4ee75f..252b499584 100644 --- a/Makefile.psp1.salamander +++ b/Makefile.psp1.salamander @@ -14,7 +14,7 @@ INCDIR = $(PSPPATH)/include libretro-sdk/include CFLAGS = $(OPTIMIZE_LV) -G0 -std=gnu99 -ffast-math ASFLAGS = $(CFLAGS) -RARCH_DEFINES = -DPSP -DIS_SALAMANDER -DRARCH_CONSOLE -DRARCH_INTERNAL +RARCH_DEFINES = -DPSP -DIS_SALAMANDER -DRARCH_CONSOLE LIBDIR = LDFLAGS = diff --git a/audio/drivers/gx_audio.c b/audio/drivers/gx_audio.c index 24da783d1c..0c3eaa4aee 100644 --- a/audio/drivers/gx_audio.c +++ b/audio/drivers/gx_audio.c @@ -27,7 +27,7 @@ #include #endif -#include "../../gfx/gx/sdk_defines.h" +#include "../../gfx/gx/gx_sdk_defines.h" #define CHUNK_FRAMES 64 #define CHUNK_SIZE (CHUNK_FRAMES * sizeof(uint32_t)) diff --git a/frontend/platform/platform_gx.c b/frontend/platform/platform_gx.c index b6ed20e50c..041a05c9f5 100644 --- a/frontend/platform/platform_gx.c +++ b/frontend/platform/platform_gx.c @@ -19,7 +19,7 @@ #include "../../driver.h" #include "../../general.h" #include "../../libretro_private.h" -#include "../../gfx/gx/sdk_defines.h" +#include "../../gfx/gx/gx_sdk_defines.h" #include diff --git a/frontend/platform/platform_psp.c b/frontend/platform/platform_psp.c index c217ffbc4e..f29b924495 100644 --- a/frontend/platform/platform_psp.c +++ b/frontend/platform/platform_psp.c @@ -25,7 +25,7 @@ #include #include -#include "../../gfx/psp/sdk_defines.h" +#include "../../gfx/psp/psp_sdk_defines.h" #include #include "../../general.h" @@ -85,11 +85,14 @@ static void frontend_psp_get_environment_settings(int *argc, char *argv[], fill_pathname_join(g_defaults.config_path, g_defaults.port_dir, "retroarch.cfg", sizeof(g_defaults.config_path)); +#ifndef IS_SALAMANDER if (argv[1] && (argv[1][0] != '\0')) { static char path[PATH_MAX_LENGTH]; + struct rarch_main_wrap *args = NULL; + *path = '\0'; - struct rarch_main_wrap *args = (struct rarch_main_wrap*)params_data; + args = (struct rarch_main_wrap*)params_data; if (args) { @@ -111,6 +114,7 @@ static void frontend_psp_get_environment_settings(int *argc, char *argv[], RARCH_LOG("Auto-start game %s.\n", argv[1]); } } +#endif } static void frontend_psp_deinit(void *data) diff --git a/gfx/gx/gx_gfx.c b/gfx/gx/gx_gfx.c index 1e24c15001..4be12db350 100644 --- a/gfx/gx/gx_gfx.c +++ b/gfx/gx/gx_gfx.c @@ -34,7 +34,7 @@ #include "ppc_asm.h" #include "gx_gfx_inl.h" -#include "sdk_defines.h" +#include "gx_sdk_defines.h" #define SYSMEM1_SIZE 0x01800000 diff --git a/gfx/gx/sdk_defines.h b/gfx/gx/gx_sdk_defines.h similarity index 100% rename from gfx/gx/sdk_defines.h rename to gfx/gx/gx_sdk_defines.h diff --git a/gfx/psp/psp1_gfx.c b/gfx/psp/psp1_gfx.c index f09f24fb54..f2f9566a06 100644 --- a/gfx/psp/psp1_gfx.c +++ b/gfx/psp/psp1_gfx.c @@ -21,7 +21,7 @@ #include #include -#include "sdk_defines.h" +#include "psp_sdk_defines.h" #include "../../general.h" #include "../../driver.h" #include "../gfx_common.h" diff --git a/gfx/psp/sdk_defines.h b/gfx/psp/sdk_defines.h deleted file mode 100644 index 51759c0264..0000000000 --- a/gfx/psp/sdk_defines.h +++ /dev/null @@ -1,96 +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 . - */ - -#ifndef _PSP_SDK_DEFINES_H -#define _PSP_SDK_DEFINES_H - -/*============================================================ - ERROR PROTOTYPES -============================================================ */ - -#if defined(PSP) -#define SCE_OK 0 -#endif - -/*============================================================ - DISPLAY PROTOTYPES -============================================================ */ - -#if defined(SN_TARGET_PSP2) -#define PSP_DISPLAY_PIXEL_FORMAT_8888 (SCE_DISPLAY_PIXELFORMAT_A8B8G8R8) - -#define DisplaySetFrameBuf(topaddr, bufferwidth, pixelformat, sync) sceDisplaySetFrameBuf(topaddr, sync) - -#define PSP_FB_WIDTH 960 -#define PSP_FB_HEIGHT 544 -#define PSP_PITCH_PIXELS 1024 - -#elif defined(PSP) -#define DisplaySetFrameBuf(topaddr, bufferwidth, pixelformat, sync) sceDisplaySetFrameBuf(topaddr, bufferwidth, pixelformat, sync) - -#define SCE_DISPLAY_UPDATETIMING_NEXTVSYNC 1 - -#define PSP_FB_WIDTH 512 -#define PSP_FB_HEIGHT 512 -#define PSP_PITCH_PIXELS 512 - -#endif - -/*============================================================ - INPUT PROTOTYPES -============================================================ */ - -#if defined(SN_TARGET_PSP2) - -#define STATE_BUTTON(state) ((state).buttons) -#define STATE_ANALOGLX(state) ((state).lx) -#define STATE_ANALOGLY(state) ((state).ly) -#define STATE_ANALOGRX(state) ((state).rx) -#define STATE_ANALOGRY(state) ((state).ry) -#define DEFAULT_SAMPLING_MODE (SCE_CTRL_MODE_DIGITALANALOG) - -#define PSP_CTRL_LEFT SCE_CTRL_LEFT -#define PSP_CTRL_DOWN SCE_CTRL_DOWN -#define PSP_CTRL_RIGHT SCE_CTRL_RIGHT -#define PSP_CTRL_UP SCE_CTRL_UP -#define PSP_CTRL_START SCE_CTRL_START -#define PSP_CTRL_SELECT SCE_CTRL_SELECT -#define PSP_CTRL_TRIANGLE SCE_CTRL_TRIANGLE -#define PSP_CTRL_SQUARE SCE_CTRL_SQUARE -#define PSP_CTRL_CROSS SCE_CTRL_CROSS -#define PSP_CTRL_CIRCLE SCE_CTRL_CIRCLE -#define PSP_CTRL_L SCE_CTRL_L -#define PSP_CTRL_R SCE_CTRL_R - -#define CtrlPeekBufferPositive(port, pad_data, bufs) sceCtrlPeekBufferPositive(port, pad_data, bufs) - -#elif defined(PSP) - -#define PSP_CTRL_L PSP_CTRL_LTRIGGER -#define PSP_CTRL_R PSP_CTRL_RTRIGGER - -#define STATE_BUTTON(state) ((state).Buttons) -#define STATE_ANALOGLX(state) ((state).Lx) -#define STATE_ANALOGLY(state) ((state).Ly) -#define STATE_ANALOGRX(state) ((state).Rx) -#define STATE_ANALOGRY(state) ((state).Ry) - -#define DEFAULT_SAMPLING_MODE (PSP_CTRL_MODE_ANALOG) - -#define CtrlPeekBufferPositive(port, pad_data, bufs) sceCtrlPeekBufferPositive(pad_data, bufs) -#endif - -#endif diff --git a/input/drivers/psp_input.c b/input/drivers/psp_input.c index 9c24b21159..9b3b4990fc 100644 --- a/input/drivers/psp_input.c +++ b/input/drivers/psp_input.c @@ -25,7 +25,7 @@ #include #endif -#include "../../gfx/psp/sdk_defines.h" +#include "../../gfx/psp/psp_sdk_defines.h" #include "../../driver.h" #include "../../libretro.h" From b9ab7a545d6c395127f7d27eb68e79fe29d8095a Mon Sep 17 00:00:00 2001 From: twinaphex Date: Mon, 12 Jan 2015 06:55:31 +0100 Subject: [PATCH 082/156] Move psp and gx drivers to gfx/drivers --- audio/drivers/gx_audio.c | 2 +- frontend/platform/platform_gx.c | 2 +- frontend/platform/platform_psp.c | 2 +- frontend/platform/platform_wii.c | 2 +- gfx/{gx => drivers}/gx_gfx.c | 0 gfx/{gx => drivers}/gx_gfx.h | 0 gfx/{gx => drivers}/gx_gfx_inl.h | 0 gfx/{gx => drivers}/gx_sdk_defines.h | 0 gfx/{gx => drivers}/ppc_asm.h | 0 gfx/{psp => drivers}/psp1_gfx.c | 0 gfx/{psp => drivers}/psp1_gfx.h | 0 gfx/drivers/psp_sdk_defines.h | 96 ++++++++++++++++++++++++++++ griffin/griffin.c | 4 +- input/drivers/psp_input.c | 2 +- wii/mem2_manager.c | 2 +- wii/vi_encoder.c | 2 +- 16 files changed, 105 insertions(+), 9 deletions(-) rename gfx/{gx => drivers}/gx_gfx.c (100%) rename gfx/{gx => drivers}/gx_gfx.h (100%) rename gfx/{gx => drivers}/gx_gfx_inl.h (100%) rename gfx/{gx => drivers}/gx_sdk_defines.h (100%) rename gfx/{gx => drivers}/ppc_asm.h (100%) rename gfx/{psp => drivers}/psp1_gfx.c (100%) rename gfx/{psp => drivers}/psp1_gfx.h (100%) create mode 100644 gfx/drivers/psp_sdk_defines.h diff --git a/audio/drivers/gx_audio.c b/audio/drivers/gx_audio.c index 0c3eaa4aee..439ea8d0eb 100644 --- a/audio/drivers/gx_audio.c +++ b/audio/drivers/gx_audio.c @@ -27,7 +27,7 @@ #include #endif -#include "../../gfx/gx/gx_sdk_defines.h" +#include "../../gfx/drivers/gx_sdk_defines.h" #define CHUNK_FRAMES 64 #define CHUNK_SIZE (CHUNK_FRAMES * sizeof(uint32_t)) diff --git a/frontend/platform/platform_gx.c b/frontend/platform/platform_gx.c index 041a05c9f5..0e91b261b7 100644 --- a/frontend/platform/platform_gx.c +++ b/frontend/platform/platform_gx.c @@ -19,7 +19,7 @@ #include "../../driver.h" #include "../../general.h" #include "../../libretro_private.h" -#include "../../gfx/gx/gx_sdk_defines.h" +#include "../../gfx/drivers/gx_sdk_defines.h" #include diff --git a/frontend/platform/platform_psp.c b/frontend/platform/platform_psp.c index f29b924495..4d79dc845e 100644 --- a/frontend/platform/platform_psp.c +++ b/frontend/platform/platform_psp.c @@ -25,7 +25,7 @@ #include #include -#include "../../gfx/psp/psp_sdk_defines.h" +#include "../../gfx/drivers/psp_sdk_defines.h" #include #include "../../general.h" diff --git a/frontend/platform/platform_wii.c b/frontend/platform/platform_wii.c index 13a30c1184..d859cf26ef 100644 --- a/frontend/platform/platform_wii.c +++ b/frontend/platform/platform_wii.c @@ -21,7 +21,7 @@ #include #include #include -#include "../../gfx/gx/ppc_asm.h" +#include "../../gfx/drivers/ppc_asm.h" #include #include #include diff --git a/gfx/gx/gx_gfx.c b/gfx/drivers/gx_gfx.c similarity index 100% rename from gfx/gx/gx_gfx.c rename to gfx/drivers/gx_gfx.c diff --git a/gfx/gx/gx_gfx.h b/gfx/drivers/gx_gfx.h similarity index 100% rename from gfx/gx/gx_gfx.h rename to gfx/drivers/gx_gfx.h diff --git a/gfx/gx/gx_gfx_inl.h b/gfx/drivers/gx_gfx_inl.h similarity index 100% rename from gfx/gx/gx_gfx_inl.h rename to gfx/drivers/gx_gfx_inl.h diff --git a/gfx/gx/gx_sdk_defines.h b/gfx/drivers/gx_sdk_defines.h similarity index 100% rename from gfx/gx/gx_sdk_defines.h rename to gfx/drivers/gx_sdk_defines.h diff --git a/gfx/gx/ppc_asm.h b/gfx/drivers/ppc_asm.h similarity index 100% rename from gfx/gx/ppc_asm.h rename to gfx/drivers/ppc_asm.h diff --git a/gfx/psp/psp1_gfx.c b/gfx/drivers/psp1_gfx.c similarity index 100% rename from gfx/psp/psp1_gfx.c rename to gfx/drivers/psp1_gfx.c diff --git a/gfx/psp/psp1_gfx.h b/gfx/drivers/psp1_gfx.h similarity index 100% rename from gfx/psp/psp1_gfx.h rename to gfx/drivers/psp1_gfx.h diff --git a/gfx/drivers/psp_sdk_defines.h b/gfx/drivers/psp_sdk_defines.h new file mode 100644 index 0000000000..51759c0264 --- /dev/null +++ b/gfx/drivers/psp_sdk_defines.h @@ -0,0 +1,96 @@ +/* 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 . + */ + +#ifndef _PSP_SDK_DEFINES_H +#define _PSP_SDK_DEFINES_H + +/*============================================================ + ERROR PROTOTYPES +============================================================ */ + +#if defined(PSP) +#define SCE_OK 0 +#endif + +/*============================================================ + DISPLAY PROTOTYPES +============================================================ */ + +#if defined(SN_TARGET_PSP2) +#define PSP_DISPLAY_PIXEL_FORMAT_8888 (SCE_DISPLAY_PIXELFORMAT_A8B8G8R8) + +#define DisplaySetFrameBuf(topaddr, bufferwidth, pixelformat, sync) sceDisplaySetFrameBuf(topaddr, sync) + +#define PSP_FB_WIDTH 960 +#define PSP_FB_HEIGHT 544 +#define PSP_PITCH_PIXELS 1024 + +#elif defined(PSP) +#define DisplaySetFrameBuf(topaddr, bufferwidth, pixelformat, sync) sceDisplaySetFrameBuf(topaddr, bufferwidth, pixelformat, sync) + +#define SCE_DISPLAY_UPDATETIMING_NEXTVSYNC 1 + +#define PSP_FB_WIDTH 512 +#define PSP_FB_HEIGHT 512 +#define PSP_PITCH_PIXELS 512 + +#endif + +/*============================================================ + INPUT PROTOTYPES +============================================================ */ + +#if defined(SN_TARGET_PSP2) + +#define STATE_BUTTON(state) ((state).buttons) +#define STATE_ANALOGLX(state) ((state).lx) +#define STATE_ANALOGLY(state) ((state).ly) +#define STATE_ANALOGRX(state) ((state).rx) +#define STATE_ANALOGRY(state) ((state).ry) +#define DEFAULT_SAMPLING_MODE (SCE_CTRL_MODE_DIGITALANALOG) + +#define PSP_CTRL_LEFT SCE_CTRL_LEFT +#define PSP_CTRL_DOWN SCE_CTRL_DOWN +#define PSP_CTRL_RIGHT SCE_CTRL_RIGHT +#define PSP_CTRL_UP SCE_CTRL_UP +#define PSP_CTRL_START SCE_CTRL_START +#define PSP_CTRL_SELECT SCE_CTRL_SELECT +#define PSP_CTRL_TRIANGLE SCE_CTRL_TRIANGLE +#define PSP_CTRL_SQUARE SCE_CTRL_SQUARE +#define PSP_CTRL_CROSS SCE_CTRL_CROSS +#define PSP_CTRL_CIRCLE SCE_CTRL_CIRCLE +#define PSP_CTRL_L SCE_CTRL_L +#define PSP_CTRL_R SCE_CTRL_R + +#define CtrlPeekBufferPositive(port, pad_data, bufs) sceCtrlPeekBufferPositive(port, pad_data, bufs) + +#elif defined(PSP) + +#define PSP_CTRL_L PSP_CTRL_LTRIGGER +#define PSP_CTRL_R PSP_CTRL_RTRIGGER + +#define STATE_BUTTON(state) ((state).Buttons) +#define STATE_ANALOGLX(state) ((state).Lx) +#define STATE_ANALOGLY(state) ((state).Ly) +#define STATE_ANALOGRX(state) ((state).Rx) +#define STATE_ANALOGRY(state) ((state).Ry) + +#define DEFAULT_SAMPLING_MODE (PSP_CTRL_MODE_ANALOG) + +#define CtrlPeekBufferPositive(port, pad_data, bufs) sceCtrlPeekBufferPositive(pad_data, bufs) +#endif + +#endif diff --git a/griffin/griffin.c b/griffin/griffin.c index 35a67190f8..5a131f3544 100644 --- a/griffin/griffin.c +++ b/griffin/griffin.c @@ -224,9 +224,9 @@ VIDEO DRIVER #endif #if defined(GEKKO) -#include "../gfx/gx/gx_gfx.c" +#include "../gfx/drivers/gx_gfx.c" #elif defined(PSP) -#include "../gfx/psp/psp1_gfx.c" +#include "../gfx/drivers/psp1_gfx.c" #elif defined(XENON) #include "../gfx/drivers/xenon360_gfx.c" #endif diff --git a/input/drivers/psp_input.c b/input/drivers/psp_input.c index 9b3b4990fc..c34879184b 100644 --- a/input/drivers/psp_input.c +++ b/input/drivers/psp_input.c @@ -25,7 +25,7 @@ #include #endif -#include "../../gfx/psp/psp_sdk_defines.h" +#include "../../gfx/drivers/psp_sdk_defines.h" #include "../../driver.h" #include "../../libretro.h" diff --git a/wii/mem2_manager.c b/wii/mem2_manager.c index a45fe45eb9..3bd212d54f 100644 --- a/wii/mem2_manager.c +++ b/wii/mem2_manager.c @@ -5,7 +5,7 @@ #include #include #include -#include "../gfx/gx/ppc_asm.h" +#include "../gfx/drivers/ppc_asm.h" #include #include #include diff --git a/wii/vi_encoder.c b/wii/vi_encoder.c index d51264ef31..b2fdf3729b 100644 --- a/wii/vi_encoder.c +++ b/wii/vi_encoder.c @@ -40,7 +40,7 @@ #include #include #include -#include "../gfx/gx/ppc_asm.h" +#include "../gfx/drivers/ppc_asm.h" #include "vi_encoder.h" From f4284ced570e181d69bf7cc33be14349b1746373 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Mon, 12 Jan 2015 06:57:53 +0100 Subject: [PATCH 083/156] Remove unused gfx/context/null_ctx.c --- gfx/context/null_ctx.c | 128 ----------------------------------------- 1 file changed, 128 deletions(-) delete mode 100644 gfx/context/null_ctx.c diff --git a/gfx/context/null_ctx.c b/gfx/context/null_ctx.c deleted file mode 100644 index 66fbb637c7..0000000000 --- a/gfx/context/null_ctx.c +++ /dev/null @@ -1,128 +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 . - */ - -#include "../../driver.h" -#include "../../general.h" -#include "../gfx_common.h" -#include "../gl_common.h" - -static void gfx_ctx_set_swap_interval(unsigned interval) -{ - (void)interval; -} - -static void gfx_ctx_destroy(void *data) -{ - (void)data; -} - -static void gfx_ctx_get_video_size(void *data, unsigned *width, unsigned *height) -{} - -static bool gfx_ctx_init(void) -{ - return true; -} - -static void gfx_ctx_swap_buffers(void *data) -{ - - /* video_data can have changed here... */ - video_data = driver.video_data; -} - -static void gfx_ctx_check_window(void *data, bool *quit, - bool *resize, unsigned *width, unsigned *height, unsigned frame_count) -{ - (void)data; - (void)frame_count; - - *quit = false; - - unsigned new_width, new_height; - gfx_ctx_get_video_size(&new_width, &new_height); - if (new_width != *width || new_height != *height) - { - *width = new_width; - *height = new_height; - *resize = true; - } -} - -static void gfx_ctx_set_resize(void *data, unsigned width, unsigned height) -{ - (void)data; - (void)width; - (void)height; -} - -static void gfx_ctx_update_window_title(void *data) -{ - (void)data; - char buf[128], buf_fps[128]; - gfx_get_fps(buf, sizeof(buf), buf_fps, sizeof(buf_fps)); -} - -static bool gfx_ctx_set_video_mode(void *data, - unsigned width, unsigned height, - bool fullscreen) -{ - (void)data; - (void)width; - (void)height; - (void)fullscreen; - return true; -} - - -static void gfx_ctx_input_driver(void *data, const input_driver_t **input, void **input_data) -{ - (void)data; - *input = NULL; - *input_data = NULL; -} - -static bool gfx_ctx_bind_api(void *data, enum gfx_ctx_api api) -{ - (void)data; - (void)api; - return true; -} - -static bool gfx_ctx_has_focus(void *data) -{ - (void)data; - return true; -} - -const gfx_ctx_driver_t gfx_ctx_null = { - gfx_ctx_init, - gfx_ctx_destroy, - gfx_ctx_bind_api, - gfx_ctx_set_swap_interval, - gfx_ctx_set_video_mode, - gfx_ctx_get_video_size, - NULL, - gfx_ctx_update_window_title, - gfx_ctx_check_window, - gfx_ctx_set_resize, - gfx_ctx_has_focus, - gfx_ctx_swap_buffers, - gfx_ctx_input_driver, - NULL, - NULL, - "null", -}; From d905d77ef76e013f390ba3b7dfb67f07742b629e Mon Sep 17 00:00:00 2001 From: twinaphex Date: Mon, 12 Jan 2015 07:02:55 +0100 Subject: [PATCH 084/156] Cleanups in gl_common.h --- gfx/gl_common.h | 269 ++++++++++++++++++++++++------------------------ 1 file changed, 137 insertions(+), 132 deletions(-) diff --git a/gfx/gl_common.h b/gfx/gl_common.h index 9fe8d4619b..ada57a5a26 100644 --- a/gfx/gl_common.h +++ b/gfx/gl_common.h @@ -100,30 +100,121 @@ #endif -static inline bool gl_check_error(void) -{ - int error = glGetError(); - switch (error) - { - case GL_INVALID_ENUM: - RARCH_ERR("GL: Invalid enum.\n"); - break; - case GL_INVALID_VALUE: - RARCH_ERR("GL: Invalid value.\n"); - break; - case GL_INVALID_OPERATION: - RARCH_ERR("GL: Invalid operation.\n"); - break; - case GL_OUT_OF_MEMORY: - RARCH_ERR("GL: Out of memory.\n"); - break; - case GL_NO_ERROR: - return true; - } +#ifndef MAX_SHADERS +#define MAX_SHADERS 16 +#endif - RARCH_ERR("Non specified GL error.\n"); - return false; -} +#ifndef MAX_TEXTURES +#define MAX_TEXTURES 8 +#endif + +#if defined(HAVE_PSGL) +#define RARCH_GL_INTERNAL_FORMAT32 GL_ARGB_SCE +#define RARCH_GL_INTERNAL_FORMAT16 GL_RGB5 /* TODO: Verify if this is really 565 or just 555. */ +#define RARCH_GL_TEXTURE_TYPE32 GL_BGRA +#define RARCH_GL_TEXTURE_TYPE16 GL_BGRA +#define RARCH_GL_FORMAT32 GL_UNSIGNED_INT_8_8_8_8_REV +#define RARCH_GL_FORMAT16 GL_RGB5 +#elif defined(HAVE_OPENGLES) +/* Imgtec/SGX headers have this missing. */ +#ifndef GL_BGRA_EXT +#define GL_BGRA_EXT 0x80E1 +#endif +#ifdef IOS +/* Stupid Apple. */ +#define RARCH_GL_INTERNAL_FORMAT32 GL_RGBA +#else +#define RARCH_GL_INTERNAL_FORMAT32 GL_BGRA_EXT +#endif +#define RARCH_GL_INTERNAL_FORMAT16 GL_RGB +#define RARCH_GL_TEXTURE_TYPE32 GL_BGRA_EXT +#define RARCH_GL_TEXTURE_TYPE16 GL_RGB +#define RARCH_GL_FORMAT32 GL_UNSIGNED_BYTE +#define RARCH_GL_FORMAT16 GL_UNSIGNED_SHORT_5_6_5 +#else +/* On desktop, we always use 32-bit. */ +#define RARCH_GL_INTERNAL_FORMAT32 GL_RGBA8 +#define RARCH_GL_INTERNAL_FORMAT16 GL_RGBA8 +#define RARCH_GL_TEXTURE_TYPE32 GL_BGRA +#define RARCH_GL_TEXTURE_TYPE16 GL_BGRA +#define RARCH_GL_FORMAT32 GL_UNSIGNED_INT_8_8_8_8_REV +#define RARCH_GL_FORMAT16 GL_UNSIGNED_INT_8_8_8_8_REV + +/* GL_RGB565 internal format isn't in desktop GL + * until 4.1 core (ARB_ES2_compatibility). + * Check for this. */ +#ifndef GL_RGB565 +#define GL_RGB565 0x8D62 +#endif +#define RARCH_GL_INTERNAL_FORMAT16_565 GL_RGB565 +#define RARCH_GL_TEXTURE_TYPE16_565 GL_RGB +#define RARCH_GL_FORMAT16_565 GL_UNSIGNED_SHORT_5_6_5 +#endif + +/* Platform specific workarounds/hacks. */ +#if defined(__CELLOS_LV2__) +#define NO_GL_READ_PIXELS + +/* Performance hacks. */ +#ifdef HAVE_GCMGL + +extern GLvoid* glMapBufferTextureReferenceRA( GLenum target, GLenum access ); + +extern GLboolean glUnmapBufferTextureReferenceRA( GLenum target ); + +extern void glBufferSubDataTextureReferenceRA( GLenum target, + GLintptr offset, GLsizeiptr size, const GLvoid *data ); +#define glMapBuffer(target, access) glMapBufferTextureReferenceRA(target, access) +#define glUnmapBuffer(target) glUnmapBufferTextureReferenceRA(target) +#define glBufferSubData(target, offset, size, data) glBufferSubDataTextureReferenceRA(target, offset, size, data) +#endif +#endif + +#if defined(HAVE_OPENGL_MODERN) || defined(HAVE_OPENGLES2) || defined(HAVE_PSGL) +#ifndef NO_GL_FF_VERTEX +#define NO_GL_FF_VERTEX +#endif +#endif + +#if defined(HAVE_OPENGL_MODERN) || defined(HAVE_OPENGLES2) || defined(HAVE_PSGL) +#ifndef NO_GL_FF_MATRIX +#define NO_GL_FF_MATRIX +#endif +#endif + +#if defined(HAVE_OPENGLES2) /* TODO: Figure out exactly what. */ +#define NO_GL_CLAMP_TO_BORDER +#endif + +#if defined(HAVE_OPENGLES) +#ifndef GL_UNPACK_ROW_LENGTH +#define GL_UNPACK_ROW_LENGTH 0x0CF2 +#endif + +#ifndef GL_SRGB_ALPHA_EXT +#define GL_SRGB_ALPHA_EXT 0x8C42 +#endif +#endif + +/* Fall back to FF-style if needed and possible. */ +#define gl_ff_vertex(coords) \ + glClientActiveTexture(GL_TEXTURE1); \ + glTexCoordPointer(2, GL_FLOAT, 0, coords->lut_tex_coord); \ + glEnableClientState(GL_TEXTURE_COORD_ARRAY); \ + glClientActiveTexture(GL_TEXTURE0); \ + glVertexPointer(2, GL_FLOAT, 0, coords->vertex); \ + glEnableClientState(GL_VERTEX_ARRAY); \ + glColorPointer(4, GL_FLOAT, 0, coords->color); \ + glEnableClientState(GL_COLOR_ARRAY); \ + glTexCoordPointer(2, GL_FLOAT, 0, coords->tex_coord); \ + glEnableClientState(GL_TEXTURE_COORD_ARRAY) + +/* Fall back to FF-style if needed and possible. */ +#define gl_ff_matrix(mat) \ + glMatrixMode(GL_PROJECTION); \ + glLoadMatrixf(mat->data); \ + glMatrixMode(GL_MODELVIEW); \ + glLoadIdentity() struct gl_fbo_rect { @@ -162,9 +253,6 @@ struct gl_coords unsigned vertices; }; -#define MAX_SHADERS 16 -#define MAX_TEXTURES 8 - typedef struct gl { const gfx_ctx_driver_t *ctx_driver; @@ -287,113 +375,30 @@ typedef struct gl GLuint vao; } gl_t; -#if defined(HAVE_PSGL) -#define RARCH_GL_INTERNAL_FORMAT32 GL_ARGB_SCE -#define RARCH_GL_INTERNAL_FORMAT16 GL_RGB5 /* TODO: Verify if this is really 565 or just 555. */ -#define RARCH_GL_TEXTURE_TYPE32 GL_BGRA -#define RARCH_GL_TEXTURE_TYPE16 GL_BGRA -#define RARCH_GL_FORMAT32 GL_UNSIGNED_INT_8_8_8_8_REV -#define RARCH_GL_FORMAT16 GL_RGB5 -#elif defined(HAVE_OPENGLES) -/* Imgtec/SGX headers have this missing. */ -#ifndef GL_BGRA_EXT -#define GL_BGRA_EXT 0x80E1 -#endif -#ifdef IOS -/* Stupid Apple. */ -#define RARCH_GL_INTERNAL_FORMAT32 GL_RGBA -#else -#define RARCH_GL_INTERNAL_FORMAT32 GL_BGRA_EXT -#endif -#define RARCH_GL_INTERNAL_FORMAT16 GL_RGB -#define RARCH_GL_TEXTURE_TYPE32 GL_BGRA_EXT -#define RARCH_GL_TEXTURE_TYPE16 GL_RGB -#define RARCH_GL_FORMAT32 GL_UNSIGNED_BYTE -#define RARCH_GL_FORMAT16 GL_UNSIGNED_SHORT_5_6_5 -#else -/* On desktop, we always use 32-bit. */ -#define RARCH_GL_INTERNAL_FORMAT32 GL_RGBA8 -#define RARCH_GL_INTERNAL_FORMAT16 GL_RGBA8 -#define RARCH_GL_TEXTURE_TYPE32 GL_BGRA -#define RARCH_GL_TEXTURE_TYPE16 GL_BGRA -#define RARCH_GL_FORMAT32 GL_UNSIGNED_INT_8_8_8_8_REV -#define RARCH_GL_FORMAT16 GL_UNSIGNED_INT_8_8_8_8_REV +static inline bool gl_check_error(void) +{ + int error = glGetError(); + switch (error) + { + case GL_INVALID_ENUM: + RARCH_ERR("GL: Invalid enum.\n"); + break; + case GL_INVALID_VALUE: + RARCH_ERR("GL: Invalid value.\n"); + break; + case GL_INVALID_OPERATION: + RARCH_ERR("GL: Invalid operation.\n"); + break; + case GL_OUT_OF_MEMORY: + RARCH_ERR("GL: Out of memory.\n"); + break; + case GL_NO_ERROR: + return true; + } -/* GL_RGB565 internal format isn't in desktop GL - * until 4.1 core (ARB_ES2_compatibility). - * Check for this. */ -#ifndef GL_RGB565 -#define GL_RGB565 0x8D62 -#endif -#define RARCH_GL_INTERNAL_FORMAT16_565 GL_RGB565 -#define RARCH_GL_TEXTURE_TYPE16_565 GL_RGB -#define RARCH_GL_FORMAT16_565 GL_UNSIGNED_SHORT_5_6_5 -#endif - -/* Platform specific workarounds/hacks. */ -#if defined(__CELLOS_LV2__) -#define NO_GL_READ_PIXELS - -/* Performance hacks. */ -#ifdef HAVE_GCMGL - -extern GLvoid* glMapBufferTextureReferenceRA( GLenum target, GLenum access ); - -extern GLboolean glUnmapBufferTextureReferenceRA( GLenum target ); - -extern void glBufferSubDataTextureReferenceRA( GLenum target, - GLintptr offset, GLsizeiptr size, const GLvoid *data ); -#define glMapBuffer(target, access) glMapBufferTextureReferenceRA(target, access) -#define glUnmapBuffer(target) glUnmapBufferTextureReferenceRA(target) -#define glBufferSubData(target, offset, size, data) glBufferSubDataTextureReferenceRA(target, offset, size, data) -#endif -#endif - -#if defined(HAVE_OPENGL_MODERN) || defined(HAVE_OPENGLES2) || defined(HAVE_PSGL) -#ifndef NO_GL_FF_VERTEX -#define NO_GL_FF_VERTEX -#endif -#endif - -#if defined(HAVE_OPENGL_MODERN) || defined(HAVE_OPENGLES2) || defined(HAVE_PSGL) -#ifndef NO_GL_FF_MATRIX -#define NO_GL_FF_MATRIX -#endif -#endif - -#if defined(HAVE_OPENGLES2) /* TODO: Figure out exactly what. */ -#define NO_GL_CLAMP_TO_BORDER -#endif - -#if defined(HAVE_OPENGLES) -#ifndef GL_UNPACK_ROW_LENGTH -#define GL_UNPACK_ROW_LENGTH 0x0CF2 -#endif - -#ifndef GL_SRGB_ALPHA_EXT -#define GL_SRGB_ALPHA_EXT 0x8C42 -#endif -#endif - -/* Fall back to FF-style if needed and possible. */ -#define gl_ff_vertex(coords) \ - glClientActiveTexture(GL_TEXTURE1); \ - glTexCoordPointer(2, GL_FLOAT, 0, coords->lut_tex_coord); \ - glEnableClientState(GL_TEXTURE_COORD_ARRAY); \ - glClientActiveTexture(GL_TEXTURE0); \ - glVertexPointer(2, GL_FLOAT, 0, coords->vertex); \ - glEnableClientState(GL_VERTEX_ARRAY); \ - glColorPointer(4, GL_FLOAT, 0, coords->color); \ - glEnableClientState(GL_COLOR_ARRAY); \ - glTexCoordPointer(2, GL_FLOAT, 0, coords->tex_coord); \ - glEnableClientState(GL_TEXTURE_COORD_ARRAY) - -/* Fall back to FF-style if needed and possible. */ -#define gl_ff_matrix(mat) \ - glMatrixMode(GL_PROJECTION); \ - glLoadMatrixf(mat->data); \ - glMatrixMode(GL_MODELVIEW); \ - glLoadIdentity() + RARCH_ERR("Non specified GL error.\n"); + return false; +} void gl_set_viewport(gl_t *gl, unsigned width, unsigned height, bool force_full, bool allow_rotate); From bf4dd752de816fa35332e7e2ab438764b2f5aa09 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Mon, 12 Jan 2015 15:06:29 +0100 Subject: [PATCH 085/156] Update SDK --- libretro-sdk/libco/amd64.c | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) diff --git a/libretro-sdk/libco/amd64.c b/libretro-sdk/libco/amd64.c index a9f6ee5f01..7326a10d85 100644 --- a/libretro-sdk/libco/amd64.c +++ b/libretro-sdk/libco/amd64.c @@ -9,13 +9,19 @@ #include #include +#if defined(__GNUC__) && !defined(_WIN32) +#define CO_USE_INLINE_ASM +#endif + #ifdef __cplusplus extern "C" { #endif static thread_local long long co_active_buffer[64]; static thread_local cothread_t co_active_handle = 0; +#ifndef CO_USE_INLINE_ASM static void (*co_swap)(cothread_t, cothread_t) = 0; +#endif #ifdef _WIN32 //ABI: Win64 @@ -76,6 +82,7 @@ void co_init(void) } #else //ABI: SystemV +#ifndef CO_USE_INLINE_ASM static unsigned char co_swap_function[] = { 0x48, 0x89, 0x26, /* mov [rsi],rsp */ 0x48, 0x8b, 0x27, /* mov rsp,[rdi] */ @@ -105,6 +112,9 @@ void co_init(void) unsigned long long size = (addr - base) + sizeof(co_swap_function); mprotect((void*)base, size, PROT_READ | PROT_WRITE | PROT_EXEC); } +#else +void co_init(void) {} +#endif #endif static void crash(void) @@ -123,11 +133,13 @@ cothread_t co_create(unsigned int size, void (*entrypoint)(void)) { cothread_t handle; +#ifndef CO_USE_INLINE_ASM if(!co_swap) { co_init(); co_swap = (void (*)(cothread_t, cothread_t))co_swap_function; } +#endif if (!co_active_handle) co_active_handle = &co_active_buffer; @@ -150,11 +162,37 @@ void co_delete(cothread_t handle) free(handle); } +#ifndef CO_USE_INLINE_ASM void co_switch(cothread_t handle) { register cothread_t co_previous_handle = co_active_handle; co_swap(co_active_handle = handle, co_previous_handle); } +#else +__asm__( +".intel_syntax noprefix \n" +".globl co_switch \n" +"co_switch: \n" +"mov rsi, co_active_handle[rip]\n" +"mov [rsi],rsp \n" +"mov [rsi+0x08],rbp \n" +"mov [rsi+0x10],rbx \n" +"mov [rsi+0x18],r12 \n" +"mov [rsi+0x20],r13 \n" +"mov [rsi+0x28],r14 \n" +"mov [rsi+0x30],r15 \n" +"mov co_active_handle[rip], rdi\n" +"mov rsp,[rdi] \n" +"mov rbp,[rdi+0x08] \n" +"mov rbx,[rdi+0x10] \n" +"mov r12,[rdi+0x18] \n" +"mov r13,[rdi+0x20] \n" +"mov r14,[rdi+0x28] \n" +"mov r15,[rdi+0x30] \n" +"ret \n" +".att_syntax \n" +); +#endif #ifdef __cplusplus } From fc806d2914d137f930a103f7ddc276256dd82e25 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Mon, 12 Jan 2015 16:00:13 +0100 Subject: [PATCH 086/156] Rename state tracker files --- Makefile.common | 4 ++-- gfx/d3d/render_chain.h | 2 +- gfx/shader/shader_gl_cg.c | 2 +- gfx/shader/shader_glsl.c | 2 +- gfx/shader/shader_null.c | 2 +- gfx/shader/shader_parse.h | 2 +- .../py_state.c => video_state_python.c} | 21 ++++++++++++------- .../py_state.h => video_state_python.h} | 4 ++-- ...{state_tracker.c => video_state_tracker.c} | 4 ++-- ...{state_tracker.h => video_state_tracker.h} | 4 ++-- griffin/griffin.c | 4 ++-- 11 files changed, 29 insertions(+), 22 deletions(-) rename gfx/{py_state/py_state.c => video_state_python.c} (95%) rename gfx/{py_state/py_state.h => video_state_python.h} (94%) rename gfx/{state_tracker.c => video_state_tracker.c} (99%) rename gfx/{state_tracker.h => video_state_tracker.h} (97%) diff --git a/Makefile.common b/Makefile.common index 3d2d0d6546..f48484a7ae 100644 --- a/Makefile.common +++ b/Makefile.common @@ -167,7 +167,7 @@ endif ifeq ($(HAVE_PYTHON), 1) DEFINES += $(PYTHON_CFLAGS) -Wno-unused-parameter LIBS += $(PYTHON_LIBS) - OBJ += gfx/py_state/py_state.o + OBJ += gfx/video_state_python.o endif ifeq ($(HAVE_EMSCRIPTEN), 1) @@ -372,7 +372,7 @@ ifeq ($(HAVE_OPENGL), 1) gfx/fonts/gl_font.o \ gfx/fonts/gl_raster_font.o \ libretro-sdk/gfx/math/matrix_4x4.o \ - gfx/state_tracker.o \ + gfx/video_state_tracker.o \ libretro-sdk/glsym/rglgen.o ifeq ($(HAVE_KMS), 1) diff --git a/gfx/d3d/render_chain.h b/gfx/d3d/render_chain.h index 0658c229e9..e58bfb33c1 100644 --- a/gfx/d3d/render_chain.h +++ b/gfx/d3d/render_chain.h @@ -18,7 +18,7 @@ #define __D3D_RENDER_CHAIN_H #include "d3d.h" -#include "../state_tracker.h" +#include "../video_state_tracker.h" #include "../shader/shader_parse.h" struct Vertex diff --git a/gfx/shader/shader_gl_cg.c b/gfx/shader/shader_gl_cg.c index 20a63e392b..bc9d090ea5 100644 --- a/gfx/shader/shader_gl_cg.c +++ b/gfx/shader/shader_gl_cg.c @@ -37,7 +37,7 @@ #include "../../dynamic.h" #include -#include "../state_tracker.h" +#include "../video_state_tracker.h" #if 0 #define RARCH_CG_DEBUG diff --git a/gfx/shader/shader_glsl.c b/gfx/shader/shader_glsl.c index 89b6032533..8b34f9267a 100644 --- a/gfx/shader/shader_glsl.c +++ b/gfx/shader/shader_glsl.c @@ -19,7 +19,7 @@ #include "shader_glsl.h" #include #include -#include "../state_tracker.h" +#include "../video_state_tracker.h" #include "../../dynamic.h" #include "../../file_ops.h" diff --git a/gfx/shader/shader_null.c b/gfx/shader/shader_null.c index 074ed0cc7d..e98795330e 100644 --- a/gfx/shader/shader_null.c +++ b/gfx/shader/shader_null.c @@ -19,7 +19,7 @@ #include "../../general.h" #include #include -#include "../state_tracker.h" +#include "../video_state_tracker.h" #include "../../dynamic.h" #include diff --git a/gfx/shader/shader_parse.h b/gfx/shader/shader_parse.h index c4b97f44fe..748f49dcbf 100644 --- a/gfx/shader/shader_parse.h +++ b/gfx/shader/shader_parse.h @@ -19,7 +19,7 @@ #include #include -#include "../state_tracker.h" +#include "../video_state_tracker.h" #include #ifdef __cplusplus diff --git a/gfx/py_state/py_state.c b/gfx/video_state_python.c similarity index 95% rename from gfx/py_state/py_state.c rename to gfx/video_state_python.c index 1d2e018513..43ba3c28f9 100644 --- a/gfx/py_state/py_state.c +++ b/gfx/video_state_python.c @@ -19,14 +19,14 @@ #include #include -#include "py_state.h" -#include "../../dynamic.h" -#include "../../libretro.h" -#include "../../general.h" +#include "video_state_python.h" +#include "../dynamic.h" +#include "../libretro.h" +#include "../general.h" #include #include -#include "../../input/input_common.h" -#include "../../file_ops.h" +#include "../input/input_common.h" +#include "../file_ops.h" static PyObject* py_read_wram(PyObject *self, PyObject *args) { @@ -95,6 +95,14 @@ static const struct retro_keybind *py_binds[MAX_USERS] = { g_settings.input.binds[5], g_settings.input.binds[6], g_settings.input.binds[7], + g_settings.input.binds[8], + g_settings.input.binds[9], + g_settings.input.binds[10], + g_settings.input.binds[11], + g_settings.input.binds[12], + g_settings.input.binds[13], + g_settings.input.binds[14], + g_settings.input.binds[15], }; static PyObject *py_read_input(PyObject *self, PyObject *args) @@ -397,4 +405,3 @@ float py_state_get(py_state_t *handle, const char *id, Py_DECREF(ret); return retval; } - diff --git a/gfx/py_state/py_state.h b/gfx/video_state_python.h similarity index 94% rename from gfx/py_state/py_state.h rename to gfx/video_state_python.h index 2381c2ece3..d38a5f62e9 100644 --- a/gfx/py_state/py_state.h +++ b/gfx/video_state_python.h @@ -14,8 +14,8 @@ * If not, see . */ -#ifndef __RARCH_PY_STATE_H -#define __RARCH_PY_STATE_H +#ifndef __VIDEO_STATE_PYTHON_H +#define __VIDEO_STATE_PYTHON_H #include #include diff --git a/gfx/state_tracker.c b/gfx/video_state_tracker.c similarity index 99% rename from gfx/state_tracker.c rename to gfx/video_state_tracker.c index 66def8253e..7db13731a0 100644 --- a/gfx/state_tracker.c +++ b/gfx/video_state_tracker.c @@ -14,14 +14,14 @@ * If not, see . */ -#include "state_tracker.h" +#include "video_state_tracker.h" #include #include #include "../general.h" #include "../input/input_common.h" #ifdef HAVE_PYTHON -#include "py_state/py_state.h" +#include "video_state_python.h" #endif struct state_tracker_internal diff --git a/gfx/state_tracker.h b/gfx/video_state_tracker.h similarity index 97% rename from gfx/state_tracker.h rename to gfx/video_state_tracker.h index e02e400fde..8e8924145b 100644 --- a/gfx/state_tracker.h +++ b/gfx/video_state_tracker.h @@ -14,8 +14,8 @@ * If not, see . */ -#ifndef __RARCH_LIBRETRO_TRACKER_H -#define __RARCH_LIBRETRO_TRACKER_H +#ifndef __VIDEO_STATE_TRACKER_H +#define __VIDEO_STATE_TRACKER_H #ifdef __cplusplus extern "C" { diff --git a/griffin/griffin.c b/griffin/griffin.c index 5a131f3544..a950d92a08 100644 --- a/griffin/griffin.c +++ b/griffin/griffin.c @@ -395,10 +395,10 @@ INPUT /*============================================================ STATE TRACKER ============================================================ */ -#include "../gfx/state_tracker.c" +#include "../gfx/video_state_tracker.c" #ifdef HAVE_PYTHON -#include "../gfx/py_state/py_state.c" +#include "../gfx/video_state_python.c" #endif /*============================================================ From d04121037d30a8c781de04c6a53727435bb7f063 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Mon, 12 Jan 2015 16:49:37 +0100 Subject: [PATCH 087/156] Add video_driver_find_handle/video_driver_find_ident --- driver.c | 48 ++++++++++++++++++++++++++++++++++++++++-------- 1 file changed, 40 insertions(+), 8 deletions(-) diff --git a/driver.c b/driver.c index 5efef8f072..3fec633ca8 100644 --- a/driver.c +++ b/driver.c @@ -177,6 +177,36 @@ static const video_driver_t *video_drivers[] = { NULL, }; +/** + * video_driver_find_handle: + * @index : index of driver to get handle to. + * + * Returns: handle to video driver at index. Can be NULL + * if nothing found. + **/ +static const void *video_driver_find_handle(int index) +{ + const void *drv = video_drivers[index]; + if (!drv) + return NULL; + return drv; +} + +/** + * video_driver_find_ident: + * @index : index of driver to get handle to. + * + * Returns: Human-readable identifier of video driver at index. Can be NULL + * if nothing found. + **/ +static const char *video_driver_find_ident(int index) +{ + const video_driver_t *drv = video_drivers[index]; + if (!drv) + return NULL; + return drv->ident; +} + /** * config_get_video_driver_options: * @@ -194,9 +224,9 @@ const char* config_get_video_driver_options(void) attr.i = 0; - for (option_k = 0; video_drivers[option_k]; option_k++) + for (option_k = 0; video_driver_find_handle(option_k); option_k++) { - const char *opt = video_drivers[option_k]->ident; + const char *opt = video_driver_find_ident(option_k); options_len += strlen(opt) + 1; string_list_append(options_l, opt, attr); } @@ -502,6 +532,7 @@ const char* config_get_menu_driver_options(void) } #endif + /** * find_driver_nonempty: * @label : string of driver type to be found. @@ -560,9 +591,9 @@ static const void *find_driver_nonempty(const char *label, int i, } else if (!strcmp(label, "video_driver")) { - drv = video_drivers[i]; + drv = video_driver_find_handle(i); if (drv) - strlcpy(str, video_drivers[i]->ident, sizeof_str); + strlcpy(str, video_driver_find_ident(i), sizeof_str); } else if (!strcmp(label, "audio_driver")) { @@ -604,6 +635,7 @@ static int find_driver_index(const char * label, const char *drv) return -1; } + /** * find_prev_driver: * @label : string of driver type to be found. @@ -1014,18 +1046,18 @@ static void find_video_driver(void) i = find_driver_index("video_driver", g_settings.video.driver); if (i >= 0) - driver.video = video_drivers[i]; + driver.video = video_driver_find_handle(i); else { unsigned d; RARCH_ERR("Couldn't find any video driver named \"%s\"\n", g_settings.video.driver); RARCH_LOG_OUTPUT("Available video drivers are:\n"); - for (d = 0; video_drivers[d]; d++) - RARCH_LOG_OUTPUT("\t%s\n", video_drivers[d]->ident); + for (d = 0; video_driver_find_handle(d); d++) + RARCH_LOG_OUTPUT("\t%s\n", video_driver_find_ident(d)); RARCH_WARN("Going to default to first video driver...\n"); - driver.video = video_drivers[0]; + driver.video = video_driver_find_handle(0); if (!driver.video) rarch_fail(1, "find_video_driver()"); From 017c0398f36f47b76588d4e54c24bfce9734ab0b Mon Sep 17 00:00:00 2001 From: twinaphex Date: Mon, 12 Jan 2015 16:52:10 +0100 Subject: [PATCH 088/156] Add audio_driver_find_handle/audio_driver_find_ident --- driver.c | 46 ++++++++++++++++++++++++++++++++++++++-------- 1 file changed, 38 insertions(+), 8 deletions(-) diff --git a/driver.c b/driver.c index 3fec633ca8..0e6c0723e0 100644 --- a/driver.c +++ b/driver.c @@ -102,6 +102,36 @@ static const audio_driver_t *audio_drivers[] = { NULL, }; +/** + * audio_driver_find_handle: + * @index : index of driver to get handle to. + * + * Returns: handle to audio driver at index. Can be NULL + * if nothing found. + **/ +static const void *audio_driver_find_handle(int index) +{ + const void *drv = audio_drivers[index]; + if (!drv) + return NULL; + return drv; +} + +/** + * audio_driver_find_ident: + * @index : index of driver to get handle to. + * + * Returns: Human-readable identifier of audio driver at index. Can be NULL + * if nothing found. + **/ +static const char *audio_driver_find_ident(int index) +{ + const audio_driver_t *drv = audio_drivers[index]; + if (!drv) + return NULL; + return drv->ident; +} + /** * config_get_audio_driver_options: * @@ -119,9 +149,9 @@ const char* config_get_audio_driver_options(void) attr.i = 0; - for (option_k = 0; audio_drivers[option_k]; option_k++) + for (option_k = 0; audio_driver_find_handle(option_k); option_k++) { - const char *opt = audio_drivers[option_k]->ident; + const char *opt = audio_driver_find_ident(option_k); options_len += strlen(opt) + 1; string_list_append(options_l, opt, attr); } @@ -597,9 +627,9 @@ static const void *find_driver_nonempty(const char *label, int i, } else if (!strcmp(label, "audio_driver")) { - drv = audio_drivers[i]; + drv = audio_driver_find_handle(i); if (drv) - strlcpy(str, audio_drivers[i]->ident, sizeof_str); + strlcpy(str, audio_driver_find_ident(i), sizeof_str); } return drv; @@ -1003,18 +1033,18 @@ static void find_audio_driver(void) { int i = find_driver_index("audio_driver", g_settings.audio.driver); if (i >= 0) - driver.audio = audio_drivers[i]; + driver.audio = audio_driver_find_handle(i); else { unsigned d; RARCH_ERR("Couldn't find any audio driver named \"%s\"\n", g_settings.audio.driver); RARCH_LOG_OUTPUT("Available audio drivers are:\n"); - for (d = 0; audio_drivers[d]; d++) - RARCH_LOG_OUTPUT("\t%s\n", audio_drivers[d]->ident); + for (d = 0; audio_driver_find_handle(d); d++) + RARCH_LOG_OUTPUT("\t%s\n", audio_driver_find_ident(d)); RARCH_WARN("Going to default to first audio driver...\n"); - driver.audio = audio_drivers[0]; + driver.audio = audio_driver_find_handle(0); if (!driver.audio) rarch_fail(1, "find_audio_driver()"); From 5aca1d385b9f997925b23b6a52a4d54e68de33ee Mon Sep 17 00:00:00 2001 From: twinaphex Date: Mon, 12 Jan 2015 16:56:11 +0100 Subject: [PATCH 089/156] Add input_driver_find_handle/input_driver_find_ident --- driver.c | 46 ++++++++++++++++++++++++++++++++++++++-------- 1 file changed, 38 insertions(+), 8 deletions(-) diff --git a/driver.c b/driver.c index 0e6c0723e0..148917eb42 100644 --- a/driver.c +++ b/driver.c @@ -319,6 +319,36 @@ static const input_driver_t *input_drivers[] = { NULL, }; +/** + * input_driver_find_handle: + * @index : index of driver to get handle to. + * + * Returns: handle to input driver at index. Can be NULL + * if nothing found. + **/ +static const void *input_driver_find_handle(int index) +{ + const void *drv = input_drivers[index]; + if (!drv) + return NULL; + return drv; +} + +/** + * input_driver_find_ident: + * @index : index of driver to get handle to. + * + * Returns: Human-readable identifier of input driver at index. Can be NULL + * if nothing found. + **/ +static const char *input_driver_find_ident(int index) +{ + const input_driver_t *drv = input_drivers[index]; + if (!drv) + return NULL; + return drv->ident; +} + /** * config_get_input_driver_options: * @@ -336,9 +366,9 @@ const char* config_get_input_driver_options(void) attr.i = 0; - for (option_k = 0; input_drivers[option_k]; option_k++) + for (option_k = 0; input_driver_find_handle(option_k); option_k++) { - const char *opt = input_drivers[option_k]->ident; + const char *opt = input_driver_find_ident(option_k); options_len += strlen(opt) + 1; string_list_append(options_l, opt, attr); } @@ -609,9 +639,9 @@ static const void *find_driver_nonempty(const char *label, int i, #endif else if (!strcmp(label, "input_driver")) { - drv = input_drivers[i]; + drv = input_driver_find_handle(i); if (drv) - strlcpy(str, input_drivers[i]->ident, sizeof_str); + strlcpy(str, input_driver_find_ident(i), sizeof_str); } else if (!strcmp(label, "input_joypad_driver")) { @@ -1099,18 +1129,18 @@ static void find_input_driver(void) { int i = find_driver_index("input_driver", g_settings.input.driver); if (i >= 0) - driver.input = input_drivers[i]; + driver.input = input_driver_find_handle(i); else { unsigned d; RARCH_ERR("Couldn't find any input driver named \"%s\"\n", g_settings.input.driver); RARCH_LOG_OUTPUT("Available input drivers are:\n"); - for (d = 0; input_drivers[d]; d++) - RARCH_LOG_OUTPUT("\t%s\n", input_drivers[d]->ident); + for (d = 0; input_driver_find_handle(d); d++) + RARCH_LOG_OUTPUT("\t%s\n", input_driver_find_ident(d)); RARCH_WARN("Going to default to first input driver...\n"); - driver.input = input_drivers[0]; + driver.input = input_driver_find_handle(0); if (!driver.input) rarch_fail(1, "find_input_driver()"); From 11941119519c33daa8b24f7bc7eee001cb8abe18 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Mon, 12 Jan 2015 17:00:35 +0100 Subject: [PATCH 090/156] Add osk_driver_find_handle/osk_driver_find_ident --- driver.c | 46 ++++++++++++++++++++++++++++++++++++++-------- 1 file changed, 38 insertions(+), 8 deletions(-) diff --git a/driver.c b/driver.c index 148917eb42..756d2c51f2 100644 --- a/driver.c +++ b/driver.c @@ -391,6 +391,36 @@ static const input_osk_driver_t *osk_drivers[] = { NULL, }; +/** + * osk_driver_find_handle: + * @index : index of driver to get handle to. + * + * Returns: handle to OSK driver at index. Can be NULL + * if nothing found. + **/ +static const void *osk_driver_find_handle(int index) +{ + const void *drv = osk_drivers[index]; + if (!drv) + return NULL; + return drv; +} + +/** + * osk_driver_find_ident: + * @index : index of driver to get handle to. + * + * Returns: Human-readable identifier of OSK driver at index. Can be NULL + * if nothing found. + **/ +static const char *osk_driver_find_ident(int index) +{ + const input_osk_driver_t *drv = osk_drivers[index]; + if (!drv) + return NULL; + return drv->ident; +} + /** * config_get_osk_driver_options: * @@ -410,9 +440,9 @@ const char* config_get_osk_driver_options(void) attr.i = 0; - for (option_k = 0; osk_drivers[option_k]; option_k++) + for (option_k = 0; osk_driver_find_handle(option_k); option_k++) { - const char *opt = osk_drivers[option_k]->ident; + const char *opt = osk_driver_find_ident(option_k); options_len += strlen(opt) + 1; string_list_append(options_l, opt, attr); } @@ -625,9 +655,9 @@ static const void *find_driver_nonempty(const char *label, int i, } else if (!strcmp(label, "osk_driver")) { - drv = osk_drivers[i]; + drv = osk_driver_find_handle(i); if (drv) - strlcpy(str, osk_drivers[i]->ident, sizeof_str); + strlcpy(str, osk_driver_find_ident(i), sizeof_str); } #ifdef HAVE_MENU else if (!strcmp(label, "menu_driver")) @@ -740,19 +770,19 @@ static void find_osk_driver(void) { int i = find_driver_index("osk_driver", g_settings.osk.driver); if (i >= 0) - driver.osk = osk_drivers[i]; + driver.osk = osk_driver_find_handle(i); else { unsigned d; RARCH_ERR("Couldn't find any OSK driver named \"%s\"\n", g_settings.osk.driver); RARCH_LOG_OUTPUT("Available OSK drivers are:\n"); - for (d = 0; osk_drivers[d]; d++) - RARCH_LOG_OUTPUT("\t%s\n", osk_drivers[d]->ident); + for (d = 0; osk_driver_find_handle(d); d++) + RARCH_LOG_OUTPUT("\t%s\n", osk_driver_find_ident(d)); RARCH_WARN("Going to default to first OSK driver...\n"); - driver.osk = osk_drivers[0]; + driver.osk = osk_driver_find_handle(0); if (!driver.osk) rarch_fail(1, "find_osk_driver()"); From 710d52ecc815f0fe64a38651f8056374b50a75cd Mon Sep 17 00:00:00 2001 From: twinaphex Date: Mon, 12 Jan 2015 17:03:01 +0100 Subject: [PATCH 091/156] Add camera_driver_find_handle/camera_driver_find_ident --- driver.c | 46 ++++++++++++++++++++++++++++++++++++++-------- 1 file changed, 38 insertions(+), 8 deletions(-) diff --git a/driver.c b/driver.c index 756d2c51f2..53c68861f2 100644 --- a/driver.c +++ b/driver.c @@ -474,6 +474,36 @@ static const camera_driver_t *camera_drivers[] = { NULL, }; +/** + * camera_driver_find_handle: + * @index : index of driver to get handle to. + * + * Returns: handle to camera driver at index. Can be NULL + * if nothing found. + **/ +static const void *camera_driver_find_handle(int index) +{ + const void *drv = camera_drivers[index]; + if (!drv) + return NULL; + return drv; +} + +/** + * camera_driver_find_ident: + * @index : index of driver to get handle to. + * + * Returns: Human-readable identifier of camera driver at index. Can be NULL + * if nothing found. + **/ +static const char *camera_driver_find_ident(int index) +{ + const camera_driver_t *drv = camera_drivers[index]; + if (!drv) + return NULL; + return drv->ident; +} + /** * config_get_camera_driver_options: * @@ -493,9 +523,9 @@ const char* config_get_camera_driver_options(void) attr.i = 0; - for (option_k = 0; camera_drivers[option_k]; option_k++) + for (option_k = 0; camera_driver_find_handle(option_k); option_k++) { - const char *opt = camera_drivers[option_k]->ident; + const char *opt = camera_driver_find_ident(option_k); options_len += strlen(opt) + 1; string_list_append(options_l, opt, attr); } @@ -643,9 +673,9 @@ static const void *find_driver_nonempty(const char *label, int i, if (!strcmp(label, "camera_driver")) { - drv = camera_drivers[i]; + drv = camera_driver_find_handle(i); if (drv) - strlcpy(str, camera_drivers[i]->ident, sizeof_str); + strlcpy(str, camera_driver_find_ident(i), sizeof_str); } else if (!strcmp(label, "location_driver")) { @@ -820,19 +850,19 @@ static void find_camera_driver(void) { int i = find_driver_index("camera_driver", g_settings.camera.driver); if (i >= 0) - driver.camera = camera_drivers[i]; + driver.camera = camera_driver_find_handle(i); else { unsigned d; RARCH_ERR("Couldn't find any camera driver named \"%s\"\n", g_settings.camera.driver); RARCH_LOG_OUTPUT("Available camera drivers are:\n"); - for (d = 0; camera_drivers[d]; d++) - RARCH_LOG_OUTPUT("\t%s\n", camera_drivers[d]->ident); + for (d = 0; camera_driver_find_handle(d); d++) + RARCH_LOG_OUTPUT("\t%s\n", camera_driver_find_ident(d)); RARCH_WARN("Going to default to first camera driver...\n"); - driver.camera = camera_drivers[0]; + driver.camera = camera_driver_find_handle(0); if (!driver.camera) rarch_fail(1, "find_camera_driver()"); From af08a3f617d5519d3cc3291ad75744ff8e1bcc7a Mon Sep 17 00:00:00 2001 From: twinaphex Date: Mon, 12 Jan 2015 17:05:54 +0100 Subject: [PATCH 092/156] Add location_driver_find_handle/location_driver_find_ident --- driver.c | 46 ++++++++++++++++++++++++++++++++++++++-------- 1 file changed, 38 insertions(+), 8 deletions(-) diff --git a/driver.c b/driver.c index 53c68861f2..c583e0dc7f 100644 --- a/driver.c +++ b/driver.c @@ -553,6 +553,36 @@ static const location_driver_t *location_drivers[] = { NULL, }; +/** + * location_driver_find_handle: + * @index : index of driver to get handle to. + * + * Returns: handle to location driver at index. Can be NULL + * if nothing found. + **/ +static const void *location_driver_find_handle(int index) +{ + const void *drv = location_drivers[index]; + if (!drv) + return NULL; + return drv; +} + +/** + * location_driver_find_ident: + * @index : index of driver to get handle to. + * + * Returns: Human-readable identifier of location driver at index. Can be NULL + * if nothing found. + **/ +static const char *location_driver_find_ident(int index) +{ + const location_driver_t *drv = location_drivers[index]; + if (!drv) + return NULL; + return drv->ident; +} + /** * config_get_location_driver_options: * @@ -572,9 +602,9 @@ const char* config_get_location_driver_options(void) attr.i = 0; - for (option_k = 0; location_drivers[option_k]; option_k++) + for (option_k = 0; location_driver_find_handle(option_k); option_k++) { - const char *opt = location_drivers[option_k]->ident; + const char *opt = location_driver_find_ident(option_k); options_len += strlen(opt) + 1; string_list_append(options_l, opt, attr); } @@ -679,9 +709,9 @@ static const void *find_driver_nonempty(const char *label, int i, } else if (!strcmp(label, "location_driver")) { - drv = location_drivers[i]; + drv = location_driver_find_handle(i); if (drv) - strlcpy(str, location_drivers[i]->ident, sizeof_str); + strlcpy(str, location_driver_find_ident(i), sizeof_str); } else if (!strcmp(label, "osk_driver")) { @@ -963,19 +993,19 @@ static void find_location_driver(void) { int i = find_driver_index("location_driver", g_settings.location.driver); if (i >= 0) - driver.location = location_drivers[i]; + driver.location = location_driver_find_handle(i); else { unsigned d; RARCH_ERR("Couldn't find any location driver named \"%s\"\n", g_settings.location.driver); RARCH_LOG_OUTPUT("Available location drivers are:\n"); - for (d = 0; location_drivers[d]; d++) - RARCH_LOG_OUTPUT("\t%s\n", location_drivers[d]->ident); + for (d = 0; location_driver_find_handle(d); d++) + RARCH_LOG_OUTPUT("\t%s\n", location_driver_find_ident(d)); RARCH_WARN("Going to default to first location driver...\n"); - driver.location = location_drivers[0]; + driver.location = location_driver_find_handle(0); if (!driver.location) rarch_fail(1, "find_location_driver()"); From 483b8bec107256ed614e5f7aa2707f74e2f8735e Mon Sep 17 00:00:00 2001 From: twinaphex Date: Mon, 12 Jan 2015 17:08:22 +0100 Subject: [PATCH 093/156] Add menu_driver_find_handle/menu_driver_find_ident --- driver.c | 46 ++++++++++++++++++++++++++++++++++++++-------- 1 file changed, 38 insertions(+), 8 deletions(-) diff --git a/driver.c b/driver.c index c583e0dc7f..a4a2212bd3 100644 --- a/driver.c +++ b/driver.c @@ -645,6 +645,36 @@ static const menu_ctx_driver_t *menu_ctx_drivers[] = { NULL }; +/** + * menu_driver_find_handle: + * @index : index of driver to get handle to. + * + * Returns: handle to menu driver at index. Can be NULL + * if nothing found. + **/ +static const void *menu_driver_find_handle(int index) +{ + const void *drv = menu_ctx_drivers[index]; + if (!drv) + return NULL; + return drv; +} + +/** + * menu_driver_find_ident: + * @index : index of driver to get handle to. + * + * Returns: Human-readable identifier of menu driver at index. Can be NULL + * if nothing found. + **/ +static const char *menu_driver_find_ident(int index) +{ + const menu_ctx_driver_t *drv = menu_ctx_drivers[index]; + if (!drv) + return NULL; + return drv->ident; +} + /** * config_get_menu_driver_options: * @@ -664,9 +694,9 @@ const char* config_get_menu_driver_options(void) attr.i = 0; - for (option_k = 0; menu_ctx_drivers[option_k]; option_k++) + for (option_k = 0; menu_driver_find_handle(option_k); option_k++) { - const char *opt = menu_ctx_drivers[option_k]->ident; + const char *opt = menu_driver_find_ident(option_k); options_len += strlen(opt) + 1; string_list_append(options_l, opt, attr); } @@ -722,9 +752,9 @@ static const void *find_driver_nonempty(const char *label, int i, #ifdef HAVE_MENU else if (!strcmp(label, "menu_driver")) { - drv = menu_ctx_drivers[i]; + drv = menu_driver_find_handle(i); if (drv) - strlcpy(str, menu_ctx_drivers[i]->ident, sizeof_str); + strlcpy(str, menu_driver_find_ident(i), sizeof_str); } #endif else if (!strcmp(label, "input_driver")) @@ -1129,18 +1159,18 @@ static void find_menu_driver(void) { int i = find_driver_index("menu_driver", g_settings.menu.driver); if (i >= 0) - driver.menu_ctx = menu_ctx_drivers[i]; + driver.menu_ctx = menu_driver_find_handle(i); else { unsigned d; RARCH_WARN("Couldn't find any menu driver named \"%s\"\n", g_settings.menu.driver); RARCH_LOG_OUTPUT("Available menu drivers are:\n"); - for (d = 0; menu_ctx_drivers[d]; d++) - RARCH_LOG_OUTPUT("\t%s\n", menu_ctx_drivers[d]->ident); + for (d = 0; menu_driver_find_handle(d); d++) + RARCH_LOG_OUTPUT("\t%s\n", menu_driver_find_ident(d)); RARCH_WARN("Going to default to first menu driver...\n"); - driver.menu_ctx = menu_ctx_drivers[0]; + driver.menu_ctx = menu_driver_find_handle(0); if (!driver.menu_ctx) rarch_fail(1, "find_menu_driver()"); From c7acbc84697b97121543126573250e87cdffc981 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Mon, 12 Jan 2015 17:10:00 +0100 Subject: [PATCH 094/156] Rename local variable option_k --- driver.c | 42 +++++++++++++++++++++--------------------- 1 file changed, 21 insertions(+), 21 deletions(-) diff --git a/driver.c b/driver.c index a4a2212bd3..5b6474c873 100644 --- a/driver.c +++ b/driver.c @@ -142,16 +142,16 @@ static const char *audio_driver_find_ident(int index) const char* config_get_audio_driver_options(void) { union string_list_elem_attr attr; + unsigned i; char *options = NULL; - int option_k = 0; int options_len = 0; struct string_list *options_l = string_list_new(); attr.i = 0; - for (option_k = 0; audio_driver_find_handle(option_k); option_k++) + for (i = 0; audio_driver_find_handle(i); i++) { - const char *opt = audio_driver_find_ident(option_k); + const char *opt = audio_driver_find_ident(i); options_len += strlen(opt) + 1; string_list_append(options_l, opt, attr); } @@ -247,16 +247,16 @@ static const char *video_driver_find_ident(int index) const char* config_get_video_driver_options(void) { union string_list_elem_attr attr; + unsigned i; char *options = NULL; - int option_k = 0; int options_len = 0; struct string_list *options_l = string_list_new(); attr.i = 0; - for (option_k = 0; video_driver_find_handle(option_k); option_k++) + for (i = 0; video_driver_find_handle(i); i++) { - const char *opt = video_driver_find_ident(option_k); + const char *opt = video_driver_find_ident(i); options_len += strlen(opt) + 1; string_list_append(options_l, opt, attr); } @@ -359,16 +359,16 @@ static const char *input_driver_find_ident(int index) const char* config_get_input_driver_options(void) { union string_list_elem_attr attr; + unsigned i; char *options = NULL; - int option_k = 0; int options_len = 0; struct string_list *options_l = string_list_new(); attr.i = 0; - for (option_k = 0; input_driver_find_handle(option_k); option_k++) + for (i = 0; input_driver_find_handle(i); i++) { - const char *opt = input_driver_find_ident(option_k); + const char *opt = input_driver_find_ident(i); options_len += strlen(opt) + 1; string_list_append(options_l, opt, attr); } @@ -433,16 +433,16 @@ static const char *osk_driver_find_ident(int index) const char* config_get_osk_driver_options(void) { union string_list_elem_attr attr; + unsigned i; char *options = NULL; - int option_k = 0; int options_len = 0; struct string_list *options_l = string_list_new(); attr.i = 0; - for (option_k = 0; osk_driver_find_handle(option_k); option_k++) + for (i = 0; osk_driver_find_handle(i); i++) { - const char *opt = osk_driver_find_ident(option_k); + const char *opt = osk_driver_find_ident(i); options_len += strlen(opt) + 1; string_list_append(options_l, opt, attr); } @@ -516,16 +516,16 @@ static const char *camera_driver_find_ident(int index) const char* config_get_camera_driver_options(void) { union string_list_elem_attr attr; + unsigned i; char *options = NULL; - int option_k = 0; int options_len = 0; struct string_list *options_l = string_list_new(); attr.i = 0; - for (option_k = 0; camera_driver_find_handle(option_k); option_k++) + for (i = 0; camera_driver_find_handle(i); i++) { - const char *opt = camera_driver_find_ident(option_k); + const char *opt = camera_driver_find_ident(i); options_len += strlen(opt) + 1; string_list_append(options_l, opt, attr); } @@ -595,16 +595,16 @@ static const char *location_driver_find_ident(int index) const char* config_get_location_driver_options(void) { union string_list_elem_attr attr; + unsigned i; char *options = NULL; - int option_k = 0; int options_len = 0; struct string_list *options_l = string_list_new(); attr.i = 0; - for (option_k = 0; location_driver_find_handle(option_k); option_k++) + for (i = 0; location_driver_find_handle(i); i++) { - const char *opt = location_driver_find_ident(option_k); + const char *opt = location_driver_find_ident(i); options_len += strlen(opt) + 1; string_list_append(options_l, opt, attr); } @@ -687,16 +687,16 @@ static const char *menu_driver_find_ident(int index) const char* config_get_menu_driver_options(void) { union string_list_elem_attr attr; + unsigned i; char *options = NULL; - int option_k = 0; int options_len = 0; struct string_list *options_l = string_list_new(); attr.i = 0; - for (option_k = 0; menu_driver_find_handle(option_k); option_k++) + for (i = 0; menu_driver_find_handle(i); i++) { - const char *opt = menu_driver_find_ident(option_k); + const char *opt = menu_driver_find_ident(i); options_len += strlen(opt) + 1; string_list_append(options_l, opt, attr); } From 63e2eab86be89ac9d110c7bb53496affc14ffdf5 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Mon, 12 Jan 2015 17:14:06 +0100 Subject: [PATCH 095/156] Add joypad_driver_find_handle/joypad_driver_find_ident --- driver.c | 33 +++++++++++++++++++++++++++++++-- 1 file changed, 31 insertions(+), 2 deletions(-) diff --git a/driver.c b/driver.c index 5b6474c873..792e8b5d78 100644 --- a/driver.c +++ b/driver.c @@ -712,6 +712,35 @@ const char* config_get_menu_driver_options(void) } #endif +/** + * joypad_driver_find_handle: + * @index : index of driver to get handle to. + * + * Returns: handle to joypad driver at index. Can be NULL + * if nothing found. + **/ +static const void *joypad_driver_find_handle(int index) +{ + const void *drv = joypad_drivers[index]; + if (!drv) + return NULL; + return drv; +} + +/** + * joypad_driver_find_ident: + * @index : index of driver to get handle to. + * + * Returns: Human-readable identifier of joypad driver at index. Can be NULL + * if nothing found. + **/ +static const char *joypad_driver_find_ident(int index) +{ + const rarch_joypad_driver_t *drv = joypad_drivers[index]; + if (!drv) + return NULL; + return drv->ident; +} /** * find_driver_nonempty: @@ -765,9 +794,9 @@ static const void *find_driver_nonempty(const char *label, int i, } else if (!strcmp(label, "input_joypad_driver")) { - drv = joypad_drivers[i]; + drv = joypad_driver_find_handle(i); if (drv) - strlcpy(str, joypad_drivers[i]->ident, sizeof_str); + strlcpy(str, joypad_driver_find_ident(i), sizeof_str); } else if (!strcmp(label, "video_driver")) { From a3dc6203b2f47ab8bda824d9caf5e0583543e017 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Mon, 12 Jan 2015 17:16:14 +0100 Subject: [PATCH 096/156] Rename option_k local variables --- audio/resamplers/resampler.c | 6 +++--- input/input_context.c | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/audio/resamplers/resampler.c b/audio/resamplers/resampler.c index a364b6ee71..09ea80dc28 100644 --- a/audio/resamplers/resampler.c +++ b/audio/resamplers/resampler.c @@ -104,16 +104,16 @@ void find_next_resampler_driver(void) const char* config_get_audio_resampler_driver_options(void) { union string_list_elem_attr attr; + unsigned i; char *options = NULL; - int option_k = 0; int options_len = 0; struct string_list *options_l = string_list_new(); attr.i = 0; - for (option_k = 0; resampler_drivers[option_k]; option_k++) + for (i = 0; resampler_drivers[i]; i++) { - const char *opt = resampler_drivers[option_k]->ident; + const char *opt = resampler_drivers[i]->ident; options_len += strlen(opt) + 1; string_list_append(options_l, opt, attr); } diff --git a/input/input_context.c b/input/input_context.c index 47be0e30a8..0729e3051f 100644 --- a/input/input_context.c +++ b/input/input_context.c @@ -81,16 +81,16 @@ rarch_joypad_driver_t *joypad_drivers[] = { const char* config_get_joypad_driver_options(void) { union string_list_elem_attr attr; + unsigned i; char *options = NULL; - int option_k = 0; int options_len = 0; struct string_list *options_l = string_list_new(); attr.i = 0; - for (option_k = 0; joypad_drivers[option_k]; option_k++) + for (i = 0; joypad_drivers[i]; i++) { - const char *opt = joypad_drivers[option_k]->ident; + const char *opt = joypad_drivers[i]->ident; options_len += strlen(opt) + 1; string_list_append(options_l, opt, attr); } From 0fbf48e4510b278fc6e8936b96c2d6ed2bc02c8a Mon Sep 17 00:00:00 2001 From: twinaphex Date: Mon, 12 Jan 2015 18:06:38 +0100 Subject: [PATCH 097/156] Split up audio_driver code into audio_driver.c --- Makefile.common | 1 + audio_driver.c | 383 ++++++++++++++++++++++++++++++++++++++++++++++ audio_driver.h | 117 ++++++++++++++ driver.c | 366 +------------------------------------------- driver.h | 68 ++------ griffin/griffin.c | 1 + 6 files changed, 517 insertions(+), 419 deletions(-) create mode 100644 audio_driver.c create mode 100644 audio_driver.h diff --git a/Makefile.common b/Makefile.common index f48484a7ae..fc4548ca24 100644 --- a/Makefile.common +++ b/Makefile.common @@ -97,6 +97,7 @@ OBJ += frontend/frontend.o \ file_ops.o \ libretro-sdk/file/file_path.o \ hash.o \ + audio_driver.o \ driver.o \ settings.o \ settings_list.o \ diff --git a/audio_driver.c b/audio_driver.c new file mode 100644 index 0000000000..30ef88cf48 --- /dev/null +++ b/audio_driver.c @@ -0,0 +1,383 @@ +/* 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 . + */ + +#include +#include +#include "audio_driver.h" +#include "audio/utils.h" +#include "audio/audio_thread_wrapper.h" +#include "driver.h" +#include "general.h" +#include "retroarch.h" + +static const audio_driver_t *audio_drivers[] = { +#ifdef HAVE_ALSA + &audio_alsa, +#ifndef __QNX__ + &audio_alsathread, +#endif +#endif +#if defined(HAVE_OSS) || defined(HAVE_OSS_BSD) + &audio_oss, +#endif +#ifdef HAVE_RSOUND + &audio_rsound, +#endif +#ifdef HAVE_COREAUDIO + &audio_coreaudio, +#endif +#ifdef HAVE_AL + &audio_openal, +#endif +#ifdef HAVE_SL + &audio_opensl, +#endif +#ifdef HAVE_ROAR + &audio_roar, +#endif +#ifdef HAVE_JACK + &audio_jack, +#endif +#if defined(HAVE_SDL) || defined(HAVE_SDL2) + &audio_sdl, +#endif +#ifdef HAVE_XAUDIO + &audio_xa, +#endif +#ifdef HAVE_DSOUND + &audio_dsound, +#endif +#ifdef HAVE_PULSE + &audio_pulse, +#endif +#ifdef __CELLOS_LV2__ + &audio_ps3, +#endif +#ifdef XENON + &audio_xenon360, +#endif +#ifdef GEKKO + &audio_gx, +#endif +#ifdef EMSCRIPTEN + &audio_rwebaudio, +#endif +#ifdef PSP + &audio_psp1, +#endif + &audio_null, + NULL, +}; + +/** + * compute_audio_buffer_statistics: + * + * Computes audio buffer statistics. + * + **/ +static void compute_audio_buffer_statistics(void) +{ + unsigned i, low_water_size, high_water_size, avg, stddev; + float avg_filled, deviation; + uint64_t accum = 0, accum_var = 0; + unsigned low_water_count = 0, high_water_count = 0; + unsigned samples = min(g_extern.measure_data.buffer_free_samples_count, + AUDIO_BUFFER_FREE_SAMPLES_COUNT); + + if (samples < 3) + return; + + for (i = 1; i < samples; i++) + accum += g_extern.measure_data.buffer_free_samples[i]; + + avg = accum / (samples - 1); + + for (i = 1; i < samples; i++) + { + int diff = avg - g_extern.measure_data.buffer_free_samples[i]; + accum_var += diff * diff; + } + + stddev = (unsigned)sqrt((double)accum_var / (samples - 2)); + avg_filled = 1.0f - (float)avg / g_extern.audio_data.driver_buffer_size; + deviation = (float)stddev / g_extern.audio_data.driver_buffer_size; + + low_water_size = g_extern.audio_data.driver_buffer_size * 3 / 4; + high_water_size = g_extern.audio_data.driver_buffer_size / 4; + + for (i = 1; i < samples; i++) + { + if (g_extern.measure_data.buffer_free_samples[i] >= low_water_size) + low_water_count++; + else if (g_extern.measure_data.buffer_free_samples[i] <= high_water_size) + high_water_count++; + } + + RARCH_LOG("Average audio buffer saturation: %.2f %%, standard deviation (percentage points): %.2f %%.\n", + avg_filled * 100.0, deviation * 100.0); + RARCH_LOG("Amount of time spent close to underrun: %.2f %%. Close to blocking: %.2f %%.\n", + (100.0 * low_water_count) / (samples - 1), + (100.0 * high_water_count) / (samples - 1)); +} + +/** + * audio_driver_find_handle: + * @index : index of driver to get handle to. + * + * Returns: handle to audio driver at index. Can be NULL + * if nothing found. + **/ +const void *audio_driver_find_handle(int index) +{ + const void *drv = audio_drivers[index]; + if (!drv) + return NULL; + return drv; +} + +/** + * audio_driver_find_ident: + * @index : index of driver to get handle to. + * + * Returns: Human-readable identifier of audio driver at index. Can be NULL + * if nothing found. + **/ +const char *audio_driver_find_ident(int index) +{ + const audio_driver_t *drv = audio_drivers[index]; + if (!drv) + return NULL; + return drv->ident; +} + +/** + * config_get_audio_driver_options: + * + * Get an enumerated list of all audio driver names, separated by '|'. + * + * Returns: string listing of all audio driver names, separated by '|'. + **/ +const char* config_get_audio_driver_options(void) +{ + union string_list_elem_attr attr; + unsigned i; + char *options = NULL; + int options_len = 0; + struct string_list *options_l = string_list_new(); + + attr.i = 0; + + for (i = 0; audio_driver_find_handle(i); i++) + { + const char *opt = audio_driver_find_ident(i); + options_len += strlen(opt) + 1; + string_list_append(options_l, opt, attr); + } + + options = (char*)calloc(options_len, sizeof(char)); + + string_list_join_concat(options, options_len, options_l, "|"); + + string_list_free(options_l); + options_l = NULL; + + return options; +} + +void find_audio_driver(void) +{ + int i = find_driver_index("audio_driver", g_settings.audio.driver); + if (i >= 0) + driver.audio = audio_driver_find_handle(i); + else + { + unsigned d; + RARCH_ERR("Couldn't find any audio driver named \"%s\"\n", + g_settings.audio.driver); + RARCH_LOG_OUTPUT("Available audio drivers are:\n"); + for (d = 0; audio_driver_find_handle(d); d++) + RARCH_LOG_OUTPUT("\t%s\n", audio_driver_find_ident(d)); + RARCH_WARN("Going to default to first audio driver...\n"); + + driver.audio = audio_driver_find_handle(0); + + if (!driver.audio) + rarch_fail(1, "find_audio_driver()"); + } +} + +void uninit_audio(void) +{ + if (driver.audio_data && driver.audio) + driver.audio->free(driver.audio_data); + + free(g_extern.audio_data.conv_outsamples); + g_extern.audio_data.conv_outsamples = NULL; + g_extern.audio_data.data_ptr = 0; + + free(g_extern.audio_data.rewind_buf); + g_extern.audio_data.rewind_buf = NULL; + + if (!g_settings.audio.enable) + { + driver.audio_active = false; + return; + } + + rarch_resampler_freep(&driver.resampler, + &driver.resampler_data); + + free(g_extern.audio_data.data); + g_extern.audio_data.data = NULL; + + free(g_extern.audio_data.outsamples); + g_extern.audio_data.outsamples = NULL; + + rarch_main_command(RARCH_CMD_DSP_FILTER_DEINIT); + + compute_audio_buffer_statistics(); +} + +void init_audio(void) +{ + size_t outsamples_max, max_bufsamples = AUDIO_CHUNK_SIZE_NONBLOCKING * 2; + + audio_convert_init_simd(); + + /* Resource leaks will follow if audio is initialized twice. */ + if (driver.audio_data) + return; + + /* Accomodate rewind since at some point we might have two full buffers. */ + outsamples_max = max_bufsamples * AUDIO_MAX_RATIO * + g_settings.slowmotion_ratio; + + /* Used for recording even if audio isn't enabled. */ + rarch_assert(g_extern.audio_data.conv_outsamples = + (int16_t*)malloc(outsamples_max * sizeof(int16_t))); + + g_extern.audio_data.block_chunk_size = AUDIO_CHUNK_SIZE_BLOCKING; + g_extern.audio_data.nonblock_chunk_size = AUDIO_CHUNK_SIZE_NONBLOCKING; + g_extern.audio_data.chunk_size = + g_extern.audio_data.block_chunk_size; + + /* Needs to be able to hold full content of a full max_bufsamples + * in addition to its own. */ + rarch_assert(g_extern.audio_data.rewind_buf = (int16_t*) + malloc(max_bufsamples * sizeof(int16_t))); + g_extern.audio_data.rewind_size = max_bufsamples; + + if (!g_settings.audio.enable) + { + driver.audio_active = false; + return; + } + + find_audio_driver(); +#ifdef HAVE_THREADS + if (g_extern.system.audio_callback.callback) + { + RARCH_LOG("Starting threaded audio driver ...\n"); + if (!rarch_threaded_audio_init(&driver.audio, &driver.audio_data, + *g_settings.audio.device ? g_settings.audio.device : NULL, + g_settings.audio.out_rate, g_settings.audio.latency, + driver.audio)) + { + RARCH_ERR("Cannot open threaded audio driver ... Exiting ...\n"); + rarch_fail(1, "init_audio()"); + } + } + else +#endif + { + driver.audio_data = driver.audio->init(*g_settings.audio.device ? + g_settings.audio.device : NULL, + g_settings.audio.out_rate, g_settings.audio.latency); + } + + if (!driver.audio_data) + { + RARCH_ERR("Failed to initialize audio driver. Will continue without audio.\n"); + driver.audio_active = false; + } + + g_extern.audio_data.use_float = false; + if (driver.audio_active && driver.audio->use_float(driver.audio_data)) + g_extern.audio_data.use_float = true; + + if (!g_settings.audio.sync && driver.audio_active) + { + rarch_main_command(RARCH_CMD_AUDIO_SET_NONBLOCKING_STATE); + g_extern.audio_data.chunk_size = + g_extern.audio_data.nonblock_chunk_size; + } + + if (g_extern.audio_data.in_rate <= 0.0f) + { + /* Should never happen. */ + RARCH_WARN("Input rate is invalid (%.3f Hz). Using output rate (%u Hz).\n", + g_extern.audio_data.in_rate, g_settings.audio.out_rate); + g_extern.audio_data.in_rate = g_settings.audio.out_rate; + } + + g_extern.audio_data.orig_src_ratio = + g_extern.audio_data.src_ratio = + (double)g_settings.audio.out_rate / g_extern.audio_data.in_rate; + + if (!rarch_resampler_realloc(&driver.resampler_data, + &driver.resampler, + g_settings.audio.resampler, g_extern.audio_data.orig_src_ratio)) + { + RARCH_ERR("Failed to initialize resampler \"%s\".\n", + g_settings.audio.resampler); + driver.audio_active = false; + } + + rarch_assert(g_extern.audio_data.data = (float*) + malloc(max_bufsamples * sizeof(float))); + + g_extern.audio_data.data_ptr = 0; + + rarch_assert(g_settings.audio.out_rate < + g_extern.audio_data.in_rate * AUDIO_MAX_RATIO); + rarch_assert(g_extern.audio_data.outsamples = (float*) + malloc(outsamples_max * sizeof(float))); + + g_extern.audio_data.rate_control = false; + if (!g_extern.system.audio_callback.callback && driver.audio_active && + g_settings.audio.rate_control) + { + if (driver.audio->buffer_size && driver.audio->write_avail) + { + g_extern.audio_data.driver_buffer_size = + driver.audio->buffer_size(driver.audio_data); + g_extern.audio_data.rate_control = true; + } + else + RARCH_WARN("Audio rate control was desired, but driver does not support needed features.\n"); + } + + rarch_main_command(RARCH_CMD_DSP_FILTER_DEINIT); + + g_extern.measure_data.buffer_free_samples_count = 0; + + if (driver.audio_active && !g_extern.audio_data.mute && + g_extern.system.audio_callback.callback) + { + /* Threaded driver is initially stopped. */ + driver.audio->start(driver.audio_data); + } +} diff --git a/audio_driver.h b/audio_driver.h new file mode 100644 index 0000000000..91fc2a8139 --- /dev/null +++ b/audio_driver.h @@ -0,0 +1,117 @@ +/* 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 . + */ + +#ifndef __AUDIO_DRIVER__H +#define __AUDIO_DRIVER__H + +#include +#include +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +typedef struct audio_driver +{ + void *(*init)(const char *device, unsigned rate, unsigned latency); + + ssize_t (*write)(void *data, const void *buf, size_t size); + + bool (*stop)(void *data); + + bool (*start)(void *data); + + /* Is the audio driver currently running? */ + bool (*alive)(void *data); + + /* Should we care about blocking in audio thread? Fast forwarding. */ + void (*set_nonblock_state)(void *data, bool toggle); + + void (*free)(void *data); + + /* Defines if driver will take standard floating point samples, + * or int16_t samples. */ + bool (*use_float)(void *data); + + /* Human-readable identifier. */ + const char *ident; + + /* Optional. */ + size_t (*write_avail)(void *data); + + size_t (*buffer_size)(void *data); +} audio_driver_t; + +extern audio_driver_t audio_rsound; +extern audio_driver_t audio_oss; +extern audio_driver_t audio_alsa; +extern audio_driver_t audio_alsathread; +extern audio_driver_t audio_roar; +extern audio_driver_t audio_openal; +extern audio_driver_t audio_opensl; +extern audio_driver_t audio_jack; +extern audio_driver_t audio_sdl; +extern audio_driver_t audio_xa; +extern audio_driver_t audio_pulse; +extern audio_driver_t audio_dsound; +extern audio_driver_t audio_coreaudio; +extern audio_driver_t audio_xenon360; +extern audio_driver_t audio_ps3; +extern audio_driver_t audio_gx; +extern audio_driver_t audio_psp1; +extern audio_driver_t audio_rwebaudio; +extern audio_driver_t audio_null; + +/** + * audio_driver_find_handle: + * @index : index of driver to get handle to. + * + * Returns: handle to audio driver at index. Can be NULL + * if nothing found. + **/ +const void *audio_driver_find_handle(int index); + +/** + * audio_driver_find_ident: + * @index : index of driver to get handle to. + * + * Returns: Human-readable identifier of audio driver at index. Can be NULL + * if nothing found. + **/ +const char *audio_driver_find_ident(int index); + +/** + * config_get_audio_driver_options: + * + * Get an enumerated list of all audio driver names, separated by '|'. + * + * Returns: string listing of all audio driver names, separated by '|'. + **/ +const char* config_get_audio_driver_options(void); + +void find_audio_driver(void); + +void uninit_audio(void); + +void init_audio(void); + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/driver.c b/driver.c index 792e8b5d78..621029a701 100644 --- a/driver.c +++ b/driver.c @@ -14,7 +14,6 @@ * If not, see . */ - #include "driver.h" #include "general.h" #include "retroarch.h" @@ -23,9 +22,7 @@ #include #include #include "compat/posix_string.h" -#include "audio/utils.h" #include "gfx/video_thread_wrapper.h" -#include "audio/audio_thread_wrapper.h" #include "gfx/gfx_common.h" #include @@ -43,129 +40,6 @@ driver_t driver; -static const audio_driver_t *audio_drivers[] = { -#ifdef HAVE_ALSA - &audio_alsa, -#ifndef __QNX__ - &audio_alsathread, -#endif -#endif -#if defined(HAVE_OSS) || defined(HAVE_OSS_BSD) - &audio_oss, -#endif -#ifdef HAVE_RSOUND - &audio_rsound, -#endif -#ifdef HAVE_COREAUDIO - &audio_coreaudio, -#endif -#ifdef HAVE_AL - &audio_openal, -#endif -#ifdef HAVE_SL - &audio_opensl, -#endif -#ifdef HAVE_ROAR - &audio_roar, -#endif -#ifdef HAVE_JACK - &audio_jack, -#endif -#if defined(HAVE_SDL) || defined(HAVE_SDL2) - &audio_sdl, -#endif -#ifdef HAVE_XAUDIO - &audio_xa, -#endif -#ifdef HAVE_DSOUND - &audio_dsound, -#endif -#ifdef HAVE_PULSE - &audio_pulse, -#endif -#ifdef __CELLOS_LV2__ - &audio_ps3, -#endif -#ifdef XENON - &audio_xenon360, -#endif -#ifdef GEKKO - &audio_gx, -#endif -#ifdef EMSCRIPTEN - &audio_rwebaudio, -#endif -#ifdef PSP - &audio_psp1, -#endif - &audio_null, - NULL, -}; - -/** - * audio_driver_find_handle: - * @index : index of driver to get handle to. - * - * Returns: handle to audio driver at index. Can be NULL - * if nothing found. - **/ -static const void *audio_driver_find_handle(int index) -{ - const void *drv = audio_drivers[index]; - if (!drv) - return NULL; - return drv; -} - -/** - * audio_driver_find_ident: - * @index : index of driver to get handle to. - * - * Returns: Human-readable identifier of audio driver at index. Can be NULL - * if nothing found. - **/ -static const char *audio_driver_find_ident(int index) -{ - const audio_driver_t *drv = audio_drivers[index]; - if (!drv) - return NULL; - return drv->ident; -} - -/** - * config_get_audio_driver_options: - * - * Get an enumerated list of all audio driver names, separated by '|'. - * - * Returns: string listing of all audio driver names, separated by '|'. - **/ -const char* config_get_audio_driver_options(void) -{ - union string_list_elem_attr attr; - unsigned i; - char *options = NULL; - int options_len = 0; - struct string_list *options_l = string_list_new(); - - attr.i = 0; - - for (i = 0; audio_driver_find_handle(i); i++) - { - const char *opt = audio_driver_find_ident(i); - options_len += strlen(opt) + 1; - string_list_append(options_l, opt, attr); - } - - options = (char*)calloc(options_len, sizeof(char)); - - string_list_join_concat(options, options_len, options_l, "|"); - - string_list_free(options_l); - options_l = NULL; - - return options; -} - static const video_driver_t *video_drivers[] = { #ifdef HAVE_OPENGL &video_gl, @@ -824,7 +698,7 @@ static const void *find_driver_nonempty(const char *label, int i, * Returns: -1 if no driver based on @label and @drv found, otherwise * index number of the driver found in the array. **/ -static int find_driver_index(const char * label, const char *drv) +int find_driver_index(const char * label, const char *drv) { unsigned i; char str[PATH_MAX_LENGTH]; @@ -1207,30 +1081,6 @@ static void find_menu_driver(void) } #endif - -static void find_audio_driver(void) -{ - int i = find_driver_index("audio_driver", g_settings.audio.driver); - if (i >= 0) - driver.audio = audio_driver_find_handle(i); - else - { - unsigned d; - RARCH_ERR("Couldn't find any audio driver named \"%s\"\n", - g_settings.audio.driver); - RARCH_LOG_OUTPUT("Available audio drivers are:\n"); - for (d = 0; audio_driver_find_handle(d); d++) - RARCH_LOG_OUTPUT("\t%s\n", audio_driver_find_ident(d)); - RARCH_WARN("Going to default to first audio driver...\n"); - - driver.audio = audio_driver_find_handle(0); - - if (!driver.audio) - rarch_fail(1, "find_audio_driver()"); - } -} - - static void find_video_driver(void) { int i; @@ -1536,137 +1386,6 @@ static void init_menu(void) } #endif -static void init_audio(void) -{ - size_t outsamples_max, max_bufsamples = AUDIO_CHUNK_SIZE_NONBLOCKING * 2; - - audio_convert_init_simd(); - - /* Resource leaks will follow if audio is initialized twice. */ - if (driver.audio_data) - return; - - /* Accomodate rewind since at some point we might have two full buffers. */ - outsamples_max = max_bufsamples * AUDIO_MAX_RATIO * - g_settings.slowmotion_ratio; - - /* Used for recording even if audio isn't enabled. */ - rarch_assert(g_extern.audio_data.conv_outsamples = - (int16_t*)malloc(outsamples_max * sizeof(int16_t))); - - g_extern.audio_data.block_chunk_size = AUDIO_CHUNK_SIZE_BLOCKING; - g_extern.audio_data.nonblock_chunk_size = AUDIO_CHUNK_SIZE_NONBLOCKING; - g_extern.audio_data.chunk_size = - g_extern.audio_data.block_chunk_size; - - /* Needs to be able to hold full content of a full max_bufsamples - * in addition to its own. */ - rarch_assert(g_extern.audio_data.rewind_buf = (int16_t*) - malloc(max_bufsamples * sizeof(int16_t))); - g_extern.audio_data.rewind_size = max_bufsamples; - - if (!g_settings.audio.enable) - { - driver.audio_active = false; - return; - } - - find_audio_driver(); -#ifdef HAVE_THREADS - if (g_extern.system.audio_callback.callback) - { - RARCH_LOG("Starting threaded audio driver ...\n"); - if (!rarch_threaded_audio_init(&driver.audio, &driver.audio_data, - *g_settings.audio.device ? g_settings.audio.device : NULL, - g_settings.audio.out_rate, g_settings.audio.latency, - driver.audio)) - { - RARCH_ERR("Cannot open threaded audio driver ... Exiting ...\n"); - rarch_fail(1, "init_audio()"); - } - } - else -#endif - { - driver.audio_data = driver.audio->init(*g_settings.audio.device ? - g_settings.audio.device : NULL, - g_settings.audio.out_rate, g_settings.audio.latency); - } - - if (!driver.audio_data) - { - RARCH_ERR("Failed to initialize audio driver. Will continue without audio.\n"); - driver.audio_active = false; - } - - g_extern.audio_data.use_float = false; - if (driver.audio_active && driver.audio->use_float(driver.audio_data)) - g_extern.audio_data.use_float = true; - - if (!g_settings.audio.sync && driver.audio_active) - { - rarch_main_command(RARCH_CMD_AUDIO_SET_NONBLOCKING_STATE); - g_extern.audio_data.chunk_size = - g_extern.audio_data.nonblock_chunk_size; - } - - if (g_extern.audio_data.in_rate <= 0.0f) - { - /* Should never happen. */ - RARCH_WARN("Input rate is invalid (%.3f Hz). Using output rate (%u Hz).\n", - g_extern.audio_data.in_rate, g_settings.audio.out_rate); - g_extern.audio_data.in_rate = g_settings.audio.out_rate; - } - - g_extern.audio_data.orig_src_ratio = - g_extern.audio_data.src_ratio = - (double)g_settings.audio.out_rate / g_extern.audio_data.in_rate; - - if (!rarch_resampler_realloc(&driver.resampler_data, - &driver.resampler, - g_settings.audio.resampler, g_extern.audio_data.orig_src_ratio)) - { - RARCH_ERR("Failed to initialize resampler \"%s\".\n", - g_settings.audio.resampler); - driver.audio_active = false; - } - - rarch_assert(g_extern.audio_data.data = (float*) - malloc(max_bufsamples * sizeof(float))); - - g_extern.audio_data.data_ptr = 0; - - rarch_assert(g_settings.audio.out_rate < - g_extern.audio_data.in_rate * AUDIO_MAX_RATIO); - rarch_assert(g_extern.audio_data.outsamples = (float*) - malloc(outsamples_max * sizeof(float))); - - g_extern.audio_data.rate_control = false; - if (!g_extern.system.audio_callback.callback && driver.audio_active && - g_settings.audio.rate_control) - { - if (driver.audio->buffer_size && driver.audio->write_avail) - { - g_extern.audio_data.driver_buffer_size = - driver.audio->buffer_size(driver.audio_data); - g_extern.audio_data.rate_control = true; - } - else - RARCH_WARN("Audio rate control was desired, but driver does not support needed features.\n"); - } - - rarch_main_command(RARCH_CMD_DSP_FILTER_DEINIT); - - g_extern.measure_data.buffer_free_samples_count = 0; - - if (driver.audio_active && !g_extern.audio_data.mute && - g_extern.system.audio_callback.callback) - { - /* Threaded driver is initially stopped. */ - driver.audio->start(driver.audio_data); - } -} - static void deinit_pixel_converter(void) { scaler_ctx_gen_reset(&driver.scaler); @@ -2063,89 +1782,6 @@ static void compute_monitor_fps_statistics(void) } } -/** - * compute_audio_buffer_statistics: - * - * Computes audio buffer statistics. - * - **/ -static void compute_audio_buffer_statistics(void) -{ - unsigned i, low_water_size, high_water_size, avg, stddev; - float avg_filled, deviation; - uint64_t accum = 0, accum_var = 0; - unsigned low_water_count = 0, high_water_count = 0; - unsigned samples = min(g_extern.measure_data.buffer_free_samples_count, - AUDIO_BUFFER_FREE_SAMPLES_COUNT); - - if (samples < 3) - return; - - for (i = 1; i < samples; i++) - accum += g_extern.measure_data.buffer_free_samples[i]; - - avg = accum / (samples - 1); - - for (i = 1; i < samples; i++) - { - int diff = avg - g_extern.measure_data.buffer_free_samples[i]; - accum_var += diff * diff; - } - - stddev = (unsigned)sqrt((double)accum_var / (samples - 2)); - avg_filled = 1.0f - (float)avg / g_extern.audio_data.driver_buffer_size; - deviation = (float)stddev / g_extern.audio_data.driver_buffer_size; - - low_water_size = g_extern.audio_data.driver_buffer_size * 3 / 4; - high_water_size = g_extern.audio_data.driver_buffer_size / 4; - - for (i = 1; i < samples; i++) - { - if (g_extern.measure_data.buffer_free_samples[i] >= low_water_size) - low_water_count++; - else if (g_extern.measure_data.buffer_free_samples[i] <= high_water_size) - high_water_count++; - } - - RARCH_LOG("Average audio buffer saturation: %.2f %%, standard deviation (percentage points): %.2f %%.\n", - avg_filled * 100.0, deviation * 100.0); - RARCH_LOG("Amount of time spent close to underrun: %.2f %%. Close to blocking: %.2f %%.\n", - (100.0 * low_water_count) / (samples - 1), - (100.0 * high_water_count) / (samples - 1)); -} - -static void uninit_audio(void) -{ - if (driver.audio_data && driver.audio) - driver.audio->free(driver.audio_data); - - free(g_extern.audio_data.conv_outsamples); - g_extern.audio_data.conv_outsamples = NULL; - g_extern.audio_data.data_ptr = 0; - - free(g_extern.audio_data.rewind_buf); - g_extern.audio_data.rewind_buf = NULL; - - if (!g_settings.audio.enable) - { - driver.audio_active = false; - return; - } - - rarch_resampler_freep(&driver.resampler, - &driver.resampler_data); - - free(g_extern.audio_data.data); - g_extern.audio_data.data = NULL; - - free(g_extern.audio_data.outsamples); - g_extern.audio_data.outsamples = NULL; - - rarch_main_command(RARCH_CMD_DSP_FILTER_DEINIT); - - compute_audio_buffer_statistics(); -} - static void uninit_video_input(void) { rarch_main_command(RARCH_CMD_OVERLAY_DEINIT); diff --git a/driver.h b/driver.h index 930f3036a7..72a61ce679 100644 --- a/driver.h +++ b/driver.h @@ -14,7 +14,6 @@ * If not, see . */ - #ifndef __DRIVER__H #define __DRIVER__H @@ -36,6 +35,8 @@ #include "frontend/frontend_context.h" #include +#include "audio_driver.h" + #include "menu/menu_driver.h" #include "menu/backend/menu_backend.h" #include "menu/disp/menu_display.h" @@ -180,30 +181,6 @@ typedef struct video_info bool rgb32; } video_info_t; -typedef struct audio_driver -{ - void *(*init)(const char *device, unsigned rate, unsigned latency); - ssize_t (*write)(void *data, const void *buf, size_t size); - bool (*stop)(void *data); - bool (*start)(void *data); - - /* Is the audio driver currently running? */ - bool (*alive)(void *data); - - /* Should we care about blocking in audio thread? Fast forwarding. */ - void (*set_nonblock_state)(void *data, bool toggle); - void (*free)(void *data); - - /* Defines if driver will take standard floating point samples, - * or int16_t samples. */ - bool (*use_float)(void *data); - const char *ident; - - /* Optional. */ - size_t (*write_avail)(void *data); - size_t (*buffer_size)(void *data); -} audio_driver_t; - #define AXIS_NEG(x) (((uint32_t)(x) << 16) | UINT16_C(0xFFFF)) #define AXIS_POS(x) ((uint32_t)(x) | UINT32_C(0xFFFF0000)) #define AXIS_NONE UINT32_C(0xFFFFFFFF) @@ -805,26 +782,6 @@ bool driver_update_system_av_info(const struct retro_system_av_info *info); extern driver_t driver; /* Backends */ -extern audio_driver_t audio_rsound; -extern audio_driver_t audio_oss; -extern audio_driver_t audio_alsa; -extern audio_driver_t audio_alsathread; -extern audio_driver_t audio_roar; -extern audio_driver_t audio_openal; -extern audio_driver_t audio_opensl; -extern audio_driver_t audio_jack; -extern audio_driver_t audio_sdl; -extern audio_driver_t audio_xa; -extern audio_driver_t audio_pulse; -extern audio_driver_t audio_dsound; -extern audio_driver_t audio_coreaudio; -extern audio_driver_t audio_xenon360; -extern audio_driver_t audio_ps3; -extern audio_driver_t audio_gx; -extern audio_driver_t audio_psp1; -extern audio_driver_t audio_rwebaudio; -extern audio_driver_t audio_null; - extern video_driver_t video_gl; extern video_driver_t video_psp1; extern video_driver_t video_vita; @@ -886,15 +843,6 @@ const char* config_get_camera_driver_options(void); **/ const char* config_get_video_driver_options(void); -/** - * config_get_audio_driver_options: - * - * Get an enumerated list of all audio driver names, separated by '|'. - * - * Returns: string listing of all audio driver names, separated by '|'. - **/ -const char* config_get_audio_driver_options(void); - /** * config_get_osk_driver_options: * @@ -929,6 +877,18 @@ const char* config_get_location_driver_options(void); **/ const char* config_get_menu_driver_options(void); #endif + +/** + * find_driver_index: + * @label : string of driver type to be found. + * @drv : identifier of driver to be found. + * + * Find index of the driver, based on @label. + * + * Returns: -1 if no driver based on @label and @drv found, otherwise + * index number of the driver found in the array. + **/ +int find_driver_index(const char * label, const char *drv); extern camera_driver_t camera_v4l2; extern camera_driver_t camera_android; diff --git a/griffin/griffin.c b/griffin/griffin.c index a950d92a08..ff537384c5 100644 --- a/griffin/griffin.c +++ b/griffin/griffin.c @@ -496,6 +496,7 @@ AUDIO /*============================================================ DRIVERS ============================================================ */ +#include "../audio_driver.c" #include "../driver.c" /*============================================================ From 7283ce17bc01792d98a232bc12e431c4aa33764f Mon Sep 17 00:00:00 2001 From: twinaphex Date: Mon, 12 Jan 2015 18:09:31 +0100 Subject: [PATCH 098/156] Move audio_driver.c to audio/ --- Makefile.common | 2 +- audio_driver.c => audio/audio_driver.c | 10 +++++----- audio_driver.h => audio/audio_driver.h | 0 driver.h | 2 +- griffin/griffin.c | 2 +- 5 files changed, 8 insertions(+), 8 deletions(-) rename audio_driver.c => audio/audio_driver.c (98%) rename audio_driver.h => audio/audio_driver.h (100%) diff --git a/Makefile.common b/Makefile.common index fc4548ca24..e285772b92 100644 --- a/Makefile.common +++ b/Makefile.common @@ -97,7 +97,7 @@ OBJ += frontend/frontend.o \ file_ops.o \ libretro-sdk/file/file_path.o \ hash.o \ - audio_driver.o \ + audio/audio_driver.o \ driver.o \ settings.o \ settings_list.o \ diff --git a/audio_driver.c b/audio/audio_driver.c similarity index 98% rename from audio_driver.c rename to audio/audio_driver.c index 30ef88cf48..86d498d3d2 100644 --- a/audio_driver.c +++ b/audio/audio_driver.c @@ -17,11 +17,11 @@ #include #include #include "audio_driver.h" -#include "audio/utils.h" -#include "audio/audio_thread_wrapper.h" -#include "driver.h" -#include "general.h" -#include "retroarch.h" +#include "utils.h" +#include "audio_thread_wrapper.h" +#include "../driver.h" +#include "../general.h" +#include "../retroarch.h" static const audio_driver_t *audio_drivers[] = { #ifdef HAVE_ALSA diff --git a/audio_driver.h b/audio/audio_driver.h similarity index 100% rename from audio_driver.h rename to audio/audio_driver.h diff --git a/driver.h b/driver.h index 72a61ce679..2ecc4e551a 100644 --- a/driver.h +++ b/driver.h @@ -35,7 +35,7 @@ #include "frontend/frontend_context.h" #include -#include "audio_driver.h" +#include "audio/audio_driver.h" #include "menu/menu_driver.h" #include "menu/backend/menu_backend.h" diff --git a/griffin/griffin.c b/griffin/griffin.c index ff537384c5..efe84dd338 100644 --- a/griffin/griffin.c +++ b/griffin/griffin.c @@ -496,7 +496,7 @@ AUDIO /*============================================================ DRIVERS ============================================================ */ -#include "../audio_driver.c" +#include "../audio/audio_driver.c" #include "../driver.c" /*============================================================ From 0e5a9f03fe34ca049f6f82c1dbfa332ca4e7c726 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Mon, 12 Jan 2015 18:26:46 +0100 Subject: [PATCH 099/156] Split up video_driver code to separate file --- Makefile.common | 1 + driver.c | 148 ------------------------ driver.h | 216 +---------------------------------- griffin/griffin.c | 1 + video_driver.c | 167 +++++++++++++++++++++++++++ video_driver.h | 281 ++++++++++++++++++++++++++++++++++++++++++++++ 6 files changed, 451 insertions(+), 363 deletions(-) create mode 100644 video_driver.c create mode 100644 video_driver.h diff --git a/Makefile.common b/Makefile.common index e285772b92..a9b9db40d2 100644 --- a/Makefile.common +++ b/Makefile.common @@ -98,6 +98,7 @@ OBJ += frontend/frontend.o \ libretro-sdk/file/file_path.o \ hash.o \ audio/audio_driver.o \ + video_driver.o \ driver.o \ settings.o \ settings_list.o \ diff --git a/driver.c b/driver.c index 621029a701..1561d26e7a 100644 --- a/driver.c +++ b/driver.c @@ -40,111 +40,6 @@ driver_t driver; -static const video_driver_t *video_drivers[] = { -#ifdef HAVE_OPENGL - &video_gl, -#endif -#ifdef XENON - &video_xenon360, -#endif -#if defined(_XBOX) && (defined(HAVE_D3D8) || defined(HAVE_D3D9)) || defined(HAVE_WIN32_D3D9) - &video_d3d, -#endif -#ifdef SN_TARGET_PSP2 - &video_vita, -#endif -#ifdef PSP - &video_psp1, -#endif -#ifdef HAVE_SDL - &video_sdl, -#endif -#ifdef HAVE_SDL2 - &video_sdl2, -#endif -#ifdef HAVE_XVIDEO - &video_xvideo, -#endif -#ifdef GEKKO - &video_gx, -#endif -#ifdef HAVE_VG - &video_vg, -#endif -#ifdef HAVE_OMAP - &video_omap, -#endif -#ifdef HAVE_EXYNOS - &video_exynos, -#endif - &video_null, - NULL, -}; - -/** - * video_driver_find_handle: - * @index : index of driver to get handle to. - * - * Returns: handle to video driver at index. Can be NULL - * if nothing found. - **/ -static const void *video_driver_find_handle(int index) -{ - const void *drv = video_drivers[index]; - if (!drv) - return NULL; - return drv; -} - -/** - * video_driver_find_ident: - * @index : index of driver to get handle to. - * - * Returns: Human-readable identifier of video driver at index. Can be NULL - * if nothing found. - **/ -static const char *video_driver_find_ident(int index) -{ - const video_driver_t *drv = video_drivers[index]; - if (!drv) - return NULL; - return drv->ident; -} - -/** - * config_get_video_driver_options: - * - * Get an enumerated list of all video driver names, separated by '|'. - * - * Returns: string listing of all video driver names, separated by '|'. - **/ -const char* config_get_video_driver_options(void) -{ - union string_list_elem_attr attr; - unsigned i; - char *options = NULL; - int options_len = 0; - struct string_list *options_l = string_list_new(); - - attr.i = 0; - - for (i = 0; video_driver_find_handle(i); i++) - { - const char *opt = video_driver_find_ident(i); - options_len += strlen(opt) + 1; - string_list_append(options_l, opt, attr); - } - - options = (char*)calloc(options_len, sizeof(char)); - - string_list_join_concat(options, options_len, options_l, "|"); - - string_list_free(options_l); - options_l = NULL; - - return options; -} - static const input_driver_t *input_drivers[] = { #ifdef __CELLOS_LV2__ &input_ps3, @@ -1081,49 +976,6 @@ static void find_menu_driver(void) } #endif -static void find_video_driver(void) -{ - int i; -#if defined(HAVE_OPENGL) && defined(HAVE_FBO) - if (g_extern.system.hw_render_callback.context_type) - { - RARCH_LOG("Using HW render, OpenGL driver forced.\n"); - driver.video = &video_gl; - return; - } -#endif - - if (driver.frontend_ctx && - driver.frontend_ctx->get_video_driver) - { - driver.video = driver.frontend_ctx->get_video_driver(); - - if (driver.video) - return; - RARCH_WARN("Frontend supports get_video_driver() but did not specify one.\n"); - } - - i = find_driver_index("video_driver", g_settings.video.driver); - if (i >= 0) - driver.video = video_driver_find_handle(i); - else - { - unsigned d; - RARCH_ERR("Couldn't find any video driver named \"%s\"\n", - g_settings.video.driver); - RARCH_LOG_OUTPUT("Available video drivers are:\n"); - for (d = 0; video_driver_find_handle(d); d++) - RARCH_LOG_OUTPUT("\t%s\n", video_driver_find_ident(d)); - RARCH_WARN("Going to default to first video driver...\n"); - - driver.video = video_driver_find_handle(0); - - if (!driver.video) - rarch_fail(1, "find_video_driver()"); - } -} - - static void find_input_driver(void) { int i = find_driver_index("input_driver", g_settings.input.driver); diff --git a/driver.h b/driver.h index 2ecc4e551a..3a6950f0e4 100644 --- a/driver.h +++ b/driver.h @@ -25,16 +25,12 @@ #include #include "gfx/scaler/scaler.h" #include "gfx/image/image.h" -#include "gfx/shader/shader_parse.h" #include "input/input_context.h" -#ifdef HAVE_OVERLAY -#include "input/overlay.h" -#endif - #include "frontend/frontend_context.h" #include +#include "video_driver.h" #include "audio/audio_driver.h" #include "menu/menu_driver.h" @@ -137,50 +133,6 @@ enum RARCH_BIND_LIST_END_NULL }; -struct retro_keybind -{ - bool valid; - unsigned id; - const char *desc; - enum retro_key key; - - uint64_t joykey; - /* Default key binding value - for resetting bind to default */ - uint64_t def_joykey; - - uint32_t joyaxis; - uint32_t def_joyaxis; - - /* Used by input_{push,pop}_analog_dpad(). */ - uint32_t orig_joyaxis; - - char joykey_label[256]; - char joyaxis_label[256]; -}; - -typedef struct video_info -{ - unsigned width; - unsigned height; - bool fullscreen; - bool vsync; - bool force_aspect; -#ifdef GEKKO - /* TODO - we can't really have driver system-specific - * variables in here. There should be some - * kind of publicly accessible driver implementation - * video struct for specific things like this. - */ - unsigned viwidth; -#endif - bool vfilter; - bool smooth; - /* Maximum input size: RARCH_SCALE_BASE * input_scale */ - unsigned input_scale; - /* Use 32bit RGBA rather than native XBGR1555. */ - bool rgb32; -} video_info_t; - #define AXIS_NEG(x) (((uint32_t)(x) << 16) | UINT16_C(0xFFFF)) #define AXIS_POS(x) ((uint32_t)(x) | UINT32_C(0xFFFF0000)) #define AXIS_NONE UINT32_C(0xFFFFFFFF) @@ -213,27 +165,6 @@ enum analog_dpad_mode ANALOG_DPAD_LAST }; -typedef struct input_driver -{ - void *(*init)(void); - void (*poll)(void *data); - int16_t (*input_state)(void *data, - const struct retro_keybind **retro_keybinds, - unsigned port, unsigned device, unsigned index, unsigned id); - bool (*key_pressed)(void *data, int key); - void (*free)(void *data); - bool (*set_sensor_state)(void *data, unsigned port, - enum retro_sensor_action action, unsigned rate); - float (*get_sensor_input)(void *data, unsigned port, unsigned id); - uint64_t (*get_capabilities)(void *data); - const char *ident; - - void (*grab_mouse)(void *data, bool state); - bool (*set_rumble)(void *data, unsigned port, - enum retro_rumble_effect effect, uint16_t state); - const rarch_joypad_driver_t *(*get_joypad_driver)(void *data); -} input_driver_t; - typedef struct input_osk_driver { void *(*init)(size_t size); @@ -285,118 +216,6 @@ typedef struct location_driver const char *ident; } location_driver_t; -struct rarch_viewport; - -struct font_params -{ - float x; - float y; - float scale; - /* Drop shadow color multiplier. */ - float drop_mod; - /* Drop shadow offset. - * If both are 0, no drop shadow will be rendered. */ - int drop_x, drop_y; - /* ABGR. Use the macros. */ - uint32_t color; - bool full_screen; -}; -#define FONT_COLOR_RGBA(r, g, b, a) (((r) << 0) | ((g) << 8) | ((b) << 16) | ((a) << 24)) -#define FONT_COLOR_GET_RED(col) (((col) >> 0) & 0xff) -#define FONT_COLOR_GET_GREEN(col) (((col) >> 8) & 0xff) -#define FONT_COLOR_GET_BLUE(col) (((col) >> 16) & 0xff) -#define FONT_COLOR_GET_ALPHA(col) (((col) >> 24) & 0xff) - -/* Optionally implemented interface to poke more - * deeply into video driver. */ - -typedef struct video_poke_interface -{ - void (*set_filtering)(void *data, unsigned index, bool smooth); -#ifdef HAVE_FBO - uintptr_t (*get_current_framebuffer)(void *data); - retro_proc_address_t (*get_proc_address)(void *data, const char *sym); -#endif - void (*set_aspect_ratio)(void *data, unsigned aspectratio_index); - void (*apply_state_changes)(void *data); - -#ifdef HAVE_MENU - /* Update texture. */ - void (*set_texture_frame)(void *data, const void *frame, bool rgb32, - unsigned width, unsigned height, float alpha); - - /* Enable or disable rendering. */ - void (*set_texture_enable)(void *data, bool enable, bool full_screen); -#endif - void (*set_osd_msg)(void *data, const char *msg, - const struct font_params *params, void *font); - - void (*show_mouse)(void *data, bool state); - void (*grab_mouse_toggle)(void *data); - - struct gfx_shader *(*get_current_shader)(void *data); -} video_poke_interface_t; - -typedef struct video_driver -{ - /* Should the video driver act as an input driver as well? - * The video initialization might preinitialize an input driver - * to override the settings in case the video driver relies on - * input driver for event handling. */ - void *(*init)(const video_info_t *video, const input_driver_t **input, - void **input_data); - - /* msg is for showing a message on the screen along with the video frame. */ - bool (*frame)(void *data, const void *frame, unsigned width, - unsigned height, unsigned pitch, const char *msg); - - /* Should we care about syncing to vblank? Fast forwarding. */ - void (*set_nonblock_state)(void *data, bool toggle); - - /* Is the window still active? */ - bool (*alive)(void *data); - - /* Does the window have focus? */ - bool (*focus)(void *data); - - /* Does the graphics conext support windowed mode? */ - bool (*has_windowed)(void *data); - - /* Sets shader. Might not be implemented. Will be moved to - * poke_interface later. */ - bool (*set_shader)(void *data, enum rarch_shader_type type, - const char *path); - - /* Frees driver. */ - void (*free)(void *data); - - /* Human-readable identifier. */ - const char *ident; - - void (*set_rotation)(void *data, unsigned rotation); - void (*viewport_info)(void *data, struct rarch_viewport *vp); - - /* Reads out in BGR byte order (24bpp). */ - bool (*read_viewport)(void *data, uint8_t *buffer); - -#ifdef HAVE_OVERLAY - void (*overlay_interface)(void *data, const video_overlay_interface_t **iface); -#endif - void (*poke_interface)(void *data, const video_poke_interface_t **iface); - unsigned (*wrap_type_to_enum)(enum gfx_wrap_type type); -} video_driver_t; - -enum rarch_display_type -{ - /* Non-bindable types like consoles, KMS, VideoCore, etc. */ - RARCH_DISPLAY_NONE = 0, - /* video_display => Display*, video_window => Window */ - RARCH_DISPLAY_X11, - /* video_display => N/A, video_window => HWND */ - RARCH_DISPLAY_WIN32, - RARCH_DISPLAY_OSX -}; - /* Flags for init_drivers/uninit_drivers */ enum { @@ -781,39 +600,6 @@ bool driver_update_system_av_info(const struct retro_system_av_info *info); extern driver_t driver; -/* Backends */ -extern video_driver_t video_gl; -extern video_driver_t video_psp1; -extern video_driver_t video_vita; -extern video_driver_t video_d3d; -extern video_driver_t video_gx; -extern video_driver_t video_xenon360; -extern video_driver_t video_xvideo; -extern video_driver_t video_xdk_d3d; -extern video_driver_t video_sdl; -extern video_driver_t video_sdl2; -extern video_driver_t video_vg; -extern video_driver_t video_omap; -extern video_driver_t video_exynos; -extern video_driver_t video_null; - -extern input_driver_t input_android; -extern input_driver_t input_sdl; -extern input_driver_t input_dinput; -extern input_driver_t input_x; -extern input_driver_t input_wayland; -extern input_driver_t input_ps3; -extern input_driver_t input_psp; -extern input_driver_t input_xenon360; -extern input_driver_t input_gx; -extern input_driver_t input_xinput; -extern input_driver_t input_linuxraw; -extern input_driver_t input_udev; -extern input_driver_t input_apple; -extern input_driver_t input_qnx; -extern input_driver_t input_rwebinput; -extern input_driver_t input_null; - /** * config_get_input_driver_options: * diff --git a/griffin/griffin.c b/griffin/griffin.c index efe84dd338..4a3ec780d6 100644 --- a/griffin/griffin.c +++ b/griffin/griffin.c @@ -496,6 +496,7 @@ AUDIO /*============================================================ DRIVERS ============================================================ */ +#include "../video_driver.c" #include "../audio/audio_driver.c" #include "../driver.c" diff --git a/video_driver.c b/video_driver.c new file mode 100644 index 0000000000..42ba784877 --- /dev/null +++ b/video_driver.c @@ -0,0 +1,167 @@ +/* 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 . + */ + +#include +#include +#include "video_driver.h" +#include "general.h" + +static const video_driver_t *video_drivers[] = { +#ifdef HAVE_OPENGL + &video_gl, +#endif +#ifdef XENON + &video_xenon360, +#endif +#if defined(_XBOX) && (defined(HAVE_D3D8) || defined(HAVE_D3D9)) || defined(HAVE_WIN32_D3D9) + &video_d3d, +#endif +#ifdef SN_TARGET_PSP2 + &video_vita, +#endif +#ifdef PSP + &video_psp1, +#endif +#ifdef HAVE_SDL + &video_sdl, +#endif +#ifdef HAVE_SDL2 + &video_sdl2, +#endif +#ifdef HAVE_XVIDEO + &video_xvideo, +#endif +#ifdef GEKKO + &video_gx, +#endif +#ifdef HAVE_VG + &video_vg, +#endif +#ifdef HAVE_OMAP + &video_omap, +#endif +#ifdef HAVE_EXYNOS + &video_exynos, +#endif + &video_null, + NULL, +}; + +/** + * video_driver_find_handle: + * @index : index of driver to get handle to. + * + * Returns: handle to video driver at index. Can be NULL + * if nothing found. + **/ +const void *video_driver_find_handle(int index) +{ + const void *drv = video_drivers[index]; + if (!drv) + return NULL; + return drv; +} + +/** + * video_driver_find_ident: + * @index : index of driver to get handle to. + * + * Returns: Human-readable identifier of video driver at index. Can be NULL + * if nothing found. + **/ +const char *video_driver_find_ident(int index) +{ + const video_driver_t *drv = video_drivers[index]; + if (!drv) + return NULL; + return drv->ident; +} + +/** + * config_get_video_driver_options: + * + * Get an enumerated list of all video driver names, separated by '|'. + * + * Returns: string listing of all video driver names, separated by '|'. + **/ +const char* config_get_video_driver_options(void) +{ + union string_list_elem_attr attr; + unsigned i; + char *options = NULL; + int options_len = 0; + struct string_list *options_l = string_list_new(); + + attr.i = 0; + + for (i = 0; video_driver_find_handle(i); i++) + { + const char *opt = video_driver_find_ident(i); + options_len += strlen(opt) + 1; + string_list_append(options_l, opt, attr); + } + + options = (char*)calloc(options_len, sizeof(char)); + + string_list_join_concat(options, options_len, options_l, "|"); + + string_list_free(options_l); + options_l = NULL; + + return options; +} + +void find_video_driver(void) +{ + int i; +#if defined(HAVE_OPENGL) && defined(HAVE_FBO) + if (g_extern.system.hw_render_callback.context_type) + { + RARCH_LOG("Using HW render, OpenGL driver forced.\n"); + driver.video = &video_gl; + return; + } +#endif + + if (driver.frontend_ctx && + driver.frontend_ctx->get_video_driver) + { + driver.video = driver.frontend_ctx->get_video_driver(); + + if (driver.video) + return; + RARCH_WARN("Frontend supports get_video_driver() but did not specify one.\n"); + } + + i = find_driver_index("video_driver", g_settings.video.driver); + if (i >= 0) + driver.video = video_driver_find_handle(i); + else + { + unsigned d; + RARCH_ERR("Couldn't find any video driver named \"%s\"\n", + g_settings.video.driver); + RARCH_LOG_OUTPUT("Available video drivers are:\n"); + for (d = 0; video_driver_find_handle(d); d++) + RARCH_LOG_OUTPUT("\t%s\n", video_driver_find_ident(d)); + RARCH_WARN("Going to default to first video driver...\n"); + + driver.video = video_driver_find_handle(0); + + if (!driver.video) + rarch_fail(1, "find_video_driver()"); + } +} diff --git a/video_driver.h b/video_driver.h new file mode 100644 index 0000000000..d70feb4d70 --- /dev/null +++ b/video_driver.h @@ -0,0 +1,281 @@ +/* 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 . + */ + +#ifndef __VIDEO_DRIVER__H +#define __VIDEO_DRIVER__H + +#include +#include +#include +#include +#include "libretro.h" + +#include "input/input_context.h" +#include "gfx/shader/shader_parse.h" + +#ifdef HAVE_OVERLAY +#include "input/overlay.h" +#endif + +#ifdef __cplusplus +extern "C" { +#endif + +struct retro_keybind +{ + bool valid; + unsigned id; + const char *desc; + enum retro_key key; + + uint64_t joykey; + /* Default key binding value - for resetting bind to default */ + uint64_t def_joykey; + + uint32_t joyaxis; + uint32_t def_joyaxis; + + /* Used by input_{push,pop}_analog_dpad(). */ + uint32_t orig_joyaxis; + + char joykey_label[256]; + char joyaxis_label[256]; +}; + +typedef struct input_driver +{ + void *(*init)(void); + void (*poll)(void *data); + int16_t (*input_state)(void *data, + const struct retro_keybind **retro_keybinds, + unsigned port, unsigned device, unsigned index, unsigned id); + bool (*key_pressed)(void *data, int key); + void (*free)(void *data); + bool (*set_sensor_state)(void *data, unsigned port, + enum retro_sensor_action action, unsigned rate); + float (*get_sensor_input)(void *data, unsigned port, unsigned id); + uint64_t (*get_capabilities)(void *data); + const char *ident; + + void (*grab_mouse)(void *data, bool state); + bool (*set_rumble)(void *data, unsigned port, + enum retro_rumble_effect effect, uint16_t state); + const rarch_joypad_driver_t *(*get_joypad_driver)(void *data); +} input_driver_t; + +extern input_driver_t input_android; +extern input_driver_t input_sdl; +extern input_driver_t input_dinput; +extern input_driver_t input_x; +extern input_driver_t input_wayland; +extern input_driver_t input_ps3; +extern input_driver_t input_psp; +extern input_driver_t input_xenon360; +extern input_driver_t input_gx; +extern input_driver_t input_xinput; +extern input_driver_t input_linuxraw; +extern input_driver_t input_udev; +extern input_driver_t input_apple; +extern input_driver_t input_qnx; +extern input_driver_t input_rwebinput; +extern input_driver_t input_null; + +struct rarch_viewport; + +typedef struct video_info +{ + unsigned width; + unsigned height; + bool fullscreen; + bool vsync; + bool force_aspect; +#ifdef GEKKO + /* TODO - we can't really have driver system-specific + * variables in here. There should be some + * kind of publicly accessible driver implementation + * video struct for specific things like this. + */ + unsigned viwidth; +#endif + bool vfilter; + bool smooth; + /* Maximum input size: RARCH_SCALE_BASE * input_scale */ + unsigned input_scale; + /* Use 32bit RGBA rather than native XBGR1555. */ + bool rgb32; +} video_info_t; + +struct font_params +{ + float x; + float y; + float scale; + /* Drop shadow color multiplier. */ + float drop_mod; + /* Drop shadow offset. + * If both are 0, no drop shadow will be rendered. */ + int drop_x, drop_y; + /* ABGR. Use the macros. */ + uint32_t color; + bool full_screen; +}; + + +#define FONT_COLOR_RGBA(r, g, b, a) (((r) << 0) | ((g) << 8) | ((b) << 16) | ((a) << 24)) +#define FONT_COLOR_GET_RED(col) (((col) >> 0) & 0xff) +#define FONT_COLOR_GET_GREEN(col) (((col) >> 8) & 0xff) +#define FONT_COLOR_GET_BLUE(col) (((col) >> 16) & 0xff) +#define FONT_COLOR_GET_ALPHA(col) (((col) >> 24) & 0xff) + +/* Optionally implemented interface to poke more + * deeply into video driver. */ + +typedef struct video_poke_interface +{ + void (*set_filtering)(void *data, unsigned index, bool smooth); +#ifdef HAVE_FBO + uintptr_t (*get_current_framebuffer)(void *data); + retro_proc_address_t (*get_proc_address)(void *data, const char *sym); +#endif + void (*set_aspect_ratio)(void *data, unsigned aspectratio_index); + void (*apply_state_changes)(void *data); + +#ifdef HAVE_MENU + /* Update texture. */ + void (*set_texture_frame)(void *data, const void *frame, bool rgb32, + unsigned width, unsigned height, float alpha); + + /* Enable or disable rendering. */ + void (*set_texture_enable)(void *data, bool enable, bool full_screen); +#endif + void (*set_osd_msg)(void *data, const char *msg, + const struct font_params *params, void *font); + + void (*show_mouse)(void *data, bool state); + void (*grab_mouse_toggle)(void *data); + + struct gfx_shader *(*get_current_shader)(void *data); +} video_poke_interface_t; + +typedef struct video_driver +{ + /* Should the video driver act as an input driver as well? + * The video initialization might preinitialize an input driver + * to override the settings in case the video driver relies on + * input driver for event handling. */ + void *(*init)(const video_info_t *video, const input_driver_t **input, + void **input_data); + + /* msg is for showing a message on the screen along with the video frame. */ + bool (*frame)(void *data, const void *frame, unsigned width, + unsigned height, unsigned pitch, const char *msg); + + /* Should we care about syncing to vblank? Fast forwarding. */ + void (*set_nonblock_state)(void *data, bool toggle); + + /* Is the window still active? */ + bool (*alive)(void *data); + + /* Does the window have focus? */ + bool (*focus)(void *data); + + /* Does the graphics conext support windowed mode? */ + bool (*has_windowed)(void *data); + + /* Sets shader. Might not be implemented. Will be moved to + * poke_interface later. */ + bool (*set_shader)(void *data, enum rarch_shader_type type, + const char *path); + + /* Frees driver. */ + void (*free)(void *data); + + /* Human-readable identifier. */ + const char *ident; + + void (*set_rotation)(void *data, unsigned rotation); + void (*viewport_info)(void *data, struct rarch_viewport *vp); + + /* Reads out in BGR byte order (24bpp). */ + bool (*read_viewport)(void *data, uint8_t *buffer); + +#ifdef HAVE_OVERLAY + void (*overlay_interface)(void *data, const video_overlay_interface_t **iface); +#endif + void (*poke_interface)(void *data, const video_poke_interface_t **iface); + unsigned (*wrap_type_to_enum)(enum gfx_wrap_type type); +} video_driver_t; + +enum rarch_display_type +{ + /* Non-bindable types like consoles, KMS, VideoCore, etc. */ + RARCH_DISPLAY_NONE = 0, + /* video_display => Display*, video_window => Window */ + RARCH_DISPLAY_X11, + /* video_display => N/A, video_window => HWND */ + RARCH_DISPLAY_WIN32, + RARCH_DISPLAY_OSX +}; + +extern video_driver_t video_gl; +extern video_driver_t video_psp1; +extern video_driver_t video_vita; +extern video_driver_t video_d3d; +extern video_driver_t video_gx; +extern video_driver_t video_xenon360; +extern video_driver_t video_xvideo; +extern video_driver_t video_xdk_d3d; +extern video_driver_t video_sdl; +extern video_driver_t video_sdl2; +extern video_driver_t video_vg; +extern video_driver_t video_omap; +extern video_driver_t video_exynos; +extern video_driver_t video_null; + +/** + * video_driver_find_handle: + * @index : index of driver to get handle to. + * + * Returns: handle to video driver at index. Can be NULL + * if nothing found. + **/ +const void *video_driver_find_handle(int index); + +/** + * video_driver_find_ident: + * @index : index of driver to get handle to. + * + * Returns: Human-readable identifier of video driver at index. Can be NULL + * if nothing found. + **/ +const char *video_driver_find_ident(int index); + +/** + * config_get_video_driver_options: + * + * Get an enumerated list of all video driver names, separated by '|'. + * + * Returns: string listing of all video driver names, separated by '|'. + **/ +const char* config_get_video_driver_options(void); + +void find_video_driver(void); + +#ifdef __cplusplus +} +#endif + +#endif From 7f484edc982430182a9091bfd4e81972923c540b Mon Sep 17 00:00:00 2001 From: twinaphex Date: Mon, 12 Jan 2015 18:28:32 +0100 Subject: [PATCH 100/156] Move video_driver.c to gfx/ --- Makefile.common | 2 +- driver.h | 2 +- video_driver.c => gfx/video_driver.c | 2 +- video_driver.h => gfx/video_driver.h | 8 ++++---- griffin/griffin.c | 2 +- 5 files changed, 8 insertions(+), 8 deletions(-) rename video_driver.c => gfx/video_driver.c (99%) rename video_driver.h => gfx/video_driver.h (98%) diff --git a/Makefile.common b/Makefile.common index a9b9db40d2..aee0f662dc 100644 --- a/Makefile.common +++ b/Makefile.common @@ -98,7 +98,7 @@ OBJ += frontend/frontend.o \ libretro-sdk/file/file_path.o \ hash.o \ audio/audio_driver.o \ - video_driver.o \ + gfx/video_driver.o \ driver.o \ settings.o \ settings_list.o \ diff --git a/driver.h b/driver.h index 3a6950f0e4..18fb2f8c80 100644 --- a/driver.h +++ b/driver.h @@ -30,7 +30,7 @@ #include "frontend/frontend_context.h" #include -#include "video_driver.h" +#include "gfx/video_driver.h" #include "audio/audio_driver.h" #include "menu/menu_driver.h" diff --git a/video_driver.c b/gfx/video_driver.c similarity index 99% rename from video_driver.c rename to gfx/video_driver.c index 42ba784877..d23fadca4c 100644 --- a/video_driver.c +++ b/gfx/video_driver.c @@ -17,7 +17,7 @@ #include #include #include "video_driver.h" -#include "general.h" +#include "../general.h" static const video_driver_t *video_drivers[] = { #ifdef HAVE_OPENGL diff --git a/video_driver.h b/gfx/video_driver.h similarity index 98% rename from video_driver.h rename to gfx/video_driver.h index d70feb4d70..0954205f71 100644 --- a/video_driver.h +++ b/gfx/video_driver.h @@ -21,13 +21,13 @@ #include #include #include -#include "libretro.h" +#include "../libretro.h" -#include "input/input_context.h" -#include "gfx/shader/shader_parse.h" +#include "../input/input_context.h" +#include "../gfx/shader/shader_parse.h" #ifdef HAVE_OVERLAY -#include "input/overlay.h" +#include "../input/overlay.h" #endif #ifdef __cplusplus diff --git a/griffin/griffin.c b/griffin/griffin.c index 4a3ec780d6..b62f687643 100644 --- a/griffin/griffin.c +++ b/griffin/griffin.c @@ -496,7 +496,7 @@ AUDIO /*============================================================ DRIVERS ============================================================ */ -#include "../video_driver.c" +#include "../gfx/video_driver.c" #include "../audio/audio_driver.c" #include "../driver.c" From 07a7386c9d5f0e8a82679b318aa87e711d5a14b9 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Mon, 12 Jan 2015 18:37:50 +0100 Subject: [PATCH 101/156] Split up input_driver code to separate file - input_driver.c --- Makefile.common | 1 + driver.c | 134 --------------------------------------- driver.h | 10 --- gfx/video_driver.h | 66 +------------------ griffin/griffin.c | 1 + input_driver.c | 155 +++++++++++++++++++++++++++++++++++++++++++++ input_driver.h | 128 +++++++++++++++++++++++++++++++++++++ 7 files changed, 287 insertions(+), 208 deletions(-) create mode 100644 input_driver.c create mode 100644 input_driver.h diff --git a/Makefile.common b/Makefile.common index aee0f662dc..7438ea5fd1 100644 --- a/Makefile.common +++ b/Makefile.common @@ -98,6 +98,7 @@ OBJ += frontend/frontend.o \ libretro-sdk/file/file_path.o \ hash.o \ audio/audio_driver.o \ + input_driver.o \ gfx/video_driver.o \ driver.o \ settings.o \ diff --git a/driver.c b/driver.c index 1561d26e7a..7d0b5297e6 100644 --- a/driver.c +++ b/driver.c @@ -40,118 +40,6 @@ driver_t driver; -static const input_driver_t *input_drivers[] = { -#ifdef __CELLOS_LV2__ - &input_ps3, -#endif -#if defined(SN_TARGET_PSP2) || defined(PSP) - &input_psp, -#endif -#if defined(HAVE_SDL) || defined(HAVE_SDL2) - &input_sdl, -#endif -#ifdef HAVE_DINPUT - &input_dinput, -#endif -#ifdef HAVE_X11 - &input_x, -#endif -#ifdef XENON - &input_xenon360, -#endif -#if defined(HAVE_XINPUT2) || defined(HAVE_XINPUT_XBOX1) - &input_xinput, -#endif -#ifdef GEKKO - &input_gx, -#endif -#ifdef ANDROID - &input_android, -#endif -#ifdef HAVE_UDEV - &input_udev, -#endif -#if defined(__linux__) && !defined(ANDROID) - &input_linuxraw, -#endif -#if defined(IOS) || defined(OSX) - /* Don't use __APPLE__ as it breaks basic SDL builds */ - &input_apple, -#endif -#ifdef __QNX__ - &input_qnx, -#endif -#ifdef EMSCRIPTEN - &input_rwebinput, -#endif - &input_null, - NULL, -}; - -/** - * input_driver_find_handle: - * @index : index of driver to get handle to. - * - * Returns: handle to input driver at index. Can be NULL - * if nothing found. - **/ -static const void *input_driver_find_handle(int index) -{ - const void *drv = input_drivers[index]; - if (!drv) - return NULL; - return drv; -} - -/** - * input_driver_find_ident: - * @index : index of driver to get handle to. - * - * Returns: Human-readable identifier of input driver at index. Can be NULL - * if nothing found. - **/ -static const char *input_driver_find_ident(int index) -{ - const input_driver_t *drv = input_drivers[index]; - if (!drv) - return NULL; - return drv->ident; -} - -/** - * config_get_input_driver_options: - * - * Get an enumerated list of all input driver names, separated by '|'. - * - * Returns: string listing of all input driver names, separated by '|'. - **/ -const char* config_get_input_driver_options(void) -{ - union string_list_elem_attr attr; - unsigned i; - char *options = NULL; - int options_len = 0; - struct string_list *options_l = string_list_new(); - - attr.i = 0; - - for (i = 0; input_driver_find_handle(i); i++) - { - const char *opt = input_driver_find_ident(i); - options_len += strlen(opt) + 1; - string_list_append(options_l, opt, attr); - } - - options = (char*)calloc(options_len, sizeof(char)); - - string_list_join_concat(options, options_len, options_l, "|"); - - string_list_free(options_l); - options_l = NULL; - - return options; -} - static const input_osk_driver_t *osk_drivers[] = { #ifdef __CELLOS_LV2__ &input_ps3_osk, @@ -976,28 +864,6 @@ static void find_menu_driver(void) } #endif -static void find_input_driver(void) -{ - int i = find_driver_index("input_driver", g_settings.input.driver); - if (i >= 0) - driver.input = input_driver_find_handle(i); - else - { - unsigned d; - RARCH_ERR("Couldn't find any input driver named \"%s\"\n", - g_settings.input.driver); - RARCH_LOG_OUTPUT("Available input drivers are:\n"); - for (d = 0; input_driver_find_handle(d); d++) - RARCH_LOG_OUTPUT("\t%s\n", input_driver_find_ident(d)); - RARCH_WARN("Going to default to first input driver...\n"); - - driver.input = input_driver_find_handle(0); - - if (!driver.input) - rarch_fail(1, "find_input_driver()"); - } -} - /** * init_drivers_pre: * diff --git a/driver.h b/driver.h index 18fb2f8c80..e0683f850b 100644 --- a/driver.h +++ b/driver.h @@ -25,7 +25,6 @@ #include #include "gfx/scaler/scaler.h" #include "gfx/image/image.h" -#include "input/input_context.h" #include "frontend/frontend_context.h" #include @@ -600,15 +599,6 @@ bool driver_update_system_av_info(const struct retro_system_av_info *info); extern driver_t driver; -/** - * config_get_input_driver_options: - * - * Get an enumerated list of all input driver names, separated by '|'. - * - * Returns: string listing of all input driver names, separated by '|'. - **/ -const char* config_get_input_driver_options(void); - /** * config_get_camera_driver_options: * diff --git a/gfx/video_driver.h b/gfx/video_driver.h index 0954205f71..b5bee64b64 100644 --- a/gfx/video_driver.h +++ b/gfx/video_driver.h @@ -23,76 +23,14 @@ #include #include "../libretro.h" -#include "../input/input_context.h" -#include "../gfx/shader/shader_parse.h" +#include "../input_driver.h" -#ifdef HAVE_OVERLAY -#include "../input/overlay.h" -#endif +#include "../gfx/shader/shader_parse.h" #ifdef __cplusplus extern "C" { #endif -struct retro_keybind -{ - bool valid; - unsigned id; - const char *desc; - enum retro_key key; - - uint64_t joykey; - /* Default key binding value - for resetting bind to default */ - uint64_t def_joykey; - - uint32_t joyaxis; - uint32_t def_joyaxis; - - /* Used by input_{push,pop}_analog_dpad(). */ - uint32_t orig_joyaxis; - - char joykey_label[256]; - char joyaxis_label[256]; -}; - -typedef struct input_driver -{ - void *(*init)(void); - void (*poll)(void *data); - int16_t (*input_state)(void *data, - const struct retro_keybind **retro_keybinds, - unsigned port, unsigned device, unsigned index, unsigned id); - bool (*key_pressed)(void *data, int key); - void (*free)(void *data); - bool (*set_sensor_state)(void *data, unsigned port, - enum retro_sensor_action action, unsigned rate); - float (*get_sensor_input)(void *data, unsigned port, unsigned id); - uint64_t (*get_capabilities)(void *data); - const char *ident; - - void (*grab_mouse)(void *data, bool state); - bool (*set_rumble)(void *data, unsigned port, - enum retro_rumble_effect effect, uint16_t state); - const rarch_joypad_driver_t *(*get_joypad_driver)(void *data); -} input_driver_t; - -extern input_driver_t input_android; -extern input_driver_t input_sdl; -extern input_driver_t input_dinput; -extern input_driver_t input_x; -extern input_driver_t input_wayland; -extern input_driver_t input_ps3; -extern input_driver_t input_psp; -extern input_driver_t input_xenon360; -extern input_driver_t input_gx; -extern input_driver_t input_xinput; -extern input_driver_t input_linuxraw; -extern input_driver_t input_udev; -extern input_driver_t input_apple; -extern input_driver_t input_qnx; -extern input_driver_t input_rwebinput; -extern input_driver_t input_null; - struct rarch_viewport; typedef struct video_info diff --git a/griffin/griffin.c b/griffin/griffin.c index b62f687643..b91c5b808d 100644 --- a/griffin/griffin.c +++ b/griffin/griffin.c @@ -497,6 +497,7 @@ AUDIO DRIVERS ============================================================ */ #include "../gfx/video_driver.c" +#include "../input_driver.c" #include "../audio/audio_driver.c" #include "../driver.c" diff --git a/input_driver.c b/input_driver.c new file mode 100644 index 0000000000..1eef700757 --- /dev/null +++ b/input_driver.c @@ -0,0 +1,155 @@ +/* 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 . + */ + +#include +#include +#include "input_driver.h" +#include "driver.h" +#include "general.h" + +static const input_driver_t *input_drivers[] = { +#ifdef __CELLOS_LV2__ + &input_ps3, +#endif +#if defined(SN_TARGET_PSP2) || defined(PSP) + &input_psp, +#endif +#if defined(HAVE_SDL) || defined(HAVE_SDL2) + &input_sdl, +#endif +#ifdef HAVE_DINPUT + &input_dinput, +#endif +#ifdef HAVE_X11 + &input_x, +#endif +#ifdef XENON + &input_xenon360, +#endif +#if defined(HAVE_XINPUT2) || defined(HAVE_XINPUT_XBOX1) + &input_xinput, +#endif +#ifdef GEKKO + &input_gx, +#endif +#ifdef ANDROID + &input_android, +#endif +#ifdef HAVE_UDEV + &input_udev, +#endif +#if defined(__linux__) && !defined(ANDROID) + &input_linuxraw, +#endif +#if defined(IOS) || defined(OSX) + /* Don't use __APPLE__ as it breaks basic SDL builds */ + &input_apple, +#endif +#ifdef __QNX__ + &input_qnx, +#endif +#ifdef EMSCRIPTEN + &input_rwebinput, +#endif + &input_null, + NULL, +}; + +/** + * input_driver_find_handle: + * @index : index of driver to get handle to. + * + * Returns: handle to input driver at index. Can be NULL + * if nothing found. + **/ +const void *input_driver_find_handle(int index) +{ + const void *drv = input_drivers[index]; + if (!drv) + return NULL; + return drv; +} + +/** + * input_driver_find_ident: + * @index : index of driver to get handle to. + * + * Returns: Human-readable identifier of input driver at index. Can be NULL + * if nothing found. + **/ +const char *input_driver_find_ident(int index) +{ + const input_driver_t *drv = input_drivers[index]; + if (!drv) + return NULL; + return drv->ident; +} + +/** + * config_get_input_driver_options: + * + * Get an enumerated list of all input driver names, separated by '|'. + * + * Returns: string listing of all input driver names, separated by '|'. + **/ +const char* config_get_input_driver_options(void) +{ + union string_list_elem_attr attr; + unsigned i; + char *options = NULL; + int options_len = 0; + struct string_list *options_l = string_list_new(); + + attr.i = 0; + + for (i = 0; input_driver_find_handle(i); i++) + { + const char *opt = input_driver_find_ident(i); + options_len += strlen(opt) + 1; + string_list_append(options_l, opt, attr); + } + + options = (char*)calloc(options_len, sizeof(char)); + + string_list_join_concat(options, options_len, options_l, "|"); + + string_list_free(options_l); + options_l = NULL; + + return options; +} + +void find_input_driver(void) +{ + int i = find_driver_index("input_driver", g_settings.input.driver); + if (i >= 0) + driver.input = input_driver_find_handle(i); + else + { + unsigned d; + RARCH_ERR("Couldn't find any input driver named \"%s\"\n", + g_settings.input.driver); + RARCH_LOG_OUTPUT("Available input drivers are:\n"); + for (d = 0; input_driver_find_handle(d); d++) + RARCH_LOG_OUTPUT("\t%s\n", input_driver_find_ident(d)); + RARCH_WARN("Going to default to first input driver...\n"); + + driver.input = input_driver_find_handle(0); + + if (!driver.input) + rarch_fail(1, "find_input_driver()"); + } +} diff --git a/input_driver.h b/input_driver.h new file mode 100644 index 0000000000..6403d491d6 --- /dev/null +++ b/input_driver.h @@ -0,0 +1,128 @@ +/* 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 . + */ + +#ifndef __INPUT_DRIVER__H +#define __INPUT_DRIVER__H + +#include +#include +#include +#include +#include "libretro.h" + +#include "input/input_context.h" + +#ifdef HAVE_OVERLAY +#include "input/overlay.h" +#endif + +#ifdef __cplusplus +extern "C" { +#endif + +struct retro_keybind +{ + bool valid; + unsigned id; + const char *desc; + enum retro_key key; + + uint64_t joykey; + /* Default key binding value - for resetting bind to default */ + uint64_t def_joykey; + + uint32_t joyaxis; + uint32_t def_joyaxis; + + /* Used by input_{push,pop}_analog_dpad(). */ + uint32_t orig_joyaxis; + + char joykey_label[256]; + char joyaxis_label[256]; +}; + +typedef struct input_driver +{ + void *(*init)(void); + void (*poll)(void *data); + int16_t (*input_state)(void *data, + const struct retro_keybind **retro_keybinds, + unsigned port, unsigned device, unsigned index, unsigned id); + bool (*key_pressed)(void *data, int key); + void (*free)(void *data); + bool (*set_sensor_state)(void *data, unsigned port, + enum retro_sensor_action action, unsigned rate); + float (*get_sensor_input)(void *data, unsigned port, unsigned id); + uint64_t (*get_capabilities)(void *data); + const char *ident; + + void (*grab_mouse)(void *data, bool state); + bool (*set_rumble)(void *data, unsigned port, + enum retro_rumble_effect effect, uint16_t state); + const rarch_joypad_driver_t *(*get_joypad_driver)(void *data); +} input_driver_t; + +extern input_driver_t input_android; +extern input_driver_t input_sdl; +extern input_driver_t input_dinput; +extern input_driver_t input_x; +extern input_driver_t input_wayland; +extern input_driver_t input_ps3; +extern input_driver_t input_psp; +extern input_driver_t input_xenon360; +extern input_driver_t input_gx; +extern input_driver_t input_xinput; +extern input_driver_t input_linuxraw; +extern input_driver_t input_udev; +extern input_driver_t input_apple; +extern input_driver_t input_qnx; +extern input_driver_t input_rwebinput; +extern input_driver_t input_null; + +/** + * input_driver_find_handle: + * @index : index of driver to get handle to. + * + * Returns: handle to input driver at index. Can be NULL + * if nothing found. + **/ +const void *input_driver_find_handle(int index); + +/** + * input_driver_find_ident: + * @index : index of driver to get handle to. + * + * Returns: Human-readable identifier of input driver at index. Can be NULL + * if nothing found. + **/ +const char *input_driver_find_ident(int index); + +/** + * config_get_input_driver_options: + * + * Get an enumerated list of all input driver names, separated by '|'. + * + * Returns: string listing of all input driver names, separated by '|'. + **/ +const char* config_get_input_driver_options(void); + +void find_input_driver(void); + +#ifdef __cplusplus +} +#endif + +#endif From 487c5f58de3d42574bf3c70618adef1de24371e0 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Mon, 12 Jan 2015 18:39:27 +0100 Subject: [PATCH 102/156] Move input_driver.c to input/ --- Makefile.common | 2 +- gfx/video_driver.h | 2 +- griffin/griffin.c | 2 +- input_driver.c => input/input_driver.c | 4 ++-- input_driver.h => input/input_driver.h | 6 +++--- 5 files changed, 8 insertions(+), 8 deletions(-) rename input_driver.c => input/input_driver.c (98%) rename input_driver.h => input/input_driver.h (97%) diff --git a/Makefile.common b/Makefile.common index 7438ea5fd1..fe562faed4 100644 --- a/Makefile.common +++ b/Makefile.common @@ -98,7 +98,7 @@ OBJ += frontend/frontend.o \ libretro-sdk/file/file_path.o \ hash.o \ audio/audio_driver.o \ - input_driver.o \ + input/input_driver.o \ gfx/video_driver.o \ driver.o \ settings.o \ diff --git a/gfx/video_driver.h b/gfx/video_driver.h index b5bee64b64..6448d7a728 100644 --- a/gfx/video_driver.h +++ b/gfx/video_driver.h @@ -23,7 +23,7 @@ #include #include "../libretro.h" -#include "../input_driver.h" +#include "../input/input_driver.h" #include "../gfx/shader/shader_parse.h" diff --git a/griffin/griffin.c b/griffin/griffin.c index b91c5b808d..8f0494612b 100644 --- a/griffin/griffin.c +++ b/griffin/griffin.c @@ -497,7 +497,7 @@ AUDIO DRIVERS ============================================================ */ #include "../gfx/video_driver.c" -#include "../input_driver.c" +#include "../input/input_driver.c" #include "../audio/audio_driver.c" #include "../driver.c" diff --git a/input_driver.c b/input/input_driver.c similarity index 98% rename from input_driver.c rename to input/input_driver.c index 1eef700757..0784929532 100644 --- a/input_driver.c +++ b/input/input_driver.c @@ -17,8 +17,8 @@ #include #include #include "input_driver.h" -#include "driver.h" -#include "general.h" +#include "../driver.h" +#include "../general.h" static const input_driver_t *input_drivers[] = { #ifdef __CELLOS_LV2__ diff --git a/input_driver.h b/input/input_driver.h similarity index 97% rename from input_driver.h rename to input/input_driver.h index 6403d491d6..5d5fa21cd7 100644 --- a/input_driver.h +++ b/input/input_driver.h @@ -21,12 +21,12 @@ #include #include #include -#include "libretro.h" +#include "../libretro.h" -#include "input/input_context.h" +#include "input_context.h" #ifdef HAVE_OVERLAY -#include "input/overlay.h" +#include "overlay.h" #endif #ifdef __cplusplus From bd0f0c3f63cb6bbd253a77bc546323dcac35a41a Mon Sep 17 00:00:00 2001 From: twinaphex Date: Mon, 12 Jan 2015 18:47:39 +0100 Subject: [PATCH 103/156] Rename gfx_context.c to video_context.c --- Makefile.common | 2 +- apple/common/apple_gfx_context.c.inl | 2 +- gfx/context/drm_egl_ctx.c | 2 +- gfx/context/emscriptenegl_ctx.c | 2 +- gfx/context/gfx_null_ctx.c | 2 +- gfx/context/glx_ctx.c | 2 +- gfx/context/ps3_ctx.c | 2 +- gfx/context/sdl_gl_ctx.c | 2 +- gfx/context/vc_egl_ctx.c | 2 +- gfx/context/wgl_ctx.c | 2 +- gfx/context/xegl_ctx.c | 2 +- gfx/d3d/d3d.h | 2 +- gfx/drivers/gl.c | 2 +- gfx/drivers/omap_gfx.c | 2 +- gfx/drivers/sdl2_gfx.c | 2 +- gfx/drivers/sdl_gfx.c | 2 +- gfx/drivers/vg.c | 2 +- gfx/gl_common.h | 2 +- gfx/shader/shader_context.h | 2 +- gfx/shader/shader_glsl.c | 2 +- gfx/shader/shader_null.c | 2 +- gfx/{gfx_context.c => video_context.c} | 3 +-- gfx/{gfx_context.h => video_context.h} | 4 ++-- griffin/griffin.c | 2 +- input/drivers/sdl_input.c | 2 +- menu/disp/rmenu_xui.cpp | 2 +- 26 files changed, 27 insertions(+), 28 deletions(-) rename gfx/{gfx_context.c => video_context.c} (99%) rename gfx/{gfx_context.h => video_context.h} (99%) diff --git a/Makefile.common b/Makefile.common index fe562faed4..2e5266de3a 100644 --- a/Makefile.common +++ b/Makefile.common @@ -370,7 +370,7 @@ ifeq ($(HAVE_OPENGL), 1) DEFINES += -DHAVE_OPENGL -DHAVE_GLSL OBJ += gfx/drivers/gl.o \ gfx/gl_common.o \ - gfx/gfx_context.o \ + gfx/video_context.o \ gfx/context/gfx_null_ctx.o \ gfx/fonts/gl_font.o \ gfx/fonts/gl_raster_font.o \ diff --git a/apple/common/apple_gfx_context.c.inl b/apple/common/apple_gfx_context.c.inl index 6832360cce..758b53eee1 100644 --- a/apple/common/apple_gfx_context.c.inl +++ b/apple/common/apple_gfx_context.c.inl @@ -4,7 +4,7 @@ #endif #include "../../gfx/gfx_common.h" -#include "../../gfx/gfx_context.h" +#include "../../gfx/video_context.h" #include "../../gfx/gl_common.h" //#define HAVE_NSOPENGL diff --git a/gfx/context/drm_egl_ctx.c b/gfx/context/drm_egl_ctx.c index 8ae17257f3..962e451d7e 100644 --- a/gfx/context/drm_egl_ctx.c +++ b/gfx/context/drm_egl_ctx.c @@ -19,7 +19,7 @@ */ #include "../../driver.h" -#include "../gfx_context.h" +#include "../video_context.h" #include "../gl_common.h" #include "../gfx_common.h" #include diff --git a/gfx/context/emscriptenegl_ctx.c b/gfx/context/emscriptenegl_ctx.c index 321bf13eed..431f6b5af4 100644 --- a/gfx/context/emscriptenegl_ctx.c +++ b/gfx/context/emscriptenegl_ctx.c @@ -15,7 +15,7 @@ */ #include "../../driver.h" -#include "../gfx_context.h" +#include "../video_context.h" #include "../gl_common.h" #include "../gfx_common.h" diff --git a/gfx/context/gfx_null_ctx.c b/gfx/context/gfx_null_ctx.c index 630e5427a0..223e30ccde 100644 --- a/gfx/context/gfx_null_ctx.c +++ b/gfx/context/gfx_null_ctx.c @@ -17,7 +17,7 @@ // Null context. #include "../../driver.h" -#include "../gfx_context.h" +#include "../video_context.h" #include "../gfx_common.h" static void gfx_ctx_null_swap_interval(void *data, unsigned interval) diff --git a/gfx/context/glx_ctx.c b/gfx/context/glx_ctx.c index b2644f2a45..1b535ace98 100644 --- a/gfx/context/glx_ctx.c +++ b/gfx/context/glx_ctx.c @@ -15,7 +15,7 @@ */ #include "../../driver.h" -#include "../gfx_context.h" +#include "../video_context.h" #include "../gl_common.h" #include "../gfx_common.h" #include "x11_common.h" diff --git a/gfx/context/ps3_ctx.c b/gfx/context/ps3_ctx.c index 7c36996147..132e55c6ec 100644 --- a/gfx/context/ps3_ctx.c +++ b/gfx/context/ps3_ctx.c @@ -37,7 +37,7 @@ #include "../gl_common.h" -#include "../gfx_context.h" +#include "../video_context.h" typedef struct gfx_ctx_ps3_data { diff --git a/gfx/context/sdl_gl_ctx.c b/gfx/context/sdl_gl_ctx.c index 536ba41f3e..0e22610883 100644 --- a/gfx/context/sdl_gl_ctx.c +++ b/gfx/context/sdl_gl_ctx.c @@ -15,7 +15,7 @@ */ #include "../../driver.h" -#include "../gfx_context.h" +#include "../video_context.h" #include "../gl_common.h" #include "../gfx_common.h" diff --git a/gfx/context/vc_egl_ctx.c b/gfx/context/vc_egl_ctx.c index 8f68ad235f..d847c54f64 100644 --- a/gfx/context/vc_egl_ctx.c +++ b/gfx/context/vc_egl_ctx.c @@ -15,7 +15,7 @@ */ #include "../../driver.h" -#include "../gfx_context.h" +#include "../video_context.h" #include "../gl_common.h" #include "../gfx_common.h" diff --git a/gfx/context/wgl_ctx.c b/gfx/context/wgl_ctx.c index bc4a71e7f5..fa80af1395 100644 --- a/gfx/context/wgl_ctx.c +++ b/gfx/context/wgl_ctx.c @@ -22,7 +22,7 @@ #endif #include "../../driver.h" -#include "../gfx_context.h" +#include "../video_context.h" #include "../gl_common.h" #include "../gfx_common.h" #include "win32_common.h" diff --git a/gfx/context/xegl_ctx.c b/gfx/context/xegl_ctx.c index 3e24f0feb7..1e72a91fab 100644 --- a/gfx/context/xegl_ctx.c +++ b/gfx/context/xegl_ctx.c @@ -19,7 +19,7 @@ */ #include "../../driver.h" -#include "../gfx_context.h" +#include "../video_context.h" #include "../gl_common.h" #include "../gfx_common.h" #include "x11_common.h" diff --git a/gfx/d3d/d3d.h b/gfx/d3d/d3d.h index 9491fa4f3f..8a94f6ff3e 100644 --- a/gfx/d3d/d3d.h +++ b/gfx/d3d/d3d.h @@ -50,7 +50,7 @@ #endif #include "../fonts/d3d_font.h" -#include "../gfx_context.h" +#include "../video_context.h" #include "../gfx_common.h" #ifdef HAVE_CG diff --git a/gfx/drivers/gl.c b/gfx/drivers/gl.c index eaf7ec362c..2e5b3ba336 100644 --- a/gfx/drivers/gl.c +++ b/gfx/drivers/gl.c @@ -38,7 +38,7 @@ #include "../gl_common.h" #include "../gfx_common.h" -#include "../gfx_context.h" +#include "../video_context.h" #include #ifdef HAVE_GLSL diff --git a/gfx/drivers/omap_gfx.c b/gfx/drivers/omap_gfx.c index d5194d3485..3c5cfb4f02 100644 --- a/gfx/drivers/omap_gfx.c +++ b/gfx/drivers/omap_gfx.c @@ -21,7 +21,7 @@ #include "../../retroarch.h" #include #include "../gfx_common.h" -#include "../gfx_context.h" +#include "../video_context.h" #include "../fonts/fonts.h" #include diff --git a/gfx/drivers/sdl2_gfx.c b/gfx/drivers/sdl2_gfx.c index 4ed2ba13c0..a332f38fa8 100644 --- a/gfx/drivers/sdl2_gfx.c +++ b/gfx/drivers/sdl2_gfx.c @@ -23,7 +23,7 @@ #include "../../retroarch.h" #include #include "../gfx_common.h" -#include "../gfx_context.h" +#include "../video_context.h" #include "../fonts/fonts.h" #ifdef HAVE_X11 diff --git a/gfx/drivers/sdl_gfx.c b/gfx/drivers/sdl_gfx.c index e9ed6ac3c9..0e400e5a3a 100644 --- a/gfx/drivers/sdl_gfx.c +++ b/gfx/drivers/sdl_gfx.c @@ -21,7 +21,7 @@ #include "../../general.h" #include #include "../gfx_common.h" -#include "../gfx_context.h" +#include "../video_context.h" #include "../fonts/fonts.h" #ifdef HAVE_X11 diff --git a/gfx/drivers/vg.c b/gfx/drivers/vg.c index ce7cb3402d..1edc1964db 100644 --- a/gfx/drivers/vg.c +++ b/gfx/drivers/vg.c @@ -19,7 +19,7 @@ #include #include #include -#include "../gfx_context.h" +#include "../video_context.h" #include #include "../../libretro.h" #include "../../general.h" diff --git a/gfx/gl_common.h b/gfx/gl_common.h index ada57a5a26..ec2d27a56a 100644 --- a/gfx/gl_common.h +++ b/gfx/gl_common.h @@ -20,7 +20,7 @@ #include "../general.h" #include "fonts/fonts.h" #include -#include "gfx_context.h" +#include "video_context.h" #include #include "fonts/gl_font.h" #include "shader/shader_context.h" diff --git a/gfx/shader/shader_context.h b/gfx/shader/shader_context.h index dccf93b339..73de244d1a 100644 --- a/gfx/shader/shader_context.h +++ b/gfx/shader/shader_context.h @@ -22,7 +22,7 @@ #include "../../config.h" #endif -#include "../gfx_context.h" +#include "../video_context.h" #include typedef struct shader_backend diff --git a/gfx/shader/shader_glsl.c b/gfx/shader/shader_glsl.c index 8b34f9267a..19ddad2e2e 100644 --- a/gfx/shader/shader_glsl.c +++ b/gfx/shader/shader_glsl.c @@ -27,7 +27,7 @@ #include "../../config.h" #endif -#include "../gfx_context.h" +#include "../video_context.h" #include #ifdef HAVE_OPENGL diff --git a/gfx/shader/shader_null.c b/gfx/shader/shader_null.c index e98795330e..840fa711e1 100644 --- a/gfx/shader/shader_null.c +++ b/gfx/shader/shader_null.c @@ -31,7 +31,7 @@ #include "../gl_common.h" #endif -#include "../gfx_context.h" +#include "../video_context.h" #include "shader_context.h" #include diff --git a/gfx/gfx_context.c b/gfx/video_context.c similarity index 99% rename from gfx/gfx_context.c rename to gfx/video_context.c index ec0413afc7..e02db81926 100644 --- a/gfx/gfx_context.c +++ b/gfx/video_context.c @@ -15,8 +15,7 @@ */ #include "../general.h" -#include "gfx_context.h" -#include "../general.h" +#include "video_context.h" #include #ifdef HAVE_CONFIG_H diff --git a/gfx/gfx_context.h b/gfx/video_context.h similarity index 99% rename from gfx/gfx_context.h rename to gfx/video_context.h index 795225fb98..64639551f6 100644 --- a/gfx/gfx_context.h +++ b/gfx/video_context.h @@ -14,8 +14,8 @@ * If not, see . */ -#ifndef __GFX_CONTEXT_H -#define __GFX_CONTEXT_H +#ifndef __VIDEO_CONTEXT_H +#define __VIDEO_CONTEXT_H #include #include "../driver.h" diff --git a/griffin/griffin.c b/griffin/griffin.c index 8f0494612b..5a6fe01dd5 100644 --- a/griffin/griffin.c +++ b/griffin/griffin.c @@ -86,7 +86,7 @@ CHEATS VIDEO CONTEXT ============================================================ */ -#include "../gfx/gfx_context.c" +#include "../gfx/video_context.c" #include "../gfx/context/gfx_null_ctx.c" #if defined(__CELLOS_LV2__) diff --git a/input/drivers/sdl_input.c b/input/drivers/sdl_input.c index 0fd3301da3..ba2adc0f1d 100644 --- a/input/drivers/sdl_input.c +++ b/input/drivers/sdl_input.c @@ -17,7 +17,7 @@ #include "../../driver.h" #include "SDL.h" -#include "../../gfx/gfx_context.h" +#include "../../gfx/video_context.h" #include #include "../../general.h" #include diff --git a/menu/disp/rmenu_xui.cpp b/menu/disp/rmenu_xui.cpp index af187809df..7fc6033592 100644 --- a/menu/disp/rmenu_xui.cpp +++ b/menu/disp/rmenu_xui.cpp @@ -25,7 +25,7 @@ #include "../menu_list.h" #include "../../gfx/gfx_common.h" -#include "../../gfx/gfx_context.h" +#include "../../gfx/video_context.h" #include "../../settings_data.h" #include "../../general.h" From 32eb748057c2503af98b80f0b449b33e2f5256bf Mon Sep 17 00:00:00 2001 From: twinaphex Date: Mon, 12 Jan 2015 18:50:25 +0100 Subject: [PATCH 104/156] Remove some header includes --- gfx/context/drm_egl_ctx.c | 1 - gfx/context/glx_ctx.c | 1 - gfx/context/sdl_gl_ctx.c | 1 - gfx/context/xegl_ctx.c | 1 - 4 files changed, 4 deletions(-) diff --git a/gfx/context/drm_egl_ctx.c b/gfx/context/drm_egl_ctx.c index 962e451d7e..d9bb67a396 100644 --- a/gfx/context/drm_egl_ctx.c +++ b/gfx/context/drm_egl_ctx.c @@ -19,7 +19,6 @@ */ #include "../../driver.h" -#include "../video_context.h" #include "../gl_common.h" #include "../gfx_common.h" #include diff --git a/gfx/context/glx_ctx.c b/gfx/context/glx_ctx.c index 1b535ace98..b83caca2bd 100644 --- a/gfx/context/glx_ctx.c +++ b/gfx/context/glx_ctx.c @@ -15,7 +15,6 @@ */ #include "../../driver.h" -#include "../video_context.h" #include "../gl_common.h" #include "../gfx_common.h" #include "x11_common.h" diff --git a/gfx/context/sdl_gl_ctx.c b/gfx/context/sdl_gl_ctx.c index 0e22610883..928b91bcd1 100644 --- a/gfx/context/sdl_gl_ctx.c +++ b/gfx/context/sdl_gl_ctx.c @@ -15,7 +15,6 @@ */ #include "../../driver.h" -#include "../video_context.h" #include "../gl_common.h" #include "../gfx_common.h" diff --git a/gfx/context/xegl_ctx.c b/gfx/context/xegl_ctx.c index 1e72a91fab..7e4977d60d 100644 --- a/gfx/context/xegl_ctx.c +++ b/gfx/context/xegl_ctx.c @@ -19,7 +19,6 @@ */ #include "../../driver.h" -#include "../video_context.h" #include "../gl_common.h" #include "../gfx_common.h" #include "x11_common.h" From 71cc6515d211697b93ee50efc1f4ed38f538b873 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Mon, 12 Jan 2015 18:53:47 +0100 Subject: [PATCH 105/156] Remove more header includes --- gfx/gl_common.h | 1 - gfx/shader/shader_glsl.c | 1 - gfx/shader/shader_null.c | 1 - 3 files changed, 3 deletions(-) diff --git a/gfx/gl_common.h b/gfx/gl_common.h index ec2d27a56a..ae2ee038d1 100644 --- a/gfx/gl_common.h +++ b/gfx/gl_common.h @@ -20,7 +20,6 @@ #include "../general.h" #include "fonts/fonts.h" #include -#include "video_context.h" #include #include "fonts/gl_font.h" #include "shader/shader_context.h" diff --git a/gfx/shader/shader_glsl.c b/gfx/shader/shader_glsl.c index 19ddad2e2e..9e8b7c77c9 100644 --- a/gfx/shader/shader_glsl.c +++ b/gfx/shader/shader_glsl.c @@ -27,7 +27,6 @@ #include "../../config.h" #endif -#include "../video_context.h" #include #ifdef HAVE_OPENGL diff --git a/gfx/shader/shader_null.c b/gfx/shader/shader_null.c index 840fa711e1..ac917e7a15 100644 --- a/gfx/shader/shader_null.c +++ b/gfx/shader/shader_null.c @@ -31,7 +31,6 @@ #include "../gl_common.h" #endif -#include "../video_context.h" #include "shader_context.h" #include From f3dc94818e80c9fd05269694b686c3de7524a3c9 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Mon, 12 Jan 2015 18:56:23 +0100 Subject: [PATCH 106/156] driver.h - cleanups --- driver.h | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/driver.h b/driver.h index e0683f850b..e3a2936901 100644 --- a/driver.h +++ b/driver.h @@ -23,8 +23,7 @@ #include #include #include -#include "gfx/scaler/scaler.h" -#include "gfx/image/image.h" +#include #include "frontend/frontend_context.h" #include From d2449f07f720218e9316d7119cc8059bdebdebd0 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Mon, 12 Jan 2015 18:57:37 +0100 Subject: [PATCH 107/156] Move header include to gfx/video_driver.h --- driver.h | 1 - gfx/video_driver.h | 1 + 2 files changed, 1 insertion(+), 1 deletion(-) diff --git a/driver.h b/driver.h index e3a2936901..30b1b353c0 100644 --- a/driver.h +++ b/driver.h @@ -23,7 +23,6 @@ #include #include #include -#include #include "frontend/frontend_context.h" #include diff --git a/gfx/video_driver.h b/gfx/video_driver.h index 6448d7a728..931ee425f9 100644 --- a/gfx/video_driver.h +++ b/gfx/video_driver.h @@ -21,6 +21,7 @@ #include #include #include +#include #include "../libretro.h" #include "../input/input_driver.h" From 33cdd16c22155637a14d160fd816836b8163df7b Mon Sep 17 00:00:00 2001 From: twinaphex Date: Mon, 12 Jan 2015 19:02:30 +0100 Subject: [PATCH 108/156] Move input/osk to osk/ --- Makefile.common | 2 +- griffin/griffin.c | 4 ++-- {input/osk => osk/drivers}/nullosk.c | 0 {input/osk => osk/drivers}/ps3_osk.c | 0 4 files changed, 3 insertions(+), 3 deletions(-) rename {input/osk => osk/drivers}/nullosk.c (100%) rename {input/osk => osk/drivers}/ps3_osk.c (100%) diff --git a/Makefile.common b/Makefile.common index 2e5266de3a..d40675febd 100644 --- a/Makefile.common +++ b/Makefile.common @@ -147,7 +147,7 @@ OBJ += frontend/frontend.o \ audio/drivers/nullaudio.o \ input/drivers/nullinput.o \ input/drivers_joypad/nullinput_joypad.o \ - input/osk/nullosk.o \ + osk/drivers/nullosk.o \ playlist.o \ movie.o \ record/ffemu.o \ diff --git a/griffin/griffin.c b/griffin/griffin.c index 5a6fe01dd5..bca1e95bdb 100644 --- a/griffin/griffin.c +++ b/griffin/griffin.c @@ -350,10 +350,10 @@ INPUT #endif #if defined(__CELLOS_LV2__) -#include "../input/osk/ps3_osk.c" +#include "../osk/drivers/ps3_osk.c" #endif -#include "../input/osk/nullosk.c" +#include "../osk/drivers/nullosk.c" #if defined(__linux__) && !defined(ANDROID) #include "../input/drivers/linuxraw_input.c" diff --git a/input/osk/nullosk.c b/osk/drivers/nullosk.c similarity index 100% rename from input/osk/nullosk.c rename to osk/drivers/nullosk.c diff --git a/input/osk/ps3_osk.c b/osk/drivers/ps3_osk.c similarity index 100% rename from input/osk/ps3_osk.c rename to osk/drivers/ps3_osk.c From 444adb622ff9ffabce45852acffb292fa74a200c Mon Sep 17 00:00:00 2001 From: twinaphex Date: Mon, 12 Jan 2015 19:04:12 +0100 Subject: [PATCH 109/156] Move camera drivers to camera/drivers/ --- Makefile.common | 6 +++--- camera/{ => drivers}/android.c | 2 +- camera/{ => drivers}/nullcamera.c | 2 +- camera/{ => drivers}/rwebcam.c | 4 ++-- camera/{ => drivers}/video4linux2.c | 2 +- griffin/griffin.c | 8 ++++---- 6 files changed, 12 insertions(+), 12 deletions(-) rename camera/{ => drivers}/android.c (99%) rename camera/{ => drivers}/nullcamera.c (98%) rename camera/{ => drivers}/rwebcam.c (95%) rename camera/{ => drivers}/video4linux2.c (99%) diff --git a/Makefile.common b/Makefile.common index d40675febd..e792ed42bb 100644 --- a/Makefile.common +++ b/Makefile.common @@ -142,7 +142,7 @@ OBJ += frontend/frontend.o \ audio/resamplers/nearest.o \ audio/resamplers/cc_resampler.o \ location/nulllocation.o \ - camera/nullcamera.o \ + camera/drivers/nullcamera.o \ gfx/drivers/nullgfx.o \ audio/drivers/nullaudio.o \ input/drivers/nullinput.o \ @@ -177,7 +177,7 @@ ifeq ($(HAVE_EMSCRIPTEN), 1) OBJ += frontend/platform/platform_emscripten.o \ input/drivers/rwebinput_input.o \ audio/drivers/rwebaudio.o \ - camera/rwebcam.o + camera/drivers/rwebcam.o endif # Audio @@ -601,7 +601,7 @@ endif # Camera ifeq ($(HAVE_V4L2),1) - OBJ += camera/video4linux2.o + OBJ += camera/drivers/video4linux2.o DEFINES += -DHAVE_V4L2 endif diff --git a/camera/android.c b/camera/drivers/android.c similarity index 99% rename from camera/android.c rename to camera/drivers/android.c index eb2705274a..e1044bea1c 100644 --- a/camera/android.c +++ b/camera/drivers/android.c @@ -16,7 +16,7 @@ */ #include -#include "../driver.h" +#include "../../driver.h" typedef struct android_camera { diff --git a/camera/nullcamera.c b/camera/drivers/nullcamera.c similarity index 98% rename from camera/nullcamera.c rename to camera/drivers/nullcamera.c index 5617d97829..beacb6542a 100644 --- a/camera/nullcamera.c +++ b/camera/drivers/nullcamera.c @@ -13,7 +13,7 @@ * If not, see . */ -#include "../driver.h" +#include "../../driver.h" static void *nullcamera_init(const char *device, uint64_t caps, unsigned width, unsigned height) diff --git a/camera/rwebcam.c b/camera/drivers/rwebcam.c similarity index 95% rename from camera/rwebcam.c rename to camera/drivers/rwebcam.c index 0be75627a0..be2437521e 100644 --- a/camera/rwebcam.c +++ b/camera/drivers/rwebcam.c @@ -13,8 +13,8 @@ * If not, see . */ -#include "../driver.h" -#include "../emscripten/RWebCam.h" +#include "../../driver.h" +#include "../../emscripten/RWebCam.h" static void *rwebcam_init(const char *device, uint64_t caps, unsigned width, unsigned height) diff --git a/camera/video4linux2.c b/camera/drivers/video4linux2.c similarity index 99% rename from camera/video4linux2.c rename to camera/drivers/video4linux2.c index 3148bb1974..164cb93957 100644 --- a/camera/video4linux2.c +++ b/camera/drivers/video4linux2.c @@ -20,7 +20,7 @@ #include #include #include -#include "../performance.h" +#include "../../performance.h" #include #include #include diff --git a/griffin/griffin.c b/griffin/griffin.c index bca1e95bdb..ee257c3bfc 100644 --- a/griffin/griffin.c +++ b/griffin/griffin.c @@ -418,16 +418,16 @@ AUDIO RESAMPLER CAMERA ============================================================ */ #if defined(ANDROID) -#include "../camera/android.c" +#include "../camera/drivers/android.c" #elif defined(EMSCRIPTEN) -#include "../camera/rwebcam.c" +#include "../camera/drivers/rwebcam.c" #endif #ifdef HAVE_V4L2 -#include "../camera/video4linux2.c" +#include "../camera/drivers/video4linux2.c" #endif -#include "../camera/nullcamera.c" +#include "../camera/drivers/nullcamera.c" /*============================================================ LOCATION From 6a9d24b10ae58c1c938011e2b174e657bca31258 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Mon, 12 Jan 2015 19:05:33 +0100 Subject: [PATCH 110/156] Move location drivers to location/drivers/ --- Makefile.common | 2 +- griffin/griffin.c | 4 ++-- location/{ => drivers}/android.c | 2 +- location/{ => drivers}/nulllocation.c | 2 +- 4 files changed, 5 insertions(+), 5 deletions(-) rename location/{ => drivers}/android.c (99%) rename location/{ => drivers}/nulllocation.c (98%) diff --git a/Makefile.common b/Makefile.common index e792ed42bb..d86e149789 100644 --- a/Makefile.common +++ b/Makefile.common @@ -141,7 +141,7 @@ OBJ += frontend/frontend.o \ audio/resamplers/sinc.o \ audio/resamplers/nearest.o \ audio/resamplers/cc_resampler.o \ - location/nulllocation.o \ + location/drivers/nulllocation.o \ camera/drivers/nullcamera.o \ gfx/drivers/nullgfx.o \ audio/drivers/nullaudio.o \ diff --git a/griffin/griffin.c b/griffin/griffin.c index ee257c3bfc..72e4305674 100644 --- a/griffin/griffin.c +++ b/griffin/griffin.c @@ -433,10 +433,10 @@ CAMERA LOCATION ============================================================ */ #if defined(ANDROID) -#include "../location/android.c" +#include "../location/drivers/android.c" #endif -#include "../location/nulllocation.c" +#include "../location/drivers/nulllocation.c" /*============================================================ RSOUND diff --git a/location/android.c b/location/drivers/android.c similarity index 99% rename from location/android.c rename to location/drivers/android.c index 031f7a1869..959dd8b160 100644 --- a/location/android.c +++ b/location/drivers/android.c @@ -14,7 +14,7 @@ * If not, see . */ -#include "../driver.h" +#include "../../driver.h" typedef struct android_location { diff --git a/location/nulllocation.c b/location/drivers/nulllocation.c similarity index 98% rename from location/nulllocation.c rename to location/drivers/nulllocation.c index 55ab50cc9f..1507ed3f94 100644 --- a/location/nulllocation.c +++ b/location/drivers/nulllocation.c @@ -14,7 +14,7 @@ * If not, see . */ -#include "../driver.h" +#include "../../driver.h" static void *null_location_init(void) { From 0d9ba863dc5dccf65bf83d5be424c83e3cf1d84a Mon Sep 17 00:00:00 2001 From: twinaphex Date: Mon, 12 Jan 2015 19:11:51 +0100 Subject: [PATCH 111/156] Remove menu/disp/menu_display.h and menu/backend/menu_backend.h and merge into menu/menu_driver.h --- driver.h | 2 - menu/backend/menu_backend.h | 48 ----------------------- menu/backend/menu_common_backend.c | 1 - menu/backend/menu_lakka_backend.c | 1 - menu/disp/ios.c | 2 +- menu/disp/menu_display.h | 61 ------------------------------ menu/disp/rmenu.c | 2 +- menu/disp/rmenu_xui.cpp | 2 +- menu/menu_driver.h | 54 ++++++++++++++++++++++++++ 9 files changed, 57 insertions(+), 116 deletions(-) delete mode 100644 menu/backend/menu_backend.h delete mode 100644 menu/disp/menu_display.h diff --git a/driver.h b/driver.h index 30b1b353c0..ae7f4924ec 100644 --- a/driver.h +++ b/driver.h @@ -31,8 +31,6 @@ #include "audio/audio_driver.h" #include "menu/menu_driver.h" -#include "menu/backend/menu_backend.h" -#include "menu/disp/menu_display.h" #include "audio/resamplers/resampler.h" #include "record/ffemu.h" diff --git a/menu/backend/menu_backend.h b/menu/backend/menu_backend.h deleted file mode 100644 index 27f4f58a60..0000000000 --- a/menu/backend/menu_backend.h +++ /dev/null @@ -1,48 +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 . - */ - -#ifndef DRIVER_MENU_BACKEND_H__ -#define DRIVER_MENU_BACKEND_H__ - -#ifdef __cplusplus -extern "C" { -#endif - -typedef struct menu_file_list_cbs -{ - int (*action_deferred_push)(void *data, void *userdata, const char - *path, const char *label, unsigned type); - int (*action_ok)(const char *path, const char *label, unsigned type, - size_t idx); - int (*action_cancel)(const char *path, const char *label, unsigned type, - size_t idx); - int (*action_start)(unsigned type, const char *label, unsigned action); - int (*action_content_list_switch)(void *data, void *userdata, const char - *path, const char *label, unsigned type); - int (*action_toggle)(unsigned type, const char *label, unsigned action); -} menu_file_list_cbs_t; - -typedef struct menu_ctx_driver_backend -{ - int (*iterate)(unsigned); - const char *ident; -} menu_ctx_driver_backend_t; - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/menu/backend/menu_common_backend.c b/menu/backend/menu_common_backend.c index dd827aa7a7..184ad2e6dd 100644 --- a/menu/backend/menu_common_backend.c +++ b/menu/backend/menu_common_backend.c @@ -20,7 +20,6 @@ #include #include #include -#include "menu_backend.h" #include "../menu_entries.h" #include "../menu_input.h" diff --git a/menu/backend/menu_lakka_backend.c b/menu/backend/menu_lakka_backend.c index 18011267c5..843efa45e2 100644 --- a/menu/backend/menu_lakka_backend.c +++ b/menu/backend/menu_lakka_backend.c @@ -23,7 +23,6 @@ #include #include "../menu_action.h" #include "../menu_navigation.h" -#include "menu_backend.h" #include "../../gfx/gfx_common.h" #include "../../driver.h" diff --git a/menu/disp/ios.c b/menu/disp/ios.c index 2a66ee113c..e7b8ccd07c 100644 --- a/menu/disp/ios.c +++ b/menu/disp/ios.c @@ -15,7 +15,7 @@ #include #include -#include "menu_display.h" +#include "../menu_driver.h" #include "../menu.h" #include "../../general.h" #include "ios.h" diff --git a/menu/disp/menu_display.h b/menu/disp/menu_display.h deleted file mode 100644 index bd9bd4ab3d..0000000000 --- a/menu/disp/menu_display.h +++ /dev/null @@ -1,61 +0,0 @@ -/* RetroArch - A frontend for libretro. - * 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 . - */ - -#ifndef DRIVER_MENU_DISPLAY_H__ -#define DRIVER_MENU_DISPLAY_H__ - -#ifdef __cplusplus -extern "C" { -#endif - -typedef struct menu_ctx_driver -{ - void (*set_texture)(void*); - void (*render_messagebox)(const char*); - void (*render)(void); - void (*frame)(void); - void* (*init)(void); - bool (*init_lists)(void*); - void (*free)(void*); - void (*context_reset)(void*); - void (*context_destroy)(void*); - void (*populate_entries)(void*, const char *, const char *, - unsigned); - void (*iterate)(void*, unsigned); - int (*input_postprocess)(uint64_t, uint64_t); - void (*navigation_clear)(void *, bool); - void (*navigation_decrement)(void *); - void (*navigation_increment)(void *); - void (*navigation_set)(void *, bool); - void (*navigation_set_last)(void *); - void (*navigation_descend_alphabet)(void *, size_t *); - void (*navigation_ascend_alphabet)(void *, size_t *); - void (*list_insert)(void *, const char *, const char *, size_t); - void (*list_delete)(void *, size_t, size_t); - void (*list_clear)(void *); - void (*list_cache)(bool, unsigned); - void (*list_set_selection)(void *); - void (*init_core_info)(void *); - void (*update_core_info)(void *); - - const menu_ctx_driver_backend_t *backend; - const char *ident; -} menu_ctx_driver_t; - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/menu/disp/rmenu.c b/menu/disp/rmenu.c index 44811d33a2..8a863ba8d6 100644 --- a/menu/disp/rmenu.c +++ b/menu/disp/rmenu.c @@ -21,7 +21,7 @@ #include #include -#include "menu_display.h" +#include "../menu_driver.h" #include "../menu.h" #include "../../general.h" #include "../../gfx/gfx_common.h" diff --git a/menu/disp/rmenu_xui.cpp b/menu/disp/rmenu_xui.cpp index 7fc6033592..f464792e11 100644 --- a/menu/disp/rmenu_xui.cpp +++ b/menu/disp/rmenu_xui.cpp @@ -20,7 +20,7 @@ #include #include -#include "menu_display.h" +#include "../menu_driver.h" #include "../menu.h" #include "../menu_list.h" diff --git a/menu/menu_driver.h b/menu/menu_driver.h index 880deb1593..1dadf40956 100644 --- a/menu/menu_driver.h +++ b/menu/menu_driver.h @@ -141,6 +141,60 @@ typedef struct rarch_setting_t *list_settings; } menu_handle_t; +typedef struct menu_file_list_cbs +{ + int (*action_deferred_push)(void *data, void *userdata, const char + *path, const char *label, unsigned type); + int (*action_ok)(const char *path, const char *label, unsigned type, + size_t idx); + int (*action_cancel)(const char *path, const char *label, unsigned type, + size_t idx); + int (*action_start)(unsigned type, const char *label, unsigned action); + int (*action_content_list_switch)(void *data, void *userdata, const char + *path, const char *label, unsigned type); + int (*action_toggle)(unsigned type, const char *label, unsigned action); +} menu_file_list_cbs_t; + +typedef struct menu_ctx_driver_backend +{ + int (*iterate)(unsigned); + const char *ident; +} menu_ctx_driver_backend_t; + +typedef struct menu_ctx_driver +{ + void (*set_texture)(void*); + void (*render_messagebox)(const char*); + void (*render)(void); + void (*frame)(void); + void* (*init)(void); + bool (*init_lists)(void*); + void (*free)(void*); + void (*context_reset)(void*); + void (*context_destroy)(void*); + void (*populate_entries)(void*, const char *, const char *, + unsigned); + void (*iterate)(void*, unsigned); + int (*input_postprocess)(uint64_t, uint64_t); + void (*navigation_clear)(void *, bool); + void (*navigation_decrement)(void *); + void (*navigation_increment)(void *); + void (*navigation_set)(void *, bool); + void (*navigation_set_last)(void *); + void (*navigation_descend_alphabet)(void *, size_t *); + void (*navigation_ascend_alphabet)(void *, size_t *); + void (*list_insert)(void *, const char *, const char *, size_t); + void (*list_delete)(void *, size_t, size_t); + void (*list_clear)(void *); + void (*list_cache)(bool, unsigned); + void (*list_set_selection)(void *); + void (*init_core_info)(void *); + void (*update_core_info)(void *); + + const menu_ctx_driver_backend_t *backend; + const char *ident; +} menu_ctx_driver_t; + #ifdef __cplusplus } #endif From f1196733b1574b0dd868bc6a7a3e61ee94430d75 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Mon, 12 Jan 2015 19:13:45 +0100 Subject: [PATCH 112/156] Move definitions to menu_driver.h --- driver.h | 11 ----------- menu/menu_driver.h | 11 +++++++++++ 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/driver.h b/driver.h index ae7f4924ec..57e05d2b85 100644 --- a/driver.h +++ b/driver.h @@ -675,17 +675,6 @@ extern location_driver_t location_null; extern input_osk_driver_t input_ps3_osk; extern input_osk_driver_t input_null_osk; -extern menu_ctx_driver_t menu_ctx_rmenu; -extern menu_ctx_driver_t menu_ctx_rmenu_xui; -extern menu_ctx_driver_t menu_ctx_rgui; -extern menu_ctx_driver_t menu_ctx_glui; -extern menu_ctx_driver_t menu_ctx_xmb; -extern menu_ctx_driver_t menu_ctx_lakka; -extern menu_ctx_driver_t menu_ctx_ios; - -extern menu_ctx_driver_backend_t menu_ctx_backend_common; -extern menu_ctx_driver_backend_t menu_ctx_backend_lakka; - extern rarch_joypad_driver_t *joypad_drivers[]; #ifdef __cplusplus diff --git a/menu/menu_driver.h b/menu/menu_driver.h index 1dadf40956..2a054b255f 100644 --- a/menu/menu_driver.h +++ b/menu/menu_driver.h @@ -195,6 +195,17 @@ typedef struct menu_ctx_driver const char *ident; } menu_ctx_driver_t; +extern menu_ctx_driver_t menu_ctx_rmenu; +extern menu_ctx_driver_t menu_ctx_rmenu_xui; +extern menu_ctx_driver_t menu_ctx_rgui; +extern menu_ctx_driver_t menu_ctx_glui; +extern menu_ctx_driver_t menu_ctx_xmb; +extern menu_ctx_driver_t menu_ctx_lakka; +extern menu_ctx_driver_t menu_ctx_ios; + +extern menu_ctx_driver_backend_t menu_ctx_backend_common; +extern menu_ctx_driver_backend_t menu_ctx_backend_lakka; + #ifdef __cplusplus } #endif From 2029e13e239825afd30f4a6052fe22e3151f57c1 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Mon, 12 Jan 2015 19:28:40 +0100 Subject: [PATCH 113/156] Split up OSK driver code into separate file osk_driver.c --- Makefile.common | 1 + driver.c | 129 ---------------------------------------- driver.h | 29 +-------- griffin/griffin.c | 1 + osk_driver.c | 148 ++++++++++++++++++++++++++++++++++++++++++++++ osk_driver.h | 89 ++++++++++++++++++++++++++++ 6 files changed, 240 insertions(+), 157 deletions(-) create mode 100644 osk_driver.c create mode 100644 osk_driver.h diff --git a/Makefile.common b/Makefile.common index d86e149789..4cc2597f63 100644 --- a/Makefile.common +++ b/Makefile.common @@ -100,6 +100,7 @@ OBJ += frontend/frontend.o \ audio/audio_driver.o \ input/input_driver.o \ gfx/video_driver.o \ + osk_driver.o \ driver.o \ settings.o \ settings_list.o \ diff --git a/driver.c b/driver.c index 7d0b5297e6..e41e3bb743 100644 --- a/driver.c +++ b/driver.c @@ -40,80 +40,6 @@ driver_t driver; -static const input_osk_driver_t *osk_drivers[] = { -#ifdef __CELLOS_LV2__ - &input_ps3_osk, -#endif - &input_null_osk, - NULL, -}; - -/** - * osk_driver_find_handle: - * @index : index of driver to get handle to. - * - * Returns: handle to OSK driver at index. Can be NULL - * if nothing found. - **/ -static const void *osk_driver_find_handle(int index) -{ - const void *drv = osk_drivers[index]; - if (!drv) - return NULL; - return drv; -} - -/** - * osk_driver_find_ident: - * @index : index of driver to get handle to. - * - * Returns: Human-readable identifier of OSK driver at index. Can be NULL - * if nothing found. - **/ -static const char *osk_driver_find_ident(int index) -{ - const input_osk_driver_t *drv = osk_drivers[index]; - if (!drv) - return NULL; - return drv->ident; -} - -/** - * config_get_osk_driver_options: - * - * Get an enumerated list of all OSK (onscreen keyboard) driver names, - * separated by '|'. - * - * Returns: string listing of all OSK (onscreen keyboard) driver names, - * separated by '|'. - **/ -const char* config_get_osk_driver_options(void) -{ - union string_list_elem_attr attr; - unsigned i; - char *options = NULL; - int options_len = 0; - struct string_list *options_l = string_list_new(); - - attr.i = 0; - - for (i = 0; osk_driver_find_handle(i); i++) - { - const char *opt = osk_driver_find_ident(i); - options_len += strlen(opt) + 1; - string_list_append(options_l, opt, attr); - } - - options = (char*)calloc(options_len, sizeof(char)); - - string_list_join_concat(options, options_len, options_l, "|"); - - string_list_free(options_l); - options_l = NULL; - - return options; -} - static const camera_driver_t *camera_drivers[] = { #ifdef HAVE_V4L2 &camera_v4l2, @@ -537,61 +463,6 @@ void find_next_driver(const char *label, char *str, size_t sizeof_str) RARCH_WARN("Couldn't find any next driver (current one: \"%s\").\n", str); } -/** - * find_osk_driver: - * - * Find OSK (onscreen keyboard) driver. - **/ -static void find_osk_driver(void) -{ - int i = find_driver_index("osk_driver", g_settings.osk.driver); - if (i >= 0) - driver.osk = osk_driver_find_handle(i); - else - { - unsigned d; - RARCH_ERR("Couldn't find any OSK driver named \"%s\"\n", - g_settings.osk.driver); - RARCH_LOG_OUTPUT("Available OSK drivers are:\n"); - for (d = 0; osk_driver_find_handle(d); d++) - RARCH_LOG_OUTPUT("\t%s\n", osk_driver_find_ident(d)); - - RARCH_WARN("Going to default to first OSK driver...\n"); - - driver.osk = osk_driver_find_handle(0); - - if (!driver.osk) - rarch_fail(1, "find_osk_driver()"); - } -} - -static void init_osk(void) -{ - /* Resource leaks will follow if osk is initialized twice. */ - if (driver.osk_data) - return; - - find_osk_driver(); - - /* FIXME - refactor params later based on semantics */ - driver.osk_data = driver.osk->init(0); - - if (!driver.osk_data) - { - RARCH_ERR("Failed to initialize OSK driver. Will continue without OSK.\n"); - driver.osk_active = false; - } -} - -static void uninit_osk(void) -{ - if (driver.osk_data && driver.osk && driver.osk->free) - driver.osk->free(driver.osk_data); - driver.osk_data = NULL; -} - - - static void find_camera_driver(void) { int i = find_driver_index("camera_driver", g_settings.camera.driver); diff --git a/driver.h b/driver.h index 57e05d2b85..043d01b70c 100644 --- a/driver.h +++ b/driver.h @@ -31,6 +31,7 @@ #include "audio/audio_driver.h" #include "menu/menu_driver.h" +#include "osk_driver.h" #include "audio/resamplers/resampler.h" #include "record/ffemu.h" @@ -160,20 +161,6 @@ enum analog_dpad_mode ANALOG_DPAD_LAST }; -typedef struct input_osk_driver -{ - void *(*init)(size_t size); - void (*free)(void *data); - bool (*enable_key_layout)(void *data); - void (*oskutil_create_activation_parameters)(void *data); - void (*write_msg)(void *data, const void *msg); - void (*write_initial_msg)(void *data, const void *msg); - bool (*start)(void *data); - void (*lifecycle)(void *data, uint64_t status); - void *(*get_text_buf)(void *data); - const char *ident; -} input_osk_driver_t; - typedef struct camera_driver { /* FIXME: params for initialization - queries for resolution, @@ -615,17 +602,6 @@ const char* config_get_camera_driver_options(void); **/ const char* config_get_video_driver_options(void); -/** - * config_get_osk_driver_options: - * - * Get an enumerated list of all OSK (onscreen keyboard) driver names, - * separated by '|'. - * - * Returns: string listing of all OSK (onscreen keyboard) driver names, - * separated by '|'. - **/ -const char* config_get_osk_driver_options(void); - /** * config_get_location_driver_options: * @@ -672,9 +648,6 @@ extern location_driver_t location_apple; extern location_driver_t location_android; extern location_driver_t location_null; -extern input_osk_driver_t input_ps3_osk; -extern input_osk_driver_t input_null_osk; - extern rarch_joypad_driver_t *joypad_drivers[]; #ifdef __cplusplus diff --git a/griffin/griffin.c b/griffin/griffin.c index 72e4305674..91b42b2a85 100644 --- a/griffin/griffin.c +++ b/griffin/griffin.c @@ -499,6 +499,7 @@ DRIVERS #include "../gfx/video_driver.c" #include "../input/input_driver.c" #include "../audio/audio_driver.c" +#include "../osk_driver.c" #include "../driver.c" /*============================================================ diff --git a/osk_driver.c b/osk_driver.c new file mode 100644 index 0000000000..09f142cb01 --- /dev/null +++ b/osk_driver.c @@ -0,0 +1,148 @@ +/* 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 . + */ + +#include +#include +#include "osk_driver.h" +#include "driver.h" +#include "general.h" + +static const input_osk_driver_t *osk_drivers[] = { +#ifdef __CELLOS_LV2__ + &input_ps3_osk, +#endif + &input_null_osk, + NULL, +}; + +/** + * osk_driver_find_handle: + * @index : index of driver to get handle to. + * + * Returns: handle to OSK driver at index. Can be NULL + * if nothing found. + **/ +const void *osk_driver_find_handle(int index) +{ + const void *drv = osk_drivers[index]; + if (!drv) + return NULL; + return drv; +} + +/** + * osk_driver_find_ident: + * @index : index of driver to get handle to. + * + * Returns: Human-readable identifier of OSK driver at index. Can be NULL + * if nothing found. + **/ +const char *osk_driver_find_ident(int index) +{ + const input_osk_driver_t *drv = osk_drivers[index]; + if (!drv) + return NULL; + return drv->ident; +} + +/** + * config_get_osk_driver_options: + * + * Get an enumerated list of all OSK (onscreen keyboard) driver names, + * separated by '|'. + * + * Returns: string listing of all OSK (onscreen keyboard) driver names, + * separated by '|'. + **/ +const char* config_get_osk_driver_options(void) +{ + union string_list_elem_attr attr; + unsigned i; + char *options = NULL; + int options_len = 0; + struct string_list *options_l = string_list_new(); + + attr.i = 0; + + for (i = 0; osk_driver_find_handle(i); i++) + { + const char *opt = osk_driver_find_ident(i); + options_len += strlen(opt) + 1; + string_list_append(options_l, opt, attr); + } + + options = (char*)calloc(options_len, sizeof(char)); + + string_list_join_concat(options, options_len, options_l, "|"); + + string_list_free(options_l); + options_l = NULL; + + return options; +} + +/** + * find_osk_driver: + * + * Find OSK (onscreen keyboard) driver. + **/ +void find_osk_driver(void) +{ + int i = find_driver_index("osk_driver", g_settings.osk.driver); + if (i >= 0) + driver.osk = osk_driver_find_handle(i); + else + { + unsigned d; + RARCH_ERR("Couldn't find any OSK driver named \"%s\"\n", + g_settings.osk.driver); + RARCH_LOG_OUTPUT("Available OSK drivers are:\n"); + for (d = 0; osk_driver_find_handle(d); d++) + RARCH_LOG_OUTPUT("\t%s\n", osk_driver_find_ident(d)); + + RARCH_WARN("Going to default to first OSK driver...\n"); + + driver.osk = osk_driver_find_handle(0); + + if (!driver.osk) + rarch_fail(1, "find_osk_driver()"); + } +} + +void init_osk(void) +{ + /* Resource leaks will follow if osk is initialized twice. */ + if (driver.osk_data) + return; + + find_osk_driver(); + + /* FIXME - refactor params later based on semantics */ + driver.osk_data = driver.osk->init(0); + + if (!driver.osk_data) + { + RARCH_ERR("Failed to initialize OSK driver. Will continue without OSK.\n"); + driver.osk_active = false; + } +} + +void uninit_osk(void) +{ + if (driver.osk_data && driver.osk && driver.osk->free) + driver.osk->free(driver.osk_data); + driver.osk_data = NULL; +} diff --git a/osk_driver.h b/osk_driver.h new file mode 100644 index 0000000000..5d75be9ff0 --- /dev/null +++ b/osk_driver.h @@ -0,0 +1,89 @@ +/* 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 . + */ + +#ifndef __OSK_DRIVER__H +#define __OSK_DRIVER__H + +#include +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +typedef struct input_osk_driver +{ + void *(*init)(size_t size); + void (*free)(void *data); + bool (*enable_key_layout)(void *data); + void (*oskutil_create_activation_parameters)(void *data); + void (*write_msg)(void *data, const void *msg); + void (*write_initial_msg)(void *data, const void *msg); + bool (*start)(void *data); + void (*lifecycle)(void *data, uint64_t status); + void *(*get_text_buf)(void *data); + const char *ident; +} input_osk_driver_t; + +/** + * osk_driver_find_handle: + * @index : index of driver to get handle to. + * + * Returns: handle to OSK driver at index. Can be NULL + * if nothing found. + **/ +const void *osk_driver_find_handle(int index); + +/** + * osk_driver_find_ident: + * @index : index of driver to get handle to. + * + * Returns: Human-readable identifier of OSK driver at index. Can be NULL + * if nothing found. + **/ +const char *osk_driver_find_ident(int index); + +/** + * config_get_osk_driver_options: + * + * Get an enumerated list of all OSK (onscreen keyboard) driver names, + * separated by '|'. + * + * Returns: string listing of all OSK (onscreen keyboard) driver names, + * separated by '|'. + **/ +const char* config_get_osk_driver_options(void); + +/** + * find_osk_driver: + * + * Find OSK (onscreen keyboard) driver. + **/ +void find_osk_driver(void); + +void init_osk(void); + +void uninit_osk(void); + +extern input_osk_driver_t input_ps3_osk; +extern input_osk_driver_t input_null_osk; + +#ifdef __cplusplus +} +#endif + +#endif From 36d68b98b281b29fe56ce8e0fbc878f2a1f33584 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Mon, 12 Jan 2015 19:29:55 +0100 Subject: [PATCH 114/156] Move osk_driver.c to osk/ --- Makefile.common | 2 +- driver.h | 2 +- griffin/griffin.c | 2 +- osk_driver.c => osk/osk_driver.c | 4 ++-- osk_driver.h => osk/osk_driver.h | 0 5 files changed, 5 insertions(+), 5 deletions(-) rename osk_driver.c => osk/osk_driver.c (98%) rename osk_driver.h => osk/osk_driver.h (100%) diff --git a/Makefile.common b/Makefile.common index 4cc2597f63..06e76c795b 100644 --- a/Makefile.common +++ b/Makefile.common @@ -100,7 +100,7 @@ OBJ += frontend/frontend.o \ audio/audio_driver.o \ input/input_driver.o \ gfx/video_driver.o \ - osk_driver.o \ + osk/osk_driver.o \ driver.o \ settings.o \ settings_list.o \ diff --git a/driver.h b/driver.h index 043d01b70c..71dade44a3 100644 --- a/driver.h +++ b/driver.h @@ -31,7 +31,7 @@ #include "audio/audio_driver.h" #include "menu/menu_driver.h" -#include "osk_driver.h" +#include "osk/osk_driver.h" #include "audio/resamplers/resampler.h" #include "record/ffemu.h" diff --git a/griffin/griffin.c b/griffin/griffin.c index 91b42b2a85..df71ac2a48 100644 --- a/griffin/griffin.c +++ b/griffin/griffin.c @@ -499,7 +499,7 @@ DRIVERS #include "../gfx/video_driver.c" #include "../input/input_driver.c" #include "../audio/audio_driver.c" -#include "../osk_driver.c" +#include "../osk/osk_driver.c" #include "../driver.c" /*============================================================ diff --git a/osk_driver.c b/osk/osk_driver.c similarity index 98% rename from osk_driver.c rename to osk/osk_driver.c index 09f142cb01..7997d196cb 100644 --- a/osk_driver.c +++ b/osk/osk_driver.c @@ -17,8 +17,8 @@ #include #include #include "osk_driver.h" -#include "driver.h" -#include "general.h" +#include "../driver.h" +#include "../general.h" static const input_osk_driver_t *osk_drivers[] = { #ifdef __CELLOS_LV2__ diff --git a/osk_driver.h b/osk/osk_driver.h similarity index 100% rename from osk_driver.h rename to osk/osk_driver.h From 4b0bd67d8d8cd62450e2e25ef85f72c1f875ebc1 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Mon, 12 Jan 2015 19:42:43 +0100 Subject: [PATCH 115/156] Split up camera driver code into separate file camera_driver.c --- Makefile.common | 1 + camera_driver.c | 217 ++++++++++++++++++++++++++++++++++++++++++++++ camera_driver.h | 125 ++++++++++++++++++++++++++ driver.c | 196 ----------------------------------------- driver.h | 69 +-------------- griffin/griffin.c | 1 + 6 files changed, 345 insertions(+), 264 deletions(-) create mode 100644 camera_driver.c create mode 100644 camera_driver.h diff --git a/Makefile.common b/Makefile.common index 06e76c795b..fe79e2fc83 100644 --- a/Makefile.common +++ b/Makefile.common @@ -101,6 +101,7 @@ OBJ += frontend/frontend.o \ input/input_driver.o \ gfx/video_driver.o \ osk/osk_driver.o \ + camera_driver.o \ driver.o \ settings.o \ settings_list.o \ diff --git a/camera_driver.c b/camera_driver.c new file mode 100644 index 0000000000..05cba33954 --- /dev/null +++ b/camera_driver.c @@ -0,0 +1,217 @@ +/* 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 . + */ + +#include +#include +#include "camera_driver.h" +#include "driver.h" +#include "general.h" + +static const camera_driver_t *camera_drivers[] = { +#ifdef HAVE_V4L2 + &camera_v4l2, +#endif +#ifdef EMSCRIPTEN + &camera_rwebcam, +#endif +#ifdef ANDROID + &camera_android, +#endif +#if defined(MAC_OS_X_VERSION_10_7) || defined(__IPHONE_4_0) + &camera_apple, +#endif + &camera_null, + NULL, +}; + +/** + * camera_driver_find_handle: + * @index : index of driver to get handle to. + * + * Returns: handle to camera driver at index. Can be NULL + * if nothing found. + **/ +const void *camera_driver_find_handle(int index) +{ + const void *drv = camera_drivers[index]; + if (!drv) + return NULL; + return drv; +} + +/** + * camera_driver_find_ident: + * @index : index of driver to get handle to. + * + * Returns: Human-readable identifier of camera driver at index. Can be NULL + * if nothing found. + **/ +const char *camera_driver_find_ident(int index) +{ + const camera_driver_t *drv = camera_drivers[index]; + if (!drv) + return NULL; + return drv->ident; +} + +/** + * config_get_camera_driver_options: + * + * Get an enumerated list of all camera driver names, + * separated by '|'. + * + * Returns: string listing of all camera driver names, + * separated by '|'. + **/ +const char* config_get_camera_driver_options(void) +{ + union string_list_elem_attr attr; + unsigned i; + char *options = NULL; + int options_len = 0; + struct string_list *options_l = string_list_new(); + + attr.i = 0; + + for (i = 0; camera_driver_find_handle(i); i++) + { + const char *opt = camera_driver_find_ident(i); + options_len += strlen(opt) + 1; + string_list_append(options_l, opt, attr); + } + + options = (char*)calloc(options_len, sizeof(char)); + + string_list_join_concat(options, options_len, options_l, "|"); + + string_list_free(options_l); + options_l = NULL; + + return options; +} + +void find_camera_driver(void) +{ + int i = find_driver_index("camera_driver", g_settings.camera.driver); + if (i >= 0) + driver.camera = camera_driver_find_handle(i); + else + { + unsigned d; + RARCH_ERR("Couldn't find any camera driver named \"%s\"\n", + g_settings.camera.driver); + RARCH_LOG_OUTPUT("Available camera drivers are:\n"); + for (d = 0; camera_driver_find_handle(d); d++) + RARCH_LOG_OUTPUT("\t%s\n", camera_driver_find_ident(d)); + + RARCH_WARN("Going to default to first camera driver...\n"); + + driver.camera = camera_driver_find_handle(0); + + if (!driver.camera) + rarch_fail(1, "find_camera_driver()"); + } +} + +/** + * driver_camera_start: + * + * Starts camera driver interface. + * Used by RETRO_ENVIRONMENT_GET_CAMERA_INTERFACE. + * + * Returns: true (1) if successful, otherwise false (0). + **/ +bool driver_camera_start(void) +{ + if (driver.camera && driver.camera_data && driver.camera->start) + { + if (g_settings.camera.allow) + return driver.camera->start(driver.camera_data); + + msg_queue_push(g_extern.msg_queue, + "Camera is explicitly disabled.\n", 1, 180); + } + return false; +} + +/** + * driver_camera_stop: + * + * Stops camera driver. + * Used by RETRO_ENVIRONMENT_GET_CAMERA_INTERFACE. + * + * Returns: true (1) if successful, otherwise false (0). + **/ +void driver_camera_stop(void) +{ + if (driver.camera && driver.camera->stop && driver.camera_data) + driver.camera->stop(driver.camera_data); +} + +/** + * driver_camera_poll: + * + * Call camera driver's poll function. + * Used by RETRO_ENVIRONMENT_GET_CAMERA_INTERFACE. + * + * Returns: true (1) if successful, otherwise false (0). + **/ +void driver_camera_poll(void) +{ + if (driver.camera && driver.camera->poll && driver.camera_data) + driver.camera->poll(driver.camera_data, + g_extern.system.camera_callback.frame_raw_framebuffer, + g_extern.system.camera_callback.frame_opengl_texture); +} + +void init_camera(void) +{ + /* Resource leaks will follow if camera is initialized twice. */ + if (driver.camera_data) + return; + + find_camera_driver(); + + driver.camera_data = driver.camera->init( + *g_settings.camera.device ? g_settings.camera.device : NULL, + g_extern.system.camera_callback.caps, + g_settings.camera.width ? + g_settings.camera.width : g_extern.system.camera_callback.width, + g_settings.camera.height ? + g_settings.camera.height : g_extern.system.camera_callback.height); + + if (!driver.camera_data) + { + RARCH_ERR("Failed to initialize camera driver. Will continue without camera.\n"); + driver.camera_active = false; + } + + if (g_extern.system.camera_callback.initialized) + g_extern.system.camera_callback.initialized(); +} + +void uninit_camera(void) +{ + if (driver.camera_data && driver.camera) + { + if (g_extern.system.camera_callback.deinitialized) + g_extern.system.camera_callback.deinitialized(); + + if (driver.camera->free) + driver.camera->free(driver.camera_data); + } + driver.camera_data = NULL; +} diff --git a/camera_driver.h b/camera_driver.h new file mode 100644 index 0000000000..9e634ac66c --- /dev/null +++ b/camera_driver.h @@ -0,0 +1,125 @@ +/* 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 . + */ + +#ifndef __CAMERA_DRIVER__H +#define __CAMERA_DRIVER__H + +#include +#include +#include "libretro.h" + +#ifdef __cplusplus +extern "C" { +#endif + +typedef struct camera_driver +{ + /* FIXME: params for initialization - queries for resolution, + * framerate, color format which might or might not be honored. */ + void *(*init)(const char *device, uint64_t buffer_types, + unsigned width, unsigned height); + + void (*free)(void *data); + + bool (*start)(void *data); + void (*stop)(void *data); + + /* Polls the camera driver. + * Will call the appropriate callback if a new frame is ready. + * Returns true if a new frame was handled. */ + bool (*poll)(void *data, + retro_camera_frame_raw_framebuffer_t frame_raw_cb, + retro_camera_frame_opengl_texture_t frame_gl_cb); + + const char *ident; +} camera_driver_t; + +/** + * driver_camera_start: + * + * Starts camera driver. + * Used by RETRO_ENVIRONMENT_GET_CAMERA_INTERFACE. + * + * Returns: true (1) if successful, otherwise false (0). + **/ +bool driver_camera_start(void); + +/** + * driver_camera_stop: + * + * Stops camera driver. + * Used by RETRO_ENVIRONMENT_GET_CAMERA_INTERFACE. + * + * Returns: true (1) if successful, otherwise false (0). + **/ +void driver_camera_stop(void); + +/** + * driver_camera_poll: + * + * Call camera driver's poll function. + * Used by RETRO_ENVIRONMENT_GET_CAMERA_INTERFACE. + * + * Returns: true (1) if successful, otherwise false (0). + **/ +void driver_camera_poll(void); + +/** + * config_get_camera_driver_options: + * + * Get an enumerated list of all camera driver names, + * separated by '|'. + * + * Returns: string listing of all camera driver names, + * separated by '|'. + **/ +const char* config_get_camera_driver_options(void); + +/** + * camera_driver_find_handle: + * @index : index of driver to get handle to. + * + * Returns: handle to camera driver at index. Can be NULL + * if nothing found. + **/ +const void *camera_driver_find_handle(int index); + +/** + * camera_driver_find_ident: + * @index : index of driver to get handle to. + * + * Returns: Human-readable identifier of camera driver at index. Can be NULL + * if nothing found. + **/ +const char *camera_driver_find_ident(int index); + +void find_camera_driver(void); + +void init_camera(void); + +void uninit_camera(void); + +extern camera_driver_t camera_v4l2; +extern camera_driver_t camera_android; +extern camera_driver_t camera_rwebcam; +extern camera_driver_t camera_apple; +extern camera_driver_t camera_null; + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/driver.c b/driver.c index e41e3bb743..2e44b3d376 100644 --- a/driver.c +++ b/driver.c @@ -40,89 +40,6 @@ driver_t driver; -static const camera_driver_t *camera_drivers[] = { -#ifdef HAVE_V4L2 - &camera_v4l2, -#endif -#ifdef EMSCRIPTEN - &camera_rwebcam, -#endif -#ifdef ANDROID - &camera_android, -#endif -#if defined(MAC_OS_X_VERSION_10_7) || defined(__IPHONE_4_0) - &camera_apple, -#endif - &camera_null, - NULL, -}; - -/** - * camera_driver_find_handle: - * @index : index of driver to get handle to. - * - * Returns: handle to camera driver at index. Can be NULL - * if nothing found. - **/ -static const void *camera_driver_find_handle(int index) -{ - const void *drv = camera_drivers[index]; - if (!drv) - return NULL; - return drv; -} - -/** - * camera_driver_find_ident: - * @index : index of driver to get handle to. - * - * Returns: Human-readable identifier of camera driver at index. Can be NULL - * if nothing found. - **/ -static const char *camera_driver_find_ident(int index) -{ - const camera_driver_t *drv = camera_drivers[index]; - if (!drv) - return NULL; - return drv->ident; -} - -/** - * config_get_camera_driver_options: - * - * Get an enumerated list of all camera driver names, - * separated by '|'. - * - * Returns: string listing of all camera driver names, - * separated by '|'. - **/ -const char* config_get_camera_driver_options(void) -{ - union string_list_elem_attr attr; - unsigned i; - char *options = NULL; - int options_len = 0; - struct string_list *options_l = string_list_new(); - - attr.i = 0; - - for (i = 0; camera_driver_find_handle(i); i++) - { - const char *opt = camera_driver_find_ident(i); - options_len += strlen(opt) + 1; - string_list_append(options_l, opt, attr); - } - - options = (char*)calloc(options_len, sizeof(char)); - - string_list_join_concat(options, options_len, options_l, "|"); - - string_list_free(options_l); - options_l = NULL; - - return options; -} - static const location_driver_t *location_drivers[] = { #ifdef ANDROID &location_android, @@ -463,119 +380,6 @@ void find_next_driver(const char *label, char *str, size_t sizeof_str) RARCH_WARN("Couldn't find any next driver (current one: \"%s\").\n", str); } -static void find_camera_driver(void) -{ - int i = find_driver_index("camera_driver", g_settings.camera.driver); - if (i >= 0) - driver.camera = camera_driver_find_handle(i); - else - { - unsigned d; - RARCH_ERR("Couldn't find any camera driver named \"%s\"\n", - g_settings.camera.driver); - RARCH_LOG_OUTPUT("Available camera drivers are:\n"); - for (d = 0; camera_driver_find_handle(d); d++) - RARCH_LOG_OUTPUT("\t%s\n", camera_driver_find_ident(d)); - - RARCH_WARN("Going to default to first camera driver...\n"); - - driver.camera = camera_driver_find_handle(0); - - if (!driver.camera) - rarch_fail(1, "find_camera_driver()"); - } -} - -/** - * driver_camera_start: - * - * Starts camera driver interface. - * Used by RETRO_ENVIRONMENT_GET_CAMERA_INTERFACE. - * - * Returns: true (1) if successful, otherwise false (0). - **/ -bool driver_camera_start(void) -{ - if (driver.camera && driver.camera_data && driver.camera->start) - { - if (g_settings.camera.allow) - return driver.camera->start(driver.camera_data); - - msg_queue_push(g_extern.msg_queue, - "Camera is explicitly disabled.\n", 1, 180); - } - return false; -} - -/** - * driver_camera_stop: - * - * Stops camera driver. - * Used by RETRO_ENVIRONMENT_GET_CAMERA_INTERFACE. - * - * Returns: true (1) if successful, otherwise false (0). - **/ -void driver_camera_stop(void) -{ - if (driver.camera && driver.camera->stop && driver.camera_data) - driver.camera->stop(driver.camera_data); -} - -/** - * driver_camera_poll: - * - * Call camera driver's poll function. - * Used by RETRO_ENVIRONMENT_GET_CAMERA_INTERFACE. - * - * Returns: true (1) if successful, otherwise false (0). - **/ -void driver_camera_poll(void) -{ - if (driver.camera && driver.camera->poll && driver.camera_data) - driver.camera->poll(driver.camera_data, - g_extern.system.camera_callback.frame_raw_framebuffer, - g_extern.system.camera_callback.frame_opengl_texture); -} - -static void init_camera(void) -{ - /* Resource leaks will follow if camera is initialized twice. */ - if (driver.camera_data) - return; - - find_camera_driver(); - - driver.camera_data = driver.camera->init( - *g_settings.camera.device ? g_settings.camera.device : NULL, - g_extern.system.camera_callback.caps, - g_settings.camera.width ? - g_settings.camera.width : g_extern.system.camera_callback.width, - g_settings.camera.height ? - g_settings.camera.height : g_extern.system.camera_callback.height); - - if (!driver.camera_data) - { - RARCH_ERR("Failed to initialize camera driver. Will continue without camera.\n"); - driver.camera_active = false; - } - - if (g_extern.system.camera_callback.initialized) - g_extern.system.camera_callback.initialized(); -} - -static void uninit_camera(void) -{ - if (driver.camera_data && driver.camera) - { - if (g_extern.system.camera_callback.deinitialized) - g_extern.system.camera_callback.deinitialized(); - - if (driver.camera->free) - driver.camera->free(driver.camera_data); - } - driver.camera_data = NULL; -} - static void find_location_driver(void) { int i = find_driver_index("location_driver", g_settings.location.driver); diff --git a/driver.h b/driver.h index 71dade44a3..bef06b1f0e 100644 --- a/driver.h +++ b/driver.h @@ -32,6 +32,7 @@ #include "menu/menu_driver.h" #include "osk/osk_driver.h" +#include "camera_driver.h" #include "audio/resamplers/resampler.h" #include "record/ffemu.h" @@ -161,27 +162,6 @@ enum analog_dpad_mode ANALOG_DPAD_LAST }; -typedef struct camera_driver -{ - /* FIXME: params for initialization - queries for resolution, - * framerate, color format which might or might not be honored. */ - void *(*init)(const char *device, uint64_t buffer_types, - unsigned width, unsigned height); - - void (*free)(void *data); - - bool (*start)(void *data); - void (*stop)(void *data); - - /* Polls the camera driver. - * Will call the appropriate callback if a new frame is ready. - * Returns true if a new frame was handled. */ - bool (*poll)(void *data, - retro_camera_frame_raw_framebuffer_t frame_raw_cb, - retro_camera_frame_opengl_texture_t frame_gl_cb); - - const char *ident; -} camera_driver_t; typedef struct location_driver { @@ -491,36 +471,6 @@ float driver_sensor_get_input(unsigned port, unsigned action); **/ void *driver_video_resolve(const video_driver_t **drv); -/** - * driver_camera_start: - * - * Starts camera driver. - * Used by RETRO_ENVIRONMENT_GET_CAMERA_INTERFACE. - * - * Returns: true (1) if successful, otherwise false (0). - **/ -bool driver_camera_start(void); - -/** - * driver_camera_stop: - * - * Stops camera driver. - * Used by RETRO_ENVIRONMENT_GET_CAMERA_INTERFACE. - * - * Returns: true (1) if successful, otherwise false (0). - **/ -void driver_camera_stop(void); - -/** - * driver_camera_poll: - * - * Call camera driver's poll function. - * Used by RETRO_ENVIRONMENT_GET_CAMERA_INTERFACE. - * - * Returns: true (1) if successful, otherwise false (0). - **/ -void driver_camera_poll(void); - /** * driver_location_start: * @@ -582,17 +532,6 @@ bool driver_update_system_av_info(const struct retro_system_av_info *info); extern driver_t driver; -/** - * config_get_camera_driver_options: - * - * Get an enumerated list of all camera driver names, - * separated by '|'. - * - * Returns: string listing of all camera driver names, - * separated by '|'. - **/ -const char* config_get_camera_driver_options(void); - /** * config_get_video_driver_options: * @@ -638,12 +577,6 @@ const char* config_get_menu_driver_options(void); **/ int find_driver_index(const char * label, const char *drv); -extern camera_driver_t camera_v4l2; -extern camera_driver_t camera_android; -extern camera_driver_t camera_rwebcam; -extern camera_driver_t camera_apple; -extern camera_driver_t camera_null; - extern location_driver_t location_apple; extern location_driver_t location_android; extern location_driver_t location_null; diff --git a/griffin/griffin.c b/griffin/griffin.c index df71ac2a48..ce4226cae9 100644 --- a/griffin/griffin.c +++ b/griffin/griffin.c @@ -500,6 +500,7 @@ DRIVERS #include "../input/input_driver.c" #include "../audio/audio_driver.c" #include "../osk/osk_driver.c" +#include "../camera_driver.c" #include "../driver.c" /*============================================================ From f45d9efb375d07d49db8eb0597bf27396b7e98d2 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Mon, 12 Jan 2015 19:44:29 +0100 Subject: [PATCH 116/156] Move camera_driver.c to camera/ --- Makefile.common | 2 +- camera_driver.c => camera/camera_driver.c | 4 ++-- camera_driver.h => camera/camera_driver.h | 2 +- driver.h | 2 +- griffin/griffin.c | 2 +- 5 files changed, 6 insertions(+), 6 deletions(-) rename camera_driver.c => camera/camera_driver.c (99%) rename camera_driver.h => camera/camera_driver.h (99%) diff --git a/Makefile.common b/Makefile.common index fe79e2fc83..229edcb683 100644 --- a/Makefile.common +++ b/Makefile.common @@ -101,7 +101,7 @@ OBJ += frontend/frontend.o \ input/input_driver.o \ gfx/video_driver.o \ osk/osk_driver.o \ - camera_driver.o \ + camera/camera_driver.o \ driver.o \ settings.o \ settings_list.o \ diff --git a/camera_driver.c b/camera/camera_driver.c similarity index 99% rename from camera_driver.c rename to camera/camera_driver.c index 05cba33954..9f88e5eb29 100644 --- a/camera_driver.c +++ b/camera/camera_driver.c @@ -17,8 +17,8 @@ #include #include #include "camera_driver.h" -#include "driver.h" -#include "general.h" +#include "../driver.h" +#include "../general.h" static const camera_driver_t *camera_drivers[] = { #ifdef HAVE_V4L2 diff --git a/camera_driver.h b/camera/camera_driver.h similarity index 99% rename from camera_driver.h rename to camera/camera_driver.h index 9e634ac66c..a03f8833c9 100644 --- a/camera_driver.h +++ b/camera/camera_driver.h @@ -19,7 +19,7 @@ #include #include -#include "libretro.h" +#include "../libretro.h" #ifdef __cplusplus extern "C" { diff --git a/driver.h b/driver.h index bef06b1f0e..43f45fdd66 100644 --- a/driver.h +++ b/driver.h @@ -32,7 +32,7 @@ #include "menu/menu_driver.h" #include "osk/osk_driver.h" -#include "camera_driver.h" +#include "camera/camera_driver.h" #include "audio/resamplers/resampler.h" #include "record/ffemu.h" diff --git a/griffin/griffin.c b/griffin/griffin.c index ce4226cae9..c068ab5eef 100644 --- a/griffin/griffin.c +++ b/griffin/griffin.c @@ -500,7 +500,7 @@ DRIVERS #include "../input/input_driver.c" #include "../audio/audio_driver.c" #include "../osk/osk_driver.c" -#include "../camera_driver.c" +#include "../camera/camera_driver.c" #include "../driver.c" /*============================================================ From a71b143dade5530c664049a2c0408318ba4316de Mon Sep 17 00:00:00 2001 From: twinaphex Date: Mon, 12 Jan 2015 19:51:33 +0100 Subject: [PATCH 117/156] Move location driver code to separate file location_driver.c --- Makefile.common | 1 + driver.c | 214 ----------------------------------------- driver.h | 78 +-------------- griffin/griffin.c | 1 + location_driver.c | 235 ++++++++++++++++++++++++++++++++++++++++++++++ location_driver.h | 129 +++++++++++++++++++++++++ 6 files changed, 367 insertions(+), 291 deletions(-) create mode 100644 location_driver.c create mode 100644 location_driver.h diff --git a/Makefile.common b/Makefile.common index 229edcb683..acdda586f8 100644 --- a/Makefile.common +++ b/Makefile.common @@ -102,6 +102,7 @@ OBJ += frontend/frontend.o \ gfx/video_driver.o \ osk/osk_driver.o \ camera/camera_driver.o \ + location_driver.o \ driver.o \ settings.o \ settings_list.o \ diff --git a/driver.c b/driver.c index 2e44b3d376..838324d0d3 100644 --- a/driver.c +++ b/driver.c @@ -40,85 +40,6 @@ driver_t driver; -static const location_driver_t *location_drivers[] = { -#ifdef ANDROID - &location_android, -#endif -#if defined(IOS) || defined(OSX) -#ifdef HAVE_LOCATION - &location_apple, -#endif -#endif - &location_null, - NULL, -}; - -/** - * location_driver_find_handle: - * @index : index of driver to get handle to. - * - * Returns: handle to location driver at index. Can be NULL - * if nothing found. - **/ -static const void *location_driver_find_handle(int index) -{ - const void *drv = location_drivers[index]; - if (!drv) - return NULL; - return drv; -} - -/** - * location_driver_find_ident: - * @index : index of driver to get handle to. - * - * Returns: Human-readable identifier of location driver at index. Can be NULL - * if nothing found. - **/ -static const char *location_driver_find_ident(int index) -{ - const location_driver_t *drv = location_drivers[index]; - if (!drv) - return NULL; - return drv->ident; -} - -/** - * config_get_location_driver_options: - * - * Get an enumerated list of all location driver names, - * separated by '|'. - * - * Returns: string listing of all location driver names, - * separated by '|'. - **/ -const char* config_get_location_driver_options(void) -{ - union string_list_elem_attr attr; - unsigned i; - char *options = NULL; - int options_len = 0; - struct string_list *options_l = string_list_new(); - - attr.i = 0; - - for (i = 0; location_driver_find_handle(i); i++) - { - const char *opt = location_driver_find_ident(i); - options_len += strlen(opt) + 1; - string_list_append(options_l, opt, attr); - } - - options = (char*)calloc(options_len, sizeof(char)); - - string_list_join_concat(options, options_len, options_l, "|"); - - string_list_free(options_l); - options_l = NULL; - - return options; -} - #ifdef HAVE_MENU static const menu_ctx_driver_t *menu_ctx_drivers[] = { #ifdef IOS @@ -380,141 +301,6 @@ void find_next_driver(const char *label, char *str, size_t sizeof_str) RARCH_WARN("Couldn't find any next driver (current one: \"%s\").\n", str); } -static void find_location_driver(void) -{ - int i = find_driver_index("location_driver", g_settings.location.driver); - if (i >= 0) - driver.location = location_driver_find_handle(i); - else - { - unsigned d; - RARCH_ERR("Couldn't find any location driver named \"%s\"\n", - g_settings.location.driver); - RARCH_LOG_OUTPUT("Available location drivers are:\n"); - for (d = 0; location_driver_find_handle(d); d++) - RARCH_LOG_OUTPUT("\t%s\n", location_driver_find_ident(d)); - - RARCH_WARN("Going to default to first location driver...\n"); - - driver.location = location_driver_find_handle(0); - - if (!driver.location) - rarch_fail(1, "find_location_driver()"); - } -} - -/** - * driver_location_start: - * - * Starts location driver interface.. - * Used by RETRO_ENVIRONMENT_GET_LOCATION_INTERFACE. - * - * Returns: true (1) if successful, otherwise false (0). - **/ -bool driver_location_start(void) -{ - if (driver.location && driver.location_data && driver.location->start) - { - if (g_settings.location.allow) - return driver.location->start(driver.location_data); - - msg_queue_push(g_extern.msg_queue, "Location is explicitly disabled.\n", 1, 180); - } - return false; -} - -/** - * driver_location_stop: - * - * Stops location driver interface.. - * Used by RETRO_ENVIRONMENT_GET_LOCATION_INTERFACE. - * - * Returns: true (1) if successful, otherwise false (0). - **/ -void driver_location_stop(void) -{ - if (driver.location && driver.location->stop && driver.location_data) - driver.location->stop(driver.location_data); -} - -/** - * driver_location_set_interval: - * @interval_msecs : Interval time in milliseconds. - * @interval_distance : Distance at which to update. - * - * Sets interval update time for location driver interface. - * Used by RETRO_ENVIRONMENT_GET_LOCATION_INTERFACE. - **/ -void driver_location_set_interval(unsigned interval_msecs, - unsigned interval_distance) -{ - if (driver.location && driver.location->set_interval - && driver.location_data) - driver.location->set_interval(driver.location_data, - interval_msecs, interval_distance); -} - -/** - * driver_location_get_position: - * @lat : Latitude of current position. - * @lon : Longitude of current position. - * @horiz_accuracy : Horizontal accuracy. - * @vert_accuracy : Vertical accuracy. - * - * Gets current positioning information from - * location driver interface. - * Used by RETRO_ENVIRONMENT_GET_LOCATION_INTERFACE. - * - * Returns: bool (1) if successful, otherwise false (0). - **/ -bool driver_location_get_position(double *lat, double *lon, - double *horiz_accuracy, double *vert_accuracy) -{ - if (driver.location && driver.location->get_position - && driver.location_data) - return driver.location->get_position(driver.location_data, - lat, lon, horiz_accuracy, vert_accuracy); - - *lat = 0.0; - *lon = 0.0; - *horiz_accuracy = 0.0; - *vert_accuracy = 0.0; - return false; -} - -static void init_location(void) -{ - /* Resource leaks will follow if location interface is initialized twice. */ - if (driver.location_data) - return; - - find_location_driver(); - - driver.location_data = driver.location->init(); - - if (!driver.location_data) - { - RARCH_ERR("Failed to initialize location driver. Will continue without location.\n"); - driver.location_active = false; - } - - if (g_extern.system.location_callback.initialized) - g_extern.system.location_callback.initialized(); -} - -static void uninit_location(void) -{ - if (driver.location_data && driver.location) - { - if (g_extern.system.location_callback.deinitialized) - g_extern.system.location_callback.deinitialized(); - - if (driver.location->free) - driver.location->free(driver.location_data); - } - driver.location_data = NULL; -} - #ifdef HAVE_MENU static void find_menu_driver(void) { diff --git a/driver.h b/driver.h index 43f45fdd66..9e70c4349b 100644 --- a/driver.h +++ b/driver.h @@ -33,6 +33,7 @@ #include "menu/menu_driver.h" #include "osk/osk_driver.h" #include "camera/camera_driver.h" +#include "location_driver.h" #include "audio/resamplers/resampler.h" #include "record/ffemu.h" @@ -162,22 +163,6 @@ enum analog_dpad_mode ANALOG_DPAD_LAST }; - -typedef struct location_driver -{ - void *(*init)(void); - void (*free)(void *data); - - bool (*start)(void *data); - void (*stop)(void *data); - - bool (*get_position)(void *data, double *lat, double *lon, - double *horiz_accuracy, double *vert_accuracy); - void (*set_interval)(void *data, unsigned interval_msecs, - unsigned interval_distance); - const char *ident; -} location_driver_t; - /* Flags for init_drivers/uninit_drivers */ enum { @@ -471,52 +456,6 @@ float driver_sensor_get_input(unsigned port, unsigned action); **/ void *driver_video_resolve(const video_driver_t **drv); -/** - * driver_location_start: - * - * Starts location driver interface.. - * Used by RETRO_ENVIRONMENT_GET_LOCATION_INTERFACE. - * - * Returns: true (1) if successful, otherwise false (0). - **/ -bool driver_location_start(void); - -/** - * driver_location_stop: - * - * Stops location driver interface.. - * Used by RETRO_ENVIRONMENT_GET_LOCATION_INTERFACE. - * - * Returns: true (1) if successful, otherwise false (0). - **/ -void driver_location_stop(void); - -/** - * driver_location_get_position: - * @lat : Latitude of current position. - * @lon : Longitude of current position. - * @horiz_accuracy : Horizontal accuracy. - * @vert_accuracy : Vertical accuracy. - * - * Gets current positioning information from - * location driver interface. - * Used by RETRO_ENVIRONMENT_GET_LOCATION_INTERFACE. - * - * Returns: bool (1) if successful, otherwise false (0). - **/ -bool driver_location_get_position(double *lat, double *lon, - double *horiz_accuracy, double *vert_accuracy); - -/** - * driver_location_set_interval: - * @interval_msecs : Interval time in milliseconds. - * @interval_distance : Distance at which to update. - * - * Sets interval update time for location driver interface. - * Used by RETRO_ENVIRONMENT_GET_LOCATION_INTERFACE. - **/ -void driver_location_set_interval(unsigned interval_msecs, - unsigned interval_distance); /** * driver_update_system_av_info: @@ -541,17 +480,6 @@ extern driver_t driver; **/ const char* config_get_video_driver_options(void); -/** - * config_get_location_driver_options: - * - * Get an enumerated list of all location driver names, - * separated by '|'. - * - * Returns: string listing of all location driver names, - * separated by '|'. - **/ -const char* config_get_location_driver_options(void); - #ifdef HAVE_MENU /** * config_get_menu_driver_options: @@ -577,10 +505,6 @@ const char* config_get_menu_driver_options(void); **/ int find_driver_index(const char * label, const char *drv); -extern location_driver_t location_apple; -extern location_driver_t location_android; -extern location_driver_t location_null; - extern rarch_joypad_driver_t *joypad_drivers[]; #ifdef __cplusplus diff --git a/griffin/griffin.c b/griffin/griffin.c index c068ab5eef..8cbeb0264c 100644 --- a/griffin/griffin.c +++ b/griffin/griffin.c @@ -501,6 +501,7 @@ DRIVERS #include "../audio/audio_driver.c" #include "../osk/osk_driver.c" #include "../camera/camera_driver.c" +#include "../location_driver.c" #include "../driver.c" /*============================================================ diff --git a/location_driver.c b/location_driver.c new file mode 100644 index 0000000000..5400f198dc --- /dev/null +++ b/location_driver.c @@ -0,0 +1,235 @@ +/* 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 . + */ + +#include +#include +#include "location_driver.h" +#include "driver.h" +#include "general.h" + +static const location_driver_t *location_drivers[] = { +#ifdef ANDROID + &location_android, +#endif +#if defined(IOS) || defined(OSX) +#ifdef HAVE_LOCATION + &location_apple, +#endif +#endif + &location_null, + NULL, +}; + +/** + * location_driver_find_handle: + * @index : index of driver to get handle to. + * + * Returns: handle to location driver at index. Can be NULL + * if nothing found. + **/ +const void *location_driver_find_handle(int index) +{ + const void *drv = location_drivers[index]; + if (!drv) + return NULL; + return drv; +} + +/** + * location_driver_find_ident: + * @index : index of driver to get handle to. + * + * Returns: Human-readable identifier of location driver at index. Can be NULL + * if nothing found. + **/ +const char *location_driver_find_ident(int index) +{ + const location_driver_t *drv = location_drivers[index]; + if (!drv) + return NULL; + return drv->ident; +} + +/** + * config_get_location_driver_options: + * + * Get an enumerated list of all location driver names, + * separated by '|'. + * + * Returns: string listing of all location driver names, + * separated by '|'. + **/ +const char* config_get_location_driver_options(void) +{ + union string_list_elem_attr attr; + unsigned i; + char *options = NULL; + int options_len = 0; + struct string_list *options_l = string_list_new(); + + attr.i = 0; + + for (i = 0; location_driver_find_handle(i); i++) + { + const char *opt = location_driver_find_ident(i); + options_len += strlen(opt) + 1; + string_list_append(options_l, opt, attr); + } + + options = (char*)calloc(options_len, sizeof(char)); + + string_list_join_concat(options, options_len, options_l, "|"); + + string_list_free(options_l); + options_l = NULL; + + return options; +} + +void find_location_driver(void) +{ + int i = find_driver_index("location_driver", g_settings.location.driver); + if (i >= 0) + driver.location = location_driver_find_handle(i); + else + { + unsigned d; + RARCH_ERR("Couldn't find any location driver named \"%s\"\n", + g_settings.location.driver); + RARCH_LOG_OUTPUT("Available location drivers are:\n"); + for (d = 0; location_driver_find_handle(d); d++) + RARCH_LOG_OUTPUT("\t%s\n", location_driver_find_ident(d)); + + RARCH_WARN("Going to default to first location driver...\n"); + + driver.location = location_driver_find_handle(0); + + if (!driver.location) + rarch_fail(1, "find_location_driver()"); + } +} + +/** + * driver_location_start: + * + * Starts location driver interface.. + * Used by RETRO_ENVIRONMENT_GET_LOCATION_INTERFACE. + * + * Returns: true (1) if successful, otherwise false (0). + **/ +bool driver_location_start(void) +{ + if (driver.location && driver.location_data && driver.location->start) + { + if (g_settings.location.allow) + return driver.location->start(driver.location_data); + + msg_queue_push(g_extern.msg_queue, "Location is explicitly disabled.\n", 1, 180); + } + return false; +} + +/** + * driver_location_stop: + * + * Stops location driver interface.. + * Used by RETRO_ENVIRONMENT_GET_LOCATION_INTERFACE. + * + * Returns: true (1) if successful, otherwise false (0). + **/ +void driver_location_stop(void) +{ + if (driver.location && driver.location->stop && driver.location_data) + driver.location->stop(driver.location_data); +} + +/** + * driver_location_set_interval: + * @interval_msecs : Interval time in milliseconds. + * @interval_distance : Distance at which to update. + * + * Sets interval update time for location driver interface. + * Used by RETRO_ENVIRONMENT_GET_LOCATION_INTERFACE. + **/ +void driver_location_set_interval(unsigned interval_msecs, + unsigned interval_distance) +{ + if (driver.location && driver.location->set_interval + && driver.location_data) + driver.location->set_interval(driver.location_data, + interval_msecs, interval_distance); +} + +/** + * driver_location_get_position: + * @lat : Latitude of current position. + * @lon : Longitude of current position. + * @horiz_accuracy : Horizontal accuracy. + * @vert_accuracy : Vertical accuracy. + * + * Gets current positioning information from + * location driver interface. + * Used by RETRO_ENVIRONMENT_GET_LOCATION_INTERFACE. + * + * Returns: bool (1) if successful, otherwise false (0). + **/ +bool driver_location_get_position(double *lat, double *lon, + double *horiz_accuracy, double *vert_accuracy) +{ + if (driver.location && driver.location->get_position + && driver.location_data) + return driver.location->get_position(driver.location_data, + lat, lon, horiz_accuracy, vert_accuracy); + + *lat = 0.0; + *lon = 0.0; + *horiz_accuracy = 0.0; + *vert_accuracy = 0.0; + return false; +} + +void init_location(void) +{ + /* Resource leaks will follow if location interface is initialized twice. */ + if (driver.location_data) + return; + + find_location_driver(); + + driver.location_data = driver.location->init(); + + if (!driver.location_data) + { + RARCH_ERR("Failed to initialize location driver. Will continue without location.\n"); + driver.location_active = false; + } + + if (g_extern.system.location_callback.initialized) + g_extern.system.location_callback.initialized(); +} + +void uninit_location(void) +{ + if (driver.location_data && driver.location) + { + if (g_extern.system.location_callback.deinitialized) + g_extern.system.location_callback.deinitialized(); + + if (driver.location->free) + driver.location->free(driver.location_data); + } + driver.location_data = NULL; +} diff --git a/location_driver.h b/location_driver.h new file mode 100644 index 0000000000..05bb5fed9e --- /dev/null +++ b/location_driver.h @@ -0,0 +1,129 @@ +/* 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 . + */ + +#ifndef __LOCATION_DRIVER__H +#define __LOCATION_DRIVER__H + +#ifdef __cplusplus +extern "C" { +#endif + +typedef struct location_driver +{ + void *(*init)(void); + void (*free)(void *data); + + bool (*start)(void *data); + void (*stop)(void *data); + + bool (*get_position)(void *data, double *lat, double *lon, + double *horiz_accuracy, double *vert_accuracy); + void (*set_interval)(void *data, unsigned interval_msecs, + unsigned interval_distance); + const char *ident; +} location_driver_t; + +/** + * driver_location_start: + * + * Starts location driver interface.. + * Used by RETRO_ENVIRONMENT_GET_LOCATION_INTERFACE. + * + * Returns: true (1) if successful, otherwise false (0). + **/ +bool driver_location_start(void); + +/** + * driver_location_stop: + * + * Stops location driver interface.. + * Used by RETRO_ENVIRONMENT_GET_LOCATION_INTERFACE. + * + * Returns: true (1) if successful, otherwise false (0). + **/ +void driver_location_stop(void); + +/** + * driver_location_get_position: + * @lat : Latitude of current position. + * @lon : Longitude of current position. + * @horiz_accuracy : Horizontal accuracy. + * @vert_accuracy : Vertical accuracy. + * + * Gets current positioning information from + * location driver interface. + * Used by RETRO_ENVIRONMENT_GET_LOCATION_INTERFACE. + * + * Returns: bool (1) if successful, otherwise false (0). + **/ +bool driver_location_get_position(double *lat, double *lon, + double *horiz_accuracy, double *vert_accuracy); + +/** + * driver_location_set_interval: + * @interval_msecs : Interval time in milliseconds. + * @interval_distance : Distance at which to update. + * + * Sets interval update time for location driver interface. + * Used by RETRO_ENVIRONMENT_GET_LOCATION_INTERFACE. + **/ +void driver_location_set_interval(unsigned interval_msecs, + unsigned interval_distance); + +/** + * config_get_location_driver_options: + * + * Get an enumerated list of all location driver names, + * separated by '|'. + * + * Returns: string listing of all location driver names, + * separated by '|'. + **/ +const char* config_get_location_driver_options(void); + +/** + * location_driver_find_handle: + * @index : index of driver to get handle to. + * + * Returns: handle to location driver at index. Can be NULL + * if nothing found. + **/ +const void *location_driver_find_handle(int index); + +/** + * location_driver_find_ident: + * @index : index of driver to get handle to. + * + * Returns: Human-readable identifier of location driver at index. Can be NULL + * if nothing found. + **/ +const char *location_driver_find_ident(int index); + +void find_location_driver(void); + +void init_location(void); + +void uninit_location(void); + +extern location_driver_t location_apple; +extern location_driver_t location_android; +extern location_driver_t location_null; + +#ifdef __cplusplus +} +#endif + +#endif From c4bf097d7f5c23d54109d739fa6b857ca8952de0 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Mon, 12 Jan 2015 19:53:10 +0100 Subject: [PATCH 118/156] Move location_driver.c to location/ --- Makefile.common | 2 +- driver.h | 2 +- griffin/griffin.c | 2 +- location_driver.c => location/location_driver.c | 4 ++-- location_driver.h => location/location_driver.h | 4 ++++ 5 files changed, 9 insertions(+), 5 deletions(-) rename location_driver.c => location/location_driver.c (99%) rename location_driver.h => location/location_driver.h (98%) diff --git a/Makefile.common b/Makefile.common index acdda586f8..69ef79a020 100644 --- a/Makefile.common +++ b/Makefile.common @@ -102,7 +102,7 @@ OBJ += frontend/frontend.o \ gfx/video_driver.o \ osk/osk_driver.o \ camera/camera_driver.o \ - location_driver.o \ + location/location_driver.o \ driver.o \ settings.o \ settings_list.o \ diff --git a/driver.h b/driver.h index 9e70c4349b..1af3b652bc 100644 --- a/driver.h +++ b/driver.h @@ -33,7 +33,7 @@ #include "menu/menu_driver.h" #include "osk/osk_driver.h" #include "camera/camera_driver.h" -#include "location_driver.h" +#include "location/location_driver.h" #include "audio/resamplers/resampler.h" #include "record/ffemu.h" diff --git a/griffin/griffin.c b/griffin/griffin.c index 8cbeb0264c..16cddd60c4 100644 --- a/griffin/griffin.c +++ b/griffin/griffin.c @@ -501,7 +501,7 @@ DRIVERS #include "../audio/audio_driver.c" #include "../osk/osk_driver.c" #include "../camera/camera_driver.c" -#include "../location_driver.c" +#include "../location/location_driver.c" #include "../driver.c" /*============================================================ diff --git a/location_driver.c b/location/location_driver.c similarity index 99% rename from location_driver.c rename to location/location_driver.c index 5400f198dc..e764d3961b 100644 --- a/location_driver.c +++ b/location/location_driver.c @@ -17,8 +17,8 @@ #include #include #include "location_driver.h" -#include "driver.h" -#include "general.h" +#include "../driver.h" +#include "../general.h" static const location_driver_t *location_drivers[] = { #ifdef ANDROID diff --git a/location_driver.h b/location/location_driver.h similarity index 98% rename from location_driver.h rename to location/location_driver.h index 05bb5fed9e..f2c5c617ae 100644 --- a/location_driver.h +++ b/location/location_driver.h @@ -17,6 +17,10 @@ #ifndef __LOCATION_DRIVER__H #define __LOCATION_DRIVER__H +#include +#include +#include + #ifdef __cplusplus extern "C" { #endif From 6b2fced631d6348009aacc1e72d04ce2b591a3f4 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Mon, 12 Jan 2015 20:00:43 +0100 Subject: [PATCH 119/156] Split up menu code into separate file menu_driver.c --- Makefile.common | 1 + driver.c | 138 ---------------------------------------- driver.h | 13 ---- griffin/griffin.c | 1 + menu/menu_driver.h | 34 ++++++++++ menu_driver.c | 154 +++++++++++++++++++++++++++++++++++++++++++++ 6 files changed, 190 insertions(+), 151 deletions(-) create mode 100644 menu_driver.c diff --git a/Makefile.common b/Makefile.common index 69ef79a020..92b7b41792 100644 --- a/Makefile.common +++ b/Makefile.common @@ -102,6 +102,7 @@ OBJ += frontend/frontend.o \ gfx/video_driver.o \ osk/osk_driver.o \ camera/camera_driver.o \ + menu_driver.o \ location/location_driver.o \ driver.o \ settings.o \ diff --git a/driver.c b/driver.c index 838324d0d3..08d1dd98b9 100644 --- a/driver.c +++ b/driver.c @@ -40,99 +40,6 @@ driver_t driver; -#ifdef HAVE_MENU -static const menu_ctx_driver_t *menu_ctx_drivers[] = { -#ifdef IOS - &menu_ctx_ios, -#endif -#if defined(HAVE_RMENU) - &menu_ctx_rmenu, -#endif -#if defined(HAVE_RMENU_XUI) - &menu_ctx_rmenu_xui, -#endif -#if defined(HAVE_LAKKA) - &menu_ctx_lakka, -#endif -#if defined(HAVE_GLUI) - &menu_ctx_glui, -#endif -#if defined(HAVE_XMB) - &menu_ctx_xmb, -#endif -#if defined(HAVE_RGUI) - &menu_ctx_rgui, -#endif - NULL -}; - -/** - * menu_driver_find_handle: - * @index : index of driver to get handle to. - * - * Returns: handle to menu driver at index. Can be NULL - * if nothing found. - **/ -static const void *menu_driver_find_handle(int index) -{ - const void *drv = menu_ctx_drivers[index]; - if (!drv) - return NULL; - return drv; -} - -/** - * menu_driver_find_ident: - * @index : index of driver to get handle to. - * - * Returns: Human-readable identifier of menu driver at index. Can be NULL - * if nothing found. - **/ -static const char *menu_driver_find_ident(int index) -{ - const menu_ctx_driver_t *drv = menu_ctx_drivers[index]; - if (!drv) - return NULL; - return drv->ident; -} - -/** - * config_get_menu_driver_options: - * - * Get an enumerated list of all menu driver names, - * separated by '|'. - * - * Returns: string listing of all menu driver names, - * separated by '|'. - **/ -const char* config_get_menu_driver_options(void) -{ - union string_list_elem_attr attr; - unsigned i; - char *options = NULL; - int options_len = 0; - struct string_list *options_l = string_list_new(); - - attr.i = 0; - - for (i = 0; menu_driver_find_handle(i); i++) - { - const char *opt = menu_driver_find_ident(i); - options_len += strlen(opt) + 1; - string_list_append(options_l, opt, attr); - } - - options = (char*)calloc(options_len, sizeof(char)); - - string_list_join_concat(options, options_len, options_l, "|"); - - string_list_free(options_l); - options_l = NULL; - - return options; -} -#endif - /** * joypad_driver_find_handle: * @index : index of driver to get handle to. @@ -301,30 +208,6 @@ void find_next_driver(const char *label, char *str, size_t sizeof_str) RARCH_WARN("Couldn't find any next driver (current one: \"%s\").\n", str); } -#ifdef HAVE_MENU -static void find_menu_driver(void) -{ - int i = find_driver_index("menu_driver", g_settings.menu.driver); - if (i >= 0) - driver.menu_ctx = menu_driver_find_handle(i); - else - { - unsigned d; - RARCH_WARN("Couldn't find any menu driver named \"%s\"\n", - g_settings.menu.driver); - RARCH_LOG_OUTPUT("Available menu drivers are:\n"); - for (d = 0; menu_driver_find_handle(d); d++) - RARCH_LOG_OUTPUT("\t%s\n", menu_driver_find_ident(d)); - RARCH_WARN("Going to default to first menu driver...\n"); - - driver.menu_ctx = menu_driver_find_handle(0); - - if (!driver.menu_ctx) - rarch_fail(1, "find_menu_driver()"); - } -} -#endif - /** * init_drivers_pre: * @@ -544,27 +427,6 @@ bool driver_update_system_av_info(const struct retro_system_av_info *info) return true; } -#ifdef HAVE_MENU -static void init_menu(void) -{ - if (driver.menu) - return; - - find_menu_driver(); - if (!(driver.menu = (menu_handle_t*)menu_init(driver.menu_ctx))) - { - RARCH_ERR("Cannot initialize menu.\n"); - rarch_fail(1, "init_menu()"); - } - - if (!(menu_init_list(driver.menu))) - { - RARCH_ERR("Cannot initialize menu lists.\n"); - rarch_fail(1, "init_menu()"); - } -} -#endif - static void deinit_pixel_converter(void) { scaler_ctx_gen_reset(&driver.scaler); diff --git a/driver.h b/driver.h index 1af3b652bc..770c9a09e2 100644 --- a/driver.h +++ b/driver.h @@ -480,19 +480,6 @@ extern driver_t driver; **/ const char* config_get_video_driver_options(void); -#ifdef HAVE_MENU -/** - * config_get_menu_driver_options: - * - * Get an enumerated list of all menu driver names, - * separated by '|'. - * - * Returns: string listing of all menu driver names, - * separated by '|'. - **/ -const char* config_get_menu_driver_options(void); -#endif - /** * find_driver_index: * @label : string of driver type to be found. diff --git a/griffin/griffin.c b/griffin/griffin.c index 16cddd60c4..83c0c832af 100644 --- a/griffin/griffin.c +++ b/griffin/griffin.c @@ -502,6 +502,7 @@ DRIVERS #include "../osk/osk_driver.c" #include "../camera/camera_driver.c" #include "../location/location_driver.c" +#include "../menu_driver.c" #include "../driver.c" /*============================================================ diff --git a/menu/menu_driver.h b/menu/menu_driver.h index 2a054b255f..99bea6ee06 100644 --- a/menu/menu_driver.h +++ b/menu/menu_driver.h @@ -20,6 +20,7 @@ #include #include #include +#include #include "menu_list.h" #include "../settings_list.h" @@ -195,6 +196,39 @@ typedef struct menu_ctx_driver const char *ident; } menu_ctx_driver_t; +/** + * menu_driver_find_handle: + * @index : index of driver to get handle to. + * + * Returns: handle to menu driver at index. Can be NULL + * if nothing found. + **/ +const void *menu_driver_find_handle(int index); + +/** + * menu_driver_find_ident: + * @index : index of driver to get handle to. + * + * Returns: Human-readable identifier of menu driver at index. Can be NULL + * if nothing found. + **/ +const char *menu_driver_find_ident(int index); + +/** + * config_get_menu_driver_options: + * + * Get an enumerated list of all menu driver names, + * separated by '|'. + * + * Returns: string listing of all menu driver names, + * separated by '|'. + **/ +const char* config_get_menu_driver_options(void); + +void find_menu_driver(void); + +void init_menu(void); + extern menu_ctx_driver_t menu_ctx_rmenu; extern menu_ctx_driver_t menu_ctx_rmenu_xui; extern menu_ctx_driver_t menu_ctx_rgui; diff --git a/menu_driver.c b/menu_driver.c new file mode 100644 index 0000000000..59505695a7 --- /dev/null +++ b/menu_driver.c @@ -0,0 +1,154 @@ +/* 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 . + */ + +#include +#include +#include "menu/menu_driver.h" +#include "menu/menu.h" +#include "driver.h" +#include "general.h" + +static const menu_ctx_driver_t *menu_ctx_drivers[] = { +#ifdef IOS + &menu_ctx_ios, +#endif +#if defined(HAVE_RMENU) + &menu_ctx_rmenu, +#endif +#if defined(HAVE_RMENU_XUI) + &menu_ctx_rmenu_xui, +#endif +#if defined(HAVE_LAKKA) + &menu_ctx_lakka, +#endif +#if defined(HAVE_GLUI) + &menu_ctx_glui, +#endif +#if defined(HAVE_XMB) + &menu_ctx_xmb, +#endif +#if defined(HAVE_RGUI) + &menu_ctx_rgui, +#endif + NULL +}; + +/** + * menu_driver_find_handle: + * @index : index of driver to get handle to. + * + * Returns: handle to menu driver at index. Can be NULL + * if nothing found. + **/ +const void *menu_driver_find_handle(int index) +{ + const void *drv = menu_ctx_drivers[index]; + if (!drv) + return NULL; + return drv; +} + +/** + * menu_driver_find_ident: + * @index : index of driver to get handle to. + * + * Returns: Human-readable identifier of menu driver at index. Can be NULL + * if nothing found. + **/ +const char *menu_driver_find_ident(int index) +{ + const menu_ctx_driver_t *drv = menu_ctx_drivers[index]; + if (!drv) + return NULL; + return drv->ident; +} + +/** + * config_get_menu_driver_options: + * + * Get an enumerated list of all menu driver names, + * separated by '|'. + * + * Returns: string listing of all menu driver names, + * separated by '|'. + **/ +const char* config_get_menu_driver_options(void) +{ + union string_list_elem_attr attr; + unsigned i; + char *options = NULL; + int options_len = 0; + struct string_list *options_l = string_list_new(); + + attr.i = 0; + + for (i = 0; menu_driver_find_handle(i); i++) + { + const char *opt = menu_driver_find_ident(i); + options_len += strlen(opt) + 1; + string_list_append(options_l, opt, attr); + } + + options = (char*)calloc(options_len, sizeof(char)); + + string_list_join_concat(options, options_len, options_l, "|"); + + string_list_free(options_l); + options_l = NULL; + + return options; +} + +void find_menu_driver(void) +{ + int i = find_driver_index("menu_driver", g_settings.menu.driver); + if (i >= 0) + driver.menu_ctx = menu_driver_find_handle(i); + else + { + unsigned d; + RARCH_WARN("Couldn't find any menu driver named \"%s\"\n", + g_settings.menu.driver); + RARCH_LOG_OUTPUT("Available menu drivers are:\n"); + for (d = 0; menu_driver_find_handle(d); d++) + RARCH_LOG_OUTPUT("\t%s\n", menu_driver_find_ident(d)); + RARCH_WARN("Going to default to first menu driver...\n"); + + driver.menu_ctx = menu_driver_find_handle(0); + + if (!driver.menu_ctx) + rarch_fail(1, "find_menu_driver()"); + } +} + +void init_menu(void) +{ + if (driver.menu) + return; + + find_menu_driver(); + if (!(driver.menu = (menu_handle_t*)menu_init(driver.menu_ctx))) + { + RARCH_ERR("Cannot initialize menu.\n"); + rarch_fail(1, "init_menu()"); + } + + if (!(menu_init_list(driver.menu))) + { + RARCH_ERR("Cannot initialize menu lists.\n"); + rarch_fail(1, "init_menu()"); + } +} From cc1bbac89c85ee7563f1f5082017be8d9f335db6 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Mon, 12 Jan 2015 20:02:39 +0100 Subject: [PATCH 120/156] Move menu_driver.c to menu/ --- Makefile.common | 2 +- griffin/griffin.c | 2 +- menu_driver.c => menu/menu_driver.c | 8 ++++---- 3 files changed, 6 insertions(+), 6 deletions(-) rename menu_driver.c => menu/menu_driver.c (97%) diff --git a/Makefile.common b/Makefile.common index 92b7b41792..83446d48fc 100644 --- a/Makefile.common +++ b/Makefile.common @@ -102,7 +102,7 @@ OBJ += frontend/frontend.o \ gfx/video_driver.o \ osk/osk_driver.o \ camera/camera_driver.o \ - menu_driver.o \ + menu/menu_driver.o \ location/location_driver.o \ driver.o \ settings.o \ diff --git a/griffin/griffin.c b/griffin/griffin.c index 83c0c832af..3bab7799b2 100644 --- a/griffin/griffin.c +++ b/griffin/griffin.c @@ -502,7 +502,7 @@ DRIVERS #include "../osk/osk_driver.c" #include "../camera/camera_driver.c" #include "../location/location_driver.c" -#include "../menu_driver.c" +#include "../menu/menu_driver.c" #include "../driver.c" /*============================================================ diff --git a/menu_driver.c b/menu/menu_driver.c similarity index 97% rename from menu_driver.c rename to menu/menu_driver.c index 59505695a7..b8dd2b1a76 100644 --- a/menu_driver.c +++ b/menu/menu_driver.c @@ -16,10 +16,10 @@ #include #include -#include "menu/menu_driver.h" -#include "menu/menu.h" -#include "driver.h" -#include "general.h" +#include "menu_driver.h" +#include "menu.h" +#include "../driver.h" +#include "../general.h" static const menu_ctx_driver_t *menu_ctx_drivers[] = { #ifdef IOS From 72a7f437361fda8465db4ec4045962e35be4dd14 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Mon, 12 Jan 2015 20:09:36 +0100 Subject: [PATCH 121/156] Cleanup in driver.h --- driver.h | 9 --------- 1 file changed, 9 deletions(-) diff --git a/driver.h b/driver.h index 770c9a09e2..6082fc21a4 100644 --- a/driver.h +++ b/driver.h @@ -471,15 +471,6 @@ bool driver_update_system_av_info(const struct retro_system_av_info *info); extern driver_t driver; -/** - * config_get_video_driver_options: - * - * Get an enumerated list of all video driver names, separated by '|'. - * - * Returns: string listing of all video driver names, separated by '|'. - **/ -const char* config_get_video_driver_options(void); - /** * find_driver_index: * @label : string of driver type to be found. From 6b3a67d5ea320d1cb8f3ed133d1d982d02609610 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Mon, 12 Jan 2015 20:20:58 +0100 Subject: [PATCH 122/156] Move driver_video_resolve to gfx/video_driver.c --- driver.c | 22 ---------------------- driver.h | 12 ------------ gfx/video_driver.c | 23 +++++++++++++++++++++++ gfx/video_driver.h | 11 +++++++++++ 4 files changed, 34 insertions(+), 34 deletions(-) diff --git a/driver.c b/driver.c index 08d1dd98b9..f146e04869 100644 --- a/driver.c +++ b/driver.c @@ -967,25 +967,3 @@ bool driver_monitor_fps_statistics(double *refresh_rate, return true; } - -/** - * driver_video_resolve: - * @drv : real video driver will be set to this. - * - * Use this if you need the real video driver - * and driver data pointers. - * - * Returns: video driver's userdata. - **/ -void *driver_video_resolve(const video_driver_t **drv) -{ -#ifdef HAVE_THREADS - if (g_settings.video.threaded - && !g_extern.system.hw_render_callback.context_type) - return rarch_threaded_video_resolve(drv); -#endif - if (drv) - *drv = driver.video; - - return driver.video_data; -} diff --git a/driver.h b/driver.h index 6082fc21a4..52450f60c3 100644 --- a/driver.h +++ b/driver.h @@ -445,18 +445,6 @@ bool driver_set_sensor_state(unsigned port, float driver_sensor_get_input(unsigned port, unsigned action); -/** - * driver_video_resolve: - * @drv : real video driver will be set to this. - * - * Use this if you need the real video driver - * and driver data pointers. - * - * Returns: video driver's userdata. - **/ -void *driver_video_resolve(const video_driver_t **drv); - - /** * driver_update_system_av_info: * @info : pointer to new A/V info diff --git a/gfx/video_driver.c b/gfx/video_driver.c index d23fadca4c..da9a4468e2 100644 --- a/gfx/video_driver.c +++ b/gfx/video_driver.c @@ -17,6 +17,7 @@ #include #include #include "video_driver.h" +#include "video_thread_wrapper.h" #include "../general.h" static const video_driver_t *video_drivers[] = { @@ -165,3 +166,25 @@ void find_video_driver(void) rarch_fail(1, "find_video_driver()"); } } + +/** + * driver_video_resolve: + * @drv : real video driver will be set to this. + * + * Use this if you need the real video driver + * and driver data pointers. + * + * Returns: video driver's userdata. + **/ +void *driver_video_resolve(const video_driver_t **drv) +{ +#ifdef HAVE_THREADS + if (g_settings.video.threaded + && !g_extern.system.hw_render_callback.context_type) + return rarch_threaded_video_resolve(drv); +#endif + if (drv) + *drv = driver.video; + + return driver.video_data; +} diff --git a/gfx/video_driver.h b/gfx/video_driver.h index 931ee425f9..ebe6ecae1a 100644 --- a/gfx/video_driver.h +++ b/gfx/video_driver.h @@ -213,6 +213,17 @@ const char* config_get_video_driver_options(void); void find_video_driver(void); +/** + * driver_video_resolve: + * @drv : real video driver will be set to this. + * + * Use this if you need the real video driver + * and driver data pointers. + * + * Returns: video driver's userdata. + **/ +void *driver_video_resolve(const video_driver_t **drv); + #ifdef __cplusplus } #endif From 63281f8ca11ae54d2eedc4b015fd9b68da40b149 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Mon, 12 Jan 2015 20:25:07 +0100 Subject: [PATCH 123/156] Move some code from driver.c to input_context.c --- driver.c | 30 ------------------------------ driver.h | 2 -- input/input_context.c | 32 +++++++++++++++++++++++++++++++- input/input_context.h | 18 ++++++++++++++++++ 4 files changed, 49 insertions(+), 33 deletions(-) diff --git a/driver.c b/driver.c index f146e04869..b24f63dc24 100644 --- a/driver.c +++ b/driver.c @@ -40,36 +40,6 @@ driver_t driver; -/** - * joypad_driver_find_handle: - * @index : index of driver to get handle to. - * - * Returns: handle to joypad driver at index. Can be NULL - * if nothing found. - **/ -static const void *joypad_driver_find_handle(int index) -{ - const void *drv = joypad_drivers[index]; - if (!drv) - return NULL; - return drv; -} - -/** - * joypad_driver_find_ident: - * @index : index of driver to get handle to. - * - * Returns: Human-readable identifier of joypad driver at index. Can be NULL - * if nothing found. - **/ -static const char *joypad_driver_find_ident(int index) -{ - const rarch_joypad_driver_t *drv = joypad_drivers[index]; - if (!drv) - return NULL; - return drv->ident; -} - /** * find_driver_nonempty: * @label : string of driver type to be found. diff --git a/driver.h b/driver.h index 52450f60c3..c1f34ba5b3 100644 --- a/driver.h +++ b/driver.h @@ -471,8 +471,6 @@ extern driver_t driver; **/ int find_driver_index(const char * label, const char *drv); -extern rarch_joypad_driver_t *joypad_drivers[]; - #ifdef __cplusplus } #endif diff --git a/input/input_context.c b/input/input_context.c index 0729e3051f..08318a359a 100644 --- a/input/input_context.c +++ b/input/input_context.c @@ -22,7 +22,7 @@ #include #include "../general.h" -rarch_joypad_driver_t *joypad_drivers[] = { +static rarch_joypad_driver_t *joypad_drivers[] = { #ifdef __CELLOS_LV2__ &ps3_joypad, #endif @@ -71,6 +71,36 @@ rarch_joypad_driver_t *joypad_drivers[] = { NULL, }; +/** + * joypad_driver_find_handle: + * @index : index of driver to get handle to. + * + * Returns: handle to joypad driver at index. Can be NULL + * if nothing found. + **/ +const void *joypad_driver_find_handle(int index) +{ + const void *drv = joypad_drivers[index]; + if (!drv) + return NULL; + return drv; +} + +/** + * joypad_driver_find_ident: + * @index : index of driver to get handle to. + * + * Returns: Human-readable identifier of joypad driver at index. Can be NULL + * if nothing found. + **/ +const char *joypad_driver_find_ident(int index) +{ + const rarch_joypad_driver_t *drv = joypad_drivers[index]; + if (!drv) + return NULL; + return drv->ident; +} + /** * config_get_joypad_driver_options: * diff --git a/input/input_context.h b/input/input_context.h index d5ceb01216..7d44201eec 100644 --- a/input/input_context.h +++ b/input/input_context.h @@ -59,6 +59,24 @@ extern rarch_joypad_driver_t android_joypad; extern rarch_joypad_driver_t qnx_joypad; extern rarch_joypad_driver_t null_joypad; +/** + * joypad_driver_find_handle: + * @index : index of driver to get handle to. + * + * Returns: handle to joypad driver at index. Can be NULL + * if nothing found. + **/ +const void *joypad_driver_find_handle(int index); + +/** + * joypad_driver_find_ident: + * @index : index of driver to get handle to. + * + * Returns: Human-readable identifier of joypad driver at index. Can be NULL + * if nothing found. + **/ +const char *joypad_driver_find_ident(int index); + /** * config_get_joypad_driver_options: * From 4e5314b6bb42d8a27eb7e630a50ae40df9e4b75a Mon Sep 17 00:00:00 2001 From: twinaphex Date: Mon, 12 Jan 2015 20:29:01 +0100 Subject: [PATCH 124/156] Rename input_context.c to input_joypad_driver.c --- Makefile.common | 2 +- griffin/griffin.c | 2 +- input/drivers_joypad/nullinput_joypad.c | 2 +- input/input_driver.h | 2 +- input/{input_context.c => input_joypad_driver.c} | 2 +- input/{input_context.h => input_joypad_driver.h} | 4 ++-- input/keyboard_event_xkb.c | 2 +- tools/retroarch-joyconfig-griffin.c | 2 +- 8 files changed, 9 insertions(+), 9 deletions(-) rename input/{input_context.c => input_joypad_driver.c} (99%) rename input/{input_context.h => input_joypad_driver.h} (98%) diff --git a/Makefile.common b/Makefile.common index 83446d48fc..64c8c2ad52 100644 --- a/Makefile.common +++ b/Makefile.common @@ -115,7 +115,7 @@ OBJ += frontend/frontend.o \ gfx/gfx_common.o \ gfx/fonts/bitmapfont.o \ input/input_autodetect.o \ - input/input_context.o \ + input/input_joypad_driver.o \ input/input_joypad.o \ input/input_common.o \ input/input_keymaps.o \ diff --git a/griffin/griffin.c b/griffin/griffin.c index 3bab7799b2..f228aa99ff 100644 --- a/griffin/griffin.c +++ b/griffin/griffin.c @@ -280,7 +280,7 @@ FONTS INPUT ============================================================ */ #include "../input/input_autodetect.c" -#include "../input/input_context.c" +#include "../input/input_joypad_driver.c" #include "../input/input_joypad.c" #include "../input/input_common.c" #include "../input/input_keymaps.c" diff --git a/input/drivers_joypad/nullinput_joypad.c b/input/drivers_joypad/nullinput_joypad.c index 472c8c000f..2fbd2ac308 100644 --- a/input/drivers_joypad/nullinput_joypad.c +++ b/input/drivers_joypad/nullinput_joypad.c @@ -18,7 +18,7 @@ #include #include #include -#include "../input_context.h" +#include "../input_joypad_driver.h" static const char *null_joypad_name(unsigned pad) { diff --git a/input/input_driver.h b/input/input_driver.h index 5d5fa21cd7..bb7a7b4308 100644 --- a/input/input_driver.h +++ b/input/input_driver.h @@ -23,7 +23,7 @@ #include #include "../libretro.h" -#include "input_context.h" +#include "input_joypad_driver.h" #ifdef HAVE_OVERLAY #include "overlay.h" diff --git a/input/input_context.c b/input/input_joypad_driver.c similarity index 99% rename from input/input_context.c rename to input/input_joypad_driver.c index 08318a359a..423f9de33d 100644 --- a/input/input_context.c +++ b/input/input_joypad_driver.c @@ -14,7 +14,7 @@ * If not, see . */ -#include "input_context.h" +#include "input_joypad_driver.h" #include "input_keymaps.h" #include #include diff --git a/input/input_context.h b/input/input_joypad_driver.h similarity index 98% rename from input/input_context.h rename to input/input_joypad_driver.h index 7d44201eec..bd1223068f 100644 --- a/input/input_context.h +++ b/input/input_joypad_driver.h @@ -14,8 +14,8 @@ * If not, see . */ -#ifndef INPUT_CONTEXT_H__ -#define INPUT_CONTEXT_H__ +#ifndef INPUT_JOYPAD_DRIVER_H__ +#define INPUT_JOYPAD_DRIVER_H__ #ifdef __cplusplus extern "C" { diff --git a/input/keyboard_event_xkb.c b/input/keyboard_event_xkb.c index 60436ea407..3287c6b85d 100644 --- a/input/keyboard_event_xkb.c +++ b/input/keyboard_event_xkb.c @@ -15,7 +15,7 @@ */ #include -#include "input_context.h" +#include "input_joypad_driver.h" #include "input_keymaps.h" #include "keyboard_line.h" diff --git a/tools/retroarch-joyconfig-griffin.c b/tools/retroarch-joyconfig-griffin.c index a55b82ed1e..47ca9ba247 100644 --- a/tools/retroarch-joyconfig-griffin.c +++ b/tools/retroarch-joyconfig-griffin.c @@ -49,7 +49,7 @@ #include "../input/drivers/nullinput.c" #include "../input/drivers_joypad/nullinput_joypad.c" -#include "../input/input_context.c" +#include "../input/input_joypad_driver.c" #include "../input/input_joypad.c" #include "../input/input_common.c" #include "../input/input_keymaps.c" From d4b2c47d738fe743bd7509f155c64e8880109860 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Mon, 12 Jan 2015 20:34:48 +0100 Subject: [PATCH 125/156] driver.c- remove some header includes --- driver.c | 3 --- 1 file changed, 3 deletions(-) diff --git a/driver.c b/driver.c index b24f63dc24..d954303edb 100644 --- a/driver.c +++ b/driver.c @@ -17,14 +17,11 @@ #include "driver.h" #include "general.h" #include "retroarch.h" -#include "libretro.h" #include #include -#include #include "compat/posix_string.h" #include "gfx/video_thread_wrapper.h" #include "gfx/gfx_common.h" -#include #ifdef HAVE_X11 #include "gfx/context/x11_common.h" From e59dace9e1a049bde15eecb312ec196b6672ce4f Mon Sep 17 00:00:00 2001 From: twinaphex Date: Mon, 12 Jan 2015 21:02:13 +0100 Subject: [PATCH 126/156] (audio/resampler) Some changes --- audio/resamplers/resampler.c | 5 +++++ audio/resamplers/resampler.h | 11 +++++++++++ driver.h | 9 --------- 3 files changed, 16 insertions(+), 9 deletions(-) diff --git a/audio/resamplers/resampler.c b/audio/resamplers/resampler.c index 09ea80dc28..fb89e44605 100644 --- a/audio/resamplers/resampler.c +++ b/audio/resamplers/resampler.c @@ -20,6 +20,9 @@ #endif #include #include +#ifndef DONT_HAVE_STRING_LIST +#include +#endif static const rarch_resampler_t *resampler_drivers[] = { &sinc_resampler, @@ -93,7 +96,9 @@ void find_next_resampler_driver(void) RARCH_WARN("Couldn't find any next resampler driver (current one: \"%s\").\n", driver.resampler->ident); } +#endif +#ifndef DONT_HAVE_STRING_LIST /** * config_get_audio_resampler_driver_options: * diff --git a/audio/resamplers/resampler.h b/audio/resamplers/resampler.h index cef79242bb..d392d9c217 100644 --- a/audio/resamplers/resampler.h +++ b/audio/resamplers/resampler.h @@ -143,6 +143,17 @@ extern rarch_resampler_t sinc_resampler; extern rarch_resampler_t CC_resampler; extern rarch_resampler_t nearest_resampler; +#ifndef DONT_HAVE_STRING_LIST +/** + * config_get_audio_resampler_driver_options: + * + * Get an enumerated list of all resampler driver names, separated by '|'. + * + * Returns: string listing of all resampler driver names, separated by '|'. + **/ +const char* config_get_audio_resampler_driver_options(void); +#endif + /** * rarch_resampler_realloc: * @re : Resampler handle diff --git a/driver.h b/driver.h index c1f34ba5b3..e6117ec89e 100644 --- a/driver.h +++ b/driver.h @@ -347,15 +347,6 @@ void find_prev_driver(const char *label, char *str, size_t sizeof_str); **/ void find_next_driver(const char *label, char *str, size_t sizeof_str); -/** - * config_get_audio_resampler_driver_options: - * - * Get an enumerated list of all resampler driver names, separated by '|'. - * - * Returns: string listing of all resampler driver names, separated by '|'. - **/ -const char* config_get_audio_resampler_driver_options(void); - /** * find_prev_resampler_driver: * From 8b95cfe6e379cc838d1f44de637d4a8eece9fb3a Mon Sep 17 00:00:00 2001 From: twinaphex Date: Mon, 12 Jan 2015 21:12:48 +0100 Subject: [PATCH 127/156] Get rid of RARCH_INTERNAL-specific code in resampler.c --- audio/resamplers/resampler.c | 45 +++++++++++++++--------------------- audio/resamplers/resampler.h | 18 +++++++++++++++ driver.c | 6 +++++ driver.h | 14 ----------- settings_data.c | 23 +----------------- 5 files changed, 43 insertions(+), 63 deletions(-) diff --git a/audio/resamplers/resampler.c b/audio/resamplers/resampler.c index fb89e44605..7118a70b44 100644 --- a/audio/resamplers/resampler.c +++ b/audio/resamplers/resampler.c @@ -59,44 +59,35 @@ static int find_resampler_driver_index(const char *ident) return -1; } -#if !defined(RESAMPLER_TEST) && defined(RARCH_INTERNAL) -#include -#include "../../general.h" - /** - * find_prev_resampler_driver: + * audio_resampler_driver_find_handle: + * @index : index of driver to get handle to. * - * Finds previous driver in resampler driver array. + * Returns: handle to audio resampler driver at index. Can be NULL + * if nothing found. **/ -void find_prev_resampler_driver(void) +const void *audio_resampler_driver_find_handle(int index) { - int i = find_resampler_driver_index(g_settings.audio.resampler); - - if (i > 0) - strlcpy(g_settings.audio.resampler, resampler_drivers[i - 1]->ident, - sizeof(g_settings.audio.resampler)); - else - RARCH_WARN("Couldn't find any previous resampler driver (current one: \"%s\").\n", - driver.resampler->ident); + const void *drv = resampler_drivers[index]; + if (!drv) + return NULL; + return drv; } /** - * find_next_resampler_driver: + * audio_resampler_driver_find_ident: + * @index : index of driver to get handle to. * - * Finds next driver in resampler driver array. + * Returns: Human-readable identifier of audio resampler driver at index. + * Can be NULL if nothing found. **/ -void find_next_resampler_driver(void) +const char *audio_resampler_driver_find_ident(int index) { - int i = find_resampler_driver_index(g_settings.audio.resampler); - - if (i >= 0 && resampler_drivers[i + 1]) - strlcpy(g_settings.audio.resampler, resampler_drivers[i + 1]->ident, - sizeof(g_settings.audio.resampler)); - else - RARCH_WARN("Couldn't find any next resampler driver (current one: \"%s\").\n", - driver.resampler->ident); + const rarch_resampler_t *drv = resampler_drivers[index]; + if (!drv) + return NULL; + return drv->ident; } -#endif #ifndef DONT_HAVE_STRING_LIST /** diff --git a/audio/resamplers/resampler.h b/audio/resamplers/resampler.h index d392d9c217..8d376a4cb8 100644 --- a/audio/resamplers/resampler.h +++ b/audio/resamplers/resampler.h @@ -154,6 +154,24 @@ extern rarch_resampler_t nearest_resampler; const char* config_get_audio_resampler_driver_options(void); #endif +/** + * audio_resampler_driver_find_handle: + * @index : index of driver to get handle to. + * + * Returns: handle to audio resampler driver at index. Can be NULL + * if nothing found. + **/ +const void *audio_resampler_driver_find_handle(int index); + +/** + * audio_resampler_driver_find_ident: + * @index : index of driver to get handle to. + * + * Returns: Human-readable identifier of audio resampler driver at index. + * Can be NULL if nothing found. + **/ +const char *audio_resampler_driver_find_ident(int index); + /** * rarch_resampler_realloc: * @re : Resampler handle diff --git a/driver.c b/driver.c index d954303edb..48a49d5211 100644 --- a/driver.c +++ b/driver.c @@ -105,6 +105,12 @@ static const void *find_driver_nonempty(const char *label, int i, if (drv) strlcpy(str, audio_driver_find_ident(i), sizeof_str); } + else if (!strcmp(label, "audio_resampler_driver")) + { + drv = audio_resampler_driver_find_handle(i); + if (drv) + strlcpy(str, audio_resampler_driver_find_ident(i), sizeof_str); + } return drv; } diff --git a/driver.h b/driver.h index e6117ec89e..ef9c09019a 100644 --- a/driver.h +++ b/driver.h @@ -347,20 +347,6 @@ void find_prev_driver(const char *label, char *str, size_t sizeof_str); **/ void find_next_driver(const char *label, char *str, size_t sizeof_str); -/** - * find_prev_resampler_driver: - * - * Find previous driver in resampler driver array. - **/ -void find_prev_resampler_driver(void); - -/** - * find_next_resampler_driver: - * - * Find next driver in resampler driver array. - **/ -void find_next_resampler_driver(void); - /** * driver_set_monitor_refresh_rate: * @hz : New refresh rate for monitor. diff --git a/settings_data.c b/settings_data.c index fee0b86835..bf7972534e 100644 --- a/settings_data.c +++ b/settings_data.c @@ -830,27 +830,6 @@ static int setting_data_string_action_toggle_driver(void *data, return 0; } -static int setting_data_string_action_toggle_audio_resampler(void *data, - unsigned action) -{ - rarch_setting_t *setting = (rarch_setting_t*)data; - - if (!setting) - return -1; - - switch (action) - { - case MENU_ACTION_LEFT: - find_prev_resampler_driver(); - break; - case MENU_ACTION_RIGHT: - find_next_resampler_driver(); - break; - } - - return 0; -} - int core_list_action_toggle(void *data, unsigned action) { rarch_setting_t *setting = (rarch_setting_t *)data; @@ -3582,7 +3561,7 @@ static bool setting_data_append_list_driver_options( subgroup_info.name, NULL, NULL); - (*list)[list_info->index - 1].action_toggle = &setting_data_string_action_toggle_audio_resampler; + settings_data_list_current_add_flags(list, list_info, SD_FLAG_IS_DRIVER); CONFIG_STRING_OPTIONS( g_settings.camera.driver, From 1b28a4a49881a4e312e9695836fa80732a160216 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Mon, 12 Jan 2015 21:16:17 +0100 Subject: [PATCH 128/156] Cleanups --- camera/camera_driver.h | 12 ++++++------ gfx/video_driver.h | 22 +++++++++++----------- location/location_driver.h | 8 ++++---- osk/osk_driver.h | 6 +++--- 4 files changed, 24 insertions(+), 24 deletions(-) diff --git a/camera/camera_driver.h b/camera/camera_driver.h index a03f8833c9..ee11cfa324 100644 --- a/camera/camera_driver.h +++ b/camera/camera_driver.h @@ -47,6 +47,12 @@ typedef struct camera_driver const char *ident; } camera_driver_t; +extern camera_driver_t camera_v4l2; +extern camera_driver_t camera_android; +extern camera_driver_t camera_rwebcam; +extern camera_driver_t camera_apple; +extern camera_driver_t camera_null; + /** * driver_camera_start: * @@ -112,12 +118,6 @@ void init_camera(void); void uninit_camera(void); -extern camera_driver_t camera_v4l2; -extern camera_driver_t camera_android; -extern camera_driver_t camera_rwebcam; -extern camera_driver_t camera_apple; -extern camera_driver_t camera_null; - #ifdef __cplusplus } #endif diff --git a/gfx/video_driver.h b/gfx/video_driver.h index ebe6ecae1a..d03a1f3406 100644 --- a/gfx/video_driver.h +++ b/gfx/video_driver.h @@ -158,17 +158,6 @@ typedef struct video_driver unsigned (*wrap_type_to_enum)(enum gfx_wrap_type type); } video_driver_t; -enum rarch_display_type -{ - /* Non-bindable types like consoles, KMS, VideoCore, etc. */ - RARCH_DISPLAY_NONE = 0, - /* video_display => Display*, video_window => Window */ - RARCH_DISPLAY_X11, - /* video_display => N/A, video_window => HWND */ - RARCH_DISPLAY_WIN32, - RARCH_DISPLAY_OSX -}; - extern video_driver_t video_gl; extern video_driver_t video_psp1; extern video_driver_t video_vita; @@ -184,6 +173,17 @@ extern video_driver_t video_omap; extern video_driver_t video_exynos; extern video_driver_t video_null; +enum rarch_display_type +{ + /* Non-bindable types like consoles, KMS, VideoCore, etc. */ + RARCH_DISPLAY_NONE = 0, + /* video_display => Display*, video_window => Window */ + RARCH_DISPLAY_X11, + /* video_display => N/A, video_window => HWND */ + RARCH_DISPLAY_WIN32, + RARCH_DISPLAY_OSX +}; + /** * video_driver_find_handle: * @index : index of driver to get handle to. diff --git a/location/location_driver.h b/location/location_driver.h index f2c5c617ae..797a3d0322 100644 --- a/location/location_driver.h +++ b/location/location_driver.h @@ -40,6 +40,10 @@ typedef struct location_driver const char *ident; } location_driver_t; +extern location_driver_t location_apple; +extern location_driver_t location_android; +extern location_driver_t location_null; + /** * driver_location_start: * @@ -122,10 +126,6 @@ void init_location(void); void uninit_location(void); -extern location_driver_t location_apple; -extern location_driver_t location_android; -extern location_driver_t location_null; - #ifdef __cplusplus } #endif diff --git a/osk/osk_driver.h b/osk/osk_driver.h index 5d75be9ff0..c27f365879 100644 --- a/osk/osk_driver.h +++ b/osk/osk_driver.h @@ -39,6 +39,9 @@ typedef struct input_osk_driver const char *ident; } input_osk_driver_t; +extern input_osk_driver_t input_ps3_osk; +extern input_osk_driver_t input_null_osk; + /** * osk_driver_find_handle: * @index : index of driver to get handle to. @@ -79,9 +82,6 @@ void init_osk(void); void uninit_osk(void); -extern input_osk_driver_t input_ps3_osk; -extern input_osk_driver_t input_null_osk; - #ifdef __cplusplus } #endif From 64903de4654c13980be0b08c23d3a435051206e9 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Mon, 12 Jan 2015 21:21:08 +0100 Subject: [PATCH 129/156] Rename frontend_context.c to frontend_driver.c --- Makefile.common | 2 +- driver.h | 2 +- frontend/{frontend_context.c => frontend_driver.c} | 2 +- frontend/{frontend_context.h => frontend_driver.h} | 4 ++-- frontend/frontend_salamander.c | 2 +- frontend/platform/platform_null.c | 2 +- griffin/griffin.c | 2 +- 7 files changed, 8 insertions(+), 8 deletions(-) rename frontend/{frontend_context.c => frontend_driver.c} (98%) rename frontend/{frontend_context.h => frontend_driver.h} (97%) diff --git a/Makefile.common b/Makefile.common index 64c8c2ad52..f326a59049 100644 --- a/Makefile.common +++ b/Makefile.common @@ -85,7 +85,7 @@ endif # General object files OBJ += frontend/frontend.o \ - frontend/frontend_context.o \ + frontend/frontend_driver.o \ frontend/platform/platform_null.o \ libretro_version_1.o \ retroarch.o \ diff --git a/driver.h b/driver.h index ef9c09019a..ddc21a3883 100644 --- a/driver.h +++ b/driver.h @@ -24,9 +24,9 @@ #include #include -#include "frontend/frontend_context.h" #include +#include "frontend/frontend_driver.h" #include "gfx/video_driver.h" #include "audio/audio_driver.h" diff --git a/frontend/frontend_context.c b/frontend/frontend_driver.c similarity index 98% rename from frontend/frontend_context.c rename to frontend/frontend_driver.c index b84f233602..3f7f2602b6 100644 --- a/frontend/frontend_context.c +++ b/frontend/frontend_driver.c @@ -14,7 +14,7 @@ * If not, see . */ -#include "frontend_context.h" +#include "frontend_driver.h" #include #ifdef HAVE_CONFIG_H diff --git a/frontend/frontend_context.h b/frontend/frontend_driver.h similarity index 97% rename from frontend/frontend_context.h rename to frontend/frontend_driver.h index 20c301537c..60b8a3cfb0 100644 --- a/frontend/frontend_context.h +++ b/frontend/frontend_driver.h @@ -14,8 +14,8 @@ * If not, see . */ -#ifndef __FRONTEND_CONTEXT_H -#define __FRONTEND_CONTEXT_H +#ifndef __FRONTEND_DRIVER_H +#define __FRONTEND_DRIVER_H #include #include diff --git a/frontend/frontend_salamander.c b/frontend/frontend_salamander.c index f658ec0521..50b3118087 100644 --- a/frontend/frontend_salamander.c +++ b/frontend/frontend_salamander.c @@ -24,7 +24,7 @@ #include "../file_ext.h" #include #include -#include "frontend_context.h" +#include "frontend_driver.h" struct defaults g_defaults; diff --git a/frontend/platform/platform_null.c b/frontend/platform/platform_null.c index ede96fee56..cd45c8d008 100644 --- a/frontend/platform/platform_null.c +++ b/frontend/platform/platform_null.c @@ -14,7 +14,7 @@ * If not, see . */ -#include "../frontend_context.h" +#include "../frontend_driver.h" #include #include diff --git a/griffin/griffin.c b/griffin/griffin.c index f228aa99ff..3ed0e252a7 100644 --- a/griffin/griffin.c +++ b/griffin/griffin.c @@ -581,7 +581,7 @@ REWIND FRONTEND ============================================================ */ -#include "../frontend/frontend_context.c" +#include "../frontend/frontend_driver.c" #if defined(__CELLOS_LV2__) #include "../frontend/platform/platform_ps3.c" From f21f7e17b56df0c947eb0e459e498c916daa6006 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Mon, 12 Jan 2015 21:22:50 +0100 Subject: [PATCH 130/156] Cleanups --- menu/menu_driver.h | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/menu/menu_driver.h b/menu/menu_driver.h index 99bea6ee06..963e5a5de7 100644 --- a/menu/menu_driver.h +++ b/menu/menu_driver.h @@ -14,8 +14,8 @@ * If not, see . */ -#ifndef DRIVER_MENU_H__ -#define DRIVER_MENU_H__ +#ifndef __MENU_DRIVER_H__ +#define __MENU_DRIVER_H__ #include #include @@ -162,6 +162,9 @@ typedef struct menu_ctx_driver_backend const char *ident; } menu_ctx_driver_backend_t; +extern menu_ctx_driver_backend_t menu_ctx_backend_common; +extern menu_ctx_driver_backend_t menu_ctx_backend_lakka; + typedef struct menu_ctx_driver { void (*set_texture)(void*); @@ -196,6 +199,14 @@ typedef struct menu_ctx_driver const char *ident; } menu_ctx_driver_t; +extern menu_ctx_driver_t menu_ctx_rmenu; +extern menu_ctx_driver_t menu_ctx_rmenu_xui; +extern menu_ctx_driver_t menu_ctx_rgui; +extern menu_ctx_driver_t menu_ctx_glui; +extern menu_ctx_driver_t menu_ctx_xmb; +extern menu_ctx_driver_t menu_ctx_lakka; +extern menu_ctx_driver_t menu_ctx_ios; + /** * menu_driver_find_handle: * @index : index of driver to get handle to. @@ -229,17 +240,6 @@ void find_menu_driver(void); void init_menu(void); -extern menu_ctx_driver_t menu_ctx_rmenu; -extern menu_ctx_driver_t menu_ctx_rmenu_xui; -extern menu_ctx_driver_t menu_ctx_rgui; -extern menu_ctx_driver_t menu_ctx_glui; -extern menu_ctx_driver_t menu_ctx_xmb; -extern menu_ctx_driver_t menu_ctx_lakka; -extern menu_ctx_driver_t menu_ctx_ios; - -extern menu_ctx_driver_backend_t menu_ctx_backend_common; -extern menu_ctx_driver_backend_t menu_ctx_backend_lakka; - #ifdef __cplusplus } #endif From cec3af8e4ae0f4b22b75bf88b2b350a9761e0216 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Mon, 12 Jan 2015 21:41:27 +0100 Subject: [PATCH 131/156] Rename shader_context.c to video_shader_driver.c --- Makefile.common | 2 +- gfx/d3d/d3d.h | 2 +- gfx/drivers/gl.c | 2 +- gfx/fonts/gl_raster_font.c | 2 +- gfx/gl_common.h | 2 +- gfx/shader/shader_gl_cg.c | 2 +- gfx/shader/shader_glsl.h | 4 +++- gfx/shader/shader_hlsl.h | 2 +- gfx/shader/shader_null.c | 2 +- gfx/{shader/shader_context.c => video_shader_driver.c} | 8 ++------ gfx/{shader/shader_context.h => video_shader_driver.h} | 10 +++++----- griffin/griffin.c | 2 +- menu/menu.h | 2 +- menu/menu_shader.h | 2 +- 14 files changed, 21 insertions(+), 23 deletions(-) rename gfx/{shader/shader_context.c => video_shader_driver.c} (93%) rename gfx/{shader/shader_context.h => video_shader_driver.h} (95%) diff --git a/Makefile.common b/Makefile.common index f326a59049..8a76af68e4 100644 --- a/Makefile.common +++ b/Makefile.common @@ -132,7 +132,7 @@ OBJ += frontend/frontend.o \ screenshot.o \ libretro-sdk/gfx/scaler/scaler.o \ gfx/shader/shader_null.o \ - gfx/shader/shader_context.o \ + gfx/video_shader_driver.o \ gfx/shader/shader_parse.o \ libretro-sdk/gfx/scaler/pixconv.o \ libretro-sdk/gfx/scaler/scaler_int.o \ diff --git a/gfx/d3d/d3d.h b/gfx/d3d/d3d.h index 8a94f6ff3e..4e80bc0a2a 100644 --- a/gfx/d3d/d3d.h +++ b/gfx/d3d/d3d.h @@ -46,7 +46,7 @@ #include "../../driver.h" #if defined(HAVE_CG) || defined(HAVE_GLSL) || defined(HAVE_HLSL) -#include "../shader/shader_context.h" +#include "../video_shader_driver.h" #endif #include "../fonts/d3d_font.h" diff --git a/gfx/drivers/gl.c b/gfx/drivers/gl.c index 2e5b3ba336..f81528a499 100644 --- a/gfx/drivers/gl.c +++ b/gfx/drivers/gl.c @@ -49,7 +49,7 @@ #include #endif -#include "../shader/shader_context.h" +#include "../video_shader_driver.h" /* Used for the last pass when rendering to the back buffer. */ static const GLfloat vertexes_flipped[] = { diff --git a/gfx/fonts/gl_raster_font.c b/gfx/fonts/gl_raster_font.c index 72ce08d671..e3f003cf2d 100644 --- a/gfx/fonts/gl_raster_font.c +++ b/gfx/fonts/gl_raster_font.c @@ -16,7 +16,7 @@ #include "../gfx_common.h" #include "../gl_common.h" -#include "../shader/shader_context.h" +#include "../video_shader_driver.h" #define emit(c, vx, vy) do { \ font_vertex[ 2 * (6 * i + c) + 0] = (x + (delta_x + off_x + vx * width) * scale) * inv_win_width; \ diff --git a/gfx/gl_common.h b/gfx/gl_common.h index ae2ee038d1..6e4befde8a 100644 --- a/gfx/gl_common.h +++ b/gfx/gl_common.h @@ -22,7 +22,7 @@ #include #include #include "fonts/gl_font.h" -#include "shader/shader_context.h" +#include "video_shader_driver.h" #ifdef HAVE_CONFIG_H #include "../config.h" diff --git a/gfx/shader/shader_gl_cg.c b/gfx/shader/shader_gl_cg.c index bc9d090ea5..b7fe044c63 100644 --- a/gfx/shader/shader_gl_cg.c +++ b/gfx/shader/shader_gl_cg.c @@ -20,7 +20,7 @@ #endif #include -#include "shader_context.h" +#include "../video_shader_driver.h" #include diff --git a/gfx/shader/shader_glsl.h b/gfx/shader/shader_glsl.h index 0be7d6c256..0af251e5d8 100644 --- a/gfx/shader/shader_glsl.h +++ b/gfx/shader/shader_glsl.h @@ -18,8 +18,10 @@ #define __RARCH_GLSL_H #include -#include "shader_context.h" +#include "../video_shader_driver.h" void gl_glsl_set_get_proc_address(gfx_ctx_proc_t (*proc)(const char*)); + void gl_glsl_set_context_type(bool core_profile, unsigned major, unsigned minor); + #endif diff --git a/gfx/shader/shader_hlsl.h b/gfx/shader/shader_hlsl.h index b3ac8e038e..ec8ffb578d 100644 --- a/gfx/shader/shader_hlsl.h +++ b/gfx/shader/shader_hlsl.h @@ -18,7 +18,7 @@ #ifndef __RARCH_HLSL_H #define __RARCH_HLSL_H -#include "shader_context.h" +#include "../video_shader_driver.h" #include void hlsl_set_proj_matrix(XMMATRIX rotation_value); diff --git a/gfx/shader/shader_null.c b/gfx/shader/shader_null.c index ac917e7a15..cfbccd9ed4 100644 --- a/gfx/shader/shader_null.c +++ b/gfx/shader/shader_null.c @@ -31,7 +31,7 @@ #include "../gl_common.h" #endif -#include "shader_context.h" +#include "../video_shader_driver.h" #include static void shader_null_deinit(void) { } diff --git a/gfx/shader/shader_context.c b/gfx/video_shader_driver.c similarity index 93% rename from gfx/shader/shader_context.c rename to gfx/video_shader_driver.c index bef65b6cce..2276f30402 100644 --- a/gfx/shader/shader_context.c +++ b/gfx/video_shader_driver.c @@ -13,14 +13,10 @@ * If not, see . */ -#include "shader_context.h" -#include "../../retroarch_logger.h" +#include "video_shader_driver.h" +#include "../retroarch_logger.h" #include -#ifdef HAVE_CONFIG_H -#include "../../config.h" -#endif - static const shader_backend_t *shader_ctx_drivers[] = { #ifdef HAVE_CG &gl_cg_backend, diff --git a/gfx/shader/shader_context.h b/gfx/video_shader_driver.h similarity index 95% rename from gfx/shader/shader_context.h rename to gfx/video_shader_driver.h index 73de244d1a..f0f4eef743 100644 --- a/gfx/shader/shader_context.h +++ b/gfx/video_shader_driver.h @@ -13,16 +13,16 @@ * If not, see . */ -#ifndef SHADER_CONTEXT_H__ -#define SHADER_CONTEXT_H__ +#ifndef VIDEO_SHADER_DRIVER_H__ +#define VIDEO_SHADER_DRIVER_H__ #include #ifdef HAVE_CONFIG_H -#include "../../config.h" +#include "../config.h" #endif -#include "../video_context.h" +#include "video_context.h" #include typedef struct shader_backend @@ -78,7 +78,7 @@ extern const shader_backend_t shader_null_backend; #define HAVE_SHADER_MANAGER #endif -#include "shader_parse.h" +#include "shader/shader_parse.h" #define GL_SHADER_STOCK_BLEND (GFX_MAX_SHADERS - 1) diff --git a/griffin/griffin.c b/griffin/griffin.c index 3ed0e252a7..0c290e6553 100644 --- a/griffin/griffin.c +++ b/griffin/griffin.c @@ -134,7 +134,7 @@ VIDEO SHADERS ============================================================ */ #ifdef HAVE_SHADERS -#include "../gfx/shader/shader_context.c" +#include "../gfx/video_shader_driver.c" #include "../gfx/shader/shader_parse.c" #include "../gfx/shader/shader_null.c" diff --git a/menu/menu.h b/menu/menu.h index 762748aaf9..8f2815a5c7 100644 --- a/menu/menu.h +++ b/menu/menu.h @@ -28,7 +28,7 @@ #include "../../core_info.h" #include "../../playlist.h" #include "menu_input.h" -#include "../../gfx/shader/shader_context.h" +#include "../../gfx/video_shader_driver.h" #ifdef HAVE_RGUI #define MENU_TEXTURE_FULLSCREEN false diff --git a/menu/menu_shader.h b/menu/menu_shader.h index 97100887f8..698a4daa18 100644 --- a/menu/menu_shader.h +++ b/menu/menu_shader.h @@ -17,7 +17,7 @@ #ifndef _MENU_SHADER_MANAGER_H #define _MENU_SHADER_MANAGER_H -#include "../gfx/shader/shader_context.h" +#include "../gfx/video_shader_driver.h" #ifdef __cplusplus extern "C" { From ca67f9c317e946d46443ffac70d574efbc246bb1 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Mon, 12 Jan 2015 21:47:01 +0100 Subject: [PATCH 132/156] Rename frontend/platform/ to frontend/drivers/ --- Makefile.common | 4 ++-- Makefile.ps3.salamander | 2 +- Makefile.psp1.salamander | 2 +- Makefile.wii.salamander | 2 +- .../{platform => drivers}/platform_android.c | 0 .../{platform => drivers}/platform_android.h | 0 .../{platform => drivers}/platform_apple.c | 0 .../platform_emscripten.c | 0 frontend/{platform => drivers}/platform_gx.c | 0 frontend/{platform => drivers}/platform_null.c | 0 frontend/{platform => drivers}/platform_ps3.c | 0 frontend/{platform => drivers}/platform_psp.c | 0 frontend/{platform => drivers}/platform_qnx.c | 0 frontend/{platform => drivers}/platform_wii.c | 0 frontend/{platform => drivers}/platform_xdk.c | 0 frontend/{platform => drivers}/platform_xdk.h | 0 frontend/frontend.h | 2 +- gfx/context/androidegl_ctx.c | 2 +- griffin/griffin.c | 18 +++++++++--------- input/drivers/android_input.c | 2 +- 20 files changed, 17 insertions(+), 17 deletions(-) rename frontend/{platform => drivers}/platform_android.c (100%) rename frontend/{platform => drivers}/platform_android.h (100%) rename frontend/{platform => drivers}/platform_apple.c (100%) rename frontend/{platform => drivers}/platform_emscripten.c (100%) rename frontend/{platform => drivers}/platform_gx.c (100%) rename frontend/{platform => drivers}/platform_null.c (100%) rename frontend/{platform => drivers}/platform_ps3.c (100%) rename frontend/{platform => drivers}/platform_psp.c (100%) rename frontend/{platform => drivers}/platform_qnx.c (100%) rename frontend/{platform => drivers}/platform_wii.c (100%) rename frontend/{platform => drivers}/platform_xdk.c (100%) rename frontend/{platform => drivers}/platform_xdk.h (100%) diff --git a/Makefile.common b/Makefile.common index 8a76af68e4..45db8d1b7f 100644 --- a/Makefile.common +++ b/Makefile.common @@ -86,7 +86,7 @@ endif OBJ += frontend/frontend.o \ frontend/frontend_driver.o \ - frontend/platform/platform_null.o \ + frontend/drivers/platform_null.o \ libretro_version_1.o \ retroarch.o \ runloop.o \ @@ -178,7 +178,7 @@ ifeq ($(HAVE_PYTHON), 1) endif ifeq ($(HAVE_EMSCRIPTEN), 1) -OBJ += frontend/platform/platform_emscripten.o \ +OBJ += frontend/drivers/platform_emscripten.o \ input/drivers/rwebinput_input.o \ audio/drivers/rwebaudio.o \ camera/drivers/rwebcam.o diff --git a/Makefile.ps3.salamander b/Makefile.ps3.salamander index a23216b302..2d1430afd4 100644 --- a/Makefile.ps3.salamander +++ b/Makefile.ps3.salamander @@ -19,7 +19,7 @@ endif STRIP = $(CELL_SDK)/host-win32/ppu/bin/ppu-lv2-strip.exe PPU_CFLAGS += -I. -Ilibretro-sdk/include -D__CELLOS_LV2__ -DIS_SALAMANDER -DRARCH_CONSOLE -DHAVE_SYSUTILS -DHAVE_SYSMODULES -DHAVE_RARCH_EXEC -PPU_SRCS = frontend/frontend_salamander.c frontend/frontend_context.c frontend/platform/platform_ps3.c frontend/platform/platform_null.c libretro-sdk/file/file_path.c libretro-sdk/file/dir_list.c libretro-sdk/string/string_list.c libretro-sdk/compat/compat.c libretro-sdk/file/config_file.c +PPU_SRCS = frontend/frontend_salamander.c frontend/frontend_context.c frontend/drivers/platform_ps3.c frontend/drivers/platform_null.c libretro-sdk/file/file_path.c libretro-sdk/file/dir_list.c libretro-sdk/string/string_list.c libretro-sdk/compat/compat.c libretro-sdk/file/config_file.c ifeq ($(HAVE_LOGGER), 1) PPU_CFLAGS += -DHAVE_LOGGER -Ilogger/netlogger diff --git a/Makefile.psp1.salamander b/Makefile.psp1.salamander index 252b499584..cbd5afc4a6 100644 --- a/Makefile.psp1.salamander +++ b/Makefile.psp1.salamander @@ -31,7 +31,7 @@ PSP_EBOOT_TITLE = RetroArch PSP_EBOOT_ICON = psp1/ICON0.PNG PSP_EBOOT_PIC1 = psp1/PIC1.PNG -OBJS = frontend/frontend_salamander.o frontend/frontend_context.o frontend/platform/platform_psp.o frontend/platform/platform_null.o libretro-sdk/file/file_path.o libretro-sdk/string/string_list.o libretro-sdk/file/dir_list.o libretro-sdk/compat/compat.o libretro-sdk/file/config_file.o psp1/kernel_functions.o +OBJS = frontend/frontend_salamander.o frontend/frontend_context.o frontend/drivers/platform_psp.o frontend/drivers/platform_null.o libretro-sdk/file/file_path.o libretro-sdk/string/string_list.o libretro-sdk/file/dir_list.o libretro-sdk/compat/compat.o libretro-sdk/file/config_file.o psp1/kernel_functions.o PSPSDK=$(shell psp-config --pspsdk-path) include $(PSPSDK)/lib/build.mak diff --git a/Makefile.wii.salamander b/Makefile.wii.salamander index 24dca9907e..cd0b97e088 100644 --- a/Makefile.wii.salamander +++ b/Makefile.wii.salamander @@ -39,7 +39,7 @@ LIBS := -lfat -lwiiuse -logc -lbte APP_BOOTER_DIR = wii/app_booter -OBJ = frontend/frontend_salamander.o frontend/frontend_context.o frontend/platform/platform_gx.o frontend/platform/platform_wii.o frontend/platform/platform_null.o libretro-sdk/file/file_path.o libretro-sdk/string/string_list.o libretro-sdk/file/dir_list.o libretro-sdk/compat/compat.o libretro-sdk/file/config_file.o $(APP_BOOTER_DIR)/app_booter.binobj +OBJ = frontend/frontend_salamander.o frontend/frontend_context.o frontend/drivers/platform_gx.o frontend/drivers/platform_wii.o frontend/drivers/platform_null.o libretro-sdk/file/file_path.o libretro-sdk/string/string_list.o libretro-sdk/file/dir_list.o libretro-sdk/compat/compat.o libretro-sdk/file/config_file.o $(APP_BOOTER_DIR)/app_booter.binobj ifeq ($(HAVE_LOGGER), 1) CFLAGS += -DHAVE_LOGGER diff --git a/frontend/platform/platform_android.c b/frontend/drivers/platform_android.c similarity index 100% rename from frontend/platform/platform_android.c rename to frontend/drivers/platform_android.c diff --git a/frontend/platform/platform_android.h b/frontend/drivers/platform_android.h similarity index 100% rename from frontend/platform/platform_android.h rename to frontend/drivers/platform_android.h diff --git a/frontend/platform/platform_apple.c b/frontend/drivers/platform_apple.c similarity index 100% rename from frontend/platform/platform_apple.c rename to frontend/drivers/platform_apple.c diff --git a/frontend/platform/platform_emscripten.c b/frontend/drivers/platform_emscripten.c similarity index 100% rename from frontend/platform/platform_emscripten.c rename to frontend/drivers/platform_emscripten.c diff --git a/frontend/platform/platform_gx.c b/frontend/drivers/platform_gx.c similarity index 100% rename from frontend/platform/platform_gx.c rename to frontend/drivers/platform_gx.c diff --git a/frontend/platform/platform_null.c b/frontend/drivers/platform_null.c similarity index 100% rename from frontend/platform/platform_null.c rename to frontend/drivers/platform_null.c diff --git a/frontend/platform/platform_ps3.c b/frontend/drivers/platform_ps3.c similarity index 100% rename from frontend/platform/platform_ps3.c rename to frontend/drivers/platform_ps3.c diff --git a/frontend/platform/platform_psp.c b/frontend/drivers/platform_psp.c similarity index 100% rename from frontend/platform/platform_psp.c rename to frontend/drivers/platform_psp.c diff --git a/frontend/platform/platform_qnx.c b/frontend/drivers/platform_qnx.c similarity index 100% rename from frontend/platform/platform_qnx.c rename to frontend/drivers/platform_qnx.c diff --git a/frontend/platform/platform_wii.c b/frontend/drivers/platform_wii.c similarity index 100% rename from frontend/platform/platform_wii.c rename to frontend/drivers/platform_wii.c diff --git a/frontend/platform/platform_xdk.c b/frontend/drivers/platform_xdk.c similarity index 100% rename from frontend/platform/platform_xdk.c rename to frontend/drivers/platform_xdk.c diff --git a/frontend/platform/platform_xdk.h b/frontend/drivers/platform_xdk.h similarity index 100% rename from frontend/platform/platform_xdk.h rename to frontend/drivers/platform_xdk.h diff --git a/frontend/frontend.h b/frontend/frontend.h index f4ce3b044b..e7a246945a 100644 --- a/frontend/frontend.h +++ b/frontend/frontend.h @@ -23,7 +23,7 @@ #include #if defined(ANDROID) -#include "platform/platform_android.h" +#include "drivers/platform_android.h" #define main_entry android_app_entry #define args_type() struct android_app* #define signature() void* data diff --git a/gfx/context/androidegl_ctx.c b/gfx/context/androidegl_ctx.c index 639c1837b5..d3eda923df 100644 --- a/gfx/context/androidegl_ctx.c +++ b/gfx/context/androidegl_ctx.c @@ -21,7 +21,7 @@ #include -#include "../../frontend/platform/platform_android.h" +#include "../../frontend/drivers/platform_android.h" #include "../image/image.h" #include diff --git a/griffin/griffin.c b/griffin/griffin.c index 0c290e6553..99a5acd522 100644 --- a/griffin/griffin.c +++ b/griffin/griffin.c @@ -584,24 +584,24 @@ FRONTEND #include "../frontend/frontend_driver.c" #if defined(__CELLOS_LV2__) -#include "../frontend/platform/platform_ps3.c" +#include "../frontend/drivers/platform_ps3.c" #elif defined(GEKKO) -#include "../frontend/platform/platform_gx.c" +#include "../frontend/drivers/platform_gx.c" #ifdef HW_RVL -#include "../frontend/platform/platform_wii.c" +#include "../frontend/drivers/platform_wii.c" #endif #elif defined(_XBOX) -#include "../frontend/platform/platform_xdk.c" +#include "../frontend/drivers/platform_xdk.c" #elif defined(PSP) -#include "../frontend/platform/platform_psp.c" +#include "../frontend/drivers/platform_psp.c" #elif defined(__QNX__) -#include "../frontend/platform/platform_qnx.c" +#include "../frontend/drivers/platform_qnx.c" #elif defined(OSX) || defined(IOS) -#include "../frontend/platform/platform_apple.c" +#include "../frontend/drivers/platform_apple.c" #elif defined(ANDROID) -#include "../frontend/platform/platform_android.c" +#include "../frontend/drivers/platform_android.c" #endif -#include "../frontend/platform/platform_null.c" +#include "../frontend/drivers/platform_null.c" #include "../core_info.c" diff --git a/input/drivers/android_input.c b/input/drivers/android_input.c index 919de556ab..fbc9c608c9 100644 --- a/input/drivers/android_input.c +++ b/input/drivers/android_input.c @@ -19,7 +19,7 @@ #include #include #include -#include "../../frontend/platform/platform_android.h" +#include "../../frontend/drivers/platform_android.h" #include "../input_autodetect.h" #include "../input_common.h" #include "../input_joypad.h" From 0b2d51853168a3bfcd66ee7c10b0cd27c4d3d166 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Mon, 12 Jan 2015 21:53:04 +0100 Subject: [PATCH 133/156] Rename video_context.c to video_context_driver.c --- Makefile.common | 2 +- apple/common/apple_gfx_context.c.inl | 2 +- gfx/context/emscriptenegl_ctx.c | 2 +- gfx/context/gfx_null_ctx.c | 2 +- gfx/context/ps3_ctx.c | 2 +- gfx/context/vc_egl_ctx.c | 2 +- gfx/context/wgl_ctx.c | 2 +- gfx/d3d/d3d.h | 2 +- gfx/drivers/gl.c | 2 +- gfx/drivers/omap_gfx.c | 2 +- gfx/drivers/sdl2_gfx.c | 2 +- gfx/drivers/sdl_gfx.c | 2 +- gfx/drivers/vg.c | 2 +- gfx/{video_context.c => video_context_driver.c} | 2 +- gfx/{video_context.h => video_context_driver.h} | 4 ++-- gfx/video_shader_driver.h | 2 +- griffin/griffin.c | 2 +- input/drivers/sdl_input.c | 2 +- menu/disp/rmenu_xui.cpp | 2 +- 19 files changed, 20 insertions(+), 20 deletions(-) rename gfx/{video_context.c => video_context_driver.c} (99%) rename gfx/{video_context.h => video_context_driver.h} (98%) diff --git a/Makefile.common b/Makefile.common index 45db8d1b7f..f210ccb8bb 100644 --- a/Makefile.common +++ b/Makefile.common @@ -374,7 +374,7 @@ ifeq ($(HAVE_OPENGL), 1) DEFINES += -DHAVE_OPENGL -DHAVE_GLSL OBJ += gfx/drivers/gl.o \ gfx/gl_common.o \ - gfx/video_context.o \ + gfx/video_context_driver.o \ gfx/context/gfx_null_ctx.o \ gfx/fonts/gl_font.o \ gfx/fonts/gl_raster_font.o \ diff --git a/apple/common/apple_gfx_context.c.inl b/apple/common/apple_gfx_context.c.inl index 758b53eee1..83b91e1260 100644 --- a/apple/common/apple_gfx_context.c.inl +++ b/apple/common/apple_gfx_context.c.inl @@ -4,7 +4,7 @@ #endif #include "../../gfx/gfx_common.h" -#include "../../gfx/video_context.h" +#include "../../gfx/video_context_driver.h" #include "../../gfx/gl_common.h" //#define HAVE_NSOPENGL diff --git a/gfx/context/emscriptenegl_ctx.c b/gfx/context/emscriptenegl_ctx.c index 431f6b5af4..88e9241e64 100644 --- a/gfx/context/emscriptenegl_ctx.c +++ b/gfx/context/emscriptenegl_ctx.c @@ -15,7 +15,7 @@ */ #include "../../driver.h" -#include "../video_context.h" +#include "../video_context_driver.h" #include "../gl_common.h" #include "../gfx_common.h" diff --git a/gfx/context/gfx_null_ctx.c b/gfx/context/gfx_null_ctx.c index 223e30ccde..a6dd7a0a84 100644 --- a/gfx/context/gfx_null_ctx.c +++ b/gfx/context/gfx_null_ctx.c @@ -17,7 +17,7 @@ // Null context. #include "../../driver.h" -#include "../video_context.h" +#include "../video_context_driver.h" #include "../gfx_common.h" static void gfx_ctx_null_swap_interval(void *data, unsigned interval) diff --git a/gfx/context/ps3_ctx.c b/gfx/context/ps3_ctx.c index 132e55c6ec..74f393926e 100644 --- a/gfx/context/ps3_ctx.c +++ b/gfx/context/ps3_ctx.c @@ -37,7 +37,7 @@ #include "../gl_common.h" -#include "../video_context.h" +#include "../video_context_driver.h" typedef struct gfx_ctx_ps3_data { diff --git a/gfx/context/vc_egl_ctx.c b/gfx/context/vc_egl_ctx.c index d847c54f64..85d294cb62 100644 --- a/gfx/context/vc_egl_ctx.c +++ b/gfx/context/vc_egl_ctx.c @@ -15,7 +15,7 @@ */ #include "../../driver.h" -#include "../video_context.h" +#include "../video_context_driver.h" #include "../gl_common.h" #include "../gfx_common.h" diff --git a/gfx/context/wgl_ctx.c b/gfx/context/wgl_ctx.c index fa80af1395..567bd7f95b 100644 --- a/gfx/context/wgl_ctx.c +++ b/gfx/context/wgl_ctx.c @@ -22,7 +22,7 @@ #endif #include "../../driver.h" -#include "../video_context.h" +#include "../video_context_driver.h" #include "../gl_common.h" #include "../gfx_common.h" #include "win32_common.h" diff --git a/gfx/d3d/d3d.h b/gfx/d3d/d3d.h index 4e80bc0a2a..db86dd87a6 100644 --- a/gfx/d3d/d3d.h +++ b/gfx/d3d/d3d.h @@ -50,7 +50,7 @@ #endif #include "../fonts/d3d_font.h" -#include "../video_context.h" +#include "../video_context_driver.h" #include "../gfx_common.h" #ifdef HAVE_CG diff --git a/gfx/drivers/gl.c b/gfx/drivers/gl.c index f81528a499..b315666cb8 100644 --- a/gfx/drivers/gl.c +++ b/gfx/drivers/gl.c @@ -38,7 +38,7 @@ #include "../gl_common.h" #include "../gfx_common.h" -#include "../video_context.h" +#include "../video_context_driver.h" #include #ifdef HAVE_GLSL diff --git a/gfx/drivers/omap_gfx.c b/gfx/drivers/omap_gfx.c index 3c5cfb4f02..b8000623b3 100644 --- a/gfx/drivers/omap_gfx.c +++ b/gfx/drivers/omap_gfx.c @@ -21,7 +21,7 @@ #include "../../retroarch.h" #include #include "../gfx_common.h" -#include "../video_context.h" +#include "../video_context_driver.h" #include "../fonts/fonts.h" #include diff --git a/gfx/drivers/sdl2_gfx.c b/gfx/drivers/sdl2_gfx.c index a332f38fa8..379b854146 100644 --- a/gfx/drivers/sdl2_gfx.c +++ b/gfx/drivers/sdl2_gfx.c @@ -23,7 +23,7 @@ #include "../../retroarch.h" #include #include "../gfx_common.h" -#include "../video_context.h" +#include "../video_context_driver.h" #include "../fonts/fonts.h" #ifdef HAVE_X11 diff --git a/gfx/drivers/sdl_gfx.c b/gfx/drivers/sdl_gfx.c index 0e400e5a3a..8e357145fd 100644 --- a/gfx/drivers/sdl_gfx.c +++ b/gfx/drivers/sdl_gfx.c @@ -21,7 +21,7 @@ #include "../../general.h" #include #include "../gfx_common.h" -#include "../video_context.h" +#include "../video_context_driver.h" #include "../fonts/fonts.h" #ifdef HAVE_X11 diff --git a/gfx/drivers/vg.c b/gfx/drivers/vg.c index 1edc1964db..6ceb608b4b 100644 --- a/gfx/drivers/vg.c +++ b/gfx/drivers/vg.c @@ -19,7 +19,7 @@ #include #include #include -#include "../video_context.h" +#include "../video_context_driver.h" #include #include "../../libretro.h" #include "../../general.h" diff --git a/gfx/video_context.c b/gfx/video_context_driver.c similarity index 99% rename from gfx/video_context.c rename to gfx/video_context_driver.c index e02db81926..06499bebe8 100644 --- a/gfx/video_context.c +++ b/gfx/video_context_driver.c @@ -15,7 +15,7 @@ */ #include "../general.h" -#include "video_context.h" +#include "video_context_driver.h" #include #ifdef HAVE_CONFIG_H diff --git a/gfx/video_context.h b/gfx/video_context_driver.h similarity index 98% rename from gfx/video_context.h rename to gfx/video_context_driver.h index 64639551f6..0797fd610f 100644 --- a/gfx/video_context.h +++ b/gfx/video_context_driver.h @@ -14,8 +14,8 @@ * If not, see . */ -#ifndef __VIDEO_CONTEXT_H -#define __VIDEO_CONTEXT_H +#ifndef __VIDEO_CONTEXT_DRIVER_H +#define __VIDEO_CONTEXT_DRIVER_H #include #include "../driver.h" diff --git a/gfx/video_shader_driver.h b/gfx/video_shader_driver.h index f0f4eef743..e9bded1ec6 100644 --- a/gfx/video_shader_driver.h +++ b/gfx/video_shader_driver.h @@ -22,7 +22,7 @@ #include "../config.h" #endif -#include "video_context.h" +#include "video_context_driver.h" #include typedef struct shader_backend diff --git a/griffin/griffin.c b/griffin/griffin.c index 99a5acd522..750f175ee6 100644 --- a/griffin/griffin.c +++ b/griffin/griffin.c @@ -86,7 +86,7 @@ CHEATS VIDEO CONTEXT ============================================================ */ -#include "../gfx/video_context.c" +#include "../gfx/video_context_driver.c" #include "../gfx/context/gfx_null_ctx.c" #if defined(__CELLOS_LV2__) diff --git a/input/drivers/sdl_input.c b/input/drivers/sdl_input.c index ba2adc0f1d..c365c4f73a 100644 --- a/input/drivers/sdl_input.c +++ b/input/drivers/sdl_input.c @@ -17,7 +17,7 @@ #include "../../driver.h" #include "SDL.h" -#include "../../gfx/video_context.h" +#include "../../gfx/video_context_driver.h" #include #include "../../general.h" #include diff --git a/menu/disp/rmenu_xui.cpp b/menu/disp/rmenu_xui.cpp index f464792e11..c706458b13 100644 --- a/menu/disp/rmenu_xui.cpp +++ b/menu/disp/rmenu_xui.cpp @@ -25,7 +25,7 @@ #include "../menu_list.h" #include "../../gfx/gfx_common.h" -#include "../../gfx/video_context.h" +#include "../../gfx/video_context_driver.h" #include "../../settings_data.h" #include "../../general.h" From 2eee9d294e5feabedeabf5f59055beda15ef1811 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Mon, 12 Jan 2015 21:55:41 +0100 Subject: [PATCH 134/156] Rename ffemu.c to record_driver.c --- Makefile.common | 2 +- driver.h | 2 +- griffin/griffin.c | 2 +- record/ffmpeg.c | 2 +- record/{ffemu.c => record_driver.c} | 2 +- record/{ffemu.h => record_driver.h} | 4 ++-- 6 files changed, 7 insertions(+), 7 deletions(-) rename record/{ffemu.c => record_driver.c} (98%) rename record/{ffemu.h => record_driver.h} (98%) diff --git a/Makefile.common b/Makefile.common index f210ccb8bb..7429869b14 100644 --- a/Makefile.common +++ b/Makefile.common @@ -154,7 +154,7 @@ OBJ += frontend/frontend.o \ osk/drivers/nullosk.o \ playlist.o \ movie.o \ - record/ffemu.o \ + record/record_driver.o \ performance.o # RarchDB diff --git a/driver.h b/driver.h index ddc21a3883..3574a65666 100644 --- a/driver.h +++ b/driver.h @@ -35,7 +35,7 @@ #include "camera/camera_driver.h" #include "location/location_driver.h" #include "audio/resamplers/resampler.h" -#include "record/ffemu.h" +#include "record/record_driver.h" #include "retro.h" diff --git a/griffin/griffin.c b/griffin/griffin.c index 750f175ee6..95036af85c 100644 --- a/griffin/griffin.c +++ b/griffin/griffin.c @@ -625,7 +625,7 @@ RETROARCH RECORDING ============================================================ */ #include "../movie.c" -#include "../record/ffemu.c" +#include "../record/record_driver.c" /*============================================================ THREAD diff --git a/record/ffmpeg.c b/record/ffmpeg.c index 8cd58ecd2d..4e725440b9 100644 --- a/record/ffmpeg.c +++ b/record/ffmpeg.c @@ -50,7 +50,7 @@ extern "C" { #include #include #include "../audio/utils.h" -#include "ffemu.h" +#include "record_driver.h" #include #ifdef FFEMU_PERF diff --git a/record/ffemu.c b/record/record_driver.c similarity index 98% rename from record/ffemu.c rename to record/record_driver.c index 0d92125a1f..388b0a649f 100644 --- a/record/ffemu.c +++ b/record/record_driver.c @@ -15,7 +15,7 @@ */ #include -#include "ffemu.h" +#include "record_driver.h" #include "../dynamic.h" diff --git a/record/ffemu.h b/record/record_driver.h similarity index 98% rename from record/ffemu.h rename to record/record_driver.h index bcf2021dcc..50089ed8ae 100644 --- a/record/ffemu.h +++ b/record/record_driver.h @@ -14,8 +14,8 @@ * If not, see . */ -#ifndef __FFEMU_H -#define __FFEMU_H +#ifndef __RECORD_DRIVER_H +#define __RECORD_DRIVER_H #include #include From 24e1699feda3ee3b99f5f9fb86707e375f07815b Mon Sep 17 00:00:00 2001 From: twinaphex Date: Mon, 12 Jan 2015 21:57:07 +0100 Subject: [PATCH 135/156] Create record/drivers and move record/ffmpeg.c to it --- Makefile.common | 2 +- record/{ => drivers}/ffmpeg.c | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) rename record/{ => drivers}/ffmpeg.c (99%) diff --git a/Makefile.common b/Makefile.common index 7429869b14..5750ad4851 100644 --- a/Makefile.common +++ b/Makefile.common @@ -629,7 +629,7 @@ endif # Record ifeq ($(HAVE_FFMPEG), 1) - OBJ += record/ffmpeg.o + OBJ += record/drivers/ffmpeg.o LIBS += $(AVCODEC_LIBS) $(AVFORMAT_LIBS) $(AVUTIL_LIBS) $(SWSCALE_LIBS) $(FFMPEG_LIBS) DEFINES += $(AVCODEC_CFLAGS) $(AVFORMAT_CFLAGS) $(AVUTIL_CFLAGS) $(SWSCALE_CFLAGS) DEFINES += -DHAVE_FFMPEG -Iffmpeg diff --git a/record/ffmpeg.c b/record/drivers/ffmpeg.c similarity index 99% rename from record/ffmpeg.c rename to record/drivers/ffmpeg.c index 4e725440b9..9a38bdf6bb 100644 --- a/record/ffmpeg.c +++ b/record/drivers/ffmpeg.c @@ -17,7 +17,7 @@ #include #ifdef HAVE_CONFIG_H -#include "../config.h" +#include "../../config.h" #endif #ifdef __cplusplus @@ -46,11 +46,11 @@ extern "C" { #include #include #include -#include "../general.h" +#include "../../general.h" #include #include -#include "../audio/utils.h" -#include "record_driver.h" +#include "../../audio/utils.h" +#include "../record_driver.h" #include #ifdef FFEMU_PERF From 73a1f5afbb05ac20e997f5adf547d8a9905dee3a Mon Sep 17 00:00:00 2001 From: twinaphex Date: Mon, 12 Jan 2015 21:59:32 +0100 Subject: [PATCH 136/156] Rename input/overlay.c to input/input_overlay.c --- Makefile.common | 2 +- griffin/griffin.c | 2 +- input/input_driver.h | 2 +- input/{overlay.c => input_overlay.c} | 2 +- input/{overlay.h => input_overlay.h} | 0 5 files changed, 4 insertions(+), 4 deletions(-) rename input/{overlay.c => input_overlay.c} (99%) rename input/{overlay.h => input_overlay.h} (100%) diff --git a/Makefile.common b/Makefile.common index 5750ad4851..bf69258fe6 100644 --- a/Makefile.common +++ b/Makefile.common @@ -120,7 +120,7 @@ OBJ += frontend/frontend.o \ input/input_common.o \ input/input_keymaps.o \ input/keyboard_line.o \ - input/overlay.o \ + input/input_overlay.o \ patch.o \ libretro-sdk/queues/fifo_buffer.o \ core_options.o \ diff --git a/griffin/griffin.c b/griffin/griffin.c index 95036af85c..fe1e54a951 100644 --- a/griffin/griffin.c +++ b/griffin/griffin.c @@ -287,7 +287,7 @@ INPUT #include "../input/keyboard_line.c" #ifdef HAVE_OVERLAY -#include "../input/overlay.c" +#include "../input/input_overlay.c" #endif #if defined(__CELLOS_LV2__) diff --git a/input/input_driver.h b/input/input_driver.h index bb7a7b4308..33494b3809 100644 --- a/input/input_driver.h +++ b/input/input_driver.h @@ -26,7 +26,7 @@ #include "input_joypad_driver.h" #ifdef HAVE_OVERLAY -#include "overlay.h" +#include "input_overlay.h" #endif #ifdef __cplusplus diff --git a/input/overlay.c b/input/input_overlay.c similarity index 99% rename from input/overlay.c rename to input/input_overlay.c index c9bef38ff4..bc7112c707 100644 --- a/input/overlay.c +++ b/input/input_overlay.c @@ -14,7 +14,7 @@ * If not, see . */ -#include "overlay.h" +#include "input_overlay.h" #include "../general.h" #include "../driver.h" #include diff --git a/input/overlay.h b/input/input_overlay.h similarity index 100% rename from input/overlay.h rename to input/input_overlay.h From 11bcc24c58400786bff2bfc4910704fd67c52fbb Mon Sep 17 00:00:00 2001 From: twinaphex Date: Mon, 12 Jan 2015 22:11:13 +0100 Subject: [PATCH 137/156] Rename some more files --- Makefile.common | 12 ++++++------ android/phoenix/jni/Android.mk | 4 ++-- apple/iOS/RetroArch_iOS.xcodeproj/project.pbxproj | 4 ++-- .../resampler.c => audio_resampler_driver.c} | 4 ++-- .../resampler.h => audio_resampler_driver.h} | 4 ++-- .../{resamplers => drivers_resampler}/cc_resampler.c | 8 ++++---- .../cc_resampler_neon.S | 0 audio/{resamplers => drivers_resampler}/nearest.c | 2 +- audio/{resamplers => drivers_resampler}/sinc.c | 2 +- audio/{resamplers => drivers_resampler}/sinc_neon.S | 0 driver.h | 2 +- griffin/griffin.c | 8 ++++---- 12 files changed, 25 insertions(+), 25 deletions(-) rename audio/{resamplers/resampler.c => audio_resampler_driver.c} (98%) rename audio/{resamplers/resampler.h => audio_resampler_driver.h} (98%) rename audio/{resamplers => drivers_resampler}/cc_resampler.c (99%) rename audio/{resamplers => drivers_resampler}/cc_resampler_neon.S (100%) rename audio/{resamplers => drivers_resampler}/nearest.c (98%) rename audio/{resamplers => drivers_resampler}/sinc.c (99%) rename audio/{resamplers => drivers_resampler}/sinc_neon.S (100%) diff --git a/Makefile.common b/Makefile.common index bf69258fe6..ec18336cb2 100644 --- a/Makefile.common +++ b/Makefile.common @@ -140,11 +140,11 @@ OBJ += frontend/frontend.o \ gfx/image/image_rpng.o \ gfx/fonts/fonts.o \ gfx/video_filter.o \ - audio/resamplers/resampler.o \ + audio/audio_resampler_driver.o \ audio/dsp_filter.o \ - audio/resamplers/sinc.o \ - audio/resamplers/nearest.o \ - audio/resamplers/cc_resampler.o \ + audio/drivers_resampler/sinc.o \ + audio/drivers_resampler/nearest.o \ + audio/drivers_resampler/cc_resampler.o \ location/drivers/nulllocation.o \ camera/drivers/nullcamera.o \ gfx/drivers/nullgfx.o \ @@ -257,8 +257,8 @@ endif # Audio Resamplers ifeq ($(HAVE_NEON),1) - OBJ += audio/resamplers/sinc_neon.o - OBJ += audio/resamplers/cc_resampler_neon.o + OBJ += audio/drivers_resampler/sinc_neon.o + OBJ += audio/drivers_resampler/cc_resampler_neon.o # When compiled without this, tries to attempt to compile sinc lerp, # which will error out # diff --git a/android/phoenix/jni/Android.mk b/android/phoenix/jni/Android.mk index c6a2607c8d..17a9fdb258 100644 --- a/android/phoenix/jni/Android.mk +++ b/android/phoenix/jni/Android.mk @@ -29,8 +29,8 @@ ifeq ($(TARGET_ARCH_ABI),armeabi-v7a) ifeq ($(HAVE_NEON),1) LOCAL_CFLAGS += -D__ARM_NEON__ LOCAL_SRC_FILES += $(RARCH_DIR)/audio/utils_neon.S.neon - LOCAL_SRC_FILES += $(RARCH_DIR)/audio/resamplers/sinc_neon.S.neon - LOCAL_SRC_FILES += $(RARCH_DIR)/audio/resamplers/cc_resampler_neon.S.neon + LOCAL_SRC_FILES += $(RARCH_DIR)/audio/drivers_resampler/sinc_neon.S.neon + LOCAL_SRC_FILES += $(RARCH_DIR)/audio/drivers_resampler/cc_resampler_neon.S.neon endif LOCAL_CFLAGS += -DSINC_LOWER_QUALITY diff --git a/apple/iOS/RetroArch_iOS.xcodeproj/project.pbxproj b/apple/iOS/RetroArch_iOS.xcodeproj/project.pbxproj index bbf1d7f6f7..59a40adb8f 100644 --- a/apple/iOS/RetroArch_iOS.xcodeproj/project.pbxproj +++ b/apple/iOS/RetroArch_iOS.xcodeproj/project.pbxproj @@ -42,7 +42,7 @@ /* Begin PBXFileReference section */ 501232C7192E5FB00063A359 /* apple_gamecontroller.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = apple_gamecontroller.m; path = ../common/apple_gamecontroller.m; sourceTree = ""; }; 501232C9192E5FC40063A359 /* griffin.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = griffin.c; path = ../../griffin/griffin.c; sourceTree = ""; }; - 501232CB192E5FDC0063A359 /* sinc_neon.S */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.asm; name = sinc_neon.S; path = ../../audio/resamplers/sinc_neon.S; sourceTree = ""; }; + 501232CB192E5FDC0063A359 /* sinc_neon.S */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.asm; name = sinc_neon.S; path = ../../audio/drivers_resampler/sinc_neon.S; sourceTree = ""; }; 501232CD192E5FE30063A359 /* utils_neon.S */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.asm; name = utils_neon.S; path = ../../audio/utils_neon.S; sourceTree = ""; }; 501232D5192E60580063A359 /* platform.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = platform.m; sourceTree = ""; }; 501232D7192E605F0063A359 /* browser.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = browser.m; sourceTree = ""; }; @@ -52,7 +52,7 @@ 5073C587196C0BA40026E146 /* RAGameView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = RAGameView.m; path = ../common/RAGameView.m; sourceTree = SOURCE_ROOT; }; 5073C588196C0BA40026E146 /* utility.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = utility.m; path = ../common/utility.m; sourceTree = SOURCE_ROOT; }; 50CCC827185E0E7D001F5BC8 /* CoreLocation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreLocation.framework; path = System/Library/Frameworks/CoreLocation.framework; sourceTree = SDKROOT; }; - 50D00E8D19D117C400EBA71E /* cc_resampler_neon.S */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.asm; name = cc_resampler_neon.S; path = ../../audio/resamplers/cc_resampler_neon.S; sourceTree = ""; }; + 50D00E8D19D117C400EBA71E /* cc_resampler_neon.S */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.asm; name = cc_resampler_neon.S; path = ../../audio/drivers_resampler/cc_resampler_neon.S; sourceTree = ""; }; 50E7189E184B88AA001956CE /* CoreVideo.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreVideo.framework; path = System/Library/Frameworks/CoreVideo.framework; sourceTree = SDKROOT; }; 6949E72219FABADC00CC7F42 /* CFExtensions.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; name = CFExtensions.m; path = ../common/CFExtensions.m; sourceTree = ""; }; 696012F119F3389A006A1088 /* CoreText.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreText.framework; path = System/Library/Frameworks/CoreText.framework; sourceTree = SDKROOT; }; diff --git a/audio/resamplers/resampler.c b/audio/audio_resampler_driver.c similarity index 98% rename from audio/resamplers/resampler.c rename to audio/audio_resampler_driver.c index 7118a70b44..22ecd00687 100644 --- a/audio/resamplers/resampler.c +++ b/audio/audio_resampler_driver.c @@ -14,9 +14,9 @@ * If not, see . */ -#include "resampler.h" +#include "audio_resampler_driver.h" #ifdef RARCH_INTERNAL -#include "../../performance.h" +#include "../performance.h" #endif #include #include diff --git a/audio/resamplers/resampler.h b/audio/audio_resampler_driver.h similarity index 98% rename from audio/resamplers/resampler.h rename to audio/audio_resampler_driver.h index 8d376a4cb8..ad88d9a372 100644 --- a/audio/resamplers/resampler.h +++ b/audio/audio_resampler_driver.h @@ -15,8 +15,8 @@ */ -#ifndef __RARCH_RESAMPLER_H -#define __RARCH_RESAMPLER_H +#ifndef __AUDIO_RESAMPLER_DRIVER_H +#define __AUDIO_RESAMPLER_DRIVER_H #ifdef __cplusplus extern "C" { diff --git a/audio/resamplers/cc_resampler.c b/audio/drivers_resampler/cc_resampler.c similarity index 99% rename from audio/resamplers/cc_resampler.c rename to audio/drivers_resampler/cc_resampler.c index 65d71f042d..bc1eb991a2 100644 --- a/audio/resamplers/cc_resampler.c +++ b/audio/drivers_resampler/cc_resampler.c @@ -15,10 +15,13 @@ /* Convoluted Cosine Resampler */ -#include "resampler.h" +#include "../audio_resampler_driver.h" #include #include #include +#ifdef __SSE__ +#include +#endif #if !defined(RESAMPLER_TEST) && defined(RARCH_INTERNAL) #include "../../general.h" @@ -212,9 +215,6 @@ static void *resampler_CC_init(const struct resampler_config *config, #if defined(__SSE__) - -#include - #define CC_RESAMPLER_IDENT "SSE" static void resampler_CC_downsample(void *re_, struct resampler_data *data) diff --git a/audio/resamplers/cc_resampler_neon.S b/audio/drivers_resampler/cc_resampler_neon.S similarity index 100% rename from audio/resamplers/cc_resampler_neon.S rename to audio/drivers_resampler/cc_resampler_neon.S diff --git a/audio/resamplers/nearest.c b/audio/drivers_resampler/nearest.c similarity index 98% rename from audio/resamplers/nearest.c rename to audio/drivers_resampler/nearest.c index 8664518302..2166d2374a 100644 --- a/audio/resamplers/nearest.c +++ b/audio/drivers_resampler/nearest.c @@ -13,7 +13,7 @@ * If not, see . */ -#include "resampler.h" +#include "../audio_resampler_driver.h" #include #include #include diff --git a/audio/resamplers/sinc.c b/audio/drivers_resampler/sinc.c similarity index 99% rename from audio/resamplers/sinc.c rename to audio/drivers_resampler/sinc.c index faac11b66e..456478b238 100644 --- a/audio/resamplers/sinc.c +++ b/audio/drivers_resampler/sinc.c @@ -15,7 +15,7 @@ /* Bog-standard windowed SINC implementation. */ -#include "resampler.h" +#include "../audio_resampler_driver.h" #include #include #include diff --git a/audio/resamplers/sinc_neon.S b/audio/drivers_resampler/sinc_neon.S similarity index 100% rename from audio/resamplers/sinc_neon.S rename to audio/drivers_resampler/sinc_neon.S diff --git a/driver.h b/driver.h index 3574a65666..9e88866a3e 100644 --- a/driver.h +++ b/driver.h @@ -34,7 +34,7 @@ #include "osk/osk_driver.h" #include "camera/camera_driver.h" #include "location/location_driver.h" -#include "audio/resamplers/resampler.h" +#include "audio/audio_resampler_driver.h" #include "record/record_driver.h" #include "retro.h" diff --git a/griffin/griffin.c b/griffin/griffin.c index fe1e54a951..961e31ce6a 100644 --- a/griffin/griffin.c +++ b/griffin/griffin.c @@ -409,10 +409,10 @@ FIFO BUFFER /*============================================================ AUDIO RESAMPLER ============================================================ */ -#include "../audio/resamplers/resampler.c" -#include "../audio/resamplers/sinc.c" -#include "../audio/resamplers/nearest.c" -#include "../audio/resamplers/cc_resampler.c" +#include "../audio/audio_resampler_driver.c" +#include "../audio/drivers_resampler/sinc.c" +#include "../audio/drivers_resampler/nearest.c" +#include "../audio/drivers_resampler/cc_resampler.c" /*============================================================ CAMERA From 069fb556f0e8082305b3e999e95555e51b7f2e04 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Mon, 12 Jan 2015 22:19:31 +0100 Subject: [PATCH 138/156] Rename graphics context drivers --- Makefile.common | 28 +++++++++---------- Makefile.emscripten | 2 +- Makefile.pandora | 2 +- driver.c | 2 +- gfx/d3d/d3d.cpp | 2 +- gfx/d3d/d3d_wrapper.h | 2 +- gfx/drivers/sdl2_gfx.c | 2 +- gfx/drivers/sdl_gfx.c | 2 +- gfx/drivers/xvideo.c | 2 +- .../androidegl_ctx.c | 0 gfx/{context => drivers_context}/bbqnx_ctx.c | 0 gfx/{context => drivers_context}/d3d_ctx.cpp | 0 .../drm_egl_ctx.c | 0 .../emscriptenegl_ctx.c | 0 .../gfx_null_ctx.c | 0 gfx/{context => drivers_context}/glx_ctx.c | 0 .../mali_fbdev_ctx.c | 0 gfx/{context => drivers_context}/ps3_ctx.c | 0 gfx/{context => drivers_context}/sdl_gl_ctx.c | 0 gfx/{context => drivers_context}/vc_egl_ctx.c | 0 .../vivante_fbdev_ctx.c | 0 .../wayland_ctx.c | 0 gfx/{context => drivers_context}/wgl_ctx.c | 0 .../win32_common.h | 0 gfx/{context => drivers_context}/x11_common.c | 0 gfx/{context => drivers_context}/x11_common.h | 0 gfx/{context => drivers_context}/xegl_ctx.c | 0 gfx/image/image.h | 2 +- griffin/griffin.c | 24 ++++++++-------- input/keyboard_event_win32.c | 2 +- 30 files changed, 36 insertions(+), 36 deletions(-) rename gfx/{context => drivers_context}/androidegl_ctx.c (100%) rename gfx/{context => drivers_context}/bbqnx_ctx.c (100%) rename gfx/{context => drivers_context}/d3d_ctx.cpp (100%) rename gfx/{context => drivers_context}/drm_egl_ctx.c (100%) rename gfx/{context => drivers_context}/emscriptenegl_ctx.c (100%) rename gfx/{context => drivers_context}/gfx_null_ctx.c (100%) rename gfx/{context => drivers_context}/glx_ctx.c (100%) rename gfx/{context => drivers_context}/mali_fbdev_ctx.c (100%) rename gfx/{context => drivers_context}/ps3_ctx.c (100%) rename gfx/{context => drivers_context}/sdl_gl_ctx.c (100%) rename gfx/{context => drivers_context}/vc_egl_ctx.c (100%) rename gfx/{context => drivers_context}/vivante_fbdev_ctx.c (100%) rename gfx/{context => drivers_context}/wayland_ctx.c (100%) rename gfx/{context => drivers_context}/wgl_ctx.c (100%) rename gfx/{context => drivers_context}/win32_common.h (100%) rename gfx/{context => drivers_context}/x11_common.c (100%) rename gfx/{context => drivers_context}/x11_common.h (100%) rename gfx/{context => drivers_context}/xegl_ctx.c (100%) diff --git a/Makefile.common b/Makefile.common index ec18336cb2..c1aa3eac29 100644 --- a/Makefile.common +++ b/Makefile.common @@ -346,7 +346,7 @@ ifeq ($(HAVE_WINXINPUT), 1) endif ifeq ($(HAVE_X11), 1) - OBJ += input/drivers/x11_input.o gfx/context/x11_common.o input/keyboard_event_x11.o + OBJ += input/drivers/x11_input.o gfx/drivers_context/x11_common.o input/keyboard_event_x11.o LIBS += $(X11_LIBS) $(XEXT_LIBS) $(XF86VM_LIBS) $(XINERAMA_LIBS) DEFINES += $(X11_CFLAGS) $(XEXT_CFLAGS) $(XF86VM_CFLAGS) $(XINERAMA_CFLAGS) endif @@ -375,7 +375,7 @@ ifeq ($(HAVE_OPENGL), 1) OBJ += gfx/drivers/gl.o \ gfx/gl_common.o \ gfx/video_context_driver.o \ - gfx/context/gfx_null_ctx.o \ + gfx/drivers_context/gfx_null_ctx.o \ gfx/fonts/gl_font.o \ gfx/fonts/gl_raster_font.o \ libretro-sdk/gfx/math/matrix_4x4.o \ @@ -383,39 +383,39 @@ ifeq ($(HAVE_OPENGL), 1) libretro-sdk/glsym/rglgen.o ifeq ($(HAVE_KMS), 1) - OBJ += gfx/context/drm_egl_ctx.o + OBJ += gfx/drivers_context/drm_egl_ctx.o DEFINES += $(GBM_CFLAGS) $(DRM_CFLAGS) $(EGL_CFLAGS) LIBS += $(GBM_LIBS) $(DRM_LIBS) $(EGL_LIBS) endif ifeq ($(HAVE_VIDEOCORE), 1) - OBJ += gfx/context/vc_egl_ctx.o + OBJ += gfx/drivers_context/vc_egl_ctx.o DEFINES += $(EGL_CFLAGS) LIBS += $(EGL_LIBS) endif ifeq ($(HAVE_EMSCRIPTEN), 1) - OBJ += gfx/context/emscriptenegl_ctx.o + OBJ += gfx/drivers_context/emscriptenegl_ctx.o endif ifeq ($(HAVE_MALI_FBDEV), 1) - OBJ += gfx/context/mali_fbdev_ctx.o + OBJ += gfx/drivers_context/mali_fbdev_ctx.o DEFINES += $(EGL_CFLAGS) LIBS += $(EGL_LIBS) endif ifeq ($(HAVE_VIVANTE_FBDEV), 1) - OBJ += gfx/context/vivante_fbdev_ctx.o + OBJ += gfx/drivers_context/vivante_fbdev_ctx.o DEFINES += $(EGL_CFLAGS) LIBS += $(EGL_LIBS) endif ifeq ($(HAVE_X11), 1) ifeq ($(HAVE_GLES), 0) - OBJ += gfx/context/glx_ctx.o + OBJ += gfx/drivers_context/glx_ctx.o endif ifeq ($(HAVE_EGL), 1) - OBJ += gfx/context/xegl_ctx.o + OBJ += gfx/drivers_context/xegl_ctx.o DEFINES += $(EGL_CFLAGS) LIBS += $(EGL_LIBS) endif @@ -423,7 +423,7 @@ ifeq ($(HAVE_OPENGL), 1) ifeq ($(HAVE_WAYLAND), 1) ifeq ($(HAVE_EGL), 1) - OBJ += gfx/context/wayland_ctx.o + OBJ += gfx/drivers_context/wayland_ctx.o endif endif @@ -441,7 +441,7 @@ ifeq ($(HAVE_OPENGL), 1) LIBS += -framework OpenGL else ifneq ($(findstring Win32,$(OS)),) LIBS += -lopengl32 -lgdi32 -lcomdlg32 - OBJ += gfx/context/wgl_ctx.o + OBJ += gfx/drivers_context/wgl_ctx.o else LIBS += -lGL endif @@ -459,7 +459,7 @@ ifeq ($(HAVE_SDL), 1) OBJ += gfx/drivers/sdl_gfx.o input/drivers/sdl_input.o input/drivers_joypad/sdl_joypad.o audio/drivers/sdl_audio.o ifeq ($(HAVE_OPENGL), 1) - OBJ += gfx/context/sdl_gl_ctx.o + OBJ += gfx/drivers_context/sdl_gl_ctx.o endif JOYCONFIG_LIBS += $(SDL_LIBS) @@ -471,7 +471,7 @@ ifeq ($(HAVE_SDL2), 1) OBJ += gfx/drivers/sdl2_gfx.o input/drivers/sdl_input.o input/drivers_joypad/sdl_joypad.o audio/drivers/sdl_audio.o ifeq ($(HAVE_OPENGL), 1) - OBJ += gfx/context/sdl_gl_ctx.o + OBJ += gfx/drivers_context/sdl_gl_ctx.o endif JOYCONFIG_LIBS += $(SDL2_LIBS) @@ -514,7 +514,7 @@ ifeq ($(HAVE_D3D9), 1) gfx/d3d/d3d_wrapper.o \ gfx/fonts/d3d_font.o \ gfx/fonts/d3d_w32_font.o \ - gfx/context/d3d_ctx.o + gfx/drivers_context/d3d_ctx.o DEFINES += -DHAVE_WIN32_D3D9 LIBS += -ld3d9 -ld3dx9 -ldxguid diff --git a/Makefile.emscripten b/Makefile.emscripten index b1835ceb9b..b489cf725e 100644 --- a/Makefile.emscripten +++ b/Makefile.emscripten @@ -76,7 +76,7 @@ clean: rm -f gfx/scaler/*.o rm -f gfx/*.o rm -f gfx/d3d/*.o - rm -f gfx/context/*.o + rm -f gfx/drivers_context/*.o rm -f gfx/math/*.o rm -f gfx/fonts/*.o rm -f gfx/py_state/*.o diff --git a/Makefile.pandora b/Makefile.pandora index 6ba39ef28e..9160791bde 100644 --- a/Makefile.pandora +++ b/Makefile.pandora @@ -41,7 +41,7 @@ clean: rm -f conf/*.o rm -f gfx/*.o rm -f gfx/fonts/*.o - rm -f gfx/context/*.o + rm -f gfx/drivers_context/*.o rm -f gfx/py_state/*.o rm -f compat/*.o rm -f record/*.o diff --git a/driver.c b/driver.c index 48a49d5211..6d0010d1bb 100644 --- a/driver.c +++ b/driver.c @@ -24,7 +24,7 @@ #include "gfx/gfx_common.h" #ifdef HAVE_X11 -#include "gfx/context/x11_common.h" +#include "gfx/drivers_context/x11_common.h" #endif #ifdef HAVE_MENU diff --git a/gfx/d3d/d3d.cpp b/gfx/d3d/d3d.cpp index 2869685be2..22d4a4f6a5 100644 --- a/gfx/d3d/d3d.cpp +++ b/gfx/d3d/d3d.cpp @@ -26,7 +26,7 @@ #endif #include "../gfx_common.h" -#include "../context/win32_common.h" +#include "../drivers_context/win32_common.h" #ifndef _XBOX #define HAVE_MONITOR diff --git a/gfx/d3d/d3d_wrapper.h b/gfx/d3d/d3d_wrapper.h index e9b8ea451a..8479d61391 100644 --- a/gfx/d3d/d3d_wrapper.h +++ b/gfx/d3d/d3d_wrapper.h @@ -17,7 +17,7 @@ #ifndef _D3D_WRAPPER_H #define _D3D_WRAPPER_H -#include "../context/win32_common.h" +#include "../drivers_context/win32_common.h" #include "d3d_defines.h" void d3d_swap(void *data, LPDIRECT3DDEVICE dev); diff --git a/gfx/drivers/sdl2_gfx.c b/gfx/drivers/sdl2_gfx.c index 379b854146..da2cdeabcf 100644 --- a/gfx/drivers/sdl2_gfx.c +++ b/gfx/drivers/sdl2_gfx.c @@ -27,7 +27,7 @@ #include "../fonts/fonts.h" #ifdef HAVE_X11 -#include "../context/x11_common.h" +#include "../drivers_context/x11_common.h" #endif #ifdef HAVE_CONFIG_H diff --git a/gfx/drivers/sdl_gfx.c b/gfx/drivers/sdl_gfx.c index 8e357145fd..4d30f2da6e 100644 --- a/gfx/drivers/sdl_gfx.c +++ b/gfx/drivers/sdl_gfx.c @@ -25,7 +25,7 @@ #include "../fonts/fonts.h" #ifdef HAVE_X11 -#include "../context/x11_common.h" +#include "../drivers_context/x11_common.h" #endif #ifdef HAVE_CONFIG_H diff --git a/gfx/drivers/xvideo.c b/gfx/drivers/xvideo.c index 54dbffcee4..60930a8e0c 100644 --- a/gfx/drivers/xvideo.c +++ b/gfx/drivers/xvideo.c @@ -22,7 +22,7 @@ #include "../gfx_common.h" #include "../fonts/fonts.h" -#include "../context/x11_common.h" +#include "../drivers_context/x11_common.h" #include #include diff --git a/gfx/context/androidegl_ctx.c b/gfx/drivers_context/androidegl_ctx.c similarity index 100% rename from gfx/context/androidegl_ctx.c rename to gfx/drivers_context/androidegl_ctx.c diff --git a/gfx/context/bbqnx_ctx.c b/gfx/drivers_context/bbqnx_ctx.c similarity index 100% rename from gfx/context/bbqnx_ctx.c rename to gfx/drivers_context/bbqnx_ctx.c diff --git a/gfx/context/d3d_ctx.cpp b/gfx/drivers_context/d3d_ctx.cpp similarity index 100% rename from gfx/context/d3d_ctx.cpp rename to gfx/drivers_context/d3d_ctx.cpp diff --git a/gfx/context/drm_egl_ctx.c b/gfx/drivers_context/drm_egl_ctx.c similarity index 100% rename from gfx/context/drm_egl_ctx.c rename to gfx/drivers_context/drm_egl_ctx.c diff --git a/gfx/context/emscriptenegl_ctx.c b/gfx/drivers_context/emscriptenegl_ctx.c similarity index 100% rename from gfx/context/emscriptenegl_ctx.c rename to gfx/drivers_context/emscriptenegl_ctx.c diff --git a/gfx/context/gfx_null_ctx.c b/gfx/drivers_context/gfx_null_ctx.c similarity index 100% rename from gfx/context/gfx_null_ctx.c rename to gfx/drivers_context/gfx_null_ctx.c diff --git a/gfx/context/glx_ctx.c b/gfx/drivers_context/glx_ctx.c similarity index 100% rename from gfx/context/glx_ctx.c rename to gfx/drivers_context/glx_ctx.c diff --git a/gfx/context/mali_fbdev_ctx.c b/gfx/drivers_context/mali_fbdev_ctx.c similarity index 100% rename from gfx/context/mali_fbdev_ctx.c rename to gfx/drivers_context/mali_fbdev_ctx.c diff --git a/gfx/context/ps3_ctx.c b/gfx/drivers_context/ps3_ctx.c similarity index 100% rename from gfx/context/ps3_ctx.c rename to gfx/drivers_context/ps3_ctx.c diff --git a/gfx/context/sdl_gl_ctx.c b/gfx/drivers_context/sdl_gl_ctx.c similarity index 100% rename from gfx/context/sdl_gl_ctx.c rename to gfx/drivers_context/sdl_gl_ctx.c diff --git a/gfx/context/vc_egl_ctx.c b/gfx/drivers_context/vc_egl_ctx.c similarity index 100% rename from gfx/context/vc_egl_ctx.c rename to gfx/drivers_context/vc_egl_ctx.c diff --git a/gfx/context/vivante_fbdev_ctx.c b/gfx/drivers_context/vivante_fbdev_ctx.c similarity index 100% rename from gfx/context/vivante_fbdev_ctx.c rename to gfx/drivers_context/vivante_fbdev_ctx.c diff --git a/gfx/context/wayland_ctx.c b/gfx/drivers_context/wayland_ctx.c similarity index 100% rename from gfx/context/wayland_ctx.c rename to gfx/drivers_context/wayland_ctx.c diff --git a/gfx/context/wgl_ctx.c b/gfx/drivers_context/wgl_ctx.c similarity index 100% rename from gfx/context/wgl_ctx.c rename to gfx/drivers_context/wgl_ctx.c diff --git a/gfx/context/win32_common.h b/gfx/drivers_context/win32_common.h similarity index 100% rename from gfx/context/win32_common.h rename to gfx/drivers_context/win32_common.h diff --git a/gfx/context/x11_common.c b/gfx/drivers_context/x11_common.c similarity index 100% rename from gfx/context/x11_common.c rename to gfx/drivers_context/x11_common.c diff --git a/gfx/context/x11_common.h b/gfx/drivers_context/x11_common.h similarity index 100% rename from gfx/context/x11_common.h rename to gfx/drivers_context/x11_common.h diff --git a/gfx/context/xegl_ctx.c b/gfx/drivers_context/xegl_ctx.c similarity index 100% rename from gfx/context/xegl_ctx.c rename to gfx/drivers_context/xegl_ctx.c diff --git a/gfx/image/image.h b/gfx/image/image.h index 63232cb5f6..a483d64923 100644 --- a/gfx/image/image.h +++ b/gfx/image/image.h @@ -21,7 +21,7 @@ #include #ifdef _WIN32 -#include "../context/win32_common.h" +#include "../drivers_context/win32_common.h" #ifdef _XBOX1 #include "../d3d/d3d_defines.h" #endif diff --git a/griffin/griffin.c b/griffin/griffin.c index 961e31ce6a..8b31318ac2 100644 --- a/griffin/griffin.c +++ b/griffin/griffin.c @@ -87,45 +87,45 @@ VIDEO CONTEXT ============================================================ */ #include "../gfx/video_context_driver.c" -#include "../gfx/context/gfx_null_ctx.c" +#include "../gfx/drivers_context/gfx_null_ctx.c" #if defined(__CELLOS_LV2__) -#include "../gfx/context/ps3_ctx.c" +#include "../gfx/drivers_context/ps3_ctx.c" #elif defined(_XBOX) || defined(HAVE_WIN32_D3D9) -#include "../gfx/context/d3d_ctx.cpp" +#include "../gfx/drivers_context/d3d_ctx.cpp" #elif defined(ANDROID) -#include "../gfx/context/androidegl_ctx.c" +#include "../gfx/drivers_context/androidegl_ctx.c" #elif defined(__QNX__) -#include "../gfx/context/bbqnx_ctx.c" +#include "../gfx/drivers_context/bbqnx_ctx.c" #elif defined(EMSCRIPTEN) -#include "../gfx/context/emscriptenegl_ctx.c" +#include "../gfx/drivers_context/emscriptenegl_ctx.c" #endif #if defined(HAVE_OPENGL) #if defined(HAVE_KMS) -#include "../gfx/context/drm_egl_ctx.c" +#include "../gfx/drivers_context/drm_egl_ctx.c" #endif #if defined(HAVE_VIDEOCORE) -#include "../gfx/context/vc_egl_ctx.c" +#include "../gfx/drivers_context/vc_egl_ctx.c" #endif #if defined(HAVE_X11) && !defined(HAVE_OPENGLES) -#include "../gfx/context/glx_ctx.c" +#include "../gfx/drivers_context/glx_ctx.c" #endif #if defined(HAVE_EGL) -#include "../gfx/context/xegl_ctx.c" +#include "../gfx/drivers_context/xegl_ctx.c" #endif #if defined(_WIN32) && !defined(_XBOX) -#include "../gfx/context/wgl_ctx.c" +#include "../gfx/drivers_context/wgl_ctx.c" #endif #endif #ifdef HAVE_X11 -#include "../gfx/context/x11_common.c" +#include "../gfx/drivers_context/x11_common.c" #endif diff --git a/input/keyboard_event_win32.c b/input/keyboard_event_win32.c index d8dfd72a99..f60573a20e 100644 --- a/input/keyboard_event_win32.c +++ b/input/keyboard_event_win32.c @@ -16,7 +16,7 @@ #include "../general.h" #include "keyboard_line.h" -#include "../gfx/context/win32_common.h" +#include "../gfx/drivers_context/win32_common.h" #include "input_common.h" #include "input_keymaps.h" From 64411558eba6cc3e49eb2aa8993bcda5906ffff6 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Mon, 12 Jan 2015 22:23:48 +0100 Subject: [PATCH 139/156] Rename gfx/shader/ to gfx/drivers_shader --- Makefile.common | 8 ++++---- gfx/d3d/d3d.cpp | 4 ++-- gfx/d3d/render_chain.h | 2 +- gfx/drivers/gl.c | 2 +- gfx/{shader => drivers_shader}/shader_gl_cg.c | 0 gfx/{shader => drivers_shader}/shader_glsl.c | 0 gfx/{shader => drivers_shader}/shader_glsl.h | 0 gfx/{shader => drivers_shader}/shader_hlsl.c | 0 gfx/{shader => drivers_shader}/shader_hlsl.h | 0 gfx/{shader => drivers_shader}/shader_null.c | 0 gfx/{shader => drivers_shader}/shader_parse.c | 0 gfx/{shader => drivers_shader}/shader_parse.h | 0 gfx/video_driver.h | 2 +- gfx/video_shader_driver.h | 2 +- griffin/griffin.c | 10 +++++----- menu/menu.h | 2 +- 16 files changed, 16 insertions(+), 16 deletions(-) rename gfx/{shader => drivers_shader}/shader_gl_cg.c (100%) rename gfx/{shader => drivers_shader}/shader_glsl.c (100%) rename gfx/{shader => drivers_shader}/shader_glsl.h (100%) rename gfx/{shader => drivers_shader}/shader_hlsl.c (100%) rename gfx/{shader => drivers_shader}/shader_hlsl.h (100%) rename gfx/{shader => drivers_shader}/shader_null.c (100%) rename gfx/{shader => drivers_shader}/shader_parse.c (100%) rename gfx/{shader => drivers_shader}/shader_parse.h (100%) diff --git a/Makefile.common b/Makefile.common index c1aa3eac29..4bea588dbb 100644 --- a/Makefile.common +++ b/Makefile.common @@ -131,9 +131,9 @@ OBJ += frontend/frontend.o \ libretro-sdk/file/config_file_userdata.o \ screenshot.o \ libretro-sdk/gfx/scaler/scaler.o \ - gfx/shader/shader_null.o \ + gfx/drivers_shader/shader_null.o \ gfx/video_shader_driver.o \ - gfx/shader/shader_parse.o \ + gfx/drivers_shader/shader_parse.o \ libretro-sdk/gfx/scaler/pixconv.o \ libretro-sdk/gfx/scaler/scaler_int.o \ libretro-sdk/gfx/scaler/scaler_filter.o \ @@ -447,7 +447,7 @@ ifeq ($(HAVE_OPENGL), 1) endif endif - OBJ += gfx/shader/shader_glsl.o + OBJ += gfx/drivers_shader/shader_glsl.o DEFINES += -DHAVE_GLSL endif @@ -504,7 +504,7 @@ endif ifeq ($(HAVE_CG), 1) DEFINES += -DHAVE_CG - OBJ += gfx/shader/shader_gl_cg.o + OBJ += gfx/drivers_shader/shader_gl_cg.o LIBS += $(CG_LIBS) endif diff --git a/gfx/d3d/d3d.cpp b/gfx/d3d/d3d.cpp index 22d4a4f6a5..16fb5b8e96 100644 --- a/gfx/d3d/d3d.cpp +++ b/gfx/d3d/d3d.cpp @@ -42,14 +42,14 @@ #endif #ifdef HAVE_HLSL -#include "../../gfx/shader/shader_hlsl.h" +#include "../drivers_shader/shader_hlsl.h" #endif #include "d3d_defines.h" #if defined(HAVE_CG) || defined(HAVE_GLSL) || defined(HAVE_HLSL) #ifdef HAVE_HLSL -#include "../shader/shader_hlsl.h" +#include "../drivers_shader/shader_hlsl.h" #endif #endif diff --git a/gfx/d3d/render_chain.h b/gfx/d3d/render_chain.h index e58bfb33c1..8cb6c3db6d 100644 --- a/gfx/d3d/render_chain.h +++ b/gfx/d3d/render_chain.h @@ -19,7 +19,7 @@ #include "d3d.h" #include "../video_state_tracker.h" -#include "../shader/shader_parse.h" +#include "../drivers_shader/shader_parse.h" struct Vertex { diff --git a/gfx/drivers/gl.c b/gfx/drivers/gl.c index b315666cb8..5a20a0993f 100644 --- a/gfx/drivers/gl.c +++ b/gfx/drivers/gl.c @@ -42,7 +42,7 @@ #include #ifdef HAVE_GLSL -#include "../shader/shader_glsl.h" +#include "../drivers_shader/shader_glsl.h" #endif #ifdef GL_DEBUG diff --git a/gfx/shader/shader_gl_cg.c b/gfx/drivers_shader/shader_gl_cg.c similarity index 100% rename from gfx/shader/shader_gl_cg.c rename to gfx/drivers_shader/shader_gl_cg.c diff --git a/gfx/shader/shader_glsl.c b/gfx/drivers_shader/shader_glsl.c similarity index 100% rename from gfx/shader/shader_glsl.c rename to gfx/drivers_shader/shader_glsl.c diff --git a/gfx/shader/shader_glsl.h b/gfx/drivers_shader/shader_glsl.h similarity index 100% rename from gfx/shader/shader_glsl.h rename to gfx/drivers_shader/shader_glsl.h diff --git a/gfx/shader/shader_hlsl.c b/gfx/drivers_shader/shader_hlsl.c similarity index 100% rename from gfx/shader/shader_hlsl.c rename to gfx/drivers_shader/shader_hlsl.c diff --git a/gfx/shader/shader_hlsl.h b/gfx/drivers_shader/shader_hlsl.h similarity index 100% rename from gfx/shader/shader_hlsl.h rename to gfx/drivers_shader/shader_hlsl.h diff --git a/gfx/shader/shader_null.c b/gfx/drivers_shader/shader_null.c similarity index 100% rename from gfx/shader/shader_null.c rename to gfx/drivers_shader/shader_null.c diff --git a/gfx/shader/shader_parse.c b/gfx/drivers_shader/shader_parse.c similarity index 100% rename from gfx/shader/shader_parse.c rename to gfx/drivers_shader/shader_parse.c diff --git a/gfx/shader/shader_parse.h b/gfx/drivers_shader/shader_parse.h similarity index 100% rename from gfx/shader/shader_parse.h rename to gfx/drivers_shader/shader_parse.h diff --git a/gfx/video_driver.h b/gfx/video_driver.h index d03a1f3406..c7642443c5 100644 --- a/gfx/video_driver.h +++ b/gfx/video_driver.h @@ -26,7 +26,7 @@ #include "../input/input_driver.h" -#include "../gfx/shader/shader_parse.h" +#include "drivers_shader/shader_parse.h" #ifdef __cplusplus extern "C" { diff --git a/gfx/video_shader_driver.h b/gfx/video_shader_driver.h index e9bded1ec6..748e8742da 100644 --- a/gfx/video_shader_driver.h +++ b/gfx/video_shader_driver.h @@ -78,7 +78,7 @@ extern const shader_backend_t shader_null_backend; #define HAVE_SHADER_MANAGER #endif -#include "shader/shader_parse.h" +#include "drivers_shader/shader_parse.h" #define GL_SHADER_STOCK_BLEND (GFX_MAX_SHADERS - 1) diff --git a/griffin/griffin.c b/griffin/griffin.c index 8b31318ac2..626e4d81a9 100644 --- a/griffin/griffin.c +++ b/griffin/griffin.c @@ -135,21 +135,21 @@ VIDEO SHADERS #ifdef HAVE_SHADERS #include "../gfx/video_shader_driver.c" -#include "../gfx/shader/shader_parse.c" -#include "../gfx/shader/shader_null.c" +#include "../gfx/drivers_shader/shader_parse.c" +#include "../gfx/drivers_shader/shader_null.c" #ifdef HAVE_CG #ifdef HAVE_OPENGL -#include "../gfx/shader/shader_gl_cg.c" +#include "../gfx/drivers_shader/shader_gl_cg.c" #endif #endif #ifdef HAVE_HLSL -#include "../gfx/shader/shader_hlsl.c" +#include "../gfx/drivers_shader/shader_hlsl.c" #endif #ifdef HAVE_GLSL -#include "../gfx/shader/shader_glsl.c" +#include "../gfx/drivers_shader/shader_glsl.c" #endif #endif diff --git a/menu/menu.h b/menu/menu.h index 8f2815a5c7..a5b797a7fc 100644 --- a/menu/menu.h +++ b/menu/menu.h @@ -28,7 +28,7 @@ #include "../../core_info.h" #include "../../playlist.h" #include "menu_input.h" -#include "../../gfx/video_shader_driver.h" +#include "../gfx/video_shader_driver.h" #ifdef HAVE_RGUI #define MENU_TEXTURE_FULLSCREEN false From bbc6a5cee4dc604133934428f78b6f002e3a0f0b Mon Sep 17 00:00:00 2001 From: twinaphex Date: Mon, 12 Jan 2015 22:28:59 +0100 Subject: [PATCH 140/156] Move rsound.c to audio/drivers --- audio/{ => drivers}/rsound.c | 2 +- audio/{ => drivers}/rsound.h | 0 audio/librsound.c | 4 ++-- griffin/griffin.c | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) rename audio/{ => drivers}/rsound.c (99%) rename audio/{ => drivers}/rsound.h (100%) diff --git a/audio/rsound.c b/audio/drivers/rsound.c similarity index 99% rename from audio/rsound.c rename to audio/drivers/rsound.c index 9b49e9f67f..f3fcd4bb86 100644 --- a/audio/rsound.c +++ b/audio/drivers/rsound.c @@ -14,7 +14,7 @@ */ -#include "../driver.h" +#include "../audio_driver.h" #include #include "rsound.h" #include diff --git a/audio/rsound.h b/audio/drivers/rsound.h similarity index 100% rename from audio/rsound.h rename to audio/drivers/rsound.h diff --git a/audio/librsound.c b/audio/librsound.c index ba352b7af5..68830fb9a2 100644 --- a/audio/librsound.c +++ b/audio/librsound.c @@ -29,14 +29,14 @@ * If not, see . */ -#include "rsound.h" +#include "drivers/rsound.h" #if defined(__CELLOS_LV2__) #include #include #include -// network headers +/* Network headers */ #include #include #define NETWORK_COMPAT_HEADERS 1 diff --git a/griffin/griffin.c b/griffin/griffin.c index 626e4d81a9..510531eb43 100644 --- a/griffin/griffin.c +++ b/griffin/griffin.c @@ -443,7 +443,7 @@ RSOUND ============================================================ */ #ifdef HAVE_RSOUND #include "../audio/librsound.c" -#include "../audio/rsound.c" +#include "../audio/drivers/rsound.c" #endif /*============================================================ From 1c5df70eedce08d68eea6de7bd28b0f2bac4be37 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Mon, 12 Jan 2015 22:30:26 +0100 Subject: [PATCH 141/156] Build fixes for RetroArch Salamander --- Makefile.ps3.salamander | 2 +- Makefile.psp1.salamander | 2 +- Makefile.wii.salamander | 2 +- .../RetroArch-360-Salamander/RetroArch-Salamander.vcxproj | 8 ++++---- .../RetroArch-Salamander.vcproj | 6 +++--- 5 files changed, 10 insertions(+), 10 deletions(-) diff --git a/Makefile.ps3.salamander b/Makefile.ps3.salamander index 2d1430afd4..9f936e83e7 100644 --- a/Makefile.ps3.salamander +++ b/Makefile.ps3.salamander @@ -19,7 +19,7 @@ endif STRIP = $(CELL_SDK)/host-win32/ppu/bin/ppu-lv2-strip.exe PPU_CFLAGS += -I. -Ilibretro-sdk/include -D__CELLOS_LV2__ -DIS_SALAMANDER -DRARCH_CONSOLE -DHAVE_SYSUTILS -DHAVE_SYSMODULES -DHAVE_RARCH_EXEC -PPU_SRCS = frontend/frontend_salamander.c frontend/frontend_context.c frontend/drivers/platform_ps3.c frontend/drivers/platform_null.c libretro-sdk/file/file_path.c libretro-sdk/file/dir_list.c libretro-sdk/string/string_list.c libretro-sdk/compat/compat.c libretro-sdk/file/config_file.c +PPU_SRCS = frontend/frontend_salamander.c frontend/frontend_driver.c frontend/drivers/platform_ps3.c frontend/drivers/platform_null.c libretro-sdk/file/file_path.c libretro-sdk/file/dir_list.c libretro-sdk/string/string_list.c libretro-sdk/compat/compat.c libretro-sdk/file/config_file.c ifeq ($(HAVE_LOGGER), 1) PPU_CFLAGS += -DHAVE_LOGGER -Ilogger/netlogger diff --git a/Makefile.psp1.salamander b/Makefile.psp1.salamander index cbd5afc4a6..2eef884ca2 100644 --- a/Makefile.psp1.salamander +++ b/Makefile.psp1.salamander @@ -31,7 +31,7 @@ PSP_EBOOT_TITLE = RetroArch PSP_EBOOT_ICON = psp1/ICON0.PNG PSP_EBOOT_PIC1 = psp1/PIC1.PNG -OBJS = frontend/frontend_salamander.o frontend/frontend_context.o frontend/drivers/platform_psp.o frontend/drivers/platform_null.o libretro-sdk/file/file_path.o libretro-sdk/string/string_list.o libretro-sdk/file/dir_list.o libretro-sdk/compat/compat.o libretro-sdk/file/config_file.o psp1/kernel_functions.o +OBJS = frontend/frontend_salamander.o frontend/frontend_driver.o frontend/drivers/platform_psp.o frontend/drivers/platform_null.o libretro-sdk/file/file_path.o libretro-sdk/string/string_list.o libretro-sdk/file/dir_list.o libretro-sdk/compat/compat.o libretro-sdk/file/config_file.o psp1/kernel_functions.o PSPSDK=$(shell psp-config --pspsdk-path) include $(PSPSDK)/lib/build.mak diff --git a/Makefile.wii.salamander b/Makefile.wii.salamander index cd0b97e088..3a164175c6 100644 --- a/Makefile.wii.salamander +++ b/Makefile.wii.salamander @@ -39,7 +39,7 @@ LIBS := -lfat -lwiiuse -logc -lbte APP_BOOTER_DIR = wii/app_booter -OBJ = frontend/frontend_salamander.o frontend/frontend_context.o frontend/drivers/platform_gx.o frontend/drivers/platform_wii.o frontend/drivers/platform_null.o libretro-sdk/file/file_path.o libretro-sdk/string/string_list.o libretro-sdk/file/dir_list.o libretro-sdk/compat/compat.o libretro-sdk/file/config_file.o $(APP_BOOTER_DIR)/app_booter.binobj +OBJ = frontend/frontend_salamander.o frontend/frontend_driver.o frontend/drivers/platform_gx.o frontend/drivers/platform_wii.o frontend/drivers/platform_null.o libretro-sdk/file/file_path.o libretro-sdk/string/string_list.o libretro-sdk/file/dir_list.o libretro-sdk/compat/compat.o libretro-sdk/file/config_file.o $(APP_BOOTER_DIR)/app_booter.binobj ifeq ($(HAVE_LOGGER), 1) CFLAGS += -DHAVE_LOGGER diff --git a/msvc/RetroArch-360-Salamander/RetroArch-Salamander.vcxproj b/msvc/RetroArch-360-Salamander/RetroArch-Salamander.vcxproj index d742c49898..a5d4692c3d 100644 --- a/msvc/RetroArch-360-Salamander/RetroArch-Salamander.vcxproj +++ b/msvc/RetroArch-360-Salamander/RetroArch-Salamander.vcxproj @@ -295,9 +295,9 @@ CompileAsC - - - + + + CompileAsC CompileAsC @@ -310,4 +310,4 @@ - \ No newline at end of file + diff --git a/msvc/RetroArch-Xbox1-Salamander/RetroArch-Salamander.vcproj b/msvc/RetroArch-Xbox1-Salamander/RetroArch-Salamander.vcproj index 3074c399b0..a83285970e 100644 --- a/msvc/RetroArch-Xbox1-Salamander/RetroArch-Salamander.vcproj +++ b/msvc/RetroArch-Xbox1-Salamander/RetroArch-Salamander.vcproj @@ -273,7 +273,7 @@ Filter="cpp;c;cxx;def;odl;idl;hpj;bat;asm;asmx" UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}"> + RelativePath="..\..\frontend\frontend_driver.c"> + RelativePath="..\..\frontend\drivers\platform_null.c"> + RelativePath="..\..\frontend\drivers\platform_xdk.c"> Date: Mon, 12 Jan 2015 22:35:34 +0100 Subject: [PATCH 142/156] Silence one warning --- menu/menu_entries.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/menu/menu_entries.c b/menu/menu_entries.c index b44eaf28f6..a220a75871 100644 --- a/menu/menu_entries.c +++ b/menu/menu_entries.c @@ -354,9 +354,9 @@ int menu_entries_parse_list( unsigned default_type_plain, const char *exts, rarch_setting_t *setting) { - int device; size_t i, list_size; bool path_is_compressed, push_dir; + int device = 0; struct string_list *str_list = NULL; (void)device; From 327d15b7f2ee5a1628a11ddaf13d42da1249dd96 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Mon, 12 Jan 2015 22:37:53 +0100 Subject: [PATCH 143/156] (PS3) Build fix --- gfx/gl_common.h | 1 + 1 file changed, 1 insertion(+) diff --git a/gfx/gl_common.h b/gfx/gl_common.h index 6e4befde8a..85f392ee8e 100644 --- a/gfx/gl_common.h +++ b/gfx/gl_common.h @@ -22,6 +22,7 @@ #include #include #include "fonts/gl_font.h" +#include "image/image.h" #include "video_shader_driver.h" #ifdef HAVE_CONFIG_H From 6cdaa4e282ab7f00ce3b23b56ef56d300802aec0 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Mon, 12 Jan 2015 22:47:12 +0100 Subject: [PATCH 144/156] (MSVC) Build fixes --- audio/audio_driver.c | 4 ++-- audio/drivers/xaudio.c | 2 +- camera/camera_driver.c | 4 ++-- gfx/video_driver.c | 4 ++-- input/input_driver.c | 4 ++-- location/location_driver.c | 4 ++-- menu/menu_driver.c | 4 ++-- osk/osk_driver.c | 4 ++-- 8 files changed, 15 insertions(+), 15 deletions(-) diff --git a/audio/audio_driver.c b/audio/audio_driver.c index 86d498d3d2..55569ea56b 100644 --- a/audio/audio_driver.c +++ b/audio/audio_driver.c @@ -201,7 +201,7 @@ void find_audio_driver(void) { int i = find_driver_index("audio_driver", g_settings.audio.driver); if (i >= 0) - driver.audio = audio_driver_find_handle(i); + driver.audio = (const audio_driver_t*)audio_driver_find_handle(i); else { unsigned d; @@ -212,7 +212,7 @@ void find_audio_driver(void) RARCH_LOG_OUTPUT("\t%s\n", audio_driver_find_ident(d)); RARCH_WARN("Going to default to first audio driver...\n"); - driver.audio = audio_driver_find_handle(0); + driver.audio = (const audio_driver_t*)audio_driver_find_handle(0); if (!driver.audio) rarch_fail(1, "find_audio_driver()"); diff --git a/audio/drivers/xaudio.c b/audio/drivers/xaudio.c index 630e4e646d..c744f6aa50 100644 --- a/audio/drivers/xaudio.c +++ b/audio/drivers/xaudio.c @@ -36,7 +36,7 @@ static void *xa_init(const char *device, unsigned rate, unsigned latency) if (latency < 8) latency = 8; /* Do not allow shenanigans. */ - xa_t *xa = (xa_t*)calloc(1, sizeof(*xa)); + xa = (xa_t*)calloc(1, sizeof(*xa)); if (!xa) return NULL; diff --git a/camera/camera_driver.c b/camera/camera_driver.c index 9f88e5eb29..3d3eb03097 100644 --- a/camera/camera_driver.c +++ b/camera/camera_driver.c @@ -107,7 +107,7 @@ void find_camera_driver(void) { int i = find_driver_index("camera_driver", g_settings.camera.driver); if (i >= 0) - driver.camera = camera_driver_find_handle(i); + driver.camera = (const camera_driver_t*)camera_driver_find_handle(i); else { unsigned d; @@ -119,7 +119,7 @@ void find_camera_driver(void) RARCH_WARN("Going to default to first camera driver...\n"); - driver.camera = camera_driver_find_handle(0); + driver.camera = (const camera_driver_t*)camera_driver_find_handle(0); if (!driver.camera) rarch_fail(1, "find_camera_driver()"); diff --git a/gfx/video_driver.c b/gfx/video_driver.c index da9a4468e2..38f27b815d 100644 --- a/gfx/video_driver.c +++ b/gfx/video_driver.c @@ -149,7 +149,7 @@ void find_video_driver(void) i = find_driver_index("video_driver", g_settings.video.driver); if (i >= 0) - driver.video = video_driver_find_handle(i); + driver.video = (const video_driver_t*)video_driver_find_handle(i); else { unsigned d; @@ -160,7 +160,7 @@ void find_video_driver(void) RARCH_LOG_OUTPUT("\t%s\n", video_driver_find_ident(d)); RARCH_WARN("Going to default to first video driver...\n"); - driver.video = video_driver_find_handle(0); + driver.video = (const video_driver_t*)video_driver_find_handle(0); if (!driver.video) rarch_fail(1, "find_video_driver()"); diff --git a/input/input_driver.c b/input/input_driver.c index 0784929532..788a66dc99 100644 --- a/input/input_driver.c +++ b/input/input_driver.c @@ -136,7 +136,7 @@ void find_input_driver(void) { int i = find_driver_index("input_driver", g_settings.input.driver); if (i >= 0) - driver.input = input_driver_find_handle(i); + driver.input = (const input_driver_t*)input_driver_find_handle(i); else { unsigned d; @@ -147,7 +147,7 @@ void find_input_driver(void) RARCH_LOG_OUTPUT("\t%s\n", input_driver_find_ident(d)); RARCH_WARN("Going to default to first input driver...\n"); - driver.input = input_driver_find_handle(0); + driver.input = (const input_driver_t*)input_driver_find_handle(0); if (!driver.input) rarch_fail(1, "find_input_driver()"); diff --git a/location/location_driver.c b/location/location_driver.c index e764d3961b..b63fabc646 100644 --- a/location/location_driver.c +++ b/location/location_driver.c @@ -103,7 +103,7 @@ void find_location_driver(void) { int i = find_driver_index("location_driver", g_settings.location.driver); if (i >= 0) - driver.location = location_driver_find_handle(i); + driver.location = (const location_driver_t*)location_driver_find_handle(i); else { unsigned d; @@ -115,7 +115,7 @@ void find_location_driver(void) RARCH_WARN("Going to default to first location driver...\n"); - driver.location = location_driver_find_handle(0); + driver.location = (const location_driver_t*)location_driver_find_handle(0); if (!driver.location) rarch_fail(1, "find_location_driver()"); diff --git a/menu/menu_driver.c b/menu/menu_driver.c index b8dd2b1a76..0e243da3bc 100644 --- a/menu/menu_driver.c +++ b/menu/menu_driver.c @@ -116,7 +116,7 @@ void find_menu_driver(void) { int i = find_driver_index("menu_driver", g_settings.menu.driver); if (i >= 0) - driver.menu_ctx = menu_driver_find_handle(i); + driver.menu_ctx = (const menu_ctx_driver_t*)menu_driver_find_handle(i); else { unsigned d; @@ -127,7 +127,7 @@ void find_menu_driver(void) RARCH_LOG_OUTPUT("\t%s\n", menu_driver_find_ident(d)); RARCH_WARN("Going to default to first menu driver...\n"); - driver.menu_ctx = menu_driver_find_handle(0); + driver.menu_ctx = (const menu_ctx_driver_t*)menu_driver_find_handle(0); if (!driver.menu_ctx) rarch_fail(1, "find_menu_driver()"); diff --git a/osk/osk_driver.c b/osk/osk_driver.c index 7997d196cb..580b627f46 100644 --- a/osk/osk_driver.c +++ b/osk/osk_driver.c @@ -103,7 +103,7 @@ void find_osk_driver(void) { int i = find_driver_index("osk_driver", g_settings.osk.driver); if (i >= 0) - driver.osk = osk_driver_find_handle(i); + driver.osk = (const input_osk_driver_t*)osk_driver_find_handle(i); else { unsigned d; @@ -115,7 +115,7 @@ void find_osk_driver(void) RARCH_WARN("Going to default to first OSK driver...\n"); - driver.osk = osk_driver_find_handle(0); + driver.osk = (const input_osk_driver_t*)osk_driver_find_handle(0); if (!driver.osk) rarch_fail(1, "find_osk_driver()"); From 09b25e54c5742c7e1ba32f3eac33863681cad9b9 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Mon, 12 Jan 2015 23:19:21 +0100 Subject: [PATCH 145/156] Rename gl_font.c and d3d_font.c --- Makefile.common | 4 ++-- gfx/d3d/d3d.h | 2 +- gfx/drivers_context/bbqnx_ctx.c | 1 - gfx/{fonts/d3d_font.c => font_d3d_driver.c} | 4 ++-- gfx/{fonts/d3d_font.h => font_d3d_driver.h} | 6 +++--- gfx/{fonts/gl_font.c => font_gl_driver.c} | 4 ++-- gfx/{fonts/gl_font.h => font_gl_driver.h} | 7 +++---- gfx/fonts/d3d_w32_font.cpp | 2 +- gfx/fonts/fonts.c | 1 - gfx/fonts/xdk1_xfonts.c | 2 +- gfx/fonts/xdk360_fonts.cpp | 2 +- gfx/gl_common.h | 2 +- gfx/video_thread_wrapper.h | 2 +- griffin/griffin.c | 4 ++-- 14 files changed, 20 insertions(+), 23 deletions(-) rename gfx/{fonts/d3d_font.c => font_d3d_driver.c} (96%) rename gfx/{fonts/d3d_font.h => font_d3d_driver.h} (94%) rename gfx/{fonts/gl_font.c => font_gl_driver.c} (96%) rename gfx/{fonts/gl_font.h => font_gl_driver.h} (94%) diff --git a/Makefile.common b/Makefile.common index 4bea588dbb..5524ff5591 100644 --- a/Makefile.common +++ b/Makefile.common @@ -376,7 +376,7 @@ ifeq ($(HAVE_OPENGL), 1) gfx/gl_common.o \ gfx/video_context_driver.o \ gfx/drivers_context/gfx_null_ctx.o \ - gfx/fonts/gl_font.o \ + gfx/font_gl_driver.o \ gfx/fonts/gl_raster_font.o \ libretro-sdk/gfx/math/matrix_4x4.o \ gfx/video_state_tracker.o \ @@ -512,7 +512,7 @@ ifeq ($(HAVE_D3D9), 1) OBJ += gfx/d3d/d3d.o \ gfx/d3d/render_chain.o \ gfx/d3d/d3d_wrapper.o \ - gfx/fonts/d3d_font.o \ + gfx/font_d3d_driver.o \ gfx/fonts/d3d_w32_font.o \ gfx/drivers_context/d3d_ctx.o DEFINES += -DHAVE_WIN32_D3D9 diff --git a/gfx/d3d/d3d.h b/gfx/d3d/d3d.h index db86dd87a6..809a55a883 100644 --- a/gfx/d3d/d3d.h +++ b/gfx/d3d/d3d.h @@ -49,7 +49,7 @@ #include "../video_shader_driver.h" #endif -#include "../fonts/d3d_font.h" +#include "../font_d3d_driver.h" #include "../video_context_driver.h" #include "../gfx_common.h" diff --git a/gfx/drivers_context/bbqnx_ctx.c b/gfx/drivers_context/bbqnx_ctx.c index 373649128f..596da9a903 100644 --- a/gfx/drivers_context/bbqnx_ctx.c +++ b/gfx/drivers_context/bbqnx_ctx.c @@ -29,7 +29,6 @@ #include "../image/image.h" -#include "../fonts/gl_font.h" #include #ifdef HAVE_GLSL diff --git a/gfx/fonts/d3d_font.c b/gfx/font_d3d_driver.c similarity index 96% rename from gfx/fonts/d3d_font.c rename to gfx/font_d3d_driver.c index 1601191679..c971031c96 100644 --- a/gfx/fonts/d3d_font.c +++ b/gfx/font_d3d_driver.c @@ -14,8 +14,8 @@ * If not, see . */ -#include "d3d_font.h" -#include "../../general.h" +#include "font_d3d_driver.h" +#include "../general.h" static const d3d_font_renderer_t *d3d_font_backends[] = { #if defined(_XBOX1) diff --git a/gfx/fonts/d3d_font.h b/gfx/font_d3d_driver.h similarity index 94% rename from gfx/fonts/d3d_font.h rename to gfx/font_d3d_driver.h index b84e17a63c..3cc0074d47 100644 --- a/gfx/fonts/d3d_font.h +++ b/gfx/font_d3d_driver.h @@ -14,12 +14,12 @@ * If not, see . */ -#ifndef D3D_FONT_H__ -#define D3D_FONT_H__ +#ifndef __FONT_D3D_DRIVER_H__ +#define __FONT_D3D_DRIVER_H__ #include #include -#include "../../driver.h" +#include "../driver.h" #ifdef __cplusplus extern "C" { diff --git a/gfx/fonts/gl_font.c b/gfx/font_gl_driver.c similarity index 96% rename from gfx/fonts/gl_font.c rename to gfx/font_gl_driver.c index a534b92548..1d12ca4786 100644 --- a/gfx/fonts/gl_font.c +++ b/gfx/font_gl_driver.c @@ -14,8 +14,8 @@ * If not, see . */ -#include "gl_font.h" -#include "../../general.h" +#include "font_gl_driver.h" +#include "../general.h" static const gl_font_renderer_t *gl_font_backends[] = { #if defined(HAVE_LIBDBGFONT) diff --git a/gfx/fonts/gl_font.h b/gfx/font_gl_driver.h similarity index 94% rename from gfx/fonts/gl_font.h rename to gfx/font_gl_driver.h index 15f05d8902..c710dd2132 100644 --- a/gfx/fonts/gl_font.h +++ b/gfx/font_gl_driver.h @@ -14,10 +14,10 @@ * If not, see . */ -#ifndef GL_FONT_H__ -#define GL_FONT_H__ +#ifndef __FONT_GL_DRIVER_H__ +#define __FONT_GL_DRIVER_H__ -#include "../../driver.h" +#include "../driver.h" #include struct font_glyph; @@ -41,4 +41,3 @@ bool gl_font_init_first(const gl_font_renderer_t **font_driver, const char *font_path, float font_size); #endif - diff --git a/gfx/fonts/d3d_w32_font.cpp b/gfx/fonts/d3d_w32_font.cpp index 4771d631de..bb32272272 100644 --- a/gfx/fonts/d3d_w32_font.cpp +++ b/gfx/fonts/d3d_w32_font.cpp @@ -15,7 +15,7 @@ */ #include "../d3d/d3d.h" -#include "d3d_font.h" +#include "../font_d3d_driver.h" #include "../gfx_common.h" #include "../../general.h" diff --git a/gfx/fonts/fonts.c b/gfx/fonts/fonts.c index d804fabfdd..e4a433c1f8 100644 --- a/gfx/fonts/fonts.c +++ b/gfx/fonts/fonts.c @@ -64,4 +64,3 @@ bool font_renderer_create_default( *handle = NULL; return false; } - diff --git a/gfx/fonts/xdk1_xfonts.c b/gfx/fonts/xdk1_xfonts.c index 67d5f36c7b..e72479ef2e 100644 --- a/gfx/fonts/xdk1_xfonts.c +++ b/gfx/fonts/xdk1_xfonts.c @@ -15,7 +15,7 @@ */ #include -#include "d3d_font.h" +#include "../font_d3d_driver.h" #include "../gfx_common.h" #include "../../general.h" diff --git a/gfx/fonts/xdk360_fonts.cpp b/gfx/fonts/xdk360_fonts.cpp index 15e05f17a9..436f3054a3 100644 --- a/gfx/fonts/xdk360_fonts.cpp +++ b/gfx/fonts/xdk360_fonts.cpp @@ -15,7 +15,7 @@ */ #include -#include "d3d_font.h" +#include "../font_d3d_driver.h" #include "../d3d/d3d.h" #include "../gfx_common.h" #include "../../general.h" diff --git a/gfx/gl_common.h b/gfx/gl_common.h index 85f392ee8e..9ad877af39 100644 --- a/gfx/gl_common.h +++ b/gfx/gl_common.h @@ -21,7 +21,7 @@ #include "fonts/fonts.h" #include #include -#include "fonts/gl_font.h" +#include "font_gl_driver.h" #include "image/image.h" #include "video_shader_driver.h" diff --git a/gfx/video_thread_wrapper.h b/gfx/video_thread_wrapper.h index 6f53f2d406..7983505f6a 100644 --- a/gfx/video_thread_wrapper.h +++ b/gfx/video_thread_wrapper.h @@ -21,7 +21,7 @@ #include "../general.h" #include #include -#include "fonts/gl_font.h" +#include "font_gl_driver.h" enum thread_cmd { diff --git a/griffin/griffin.c b/griffin/griffin.c index 510531eb43..2239987616 100644 --- a/griffin/griffin.c +++ b/griffin/griffin.c @@ -249,11 +249,11 @@ FONTS #endif #ifdef HAVE_OPENGL -#include "../gfx/fonts/gl_font.c" +#include "../gfx/font_gl_driver.c" #endif #if defined(_XBOX) || defined(HAVE_WIN32_D3D9) -#include "../gfx/fonts/d3d_font.c" +#include "../gfx/font_d3d_driver.c" #endif #if defined(HAVE_WIN32_D3D9) From 8111567d3ec1ca068d36690aa327532cd14c696d Mon Sep 17 00:00:00 2001 From: twinaphex Date: Mon, 12 Jan 2015 23:34:10 +0100 Subject: [PATCH 146/156] Move some files around --- Makefile.common | 6 +++--- gfx/drivers/sdl2_gfx.c | 2 +- gfx/drivers/xvideo.c | 2 +- gfx/{fonts => drivers_font_renderer}/bitmap.bin | Bin gfx/{fonts => drivers_font_renderer}/bitmap.bmp | Bin gfx/{fonts => drivers_font_renderer}/bitmap.h | 0 gfx/{fonts => drivers_font_renderer}/bitmapfont.c | 2 +- gfx/{fonts => drivers_font_renderer}/coretext.c | 2 +- gfx/{fonts => drivers_font_renderer}/freetype.c | 2 +- gfx/{fonts/fonts.c => font_renderer_driver.c} | 6 +++--- gfx/{fonts/fonts.h => font_renderer_driver.h} | 0 gfx/gl_common.h | 2 +- griffin/griffin.c | 8 ++++---- menu/disp/lakka.h | 2 +- menu/disp/rgui.c | 2 +- 15 files changed, 18 insertions(+), 18 deletions(-) rename gfx/{fonts => drivers_font_renderer}/bitmap.bin (100%) rename gfx/{fonts => drivers_font_renderer}/bitmap.bmp (100%) rename gfx/{fonts => drivers_font_renderer}/bitmap.h (100%) rename gfx/{fonts => drivers_font_renderer}/bitmapfont.c (99%) rename gfx/{fonts => drivers_font_renderer}/coretext.c (99%) rename gfx/{fonts => drivers_font_renderer}/freetype.c (99%) rename gfx/{fonts/fonts.c => font_renderer_driver.c} (95%) rename gfx/{fonts/fonts.h => font_renderer_driver.h} (100%) diff --git a/Makefile.common b/Makefile.common index 5524ff5591..f59932ed00 100644 --- a/Makefile.common +++ b/Makefile.common @@ -113,7 +113,7 @@ OBJ += frontend/frontend.o \ libretro-sdk/queues/message_queue.o \ rewind.o \ gfx/gfx_common.o \ - gfx/fonts/bitmapfont.o \ + gfx/drivers_font_renderer/bitmapfont.o \ input/input_autodetect.o \ input/input_joypad_driver.o \ input/input_joypad.o \ @@ -138,7 +138,7 @@ OBJ += frontend/frontend.o \ libretro-sdk/gfx/scaler/scaler_int.o \ libretro-sdk/gfx/scaler/scaler_filter.o \ gfx/image/image_rpng.o \ - gfx/fonts/fonts.o \ + gfx/font_renderer_driver.o \ gfx/video_filter.o \ audio/audio_resampler_driver.o \ audio/dsp_filter.o \ @@ -307,7 +307,7 @@ ifeq ($(HAVE_MENU_COMMON), 1) endif ifeq ($(HAVE_FREETYPE), 1) - OBJ += gfx/fonts/freetype.o + OBJ += gfx/drivers_font_renderer/freetype.o LIBS += $(FREETYPE_LIBS) DEFINES += $(FREETYPE_CFLAGS) endif diff --git a/gfx/drivers/sdl2_gfx.c b/gfx/drivers/sdl2_gfx.c index da2cdeabcf..46a7e2fad2 100644 --- a/gfx/drivers/sdl2_gfx.c +++ b/gfx/drivers/sdl2_gfx.c @@ -24,7 +24,7 @@ #include #include "../gfx_common.h" #include "../video_context_driver.h" -#include "../fonts/fonts.h" +#include "../font_renderer_driver.h" #ifdef HAVE_X11 #include "../drivers_context/x11_common.h" diff --git a/gfx/drivers/xvideo.c b/gfx/drivers/xvideo.c index 60930a8e0c..3e6e8e7b9e 100644 --- a/gfx/drivers/xvideo.c +++ b/gfx/drivers/xvideo.c @@ -20,7 +20,7 @@ #include #include #include "../gfx_common.h" -#include "../fonts/fonts.h" +#include "../font_renderer_driver.h" #include "../drivers_context/x11_common.h" diff --git a/gfx/fonts/bitmap.bin b/gfx/drivers_font_renderer/bitmap.bin similarity index 100% rename from gfx/fonts/bitmap.bin rename to gfx/drivers_font_renderer/bitmap.bin diff --git a/gfx/fonts/bitmap.bmp b/gfx/drivers_font_renderer/bitmap.bmp similarity index 100% rename from gfx/fonts/bitmap.bmp rename to gfx/drivers_font_renderer/bitmap.bmp diff --git a/gfx/fonts/bitmap.h b/gfx/drivers_font_renderer/bitmap.h similarity index 100% rename from gfx/fonts/bitmap.h rename to gfx/drivers_font_renderer/bitmap.h diff --git a/gfx/fonts/bitmapfont.c b/gfx/drivers_font_renderer/bitmapfont.c similarity index 99% rename from gfx/fonts/bitmapfont.c rename to gfx/drivers_font_renderer/bitmapfont.c index b301518ecd..0ddec545b7 100644 --- a/gfx/fonts/bitmapfont.c +++ b/gfx/drivers_font_renderer/bitmapfont.c @@ -14,7 +14,7 @@ * If not, see . */ -#include "fonts.h" +#include "../font_renderer_driver.h" #include "bitmap.h" #include #include diff --git a/gfx/fonts/coretext.c b/gfx/drivers_font_renderer/coretext.c similarity index 99% rename from gfx/fonts/coretext.c rename to gfx/drivers_font_renderer/coretext.c index d7a671b120..1d166a19bb 100644 --- a/gfx/fonts/coretext.c +++ b/gfx/drivers_font_renderer/coretext.c @@ -13,7 +13,7 @@ * If not, see . */ -#include "fonts.h" +#include "../font_renderer_driver.h" #include "../../general.h" #include #include diff --git a/gfx/fonts/freetype.c b/gfx/drivers_font_renderer/freetype.c similarity index 99% rename from gfx/fonts/freetype.c rename to gfx/drivers_font_renderer/freetype.c index 7ed8cb8b6c..30e1a192bb 100644 --- a/gfx/fonts/freetype.c +++ b/gfx/drivers_font_renderer/freetype.c @@ -14,7 +14,7 @@ * If not, see . */ -#include "fonts.h" +#include "../font_renderer_driver.h" #include #include "../../general.h" #include diff --git a/gfx/fonts/fonts.c b/gfx/font_renderer_driver.c similarity index 95% rename from gfx/fonts/fonts.c rename to gfx/font_renderer_driver.c index e4a433c1f8..78bc700703 100644 --- a/gfx/fonts/fonts.c +++ b/gfx/font_renderer_driver.c @@ -14,11 +14,11 @@ * If not, see . */ -#include "fonts.h" -#include "../../general.h" +#include "font_renderer_driver.h" +#include "../general.h" #ifdef HAVE_CONFIG_H -#include "../../config.h" +#include "../config.h" #endif static const font_renderer_driver_t *font_backends[] = { diff --git a/gfx/fonts/fonts.h b/gfx/font_renderer_driver.h similarity index 100% rename from gfx/fonts/fonts.h rename to gfx/font_renderer_driver.h diff --git a/gfx/gl_common.h b/gfx/gl_common.h index 9ad877af39..4b439d24d5 100644 --- a/gfx/gl_common.h +++ b/gfx/gl_common.h @@ -18,7 +18,7 @@ #define __GL_COMMON_H #include "../general.h" -#include "fonts/fonts.h" +#include "font_renderer_driver.h" #include #include #include "font_gl_driver.h" diff --git a/griffin/griffin.c b/griffin/griffin.c index 2239987616..6caf9d7ba5 100644 --- a/griffin/griffin.c +++ b/griffin/griffin.c @@ -237,15 +237,15 @@ VIDEO DRIVER FONTS ============================================================ */ -#include "../gfx/fonts/fonts.c" -#include "../gfx/fonts/bitmapfont.c" +#include "../gfx/font_renderer_driver.c" +#include "../gfx/drivers_font_renderer/bitmapfont.c" #if defined(HAVE_FREETYPE) -#include "../gfx/fonts/freetype.c" +#include "../gfx/drivers_font_renderer/freetype.c" #endif #if defined(__APPLE__) -#include "../gfx/fonts/coretext.c" +#include "../gfx/drivers_font_renderer/coretext.c" #endif #ifdef HAVE_OPENGL diff --git a/menu/disp/lakka.h b/menu/disp/lakka.h index 43afec4ac9..5ba01180d6 100644 --- a/menu/disp/lakka.h +++ b/menu/disp/lakka.h @@ -20,7 +20,7 @@ #define _MENU_DISP_LAKKA_H #include "../../gfx/gl_common.h" -#include "../../gfx/fonts/fonts.h" +#include "../../gfx/font_renderer_driver.h" #define THEME "monochrome" // flatui or monochrome themes are available diff --git a/menu/disp/rgui.c b/menu/disp/rgui.c index 34fc8df343..64044c00df 100644 --- a/menu/disp/rgui.c +++ b/menu/disp/rgui.c @@ -26,7 +26,7 @@ #include #include -#include "../../gfx/fonts/bitmap.h" +#include "../../gfx/drivers_font_renderer/bitmap.h" #include "shared.h" From 7f6a9fe594777111a0b485bfdd67328d4d033294 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Mon, 12 Jan 2015 23:35:40 +0100 Subject: [PATCH 147/156] Build fixes --- gfx/drivers/exynos_gfx.c | 2 +- gfx/drivers/omap_gfx.c | 2 +- gfx/drivers/sdl_gfx.c | 2 +- gfx/drivers/vg.c | 2 +- gfx/fonts/ps_libdbgfont.c | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) diff --git a/gfx/drivers/exynos_gfx.c b/gfx/drivers/exynos_gfx.c index 934ecbb61a..15acc8b6e9 100644 --- a/gfx/drivers/exynos_gfx.c +++ b/gfx/drivers/exynos_gfx.c @@ -33,7 +33,7 @@ #include "../../general.h" #include "../../retroarch.h" #include "../gfx_common.h" -#include "../fonts/fonts.h" +#include "../font_renderer_driver.h" /* TODO: Honor these properties: vsync, menu rotation, menu alpha, aspect ratio change */ diff --git a/gfx/drivers/omap_gfx.c b/gfx/drivers/omap_gfx.c index b8000623b3..77789f7f0e 100644 --- a/gfx/drivers/omap_gfx.c +++ b/gfx/drivers/omap_gfx.c @@ -22,7 +22,7 @@ #include #include "../gfx_common.h" #include "../video_context_driver.h" -#include "../fonts/fonts.h" +#include "../font_renderer_driver.h" #include #include diff --git a/gfx/drivers/sdl_gfx.c b/gfx/drivers/sdl_gfx.c index 4d30f2da6e..6acb046d75 100644 --- a/gfx/drivers/sdl_gfx.c +++ b/gfx/drivers/sdl_gfx.c @@ -22,7 +22,7 @@ #include #include "../gfx_common.h" #include "../video_context_driver.h" -#include "../fonts/fonts.h" +#include "../font_renderer_driver.h" #ifdef HAVE_X11 #include "../drivers_context/x11_common.h" diff --git a/gfx/drivers/vg.c b/gfx/drivers/vg.c index 6ceb608b4b..0b204f86e3 100644 --- a/gfx/drivers/vg.c +++ b/gfx/drivers/vg.c @@ -26,7 +26,7 @@ #include "../../retroarch.h" #include "../../driver.h" #include "../../performance.h" -#include "../fonts/fonts.h" +#include "../font_renderer_driver.h" #include "../../content.h" typedef struct diff --git a/gfx/fonts/ps_libdbgfont.c b/gfx/fonts/ps_libdbgfont.c index 0db89fa7c3..517f1f7ab4 100644 --- a/gfx/fonts/ps_libdbgfont.c +++ b/gfx/fonts/ps_libdbgfont.c @@ -14,7 +14,7 @@ * If not, see . */ -#include "fonts.h" +#include "../font_renderer_driver.h" #include "../gfx_common.h" #include "../gl_common.h" From ba5a31e33bc8302e3b1e3dcab2433098652682fb Mon Sep 17 00:00:00 2001 From: twinaphex Date: Mon, 12 Jan 2015 23:38:21 +0100 Subject: [PATCH 148/156] Build fixes --- Makefile.common | 4 +- Makefile.emscripten | 3 +- Makefile.pandora | 3 +- gfx/drivers/gx_gfx.c | 2 +- gfx/fonts/d3d_w32_font.cpp | 92 ------- gfx/fonts/gl_raster_font.c | 298 ---------------------- gfx/fonts/ps_libdbgfont.c | 104 -------- gfx/fonts/xdk1_xfonts.c | 77 ------ gfx/fonts/xdk360_fonts.cpp | 488 ------------------------------------- griffin/griffin.c | 10 +- menu/disp/rmenu.c | 2 +- 11 files changed, 13 insertions(+), 1070 deletions(-) delete mode 100644 gfx/fonts/d3d_w32_font.cpp delete mode 100644 gfx/fonts/gl_raster_font.c delete mode 100644 gfx/fonts/ps_libdbgfont.c delete mode 100644 gfx/fonts/xdk1_xfonts.c delete mode 100644 gfx/fonts/xdk360_fonts.cpp diff --git a/Makefile.common b/Makefile.common index f59932ed00..ba663bf277 100644 --- a/Makefile.common +++ b/Makefile.common @@ -377,7 +377,7 @@ ifeq ($(HAVE_OPENGL), 1) gfx/video_context_driver.o \ gfx/drivers_context/gfx_null_ctx.o \ gfx/font_gl_driver.o \ - gfx/fonts/gl_raster_font.o \ + gfx/drivers_font/gl_raster_font.o \ libretro-sdk/gfx/math/matrix_4x4.o \ gfx/video_state_tracker.o \ libretro-sdk/glsym/rglgen.o @@ -513,7 +513,7 @@ ifeq ($(HAVE_D3D9), 1) gfx/d3d/render_chain.o \ gfx/d3d/d3d_wrapper.o \ gfx/font_d3d_driver.o \ - gfx/fonts/d3d_w32_font.o \ + gfx/drivers_font/d3d_w32_font.o \ gfx/drivers_context/d3d_ctx.o DEFINES += -DHAVE_WIN32_D3D9 LIBS += -ld3d9 -ld3dx9 -ldxguid diff --git a/Makefile.emscripten b/Makefile.emscripten index b489cf725e..5b42a7e494 100644 --- a/Makefile.emscripten +++ b/Makefile.emscripten @@ -78,7 +78,8 @@ clean: rm -f gfx/d3d/*.o rm -f gfx/drivers_context/*.o rm -f gfx/math/*.o - rm -f gfx/fonts/*.o + rm -f gfx/drivers_font/*.o + rm -f gfx/drivers_font_renderer/*.o rm -f gfx/py_state/*.o rm -f gfx/rpng/*.o rm -f gfx/glsym/*.o diff --git a/Makefile.pandora b/Makefile.pandora index 9160791bde..1e3194ba18 100644 --- a/Makefile.pandora +++ b/Makefile.pandora @@ -40,7 +40,8 @@ clean: rm -f audio/*.o rm -f conf/*.o rm -f gfx/*.o - rm -f gfx/fonts/*.o + rm -f gfx/drivers_font/*.o + rm -f gfx/drivers_font_renderer/*.o rm -f gfx/drivers_context/*.o rm -f gfx/py_state/*.o rm -f compat/*.o diff --git a/gfx/drivers/gx_gfx.c b/gfx/drivers/gx_gfx.c index 4be12db350..0531fd5343 100644 --- a/gfx/drivers/gx_gfx.c +++ b/gfx/drivers/gx_gfx.c @@ -17,7 +17,7 @@ #include "../../driver.h" #include "../../general.h" -#include "../fonts/bitmap.h" +#include "../drivers_font_renderer/bitmap.h" #include "../../menu/menu.h" #include "../gfx_common.h" diff --git a/gfx/fonts/d3d_w32_font.cpp b/gfx/fonts/d3d_w32_font.cpp deleted file mode 100644 index bb32272272..0000000000 --- a/gfx/fonts/d3d_w32_font.cpp +++ /dev/null @@ -1,92 +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 . - */ - -#include "../d3d/d3d.h" -#include "../font_d3d_driver.h" -#include "../gfx_common.h" -#include "../../general.h" - -static LPD3DXFONT d3d_font; - -static bool d3dfonts_w32_init_font(void *data, - const char *font_path, unsigned font_size) -{ - uint32_t r, g, b; - d3d_video_t *d3d = (d3d_video_t*)data; - D3DXFONT_DESC desc = { - static_cast(font_size), 0, 400, 0, - false, DEFAULT_CHARSET, - OUT_TT_PRECIS, - CLIP_DEFAULT_PRECIS, - DEFAULT_PITCH, - "Verdana" // Hardcode ftl :( - }; - - (void)font_path; - - r = static_cast(g_settings.video.msg_color_r * 255) & 0xff; - g = static_cast(g_settings.video.msg_color_g * 255) & 0xff; - b = static_cast(g_settings.video.msg_color_b * 255) & 0xff; - - d3d->font_color = D3DCOLOR_XRGB(r, g, b); - - return SUCCEEDED(D3DXCreateFontIndirect(d3d->dev, &desc, &d3d_font)); -} - -static void d3dfonts_w32_deinit_font(void *data) -{ - (void)data; - - if (d3d_font) - d3d_font->Release(); - d3d_font = NULL; -} - -static void d3dfonts_w32_render_msg(void *data, const char *msg, - const struct font_params *params) -{ - d3d_video_t *d3d = (d3d_video_t*)data; - - if (!d3d) - return; - if (!msg) - return; - if (!(SUCCEEDED(d3d->dev->BeginScene()))) - return; - - d3d_font->DrawTextA(NULL, - msg, - -1, - &d3d->font_rect_shifted, - DT_LEFT, - ((d3d->font_color >> 2) & 0x3f3f3f) | 0xff000000); - - d3d_font->DrawTextA(NULL, - msg, - -1, - &d3d->font_rect, - DT_LEFT, - d3d->font_color | 0xff000000); - - d3d->dev->EndScene(); -} - -d3d_font_renderer_t d3d_win32_font = { - d3dfonts_w32_init_font, - d3dfonts_w32_deinit_font, - d3dfonts_w32_render_msg, - "d3d-fonts-w32", -}; diff --git a/gfx/fonts/gl_raster_font.c b/gfx/fonts/gl_raster_font.c deleted file mode 100644 index e3f003cf2d..0000000000 --- a/gfx/fonts/gl_raster_font.c +++ /dev/null @@ -1,298 +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 . - */ - -#include "../gfx_common.h" -#include "../gl_common.h" -#include "../video_shader_driver.h" - -#define emit(c, vx, vy) do { \ - font_vertex[ 2 * (6 * i + c) + 0] = (x + (delta_x + off_x + vx * width) * scale) * inv_win_width; \ - font_vertex[ 2 * (6 * i + c) + 1] = (y + (delta_y - off_y - vy * height) * scale) * inv_win_height; \ - font_tex_coords[ 2 * (6 * i + c) + 0] = (tex_x + vx * width) * inv_tex_size_x; \ - font_tex_coords[ 2 * (6 * i + c) + 1] = (tex_y + vy * height) * inv_tex_size_y; \ - font_color[ 4 * (6 * i + c) + 0] = color[0]; \ - font_color[ 4 * (6 * i + c) + 1] = color[1]; \ - font_color[ 4 * (6 * i + c) + 2] = color[2]; \ - font_color[ 4 * (6 * i + c) + 3] = color[3]; \ -} while(0) - -#define MAX_MSG_LEN_CHUNK 64 - -typedef struct -{ - gl_t *gl; - GLuint tex; - unsigned tex_width, tex_height; - - const font_renderer_driver_t *font_driver; - void *font_data; -} gl_raster_t; - -static void *gl_raster_font_init_font(void *gl_data, - const char *font_path, float font_size) -{ - unsigned width, height; - uint8_t *tmp_buffer; - const struct font_atlas *atlas = NULL; - gl_raster_t *font = (gl_raster_t*)calloc(1, sizeof(*font)); - - if (!font) - return NULL; - - font->gl = (gl_t*)gl_data; - - if (!font_renderer_create_default(&font->font_driver, - &font->font_data, font_path, font_size)) - { - RARCH_WARN("Couldn't init font renderer.\n"); - free(font); - return NULL; - } - - glGenTextures(1, &font->tex); - glBindTexture(GL_TEXTURE_2D, font->tex); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); - - atlas = font->font_driver->get_atlas(font->font_data); - - width = next_pow2(atlas->width); - height = next_pow2(atlas->height); - - /* Ideally, we'd use single component textures, but the - * difference in ways to do that between core GL and GLES/legacy GL - * is too great to bother going down that route. */ - glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, width, height, - 0, GL_RGBA, GL_UNSIGNED_BYTE, NULL); - - tmp_buffer = (uint8_t*)malloc(atlas->width * atlas->height * 4); - - if (tmp_buffer) - { - unsigned i; - uint8_t *dst = tmp_buffer; - const uint8_t *src = atlas->buffer; - - for (i = 0; i < atlas->width * atlas->height; i++) - { - *dst++ = 0xff; - *dst++ = 0xff; - *dst++ = 0xff; - *dst++ = *src++; - } - - glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, atlas->width, - atlas->height, GL_RGBA, GL_UNSIGNED_BYTE, tmp_buffer); - free(tmp_buffer); - } - - font->tex_width = width; - font->tex_height = height; - - glBindTexture(GL_TEXTURE_2D, font->gl->texture[font->gl->tex_index]); - return font; -} - -static void gl_raster_font_free_font(void *data) -{ - gl_raster_t *font = (gl_raster_t*)data; - if (!font) - return; - - if (font->font_driver && font->font_data) - font->font_driver->free(font->font_data); - - glDeleteTextures(1, &font->tex); - free(font); -} - - -static void render_message(gl_raster_t *font, const char *msg, GLfloat scale, - const GLfloat color[4], GLfloat pos_x, GLfloat pos_y) -{ - int x, y, delta_x, delta_y; - float inv_tex_size_x, inv_tex_size_y, inv_win_width, inv_win_height; - unsigned i, msg_len_full, msg_len; - GLfloat font_tex_coords[2 * 6 * MAX_MSG_LEN_CHUNK]; - GLfloat font_vertex[2 * 6 * MAX_MSG_LEN_CHUNK]; - GLfloat font_color[4 * 6 * MAX_MSG_LEN_CHUNK]; - gl_t *gl = font->gl; - - glBindTexture(GL_TEXTURE_2D, font->tex); - - msg_len_full = strlen(msg); - msg_len = min(msg_len_full, MAX_MSG_LEN_CHUNK); - - x = roundf(pos_x * gl->vp.width); - y = roundf(pos_y * gl->vp.height); - delta_x = 0; - delta_y = 0; - - inv_tex_size_x = 1.0f / font->tex_width; - inv_tex_size_y = 1.0f / font->tex_height; - inv_win_width = 1.0f / font->gl->vp.width; - inv_win_height = 1.0f / font->gl->vp.height; - - while (msg_len_full) - { - /* Rebind shaders so attrib cache gets reset. */ - if (gl->shader && gl->shader->use) - gl->shader->use(gl, GL_SHADER_STOCK_BLEND); - - for (i = 0; i < msg_len; i++) - { - int off_x, off_y, tex_x, tex_y, width, height; - const struct font_glyph *glyph = - font->font_driver->get_glyph(font->font_data, (uint8_t)msg[i]); - if (!glyph) - glyph = font->font_driver->get_glyph(font->font_data, '?'); /* Do something smarter here ... */ - if (!glyph) - continue; - - off_x = glyph->draw_offset_x; - off_y = glyph->draw_offset_y; - tex_x = glyph->atlas_offset_x; - tex_y = glyph->atlas_offset_y; - width = glyph->width; - height = glyph->height; - - emit(0, 0, 1); /* Bottom-left */ - emit(1, 1, 1); /* Bottom-right */ - emit(2, 0, 0); /* Top-left */ - - emit(3, 1, 0); /* Top-right */ - emit(4, 0, 0); /* Top-left */ - emit(5, 1, 1); /* Bottom-right */ -#undef emit - - delta_x += glyph->advance_x; - delta_y -= glyph->advance_y; - } - - gl->coords.tex_coord = font_tex_coords; - gl->coords.vertex = font_vertex; - gl->coords.color = font_color; - gl->coords.vertices = 6 * msg_len; - gl->shader->set_coords(&gl->coords); - gl->shader->set_mvp(gl, &gl->mvp_no_rot); - glDrawArrays(GL_TRIANGLES, 0, 6 * msg_len); - - msg_len_full -= msg_len; - msg += msg_len; - msg_len = min(msg_len_full, MAX_MSG_LEN_CHUNK); - } - - /* Post - Go back to old rendering path. */ - gl->coords.vertex = gl->vertex_ptr; - gl->coords.tex_coord = gl->tex_info.coord; - gl->coords.color = gl->white_color_ptr; - gl->coords.vertices = 4; - glBindTexture(GL_TEXTURE_2D, gl->texture[gl->tex_index]); -} - -static void gl_raster_font_render_msg(void *data, const char *msg, - const struct font_params *params) -{ - GLfloat x, y, scale, drop_mod; - GLfloat color[4], color_dark[4]; - int drop_x, drop_y; - bool full_screen; - gl_t *gl = NULL; - gl_raster_t *font = (gl_raster_t*)data; - - if (!font) - return; - - gl = font->gl; - - if (params) - { - x = params->x; - y = params->y; - scale = params->scale; - full_screen = params->full_screen; - drop_x = params->drop_x; - drop_y = params->drop_y; - drop_mod = params->drop_mod; - - color[0] = FONT_COLOR_GET_RED(params->color) / 255.0f; - color[1] = FONT_COLOR_GET_GREEN(params->color) / 255.0f; - color[2] = FONT_COLOR_GET_BLUE(params->color) / 255.0f; - color[3] = FONT_COLOR_GET_ALPHA(params->color) / 255.0f; - - /* If alpha is 0.0f, turn it into default 1.0f */ - if (color[3] <= 0.0f) - color[3] = 1.0f; - } - else - { - x = g_settings.video.msg_pos_x; - y = g_settings.video.msg_pos_y; - scale = 1.0f; - full_screen = false; - - color[0] = g_settings.video.msg_color_r; - color[1] = g_settings.video.msg_color_g; - color[2] = g_settings.video.msg_color_b; - color[3] = 1.0f; - - drop_x = -2; - drop_y = -2; - drop_mod = 0.3f; - } - - gl_set_viewport(gl, gl->win_width, gl->win_height, - full_screen, false); - glEnable(GL_BLEND); - glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); - glBlendEquation(GL_FUNC_ADD); - - if (drop_x || drop_y) - { - color_dark[0] = color[0] * drop_mod; - color_dark[1] = color[1] * drop_mod; - color_dark[2] = color[2] * drop_mod; - color_dark[3] = color[3]; - - render_message(font, msg, scale, color_dark, - x + scale * drop_x / gl->vp.width, y + - scale * drop_y / gl->vp.height); - } - render_message(font, msg, scale, color, x, y); - - glDisable(GL_BLEND); - gl_set_viewport(gl, gl->win_width, gl->win_height, false, true); -} - -static const struct font_glyph *gl_raster_font_get_glyph( - void *data, uint32_t code) -{ - gl_raster_t *font = (gl_raster_t*)data; - - if (!font) - return NULL; - return font->font_driver->get_glyph((void*)font->font_driver, code); -} - -gl_font_renderer_t gl_raster_font = { - gl_raster_font_init_font, - gl_raster_font_free_font, - gl_raster_font_render_msg, - "GL raster", - gl_raster_font_get_glyph, -}; diff --git a/gfx/fonts/ps_libdbgfont.c b/gfx/fonts/ps_libdbgfont.c deleted file mode 100644 index 517f1f7ab4..0000000000 --- a/gfx/fonts/ps_libdbgfont.c +++ /dev/null @@ -1,104 +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 . - */ - -#include "../font_renderer_driver.h" -#include "../gfx_common.h" -#include "../gl_common.h" - -#if defined(SN_TARGET_PSP2) -#include -#define DbgFontPrint(x, y, scale, color, msg) sceDbgFontPrint(x, y, color, msg) -#define DbgFontConfig SceDbgFontConfig -#define DbgFontInit sceDbgFontInit -#define DbgFontExit sceDbgFontExit -#elif defined(__CELLOS_LV2__) -#include -#define SCE_DBGFONT_BUFSIZE_LARGE 2048 -#define DbgFontPrint(x, y, scale, color, msg) cellDbgFontPrintf(x, y, scale, color, msg) -#define DbgFontConfig CellDbgFontConfig -#define DbgFontInit cellDbgFontInit -#define DbgFontExit cellDbgFontExit -#endif - -static void *libdbg_font_init_font(void *gl_data, const char *font_path, float font_size) -{ - gl_t *gl = (gl_t*)gl_data; - - (void)font_path; - (void)font_size; - - DbgFontConfig cfg; -#if defined(SN_TARGET_PSP2) - cfg.fontSize = SCE_DBGFONT_FONTSIZE_LARGE; -#elif defined(__CELLOS_LV2__) - cfg.bufSize = SCE_DBGFONT_BUFSIZE_LARGE; - cfg.screenWidth = gl->win_width; - cfg.screenHeight = gl->win_height; -#endif - - DbgFontInit(&cfg); - - /* Doesn't need any state. */ - return (void*)-1; -} - -static void libdbg_font_deinit_font(void *data) -{ - (void)data; - DbgFontExit(); -} - -static void libdbg_font_render_msg(void *data, const char *msg, - const struct font_params *params) -{ - float x, y, scale; - unsigned color; - - (void)data; - - if (params) - { - x = params->x; - y = params->y; - scale = params->scale; - color = params->color; - } - else - { - x = g_settings.video.msg_pos_x; - y = 0.90f; - scale = 1.04f; - color = SILVER; - } - - DbgFontPrint(x, y, scale, color, msg); - - if (!params) - DbgFontPrint(x, y, scale - 0.01f, WHITE, msg); - -#ifdef SN_TARGET_PSP2 - /* FIXME - if we ever get around to this port, - * move this out to some better place */ - sceDbgFontFlush(); -#endif -} - -gl_font_renderer_t libdbg_font = { - libdbg_font_init_font, - libdbg_font_deinit_font, - libdbg_font_render_msg, - "GL raster", -}; diff --git a/gfx/fonts/xdk1_xfonts.c b/gfx/fonts/xdk1_xfonts.c deleted file mode 100644 index e72479ef2e..0000000000 --- a/gfx/fonts/xdk1_xfonts.c +++ /dev/null @@ -1,77 +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 . - */ - -#include -#include "../font_d3d_driver.h" -#include "../gfx_common.h" -#include "../../general.h" - -static XFONT *debug_font; -static D3DSurface *pFrontBuffer; - -static bool xfonts_init_font(void *data, - const char *font_path, unsigned font_size) -{ - (void)font_path; - (void)font_size; - (void)data; - - XFONT_OpenDefaultFont(&debug_font); - debug_font->SetBkMode(XFONT_TRANSPARENT); - debug_font->SetBkColor(D3DCOLOR_ARGB(100,0,0,0)); - debug_font->SetTextHeight(14); - debug_font->SetTextAntialiasLevel(debug_font->GetTextAntialiasLevel()); - - return true; -} - -static void xfonts_deinit_font(void *data) -{ - (void)data; -} - -static void xfonts_render_msg(void *data, const char *msg, - const struct font_params *params) -{ - d3d_video_t *d3d = (d3d_video_t*)data; - wchar_t str[PATH_MAX_LENGTH]; - float x, y; - - if (params) - { - x = params->x; - y = params->y; - } - else - { - x = g_settings.video.msg_pos_x; - y = g_settings.video.msg_pos_y; - } - - d3d->dev->GetBackBuffer(-1, D3DBACKBUFFER_TYPE_MONO, &pFrontBuffer); - - mbstowcs(str, msg, sizeof(str) / sizeof(wchar_t)); - debug_font->TextOut(pFrontBuffer, str, (unsigned)-1, x, y); - - pFrontBuffer->Release(); -} - -d3d_font_renderer_t d3d_xdk1_font = { - xfonts_init_font, - xfonts_deinit_font, - xfonts_render_msg, - "XDK1 Xfonts", -}; diff --git a/gfx/fonts/xdk360_fonts.cpp b/gfx/fonts/xdk360_fonts.cpp deleted file mode 100644 index 436f3054a3..0000000000 --- a/gfx/fonts/xdk360_fonts.cpp +++ /dev/null @@ -1,488 +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 . - */ - -#include -#include "../font_d3d_driver.h" -#include "../d3d/d3d.h" -#include "../gfx_common.h" -#include "../../general.h" -#include "../../xdk/xdk_resources.h" - -#define FONT_SCALE(d3d) ((d3d->resolution_hd_enable) ? 2 : 1) - -typedef struct GLYPH_ATTR -{ - unsigned short tu1, tv1, tu2, tv2; /* Texture coordinates for the image. */ - short wOffset; /* Pixel offset for glyph start. */ - short wWidth; /* Pixel width of the glyph. */ - short wAdvance; /* Pixels to advance after the glyph. */ - unsigned short wMask; -} GLYPH_ATTR; - -typedef struct -{ - unsigned long m_dwSavedState; - unsigned long m_cMaxGlyph; /* Number of entries in the translator table. */ - unsigned long m_dwNumGlyphs; /* Number of valid glyphs. */ - float m_fFontHeight; /* Height of the font strike in pixels. */ - float m_fFontTopPadding; /* Padding above the strike zone. */ - float m_fFontBottomPadding; /* Padding below the strike zone. */ - float m_fFontYAdvance; /* Number of pixels to move the cursor for a line feed. */ - wchar_t * m_TranslatorTable; /* ASCII to glyph lookup table. */ - D3DTexture* m_pFontTexture; - const GLYPH_ATTR* m_Glyphs; /* Array of glyphs. */ -} xdk360_video_font_t; - -static xdk360_video_font_t m_Font; -static PackedResource m_xprResource; - -#define CALCFONTFILEHEADERSIZE(x) ( sizeof(unsigned long) + (sizeof(float)* 4) + sizeof(unsigned short) + (sizeof(wchar_t)*(x)) ) -#define FONTFILEVERSION 5 - -typedef struct { - unsigned long m_dwFileVersion; /* Version of the font file (Must match FONTFILEVERSION). */ - float m_fFontHeight; /* Height of the font strike in pixels. */ - float m_fFontTopPadding; /* Padding above the strike zone. */ - float m_fFontBottomPadding; /* Padding below the strike zone. */ - float m_fFontYAdvance; /* Number of pixels to move the cursor for a line feed. */ - unsigned short m_cMaxGlyph; /* Number of font characters (Should be an odd number to maintain DWORD Alignment). */ - wchar_t m_TranslatorTable[1]; /* ASCII to Glyph lookup table, NOTE: It's m_cMaxGlyph+1 in size. */ -} FontFileHeaderImage_t; - -typedef struct { - unsigned long m_dwNumGlyphs; /* Size of font strike array (First entry is the unknown glyph). */ - GLYPH_ATTR m_Glyphs[1]; /* Array of font strike uv's etc... NOTE: It's m_dwNumGlyphs in size. */ -} FontFileStrikesImage_t; - -static const char g_strFontShader[] = -"struct VS_IN\n" -"{\n" -"float2 Pos : POSITION;\n" -"float2 Tex : TEXCOORD0;\n" -"};\n" -"struct VS_OUT\n" -"{\n" -"float4 Position : POSITION;\n" -"float2 TexCoord0 : TEXCOORD0;\n" -"};\n" -"uniform float4 Color : register(c1);\n" -"uniform float2 TexScale : register(c2);\n" -"sampler FontTexture : register(s0);\n" -"VS_OUT main_vertex( VS_IN In )\n" -"{\n" -"VS_OUT Out;\n" -"Out.Position.x = (In.Pos.x-0.5);\n" -"Out.Position.y = (In.Pos.y-0.5);\n" -"Out.Position.z = ( 0.0 );\n" -"Out.Position.w = ( 1.0 );\n" -"Out.TexCoord0.x = In.Tex.x * TexScale.x;\n" -"Out.TexCoord0.y = In.Tex.y * TexScale.y;\n" -"return Out;\n" -"}\n" -"float4 main_fragment( VS_OUT In ) : COLOR0\n" -"{\n" -"float4 FontTexel = tex2D( FontTexture, In.TexCoord0 );\n" -"return FontTexel;\n" -"}\n"; - -typedef struct { - D3DVertexDeclaration* m_pFontVertexDecl; - D3DVertexShader* m_pFontVertexShader; - D3DPixelShader* m_pFontPixelShader; -} Font_Locals_t; - -static Font_Locals_t s_FontLocals; - -static HRESULT xdk360_video_font_create_shaders( - void *data, xdk360_video_font_t * font) -{ - HRESULT hr; - d3d_video_t *d3d = (d3d_video_t*)data; - LPDIRECT3DDEVICE d3dr = d3d->dev; - - if (s_FontLocals.m_pFontVertexDecl) - { - s_FontLocals.m_pFontVertexDecl->AddRef(); - s_FontLocals.m_pFontVertexShader->AddRef(); - s_FontLocals.m_pFontPixelShader->AddRef(); - return 0; - } - - do - { - static const D3DVERTEXELEMENT9 decl[] = - { - { 0, 0, D3DDECLTYPE_FLOAT2, D3DDECLMETHOD_DEFAULT, D3DDECLUSAGE_POSITION, 0 }, - { 0, 8, D3DDECLTYPE_USHORT2, D3DDECLMETHOD_DEFAULT, D3DDECLUSAGE_TEXCOORD, 0 }, - { 0, 12, D3DDECLTYPE_D3DCOLOR, D3DDECLMETHOD_DEFAULT, D3DDECLUSAGE_TEXCOORD, 1 }, - D3DDECL_END() - }; - - - hr = d3dr->CreateVertexDeclaration( decl, &s_FontLocals.m_pFontVertexDecl ); - - if (hr >= 0) - { - ID3DXBuffer* pShaderCode; - - hr = D3DXCompileShader( g_strFontShader, sizeof(g_strFontShader)-1 , - NULL, NULL, "main_vertex", "vs.2.0", 0,&pShaderCode, NULL, NULL ); - - if (hr >= 0) - { - hr = d3dr->CreateVertexShader( ( unsigned long * )pShaderCode->GetBufferPointer(), - &s_FontLocals.m_pFontVertexShader ); - pShaderCode->Release(); - - if (hr >= 0) - { - hr = D3DXCompileShader( g_strFontShader, sizeof(g_strFontShader)-1 , - NULL, NULL, "main_fragment", "ps.2.0", 0,&pShaderCode, NULL, NULL ); - - if (hr >= 0) - { - hr = d3dr->CreatePixelShader((DWORD*)pShaderCode->GetBufferPointer(), - &s_FontLocals.m_pFontPixelShader ); - pShaderCode->Release(); - - if (hr >= 0) - { - hr = 0; - break; - } - } - s_FontLocals.m_pFontVertexShader->Release(); - } - - s_FontLocals.m_pFontVertexShader = NULL; - } - - s_FontLocals.m_pFontVertexDecl->Release(); - } - s_FontLocals.m_pFontVertexDecl = NULL; - }while(0); - - return hr; -} - -static bool xdk360_init_font(void *data, - const char *font_path, unsigned font_size) -{ - unsigned long dwFileVersion; - const void *pFontData = NULL; - D3DTexture *pFontTexture = NULL; - const unsigned char * pData = NULL; - xdk360_video_font_t *font = &m_Font; - d3d_video_t *d3d = (d3d_video_t*)data; - - (void)font_size; - - font->m_pFontTexture = NULL; - font->m_dwNumGlyphs = 0L; - font->m_Glyphs = NULL; - font->m_cMaxGlyph = 0; - font->m_TranslatorTable = NULL; - - /* Create the font. */ - if (FAILED( m_xprResource.Create(font_path))) - goto error; - - pFontTexture = m_xprResource.GetTexture( "FontTexture" ); - pFontData = m_xprResource.GetData( "FontData"); - - /* Save a copy of the texture. */ - font->m_pFontTexture = pFontTexture; - - /* Check version of file (to make sure it matches up with the FontMaker tool). */ - pData = (const unsigned char*)pFontData; - dwFileVersion = ((const FontFileHeaderImage_t *)pData)->m_dwFileVersion; - - if (dwFileVersion != FONTFILEVERSION) - { - RARCH_ERR("Incorrect version number on font file.\n"); - goto error; - } - - font->m_fFontHeight = ((const FontFileHeaderImage_t *)pData)->m_fFontHeight; - font->m_fFontTopPadding = ((const FontFileHeaderImage_t *)pData)->m_fFontTopPadding; - font->m_fFontBottomPadding = ((const FontFileHeaderImage_t *)pData)->m_fFontBottomPadding; - font->m_fFontYAdvance = ((const FontFileHeaderImage_t *)pData)->m_fFontYAdvance; - - /* Point to the translator string which immediately follows the 4 floats. */ - font->m_cMaxGlyph = ((const FontFileHeaderImage_t *)pData)->m_cMaxGlyph; - font->m_TranslatorTable = const_cast((const FontFileHeaderImage_t *)pData)->m_TranslatorTable; - - pData += CALCFONTFILEHEADERSIZE( font->m_cMaxGlyph + 1 ); - - /* Read the glyph attributes from the file. */ - font->m_dwNumGlyphs = ((const FontFileStrikesImage_t *)pData)->m_dwNumGlyphs; - font->m_Glyphs = ((const FontFileStrikesImage_t *)pData)->m_Glyphs; - - /* Create the vertex and pixel shaders for rendering the font */ - if (FAILED(xdk360_video_font_create_shaders(d3d, font))) - { - RARCH_ERR( "Could not create font shaders.\n" ); - goto error; - } - - RARCH_LOG("Successfully initialized D3D9 HLSL fonts.\n"); - return true; -error: - RARCH_ERR("Could not initialize D3D9 HLSL fonts.\n"); - return false; -} - -static void xdk360_deinit_font(void *data) -{ - xdk360_video_font_t *font = &m_Font; - - /* Destroy the font */ - font->m_pFontTexture = NULL; - font->m_dwNumGlyphs = 0L; - font->m_Glyphs = NULL; - font->m_cMaxGlyph = 0; - font->m_TranslatorTable = NULL; - - if (s_FontLocals.m_pFontPixelShader) - s_FontLocals.m_pFontPixelShader->Release(); - if (s_FontLocals.m_pFontVertexShader) - s_FontLocals.m_pFontVertexShader->Release(); - if (s_FontLocals.m_pFontVertexDecl) - s_FontLocals.m_pFontVertexDecl->Release(); - - s_FontLocals.m_pFontPixelShader = NULL; - s_FontLocals.m_pFontVertexShader = NULL; - s_FontLocals.m_pFontVertexDecl = NULL; - - if (m_xprResource.Initialized()) - m_xprResource.Destroy(); -} - -static void xdk360_render_msg_post(xdk360_video_font_t * font, void *video_data) -{ - // Cache the global pointer into a register - d3d_video_t *d3d = (d3d_video_t*)video_data; - LPDIRECT3DDEVICE d3dr = d3d->dev; - - d3d_set_texture(d3dr, 0, NULL); - d3dr->SetVertexDeclaration(NULL); - d3d_set_vertex_shader(d3dr, 0, NULL); - D3DDevice_SetPixelShader(d3dr, NULL); - d3dr->SetRenderState( D3DRS_VIEWPORTENABLE, font->m_dwSavedState ); -} - -static void xdk360_render_msg_pre(xdk360_video_font_t * font, void *video_data) -{ - float vTexScale[4]; - D3DSURFACE_DESC TextureDesc; - d3d_video_t *d3d = (d3d_video_t*)video_data; - LPDIRECT3DDEVICE d3dr = d3d->dev; - - /* Save state. */ - d3dr->GetRenderState( D3DRS_VIEWPORTENABLE, &font->m_dwSavedState ); - - /* Set the texture scaling factor as a vertex shader constant. */ - D3DTexture_GetLevelDesc(font->m_pFontTexture, 0, &TextureDesc); // Get the description - - /* Set render state. */ - d3d_set_texture(d3dr, 0, font->m_pFontTexture); - - /* Read the TextureDesc here to ensure no load/hit/store from GetLevelDesc(). */ - vTexScale[0] = 1.0f / TextureDesc.Width; /* LHS due to int->float conversion. */ - vTexScale[1] = 1.0f / TextureDesc.Height; - vTexScale[2] = 0.0f; - vTexScale[3] = 0.0f; - - d3dr->SetRenderState( D3DRS_VIEWPORTENABLE, FALSE ); - d3dr->SetVertexDeclaration(s_FontLocals.m_pFontVertexDecl); - d3d_set_vertex_shader(d3dr, 0, s_FontLocals.m_pFontVertexShader); - d3dr->SetPixelShader(s_FontLocals.m_pFontPixelShader); - - /* Set the texture scaling factor as a vertex shader constant. - * Call here to avoid load hit store from writing to vTexScale above - */ - d3dr->SetVertexShaderConstantF( 2, vTexScale, 1 ); -} - -static void xdk360_draw_text(xdk360_video_font_t *font, void *video_data, - float x, float y, const wchar_t * strText) -{ - unsigned long dwNumChars; - volatile float *pVertex; - float vColor[4], m_fCursorX, m_fCursorY; - d3d_video_t *d3d = (d3d_video_t*)video_data; - LPDIRECT3DDEVICE d3dr = d3d->dev; - - /* Set the color as a vertex shader constant. */ - vColor[0] = ( ( 0xffffffff & 0x00ff0000 ) >> 16L ) / 255.0f; - vColor[1] = ( ( 0xffffffff & 0x0000ff00 ) >> 8L ) / 255.0f; - vColor[2] = ( ( 0xffffffff & 0x000000ff ) >> 0L ) / 255.0f; - vColor[3] = ( ( 0xffffffff & 0xff000000 ) >> 24L ) / 255.0f; - - /* Perform the actual storing of the color constant here to prevent - * a load-hit-store by inserting work between the store and the use of - * the vColor array. */ - d3dr->SetVertexShaderConstantF( 1, vColor, 1 ); - - m_fCursorX = floorf(x); - m_fCursorY = floorf(y); - - /* Adjust for padding. */ - y -= font->m_fFontTopPadding; - - /* Begin drawing the vertices - * Declared as volatile to force writing in ascending - * address order. - * - * It prevents out of sequence writing in write combined - * memory. - */ - - dwNumChars = wcslen(strText); - d3dr->BeginVertices(D3DPT_QUADLIST, 4 * dwNumChars, - sizeof(XMFLOAT4), (void**)&pVertex); - - /* Draw four vertices for each glyph. */ - while (*strText) - { - float fOffset, fAdvance, fWidth, fHeight; - unsigned long tu1, tu2, tv1, tv2; - const GLYPH_ATTR *pGlyph; - wchar_t letter = *strText++; /* Get the current letter in the string */ - - /* Handle the newline character. */ - if (letter == L'\n') - { - m_fCursorX = x; - m_fCursorY += font->m_fFontYAdvance * FONT_SCALE(d3d); - continue; - } - - /* Translate unprintable characters. */ - if (letter <= font->m_cMaxGlyph) - pGlyph = &font->m_Glyphs[font->m_TranslatorTable[letter]]; - else - pGlyph = &font->m_Glyphs[0]; - - fOffset = FONT_SCALE(d3d) * (float)pGlyph->wOffset; - fAdvance = FONT_SCALE(d3d) * (float)pGlyph->wAdvance; - fWidth = FONT_SCALE(d3d) * (float)pGlyph->wWidth; - fHeight = FONT_SCALE(d3d) * font->m_fFontHeight; - - m_fCursorX += fOffset; - - /* Add the vertices to draw this glyph. */ - - /* Convert shorts to 32 bit longs for in register merging */ - tu1 = pGlyph->tu1; - tv1 = pGlyph->tv1; - tu2 = pGlyph->tu2; - tv2 = pGlyph->tv2; - - /* NOTE: The vertexes are 2 floats for the screen coordinates, - * followed by two USHORTS for the u/vs of the character, - * terminated with the ARGB 32 bit color. - * - * This makes for 16 bytes per vertex data (Easier to read) - * - * Second NOTE: The U/V coordinates are merged and written - * using a DWORD due to the write combining hardware - * being only able to handle 32, 64 and 128 writes. - * - * Never store to write combined memory with 8 or 16bit - * instructions. You've been warned. - */ - - /* Setup the vertex/screen coordinates */ - - pVertex[0] = m_fCursorX; - pVertex[1] = m_fCursorY; - pVertex[3] = 0; - pVertex[4] = m_fCursorX + fWidth; - pVertex[5] = m_fCursorY; - pVertex[7] = 0; - pVertex[8] = m_fCursorX + fWidth; - pVertex[9] = m_fCursorY + fHeight; - pVertex[11] = 0; - pVertex[12] = m_fCursorX; - pVertex[13] = m_fCursorY + fHeight; -#ifndef LSB_FIRST - ((volatile unsigned long *)pVertex)[2] = (tu1 << 16) | tv1; // Merged using big endian rules - ((volatile unsigned long *)pVertex)[6] = (tu2 << 16) | tv1; // Merged using big endian rules - ((volatile unsigned long *)pVertex)[10] = (tu2 << 16) | tv2; // Merged using big endian rules - ((volatile unsigned long *)pVertex)[14] = (tu1 << 16) | tv2; // Merged using big endian rules -#endif - pVertex[15] = 0; - pVertex += 16; - - m_fCursorX += fAdvance; - - dwNumChars--; - } - - /* Since we allocated vertex data space - * based on the string length, we now need to - * add some dummy verts for any skipped - * characters (like newlines, etc.) - */ - while (dwNumChars) - { - unsigned i; - for (i = 0; i < 16; i++) - pVertex[i] = 0; - - pVertex += 16; - dwNumChars--; - } - - d3dr->EndVertices(); -} - -static void xdk360_render_msg(void *data, const char *str_msg, - const struct font_params *params) -{ - float x, y; - wchar_t msg[PATH_MAX_LENGTH]; - d3d_video_t *d3d = (d3d_video_t*)data; - xdk360_video_font_t *font = &m_Font; - - if (params) - { - x = params->x; - y = params->y; - } - else - { - x = d3d->resolution_hd_enable ? 160 : 100; - y = 120; - } - - mbstowcs(msg, str_msg, sizeof(msg) / sizeof(wchar_t)); - - if (msg || msg[0] != L'\0') - { - xdk360_render_msg_pre(font, d3d); - xdk360_draw_text(font, d3d, x, y, msg); - xdk360_render_msg_post(font, d3d); - } -} - -d3d_font_renderer_t d3d_xbox360_font = { - xdk360_init_font, - xdk360_deinit_font, - xdk360_render_msg, - "Xbox 360 fonts", -}; diff --git a/griffin/griffin.c b/griffin/griffin.c index 6caf9d7ba5..86befa8e27 100644 --- a/griffin/griffin.c +++ b/griffin/griffin.c @@ -257,23 +257,23 @@ FONTS #endif #if defined(HAVE_WIN32_D3D9) -#include "../gfx/fonts/d3d_w32_font.cpp" +#include "../gfx/drivers_font/d3d_w32_font.cpp" #endif #if defined(HAVE_LIBDBGFONT) -#include "../gfx/fonts/ps_libdbgfont.c" +#include "../gfx/drivers_font/ps_libdbgfont.c" #endif #if defined(HAVE_OPENGL) -#include "../gfx/fonts/gl_raster_font.c" +#include "../gfx/drivers_font/gl_raster_font.c" #endif #if defined(_XBOX1) -#include "../gfx/fonts/xdk1_xfonts.c" +#include "../gfx/drivers_font/xdk1_xfonts.c" #endif #if defined(_XBOX360) -#include "../gfx/fonts/xdk360_fonts.cpp" +#include "../gfx/drivers_font/xdk360_fonts.cpp" #endif /*============================================================ diff --git a/menu/disp/rmenu.c b/menu/disp/rmenu.c index 8a863ba8d6..1019a2d4f8 100644 --- a/menu/disp/rmenu.c +++ b/menu/disp/rmenu.c @@ -31,7 +31,7 @@ #include "../../settings_data.h" #include "../../screenshot.h" -#include "../../gfx/fonts/bitmap.h" +#include "../../gfx/drivers_font_renderer/bitmap.h" #include "shared.h" From dbeb06aec629b960926ed57886c4439f63d967d4 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Mon, 12 Jan 2015 23:38:39 +0100 Subject: [PATCH 149/156] Reupload font drivers at new location gfx/drivers_font --- gfx/drivers_font/d3d_w32_font.cpp | 92 ++++++ gfx/drivers_font/gl_raster_font.c | 298 ++++++++++++++++++ gfx/drivers_font/ps_libdbgfont.c | 104 +++++++ gfx/drivers_font/xdk1_xfonts.c | 77 +++++ gfx/drivers_font/xdk360_fonts.cpp | 488 ++++++++++++++++++++++++++++++ 5 files changed, 1059 insertions(+) create mode 100644 gfx/drivers_font/d3d_w32_font.cpp create mode 100644 gfx/drivers_font/gl_raster_font.c create mode 100644 gfx/drivers_font/ps_libdbgfont.c create mode 100644 gfx/drivers_font/xdk1_xfonts.c create mode 100644 gfx/drivers_font/xdk360_fonts.cpp diff --git a/gfx/drivers_font/d3d_w32_font.cpp b/gfx/drivers_font/d3d_w32_font.cpp new file mode 100644 index 0000000000..bb32272272 --- /dev/null +++ b/gfx/drivers_font/d3d_w32_font.cpp @@ -0,0 +1,92 @@ +/* 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 . + */ + +#include "../d3d/d3d.h" +#include "../font_d3d_driver.h" +#include "../gfx_common.h" +#include "../../general.h" + +static LPD3DXFONT d3d_font; + +static bool d3dfonts_w32_init_font(void *data, + const char *font_path, unsigned font_size) +{ + uint32_t r, g, b; + d3d_video_t *d3d = (d3d_video_t*)data; + D3DXFONT_DESC desc = { + static_cast(font_size), 0, 400, 0, + false, DEFAULT_CHARSET, + OUT_TT_PRECIS, + CLIP_DEFAULT_PRECIS, + DEFAULT_PITCH, + "Verdana" // Hardcode ftl :( + }; + + (void)font_path; + + r = static_cast(g_settings.video.msg_color_r * 255) & 0xff; + g = static_cast(g_settings.video.msg_color_g * 255) & 0xff; + b = static_cast(g_settings.video.msg_color_b * 255) & 0xff; + + d3d->font_color = D3DCOLOR_XRGB(r, g, b); + + return SUCCEEDED(D3DXCreateFontIndirect(d3d->dev, &desc, &d3d_font)); +} + +static void d3dfonts_w32_deinit_font(void *data) +{ + (void)data; + + if (d3d_font) + d3d_font->Release(); + d3d_font = NULL; +} + +static void d3dfonts_w32_render_msg(void *data, const char *msg, + const struct font_params *params) +{ + d3d_video_t *d3d = (d3d_video_t*)data; + + if (!d3d) + return; + if (!msg) + return; + if (!(SUCCEEDED(d3d->dev->BeginScene()))) + return; + + d3d_font->DrawTextA(NULL, + msg, + -1, + &d3d->font_rect_shifted, + DT_LEFT, + ((d3d->font_color >> 2) & 0x3f3f3f) | 0xff000000); + + d3d_font->DrawTextA(NULL, + msg, + -1, + &d3d->font_rect, + DT_LEFT, + d3d->font_color | 0xff000000); + + d3d->dev->EndScene(); +} + +d3d_font_renderer_t d3d_win32_font = { + d3dfonts_w32_init_font, + d3dfonts_w32_deinit_font, + d3dfonts_w32_render_msg, + "d3d-fonts-w32", +}; diff --git a/gfx/drivers_font/gl_raster_font.c b/gfx/drivers_font/gl_raster_font.c new file mode 100644 index 0000000000..e3f003cf2d --- /dev/null +++ b/gfx/drivers_font/gl_raster_font.c @@ -0,0 +1,298 @@ +/* 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 . + */ + +#include "../gfx_common.h" +#include "../gl_common.h" +#include "../video_shader_driver.h" + +#define emit(c, vx, vy) do { \ + font_vertex[ 2 * (6 * i + c) + 0] = (x + (delta_x + off_x + vx * width) * scale) * inv_win_width; \ + font_vertex[ 2 * (6 * i + c) + 1] = (y + (delta_y - off_y - vy * height) * scale) * inv_win_height; \ + font_tex_coords[ 2 * (6 * i + c) + 0] = (tex_x + vx * width) * inv_tex_size_x; \ + font_tex_coords[ 2 * (6 * i + c) + 1] = (tex_y + vy * height) * inv_tex_size_y; \ + font_color[ 4 * (6 * i + c) + 0] = color[0]; \ + font_color[ 4 * (6 * i + c) + 1] = color[1]; \ + font_color[ 4 * (6 * i + c) + 2] = color[2]; \ + font_color[ 4 * (6 * i + c) + 3] = color[3]; \ +} while(0) + +#define MAX_MSG_LEN_CHUNK 64 + +typedef struct +{ + gl_t *gl; + GLuint tex; + unsigned tex_width, tex_height; + + const font_renderer_driver_t *font_driver; + void *font_data; +} gl_raster_t; + +static void *gl_raster_font_init_font(void *gl_data, + const char *font_path, float font_size) +{ + unsigned width, height; + uint8_t *tmp_buffer; + const struct font_atlas *atlas = NULL; + gl_raster_t *font = (gl_raster_t*)calloc(1, sizeof(*font)); + + if (!font) + return NULL; + + font->gl = (gl_t*)gl_data; + + if (!font_renderer_create_default(&font->font_driver, + &font->font_data, font_path, font_size)) + { + RARCH_WARN("Couldn't init font renderer.\n"); + free(font); + return NULL; + } + + glGenTextures(1, &font->tex); + glBindTexture(GL_TEXTURE_2D, font->tex); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); + + atlas = font->font_driver->get_atlas(font->font_data); + + width = next_pow2(atlas->width); + height = next_pow2(atlas->height); + + /* Ideally, we'd use single component textures, but the + * difference in ways to do that between core GL and GLES/legacy GL + * is too great to bother going down that route. */ + glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, width, height, + 0, GL_RGBA, GL_UNSIGNED_BYTE, NULL); + + tmp_buffer = (uint8_t*)malloc(atlas->width * atlas->height * 4); + + if (tmp_buffer) + { + unsigned i; + uint8_t *dst = tmp_buffer; + const uint8_t *src = atlas->buffer; + + for (i = 0; i < atlas->width * atlas->height; i++) + { + *dst++ = 0xff; + *dst++ = 0xff; + *dst++ = 0xff; + *dst++ = *src++; + } + + glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, atlas->width, + atlas->height, GL_RGBA, GL_UNSIGNED_BYTE, tmp_buffer); + free(tmp_buffer); + } + + font->tex_width = width; + font->tex_height = height; + + glBindTexture(GL_TEXTURE_2D, font->gl->texture[font->gl->tex_index]); + return font; +} + +static void gl_raster_font_free_font(void *data) +{ + gl_raster_t *font = (gl_raster_t*)data; + if (!font) + return; + + if (font->font_driver && font->font_data) + font->font_driver->free(font->font_data); + + glDeleteTextures(1, &font->tex); + free(font); +} + + +static void render_message(gl_raster_t *font, const char *msg, GLfloat scale, + const GLfloat color[4], GLfloat pos_x, GLfloat pos_y) +{ + int x, y, delta_x, delta_y; + float inv_tex_size_x, inv_tex_size_y, inv_win_width, inv_win_height; + unsigned i, msg_len_full, msg_len; + GLfloat font_tex_coords[2 * 6 * MAX_MSG_LEN_CHUNK]; + GLfloat font_vertex[2 * 6 * MAX_MSG_LEN_CHUNK]; + GLfloat font_color[4 * 6 * MAX_MSG_LEN_CHUNK]; + gl_t *gl = font->gl; + + glBindTexture(GL_TEXTURE_2D, font->tex); + + msg_len_full = strlen(msg); + msg_len = min(msg_len_full, MAX_MSG_LEN_CHUNK); + + x = roundf(pos_x * gl->vp.width); + y = roundf(pos_y * gl->vp.height); + delta_x = 0; + delta_y = 0; + + inv_tex_size_x = 1.0f / font->tex_width; + inv_tex_size_y = 1.0f / font->tex_height; + inv_win_width = 1.0f / font->gl->vp.width; + inv_win_height = 1.0f / font->gl->vp.height; + + while (msg_len_full) + { + /* Rebind shaders so attrib cache gets reset. */ + if (gl->shader && gl->shader->use) + gl->shader->use(gl, GL_SHADER_STOCK_BLEND); + + for (i = 0; i < msg_len; i++) + { + int off_x, off_y, tex_x, tex_y, width, height; + const struct font_glyph *glyph = + font->font_driver->get_glyph(font->font_data, (uint8_t)msg[i]); + if (!glyph) + glyph = font->font_driver->get_glyph(font->font_data, '?'); /* Do something smarter here ... */ + if (!glyph) + continue; + + off_x = glyph->draw_offset_x; + off_y = glyph->draw_offset_y; + tex_x = glyph->atlas_offset_x; + tex_y = glyph->atlas_offset_y; + width = glyph->width; + height = glyph->height; + + emit(0, 0, 1); /* Bottom-left */ + emit(1, 1, 1); /* Bottom-right */ + emit(2, 0, 0); /* Top-left */ + + emit(3, 1, 0); /* Top-right */ + emit(4, 0, 0); /* Top-left */ + emit(5, 1, 1); /* Bottom-right */ +#undef emit + + delta_x += glyph->advance_x; + delta_y -= glyph->advance_y; + } + + gl->coords.tex_coord = font_tex_coords; + gl->coords.vertex = font_vertex; + gl->coords.color = font_color; + gl->coords.vertices = 6 * msg_len; + gl->shader->set_coords(&gl->coords); + gl->shader->set_mvp(gl, &gl->mvp_no_rot); + glDrawArrays(GL_TRIANGLES, 0, 6 * msg_len); + + msg_len_full -= msg_len; + msg += msg_len; + msg_len = min(msg_len_full, MAX_MSG_LEN_CHUNK); + } + + /* Post - Go back to old rendering path. */ + gl->coords.vertex = gl->vertex_ptr; + gl->coords.tex_coord = gl->tex_info.coord; + gl->coords.color = gl->white_color_ptr; + gl->coords.vertices = 4; + glBindTexture(GL_TEXTURE_2D, gl->texture[gl->tex_index]); +} + +static void gl_raster_font_render_msg(void *data, const char *msg, + const struct font_params *params) +{ + GLfloat x, y, scale, drop_mod; + GLfloat color[4], color_dark[4]; + int drop_x, drop_y; + bool full_screen; + gl_t *gl = NULL; + gl_raster_t *font = (gl_raster_t*)data; + + if (!font) + return; + + gl = font->gl; + + if (params) + { + x = params->x; + y = params->y; + scale = params->scale; + full_screen = params->full_screen; + drop_x = params->drop_x; + drop_y = params->drop_y; + drop_mod = params->drop_mod; + + color[0] = FONT_COLOR_GET_RED(params->color) / 255.0f; + color[1] = FONT_COLOR_GET_GREEN(params->color) / 255.0f; + color[2] = FONT_COLOR_GET_BLUE(params->color) / 255.0f; + color[3] = FONT_COLOR_GET_ALPHA(params->color) / 255.0f; + + /* If alpha is 0.0f, turn it into default 1.0f */ + if (color[3] <= 0.0f) + color[3] = 1.0f; + } + else + { + x = g_settings.video.msg_pos_x; + y = g_settings.video.msg_pos_y; + scale = 1.0f; + full_screen = false; + + color[0] = g_settings.video.msg_color_r; + color[1] = g_settings.video.msg_color_g; + color[2] = g_settings.video.msg_color_b; + color[3] = 1.0f; + + drop_x = -2; + drop_y = -2; + drop_mod = 0.3f; + } + + gl_set_viewport(gl, gl->win_width, gl->win_height, + full_screen, false); + glEnable(GL_BLEND); + glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); + glBlendEquation(GL_FUNC_ADD); + + if (drop_x || drop_y) + { + color_dark[0] = color[0] * drop_mod; + color_dark[1] = color[1] * drop_mod; + color_dark[2] = color[2] * drop_mod; + color_dark[3] = color[3]; + + render_message(font, msg, scale, color_dark, + x + scale * drop_x / gl->vp.width, y + + scale * drop_y / gl->vp.height); + } + render_message(font, msg, scale, color, x, y); + + glDisable(GL_BLEND); + gl_set_viewport(gl, gl->win_width, gl->win_height, false, true); +} + +static const struct font_glyph *gl_raster_font_get_glyph( + void *data, uint32_t code) +{ + gl_raster_t *font = (gl_raster_t*)data; + + if (!font) + return NULL; + return font->font_driver->get_glyph((void*)font->font_driver, code); +} + +gl_font_renderer_t gl_raster_font = { + gl_raster_font_init_font, + gl_raster_font_free_font, + gl_raster_font_render_msg, + "GL raster", + gl_raster_font_get_glyph, +}; diff --git a/gfx/drivers_font/ps_libdbgfont.c b/gfx/drivers_font/ps_libdbgfont.c new file mode 100644 index 0000000000..517f1f7ab4 --- /dev/null +++ b/gfx/drivers_font/ps_libdbgfont.c @@ -0,0 +1,104 @@ +/* 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 . + */ + +#include "../font_renderer_driver.h" +#include "../gfx_common.h" +#include "../gl_common.h" + +#if defined(SN_TARGET_PSP2) +#include +#define DbgFontPrint(x, y, scale, color, msg) sceDbgFontPrint(x, y, color, msg) +#define DbgFontConfig SceDbgFontConfig +#define DbgFontInit sceDbgFontInit +#define DbgFontExit sceDbgFontExit +#elif defined(__CELLOS_LV2__) +#include +#define SCE_DBGFONT_BUFSIZE_LARGE 2048 +#define DbgFontPrint(x, y, scale, color, msg) cellDbgFontPrintf(x, y, scale, color, msg) +#define DbgFontConfig CellDbgFontConfig +#define DbgFontInit cellDbgFontInit +#define DbgFontExit cellDbgFontExit +#endif + +static void *libdbg_font_init_font(void *gl_data, const char *font_path, float font_size) +{ + gl_t *gl = (gl_t*)gl_data; + + (void)font_path; + (void)font_size; + + DbgFontConfig cfg; +#if defined(SN_TARGET_PSP2) + cfg.fontSize = SCE_DBGFONT_FONTSIZE_LARGE; +#elif defined(__CELLOS_LV2__) + cfg.bufSize = SCE_DBGFONT_BUFSIZE_LARGE; + cfg.screenWidth = gl->win_width; + cfg.screenHeight = gl->win_height; +#endif + + DbgFontInit(&cfg); + + /* Doesn't need any state. */ + return (void*)-1; +} + +static void libdbg_font_deinit_font(void *data) +{ + (void)data; + DbgFontExit(); +} + +static void libdbg_font_render_msg(void *data, const char *msg, + const struct font_params *params) +{ + float x, y, scale; + unsigned color; + + (void)data; + + if (params) + { + x = params->x; + y = params->y; + scale = params->scale; + color = params->color; + } + else + { + x = g_settings.video.msg_pos_x; + y = 0.90f; + scale = 1.04f; + color = SILVER; + } + + DbgFontPrint(x, y, scale, color, msg); + + if (!params) + DbgFontPrint(x, y, scale - 0.01f, WHITE, msg); + +#ifdef SN_TARGET_PSP2 + /* FIXME - if we ever get around to this port, + * move this out to some better place */ + sceDbgFontFlush(); +#endif +} + +gl_font_renderer_t libdbg_font = { + libdbg_font_init_font, + libdbg_font_deinit_font, + libdbg_font_render_msg, + "GL raster", +}; diff --git a/gfx/drivers_font/xdk1_xfonts.c b/gfx/drivers_font/xdk1_xfonts.c new file mode 100644 index 0000000000..e72479ef2e --- /dev/null +++ b/gfx/drivers_font/xdk1_xfonts.c @@ -0,0 +1,77 @@ +/* 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 . + */ + +#include +#include "../font_d3d_driver.h" +#include "../gfx_common.h" +#include "../../general.h" + +static XFONT *debug_font; +static D3DSurface *pFrontBuffer; + +static bool xfonts_init_font(void *data, + const char *font_path, unsigned font_size) +{ + (void)font_path; + (void)font_size; + (void)data; + + XFONT_OpenDefaultFont(&debug_font); + debug_font->SetBkMode(XFONT_TRANSPARENT); + debug_font->SetBkColor(D3DCOLOR_ARGB(100,0,0,0)); + debug_font->SetTextHeight(14); + debug_font->SetTextAntialiasLevel(debug_font->GetTextAntialiasLevel()); + + return true; +} + +static void xfonts_deinit_font(void *data) +{ + (void)data; +} + +static void xfonts_render_msg(void *data, const char *msg, + const struct font_params *params) +{ + d3d_video_t *d3d = (d3d_video_t*)data; + wchar_t str[PATH_MAX_LENGTH]; + float x, y; + + if (params) + { + x = params->x; + y = params->y; + } + else + { + x = g_settings.video.msg_pos_x; + y = g_settings.video.msg_pos_y; + } + + d3d->dev->GetBackBuffer(-1, D3DBACKBUFFER_TYPE_MONO, &pFrontBuffer); + + mbstowcs(str, msg, sizeof(str) / sizeof(wchar_t)); + debug_font->TextOut(pFrontBuffer, str, (unsigned)-1, x, y); + + pFrontBuffer->Release(); +} + +d3d_font_renderer_t d3d_xdk1_font = { + xfonts_init_font, + xfonts_deinit_font, + xfonts_render_msg, + "XDK1 Xfonts", +}; diff --git a/gfx/drivers_font/xdk360_fonts.cpp b/gfx/drivers_font/xdk360_fonts.cpp new file mode 100644 index 0000000000..436f3054a3 --- /dev/null +++ b/gfx/drivers_font/xdk360_fonts.cpp @@ -0,0 +1,488 @@ +/* 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 . + */ + +#include +#include "../font_d3d_driver.h" +#include "../d3d/d3d.h" +#include "../gfx_common.h" +#include "../../general.h" +#include "../../xdk/xdk_resources.h" + +#define FONT_SCALE(d3d) ((d3d->resolution_hd_enable) ? 2 : 1) + +typedef struct GLYPH_ATTR +{ + unsigned short tu1, tv1, tu2, tv2; /* Texture coordinates for the image. */ + short wOffset; /* Pixel offset for glyph start. */ + short wWidth; /* Pixel width of the glyph. */ + short wAdvance; /* Pixels to advance after the glyph. */ + unsigned short wMask; +} GLYPH_ATTR; + +typedef struct +{ + unsigned long m_dwSavedState; + unsigned long m_cMaxGlyph; /* Number of entries in the translator table. */ + unsigned long m_dwNumGlyphs; /* Number of valid glyphs. */ + float m_fFontHeight; /* Height of the font strike in pixels. */ + float m_fFontTopPadding; /* Padding above the strike zone. */ + float m_fFontBottomPadding; /* Padding below the strike zone. */ + float m_fFontYAdvance; /* Number of pixels to move the cursor for a line feed. */ + wchar_t * m_TranslatorTable; /* ASCII to glyph lookup table. */ + D3DTexture* m_pFontTexture; + const GLYPH_ATTR* m_Glyphs; /* Array of glyphs. */ +} xdk360_video_font_t; + +static xdk360_video_font_t m_Font; +static PackedResource m_xprResource; + +#define CALCFONTFILEHEADERSIZE(x) ( sizeof(unsigned long) + (sizeof(float)* 4) + sizeof(unsigned short) + (sizeof(wchar_t)*(x)) ) +#define FONTFILEVERSION 5 + +typedef struct { + unsigned long m_dwFileVersion; /* Version of the font file (Must match FONTFILEVERSION). */ + float m_fFontHeight; /* Height of the font strike in pixels. */ + float m_fFontTopPadding; /* Padding above the strike zone. */ + float m_fFontBottomPadding; /* Padding below the strike zone. */ + float m_fFontYAdvance; /* Number of pixels to move the cursor for a line feed. */ + unsigned short m_cMaxGlyph; /* Number of font characters (Should be an odd number to maintain DWORD Alignment). */ + wchar_t m_TranslatorTable[1]; /* ASCII to Glyph lookup table, NOTE: It's m_cMaxGlyph+1 in size. */ +} FontFileHeaderImage_t; + +typedef struct { + unsigned long m_dwNumGlyphs; /* Size of font strike array (First entry is the unknown glyph). */ + GLYPH_ATTR m_Glyphs[1]; /* Array of font strike uv's etc... NOTE: It's m_dwNumGlyphs in size. */ +} FontFileStrikesImage_t; + +static const char g_strFontShader[] = +"struct VS_IN\n" +"{\n" +"float2 Pos : POSITION;\n" +"float2 Tex : TEXCOORD0;\n" +"};\n" +"struct VS_OUT\n" +"{\n" +"float4 Position : POSITION;\n" +"float2 TexCoord0 : TEXCOORD0;\n" +"};\n" +"uniform float4 Color : register(c1);\n" +"uniform float2 TexScale : register(c2);\n" +"sampler FontTexture : register(s0);\n" +"VS_OUT main_vertex( VS_IN In )\n" +"{\n" +"VS_OUT Out;\n" +"Out.Position.x = (In.Pos.x-0.5);\n" +"Out.Position.y = (In.Pos.y-0.5);\n" +"Out.Position.z = ( 0.0 );\n" +"Out.Position.w = ( 1.0 );\n" +"Out.TexCoord0.x = In.Tex.x * TexScale.x;\n" +"Out.TexCoord0.y = In.Tex.y * TexScale.y;\n" +"return Out;\n" +"}\n" +"float4 main_fragment( VS_OUT In ) : COLOR0\n" +"{\n" +"float4 FontTexel = tex2D( FontTexture, In.TexCoord0 );\n" +"return FontTexel;\n" +"}\n"; + +typedef struct { + D3DVertexDeclaration* m_pFontVertexDecl; + D3DVertexShader* m_pFontVertexShader; + D3DPixelShader* m_pFontPixelShader; +} Font_Locals_t; + +static Font_Locals_t s_FontLocals; + +static HRESULT xdk360_video_font_create_shaders( + void *data, xdk360_video_font_t * font) +{ + HRESULT hr; + d3d_video_t *d3d = (d3d_video_t*)data; + LPDIRECT3DDEVICE d3dr = d3d->dev; + + if (s_FontLocals.m_pFontVertexDecl) + { + s_FontLocals.m_pFontVertexDecl->AddRef(); + s_FontLocals.m_pFontVertexShader->AddRef(); + s_FontLocals.m_pFontPixelShader->AddRef(); + return 0; + } + + do + { + static const D3DVERTEXELEMENT9 decl[] = + { + { 0, 0, D3DDECLTYPE_FLOAT2, D3DDECLMETHOD_DEFAULT, D3DDECLUSAGE_POSITION, 0 }, + { 0, 8, D3DDECLTYPE_USHORT2, D3DDECLMETHOD_DEFAULT, D3DDECLUSAGE_TEXCOORD, 0 }, + { 0, 12, D3DDECLTYPE_D3DCOLOR, D3DDECLMETHOD_DEFAULT, D3DDECLUSAGE_TEXCOORD, 1 }, + D3DDECL_END() + }; + + + hr = d3dr->CreateVertexDeclaration( decl, &s_FontLocals.m_pFontVertexDecl ); + + if (hr >= 0) + { + ID3DXBuffer* pShaderCode; + + hr = D3DXCompileShader( g_strFontShader, sizeof(g_strFontShader)-1 , + NULL, NULL, "main_vertex", "vs.2.0", 0,&pShaderCode, NULL, NULL ); + + if (hr >= 0) + { + hr = d3dr->CreateVertexShader( ( unsigned long * )pShaderCode->GetBufferPointer(), + &s_FontLocals.m_pFontVertexShader ); + pShaderCode->Release(); + + if (hr >= 0) + { + hr = D3DXCompileShader( g_strFontShader, sizeof(g_strFontShader)-1 , + NULL, NULL, "main_fragment", "ps.2.0", 0,&pShaderCode, NULL, NULL ); + + if (hr >= 0) + { + hr = d3dr->CreatePixelShader((DWORD*)pShaderCode->GetBufferPointer(), + &s_FontLocals.m_pFontPixelShader ); + pShaderCode->Release(); + + if (hr >= 0) + { + hr = 0; + break; + } + } + s_FontLocals.m_pFontVertexShader->Release(); + } + + s_FontLocals.m_pFontVertexShader = NULL; + } + + s_FontLocals.m_pFontVertexDecl->Release(); + } + s_FontLocals.m_pFontVertexDecl = NULL; + }while(0); + + return hr; +} + +static bool xdk360_init_font(void *data, + const char *font_path, unsigned font_size) +{ + unsigned long dwFileVersion; + const void *pFontData = NULL; + D3DTexture *pFontTexture = NULL; + const unsigned char * pData = NULL; + xdk360_video_font_t *font = &m_Font; + d3d_video_t *d3d = (d3d_video_t*)data; + + (void)font_size; + + font->m_pFontTexture = NULL; + font->m_dwNumGlyphs = 0L; + font->m_Glyphs = NULL; + font->m_cMaxGlyph = 0; + font->m_TranslatorTable = NULL; + + /* Create the font. */ + if (FAILED( m_xprResource.Create(font_path))) + goto error; + + pFontTexture = m_xprResource.GetTexture( "FontTexture" ); + pFontData = m_xprResource.GetData( "FontData"); + + /* Save a copy of the texture. */ + font->m_pFontTexture = pFontTexture; + + /* Check version of file (to make sure it matches up with the FontMaker tool). */ + pData = (const unsigned char*)pFontData; + dwFileVersion = ((const FontFileHeaderImage_t *)pData)->m_dwFileVersion; + + if (dwFileVersion != FONTFILEVERSION) + { + RARCH_ERR("Incorrect version number on font file.\n"); + goto error; + } + + font->m_fFontHeight = ((const FontFileHeaderImage_t *)pData)->m_fFontHeight; + font->m_fFontTopPadding = ((const FontFileHeaderImage_t *)pData)->m_fFontTopPadding; + font->m_fFontBottomPadding = ((const FontFileHeaderImage_t *)pData)->m_fFontBottomPadding; + font->m_fFontYAdvance = ((const FontFileHeaderImage_t *)pData)->m_fFontYAdvance; + + /* Point to the translator string which immediately follows the 4 floats. */ + font->m_cMaxGlyph = ((const FontFileHeaderImage_t *)pData)->m_cMaxGlyph; + font->m_TranslatorTable = const_cast((const FontFileHeaderImage_t *)pData)->m_TranslatorTable; + + pData += CALCFONTFILEHEADERSIZE( font->m_cMaxGlyph + 1 ); + + /* Read the glyph attributes from the file. */ + font->m_dwNumGlyphs = ((const FontFileStrikesImage_t *)pData)->m_dwNumGlyphs; + font->m_Glyphs = ((const FontFileStrikesImage_t *)pData)->m_Glyphs; + + /* Create the vertex and pixel shaders for rendering the font */ + if (FAILED(xdk360_video_font_create_shaders(d3d, font))) + { + RARCH_ERR( "Could not create font shaders.\n" ); + goto error; + } + + RARCH_LOG("Successfully initialized D3D9 HLSL fonts.\n"); + return true; +error: + RARCH_ERR("Could not initialize D3D9 HLSL fonts.\n"); + return false; +} + +static void xdk360_deinit_font(void *data) +{ + xdk360_video_font_t *font = &m_Font; + + /* Destroy the font */ + font->m_pFontTexture = NULL; + font->m_dwNumGlyphs = 0L; + font->m_Glyphs = NULL; + font->m_cMaxGlyph = 0; + font->m_TranslatorTable = NULL; + + if (s_FontLocals.m_pFontPixelShader) + s_FontLocals.m_pFontPixelShader->Release(); + if (s_FontLocals.m_pFontVertexShader) + s_FontLocals.m_pFontVertexShader->Release(); + if (s_FontLocals.m_pFontVertexDecl) + s_FontLocals.m_pFontVertexDecl->Release(); + + s_FontLocals.m_pFontPixelShader = NULL; + s_FontLocals.m_pFontVertexShader = NULL; + s_FontLocals.m_pFontVertexDecl = NULL; + + if (m_xprResource.Initialized()) + m_xprResource.Destroy(); +} + +static void xdk360_render_msg_post(xdk360_video_font_t * font, void *video_data) +{ + // Cache the global pointer into a register + d3d_video_t *d3d = (d3d_video_t*)video_data; + LPDIRECT3DDEVICE d3dr = d3d->dev; + + d3d_set_texture(d3dr, 0, NULL); + d3dr->SetVertexDeclaration(NULL); + d3d_set_vertex_shader(d3dr, 0, NULL); + D3DDevice_SetPixelShader(d3dr, NULL); + d3dr->SetRenderState( D3DRS_VIEWPORTENABLE, font->m_dwSavedState ); +} + +static void xdk360_render_msg_pre(xdk360_video_font_t * font, void *video_data) +{ + float vTexScale[4]; + D3DSURFACE_DESC TextureDesc; + d3d_video_t *d3d = (d3d_video_t*)video_data; + LPDIRECT3DDEVICE d3dr = d3d->dev; + + /* Save state. */ + d3dr->GetRenderState( D3DRS_VIEWPORTENABLE, &font->m_dwSavedState ); + + /* Set the texture scaling factor as a vertex shader constant. */ + D3DTexture_GetLevelDesc(font->m_pFontTexture, 0, &TextureDesc); // Get the description + + /* Set render state. */ + d3d_set_texture(d3dr, 0, font->m_pFontTexture); + + /* Read the TextureDesc here to ensure no load/hit/store from GetLevelDesc(). */ + vTexScale[0] = 1.0f / TextureDesc.Width; /* LHS due to int->float conversion. */ + vTexScale[1] = 1.0f / TextureDesc.Height; + vTexScale[2] = 0.0f; + vTexScale[3] = 0.0f; + + d3dr->SetRenderState( D3DRS_VIEWPORTENABLE, FALSE ); + d3dr->SetVertexDeclaration(s_FontLocals.m_pFontVertexDecl); + d3d_set_vertex_shader(d3dr, 0, s_FontLocals.m_pFontVertexShader); + d3dr->SetPixelShader(s_FontLocals.m_pFontPixelShader); + + /* Set the texture scaling factor as a vertex shader constant. + * Call here to avoid load hit store from writing to vTexScale above + */ + d3dr->SetVertexShaderConstantF( 2, vTexScale, 1 ); +} + +static void xdk360_draw_text(xdk360_video_font_t *font, void *video_data, + float x, float y, const wchar_t * strText) +{ + unsigned long dwNumChars; + volatile float *pVertex; + float vColor[4], m_fCursorX, m_fCursorY; + d3d_video_t *d3d = (d3d_video_t*)video_data; + LPDIRECT3DDEVICE d3dr = d3d->dev; + + /* Set the color as a vertex shader constant. */ + vColor[0] = ( ( 0xffffffff & 0x00ff0000 ) >> 16L ) / 255.0f; + vColor[1] = ( ( 0xffffffff & 0x0000ff00 ) >> 8L ) / 255.0f; + vColor[2] = ( ( 0xffffffff & 0x000000ff ) >> 0L ) / 255.0f; + vColor[3] = ( ( 0xffffffff & 0xff000000 ) >> 24L ) / 255.0f; + + /* Perform the actual storing of the color constant here to prevent + * a load-hit-store by inserting work between the store and the use of + * the vColor array. */ + d3dr->SetVertexShaderConstantF( 1, vColor, 1 ); + + m_fCursorX = floorf(x); + m_fCursorY = floorf(y); + + /* Adjust for padding. */ + y -= font->m_fFontTopPadding; + + /* Begin drawing the vertices + * Declared as volatile to force writing in ascending + * address order. + * + * It prevents out of sequence writing in write combined + * memory. + */ + + dwNumChars = wcslen(strText); + d3dr->BeginVertices(D3DPT_QUADLIST, 4 * dwNumChars, + sizeof(XMFLOAT4), (void**)&pVertex); + + /* Draw four vertices for each glyph. */ + while (*strText) + { + float fOffset, fAdvance, fWidth, fHeight; + unsigned long tu1, tu2, tv1, tv2; + const GLYPH_ATTR *pGlyph; + wchar_t letter = *strText++; /* Get the current letter in the string */ + + /* Handle the newline character. */ + if (letter == L'\n') + { + m_fCursorX = x; + m_fCursorY += font->m_fFontYAdvance * FONT_SCALE(d3d); + continue; + } + + /* Translate unprintable characters. */ + if (letter <= font->m_cMaxGlyph) + pGlyph = &font->m_Glyphs[font->m_TranslatorTable[letter]]; + else + pGlyph = &font->m_Glyphs[0]; + + fOffset = FONT_SCALE(d3d) * (float)pGlyph->wOffset; + fAdvance = FONT_SCALE(d3d) * (float)pGlyph->wAdvance; + fWidth = FONT_SCALE(d3d) * (float)pGlyph->wWidth; + fHeight = FONT_SCALE(d3d) * font->m_fFontHeight; + + m_fCursorX += fOffset; + + /* Add the vertices to draw this glyph. */ + + /* Convert shorts to 32 bit longs for in register merging */ + tu1 = pGlyph->tu1; + tv1 = pGlyph->tv1; + tu2 = pGlyph->tu2; + tv2 = pGlyph->tv2; + + /* NOTE: The vertexes are 2 floats for the screen coordinates, + * followed by two USHORTS for the u/vs of the character, + * terminated with the ARGB 32 bit color. + * + * This makes for 16 bytes per vertex data (Easier to read) + * + * Second NOTE: The U/V coordinates are merged and written + * using a DWORD due to the write combining hardware + * being only able to handle 32, 64 and 128 writes. + * + * Never store to write combined memory with 8 or 16bit + * instructions. You've been warned. + */ + + /* Setup the vertex/screen coordinates */ + + pVertex[0] = m_fCursorX; + pVertex[1] = m_fCursorY; + pVertex[3] = 0; + pVertex[4] = m_fCursorX + fWidth; + pVertex[5] = m_fCursorY; + pVertex[7] = 0; + pVertex[8] = m_fCursorX + fWidth; + pVertex[9] = m_fCursorY + fHeight; + pVertex[11] = 0; + pVertex[12] = m_fCursorX; + pVertex[13] = m_fCursorY + fHeight; +#ifndef LSB_FIRST + ((volatile unsigned long *)pVertex)[2] = (tu1 << 16) | tv1; // Merged using big endian rules + ((volatile unsigned long *)pVertex)[6] = (tu2 << 16) | tv1; // Merged using big endian rules + ((volatile unsigned long *)pVertex)[10] = (tu2 << 16) | tv2; // Merged using big endian rules + ((volatile unsigned long *)pVertex)[14] = (tu1 << 16) | tv2; // Merged using big endian rules +#endif + pVertex[15] = 0; + pVertex += 16; + + m_fCursorX += fAdvance; + + dwNumChars--; + } + + /* Since we allocated vertex data space + * based on the string length, we now need to + * add some dummy verts for any skipped + * characters (like newlines, etc.) + */ + while (dwNumChars) + { + unsigned i; + for (i = 0; i < 16; i++) + pVertex[i] = 0; + + pVertex += 16; + dwNumChars--; + } + + d3dr->EndVertices(); +} + +static void xdk360_render_msg(void *data, const char *str_msg, + const struct font_params *params) +{ + float x, y; + wchar_t msg[PATH_MAX_LENGTH]; + d3d_video_t *d3d = (d3d_video_t*)data; + xdk360_video_font_t *font = &m_Font; + + if (params) + { + x = params->x; + y = params->y; + } + else + { + x = d3d->resolution_hd_enable ? 160 : 100; + y = 120; + } + + mbstowcs(msg, str_msg, sizeof(msg) / sizeof(wchar_t)); + + if (msg || msg[0] != L'\0') + { + xdk360_render_msg_pre(font, d3d); + xdk360_draw_text(font, d3d, x, y, msg); + xdk360_render_msg_post(font, d3d); + } +} + +d3d_font_renderer_t d3d_xbox360_font = { + xdk360_init_font, + xdk360_deinit_font, + xdk360_render_msg, + "Xbox 360 fonts", +}; From 058900ac9f48a0592d63e47831d3b9e58925aeea Mon Sep 17 00:00:00 2001 From: twinaphex Date: Mon, 12 Jan 2015 23:42:50 +0100 Subject: [PATCH 150/156] Rename shader_parse.c to video_shader_parse.c --- Makefile.common | 2 +- gfx/d3d/render_chain.h | 2 +- gfx/drivers_shader/shader_hlsl.c | 2 +- gfx/video_driver.h | 2 +- gfx/video_shader_driver.h | 2 +- gfx/{drivers_shader/shader_parse.c => video_shader_parse.c} | 4 ++-- gfx/{drivers_shader/shader_parse.h => video_shader_parse.h} | 6 +++--- griffin/griffin.c | 3 ++- 8 files changed, 12 insertions(+), 11 deletions(-) rename gfx/{drivers_shader/shader_parse.c => video_shader_parse.c} (99%) rename gfx/{drivers_shader/shader_parse.h => video_shader_parse.h} (98%) diff --git a/Makefile.common b/Makefile.common index ba663bf277..7374567e80 100644 --- a/Makefile.common +++ b/Makefile.common @@ -133,7 +133,7 @@ OBJ += frontend/frontend.o \ libretro-sdk/gfx/scaler/scaler.o \ gfx/drivers_shader/shader_null.o \ gfx/video_shader_driver.o \ - gfx/drivers_shader/shader_parse.o \ + gfx/video_shader_parse.o \ libretro-sdk/gfx/scaler/pixconv.o \ libretro-sdk/gfx/scaler/scaler_int.o \ libretro-sdk/gfx/scaler/scaler_filter.o \ diff --git a/gfx/d3d/render_chain.h b/gfx/d3d/render_chain.h index 8cb6c3db6d..3bfaeb34f4 100644 --- a/gfx/d3d/render_chain.h +++ b/gfx/d3d/render_chain.h @@ -19,7 +19,7 @@ #include "d3d.h" #include "../video_state_tracker.h" -#include "../drivers_shader/shader_parse.h" +#include "../video_shader_parse.h" struct Vertex { diff --git a/gfx/drivers_shader/shader_hlsl.c b/gfx/drivers_shader/shader_hlsl.c index 2591b29e3c..f6b0ba1e91 100644 --- a/gfx/drivers_shader/shader_hlsl.c +++ b/gfx/drivers_shader/shader_hlsl.c @@ -15,7 +15,7 @@ */ #include "shader_hlsl.h" -#include "shader_parse.h" +#include "../video_shader_parse.h" #include "../d3d/d3d.h" static const char *stock_hlsl_program = diff --git a/gfx/video_driver.h b/gfx/video_driver.h index c7642443c5..09b0aa13a0 100644 --- a/gfx/video_driver.h +++ b/gfx/video_driver.h @@ -26,7 +26,7 @@ #include "../input/input_driver.h" -#include "drivers_shader/shader_parse.h" +#include "video_shader_parse.h" #ifdef __cplusplus extern "C" { diff --git a/gfx/video_shader_driver.h b/gfx/video_shader_driver.h index 748e8742da..9df172a76a 100644 --- a/gfx/video_shader_driver.h +++ b/gfx/video_shader_driver.h @@ -78,7 +78,7 @@ extern const shader_backend_t shader_null_backend; #define HAVE_SHADER_MANAGER #endif -#include "drivers_shader/shader_parse.h" +#include "video_shader_parse.h" #define GL_SHADER_STOCK_BLEND (GFX_MAX_SHADERS - 1) diff --git a/gfx/drivers_shader/shader_parse.c b/gfx/video_shader_parse.c similarity index 99% rename from gfx/drivers_shader/shader_parse.c rename to gfx/video_shader_parse.c index 27ed5be10b..4944ab8b39 100644 --- a/gfx/drivers_shader/shader_parse.c +++ b/gfx/video_shader_parse.c @@ -16,12 +16,12 @@ #include #include -#include "shader_parse.h" +#include "video_shader_parse.h" #include #include #include #include -#include "../../general.h" +#include "../general.h" /** * wrap_mode_to_str: diff --git a/gfx/drivers_shader/shader_parse.h b/gfx/video_shader_parse.h similarity index 98% rename from gfx/drivers_shader/shader_parse.h rename to gfx/video_shader_parse.h index 748f49dcbf..d220dd4d03 100644 --- a/gfx/drivers_shader/shader_parse.h +++ b/gfx/video_shader_parse.h @@ -14,12 +14,12 @@ * If not, see . */ -#ifndef SHADER_PARSE_H -#define SHADER_PARSE_H +#ifndef __VIDEO_SHADER_PARSE_H +#define __VIDEO_SHADER_PARSE_H #include #include -#include "../video_state_tracker.h" +#include "video_state_tracker.h" #include #ifdef __cplusplus diff --git a/griffin/griffin.c b/griffin/griffin.c index 86befa8e27..146d72fe9b 100644 --- a/griffin/griffin.c +++ b/griffin/griffin.c @@ -135,7 +135,8 @@ VIDEO SHADERS #ifdef HAVE_SHADERS #include "../gfx/video_shader_driver.c" -#include "../gfx/drivers_shader/shader_parse.c" +#include "../gfx/video_shader_parse.c" + #include "../gfx/drivers_shader/shader_null.c" #ifdef HAVE_CG From e82c439d817cc3f4cda989e0e2798410ad656b31 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Mon, 12 Jan 2015 23:52:45 +0100 Subject: [PATCH 151/156] Rename menu/disp to menu/drivers_display and menu/backend to menu/drivers_backend --- Makefile.common | 12 ++++++------ apple/iOS/platform.m | 2 +- frontend/drivers/platform_apple.c | 4 +++- griffin/griffin.c | 18 +++++++++--------- .../menu_common_backend.c | 0 .../menu_lakka_backend.c | 2 +- menu/{disp => drivers_display}/glui.c | 0 menu/{disp => drivers_display}/ios.c | 0 menu/{disp => drivers_display}/ios.h | 0 menu/{disp => drivers_display}/lakka.c | 0 menu/{disp => drivers_display}/lakka.h | 0 menu/{disp => drivers_display}/rgui.c | 0 menu/{disp => drivers_display}/rmenu.c | 0 menu/{disp => drivers_display}/rmenu_xui.cpp | 0 menu/{disp => drivers_display}/shared.h | 0 menu/{disp => drivers_display}/xmb.c | 0 16 files changed, 20 insertions(+), 18 deletions(-) rename menu/{backend => drivers_backend}/menu_common_backend.c (100%) rename menu/{backend => drivers_backend}/menu_lakka_backend.c (99%) rename menu/{disp => drivers_display}/glui.c (100%) rename menu/{disp => drivers_display}/ios.c (100%) rename menu/{disp => drivers_display}/ios.h (100%) rename menu/{disp => drivers_display}/lakka.c (100%) rename menu/{disp => drivers_display}/lakka.h (100%) rename menu/{disp => drivers_display}/rgui.c (100%) rename menu/{disp => drivers_display}/rmenu.c (100%) rename menu/{disp => drivers_display}/rmenu_xui.cpp (100%) rename menu/{disp => drivers_display}/shared.h (100%) rename menu/{disp => drivers_display}/xmb.c (100%) diff --git a/Makefile.common b/Makefile.common index 7374567e80..0fa20520a1 100644 --- a/Makefile.common +++ b/Makefile.common @@ -274,26 +274,26 @@ ifeq ($(HAVE_NEON),1) endif ifeq ($(HAVE_RGUI), 1) - OBJ += menu/disp/rgui.o + OBJ += menu/drivers_display/rgui.o DEFINES += -DHAVE_MENU -DHAVE_RGUI HAVE_MENU_COMMON = 1 ifeq ($(HAVE_GLUI), 1) - OBJ += menu/disp/glui.o + OBJ += menu/drivers_display/glui.o DEFINES += -DHAVE_GLUI endif ifeq ($(HAVE_XMB), 1) - OBJ += menu/disp/xmb.o + OBJ += menu/drivers_display/xmb.o DEFINES += -DHAVE_XMB endif ifeq ($(HAVE_LAKKA), 1) - OBJ += menu/backend/menu_lakka_backend.o \ - menu/disp/lakka.o + OBJ += menu/drivers_backend/menu_lakka_backend.o \ + menu/drivers_display/lakka.o DEFINES += -DHAVE_LAKKA endif endif ifeq ($(HAVE_MENU_COMMON), 1) - OBJ += menu/backend/menu_common_backend.o \ + OBJ += menu/drivers_backend/menu_common_backend.o \ menu/menu_input.o \ menu/menu.o \ menu/menu_common_list.o \ diff --git a/apple/iOS/platform.m b/apple/iOS/platform.m index 3a02decdb8..a4013e5c03 100644 --- a/apple/iOS/platform.m +++ b/apple/iOS/platform.m @@ -27,7 +27,7 @@ #include "bluetooth/btdynamic.h" #include "bluetooth/btpad.h" -#include "../../menu/disp/ios.h" +#include "../../menu/drivers_display/ios.h" id apple_platform; diff --git a/frontend/drivers/platform_apple.c b/frontend/drivers/platform_apple.c index d7045c4532..e60d7ab7d3 100644 --- a/frontend/drivers/platform_apple.c +++ b/frontend/drivers/platform_apple.c @@ -19,7 +19,9 @@ #include "../frontend.h" #include "../../runloop.h" -#include "../../menu/disp/ios.h" +#ifdef IOS +#include "../../menu/drivers_display/ios.h" +#endif #include #include diff --git a/griffin/griffin.c b/griffin/griffin.c index 146d72fe9b..74182bfc16 100644 --- a/griffin/griffin.c +++ b/griffin/griffin.c @@ -679,40 +679,40 @@ MENU #include "../menu/menu_navigation.c" #include "../menu/menu_animation.c" -#include "../menu/backend/menu_common_backend.c" +#include "../menu/drivers_backend/menu_common_backend.c" #endif #ifdef HAVE_RMENU -#include "../menu/disp/rmenu.c" +#include "../menu/drivers_display/rmenu.c" #endif #ifdef HAVE_RGUI -#include "../menu/disp/rgui.c" +#include "../menu/drivers_display/rgui.c" #endif #ifdef HAVE_RMENU_XUI -#include "../menu/disp/rmenu_xui.cpp" +#include "../menu/drivers_display/rmenu_xui.cpp" #endif #ifdef HAVE_OPENGL #ifdef HAVE_LAKKA -#include "../menu/backend/menu_lakka_backend.c" -#include "../menu/disp/lakka.c" +#include "../menu/drivers_backend/menu_lakka_backend.c" +#include "../menu/drivers_display/lakka.c" #endif #ifdef HAVE_XMB -#include "../menu/disp/xmb.c" +#include "../menu/drivers_display/xmb.c" #endif #ifdef HAVE_GLUI -#include "../menu/disp/glui.c" +#include "../menu/drivers_display/glui.c" #endif #endif #ifdef IOS -#include "../menu/disp/ios.c" +#include "../menu/drivers_display/ios.c" #endif #ifdef HAVE_COMMAND diff --git a/menu/backend/menu_common_backend.c b/menu/drivers_backend/menu_common_backend.c similarity index 100% rename from menu/backend/menu_common_backend.c rename to menu/drivers_backend/menu_common_backend.c diff --git a/menu/backend/menu_lakka_backend.c b/menu/drivers_backend/menu_lakka_backend.c similarity index 99% rename from menu/backend/menu_lakka_backend.c rename to menu/drivers_backend/menu_lakka_backend.c index 843efa45e2..f4833ecc71 100644 --- a/menu/backend/menu_lakka_backend.c +++ b/menu/drivers_backend/menu_lakka_backend.c @@ -34,7 +34,7 @@ #include "../../settings_data.h" #include "../../retroarch.h" -#include "../disp/lakka.h" +#include "../drivers_display/lakka.h" #include "../menu_animation.h" #ifdef HAVE_CONFIG_H diff --git a/menu/disp/glui.c b/menu/drivers_display/glui.c similarity index 100% rename from menu/disp/glui.c rename to menu/drivers_display/glui.c diff --git a/menu/disp/ios.c b/menu/drivers_display/ios.c similarity index 100% rename from menu/disp/ios.c rename to menu/drivers_display/ios.c diff --git a/menu/disp/ios.h b/menu/drivers_display/ios.h similarity index 100% rename from menu/disp/ios.h rename to menu/drivers_display/ios.h diff --git a/menu/disp/lakka.c b/menu/drivers_display/lakka.c similarity index 100% rename from menu/disp/lakka.c rename to menu/drivers_display/lakka.c diff --git a/menu/disp/lakka.h b/menu/drivers_display/lakka.h similarity index 100% rename from menu/disp/lakka.h rename to menu/drivers_display/lakka.h diff --git a/menu/disp/rgui.c b/menu/drivers_display/rgui.c similarity index 100% rename from menu/disp/rgui.c rename to menu/drivers_display/rgui.c diff --git a/menu/disp/rmenu.c b/menu/drivers_display/rmenu.c similarity index 100% rename from menu/disp/rmenu.c rename to menu/drivers_display/rmenu.c diff --git a/menu/disp/rmenu_xui.cpp b/menu/drivers_display/rmenu_xui.cpp similarity index 100% rename from menu/disp/rmenu_xui.cpp rename to menu/drivers_display/rmenu_xui.cpp diff --git a/menu/disp/shared.h b/menu/drivers_display/shared.h similarity index 100% rename from menu/disp/shared.h rename to menu/drivers_display/shared.h diff --git a/menu/disp/xmb.c b/menu/drivers_display/xmb.c similarity index 100% rename from menu/disp/xmb.c rename to menu/drivers_display/xmb.c From 7117db776bed5f57ef979c666c9885425499a2bb Mon Sep 17 00:00:00 2001 From: Twinaphex Date: Mon, 12 Jan 2015 23:53:53 +0100 Subject: [PATCH 152/156] (iOS) Build fix --- apple/iOS/menu.m | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apple/iOS/menu.m b/apple/iOS/menu.m index 8e718757a7..3725cf2905 100644 --- a/apple/iOS/menu.m +++ b/apple/iOS/menu.m @@ -24,7 +24,7 @@ #include "../../menu/menu.h" #include "../../menu/menu_entries.h" -#include "../../menu/disp/shared.h" +#include "../../menu/drivers_display/shared.h" /*********************************************/ /* RunActionSheet */ From ef79bb7242bc53310441d324a9ff641531db6fe5 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Tue, 13 Jan 2015 00:13:28 +0100 Subject: [PATCH 153/156] Rename dsp_filter.c to audio_dsp_filter.c --- Makefile.common | 2 +- audio/{dsp_filter.c => audio_dsp_filter.c} | 2 +- audio/{dsp_filter.h => audio_dsp_filter.h} | 4 ++-- general.h | 2 +- griffin/griffin.c | 2 +- 5 files changed, 6 insertions(+), 6 deletions(-) rename audio/{dsp_filter.c => audio_dsp_filter.c} (99%) rename audio/{dsp_filter.h => audio_dsp_filter.h} (95%) diff --git a/Makefile.common b/Makefile.common index 0fa20520a1..8b31d3fe0c 100644 --- a/Makefile.common +++ b/Makefile.common @@ -141,7 +141,7 @@ OBJ += frontend/frontend.o \ gfx/font_renderer_driver.o \ gfx/video_filter.o \ audio/audio_resampler_driver.o \ - audio/dsp_filter.o \ + audio/audio_dsp_filter.o \ audio/drivers_resampler/sinc.o \ audio/drivers_resampler/nearest.o \ audio/drivers_resampler/cc_resampler.o \ diff --git a/audio/dsp_filter.c b/audio/audio_dsp_filter.c similarity index 99% rename from audio/dsp_filter.c rename to audio/audio_dsp_filter.c index 946b8260d3..fc74b1ca24 100644 --- a/audio/dsp_filter.c +++ b/audio/audio_dsp_filter.c @@ -16,7 +16,7 @@ #include "../performance.h" -#include "dsp_filter.h" +#include "audio_dsp_filter.h" #include "../dynamic.h" #include #include "audio_filters/dspfilter.h" diff --git a/audio/dsp_filter.h b/audio/audio_dsp_filter.h similarity index 95% rename from audio/dsp_filter.h rename to audio/audio_dsp_filter.h index 4a401d2456..6532328e8e 100644 --- a/audio/dsp_filter.h +++ b/audio/audio_dsp_filter.h @@ -14,8 +14,8 @@ * If not, see . */ -#ifndef RARCH_DSP_FILTER_H__ -#define RARCH_DSP_FILTER_H__ +#ifndef __AUDIO_DSP_FILTER_H__ +#define __AUDIO_DSP_FILTER_H__ #ifdef __cplusplus extern "C" { diff --git a/general.h b/general.h index 11b5063ad8..b72f5209a3 100644 --- a/general.h +++ b/general.h @@ -27,7 +27,7 @@ #include "movie.h" #include "autosave.h" #include "cheats.h" -#include "audio/dsp_filter.h" +#include "audio/audio_dsp_filter.h" #include #include "core_options.h" #include "core_info.h" diff --git a/griffin/griffin.c b/griffin/griffin.c index 74182bfc16..0b1bbbe80d 100644 --- a/griffin/griffin.c +++ b/griffin/griffin.c @@ -545,7 +545,7 @@ DYNAMIC #include "../dynamic.c" #include "../dynamic_dummy.c" #include "../gfx/video_filter.c" -#include "../audio/dsp_filter.c" +#include "../audio/audio_dsp_filter.c" /*============================================================ From 2679c3d5c28bbb3c4be4ae2e99f77ee9fbbd3866 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Tue, 13 Jan 2015 00:19:46 +0100 Subject: [PATCH 154/156] Rename audio/utils.c to audio/audio_utils.c --- Makefile.common | 4 ++-- Makefile.openpandora | 2 +- android/phoenix/jni/Android.mk | 2 +- apple/iOS/RetroArch_iOS.xcodeproj/project.pbxproj | 8 ++++---- audio/audio_driver.c | 2 +- audio/{utils.c => audio_utils.c} | 2 +- audio/{utils.h => audio_utils.h} | 0 audio/{utils_neon.S => audio_utils_neon.S} | 0 audio/test/main.c | 2 +- audio/test/snr.c | 2 +- blackberry-qnx/bb10/.cproject | 14 +++++++------- blackberry-qnx/playbook/.cproject | 8 ++++---- griffin/griffin.c | 2 +- libretro_version_1.c | 2 +- record/drivers/ffmpeg.c | 2 +- 15 files changed, 26 insertions(+), 26 deletions(-) rename audio/{utils.c => audio_utils.c} (99%) rename audio/{utils.h => audio_utils.h} (100%) rename audio/{utils_neon.S => audio_utils_neon.S} (100%) diff --git a/Makefile.common b/Makefile.common index 8b31d3fe0c..e1e3cab79b 100644 --- a/Makefile.common +++ b/Makefile.common @@ -268,9 +268,9 @@ ifeq ($(HAVE_NEON),1) DEFINES += -DSINC_LOWER_QUALITY endif -OBJ += audio/utils.o +OBJ += audio/audio_utils.o ifeq ($(HAVE_NEON),1) - OBJ += audio/utils_neon.o + OBJ += audio/audio_utils_neon.o endif ifeq ($(HAVE_RGUI), 1) diff --git a/Makefile.openpandora b/Makefile.openpandora index f837719d3f..04f82f0a97 100644 --- a/Makefile.openpandora +++ b/Makefile.openpandora @@ -10,7 +10,7 @@ TARGET := retroarch-pandora LDDIRS = -L. -L$(PNDSDK)/usr/lib INCDIRS = -I. -I$(PNDSDK)/usr/include -OBJ = griffin/griffin.o audio/resamplers/sinc_neon.o audio/utils_neon.o +OBJ = griffin/griffin.o audio/resamplers/sinc_neon.o audio/audio_utils_neon.o LDFLAGS = -L$(PNDSDK)/usr/lib -Wl,-rpath,$(PNDSDK)/usr/lib LIBS = -lGLESv2 -lEGL -ldl -lm -lpthread -lrt -lasound diff --git a/android/phoenix/jni/Android.mk b/android/phoenix/jni/Android.mk index 17a9fdb258..cb419b46df 100644 --- a/android/phoenix/jni/Android.mk +++ b/android/phoenix/jni/Android.mk @@ -28,7 +28,7 @@ ifeq ($(TARGET_ARCH_ABI),armeabi-v7a) ifeq ($(HAVE_NEON),1) LOCAL_CFLAGS += -D__ARM_NEON__ - LOCAL_SRC_FILES += $(RARCH_DIR)/audio/utils_neon.S.neon + LOCAL_SRC_FILES += $(RARCH_DIR)/audio/audio_utils_neon.S.neon LOCAL_SRC_FILES += $(RARCH_DIR)/audio/drivers_resampler/sinc_neon.S.neon LOCAL_SRC_FILES += $(RARCH_DIR)/audio/drivers_resampler/cc_resampler_neon.S.neon endif diff --git a/apple/iOS/RetroArch_iOS.xcodeproj/project.pbxproj b/apple/iOS/RetroArch_iOS.xcodeproj/project.pbxproj index 59a40adb8f..fbab903463 100644 --- a/apple/iOS/RetroArch_iOS.xcodeproj/project.pbxproj +++ b/apple/iOS/RetroArch_iOS.xcodeproj/project.pbxproj @@ -10,7 +10,7 @@ 501232C8192E5FB00063A359 /* apple_gamecontroller.m in Sources */ = {isa = PBXBuildFile; fileRef = 501232C7192E5FB00063A359 /* apple_gamecontroller.m */; }; 501232CA192E5FC40063A359 /* griffin.c in Sources */ = {isa = PBXBuildFile; fileRef = 501232C9192E5FC40063A359 /* griffin.c */; }; 501232CC192E5FDC0063A359 /* sinc_neon.S in Sources */ = {isa = PBXBuildFile; fileRef = 501232CB192E5FDC0063A359 /* sinc_neon.S */; }; - 501232CE192E5FE30063A359 /* utils_neon.S in Sources */ = {isa = PBXBuildFile; fileRef = 501232CD192E5FE30063A359 /* utils_neon.S */; }; + 501232CE192E5FE30063A359 /* audio_utils_neon.S in Sources */ = {isa = PBXBuildFile; fileRef = 501232CD192E5FE30063A359 /* audio_utils_neon.S */; }; 501232D6192E60580063A359 /* platform.m in Sources */ = {isa = PBXBuildFile; fileRef = 501232D5192E60580063A359 /* platform.m */; }; 501232D8192E605F0063A359 /* browser.m in Sources */ = {isa = PBXBuildFile; fileRef = 501232D7192E605F0063A359 /* browser.m */; }; 501232DA192E606D0063A359 /* menu.m in Sources */ = {isa = PBXBuildFile; fileRef = 501232D9192E606D0063A359 /* menu.m */; }; @@ -43,7 +43,7 @@ 501232C7192E5FB00063A359 /* apple_gamecontroller.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = apple_gamecontroller.m; path = ../common/apple_gamecontroller.m; sourceTree = ""; }; 501232C9192E5FC40063A359 /* griffin.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = griffin.c; path = ../../griffin/griffin.c; sourceTree = ""; }; 501232CB192E5FDC0063A359 /* sinc_neon.S */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.asm; name = sinc_neon.S; path = ../../audio/drivers_resampler/sinc_neon.S; sourceTree = ""; }; - 501232CD192E5FE30063A359 /* utils_neon.S */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.asm; name = utils_neon.S; path = ../../audio/utils_neon.S; sourceTree = ""; }; + 501232CD192E5FE30063A359 /* audio_utils_neon.S */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.asm; name = audio_utils_neon.S; path = ../../audio/audio_utils_neon.S; sourceTree = ""; }; 501232D5192E60580063A359 /* platform.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = platform.m; sourceTree = ""; }; 501232D7192E605F0063A359 /* browser.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = browser.m; sourceTree = ""; }; 501232D9192E606D0063A359 /* menu.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = menu.m; sourceTree = ""; }; @@ -201,7 +201,7 @@ 96AFAEE516C1DC73009DE44C /* audio */ = { isa = PBXGroup; children = ( - 501232CD192E5FE30063A359 /* utils_neon.S */, + 501232CD192E5FE30063A359 /* audio_utils_neon.S */, 501232CB192E5FDC0063A359 /* sinc_neon.S */, ); name = audio; @@ -312,7 +312,7 @@ 501232DA192E606D0063A359 /* menu.m in Sources */, 501232D8192E605F0063A359 /* browser.m in Sources */, 501232D6192E60580063A359 /* platform.m in Sources */, - 501232CE192E5FE30063A359 /* utils_neon.S in Sources */, + 501232CE192E5FE30063A359 /* audio_utils_neon.S in Sources */, 501232C8192E5FB00063A359 /* apple_gamecontroller.m in Sources */, 5073C58A196C0BA40026E146 /* RAGameView.m in Sources */, 501232CC192E5FDC0063A359 /* sinc_neon.S in Sources */, diff --git a/audio/audio_driver.c b/audio/audio_driver.c index 55569ea56b..c98aac1956 100644 --- a/audio/audio_driver.c +++ b/audio/audio_driver.c @@ -17,7 +17,7 @@ #include #include #include "audio_driver.h" -#include "utils.h" +#include "audio_utils.h" #include "audio_thread_wrapper.h" #include "../driver.h" #include "../general.h" diff --git a/audio/utils.c b/audio/audio_utils.c similarity index 99% rename from audio/utils.c rename to audio/audio_utils.c index 916540fd5d..d492f43c1c 100644 --- a/audio/utils.c +++ b/audio/audio_utils.c @@ -15,7 +15,7 @@ */ #include -#include "utils.h" +#include "audio_utils.h" #include "../performance.h" diff --git a/audio/utils.h b/audio/audio_utils.h similarity index 100% rename from audio/utils.h rename to audio/audio_utils.h diff --git a/audio/utils_neon.S b/audio/audio_utils_neon.S similarity index 100% rename from audio/utils_neon.S rename to audio/audio_utils_neon.S diff --git a/audio/test/main.c b/audio/test/main.c index fe04bebe15..15e5bfc4e3 100644 --- a/audio/test/main.c +++ b/audio/test/main.c @@ -17,7 +17,7 @@ // Used for testing and performance benchmarking. #include "../resamplers/resampler.h" -#include "../utils.h" +#include "../audio_utils.h" #include #include #include diff --git a/audio/test/snr.c b/audio/test/snr.c index 565c417010..01d91b16c3 100644 --- a/audio/test/snr.c +++ b/audio/test/snr.c @@ -14,7 +14,7 @@ */ #include "../resamplers/resampler.h" -#include "../utils.h" +#include "../audio_utils.h" #include #include #include diff --git a/blackberry-qnx/bb10/.cproject b/blackberry-qnx/bb10/.cproject index 3360d1ae04..856fd0f472 100644 --- a/blackberry-qnx/bb10/.cproject +++ b/blackberry-qnx/bb10/.cproject @@ -104,7 +104,7 @@ - + - + - + - + - + - + - + - + - + - + - +