From 3479ba2dba23b745092ee662296a125835fe62dc Mon Sep 17 00:00:00 2001 From: Andre Leiradella Date: Sun, 8 Nov 2015 17:40:25 -0200 Subject: [PATCH 001/216] url-encode user-provided data --- cheevos.c | 42 +++++++++++++++++++++++++++++++++++++++--- 1 file changed, 39 insertions(+), 3 deletions(-) diff --git a/cheevos.c b/cheevos.c index d0572a6eab..d45a7ea5f1 100644 --- a/cheevos.c +++ b/cheevos.c @@ -1139,10 +1139,43 @@ static int cheevos_test_cheevo(cheevo_t *cheevo) return ret_val && ret_val_sub_cond; } +static void cheevos_url_encode(const char *str, char *encoded, size_t len) +{ + while (*str) + { + if (isalnum(*str) || *str == '-' || *str == '_' || *str == '.' || *str == '~') + { + if (len >= 2) + { + *encoded++ = *str++; + len--; + } + else + break; + } + else + { + if (len >= 4) + { + sprintf(encoded, "%%%02x", (uint8_t)*str); + encoded += 3; + str++; + len -= 3; + } + else + break; + } + } + + *encoded = 0; +} + static int cheevos_login(retro_time_t *timeout) { const char *username; const char *password; + char urle_user[64]; + char urle_pwd[64]; char request[256]; const char *json; int res; @@ -1161,13 +1194,16 @@ static int cheevos_login(retro_time_t *timeout) RARCH_LOG("CHEEVOS username and/or password not informed\n"); return -1; } - + + cheevos_url_encode(username, urle_user, sizeof(urle_user)); + cheevos_url_encode(password, urle_pwd, sizeof(urle_pwd)); + snprintf( request, sizeof(request), "http://retroachievements.org/dorequest.php?r=login&u=%s&p=%s", - username, password + urle_user, urle_pwd ); - + request[sizeof(request) - 1] = 0; if (!cheevos_http_get(&json, NULL, request, timeout)) From ab7b7b538fcf4ae865d5fa4de630fdaa37d9af19 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Sun, 8 Nov 2015 21:03:12 +0100 Subject: [PATCH 002/216] (Menu) Add get_default_mvp function pointer --- menu/drivers_display/menu_display_gl.c | 29 ++++-------------------- menu/drivers_display/menu_display_null.c | 13 +++++------ menu/menu_display.c | 19 ++++++++++++++-- menu/menu_display.h | 3 +-- 4 files changed, 28 insertions(+), 36 deletions(-) diff --git a/menu/drivers_display/menu_display_gl.c b/menu/drivers_display/menu_display_gl.c index 602f99a01e..22e1158da4 100644 --- a/menu/drivers_display/menu_display_gl.c +++ b/menu/drivers_display/menu_display_gl.c @@ -17,7 +17,6 @@ #include #include -#include #include "../../config.def.h" #include "../../gfx/font_renderer_driver.h" @@ -42,14 +41,14 @@ static const GLfloat gl_tex_coords[] = { 1, 0 }; -static math_matrix_4x4 *menu_display_get_default_mvp(void) +static void *menu_display_gl_get_default_mvp(void) { - gl_t *gl = (gl_t*)video_driver_get_ptr(NULL); + gl_t *gl = (gl_t*)video_driver_get_ptr(NULL); if (!gl) return NULL; - return (math_matrix_4x4*)&gl->mvp_no_rot; + return &gl->mvp_no_rot; } static GLenum menu_display_prim_to_gl_enum(enum menu_display_prim_type prim_type) @@ -194,26 +193,6 @@ static void menu_display_gl_clear_color(float r, float g, float b, float a) glClear(GL_COLOR_BUFFER_BIT); } -static void menu_display_gl_matrix_4x4_rotate_z(void *data, float rotation, - float scale_x, float scale_y, float scale_z, bool scale_enable) -{ - math_matrix_4x4 matrix_rotated; - math_matrix_4x4 matrix_scaled; - math_matrix_4x4 *matrix = (math_matrix_4x4*)data; - math_matrix_4x4 *b = menu_display_get_default_mvp(); - if (!matrix) - return; - - matrix_4x4_rotate_z(&matrix_rotated, rotation); - matrix_4x4_multiply(matrix, &matrix_rotated, b); - - if (!scale_enable) - return; - - matrix_4x4_scale(&matrix_scaled, scale_x, scale_y, scale_z); - matrix_4x4_multiply(matrix, &matrix_scaled, matrix); -} - static unsigned menu_display_gl_texture_load(void *data, enum texture_filter_type type) { return video_texture_load(data, TEXTURE_BACKEND_OPENGL, type); @@ -238,7 +217,7 @@ menu_display_ctx_driver_t menu_display_ctx_gl = { menu_display_gl_blend_end, menu_display_gl_restore_clear_color, menu_display_gl_clear_color, - menu_display_gl_matrix_4x4_rotate_z, + menu_display_gl_get_default_mvp, menu_display_gl_get_tex_coords, menu_display_gl_texture_load, menu_display_gl_texture_unload, diff --git a/menu/drivers_display/menu_display_null.c b/menu/drivers_display/menu_display_null.c index 4b5018b314..d10bfe58b2 100644 --- a/menu/drivers_display/menu_display_null.c +++ b/menu/drivers_display/menu_display_null.c @@ -17,7 +17,6 @@ #include #include -#include #include "../../config.def.h" #include "../../gfx/font_renderer_driver.h" @@ -27,6 +26,11 @@ #include "../menu_display.h" +static void *menu_display_null_get_default_mvp(void) +{ + return NULL; +} + static void menu_display_null_blend_begin(void) { } @@ -69,11 +73,6 @@ static void menu_display_null_clear_color(float r, float g, float b, float a) { } -static void menu_display_null_matrix_4x4_rotate_z(void *data, float rotation, - float scale_x, float scale_y, float scale_z, bool scale_enable) -{ -} - static unsigned menu_display_null_texture_load(void *data, enum texture_filter_type type) { return 0; @@ -96,7 +95,7 @@ menu_display_ctx_driver_t menu_display_ctx_null = { menu_display_null_blend_end, menu_display_null_restore_clear_color, menu_display_null_clear_color, - menu_display_null_matrix_4x4_rotate_z, + menu_display_null_get_default_mvp, menu_display_null_get_tex_coords, menu_display_null_texture_load, menu_display_null_texture_unload, diff --git a/menu/menu_display.c b/menu/menu_display.c index 795aedd197..c8cd8103b2 100644 --- a/menu/menu_display.c +++ b/menu/menu_display.c @@ -581,11 +581,26 @@ void menu_display_blend_end(void) void menu_display_matrix_4x4_rotate_z(void *data, float rotation, float scale_x, float scale_y, float scale_z, bool scale_enable) { + math_matrix_4x4 *matrix, *b; + math_matrix_4x4 matrix_rotated; + math_matrix_4x4 matrix_scaled; menu_display_ctx_driver_t *menu_disp = menu_display_context_get_ptr(); - if (!menu_disp) + if (!menu_disp || !menu_disp->get_default_mvp) return; - menu_disp->matrix_4x4_rotate_z(data, rotation, scale_x, scale_y, scale_z, scale_enable); + matrix = (math_matrix_4x4*)data; + b = (math_matrix_4x4*)menu_disp->get_default_mvp(); + if (!matrix) + return; + + matrix_4x4_rotate_z(&matrix_rotated, rotation); + matrix_4x4_multiply(matrix, &matrix_rotated, b); + + if (!scale_enable) + return; + + matrix_4x4_scale(&matrix_scaled, scale_x, scale_y, scale_z); + matrix_4x4_multiply(matrix, &matrix_scaled, matrix); } unsigned menu_display_texture_load(void *data, diff --git a/menu/menu_display.h b/menu/menu_display.h index e28795bfbd..745b30db9e 100644 --- a/menu/menu_display.h +++ b/menu/menu_display.h @@ -103,8 +103,7 @@ typedef struct menu_display_ctx_driver void (*clear_color)(float r, float g, float b, float a); - void (*matrix_4x4_rotate_z)(void *data, float rotation, - float scale_x, float scale_y, float scale_z, bool scale_enable); + void *(*get_default_mvp)(void); const float *(*get_tex_coords)(void); unsigned (*texture_load)(void *data, enum texture_filter_type type); void (*texture_unload)(uintptr_t *id); From b3e51ef5b4e25376b91e35d6c1c839f1f83346b1 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Sun, 8 Nov 2015 21:26:19 +0100 Subject: [PATCH 003/216] Start adding preliminary D3D menu_display_d3d.c --- menu/drivers_display/menu_display_d3d.c | 243 ++++++++++++++++++++++++ 1 file changed, 243 insertions(+) create mode 100644 menu/drivers_display/menu_display_d3d.c diff --git a/menu/drivers_display/menu_display_d3d.c b/menu/drivers_display/menu_display_d3d.c new file mode 100644 index 0000000000..6305645249 --- /dev/null +++ b/menu/drivers_display/menu_display_d3d.c @@ -0,0 +1,243 @@ +/* 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 . + */ + +#include + +#include +#include + +#include "../../config.def.h" +#include "../../gfx/font_renderer_driver.h" +#include "../../gfx/video_context_driver.h" +#include "../../gfx/video_thread_wrapper.h" +#include "../../gfx/video_texture.h" +#include "../../gfx/d3d/d3d.h" +#include "../../gfx/d3d/d3d_wrapper.h" + +#include "../menu_display.h" + +static const float gl_vertexes[] = { + 0, 0, + 1, 0, + 0, 1, + 1, 1 +}; + +static const float gl_tex_coords[] = { + 0, 1, + 1, 1, + 0, 0, + 1, 0 +}; + +static void *menu_display_d3d_get_default_mvp(void) +{ + d3d_video_t *d3d = (d3d_video_t*)video_driver_get_ptr(NULL); + + if (!d3d) + return NULL; + + return &d3d->mvp_no_rot; +} + +static GLenum menu_display_prim_to_d3d_enum(enum menu_display_prim_type prim_type) +{ + switch (prim_type) + { + case MENU_DISPLAY_PRIM_TRIANGLES: + case MENU_DISPLAY_PRIM_TRIANGLESTRIP: + return D3DPT_TRIANGLESTRIP; + case MENU_DISPLAY_PRIM_NONE: + default: + break; + } + + return 0; +} + +static void menu_display_d3d_blend_begin(void) +{ + d3d_video_t *d3d = (d3d_video_t*)video_driver_get_ptr(NULL); + + if (!d3d) + return; + + d3d_enable_blend_func(d3d->dev); + +#if 0 + if (gl->shader && gl->shader->use) + gl->shader->use(gl, GL_SHADER_STOCK_BLEND); +#endif +} + +static void menu_display_d3d_blend_end(void) +{ + d3d_video_t *d3d = (d3d_video_t*)video_driver_get_ptr(NULL); + + if (!d3d) + return; + + d3d_disable_blend_func(d3d->dev); +} + +static void menu_display_d3d_draw( + unsigned x, unsigned y, + unsigned width, unsigned height, + struct gfx_coords *coords, + void *matrix_data, + uintptr_t texture, + enum menu_display_prim_type prim_type + ) +{ + D3DVIEWPORT vp = {0}; + driver_t *driver = driver_get_ptr(); + d3d_video_t *d3d = (d3d_video_t*)video_driver_get_ptr(NULL); + math_matrix_4x4 *mat = (math_matrix_4x4*)matrix_data; + + if (!d3d) + return; + + /* TODO - edge case */ + if (height <= 0) + height = 1; + + if (!mat) + mat = &gl->mvp_no_rot; + if (!coords->vertex) + coords->vertex = &gl_vertexes[0]; + if (!coords->tex_coord) + coords->tex_coord = &gl_tex_coords[0]; + if (!coords->lut_tex_coord) + coords->lut_tex_coord = &gl_tex_coords[0]; + + vp.X = x; + vp.Y = y; + vp.Width = width; + vp.Height = height; + vp.MinZ = 0.0f; + vp.MaxZ = 1.0f; + + d3d_set_viewport(d3d->dev, &vp); + d3d_set_texture(d3d->dev, 0, texture); + +#if 0 + gl->shader->set_coords(coords); + gl->shader->set_mvp(driver->video_data, mat); +#endif + + d3d_draw_primitive(d3d->dev, menu_display_prim_to_d3d_enum(prim_type), 0, coords->vertices); + + gl->coords.color = gl->white_color_ptr; +} + +static void menu_display_d3d_draw_bg( + unsigned width, + unsigned height, + uintptr_t texture, + float handle_alpha, + bool force_transparency, + GLfloat *coord_color, + GLfloat *coord_color2, + const float *vertex, + const float *tex_coord, + size_t vertex_count, + enum menu_display_prim_type prim_type) +{ + struct gfx_coords coords; + const GLfloat *new_vertex = NULL; + const GLfloat *new_tex_coord = NULL; + global_t *global = global_get_ptr(); + settings_t *settings = config_get_ptr(); + gl_t *gl = (gl_t*)video_driver_get_ptr(NULL); + + if (!gl) + return; + + new_vertex = vertex; + new_tex_coord = tex_coord; + + if (!new_vertex) + new_vertex = &gl_vertexes[0]; + if (!new_tex_coord) + new_tex_coord = &gl_tex_coords[0]; + + coords.vertices = vertex_count; + coords.vertex = new_vertex; + coords.tex_coord = new_tex_coord; + coords.lut_tex_coord = new_tex_coord; + coords.color = (const float*)coord_color; + + menu_display_d3d_blend_begin(); + + menu_display_ctl(MENU_DISPLAY_CTL_SET_VIEWPORT, NULL); + + if ((settings->menu.pause_libretro + || !global->inited.main || (global->inited.core.type == CORE_TYPE_DUMMY)) + && !force_transparency + && texture) + coords.color = (const float*)coord_color2; + + menu_display_d3d_draw(0, 0, width, height, + &coords, &gl->mvp_no_rot, + (GLuint)texture, prim_type); + + menu_display_d3d_blend_end(); + + gl->coords.color = gl->white_color_ptr; +} + +static void menu_display_d3d_restore_clear_color(void) +{ + DWORD clear_color = 0x00000000; + d3d_clear(d3d->dev, 0, NULL, D3DCLEAR_TARGET, clear_color, 0, 0); +} + +static void menu_display_d3d_clear_color(float r, float g, float b, float a) +{ + DWORD clear_color = D3DCOLOR_ARGB(BYTE_CLAMP(a * 255.0f, r * 255.0f, g * 255.0f, b * 255.0f)); + d3d_clear(d3d->dev, 0, NULL, D3DCLEAR_TARGET, clear_color, 0, 0); +} + +static unsigned menu_display_d3d_texture_load(void *data, enum texture_filter_type type) +{ + return video_texture_load(data, TEXTURE_BACKEND_OPENGL, type); +} + +static void menu_display_d3d_texture_unload(uintptr_t *id) +{ + if (!id) + return; + video_texture_unload(id); +} + +static const float *menu_display_d3d_get_tex_coords(void) +{ + return &gl_tex_coords[0]; +} + +menu_display_ctx_driver_t menu_display_ctx_d3d = { + menu_display_d3d_draw, + menu_display_d3d_draw_bg, + menu_display_d3d_blend_begin, + menu_display_d3d_blend_end, + menu_display_d3d_restore_clear_color, + menu_display_d3d_clear_color, + menu_display_d3d_get_default_mvp, + menu_display_d3d_get_tex_coords, + menu_display_d3d_texture_load, + menu_display_d3d_texture_unload, + MENU_VIDEO_DRIVER_DIRECT3D, + "menu_display_d3d", +}; From 7f2814a534cb802f2946b389d38e86102a95b09a Mon Sep 17 00:00:00 2001 From: twinaphex Date: Sun, 8 Nov 2015 21:27:07 +0100 Subject: [PATCH 004/216] Remove some header dependencies --- menu/drivers_display/menu_display_d3d.c | 3 --- menu/drivers_display/menu_display_gl.c | 3 --- 2 files changed, 6 deletions(-) diff --git a/menu/drivers_display/menu_display_d3d.c b/menu/drivers_display/menu_display_d3d.c index 6305645249..7bd4c8bc7e 100644 --- a/menu/drivers_display/menu_display_d3d.c +++ b/menu/drivers_display/menu_display_d3d.c @@ -13,9 +13,6 @@ * If not, see . */ -#include - -#include #include #include "../../config.def.h" diff --git a/menu/drivers_display/menu_display_gl.c b/menu/drivers_display/menu_display_gl.c index 22e1158da4..4f5a1edb3e 100644 --- a/menu/drivers_display/menu_display_gl.c +++ b/menu/drivers_display/menu_display_gl.c @@ -13,9 +13,6 @@ * If not, see . */ -#include - -#include #include #include "../../config.def.h" From e568d4eb0da0b4a8f57df21da4ad631451b6b00d Mon Sep 17 00:00:00 2001 From: twinaphex Date: Sun, 8 Nov 2015 21:31:14 +0100 Subject: [PATCH 005/216] (menu_display_d3d.c) Change some variables --- menu/drivers_display/menu_display_d3d.c | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/menu/drivers_display/menu_display_d3d.c b/menu/drivers_display/menu_display_d3d.c index 7bd4c8bc7e..b5ad263f91 100644 --- a/menu/drivers_display/menu_display_d3d.c +++ b/menu/drivers_display/menu_display_d3d.c @@ -25,14 +25,16 @@ #include "../menu_display.h" -static const float gl_vertexes[] = { +#define BYTE_CLAMP(i) (int) ((((i) > 255) ? 255 : (((i) < 0) ? 0 : (i)))) + +static const float d3d_vertexes[] = { 0, 0, 1, 0, 0, 1, 1, 1 }; -static const float gl_tex_coords[] = { +static const float d3d_tex_coords[] = { 0, 1, 1, 1, 0, 0, @@ -113,11 +115,11 @@ static void menu_display_d3d_draw( if (!mat) mat = &gl->mvp_no_rot; if (!coords->vertex) - coords->vertex = &gl_vertexes[0]; + coords->vertex = &d3d_vertexes[0]; if (!coords->tex_coord) - coords->tex_coord = &gl_tex_coords[0]; + coords->tex_coord = &d3d_tex_coords[0]; if (!coords->lut_tex_coord) - coords->lut_tex_coord = &gl_tex_coords[0]; + coords->lut_tex_coord = &d3d_tex_coords[0]; vp.X = x; vp.Y = y; @@ -157,18 +159,18 @@ static void menu_display_d3d_draw_bg( const GLfloat *new_tex_coord = NULL; global_t *global = global_get_ptr(); settings_t *settings = config_get_ptr(); - gl_t *gl = (gl_t*)video_driver_get_ptr(NULL); + d3d_video_t *d3d = (d3d_video_t*)video_driver_get_ptr(NULL); - if (!gl) + if (!d3d) return; new_vertex = vertex; new_tex_coord = tex_coord; if (!new_vertex) - new_vertex = &gl_vertexes[0]; + new_vertex = &d3d_vertexes[0]; if (!new_tex_coord) - new_tex_coord = &gl_tex_coords[0]; + new_tex_coord = &d3d_tex_coords[0]; coords.vertices = vertex_count; coords.vertex = new_vertex; @@ -221,7 +223,7 @@ static void menu_display_d3d_texture_unload(uintptr_t *id) static const float *menu_display_d3d_get_tex_coords(void) { - return &gl_tex_coords[0]; + return &d3d_tex_coords[0]; } menu_display_ctx_driver_t menu_display_ctx_d3d = { From 4efb9eb6459757d2f407bc7a5c2f2aad46eba410 Mon Sep 17 00:00:00 2001 From: Andre Leiradella Date: Sun, 8 Nov 2015 18:47:05 -0200 Subject: [PATCH 006/216] flush the log file at every output --- libretro-common/include/retro_log.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/libretro-common/include/retro_log.h b/libretro-common/include/retro_log.h index c1b156f9a6..57d2f62aa6 100644 --- a/libretro-common/include/retro_log.h +++ b/libretro-common/include/retro_log.h @@ -217,7 +217,8 @@ static INLINE void RARCH_LOG_V(const char *tag, const char *fmt, va_list ap) __android_log_vprint(prio, PROGRAM_NAME, fmt, ap); #else fprintf(LOG_FILE, "%s %s :: ", PROGRAM_NAME, tag ? tag : "[INFO]"); - vfprintf(LOG_FILE, fmt, ap); + vfprintf(LOG_FILE, fmt, ap); + fflush(LOG_FILE); #endif } From b52d36e7eb32f5587c7b7d7668d7df6f3f8424dd Mon Sep 17 00:00:00 2001 From: twinaphex Date: Sun, 8 Nov 2015 23:14:33 +0100 Subject: [PATCH 007/216] Reuse get_default_mvp --- menu/drivers_display/menu_display_gl.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/menu/drivers_display/menu_display_gl.c b/menu/drivers_display/menu_display_gl.c index 4f5a1edb3e..96ca59d905 100644 --- a/menu/drivers_display/menu_display_gl.c +++ b/menu/drivers_display/menu_display_gl.c @@ -104,7 +104,7 @@ static void menu_display_gl_draw( height = 1; if (!mat) - mat = &gl->mvp_no_rot; + mat = (math_matrix_4x4*)menu_display_gl_get_default_mvp(); if (!coords->vertex) coords->vertex = &gl_vertexes[0]; if (!coords->tex_coord) @@ -171,7 +171,7 @@ static void menu_display_gl_draw_bg( coords.color = (const float*)coord_color2; menu_display_gl_draw(0, 0, width, height, - &coords, &gl->mvp_no_rot, + &coords, (math_matrix_4x4*)menu_display_gl_get_default_mvp(), (GLuint)texture, prim_type); menu_display_gl_blend_end(); From 1a99b3ac2cde8b35ffad19b380a944e0e053e0ab Mon Sep 17 00:00:00 2001 From: twinaphex Date: Sun, 8 Nov 2015 23:15:54 +0100 Subject: [PATCH 008/216] (menu_display_d3d) Reuse default_get_mvp --- menu/drivers_display/menu_display_d3d.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/menu/drivers_display/menu_display_d3d.c b/menu/drivers_display/menu_display_d3d.c index b5ad263f91..d054a0bc41 100644 --- a/menu/drivers_display/menu_display_d3d.c +++ b/menu/drivers_display/menu_display_d3d.c @@ -113,7 +113,7 @@ static void menu_display_d3d_draw( height = 1; if (!mat) - mat = &gl->mvp_no_rot; + mat = menu_display_d3d_get_default_mvp(); if (!coords->vertex) coords->vertex = &d3d_vertexes[0]; if (!coords->tex_coord) @@ -189,7 +189,7 @@ static void menu_display_d3d_draw_bg( coords.color = (const float*)coord_color2; menu_display_d3d_draw(0, 0, width, height, - &coords, &gl->mvp_no_rot, + &coords, (math_matrix_4x4*)menu_display_d3d_get_default_mvp(), (GLuint)texture, prim_type); menu_display_d3d_blend_end(); From 9fa647097aa332d5a9ec02ace5f6950be072b62e Mon Sep 17 00:00:00 2001 From: twinaphex Date: Sun, 8 Nov 2015 23:16:44 +0100 Subject: [PATCH 009/216] (D3D) add cast --- menu/drivers_display/menu_display_d3d.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/menu/drivers_display/menu_display_d3d.c b/menu/drivers_display/menu_display_d3d.c index d054a0bc41..2582d901a6 100644 --- a/menu/drivers_display/menu_display_d3d.c +++ b/menu/drivers_display/menu_display_d3d.c @@ -113,7 +113,7 @@ static void menu_display_d3d_draw( height = 1; if (!mat) - mat = menu_display_d3d_get_default_mvp(); + mat = (math_matrix_4x4*)menu_display_d3d_get_default_mvp(); if (!coords->vertex) coords->vertex = &d3d_vertexes[0]; if (!coords->tex_coord) From 3b0e324a8488876ca7522ec5cfb0d126e9b8e4ff Mon Sep 17 00:00:00 2001 From: twinaphex Date: Sun, 8 Nov 2015 23:18:43 +0100 Subject: [PATCH 010/216] Add D3D hooks --- menu/menu_display.c | 5 +++++ menu/menu_display.h | 1 + 2 files changed, 6 insertions(+) diff --git a/menu/menu_display.c b/menu/menu_display.c index c8cd8103b2..f6c3546ba7 100644 --- a/menu/menu_display.c +++ b/menu/menu_display.c @@ -60,6 +60,11 @@ typedef struct menu_display static menu_display_ctx_driver_t *menu_display_ctx_drivers[] = { +#if 0 +#ifdef HAVE_DIRECT3D + &menu_display_ctx_d3d, +#endif +#endif #ifdef HAVE_OPENGL &menu_display_ctx_gl, #endif diff --git a/menu/menu_display.h b/menu/menu_display.h index 745b30db9e..7d978e2fc9 100644 --- a/menu/menu_display.h +++ b/menu/menu_display.h @@ -178,6 +178,7 @@ void menu_display_texture_unload(uintptr_t *id); const float *menu_display_get_tex_coords(void); extern menu_display_ctx_driver_t menu_display_ctx_gl; +extern menu_display_ctx_driver_t menu_display_ctx_d3d; extern menu_display_ctx_driver_t menu_display_ctx_null; #ifdef __cplusplus From 8b0628f13e34c9649f5d0e9803b33ed2c1160a6e Mon Sep 17 00:00:00 2001 From: twinaphex Date: Sun, 8 Nov 2015 23:20:46 +0100 Subject: [PATCH 011/216] Add file to Griffin/Makefile --- Makefile.common | 4 ++++ griffin/griffin.c | 17 +++++++++++++---- 2 files changed, 17 insertions(+), 4 deletions(-) diff --git a/Makefile.common b/Makefile.common index dcc115e924..ea835367b6 100644 --- a/Makefile.common +++ b/Makefile.common @@ -746,6 +746,10 @@ ifeq ($(HAVE_D3D9), 1) DEFINES += -DHAVE_D3D -DHAVE_D3D9 LIBS += -ld3d9 -ld3dx9 -ldxguid + #ifeq ($(HAVE_MENU_COMMON), 1) + #OBJ += menu/drivers_display/menu_display_d3d.o + #endif + ifeq ($(HAVE_CG), 1) LIBS += -lcgD3D9 OBJ += gfx/d3d/render_chain_cg.o diff --git a/griffin/griffin.c b/griffin/griffin.c index 0c8a4ffa6b..3a9c3aad5d 100644 --- a/griffin/griffin.c +++ b/griffin/griffin.c @@ -139,9 +139,6 @@ VIDEO CONTEXT #include "../gfx/drivers_context/vc_egl_ctx.c" #endif -#ifdef HAVE_MENU -#include "../menu/drivers_display/menu_display_gl.c" -#endif #if defined(_WIN32) && !defined(_XBOX) #include "../gfx/drivers_context/wgl_ctx.c" @@ -817,9 +814,21 @@ MENU #include "../menu/intl/menu_hash_pt.c" #include "../menu/intl/menu_hash_us.c" -#include "../menu/drivers_display/menu_display_null.c" #include "../menu/drivers/null.c" #include "../menu/drivers/menu_generic.c" + +#include "../menu/drivers_display/menu_display_null.c" + +#ifdef HAVE_OPENGL +#include "../menu/drivers_display/menu_display_gl.c" +#endif + +#if 0 +#if defined(HAVE_D3D) +#include "../menu/drivers_display/menu_display_d3d.c" +#endif +#endif + #endif From 2fe6a6af5b03a22cb8d91e01c952f9dff4922e4f Mon Sep 17 00:00:00 2001 From: twinaphex Date: Sun, 8 Nov 2015 23:30:21 +0100 Subject: [PATCH 012/216] Always compile in matrix files now --- griffin/griffin.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/griffin/griffin.c b/griffin/griffin.c index 3a9c3aad5d..7e9244db5c 100644 --- a/griffin/griffin.c +++ b/griffin/griffin.c @@ -210,6 +210,9 @@ VIDEO IMAGE VIDEO DRIVER ============================================================ */ +#include "../libretro-common/gfx/math/matrix_4x4.c" +#include "../libretro-common/gfx/math/matrix_3x3.c" + #if defined(GEKKO) #ifdef HW_RVL #include "../gfx/drivers/gx_gfx_vi_encoder.c" @@ -219,7 +222,6 @@ VIDEO DRIVER #ifdef HAVE_VG #include "../gfx/drivers/vg.c" -#include "../libretro-common/gfx/math/matrix_3x3.c" #endif #ifdef HAVE_OMAP @@ -227,8 +229,6 @@ VIDEO DRIVER #endif #ifdef HAVE_OPENGL -#include "../libretro-common/gfx/math/matrix_4x4.c" - #include "../gfx/drivers/gl.c" #include "../gfx/drivers/gl_common.c" From 2448d356e86c1341d32f3a53f64403fe4cd3e42b Mon Sep 17 00:00:00 2001 From: twinaphex Date: Sun, 8 Nov 2015 23:31:07 +0100 Subject: [PATCH 013/216] Same thing for non-Griffin build --- Makefile.common | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Makefile.common b/Makefile.common index ea835367b6..c52d68ffcf 100644 --- a/Makefile.common +++ b/Makefile.common @@ -569,14 +569,15 @@ endif OBJ += gfx/video_context_driver.o \ gfx/drivers_context/gfx_null_ctx.o \ gfx/video_state_tracker.o \ - gfx/video_texture.o + gfx/video_texture.o \ + libretro-common/gfx/math/matrix_4x4.o \ + libretro-common/gfx/math/matrix_3x3.o ifeq ($(HAVE_GL_CONTEXT), 1) DEFINES += -DHAVE_OPENGL -DHAVE_GLSL OBJ += gfx/drivers/gl.o \ gfx/drivers/gl_common.o \ gfx/drivers_font/gl_raster_font.o \ - libretro-common/gfx/math/matrix_4x4.o \ libretro-common/glsym/rglgen.o ifeq ($(HAVE_MENU_COMMON), 1) @@ -712,8 +713,7 @@ ifeq ($(HAVE_SUNXI), 1) endif ifeq ($(HAVE_VG), 1) - OBJ += gfx/drivers/vg.o \ - libretro-common/gfx/math/matrix_3x3.o + OBJ += gfx/drivers/vg.o DEFINES += $(VG_CFLAGS) LIBS += $(VG_LIBS) endif From 3114d4df7a71d94d0052d5376c8930d0dc710653 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Sun, 8 Nov 2015 23:32:46 +0100 Subject: [PATCH 014/216] menu_display_d3d.c can now be compiled - does not work yet --- griffin/griffin.c | 2 -- menu/drivers_display/menu_display_d3d.c | 18 +++++++++++++----- 2 files changed, 13 insertions(+), 7 deletions(-) diff --git a/griffin/griffin.c b/griffin/griffin.c index 7e9244db5c..7a86cfc961 100644 --- a/griffin/griffin.c +++ b/griffin/griffin.c @@ -823,11 +823,9 @@ MENU #include "../menu/drivers_display/menu_display_gl.c" #endif -#if 0 #if defined(HAVE_D3D) #include "../menu/drivers_display/menu_display_d3d.c" #endif -#endif #endif diff --git a/menu/drivers_display/menu_display_d3d.c b/menu/drivers_display/menu_display_d3d.c index 2582d901a6..3f2296b0e2 100644 --- a/menu/drivers_display/menu_display_d3d.c +++ b/menu/drivers_display/menu_display_d3d.c @@ -48,10 +48,10 @@ static void *menu_display_d3d_get_default_mvp(void) if (!d3d) return NULL; - return &d3d->mvp_no_rot; + return NULL; /* TODO/FIXME */ } -static GLenum menu_display_prim_to_d3d_enum(enum menu_display_prim_type prim_type) +static unsigned menu_display_prim_to_d3d_enum(enum menu_display_prim_type prim_type) { switch (prim_type) { @@ -129,16 +129,18 @@ static void menu_display_d3d_draw( vp.MaxZ = 1.0f; d3d_set_viewport(d3d->dev, &vp); - d3d_set_texture(d3d->dev, 0, texture); + d3d_set_texture(d3d->dev, 0, (LPDIRECT3DTEXTURE9)texture); #if 0 gl->shader->set_coords(coords); gl->shader->set_mvp(driver->video_data, mat); #endif - d3d_draw_primitive(d3d->dev, menu_display_prim_to_d3d_enum(prim_type), 0, coords->vertices); + d3d_draw_primitive(d3d->dev, (D3DPRIMITIVETYPE)menu_display_prim_to_d3d_enum(prim_type), 0, coords->vertices); +#if 0 gl->coords.color = gl->white_color_ptr; +#endif } static void menu_display_d3d_draw_bg( @@ -194,18 +196,24 @@ static void menu_display_d3d_draw_bg( menu_display_d3d_blend_end(); +#if 0 gl->coords.color = gl->white_color_ptr; +#endif } static void menu_display_d3d_restore_clear_color(void) { + d3d_video_t *d3d = (d3d_video_t*)video_driver_get_ptr(NULL); DWORD clear_color = 0x00000000; + d3d_clear(d3d->dev, 0, NULL, D3DCLEAR_TARGET, clear_color, 0, 0); } static void menu_display_d3d_clear_color(float r, float g, float b, float a) { - DWORD clear_color = D3DCOLOR_ARGB(BYTE_CLAMP(a * 255.0f, r * 255.0f, g * 255.0f, b * 255.0f)); + d3d_video_t *d3d = (d3d_video_t*)video_driver_get_ptr(NULL); + DWORD clear_color = D3DCOLOR_ARGB(BYTE_CLAMP(a * 255.0f), BYTE_CLAMP(r * 255.0f), BYTE_CLAMP(g * 255.0f), BYTE_CLAMP(b * 255.0f)); + d3d_clear(d3d->dev, 0, NULL, D3DCLEAR_TARGET, clear_color, 0, 0); } From 7bddda2252a6efb600491158033423e4199ad1e7 Mon Sep 17 00:00:00 2001 From: radius Date: Sun, 8 Nov 2015 17:50:29 -0500 Subject: [PATCH 015/216] make the OSD coordinates relative to screen size instead of viewport size --- gfx/drivers_font/gl_raster_font.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gfx/drivers_font/gl_raster_font.c b/gfx/drivers_font/gl_raster_font.c index 59cdd5c9cb..76e07ade74 100644 --- a/gfx/drivers_font/gl_raster_font.c +++ b/gfx/drivers_font/gl_raster_font.c @@ -440,7 +440,7 @@ static void gl_raster_font_render_msg(void *data, const char *msg, x = settings->video.msg_pos_x; y = settings->video.msg_pos_y; scale = 1.0f; - full_screen = false; + full_screen = true; text_align = TEXT_ALIGN_LEFT; color[0] = settings->video.msg_color_r; From 1bcbaf5fbac5073a981ff5a1a4f5b46a2ee4ee6d Mon Sep 17 00:00:00 2001 From: twinaphex Date: Mon, 9 Nov 2015 00:38:02 +0100 Subject: [PATCH 016/216] Add D3D support for video_texture_{load/unload} --- gfx/video_texture.c | 63 +++++++++++++++++++++++-- gfx/video_texture.h | 5 +- menu/drivers_display/menu_display_d3d.c | 4 +- menu/drivers_display/menu_display_gl.c | 2 +- 4 files changed, 65 insertions(+), 9 deletions(-) diff --git a/gfx/video_texture.c b/gfx/video_texture.c index bebe3afa5c..8788e3eee6 100644 --- a/gfx/video_texture.c +++ b/gfx/video_texture.c @@ -25,7 +25,7 @@ static void video_texture_png_load_gl(struct texture_image *ti, enum texture_filter_type filter_type, - unsigned *id) + uintptr_t *id) { /* Generate the OpenGL texture object */ glGenTextures(1, (GLuint*)id); @@ -38,11 +38,30 @@ static void video_texture_png_load_gl(struct texture_image *ti, } #endif +#ifdef HAVE_D3D +#include "d3d/d3d.h" + +static void video_texture_png_load_d3d(struct texture_image *ti, + enum texture_filter_type filter_type, + uintptr_t *id) +{ + d3d_video_t *d3d = (d3d_video_t*)video_driver_get_ptr(NULL); + + if (!d3d) + return; + + id = (uintptr_t*)d3d_texture_new(d3d->dev, NULL, + ti->width, ti->height, 1, + 0, D3DFMT_A8R8G8B8, D3DPOOL_MANAGED, 0, 0, 0, + NULL, NULL); +} +#endif + static unsigned video_texture_png_load(void *data, enum texture_backend_type type, enum texture_filter_type filter_type) { - unsigned id = 0; + uintptr_t id = 0; if (!data) return 0; @@ -52,6 +71,11 @@ static unsigned video_texture_png_load(void *data, case TEXTURE_BACKEND_OPENGL: #ifdef HAVE_OPENGL video_texture_png_load_gl((struct texture_image*)data, filter_type, &id); +#endif + break; + case TEXTURE_BACKEND_DIRECT3D: +#ifdef HAVE_D3D + video_texture_png_load_d3d((struct texture_image*)data, filter_type, &id); #endif break; case TEXTURE_BACKEND_DEFAULT: @@ -80,6 +104,18 @@ static int video_texture_png_load_wrap_gl(void *data) TEXTURE_FILTER_LINEAR); } +static int video_texture_png_load_wrap_d3d_mipmap(void *data) +{ + return video_texture_png_load(data, TEXTURE_BACKEND_DIRECT3D, + TEXTURE_FILTER_MIPMAP_LINEAR); +} + +static int video_texture_png_load_wrap_d3d(void *data) +{ + return video_texture_png_load(data, TEXTURE_BACKEND_DIRECT3D, + TEXTURE_FILTER_LINEAR); +} + unsigned video_texture_load(void *data, enum texture_backend_type type, enum texture_filter_type filter_type) @@ -106,6 +142,13 @@ unsigned video_texture_load(void *data, else pkt.data.custom_command.method = video_texture_png_load_wrap_gl; break; + case TEXTURE_BACKEND_DIRECT3D: + if (filter_type == TEXTURE_FILTER_MIPMAP_LINEAR || + filter_type == TEXTURE_FILTER_MIPMAP_NEAREST) + pkt.data.custom_command.method = video_texture_png_load_wrap_d3d_mipmap; + else + pkt.data.custom_command.method = video_texture_png_load_wrap_d3d; + break; case TEXTURE_BACKEND_DEFAULT: default: pkt.data.custom_command.method = video_texture_png_load_wrap; @@ -131,9 +174,21 @@ static void video_texture_gl_unload(uintptr_t *id) } #endif -void video_texture_unload(uintptr_t *id) +void video_texture_unload(enum texture_backend_type type, uintptr_t *id) { + switch (type) + { + case TEXTURE_BACKEND_OPENGL: #ifdef HAVE_OPENGL - video_texture_gl_unload(id); + video_texture_gl_unload(id); #endif + break; + case TEXTURE_BACKEND_DIRECT3D: +#ifdef HAVE_D3D + d3d_texture_free((LPDIRECT3DTEXTURE)id); +#endif + break; + case TEXTURE_BACKEND_DEFAULT: + break; + } } diff --git a/gfx/video_texture.h b/gfx/video_texture.h index fd082cd34f..d26e02d391 100644 --- a/gfx/video_texture.h +++ b/gfx/video_texture.h @@ -22,7 +22,8 @@ enum texture_backend_type { TEXTURE_BACKEND_DEFAULT = 0, - TEXTURE_BACKEND_OPENGL + TEXTURE_BACKEND_OPENGL, + TEXTURE_BACKEND_DIRECT3D }; #ifdef __cplusplus @@ -33,7 +34,7 @@ unsigned video_texture_load(void *data, enum texture_backend_type type, enum texture_filter_type filter_type); -void video_texture_unload(uintptr_t *id); +void video_texture_unload(enum texture_backend_type type, uintptr_t *id); #ifdef __cplusplus } diff --git a/menu/drivers_display/menu_display_d3d.c b/menu/drivers_display/menu_display_d3d.c index 3f2296b0e2..44436cd8a1 100644 --- a/menu/drivers_display/menu_display_d3d.c +++ b/menu/drivers_display/menu_display_d3d.c @@ -219,14 +219,14 @@ static void menu_display_d3d_clear_color(float r, float g, float b, float a) static unsigned menu_display_d3d_texture_load(void *data, enum texture_filter_type type) { - return video_texture_load(data, TEXTURE_BACKEND_OPENGL, type); + return video_texture_load(data, TEXTURE_BACKEND_DIRECT3D, type); } static void menu_display_d3d_texture_unload(uintptr_t *id) { if (!id) return; - video_texture_unload(id); + video_texture_unload(TEXTURE_BACKEND_DIRECT3D, id); } static const float *menu_display_d3d_get_tex_coords(void) diff --git a/menu/drivers_display/menu_display_gl.c b/menu/drivers_display/menu_display_gl.c index 96ca59d905..417c28838a 100644 --- a/menu/drivers_display/menu_display_gl.c +++ b/menu/drivers_display/menu_display_gl.c @@ -199,7 +199,7 @@ static void menu_display_gl_texture_unload(uintptr_t *id) { if (!id) return; - video_texture_unload(id); + video_texture_unload(TEXTURE_BACKEND_OPENGL, id); } static const float *menu_display_gl_get_tex_coords(void) From ab651ec09b039a20f1d7f61f1453104e687222a7 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Mon, 9 Nov 2015 00:43:39 +0100 Subject: [PATCH 017/216] Don't include inside gfx/d3d/d3d.h --- gfx/d3d/d3d.h | 1 - 1 file changed, 1 deletion(-) diff --git a/gfx/d3d/d3d.h b/gfx/d3d/d3d.h index 8d4189263f..d57cb5af0c 100644 --- a/gfx/d3d/d3d.h +++ b/gfx/d3d/d3d.h @@ -17,7 +17,6 @@ #ifndef __D3DVIDEO_INTF_H__ #define __D3DVIDEO_INTF_H__ -#include #include #ifdef HAVE_CONFIG_H From 44464624e9fd8608ed66a7b95d808a585dbf99eb Mon Sep 17 00:00:00 2001 From: twinaphex Date: Mon, 9 Nov 2015 00:46:59 +0100 Subject: [PATCH 018/216] (video_texture.c) Don't use video_driver_get_ptr --- gfx/d3d/d3d_wrapper.cpp | 7 ++++++- gfx/video_texture.c | 9 ++------- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/gfx/d3d/d3d_wrapper.cpp b/gfx/d3d/d3d_wrapper.cpp index ccc69791f8..dce8416aa6 100644 --- a/gfx/d3d/d3d_wrapper.cpp +++ b/gfx/d3d/d3d_wrapper.cpp @@ -60,7 +60,12 @@ LPDIRECT3DTEXTURE d3d_texture_new(LPDIRECT3DDEVICE dev, LPDIRECT3DTEXTURE buf; if (!dev) - return NULL; + { + d3d_video_t *d3d = (d3d_video_t*)video_driver_get_ptr(NULL); + if (!d3d->dev) + return NULL; + dev = d3d->dev; + } if (path) hr = D3DXCreateTextureFromFileExA(dev, diff --git a/gfx/video_texture.c b/gfx/video_texture.c index 8788e3eee6..ce8c8e44a6 100644 --- a/gfx/video_texture.c +++ b/gfx/video_texture.c @@ -39,18 +39,13 @@ static void video_texture_png_load_gl(struct texture_image *ti, #endif #ifdef HAVE_D3D -#include "d3d/d3d.h" +#include "d3d/d3d_wrapper.h" static void video_texture_png_load_d3d(struct texture_image *ti, enum texture_filter_type filter_type, uintptr_t *id) { - d3d_video_t *d3d = (d3d_video_t*)video_driver_get_ptr(NULL); - - if (!d3d) - return; - - id = (uintptr_t*)d3d_texture_new(d3d->dev, NULL, + id = (uintptr_t*)d3d_texture_new(NULL, NULL, ti->width, ti->height, 1, 0, D3DFMT_A8R8G8B8, D3DPOOL_MANAGED, 0, 0, 0, NULL, NULL); From d2657fb18a60711916653349ac175f6838a26a40 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Mon, 9 Nov 2015 01:04:32 +0100 Subject: [PATCH 019/216] d3d_wrapper.cpp - don't make us require d3d.h --- gfx/d3d/d3d_wrapper.cpp | 74 ++++++++++++++++++++++++++++++++--------- gfx/d3d/d3d_wrapper.h | 4 ++- 2 files changed, 62 insertions(+), 16 deletions(-) diff --git a/gfx/d3d/d3d_wrapper.cpp b/gfx/d3d/d3d_wrapper.cpp index dce8416aa6..8d5790f50e 100644 --- a/gfx/d3d/d3d_wrapper.cpp +++ b/gfx/d3d/d3d_wrapper.cpp @@ -14,16 +14,26 @@ * If not, see . */ -#include "d3d.h" #include "d3d_wrapper.h" -#include "render_chain_driver.h" -void d3d_swap(void *data, LPDIRECT3DDEVICE dev) +static LPDIRECT3DDEVICE d3d_wrapper_dev; + +static bool d3d_restore_device(LPDIRECT3DDEVICE dev) { - d3d_video_t *d3d = (d3d_video_t*)data; + if (!dev) + { + if (!d3d_wrapper_dev) + return false; + dev = d3d_wrapper_dev; + } + d3d_wrapper_dev = dev; + return true; +} - if (!d3d) - return; +bool d3d_swap(void *data, LPDIRECT3DDEVICE dev) +{ + if (!d3d_restore_device(dev)) + return false; #if defined(_XBOX1) D3DDevice_Swap(0); @@ -33,14 +43,17 @@ void d3d_swap(void *data, LPDIRECT3DDEVICE dev) if (dev->Present(NULL, NULL, NULL, NULL) != D3D_OK) { RARCH_ERR("[D3D]: Present() failed.\n"); - d3d->needs_restore = true; + return false; } #endif + return true; } void d3d_set_transform(LPDIRECT3DDEVICE dev, D3DTRANSFORMSTATETYPE state, CONST D3DMATRIX *matrix) { + if (!d3d_restore_device(dev)) + return; #ifdef _XBOX1 D3DDevice_SetTransform(state, matrix); #elif !defined(_XBOX360) @@ -59,13 +72,8 @@ LPDIRECT3DTEXTURE d3d_texture_new(LPDIRECT3DDEVICE dev, HRESULT hr; LPDIRECT3DTEXTURE buf; - if (!dev) - { - d3d_video_t *d3d = (d3d_video_t*)video_driver_get_ptr(NULL); - if (!d3d->dev) - return NULL; - dev = d3d->dev; - } + if (!d3d_restore_device(dev)) + return NULL; if (path) hr = D3DXCreateTextureFromFileExA(dev, @@ -101,6 +109,9 @@ LPDIRECT3DVERTEXBUFFER d3d_vertex_buffer_new(LPDIRECT3DDEVICE dev, { HRESULT hr; LPDIRECT3DVERTEXBUFFER buf; + + if (!d3d_restore_device(dev)) + return NULL; #ifndef _XBOX if (usage == 0) { @@ -180,6 +191,8 @@ void d3d_set_stream_source(LPDIRECT3DDEVICE dev, unsigned stream_no, LPDIRECT3DVERTEXBUFFER stream_vertbuf, unsigned offset_bytes, unsigned stride) { + if (!d3d_restore_device(dev)) + return; #if defined(HAVE_D3D8) IDirect3DDevice8_SetStreamSource(dev, stream_no, stream_vertbuf, stride); #elif defined(_XBOX360) @@ -193,6 +206,8 @@ void d3d_set_stream_source(LPDIRECT3DDEVICE dev, unsigned stream_no, void d3d_set_sampler_address_u(LPDIRECT3DDEVICE dev, unsigned sampler, unsigned value) { + if (!d3d_restore_device(dev)) + return; #if defined(_XBOX1) D3D__DirtyFlags |= (D3DDIRTYFLAG_TEXTURE_STATE_0 << sampler); D3D__TextureState[sampler][D3DTSS_ADDRESSU] = value; @@ -206,6 +221,8 @@ void d3d_set_sampler_address_u(LPDIRECT3DDEVICE dev, void d3d_set_sampler_address_v(LPDIRECT3DDEVICE dev, unsigned sampler, unsigned value) { + if (!d3d_restore_device(dev)) + return; #if defined(_XBOX1) D3D__DirtyFlags |= (D3DDIRTYFLAG_TEXTURE_STATE_0 << sampler); D3D__TextureState[sampler][D3DTSS_ADDRESSV] = value; @@ -219,6 +236,8 @@ void d3d_set_sampler_address_v(LPDIRECT3DDEVICE dev, void d3d_set_sampler_minfilter(LPDIRECT3DDEVICE dev, unsigned sampler, unsigned value) { + if (!d3d_restore_device(dev)) + return; #if defined(_XBOX1) D3D__DirtyFlags |= (D3DDIRTYFLAG_TEXTURE_STATE_0 << sampler); D3D__TextureState[sampler][D3DTSS_MINFILTER] = value; @@ -232,6 +251,8 @@ void d3d_set_sampler_minfilter(LPDIRECT3DDEVICE dev, void d3d_set_sampler_magfilter(LPDIRECT3DDEVICE dev, unsigned sampler, unsigned value) { + if (!d3d_restore_device(dev)) + return; #if defined(_XBOX1) D3D__DirtyFlags |= (D3DDIRTYFLAG_TEXTURE_STATE_0 << sampler); D3D__TextureState[sampler][D3DTSS_MAGFILTER] = value; @@ -245,6 +266,8 @@ void d3d_set_sampler_magfilter(LPDIRECT3DDEVICE dev, void d3d_draw_primitive(LPDIRECT3DDEVICE dev, D3DPRIMITIVETYPE type, unsigned start, unsigned count) { + if (!d3d_restore_device(dev)) + return; #if defined(_XBOX1) D3DDevice_DrawVertices(type, start, D3DVERTEXCOUNT(type, count)); #elif defined(_XBOX360) @@ -262,6 +285,8 @@ void d3d_clear(LPDIRECT3DDEVICE dev, unsigned count, const D3DRECT *rects, unsigned flags, D3DCOLOR color, float z, unsigned stencil) { + if (!d3d_restore_device(dev)) + return; #if defined(_XBOX1) D3DDevice_Clear(count, rects, flags, color, z, stencil); #elif defined(_XBOX360) @@ -276,6 +301,8 @@ void d3d_lockrectangle_clear(LPDIRECT3DTEXTURE tex, unsigned level, D3DLOCKED_RECT *lock_rect, RECT *rect, unsigned rectangle_height, unsigned flags) { + if (!d3d_restore_device(dev)) + return; #if defined(_XBOX) D3DTexture_LockRect(tex, level, lock_rect, rect, flags); memset(lock_rect->pBits, 0, rectangle_height * lock_rect->Pitch); @@ -290,7 +317,8 @@ void d3d_lockrectangle_clear(LPDIRECT3DTEXTURE tex, void d3d_set_viewport(LPDIRECT3DDEVICE dev, D3DVIEWPORT *vp) { - (void)dev; + if (!d3d_restore_device(dev)) + return; #if defined(_XBOX360) D3DDevice_SetViewport(dev, vp); #elif defined(_XBOX1) @@ -303,6 +331,8 @@ void d3d_set_viewport(LPDIRECT3DDEVICE dev, D3DVIEWPORT *vp) void d3d_set_texture(LPDIRECT3DDEVICE dev, unsigned sampler, LPDIRECT3DTEXTURE tex) { + if (!d3d_restore_device(dev)) + return; #if defined(_XBOX1) D3DDevice_SetTexture(sampler, tex); #elif defined(_XBOX360) @@ -321,6 +351,8 @@ void d3d_set_texture(LPDIRECT3DDEVICE dev, unsigned sampler, HRESULT d3d_set_vertex_shader(LPDIRECT3DDEVICE dev, unsigned index, void *data) { + if (!d3d_restore_device(dev)) + return -1; #if defined(_XBOX1) return dev->SetVertexShader(index); #elif defined(_XBOX360) @@ -338,6 +370,8 @@ void d3d_texture_blit(unsigned pixel_size, LPDIRECT3DTEXTURE tex, D3DLOCKED_RECT *lr, const void *frame, unsigned width, unsigned height, unsigned pitch) { + if (!d3d_restore_device(dev)) + return; #ifdef _XBOX D3DTexture_LockRect(tex, 0, lr, NULL, D3DLOCK_NOSYSLOCK); #if defined(_XBOX360) @@ -376,6 +410,8 @@ void d3d_enable_blend_func(void *data) if (!dev) return; + if (!d3d_restore_device(dev)) + return; dev->SetRenderState(D3DRS_SRCBLEND, D3DBLEND_SRCALPHA); dev->SetRenderState(D3DRS_DESTBLEND, D3DBLEND_INVSRCALPHA); @@ -388,6 +424,8 @@ void d3d_enable_alpha_blend_texture_func(void *data) if (!dev) return; + if (!d3d_restore_device(dev)) + return; #ifndef _XBOX360 /* Also blend the texture with the set alpha value. */ @@ -405,6 +443,8 @@ void d3d_frame_postprocess(void *data) if (!dev) return; + if (!d3d_restore_device(dev)) + return; dev->SetFlickerFilter(global->console.screen.flicker_filter_index); dev->SetSoftDisplayFilter(global->console.softfilter_enable); @@ -417,6 +457,8 @@ void d3d_disable_blend_func(void *data) if (!dev) return; + if (!d3d_restore_device(dev)) + return; dev->SetRenderState(D3DRS_ALPHABLENDENABLE, false); } @@ -429,6 +471,8 @@ void d3d_set_vertex_declaration(void *data, void *vertex_data) #endif if (!dev) return; + if (!d3d_restore_device(dev)) + return; #ifdef _XBOX1 d3d_set_vertex_shader(dev, D3DFVF_XYZ | D3DFVF_TEX1, NULL); #elif defined(HAVE_D3D9) diff --git a/gfx/d3d/d3d_wrapper.h b/gfx/d3d/d3d_wrapper.h index f2465747e2..16a02beebc 100644 --- a/gfx/d3d/d3d_wrapper.h +++ b/gfx/d3d/d3d_wrapper.h @@ -17,10 +17,12 @@ #ifndef _D3D_WRAPPER_H #define _D3D_WRAPPER_H +#include + #include "../common/win32_common.h" #include "d3d_defines.h" -void d3d_swap(void *data, LPDIRECT3DDEVICE dev); +bool d3d_swap(void *data, LPDIRECT3DDEVICE dev); LPDIRECT3DVERTEXBUFFER d3d_vertex_buffer_new(LPDIRECT3DDEVICE dev, unsigned length, unsigned usage, unsigned fvf, From bbeebcc29a340f3522b3acde30dee9627a365b26 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Mon, 9 Nov 2015 01:06:35 +0100 Subject: [PATCH 020/216] (d3d_wrapper.cpp) Buildfixes --- gfx/d3d/d3d.h | 1 + gfx/d3d/d3d_wrapper.cpp | 6 ++---- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/gfx/d3d/d3d.h b/gfx/d3d/d3d.h index d57cb5af0c..8d4189263f 100644 --- a/gfx/d3d/d3d.h +++ b/gfx/d3d/d3d.h @@ -17,6 +17,7 @@ #ifndef __D3DVIDEO_INTF_H__ #define __D3DVIDEO_INTF_H__ +#include #include #ifdef HAVE_CONFIG_H diff --git a/gfx/d3d/d3d_wrapper.cpp b/gfx/d3d/d3d_wrapper.cpp index 8d5790f50e..3fc422af3c 100644 --- a/gfx/d3d/d3d_wrapper.cpp +++ b/gfx/d3d/d3d_wrapper.cpp @@ -14,6 +14,8 @@ * If not, see . */ +#include + #include "d3d_wrapper.h" static LPDIRECT3DDEVICE d3d_wrapper_dev; @@ -301,8 +303,6 @@ void d3d_lockrectangle_clear(LPDIRECT3DTEXTURE tex, unsigned level, D3DLOCKED_RECT *lock_rect, RECT *rect, unsigned rectangle_height, unsigned flags) { - if (!d3d_restore_device(dev)) - return; #if defined(_XBOX) D3DTexture_LockRect(tex, level, lock_rect, rect, flags); memset(lock_rect->pBits, 0, rectangle_height * lock_rect->Pitch); @@ -370,8 +370,6 @@ void d3d_texture_blit(unsigned pixel_size, LPDIRECT3DTEXTURE tex, D3DLOCKED_RECT *lr, const void *frame, unsigned width, unsigned height, unsigned pitch) { - if (!d3d_restore_device(dev)) - return; #ifdef _XBOX D3DTexture_LockRect(tex, 0, lr, NULL, D3DLOCK_NOSYSLOCK); #if defined(_XBOX360) From cb9960c6e2d3fa59b88bbde9fa15b4c509c0ec49 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Mon, 9 Nov 2015 01:19:09 +0100 Subject: [PATCH 021/216] Compile video_texture as C++ for Win32 --- Makefile.common | 7 ++++++- gfx/d3d/d3d_wrapper.h | 8 ++++++++ gfx/video_texture.cpp | 1 + gfx/video_texture.h | 4 ++-- gfx/{video_texture.c => video_texture_c.c} | 0 griffin/griffin.c | 5 ++++- griffin/griffin_cpp.cpp | 3 +++ 7 files changed, 24 insertions(+), 4 deletions(-) create mode 100644 gfx/video_texture.cpp rename gfx/{video_texture.c => video_texture_c.c} (100%) diff --git a/Makefile.common b/Makefile.common index c52d68ffcf..cd19227cdc 100644 --- a/Makefile.common +++ b/Makefile.common @@ -569,10 +569,15 @@ endif OBJ += gfx/video_context_driver.o \ gfx/drivers_context/gfx_null_ctx.o \ gfx/video_state_tracker.o \ - gfx/video_texture.o \ libretro-common/gfx/math/matrix_4x4.o \ libretro-common/gfx/math/matrix_3x3.o +ifneq ($(findstring Win32,$(OS)),) +OBJ += gfx/video_texture.o +else +OBJ += gfx/video_texture_c.o +endif + ifeq ($(HAVE_GL_CONTEXT), 1) DEFINES += -DHAVE_OPENGL -DHAVE_GLSL OBJ += gfx/drivers/gl.o \ diff --git a/gfx/d3d/d3d_wrapper.h b/gfx/d3d/d3d_wrapper.h index 16a02beebc..4e2c4a71e1 100644 --- a/gfx/d3d/d3d_wrapper.h +++ b/gfx/d3d/d3d_wrapper.h @@ -22,6 +22,10 @@ #include "../common/win32_common.h" #include "d3d_defines.h" +#ifdef __cplusplus +extern "C" { +#endif + bool d3d_swap(void *data, LPDIRECT3DDEVICE dev); LPDIRECT3DVERTEXBUFFER d3d_vertex_buffer_new(LPDIRECT3DDEVICE dev, @@ -95,4 +99,8 @@ void d3d_enable_alpha_blend_texture_func(void *data); void d3d_frame_postprocess(void *data); +#ifdef __cplusplus +} +#endif + #endif diff --git a/gfx/video_texture.cpp b/gfx/video_texture.cpp new file mode 100644 index 0000000000..3f4447b2cc --- /dev/null +++ b/gfx/video_texture.cpp @@ -0,0 +1 @@ +#include "video_texture.c" diff --git a/gfx/video_texture.h b/gfx/video_texture.h index d26e02d391..993f189e67 100644 --- a/gfx/video_texture.h +++ b/gfx/video_texture.h @@ -26,7 +26,7 @@ enum texture_backend_type TEXTURE_BACKEND_DIRECT3D }; -#ifdef __cplusplus +#if defined(__cplusplus) && !defined(_WIN32) extern "C" { #endif @@ -36,7 +36,7 @@ unsigned video_texture_load(void *data, void video_texture_unload(enum texture_backend_type type, uintptr_t *id); -#ifdef __cplusplus +#if defined(__cplusplus) && !defined(_WIN32) } #endif diff --git a/gfx/video_texture.c b/gfx/video_texture_c.c similarity index 100% rename from gfx/video_texture.c rename to gfx/video_texture_c.c diff --git a/griffin/griffin.c b/griffin/griffin.c index 7a86cfc961..784c5b8155 100644 --- a/griffin/griffin.c +++ b/griffin/griffin.c @@ -192,7 +192,10 @@ VIDEO IMAGE ============================================================ */ #include "../gfx/image/image.c" -#include "../gfx/video_texture.c" + +#if !defined(_WIN32) +#include "../gfx/video_texture_c.c" +#endif #include "../libretro-common/formats/tga/rtga.c" diff --git a/griffin/griffin_cpp.cpp b/griffin/griffin_cpp.cpp index ae5aead24f..199c3a6024 100644 --- a/griffin/griffin_cpp.cpp +++ b/griffin/griffin_cpp.cpp @@ -53,6 +53,9 @@ VIDEO DRIVER #ifdef _XBOX #include "../frontend/drivers/platform_xdk.cpp" #endif +#ifdef _WIN32 +#include "../gfx/video_texture.cpp" +#endif #if defined(HAVE_D3D) #include "../gfx/d3d/d3d_wrapper.cpp" From 15fc4fe11801e707e94432002e77be6c5154d6d2 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Mon, 9 Nov 2015 01:24:11 +0100 Subject: [PATCH 022/216] Fix include --- gfx/video_texture.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gfx/video_texture.cpp b/gfx/video_texture.cpp index 3f4447b2cc..7c6f27b269 100644 --- a/gfx/video_texture.cpp +++ b/gfx/video_texture.cpp @@ -1 +1 @@ -#include "video_texture.c" +#include "video_texture_c.c" From e81e027022b16bb9ed96f573935bf3081986a1fe Mon Sep 17 00:00:00 2001 From: twinaphex Date: Mon, 9 Nov 2015 01:33:46 +0100 Subject: [PATCH 023/216] Fix linking problems --- gfx/video_texture.h | 4 ++-- gfx/video_texture_c.c | 21 +++++++++++++++++++-- 2 files changed, 21 insertions(+), 4 deletions(-) diff --git a/gfx/video_texture.h b/gfx/video_texture.h index 993f189e67..d26e02d391 100644 --- a/gfx/video_texture.h +++ b/gfx/video_texture.h @@ -26,7 +26,7 @@ enum texture_backend_type TEXTURE_BACKEND_DIRECT3D }; -#if defined(__cplusplus) && !defined(_WIN32) +#ifdef __cplusplus extern "C" { #endif @@ -36,7 +36,7 @@ unsigned video_texture_load(void *data, void video_texture_unload(enum texture_backend_type type, uintptr_t *id); -#if defined(__cplusplus) && !defined(_WIN32) +#ifdef __cplusplus } #endif diff --git a/gfx/video_texture_c.c b/gfx/video_texture_c.c index ce8c8e44a6..496175a4bd 100644 --- a/gfx/video_texture_c.c +++ b/gfx/video_texture_c.c @@ -21,9 +21,13 @@ #include "video_thread_wrapper.h" #ifdef HAVE_OPENGL -#include "drivers/gl_common.h" -static void video_texture_png_load_gl(struct texture_image *ti, +#ifdef __cplusplus +extern "C" { +#endif + +#include "drivers/gl_common.h" +void video_texture_png_load_gl(struct texture_image *ti, enum texture_filter_type filter_type, uintptr_t *id) { @@ -36,6 +40,11 @@ static void video_texture_png_load_gl(struct texture_image *ti, sizeof(uint32_t) /* TODO/FIXME - dehardcode */ ); } + +#ifdef __cplusplus +} +#endif + #endif #ifdef HAVE_D3D @@ -111,6 +120,10 @@ static int video_texture_png_load_wrap_d3d(void *data) TEXTURE_FILTER_LINEAR); } +#ifdef __cplusplus +extern "C" { +#endif + unsigned video_texture_load(void *data, enum texture_backend_type type, enum texture_filter_type filter_type) @@ -160,6 +173,10 @@ unsigned video_texture_load(void *data, return video_texture_png_load(data, type, filter_type); } +#ifdef __cplusplus +} +#endif + #ifdef HAVE_OPENGL static void video_texture_gl_unload(uintptr_t *id) { From 780bf7427303a951ecc4b4071b6b0600edfc3f28 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Mon, 9 Nov 2015 01:50:05 +0100 Subject: [PATCH 024/216] Try to not use glDeleteTextures directly outside --- camera/drivers/android.c | 3 ++- gfx/drivers_font/gl_raster_font.c | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/camera/drivers/android.c b/camera/drivers/android.c index acba089ef2..06e923d4e6 100644 --- a/camera/drivers/android.c +++ b/camera/drivers/android.c @@ -17,6 +17,7 @@ #include #include "../../driver.h" +#include "../../gfx/video_texture.h" typedef struct android_camera { @@ -149,7 +150,7 @@ static void android_camera_stop(void *data) androidcamera->onCameraStop); if (androidcamera->tex) - glDeleteTextures(1, &androidcamera->tex); + video_texture_unload(TEXTURE_BACKEND_OPENGL, (uintptr_t*)&androidcamera->tex); } static bool android_camera_poll(void *data, diff --git a/gfx/drivers_font/gl_raster_font.c b/gfx/drivers_font/gl_raster_font.c index 76e07ade74..9274943509 100644 --- a/gfx/drivers_font/gl_raster_font.c +++ b/gfx/drivers_font/gl_raster_font.c @@ -17,6 +17,7 @@ #include "../drivers/gl_common.h" #include "../font_driver.h" #include "../video_shader_driver.h" +#include "../video_texture.h" /* TODO: Move viewport side effects to the caller: it's a source of bugs. */ @@ -185,7 +186,7 @@ static void gl_raster_font_free_font(void *data) if (font->font_driver && font->font_data) font->font_driver->free(font->font_data); - glDeleteTextures(1, &font->tex); + video_texture_unload(TEXTURE_BACKEND_OPENGL, (uintptr_t*)&font->tex); free(font); } From b6f995a1d70e90118c2b5cd68a41ed33a3a30183 Mon Sep 17 00:00:00 2001 From: Andre Leiradella Date: Sun, 8 Nov 2015 22:53:17 -0200 Subject: [PATCH 025/216] moved the async job queue to the global_t scope --- cheevos.c | 39 ++++++++++++---------------- frontend/frontend.c | 7 +++++ libretro-common/rthreads/async_job.c | 9 +++++-- runloop.h | 7 ++++- 4 files changed, 36 insertions(+), 26 deletions(-) diff --git a/cheevos.c b/cheevos.c index d45a7ea5f1..0714a00868 100644 --- a/cheevos.c +++ b/cheevos.c @@ -154,8 +154,6 @@ typedef struct cheevoset_t unofficial; char token[32]; - - async_job_t *jobs; } cheevos_locals_t; cheevos_locals_t cheevos_locals = @@ -164,7 +162,6 @@ cheevos_locals_t cheevos_locals = {NULL, 0}, {NULL, 0}, {0}, - NULL }; cheevos_globals_t cheevos_globals = @@ -812,8 +809,6 @@ static int cheevos_parse(const char *json) NULL }; - static int initialize = 1; - unsigned core_count, unofficial_count; cheevos_readud_t ud; settings_t *settings = config_get_ptr(); @@ -860,13 +855,7 @@ static int cheevos_parse(const char *json) return -1; } - if (initialize) - { - initialize = 0; - cheevos_locals.jobs = async_job_new(); - } - - return -(cheevos_locals.jobs == NULL); + return 0; } /***************************************************************************** @@ -1228,8 +1217,9 @@ static void cheevos_unlocker(void *payload) { char request[256]; const char *result; - settings_t *settings = config_get_ptr(); - unsigned cheevo_id = (unsigned)(uintptr_t)payload; + settings_t *settings = config_get_ptr(); + global_t *global = global_get_ptr(); + unsigned cheevo_id = (unsigned)(uintptr_t)payload; if (!cheevos_login(NULL)) { @@ -1250,13 +1240,14 @@ static void cheevos_unlocker(void *payload) else { RARCH_LOG("CHEEVOS error awarding achievement %u, will retry\n", cheevo_id); - async_job_add(cheevos_locals.jobs, cheevos_unlocker, (void*)(uintptr_t)cheevo_id); + async_job_add(global->async_jobs, cheevos_unlocker, (void*)(uintptr_t)cheevo_id); } } } static void cheevos_test_cheevo_set(const cheevoset_t *set) { + global_t *global = global_get_ptr(); const cheevo_t *end = set->cheevos + set->count; cheevo_t *cheevo; @@ -1270,7 +1261,7 @@ static void cheevos_test_cheevo_set(const cheevoset_t *set) rarch_main_msg_queue_push(cheevo->title, 0, 3 * 60, false); rarch_main_msg_queue_push(cheevo->description, 0, 5 * 60, false); - async_job_add(cheevos_locals.jobs, cheevos_unlocker, (void*)(uintptr_t)cheevo->id); + async_job_add(global->async_jobs, cheevos_unlocker, (void*)(uintptr_t)cheevo->id); cheevo->active = 0; } @@ -1412,8 +1403,9 @@ static void cheevos_playing(void *payload) { char request[256]; const char* json; - unsigned game_id = (unsigned)(uintptr_t)payload; - settings_t *settings = config_get_ptr(); + global_t *global = global_get_ptr(); + unsigned game_id = (unsigned)(uintptr_t)payload; + settings_t *settings = config_get_ptr(); if (!cheevos_login(NULL)) { @@ -1434,7 +1426,7 @@ static void cheevos_playing(void *payload) else { RARCH_LOG("CHEEVOS error posting playing game %u activity, will retry\n", game_id); - async_job_add(cheevos_locals.jobs, cheevos_playing, (void*)(uintptr_t)game_id); + async_job_add(global->async_jobs, cheevos_playing, (void*)(uintptr_t)game_id); } } } @@ -1815,9 +1807,10 @@ int cheevos_load(const struct retro_game_info *info) struct retro_system_info sysinfo; int i; const char *json; - retro_time_t timeout = 5000000; - unsigned game_id = 0; - settings_t *settings = config_get_ptr(); + retro_time_t timeout = 5000000; + unsigned game_id = 0; + global_t *global = global_get_ptr(); + settings_t *settings = config_get_ptr(); cheevos_locals.loaded = 0; @@ -1913,7 +1906,7 @@ int cheevos_load(const struct retro_game_info *info) free((void*)json); cheevos_locals.loaded = 1; - async_job_add(cheevos_locals.jobs, cheevos_playing, (void*)(uintptr_t)game_id); + async_job_add(global->async_jobs, cheevos_playing, (void*)(uintptr_t)game_id); return 0; } diff --git a/frontend/frontend.c b/frontend/frontend.c index 8cd1dc2a4f..d6c1b1fa4e 100644 --- a/frontend/frontend.c +++ b/frontend/frontend.c @@ -17,6 +17,7 @@ #include #include +#include #include "frontend.h" #include "../system.h" @@ -285,6 +286,7 @@ int rarch_main(int argc, char *argv[], void *data) void *args = (void*)data; int ret = 0; settings_t *settings = NULL; + global_t *global = NULL; driver_t *driver = NULL; rarch_main_alloc(); @@ -302,6 +304,11 @@ int rarch_main(int argc, char *argv[], void *data) rarch_main_new(); +#ifdef HAVE_THREADS + global = global_get_ptr(); + global->async_jobs = async_job_new(); +#endif + if (driver->frontend_ctx) { if (!(ret = (main_load_content(argc, argv, args, diff --git a/libretro-common/rthreads/async_job.c b/libretro-common/rthreads/async_job.c index 3aa1778997..7a35fef2c7 100644 --- a/libretro-common/rthreads/async_job.c +++ b/libretro-common/rthreads/async_job.c @@ -111,8 +111,13 @@ void async_job_free(async_job_t *ajob) int async_job_add(async_job_t *ajob, async_task_t task, void *payload) { - async_job_node_t *node = (async_job_node_t*)calloc(1, sizeof(*node)); - + async_job_node_t *node; + + if (!ajob) + return -1; + + node = (async_job_node_t*)calloc(1, sizeof(*node)); + if (!node) return -1; diff --git a/runloop.h b/runloop.h index 6314fdc571..e9cb3e4970 100644 --- a/runloop.h +++ b/runloop.h @@ -17,6 +17,7 @@ #define __RETROARCH_RUNLOOP_H #include +#include #include "libretro.h" #include "core_info.h" #include "core_options.h" @@ -299,7 +300,11 @@ typedef struct global bool flickerfilter_enable; bool softfilter_enable; } console; - + +#ifdef HAVE_THREADS + async_job_t *async_jobs; +#endif + /* If this is non-NULL. RARCH_LOG and friends * will write to this file. */ FILE *log_file; From 6a12e874b8ee26cb78972bbbe93ae7b3293c558d Mon Sep 17 00:00:00 2001 From: twinaphex Date: Mon, 9 Nov 2015 01:59:24 +0100 Subject: [PATCH 026/216] Handle failure with d3d_swap --- gfx/d3d/d3d.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/gfx/d3d/d3d.cpp b/gfx/d3d/d3d.cpp index e9c7758373..ab334cef53 100644 --- a/gfx/d3d/d3d.cpp +++ b/gfx/d3d/d3d.cpp @@ -1684,8 +1684,7 @@ static bool d3d_frame(void *data, const void *frame, * can screenshot, etc. */ if (settings->video.black_frame_insertion) { - d3d_swap(d3d, d3dr); - if (d3d->needs_restore) + if (!d3d_swap(d3d, d3dr) || d3d->needs_restore) return true; d3d_clear(d3dr, 0, 0, D3DCLEAR_TARGET, 0, 1, 0); } From 8a55aae0a5172ae3ccc15b1b2de6079518ab6185 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Mon, 9 Nov 2015 02:07:02 +0100 Subject: [PATCH 027/216] Move gl_load_texture_data to video_texture_c --- gfx/drivers/gl_common.c | 63 +---------------------------------------- gfx/drivers/gl_common.h | 8 ------ gfx/video_texture.h | 12 ++++++++ gfx/video_texture_c.c | 63 ++++++++++++++++++++++++++++++++++++++++- 4 files changed, 75 insertions(+), 71 deletions(-) diff --git a/gfx/drivers/gl_common.c b/gfx/drivers/gl_common.c index 944e132630..9d6a629b06 100644 --- a/gfx/drivers/gl_common.c +++ b/gfx/drivers/gl_common.c @@ -15,6 +15,7 @@ */ #include "gl_common.h" +#include "../video_texture.h" void gl_ff_vertex(const void *data) { @@ -48,68 +49,6 @@ void gl_ff_matrix(const void *data) #endif } -void gl_load_texture_data(GLuint id, - enum gfx_wrap_type wrap_type, - enum texture_filter_type filter_type, - unsigned alignment, - unsigned width, unsigned height, - const void *frame, unsigned base_size) -{ - GLint mag_filter, min_filter; - bool want_mipmap = false; - bool rgb32 = (base_size == (sizeof(uint32_t))); - driver_t *driver = driver_get_ptr(); - GLenum wrap = gl_wrap_type_to_enum(wrap_type); - - glBindTexture(GL_TEXTURE_2D, id); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, wrap); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, wrap); - -#if defined(HAVE_OPENGLES2) || defined(HAVE_PSGL) || defined(OSX_PPC) - if (filter_type == TEXTURE_FILTER_MIPMAP_LINEAR) - filter_type = TEXTURE_FILTER_LINEAR; - if (filter_type == TEXTURE_FILTER_MIPMAP_NEAREST) - filter_type = TEXTURE_FILTER_NEAREST; -#endif - - switch (filter_type) - { - case TEXTURE_FILTER_MIPMAP_LINEAR: - min_filter = GL_LINEAR_MIPMAP_NEAREST; - mag_filter = GL_LINEAR; - want_mipmap = true; - break; - case TEXTURE_FILTER_MIPMAP_NEAREST: - min_filter = GL_NEAREST_MIPMAP_NEAREST; - mag_filter = GL_NEAREST; - want_mipmap = true; - break; - case TEXTURE_FILTER_NEAREST: - min_filter = GL_NEAREST; - mag_filter = GL_NEAREST; - break; - case TEXTURE_FILTER_LINEAR: - default: - min_filter = GL_LINEAR; - mag_filter = GL_LINEAR; - break; - } - - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, mag_filter); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, min_filter); - - glPixelStorei(GL_UNPACK_ALIGNMENT, alignment); - glTexImage2D(GL_TEXTURE_2D, - 0, - (driver->gfx_use_rgba || !rgb32) ? GL_RGBA : RARCH_GL_INTERNAL_FORMAT32, - width, height, 0, - (driver->gfx_use_rgba || !rgb32) ? GL_RGBA : RARCH_GL_TEXTURE_TYPE32, - (rgb32) ? RARCH_GL_FORMAT32 : GL_UNSIGNED_SHORT_4_4_4_4, frame); - - if (want_mipmap) - glGenerateMipmap(GL_TEXTURE_2D); -} - bool gl_load_luts(const struct video_shader *shader, GLuint *textures_lut) { diff --git a/gfx/drivers/gl_common.h b/gfx/drivers/gl_common.h index c4c21a89c6..571115ac80 100644 --- a/gfx/drivers/gl_common.h +++ b/gfx/drivers/gl_common.h @@ -333,14 +333,6 @@ static INLINE bool gl_check_error(void) return false; } -void gl_load_texture_data(GLuint id, - enum gfx_wrap_type wrap_type, - enum texture_filter_type filter_type, - unsigned alignment, - unsigned width, unsigned height, - const void *frame, - unsigned base_size); - bool gl_load_luts(const struct video_shader *generic_shader, GLuint *lut_textures); diff --git a/gfx/video_texture.h b/gfx/video_texture.h index d26e02d391..dfe6699810 100644 --- a/gfx/video_texture.h +++ b/gfx/video_texture.h @@ -30,6 +30,18 @@ enum texture_backend_type extern "C" { #endif +#ifdef HAVE_OPENGL +#include "drivers/gl_common.h" + +void gl_load_texture_data(GLuint id, + enum gfx_wrap_type wrap_type, + enum texture_filter_type filter_type, + unsigned alignment, + unsigned width, unsigned height, + const void *frame, + unsigned base_size); +#endif + unsigned video_texture_load(void *data, enum texture_backend_type type, enum texture_filter_type filter_type); diff --git a/gfx/video_texture_c.c b/gfx/video_texture_c.c index 496175a4bd..388a563e4a 100644 --- a/gfx/video_texture_c.c +++ b/gfx/video_texture_c.c @@ -26,7 +26,68 @@ extern "C" { #endif -#include "drivers/gl_common.h" +void gl_load_texture_data(GLuint id, + enum gfx_wrap_type wrap_type, + enum texture_filter_type filter_type, + unsigned alignment, + unsigned width, unsigned height, + const void *frame, unsigned base_size) +{ + GLint mag_filter, min_filter; + bool want_mipmap = false; + bool rgb32 = (base_size == (sizeof(uint32_t))); + driver_t *driver = driver_get_ptr(); + GLenum wrap = gl_wrap_type_to_enum(wrap_type); + + glBindTexture(GL_TEXTURE_2D, id); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, wrap); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, wrap); + +#if defined(HAVE_OPENGLES2) || defined(HAVE_PSGL) || defined(OSX_PPC) + if (filter_type == TEXTURE_FILTER_MIPMAP_LINEAR) + filter_type = TEXTURE_FILTER_LINEAR; + if (filter_type == TEXTURE_FILTER_MIPMAP_NEAREST) + filter_type = TEXTURE_FILTER_NEAREST; +#endif + + switch (filter_type) + { + case TEXTURE_FILTER_MIPMAP_LINEAR: + min_filter = GL_LINEAR_MIPMAP_NEAREST; + mag_filter = GL_LINEAR; + want_mipmap = true; + break; + case TEXTURE_FILTER_MIPMAP_NEAREST: + min_filter = GL_NEAREST_MIPMAP_NEAREST; + mag_filter = GL_NEAREST; + want_mipmap = true; + break; + case TEXTURE_FILTER_NEAREST: + min_filter = GL_NEAREST; + mag_filter = GL_NEAREST; + break; + case TEXTURE_FILTER_LINEAR: + default: + min_filter = GL_LINEAR; + mag_filter = GL_LINEAR; + break; + } + + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, mag_filter); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, min_filter); + + glPixelStorei(GL_UNPACK_ALIGNMENT, alignment); + glTexImage2D(GL_TEXTURE_2D, + 0, + (driver->gfx_use_rgba || !rgb32) ? GL_RGBA : RARCH_GL_INTERNAL_FORMAT32, + width, height, 0, + (driver->gfx_use_rgba || !rgb32) ? GL_RGBA : RARCH_GL_TEXTURE_TYPE32, + (rgb32) ? RARCH_GL_FORMAT32 : GL_UNSIGNED_SHORT_4_4_4_4, frame); + + if (want_mipmap) + glGenerateMipmap(GL_TEXTURE_2D); +} + void video_texture_png_load_gl(struct texture_image *ti, enum texture_filter_type filter_type, uintptr_t *id) From 7e207626ad2b36456a9316c191664b97eb869b57 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Mon, 9 Nov 2015 02:08:40 +0100 Subject: [PATCH 028/216] (gl.c) Add video_texture.h header include --- gfx/drivers/gl.c | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/gfx/drivers/gl.c b/gfx/drivers/gl.c index df14b84dcf..ea2390d0b5 100644 --- a/gfx/drivers/gl.c +++ b/gfx/drivers/gl.c @@ -19,30 +19,32 @@ #pragma comment(lib, "opengl32") #endif +#include +#include +#include +#include + +#include + #include "../../driver.h" #include "../../performance.h" #include #include #include -#include #include "../../libretro.h" -#include -#include #include "../../general.h" #include "../../retroarch.h" -#include #ifdef HAVE_CONFIG_H #include "config.h" #endif -#include "gl_common.h" #include "../font_driver.h" #include "../video_viewport.h" #include "../video_pixel_converter.h" #include "../video_context_driver.h" -#include +#include "../video_texture.h" #ifdef HAVE_GLSL #include "../drivers_shader/shader_glsl.h" From c1769ecce4e97797a6acadb855a8f26295097c56 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Mon, 9 Nov 2015 02:14:27 +0100 Subject: [PATCH 029/216] Don't comment this out anymore --- menu/menu_display.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/menu/menu_display.c b/menu/menu_display.c index f6c3546ba7..3af39b127a 100644 --- a/menu/menu_display.c +++ b/menu/menu_display.c @@ -60,11 +60,9 @@ typedef struct menu_display static menu_display_ctx_driver_t *menu_display_ctx_drivers[] = { -#if 0 #ifdef HAVE_DIRECT3D &menu_display_ctx_d3d, #endif -#endif #ifdef HAVE_OPENGL &menu_display_ctx_gl, #endif From c70d230aa3abb15eaffdf89db4174f7790bd2ac4 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Mon, 9 Nov 2015 02:14:59 +0100 Subject: [PATCH 030/216] Don't comment this out anymore --- Makefile.common | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Makefile.common b/Makefile.common index cd19227cdc..4af47e7787 100644 --- a/Makefile.common +++ b/Makefile.common @@ -751,9 +751,9 @@ ifeq ($(HAVE_D3D9), 1) DEFINES += -DHAVE_D3D -DHAVE_D3D9 LIBS += -ld3d9 -ld3dx9 -ldxguid - #ifeq ($(HAVE_MENU_COMMON), 1) - #OBJ += menu/drivers_display/menu_display_d3d.o - #endif + ifeq ($(HAVE_MENU_COMMON), 1) + OBJ += menu/drivers_display/menu_display_d3d.o + endif ifeq ($(HAVE_CG), 1) LIBS += -lcgD3D9 From eae2f3eeda71637cc66865d161b0beaed7cdfb70 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Mon, 9 Nov 2015 02:19:59 +0100 Subject: [PATCH 031/216] Convert menu_display_d3d.c to C++ --- griffin/griffin.c | 4 ---- griffin/griffin_cpp.cpp | 4 ++++ .../{menu_display_d3d.c => menu_display_d3d.cpp} | 0 3 files changed, 4 insertions(+), 4 deletions(-) rename menu/drivers_display/{menu_display_d3d.c => menu_display_d3d.cpp} (100%) diff --git a/griffin/griffin.c b/griffin/griffin.c index 784c5b8155..2c9a616299 100644 --- a/griffin/griffin.c +++ b/griffin/griffin.c @@ -826,10 +826,6 @@ MENU #include "../menu/drivers_display/menu_display_gl.c" #endif -#if defined(HAVE_D3D) -#include "../menu/drivers_display/menu_display_d3d.c" -#endif - #endif diff --git a/griffin/griffin_cpp.cpp b/griffin/griffin_cpp.cpp index 199c3a6024..27648fb5ea 100644 --- a/griffin/griffin_cpp.cpp +++ b/griffin/griffin_cpp.cpp @@ -39,6 +39,10 @@ MENU #include "../menu/drivers/rmenu_xui.cpp" #endif +#if defined(HAVE_D3D) +#include "../menu/drivers_display/menu_display_d3d.cpp" +#endif + /*============================================================ VIDEO CONTEXT ============================================================ */ diff --git a/menu/drivers_display/menu_display_d3d.c b/menu/drivers_display/menu_display_d3d.cpp similarity index 100% rename from menu/drivers_display/menu_display_d3d.c rename to menu/drivers_display/menu_display_d3d.cpp From 92632a4dbb8d8ba740a3ec7ea6fbcc7e247c4e57 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Mon, 9 Nov 2015 02:29:19 +0100 Subject: [PATCH 032/216] Should save font renderer API now --- gfx/font_driver.c | 7 ++++++- menu/menu_display.c | 4 ++-- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/gfx/font_driver.c b/gfx/font_driver.c index fc0a386284..781d7ba916 100644 --- a/gfx/font_driver.c +++ b/gfx/font_driver.c @@ -17,6 +17,8 @@ #include "font_driver.h" #include "../general.h" +static enum font_driver_render_api selected_api; + #ifdef HAVE_D3D static const font_renderer_t *d3d_font_backends[] = { #if defined(_XBOX1) @@ -116,7 +118,10 @@ bool font_init_first(const void **font_driver, void **font_handle, if (font_path && !font_path[0]) font_path = NULL; - switch (api) + if (selected_api != FONT_DRIVER_RENDER_DONT_CARE) + selected_api = api; + + switch (selected_api) { #ifdef HAVE_D3D case FONT_DRIVER_RENDER_DIRECT3D_API: diff --git a/menu/menu_display.c b/menu/menu_display.c index 3af39b127a..6fcffb1137 100644 --- a/menu/menu_display.c +++ b/menu/menu_display.c @@ -154,7 +154,7 @@ bool menu_display_font_init_first(const void **font_driver, pkt.data.font_init.video_data = video_data; pkt.data.font_init.font_path = font_path; pkt.data.font_init.font_size = font_size; - pkt.data.font_init.api = FONT_DRIVER_RENDER_OPENGL_API; + pkt.data.font_init.api = FONT_DRIVER_RENDER_DONT_CARE; thr->send_and_wait(thr, &pkt); @@ -162,7 +162,7 @@ bool menu_display_font_init_first(const void **font_driver, } return font_init_first(font_driver, font_handle, video_data, - font_path, font_size, FONT_DRIVER_RENDER_OPENGL_API); + font_path, font_size, FONT_DRIVER_RENDER_DONT_CARE); } bool menu_display_font_bind_block(void *data, const void *font_data, void *userdata) From c49754fc72b19c9c6bd2ded4aaad075da48f2b4d Mon Sep 17 00:00:00 2001 From: twinaphex Date: Mon, 9 Nov 2015 04:11:21 +0100 Subject: [PATCH 033/216] Revert "Should save font renderer API now" This reverts commit 92632a4dbb8d8ba740a3ec7ea6fbcc7e247c4e57. --- gfx/font_driver.c | 7 +------ menu/menu_display.c | 4 ++-- 2 files changed, 3 insertions(+), 8 deletions(-) diff --git a/gfx/font_driver.c b/gfx/font_driver.c index 781d7ba916..fc0a386284 100644 --- a/gfx/font_driver.c +++ b/gfx/font_driver.c @@ -17,8 +17,6 @@ #include "font_driver.h" #include "../general.h" -static enum font_driver_render_api selected_api; - #ifdef HAVE_D3D static const font_renderer_t *d3d_font_backends[] = { #if defined(_XBOX1) @@ -118,10 +116,7 @@ bool font_init_first(const void **font_driver, void **font_handle, if (font_path && !font_path[0]) font_path = NULL; - if (selected_api != FONT_DRIVER_RENDER_DONT_CARE) - selected_api = api; - - switch (selected_api) + switch (api) { #ifdef HAVE_D3D case FONT_DRIVER_RENDER_DIRECT3D_API: diff --git a/menu/menu_display.c b/menu/menu_display.c index 6fcffb1137..3af39b127a 100644 --- a/menu/menu_display.c +++ b/menu/menu_display.c @@ -154,7 +154,7 @@ bool menu_display_font_init_first(const void **font_driver, pkt.data.font_init.video_data = video_data; pkt.data.font_init.font_path = font_path; pkt.data.font_init.font_size = font_size; - pkt.data.font_init.api = FONT_DRIVER_RENDER_DONT_CARE; + pkt.data.font_init.api = FONT_DRIVER_RENDER_OPENGL_API; thr->send_and_wait(thr, &pkt); @@ -162,7 +162,7 @@ bool menu_display_font_init_first(const void **font_driver, } return font_init_first(font_driver, font_handle, video_data, - font_path, font_size, FONT_DRIVER_RENDER_DONT_CARE); + font_path, font_size, FONT_DRIVER_RENDER_OPENGL_API); } bool menu_display_font_bind_block(void *data, const void *font_data, void *userdata) From ed35db13e82ac531f6080bf65d7a2f69f1befbc5 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Mon, 9 Nov 2015 05:23:11 +0100 Subject: [PATCH 034/216] Fix some linking errors with CXX_BUILD --- gfx/drivers/gl.c | 1 + 1 file changed, 1 insertion(+) diff --git a/gfx/drivers/gl.c b/gfx/drivers/gl.c index ea2390d0b5..ab254a99ec 100644 --- a/gfx/drivers/gl.c +++ b/gfx/drivers/gl.c @@ -29,6 +29,7 @@ #include "../../driver.h" #include "../../performance.h" #include +#include #include #include From 4f0405980e45014a0cf0abf34b75eeeca3faaa3e Mon Sep 17 00:00:00 2001 From: twinaphex Date: Mon, 9 Nov 2015 05:24:09 +0100 Subject: [PATCH 035/216] C89_BUILD buildfix --- menu/drivers/materialui.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/menu/drivers/materialui.c b/menu/drivers/materialui.c index bacca62066..aa7ac455cf 100644 --- a/menu/drivers/materialui.c +++ b/menu/drivers/materialui.c @@ -1158,6 +1158,7 @@ static int mui_environ(menu_environ_cb_t type, void *data) static void mui_preswitch_tabs(unsigned action) { + size_t idx = 0; size_t stack_size = 0; file_list_t *menu_stack = NULL; menu_handle_t *menu = menu_driver_get_ptr(); @@ -1166,7 +1167,6 @@ static void mui_preswitch_tabs(unsigned action) if (!mui) return; - size_t idx = 0; menu_navigation_ctl(MENU_NAVIGATION_CTL_SET_SELECTION, &idx); menu_stack = menu_entries_get_menu_stack_ptr(0); From 3a9ee7feae6909728e38ecd9f230d898012304ca Mon Sep 17 00:00:00 2001 From: twinaphex Date: Mon, 9 Nov 2015 15:34:16 +0100 Subject: [PATCH 036/216] Add more d3d_wrapper functions --- gfx/d3d/d3d_wrapper.cpp | 28 ++++++++++++++++++++++------ gfx/d3d/d3d_wrapper.h | 6 ++++++ gfx/d3d/render_chain_cg.cpp | 2 ++ gfx/d3d/render_chain_xdk.cpp | 2 ++ 4 files changed, 32 insertions(+), 6 deletions(-) diff --git a/gfx/d3d/d3d_wrapper.cpp b/gfx/d3d/d3d_wrapper.cpp index 3fc422af3c..1b24bdab11 100644 --- a/gfx/d3d/d3d_wrapper.cpp +++ b/gfx/d3d/d3d_wrapper.cpp @@ -299,22 +299,38 @@ void d3d_clear(LPDIRECT3DDEVICE dev, #endif } -void d3d_lockrectangle_clear(LPDIRECT3DTEXTURE tex, +void d3d_lockrectangle(LPDIRECT3DTEXTURE tex, unsigned level, D3DLOCKED_RECT *lock_rect, RECT *rect, unsigned rectangle_height, unsigned flags) { #if defined(_XBOX) D3DTexture_LockRect(tex, level, lock_rect, rect, flags); - memset(lock_rect->pBits, 0, rectangle_height * lock_rect->Pitch); + return true; #else if (SUCCEEDED(tex->LockRect(level, lock_rect, rect, flags))) - { - memset(lock_rect->pBits, level, rectangle_height * lock_rect->Pitch); - tex->UnlockRect(0); - } + return true; + return false; #endif } +void d3d_unlockrectangle_clear(LPDIRECT3DTEXTURE tex) +{ +#ifndef _XBOX + tex->UnlockRect(0); +#endif +} + +void d3d_lockrectangle_clear(LPDIRECT3DTEXTURE tex, + unsigned level, D3DLOCKED_RECT *lock_rect, RECT *rect, + unsigned rectangle_height, unsigned flags) +{ +#if defined(_XBOX) + level = 0; +#endif + memset(lock_rect->pBits, level, rectangle_height * lock_rect->Pitch); + d3d_unlockrectangle_clear(tex); +} + void d3d_set_viewport(LPDIRECT3DDEVICE dev, D3DVIEWPORT *vp) { if (!d3d_restore_device(dev)) diff --git a/gfx/d3d/d3d_wrapper.h b/gfx/d3d/d3d_wrapper.h index 4e2c4a71e1..530c58d1c4 100644 --- a/gfx/d3d/d3d_wrapper.h +++ b/gfx/d3d/d3d_wrapper.h @@ -72,10 +72,16 @@ void d3d_clear(LPDIRECT3DDEVICE dev, unsigned count, const D3DRECT *rects, unsigned flags, D3DCOLOR color, float z, unsigned stencil); +void d3d_lockrectangle(LPDIRECT3DTEXTURE tex, + unsigned level, D3DLOCKED_RECT *lock_rect, RECT *rect, + unsigned rectangle_height, unsigned flags); + void d3d_lockrectangle_clear(LPDIRECT3DTEXTURE tex, unsigned level, D3DLOCKED_RECT *lock_rect, RECT *rect, unsigned rectangle_height, unsigned flags); +void d3d_unlockrectangle_clear(LPDIRECT3DTEXTURE tex); + void d3d_set_texture(LPDIRECT3DDEVICE dev, unsigned sampler, LPDIRECT3DTEXTURE tex); diff --git a/gfx/d3d/render_chain_cg.cpp b/gfx/d3d/render_chain_cg.cpp index 9edab74130..12b0ddc85e 100644 --- a/gfx/d3d/render_chain_cg.cpp +++ b/gfx/d3d/render_chain_cg.cpp @@ -1338,6 +1338,8 @@ static void renderchain_blit_to_texture(void *data, if (first->last_width != width || first->last_height != height) { + d3d_lockrectangle(first->tex, 0, &d3dlr, + NULL, first->info.tex_h, D3DLOCK_NOSYSLOCK); d3d_lockrectangle_clear(first->tex, 0, &d3dlr, NULL, first->info.tex_h, D3DLOCK_NOSYSLOCK); } diff --git a/gfx/d3d/render_chain_xdk.cpp b/gfx/d3d/render_chain_xdk.cpp index 91efc2ba49..6ade1b67e9 100644 --- a/gfx/d3d/render_chain_xdk.cpp +++ b/gfx/d3d/render_chain_xdk.cpp @@ -234,6 +234,8 @@ static void renderchain_blit_to_texture(void *data, const void *frame, if (chain->last_width != width || chain->last_height != height) { + d3d_lockrectangle(chain->tex, + 0, &d3dlr, NULL, chain->tex_h, D3DLOCK_NOSYSLOCK); d3d_lockrectangle_clear(chain->tex, 0, &d3dlr, NULL, chain->tex_h, D3DLOCK_NOSYSLOCK); } From 0bb7f30d6a0488ade4d0539a5bdbaffda0a68eb5 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Mon, 9 Nov 2015 15:39:47 +0100 Subject: [PATCH 037/216] Use d3d wrapper functions more --- gfx/d3d/d3d.cpp | 16 +++++++--------- gfx/d3d/d3d_wrapper.cpp | 8 ++++---- gfx/d3d/d3d_wrapper.h | 6 +++--- gfx/d3d/render_chain_cg.cpp | 4 ++-- gfx/d3d/render_chain_xdk.cpp | 4 ++-- 5 files changed, 18 insertions(+), 20 deletions(-) diff --git a/gfx/d3d/d3d.cpp b/gfx/d3d/d3d.cpp index ab334cef53..30381d8345 100644 --- a/gfx/d3d/d3d.cpp +++ b/gfx/d3d/d3d.cpp @@ -1552,8 +1552,8 @@ static bool d3d_overlay_load(void *data, return false; } - if (SUCCEEDED(overlay->tex->LockRect(0, &d3dlr, - NULL, D3DLOCK_NOSYSLOCK))) + if (d3d_lockrectangle(overlay->tex, 0, &d3dlr, + NULL, 0, D3DLOCK_NOSYSLOCK)) { uint32_t *dst = (uint32_t*)(d3dlr.pBits); const uint32_t *src = images[i].pixels; @@ -1561,7 +1561,7 @@ static bool d3d_overlay_load(void *data, for (y = 0; y < height; y++, dst += pitch, src += width) memcpy(dst, src, width << 2); - overlay->tex->UnlockRect(0); + d3d_unlock_rectangle(overlay->tex); } overlay->tex_w = width; @@ -1916,11 +1916,8 @@ static void d3d_set_menu_texture_frame(void *data, d3d->menu->alpha_mod = alpha; -#ifdef _XBOX - d3d->menu->tex->LockRect(0, &d3dlr, NULL, D3DLOCK_NOSYSLOCK); -#else - if (SUCCEEDED(d3d->menu->tex->LockRect(0, &d3dlr, NULL, D3DLOCK_NOSYSLOCK))) -#endif + if (d3d_lock_rectangle(d3d->menu->tex, 0, &d3dlr, + NULL, 0, D3DLOCK_NOSYSLOCK)) { unsigned h, w; if (rgb32) @@ -1958,8 +1955,9 @@ static void d3d_set_menu_texture_frame(void *data, } } + if (d3d->menu) - d3d->menu->tex->UnlockRect(0); + d3d_unlock_rectangle(d3d->menu->tex); } } diff --git a/gfx/d3d/d3d_wrapper.cpp b/gfx/d3d/d3d_wrapper.cpp index 1b24bdab11..bd8f85f4a0 100644 --- a/gfx/d3d/d3d_wrapper.cpp +++ b/gfx/d3d/d3d_wrapper.cpp @@ -299,7 +299,7 @@ void d3d_clear(LPDIRECT3DDEVICE dev, #endif } -void d3d_lockrectangle(LPDIRECT3DTEXTURE tex, +void d3d_lock_rectangle(LPDIRECT3DTEXTURE tex, unsigned level, D3DLOCKED_RECT *lock_rect, RECT *rect, unsigned rectangle_height, unsigned flags) { @@ -313,14 +313,14 @@ void d3d_lockrectangle(LPDIRECT3DTEXTURE tex, #endif } -void d3d_unlockrectangle_clear(LPDIRECT3DTEXTURE tex) +void d3d_unlock_rectangle(LPDIRECT3DTEXTURE tex) { #ifndef _XBOX tex->UnlockRect(0); #endif } -void d3d_lockrectangle_clear(LPDIRECT3DTEXTURE tex, +void d3d_lock_rectangle_clear(LPDIRECT3DTEXTURE tex, unsigned level, D3DLOCKED_RECT *lock_rect, RECT *rect, unsigned rectangle_height, unsigned flags) { @@ -328,7 +328,7 @@ void d3d_lockrectangle_clear(LPDIRECT3DTEXTURE tex, level = 0; #endif memset(lock_rect->pBits, level, rectangle_height * lock_rect->Pitch); - d3d_unlockrectangle_clear(tex); + d3d_unlock_rectangle(tex); } void d3d_set_viewport(LPDIRECT3DDEVICE dev, D3DVIEWPORT *vp) diff --git a/gfx/d3d/d3d_wrapper.h b/gfx/d3d/d3d_wrapper.h index 530c58d1c4..eeaabc1050 100644 --- a/gfx/d3d/d3d_wrapper.h +++ b/gfx/d3d/d3d_wrapper.h @@ -72,15 +72,15 @@ void d3d_clear(LPDIRECT3DDEVICE dev, unsigned count, const D3DRECT *rects, unsigned flags, D3DCOLOR color, float z, unsigned stencil); -void d3d_lockrectangle(LPDIRECT3DTEXTURE tex, +void d3d_lock_rectangle(LPDIRECT3DTEXTURE tex, unsigned level, D3DLOCKED_RECT *lock_rect, RECT *rect, unsigned rectangle_height, unsigned flags); -void d3d_lockrectangle_clear(LPDIRECT3DTEXTURE tex, +void d3d_lock_rectangle_clear(LPDIRECT3DTEXTURE tex, unsigned level, D3DLOCKED_RECT *lock_rect, RECT *rect, unsigned rectangle_height, unsigned flags); -void d3d_unlockrectangle_clear(LPDIRECT3DTEXTURE tex); +void d3d_unlock_rectangle(LPDIRECT3DTEXTURE tex); void d3d_set_texture(LPDIRECT3DDEVICE dev, unsigned sampler, LPDIRECT3DTEXTURE tex); diff --git a/gfx/d3d/render_chain_cg.cpp b/gfx/d3d/render_chain_cg.cpp index 12b0ddc85e..bf5482d88b 100644 --- a/gfx/d3d/render_chain_cg.cpp +++ b/gfx/d3d/render_chain_cg.cpp @@ -1338,9 +1338,9 @@ static void renderchain_blit_to_texture(void *data, if (first->last_width != width || first->last_height != height) { - d3d_lockrectangle(first->tex, 0, &d3dlr, + d3d_lock_rectangle(first->tex, 0, &d3dlr, NULL, first->info.tex_h, D3DLOCK_NOSYSLOCK); - d3d_lockrectangle_clear(first->tex, 0, &d3dlr, + d3d_lock_rectangle_clear(first->tex, 0, &d3dlr, NULL, first->info.tex_h, D3DLOCK_NOSYSLOCK); } diff --git a/gfx/d3d/render_chain_xdk.cpp b/gfx/d3d/render_chain_xdk.cpp index 6ade1b67e9..4f4ab42910 100644 --- a/gfx/d3d/render_chain_xdk.cpp +++ b/gfx/d3d/render_chain_xdk.cpp @@ -234,9 +234,9 @@ static void renderchain_blit_to_texture(void *data, const void *frame, if (chain->last_width != width || chain->last_height != height) { - d3d_lockrectangle(chain->tex, + d3d_lock_rectangle(chain->tex, 0, &d3dlr, NULL, chain->tex_h, D3DLOCK_NOSYSLOCK); - d3d_lockrectangle_clear(chain->tex, + d3d_lock_rectangle_clear(chain->tex, 0, &d3dlr, NULL, chain->tex_h, D3DLOCK_NOSYSLOCK); } From b8a5249474727a2013318c299841a194af802afc Mon Sep 17 00:00:00 2001 From: twinaphex Date: Mon, 9 Nov 2015 15:43:03 +0100 Subject: [PATCH 038/216] d3d_lock_rectangle - fix function signature --- gfx/d3d/d3d_wrapper.cpp | 2 +- gfx/d3d/d3d_wrapper.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/gfx/d3d/d3d_wrapper.cpp b/gfx/d3d/d3d_wrapper.cpp index bd8f85f4a0..a75bcaa6f9 100644 --- a/gfx/d3d/d3d_wrapper.cpp +++ b/gfx/d3d/d3d_wrapper.cpp @@ -299,7 +299,7 @@ void d3d_clear(LPDIRECT3DDEVICE dev, #endif } -void d3d_lock_rectangle(LPDIRECT3DTEXTURE tex, +bool d3d_lock_rectangle(LPDIRECT3DTEXTURE tex, unsigned level, D3DLOCKED_RECT *lock_rect, RECT *rect, unsigned rectangle_height, unsigned flags) { diff --git a/gfx/d3d/d3d_wrapper.h b/gfx/d3d/d3d_wrapper.h index eeaabc1050..cf5fa69058 100644 --- a/gfx/d3d/d3d_wrapper.h +++ b/gfx/d3d/d3d_wrapper.h @@ -72,7 +72,7 @@ void d3d_clear(LPDIRECT3DDEVICE dev, unsigned count, const D3DRECT *rects, unsigned flags, D3DCOLOR color, float z, unsigned stencil); -void d3d_lock_rectangle(LPDIRECT3DTEXTURE tex, +bool d3d_lock_rectangle(LPDIRECT3DTEXTURE tex, unsigned level, D3DLOCKED_RECT *lock_rect, RECT *rect, unsigned rectangle_height, unsigned flags); From 64bc7cbe36f5a3a1cb0660ac2833e9285260c4a4 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Mon, 9 Nov 2015 15:43:46 +0100 Subject: [PATCH 039/216] (D3D) Fix function call --- gfx/d3d/d3d.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gfx/d3d/d3d.cpp b/gfx/d3d/d3d.cpp index 30381d8345..2403c3f6e9 100644 --- a/gfx/d3d/d3d.cpp +++ b/gfx/d3d/d3d.cpp @@ -1552,7 +1552,7 @@ static bool d3d_overlay_load(void *data, return false; } - if (d3d_lockrectangle(overlay->tex, 0, &d3dlr, + if (d3d_lock_rectangle(overlay->tex, 0, &d3dlr, NULL, 0, D3DLOCK_NOSYSLOCK)) { uint32_t *dst = (uint32_t*)(d3dlr.pBits); From b5171c251a3936aa5e7c3cad6fefd07b90f8df66 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Mon, 9 Nov 2015 16:03:40 +0100 Subject: [PATCH 040/216] Not sure why this was stubbed out --- gfx/d3d/render_chain_cg.cpp | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-) diff --git a/gfx/d3d/render_chain_cg.cpp b/gfx/d3d/render_chain_cg.cpp index bf5482d88b..cd62e40faf 100644 --- a/gfx/d3d/render_chain_cg.cpp +++ b/gfx/d3d/render_chain_cg.cpp @@ -254,7 +254,6 @@ static void renderchain_set_shaders(void *data, void *fragment_data, void *verte cgD3D9BindProgram(*vPrg); } -#if 0 static void cg_d3d9_renderchain_destroy_stock_shader(void *data) { cg_renderchain_t *chain = (cg_renderchain_t*)data; @@ -280,7 +279,6 @@ static void renderchain_destroy_shader(void *data, int i) if (chain->passes[i].vPrg) cgDestroyProgram(chain->passes[i].vPrg); } -#endif static void renderchain_set_shader_mvp(void *data, void *shader_data, void *matrix_data) @@ -724,7 +722,6 @@ static void renderchain_bind_pass(void *data, void *pass_data, unsigned pass_ind } } -#if 0 static void cg_d3d9_renderchain_clear(void *data) { unsigned i; @@ -757,7 +754,6 @@ static void cg_d3d9_renderchain_clear(void *data) chain->passes.clear(); chain->luts.clear(); } -#endif static void cg_d3d9_renderchain_deinit_shader(void *data) { @@ -771,7 +767,6 @@ static void cg_d3d9_renderchain_deinit_shader(void *data) chain->cgCtx = NULL; } -#if 0 static void cg_d3d9_renderchain_deinit(void *data) { cg_renderchain_t *renderchain = (cg_renderchain_t*)data; @@ -779,7 +774,6 @@ static void cg_d3d9_renderchain_deinit(void *data) if (renderchain) free(renderchain); } -#endif void cg_d3d9_renderchain_free(void *data) { @@ -789,13 +783,11 @@ void cg_d3d9_renderchain_free(void *data) return; cg_d3d9_renderchain_deinit_shader(chain); -#if 0 cg_d3d9_renderchain_clear(chain); cg_d3d9_renderchain_destroy_stock_shader(chain); if (chain->tracker) state_tracker_free(chain->tracker); -#endif - //cg_d3d9_renderchain_deinit(); + cg_d3d9_renderchain_deinit(); } void *cg_d3d9_renderchain_new(void) From 5d155860cb7b2e7de73436539062d4229606f00d Mon Sep 17 00:00:00 2001 From: twinaphex Date: Mon, 9 Nov 2015 16:04:33 +0100 Subject: [PATCH 041/216] (D3D) Buildfix --- gfx/d3d/render_chain_cg.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gfx/d3d/render_chain_cg.cpp b/gfx/d3d/render_chain_cg.cpp index cd62e40faf..18cf5255b5 100644 --- a/gfx/d3d/render_chain_cg.cpp +++ b/gfx/d3d/render_chain_cg.cpp @@ -787,7 +787,7 @@ void cg_d3d9_renderchain_free(void *data) cg_d3d9_renderchain_destroy_stock_shader(chain); if (chain->tracker) state_tracker_free(chain->tracker); - cg_d3d9_renderchain_deinit(); + cg_d3d9_renderchain_deinit(chain); } void *cg_d3d9_renderchain_new(void) From ffed38fbf35547b7ea21d709afd36b0e43bea80f Mon Sep 17 00:00:00 2001 From: twinaphex Date: Mon, 9 Nov 2015 17:03:25 +0100 Subject: [PATCH 042/216] (render_chain_cg.cpp) Stop abusing void pointers --- gfx/d3d/render_chain_cg.cpp | 138 ++++++++++++++++-------------------- 1 file changed, 63 insertions(+), 75 deletions(-) diff --git a/gfx/d3d/render_chain_cg.cpp b/gfx/d3d/render_chain_cg.cpp index 18cf5255b5..56bc971fdf 100644 --- a/gfx/d3d/render_chain_cg.cpp +++ b/gfx/d3d/render_chain_cg.cpp @@ -88,14 +88,14 @@ static INLINE D3DTEXTUREFILTERTYPE translate_filter(unsigned type) switch (type) { - case RARCH_FILTER_UNSPEC: - return settings->video.smooth ? D3DTEXF_LINEAR : D3DTEXF_POINT; - case RARCH_FILTER_LINEAR: - return D3DTEXF_LINEAR; - case RARCH_FILTER_NEAREST: - return D3DTEXF_POINT; + case RARCH_FILTER_UNSPEC: + return settings->video.smooth ? D3DTEXF_LINEAR : D3DTEXF_POINT; + case RARCH_FILTER_LINEAR: + return D3DTEXF_LINEAR; + case RARCH_FILTER_NEAREST: + return D3DTEXF_POINT; } - + return D3DTEXF_POINT; } @@ -191,12 +191,11 @@ static INLINE CGparameter find_param_from_semantic(CGprogram prog, return find_param_from_semantic(param, sem); } -static bool renderchain_compile_shaders(void *data, +static bool renderchain_compile_shaders(cg_renderchain_t *chain, void *fragment_data, void *vertex_data, const std::string &shader) { CGprogram *fPrg = (CGprogram*)fragment_data; CGprogram *vPrg = (CGprogram*)vertex_data; - cg_renderchain_t *chain = (cg_renderchain_t*)data; CGprofile vertex_profile = cgD3D9GetLatestVertexProfile(); CGprofile fragment_profile = cgD3D9GetLatestPixelProfile(); const char **fragment_opts = cgD3D9GetOptimalOptions(fragment_profile); @@ -267,10 +266,8 @@ static void cg_d3d9_renderchain_destroy_stock_shader(void *data) cgDestroyProgram(chain->vStock); } -static void renderchain_destroy_shader(void *data, int i) +static void renderchain_destroy_shader(cg_renderchain_t *chain, int i) { - cg_renderchain_t *chain = (cg_renderchain_t*)data; - if (!chain) return; @@ -281,7 +278,7 @@ static void renderchain_destroy_shader(void *data, int i) } -static void renderchain_set_shader_mvp(void *data, void *shader_data, void *matrix_data) +static void renderchain_set_shader_mvp(cg_renderchain_t *chain, void *shader_data, void *matrix_data) { CGprogram *vPrg = (CGprogram*)shader_data; const D3DXMATRIX *matrix = (const D3DXMATRIX*)matrix_data; @@ -296,15 +293,18 @@ static void renderchain_set_shader_mvp(void *data, void *shader_data, void *matr cgD3D9SetUniform(cgp, &val); \ } while(0) -static void renderchain_set_shader_params(void *data, void *pass_data, - unsigned video_w, unsigned video_h, - unsigned tex_w, unsigned tex_h, - unsigned viewport_w, unsigned viewport_h) +static void renderchain_set_shader_params(cg_renderchain_t *chain, + Pass *pass, + unsigned video_w, unsigned video_h, + unsigned tex_w, unsigned tex_h, + unsigned viewport_w, unsigned viewport_h) { float frame_cnt; D3DXVECTOR2 video_size, texture_size, output_size; - Pass *pass = (Pass*)pass_data; - cg_renderchain_t *chain = (cg_renderchain_t*)data; + + if (!chain || !pass) + return; + video_size.x = video_w; video_size.y = video_h; texture_size.x = tex_w; @@ -328,12 +328,11 @@ static void renderchain_set_shader_params(void *data, void *pass_data, set_cg_param(pass->vPrg, "IN.frame_count", frame_cnt); } -static void renderchain_bind_tracker(void *data, void *pass_data, unsigned pass_index) +static void renderchain_bind_tracker(cg_renderchain_t *chain, + Pass *pass, unsigned pass_index) { unsigned i; - Pass *pass = (Pass*)pass_data; - cg_renderchain_t *chain = (cg_renderchain_t*)data; - if (!chain->tracker) + if (!chain || !chain->tracker || !pass) return; if (pass_index == 1) @@ -367,8 +366,8 @@ static bool cg_d3d9_renderchain_init_shader_fvf(void *data, void *pass_data) bool texcoord0_taken = false; bool texcoord1_taken = false; bool stream_taken[4] = {false}; + cg_renderchain_t *chain = (cg_renderchain_t*)data; Pass *pass = (Pass*)pass_data; - cg_renderchain_t *chain = (cg_renderchain_t*)data; static const D3DVERTEXELEMENT decl_end = D3DDECL_END(); static const D3DVERTEXELEMENT position_decl = DECL_FVF_POSITION(0); static const D3DVERTEXELEMENT tex_coord0 = DECL_FVF_TEXCOORD(1, 3, 0); @@ -493,13 +492,12 @@ static bool cg_d3d9_renderchain_init_shader_fvf(void *data, void *pass_data) return true; } -static void renderchain_bind_orig(void *data, void *pass_data) +static void renderchain_bind_orig(cg_renderchain_t *chain, void *pass_data) { unsigned index; CGparameter param; D3DXVECTOR2 video_size, texture_size; Pass *pass = (Pass*)pass_data; - cg_renderchain_t *chain = (cg_renderchain_t*)data; video_size.x = chain->passes[0].last_width; video_size.y = chain->passes[0].last_height; texture_size.x = chain->passes[0].info.tex_w; @@ -534,7 +532,7 @@ static void renderchain_bind_orig(void *data, void *pass_data) } } -static void renderchain_bind_prev(void *data, void *pass_data) +static void renderchain_bind_prev(cg_renderchain_t *chain, void *pass_data) { unsigned i, index; D3DXVECTOR2 texture_size; @@ -543,7 +541,6 @@ static void renderchain_bind_prev(void *data, void *pass_data) char attr_tex_size[64] = {0}; char attr_coord[64] = {0}; Pass *pass = (Pass*)pass_data; - cg_renderchain_t *chain = (cg_renderchain_t*)data; static const char *prev_names[] = { "PREV", "PREV1", @@ -599,11 +596,11 @@ static void renderchain_bind_prev(void *data, void *pass_data) param = cgGetNamedParameter(pass->vPrg, attr_coord); if (param) { - LPDIRECT3DVERTEXBUFFER vert_buf; + LPDIRECT3DVERTEXBUFFER vert_buf = (LPDIRECT3DVERTEXBUFFER) + chain->prev.vertex_buf[(chain->prev.ptr - (i + 1)) & TEXTURESMASK]; index = pass->attrib_map[cgGetParameterResourceIndex(param)]; - vert_buf = (LPDIRECT3DVERTEXBUFFER) - chain->prev.vertex_buf[(chain->prev.ptr - (i + 1)) & TEXTURESMASK]; + chain->bound_vert.push_back(index); d3d_set_stream_source(chain->dev, index, vert_buf, 0, sizeof(Vertex)); @@ -628,11 +625,10 @@ static void cg_d3d9_renderchain_add_lut(void *data, chain->bound_tex.push_back(index); } -static void renderchain_bind_luts(void *data, void *pass_data) +static void renderchain_bind_luts(cg_renderchain_t *chain, + Pass *pass) { unsigned i, index; - Pass *pass = (Pass*)pass_data; - cg_renderchain_t *chain = (cg_renderchain_t*)data; for (i = 0; i < chain->luts.size(); i++) { @@ -659,11 +655,10 @@ static void renderchain_bind_luts(void *data, void *pass_data) } } -static void renderchain_bind_pass(void *data, void *pass_data, unsigned pass_index) +static void renderchain_bind_pass(cg_renderchain_t *chain, + Pass *pass, unsigned pass_index) { unsigned i, index; - Pass *pass = (Pass*)pass_data; - cg_renderchain_t *chain = (cg_renderchain_t*)data; /* We only bother binding passes which are two indices behind. */ if (pass_index < 3) @@ -722,10 +717,9 @@ static void renderchain_bind_pass(void *data, void *pass_data, unsigned pass_ind } } -static void cg_d3d9_renderchain_clear(void *data) +static void cg_d3d9_renderchain_clear(cg_renderchain_t *chain) { unsigned i; - cg_renderchain_t *chain = (cg_renderchain_t*)data; for (i = 0; i < TEXTURES; i++) { @@ -755,10 +749,9 @@ static void cg_d3d9_renderchain_clear(void *data) chain->luts.clear(); } -static void cg_d3d9_renderchain_deinit_shader(void *data) +static void cg_d3d9_renderchain_deinit_shader(cg_renderchain_t *chain) { - cg_renderchain_t *chain = (cg_renderchain_t*)data; - if (!chain->cgCtx) + if (!chain || !chain->cgCtx) return; cgD3D9UnloadAllPrograms(); @@ -767,12 +760,10 @@ static void cg_d3d9_renderchain_deinit_shader(void *data) chain->cgCtx = NULL; } -static void cg_d3d9_renderchain_deinit(void *data) +static void cg_d3d9_renderchain_deinit(cg_renderchain_t *chain) { - cg_renderchain_t *renderchain = (cg_renderchain_t*)data; - - if (renderchain) - free(renderchain); + if (chain) + free(chain); } void cg_d3d9_renderchain_free(void *data) @@ -790,7 +781,7 @@ void cg_d3d9_renderchain_free(void *data) cg_d3d9_renderchain_deinit(chain); } -void *cg_d3d9_renderchain_new(void) +static void *cg_d3d9_renderchain_new(void) { cg_renderchain_t *renderchain = (cg_renderchain_t*)calloc(1, sizeof(*renderchain)); if (!renderchain) @@ -820,7 +811,6 @@ static bool cg_d3d9_renderchain_init_shader(void *data, return true; } - static void renderchain_log_info(void *data, const void *info_data) { const LinkInfo *info = (const LinkInfo*)info_data; @@ -866,14 +856,12 @@ static void renderchain_log_info(void *data, const void *info_data) info->pass->filter == RARCH_FILTER_LINEAR ? "true" : "false"); } -static bool renderchain_create_first_pass(void *data, const void *info_data, - unsigned fmt) +static bool renderchain_create_first_pass(cg_renderchain_t *chain, + const LinkInfo *info, unsigned fmt) { unsigned i; Pass pass; D3DXMATRIX ident; - const LinkInfo *info = (const LinkInfo*)info_data; - cg_renderchain_t *chain = (cg_renderchain_t*)data; LPDIRECT3DDEVICE d3dr = NULL; if (!chain) @@ -958,10 +946,9 @@ static bool cg_d3d9_renderchain_init(void *data, return true; } -static bool renderchain_set_pass_size(void *data, unsigned pass_index, - unsigned width, unsigned height) +static bool renderchain_set_pass_size(cg_renderchain_t *chain, + unsigned pass_index, unsigned width, unsigned height) { - cg_renderchain_t *chain = (cg_renderchain_t*)data; LPDIRECT3DDEVICE d3dr = chain->dev; Pass *pass = (Pass*)&chain->passes[pass_index]; @@ -1035,8 +1022,8 @@ static void cg_d3d9_renderchain_convert_geometry( } } -static void d3d_recompute_pass_sizes(d3d_video_t *d3d, - void *renderchain_data) +static void d3d_recompute_pass_sizes(cg_renderchain_t *chain, + d3d_video_t *d3d) { unsigned i; LinkInfo link_info = {0}; @@ -1048,7 +1035,6 @@ static void d3d_recompute_pass_sizes(d3d_video_t *d3d, unsigned current_height = link_info.tex_h; unsigned out_width = 0; unsigned out_height = 0; - cg_renderchain_t *chain = (cg_renderchain_t*)renderchain_data; if (!renderchain_set_pass_size(chain, 0, current_width, current_height)) @@ -1091,7 +1077,7 @@ static void cg_d3d9_renderchain_set_final_viewport(void *data, if (chain) chain->final_viewport = (D3DVIEWPORT*)final_viewport; - d3d_recompute_pass_sizes(d3d, chain); + d3d_recompute_pass_sizes(chain, d3d); } static bool cg_d3d9_renderchain_add_pass(void *data, const void *info_data) @@ -1186,10 +1172,8 @@ static void cg_d3d9_renderchain_add_state_tracker( chain->tracker = tracker; } -static void renderchain_start_render(void *data) +static void renderchain_start_render(cg_renderchain_t *chain) { - cg_renderchain_t *chain = (cg_renderchain_t*)data; - if (!chain) return; @@ -1199,10 +1183,8 @@ static void renderchain_start_render(void *data) chain->passes[0].last_height = chain->prev.last_height[chain->prev.ptr]; } -static void renderchain_end_render(void *data) +static void renderchain_end_render(cg_renderchain_t *chain) { - cg_renderchain_t *chain = (cg_renderchain_t*)data; - if (!chain) return; @@ -1211,13 +1193,14 @@ static void renderchain_end_render(void *data) chain->prev.ptr = (chain->prev.ptr + 1) & TEXTURESMASK; } -static void renderchain_set_mvp(void *data, void *vertex_program, +static void renderchain_set_mvp( + cg_renderchain_t *chain, + void *vertex_program, unsigned vp_width, unsigned vp_height, unsigned rotation) { D3DXMATRIX proj, ortho, rot, tmp; CGprogram vPrg = (CGprogram)vertex_program; - cg_renderchain_t *chain = (cg_renderchain_t*)data; if (!chain) return; @@ -1233,14 +1216,13 @@ static void renderchain_set_mvp(void *data, void *vertex_program, } static void renderchain_set_vertices( - void *data, void *pass_data, + cg_renderchain_t *chain, + Pass *pass, unsigned width, unsigned height, unsigned out_width, unsigned out_height, unsigned vp_width, unsigned vp_height, unsigned rotation) { - Pass *pass = (Pass*)pass_data; - cg_renderchain_t *chain = (cg_renderchain_t*)data; const LinkInfo *info = (const LinkInfo*)&pass->info; if (pass->last_width != width || pass->last_height != height) @@ -1365,12 +1347,18 @@ static void renderchain_unbind_all(void *data) chain->bound_vert.clear(); } -static void renderchain_render_pass(void *data, void *pass_data, unsigned pass_index) +static void renderchain_render_pass( + cg_renderchain_t *chain, + Pass *pass, + unsigned pass_index) { unsigned i; - Pass *pass = (Pass*)pass_data; - cg_renderchain_t *chain = (cg_renderchain_t*)data; - LPDIRECT3DDEVICE d3dr = (LPDIRECT3DDEVICE)chain->dev; + LPDIRECT3DDEVICE d3dr; + + if (!chain) + return; + + d3dr = (LPDIRECT3DDEVICE)chain->dev; renderchain_set_shaders(chain, &pass->fPrg, &pass->vPrg); From 4f0be8bcb063be11823cdc33978f7ecc4be51547 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Mon, 9 Nov 2015 17:18:21 +0100 Subject: [PATCH 043/216] (D3D/renderchain_cg) More cleanups --- gfx/d3d/render_chain_cg.cpp | 39 ++++++++++++++++++++++++------------- 1 file changed, 26 insertions(+), 13 deletions(-) diff --git a/gfx/d3d/render_chain_cg.cpp b/gfx/d3d/render_chain_cg.cpp index 56bc971fdf..69e9ad4e4a 100644 --- a/gfx/d3d/render_chain_cg.cpp +++ b/gfx/d3d/render_chain_cg.cpp @@ -717,6 +717,23 @@ static void renderchain_bind_pass(cg_renderchain_t *chain, } } +static void cg_d3d9_renderchain_clear_passes(cg_renderchain_t *chain) +{ + unsigned i; + if (chain->passes.size() == 0) + return; + + d3d_vertex_buffer_free(NULL, chain->passes[0].vertex_decl); + + for (i = 1; i < chain->passes.size(); i++) + { + if (chain->passes[i].tex) + d3d_texture_free(chain->passes[i].tex); + d3d_vertex_buffer_free(chain->passes[i].vertex_buf, chain->passes[i].vertex_decl); + renderchain_destroy_shader(chain, i); + } +} + static void cg_d3d9_renderchain_clear(cg_renderchain_t *chain) { unsigned i; @@ -729,15 +746,7 @@ static void cg_d3d9_renderchain_clear(cg_renderchain_t *chain) d3d_vertex_buffer_free(chain->prev.vertex_buf[i], NULL); } - d3d_vertex_buffer_free(NULL, chain->passes[0].vertex_decl); - - for (i = 1; i < chain->passes.size(); i++) - { - if (chain->passes[i].tex) - d3d_texture_free(chain->passes[i].tex); - d3d_vertex_buffer_free(chain->passes[i].vertex_buf, chain->passes[i].vertex_decl); - renderchain_destroy_shader(chain, i); - } + cg_d3d9_renderchain_clear_passes(chain); for (i = 0; i < chain->luts.size(); i++) { @@ -745,6 +754,12 @@ static void cg_d3d9_renderchain_clear(cg_renderchain_t *chain) d3d_texture_free(chain->luts[i].tex); } +#if 0 + if (chain->tracker) + state_tracker_free(chain->tracker); + chain->tracker = NULL; +#endif + chain->passes.clear(); chain->luts.clear(); } @@ -773,11 +788,9 @@ void cg_d3d9_renderchain_free(void *data) if (!chain) return; - cg_d3d9_renderchain_deinit_shader(chain); cg_d3d9_renderchain_clear(chain); + cg_d3d9_renderchain_deinit_shader(chain); cg_d3d9_renderchain_destroy_stock_shader(chain); - if (chain->tracker) - state_tracker_free(chain->tracker); cg_d3d9_renderchain_deinit(chain); } @@ -805,7 +818,7 @@ static bool cg_d3d9_renderchain_init_shader(void *data, RARCH_LOG("[D3D]: Created shader context.\n"); - HRESULT ret = cgD3D9SetDevice(d3d->dev); + HRESULT ret = cgD3D9SetDevice((IDirect3DDevice9*)d3d->dev); if (FAILED(ret)) return false; return true; From f90bd168251cdfba2f24ef26c38e6cba09f7aa48 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Mon, 9 Nov 2015 18:56:24 +0100 Subject: [PATCH 044/216] Move releasing of devices to d3d_deinitialize --- gfx/d3d/d3d.cpp | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/gfx/d3d/d3d.cpp b/gfx/d3d/d3d.cpp index 2403c3f6e9..d85f6713f0 100644 --- a/gfx/d3d/d3d.cpp +++ b/gfx/d3d/d3d.cpp @@ -113,6 +113,12 @@ static void d3d_deinitialize(d3d_video_t *d3d) #ifndef _XBOX d3d->needs_restore = false; #endif + if (d3d->dev) + d3d->dev->Release(); + if (d3d->g_pD3D) + d3d->g_pD3D->Release(); + d3d->dev = NULL; + d3d->g_pD3D = NULL; } void d3d_make_d3dpp(void *data, @@ -318,8 +324,6 @@ static bool d3d_initialize(d3d_video_t *d3d, const video_info_t *info) RARCH_WARN("[D3D]: Attempting to recover from dead state.\n"); #endif d3d_deinitialize(d3d); - d3d->g_pD3D->Release(); - d3d->g_pD3D = NULL; ret = d3d_init_base(d3d, info); if (ret) RARCH_LOG("[D3D]: Recovered from dead state.\n"); @@ -857,7 +861,6 @@ static void d3d_free(void *data) if (!d3d) return; - d3d_deinitialize(d3d); #ifdef HAVE_OVERLAY d3d_free_overlays(d3d); #endif @@ -871,10 +874,7 @@ static void d3d_free(void *data) #endif #endif - if (d3d->dev) - d3d->dev->Release(); - if (d3d->g_pD3D) - d3d->g_pD3D->Release(); + d3d_deinitialize(d3d); #ifdef HAVE_MONITOR monitor_last = MonitorFromWindow(d3d->hWnd, From 4fbebb57df433c7384ea690766e5cc2eabc70771 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Mon, 9 Nov 2015 19:01:24 +0100 Subject: [PATCH 045/216] Revert "Move releasing of devices to d3d_deinitialize" This reverts commit f90bd168251cdfba2f24ef26c38e6cba09f7aa48. --- gfx/d3d/d3d.cpp | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/gfx/d3d/d3d.cpp b/gfx/d3d/d3d.cpp index d85f6713f0..2403c3f6e9 100644 --- a/gfx/d3d/d3d.cpp +++ b/gfx/d3d/d3d.cpp @@ -113,12 +113,6 @@ static void d3d_deinitialize(d3d_video_t *d3d) #ifndef _XBOX d3d->needs_restore = false; #endif - if (d3d->dev) - d3d->dev->Release(); - if (d3d->g_pD3D) - d3d->g_pD3D->Release(); - d3d->dev = NULL; - d3d->g_pD3D = NULL; } void d3d_make_d3dpp(void *data, @@ -324,6 +318,8 @@ static bool d3d_initialize(d3d_video_t *d3d, const video_info_t *info) RARCH_WARN("[D3D]: Attempting to recover from dead state.\n"); #endif d3d_deinitialize(d3d); + d3d->g_pD3D->Release(); + d3d->g_pD3D = NULL; ret = d3d_init_base(d3d, info); if (ret) RARCH_LOG("[D3D]: Recovered from dead state.\n"); @@ -861,6 +857,7 @@ static void d3d_free(void *data) if (!d3d) return; + d3d_deinitialize(d3d); #ifdef HAVE_OVERLAY d3d_free_overlays(d3d); #endif @@ -874,7 +871,10 @@ static void d3d_free(void *data) #endif #endif - d3d_deinitialize(d3d); + if (d3d->dev) + d3d->dev->Release(); + if (d3d->g_pD3D) + d3d->g_pD3D->Release(); #ifdef HAVE_MONITOR monitor_last = MonitorFromWindow(d3d->hWnd, From 9f6e273e6a49c8f6ff806fa23472b683b1f30997 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Mon, 9 Nov 2015 19:08:57 +0100 Subject: [PATCH 046/216] (D3D) Buildfix --- gfx/d3d/d3d.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gfx/d3d/d3d.cpp b/gfx/d3d/d3d.cpp index 2403c3f6e9..cfe1043fc5 100644 --- a/gfx/d3d/d3d.cpp +++ b/gfx/d3d/d3d.cpp @@ -90,7 +90,7 @@ static unsigned monitor_count; static void d3d_deinit_chain(d3d_video_t *d3d) { - d3d->renderchain_driver->chain_free(d3d); + d3d->renderchain_driver->chain_free(d3d->renderchain_data); d3d->renderchain_driver = NULL; d3d->renderchain_data = NULL; From f277fd53231d05908e793f8484606599f0509198 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Mon, 9 Nov 2015 19:35:59 +0100 Subject: [PATCH 047/216] Don't do overloading of translate_filter --- gfx/d3d/render_chain_cg.cpp | 17 ++++++----------- 1 file changed, 6 insertions(+), 11 deletions(-) diff --git a/gfx/d3d/render_chain_cg.cpp b/gfx/d3d/render_chain_cg.cpp index 69e9ad4e4a..34e0f1e242 100644 --- a/gfx/d3d/render_chain_cg.cpp +++ b/gfx/d3d/render_chain_cg.cpp @@ -89,23 +89,18 @@ static INLINE D3DTEXTUREFILTERTYPE translate_filter(unsigned type) switch (type) { case RARCH_FILTER_UNSPEC: - return settings->video.smooth ? D3DTEXF_LINEAR : D3DTEXF_POINT; + if (!settings->video.smooth) + break; + /* fall-through */ case RARCH_FILTER_LINEAR: return D3DTEXF_LINEAR; case RARCH_FILTER_NEAREST: - return D3DTEXF_POINT; + break; } return D3DTEXF_POINT; } -static INLINE D3DTEXTUREFILTERTYPE translate_filter(bool smooth) -{ - if (smooth) - return D3DTEXF_LINEAR; - return D3DTEXF_POINT; -} - static const char *stock_program = "void main_vertex" "(" @@ -617,9 +612,9 @@ static void cg_d3d9_renderchain_add_lut(void *data, d3d_set_texture(chain->dev, index, chain->luts[i].tex); d3d_set_sampler_magfilter(chain->dev, index, - translate_filter(chain->luts[i].smooth)); + translate_filter(chain->luts[i].smooth ? RARCH_FILTER_LINEAR : RARCH_FILTER_NEAREST)); d3d_set_sampler_minfilter(chain->dev, index, - translate_filter(chain->luts[i].smooth)); + translate_filter(chain->luts[i].smooth ? RARCH_FILTER_LINEAR : RARCH_FILTER_NEAREST)); d3d_set_sampler_address_u(chain->dev, index, D3DTADDRESS_BORDER); d3d_set_sampler_address_v(chain->dev, index, D3DTADDRESS_BORDER); chain->bound_tex.push_back(index); From b46ae033ab7d0f0e4dd858737a8ae49ffcd1b4a1 Mon Sep 17 00:00:00 2001 From: thedax Date: Mon, 9 Nov 2015 15:23:36 -0500 Subject: [PATCH 048/216] 3DS: Fix compilation for great-refactor. exitCfgu/initCfgu changed to cfguInit/cfguExit. https://github.com/smealum/ctrulib/commit/2797540a3dabf262be9701300631685e0de1696c --- frontend/drivers/platform_ctr.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/frontend/drivers/platform_ctr.c b/frontend/drivers/platform_ctr.c index 2cb36abed2..6311ae5976 100644 --- a/frontend/drivers/platform_ctr.c +++ b/frontend/drivers/platform_ctr.c @@ -151,7 +151,7 @@ static void frontend_ctr_deinit(void *data) svcCloseHandle(lcd_handle); } - exitCfgu(); + cfguExit(); ndspExit(); csndExit(); gfxExit(); @@ -244,7 +244,7 @@ static void frontend_ctr_init(void *data) ctr_check_dspfirm(); if(ndspInit() != 0) *dsp_audio_driver = audio_null; - initCfgu(); + cfguInit(); #endif } From 02d61bf992f42b291d1d0915258b88922ef20c96 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Mon, 9 Nov 2015 22:04:45 +0100 Subject: [PATCH 049/216] (D3D) Don't use std::vector for attrib_map --- gfx/d3d/render_chain_cg.cpp | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/gfx/d3d/render_chain_cg.cpp b/gfx/d3d/render_chain_cg.cpp index 34e0f1e242..827a485f61 100644 --- a/gfx/d3d/render_chain_cg.cpp +++ b/gfx/d3d/render_chain_cg.cpp @@ -53,7 +53,7 @@ struct Pass CGprogram vPrg, fPrg; unsigned last_width, last_height; LPDIRECT3DVERTEXDECLARATION vertex_decl; - std::vector attrib_map; + unsigned *attrib_map[MAXD3DDECLLENGTH]; }; typedef struct cg_renderchain @@ -458,12 +458,12 @@ static bool cg_d3d9_renderchain_init_shader_fvf(void *data, void *pass_data) for (i = 0; i < count; i++) { if (indices[i]) - pass->attrib_map.push_back(0); + pass->attrib_map[i] = 0; else { D3DVERTEXELEMENT elem = DECL_FVF_TEXCOORD(index, 3, tex_index); - pass->attrib_map.push_back(index); + pass->attrib_map[i] = index; decl[i] = elem; @@ -722,11 +722,21 @@ static void cg_d3d9_renderchain_clear_passes(cg_renderchain_t *chain) for (i = 1; i < chain->passes.size(); i++) { + unsigned j; if (chain->passes[i].tex) d3d_texture_free(chain->passes[i].tex); + + for (j = 0; j < MAXD3DDECLLENGTH; j++) + { + if (chain->passes[i].attrib_map[j]) + free(chain->passes[i].attrib_map[j]); + chain->passes[i].attrib_map[j] = NULL; + } + d3d_vertex_buffer_free(chain->passes[i].vertex_buf, chain->passes[i].vertex_decl); renderchain_destroy_shader(chain, i); } + } static void cg_d3d9_renderchain_clear(cg_renderchain_t *chain) @@ -786,6 +796,7 @@ void cg_d3d9_renderchain_free(void *data) cg_d3d9_renderchain_clear(chain); cg_d3d9_renderchain_deinit_shader(chain); cg_d3d9_renderchain_destroy_stock_shader(chain); + cg_d3d9_renderchain_deinit(chain); } @@ -888,6 +899,9 @@ static bool renderchain_create_first_pass(cg_renderchain_t *chain, chain->prev.ptr = 0; + for (i = 0; i < MAXD3DDECLLENGTH; i++) + pass.attrib_map[i] = (unsigned*)calloc(1, sizeof(unsigned)); + for (i = 0; i < TEXTURES; i++) { chain->prev.last_width[i] = 0; From 40aa2a1864795b788a1b01d35de7e0b6b2656e5e Mon Sep 17 00:00:00 2001 From: twinaphex Date: Mon, 9 Nov 2015 22:07:44 +0100 Subject: [PATCH 050/216] Revert "(D3D) Don't use std::vector for attrib_map" This reverts commit 02d61bf992f42b291d1d0915258b88922ef20c96. --- gfx/d3d/render_chain_cg.cpp | 20 +++----------------- 1 file changed, 3 insertions(+), 17 deletions(-) diff --git a/gfx/d3d/render_chain_cg.cpp b/gfx/d3d/render_chain_cg.cpp index 827a485f61..34e0f1e242 100644 --- a/gfx/d3d/render_chain_cg.cpp +++ b/gfx/d3d/render_chain_cg.cpp @@ -53,7 +53,7 @@ struct Pass CGprogram vPrg, fPrg; unsigned last_width, last_height; LPDIRECT3DVERTEXDECLARATION vertex_decl; - unsigned *attrib_map[MAXD3DDECLLENGTH]; + std::vector attrib_map; }; typedef struct cg_renderchain @@ -458,12 +458,12 @@ static bool cg_d3d9_renderchain_init_shader_fvf(void *data, void *pass_data) for (i = 0; i < count; i++) { if (indices[i]) - pass->attrib_map[i] = 0; + pass->attrib_map.push_back(0); else { D3DVERTEXELEMENT elem = DECL_FVF_TEXCOORD(index, 3, tex_index); - pass->attrib_map[i] = index; + pass->attrib_map.push_back(index); decl[i] = elem; @@ -722,21 +722,11 @@ static void cg_d3d9_renderchain_clear_passes(cg_renderchain_t *chain) for (i = 1; i < chain->passes.size(); i++) { - unsigned j; if (chain->passes[i].tex) d3d_texture_free(chain->passes[i].tex); - - for (j = 0; j < MAXD3DDECLLENGTH; j++) - { - if (chain->passes[i].attrib_map[j]) - free(chain->passes[i].attrib_map[j]); - chain->passes[i].attrib_map[j] = NULL; - } - d3d_vertex_buffer_free(chain->passes[i].vertex_buf, chain->passes[i].vertex_decl); renderchain_destroy_shader(chain, i); } - } static void cg_d3d9_renderchain_clear(cg_renderchain_t *chain) @@ -796,7 +786,6 @@ void cg_d3d9_renderchain_free(void *data) cg_d3d9_renderchain_clear(chain); cg_d3d9_renderchain_deinit_shader(chain); cg_d3d9_renderchain_destroy_stock_shader(chain); - cg_d3d9_renderchain_deinit(chain); } @@ -899,9 +888,6 @@ static bool renderchain_create_first_pass(cg_renderchain_t *chain, chain->prev.ptr = 0; - for (i = 0; i < MAXD3DDECLLENGTH; i++) - pass.attrib_map[i] = (unsigned*)calloc(1, sizeof(unsigned)); - for (i = 0; i < TEXTURES; i++) { chain->prev.last_width[i] = 0; From 2b59f18b83c1ff00432fc4da285e8b6195e26797 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Mon, 9 Nov 2015 22:12:32 +0100 Subject: [PATCH 051/216] Add function pointer for font_init_first --- menu/drivers_display/menu_display_d3d.cpp | 36 +++++++++++++++++++++++ menu/drivers_display/menu_display_gl.c | 36 +++++++++++++++++++++++ menu/drivers_display/menu_display_null.c | 8 +++++ menu/menu_display.c | 10 +++++-- menu/menu_display.h | 3 ++ 5 files changed, 91 insertions(+), 2 deletions(-) diff --git a/menu/drivers_display/menu_display_d3d.cpp b/menu/drivers_display/menu_display_d3d.cpp index 44436cd8a1..bb176be6ca 100644 --- a/menu/drivers_display/menu_display_d3d.cpp +++ b/menu/drivers_display/menu_display_d3d.cpp @@ -234,6 +234,41 @@ static const float *menu_display_d3d_get_tex_coords(void) return &d3d_tex_coords[0]; } +static bool menu_display_d3d_font_init_first(const void **font_driver, + void **font_handle, void *video_data, const char *font_path, + float font_size) +{ + settings_t *settings = config_get_ptr(); + const struct retro_hw_render_callback *hw_render = + (const struct retro_hw_render_callback*)video_driver_callback(); + + if (settings->video.threaded && !hw_render->context_type) + { + thread_packet_t pkt; + driver_t *driver = driver_get_ptr(); + thread_video_t *thr = (thread_video_t*)driver->video_data; + + if (!thr) + return false; + + pkt.type = CMD_FONT_INIT; + pkt.data.font_init.method = font_init_first; + pkt.data.font_init.font_driver = (const void**)font_driver; + pkt.data.font_init.font_handle = font_handle; + pkt.data.font_init.video_data = video_data; + pkt.data.font_init.font_path = font_path; + pkt.data.font_init.font_size = font_size; + pkt.data.font_init.api = FONT_DRIVER_RENDER_DIRECT3D_API; + + thr->send_and_wait(thr, &pkt); + + return pkt.data.font_init.return_value; + } + + return font_init_first(font_driver, font_handle, video_data, + font_path, font_size, FONT_DRIVER_RENDER_DIRECT3D_API); +} + menu_display_ctx_driver_t menu_display_ctx_d3d = { menu_display_d3d_draw, menu_display_d3d_draw_bg, @@ -245,6 +280,7 @@ menu_display_ctx_driver_t menu_display_ctx_d3d = { menu_display_d3d_get_tex_coords, menu_display_d3d_texture_load, menu_display_d3d_texture_unload, + menu_display_d3d_font_init_first, MENU_VIDEO_DRIVER_DIRECT3D, "menu_display_d3d", }; diff --git a/menu/drivers_display/menu_display_gl.c b/menu/drivers_display/menu_display_gl.c index 417c28838a..bc8dcade2f 100644 --- a/menu/drivers_display/menu_display_gl.c +++ b/menu/drivers_display/menu_display_gl.c @@ -207,6 +207,41 @@ static const float *menu_display_gl_get_tex_coords(void) return &gl_tex_coords[0]; } +static bool menu_display_gl_font_init_first(const void **font_driver, + void **font_handle, void *video_data, const char *font_path, + float font_size) +{ + settings_t *settings = config_get_ptr(); + const struct retro_hw_render_callback *hw_render = + (const struct retro_hw_render_callback*)video_driver_callback(); + + if (settings->video.threaded && !hw_render->context_type) + { + thread_packet_t pkt; + driver_t *driver = driver_get_ptr(); + thread_video_t *thr = (thread_video_t*)driver->video_data; + + if (!thr) + return false; + + pkt.type = CMD_FONT_INIT; + pkt.data.font_init.method = font_init_first; + pkt.data.font_init.font_driver = (const void**)font_driver; + pkt.data.font_init.font_handle = font_handle; + pkt.data.font_init.video_data = video_data; + pkt.data.font_init.font_path = font_path; + pkt.data.font_init.font_size = font_size; + pkt.data.font_init.api = FONT_DRIVER_RENDER_OPENGL_API; + + thr->send_and_wait(thr, &pkt); + + return pkt.data.font_init.return_value; + } + + return font_init_first(font_driver, font_handle, video_data, + font_path, font_size, FONT_DRIVER_RENDER_OPENGL_API); +} + menu_display_ctx_driver_t menu_display_ctx_gl = { menu_display_gl_draw, menu_display_gl_draw_bg, @@ -218,6 +253,7 @@ menu_display_ctx_driver_t menu_display_ctx_gl = { menu_display_gl_get_tex_coords, menu_display_gl_texture_load, menu_display_gl_texture_unload, + menu_display_gl_font_init_first, MENU_VIDEO_DRIVER_OPENGL, "menu_display_gl", }; diff --git a/menu/drivers_display/menu_display_null.c b/menu/drivers_display/menu_display_null.c index d10bfe58b2..8f4b1ca632 100644 --- a/menu/drivers_display/menu_display_null.c +++ b/menu/drivers_display/menu_display_null.c @@ -88,6 +88,13 @@ static const float *menu_display_null_get_tex_coords(void) return &floats[0]; } +static bool menu_display_null_font_init_first(const void **font_driver, + void **font_handle, void *video_data, const char *font_path, + float font_size) +{ + return true; +} + menu_display_ctx_driver_t menu_display_ctx_null = { menu_display_null_draw, menu_display_null_draw_bg, @@ -99,6 +106,7 @@ menu_display_ctx_driver_t menu_display_ctx_null = { menu_display_null_get_tex_coords, menu_display_null_texture_load, menu_display_null_texture_unload, + menu_display_null_font_init_first, MENU_VIDEO_DRIVER_GENERIC, "menu_display_null", }; diff --git a/menu/menu_display.c b/menu/menu_display.c index 3af39b127a..360d723d66 100644 --- a/menu/menu_display.c +++ b/menu/menu_display.c @@ -134,6 +134,13 @@ bool menu_display_font_init_first(const void **font_driver, void **font_handle, void *video_data, const char *font_path, float font_size) { + menu_display_ctx_driver_t *menu_disp = menu_display_context_get_ptr(); + if (!menu_disp || !menu_disp->font_init_first) + return false; + + return menu_disp->font_init_first(font_driver, font_handle, video_data, + font_path, font_size); + settings_t *settings = config_get_ptr(); const struct retro_hw_render_callback *hw_render = (const struct retro_hw_render_callback*)video_driver_callback(); @@ -577,8 +584,7 @@ void menu_display_blend_end(void) if (!menu_disp || !menu_disp->blend_end) return; - if (menu_disp) - menu_disp->blend_end(); + menu_disp->blend_end(); } void menu_display_matrix_4x4_rotate_z(void *data, float rotation, diff --git a/menu/menu_display.h b/menu/menu_display.h index 7d978e2fc9..93859dace0 100644 --- a/menu/menu_display.h +++ b/menu/menu_display.h @@ -107,6 +107,9 @@ typedef struct menu_display_ctx_driver const float *(*get_tex_coords)(void); unsigned (*texture_load)(void *data, enum texture_filter_type type); void (*texture_unload)(uintptr_t *id); + bool (*font_init_first)(const void **font_driver, + void **font_handle, void *video_data, const char *font_path, + float font_size); enum menu_display_driver_type type; const char *ident; } menu_display_ctx_driver_t; From c5b5d3c1862db00372a87695b4a21b4471302e84 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Tue, 10 Nov 2015 00:13:17 +0100 Subject: [PATCH 052/216] (D3D) Cleanups --- gfx/d3d/d3d.cpp | 45 +++++++++++++++++++++++++++++++-------------- 1 file changed, 31 insertions(+), 14 deletions(-) diff --git a/gfx/d3d/d3d.cpp b/gfx/d3d/d3d.cpp index cfe1043fc5..0316d32d04 100644 --- a/gfx/d3d/d3d.cpp +++ b/gfx/d3d/d3d.cpp @@ -416,46 +416,58 @@ static void d3d_calculate_rect(d3d_video_t *d3d, unsigned width, unsigned height, bool keep, float desired_aspect) { + int x = 0; + int y = 0; + unsigned new_width = width; + unsigned new_height = height; settings_t *settings = config_get_ptr(); if (settings->video.scale_integer) { struct video_viewport vp = {0}; video_viewport_get_scaled_integer(&vp, width, height, desired_aspect, keep); - d3d_set_viewport(d3d, vp.x, vp.y, vp.width, vp.height); + x = vp.x; + y = vp.y; + new_width = vp.width; + new_height = vp.height; } - else if (!keep) - d3d_set_viewport(d3d, 0, 0, width, height); - else + else if (keep) { if (settings->video.aspect_ratio_idx == ASPECT_RATIO_CUSTOM) { video_viewport_t *custom = video_viewport_get_custom(); if (custom) - d3d_set_viewport(d3d, custom->x, custom->y, - custom->width, custom->height); + { + x = custom->x; + y = custom->y; + new_width = custom->width; + new_height = custom->height; + } } else { float device_aspect = ((float)width) / ((float)height); - if (fabsf(device_aspect - desired_aspect) < 0.0001f) - d3d_set_viewport(d3d, 0, 0, width, height); + if (fabsf(device_aspect - desired_aspect) < 0.0001f) { } else if (device_aspect > desired_aspect) { float delta = (desired_aspect / device_aspect - 1.0f) / 2.0f + 0.5f; - d3d_set_viewport(d3d, int(roundf(width * (0.5f - delta))), - 0, unsigned(roundf(2.0f * width * delta)), height); + x = int(roundf(width * (0.5f - delta))); + y = 0; + new_width = unsigned(roundf(2.0f * width * delta)); } else { float delta = (device_aspect / desired_aspect - 1.0f) / 2.0f + 0.5f; - d3d_set_viewport(d3d, 0, int(roundf(height * (0.5f - delta))), - width, unsigned(roundf(2.0f * height * delta))); + x = 0; + y = int(roundf(height * (0.5f - delta))); + new_height = unsigned(roundf(2.0f * height * delta)); } } } + + d3d_set_viewport(d3d, x, y, new_width, new_height); } static void d3d_set_nonblock_state(void *data, bool state) @@ -743,8 +755,13 @@ static void d3d_viewport_info(void *data, struct video_viewport *vp) static void d3d_set_rotation(void *data, unsigned rot) { d3d_video_t *d3d = (d3d_video_t*)data; - if (d3d) - d3d->dev_rotation = rot; + struct gfx_ortho ortho = {0, 1, 0, 1, -1, 1}; + + if (!d3d) + return; + + d3d->dev_rotation = rot; + //d3d_set_projection(d3d, &ortho, true); } static void d3d_show_mouse(void *data, bool state) From 54b2d4685505a7c7fab73150a4e813095b4fa56e Mon Sep 17 00:00:00 2001 From: twinaphex Date: Tue, 10 Nov 2015 00:30:00 +0100 Subject: [PATCH 053/216] (D3D) Add video_viewport --- gfx/d3d/d3d.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/gfx/d3d/d3d.h b/gfx/d3d/d3d.h index 8d4189263f..e4a2577f1d 100644 --- a/gfx/d3d/d3d.h +++ b/gfx/d3d/d3d.h @@ -54,6 +54,7 @@ #include "../font_driver.h" #include "../font_renderer_driver.h" #include "../video_context_driver.h" +#include "../video_viewport.h" #include "d3d_wrapper.h" #include "render_chain_driver.h" @@ -99,6 +100,7 @@ typedef struct d3d_video bool should_resize; bool quitting; + struct video_viewport vp; #ifdef HAVE_WINDOW WNDCLASSEX windowClass; #endif From 3dfdc4ba8faa80715ad65d6c6ea5c5aeb0c8363a Mon Sep 17 00:00:00 2001 From: twinaphex Date: Tue, 10 Nov 2015 00:37:05 +0100 Subject: [PATCH 054/216] rarch_playlist_load_content - check if path is non-NULL --- retroarch.c | 47 +++++++++++++++++++++++++---------------------- 1 file changed, 25 insertions(+), 22 deletions(-) diff --git a/retroarch.c b/retroarch.c index 90c6d4d2d2..849cf01b60 100644 --- a/retroarch.c +++ b/retroarch.c @@ -1511,32 +1511,35 @@ void rarch_playlist_load_content(void *data, unsigned idx) content_playlist_get_index(playlist, idx, &path, NULL, &core_path, NULL, NULL, NULL); - path_tolower = strdup(path); - - for (i = 0; i < strlen(path_tolower); ++i) - path_tolower[i] = tolower(path_tolower[i]); - - - if (strstr(path_tolower, ".zip")) - strstr(path_tolower, ".zip")[4] = '\0'; - else if (strstr(path_tolower, ".7z")) - strstr(path_tolower, ".7z")[3] = '\0'; - - path_check = (char *)calloc(strlen(path_tolower) + 1, sizeof(char)); - strncpy(path_check, path, strlen(path_tolower)); - - fp = retro_fopen(path_check, RFILE_MODE_READ, -1); - if (!fp) + if (path && path[0] != '\0') { - rarch_main_msg_queue_push("File could not be loaded.\n", 1, 100, true); - RARCH_LOG("File at %s failed to load.\n", path_check); + path_tolower = strdup(path); + + for (i = 0; i < strlen(path_tolower); ++i) + path_tolower[i] = tolower(path_tolower[i]); + + + if (strstr(path_tolower, ".zip")) + strstr(path_tolower, ".zip")[4] = '\0'; + else if (strstr(path_tolower, ".7z")) + strstr(path_tolower, ".7z")[3] = '\0'; + + path_check = (char *)calloc(strlen(path_tolower) + 1, sizeof(char)); + strncpy(path_check, path, strlen(path_tolower)); + + fp = retro_fopen(path_check, RFILE_MODE_READ, -1); + if (!fp) + { + rarch_main_msg_queue_push("File could not be loaded.\n", 1, 100, true); + RARCH_LOG("File at %s failed to load.\n", path_check); + free(path_tolower); + free(path_check); + return; + } + retro_fclose(fp); free(path_tolower); free(path_check); - return; } - retro_fclose(fp); - free(path_tolower); - free(path_check); strlcpy(settings->libretro, core_path, sizeof(settings->libretro)); From 26474599627fb9e41fa569324f01d133933cdb6e Mon Sep 17 00:00:00 2001 From: twinaphex Date: Tue, 10 Nov 2015 00:40:23 +0100 Subject: [PATCH 055/216] Move some variables around --- retroarch.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/retroarch.c b/retroarch.c index 849cf01b60..2e343201ca 100644 --- a/retroarch.c +++ b/retroarch.c @@ -1496,9 +1496,6 @@ void rarch_playlist_load_content(void *data, unsigned idx) unsigned i; const char *core_path = NULL; const char *path = NULL; - char *path_check = NULL; - char *path_tolower = NULL; - RFILE *fp = NULL; content_playlist_t *playlist = (content_playlist_t*)data; settings_t *settings = config_get_ptr(); #ifdef HAVE_MENU @@ -1513,7 +1510,9 @@ void rarch_playlist_load_content(void *data, unsigned idx) if (path && path[0] != '\0') { - path_tolower = strdup(path); + RFILE *fp = NULL; + char *path_check = NULL; + char *path_tolower = strdup(path); for (i = 0; i < strlen(path_tolower); ++i) path_tolower[i] = tolower(path_tolower[i]); From 413d7831273eac095aa482279ad92fa035e26e98 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Tue, 10 Nov 2015 01:50:15 +0100 Subject: [PATCH 056/216] Include header --- gfx/d3d/d3d.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/gfx/d3d/d3d.cpp b/gfx/d3d/d3d.cpp index 0316d32d04..7efdb93d1f 100644 --- a/gfx/d3d/d3d.cpp +++ b/gfx/d3d/d3d.cpp @@ -28,6 +28,7 @@ #include "d3d.h" #include "../video_viewport.h" #include "../video_monitor.h" +#include "../video_common.h" #include "../../dynamic.h" #include "render_chain_driver.h" From 166626542735eddc5af9c889f84abd4397836282 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Tue, 10 Nov 2015 01:58:05 +0100 Subject: [PATCH 057/216] Don't use GRfloat/GRuint anymore --- gfx/video_common.h | 3 --- menu/drivers/zarch.c | 38 +++++++++++++++++++------------------- 2 files changed, 19 insertions(+), 22 deletions(-) diff --git a/gfx/video_common.h b/gfx/video_common.h index 5fed1a829c..632a844b57 100644 --- a/gfx/video_common.h +++ b/gfx/video_common.h @@ -22,9 +22,6 @@ #include -typedef float GRfloat; -typedef unsigned int GRuint; - #ifdef __cplusplus extern "C" { #endif diff --git a/menu/drivers/zarch.c b/menu/drivers/zarch.c index 67d6908afc..0977720db3 100644 --- a/menu/drivers/zarch.c +++ b/menu/drivers/zarch.c @@ -52,25 +52,25 @@ #define ZARCH_DEBUG #endif -const GRfloat ZUI_NORMAL[] = { +const float ZUI_NORMAL[] = { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, }; -const GRfloat ZUI_HILITE[] = { +const float ZUI_HILITE[] = { 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, }; -const GRfloat ZUI_PRESS[] = { +const float ZUI_PRESS[] = { 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, }; -const GRfloat ZUI_BARBG[] = { +const float ZUI_BARBG[] = { 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, @@ -78,26 +78,26 @@ const GRfloat ZUI_BARBG[] = { }; const uint32_t ZUI_FG_NORMAL = ~0; -const GRfloat ZUI_BG_PANEL[] = { +const float ZUI_BG_PANEL[] = { 0, 0, 0, 0.25, 0, 0, 0, 0.25, 0, 0, 0, 0.25, 0, 0, 0, 0.25, }; -const GRfloat ZUI_BG_SCREEN[] = { +const float ZUI_BG_SCREEN[] = { 0.07, 0.19, 0.26, 0.75, 0.07, 0.19, 0.26, 0.75, 0.15, 0.31, 0.47, 0.75, 0.15, 0.31, 0.47, 0.75, }; -const GRfloat ZUI_BG_HILITE[] = { +const float ZUI_BG_HILITE[] = { 0.22, 0.60, 0.74, 1, 0.22, 0.60, 0.74, 1, 0.22, 0.60, 0.74, 1, 0.22, 0.60, 0.74, 1, }; -const GRfloat ZUI_BG_PAD_HILITE[] = { +const float ZUI_BG_PAD_HILITE[] = { 0.30, 0.76, 0.93, 1, 0.30, 0.76, 0.93, 1, 0.30, 0.76, 0.93, 1, @@ -145,11 +145,11 @@ typedef struct zarch_handle { struct { - GRuint id; + uintptr_t id; char path[PATH_MAX_LENGTH]; } bg; - GRuint white; + uintptr_t white; } textures; /* LAY_ROOT's "Recent" */ @@ -327,11 +327,11 @@ static void zarch_zui_draw_text(zui_t *zui, uint32_t color, int x, int y, const } static void zarch_zui_push_quad(unsigned width, unsigned height, - const GRfloat *colors, gfx_coord_array_t *ca, int x1, int y1, + const float *colors, gfx_coord_array_t *ca, int x1, int y1, int x2, int y2) { gfx_coords_t coords; - GRfloat vertex[8]; + float vertex[8]; vertex[0] = x1 / (float)width; vertex[1] = y1 / (float)height; @@ -419,8 +419,8 @@ static void zarch_zui_snow(zui_t *zui, gfx_coord_array_t *ca, int width, int hei for (i = 0; i < NPARTICLES; ++i) { unsigned j; - GRfloat alpha; - GRfloat colors[16]; + float alpha; + float colors[16]; part_t *p = &particles[i]; if (!p->alive) @@ -445,7 +445,7 @@ static bool zarch_zui_button_full(zui_t *zui, int x1, int y1, int x2, int y2, co { unsigned id = zarch_zui_hash(zui, label); bool active = zarch_zui_check_button_up(zui, id, x1, y1, x2, y2); - const GRfloat *bg = ZUI_BG_PANEL; + const float *bg = ZUI_BG_PANEL; if (zui->item.active == id || zui->item.hot == id) bg = ZUI_BG_HILITE; @@ -471,7 +471,7 @@ static bool zarch_zui_list_item(zui_t *zui, zui_tabbed_t *tab, int x1, int y1, int x2 = x1 + zui->width - 290 - 40; int y2 = y1 + 50; bool active = zarch_zui_check_button_up(zui, id, x1, y1, x2, y2); - const GRfloat *bg = ZUI_BG_PANEL; + const float *bg = ZUI_BG_PANEL; uint64_t *frame_count = video_driver_get_frame_count(); if (tab->active_id != tab->prev_id) @@ -534,7 +534,7 @@ static bool zarch_zui_tab(zui_t *zui, zui_tabbed_t *tab, const char *label, unsi int x1, y1, x2, y2; unsigned id = zarch_zui_hash(zui, label); int width = tab->tab_width; - const GRfloat *bg = ZUI_BG_PANEL; + const float *bg = ZUI_BG_PANEL; bool selected = tab->tab_selection == tab_id; /* TODO/FIXME */ if (!width) @@ -962,8 +962,8 @@ static int zarch_zui_render_pick_core(zui_t *zui) static void zarch_frame(void) { unsigned i; - GRfloat coord_color[16]; - GRfloat coord_color2[16]; + float coord_color[16]; + float coord_color2[16]; zui_t *zui = NULL; const struct font_renderer *font_driver = NULL; driver_t *driver = driver_get_ptr(); From d1553e403289781cc2988e1e5cd895f66b79a762 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Tue, 10 Nov 2015 02:25:31 +0100 Subject: [PATCH 058/216] Double turbo period entry --- menu/menu_displaylist.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/menu/menu_displaylist.c b/menu/menu_displaylist.c index e2d1ced89f..e31b8a883c 100644 --- a/menu/menu_displaylist.c +++ b/menu/menu_displaylist.c @@ -2623,8 +2623,6 @@ int menu_displaylist_push_list(menu_displaylist_info_t *info, unsigned type) menu_hash_to_str(MENU_LABEL_INPUT_AXIS_THRESHOLD), PARSE_ONLY_FLOAT, false); ret = menu_displaylist_parse_settings(menu, info, menu_hash_to_str(MENU_LABEL_INPUT_TURBO_PERIOD), PARSE_ONLY_UINT, false); - ret = menu_displaylist_parse_settings(menu, info, - menu_hash_to_str(MENU_LABEL_INPUT_TURBO_PERIOD), PARSE_ONLY_UINT, false); ret = menu_displaylist_parse_settings(menu, info, menu_hash_to_str(MENU_LABEL_INPUT_DUTY_CYCLE), PARSE_ONLY_UINT, false); ret = menu_displaylist_parse_settings(menu, info, From eb64b100980983b2691b908c9d4a0756d1667f9f Mon Sep 17 00:00:00 2001 From: twinaphex Date: Tue, 10 Nov 2015 02:43:30 +0100 Subject: [PATCH 059/216] Fix CXX_BUILD --- libretro-common/include/retro_stat.h | 8 -------- menu/menu_cbs.h | 8 -------- 2 files changed, 16 deletions(-) diff --git a/libretro-common/include/retro_stat.h b/libretro-common/include/retro_stat.h index 6429bb60bf..cd83d003a4 100644 --- a/libretro-common/include/retro_stat.h +++ b/libretro-common/include/retro_stat.h @@ -28,10 +28,6 @@ #include -#ifdef __cplusplus -extern "C" { -#endif - /** * path_is_directory: * @path : path @@ -58,8 +54,4 @@ int32_t path_get_size(const char *path); **/ bool mkdir_norecurse(const char *dir); -#ifdef __cplusplus -} -#endif - #endif diff --git a/menu/menu_cbs.h b/menu/menu_cbs.h index d82ad14b13..ab609bd8b6 100644 --- a/menu/menu_cbs.h +++ b/menu/menu_cbs.h @@ -21,10 +21,6 @@ #include "menu_hash.h" -#ifdef __cplusplus -extern "C" { -#endif - enum { ACTION_OK_DL_DEFAULT = 0, @@ -204,8 +200,4 @@ void menu_cbs_init(void *data, bool menu_playlist_find_associated_core(const char *path, char *s, size_t len); -#ifdef __cplusplus -} -#endif - #endif From 181fae83eb5a10708079173d0a91a56e179167ea Mon Sep 17 00:00:00 2001 From: Andre Leiradella Date: Mon, 9 Nov 2015 23:46:44 -0200 Subject: [PATCH 060/216] fixed warnings in cxx build --- cheevos.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/cheevos.c b/cheevos.c index 0714a00868..9411494ca6 100644 --- a/cheevos.c +++ b/cheevos.c @@ -1702,7 +1702,7 @@ static unsigned cheevos_find_game_id_nes(const struct retro_game_info *info, ret num_read = retro_fread(file, (void*)&header, sizeof(header)); retro_fclose(file); - if (num_read < sizeof(header)) + if (num_read < (ssize_t)sizeof(header)) return 0; } @@ -1741,7 +1741,7 @@ static unsigned cheevos_find_game_id_nes(const struct retro_game_info *info, ret if (num_read <= 0) break; - if (num_read >= rom_size) + if (num_read >= (ssize_t)rom_size) { MD5_Update(&ctx, (void*)buffer, rom_size); break; @@ -1805,7 +1805,7 @@ int cheevos_load(const struct retro_game_info *info) size_t memory; struct retro_system_info sysinfo; - int i; + unsigned i; const char *json; retro_time_t timeout = 5000000; unsigned game_id = 0; From fe7926913346cedac8f40345bdef7a21ca16d0cc Mon Sep 17 00:00:00 2001 From: Andre Leiradella Date: Tue, 10 Nov 2015 00:21:35 -0200 Subject: [PATCH 061/216] don't test cheevos if there are none --- cheevos.c | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/cheevos.c b/cheevos.c index 9411494ca6..df8d5c6bda 100644 --- a/cheevos.c +++ b/cheevos.c @@ -1270,13 +1270,17 @@ static void cheevos_test_cheevo_set(const cheevoset_t *set) void cheevos_test(void) { - settings_t *settings = config_get_ptr(); - if (settings->cheevos.enable && !cheevos_globals.cheats_are_enabled && !cheevos_globals.cheats_were_enabled) + if (cheevos_locals.loaded) { - cheevos_test_cheevo_set(&cheevos_locals.core); + settings_t *settings = config_get_ptr(); + + if (settings->cheevos.enable && !cheevos_globals.cheats_are_enabled && !cheevos_globals.cheats_were_enabled) + { + cheevos_test_cheevo_set(&cheevos_locals.core); - if (settings->cheevos.test_unofficial) - cheevos_test_cheevo_set(&cheevos_locals.unofficial); + if (settings->cheevos.test_unofficial) + cheevos_test_cheevo_set(&cheevos_locals.unofficial); + } } } From fd319cb2231a1119b4c68a368f721a9391db56ed Mon Sep 17 00:00:00 2001 From: twinaphex Date: Tue, 10 Nov 2015 05:09:31 +0100 Subject: [PATCH 062/216] (D3D) Cleanups --- gfx/d3d/d3d.cpp | 27 ++++++++++++--------------- 1 file changed, 12 insertions(+), 15 deletions(-) diff --git a/gfx/d3d/d3d.cpp b/gfx/d3d/d3d.cpp index 7efdb93d1f..e058281631 100644 --- a/gfx/d3d/d3d.cpp +++ b/gfx/d3d/d3d.cpp @@ -1037,17 +1037,18 @@ static bool d3d_init_chain(d3d_video_t *d3d, const video_info_t *video_info) return false; } + if ( + !d3d->renderchain_driver->init( #ifdef _XBOX - if (!d3d->renderchain_driver->init(d3d, &d3d->video_info, - d3dr, &d3d->final_viewport, &link_info, - d3d->video_info.rgb32 ? - RETRO_PIXEL_FORMAT_XRGB8888 : RETRO_PIXEL_FORMAT_RGB565)) + d3d, #else - if (!d3d->renderchain_driver->init(d3d->renderchain_data, &d3d->video_info, + d3d->renderchain_data, +#endif + &d3d->video_info, d3dr, &d3d->final_viewport, &link_info, d3d->video_info.rgb32 ? - RETRO_PIXEL_FORMAT_XRGB8888 : RETRO_PIXEL_FORMAT_RGB565)) -#endif + RETRO_PIXEL_FORMAT_XRGB8888 : RETRO_PIXEL_FORMAT_RGB565) + ) { RARCH_ERR("[D3D]: Failed to init render chain.\n"); return false; @@ -1501,13 +1502,12 @@ static void d3d_free_overlays(d3d_video_t *d3d) d3d->overlays.clear(); } -static void d3d_overlay_tex_geom(void *data, +static void d3d_overlay_tex_geom( + d3d_video_t *d3d, unsigned index, float x, float y, float w, float h) { - d3d_video_t *d3d = (d3d_video_t*)data; - if (!d3d) return; @@ -1517,13 +1517,12 @@ static void d3d_overlay_tex_geom(void *data, d3d->overlays[index].tex_coords.h = h; } -static void d3d_overlay_vertex_geom(void *data, +static void d3d_overlay_vertex_geom( + d3d_video_t *d3d, unsigned index, float x, float y, float w, float h) { - d3d_video_t *d3d = (d3d_video_t*)data; - if (!d3d) return; @@ -1740,11 +1739,9 @@ static bool d3d_frame(void *data, const void *frame, } #ifdef HAVE_MENU -#ifndef _XBOX if (d3d->menu && d3d->menu->enabled) d3d_overlay_render(d3d, d3d->menu); #endif -#endif #ifdef HAVE_OVERLAY if (d3d->overlays_enabled) From 5cbfbb190c84e77b003e05075b345aa52757e997 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Tue, 10 Nov 2015 05:11:49 +0100 Subject: [PATCH 063/216] (D3D) Buildfix --- gfx/d3d/d3d.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/gfx/d3d/d3d.cpp b/gfx/d3d/d3d.cpp index e058281631..88f41c6877 100644 --- a/gfx/d3d/d3d.cpp +++ b/gfx/d3d/d3d.cpp @@ -1503,11 +1503,12 @@ static void d3d_free_overlays(d3d_video_t *d3d) } static void d3d_overlay_tex_geom( - d3d_video_t *d3d, + void *data, unsigned index, float x, float y, float w, float h) { + d3d_video_t *d3d = (d3d_video_t*)data; if (!d3d) return; @@ -1518,11 +1519,12 @@ static void d3d_overlay_tex_geom( } static void d3d_overlay_vertex_geom( - d3d_video_t *d3d, + void *data, unsigned index, float x, float y, float w, float h) { + d3d_video_t *d3d = (d3d_video_t*)data; if (!d3d) return; From bfe0eb9bfbd1aa9055619a37b781b75aca4db401 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Tue, 10 Nov 2015 05:26:37 +0100 Subject: [PATCH 064/216] Call gfx_ctx_set_resize from d3d_frame --- gfx/d3d/d3d.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/gfx/d3d/d3d.cpp b/gfx/d3d/d3d.cpp index 88f41c6877..b77ef92755 100644 --- a/gfx/d3d/d3d.cpp +++ b/gfx/d3d/d3d.cpp @@ -1679,13 +1679,15 @@ static bool d3d_frame(void *data, const void *frame, if (d3d->should_resize) { + d3d->should_resize = false; + + gfx_ctx_set_resize(d3d, width, height); + d3d_calculate_rect(d3d, width, width, d3d->video_info.force_aspect, video_driver_get_aspect_ratio()); d3d->renderchain_driver->set_final_viewport(d3d, d3d->renderchain_data, &d3d->final_viewport); - - d3d->should_resize = false; } /* render_chain() only clears out viewport, From 29aa5bae27ae6d9a7733537209522f79c18bfa82 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Tue, 10 Nov 2015 05:30:25 +0100 Subject: [PATCH 065/216] (D3D) Add keep_aspect --- gfx/d3d/d3d.cpp | 16 ++++++++-------- gfx/d3d/d3d.h | 1 + 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/gfx/d3d/d3d.cpp b/gfx/d3d/d3d.cpp index 88f41c6877..6066d70740 100644 --- a/gfx/d3d/d3d.cpp +++ b/gfx/d3d/d3d.cpp @@ -56,8 +56,7 @@ /* forward declarations */ static void d3d_calculate_rect(d3d_video_t *d3d, - unsigned width, unsigned height, - bool keep, float desired_aspect); + unsigned width, unsigned height, float desired_aspect); static bool d3d_init_luts(d3d_video_t *d3d); static void d3d_set_font_rect(d3d_video_t *d3d, const struct font_params *params); @@ -414,8 +413,7 @@ bool d3d_restore(d3d_video_t *d3d) } static void d3d_calculate_rect(d3d_video_t *d3d, - unsigned width, unsigned height, - bool keep, float desired_aspect) + unsigned width, unsigned height, float desired_aspect) { int x = 0; int y = 0; @@ -426,13 +424,13 @@ static void d3d_calculate_rect(d3d_video_t *d3d, if (settings->video.scale_integer) { struct video_viewport vp = {0}; - video_viewport_get_scaled_integer(&vp, width, height, desired_aspect, keep); + video_viewport_get_scaled_integer(&vp, width, height, desired_aspect, d3d->keep_aspect); x = vp.x; y = vp.y; new_width = vp.width; new_height = vp.height; } - else if (keep) + else if (d3d->keep_aspect) { if (settings->video.aspect_ratio_idx == ASPECT_RATIO_CUSTOM) { @@ -556,7 +554,7 @@ static void d3d_set_aspect_ratio(void *data, unsigned aspect_ratio_idx) if (!d3d) return; - d3d->video_info.force_aspect = true; + d3d->keep_aspect = true; d3d->should_resize = true; } @@ -853,6 +851,8 @@ static void *d3d_init(const video_info_t *info, goto error; } + vid->keep_aspect = info->force_aspect; + #ifdef _XBOX driver->video_data_own = true; driver->input_data_own = true; @@ -1679,7 +1679,7 @@ static bool d3d_frame(void *data, const void *frame, if (d3d->should_resize) { - d3d_calculate_rect(d3d, width, width, d3d->video_info.force_aspect, + d3d_calculate_rect(d3d, width, width, video_driver_get_aspect_ratio()); d3d->renderchain_driver->set_final_viewport(d3d, diff --git a/gfx/d3d/d3d.h b/gfx/d3d/d3d.h index e4a2577f1d..218d710ccf 100644 --- a/gfx/d3d/d3d.h +++ b/gfx/d3d/d3d.h @@ -97,6 +97,7 @@ typedef struct gl_shader_backend gl_shader_backend_t; typedef struct d3d_video { uint64_t frame_count; + bool keep_aspect; bool should_resize; bool quitting; From 749c0b4ef81d25b8ee9db90a8137210ec2915a23 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Tue, 10 Nov 2015 05:47:53 +0100 Subject: [PATCH 066/216] Make d3d_calculate_rect more like gl_set_viewport --- gfx/d3d/d3d.cpp | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/gfx/d3d/d3d.cpp b/gfx/d3d/d3d.cpp index 2f854072d4..8cd8eb18b4 100644 --- a/gfx/d3d/d3d.cpp +++ b/gfx/d3d/d3d.cpp @@ -56,7 +56,7 @@ /* forward declarations */ static void d3d_calculate_rect(d3d_video_t *d3d, - unsigned width, unsigned height, float desired_aspect); + unsigned width, unsigned height, bool force_full, bool allow_rotate); static bool d3d_init_luts(d3d_video_t *d3d); static void d3d_set_font_rect(d3d_video_t *d3d, const struct font_params *params); @@ -332,7 +332,7 @@ static bool d3d_initialize(d3d_video_t *d3d, const video_info_t *info) video_driver_get_size(&width, &height); d3d_calculate_rect(d3d, - width, height, video_driver_get_aspect_ratio()); + width, height, false, true); if (!d3d_init_chain(d3d, info)) { @@ -413,15 +413,21 @@ bool d3d_restore(d3d_video_t *d3d) } static void d3d_calculate_rect(d3d_video_t *d3d, - unsigned width, unsigned height, float desired_aspect) + unsigned width, unsigned height, bool force_full, bool allow_rotate) { int x = 0; int y = 0; + float device_aspect = (float)width / height; unsigned new_width = width; unsigned new_height = height; settings_t *settings = config_get_ptr(); + float desired_aspect = video_driver_get_aspect_ratio(); - if (settings->video.scale_integer) + video_driver_get_size(&width, &height); + + gfx_ctx_translate_aspect(d3d, &device_aspect, width, height); + + if (settings->video.scale_integer && !force_full) { struct video_viewport vp = {0}; video_viewport_get_scaled_integer(&vp, width, height, desired_aspect, d3d->keep_aspect); @@ -430,7 +436,7 @@ static void d3d_calculate_rect(d3d_video_t *d3d, new_width = vp.width; new_height = vp.height; } - else if (d3d->keep_aspect) + else if (d3d->keep_aspect && !force_full) { if (settings->video.aspect_ratio_idx == ASPECT_RATIO_CUSTOM) { @@ -1683,8 +1689,7 @@ static bool d3d_frame(void *data, const void *frame, gfx_ctx_set_resize(d3d, width, height); - d3d_calculate_rect(d3d, width, width, - video_driver_get_aspect_ratio()); + d3d_calculate_rect(d3d, width, width, false, true); d3d->renderchain_driver->set_final_viewport(d3d, d3d->renderchain_data, &d3d->final_viewport); From 1f1525a7e831be65e5b93b1e9a386c4af474d592 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Tue, 10 Nov 2015 15:30:24 +0100 Subject: [PATCH 067/216] (D3D) Cleanups --- gfx/d3d/d3d.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/gfx/d3d/d3d.cpp b/gfx/d3d/d3d.cpp index 8cd8eb18b4..cbfe0d2f70 100644 --- a/gfx/d3d/d3d.cpp +++ b/gfx/d3d/d3d.cpp @@ -452,19 +452,19 @@ static void d3d_calculate_rect(d3d_video_t *d3d, } else { - float device_aspect = ((float)width) / ((float)height); + float delta; if (fabsf(device_aspect - desired_aspect) < 0.0001f) { } else if (device_aspect > desired_aspect) { - float delta = (desired_aspect / device_aspect - 1.0f) / 2.0f + 0.5f; + delta = (desired_aspect / device_aspect - 1.0f) / 2.0f + 0.5f; x = int(roundf(width * (0.5f - delta))); y = 0; new_width = unsigned(roundf(2.0f * width * delta)); } else { - float delta = (device_aspect / desired_aspect - 1.0f) / 2.0f + 0.5f; + delta = (device_aspect / desired_aspect - 1.0f) / 2.0f + 0.5f; x = 0; y = int(roundf(height * (0.5f - delta))); new_height = unsigned(roundf(2.0f * height * delta)); From 36d5cc890b37a3f351877bb6b83851e4c5af57dd Mon Sep 17 00:00:00 2001 From: twinaphex Date: Tue, 10 Nov 2015 15:32:07 +0100 Subject: [PATCH 068/216] (GL) Cleanups --- gfx/drivers/gl.c | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/gfx/drivers/gl.c b/gfx/drivers/gl.c index ab254a99ec..191695962b 100644 --- a/gfx/drivers/gl.c +++ b/gfx/drivers/gl.c @@ -899,18 +899,16 @@ static void gl_set_viewport(void *data, unsigned viewport_width, viewport_height = (unsigned)roundf(2.0f * viewport_height * delta); } } - - gl->vp.x = x; - gl->vp.y = y; - gl->vp.width = viewport_width; - gl->vp.height = viewport_height; } else { - gl->vp.x = gl->vp.y = 0; - gl->vp.width = viewport_width; - gl->vp.height = viewport_height; + x = 0; + y = 0; } + gl->vp.x = x; + gl->vp.y = y; + gl->vp.width = viewport_width; + gl->vp.height = viewport_height; #if defined(RARCH_MOBILE) /* In portrait mode, we want viewport to gravitate to top of screen. */ From 4cdde1c7c47d58218bb27fd2cb1f2a90985b81ac Mon Sep 17 00:00:00 2001 From: twinaphex Date: Tue, 10 Nov 2015 21:58:33 +0100 Subject: [PATCH 069/216] Use d3d_set_viewport_wrap --- gfx/d3d/d3d.cpp | 35 ++++------------------------------- 1 file changed, 4 insertions(+), 31 deletions(-) diff --git a/gfx/d3d/d3d.cpp b/gfx/d3d/d3d.cpp index cbfe0d2f70..5f8082fc81 100644 --- a/gfx/d3d/d3d.cpp +++ b/gfx/d3d/d3d.cpp @@ -1165,16 +1165,7 @@ static bool texture_image_render(d3d_video_t *d3d, d3d_set_vertex_shader(d3dr, D3DFVF_CUSTOMVERTEX, NULL); if (force_fullscreen) - { - D3DVIEWPORT vp = {0}; - vp.Width = w; - vp.Height = h; - vp.X = 0; - vp.Y = 0; - vp.MinZ = 0.0f; - vp.MaxZ = 1.0f; - d3d_set_viewport(d3dr, &vp); - } + d3d_set_viewport_wrap(d3d, w, h, force_fullscreen, false); d3d_draw_primitive(d3dr, D3DPT_QUADLIST, 0, 1); return true; @@ -1461,18 +1452,7 @@ static void d3d_overlay_render(d3d_video_t *d3d, overlay_t *overlay) video_driver_get_size(&width, &height); if (overlay->fullscreen) - { - /* Set viewport to full window. */ - D3DVIEWPORT vp_full = {0}; - - vp_full.X = 0; - vp_full.Y = 0; - vp_full.Width = width; - vp_full.Height = height; - vp_full.MinZ = 0.0f; - vp_full.MaxZ = 1.0f; - d3d_set_viewport(d3d->dev, &vp_full); - } + d3d_set_viewport_wrap(d3d, width, height, true, false); /* Render overlay. */ d3d_set_texture(d3d->dev, 0, overlay->tex); @@ -1653,7 +1633,6 @@ static bool d3d_frame(void *data, const void *frame, const char *msg) { unsigned width, height; - D3DVIEWPORT screen_vp; static struct retro_perf_counter d3d_frame = {0}; unsigned i = 0; d3d_video_t *d3d = (d3d_video_t*)data; @@ -1689,7 +1668,7 @@ static bool d3d_frame(void *data, const void *frame, gfx_ctx_set_resize(d3d, width, height); - d3d_calculate_rect(d3d, width, width, false, true); + d3d_set_viewport_wrap(d3d, width, height, false, true); d3d->renderchain_driver->set_final_viewport(d3d, d3d->renderchain_data, &d3d->final_viewport); @@ -1697,13 +1676,7 @@ static bool d3d_frame(void *data, const void *frame, /* render_chain() only clears out viewport, * clear out everything. */ - screen_vp.X = 0; - screen_vp.Y = 0; - screen_vp.MinZ = 0; - screen_vp.MaxZ = 1; - screen_vp.Width = width; - screen_vp.Height = height; - d3d_set_viewport(d3dr, &screen_vp); + d3d_set_viewport_wrap(d3d, width, height, false, false); d3d_clear(d3dr, 0, 0, D3DCLEAR_TARGET, 0, 1, 0); /* Insert black frame first, so we From 8d4c721ee46e658382cd105763d46da4480eb4a7 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Tue, 10 Nov 2015 22:00:35 +0100 Subject: [PATCH 070/216] Move set_final_viewport to d3d_set_viewport_wrap --- gfx/d3d/d3d.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/gfx/d3d/d3d.cpp b/gfx/d3d/d3d.cpp index 5f8082fc81..ca6b317f65 100644 --- a/gfx/d3d/d3d.cpp +++ b/gfx/d3d/d3d.cpp @@ -399,6 +399,9 @@ static void d3d_set_viewport_wrap(void *data, d3d_set_viewport(d3dr, &vp_full); else d3d_set_viewport(d3dr, &d3d->final_viewport); + + d3d->renderchain_driver->set_final_viewport(d3d, + d3d->renderchain_data, &d3d->final_viewport); } bool d3d_restore(d3d_video_t *d3d) @@ -1670,8 +1673,7 @@ static bool d3d_frame(void *data, const void *frame, d3d_set_viewport_wrap(d3d, width, height, false, true); - d3d->renderchain_driver->set_final_viewport(d3d, - d3d->renderchain_data, &d3d->final_viewport); + } /* render_chain() only clears out viewport, From 21575e53180cded57f22768cdedf4aac939ffa86 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Tue, 10 Nov 2015 22:05:31 +0100 Subject: [PATCH 071/216] Call d3d_calculate_rect from set_viewport_wrap --- gfx/d3d/d3d.cpp | 18 +----------------- 1 file changed, 1 insertion(+), 17 deletions(-) diff --git a/gfx/d3d/d3d.cpp b/gfx/d3d/d3d.cpp index ca6b317f65..928379c946 100644 --- a/gfx/d3d/d3d.cpp +++ b/gfx/d3d/d3d.cpp @@ -382,24 +382,8 @@ static void d3d_set_viewport_wrap(void *data, bool force_fullscreen, bool allow_rotate) { - D3DVIEWPORT vp_full; - LPDIRECT3DDEVICE d3dr; d3d_video_t *d3d = (d3d_video_t*)data; - - vp_full.X = 0; - vp_full.Y = 0; - vp_full.Width = width; - vp_full.Height = height; - vp_full.MinZ = 0.0f; - vp_full.MaxZ = 1.0f; - - d3dr = (LPDIRECT3DDEVICE)d3d->dev; - - if (force_fullscreen) - d3d_set_viewport(d3dr, &vp_full); - else - d3d_set_viewport(d3dr, &d3d->final_viewport); - + d3d_calculate_rect(d3d, width, height, force_fullscreen, allow_rotate); d3d->renderchain_driver->set_final_viewport(d3d, d3d->renderchain_data, &d3d->final_viewport); } From 19f9833a22b2e5ef401a6340f78e677f6856fe75 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Tue, 10 Nov 2015 22:07:51 +0100 Subject: [PATCH 072/216] Refactor away d3d_calculate_rect --- gfx/d3d/d3d.cpp | 145 +++++++++++++++++++++++------------------------- 1 file changed, 70 insertions(+), 75 deletions(-) diff --git a/gfx/d3d/d3d.cpp b/gfx/d3d/d3d.cpp index 928379c946..6083ca4c27 100644 --- a/gfx/d3d/d3d.cpp +++ b/gfx/d3d/d3d.cpp @@ -55,8 +55,6 @@ #endif /* forward declarations */ -static void d3d_calculate_rect(d3d_video_t *d3d, - unsigned width, unsigned height, bool force_full, bool allow_rotate); static bool d3d_init_luts(d3d_video_t *d3d); static void d3d_set_font_rect(d3d_video_t *d3d, const struct font_params *params); @@ -271,6 +269,74 @@ static bool d3d_init_base(void *data, const video_info_t *info) return true; } +static void d3d_set_viewport_wrap(void *data, + unsigned width, unsigned height, + bool force_full, + bool allow_rotate) +{ + d3d_video_t *d3d = (d3d_video_t*)data; + int x = 0; + int y = 0; + float device_aspect = (float)width / height; + unsigned new_width = width; + unsigned new_height = height; + settings_t *settings = config_get_ptr(); + float desired_aspect = video_driver_get_aspect_ratio(); + + video_driver_get_size(&width, &height); + + gfx_ctx_translate_aspect(d3d, &device_aspect, width, height); + + if (settings->video.scale_integer && !force_full) + { + struct video_viewport vp = {0}; + video_viewport_get_scaled_integer(&vp, width, height, desired_aspect, d3d->keep_aspect); + x = vp.x; + y = vp.y; + new_width = vp.width; + new_height = vp.height; + } + else if (d3d->keep_aspect && !force_full) + { + if (settings->video.aspect_ratio_idx == ASPECT_RATIO_CUSTOM) + { + video_viewport_t *custom = video_viewport_get_custom(); + + if (custom) + { + x = custom->x; + y = custom->y; + new_width = custom->width; + new_height = custom->height; + } + } + else + { + float delta; + + if (fabsf(device_aspect - desired_aspect) < 0.0001f) { } + else if (device_aspect > desired_aspect) + { + delta = (desired_aspect / device_aspect - 1.0f) / 2.0f + 0.5f; + x = int(roundf(width * (0.5f - delta))); + y = 0; + new_width = unsigned(roundf(2.0f * width * delta)); + } + else + { + delta = (device_aspect / desired_aspect - 1.0f) / 2.0f + 0.5f; + x = 0; + y = int(roundf(height * (0.5f - delta))); + new_height = unsigned(roundf(2.0f * height * delta)); + } + } + } + + d3d_set_viewport(d3d, x, y, new_width, new_height); + d3d->renderchain_driver->set_final_viewport(d3d, + d3d->renderchain_data, &d3d->final_viewport); +} + static bool d3d_initialize(d3d_video_t *d3d, const video_info_t *info) { unsigned width, height; @@ -331,7 +397,7 @@ static bool d3d_initialize(d3d_video_t *d3d, const video_info_t *info) video_driver_get_size(&width, &height); - d3d_calculate_rect(d3d, + d3d_set_viewport_wrap(d3d, width, height, false, true); if (!d3d_init_chain(d3d, info)) @@ -377,16 +443,6 @@ static void d3d_set_viewport(d3d_video_t *d3d, int x, int y, d3d_set_font_rect(d3d, NULL); } -static void d3d_set_viewport_wrap(void *data, - unsigned width, unsigned height, - bool force_fullscreen, - bool allow_rotate) -{ - d3d_video_t *d3d = (d3d_video_t*)data; - d3d_calculate_rect(d3d, width, height, force_fullscreen, allow_rotate); - d3d->renderchain_driver->set_final_viewport(d3d, - d3d->renderchain_data, &d3d->final_viewport); -} bool d3d_restore(d3d_video_t *d3d) { @@ -399,68 +455,6 @@ bool d3d_restore(d3d_video_t *d3d) return !d3d->needs_restore; } -static void d3d_calculate_rect(d3d_video_t *d3d, - unsigned width, unsigned height, bool force_full, bool allow_rotate) -{ - int x = 0; - int y = 0; - float device_aspect = (float)width / height; - unsigned new_width = width; - unsigned new_height = height; - settings_t *settings = config_get_ptr(); - float desired_aspect = video_driver_get_aspect_ratio(); - - video_driver_get_size(&width, &height); - - gfx_ctx_translate_aspect(d3d, &device_aspect, width, height); - - if (settings->video.scale_integer && !force_full) - { - struct video_viewport vp = {0}; - video_viewport_get_scaled_integer(&vp, width, height, desired_aspect, d3d->keep_aspect); - x = vp.x; - y = vp.y; - new_width = vp.width; - new_height = vp.height; - } - else if (d3d->keep_aspect && !force_full) - { - if (settings->video.aspect_ratio_idx == ASPECT_RATIO_CUSTOM) - { - video_viewport_t *custom = video_viewport_get_custom(); - - if (custom) - { - x = custom->x; - y = custom->y; - new_width = custom->width; - new_height = custom->height; - } - } - else - { - float delta; - - if (fabsf(device_aspect - desired_aspect) < 0.0001f) { } - else if (device_aspect > desired_aspect) - { - delta = (desired_aspect / device_aspect - 1.0f) / 2.0f + 0.5f; - x = int(roundf(width * (0.5f - delta))); - y = 0; - new_width = unsigned(roundf(2.0f * width * delta)); - } - else - { - delta = (device_aspect / desired_aspect - 1.0f) / 2.0f + 0.5f; - x = 0; - y = int(roundf(height * (0.5f - delta))); - new_height = unsigned(roundf(2.0f * height * delta)); - } - } - } - - d3d_set_viewport(d3d, x, y, new_width, new_height); -} static void d3d_set_nonblock_state(void *data, bool state) { @@ -1093,6 +1087,7 @@ static bool d3d_init_chain(d3d_video_t *d3d, const video_info_t *video_info) return true; } + #ifdef _XBOX #ifdef HAVE_RMENU From 1db4e79a17e5cd1e5c45d3d31b3b425f13edc63c Mon Sep 17 00:00:00 2001 From: twinaphex Date: Tue, 10 Nov 2015 22:09:07 +0100 Subject: [PATCH 073/216] (D3D) Buildfix --- gfx/d3d/d3d.cpp | 45 +++++++++++++++++++++++---------------------- 1 file changed, 23 insertions(+), 22 deletions(-) diff --git a/gfx/d3d/d3d.cpp b/gfx/d3d/d3d.cpp index 6083ca4c27..39d2a13028 100644 --- a/gfx/d3d/d3d.cpp +++ b/gfx/d3d/d3d.cpp @@ -269,6 +269,29 @@ static bool d3d_init_base(void *data, const video_info_t *info) return true; } +static void d3d_set_viewport(d3d_video_t *d3d, int x, int y, + unsigned width, unsigned height) +{ + D3DVIEWPORT viewport; + + /* D3D doesn't support negative X/Y viewports ... */ + if (x < 0) + x = 0; + if (y < 0) + y = 0; + + viewport.X = x; + viewport.Y = y; + viewport.Width = width; + viewport.Height = height; + viewport.MinZ = 0.0f; + viewport.MaxZ = 1.0f; + + d3d->final_viewport = viewport; + + d3d_set_font_rect(d3d, NULL); +} + static void d3d_set_viewport_wrap(void *data, unsigned width, unsigned height, bool force_full, @@ -420,28 +443,6 @@ static bool d3d_initialize(d3d_video_t *d3d, const video_info_t *info) return true; } -static void d3d_set_viewport(d3d_video_t *d3d, int x, int y, - unsigned width, unsigned height) -{ - D3DVIEWPORT viewport; - - /* D3D doesn't support negative X/Y viewports ... */ - if (x < 0) - x = 0; - if (y < 0) - y = 0; - - viewport.X = x; - viewport.Y = y; - viewport.Width = width; - viewport.Height = height; - viewport.MinZ = 0.0f; - viewport.MaxZ = 1.0f; - - d3d->final_viewport = viewport; - - d3d_set_font_rect(d3d, NULL); -} bool d3d_restore(d3d_video_t *d3d) From 8ab8423f2f2c63eced8cb8717320c9cbe4f478bc Mon Sep 17 00:00:00 2001 From: twinaphex Date: Tue, 10 Nov 2015 22:12:37 +0100 Subject: [PATCH 074/216] Revert "(D3D) Buildfix" This reverts commit 1db4e79a17e5cd1e5c45d3d31b3b425f13edc63c. --- gfx/d3d/d3d.cpp | 45 ++++++++++++++++++++++----------------------- 1 file changed, 22 insertions(+), 23 deletions(-) diff --git a/gfx/d3d/d3d.cpp b/gfx/d3d/d3d.cpp index 39d2a13028..6083ca4c27 100644 --- a/gfx/d3d/d3d.cpp +++ b/gfx/d3d/d3d.cpp @@ -269,29 +269,6 @@ static bool d3d_init_base(void *data, const video_info_t *info) return true; } -static void d3d_set_viewport(d3d_video_t *d3d, int x, int y, - unsigned width, unsigned height) -{ - D3DVIEWPORT viewport; - - /* D3D doesn't support negative X/Y viewports ... */ - if (x < 0) - x = 0; - if (y < 0) - y = 0; - - viewport.X = x; - viewport.Y = y; - viewport.Width = width; - viewport.Height = height; - viewport.MinZ = 0.0f; - viewport.MaxZ = 1.0f; - - d3d->final_viewport = viewport; - - d3d_set_font_rect(d3d, NULL); -} - static void d3d_set_viewport_wrap(void *data, unsigned width, unsigned height, bool force_full, @@ -443,6 +420,28 @@ static bool d3d_initialize(d3d_video_t *d3d, const video_info_t *info) return true; } +static void d3d_set_viewport(d3d_video_t *d3d, int x, int y, + unsigned width, unsigned height) +{ + D3DVIEWPORT viewport; + + /* D3D doesn't support negative X/Y viewports ... */ + if (x < 0) + x = 0; + if (y < 0) + y = 0; + + viewport.X = x; + viewport.Y = y; + viewport.Width = width; + viewport.Height = height; + viewport.MinZ = 0.0f; + viewport.MaxZ = 1.0f; + + d3d->final_viewport = viewport; + + d3d_set_font_rect(d3d, NULL); +} bool d3d_restore(d3d_video_t *d3d) From fd3084bf18e78c66a2f6c0d1183c9acdb28b977f Mon Sep 17 00:00:00 2001 From: twinaphex Date: Tue, 10 Nov 2015 22:12:46 +0100 Subject: [PATCH 075/216] Revert "Refactor away d3d_calculate_rect" This reverts commit 19f9833a22b2e5ef401a6340f78e677f6856fe75. --- gfx/d3d/d3d.cpp | 145 +++++++++++++++++++++++++----------------------- 1 file changed, 75 insertions(+), 70 deletions(-) diff --git a/gfx/d3d/d3d.cpp b/gfx/d3d/d3d.cpp index 6083ca4c27..928379c946 100644 --- a/gfx/d3d/d3d.cpp +++ b/gfx/d3d/d3d.cpp @@ -55,6 +55,8 @@ #endif /* forward declarations */ +static void d3d_calculate_rect(d3d_video_t *d3d, + unsigned width, unsigned height, bool force_full, bool allow_rotate); static bool d3d_init_luts(d3d_video_t *d3d); static void d3d_set_font_rect(d3d_video_t *d3d, const struct font_params *params); @@ -269,74 +271,6 @@ static bool d3d_init_base(void *data, const video_info_t *info) return true; } -static void d3d_set_viewport_wrap(void *data, - unsigned width, unsigned height, - bool force_full, - bool allow_rotate) -{ - d3d_video_t *d3d = (d3d_video_t*)data; - int x = 0; - int y = 0; - float device_aspect = (float)width / height; - unsigned new_width = width; - unsigned new_height = height; - settings_t *settings = config_get_ptr(); - float desired_aspect = video_driver_get_aspect_ratio(); - - video_driver_get_size(&width, &height); - - gfx_ctx_translate_aspect(d3d, &device_aspect, width, height); - - if (settings->video.scale_integer && !force_full) - { - struct video_viewport vp = {0}; - video_viewport_get_scaled_integer(&vp, width, height, desired_aspect, d3d->keep_aspect); - x = vp.x; - y = vp.y; - new_width = vp.width; - new_height = vp.height; - } - else if (d3d->keep_aspect && !force_full) - { - if (settings->video.aspect_ratio_idx == ASPECT_RATIO_CUSTOM) - { - video_viewport_t *custom = video_viewport_get_custom(); - - if (custom) - { - x = custom->x; - y = custom->y; - new_width = custom->width; - new_height = custom->height; - } - } - else - { - float delta; - - if (fabsf(device_aspect - desired_aspect) < 0.0001f) { } - else if (device_aspect > desired_aspect) - { - delta = (desired_aspect / device_aspect - 1.0f) / 2.0f + 0.5f; - x = int(roundf(width * (0.5f - delta))); - y = 0; - new_width = unsigned(roundf(2.0f * width * delta)); - } - else - { - delta = (device_aspect / desired_aspect - 1.0f) / 2.0f + 0.5f; - x = 0; - y = int(roundf(height * (0.5f - delta))); - new_height = unsigned(roundf(2.0f * height * delta)); - } - } - } - - d3d_set_viewport(d3d, x, y, new_width, new_height); - d3d->renderchain_driver->set_final_viewport(d3d, - d3d->renderchain_data, &d3d->final_viewport); -} - static bool d3d_initialize(d3d_video_t *d3d, const video_info_t *info) { unsigned width, height; @@ -397,7 +331,7 @@ static bool d3d_initialize(d3d_video_t *d3d, const video_info_t *info) video_driver_get_size(&width, &height); - d3d_set_viewport_wrap(d3d, + d3d_calculate_rect(d3d, width, height, false, true); if (!d3d_init_chain(d3d, info)) @@ -443,6 +377,16 @@ static void d3d_set_viewport(d3d_video_t *d3d, int x, int y, d3d_set_font_rect(d3d, NULL); } +static void d3d_set_viewport_wrap(void *data, + unsigned width, unsigned height, + bool force_fullscreen, + bool allow_rotate) +{ + d3d_video_t *d3d = (d3d_video_t*)data; + d3d_calculate_rect(d3d, width, height, force_fullscreen, allow_rotate); + d3d->renderchain_driver->set_final_viewport(d3d, + d3d->renderchain_data, &d3d->final_viewport); +} bool d3d_restore(d3d_video_t *d3d) { @@ -455,6 +399,68 @@ bool d3d_restore(d3d_video_t *d3d) return !d3d->needs_restore; } +static void d3d_calculate_rect(d3d_video_t *d3d, + unsigned width, unsigned height, bool force_full, bool allow_rotate) +{ + int x = 0; + int y = 0; + float device_aspect = (float)width / height; + unsigned new_width = width; + unsigned new_height = height; + settings_t *settings = config_get_ptr(); + float desired_aspect = video_driver_get_aspect_ratio(); + + video_driver_get_size(&width, &height); + + gfx_ctx_translate_aspect(d3d, &device_aspect, width, height); + + if (settings->video.scale_integer && !force_full) + { + struct video_viewport vp = {0}; + video_viewport_get_scaled_integer(&vp, width, height, desired_aspect, d3d->keep_aspect); + x = vp.x; + y = vp.y; + new_width = vp.width; + new_height = vp.height; + } + else if (d3d->keep_aspect && !force_full) + { + if (settings->video.aspect_ratio_idx == ASPECT_RATIO_CUSTOM) + { + video_viewport_t *custom = video_viewport_get_custom(); + + if (custom) + { + x = custom->x; + y = custom->y; + new_width = custom->width; + new_height = custom->height; + } + } + else + { + float delta; + + if (fabsf(device_aspect - desired_aspect) < 0.0001f) { } + else if (device_aspect > desired_aspect) + { + delta = (desired_aspect / device_aspect - 1.0f) / 2.0f + 0.5f; + x = int(roundf(width * (0.5f - delta))); + y = 0; + new_width = unsigned(roundf(2.0f * width * delta)); + } + else + { + delta = (device_aspect / desired_aspect - 1.0f) / 2.0f + 0.5f; + x = 0; + y = int(roundf(height * (0.5f - delta))); + new_height = unsigned(roundf(2.0f * height * delta)); + } + } + } + + d3d_set_viewport(d3d, x, y, new_width, new_height); +} static void d3d_set_nonblock_state(void *data, bool state) { @@ -1087,7 +1093,6 @@ static bool d3d_init_chain(d3d_video_t *d3d, const video_info_t *video_info) return true; } - #ifdef _XBOX #ifdef HAVE_RMENU From a6ab373140af09c335b9354fd3158392ed9848dd Mon Sep 17 00:00:00 2001 From: twinaphex Date: Tue, 10 Nov 2015 22:18:08 +0100 Subject: [PATCH 076/216] (D3D) Move d3d_set_viewport_wrap up --- gfx/d3d/d3d.cpp | 23 +++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-) diff --git a/gfx/d3d/d3d.cpp b/gfx/d3d/d3d.cpp index 928379c946..3bc43a0e53 100644 --- a/gfx/d3d/d3d.cpp +++ b/gfx/d3d/d3d.cpp @@ -271,6 +271,19 @@ static bool d3d_init_base(void *data, const video_info_t *info) return true; } +static void d3d_set_viewport_wrap(void *data, + unsigned width, unsigned height, + bool force_fullscreen, + bool allow_rotate) +{ + d3d_video_t *d3d = (d3d_video_t*)data; + d3d_calculate_rect(d3d, width, height, force_fullscreen, allow_rotate); + + if (d3d->renderchain-driver && d3d->renderchain_data) + d3d->renderchain_driver->set_final_viewport(d3d, + d3d->renderchain_data, &d3d->final_viewport); +} + static bool d3d_initialize(d3d_video_t *d3d, const video_info_t *info) { unsigned width, height; @@ -377,16 +390,6 @@ static void d3d_set_viewport(d3d_video_t *d3d, int x, int y, d3d_set_font_rect(d3d, NULL); } -static void d3d_set_viewport_wrap(void *data, - unsigned width, unsigned height, - bool force_fullscreen, - bool allow_rotate) -{ - d3d_video_t *d3d = (d3d_video_t*)data; - d3d_calculate_rect(d3d, width, height, force_fullscreen, allow_rotate); - d3d->renderchain_driver->set_final_viewport(d3d, - d3d->renderchain_data, &d3d->final_viewport); -} bool d3d_restore(d3d_video_t *d3d) { From 600c93049584bdbbd557701013d4d6e6b3d535f2 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Tue, 10 Nov 2015 22:22:31 +0100 Subject: [PATCH 077/216] (D3D) No longer use calculate_rect anywhere --- gfx/d3d/d3d.cpp | 136 +++++++++++++++++++++++------------------------- 1 file changed, 64 insertions(+), 72 deletions(-) diff --git a/gfx/d3d/d3d.cpp b/gfx/d3d/d3d.cpp index 3bc43a0e53..776fa8c887 100644 --- a/gfx/d3d/d3d.cpp +++ b/gfx/d3d/d3d.cpp @@ -55,8 +55,6 @@ #endif /* forward declarations */ -static void d3d_calculate_rect(d3d_video_t *d3d, - unsigned width, unsigned height, bool force_full, bool allow_rotate); static bool d3d_init_luts(d3d_video_t *d3d); static void d3d_set_font_rect(d3d_video_t *d3d, const struct font_params *params); @@ -273,13 +271,70 @@ static bool d3d_init_base(void *data, const video_info_t *info) static void d3d_set_viewport_wrap(void *data, unsigned width, unsigned height, - bool force_fullscreen, + bool force_full, bool allow_rotate) { d3d_video_t *d3d = (d3d_video_t*)data; - d3d_calculate_rect(d3d, width, height, force_fullscreen, allow_rotate); + int x = 0; + int y = 0; + float device_aspect = (float)width / height; + unsigned new_width = width; + unsigned new_height = height; + settings_t *settings = config_get_ptr(); + float desired_aspect = video_driver_get_aspect_ratio(); - if (d3d->renderchain-driver && d3d->renderchain_data) + video_driver_get_size(&width, &height); + + gfx_ctx_translate_aspect(d3d, &device_aspect, width, height); + + if (settings->video.scale_integer && !force_full) + { + struct video_viewport vp = {0}; + video_viewport_get_scaled_integer(&vp, width, height, desired_aspect, d3d->keep_aspect); + x = vp.x; + y = vp.y; + new_width = vp.width; + new_height = vp.height; + } + else if (d3d->keep_aspect && !force_full) + { + if (settings->video.aspect_ratio_idx == ASPECT_RATIO_CUSTOM) + { + video_viewport_t *custom = video_viewport_get_custom(); + + if (custom) + { + x = custom->x; + y = custom->y; + new_width = custom->width; + new_height = custom->height; + } + } + else + { + float delta; + + if (fabsf(device_aspect - desired_aspect) < 0.0001f) { } + else if (device_aspect > desired_aspect) + { + delta = (desired_aspect / device_aspect - 1.0f) / 2.0f + 0.5f; + x = int(roundf(width * (0.5f - delta))); + y = 0; + new_width = unsigned(roundf(2.0f * width * delta)); + } + else + { + delta = (device_aspect / desired_aspect - 1.0f) / 2.0f + 0.5f; + x = 0; + y = int(roundf(height * (0.5f - delta))); + new_height = unsigned(roundf(2.0f * height * delta)); + } + } + } + + d3d_set_viewport(d3d, x, y, new_width, new_height); + + if (d3d->renderchain_driver && d3d->renderchain_data) d3d->renderchain_driver->set_final_viewport(d3d, d3d->renderchain_data, &d3d->final_viewport); } @@ -342,17 +397,16 @@ static bool d3d_initialize(d3d_video_t *d3d, const video_info_t *info) if (!ret) return ret; - video_driver_get_size(&width, &height); - - d3d_calculate_rect(d3d, - width, height, false, true); - if (!d3d_init_chain(d3d, info)) { RARCH_ERR("Failed to initialize render chain.\n"); return false; } + video_driver_get_size(&width, &height); + d3d_set_viewport_wrap(d3d, + width, height, false, true); + #if defined(_XBOX360) strlcpy(settings->video.font_path, "game:\\media\\Arial_12.xpr", sizeof(settings->video.font_path)); @@ -402,68 +456,6 @@ bool d3d_restore(d3d_video_t *d3d) return !d3d->needs_restore; } -static void d3d_calculate_rect(d3d_video_t *d3d, - unsigned width, unsigned height, bool force_full, bool allow_rotate) -{ - int x = 0; - int y = 0; - float device_aspect = (float)width / height; - unsigned new_width = width; - unsigned new_height = height; - settings_t *settings = config_get_ptr(); - float desired_aspect = video_driver_get_aspect_ratio(); - - video_driver_get_size(&width, &height); - - gfx_ctx_translate_aspect(d3d, &device_aspect, width, height); - - if (settings->video.scale_integer && !force_full) - { - struct video_viewport vp = {0}; - video_viewport_get_scaled_integer(&vp, width, height, desired_aspect, d3d->keep_aspect); - x = vp.x; - y = vp.y; - new_width = vp.width; - new_height = vp.height; - } - else if (d3d->keep_aspect && !force_full) - { - if (settings->video.aspect_ratio_idx == ASPECT_RATIO_CUSTOM) - { - video_viewport_t *custom = video_viewport_get_custom(); - - if (custom) - { - x = custom->x; - y = custom->y; - new_width = custom->width; - new_height = custom->height; - } - } - else - { - float delta; - - if (fabsf(device_aspect - desired_aspect) < 0.0001f) { } - else if (device_aspect > desired_aspect) - { - delta = (desired_aspect / device_aspect - 1.0f) / 2.0f + 0.5f; - x = int(roundf(width * (0.5f - delta))); - y = 0; - new_width = unsigned(roundf(2.0f * width * delta)); - } - else - { - delta = (device_aspect / desired_aspect - 1.0f) / 2.0f + 0.5f; - x = 0; - y = int(roundf(height * (0.5f - delta))); - new_height = unsigned(roundf(2.0f * height * delta)); - } - } - } - - d3d_set_viewport(d3d, x, y, new_width, new_height); -} static void d3d_set_nonblock_state(void *data, bool state) { From 1f49ed0438caab4dd48d8f13840fe0d0ffeea792 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Tue, 10 Nov 2015 22:23:49 +0100 Subject: [PATCH 078/216] Move d3d_set_viewport up --- gfx/d3d/d3d.cpp | 45 +++++++++++++++++++++++---------------------- 1 file changed, 23 insertions(+), 22 deletions(-) diff --git a/gfx/d3d/d3d.cpp b/gfx/d3d/d3d.cpp index 776fa8c887..b9a77ec0d6 100644 --- a/gfx/d3d/d3d.cpp +++ b/gfx/d3d/d3d.cpp @@ -269,6 +269,29 @@ static bool d3d_init_base(void *data, const video_info_t *info) return true; } +static void d3d_set_viewport(d3d_video_t *d3d, int x, int y, + unsigned width, unsigned height) +{ + D3DVIEWPORT viewport; + + /* D3D doesn't support negative X/Y viewports ... */ + if (x < 0) + x = 0; + if (y < 0) + y = 0; + + viewport.X = x; + viewport.Y = y; + viewport.Width = width; + viewport.Height = height; + viewport.MinZ = 0.0f; + viewport.MaxZ = 1.0f; + + d3d->final_viewport = viewport; + + d3d_set_font_rect(d3d, NULL); +} + static void d3d_set_viewport_wrap(void *data, unsigned width, unsigned height, bool force_full, @@ -421,28 +444,6 @@ static bool d3d_initialize(d3d_video_t *d3d, const video_info_t *info) return true; } -static void d3d_set_viewport(d3d_video_t *d3d, int x, int y, - unsigned width, unsigned height) -{ - D3DVIEWPORT viewport; - - /* D3D doesn't support negative X/Y viewports ... */ - if (x < 0) - x = 0; - if (y < 0) - y = 0; - - viewport.X = x; - viewport.Y = y; - viewport.Width = width; - viewport.Height = height; - viewport.MinZ = 0.0f; - viewport.MaxZ = 1.0f; - - d3d->final_viewport = viewport; - - d3d_set_font_rect(d3d, NULL); -} bool d3d_restore(d3d_video_t *d3d) From 07cf7cbd36bbe1897566c0278eebd8f4ac54afaf Mon Sep 17 00:00:00 2001 From: twinaphex Date: Tue, 10 Nov 2015 22:30:21 +0100 Subject: [PATCH 079/216] Rename d3d_set_viewport_wrap to d3d_set_viewport --- gfx/d3d/d3d.cpp | 64 +++++++++++++++++++++---------------------------- 1 file changed, 27 insertions(+), 37 deletions(-) diff --git a/gfx/d3d/d3d.cpp b/gfx/d3d/d3d.cpp index b9a77ec0d6..975eb6b0db 100644 --- a/gfx/d3d/d3d.cpp +++ b/gfx/d3d/d3d.cpp @@ -269,34 +269,12 @@ static bool d3d_init_base(void *data, const video_info_t *info) return true; } -static void d3d_set_viewport(d3d_video_t *d3d, int x, int y, - unsigned width, unsigned height) -{ - D3DVIEWPORT viewport; - - /* D3D doesn't support negative X/Y viewports ... */ - if (x < 0) - x = 0; - if (y < 0) - y = 0; - - viewport.X = x; - viewport.Y = y; - viewport.Width = width; - viewport.Height = height; - viewport.MinZ = 0.0f; - viewport.MaxZ = 1.0f; - - d3d->final_viewport = viewport; - - d3d_set_font_rect(d3d, NULL); -} - -static void d3d_set_viewport_wrap(void *data, +static void d3d_set_viewport(void *data, unsigned width, unsigned height, bool force_full, bool allow_rotate) { + D3DVIEWPORT viewport; d3d_video_t *d3d = (d3d_video_t*)data; int x = 0; int y = 0; @@ -355,7 +333,23 @@ static void d3d_set_viewport_wrap(void *data, } } - d3d_set_viewport(d3d, x, y, new_width, new_height); + + /* D3D doesn't support negative X/Y viewports ... */ + if (x < 0) + x = 0; + if (y < 0) + y = 0; + + viewport.X = x; + viewport.Y = y; + viewport.Width = width; + viewport.Height = height; + viewport.MinZ = 0.0f; + viewport.MaxZ = 1.0f; + + d3d->final_viewport = viewport; + + d3d_set_font_rect(d3d, NULL); if (d3d->renderchain_driver && d3d->renderchain_data) d3d->renderchain_driver->set_final_viewport(d3d, @@ -427,7 +421,7 @@ static bool d3d_initialize(d3d_video_t *d3d, const video_info_t *info) } video_driver_get_size(&width, &height); - d3d_set_viewport_wrap(d3d, + d3d_set_viewport(d3d, width, height, false, true); #if defined(_XBOX360) @@ -1148,7 +1142,7 @@ static bool texture_image_render(d3d_video_t *d3d, d3d_set_vertex_shader(d3dr, D3DFVF_CUSTOMVERTEX, NULL); if (force_fullscreen) - d3d_set_viewport_wrap(d3d, w, h, force_fullscreen, false); + d3d_set_viewport(d3d, w, h, force_fullscreen, false); d3d_draw_primitive(d3dr, D3DPT_QUADLIST, 0, 1); return true; @@ -1435,7 +1429,7 @@ static void d3d_overlay_render(d3d_video_t *d3d, overlay_t *overlay) video_driver_get_size(&width, &height); if (overlay->fullscreen) - d3d_set_viewport_wrap(d3d, width, height, true, false); + d3d_set_viewport(d3d, width, height, true, false); /* Render overlay. */ d3d_set_texture(d3d->dev, 0, overlay->tex); @@ -1447,7 +1441,7 @@ static void d3d_overlay_render(d3d_video_t *d3d, overlay_t *overlay) /* Restore previous state. */ d3d_disable_blend_func(d3d->dev); - d3d_set_viewport(d3d->dev, &d3d->final_viewport); + d3d_set_viewport(d3d->dev, width, height, false, false); } static void d3d_free_overlay(d3d_video_t *d3d, overlay_t *overlay) @@ -1648,17 +1642,13 @@ static bool d3d_frame(void *data, const void *frame, if (d3d->should_resize) { d3d->should_resize = false; - - gfx_ctx_set_resize(d3d, width, height); - - d3d_set_viewport_wrap(d3d, width, height, false, true); - - + gfx_ctx_set_resize(d3d, width, height); + d3d_set_viewport(d3d, width, height, false, true); } /* render_chain() only clears out viewport, * clear out everything. */ - d3d_set_viewport_wrap(d3d, width, height, false, false); + d3d_set_viewport(d3d, width, height, false, false); d3d_clear(d3dr, 0, 0, D3DCLEAR_TARGET, 0, 1, 0); /* Insert black frame first, so we @@ -1993,7 +1983,7 @@ video_driver_t video_d3d = { d3d_set_shader, d3d_free, "d3d", - d3d_set_viewport_wrap, + d3d_set_viewport, d3d_set_rotation, d3d_viewport_info, d3d_read_viewport, From 442ebcc1b8b38c54e621cba44456efbdfb9676e8 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Tue, 10 Nov 2015 22:36:05 +0100 Subject: [PATCH 080/216] Don't use new_width/new_height anymore --- gfx/d3d/d3d.cpp | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/gfx/d3d/d3d.cpp b/gfx/d3d/d3d.cpp index 975eb6b0db..ca97569b54 100644 --- a/gfx/d3d/d3d.cpp +++ b/gfx/d3d/d3d.cpp @@ -279,8 +279,6 @@ static void d3d_set_viewport(void *data, int x = 0; int y = 0; float device_aspect = (float)width / height; - unsigned new_width = width; - unsigned new_height = height; settings_t *settings = config_get_ptr(); float desired_aspect = video_driver_get_aspect_ratio(); @@ -294,8 +292,8 @@ static void d3d_set_viewport(void *data, video_viewport_get_scaled_integer(&vp, width, height, desired_aspect, d3d->keep_aspect); x = vp.x; y = vp.y; - new_width = vp.width; - new_height = vp.height; + width = vp.width; + height = vp.height; } else if (d3d->keep_aspect && !force_full) { @@ -307,8 +305,8 @@ static void d3d_set_viewport(void *data, { x = custom->x; y = custom->y; - new_width = custom->width; - new_height = custom->height; + width = custom->width; + height = custom->height; } } else @@ -321,14 +319,14 @@ static void d3d_set_viewport(void *data, delta = (desired_aspect / device_aspect - 1.0f) / 2.0f + 0.5f; x = int(roundf(width * (0.5f - delta))); y = 0; - new_width = unsigned(roundf(2.0f * width * delta)); + width = unsigned(roundf(2.0f * width * delta)); } else { delta = (device_aspect / desired_aspect - 1.0f) / 2.0f + 0.5f; x = 0; y = int(roundf(height * (0.5f - delta))); - new_height = unsigned(roundf(2.0f * height * delta)); + height = unsigned(roundf(2.0f * height * delta)); } } } From 028a390f8ec9945a408cfb9a0ae6341ab9bd169d Mon Sep 17 00:00:00 2001 From: twinaphex Date: Tue, 10 Nov 2015 22:46:45 +0100 Subject: [PATCH 081/216] (D3D) Cleanups --- gfx/d3d/d3d.cpp | 52 +++++++++++++++++++++++++------------------------ 1 file changed, 27 insertions(+), 25 deletions(-) diff --git a/gfx/d3d/d3d.cpp b/gfx/d3d/d3d.cpp index ca97569b54..cbe9e9e004 100644 --- a/gfx/d3d/d3d.cpp +++ b/gfx/d3d/d3d.cpp @@ -55,7 +55,30 @@ #endif /* forward declarations */ -static bool d3d_init_luts(d3d_video_t *d3d); +static bool d3d_init_luts(d3d_video_t *d3d) +{ + unsigned i; + settings_t *settings = config_get_ptr(); + + if (!d3d->renderchain_driver->add_lut) + return true; + + for (i = 0; i < d3d->shader.luts; i++) + { + bool ret = d3d->renderchain_driver->add_lut( + d3d->renderchain_data, + d3d->shader.lut[i].id, d3d->shader.lut[i].path, + d3d->shader.lut[i].filter == RARCH_FILTER_UNSPEC ? + settings->video.smooth : + (d3d->shader.lut[i].filter == RARCH_FILTER_LINEAR)); + + if (!ret) + return ret; + } + + return true; +} + static void d3d_set_font_rect(d3d_video_t *d3d, const struct font_params *params); static bool d3d_process_shader(d3d_video_t *d3d); @@ -942,7 +965,6 @@ static RECT d3d_monitor_rect(d3d_video_t *d3d) #endif #ifndef DONT_HAVE_STATE_TRACKER -#ifndef _XBOX static bool d3d_init_imports(d3d_video_t *d3d) { state_tracker_t *state_tracker = NULL; @@ -950,6 +972,8 @@ static bool d3d_init_imports(d3d_video_t *d3d) if (!d3d->shader.variables) return true; + if (!d3d->renderchain_driver->add_state_tracker) + return true; tracker_info.wram = (uint8_t*) core.retro_get_memory_data(RETRO_MEMORY_SYSTEM_RAM); @@ -975,10 +999,10 @@ static bool d3d_init_imports(d3d_video_t *d3d) } d3d->renderchain_driver->add_state_tracker(d3d->renderchain_data, state_tracker); + return true; } #endif -#endif static bool d3d_init_chain(d3d_video_t *d3d, const video_info_t *video_info) { @@ -1306,28 +1330,6 @@ static bool d3d_process_shader(d3d_video_t *d3d) return d3d_init_singlepass(d3d); } -#ifndef _XBOX -static bool d3d_init_luts(d3d_video_t *d3d) -{ - unsigned i; - settings_t *settings = config_get_ptr(); - - for (i = 0; i < d3d->shader.luts; i++) - { - bool ret = d3d->renderchain_driver->add_lut( - d3d->renderchain_data, - d3d->shader.lut[i].id, d3d->shader.lut[i].path, - d3d->shader.lut[i].filter == RARCH_FILTER_UNSPEC ? - settings->video.smooth : - (d3d->shader.lut[i].filter == RARCH_FILTER_LINEAR)); - - if (!ret) - return ret; - } - - return true; -} -#endif #ifdef HAVE_OVERLAY static void d3d_overlay_render(d3d_video_t *d3d, overlay_t *overlay) From d1626265ce20c8d1b218a7fd76794dbc0adcb622 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Tue, 10 Nov 2015 23:00:36 +0100 Subject: [PATCH 082/216] (D3D) Call SetViewport directly --- gfx/d3d/render_chain_cg.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gfx/d3d/render_chain_cg.cpp b/gfx/d3d/render_chain_cg.cpp index 34e0f1e242..ec3a53b21b 100644 --- a/gfx/d3d/render_chain_cg.cpp +++ b/gfx/d3d/render_chain_cg.cpp @@ -1306,7 +1306,7 @@ static void renderchain_set_viewport(void *data, void *viewport_data) return; d3dr = (LPDIRECT3DDEVICE)chain->dev; - d3d_set_viewport(d3dr, vp); + d3dr->SetViewport(vp); } static void renderchain_blit_to_texture(void *data, From ffe711642feb4c5665688f5b1d8c21fc8190f4a2 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Tue, 10 Nov 2015 23:09:13 +0100 Subject: [PATCH 083/216] (D3D) Get rid of some backbuffer glitches --- gfx/d3d/d3d.cpp | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/gfx/d3d/d3d.cpp b/gfx/d3d/d3d.cpp index cbe9e9e004..1564431db3 100644 --- a/gfx/d3d/d3d.cpp +++ b/gfx/d3d/d3d.cpp @@ -1648,7 +1648,14 @@ static bool d3d_frame(void *data, const void *frame, /* render_chain() only clears out viewport, * clear out everything. */ - d3d_set_viewport(d3d, width, height, false, false); + D3DVIEWPORT screen_vp; + screen_vp.X = 0; + screen_vp.Y = 0; + screen_vp.MinZ = 0; + screen_vp.MaxZ = 1; + screen_vp.Width = width; + screen_vp.Height = height; + d3dr->SetViewport(&screen_vp); d3d_clear(d3dr, 0, 0, D3DCLEAR_TARGET, 0, 1, 0); /* Insert black frame first, so we From bcc0614fc42fdc9271569530cbc1dfa105c4273b Mon Sep 17 00:00:00 2001 From: twinaphex Date: Tue, 10 Nov 2015 23:09:58 +0100 Subject: [PATCH 084/216] Use d3d_set_viewport --- gfx/d3d/d3d.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gfx/d3d/d3d.cpp b/gfx/d3d/d3d.cpp index 1564431db3..0f55f67c46 100644 --- a/gfx/d3d/d3d.cpp +++ b/gfx/d3d/d3d.cpp @@ -1655,7 +1655,7 @@ static bool d3d_frame(void *data, const void *frame, screen_vp.MaxZ = 1; screen_vp.Width = width; screen_vp.Height = height; - d3dr->SetViewport(&screen_vp); + d3d_set_viewport(d3dr, &screen_vp); d3d_clear(d3dr, 0, 0, D3DCLEAR_TARGET, 0, 1, 0); /* Insert black frame first, so we From ebe0a4aa4a61035b685ef64f2e1d1c461ddd71a7 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Wed, 11 Nov 2015 01:34:00 +0100 Subject: [PATCH 085/216] Add more function pointers to renderchain --- gfx/d3d/d3d.cpp | 132 ++++------------------------------ gfx/d3d/render_chain_cg.cpp | 110 ++++++++++++++++++++++++++++ gfx/d3d/render_chain_driver.h | 2 + gfx/d3d/render_chain_null.c | 2 + gfx/d3d/render_chain_xdk.cpp | 2 + 5 files changed, 131 insertions(+), 117 deletions(-) diff --git a/gfx/d3d/d3d.cpp b/gfx/d3d/d3d.cpp index 0f55f67c46..d51e8ab3d1 100644 --- a/gfx/d3d/d3d.cpp +++ b/gfx/d3d/d3d.cpp @@ -79,8 +79,6 @@ static bool d3d_init_luts(d3d_video_t *d3d) return true; } -static void d3d_set_font_rect(d3d_video_t *d3d, - const struct font_params *params); static bool d3d_process_shader(d3d_video_t *d3d); static bool d3d_init_chain(d3d_video_t *d3d, const video_info_t *video_info); @@ -370,11 +368,11 @@ static void d3d_set_viewport(void *data, d3d->final_viewport = viewport; - d3d_set_font_rect(d3d, NULL); - if (d3d->renderchain_driver && d3d->renderchain_data) - d3d->renderchain_driver->set_final_viewport(d3d, - d3d->renderchain_data, &d3d->final_viewport); + { + if (d3d->renderchain_driver->set_font_rect) + d3d->renderchain_driver->set_font_rect(d3d, NULL); + } } static bool d3d_initialize(d3d_video_t *d3d, const video_info_t *info) @@ -576,8 +574,8 @@ static void d3d_set_osd_msg(void *data, const char *msg, driver_t *driver = driver_get_ptr(); const font_renderer_t *font_ctx = driver->font_osd_driver; - if (params) - d3d_set_font_rect(d3d, params); + if (d3d->renderchain_driver->set_font_rect && params) + d3d->renderchain_driver->set_font_rect(d3d, params); if (font_ctx->render_msg) font_ctx->render_msg(driver->font_osd_data, msg, params); @@ -1261,39 +1259,6 @@ static bool d3d_init_multipass(d3d_video_t *d3d) } #endif -static void d3d_set_font_rect(d3d_video_t *d3d, - const struct font_params *params) -{ - settings_t *settings = config_get_ptr(); - float pos_x = settings->video.msg_pos_x; - float pos_y = settings->video.msg_pos_y; - float font_size = settings->video.font_size; - - if (params) - { - pos_x = params->x; - pos_y = params->y; - font_size *= params->scale; - } - - if (!d3d) - return; - - d3d->font_rect.left = d3d->final_viewport.X + - d3d->final_viewport.Width * pos_x; - d3d->font_rect.right = d3d->final_viewport.X + - d3d->final_viewport.Width; - d3d->font_rect.top = d3d->final_viewport.Y + - (1.0f - pos_y) * d3d->final_viewport.Height - font_size; - d3d->font_rect.bottom = d3d->final_viewport.Height; - - d3d->font_rect_shifted = d3d->font_rect; - d3d->font_rect_shifted.left -= 2; - d3d->font_rect_shifted.right -= 2; - d3d->font_rect_shifted.top += 2; - d3d->font_rect_shifted.bottom += 2; -} - static bool d3d_init_singlepass(d3d_video_t *d3d) { #ifndef _XBOX @@ -1641,9 +1606,12 @@ static bool d3d_frame(void *data, const void *frame, if (d3d->should_resize) { - d3d->should_resize = false; - gfx_ctx_set_resize(d3d, width, height); d3d_set_viewport(d3d, width, height, false, true); + if (d3d->renderchain_driver->set_final_viewport) + d3d->renderchain_driver->set_final_viewport(d3d, + d3d->renderchain_data, &d3d->final_viewport); + + d3d->should_resize = false; } /* render_chain() only clears out viewport, @@ -1736,82 +1704,12 @@ static bool d3d_frame(void *data, const void *frame, static bool d3d_read_viewport(void *data, uint8_t *buffer) { - unsigned width, height; -#ifndef _XBOX - D3DLOCKED_RECT rect; - LPDIRECT3DSURFACE target = NULL; - LPDIRECT3DSURFACE dest = NULL; -#endif - bool ret = true; - d3d_video_t *d3d = (d3d_video_t*)data; - LPDIRECT3DDEVICE d3dr = (LPDIRECT3DDEVICE)d3d->dev; - static struct retro_perf_counter d3d_read_viewport = {0}; + d3d_video_t *d3d = (d3d_video_t*)data; - video_driver_get_size(&width, &height); + if (!d3d || !d3d->renderchain_driver || !d3d->renderchain_driver->read_viewport) + return false; - rarch_perf_init(&d3d_read_viewport, "d3d_read_viewport"); - retro_perf_start(&d3d_read_viewport); - - (void)data; - (void)buffer; - -#ifdef _XBOX - ret = false; -#else - if (FAILED(d3d->d3d_err = d3dr->GetRenderTarget(0, &target))) - { - ret = false; - goto end; - } - - if (FAILED(d3d->d3d_err = d3dr->CreateOffscreenPlainSurface( - width, height, - D3DFMT_X8R8G8B8, D3DPOOL_SYSTEMMEM, - &dest, NULL))) - { - ret = false; - goto end; - } - - if (FAILED(d3d->d3d_err = d3dr->GetRenderTargetData(target, dest))) - { - ret = false; - goto end; - } - - if (SUCCEEDED(dest->LockRect(&rect, NULL, D3DLOCK_READONLY))) - { - unsigned x, y; - unsigned pitchpix = rect.Pitch / 4; - const uint32_t *pixels = (const uint32_t*)rect.pBits; - - pixels += d3d->final_viewport.X; - pixels += (d3d->final_viewport.Height - 1) * pitchpix; - pixels -= d3d->final_viewport.Y * pitchpix; - - for (y = 0; y < d3d->final_viewport.Height; y++, pixels -= pitchpix) - { - for (x = 0; x < d3d->final_viewport.Width; x++) - { - *buffer++ = (pixels[x] >> 0) & 0xff; - *buffer++ = (pixels[x] >> 8) & 0xff; - *buffer++ = (pixels[x] >> 16) & 0xff; - } - } - - dest->UnlockRect(); - } - else - ret = false; - -end: - retro_perf_stop(&d3d_read_viewport); - if (target) - target->Release(); - if (dest) - dest->Release(); -#endif - return ret; + return d3d->renderchain_driver->read_viewport(d3d, buffer); } static bool d3d_set_shader(void *data, diff --git a/gfx/d3d/render_chain_cg.cpp b/gfx/d3d/render_chain_cg.cpp index ec3a53b21b..5f0522e079 100644 --- a/gfx/d3d/render_chain_cg.cpp +++ b/gfx/d3d/render_chain_cg.cpp @@ -1486,6 +1486,114 @@ static bool cg_d3d9_renderchain_render(void *chain_data, const void *data, return true; } +static void cg_d3d9_renderchain_set_font_rect(void *data, + const struct font_params *params) +{ + settings_t *settings = config_get_ptr(); + d3d_video_t *d3d = (d3d_video_t*)data; + float pos_x = settings->video.msg_pos_x; + float pos_y = settings->video.msg_pos_y; + float font_size = settings->video.font_size; + + if (params) + { + pos_x = params->x; + pos_y = params->y; + font_size *= params->scale; + } + + if (!d3d) + return; + + d3d->font_rect.left = d3d->final_viewport.X + + d3d->final_viewport.Width * pos_x; + d3d->font_rect.right = d3d->final_viewport.X + + d3d->final_viewport.Width; + d3d->font_rect.top = d3d->final_viewport.Y + + (1.0f - pos_y) * d3d->final_viewport.Height - font_size; + d3d->font_rect.bottom = d3d->final_viewport.Height; + + d3d->font_rect_shifted = d3d->font_rect; + d3d->font_rect_shifted.left -= 2; + d3d->font_rect_shifted.right -= 2; + d3d->font_rect_shifted.top += 2; + d3d->font_rect_shifted.bottom += 2; +} + +static bool cg_d3d9_renderchain_read_viewport(void *data, uint8_t *buffer) +{ + unsigned width, height; + D3DLOCKED_RECT rect; + LPDIRECT3DSURFACE target = NULL; + LPDIRECT3DSURFACE dest = NULL; + bool ret = true; + d3d_video_t *d3d = (d3d_video_t*)data; + LPDIRECT3DDEVICE d3dr = (LPDIRECT3DDEVICE)d3d->dev; + static struct retro_perf_counter d3d_read_viewport = {0}; + + video_driver_get_size(&width, &height); + + rarch_perf_init(&d3d_read_viewport, "d3d_read_viewport"); + retro_perf_start(&d3d_read_viewport); + + (void)data; + (void)buffer; + + if (FAILED(d3d->d3d_err = d3dr->GetRenderTarget(0, &target))) + { + ret = false; + goto end; + } + + if (FAILED(d3d->d3d_err = d3dr->CreateOffscreenPlainSurface( + width, height, + D3DFMT_X8R8G8B8, D3DPOOL_SYSTEMMEM, + &dest, NULL))) + { + ret = false; + goto end; + } + + if (FAILED(d3d->d3d_err = d3dr->GetRenderTargetData(target, dest))) + { + ret = false; + goto end; + } + + if (SUCCEEDED(dest->LockRect(&rect, NULL, D3DLOCK_READONLY))) + { + unsigned x, y; + unsigned pitchpix = rect.Pitch / 4; + const uint32_t *pixels = (const uint32_t*)rect.pBits; + + pixels += d3d->final_viewport.X; + pixels += (d3d->final_viewport.Height - 1) * pitchpix; + pixels -= d3d->final_viewport.Y * pitchpix; + + for (y = 0; y < d3d->final_viewport.Height; y++, pixels -= pitchpix) + { + for (x = 0; x < d3d->final_viewport.Width; x++) + { + *buffer++ = (pixels[x] >> 0) & 0xff; + *buffer++ = (pixels[x] >> 8) & 0xff; + *buffer++ = (pixels[x] >> 16) & 0xff; + } + } + + dest->UnlockRect(); + } + else + ret = false; + +end: + retro_perf_stop(&d3d_read_viewport); + if (target) + target->Release(); + if (dest) + dest->Release(); + return ret; +} + renderchain_driver_t cg_d3d9_renderchain = { cg_d3d9_renderchain_free, cg_d3d9_renderchain_new, @@ -1499,5 +1607,7 @@ renderchain_driver_t cg_d3d9_renderchain = { cg_d3d9_renderchain_add_state_tracker, cg_d3d9_renderchain_render, cg_d3d9_renderchain_convert_geometry, + cg_d3d9_renderchain_set_font_rect, + cg_d3d9_renderchain_read_viewport, "cg_d3d9", }; diff --git a/gfx/d3d/render_chain_driver.h b/gfx/d3d/render_chain_driver.h index a92012f6bd..25edbd9fb2 100644 --- a/gfx/d3d/render_chain_driver.h +++ b/gfx/d3d/render_chain_driver.h @@ -66,6 +66,8 @@ typedef struct renderchain_driver unsigned *out_width, unsigned *out_height, unsigned width, unsigned height, void *final_viewport); + void (*set_font_rect)(void *data, const struct font_params *params); + bool (*read_viewport)(void *data, uint8_t *buffer); const char *ident; } renderchain_driver_t; diff --git a/gfx/d3d/render_chain_null.c b/gfx/d3d/render_chain_null.c index c178ed90e1..f96d418091 100644 --- a/gfx/d3d/render_chain_null.c +++ b/gfx/d3d/render_chain_null.c @@ -144,5 +144,7 @@ renderchain_driver_t null_renderchain = { null_renderchain_add_state_tracker, null_renderchain_render, null_renderchain_convert_geometry, + NULL, + NULL, "null", }; diff --git a/gfx/d3d/render_chain_xdk.cpp b/gfx/d3d/render_chain_xdk.cpp index 4f4ab42910..46376df86e 100644 --- a/gfx/d3d/render_chain_xdk.cpp +++ b/gfx/d3d/render_chain_xdk.cpp @@ -474,5 +474,7 @@ renderchain_driver_t xdk_renderchain = { xdk_renderchain_add_state_tracker, xdk_renderchain_render, xdk_renderchain_convert_geometry, + NULL, + NULL, "xdk", }; From 71c40f1bc862c8ad8e2937c9def51e518938060f Mon Sep 17 00:00:00 2001 From: twinaphex Date: Wed, 11 Nov 2015 01:43:58 +0100 Subject: [PATCH 086/216] Add viewport_info callback to renderchain --- gfx/d3d/d3d.cpp | 25 +++++++++---------------- gfx/d3d/render_chain_cg.cpp | 20 ++++++++++++++++++++ gfx/d3d/render_chain_driver.h | 4 +++- gfx/d3d/render_chain_null.c | 1 + gfx/d3d/render_chain_xdk.cpp | 20 ++++++++++++++++++++ 5 files changed, 53 insertions(+), 17 deletions(-) diff --git a/gfx/d3d/d3d.cpp b/gfx/d3d/d3d.cpp index d51e8ab3d1..a33f0e8762 100644 --- a/gfx/d3d/d3d.cpp +++ b/gfx/d3d/d3d.cpp @@ -736,21 +736,12 @@ static bool d3d_construct(d3d_video_t *d3d, static void d3d_viewport_info(void *data, struct video_viewport *vp) { - unsigned width, height; - d3d_video_t *d3d = (d3d_video_t*)data; + d3d_video_t *d3d = (d3d_video_t*)data; - if (!d3d || !vp) - return; + if (!d3d || !d3d->renderchain_driver || !d3d->renderchain_driver->viewport_info) + return false; - video_driver_get_size(&width, &height); - - vp->x = d3d->final_viewport.X; - vp->y = d3d->final_viewport.Y; - vp->width = d3d->final_viewport.Width; - vp->height = d3d->final_viewport.Height; - - vp->full_width = width; - vp->full_height = height; + d3d->renderchain_driver->viewport_info(d3d, vp); } static void d3d_set_rotation(void *data, unsigned rot) @@ -762,7 +753,6 @@ static void d3d_set_rotation(void *data, unsigned rot) return; d3d->dev_rotation = rot; - //d3d_set_projection(d3d, &ortho, true); } static void d3d_show_mouse(void *data, bool state) @@ -1299,6 +1289,7 @@ static bool d3d_process_shader(d3d_video_t *d3d) #ifdef HAVE_OVERLAY static void d3d_overlay_render(d3d_video_t *d3d, overlay_t *overlay) { + struct video_viewport vp; unsigned width, height; void *verts; unsigned i; @@ -1343,9 +1334,11 @@ static void d3d_overlay_render(d3d_video_t *d3d, overlay_t *overlay) vert[i].r = vert[i].g = vert[i].b = 1.0f; vert[i].a = overlay->alpha_mod; } + + d3d_viewport_info(d3d, &vp); - overlay_width = d3d->final_viewport.Width; - overlay_height = d3d->final_viewport.Height; + overlay_width = vp->Width; + overlay_height = vp->Height; vert[0].x = overlay->vert_coords.x * overlay_width; vert[1].x = (overlay->vert_coords.x + overlay->vert_coords.w) diff --git a/gfx/d3d/render_chain_cg.cpp b/gfx/d3d/render_chain_cg.cpp index 5f0522e079..57ca5bb141 100644 --- a/gfx/d3d/render_chain_cg.cpp +++ b/gfx/d3d/render_chain_cg.cpp @@ -1594,6 +1594,25 @@ end: return ret; } +static void cg_d3d9_renderchain_viewport_info(void *data, struct video_viewport *vp) +{ + unsigned width, height; + d3d_video_t *d3d = (d3d_video_t*)data; + + if (!d3d || !vp) + return; + + video_driver_get_size(&width, &height); + + vp->x = d3d->final_viewport.X; + vp->y = d3d->final_viewport.Y; + vp->width = d3d->final_viewport.Width; + vp->height = d3d->final_viewport.Height; + + vp->full_width = width; + vp->full_height = height; +} + renderchain_driver_t cg_d3d9_renderchain = { cg_d3d9_renderchain_free, cg_d3d9_renderchain_new, @@ -1609,5 +1628,6 @@ renderchain_driver_t cg_d3d9_renderchain = { cg_d3d9_renderchain_convert_geometry, cg_d3d9_renderchain_set_font_rect, cg_d3d9_renderchain_read_viewport, + cg_d3d9_renderchain_viewport_info, "cg_d3d9", }; diff --git a/gfx/d3d/render_chain_driver.h b/gfx/d3d/render_chain_driver.h index 25edbd9fb2..6043d17abd 100644 --- a/gfx/d3d/render_chain_driver.h +++ b/gfx/d3d/render_chain_driver.h @@ -17,8 +17,9 @@ #ifndef __D3D_RENDER_CHAIN_H #define __D3D_RENDER_CHAIN_H -#include "../video_state_tracker.h" #include "../video_shader_parse.h" +#include "../video_state_tracker.h" +#include "../video_viewport.h" #include "../../libretro.h" #include "d3d_defines.h" @@ -68,6 +69,7 @@ typedef struct renderchain_driver void *final_viewport); void (*set_font_rect)(void *data, const struct font_params *params); bool (*read_viewport)(void *data, uint8_t *buffer); + void (*viewport_info)(void *data, struct video_viewport *vp); const char *ident; } renderchain_driver_t; diff --git a/gfx/d3d/render_chain_null.c b/gfx/d3d/render_chain_null.c index f96d418091..c5731c32ce 100644 --- a/gfx/d3d/render_chain_null.c +++ b/gfx/d3d/render_chain_null.c @@ -146,5 +146,6 @@ renderchain_driver_t null_renderchain = { null_renderchain_convert_geometry, NULL, NULL, + NULL, "null", }; diff --git a/gfx/d3d/render_chain_xdk.cpp b/gfx/d3d/render_chain_xdk.cpp index 46376df86e..00b9e90c74 100644 --- a/gfx/d3d/render_chain_xdk.cpp +++ b/gfx/d3d/render_chain_xdk.cpp @@ -461,6 +461,25 @@ static bool xdk_renderchain_reinit(void *data, return true; } +static void xdk_renderchain_viewport_info(void *data, struct video_viewport *vp) +{ + unsigned width, height; + d3d_video_t *d3d = (d3d_video_t*)data; + + if (!d3d || !vp) + return; + + video_driver_get_size(&width, &height); + + vp->x = d3d->final_viewport.X; + vp->y = d3d->final_viewport.Y; + vp->width = d3d->final_viewport.Width; + vp->height = d3d->final_viewport.Height; + + vp->full_width = width; + vp->full_height = height; +} + renderchain_driver_t xdk_renderchain = { xdk_renderchain_free, xdk_renderchain_new, @@ -476,5 +495,6 @@ renderchain_driver_t xdk_renderchain = { xdk_renderchain_convert_geometry, NULL, NULL, + xdk_renderchain_viewport_info, "xdk", }; From 2b50d1c01c2720effc338245b0d40fc9658e074b Mon Sep 17 00:00:00 2001 From: twinaphex Date: Wed, 11 Nov 2015 01:45:43 +0100 Subject: [PATCH 087/216] (D3D) Buildfixes --- gfx/d3d/d3d.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/gfx/d3d/d3d.cpp b/gfx/d3d/d3d.cpp index a33f0e8762..26ada6ded8 100644 --- a/gfx/d3d/d3d.cpp +++ b/gfx/d3d/d3d.cpp @@ -739,7 +739,7 @@ static void d3d_viewport_info(void *data, struct video_viewport *vp) d3d_video_t *d3d = (d3d_video_t*)data; if (!d3d || !d3d->renderchain_driver || !d3d->renderchain_driver->viewport_info) - return false; + return; d3d->renderchain_driver->viewport_info(d3d, vp); } @@ -1337,8 +1337,8 @@ static void d3d_overlay_render(d3d_video_t *d3d, overlay_t *overlay) d3d_viewport_info(d3d, &vp); - overlay_width = vp->Width; - overlay_height = vp->Height; + overlay_width = vp->width; + overlay_height = vp->height; vert[0].x = overlay->vert_coords.x * overlay_width; vert[1].x = (overlay->vert_coords.x + overlay->vert_coords.w) From 376ecb2a479d85b2f673b29e4c295e79cfb2732f Mon Sep 17 00:00:00 2001 From: twinaphex Date: Wed, 11 Nov 2015 01:46:59 +0100 Subject: [PATCH 088/216] (D3D) Two more buildfixes --- gfx/d3d/d3d.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/gfx/d3d/d3d.cpp b/gfx/d3d/d3d.cpp index 26ada6ded8..693c590ff8 100644 --- a/gfx/d3d/d3d.cpp +++ b/gfx/d3d/d3d.cpp @@ -1337,8 +1337,8 @@ static void d3d_overlay_render(d3d_video_t *d3d, overlay_t *overlay) d3d_viewport_info(d3d, &vp); - overlay_width = vp->width; - overlay_height = vp->height; + overlay_width = vp.width; + overlay_height = vp.height; vert[0].x = overlay->vert_coords.x * overlay_width; vert[1].x = (overlay->vert_coords.x + overlay->vert_coords.w) From 91a99d9da534282a5876b75965f7ea99ef957d93 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Wed, 11 Nov 2015 01:54:05 +0100 Subject: [PATCH 089/216] (render_chain_cg.cpp) Use d3d_set_viewport --- gfx/d3d/render_chain_cg.cpp | 2 +- gfx/d3d/render_chain_xdk.cpp | 1 - 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/gfx/d3d/render_chain_cg.cpp b/gfx/d3d/render_chain_cg.cpp index 57ca5bb141..5cb48e2f4c 100644 --- a/gfx/d3d/render_chain_cg.cpp +++ b/gfx/d3d/render_chain_cg.cpp @@ -1306,7 +1306,7 @@ static void renderchain_set_viewport(void *data, void *viewport_data) return; d3dr = (LPDIRECT3DDEVICE)chain->dev; - d3dr->SetViewport(vp); + d3d_set_viewport(d3dr, vp); } static void renderchain_blit_to_texture(void *data, diff --git a/gfx/d3d/render_chain_xdk.cpp b/gfx/d3d/render_chain_xdk.cpp index 00b9e90c74..772bd57f81 100644 --- a/gfx/d3d/render_chain_xdk.cpp +++ b/gfx/d3d/render_chain_xdk.cpp @@ -20,7 +20,6 @@ typedef struct xdk_renderchain { - void *empty; unsigned pixel_size; LPDIRECT3DDEVICE dev; const video_info_t *video_info; From bc311f3962b6021dd86ddd1312a4b8e0c761bfc9 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Wed, 11 Nov 2015 02:01:00 +0100 Subject: [PATCH 090/216] (renderchain_cg) Cleanups --- gfx/d3d/render_chain_cg.cpp | 30 ++++++++++++------------------ 1 file changed, 12 insertions(+), 18 deletions(-) diff --git a/gfx/d3d/render_chain_cg.cpp b/gfx/d3d/render_chain_cg.cpp index 5cb48e2f4c..10f749d462 100644 --- a/gfx/d3d/render_chain_cg.cpp +++ b/gfx/d3d/render_chain_cg.cpp @@ -239,19 +239,14 @@ static bool renderchain_compile_shaders(cg_renderchain_t *chain, return true; } -static void renderchain_set_shaders(void *data, void *fragment_data, void *vertex_data) +static INLINE void renderchain_set_shaders(void *data, CGprogram *fPrg, CGprogram *vPrg) { - CGprogram *fPrg = (CGprogram*)fragment_data; - CGprogram *vPrg = (CGprogram*)vertex_data; - cgD3D9BindProgram(*fPrg); cgD3D9BindProgram(*vPrg); } -static void cg_d3d9_renderchain_destroy_stock_shader(void *data) +static void cg_d3d9_renderchain_destroy_stock_shader(cg_renderchain_t *chain) { - cg_renderchain_t *chain = (cg_renderchain_t*)data; - if (!chain) return; @@ -1131,11 +1126,10 @@ static bool cg_d3d9_renderchain_add_pass(void *data, const void *info_data) return true; } -static bool cg_d3d9_renderchain_add_lut(void *data, +static bool cg_d3d9_renderchain_add_lut(cg_renderchain_t *chain, const char *id, const char *path, bool smooth) { lut_info info; - cg_renderchain_t *chain = (cg_renderchain_t*)data; LPDIRECT3DDEVICE d3dr = chain->dev; LPDIRECT3DTEXTURE lut = (LPDIRECT3DTEXTURE) d3d_texture_new(d3dr, @@ -1309,13 +1303,13 @@ static void renderchain_set_viewport(void *data, void *viewport_data) d3d_set_viewport(d3dr, vp); } -static void renderchain_blit_to_texture(void *data, +static void renderchain_blit_to_texture( + cg_renderchain_t *chain, const void *frame, unsigned width, unsigned height, unsigned pitch) { D3DLOCKED_RECT d3dlr; - cg_renderchain_t *chain = (cg_renderchain_t*)data; Pass *first = (Pass*)&chain->passes[0]; if (first->last_width != width || first->last_height != height) @@ -1330,10 +1324,9 @@ static void renderchain_blit_to_texture(void *data, &d3dlr, frame, width, height, pitch); } -static void renderchain_unbind_all(void *data) +static void renderchain_unbind_all(cg_renderchain_t *chain) { unsigned i; - cg_renderchain_t *chain = (cg_renderchain_t*)data; LPDIRECT3DDEVICE d3dr = (LPDIRECT3DDEVICE)chain->dev; /* Have to be a bit anal about it. @@ -1397,13 +1390,15 @@ static void renderchain_render_pass( renderchain_unbind_all(chain); } -static bool cg_d3d9_renderchain_render(void *chain_data, const void *data, - unsigned width, unsigned height, unsigned pitch, unsigned rotation) +static bool cg_d3d9_renderchain_render( + cg_renderchain_t *chain, + const void *data, + unsigned width, unsigned height, + unsigned pitch, unsigned rotation) { Pass *last_pass; LPDIRECT3DSURFACE back_buffer, target; unsigned i, current_width, current_height, out_width = 0, out_height = 0; - cg_renderchain_t *chain = (cg_renderchain_t*)chain_data; LPDIRECT3DDEVICE d3dr = (LPDIRECT3DDEVICE)chain->dev; renderchain_start_render(chain); @@ -1527,8 +1522,7 @@ static bool cg_d3d9_renderchain_read_viewport(void *data, uint8_t *buffer) LPDIRECT3DSURFACE target = NULL; LPDIRECT3DSURFACE dest = NULL; bool ret = true; - d3d_video_t *d3d = (d3d_video_t*)data; - LPDIRECT3DDEVICE d3dr = (LPDIRECT3DDEVICE)d3d->dev; + d3d_video_t *d3d = (d3d_video_t*)data; LPDIRECT3DDEVICE d3dr = (LPDIRECT3DDEVICE)d3d->dev; static struct retro_perf_counter d3d_read_viewport = {0}; video_driver_get_size(&width, &height); From 3fb78a4ed4de5d4e65f889d8f4323c253cdcd245 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Wed, 11 Nov 2015 02:04:42 +0100 Subject: [PATCH 091/216] (D3D) Buildfixes --- gfx/d3d/render_chain_cg.cpp | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/gfx/d3d/render_chain_cg.cpp b/gfx/d3d/render_chain_cg.cpp index 10f749d462..83cb13573f 100644 --- a/gfx/d3d/render_chain_cg.cpp +++ b/gfx/d3d/render_chain_cg.cpp @@ -1126,10 +1126,11 @@ static bool cg_d3d9_renderchain_add_pass(void *data, const void *info_data) return true; } -static bool cg_d3d9_renderchain_add_lut(cg_renderchain_t *chain, +static bool cg_d3d9_renderchain_add_lut(void *data, const char *id, const char *path, bool smooth) { lut_info info; + cg_renderchain_t *chain = (cg_renderchain_t*)data; LPDIRECT3DDEVICE d3dr = chain->dev; LPDIRECT3DTEXTURE lut = (LPDIRECT3DTEXTURE) d3d_texture_new(d3dr, @@ -1391,14 +1392,15 @@ static void renderchain_render_pass( } static bool cg_d3d9_renderchain_render( - cg_renderchain_t *chain, - const void *data, + void *data + const void *frame_data, unsigned width, unsigned height, unsigned pitch, unsigned rotation) { Pass *last_pass; LPDIRECT3DSURFACE back_buffer, target; unsigned i, current_width, current_height, out_width = 0, out_height = 0; + cg_renderchain_t *chain = (cg_renderchain_t*)data; LPDIRECT3DDEVICE d3dr = (LPDIRECT3DDEVICE)chain->dev; renderchain_start_render(chain); @@ -1409,7 +1411,7 @@ static bool cg_d3d9_renderchain_render( &out_width, &out_height, current_width, current_height, chain->final_viewport); - renderchain_blit_to_texture(chain, data, width, height, pitch); + renderchain_blit_to_texture(chain, frame_data, width, height, pitch); /* Grab back buffer. */ d3dr->GetRenderTarget(0, &back_buffer); From 49f8df1f01e0403af8108079a86e2fafe70c9eb1 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Wed, 11 Nov 2015 02:05:20 +0100 Subject: [PATCH 092/216] (D3D) Another buildfix --- gfx/d3d/render_chain_cg.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gfx/d3d/render_chain_cg.cpp b/gfx/d3d/render_chain_cg.cpp index 83cb13573f..51f8e0fcfd 100644 --- a/gfx/d3d/render_chain_cg.cpp +++ b/gfx/d3d/render_chain_cg.cpp @@ -1392,7 +1392,7 @@ static void renderchain_render_pass( } static bool cg_d3d9_renderchain_render( - void *data + void *data, const void *frame_data, unsigned width, unsigned height, unsigned pitch, unsigned rotation) From f76d9f255adbcd2a1d1cc8c95929d032b3fb13bf Mon Sep 17 00:00:00 2001 From: twinaphex Date: Wed, 11 Nov 2015 02:12:25 +0100 Subject: [PATCH 093/216] (D3D) Start fleshing out WinProc --- gfx/drivers_context/d3d_ctx.cpp | 37 +++++++++++++++++++++++---------- 1 file changed, 26 insertions(+), 11 deletions(-) diff --git a/gfx/drivers_context/d3d_ctx.cpp b/gfx/drivers_context/d3d_ctx.cpp index 005e5bcfe9..3994e3fbcc 100644 --- a/gfx/drivers_context/d3d_ctx.cpp +++ b/gfx/drivers_context/d3d_ctx.cpp @@ -73,18 +73,21 @@ static void d3d_resize(void *data, unsigned new_width, unsigned new_height) } #ifdef HAVE_WINDOW -LRESULT CALLBACK WindowProc(HWND hWnd, UINT message, - WPARAM wParam, LPARAM lParam) +LRESULT CALLBACK WindowProc(HWND hwnd, UINT message, + WPARAM wparam, LPARAM lparam) { driver_t *driver = driver_get_ptr(); settings_t *settings = config_get_ptr(); switch (message) { - case WM_CREATE: + case WM_SYSCOMMAND: + /* Prevent screensavers, etc, while running. */ + switch (wparam) { - LPCREATESTRUCT p_cs = (LPCREATESTRUCT)lParam; - curD3D = (d3d_video_t*)p_cs->lpCreateParams; + case SC_SCREENSAVE: + case SC_MONITORPOWER: + return 0; } break; case WM_CHAR: @@ -92,15 +95,27 @@ LRESULT CALLBACK WindowProc(HWND hWnd, UINT message, case WM_KEYUP: case WM_SYSKEYUP: case WM_SYSKEYDOWN: - return win32_handle_keyboard_event(hWnd, message, wParam, lParam); + return win32_handle_keyboard_event(hwnd, message, wparam, lparam); + case WM_CREATE: + { + LPCREATESTRUCT p_cs = (LPCREATESTRUCT)lparam; + curD3D = (d3d_video_t*)p_cs->lpCreateParams; + } + break; + + case WM_CLOSE: case WM_DESTROY: + case WM_QUIT: d3d_quit = true; return 0; + case WM_SIZE: + /* Do not send resize message if we minimize. */ + if (wparam != SIZE_MAXHIDE && wparam != SIZE_MINIMIZED) { - unsigned new_width = LOWORD(lParam); - unsigned new_height = HIWORD(lParam); + unsigned new_width = LOWORD(lparam); + unsigned new_height = HIWORD(lparam); if (new_width && new_height) d3d_resize(driver->video_data, new_width, new_height); @@ -111,14 +126,14 @@ LRESULT CALLBACK WindowProc(HWND hWnd, UINT message, { d3d_video_t *d3d = (d3d_video_t*)driver->video_data; HWND d3dr = d3d->hWnd; - LRESULT ret = win32_menu_loop(d3dr, wParam); + LRESULT ret = win32_menu_loop(d3dr, wparam); } break; } - if (dinput_handle_message(dinput, message, wParam, lParam)) + if (dinput_handle_message(dinput, message, wparam, lparam)) return 0; - return DefWindowProc(hWnd, message, wParam, lParam); + return DefWindowProc(hwnd, message, wparam, lparam); } #endif From 47496ff0c37e637768f3dcabbae04e2204bf1f37 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Wed, 11 Nov 2015 02:17:18 +0100 Subject: [PATCH 094/216] (D3D) reimplement resizing --- gfx/drivers_context/d3d_ctx.cpp | 26 ++++++++++++++------------ 1 file changed, 14 insertions(+), 12 deletions(-) diff --git a/gfx/drivers_context/d3d_ctx.cpp b/gfx/drivers_context/d3d_ctx.cpp index 3994e3fbcc..3da317fc82 100644 --- a/gfx/drivers_context/d3d_ctx.cpp +++ b/gfx/drivers_context/d3d_ctx.cpp @@ -48,6 +48,7 @@ static bool widescreen_mode = false; static d3d_video_t *curD3D = NULL; static bool d3d_quit = false; static void *dinput; +static bool g_d3d_resized; extern bool d3d_restore(d3d_video_t *data); @@ -114,11 +115,9 @@ LRESULT CALLBACK WindowProc(HWND hwnd, UINT message, /* Do not send resize message if we minimize. */ if (wparam != SIZE_MAXHIDE && wparam != SIZE_MINIMIZED) { - unsigned new_width = LOWORD(lparam); - unsigned new_height = HIWORD(lparam); - - if (new_width && new_height) - d3d_resize(driver->video_data, new_width, new_height); + g_resize_width = LOWORD(lparam); + g_resize_height = HIWORD(lparam); + g_d3d_resized = true; } return 0; case WM_COMMAND: @@ -187,17 +186,20 @@ static void gfx_ctx_d3d_check_window(void *data, bool *quit, bool *resize, unsigned *width, unsigned *height, unsigned frame_count) { - d3d_video_t *d3d = (d3d_video_t*)data; + win32_check_window(); (void)data; + (void)frame_count; - *quit = false; - *resize = false; + *quit = d3d_quit; - if (d3d_quit) - *quit = true; - if (d3d->should_resize) - *resize = true; + if (g_d3d_resized) + { + *resize = true; + *width = g_d3d_resize_width; + *height = g_d3d_resize_height; + g_d3d_resized = false; + } win32_check_window(); } From b3662e2f27e8bc5dd38d100c1c53620ce2f3976c Mon Sep 17 00:00:00 2001 From: twinaphex Date: Wed, 11 Nov 2015 02:20:11 +0100 Subject: [PATCH 095/216] (D3D) Buildfix --- gfx/drivers_context/d3d_ctx.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/gfx/drivers_context/d3d_ctx.cpp b/gfx/drivers_context/d3d_ctx.cpp index 3da317fc82..130a5fd8a3 100644 --- a/gfx/drivers_context/d3d_ctx.cpp +++ b/gfx/drivers_context/d3d_ctx.cpp @@ -48,6 +48,8 @@ static bool widescreen_mode = false; static d3d_video_t *curD3D = NULL; static bool d3d_quit = false; static void *dinput; +static unsigned g_d3d_resize_width; +static unsigned g_d3d_resize_height; static bool g_d3d_resized; extern bool d3d_restore(d3d_video_t *data); @@ -115,8 +117,8 @@ LRESULT CALLBACK WindowProc(HWND hwnd, UINT message, /* Do not send resize message if we minimize. */ if (wparam != SIZE_MAXHIDE && wparam != SIZE_MINIMIZED) { - g_resize_width = LOWORD(lparam); - g_resize_height = HIWORD(lparam); + g_d3d_resize_width = LOWORD(lparam); + g_d3d_resize_height = HIWORD(lparam); g_d3d_resized = true; } return 0; From fa1b7b19eb7f49d7a029e7709369bba47195e9a3 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Wed, 11 Nov 2015 02:20:32 +0100 Subject: [PATCH 096/216] Don't call win32_check_window twice --- gfx/drivers_context/d3d_ctx.cpp | 2 -- 1 file changed, 2 deletions(-) diff --git a/gfx/drivers_context/d3d_ctx.cpp b/gfx/drivers_context/d3d_ctx.cpp index 130a5fd8a3..bc5c8794e8 100644 --- a/gfx/drivers_context/d3d_ctx.cpp +++ b/gfx/drivers_context/d3d_ctx.cpp @@ -202,8 +202,6 @@ static void gfx_ctx_d3d_check_window(void *data, bool *quit, *height = g_d3d_resize_height; g_d3d_resized = false; } - - win32_check_window(); } #ifdef _XBOX From b093cd4df05da07279be31da80c0a48078112490 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Wed, 11 Nov 2015 02:42:15 +0100 Subject: [PATCH 097/216] Reduce XBOX ifdefs --- gfx/d3d/d3d.cpp | 11 +---------- gfx/d3d/render_chain_cg.cpp | 14 ++++++++++---- gfx/d3d/render_chain_driver.h | 2 +- gfx/d3d/render_chain_xdk.cpp | 4 ++-- 4 files changed, 14 insertions(+), 17 deletions(-) diff --git a/gfx/d3d/d3d.cpp b/gfx/d3d/d3d.cpp index 693c590ff8..1d83cf79a4 100644 --- a/gfx/d3d/d3d.cpp +++ b/gfx/d3d/d3d.cpp @@ -1032,15 +1032,10 @@ static bool d3d_init_chain(d3d_video_t *d3d, const video_info_t *video_info) if ( !d3d->renderchain_driver->init( -#ifdef _XBOX d3d, -#else - d3d->renderchain_data, -#endif &d3d->video_info, d3dr, &d3d->final_viewport, &link_info, - d3d->video_info.rgb32 ? - RETRO_PIXEL_FORMAT_XRGB8888 : RETRO_PIXEL_FORMAT_RGB565) + d3d->video_info.rgb32) ) { RARCH_ERR("[D3D]: Failed to init render chain.\n"); @@ -1630,11 +1625,7 @@ static bool d3d_frame(void *data, const void *frame, if ( !d3d->renderchain_driver->render( -#ifdef _XBOX d3d, -#else - d3d->renderchain_data, -#endif frame, frame_width, frame_height, pitch, d3d->dev_rotation)) { diff --git a/gfx/d3d/render_chain_cg.cpp b/gfx/d3d/render_chain_cg.cpp index 51f8e0fcfd..312d7f6675 100644 --- a/gfx/d3d/render_chain_cg.cpp +++ b/gfx/d3d/render_chain_cg.cpp @@ -924,11 +924,13 @@ static bool cg_d3d9_renderchain_init(void *data, const void *_video_info, void *dev_, const void *final_viewport_, - const void *info_data, unsigned fmt) + const void *info_data, bool rgb32) { const LinkInfo *info = (const LinkInfo*)info_data; - cg_renderchain_t *chain = (cg_renderchain_t*)data; + d3d_video_t *d3d = (d3d_video_t*)data; + cg_renderchain_t *chain = (cg_renderchain_t*)d3d->renderchain_data; const video_info_t *video_info = (const video_info_t*)_video_info; + unsigned fmt = (rgb32) ? RETRO_PIXEL_FORMAT_XRGB8888 : RETRO_PIXEL_FORMAT_RGB565; if (!chain) return false; @@ -1398,10 +1400,14 @@ static bool cg_d3d9_renderchain_render( unsigned pitch, unsigned rotation) { Pass *last_pass; + LPDIRECT3DDEVICE d3dr; LPDIRECT3DSURFACE back_buffer, target; unsigned i, current_width, current_height, out_width = 0, out_height = 0; - cg_renderchain_t *chain = (cg_renderchain_t*)data; - LPDIRECT3DDEVICE d3dr = (LPDIRECT3DDEVICE)chain->dev; + d3d_video_t *d3d = (d3d_video_t*)data; + cg_renderchain_t *chain = d3d ? (cg_renderchain_t*)d3d->renderchain_data : NULL; + + if (chain) + d3dr = (LPDIRECT3DDEVICE)chain->dev; renderchain_start_render(chain); diff --git a/gfx/d3d/render_chain_driver.h b/gfx/d3d/render_chain_driver.h index 6043d17abd..b8c609e349 100644 --- a/gfx/d3d/render_chain_driver.h +++ b/gfx/d3d/render_chain_driver.h @@ -53,7 +53,7 @@ typedef struct renderchain_driver void *dev_data, const void *final_viewport_data, const void *info_data, - unsigned fmt); + bool rgb32); void (*set_final_viewport)(void *data, void *renderchain_data, const void *viewport_data); bool (*add_pass)(void *data, const void *info_data); diff --git a/gfx/d3d/render_chain_xdk.cpp b/gfx/d3d/render_chain_xdk.cpp index 772bd57f81..a51526ad13 100644 --- a/gfx/d3d/render_chain_xdk.cpp +++ b/gfx/d3d/render_chain_xdk.cpp @@ -318,7 +318,7 @@ static bool xdk_renderchain_init(void *data, void *dev_data, const void *final_viewport_data, const void *info_data, - unsigned fmt + bool rgb32 ) { unsigned width, height; @@ -328,8 +328,8 @@ static bool xdk_renderchain_init(void *data, const video_info_t *video_info = (const video_info_t*)_video_info; const LinkInfo *link_info = (const LinkInfo*)info_data; xdk_renderchain_t *chain = (xdk_renderchain_t*)d3d->renderchain_data; + unsigned fmt = (rgb32) ? RETRO_PIXEL_FORMAT_XRGB8888 : RETRO_PIXEL_FORMAT_RGB565; (void)final_viewport_data; - (void)fmt; video_driver_get_size(&width, &height); From 321d73cc665c10310558325174600fc78f06c485 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Wed, 11 Nov 2015 02:44:54 +0100 Subject: [PATCH 098/216] render_chain_null - buildfix --- gfx/d3d/render_chain_null.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gfx/d3d/render_chain_null.c b/gfx/d3d/render_chain_null.c index c5731c32ce..e2689c287c 100644 --- a/gfx/d3d/render_chain_null.c +++ b/gfx/d3d/render_chain_null.c @@ -48,7 +48,7 @@ static bool null_renderchain_init(void *data, void *dev_data, const void *final_viewport_data, const void *info_data, - unsigned fmt + bool rgb32 ) { (void)data; From 7bcd7d1d3d58d5184547cea5c3f11e6acb78524f Mon Sep 17 00:00:00 2001 From: twinaphex Date: Wed, 11 Nov 2015 02:45:37 +0100 Subject: [PATCH 099/216] Sigh - another buildfix --- gfx/d3d/render_chain_null.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gfx/d3d/render_chain_null.c b/gfx/d3d/render_chain_null.c index e2689c287c..4bb794665a 100644 --- a/gfx/d3d/render_chain_null.c +++ b/gfx/d3d/render_chain_null.c @@ -56,7 +56,7 @@ static bool null_renderchain_init(void *data, (void)dev_data; (void)final_viewport_data; (void)info_data; - (void)fmt; + (void)rgb32; return true; } From 38f30c8f10d531c14b38f8723eb2daff1c25fa0f Mon Sep 17 00:00:00 2001 From: twinaphex Date: Wed, 11 Nov 2015 02:57:20 +0100 Subject: [PATCH 100/216] Add Save Current Config to Menu --- command_event.c | 31 +++++++++++++++++++++++++++++++ command_event.h | 1 + frontend/frontend.c | 30 +----------------------------- menu/drivers/materialui.c | 2 ++ menu/drivers/xmb.c | 2 ++ menu/intl/menu_hash_us.c | 4 ++++ menu/menu_hash.h | 3 +++ menu/menu_setting.c | 8 ++++++++ 8 files changed, 52 insertions(+), 29 deletions(-) diff --git a/command_event.c b/command_event.c index 769a24eee1..32b3589a09 100644 --- a/command_event.c +++ b/command_event.c @@ -893,6 +893,34 @@ static bool event_save_core_config(void) return ret; } +/** + * event_save_current_config: + * + * Saves current configuration file to disk, and (optionally) + * autosave state. + **/ +void event_save_current_config(void) +{ + settings_t *settings = config_get_ptr(); + global_t *global = global_get_ptr(); + + if (settings->config_save_on_exit && *global->path.config) + { + /* Save last core-specific config to the default config location, + * needed on consoles for core switching and reusing last good + * config for new cores. + */ + config_save_file(global->path.config); + + /* Flush out the core specific config. */ + if (*global->path.core_specific_config && + settings->core_specific_config) + config_save_file(global->path.core_specific_config); + } + + event_command(EVENT_CMD_AUTOSAVE_STATE); +} + /** * event_save_state * @path : Path to state. @@ -1440,6 +1468,9 @@ bool event_command(enum event_command cmd) if (driver->frontend_ctx && driver->frontend_ctx->set_fork) driver->frontend_ctx->set_fork(true, false); break; + case EVENT_CMD_MENU_SAVE_CURRENT_CONFIG: + event_save_current_config(); + break; case EVENT_CMD_MENU_SAVE_CONFIG: if (!event_save_core_config()) return false; diff --git a/command_event.h b/command_event.h index 79df12f7d3..02558f7425 100644 --- a/command_event.h +++ b/command_event.h @@ -128,6 +128,7 @@ enum event_command /* Unpauses retroArch. */ EVENT_CMD_PAUSE, EVENT_CMD_PAUSE_CHECKS, + EVENT_CMD_MENU_SAVE_CURRENT_CONFIG, EVENT_CMD_MENU_SAVE_CONFIG, EVENT_CMD_MENU_PAUSE_LIBRETRO, /* Toggles menu on/off. */ diff --git a/frontend/frontend.c b/frontend/frontend.c index d6c1b1fa4e..f6e7dfa300 100644 --- a/frontend/frontend.c +++ b/frontend/frontend.c @@ -29,34 +29,6 @@ #define MAX_ARGS 32 -/** - * main_exit_save_config: - * - * Saves configuration file to disk, and (optionally) - * autosave state. - **/ -void main_exit_save_config(void) -{ - settings_t *settings = config_get_ptr(); - global_t *global = global_get_ptr(); - - if (settings->config_save_on_exit && *global->path.config) - { - /* Save last core-specific config to the default config location, - * needed on consoles for core switching and reusing last good - * config for new cores. - */ - config_save_file(global->path.config); - - /* Flush out the core specific config. */ - if (*global->path.core_specific_config && - settings->core_specific_config) - config_save_file(global->path.core_specific_config); - } - - event_command(EVENT_CMD_AUTOSAVE_STATE); -} - /** * main_exit: * @@ -73,7 +45,7 @@ void main_exit(void *args) const frontend_ctx_driver_t *frontend = frontend_get_ptr(); const ui_companion_driver_t *ui = ui_companion_get_ptr(); - main_exit_save_config(); + event_command(EVENT_CMD_MENU_SAVE_CURRENT_CONFIG); if (global->inited.main) { diff --git a/menu/drivers/materialui.c b/menu/drivers/materialui.c index aa7ac455cf..18760517ab 100644 --- a/menu/drivers/materialui.c +++ b/menu/drivers/materialui.c @@ -1309,6 +1309,8 @@ static int mui_list_push(menu_displaylist_info_t *info, unsigned type) #endif menu_displaylist_parse_settings(menu, info, menu_hash_to_str(MENU_LABEL_CONFIGURATIONS), PARSE_ACTION, false); + menu_displaylist_parse_settings(menu, info, + menu_hash_to_str(MENU_LABEL_SAVE_CURRENT_CONFIG), PARSE_ACTION, false); menu_displaylist_parse_settings(menu, info, menu_hash_to_str(MENU_LABEL_SAVE_NEW_CONFIG), PARSE_ACTION, false); menu_displaylist_parse_settings(menu, info, diff --git a/menu/drivers/xmb.c b/menu/drivers/xmb.c index c9f913bd79..49d5c2a988 100644 --- a/menu/drivers/xmb.c +++ b/menu/drivers/xmb.c @@ -2653,6 +2653,8 @@ static int xmb_list_push(menu_displaylist_info_t *info, unsigned type) #endif menu_displaylist_parse_settings(menu, info, menu_hash_to_str(MENU_LABEL_CONFIGURATIONS), PARSE_ACTION, false); + menu_displaylist_parse_settings(menu, info, + menu_hash_to_str(MENU_LABEL_SAVE_CURRENT_CONFIG), PARSE_ACTION, false); menu_displaylist_parse_settings(menu, info, menu_hash_to_str(MENU_LABEL_SAVE_NEW_CONFIG), PARSE_ACTION, false); menu_displaylist_parse_settings(menu, info, diff --git a/menu/intl/menu_hash_us.c b/menu/intl/menu_hash_us.c index 97c2bd739b..744fd063e5 100644 --- a/menu/intl/menu_hash_us.c +++ b/menu/intl/menu_hash_us.c @@ -26,6 +26,8 @@ static const char *menu_hash_to_str_us_label(uint32_t hash) { switch (hash) { + case MENU_LABEL_SAVE_CURRENT_CONFIG: + return "save_current_config"; case MENU_LABEL_STATE_SLOT: return "state_slot"; case MENU_LABEL_CHEEVOS_USERNAME: @@ -688,6 +690,8 @@ const char *menu_hash_to_str_us(uint32_t hash) switch (hash) { + case MENU_LABEL_VALUE_SAVE_CURRENT_CONFIG: + return "Save Current Config"; case MENU_LABEL_VALUE_STATE_SLOT: return "State Slot"; case MENU_LABEL_VALUE_ACCOUNTS_CHEEVOS_SETTINGS: diff --git a/menu/menu_hash.h b/menu/menu_hash.h index 6a472d33f4..400b027eb2 100644 --- a/menu/menu_hash.h +++ b/menu/menu_hash.h @@ -1074,6 +1074,9 @@ extern "C" { #define MENU_LABEL_VALUE_HELP_SCANNING_CONTENT 0x74b36f11U #define MENU_LABEL_VALUE_HELP_SCANNING_CONTENT_DESC 0xac947056U +#define MENU_LABEL_SAVE_CURRENT_CONFIG 0x8840ba8bU +#define MENU_LABEL_VALUE_SAVE_CURRENT_CONFIG 0x9a1eb42dU + const char *menu_hash_to_str_de(uint32_t hash); int menu_hash_get_help_de(uint32_t hash, char *s, size_t len); diff --git a/menu/menu_setting.c b/menu/menu_setting.c index bb5616a11f..a2f0449212 100644 --- a/menu/menu_setting.c +++ b/menu/menu_setting.c @@ -3146,6 +3146,14 @@ static bool setting_append_list_main_menu_options( subgroup_info.name, parent_group); + CONFIG_ACTION( + menu_hash_to_str(MENU_LABEL_SAVE_CURRENT_CONFIG), + menu_hash_to_str(MENU_LABEL_VALUE_SAVE_CURRENT_CONFIG), + group_info.name, + subgroup_info.name, + parent_group); + menu_settings_list_current_add_cmd(list, list_info, EVENT_CMD_MENU_SAVE_CURRENT_CONFIG); + CONFIG_ACTION( menu_hash_to_str(MENU_LABEL_SAVE_NEW_CONFIG), menu_hash_to_str(MENU_LABEL_VALUE_SAVE_NEW_CONFIG), From ea189e5fe5409e950e6825452cbb5a3c0ab7f81d Mon Sep 17 00:00:00 2001 From: twinaphex Date: Wed, 11 Nov 2015 02:58:21 +0100 Subject: [PATCH 101/216] Remove main_exit_save_config --- frontend/frontend.h | 8 -------- 1 file changed, 8 deletions(-) diff --git a/frontend/frontend.h b/frontend/frontend.h index ce97054a87..92393fe2b1 100644 --- a/frontend/frontend.h +++ b/frontend/frontend.h @@ -37,14 +37,6 @@ extern "C" { **/ void main_exit(void *args); -/** - * main_exit_save_config: - * - * Saves configuration file to disk, and (optionally) - * autosave state. - **/ -void main_exit_save_config(void); - /** * main_entry: * From e2e0f302c1946f9979e1e3071a09fcf332a52c55 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Wed, 11 Nov 2015 02:59:24 +0100 Subject: [PATCH 102/216] Add Save Current Config to main menu list --- menu/menu_displaylist.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/menu/menu_displaylist.c b/menu/menu_displaylist.c index e31b8a883c..c7696816de 100644 --- a/menu/menu_displaylist.c +++ b/menu/menu_displaylist.c @@ -2527,6 +2527,8 @@ int menu_displaylist_push_list(menu_displaylist_info_t *info, unsigned type) #endif menu_displaylist_parse_settings(menu, info, menu_hash_to_str(MENU_LABEL_CONFIGURATIONS), PARSE_ACTION, false); + menu_displaylist_parse_settings(menu, info, + menu_hash_to_str(MENU_LABEL_SAVE_CURRENT_CONFIG), PARSE_ACTION, false); menu_displaylist_parse_settings(menu, info, menu_hash_to_str(MENU_LABEL_SAVE_NEW_CONFIG), PARSE_ACTION, false); menu_displaylist_parse_settings(menu, info, From 3d65cf07ca17301a07f310b628ed837ddd17fbf9 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Wed, 11 Nov 2015 03:24:53 +0100 Subject: [PATCH 103/216] (CocoaTouch) Use new event command --- ui/drivers/ui_cocoatouch.m | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/ui/drivers/ui_cocoatouch.m b/ui/drivers/ui_cocoatouch.m index 08df3ce954..368db72df8 100644 --- a/ui/drivers/ui_cocoatouch.m +++ b/ui/drivers/ui_cocoatouch.m @@ -63,6 +63,13 @@ static void rarch_disable_ui(void) rarch_main_ctl(RARCH_MAIN_CTL_SET_IDLE, &boolean); } +static void ui_companion_cocoatouch_event_command( + void *data, enum event_command cmd) +{ + (void)data; + event_command(cmd); +} + static void rarch_draw_observer(CFRunLoopObserverRef observer, CFRunLoopActivity activity, void *info) { @@ -76,7 +83,7 @@ static void rarch_draw_observer(CFRunLoopObserverRef observer, if (ret == -1) { - main_exit_save_config(); + ui_companion_cocoatouch_event_command(NULL, EVENT_CMD_MENU_SAVE_CURRENT_CONFIG); main_exit(NULL); return; } @@ -320,7 +327,7 @@ enum { dispatch_async(dispatch_get_main_queue(), ^{ - main_exit_save_config(); + ui_companion_cocoatouch_event_command(NULL, EVENT_CMD_MENU_SAVE_CURRENT_CONFIG); }); [self showPauseMenu: self]; } @@ -368,12 +375,6 @@ enum [self.window setRootViewController:self]; } -static void ui_companion_cocoatouch_event_command(void *data, - enum event_command cmd) -{ - (void)data; - event_command(cmd); -} - (void)toggleUI { From 7e592df3e876a294ab43d225d648e609a1f0fbf4 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Wed, 11 Nov 2015 03:28:40 +0100 Subject: [PATCH 104/216] (vg.c) Variable rename --- gfx/drivers/vg.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/gfx/drivers/vg.c b/gfx/drivers/vg.c index 17ee516368..694ac737e3 100644 --- a/gfx/drivers/vg.c +++ b/gfx/drivers/vg.c @@ -36,7 +36,7 @@ typedef struct { bool should_resize; float mScreenAspect; - bool mKeepAspect; + bool keep_aspect; bool mEglImageBuf; unsigned mTextureWidth; unsigned mTextureHeight; @@ -111,8 +111,8 @@ static void *vg_init(const video_info_t *video, const input_driver_t **input, vo gfx_ctx_update_window_title(vg); - vg->mTexType = video->rgb32 ? VG_sXRGB_8888 : VG_sRGB_565; - vg->mKeepAspect = video->force_aspect; + vg->mTexType = video->rgb32 ? VG_sXRGB_8888 : VG_sRGB_565; + vg->keep_aspect = video->force_aspect; unsigned win_width = video->width; unsigned win_height = video->height; @@ -233,7 +233,7 @@ static void vg_calculate_quad(vg_t *vg) video_driver_get_size(&width, &height); /* set viewport for aspect ratio, taken from the OpenGL driver. */ - if (vg->mKeepAspect) + if (vg->keep_aspect) { float desired_aspect = video_driver_get_aspect_ratio(); From 2fb91683a14a655523063f6a8b36ce63ec9c311d Mon Sep 17 00:00:00 2001 From: twinaphex Date: Wed, 11 Nov 2015 03:48:05 +0100 Subject: [PATCH 105/216] (D3D) Remove Coords struct --- gfx/d3d/d3d.cpp | 68 ++++++++++++++++++++++++------------------------- gfx/d3d/d3d.h | 8 ++---- 2 files changed, 36 insertions(+), 40 deletions(-) diff --git a/gfx/d3d/d3d.cpp b/gfx/d3d/d3d.cpp index 1d83cf79a4..aab2624878 100644 --- a/gfx/d3d/d3d.cpp +++ b/gfx/d3d/d3d.cpp @@ -602,14 +602,14 @@ static bool d3d_construct(d3d_video_t *d3d, if (!d3d->menu) return false; - d3d->menu->tex_coords.x = 0; - d3d->menu->tex_coords.y = 0; - d3d->menu->tex_coords.w = 1; - d3d->menu->tex_coords.h = 1; - d3d->menu->vert_coords.x = 0; - d3d->menu->vert_coords.y = 1; - d3d->menu->vert_coords.w = 1; - d3d->menu->vert_coords.h = -1; + d3d->menu->tex_coords[0] = 0; + d3d->menu->tex_coords[1] = 0; + d3d->menu->tex_coords[2] = 1; + d3d->menu->tex_coords[3] = 1; + d3d->menu->vert_coords[0] = 0; + d3d->menu->vert_coords[1] = 1; + d3d->menu->vert_coords[2] = 1; + d3d->menu->vert_coords[3] = -1; #endif #if defined(HAVE_WINDOW) && !defined(_XBOX) @@ -1335,27 +1335,27 @@ static void d3d_overlay_render(d3d_video_t *d3d, overlay_t *overlay) overlay_width = vp.width; overlay_height = vp.height; - vert[0].x = overlay->vert_coords.x * overlay_width; - vert[1].x = (overlay->vert_coords.x + overlay->vert_coords.w) + vert[0].x = overlay->vert_coords[0] * overlay_width; + vert[1].x = (overlay->vert_coords[0] + overlay->vert_coords[2]) * overlay_width; - vert[2].x = overlay->vert_coords.x * overlay_width; - vert[3].x = (overlay->vert_coords.x + overlay->vert_coords.w) + vert[2].x = overlay->vert_coords[0] * overlay_width; + vert[3].x = (overlay->vert_coords[0] + overlay->vert_coords[2]) * overlay_width; - vert[0].y = overlay->vert_coords.y * overlay_height; - vert[1].y = overlay->vert_coords.y * overlay_height; - vert[2].y = (overlay->vert_coords.y + overlay->vert_coords.h) + vert[0].y = overlay->vert_coords[1] * overlay_height; + vert[1].y = overlay->vert_coords[1] * overlay_height; + vert[2].y = (overlay->vert_coords[1] + overlay->vert_coords[3]) * overlay_height; - vert[3].y = (overlay->vert_coords.y + overlay->vert_coords.h) + vert[3].y = (overlay->vert_coords[1] + overlay->vert_coords[3]) * overlay_height; - vert[0].u = overlay->tex_coords.x; - vert[1].u = overlay->tex_coords.x + overlay->tex_coords.w; - vert[2].u = overlay->tex_coords.x; - vert[3].u = overlay->tex_coords.x + overlay->tex_coords.w; - vert[0].v = overlay->tex_coords.y; - vert[1].v = overlay->tex_coords.y; - vert[2].v = overlay->tex_coords.y + overlay->tex_coords.h; - vert[3].v = overlay->tex_coords.y + overlay->tex_coords.h; + vert[0].u = overlay->tex_coords[0]; + vert[1].u = overlay->tex_coords[0] + overlay->tex_coords[2]; + vert[2].u = overlay->tex_coords[0]; + vert[3].u = overlay->tex_coords[0] + overlay->tex_coords[2]; + vert[0].v = overlay->tex_coords[1]; + vert[1].v = overlay->tex_coords[1]; + vert[2].v = overlay->tex_coords[1] + overlay->tex_coords[3]; + vert[3].v = overlay->tex_coords[1] + overlay->tex_coords[3]; /* Align texels and vertices. */ for (i = 0; i < 4; i++) @@ -1428,10 +1428,10 @@ static void d3d_overlay_tex_geom( if (!d3d) return; - d3d->overlays[index].tex_coords.x = x; - d3d->overlays[index].tex_coords.y = y; - d3d->overlays[index].tex_coords.w = w; - d3d->overlays[index].tex_coords.h = h; + d3d->overlays[index].tex_coords[0] = x; + d3d->overlays[index].tex_coords[1] = y; + d3d->overlays[index].tex_coords[2] = w; + d3d->overlays[index].tex_coords[3] = h; } static void d3d_overlay_vertex_geom( @@ -1444,12 +1444,12 @@ static void d3d_overlay_vertex_geom( if (!d3d) return; - y = 1.0f - y; - h = -h; - d3d->overlays[index].vert_coords.x = x; - d3d->overlays[index].vert_coords.y = y; - d3d->overlays[index].vert_coords.w = w; - d3d->overlays[index].vert_coords.h = h; + y = 1.0f - y; + h = -h; + d3d->overlays[index].vert_coords[0] = x; + d3d->overlays[index].vert_coords[1] = y; + d3d->overlays[index].vert_coords[2] = w; + d3d->overlays[index].vert_coords[3] = h; } static bool d3d_overlay_load(void *data, diff --git a/gfx/d3d/d3d.h b/gfx/d3d/d3d.h index 218d710ccf..609da0e76e 100644 --- a/gfx/d3d/d3d.h +++ b/gfx/d3d/d3d.h @@ -60,12 +60,8 @@ typedef struct { - struct Coords - { - float x, y, w, h; - }; - Coords tex_coords; - Coords vert_coords; + float tex_coords[4]; + float vert_coords[4]; unsigned tex_w, tex_h; bool fullscreen; bool enabled; From 646436a5a735727065ce66b9b25ae6de8ec1c856 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Wed, 11 Nov 2015 03:56:23 +0100 Subject: [PATCH 106/216] (D3D)Get rid of overlay_vertex struct --- gfx/d3d/d3d.cpp | 57 +++++++++++++++++++++++-------------------------- 1 file changed, 27 insertions(+), 30 deletions(-) diff --git a/gfx/d3d/d3d.cpp b/gfx/d3d/d3d.cpp index aab2624878..900e809a1a 100644 --- a/gfx/d3d/d3d.cpp +++ b/gfx/d3d/d3d.cpp @@ -1288,12 +1288,7 @@ static void d3d_overlay_render(d3d_video_t *d3d, overlay_t *overlay) unsigned width, height; void *verts; unsigned i; - struct overlay_vertex - { - float x, y, z; - float u, v; - float r, g, b, a; - } vert[4]; + float vert[4][9]; float overlay_width, overlay_height; #ifndef _XBOX1 LPDIRECT3DVERTEXDECLARATION vertex_decl; @@ -1317,7 +1312,7 @@ static void d3d_overlay_render(d3d_video_t *d3d, overlay_t *overlay) if (!overlay->vert_buf) { overlay->vert_buf = (LPDIRECT3DVERTEXBUFFER)d3d_vertex_buffer_new( - d3d->dev, sizeof(vert), 0, 0, D3DPOOL_MANAGED, NULL); + d3d->dev, sizeof(float) * 4 * 9, 0, 0, D3DPOOL_MANAGED, NULL); if (!overlay->vert_buf) return; @@ -1325,9 +1320,11 @@ static void d3d_overlay_render(d3d_video_t *d3d, overlay_t *overlay) for (i = 0; i < 4; i++) { - vert[i].z = 0.5f; - vert[i].r = vert[i].g = vert[i].b = 1.0f; - vert[i].a = overlay->alpha_mod; + vert[i][2] = 0.5f; + vert[i][5] = 1.0f; + vert[i][6] = 1.0f; + vert[i][7] = 1.0f; + vert[i][8] = overlay->alpha_mod; } d3d_viewport_info(d3d, &vp); @@ -1335,37 +1332,37 @@ static void d3d_overlay_render(d3d_video_t *d3d, overlay_t *overlay) overlay_width = vp.width; overlay_height = vp.height; - vert[0].x = overlay->vert_coords[0] * overlay_width; - vert[1].x = (overlay->vert_coords[0] + overlay->vert_coords[2]) + vert[0][0] = overlay->vert_coords[0] * overlay_width; + vert[1][0] = (overlay->vert_coords[0] + overlay->vert_coords[2]) * overlay_width; - vert[2].x = overlay->vert_coords[0] * overlay_width; - vert[3].x = (overlay->vert_coords[0] + overlay->vert_coords[2]) + vert[2][0] = overlay->vert_coords[0] * overlay_width; + vert[3][0] = (overlay->vert_coords[0] + overlay->vert_coords[2]) * overlay_width; - vert[0].y = overlay->vert_coords[1] * overlay_height; - vert[1].y = overlay->vert_coords[1] * overlay_height; - vert[2].y = (overlay->vert_coords[1] + overlay->vert_coords[3]) + vert[0][1] = overlay->vert_coords[1] * overlay_height; + vert[1][1] = overlay->vert_coords[1] * overlay_height; + vert[2][1] = (overlay->vert_coords[1] + overlay->vert_coords[3]) * overlay_height; - vert[3].y = (overlay->vert_coords[1] + overlay->vert_coords[3]) + vert[3][1] = (overlay->vert_coords[1] + overlay->vert_coords[3]) * overlay_height; - vert[0].u = overlay->tex_coords[0]; - vert[1].u = overlay->tex_coords[0] + overlay->tex_coords[2]; - vert[2].u = overlay->tex_coords[0]; - vert[3].u = overlay->tex_coords[0] + overlay->tex_coords[2]; - vert[0].v = overlay->tex_coords[1]; - vert[1].v = overlay->tex_coords[1]; - vert[2].v = overlay->tex_coords[1] + overlay->tex_coords[3]; - vert[3].v = overlay->tex_coords[1] + overlay->tex_coords[3]; + vert[0][3] = overlay->tex_coords[0]; + vert[1][3] = overlay->tex_coords[0] + overlay->tex_coords[2]; + vert[2][3] = overlay->tex_coords[0]; + vert[3][3] = overlay->tex_coords[0] + overlay->tex_coords[2]; + vert[0][4] = overlay->tex_coords[1]; + vert[1][4] = overlay->tex_coords[1]; + vert[2][4] = overlay->tex_coords[1] + overlay->tex_coords[3]; + vert[3][4] = overlay->tex_coords[1] + overlay->tex_coords[3]; /* Align texels and vertices. */ for (i = 0; i < 4; i++) { - vert[i].x -= 0.5f; - vert[i].y += 0.5f; + vert[i][0] -= 0.5f; + vert[i][1] += 0.5f; } - overlay->vert_buf->Lock(0, sizeof(vert), &verts, 0); - memcpy(verts, vert, sizeof(vert)); + overlay->vert_buf->Lock(0, sizeof(float) * 4 * 9, &verts, 0); + memcpy(verts, vert, sizeof(float) * 4 * 9); d3d_vertex_buffer_unlock(overlay->vert_buf); d3d_enable_blend_func(d3d->dev); From fd12b4b957ce88c6998108c52575d423abf92384 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Wed, 11 Nov 2015 04:01:50 +0100 Subject: [PATCH 107/216] Revert "(D3D)Get rid of overlay_vertex struct" This reverts commit 646436a5a735727065ce66b9b25ae6de8ec1c856. --- gfx/d3d/d3d.cpp | 57 ++++++++++++++++++++++++++----------------------- 1 file changed, 30 insertions(+), 27 deletions(-) diff --git a/gfx/d3d/d3d.cpp b/gfx/d3d/d3d.cpp index 900e809a1a..aab2624878 100644 --- a/gfx/d3d/d3d.cpp +++ b/gfx/d3d/d3d.cpp @@ -1288,7 +1288,12 @@ static void d3d_overlay_render(d3d_video_t *d3d, overlay_t *overlay) unsigned width, height; void *verts; unsigned i; - float vert[4][9]; + struct overlay_vertex + { + float x, y, z; + float u, v; + float r, g, b, a; + } vert[4]; float overlay_width, overlay_height; #ifndef _XBOX1 LPDIRECT3DVERTEXDECLARATION vertex_decl; @@ -1312,7 +1317,7 @@ static void d3d_overlay_render(d3d_video_t *d3d, overlay_t *overlay) if (!overlay->vert_buf) { overlay->vert_buf = (LPDIRECT3DVERTEXBUFFER)d3d_vertex_buffer_new( - d3d->dev, sizeof(float) * 4 * 9, 0, 0, D3DPOOL_MANAGED, NULL); + d3d->dev, sizeof(vert), 0, 0, D3DPOOL_MANAGED, NULL); if (!overlay->vert_buf) return; @@ -1320,11 +1325,9 @@ static void d3d_overlay_render(d3d_video_t *d3d, overlay_t *overlay) for (i = 0; i < 4; i++) { - vert[i][2] = 0.5f; - vert[i][5] = 1.0f; - vert[i][6] = 1.0f; - vert[i][7] = 1.0f; - vert[i][8] = overlay->alpha_mod; + vert[i].z = 0.5f; + vert[i].r = vert[i].g = vert[i].b = 1.0f; + vert[i].a = overlay->alpha_mod; } d3d_viewport_info(d3d, &vp); @@ -1332,37 +1335,37 @@ static void d3d_overlay_render(d3d_video_t *d3d, overlay_t *overlay) overlay_width = vp.width; overlay_height = vp.height; - vert[0][0] = overlay->vert_coords[0] * overlay_width; - vert[1][0] = (overlay->vert_coords[0] + overlay->vert_coords[2]) + vert[0].x = overlay->vert_coords[0] * overlay_width; + vert[1].x = (overlay->vert_coords[0] + overlay->vert_coords[2]) * overlay_width; - vert[2][0] = overlay->vert_coords[0] * overlay_width; - vert[3][0] = (overlay->vert_coords[0] + overlay->vert_coords[2]) + vert[2].x = overlay->vert_coords[0] * overlay_width; + vert[3].x = (overlay->vert_coords[0] + overlay->vert_coords[2]) * overlay_width; - vert[0][1] = overlay->vert_coords[1] * overlay_height; - vert[1][1] = overlay->vert_coords[1] * overlay_height; - vert[2][1] = (overlay->vert_coords[1] + overlay->vert_coords[3]) + vert[0].y = overlay->vert_coords[1] * overlay_height; + vert[1].y = overlay->vert_coords[1] * overlay_height; + vert[2].y = (overlay->vert_coords[1] + overlay->vert_coords[3]) * overlay_height; - vert[3][1] = (overlay->vert_coords[1] + overlay->vert_coords[3]) + vert[3].y = (overlay->vert_coords[1] + overlay->vert_coords[3]) * overlay_height; - vert[0][3] = overlay->tex_coords[0]; - vert[1][3] = overlay->tex_coords[0] + overlay->tex_coords[2]; - vert[2][3] = overlay->tex_coords[0]; - vert[3][3] = overlay->tex_coords[0] + overlay->tex_coords[2]; - vert[0][4] = overlay->tex_coords[1]; - vert[1][4] = overlay->tex_coords[1]; - vert[2][4] = overlay->tex_coords[1] + overlay->tex_coords[3]; - vert[3][4] = overlay->tex_coords[1] + overlay->tex_coords[3]; + vert[0].u = overlay->tex_coords[0]; + vert[1].u = overlay->tex_coords[0] + overlay->tex_coords[2]; + vert[2].u = overlay->tex_coords[0]; + vert[3].u = overlay->tex_coords[0] + overlay->tex_coords[2]; + vert[0].v = overlay->tex_coords[1]; + vert[1].v = overlay->tex_coords[1]; + vert[2].v = overlay->tex_coords[1] + overlay->tex_coords[3]; + vert[3].v = overlay->tex_coords[1] + overlay->tex_coords[3]; /* Align texels and vertices. */ for (i = 0; i < 4; i++) { - vert[i][0] -= 0.5f; - vert[i][1] += 0.5f; + vert[i].x -= 0.5f; + vert[i].y += 0.5f; } - overlay->vert_buf->Lock(0, sizeof(float) * 4 * 9, &verts, 0); - memcpy(verts, vert, sizeof(float) * 4 * 9); + overlay->vert_buf->Lock(0, sizeof(vert), &verts, 0); + memcpy(verts, vert, sizeof(vert)); d3d_vertex_buffer_unlock(overlay->vert_buf); d3d_enable_blend_func(d3d->dev); From a61c529d20f5b0c929ab3311427509f69ad95589 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Wed, 11 Nov 2015 04:07:48 +0100 Subject: [PATCH 108/216] (D3D) Simplify struct overlay_vertex --- gfx/d3d/d3d.cpp | 48 ++++++++++++++++++++++++------------------------ 1 file changed, 24 insertions(+), 24 deletions(-) diff --git a/gfx/d3d/d3d.cpp b/gfx/d3d/d3d.cpp index aab2624878..a913436a64 100644 --- a/gfx/d3d/d3d.cpp +++ b/gfx/d3d/d3d.cpp @@ -1290,9 +1290,7 @@ static void d3d_overlay_render(d3d_video_t *d3d, overlay_t *overlay) unsigned i; struct overlay_vertex { - float x, y, z; - float u, v; - float r, g, b, a; + float v[9]; } vert[4]; float overlay_width, overlay_height; #ifndef _XBOX1 @@ -1325,9 +1323,11 @@ static void d3d_overlay_render(d3d_video_t *d3d, overlay_t *overlay) for (i = 0; i < 4; i++) { - vert[i].z = 0.5f; - vert[i].r = vert[i].g = vert[i].b = 1.0f; - vert[i].a = overlay->alpha_mod; + vert[i].v[2] = 0.5f; + vert[i].v[5] = 1.0f; + vert[i].v[6] = 1.0f; + vert[i].v[7] = 1.0f; + vert[i].v[8] = overlay->alpha_mod; } d3d_viewport_info(d3d, &vp); @@ -1335,33 +1335,33 @@ static void d3d_overlay_render(d3d_video_t *d3d, overlay_t *overlay) overlay_width = vp.width; overlay_height = vp.height; - vert[0].x = overlay->vert_coords[0] * overlay_width; - vert[1].x = (overlay->vert_coords[0] + overlay->vert_coords[2]) + vert[0].v[0] = overlay->vert_coords[0] * overlay_width; + vert[1].v[0] = (overlay->vert_coords[0] + overlay->vert_coords[2]) * overlay_width; - vert[2].x = overlay->vert_coords[0] * overlay_width; - vert[3].x = (overlay->vert_coords[0] + overlay->vert_coords[2]) + vert[2].v[0] = overlay->vert_coords[0] * overlay_width; + vert[3].v[0] = (overlay->vert_coords[0] + overlay->vert_coords[2]) * overlay_width; - vert[0].y = overlay->vert_coords[1] * overlay_height; - vert[1].y = overlay->vert_coords[1] * overlay_height; - vert[2].y = (overlay->vert_coords[1] + overlay->vert_coords[3]) + vert[0].v[1] = overlay->vert_coords[1] * overlay_height; + vert[1].v[1] = overlay->vert_coords[1] * overlay_height; + vert[2].v[1] = (overlay->vert_coords[1] + overlay->vert_coords[3]) * overlay_height; - vert[3].y = (overlay->vert_coords[1] + overlay->vert_coords[3]) + vert[3].v[1] = (overlay->vert_coords[1] + overlay->vert_coords[3]) * overlay_height; - vert[0].u = overlay->tex_coords[0]; - vert[1].u = overlay->tex_coords[0] + overlay->tex_coords[2]; - vert[2].u = overlay->tex_coords[0]; - vert[3].u = overlay->tex_coords[0] + overlay->tex_coords[2]; - vert[0].v = overlay->tex_coords[1]; - vert[1].v = overlay->tex_coords[1]; - vert[2].v = overlay->tex_coords[1] + overlay->tex_coords[3]; - vert[3].v = overlay->tex_coords[1] + overlay->tex_coords[3]; + vert[0].v[3] = overlay->tex_coords[0]; + vert[1].v[3] = overlay->tex_coords[0] + overlay->tex_coords[2]; + vert[2].v[3] = overlay->tex_coords[0]; + vert[3].v[3] = overlay->tex_coords[0] + overlay->tex_coords[2]; + vert[0].v[4] = overlay->tex_coords[1]; + vert[1].v[4] = overlay->tex_coords[1]; + vert[2].v[4] = overlay->tex_coords[1] + overlay->tex_coords[3]; + vert[3].v[4] = overlay->tex_coords[1] + overlay->tex_coords[3]; /* Align texels and vertices. */ for (i = 0; i < 4; i++) { - vert[i].x -= 0.5f; - vert[i].y += 0.5f; + vert[i].v[0] -= 0.5f; + vert[i].v[1] += 0.5f; } overlay->vert_buf->Lock(0, sizeof(vert), &verts, 0); From e7808e03d0aea4ab4dd2d2a5040a86e81b8487bd Mon Sep 17 00:00:00 2001 From: twinaphex Date: Wed, 11 Nov 2015 04:12:33 +0100 Subject: [PATCH 109/216] (D3D) Remove overlay_vertex --- gfx/d3d/d3d.cpp | 53 +++++++++++++++++++++++-------------------------- 1 file changed, 25 insertions(+), 28 deletions(-) diff --git a/gfx/d3d/d3d.cpp b/gfx/d3d/d3d.cpp index a913436a64..cb64243086 100644 --- a/gfx/d3d/d3d.cpp +++ b/gfx/d3d/d3d.cpp @@ -1288,10 +1288,7 @@ static void d3d_overlay_render(d3d_video_t *d3d, overlay_t *overlay) unsigned width, height; void *verts; unsigned i; - struct overlay_vertex - { - float v[9]; - } vert[4]; + float vert[4][9]; float overlay_width, overlay_height; #ifndef _XBOX1 LPDIRECT3DVERTEXDECLARATION vertex_decl; @@ -1323,11 +1320,11 @@ static void d3d_overlay_render(d3d_video_t *d3d, overlay_t *overlay) for (i = 0; i < 4; i++) { - vert[i].v[2] = 0.5f; - vert[i].v[5] = 1.0f; - vert[i].v[6] = 1.0f; - vert[i].v[7] = 1.0f; - vert[i].v[8] = overlay->alpha_mod; + vert[i][2] = 0.5f; + vert[i][5] = 1.0f; + vert[i][6] = 1.0f; + vert[i][7] = 1.0f; + vert[i][8] = overlay->alpha_mod; } d3d_viewport_info(d3d, &vp); @@ -1335,33 +1332,33 @@ static void d3d_overlay_render(d3d_video_t *d3d, overlay_t *overlay) overlay_width = vp.width; overlay_height = vp.height; - vert[0].v[0] = overlay->vert_coords[0] * overlay_width; - vert[1].v[0] = (overlay->vert_coords[0] + overlay->vert_coords[2]) + vert[0][0] = overlay->vert_coords[0] * overlay_width; + vert[1][0] = (overlay->vert_coords[0] + overlay->vert_coords[2]) * overlay_width; - vert[2].v[0] = overlay->vert_coords[0] * overlay_width; - vert[3].v[0] = (overlay->vert_coords[0] + overlay->vert_coords[2]) + vert[2][0] = overlay->vert_coords[0] * overlay_width; + vert[3][0] = (overlay->vert_coords[0] + overlay->vert_coords[2]) * overlay_width; - vert[0].v[1] = overlay->vert_coords[1] * overlay_height; - vert[1].v[1] = overlay->vert_coords[1] * overlay_height; - vert[2].v[1] = (overlay->vert_coords[1] + overlay->vert_coords[3]) + vert[0][1] = overlay->vert_coords[1] * overlay_height; + vert[1][1] = overlay->vert_coords[1] * overlay_height; + vert[2][1] = (overlay->vert_coords[1] + overlay->vert_coords[3]) * overlay_height; - vert[3].v[1] = (overlay->vert_coords[1] + overlay->vert_coords[3]) + vert[3][1] = (overlay->vert_coords[1] + overlay->vert_coords[3]) * overlay_height; - vert[0].v[3] = overlay->tex_coords[0]; - vert[1].v[3] = overlay->tex_coords[0] + overlay->tex_coords[2]; - vert[2].v[3] = overlay->tex_coords[0]; - vert[3].v[3] = overlay->tex_coords[0] + overlay->tex_coords[2]; - vert[0].v[4] = overlay->tex_coords[1]; - vert[1].v[4] = overlay->tex_coords[1]; - vert[2].v[4] = overlay->tex_coords[1] + overlay->tex_coords[3]; - vert[3].v[4] = overlay->tex_coords[1] + overlay->tex_coords[3]; + vert[0][3] = overlay->tex_coords[0]; + vert[1][3] = overlay->tex_coords[0] + overlay->tex_coords[2]; + vert[2][3] = overlay->tex_coords[0]; + vert[3][3] = overlay->tex_coords[0] + overlay->tex_coords[2]; + vert[0][4] = overlay->tex_coords[1]; + vert[1][4] = overlay->tex_coords[1]; + vert[2][4] = overlay->tex_coords[1] + overlay->tex_coords[3]; + vert[3][4] = overlay->tex_coords[1] + overlay->tex_coords[3]; /* Align texels and vertices. */ for (i = 0; i < 4; i++) { - vert[i].v[0] -= 0.5f; - vert[i].v[1] += 0.5f; + vert[i][0] -= 0.5f; + vert[i][1] += 0.5f; } overlay->vert_buf->Lock(0, sizeof(vert), &verts, 0); @@ -1377,7 +1374,7 @@ static void d3d_overlay_render(d3d_video_t *d3d, overlay_t *overlay) #endif d3d_set_stream_source(d3d->dev, 0, overlay->vert_buf, - 0, sizeof(overlay_vertex)); + 0, sizeof(*vert)); video_driver_get_size(&width, &height); From edc72d477b293859108c0e37423059620c505898 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Wed, 11 Nov 2015 04:16:18 +0100 Subject: [PATCH 110/216] d3d_texture_new - unnecessary casts --- gfx/d3d/d3d.cpp | 6 ++---- gfx/d3d/render_chain_cg.cpp | 21 ++++++++++----------- gfx/d3d/render_chain_xdk.cpp | 2 +- 3 files changed, 13 insertions(+), 16 deletions(-) diff --git a/gfx/d3d/d3d.cpp b/gfx/d3d/d3d.cpp index cb64243086..d9b999bbb2 100644 --- a/gfx/d3d/d3d.cpp +++ b/gfx/d3d/d3d.cpp @@ -1470,8 +1470,7 @@ static bool d3d_overlay_load(void *data, unsigned height = images[i].height; overlay_t *overlay = (overlay_t*)&d3d->overlays[i]; - overlay->tex = (LPDIRECT3DTEXTURE) - d3d_texture_new(d3d->dev, NULL, + overlay->tex = d3d_texture_new(d3d->dev, NULL, width, height, 1, 0, D3DFMT_A8R8G8B8, @@ -1753,8 +1752,7 @@ static void d3d_set_menu_texture_frame(void *data, if (d3d->menu) d3d_texture_free(d3d->menu->tex); - d3d->menu->tex = (LPDIRECT3DTEXTURE) - d3d_texture_new(d3d->dev, NULL, + d3d->menu->tex = d3d_texture_new(d3d->dev, NULL, width, height, 1, 0, D3DFMT_A8R8G8B8, D3DPOOL_MANAGED, 0, 0, 0, NULL, NULL); diff --git a/gfx/d3d/render_chain_cg.cpp b/gfx/d3d/render_chain_cg.cpp index 312d7f6675..0fd8fd3a8d 100644 --- a/gfx/d3d/render_chain_cg.cpp +++ b/gfx/d3d/render_chain_cg.cpp @@ -893,8 +893,8 @@ static bool renderchain_create_first_pass(cg_renderchain_t *chain, if (!chain->prev.vertex_buf[i]) return false; - chain->prev.tex[i] = (LPDIRECT3DTEXTURE)d3d_texture_new( - d3dr, NULL, info->tex_w, info->tex_h, 1, 0, + chain->prev.tex[i] = d3d_texture_new(d3dr, NULL, + info->tex_w, info->tex_h, 1, 0, (fmt == RETRO_PIXEL_FORMAT_RGB565) ? D3DFMT_R5G6B5 : D3DFMT_X8R8G8B8, D3DPOOL_MANAGED, 0, 0, 0, NULL, NULL); @@ -963,13 +963,13 @@ static bool renderchain_set_pass_size(cg_renderchain_t *chain, pass->info.tex_w = width; pass->info.tex_h = height; - pass->tex = (LPDIRECT3DTEXTURE)d3d_texture_new( - d3dr, NULL, width, height, 1, - D3DUSAGE_RENDERTARGET, - chain->passes.back().info.pass->fbo.fp_fbo ? - D3DFMT_A32B32G32R32F : D3DFMT_A8R8G8B8, - D3DPOOL_DEFAULT, 0, 0, 0, - NULL, NULL); + pass->tex = d3d_texture_new(d3dr, NULL, + width, height, 1, + D3DUSAGE_RENDERTARGET, + chain->passes.back().info.pass->fbo.fp_fbo ? + D3DFMT_A32B32G32R32F : D3DFMT_A8R8G8B8, + D3DPOOL_DEFAULT, 0, 0, 0, + NULL, NULL); if (!pass->tex) return false; @@ -1134,8 +1134,7 @@ static bool cg_d3d9_renderchain_add_lut(void *data, lut_info info; cg_renderchain_t *chain = (cg_renderchain_t*)data; LPDIRECT3DDEVICE d3dr = chain->dev; - LPDIRECT3DTEXTURE lut = (LPDIRECT3DTEXTURE) - d3d_texture_new(d3dr, + LPDIRECT3DTEXTURE lut = d3d_texture_new(d3dr, path, D3DX_DEFAULT_NONPOW2, D3DX_DEFAULT_NONPOW2, diff --git a/gfx/d3d/render_chain_xdk.cpp b/gfx/d3d/render_chain_xdk.cpp index a51526ad13..4a7315d883 100644 --- a/gfx/d3d/render_chain_xdk.cpp +++ b/gfx/d3d/render_chain_xdk.cpp @@ -104,7 +104,7 @@ static bool renderchain_create_first_pass(void *data, if (!chain->vertex_buf) return false; - chain->tex = (LPDIRECT3DTEXTURE)d3d_texture_new(d3dr, NULL, + chain->tex = d3d_texture_new(d3dr, NULL, chain->tex_w, chain->tex_h, 1, 0, info->rgb32 ? D3DFMT_LIN_X8R8G8B8 : D3DFMT_LIN_R5G6B5, 0, 0, 0, 0, NULL, NULL); From 8cc70fb46b5f5743042c53622dffa4079cb89dd8 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Wed, 11 Nov 2015 04:18:10 +0100 Subject: [PATCH 111/216] Unnecessary casts for vertex_buffer_new --- gfx/d3d/d3d.cpp | 2 +- gfx/d3d/render_chain_cg.cpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/gfx/d3d/d3d.cpp b/gfx/d3d/d3d.cpp index d9b999bbb2..c839fa011a 100644 --- a/gfx/d3d/d3d.cpp +++ b/gfx/d3d/d3d.cpp @@ -1311,7 +1311,7 @@ static void d3d_overlay_render(d3d_video_t *d3d, overlay_t *overlay) if (!overlay->vert_buf) { - overlay->vert_buf = (LPDIRECT3DVERTEXBUFFER)d3d_vertex_buffer_new( + overlay->vert_buf = d3d_vertex_buffer_new( d3d->dev, sizeof(vert), 0, 0, D3DPOOL_MANAGED, NULL); if (!overlay->vert_buf) diff --git a/gfx/d3d/render_chain_cg.cpp b/gfx/d3d/render_chain_cg.cpp index 0fd8fd3a8d..8eb1e3e2c5 100644 --- a/gfx/d3d/render_chain_cg.cpp +++ b/gfx/d3d/render_chain_cg.cpp @@ -1102,7 +1102,7 @@ static bool cg_d3d9_renderchain_add_pass(void *data, const void *info_data) if (!cg_d3d9_renderchain_init_shader_fvf(chain, &pass)) return false; - pass.vertex_buf = (LPDIRECT3DVERTEXBUFFER)d3d_vertex_buffer_new(d3dr, 4 * sizeof(Vertex), + pass.vertex_buf = d3d_vertex_buffer_new(d3dr, 4 * sizeof(Vertex), 0, 0, D3DPOOL_DEFAULT, NULL); if (!pass.vertex_buf) From 3d77689bf566d7d5750217edfa23d29dab7ca025 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Wed, 11 Nov 2015 04:46:16 +0100 Subject: [PATCH 112/216] Create make_pp callback function --- gfx/d3d/d3d.cpp | 103 +--------------------------------- gfx/d3d/render_chain_cg.cpp | 40 +++++++++++++ gfx/d3d/render_chain_driver.h | 2 + gfx/d3d/render_chain_null.c | 1 + gfx/d3d/render_chain_xdk.cpp | 98 ++++++++++++++++++++++++++++++++ 5 files changed, 144 insertions(+), 100 deletions(-) diff --git a/gfx/d3d/d3d.cpp b/gfx/d3d/d3d.cpp index c839fa011a..d10aa318bb 100644 --- a/gfx/d3d/d3d.cpp +++ b/gfx/d3d/d3d.cpp @@ -138,111 +138,14 @@ void d3d_make_d3dpp(void *data, const video_info_t *info, D3DPRESENT_PARAMETERS *d3dpp) { d3d_video_t *d3d = (d3d_video_t*)data; - settings_t *settings = config_get_ptr(); - /* TODO/FIXME - get rid of global state dependencies. */ - global_t *global = global_get_ptr(); memset(d3dpp, 0, sizeof(*d3dpp)); - d3dpp->Windowed = false; -#ifndef _XBOX - d3dpp->Windowed = settings->video.windowed_fullscreen || !info->fullscreen; -#endif - d3dpp->PresentationInterval = D3DPRESENT_INTERVAL_IMMEDIATE; - - if (info->vsync) + if (d3d->renderchain_driver) { - switch (settings->video.swap_interval) - { - default: - case 1: - d3dpp->PresentationInterval = D3DPRESENT_INTERVAL_ONE; - break; - case 2: - d3dpp->PresentationInterval = D3DPRESENT_INTERVAL_TWO; - break; - case 3: - d3dpp->PresentationInterval = D3DPRESENT_INTERVAL_THREE; - break; - case 4: - d3dpp->PresentationInterval = D3DPRESENT_INTERVAL_FOUR; - break; - } + if (d3d->renderchain_driver->make_pp) + d3d->renderchain_driver->make_pp(d3d, info, d3dpp); } - - d3dpp->SwapEffect = D3DSWAPEFFECT_DISCARD; - d3dpp->BackBufferCount = 2; -#ifdef _XBOX - d3dpp->BackBufferFormat = -#ifdef _XBOX360 - global->console.screen.gamma_correction ? - (D3DFORMAT)MAKESRGBFMT(info->rgb32 ? D3DFMT_X8R8G8B8 : D3DFMT_LIN_R5G6B5) : -#endif - info->rgb32 ? D3DFMT_X8R8G8B8 : D3DFMT_LIN_R5G6B5; -#else - d3dpp->hDeviceWindow = d3d->hWnd; - d3dpp->BackBufferFormat = !d3dpp->Windowed ? D3DFMT_X8R8G8B8 : D3DFMT_UNKNOWN; -#endif - - if (!d3dpp->Windowed) - { -#ifdef _XBOX - unsigned width = 0; - unsigned height = 0; - - gfx_ctx_get_video_size(d3d, &width, &height); - - video_driver_set_size_width(width); - video_driver_set_size_height(height); -#endif - video_driver_get_size(&d3dpp->BackBufferWidth, &d3dpp->BackBufferHeight); - } - -#ifdef _XBOX - d3dpp->MultiSampleType = D3DMULTISAMPLE_NONE; - d3dpp->EnableAutoDepthStencil = FALSE; -#if defined(_XBOX1) - /* Get the "video mode" */ - DWORD video_mode = XGetVideoFlags(); - - /* Check if we are able to use progressive mode. */ - if (video_mode & XC_VIDEO_FLAGS_HDTV_480p) - d3dpp->Flags = D3DPRESENTFLAG_PROGRESSIVE; - else - d3dpp->Flags = D3DPRESENTFLAG_INTERLACED; - - /* Only valid in PAL mode, not valid for HDTV modes. */ - if (XGetVideoStandard() == XC_VIDEO_STANDARD_PAL_I) - { - if (video_mode & XC_VIDEO_FLAGS_PAL_60Hz) - d3dpp->FullScreen_RefreshRateInHz = 60; - else - d3dpp->FullScreen_RefreshRateInHz = 50; - } - - if (XGetAVPack() == XC_AV_PACK_HDTV) - { - if (video_mode & XC_VIDEO_FLAGS_HDTV_480p) - d3dpp->Flags = D3DPRESENTFLAG_PROGRESSIVE; - else if (video_mode & XC_VIDEO_FLAGS_HDTV_720p) - d3dpp->Flags = D3DPRESENTFLAG_PROGRESSIVE; - else if (video_mode & XC_VIDEO_FLAGS_HDTV_1080i) - d3dpp->Flags = D3DPRESENTFLAG_INTERLACED; - } - - if (widescreen_mode) - d3dpp->Flags |= D3DPRESENTFLAG_WIDESCREEN; -#elif defined(_XBOX360) - if (!widescreen_mode) - d3dpp->Flags |= D3DPRESENTFLAG_NO_LETTERBOX; - - if (global->console.screen.gamma_correction) - d3dpp->FrontBufferFormat = (D3DFORMAT)MAKESRGBFMT(D3DFMT_LE_X8R8G8B8); - else - d3dpp->FrontBufferFormat = D3DFMT_LE_X8R8G8B8; - d3dpp->MultiSampleQuality = 0; -#endif -#endif } static bool d3d_init_base(void *data, const video_info_t *info) diff --git a/gfx/d3d/render_chain_cg.cpp b/gfx/d3d/render_chain_cg.cpp index 8eb1e3e2c5..0c4e5b5f5b 100644 --- a/gfx/d3d/render_chain_cg.cpp +++ b/gfx/d3d/render_chain_cg.cpp @@ -1614,9 +1614,49 @@ static void cg_d3d9_renderchain_viewport_info(void *data, struct video_viewport vp->full_height = height; } +static void cg_d3d9_renderchain_make_pp(void *data, const video_info_t *info, void *pp) +{ + d3d_video_t *d3d = (d3d_video_t*)data; + settings_t *settings = config_get_ptr(); + D3DPRESENT_PARAMETERS *d3dpp = (D3DPRESENT_PARAMETERS*)pp; + + d3dpp->Windowed = false; + d3dpp->Windowed = settings->video.windowed_fullscreen || !info->fullscreen; + d3dpp->PresentationInterval = D3DPRESENT_INTERVAL_IMMEDIATE; + + if (info->vsync) + { + switch (settings->video.swap_interval) + { + default: + case 1: + d3dpp->PresentationInterval = D3DPRESENT_INTERVAL_ONE; + break; + case 2: + d3dpp->PresentationInterval = D3DPRESENT_INTERVAL_TWO; + break; + case 3: + d3dpp->PresentationInterval = D3DPRESENT_INTERVAL_THREE; + break; + case 4: + d3dpp->PresentationInterval = D3DPRESENT_INTERVAL_FOUR; + break; + } + } + + d3dpp->SwapEffect = D3DSWAPEFFECT_DISCARD; + d3dpp->BackBufferCount = 2; + d3dpp->hDeviceWindow = d3d->hWnd; + d3dpp->BackBufferFormat = !d3dpp->Windowed ? D3DFMT_X8R8G8B8 : D3DFMT_UNKNOWN; + + if (!d3dpp->Windowed) + video_driver_get_size(&d3dpp->BackBufferWidth, &d3dpp->BackBufferHeight); +} + renderchain_driver_t cg_d3d9_renderchain = { cg_d3d9_renderchain_free, cg_d3d9_renderchain_new, + cg_d3d9_renderchain_make_pp, cg_d3d9_renderchain_init_shader, cg_d3d9_renderchain_init_shader_fvf, NULL, diff --git a/gfx/d3d/render_chain_driver.h b/gfx/d3d/render_chain_driver.h index b8c609e349..5c9914d5a9 100644 --- a/gfx/d3d/render_chain_driver.h +++ b/gfx/d3d/render_chain_driver.h @@ -45,6 +45,8 @@ typedef struct renderchain_driver { void (*chain_free)(void *data); void *(*chain_new)(void); + void (*make_pp)(void *data, const video_info_t *info, + void *pp); bool (*init_shader)(void *data, void *renderchain_data); bool (*init_shader_fvf)(void *data, void *pass_data); bool (*reinit)(void *data, const void *info_data); diff --git a/gfx/d3d/render_chain_null.c b/gfx/d3d/render_chain_null.c index 4bb794665a..94b5cec6f0 100644 --- a/gfx/d3d/render_chain_null.c +++ b/gfx/d3d/render_chain_null.c @@ -134,6 +134,7 @@ static void null_renderchain_convert_geometry( renderchain_driver_t null_renderchain = { null_renderchain_free, null_renderchain_new, + NULL, null_renderchain_init_shader, null_renderchain_init_shader_fvf, NULL, diff --git a/gfx/d3d/render_chain_xdk.cpp b/gfx/d3d/render_chain_xdk.cpp index 4a7315d883..2f817b295c 100644 --- a/gfx/d3d/render_chain_xdk.cpp +++ b/gfx/d3d/render_chain_xdk.cpp @@ -479,9 +479,107 @@ static void xdk_renderchain_viewport_info(void *data, struct video_viewport *vp) vp->full_height = height; } +void xdk_renderchain_make_pp(void *data, const video_info_t *info, void *pp) +{ + d3d_video_t *d3d = (d3d_video_t*)data; + settings_t *settings = config_get_ptr(); + /* TODO/FIXME - get rid of global state dependencies. */ + global_t *global = global_get_ptr(); + D3DPRESENT_PARAMETERS *d3dpp = (D3DPRESENT_PARAMETERS*)pp; + + d3dpp->Windowed = false; + d3dpp->PresentationInterval = D3DPRESENT_INTERVAL_IMMEDIATE; + + if (info->vsync) + { + switch (settings->video.swap_interval) + { + default: + case 1: + d3dpp->PresentationInterval = D3DPRESENT_INTERVAL_ONE; + break; + case 2: + d3dpp->PresentationInterval = D3DPRESENT_INTERVAL_TWO; + break; + case 3: + d3dpp->PresentationInterval = D3DPRESENT_INTERVAL_THREE; + break; + case 4: + d3dpp->PresentationInterval = D3DPRESENT_INTERVAL_FOUR; + break; + } + } + + d3dpp->SwapEffect = D3DSWAPEFFECT_DISCARD; + d3dpp->BackBufferCount = 2; + d3dpp->BackBufferFormat = +#ifdef _XBOX360 + global->console.screen.gamma_correction ? + (D3DFORMAT)MAKESRGBFMT(info->rgb32 ? D3DFMT_X8R8G8B8 : D3DFMT_LIN_R5G6B5) : +#endif + info->rgb32 ? D3DFMT_X8R8G8B8 : D3DFMT_LIN_R5G6B5; + + if (!d3dpp->Windowed) + { + unsigned width = 0; + unsigned height = 0; + + gfx_ctx_get_video_size(d3d, &width, &height); + + video_driver_set_size_width(width); + video_driver_set_size_height(height); + video_driver_get_size(&d3dpp->BackBufferWidth, &d3dpp->BackBufferHeight); + } + + d3dpp->MultiSampleType = D3DMULTISAMPLE_NONE; + d3dpp->EnableAutoDepthStencil = FALSE; +#if defined(_XBOX1) + /* Get the "video mode" */ + DWORD video_mode = XGetVideoFlags(); + + /* Check if we are able to use progressive mode. */ + if (video_mode & XC_VIDEO_FLAGS_HDTV_480p) + d3dpp->Flags = D3DPRESENTFLAG_PROGRESSIVE; + else + d3dpp->Flags = D3DPRESENTFLAG_INTERLACED; + + /* Only valid in PAL mode, not valid for HDTV modes. */ + if (XGetVideoStandard() == XC_VIDEO_STANDARD_PAL_I) + { + if (video_mode & XC_VIDEO_FLAGS_PAL_60Hz) + d3dpp->FullScreen_RefreshRateInHz = 60; + else + d3dpp->FullScreen_RefreshRateInHz = 50; + } + + if (XGetAVPack() == XC_AV_PACK_HDTV) + { + if (video_mode & XC_VIDEO_FLAGS_HDTV_480p) + d3dpp->Flags = D3DPRESENTFLAG_PROGRESSIVE; + else if (video_mode & XC_VIDEO_FLAGS_HDTV_720p) + d3dpp->Flags = D3DPRESENTFLAG_PROGRESSIVE; + else if (video_mode & XC_VIDEO_FLAGS_HDTV_1080i) + d3dpp->Flags = D3DPRESENTFLAG_INTERLACED; + } + + if (widescreen_mode) + d3dpp->Flags |= D3DPRESENTFLAG_WIDESCREEN; +#elif defined(_XBOX360) + if (!widescreen_mode) + d3dpp->Flags |= D3DPRESENTFLAG_NO_LETTERBOX; + + if (global->console.screen.gamma_correction) + d3dpp->FrontBufferFormat = (D3DFORMAT)MAKESRGBFMT(D3DFMT_LE_X8R8G8B8); + else + d3dpp->FrontBufferFormat = D3DFMT_LE_X8R8G8B8; + d3dpp->MultiSampleQuality = 0; +#endif +} + renderchain_driver_t xdk_renderchain = { xdk_renderchain_free, xdk_renderchain_new, + xdk_renderchain_make_pp, xdk_renderchain_init_shader, xdk_renderchain_init_shader_fvf, xdk_renderchain_reinit, From 5ea9bfe7e50065d8609b47036681dd6c25ebe212 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Wed, 11 Nov 2015 04:49:20 +0100 Subject: [PATCH 113/216] Revert "Create make_pp callback function" This reverts commit 3d77689bf566d7d5750217edfa23d29dab7ca025. --- gfx/d3d/d3d.cpp | 103 +++++++++++++++++++++++++++++++++- gfx/d3d/render_chain_cg.cpp | 40 ------------- gfx/d3d/render_chain_driver.h | 2 - gfx/d3d/render_chain_null.c | 1 - gfx/d3d/render_chain_xdk.cpp | 98 -------------------------------- 5 files changed, 100 insertions(+), 144 deletions(-) diff --git a/gfx/d3d/d3d.cpp b/gfx/d3d/d3d.cpp index d10aa318bb..c839fa011a 100644 --- a/gfx/d3d/d3d.cpp +++ b/gfx/d3d/d3d.cpp @@ -138,14 +138,111 @@ void d3d_make_d3dpp(void *data, const video_info_t *info, D3DPRESENT_PARAMETERS *d3dpp) { d3d_video_t *d3d = (d3d_video_t*)data; + settings_t *settings = config_get_ptr(); + /* TODO/FIXME - get rid of global state dependencies. */ + global_t *global = global_get_ptr(); memset(d3dpp, 0, sizeof(*d3dpp)); - if (d3d->renderchain_driver) + d3dpp->Windowed = false; +#ifndef _XBOX + d3dpp->Windowed = settings->video.windowed_fullscreen || !info->fullscreen; +#endif + d3dpp->PresentationInterval = D3DPRESENT_INTERVAL_IMMEDIATE; + + if (info->vsync) { - if (d3d->renderchain_driver->make_pp) - d3d->renderchain_driver->make_pp(d3d, info, d3dpp); + switch (settings->video.swap_interval) + { + default: + case 1: + d3dpp->PresentationInterval = D3DPRESENT_INTERVAL_ONE; + break; + case 2: + d3dpp->PresentationInterval = D3DPRESENT_INTERVAL_TWO; + break; + case 3: + d3dpp->PresentationInterval = D3DPRESENT_INTERVAL_THREE; + break; + case 4: + d3dpp->PresentationInterval = D3DPRESENT_INTERVAL_FOUR; + break; + } } + + d3dpp->SwapEffect = D3DSWAPEFFECT_DISCARD; + d3dpp->BackBufferCount = 2; +#ifdef _XBOX + d3dpp->BackBufferFormat = +#ifdef _XBOX360 + global->console.screen.gamma_correction ? + (D3DFORMAT)MAKESRGBFMT(info->rgb32 ? D3DFMT_X8R8G8B8 : D3DFMT_LIN_R5G6B5) : +#endif + info->rgb32 ? D3DFMT_X8R8G8B8 : D3DFMT_LIN_R5G6B5; +#else + d3dpp->hDeviceWindow = d3d->hWnd; + d3dpp->BackBufferFormat = !d3dpp->Windowed ? D3DFMT_X8R8G8B8 : D3DFMT_UNKNOWN; +#endif + + if (!d3dpp->Windowed) + { +#ifdef _XBOX + unsigned width = 0; + unsigned height = 0; + + gfx_ctx_get_video_size(d3d, &width, &height); + + video_driver_set_size_width(width); + video_driver_set_size_height(height); +#endif + video_driver_get_size(&d3dpp->BackBufferWidth, &d3dpp->BackBufferHeight); + } + +#ifdef _XBOX + d3dpp->MultiSampleType = D3DMULTISAMPLE_NONE; + d3dpp->EnableAutoDepthStencil = FALSE; +#if defined(_XBOX1) + /* Get the "video mode" */ + DWORD video_mode = XGetVideoFlags(); + + /* Check if we are able to use progressive mode. */ + if (video_mode & XC_VIDEO_FLAGS_HDTV_480p) + d3dpp->Flags = D3DPRESENTFLAG_PROGRESSIVE; + else + d3dpp->Flags = D3DPRESENTFLAG_INTERLACED; + + /* Only valid in PAL mode, not valid for HDTV modes. */ + if (XGetVideoStandard() == XC_VIDEO_STANDARD_PAL_I) + { + if (video_mode & XC_VIDEO_FLAGS_PAL_60Hz) + d3dpp->FullScreen_RefreshRateInHz = 60; + else + d3dpp->FullScreen_RefreshRateInHz = 50; + } + + if (XGetAVPack() == XC_AV_PACK_HDTV) + { + if (video_mode & XC_VIDEO_FLAGS_HDTV_480p) + d3dpp->Flags = D3DPRESENTFLAG_PROGRESSIVE; + else if (video_mode & XC_VIDEO_FLAGS_HDTV_720p) + d3dpp->Flags = D3DPRESENTFLAG_PROGRESSIVE; + else if (video_mode & XC_VIDEO_FLAGS_HDTV_1080i) + d3dpp->Flags = D3DPRESENTFLAG_INTERLACED; + } + + if (widescreen_mode) + d3dpp->Flags |= D3DPRESENTFLAG_WIDESCREEN; +#elif defined(_XBOX360) + if (!widescreen_mode) + d3dpp->Flags |= D3DPRESENTFLAG_NO_LETTERBOX; + + if (global->console.screen.gamma_correction) + d3dpp->FrontBufferFormat = (D3DFORMAT)MAKESRGBFMT(D3DFMT_LE_X8R8G8B8); + else + d3dpp->FrontBufferFormat = D3DFMT_LE_X8R8G8B8; + d3dpp->MultiSampleQuality = 0; +#endif +#endif } static bool d3d_init_base(void *data, const video_info_t *info) diff --git a/gfx/d3d/render_chain_cg.cpp b/gfx/d3d/render_chain_cg.cpp index 0c4e5b5f5b..8eb1e3e2c5 100644 --- a/gfx/d3d/render_chain_cg.cpp +++ b/gfx/d3d/render_chain_cg.cpp @@ -1614,49 +1614,9 @@ static void cg_d3d9_renderchain_viewport_info(void *data, struct video_viewport vp->full_height = height; } -static void cg_d3d9_renderchain_make_pp(void *data, const video_info_t *info, void *pp) -{ - d3d_video_t *d3d = (d3d_video_t*)data; - settings_t *settings = config_get_ptr(); - D3DPRESENT_PARAMETERS *d3dpp = (D3DPRESENT_PARAMETERS*)pp; - - d3dpp->Windowed = false; - d3dpp->Windowed = settings->video.windowed_fullscreen || !info->fullscreen; - d3dpp->PresentationInterval = D3DPRESENT_INTERVAL_IMMEDIATE; - - if (info->vsync) - { - switch (settings->video.swap_interval) - { - default: - case 1: - d3dpp->PresentationInterval = D3DPRESENT_INTERVAL_ONE; - break; - case 2: - d3dpp->PresentationInterval = D3DPRESENT_INTERVAL_TWO; - break; - case 3: - d3dpp->PresentationInterval = D3DPRESENT_INTERVAL_THREE; - break; - case 4: - d3dpp->PresentationInterval = D3DPRESENT_INTERVAL_FOUR; - break; - } - } - - d3dpp->SwapEffect = D3DSWAPEFFECT_DISCARD; - d3dpp->BackBufferCount = 2; - d3dpp->hDeviceWindow = d3d->hWnd; - d3dpp->BackBufferFormat = !d3dpp->Windowed ? D3DFMT_X8R8G8B8 : D3DFMT_UNKNOWN; - - if (!d3dpp->Windowed) - video_driver_get_size(&d3dpp->BackBufferWidth, &d3dpp->BackBufferHeight); -} - renderchain_driver_t cg_d3d9_renderchain = { cg_d3d9_renderchain_free, cg_d3d9_renderchain_new, - cg_d3d9_renderchain_make_pp, cg_d3d9_renderchain_init_shader, cg_d3d9_renderchain_init_shader_fvf, NULL, diff --git a/gfx/d3d/render_chain_driver.h b/gfx/d3d/render_chain_driver.h index 5c9914d5a9..b8c609e349 100644 --- a/gfx/d3d/render_chain_driver.h +++ b/gfx/d3d/render_chain_driver.h @@ -45,8 +45,6 @@ typedef struct renderchain_driver { void (*chain_free)(void *data); void *(*chain_new)(void); - void (*make_pp)(void *data, const video_info_t *info, - void *pp); bool (*init_shader)(void *data, void *renderchain_data); bool (*init_shader_fvf)(void *data, void *pass_data); bool (*reinit)(void *data, const void *info_data); diff --git a/gfx/d3d/render_chain_null.c b/gfx/d3d/render_chain_null.c index 94b5cec6f0..4bb794665a 100644 --- a/gfx/d3d/render_chain_null.c +++ b/gfx/d3d/render_chain_null.c @@ -134,7 +134,6 @@ static void null_renderchain_convert_geometry( renderchain_driver_t null_renderchain = { null_renderchain_free, null_renderchain_new, - NULL, null_renderchain_init_shader, null_renderchain_init_shader_fvf, NULL, diff --git a/gfx/d3d/render_chain_xdk.cpp b/gfx/d3d/render_chain_xdk.cpp index 2f817b295c..4a7315d883 100644 --- a/gfx/d3d/render_chain_xdk.cpp +++ b/gfx/d3d/render_chain_xdk.cpp @@ -479,107 +479,9 @@ static void xdk_renderchain_viewport_info(void *data, struct video_viewport *vp) vp->full_height = height; } -void xdk_renderchain_make_pp(void *data, const video_info_t *info, void *pp) -{ - d3d_video_t *d3d = (d3d_video_t*)data; - settings_t *settings = config_get_ptr(); - /* TODO/FIXME - get rid of global state dependencies. */ - global_t *global = global_get_ptr(); - D3DPRESENT_PARAMETERS *d3dpp = (D3DPRESENT_PARAMETERS*)pp; - - d3dpp->Windowed = false; - d3dpp->PresentationInterval = D3DPRESENT_INTERVAL_IMMEDIATE; - - if (info->vsync) - { - switch (settings->video.swap_interval) - { - default: - case 1: - d3dpp->PresentationInterval = D3DPRESENT_INTERVAL_ONE; - break; - case 2: - d3dpp->PresentationInterval = D3DPRESENT_INTERVAL_TWO; - break; - case 3: - d3dpp->PresentationInterval = D3DPRESENT_INTERVAL_THREE; - break; - case 4: - d3dpp->PresentationInterval = D3DPRESENT_INTERVAL_FOUR; - break; - } - } - - d3dpp->SwapEffect = D3DSWAPEFFECT_DISCARD; - d3dpp->BackBufferCount = 2; - d3dpp->BackBufferFormat = -#ifdef _XBOX360 - global->console.screen.gamma_correction ? - (D3DFORMAT)MAKESRGBFMT(info->rgb32 ? D3DFMT_X8R8G8B8 : D3DFMT_LIN_R5G6B5) : -#endif - info->rgb32 ? D3DFMT_X8R8G8B8 : D3DFMT_LIN_R5G6B5; - - if (!d3dpp->Windowed) - { - unsigned width = 0; - unsigned height = 0; - - gfx_ctx_get_video_size(d3d, &width, &height); - - video_driver_set_size_width(width); - video_driver_set_size_height(height); - video_driver_get_size(&d3dpp->BackBufferWidth, &d3dpp->BackBufferHeight); - } - - d3dpp->MultiSampleType = D3DMULTISAMPLE_NONE; - d3dpp->EnableAutoDepthStencil = FALSE; -#if defined(_XBOX1) - /* Get the "video mode" */ - DWORD video_mode = XGetVideoFlags(); - - /* Check if we are able to use progressive mode. */ - if (video_mode & XC_VIDEO_FLAGS_HDTV_480p) - d3dpp->Flags = D3DPRESENTFLAG_PROGRESSIVE; - else - d3dpp->Flags = D3DPRESENTFLAG_INTERLACED; - - /* Only valid in PAL mode, not valid for HDTV modes. */ - if (XGetVideoStandard() == XC_VIDEO_STANDARD_PAL_I) - { - if (video_mode & XC_VIDEO_FLAGS_PAL_60Hz) - d3dpp->FullScreen_RefreshRateInHz = 60; - else - d3dpp->FullScreen_RefreshRateInHz = 50; - } - - if (XGetAVPack() == XC_AV_PACK_HDTV) - { - if (video_mode & XC_VIDEO_FLAGS_HDTV_480p) - d3dpp->Flags = D3DPRESENTFLAG_PROGRESSIVE; - else if (video_mode & XC_VIDEO_FLAGS_HDTV_720p) - d3dpp->Flags = D3DPRESENTFLAG_PROGRESSIVE; - else if (video_mode & XC_VIDEO_FLAGS_HDTV_1080i) - d3dpp->Flags = D3DPRESENTFLAG_INTERLACED; - } - - if (widescreen_mode) - d3dpp->Flags |= D3DPRESENTFLAG_WIDESCREEN; -#elif defined(_XBOX360) - if (!widescreen_mode) - d3dpp->Flags |= D3DPRESENTFLAG_NO_LETTERBOX; - - if (global->console.screen.gamma_correction) - d3dpp->FrontBufferFormat = (D3DFORMAT)MAKESRGBFMT(D3DFMT_LE_X8R8G8B8); - else - d3dpp->FrontBufferFormat = D3DFMT_LE_X8R8G8B8; - d3dpp->MultiSampleQuality = 0; -#endif -} - renderchain_driver_t xdk_renderchain = { xdk_renderchain_free, xdk_renderchain_new, - xdk_renderchain_make_pp, xdk_renderchain_init_shader, xdk_renderchain_init_shader_fvf, xdk_renderchain_reinit, From a7df537dde6552ae78d87ca143642e27c2af84fd Mon Sep 17 00:00:00 2001 From: twinaphex Date: Wed, 11 Nov 2015 05:00:09 +0100 Subject: [PATCH 114/216] (D3D) Implement (rather stub) set_video_mode --- gfx/drivers_context/d3d_ctx.cpp | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/gfx/drivers_context/d3d_ctx.cpp b/gfx/drivers_context/d3d_ctx.cpp index bc5c8794e8..80846418db 100644 --- a/gfx/drivers_context/d3d_ctx.cpp +++ b/gfx/drivers_context/d3d_ctx.cpp @@ -282,6 +282,13 @@ static void gfx_ctx_d3d_input_driver(void *data, (void)data; } +static void gfx_ctx_d3d_set_video_mode(void *data, + unsigned width, unsigned height, + bool fullscreen) +{ + win32_show_cursor(!fullscreen); +} + static void gfx_ctx_d3d_get_video_size(void *data, unsigned *width, unsigned *height) { @@ -401,7 +408,7 @@ const gfx_ctx_driver_t gfx_ctx_d3d = { gfx_ctx_d3d_destroy, gfx_ctx_d3d_bind_api, gfx_ctx_d3d_swap_interval, - NULL, + gfx_ctx_d3d_set_video_mode, gfx_ctx_d3d_get_video_size, NULL, /* get_video_output_size */ NULL, /* get_video_output_prev */ From 8da911bc659d7a418844a19f64adc552842767bb Mon Sep 17 00:00:00 2001 From: twinaphex Date: Wed, 11 Nov 2015 05:01:37 +0100 Subject: [PATCH 115/216] (D3D Ctx) Buildfix --- gfx/drivers_context/d3d_ctx.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/gfx/drivers_context/d3d_ctx.cpp b/gfx/drivers_context/d3d_ctx.cpp index 80846418db..3956295119 100644 --- a/gfx/drivers_context/d3d_ctx.cpp +++ b/gfx/drivers_context/d3d_ctx.cpp @@ -282,11 +282,13 @@ static void gfx_ctx_d3d_input_driver(void *data, (void)data; } -static void gfx_ctx_d3d_set_video_mode(void *data, +static bool gfx_ctx_d3d_set_video_mode(void *data, unsigned width, unsigned height, bool fullscreen) { win32_show_cursor(!fullscreen); + + return true; } static void gfx_ctx_d3d_get_video_size(void *data, From 0f9f8c248bb29a860b69dc60c70921ae250f4014 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Wed, 11 Nov 2015 05:32:00 +0100 Subject: [PATCH 116/216] (Win32) Refactor monitor code --- gfx/d3d/d3d.cpp | 52 ++++++++++++++++++----------------- gfx/drivers_context/wgl_ctx.c | 31 +++++++++++++-------- 2 files changed, 46 insertions(+), 37 deletions(-) diff --git a/gfx/d3d/d3d.cpp b/gfx/d3d/d3d.cpp index c839fa011a..e9f82e0986 100644 --- a/gfx/d3d/d3d.cpp +++ b/gfx/d3d/d3d.cpp @@ -98,13 +98,13 @@ static void d3d_free_overlay(d3d_video_t *d3d, overlay_t *overlay); extern LRESULT CALLBACK WindowProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam); -static RECT d3d_monitor_rect(d3d_video_t *d3d); +static void d3d_monitor_rect(d3d_video_t *d3d, MONITORINFOEX *mon, HMONITOR *hm_to_use); #endif #ifdef HAVE_MONITOR -static HMONITOR monitor_last; -static HMONITOR monitor_all[MAX_MONITORS]; -static unsigned monitor_count; +static HMONITOR monitor_d3d_last; +static HMONITOR monitor_d3d_all[MAX_MONITORS]; +static unsigned monitor_d3d_count; #endif static void d3d_deinit_chain(d3d_video_t *d3d) @@ -632,9 +632,15 @@ static bool d3d_construct(d3d_video_t *d3d, #endif #ifdef HAVE_MONITOR - RECT mon_rect = d3d_monitor_rect(d3d); + bool windowed_full; + RECT mon_rect; + MONITORINFOEX mon; + HMONITOR hm_to_use - bool windowed_full = settings->video.windowed_fullscreen; + d3d_monitor_rect(d3d, &mon, &hm_to_use); + mon_rect = mon.rcMonitor; + + windowed_full = settings->video.windowed_fullscreen; full_x = (windowed_full || info->width == 0) ? (mon_rect.right - mon_rect.left) : info->width; @@ -887,7 +893,7 @@ static void d3d_free(void *data) d3d->g_pD3D->Release(); #ifdef HAVE_MONITOR - monitor_last = MonitorFromWindow(d3d->hWnd, + monitor_d3d_last = MonitorFromWindow(d3d->hWnd, MONITOR_DEFAULTTONEAREST); DestroyWindow(d3d->hWnd); #endif @@ -904,39 +910,37 @@ static void d3d_free(void *data) static BOOL CALLBACK d3d_monitor_enum_proc(HMONITOR hMonitor, HDC hdcMonitor, LPRECT lprcMonitor, LPARAM dwData) { - monitor_all[monitor_count++] = hMonitor; + monitor_d3d_all[monitor_d3d_count++] = hMonitor; return TRUE; } /* Multi-monitor support. */ -static RECT d3d_monitor_rect(d3d_video_t *d3d) +static void d3d_monitor_rect(d3d_video_t *d3d, MONITORINFOEX *mon, HMONITOR *hm_to_use) { unsigned fs_monitor, i; - MONITORINFOEX current_mon; - HMONITOR hm_to_use; - monitor_count = 0; + monitor_d3d_count = 0; settings_t *settings = config_get_ptr(); EnumDisplayMonitors(NULL, NULL, d3d_monitor_enum_proc, 0); - if (!monitor_last) - monitor_last = MonitorFromWindow( + if (!monitor_d3d_last) + monitor_d3d_last = MonitorFromWindow( GetDesktopWindow(), MONITOR_DEFAULTTONEAREST); - hm_to_use = monitor_last; + *hm_to_use = monitor_d3d_last; fs_monitor = settings->video.monitor_index; - if (fs_monitor && fs_monitor <= monitor_count - && monitor_all[fs_monitor - 1]) + if (fs_monitor && fs_monitor <= monitor_d3d_count + && monitor_d3d_all[fs_monitor - 1]) { - hm_to_use = monitor_all[fs_monitor - 1]; + *hm_to_use = monitor_d3d_all[fs_monitor - 1]; d3d->cur_mon_id = fs_monitor - 1; } else { - for (i = 0; i < monitor_count; i++) + for (i = 0; i < monitor_d3d_count; i++) { - if (monitor_all[i] != hm_to_use) + if (monitor_d3d_all[i] != *hm_to_use) continue; d3d->cur_mon_id = i; @@ -944,11 +948,9 @@ static RECT d3d_monitor_rect(d3d_video_t *d3d) } } - memset(¤t_mon, 0, sizeof(current_mon)); - current_mon.cbSize = sizeof(MONITORINFOEX); - GetMonitorInfo(hm_to_use, (MONITORINFO*)¤t_mon); - - return current_mon.rcMonitor; + memset(mon, 0, sizeof(*mon)); + mon->cbSize = sizeof(MONITORINFOEX); + GetMonitorInfo(*hm_to_use, (MONITORINFO*)mon); } #endif diff --git a/gfx/drivers_context/wgl_ctx.c b/gfx/drivers_context/wgl_ctx.c index 89af7ef366..451fa588a4 100644 --- a/gfx/drivers_context/wgl_ctx.c +++ b/gfx/drivers_context/wgl_ctx.c @@ -51,9 +51,11 @@ static HWND g_hwnd; static HGLRC g_hrc; static HGLRC g_hw_hrc; static HDC g_hdc; -static HMONITOR g_last_hm; -static HMONITOR g_all_hms[MAX_MONITORS]; -static unsigned g_num_mons; + +static HMONITOR monitor_wgl_last; +static HMONITOR monitor_wgl_all[MAX_MONITORS]; +static unsigned monitor_wgl_count; + static unsigned g_major; static unsigned g_minor; @@ -395,7 +397,7 @@ static void gfx_ctx_wgl_get_video_size(void *data, unsigned *width, unsigned *he static BOOL CALLBACK monitor_enum_proc(HMONITOR hMonitor, HDC hdcMonitor, LPRECT lprcMonitor, LPARAM dwData) { - g_all_hms[g_num_mons++] = hMonitor; + monitor_wgl_all[monitor_wgl_count++] = hMonitor; return TRUE; } @@ -411,7 +413,7 @@ static bool gfx_ctx_wgl_init(void *data) g_quit = false; g_restore_desktop = false; - g_num_mons = 0; + monitor_wgl_count = 0; EnumDisplayMonitors(NULL, NULL, monitor_enum_proc, 0); wndclass.cbSize = sizeof(wndclass); @@ -453,13 +455,18 @@ static void monitor_info(MONITORINFOEX *mon, HMONITOR *hm_to_use) unsigned fs_monitor; settings_t *settings = config_get_ptr(); - if (!g_last_hm) - g_last_hm = MonitorFromWindow(GetDesktopWindow(), MONITOR_DEFAULTTONEAREST); - *hm_to_use = g_last_hm; + if (!monitor_wgl_last) + monitor_wgl_last = MonitorFromWindow( + GetDesktopWindow(), MONITOR_DEFAULTTONEAREST); + *hm_to_use = monitor_wgl_last; fs_monitor = 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]; + + if (fs_monitor && fs_monitor <= monitor_wgl_count + && monitor_wgl_all[fs_monitor - 1]) + { + *hm_to_use = monitor_wgl_all[fs_monitor - 1]; + } memset(mon, 0, sizeof(*mon)); mon->cbSize = sizeof(MONITORINFOEX); @@ -610,7 +617,7 @@ static void gfx_ctx_wgl_destroy(void *data) if (g_hwnd) { - g_last_hm = MonitorFromWindow(g_hwnd, MONITOR_DEFAULTTONEAREST); + monitor_wgl_last = MonitorFromWindow(g_hwnd, MONITOR_DEFAULTTONEAREST); DestroyWindow(g_hwnd); UnregisterClass("RetroArch", GetModuleHandle(NULL)); g_hwnd = NULL; @@ -621,7 +628,7 @@ static void gfx_ctx_wgl_destroy(void *data) MONITORINFOEX current_mon; memset(¤t_mon, 0, sizeof(current_mon)); current_mon.cbSize = sizeof(MONITORINFOEX); - GetMonitorInfo(g_last_hm, (MONITORINFO*)¤t_mon); + GetMonitorInfo(monitor_wgl_last, (MONITORINFO*)¤t_mon); ChangeDisplaySettingsEx(current_mon.szDevice, NULL, NULL, 0, NULL); g_restore_desktop = false; } From 268b1b61d046a08069b77bd0fd66eac3874964eb Mon Sep 17 00:00:00 2001 From: twinaphex Date: Wed, 11 Nov 2015 05:32:55 +0100 Subject: [PATCH 117/216] (D3D) Buildfix --- gfx/d3d/d3d.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gfx/d3d/d3d.cpp b/gfx/d3d/d3d.cpp index e9f82e0986..89fd413f0a 100644 --- a/gfx/d3d/d3d.cpp +++ b/gfx/d3d/d3d.cpp @@ -635,7 +635,7 @@ static bool d3d_construct(d3d_video_t *d3d, bool windowed_full; RECT mon_rect; MONITORINFOEX mon; - HMONITOR hm_to_use + HMONITOR hm_to_use; d3d_monitor_rect(d3d, &mon, &hm_to_use); mon_rect = mon.rcMonitor; From 8c1da38cb1e014acc95c165fabda902ea4e18de5 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Wed, 11 Nov 2015 05:34:21 +0100 Subject: [PATCH 118/216] (D3D) Cleanups --- gfx/d3d/d3d.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/gfx/d3d/d3d.cpp b/gfx/d3d/d3d.cpp index 89fd413f0a..327794f567 100644 --- a/gfx/d3d/d3d.cpp +++ b/gfx/d3d/d3d.cpp @@ -634,11 +634,11 @@ static bool d3d_construct(d3d_video_t *d3d, #ifdef HAVE_MONITOR bool windowed_full; RECT mon_rect; - MONITORINFOEX mon; + MONITORINFOEX curent_mon; HMONITOR hm_to_use; - d3d_monitor_rect(d3d, &mon, &hm_to_use); - mon_rect = mon.rcMonitor; + d3d_monitor_rect(d3d, ¤t_mon, &hm_to_use); + mon_rect = current_mon.rcMonitor; windowed_full = settings->video.windowed_fullscreen; From 2064164c1dc989d73347267778a68fc48857657a Mon Sep 17 00:00:00 2001 From: twinaphex Date: Wed, 11 Nov 2015 05:35:32 +0100 Subject: [PATCH 119/216] (D3D) Buildfix --- gfx/d3d/d3d.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gfx/d3d/d3d.cpp b/gfx/d3d/d3d.cpp index 327794f567..7039140371 100644 --- a/gfx/d3d/d3d.cpp +++ b/gfx/d3d/d3d.cpp @@ -634,7 +634,7 @@ static bool d3d_construct(d3d_video_t *d3d, #ifdef HAVE_MONITOR bool windowed_full; RECT mon_rect; - MONITORINFOEX curent_mon; + MONITORINFOEX current_mon; HMONITOR hm_to_use; d3d_monitor_rect(d3d, ¤t_mon, &hm_to_use); From 3f77a9b745f9f045a0d226c33ec6e1a7160ee3d1 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Wed, 11 Nov 2015 05:38:41 +0100 Subject: [PATCH 120/216] (D3D) Updates --- gfx/d3d/d3d.cpp | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/gfx/d3d/d3d.cpp b/gfx/d3d/d3d.cpp index 7039140371..b81fd5c888 100644 --- a/gfx/d3d/d3d.cpp +++ b/gfx/d3d/d3d.cpp @@ -615,8 +615,11 @@ static bool d3d_construct(d3d_video_t *d3d, #if defined(HAVE_WINDOW) && !defined(_XBOX) memset(&d3d->windowClass, 0, sizeof(d3d->windowClass)); + monitor_d3d_count = 0; + EnumDisplayMonitors(NULL, NULL, d3d_monitor_enum_proc, 0); + d3d->windowClass.cbSize = sizeof(d3d->windowClass); - d3d->windowClass.style = CS_HREDRAW | CS_VREDRAW; + d3d->windowClass.style = CS_HREDRAW | CS_VREDRAW | CS_OWNDC; d3d->windowClass.lpfnWndProc = WindowProc; d3d->windowClass.hInstance = NULL; d3d->windowClass.hCursor = LoadCursor(NULL, IDC_ARROW); @@ -628,7 +631,8 @@ static bool d3d_construct(d3d_video_t *d3d, if (!info->fullscreen) d3d->windowClass.hbrBackground = (HBRUSH)COLOR_WINDOW; - RegisterClassEx(&d3d->windowClass); + if (!RegisterClassEx(&d3d->windowClass)) + return false; #endif #ifdef HAVE_MONITOR @@ -921,7 +925,6 @@ static void d3d_monitor_rect(d3d_video_t *d3d, MONITORINFOEX *mon, HMONITOR *hm_ monitor_d3d_count = 0; settings_t *settings = config_get_ptr(); - EnumDisplayMonitors(NULL, NULL, d3d_monitor_enum_proc, 0); if (!monitor_d3d_last) monitor_d3d_last = MonitorFromWindow( From d2e778b3f6c47718bff56efa91f7c1825732d7ea Mon Sep 17 00:00:00 2001 From: twinaphex Date: Wed, 11 Nov 2015 05:39:46 +0100 Subject: [PATCH 121/216] (D3D) Move code up --- gfx/d3d/d3d.cpp | 93 +++++++++++++++++++++++++------------------------ 1 file changed, 47 insertions(+), 46 deletions(-) diff --git a/gfx/d3d/d3d.cpp b/gfx/d3d/d3d.cpp index b81fd5c888..a44dbcb34b 100644 --- a/gfx/d3d/d3d.cpp +++ b/gfx/d3d/d3d.cpp @@ -581,6 +581,53 @@ static void d3d_set_osd_msg(void *data, const char *msg, font_ctx->render_msg(driver->font_osd_data, msg, params); } +#ifdef HAVE_MONITOR +static BOOL CALLBACK d3d_monitor_enum_proc(HMONITOR hMonitor, + HDC hdcMonitor, LPRECT lprcMonitor, LPARAM dwData) +{ + monitor_d3d_all[monitor_d3d_count++] = hMonitor; + return TRUE; +} + +/* Multi-monitor support. */ +static void d3d_monitor_rect(d3d_video_t *d3d, MONITORINFOEX *mon, HMONITOR *hm_to_use) +{ + unsigned fs_monitor, i; + monitor_d3d_count = 0; + settings_t *settings = config_get_ptr(); + + + if (!monitor_d3d_last) + monitor_d3d_last = MonitorFromWindow( + GetDesktopWindow(), MONITOR_DEFAULTTONEAREST); + + *hm_to_use = monitor_d3d_last; + fs_monitor = settings->video.monitor_index; + + if (fs_monitor && fs_monitor <= monitor_d3d_count + && monitor_d3d_all[fs_monitor - 1]) + { + *hm_to_use = monitor_d3d_all[fs_monitor - 1]; + d3d->cur_mon_id = fs_monitor - 1; + } + else + { + for (i = 0; i < monitor_d3d_count; i++) + { + if (monitor_d3d_all[i] != *hm_to_use) + continue; + + d3d->cur_mon_id = i; + break; + } + } + + memset(mon, 0, sizeof(*mon)); + mon->cbSize = sizeof(MONITORINFOEX); + GetMonitorInfo(*hm_to_use, (MONITORINFO*)mon); +} +#endif + /* Delay constructor due to lack of exceptions. */ static bool d3d_construct(d3d_video_t *d3d, @@ -910,52 +957,6 @@ static void d3d_free(void *data) #endif } -#ifdef HAVE_MONITOR -static BOOL CALLBACK d3d_monitor_enum_proc(HMONITOR hMonitor, - HDC hdcMonitor, LPRECT lprcMonitor, LPARAM dwData) -{ - monitor_d3d_all[monitor_d3d_count++] = hMonitor; - return TRUE; -} - -/* Multi-monitor support. */ -static void d3d_monitor_rect(d3d_video_t *d3d, MONITORINFOEX *mon, HMONITOR *hm_to_use) -{ - unsigned fs_monitor, i; - monitor_d3d_count = 0; - settings_t *settings = config_get_ptr(); - - - if (!monitor_d3d_last) - monitor_d3d_last = MonitorFromWindow( - GetDesktopWindow(), MONITOR_DEFAULTTONEAREST); - - *hm_to_use = monitor_d3d_last; - fs_monitor = settings->video.monitor_index; - - if (fs_monitor && fs_monitor <= monitor_d3d_count - && monitor_d3d_all[fs_monitor - 1]) - { - *hm_to_use = monitor_d3d_all[fs_monitor - 1]; - d3d->cur_mon_id = fs_monitor - 1; - } - else - { - for (i = 0; i < monitor_d3d_count; i++) - { - if (monitor_d3d_all[i] != *hm_to_use) - continue; - - d3d->cur_mon_id = i; - break; - } - } - - memset(mon, 0, sizeof(*mon)); - mon->cbSize = sizeof(MONITORINFOEX); - GetMonitorInfo(*hm_to_use, (MONITORINFO*)mon); -} -#endif #ifndef DONT_HAVE_STATE_TRACKER static bool d3d_init_imports(d3d_video_t *d3d) From 37154219f042f1a63477d0161a48a0015ce0a80d Mon Sep 17 00:00:00 2001 From: twinaphex Date: Wed, 11 Nov 2015 05:42:41 +0100 Subject: [PATCH 122/216] Revert "(D3D) Move code up" This reverts commit d2e778b3f6c47718bff56efa91f7c1825732d7ea. --- gfx/d3d/d3d.cpp | 93 ++++++++++++++++++++++++------------------------- 1 file changed, 46 insertions(+), 47 deletions(-) diff --git a/gfx/d3d/d3d.cpp b/gfx/d3d/d3d.cpp index a44dbcb34b..b81fd5c888 100644 --- a/gfx/d3d/d3d.cpp +++ b/gfx/d3d/d3d.cpp @@ -581,53 +581,6 @@ static void d3d_set_osd_msg(void *data, const char *msg, font_ctx->render_msg(driver->font_osd_data, msg, params); } -#ifdef HAVE_MONITOR -static BOOL CALLBACK d3d_monitor_enum_proc(HMONITOR hMonitor, - HDC hdcMonitor, LPRECT lprcMonitor, LPARAM dwData) -{ - monitor_d3d_all[monitor_d3d_count++] = hMonitor; - return TRUE; -} - -/* Multi-monitor support. */ -static void d3d_monitor_rect(d3d_video_t *d3d, MONITORINFOEX *mon, HMONITOR *hm_to_use) -{ - unsigned fs_monitor, i; - monitor_d3d_count = 0; - settings_t *settings = config_get_ptr(); - - - if (!monitor_d3d_last) - monitor_d3d_last = MonitorFromWindow( - GetDesktopWindow(), MONITOR_DEFAULTTONEAREST); - - *hm_to_use = monitor_d3d_last; - fs_monitor = settings->video.monitor_index; - - if (fs_monitor && fs_monitor <= monitor_d3d_count - && monitor_d3d_all[fs_monitor - 1]) - { - *hm_to_use = monitor_d3d_all[fs_monitor - 1]; - d3d->cur_mon_id = fs_monitor - 1; - } - else - { - for (i = 0; i < monitor_d3d_count; i++) - { - if (monitor_d3d_all[i] != *hm_to_use) - continue; - - d3d->cur_mon_id = i; - break; - } - } - - memset(mon, 0, sizeof(*mon)); - mon->cbSize = sizeof(MONITORINFOEX); - GetMonitorInfo(*hm_to_use, (MONITORINFO*)mon); -} -#endif - /* Delay constructor due to lack of exceptions. */ static bool d3d_construct(d3d_video_t *d3d, @@ -957,6 +910,52 @@ static void d3d_free(void *data) #endif } +#ifdef HAVE_MONITOR +static BOOL CALLBACK d3d_monitor_enum_proc(HMONITOR hMonitor, + HDC hdcMonitor, LPRECT lprcMonitor, LPARAM dwData) +{ + monitor_d3d_all[monitor_d3d_count++] = hMonitor; + return TRUE; +} + +/* Multi-monitor support. */ +static void d3d_monitor_rect(d3d_video_t *d3d, MONITORINFOEX *mon, HMONITOR *hm_to_use) +{ + unsigned fs_monitor, i; + monitor_d3d_count = 0; + settings_t *settings = config_get_ptr(); + + + if (!monitor_d3d_last) + monitor_d3d_last = MonitorFromWindow( + GetDesktopWindow(), MONITOR_DEFAULTTONEAREST); + + *hm_to_use = monitor_d3d_last; + fs_monitor = settings->video.monitor_index; + + if (fs_monitor && fs_monitor <= monitor_d3d_count + && monitor_d3d_all[fs_monitor - 1]) + { + *hm_to_use = monitor_d3d_all[fs_monitor - 1]; + d3d->cur_mon_id = fs_monitor - 1; + } + else + { + for (i = 0; i < monitor_d3d_count; i++) + { + if (monitor_d3d_all[i] != *hm_to_use) + continue; + + d3d->cur_mon_id = i; + break; + } + } + + memset(mon, 0, sizeof(*mon)); + mon->cbSize = sizeof(MONITORINFOEX); + GetMonitorInfo(*hm_to_use, (MONITORINFO*)mon); +} +#endif #ifndef DONT_HAVE_STATE_TRACKER static bool d3d_init_imports(d3d_video_t *d3d) From e90b8f1007c06d1f97b0ccf4e5b3b2991f6d0bdc Mon Sep 17 00:00:00 2001 From: twinaphex Date: Wed, 11 Nov 2015 05:42:49 +0100 Subject: [PATCH 123/216] Revert "(D3D) Updates" This reverts commit 3f77a9b745f9f045a0d226c33ec6e1a7160ee3d1. --- gfx/d3d/d3d.cpp | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/gfx/d3d/d3d.cpp b/gfx/d3d/d3d.cpp index b81fd5c888..7039140371 100644 --- a/gfx/d3d/d3d.cpp +++ b/gfx/d3d/d3d.cpp @@ -615,11 +615,8 @@ static bool d3d_construct(d3d_video_t *d3d, #if defined(HAVE_WINDOW) && !defined(_XBOX) memset(&d3d->windowClass, 0, sizeof(d3d->windowClass)); - monitor_d3d_count = 0; - EnumDisplayMonitors(NULL, NULL, d3d_monitor_enum_proc, 0); - d3d->windowClass.cbSize = sizeof(d3d->windowClass); - d3d->windowClass.style = CS_HREDRAW | CS_VREDRAW | CS_OWNDC; + d3d->windowClass.style = CS_HREDRAW | CS_VREDRAW; d3d->windowClass.lpfnWndProc = WindowProc; d3d->windowClass.hInstance = NULL; d3d->windowClass.hCursor = LoadCursor(NULL, IDC_ARROW); @@ -631,8 +628,7 @@ static bool d3d_construct(d3d_video_t *d3d, if (!info->fullscreen) d3d->windowClass.hbrBackground = (HBRUSH)COLOR_WINDOW; - if (!RegisterClassEx(&d3d->windowClass)) - return false; + RegisterClassEx(&d3d->windowClass); #endif #ifdef HAVE_MONITOR @@ -925,6 +921,7 @@ static void d3d_monitor_rect(d3d_video_t *d3d, MONITORINFOEX *mon, HMONITOR *hm_ monitor_d3d_count = 0; settings_t *settings = config_get_ptr(); + EnumDisplayMonitors(NULL, NULL, d3d_monitor_enum_proc, 0); if (!monitor_d3d_last) monitor_d3d_last = MonitorFromWindow( From 0cb507886a24e9894c2faae1c9a4145e413742e0 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Wed, 11 Nov 2015 17:36:52 +0100 Subject: [PATCH 124/216] Split up win32_monitor code to win32_common --- gfx/common/win32_common.c | 59 +++++++++++++++++++++ gfx/common/win32_common.h | 8 +++ gfx/drivers_context/wgl_ctx.c | 96 +++++++++++------------------------ 3 files changed, 96 insertions(+), 67 deletions(-) diff --git a/gfx/common/win32_common.c b/gfx/common/win32_common.c index b1df29772e..85e711875e 100644 --- a/gfx/common/win32_common.c +++ b/gfx/common/win32_common.c @@ -57,6 +57,65 @@ PowerClearRequest ( HANDLE PowerRequest, POWER_REQUEST_TYPE RequestType ); + +#ifndef MAX_MONITORS +#define MAX_MONITORS 9 +#endif + +static HMONITOR win32_monitor_last; +static unsigned win32_monitor_count; +static HMONITOR win32_monitor_all[MAX_MONITORS]; + +static BOOL CALLBACK win32_monitor_enum_proc(HMONITOR hMonitor, + HDC hdcMonitor, LPRECT lprcMonitor, LPARAM dwData) +{ + win32_monitor_all[win32_monitor_count++] = hMonitor; + return TRUE; +} + +void win32_monitor_init(void) +{ + win32_monitor_count = 0; + EnumDisplayMonitors(NULL, NULL, win32_monitor_enum_proc, 0); +} + +void win32_monitor_from_window(HWND data) +{ + win32_monitor_last = MonitorFromWindow(data, MONITOR_DEFAULTTONEAREST); +} + +void win32_monitor_get_info(void) +{ + MONITORINFOEX current_mon; + + memset(¤t_mon, 0, sizeof(current_mon)); + current_mon.cbSize = sizeof(MONITORINFOEX); + + GetMonitorInfo(win32_monitor_last, (MONITORINFO*)¤t_mon); + ChangeDisplaySettingsEx(current_mon.szDevice, NULL, NULL, 0, NULL); +} + +void win32_monitor_info(void *data, void *hm_data) +{ + unsigned fs_monitor; + settings_t *settings = config_get_ptr(); + MONITORINFOEX *mon = (MONITORINFOEX*)data; + HMONITOR *hm_to_use = (HMONITOR*)hm_data; + + if (!win32_monitor_last) + win32_monitor_from_window(GetDesktopWindow()); + + *hm_to_use = win32_monitor_last; + fs_monitor = settings->video.monitor_index; + + if (fs_monitor && fs_monitor <= win32_monitor_count + && win32_monitor_all[fs_monitor - 1]) + *hm_to_use = win32_monitor_all[fs_monitor - 1]; + + memset(mon, 0, sizeof(*mon)); + mon->cbSize = sizeof(MONITORINFOEX); + GetMonitorInfo(*hm_to_use, (MONITORINFO*)mon); +} #endif static bool win32_browser( diff --git a/gfx/common/win32_common.h b/gfx/common/win32_common.h index 70322081a6..358212a101 100644 --- a/gfx/common/win32_common.h +++ b/gfx/common/win32_common.h @@ -35,6 +35,14 @@ LRESULT win32_handle_keyboard_event(HWND hwnd, UINT message, WPARAM wparam, LPARAM lparam); LRESULT win32_menu_loop(HWND handle, WPARAM wparam); + +void win32_monitor_init(void); + +void win32_monitor_from_window(HWND data); + +void win32_monitor_get_info(void); + +void win32_monitor_info(void *data, void *hm_data); #endif bool win32_suppress_screensaver(void *data, bool enable); diff --git a/gfx/drivers_context/wgl_ctx.c b/gfx/drivers_context/wgl_ctx.c index 451fa588a4..895a17a43c 100644 --- a/gfx/drivers_context/wgl_ctx.c +++ b/gfx/drivers_context/wgl_ctx.c @@ -42,8 +42,28 @@ #define IDI_ICON 1 -#ifndef MAX_MONITORS -#define MAX_MONITORS 9 +#ifndef WGL_CONTEXT_MAJOR_VERSION_ARB +#define WGL_CONTEXT_MAJOR_VERSION_ARB 0x2091 +#endif + +#ifndef WGL_CONTEXT_MINOR_VERSION_ARB +#define WGL_CONTEXT_MINOR_VERSION_ARB 0x2092 +#endif + +#ifndef WGL_CONTEXT_PROFILE_MASK_ARB +#define WGL_CONTEXT_PROFILE_MASK_ARB 0x9126 +#endif + +#ifndef WGL_CONTEXT_CORE_PROFILE_BIT_ARB +#define WGL_CONTEXT_CORE_PROFILE_BIT_ARB 0x0001 +#endif + +#ifndef WGL_CONTEXT_FLAGS_ARB +#define WGL_CONTEXT_FLAGS_ARB 0x2094 +#endif + +#ifndef WGL_CONTEXT_DEBUG_BIT_ARB +#define WGL_CONTEXT_DEBUG_BIT_ARB 0x0001 #endif static bool g_use_hw_ctx; @@ -52,10 +72,6 @@ static HGLRC g_hrc; static HGLRC g_hw_hrc; static HDC g_hdc; -static HMONITOR monitor_wgl_last; -static HMONITOR monitor_wgl_all[MAX_MONITORS]; -static unsigned monitor_wgl_count; - static unsigned g_major; static unsigned g_minor; @@ -73,8 +89,6 @@ static dylib_t dll_handle = NULL; /* Handle to OpenGL32.dll */ static bool g_restore_desktop; -static void monitor_info(MONITORINFOEX *mon, HMONITOR *hm_to_use); - static void gfx_ctx_wgl_destroy(void *data); static BOOL (APIENTRY *p_swap_interval)(int); @@ -97,24 +111,6 @@ static void setup_pixel_format(HDC hdc) SetPixelFormat(hdc, ChoosePixelFormat(hdc, &pfd), &pfd); } -#ifndef WGL_CONTEXT_MAJOR_VERSION_ARB -#define WGL_CONTEXT_MAJOR_VERSION_ARB 0x2091 -#endif -#ifndef WGL_CONTEXT_MINOR_VERSION_ARB -#define WGL_CONTEXT_MINOR_VERSION_ARB 0x2092 -#endif -#ifndef WGL_CONTEXT_PROFILE_MASK_ARB -#define WGL_CONTEXT_PROFILE_MASK_ARB 0x9126 -#endif -#ifndef WGL_CONTEXT_CORE_PROFILE_BIT_ARB -#define WGL_CONTEXT_CORE_PROFILE_BIT_ARB 0x0001 -#endif -#ifndef WGL_CONTEXT_FLAGS_ARB -#define WGL_CONTEXT_FLAGS_ARB 0x2094 -#endif -#ifndef WGL_CONTEXT_DEBUG_BIT_ARB -#define WGL_CONTEXT_DEBUG_BIT_ARB 0x0001 -#endif static void create_gl_context(HWND hwnd) { @@ -382,7 +378,7 @@ static void gfx_ctx_wgl_get_video_size(void *data, unsigned *width, unsigned *he MONITORINFOEX current_mon; HMONITOR hm_to_use = NULL; - monitor_info(¤t_mon, &hm_to_use); + win32_monitor_info(¤t_mon, &hm_to_use); mon_rect = current_mon.rcMonitor; *width = mon_rect.right - mon_rect.left; *height = mon_rect.bottom - mon_rect.top; @@ -394,13 +390,6 @@ static void gfx_ctx_wgl_get_video_size(void *data, unsigned *width, unsigned *he } } -static BOOL CALLBACK monitor_enum_proc(HMONITOR hMonitor, - HDC hdcMonitor, LPRECT lprcMonitor, LPARAM dwData) -{ - monitor_wgl_all[monitor_wgl_count++] = hMonitor; - return TRUE; -} - static bool gfx_ctx_wgl_init(void *data) { WNDCLASSEX wndclass = {0}; @@ -410,11 +399,10 @@ static bool gfx_ctx_wgl_init(void *data) if (g_inited) return false; - g_quit = false; - g_restore_desktop = false; + g_quit = false; + g_restore_desktop = false; - monitor_wgl_count = 0; - EnumDisplayMonitors(NULL, NULL, monitor_enum_proc, 0); + win32_monitor_init(); wndclass.cbSize = sizeof(wndclass); wndclass.style = CS_HREDRAW | CS_VREDRAW | CS_OWNDC; @@ -450,28 +438,6 @@ static bool set_fullscreen(unsigned width, unsigned height, unsigned refresh, ch return ChangeDisplaySettingsEx(dev_name, &devmode, NULL, CDS_FULLSCREEN, NULL) == DISP_CHANGE_SUCCESSFUL; } -static void monitor_info(MONITORINFOEX *mon, HMONITOR *hm_to_use) -{ - unsigned fs_monitor; - settings_t *settings = config_get_ptr(); - - if (!monitor_wgl_last) - monitor_wgl_last = MonitorFromWindow( - GetDesktopWindow(), MONITOR_DEFAULTTONEAREST); - - *hm_to_use = monitor_wgl_last; - fs_monitor = settings->video.monitor_index; - - if (fs_monitor && fs_monitor <= monitor_wgl_count - && monitor_wgl_all[fs_monitor - 1]) - { - *hm_to_use = monitor_wgl_all[fs_monitor - 1]; - } - - memset(mon, 0, sizeof(*mon)); - mon->cbSize = sizeof(MONITORINFOEX); - GetMonitorInfo(*hm_to_use, (MONITORINFO*)mon); -} static bool gfx_ctx_wgl_set_video_mode(void *data, unsigned width, unsigned height, @@ -489,7 +455,7 @@ static bool gfx_ctx_wgl_set_video_mode(void *data, driver_t *driver = driver_get_ptr(); settings_t *settings = config_get_ptr(); - monitor_info(¤t_mon, &hm_to_use); + win32_monitor_info(¤t_mon, &hm_to_use); mon_rect = current_mon.rcMonitor; g_resize_width = width; @@ -617,7 +583,7 @@ static void gfx_ctx_wgl_destroy(void *data) if (g_hwnd) { - monitor_wgl_last = MonitorFromWindow(g_hwnd, MONITOR_DEFAULTTONEAREST); + win32_monitor_from_window(g_hwnd); DestroyWindow(g_hwnd); UnregisterClass("RetroArch", GetModuleHandle(NULL)); g_hwnd = NULL; @@ -625,11 +591,7 @@ static void gfx_ctx_wgl_destroy(void *data) if (g_restore_desktop) { - MONITORINFOEX current_mon; - memset(¤t_mon, 0, sizeof(current_mon)); - current_mon.cbSize = sizeof(MONITORINFOEX); - GetMonitorInfo(monitor_wgl_last, (MONITORINFO*)¤t_mon); - ChangeDisplaySettingsEx(current_mon.szDevice, NULL, NULL, 0, NULL); + win32_monitor_get_info(); g_restore_desktop = false; } From 8f9218ab1b9e459ad17ab864a4982dade6132967 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Wed, 11 Nov 2015 17:41:20 +0100 Subject: [PATCH 125/216] (Win32) Cleanups --- gfx/common/win32_common.c | 6 ++++-- gfx/common/win32_common.h | 10 +++++++--- gfx/drivers_context/wgl_ctx.c | 3 +-- 3 files changed, 12 insertions(+), 7 deletions(-) diff --git a/gfx/common/win32_common.c b/gfx/common/win32_common.c index 85e711875e..cc8a8331d1 100644 --- a/gfx/common/win32_common.c +++ b/gfx/common/win32_common.c @@ -79,9 +79,11 @@ void win32_monitor_init(void) EnumDisplayMonitors(NULL, NULL, win32_monitor_enum_proc, 0); } -void win32_monitor_from_window(HWND data) +void win32_monitor_from_window(HWND data, bool destroy) { win32_monitor_last = MonitorFromWindow(data, MONITOR_DEFAULTTONEAREST); + if (destroy) + DestroyWindow(data); } void win32_monitor_get_info(void) @@ -103,7 +105,7 @@ void win32_monitor_info(void *data, void *hm_data) HMONITOR *hm_to_use = (HMONITOR*)hm_data; if (!win32_monitor_last) - win32_monitor_from_window(GetDesktopWindow()); + win32_monitor_from_window(GetDesktopWindow(), false); *hm_to_use = win32_monitor_last; fs_monitor = settings->video.monitor_index; diff --git a/gfx/common/win32_common.h b/gfx/common/win32_common.h index 358212a101..c24b463677 100644 --- a/gfx/common/win32_common.h +++ b/gfx/common/win32_common.h @@ -18,6 +18,12 @@ #define WIN32_COMMON_H__ #include + +#ifndef _XBOX +#define WIN32_LEAN_AND_MEAN +#include +#endif + #include #include "../../driver.h" #include "../video_context_driver.h" @@ -27,8 +33,6 @@ extern "C" { #endif #ifndef _XBOX -#define WIN32_LEAN_AND_MEAN -#include #include "../drivers_wm/win32_resource.h" LRESULT win32_handle_keyboard_event(HWND hwnd, UINT message, @@ -38,7 +42,7 @@ LRESULT win32_menu_loop(HWND handle, WPARAM wparam); void win32_monitor_init(void); -void win32_monitor_from_window(HWND data); +void win32_monitor_from_window(HWND data, bool destroy); void win32_monitor_get_info(void); diff --git a/gfx/drivers_context/wgl_ctx.c b/gfx/drivers_context/wgl_ctx.c index 895a17a43c..80856f1bb7 100644 --- a/gfx/drivers_context/wgl_ctx.c +++ b/gfx/drivers_context/wgl_ctx.c @@ -583,8 +583,7 @@ static void gfx_ctx_wgl_destroy(void *data) if (g_hwnd) { - win32_monitor_from_window(g_hwnd); - DestroyWindow(g_hwnd); + win32_monitor_from_window(g_hwnd, true); UnregisterClass("RetroArch", GetModuleHandle(NULL)); g_hwnd = NULL; } From e0720cd7648c791ed415b143d9da9d922a82fd58 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Wed, 11 Nov 2015 17:47:56 +0100 Subject: [PATCH 126/216] Add mon_id argument to win32_get_monitor_info --- gfx/common/win32_common.c | 18 ++++++++++++++++-- gfx/common/win32_common.h | 2 +- gfx/drivers_context/wgl_ctx.c | 6 ++++-- 3 files changed, 21 insertions(+), 5 deletions(-) diff --git a/gfx/common/win32_common.c b/gfx/common/win32_common.c index cc8a8331d1..82a3a7f03e 100644 --- a/gfx/common/win32_common.c +++ b/gfx/common/win32_common.c @@ -97,9 +97,9 @@ void win32_monitor_get_info(void) ChangeDisplaySettingsEx(current_mon.szDevice, NULL, NULL, 0, NULL); } -void win32_monitor_info(void *data, void *hm_data) +void win32_monitor_info(void *data, void *hm_data, unsigned *mon_id) { - unsigned fs_monitor; + unsigned i, fs_monitor; settings_t *settings = config_get_ptr(); MONITORINFOEX *mon = (MONITORINFOEX*)data; HMONITOR *hm_to_use = (HMONITOR*)hm_data; @@ -112,7 +112,21 @@ void win32_monitor_info(void *data, void *hm_data) if (fs_monitor && fs_monitor <= win32_monitor_count && win32_monitor_all[fs_monitor - 1]) + { *hm_to_use = win32_monitor_all[fs_monitor - 1]; + *mon_id = fs_monitor - 1; + } + else + { + for (i = 0; i < win32_monitor_count; i++) + { + if (win32_monitor_all[i] != *hm_to_use) + continue; + + *mon_id = i; + break; + } + } memset(mon, 0, sizeof(*mon)); mon->cbSize = sizeof(MONITORINFOEX); diff --git a/gfx/common/win32_common.h b/gfx/common/win32_common.h index c24b463677..91a5f77b52 100644 --- a/gfx/common/win32_common.h +++ b/gfx/common/win32_common.h @@ -46,7 +46,7 @@ void win32_monitor_from_window(HWND data, bool destroy); void win32_monitor_get_info(void); -void win32_monitor_info(void *data, void *hm_data); +void win32_monitor_info(void *data, void *hm_data, unsigned *mon_id); #endif bool win32_suppress_screensaver(void *data, bool enable); diff --git a/gfx/drivers_context/wgl_ctx.c b/gfx/drivers_context/wgl_ctx.c index 80856f1bb7..cccdff2bc1 100644 --- a/gfx/drivers_context/wgl_ctx.c +++ b/gfx/drivers_context/wgl_ctx.c @@ -374,11 +374,12 @@ static void gfx_ctx_wgl_get_video_size(void *data, unsigned *width, unsigned *he if (!g_hwnd) { + unsigned mon_id; RECT mon_rect; MONITORINFOEX current_mon; HMONITOR hm_to_use = NULL; - win32_monitor_info(¤t_mon, &hm_to_use); + win32_monitor_info(¤t_mon, &hm_to_use, &mon_id); mon_rect = current_mon.rcMonitor; *width = mon_rect.right - mon_rect.left; *height = mon_rect.bottom - mon_rect.top; @@ -446,6 +447,7 @@ static bool gfx_ctx_wgl_set_video_mode(void *data, DWORD style; MSG msg; RECT mon_rect; + unsigned mon_id; MONITORINFOEX current_mon; float refresh_mod; unsigned refresh; @@ -455,7 +457,7 @@ static bool gfx_ctx_wgl_set_video_mode(void *data, driver_t *driver = driver_get_ptr(); settings_t *settings = config_get_ptr(); - win32_monitor_info(¤t_mon, &hm_to_use); + win32_monitor_info(¤t_mon, &hm_to_use, &mon_id); mon_rect = current_mon.rcMonitor; g_resize_width = width; From ca8d2b6b38738070a7a30e573ae96f5eef90d48a Mon Sep 17 00:00:00 2001 From: twinaphex Date: Wed, 11 Nov 2015 17:51:27 +0100 Subject: [PATCH 127/216] Change function signature of d3d_monitor_rect --- gfx/d3d/d3d.cpp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/gfx/d3d/d3d.cpp b/gfx/d3d/d3d.cpp index 7039140371..706fca767c 100644 --- a/gfx/d3d/d3d.cpp +++ b/gfx/d3d/d3d.cpp @@ -98,7 +98,7 @@ static void d3d_free_overlay(d3d_video_t *d3d, overlay_t *overlay); extern LRESULT CALLBACK WindowProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam); -static void d3d_monitor_rect(d3d_video_t *d3d, MONITORINFOEX *mon, HMONITOR *hm_to_use); +static void d3d_monitor_rect(MONITORINFOEX *mon, HMONITOR *hm_to_use, unsigned *mon_id); #endif #ifdef HAVE_MONITOR @@ -637,7 +637,7 @@ static bool d3d_construct(d3d_video_t *d3d, MONITORINFOEX current_mon; HMONITOR hm_to_use; - d3d_monitor_rect(d3d, ¤t_mon, &hm_to_use); + d3d_monitor_rect(¤t_mon, &hm_to_use, &d3d->cur_mon_id); mon_rect = current_mon.rcMonitor; windowed_full = settings->video.windowed_fullscreen; @@ -915,9 +915,9 @@ static BOOL CALLBACK d3d_monitor_enum_proc(HMONITOR hMonitor, } /* Multi-monitor support. */ -static void d3d_monitor_rect(d3d_video_t *d3d, MONITORINFOEX *mon, HMONITOR *hm_to_use) +static void d3d_monitor_rect(MONITORINFOEX *mon, HMONITOR *hm_to_use, unsigned *mon_id) { - unsigned fs_monitor, i; + unsigned i, fs_monitor; monitor_d3d_count = 0; settings_t *settings = config_get_ptr(); @@ -934,7 +934,7 @@ static void d3d_monitor_rect(d3d_video_t *d3d, MONITORINFOEX *mon, HMONITOR *hm_ && monitor_d3d_all[fs_monitor - 1]) { *hm_to_use = monitor_d3d_all[fs_monitor - 1]; - d3d->cur_mon_id = fs_monitor - 1; + *mon_id = fs_monitor - 1; } else { @@ -943,7 +943,7 @@ static void d3d_monitor_rect(d3d_video_t *d3d, MONITORINFOEX *mon, HMONITOR *hm_ if (monitor_d3d_all[i] != *hm_to_use) continue; - d3d->cur_mon_id = i; + *mon_id = i; break; } } From 00cbf68e95edbd5bb4c21499b6090863d287e77b Mon Sep 17 00:00:00 2001 From: twinaphex Date: Wed, 11 Nov 2015 17:57:15 +0100 Subject: [PATCH 128/216] (D3) Reuse common multi-monitor code --- gfx/d3d/d3d.cpp | 65 +-------------------------------- gfx/drivers_context/d3d_ctx.cpp | 4 ++ 2 files changed, 6 insertions(+), 63 deletions(-) diff --git a/gfx/d3d/d3d.cpp b/gfx/d3d/d3d.cpp index 706fca767c..a4fdc1ca39 100644 --- a/gfx/d3d/d3d.cpp +++ b/gfx/d3d/d3d.cpp @@ -92,19 +92,8 @@ static void d3d_free_overlay(d3d_video_t *d3d, overlay_t *overlay); #define IDI_ICON 1 -#ifndef MAX_MONITORS -#define MAX_MONITORS 9 -#endif - extern LRESULT CALLBACK WindowProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam); -static void d3d_monitor_rect(MONITORINFOEX *mon, HMONITOR *hm_to_use, unsigned *mon_id); -#endif - -#ifdef HAVE_MONITOR -static HMONITOR monitor_d3d_last; -static HMONITOR monitor_d3d_all[MAX_MONITORS]; -static unsigned monitor_d3d_count; #endif static void d3d_deinit_chain(d3d_video_t *d3d) @@ -637,7 +626,7 @@ static bool d3d_construct(d3d_video_t *d3d, MONITORINFOEX current_mon; HMONITOR hm_to_use; - d3d_monitor_rect(¤t_mon, &hm_to_use, &d3d->cur_mon_id); + win32_monitor_info(¤t_mon, &hm_to_use, &d3d->cur_mon_id); mon_rect = current_mon.rcMonitor; windowed_full = settings->video.windowed_fullscreen; @@ -893,9 +882,7 @@ static void d3d_free(void *data) d3d->g_pD3D->Release(); #ifdef HAVE_MONITOR - monitor_d3d_last = MonitorFromWindow(d3d->hWnd, - MONITOR_DEFAULTTONEAREST); - DestroyWindow(d3d->hWnd); + win32_monitor_from_window(d3d->hWnd, true); #endif if (d3d) @@ -906,54 +893,6 @@ static void d3d_free(void *data) #endif } -#ifdef HAVE_MONITOR -static BOOL CALLBACK d3d_monitor_enum_proc(HMONITOR hMonitor, - HDC hdcMonitor, LPRECT lprcMonitor, LPARAM dwData) -{ - monitor_d3d_all[monitor_d3d_count++] = hMonitor; - return TRUE; -} - -/* Multi-monitor support. */ -static void d3d_monitor_rect(MONITORINFOEX *mon, HMONITOR *hm_to_use, unsigned *mon_id) -{ - unsigned i, fs_monitor; - monitor_d3d_count = 0; - settings_t *settings = config_get_ptr(); - - EnumDisplayMonitors(NULL, NULL, d3d_monitor_enum_proc, 0); - - if (!monitor_d3d_last) - monitor_d3d_last = MonitorFromWindow( - GetDesktopWindow(), MONITOR_DEFAULTTONEAREST); - - *hm_to_use = monitor_d3d_last; - fs_monitor = settings->video.monitor_index; - - if (fs_monitor && fs_monitor <= monitor_d3d_count - && monitor_d3d_all[fs_monitor - 1]) - { - *hm_to_use = monitor_d3d_all[fs_monitor - 1]; - *mon_id = fs_monitor - 1; - } - else - { - for (i = 0; i < monitor_d3d_count; i++) - { - if (monitor_d3d_all[i] != *hm_to_use) - continue; - - *mon_id = i; - break; - } - } - - memset(mon, 0, sizeof(*mon)); - mon->cbSize = sizeof(MONITORINFOEX); - GetMonitorInfo(*hm_to_use, (MONITORINFO*)mon); -} -#endif - #ifndef DONT_HAVE_STATE_TRACKER static bool d3d_init_imports(d3d_video_t *d3d) { diff --git a/gfx/drivers_context/d3d_ctx.cpp b/gfx/drivers_context/d3d_ctx.cpp index 3956295119..a03c39c117 100644 --- a/gfx/drivers_context/d3d_ctx.cpp +++ b/gfx/drivers_context/d3d_ctx.cpp @@ -259,6 +259,10 @@ static bool gfx_ctx_d3d_init(void *data) d3d_quit = false; +#ifndef _XBOX + win32_monitor_init(); +#endif + return true; } From 6e689ec0f0e63119dc567799a384b9f8ba3836fb Mon Sep 17 00:00:00 2001 From: twinaphex Date: Wed, 11 Nov 2015 18:03:51 +0100 Subject: [PATCH 129/216] Take out windowClass from D3D struct --- gfx/d3d/d3d.cpp | 26 ++++++++++++++------------ gfx/d3d/d3d.h | 3 --- 2 files changed, 14 insertions(+), 15 deletions(-) diff --git a/gfx/d3d/d3d.cpp b/gfx/d3d/d3d.cpp index a4fdc1ca39..cf0b6ebf9a 100644 --- a/gfx/d3d/d3d.cpp +++ b/gfx/d3d/d3d.cpp @@ -577,6 +577,9 @@ static bool d3d_construct(d3d_video_t *d3d, void **input_data) { unsigned full_x, full_y; +#ifdef HAVE_WINDOW + WNDCLASSEX wndclass = {0}; +#endif driver_t *driver = driver_get_ptr(); settings_t *settings = config_get_ptr(); @@ -602,22 +605,21 @@ static bool d3d_construct(d3d_video_t *d3d, #endif #if defined(HAVE_WINDOW) && !defined(_XBOX) - memset(&d3d->windowClass, 0, sizeof(d3d->windowClass)); - - d3d->windowClass.cbSize = sizeof(d3d->windowClass); - d3d->windowClass.style = CS_HREDRAW | CS_VREDRAW; - d3d->windowClass.lpfnWndProc = WindowProc; - d3d->windowClass.hInstance = NULL; - d3d->windowClass.hCursor = LoadCursor(NULL, IDC_ARROW); - d3d->windowClass.lpszClassName = "RetroArch"; - d3d->windowClass.hIcon = LoadIcon(GetModuleHandle(NULL), + wndclass.cbSize = sizeof(wndclass); + wndclass.style = CS_HREDRAW | CS_VREDRAW; + wndclass.lpfnWndProc = WindowProc; + wndclass.hInstance = NULL; + wndclass.hCursor = LoadCursor(NULL, IDC_ARROW); + wndclass.lpszClassName = "RetroArch"; + wndclass.hIcon = LoadIcon(GetModuleHandle(NULL), MAKEINTRESOURCE(IDI_ICON)); - d3d->windowClass.hIconSm = (HICON)LoadImage(GetModuleHandle(NULL), + wndclass.hIconSm = (HICON)LoadImage(GetModuleHandle(NULL), MAKEINTRESOURCE(IDI_ICON), IMAGE_ICON, 16, 16, 0); if (!info->fullscreen) - d3d->windowClass.hbrBackground = (HBRUSH)COLOR_WINDOW; + wndclass.hbrBackground = (HBRUSH)COLOR_WINDOW; - RegisterClassEx(&d3d->windowClass); + if (!RegisterClassEx(&wndclass)) + return false; #endif #ifdef HAVE_MONITOR diff --git a/gfx/d3d/d3d.h b/gfx/d3d/d3d.h index 609da0e76e..13dcc6d040 100644 --- a/gfx/d3d/d3d.h +++ b/gfx/d3d/d3d.h @@ -98,9 +98,6 @@ typedef struct d3d_video bool quitting; struct video_viewport vp; -#ifdef HAVE_WINDOW - WNDCLASSEX windowClass; -#endif HWND hWnd; LPDIRECT3D g_pD3D; LPDIRECT3DDEVICE dev; From 75e30002e0c38de42633842a9d741bcc6108246e Mon Sep 17 00:00:00 2001 From: twinaphex Date: Wed, 11 Nov 2015 18:07:36 +0100 Subject: [PATCH 130/216] Revert "Take out windowClass from D3D struct" This reverts commit 6e689ec0f0e63119dc567799a384b9f8ba3836fb. --- gfx/d3d/d3d.cpp | 26 ++++++++++++-------------- gfx/d3d/d3d.h | 3 +++ 2 files changed, 15 insertions(+), 14 deletions(-) diff --git a/gfx/d3d/d3d.cpp b/gfx/d3d/d3d.cpp index cf0b6ebf9a..a4fdc1ca39 100644 --- a/gfx/d3d/d3d.cpp +++ b/gfx/d3d/d3d.cpp @@ -577,9 +577,6 @@ static bool d3d_construct(d3d_video_t *d3d, void **input_data) { unsigned full_x, full_y; -#ifdef HAVE_WINDOW - WNDCLASSEX wndclass = {0}; -#endif driver_t *driver = driver_get_ptr(); settings_t *settings = config_get_ptr(); @@ -605,21 +602,22 @@ static bool d3d_construct(d3d_video_t *d3d, #endif #if defined(HAVE_WINDOW) && !defined(_XBOX) - wndclass.cbSize = sizeof(wndclass); - wndclass.style = CS_HREDRAW | CS_VREDRAW; - wndclass.lpfnWndProc = WindowProc; - wndclass.hInstance = NULL; - wndclass.hCursor = LoadCursor(NULL, IDC_ARROW); - wndclass.lpszClassName = "RetroArch"; - wndclass.hIcon = LoadIcon(GetModuleHandle(NULL), + memset(&d3d->windowClass, 0, sizeof(d3d->windowClass)); + + d3d->windowClass.cbSize = sizeof(d3d->windowClass); + d3d->windowClass.style = CS_HREDRAW | CS_VREDRAW; + d3d->windowClass.lpfnWndProc = WindowProc; + d3d->windowClass.hInstance = NULL; + d3d->windowClass.hCursor = LoadCursor(NULL, IDC_ARROW); + d3d->windowClass.lpszClassName = "RetroArch"; + d3d->windowClass.hIcon = LoadIcon(GetModuleHandle(NULL), MAKEINTRESOURCE(IDI_ICON)); - wndclass.hIconSm = (HICON)LoadImage(GetModuleHandle(NULL), + d3d->windowClass.hIconSm = (HICON)LoadImage(GetModuleHandle(NULL), MAKEINTRESOURCE(IDI_ICON), IMAGE_ICON, 16, 16, 0); if (!info->fullscreen) - wndclass.hbrBackground = (HBRUSH)COLOR_WINDOW; + d3d->windowClass.hbrBackground = (HBRUSH)COLOR_WINDOW; - if (!RegisterClassEx(&wndclass)) - return false; + RegisterClassEx(&d3d->windowClass); #endif #ifdef HAVE_MONITOR diff --git a/gfx/d3d/d3d.h b/gfx/d3d/d3d.h index 13dcc6d040..609da0e76e 100644 --- a/gfx/d3d/d3d.h +++ b/gfx/d3d/d3d.h @@ -98,6 +98,9 @@ typedef struct d3d_video bool quitting; struct video_viewport vp; +#ifdef HAVE_WINDOW + WNDCLASSEX windowClass; +#endif HWND hWnd; LPDIRECT3D g_pD3D; LPDIRECT3DDEVICE dev; From 65a9419522e17e66ffcbf61209c929076566f808 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Wed, 11 Nov 2015 18:15:21 +0100 Subject: [PATCH 131/216] Create win32_window_init --- gfx/drivers_context/wgl_ctx.c | 32 +++++++++++++++++++------------- 1 file changed, 19 insertions(+), 13 deletions(-) diff --git a/gfx/drivers_context/wgl_ctx.c b/gfx/drivers_context/wgl_ctx.c index cccdff2bc1..bc33b19745 100644 --- a/gfx/drivers_context/wgl_ctx.c +++ b/gfx/drivers_context/wgl_ctx.c @@ -391,6 +391,23 @@ static void gfx_ctx_wgl_get_video_size(void *data, unsigned *width, unsigned *he } } +static bool win32_window_init(WNDCLASSEX *wndclass) +{ + wndclass->cbSize = sizeof(*wndclass); + wndclass->style = CS_HREDRAW | CS_VREDRAW | CS_OWNDC; + wndclass->lpfnWndProc = WndProc; + wndclass->hInstance = GetModuleHandle(NULL); + wndclass->hCursor = LoadCursor(NULL, IDC_ARROW); + wndclass->lpszClassName = "RetroArch"; + wndclass->hIcon = LoadIcon(GetModuleHandle(NULL), MAKEINTRESOURCE(IDI_ICON)); + wndclass->hIconSm = (HICON)LoadImage(GetModuleHandle(NULL), + MAKEINTRESOURCE(IDI_ICON), IMAGE_ICON, 16, 16, 0); + + if (!RegisterClassEx(wndclass)) + return false; + return true; +} + static bool gfx_ctx_wgl_init(void *data) { WNDCLASSEX wndclass = {0}; @@ -404,19 +421,8 @@ static bool gfx_ctx_wgl_init(void *data) g_restore_desktop = false; win32_monitor_init(); - - wndclass.cbSize = sizeof(wndclass); - wndclass.style = CS_HREDRAW | CS_VREDRAW | CS_OWNDC; - wndclass.lpfnWndProc = WndProc; - wndclass.hInstance = GetModuleHandle(NULL); - wndclass.hCursor = LoadCursor(NULL, IDC_ARROW); - wndclass.lpszClassName = "RetroArch"; - wndclass.hIcon = LoadIcon(GetModuleHandle(NULL), MAKEINTRESOURCE(IDI_ICON)); - wndclass.hIconSm = (HICON)LoadImage(GetModuleHandle(NULL), - MAKEINTRESOURCE(IDI_ICON), IMAGE_ICON, 16, 16, 0); - - if (!RegisterClassEx(&wndclass)) - return false; + if (!win32_window_init(&wndclass)) + return false; if (!wgl_shader_dlg_init()) RARCH_ERR("[WGL]: wgl_shader_dlg_init() failed.\n"); From b40baa63230d8a40c074ac35f1efc1b7874254ba Mon Sep 17 00:00:00 2001 From: twinaphex Date: Wed, 11 Nov 2015 18:16:28 +0100 Subject: [PATCH 132/216] Move win32_window_init --- gfx/common/win32_common.c | 17 +++++++++++++++++ gfx/common/win32_common.h | 2 ++ gfx/drivers_context/wgl_ctx.c | 17 ----------------- 3 files changed, 19 insertions(+), 17 deletions(-) diff --git a/gfx/common/win32_common.c b/gfx/common/win32_common.c index 82a3a7f03e..7ad1f8e6ef 100644 --- a/gfx/common/win32_common.c +++ b/gfx/common/win32_common.c @@ -132,6 +132,23 @@ void win32_monitor_info(void *data, void *hm_data, unsigned *mon_id) mon->cbSize = sizeof(MONITORINFOEX); GetMonitorInfo(*hm_to_use, (MONITORINFO*)mon); } + +bool win32_window_init(WNDCLASSEX *wndclass) +{ + wndclass->cbSize = sizeof(*wndclass); + wndclass->style = CS_HREDRAW | CS_VREDRAW | CS_OWNDC; + wndclass->lpfnWndProc = WndProc; + wndclass->hInstance = GetModuleHandle(NULL); + wndclass->hCursor = LoadCursor(NULL, IDC_ARROW); + wndclass->lpszClassName = "RetroArch"; + wndclass->hIcon = LoadIcon(GetModuleHandle(NULL), MAKEINTRESOURCE(IDI_ICON)); + wndclass->hIconSm = (HICON)LoadImage(GetModuleHandle(NULL), + MAKEINTRESOURCE(IDI_ICON), IMAGE_ICON, 16, 16, 0); + + if (!RegisterClassEx(wndclass)) + return false; + return true; +} #endif static bool win32_browser( diff --git a/gfx/common/win32_common.h b/gfx/common/win32_common.h index 91a5f77b52..d620b56aa4 100644 --- a/gfx/common/win32_common.h +++ b/gfx/common/win32_common.h @@ -47,6 +47,8 @@ void win32_monitor_from_window(HWND data, bool destroy); void win32_monitor_get_info(void); void win32_monitor_info(void *data, void *hm_data, unsigned *mon_id); + +bool win32_window_init(WNDCLASSEX *wndclass); #endif bool win32_suppress_screensaver(void *data, bool enable); diff --git a/gfx/drivers_context/wgl_ctx.c b/gfx/drivers_context/wgl_ctx.c index bc33b19745..d0ed2eb67b 100644 --- a/gfx/drivers_context/wgl_ctx.c +++ b/gfx/drivers_context/wgl_ctx.c @@ -391,23 +391,6 @@ static void gfx_ctx_wgl_get_video_size(void *data, unsigned *width, unsigned *he } } -static bool win32_window_init(WNDCLASSEX *wndclass) -{ - wndclass->cbSize = sizeof(*wndclass); - wndclass->style = CS_HREDRAW | CS_VREDRAW | CS_OWNDC; - wndclass->lpfnWndProc = WndProc; - wndclass->hInstance = GetModuleHandle(NULL); - wndclass->hCursor = LoadCursor(NULL, IDC_ARROW); - wndclass->lpszClassName = "RetroArch"; - wndclass->hIcon = LoadIcon(GetModuleHandle(NULL), MAKEINTRESOURCE(IDI_ICON)); - wndclass->hIconSm = (HICON)LoadImage(GetModuleHandle(NULL), - MAKEINTRESOURCE(IDI_ICON), IMAGE_ICON, 16, 16, 0); - - if (!RegisterClassEx(wndclass)) - return false; - return true; -} - static bool gfx_ctx_wgl_init(void *data) { WNDCLASSEX wndclass = {0}; From 4e8000571f7fcc2b3b9bc4292669be5505ea12bf Mon Sep 17 00:00:00 2001 From: twinaphex Date: Wed, 11 Nov 2015 18:20:07 +0100 Subject: [PATCH 133/216] (renderchain/d3d) Use void pointer --- gfx/d3d/render_chain_cg.cpp | 14 +++++++------- gfx/d3d/render_chain_driver.h | 2 +- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/gfx/d3d/render_chain_cg.cpp b/gfx/d3d/render_chain_cg.cpp index 8eb1e3e2c5..7e954e0923 100644 --- a/gfx/d3d/render_chain_cg.cpp +++ b/gfx/d3d/render_chain_cg.cpp @@ -1488,14 +1488,14 @@ static bool cg_d3d9_renderchain_render( return true; } -static void cg_d3d9_renderchain_set_font_rect(void *data, - const struct font_params *params) +static void cg_d3d9_renderchain_set_font_rect(void *data, const void *font_data) { - settings_t *settings = config_get_ptr(); - d3d_video_t *d3d = (d3d_video_t*)data; - float pos_x = settings->video.msg_pos_x; - float pos_y = settings->video.msg_pos_y; - float font_size = settings->video.font_size; + settings_t *settings = config_get_ptr(); + d3d_video_t *d3d = (d3d_video_t*)data; + float pos_x = settings->video.msg_pos_x; + float pos_y = settings->video.msg_pos_y; + float font_size = settings->video.font_size; + const struct font_params *params = (const struct font_params*)font_data; if (params) { diff --git a/gfx/d3d/render_chain_driver.h b/gfx/d3d/render_chain_driver.h index b8c609e349..836f335871 100644 --- a/gfx/d3d/render_chain_driver.h +++ b/gfx/d3d/render_chain_driver.h @@ -67,7 +67,7 @@ typedef struct renderchain_driver unsigned *out_width, unsigned *out_height, unsigned width, unsigned height, void *final_viewport); - void (*set_font_rect)(void *data, const struct font_params *params); + void (*set_font_rect)(void *data, const void *param_data); bool (*read_viewport)(void *data, uint8_t *buffer); void (*viewport_info)(void *data, struct video_viewport *vp); const char *ident; From 8f6deb9dacabbaf82fc894483a243ed06e7d7b2d Mon Sep 17 00:00:00 2001 From: twinaphex Date: Wed, 11 Nov 2015 18:22:39 +0100 Subject: [PATCH 134/216] Pass function pointer to win32_window_init too --- gfx/common/win32_common.c | 2 +- gfx/common/win32_common.h | 2 +- gfx/drivers_context/wgl_ctx.c | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/gfx/common/win32_common.c b/gfx/common/win32_common.c index 7ad1f8e6ef..f8678dde05 100644 --- a/gfx/common/win32_common.c +++ b/gfx/common/win32_common.c @@ -133,7 +133,7 @@ void win32_monitor_info(void *data, void *hm_data, unsigned *mon_id) GetMonitorInfo(*hm_to_use, (MONITORINFO*)mon); } -bool win32_window_init(WNDCLASSEX *wndclass) +bool win32_window_init(WNDCLASSEX *wndclass, LRESULT CALLBACK WndProc) { wndclass->cbSize = sizeof(*wndclass); wndclass->style = CS_HREDRAW | CS_VREDRAW | CS_OWNDC; diff --git a/gfx/common/win32_common.h b/gfx/common/win32_common.h index d620b56aa4..073a65765d 100644 --- a/gfx/common/win32_common.h +++ b/gfx/common/win32_common.h @@ -48,7 +48,7 @@ void win32_monitor_get_info(void); void win32_monitor_info(void *data, void *hm_data, unsigned *mon_id); -bool win32_window_init(WNDCLASSEX *wndclass); +bool win32_window_init(WNDCLASSEX *wndclass, LRESULT CALLBACK WndProc); #endif bool win32_suppress_screensaver(void *data, bool enable); diff --git a/gfx/drivers_context/wgl_ctx.c b/gfx/drivers_context/wgl_ctx.c index d0ed2eb67b..958601d25c 100644 --- a/gfx/drivers_context/wgl_ctx.c +++ b/gfx/drivers_context/wgl_ctx.c @@ -404,7 +404,7 @@ static bool gfx_ctx_wgl_init(void *data) g_restore_desktop = false; win32_monitor_init(); - if (!win32_window_init(&wndclass)) + if (!win32_window_init(&wndclass, WndProc)) return false; if (!wgl_shader_dlg_init()) From 3c5f4bd243706acc2a88ba76135646173a587ecd Mon Sep 17 00:00:00 2001 From: twinaphex Date: Wed, 11 Nov 2015 18:26:10 +0100 Subject: [PATCH 135/216] Move WndProc to win32_common.c --- gfx/common/win32_common.c | 71 +++++++++++++++++++++++++++++++++- gfx/common/win32_common.h | 11 +++++- gfx/drivers_context/wgl_ctx.c | 73 +---------------------------------- 3 files changed, 82 insertions(+), 73 deletions(-) diff --git a/gfx/common/win32_common.c b/gfx/common/win32_common.c index f8678dde05..1be359211d 100644 --- a/gfx/common/win32_common.c +++ b/gfx/common/win32_common.c @@ -31,6 +31,13 @@ #endif #ifndef _XBOX +unsigned g_resize_width; +unsigned g_resize_height; +unsigned g_pos_x = CW_USEDEFAULT; +unsigned g_pos_y = CW_USEDEFAULT; +bool g_resized; +bool g_quit; + /* Power Request APIs */ typedef REASON_CONTEXT POWER_REQUEST_CONTEXT, *PPOWER_REQUEST_CONTEXT, *LPPOWER_REQUEST_CONTEXT; @@ -133,7 +140,69 @@ void win32_monitor_info(void *data, void *hm_data, unsigned *mon_id) GetMonitorInfo(*hm_to_use, (MONITORINFO*)mon); } -bool win32_window_init(WNDCLASSEX *wndclass, LRESULT CALLBACK WndProc) +static LRESULT CALLBACK WndProc(HWND hwnd, UINT message, + WPARAM wparam, LPARAM lparam) +{ + settings_t *settings = config_get_ptr(); + + switch (message) + { + case WM_SYSCOMMAND: + /* Prevent screensavers, etc, while running. */ + switch (wparam) + { + case SC_SCREENSAVE: + case SC_MONITORPOWER: + return 0; + } + break; + + case WM_CHAR: + case WM_KEYDOWN: + case WM_KEYUP: + case WM_SYSKEYUP: + case WM_SYSKEYDOWN: + return win32_handle_keyboard_event(hwnd, message, wparam, lparam); + + case WM_CREATE: + create_gl_context(hwnd); + return 0; + + case WM_CLOSE: + case WM_DESTROY: + case WM_QUIT: + { + WINDOWPLACEMENT placement; + GetWindowPlacement(g_hwnd, &placement); + g_pos_x = placement.rcNormalPosition.left; + g_pos_y = placement.rcNormalPosition.top; + g_quit = true; + return 0; + } + case WM_SIZE: + /* Do not send resize message if we minimize. */ + if (wparam != SIZE_MAXHIDE && wparam != SIZE_MINIMIZED) + { + g_resize_width = LOWORD(lparam); + g_resize_height = HIWORD(lparam); + g_resized = true; + } + return 0; + case WM_COMMAND: + if (settings->ui.menubar_enable) + { + LRESULT ret = win32_menu_loop(g_hwnd, wparam); + (void)ret; + } + break; + } + + if (dinput_handle_message(dinput_wgl, message, wparam, lparam)) + return 0; + return DefWindowProc(hwnd, message, wparam, lparam); +} + +bool win32_window_init(WNDCLASSEX *wndclass) { wndclass->cbSize = sizeof(*wndclass); wndclass->style = CS_HREDRAW | CS_VREDRAW | CS_OWNDC; diff --git a/gfx/common/win32_common.h b/gfx/common/win32_common.h index 073a65765d..7aa407972e 100644 --- a/gfx/common/win32_common.h +++ b/gfx/common/win32_common.h @@ -35,6 +35,13 @@ extern "C" { #ifndef _XBOX #include "../drivers_wm/win32_resource.h" +extern unsigned g_resize_width; +extern unsigned g_resize_height; +extern unsigned g_pos_x; +extern unsigned g_pos_y; +extern bool g_resized; +extern bool g_quit; + LRESULT win32_handle_keyboard_event(HWND hwnd, UINT message, WPARAM wparam, LPARAM lparam); @@ -48,7 +55,9 @@ void win32_monitor_get_info(void); void win32_monitor_info(void *data, void *hm_data, unsigned *mon_id); -bool win32_window_init(WNDCLASSEX *wndclass, LRESULT CALLBACK WndProc); +bool win32_window_init(WNDCLASSEX *wndclass); + +void create_gl_context(HWND hwnd); #endif bool win32_suppress_screensaver(void *data, bool enable); diff --git a/gfx/drivers_context/wgl_ctx.c b/gfx/drivers_context/wgl_ctx.c index 958601d25c..e6a744311a 100644 --- a/gfx/drivers_context/wgl_ctx.c +++ b/gfx/drivers_context/wgl_ctx.c @@ -75,16 +75,10 @@ static HDC g_hdc; static unsigned g_major; static unsigned g_minor; -static bool g_quit; +bool g_quit; static bool g_inited; static unsigned g_interval; -static unsigned g_resize_width; -static unsigned g_resize_height; -static unsigned g_pos_x = CW_USEDEFAULT; -static unsigned g_pos_y = CW_USEDEFAULT; -static bool g_resized; - static dylib_t dll_handle = NULL; /* Handle to OpenGL32.dll */ static bool g_restore_desktop; @@ -111,8 +105,7 @@ static void setup_pixel_format(HDC hdc) SetPixelFormat(hdc, ChoosePixelFormat(hdc, &pfd), &pfd); } - -static void create_gl_context(HWND hwnd) +void create_gl_context(HWND hwnd) { bool core_context; const struct retro_hw_render_callback *hw_render = @@ -243,68 +236,6 @@ bool dinput_handle_message(void *dinput, UINT message, WPARAM wParam, LPARAM lPa static void *dinput_wgl; -static LRESULT CALLBACK WndProc(HWND hwnd, UINT message, - WPARAM wparam, LPARAM lparam) -{ - settings_t *settings = config_get_ptr(); - - switch (message) - { - case WM_SYSCOMMAND: - /* Prevent screensavers, etc, while running. */ - switch (wparam) - { - case SC_SCREENSAVE: - case SC_MONITORPOWER: - return 0; - } - break; - - case WM_CHAR: - case WM_KEYDOWN: - case WM_KEYUP: - case WM_SYSKEYUP: - case WM_SYSKEYDOWN: - return win32_handle_keyboard_event(hwnd, message, wparam, lparam); - - case WM_CREATE: - create_gl_context(hwnd); - return 0; - - case WM_CLOSE: - case WM_DESTROY: - case WM_QUIT: - { - WINDOWPLACEMENT placement; - GetWindowPlacement(g_hwnd, &placement); - g_pos_x = placement.rcNormalPosition.left; - g_pos_y = placement.rcNormalPosition.top; - g_quit = true; - return 0; - } - case WM_SIZE: - /* Do not send resize message if we minimize. */ - if (wparam != SIZE_MAXHIDE && wparam != SIZE_MINIMIZED) - { - g_resize_width = LOWORD(lparam); - g_resize_height = HIWORD(lparam); - g_resized = true; - } - return 0; - case WM_COMMAND: - if (settings->ui.menubar_enable) - { - LRESULT ret = win32_menu_loop(g_hwnd, wparam); - (void)ret; - } - break; - } - - if (dinput_handle_message(dinput_wgl, message, wparam, lparam)) - return 0; - return DefWindowProc(hwnd, message, wparam, lparam); -} - static void gfx_ctx_wgl_swap_interval(void *data, unsigned interval) { (void)data; From 8e08db34468d8ef403c667715e6722c4f01eb175 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Wed, 11 Nov 2015 18:29:06 +0100 Subject: [PATCH 136/216] more buildfixes --- gfx/common/win32_common.c | 12 ++++++++++-- gfx/common/win32_common.h | 1 + gfx/drivers_context/wgl_ctx.c | 13 ++----------- 3 files changed, 13 insertions(+), 13 deletions(-) diff --git a/gfx/common/win32_common.c b/gfx/common/win32_common.c index 1be359211d..a7fc4659a5 100644 --- a/gfx/common/win32_common.c +++ b/gfx/common/win32_common.c @@ -18,6 +18,8 @@ #if !defined(_XBOX) +#define IDI_ICON 1 + #ifndef _WIN32_WINNT #define _WIN32_WINNT 0x0500 //_WIN32_WINNT_WIN2K #endif @@ -30,13 +32,20 @@ #include "../drivers_wm/win32_shader_dlg.h" #endif -#ifndef _XBOX +#ifdef __cplusplus +extern "C" +#endif +bool dinput_handle_message(void *dinput, UINT message, WPARAM wParam, LPARAM lParam); + unsigned g_resize_width; unsigned g_resize_height; unsigned g_pos_x = CW_USEDEFAULT; unsigned g_pos_y = CW_USEDEFAULT; bool g_resized; bool g_quit; +HWND g_hwnd; + +extern void *dinput_wgl; /* Power Request APIs */ @@ -218,7 +227,6 @@ bool win32_window_init(WNDCLASSEX *wndclass) return false; return true; } -#endif static bool win32_browser( HWND owner, diff --git a/gfx/common/win32_common.h b/gfx/common/win32_common.h index 7aa407972e..37eb4c62ab 100644 --- a/gfx/common/win32_common.h +++ b/gfx/common/win32_common.h @@ -41,6 +41,7 @@ extern unsigned g_pos_x; extern unsigned g_pos_y; extern bool g_resized; extern bool g_quit; +extern HWND g_hwnd; LRESULT win32_handle_keyboard_event(HWND hwnd, UINT message, WPARAM wparam, LPARAM lparam); diff --git a/gfx/drivers_context/wgl_ctx.c b/gfx/drivers_context/wgl_ctx.c index e6a744311a..31f56e2aed 100644 --- a/gfx/drivers_context/wgl_ctx.c +++ b/gfx/drivers_context/wgl_ctx.c @@ -40,8 +40,6 @@ #include "../common/win32_common.h" #include "../drivers_wm/win32_shader_dlg.h" -#define IDI_ICON 1 - #ifndef WGL_CONTEXT_MAJOR_VERSION_ARB #define WGL_CONTEXT_MAJOR_VERSION_ARB 0x2091 #endif @@ -67,7 +65,6 @@ #endif static bool g_use_hw_ctx; -static HWND g_hwnd; static HGLRC g_hrc; static HGLRC g_hw_hrc; static HDC g_hdc; @@ -75,7 +72,6 @@ static HDC g_hdc; static unsigned g_major; static unsigned g_minor; -bool g_quit; static bool g_inited; static unsigned g_interval; @@ -229,12 +225,7 @@ void create_gl_context(HWND hwnd) } } -#ifdef __cplusplus -extern "C" -#endif -bool dinput_handle_message(void *dinput, UINT message, WPARAM wParam, LPARAM lParam); - -static void *dinput_wgl; +void *dinput_wgl; static void gfx_ctx_wgl_swap_interval(void *data, unsigned interval) { @@ -335,7 +326,7 @@ static bool gfx_ctx_wgl_init(void *data) g_restore_desktop = false; win32_monitor_init(); - if (!win32_window_init(&wndclass, WndProc)) + if (!win32_window_init(&wndclass)) return false; if (!wgl_shader_dlg_init()) From 938dfa775a9fb4b2186199b4687d27cec86a5e1a Mon Sep 17 00:00:00 2001 From: twinaphex Date: Wed, 11 Nov 2015 19:41:32 +0100 Subject: [PATCH 137/216] (D3D/GL) Try to use common code for both --- gfx/common/win32_common.c | 64 ++++++++++++++++++++----- gfx/common/win32_common.h | 5 +- gfx/d3d/d3d.cpp | 23 +-------- gfx/drivers_context/d3d_ctx.cpp | 84 +-------------------------------- gfx/drivers_context/wgl_ctx.c | 17 +------ 5 files changed, 58 insertions(+), 135 deletions(-) diff --git a/gfx/common/win32_common.c b/gfx/common/win32_common.c index a7fc4659a5..de1507ea26 100644 --- a/gfx/common/win32_common.c +++ b/gfx/common/win32_common.c @@ -93,6 +93,8 @@ void win32_monitor_init(void) { win32_monitor_count = 0; EnumDisplayMonitors(NULL, NULL, win32_monitor_enum_proc, 0); + + g_quit = false; } void win32_monitor_from_window(HWND data, bool destroy) @@ -149,10 +151,23 @@ void win32_monitor_info(void *data, void *hm_data, unsigned *mon_id) GetMonitorInfo(*hm_to_use, (MONITORINFO*)mon); } +static const char *win32_video_get_ident(void) +{ +#ifdef HAVE_THREADS + settings_t *settings = config_get_ptr(); + + if (settings->video.threaded) + return rarch_threaded_video_get_ident(); +#endif + return video_driver_get_ident(); +} + static LRESULT CALLBACK WndProc(HWND hwnd, UINT message, WPARAM wparam, LPARAM lparam) { - settings_t *settings = config_get_ptr(); + settings_t *settings = config_get_ptr(); + driver_t *driver = driver_get_ptr(); + const char *video_driver = win32_video_get_ident(); switch (message) { @@ -174,7 +189,13 @@ static LRESULT CALLBACK WndProc(HWND hwnd, UINT message, return win32_handle_keyboard_event(hwnd, message, wparam, lparam); case WM_CREATE: - create_gl_context(hwnd); + if (!strcmp(video_driver, "gl")) + create_gl_context(hwnd); + else if (!strcmp(video_driver, "d3d")) + { + LPCREATESTRUCT p_cs = (LPCREATESTRUCT)lparam; + curD3D = (d3d_video_t*)p_cs->lpCreateParams; + } return 0; case WM_CLOSE: @@ -200,28 +221,36 @@ static LRESULT CALLBACK WndProc(HWND hwnd, UINT message, case WM_COMMAND: if (settings->ui.menubar_enable) { - LRESULT ret = win32_menu_loop(g_hwnd, wparam); + HWND d3dr = g_hwnd; + if (!strcmp(video_driver, "d3d")) + { + d3d_video_t *d3d = (d3d_video_t*)driver->video_data; + d3dr = d3d->hWnd; + } + LRESULT ret = win32_menu_loop(d3dr, wparam); (void)ret; } break; } - if (dinput_handle_message(dinput_wgl, message, wparam, lparam)) + if (dinput_handle_message((!strcmp(video_driver, "gl")) ? dinput_wgl : dinput, message, wparam, lparam)) return 0; return DefWindowProc(hwnd, message, wparam, lparam); } -bool win32_window_init(WNDCLASSEX *wndclass) +bool win32_window_init(WNDCLASSEX *wndclass, bool fullscreen) { - wndclass->cbSize = sizeof(*wndclass); - wndclass->style = CS_HREDRAW | CS_VREDRAW | CS_OWNDC; - wndclass->lpfnWndProc = WndProc; - wndclass->hInstance = GetModuleHandle(NULL); - wndclass->hCursor = LoadCursor(NULL, IDC_ARROW); + wndclass->cbSize = sizeof(WNDCLASSEX); + wndclass->style = CS_HREDRAW | CS_VREDRAW | CS_OWNDC; + wndclass->lpfnWndProc = WndProc; + wndclass->hInstance = GetModuleHandle(NULL); + wndclass->hCursor = LoadCursor(NULL, IDC_ARROW); wndclass->lpszClassName = "RetroArch"; - wndclass->hIcon = LoadIcon(GetModuleHandle(NULL), MAKEINTRESOURCE(IDI_ICON)); - wndclass->hIconSm = (HICON)LoadImage(GetModuleHandle(NULL), + wndclass->hIcon = LoadIcon(GetModuleHandle(NULL), MAKEINTRESOURCE(IDI_ICON)); + wndclass->hIconSm = (HICON)LoadImage(GetModuleHandle(NULL), MAKEINTRESOURCE(IDI_ICON), IMAGE_ICON, 16, 16, 0); + if (!fullscreen) + wndclass->hbrBackground = (HBRUSH)COLOR_WINDOW; if (!RegisterClassEx(wndclass)) return false; @@ -425,7 +454,7 @@ void win32_show_cursor(bool state) #endif } -void win32_check_window(void) +void win32_check_window(bool *quit, unsigned *resize, unsigned *width, unsigned *height) { #ifndef _XBOX MSG msg; @@ -436,6 +465,15 @@ void win32_check_window(void) DispatchMessage(&msg); } #endif + *quit = g_quit; + + if (g_resized) + { + *resize = true; + *width = g_resize_width; + *height = g_resize_height; + g_resized = false; + } } bool win32_suppress_screensaver(void *data, bool enable) diff --git a/gfx/common/win32_common.h b/gfx/common/win32_common.h index 37eb4c62ab..936eaabcce 100644 --- a/gfx/common/win32_common.h +++ b/gfx/common/win32_common.h @@ -56,7 +56,7 @@ void win32_monitor_get_info(void); void win32_monitor_info(void *data, void *hm_data, unsigned *mon_id); -bool win32_window_init(WNDCLASSEX *wndclass); +bool win32_window_init(WNDCLASSEX *wndclass, bool fullscreen); void create_gl_context(HWND hwnd); #endif @@ -68,7 +68,8 @@ bool win32_get_metrics(void *data, void win32_show_cursor(bool state); -void win32_check_window(void); +void win32_check_window(bool *quit, + unsigned *resize, unsigned *width, unsigned *height); #ifdef __cplusplus } diff --git a/gfx/d3d/d3d.cpp b/gfx/d3d/d3d.cpp index a4fdc1ca39..4a5c5c2989 100644 --- a/gfx/d3d/d3d.cpp +++ b/gfx/d3d/d3d.cpp @@ -88,14 +88,6 @@ static void d3d_free_overlays(d3d_video_t *d3d); static void d3d_free_overlay(d3d_video_t *d3d, overlay_t *overlay); #endif -#ifdef HAVE_WINDOW - -#define IDI_ICON 1 - -extern LRESULT CALLBACK WindowProc(HWND hWnd, UINT message, - WPARAM wParam, LPARAM lParam); -#endif - static void d3d_deinit_chain(d3d_video_t *d3d) { d3d->renderchain_driver->chain_free(d3d->renderchain_data); @@ -604,20 +596,7 @@ static bool d3d_construct(d3d_video_t *d3d, #if defined(HAVE_WINDOW) && !defined(_XBOX) memset(&d3d->windowClass, 0, sizeof(d3d->windowClass)); - d3d->windowClass.cbSize = sizeof(d3d->windowClass); - d3d->windowClass.style = CS_HREDRAW | CS_VREDRAW; - d3d->windowClass.lpfnWndProc = WindowProc; - d3d->windowClass.hInstance = NULL; - d3d->windowClass.hCursor = LoadCursor(NULL, IDC_ARROW); - d3d->windowClass.lpszClassName = "RetroArch"; - d3d->windowClass.hIcon = LoadIcon(GetModuleHandle(NULL), - MAKEINTRESOURCE(IDI_ICON)); - d3d->windowClass.hIconSm = (HICON)LoadImage(GetModuleHandle(NULL), - MAKEINTRESOURCE(IDI_ICON), IMAGE_ICON, 16, 16, 0); - if (!info->fullscreen) - d3d->windowClass.hbrBackground = (HBRUSH)COLOR_WINDOW; - - RegisterClassEx(&d3d->windowClass); + win32_window_init(&d3d->windowClass, true); #endif #ifdef HAVE_MONITOR diff --git a/gfx/drivers_context/d3d_ctx.cpp b/gfx/drivers_context/d3d_ctx.cpp index a03c39c117..bc7a6a787a 100644 --- a/gfx/drivers_context/d3d_ctx.cpp +++ b/gfx/drivers_context/d3d_ctx.cpp @@ -46,11 +46,7 @@ static bool widescreen_mode = false; #endif static d3d_video_t *curD3D = NULL; -static bool d3d_quit = false; static void *dinput; -static unsigned g_d3d_resize_width; -static unsigned g_d3d_resize_height; -static bool g_d3d_resized; extern bool d3d_restore(d3d_video_t *data); @@ -75,69 +71,6 @@ static void d3d_resize(void *data, unsigned new_width, unsigned new_height) } } -#ifdef HAVE_WINDOW -LRESULT CALLBACK WindowProc(HWND hwnd, UINT message, - WPARAM wparam, LPARAM lparam) -{ - driver_t *driver = driver_get_ptr(); - settings_t *settings = config_get_ptr(); - - switch (message) - { - case WM_SYSCOMMAND: - /* Prevent screensavers, etc, while running. */ - switch (wparam) - { - case SC_SCREENSAVE: - case SC_MONITORPOWER: - return 0; - } - break; - case WM_CHAR: - case WM_KEYDOWN: - case WM_KEYUP: - case WM_SYSKEYUP: - case WM_SYSKEYDOWN: - return win32_handle_keyboard_event(hwnd, message, wparam, lparam); - - case WM_CREATE: - { - LPCREATESTRUCT p_cs = (LPCREATESTRUCT)lparam; - curD3D = (d3d_video_t*)p_cs->lpCreateParams; - } - break; - - case WM_CLOSE: - case WM_DESTROY: - case WM_QUIT: - d3d_quit = true; - return 0; - - case WM_SIZE: - /* Do not send resize message if we minimize. */ - if (wparam != SIZE_MAXHIDE && wparam != SIZE_MINIMIZED) - { - g_d3d_resize_width = LOWORD(lparam); - g_d3d_resize_height = HIWORD(lparam); - g_d3d_resized = true; - } - return 0; - case WM_COMMAND: - if (settings->ui.menubar_enable) - { - d3d_video_t *d3d = (d3d_video_t*)driver->video_data; - HWND d3dr = d3d->hWnd; - LRESULT ret = win32_menu_loop(d3dr, wparam); - } - break; - } - - if (dinput_handle_message(dinput, message, wparam, lparam)) - return 0; - return DefWindowProc(hwnd, message, wparam, lparam); -} -#endif - static void gfx_ctx_d3d_swap_buffers(void *data) { d3d_video_t *d3d = (d3d_video_t*)data; @@ -188,20 +121,7 @@ static void gfx_ctx_d3d_check_window(void *data, bool *quit, bool *resize, unsigned *width, unsigned *height, unsigned frame_count) { - win32_check_window(); - - (void)data; - (void)frame_count; - - *quit = d3d_quit; - - if (g_d3d_resized) - { - *resize = true; - *width = g_d3d_resize_width; - *height = g_d3d_resize_height; - g_d3d_resized = false; - } + win32_check_window(quit, resize, width, height); } #ifdef _XBOX @@ -257,8 +177,6 @@ static bool gfx_ctx_d3d_init(void *data) { (void)data; - d3d_quit = false; - #ifndef _XBOX win32_monitor_init(); #endif diff --git a/gfx/drivers_context/wgl_ctx.c b/gfx/drivers_context/wgl_ctx.c index 31f56e2aed..c549b10676 100644 --- a/gfx/drivers_context/wgl_ctx.c +++ b/gfx/drivers_context/wgl_ctx.c @@ -245,20 +245,7 @@ static void gfx_ctx_wgl_swap_interval(void *data, unsigned interval) static void gfx_ctx_wgl_check_window(void *data, bool *quit, bool *resize, unsigned *width, unsigned *height, unsigned frame_count) { - win32_check_window(); - - (void)data; - (void)frame_count; - - *quit = g_quit; - - if (g_resized) - { - *resize = true; - *width = g_resize_width; - *height = g_resize_height; - g_resized = false; - } + win32_check_window(quit, resize, width, height); } static void gfx_ctx_wgl_swap_buffers(void *data) @@ -326,7 +313,7 @@ static bool gfx_ctx_wgl_init(void *data) g_restore_desktop = false; win32_monitor_init(); - if (!win32_window_init(&wndclass)) + if (!win32_window_init(&wndclass, true)) return false; if (!wgl_shader_dlg_init()) From 1413d97ab0579b5cf08c023bb33e30895004c9cd Mon Sep 17 00:00:00 2001 From: twinaphex Date: Wed, 11 Nov 2015 19:48:24 +0100 Subject: [PATCH 138/216] (D3D/GL) Use more common code --- gfx/common/win32_common.c | 11 +++++++++-- gfx/common/win32_common.h | 2 +- gfx/drivers_context/d3d_ctx.cpp | 4 ++-- 3 files changed, 12 insertions(+), 5 deletions(-) diff --git a/gfx/common/win32_common.c b/gfx/common/win32_common.c index de1507ea26..81b61895a5 100644 --- a/gfx/common/win32_common.c +++ b/gfx/common/win32_common.c @@ -27,11 +27,16 @@ #include #include #include "../../retroarch.h" +#include "../video_thread_wrapper.h" #ifdef HAVE_OPENGL #include "../drivers_wm/win32_shader_dlg.h" #endif +#ifdef HAVE_D3D +#include "../d3d/d3d.h" +#endif + #ifdef __cplusplus extern "C" #endif @@ -46,6 +51,8 @@ bool g_quit; HWND g_hwnd; extern void *dinput_wgl; +extern void *curD3D; +extern void *dinput; /* Power Request APIs */ @@ -194,7 +201,7 @@ static LRESULT CALLBACK WndProc(HWND hwnd, UINT message, else if (!strcmp(video_driver, "d3d")) { LPCREATESTRUCT p_cs = (LPCREATESTRUCT)lparam; - curD3D = (d3d_video_t*)p_cs->lpCreateParams; + curD3D = p_cs->lpCreateParams; } return 0; @@ -454,7 +461,7 @@ void win32_show_cursor(bool state) #endif } -void win32_check_window(bool *quit, unsigned *resize, unsigned *width, unsigned *height) +void win32_check_window(bool *quit, bool *resize, unsigned *width, unsigned *height) { #ifndef _XBOX MSG msg; diff --git a/gfx/common/win32_common.h b/gfx/common/win32_common.h index 936eaabcce..5dd0b239df 100644 --- a/gfx/common/win32_common.h +++ b/gfx/common/win32_common.h @@ -69,7 +69,7 @@ bool win32_get_metrics(void *data, void win32_show_cursor(bool state); void win32_check_window(bool *quit, - unsigned *resize, unsigned *width, unsigned *height); + bool *resize, unsigned *width, unsigned *height); #ifdef __cplusplus } diff --git a/gfx/drivers_context/d3d_ctx.cpp b/gfx/drivers_context/d3d_ctx.cpp index bc7a6a787a..07c3ac78eb 100644 --- a/gfx/drivers_context/d3d_ctx.cpp +++ b/gfx/drivers_context/d3d_ctx.cpp @@ -45,8 +45,8 @@ static bool widescreen_mode = false; #endif -static d3d_video_t *curD3D = NULL; -static void *dinput; +void *curD3D = NULL; +void *dinput; extern bool d3d_restore(d3d_video_t *data); From 3d20af91351454c2c66ad0d14049bd0b754148a8 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Wed, 11 Nov 2015 19:59:56 +0100 Subject: [PATCH 139/216] (D3D) Cleanups --- gfx/d3d/d3d.cpp | 35 ++++++++++++++++++----------------- 1 file changed, 18 insertions(+), 17 deletions(-) diff --git a/gfx/d3d/d3d.cpp b/gfx/d3d/d3d.cpp index 4a5c5c2989..0399fde913 100644 --- a/gfx/d3d/d3d.cpp +++ b/gfx/d3d/d3d.cpp @@ -626,7 +626,6 @@ static bool d3d_construct(d3d_video_t *d3d, #ifndef _XBOX #ifdef HAVE_WINDOW unsigned win_width, win_height; - char buffer[128] = {0}; RECT rect = {0}; video_driver_get_size(&win_width, &win_height); @@ -639,11 +638,7 @@ static bool d3d_construct(d3d_video_t *d3d, win_height = rect.bottom - rect.top; } - video_monitor_get_fps(buffer, sizeof(buffer), NULL, 0); - - strlcat(buffer, " || Direct3D", sizeof(buffer)); - - d3d->hWnd = CreateWindowEx(0, "RetroArch", buffer, + d3d->hWnd = CreateWindowEx(0, "RetroArch", "RetroArch", info->fullscreen ? (WS_EX_TOPMOST | WS_POPUP) : WS_OVERLAPPEDWINDOW, info->fullscreen ? mon_rect.left : CW_USEDEFAULT, @@ -667,22 +662,28 @@ static bool d3d_construct(d3d_video_t *d3d, #ifndef _XBOX #ifdef HAVE_WINDOW - if (!info->fullscreen && settings->ui.menubar_enable) + if (!info->fullscreen || windowed_full) { - RECT rc_temp = {0, 0, (LONG)win_height, 0x7FFF}; + if (!info->fullscreen && settings->ui.menubar_enable) + { + RECT rc_temp = {0, 0, (LONG)win_height, 0x7FFF}; - SetMenu(d3d->hWnd, LoadMenu(GetModuleHandle(NULL),MAKEINTRESOURCE(IDR_MENU))); - SendMessage(d3d->hWnd, WM_NCCALCSIZE, FALSE, (LPARAM)&rc_temp); - win_height += rc_temp.top + rect.top; - SetWindowPos(d3d->hWnd, NULL, 0, 0, win_width, win_height, SWP_NOMOVE); + SetMenu(d3d->hWnd, LoadMenu(GetModuleHandle(NULL),MAKEINTRESOURCE(IDR_MENU))); + SendMessage(d3d->hWnd, WM_NCCALCSIZE, FALSE, (LPARAM)&rc_temp); + win_height += rc_temp.top + rect.top; + SetWindowPos(d3d->hWnd, NULL, 0, 0, win_width, win_height, SWP_NOMOVE); + } + + ShowWindow(d3d->hWnd, SW_RESTORE); + UpdateWindow(d3d->hWnd); + SetForegroundWindow(d3d->hWnd); + SetFocus(d3d->hWnd); } - - ShowWindow(d3d->hWnd, SW_RESTORE); - UpdateWindow(d3d->hWnd); - SetForegroundWindow(d3d->hWnd); - SetFocus(d3d->hWnd); #endif + win32_show_cursor(!info->fullscreen); + + #ifdef HAVE_SHADERS /* This should only be done once here * to avoid set_shader() to be overridden From 9deeececf1da5cb3d1868d8ba8315bf795b3d682 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Wed, 11 Nov 2015 20:07:06 +0100 Subject: [PATCH 140/216] Turn win32_common and wgl_ctx into C++ --- gfx/common/{win32_common.c => win32_common.cpp} | 0 gfx/common/win32_common.h | 8 -------- gfx/drivers_context/{wgl_ctx.c => wgl_ctx.cpp} | 0 griffin/griffin.c | 9 --------- griffin/griffin_cpp.cpp | 12 ++++++++++++ 5 files changed, 12 insertions(+), 17 deletions(-) rename gfx/common/{win32_common.c => win32_common.cpp} (100%) rename gfx/drivers_context/{wgl_ctx.c => wgl_ctx.cpp} (100%) diff --git a/gfx/common/win32_common.c b/gfx/common/win32_common.cpp similarity index 100% rename from gfx/common/win32_common.c rename to gfx/common/win32_common.cpp diff --git a/gfx/common/win32_common.h b/gfx/common/win32_common.h index 5dd0b239df..76ff1cd5fa 100644 --- a/gfx/common/win32_common.h +++ b/gfx/common/win32_common.h @@ -28,10 +28,6 @@ #include "../../driver.h" #include "../video_context_driver.h" -#ifdef __cplusplus -extern "C" { -#endif - #ifndef _XBOX #include "../drivers_wm/win32_resource.h" @@ -71,8 +67,4 @@ void win32_show_cursor(bool state); void win32_check_window(bool *quit, bool *resize, unsigned *width, unsigned *height); -#ifdef __cplusplus -} -#endif - #endif diff --git a/gfx/drivers_context/wgl_ctx.c b/gfx/drivers_context/wgl_ctx.cpp similarity index 100% rename from gfx/drivers_context/wgl_ctx.c rename to gfx/drivers_context/wgl_ctx.cpp diff --git a/griffin/griffin.c b/griffin/griffin.c index 2c9a616299..7845d1e35a 100644 --- a/griffin/griffin.c +++ b/griffin/griffin.c @@ -103,13 +103,6 @@ CHEATS #include "../cheats.c" #include "../libretro-common/hash/rhash.c" -/*============================================================ -UI COMMON CONTEXT -============================================================ */ -#if defined(_WIN32) -#include "../gfx/common/win32_common.c" -#endif - /*============================================================ VIDEO CONTEXT ============================================================ */ @@ -139,9 +132,7 @@ VIDEO CONTEXT #include "../gfx/drivers_context/vc_egl_ctx.c" #endif - #if defined(_WIN32) && !defined(_XBOX) -#include "../gfx/drivers_context/wgl_ctx.c" #include "../gfx/drivers_wm/win32_shader_dlg.c" #endif diff --git a/griffin/griffin_cpp.cpp b/griffin/griffin_cpp.cpp index 27648fb5ea..d81d425e2d 100644 --- a/griffin/griffin_cpp.cpp +++ b/griffin/griffin_cpp.cpp @@ -32,6 +32,18 @@ AUDIO #include "../audio/drivers/xaudio.cpp" #endif +/*============================================================ +UI COMMON CONTEXT +============================================================ */ +#if defined(_WIN32) && !defined(_XBOX) +#include "../gfx/common/win32_common.cpp" + +#ifdef HAVE_OPENGL +#include "../gfx/drivers_context/wgl_ctx.cpp" +#endif +#endif + + /*============================================================ MENU ============================================================ */ From 1b7576aa640c7ba2241614d3aab84b94a6ad468d Mon Sep 17 00:00:00 2001 From: twinaphex Date: Wed, 11 Nov 2015 20:15:27 +0100 Subject: [PATCH 141/216] Kill off IS_JOYCONFIG --- Makefile | 23 +- Makefile.common | 13 - input/input_common.c | 2 - input/input_hid_driver.c | 4 - input/input_joypad_driver.c | 4 - libretro-common/include/retro_log.h | 2 +- tools/retroarch-joyconfig-griffin.c | 115 ------ tools/retroarch-joyconfig.c | 538 ---------------------------- 8 files changed, 2 insertions(+), 699 deletions(-) delete mode 100644 tools/retroarch-joyconfig-griffin.c delete mode 100644 tools/retroarch-joyconfig.c diff --git a/Makefile b/Makefile index ed9f5253ad..7889461dcf 100644 --- a/Makefile +++ b/Makefile @@ -17,7 +17,6 @@ ifeq ($(GLOBAL_CONFIG_DIR),) endif OBJ := -JOYCONFIG_OBJ := LIBS := DEFINES := -DHAVE_CONFIG_H -DRARCH_INTERNAL -DHAVE_OVERLAY DEFINES += -DGLOBAL_CONFIG_DIR='"$(GLOBAL_CONFIG_DIR)"' @@ -96,7 +95,6 @@ ifeq ($(NOUNUSED_VARIABLE), yes) endif RARCH_OBJ := $(addprefix $(OBJDIR)/,$(OBJ)) -RARCH_JOYCONFIG_OBJ := $(addprefix $(OBJDIR)/,$(JOYCONFIG_OBJ)) ifneq ($(SANITIZER),) CFLAGS := -fsanitize=$(SANITIZER) $(CFLAGS) @@ -106,7 +104,7 @@ endif all: $(TARGET) $(JTARGET) config.mk --include $(RARCH_OBJ:.o=.d) $(RARCH_JOYCONFIG_OBJ:.o=.d) +-include $(RARCH_OBJ:.o=.d) config.mk: configure qb/* @echo "config.mk is outdated or non-existing. Run ./configure again." @exit 1 @@ -115,10 +113,6 @@ retroarch: $(RARCH_OBJ) @$(if $(Q), $(shell echo echo LD $@),) $(Q)$(LINK) -o $@ $(RARCH_OBJ) $(LIBS) $(LDFLAGS) $(LIBRARY_DIRS) -$(JTARGET): $(RARCH_JOYCONFIG_OBJ) - @$(if $(Q), $(shell echo echo LD $@),) - $(Q)$(LINK) -o $@ $(RARCH_JOYCONFIG_OBJ) $(JOYCONFIG_LIBS) $(LDFLAGS) $(LIBRARY_DIRS) - $(OBJDIR)/%.o: %.c config.h config.mk @mkdir -p $(dir $@) @$(if $(Q), $(shell echo echo CC $<),) @@ -141,21 +135,6 @@ $(OBJDIR)/git_version.o: git_version.c .FORCE @$(if $(Q), $(shell echo echo CC $<),) $(Q)$(CC) $(CFLAGS) $(DEFINES) -MMD -c -o $@ $< -$(OBJDIR)/tools/linuxraw_joypad.o: input/linuxraw_joypad.c - @mkdir -p $(dir $@) - @$(if $(Q), $(shell echo echo CC $<),) - $(Q)$(CC) $(CFLAGS) $(DEFINES) -MMD -DIS_JOYCONFIG -c -o $@ $< - -$(OBJDIR)/tools/parport_joypad.o: input/parport_joypad.c - @mkdir -p $(dir $@) - @$(if $(Q), $(shell echo echo CC $<),) - $(Q)$(CC) $(CFLAGS) $(DEFINES) -MMD -DIS_JOYCONFIG -c -o $@ $< - -$(OBJDIR)/tools/udev_joypad.o: input/udev_joypad.c - @mkdir -p $(dir $@) - @$(if $(Q), $(shell echo echo CC $<),) - $(Q)$(CC) $(CFLAGS) $(DEFINES) -MMD -DIS_JOYCONFIG -c -o $@ $< - $(OBJDIR)/%.o: %.S config.h config.mk $(HEADERS) @mkdir -p $(dir $@) @$(if $(Q), $(shell echo echo AS $<),) diff --git a/Makefile.common b/Makefile.common index 4af47e7787..30c1fb825f 100644 --- a/Makefile.common +++ b/Makefile.common @@ -28,7 +28,6 @@ endif ifeq ($(HAVE_DYLIB), 1) DEFINES += -DHAVE_DYLIB - JOYCONFIG_LIBS += $(DYLIB_LIB) endif ifeq ($(SCALER_NO_SIMD), 1) @@ -71,14 +70,12 @@ endif ifneq ($(findstring Darwin,$(OS)),) OSX := 1 LIBS += -framework AppKit - JOYCONFIG_LIBS += -framework CoreFoundation else OSX := 0 endif ifneq ($(findstring Linux,$(OS)),) LIBS += -lrt - JOYCONFIG_LIBS += -lrt -lpthread OBJ += input/drivers/linuxraw_input.o \ input/drivers_joypad/linuxraw_joypad.o \ frontend/drivers/platform_linux.o @@ -499,7 +496,6 @@ ifeq ($(HAVE_DINPUT), 1) DEFINES += -DHAVE_DINPUT OBJ += input/drivers/dinput.o \ input/drivers_joypad/dinput_joypad.o - JOYCONFIG_LIBS += -ldinput8 -ldxguid -lole32 endif ifeq ($(HAVE_XINPUT), 1) @@ -526,7 +522,6 @@ endif ifeq ($(HAVE_UDEV), 1) DEFINES += $(UDEV_CFLAGS) LIBS += $(UDEV_LIBS) - JOYCONFIG_LIBS += $(UDEV_LIBS) OBJ += input/drivers/udev_input.o \ input/drivers_joypad/udev_joypad.o endif @@ -535,7 +530,6 @@ ifeq ($(HAVE_LIBUSB), 1) DEFINES += -DHAVE_LIBUSB OBJ += input/drivers_hid/libusb_hid.o LIBS += -lusb-1.0 - JOYCONFIG_LIBS += -lusb-1.0 HAVE_HID = 1 endif @@ -544,7 +538,6 @@ ifeq ($(HAVE_IOHIDMANAGER), 1) OBJ += input/drivers_hid/iohidmanager_hid.o HAVE_HID = 1 LIBS += -framework IOKit - JOYCONFIG_LIBS += -framework IOKit endif ifeq ($(HAVE_CORELOCATION), 1) @@ -674,7 +667,6 @@ ifeq ($(HAVE_SDL), 1) OBJ += gfx/drivers_context/sdl_gl_ctx.o endif - JOYCONFIG_LIBS += $(SDL_LIBS) DEFINES += $(SDL_CFLAGS) $(BSD_LOCAL_INC) LIBS += $(SDL_LIBS) endif @@ -689,7 +681,6 @@ ifeq ($(HAVE_SDL2), 1) OBJ += gfx/drivers_context/sdl_gl_ctx.o endif - JOYCONFIG_LIBS += $(SDL2_LIBS) DEFINES += $(SDL2_CFLAGS) $(BSD_LOCAL_INC) LIBS += $(SDL2_LIBS) HAVE_SDL = 0 @@ -927,7 +918,3 @@ ifeq ($(HAVE_COCOA),1) ui/drivers/cocoa/cocoa_common.o \ gfx/drivers_context/cocoa_gl_ctx.o endif - - -# Joyconfig binary -JOYCONFIG_OBJ += tools/retroarch-joyconfig-griffin.o diff --git a/input/input_common.c b/input/input_common.c index 484f514d9b..633e199dd7 100644 --- a/input/input_common.c +++ b/input/input_common.c @@ -339,7 +339,6 @@ void input_config_parse_joy_axis(config_file_t *conf, const char *prefix, } } -#if !defined(IS_JOYCONFIG) static void input_get_bind_string_joykey(char *buf, const char *prefix, const struct retro_keybind *bind, size_t size) { @@ -434,7 +433,6 @@ void input_get_bind_string(char *buf, const struct retro_keybind *bind, strlcat(buf, keybuf, size); #endif } -#endif /** * input_push_analog_dpad: diff --git a/input/input_hid_driver.c b/input/input_hid_driver.c index 1c0070f4f8..d86a305624 100644 --- a/input/input_hid_driver.c +++ b/input/input_hid_driver.c @@ -20,9 +20,7 @@ #include "input_hid_driver.h" #include "../general.h" -#ifndef IS_JOYCONFIG #include "../string_list_special.h" -#endif static hid_driver_t *hid_drivers[] = { #if defined(__APPLE__) && defined(IOS) @@ -71,7 +69,6 @@ const char *hid_driver_find_ident(int idx) return drv->ident; } -#ifndef IS_JOYCONFIG /** * config_get_hid_driver_options: * @@ -83,7 +80,6 @@ const char* config_get_hid_driver_options(void) { return char_list_new_special(STRING_LIST_INPUT_HID_DRIVERS, NULL); } -#endif /** * input_hid_init_first: diff --git a/input/input_joypad_driver.c b/input/input_joypad_driver.c index 6e6dd4b7d2..b0af6763ec 100644 --- a/input/input_joypad_driver.c +++ b/input/input_joypad_driver.c @@ -20,9 +20,7 @@ #include "input_keymaps.h" #include "../general.h" -#ifndef IS_JOYCONFIG #include "../string_list_special.h" -#endif static input_device_driver_t *joypad_drivers[] = { #ifdef __CELLOS_LV2__ @@ -99,7 +97,6 @@ const char *joypad_driver_find_ident(int idx) return drv->ident; } -#ifndef IS_JOYCONFIG /** * config_get_joypad_driver_options: * @@ -111,7 +108,6 @@ const char* config_get_joypad_driver_options(void) { return char_list_new_special(STRING_LIST_INPUT_JOYPAD_DRIVERS, NULL); } -#endif /** * input_joypad_init_driver: diff --git a/libretro-common/include/retro_log.h b/libretro-common/include/retro_log.h index 57d2f62aa6..4ffd99fa0a 100644 --- a/libretro-common/include/retro_log.h +++ b/libretro-common/include/retro_log.h @@ -41,7 +41,7 @@ #include #include -#if defined(HAVE_FILE_LOGGER) && defined(RARCH_INTERNAL) && !defined(IS_JOYCONFIG) +#if defined(HAVE_FILE_LOGGER) && defined(RARCH_INTERNAL) #ifdef __cplusplus extern "C" diff --git a/tools/retroarch-joyconfig-griffin.c b/tools/retroarch-joyconfig-griffin.c deleted file mode 100644 index af72ce0b51..0000000000 --- a/tools/retroarch-joyconfig-griffin.c +++ /dev/null @@ -1,115 +0,0 @@ -/* RetroArch JoyConfig. - * 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 . - */ - -#define IS_JOYCONFIG - -#include - -#include "retroarch-joyconfig.c" - -#include "../libretro-common/dynamic/dylib.c" -#include "../libretro-common/file/retro_file.c" - -#ifdef __cplusplus -extern "C" { -#endif - -#include "../libretro-common/file/retro_stat.c" - -#ifdef __cplusplus -} -#endif - -#if defined(__linux) && !defined(ANDROID) -#include "../input/drivers/linuxraw_input.c" -#include "../input/drivers_joypad/linuxraw_joypad.c" -#endif - -#if defined(HAVE_DINPUT) -#include "../input/drivers/dinput.c" -#include "../input/drivers_joypad/dinput_joypad.c" -#endif - -#if defined(HAVE_XINPUT) -#include "../input/drivers_joypad/xinput_joypad.c" -#endif - -#if defined(HAVE_UDEV) -#include "../input/drivers_joypad/udev_joypad.c" -#endif - -#if defined(HAVE_PARPORT) -#include "../input/drivers_joypad/parport_joypad.c" -#endif - -#if __cplusplus || __STDC_VERSION__ >= 199901L -#if defined(HAVE_SDL) || defined(HAVE_SDL2) -#include "../input/drivers_joypad/sdl_joypad.c" -#endif -#endif - -#include "../libretro-common/queues/fifo_buffer.c" -#include "../libretro-common/file/config_file.c" -#include "../libretro-common/file/file_path.c" -#include "../libretro-common/hash/rhash.c" -#include "../file_path_special.c" -#include "../libretro-common/string/string_list.c" -#include "../libretro-common/compat/compat_strl.c" -#if defined(_WIN32) && !defined(_XBOX) -#include "../libretro-common/compat/compat_posix_string.c" -#include "../libretro-common/compat/compat_getopt.c" -#endif - -#include "../input/drivers/nullinput.c" -#include "../input/drivers_hid/null_hid.c" - -#include "../libretro-common/rthreads/rthreads.c" - -#if __cplusplus || __STDC_VERSION__ >= 199901L -#ifdef HAVE_LIBUSB -#include "../input/drivers_hid/libusb_hid.c" - -#ifndef HAVE_HID -#define HAVE_HID -#endif -#endif -#endif - -#if defined(__APPLE__) && defined(HAVE_IOHIDMANAGER) -#include "../input/drivers_hid/iohidmanager_hid.c" - -#ifndef HAVE_HID -#define HAVE_HID -#endif -#endif - -#ifdef HAVE_HID -#include "../input/connect/joypad_connection.c" -#include "../input/connect/connect_ps3.c" -#include "../input/connect/connect_ps4.c" -#include "../input/connect/connect_wii.c" -#endif - -#include "../input/drivers_joypad/hid_joypad.c" -#include "../input/drivers_joypad/null_joypad.c" - -#include "../input/input_hid_driver.c" -#include "../input/input_joypad_driver.c" -#include "../input/input_joypad.c" -#include "../input/input_common.c" -#include "../input/input_keymaps.c" - -#include "../libretro-common/queues/message_queue.c" diff --git a/tools/retroarch-joyconfig.c b/tools/retroarch-joyconfig.c deleted file mode 100644 index 12b08920d6..0000000000 --- a/tools/retroarch-joyconfig.c +++ /dev/null @@ -1,538 +0,0 @@ -/* RetroArch - A frontend for libretro. - * Copyright (C) 2010-2014 - Hans-Kristian Arntzen - * - * 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 . - */ - -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - -#include -#include -#include -#include -#include -#include -#include "../input/input_common.h" -#include "../input/input_joypad.h" -#include "../input/input_autodetect.h" -#include "../general.h" -#include "../runloop.h" -#include - -/* Need to be present for build to work, but it's not *really* used. - * Better than having to build special versions of lots of objects - * with special #ifdefs. - */ -struct settings g_config; -struct global g_extern; -driver_t driver; - -static int g_player = 1; -static int g_joypad = 0; -static int g_timeout = 0; -static char *g_in_path = NULL; -static char *g_out_path = NULL; -static char *g_auto_path = NULL; -static char *g_driver = NULL; -static unsigned g_meta_level = 0; - -bool retro_main_verbosity(void) -{ - return true; -} - -settings_t *config_get_ptr(void) -{ - return &g_config; -} - -driver_t *driver_get_ptr(void) -{ - return &driver; -} - -static void print_help(void) -{ - puts("====================="); - puts(" retroarch-joyconfig"); - puts("====================="); - puts("Usage: retroarch-joyconfig [ options ... ]"); - puts(""); - puts("-p/--player: Which player to configure for (1 up to and including 8)."); - puts("-j/--joypad: Which joypad to use when configuring (first joypad is 0)."); - puts("-i/--input: Input file to configure with. Binds will be added on or overwritten."); - puts("\tIf not selected, an empty config will be used as a base."); - puts("-o/--output: Output file to write to. If not selected, config file will be dumped to stdout."); - puts("-a/--autoconfig: Outputs an autoconfig file for joypad which was configured."); - puts("-M/--allmisc: Also configure various keybinds that are not directly libretro related."); - puts("\tThese configurations are for player 1 only."); - puts("-m/--misc: Same as --allmisc, but exposes a smaller subset of misc binds which are deemed most useful for regular use."); - puts("-t/--timeout: Adds a timeout of N seconds to each bind. If timed out, the bind will not be used."); - puts("-d/--driver: Uses a specific joypad driver."); - puts("-h/--help: This help."); -} - -#define MAX_BUTTONS 64 -#define MAX_AXES 32 -#define MAX_HATS 32 -struct poll_data -{ - bool buttons[MAX_BUTTONS]; - int16_t axes[MAX_AXES]; - uint16_t hats[MAX_HATS]; -}; - -static void poll_joypad(const input_device_driver_t *driver, - unsigned pad, - struct poll_data *data) -{ - unsigned i; - - if (driver) - driver->poll(); - - for (i = 0; i < MAX_BUTTONS; i++) - data->buttons[i] = input_joypad_button_raw(driver, pad, i); - - for (i = 0; i < MAX_AXES; i++) - data->axes[i] = input_joypad_axis_raw(driver, pad, i); - - for (i = 0; i < MAX_HATS; i++) - { - uint16_t hat = 0; - hat |= input_joypad_hat_raw(driver, pad, HAT_UP_MASK, i) << HAT_UP_SHIFT; - hat |= input_joypad_hat_raw(driver, pad, HAT_DOWN_MASK, i) << HAT_DOWN_SHIFT; - hat |= input_joypad_hat_raw(driver, pad, HAT_LEFT_MASK, i) << HAT_LEFT_SHIFT; - hat |= input_joypad_hat_raw(driver, pad, HAT_RIGHT_MASK, i) << HAT_RIGHT_SHIFT; - - data->hats[i] = hat; - } -} - -static void get_binds(config_file_t *conf, config_file_t *auto_conf, - int player, int joypad) -{ - int i, timeout_cnt; - const input_device_driver_t *driver = input_joypad_init_driver(g_driver, NULL); - const char *joypad_name; - - int16_t initial_axes[MAX_AXES] = {0}; - struct poll_data old_poll = {{0}}; - struct poll_data new_poll = {{0}}; - - int last_axis = -1; - bool block_axis = false; - - int timeout_ticks = g_timeout * 100; - - if (!driver) - { - fprintf(stderr, "Cannot find any valid input driver.\n"); - exit(1); - } - - if (!driver->query_pad(joypad)) - { - fprintf(stderr, "Couldn't open joystick #%d.\n", joypad); - exit(1); - } - - fprintf(stderr, "Found joypad driver: %s\n", driver->ident); - joypad_name = input_joypad_name(driver, joypad); - fprintf(stderr, "Using joypad: %s\n", joypad_name ? joypad_name : "Unknown"); - - if (joypad_name && auto_conf) - { - config_set_string(auto_conf, "input_device", joypad_name); - config_set_string(auto_conf, "input_driver", driver->ident); - } - - poll_joypad(driver, joypad, &old_poll); - fprintf(stderr, "\nJoypads tend to have stale state after opened.\nPress some buttons and move some axes around to make sure joypad state is completely neutral before proceeding.\nWhen done, press Enter ... "); - getchar(); - poll_joypad(driver, joypad, &old_poll); - - for (i = 0; i < MAX_AXES; i++) - { - int16_t initial = input_joypad_axis_raw(driver, joypad, i); - if (abs(initial) < 20000) - initial = 0; - - /* Certain joypads (such as XBox360 controller on Linux) - * has a default negative axis for shoulder triggers, - * which makes configuration very awkward. - * - * If default negative, we can't trigger on the negative axis, - * and similar with defaulted positive axes. - */ - - if (initial) - fprintf(stderr, "Axis %d is defaulted to %s axis value of %d.\n", i, initial > 0 ? "positive" : "negative", initial); - - initial_axes[i] = initial; - } - - for (i = 0; i < MAX_BUTTONS; i++) - { - if (old_poll.buttons[i]) - fprintf(stderr, "Button %d was initially pressed. This indicates broken initial state.\n", i); - } - - fprintf(stderr, "Configuring binds for player #%d on joypad #%d.\n\n", - player + 1, joypad); - - for (i = 0, timeout_cnt = 0; input_config_bind_map[i].valid; i++, timeout_cnt = 0) - { - unsigned meta_level; - unsigned player_index; - int j; - if (i == RARCH_TURBO_ENABLE) - continue; - - meta_level = input_config_bind_map[i].meta; - if (meta_level > g_meta_level) - continue; - - fprintf(stderr, "%s\n", input_config_bind_map[i].desc); - - player_index = input_config_bind_map[i].meta ? 0 : player; - - for (;;) - { - old_poll = new_poll; - - /* To avoid pegging CPU. - * Ideally use an event-based joypad scheme, - * but it adds far more complexity, so, meh. - */ - retro_sleep(10); - - if (timeout_ticks) - { - timeout_cnt++; - if (timeout_cnt >= timeout_ticks) - { - fprintf(stderr, "\tTimed out ...\n"); - break; - } - } - - poll_joypad(driver, joypad, &new_poll); - for (j = 0; j < MAX_BUTTONS; j++) - { - if (new_poll.buttons[j] && !old_poll.buttons[j]) - { - char key[64] = {0}; - - fprintf(stderr, "\tJoybutton pressed: %d\n", j); - - snprintf(key, sizeof(key), "%s_%s_btn", - input_config_get_prefix(player_index, - input_config_bind_map[i].meta), - input_config_bind_map[i].base); - config_set_int(conf, key, j); - - if (auto_conf) - { - snprintf(key, sizeof(key), "input_%s_btn", - input_config_bind_map[i].base); - config_set_int(auto_conf, key, j); - } - - goto out; - } - } - - for (j = 0; j < MAX_AXES; j++) - { - int16_t value; - bool same_axis; - bool require_negative; - bool require_positive; - - if (new_poll.axes[j] == old_poll.axes[j]) - continue; - - value = new_poll.axes[j]; - same_axis = last_axis == j; - require_negative = initial_axes[j] > 0; - require_positive = initial_axes[j] < 0; - - /* Block the axis config until we're sure - * axes have returned to their neutral state. */ - if (same_axis) - { - if (abs(value) < 10000 || - (require_positive && value < 0) || - (require_negative && value > 0)) - block_axis = false; - } - - /* If axes are in their neutral state, - * we can't allow it. */ - if (require_negative && value >= 0) - continue; - if (require_positive && value <= 0) - continue; - - if (block_axis) - continue; - - if (abs(value) > 20000) - { - char buf[8] = {0}; - char key[64] = {0}; - - last_axis = j; - fprintf(stderr, "\tJoyaxis moved: Axis %d, Value %d\n", - j, value); - - snprintf(buf, sizeof(buf), - value > 0 ? "+%d" : "-%d", j); - - snprintf(key, sizeof(key), "%s_%s_axis", - input_config_get_prefix(player_index, - input_config_bind_map[i].meta), - input_config_bind_map[i].base); - - config_set_string(conf, key, buf); - - if (auto_conf) - { - snprintf(key, sizeof(key), "input_%s_axis", - input_config_bind_map[i].base); - config_set_string(auto_conf, key, buf); - } - - block_axis = true; - goto out; - } - } - - for (j = 0; j < MAX_HATS; j++) - { - const char *quark = NULL; - uint16_t value = new_poll.hats[j]; - uint16_t old_value = old_poll.hats[j]; - - if ((value & HAT_UP_MASK) && !(old_value & HAT_UP_MASK)) - quark = "up"; - else if ((value & HAT_LEFT_MASK) && !(old_value & HAT_LEFT_MASK)) - quark = "left"; - else if ((value & HAT_RIGHT_MASK) && !(old_value & HAT_RIGHT_MASK)) - quark = "right"; - else if ((value & HAT_DOWN_MASK) && !(old_value & HAT_DOWN_MASK)) - quark = "down"; - - if (quark) - { - char buf[16] = {0}; - char key[64] = {0}; - - fprintf(stderr, "\tJoyhat moved: Hat %d, direction %s\n", j, quark); - snprintf(buf, sizeof(buf), "h%d%s", j, quark); - - snprintf(key, sizeof(key), "%s_%s_btn", - input_config_get_prefix(player_index, - input_config_bind_map[i].meta), - input_config_bind_map[i].base); - - config_set_string(conf, key, buf); - - if (auto_conf) - { - snprintf(key, sizeof(key), "input_%s_btn", - input_config_bind_map[i].base); - config_set_string(auto_conf, key, buf); - } - - goto out; - } - } - } -out: - old_poll = new_poll; - } -} - -static void parse_input(int argc, char *argv[]) -{ - char optstring[] = "i:o:a:p:j:t:hmMd:"; - struct option opts[] = { - { "input", 1, NULL, 'i' }, - { "output", 1, NULL, 'o' }, - { "autoconfig", 1, NULL, 'a' }, - { "player", 1, NULL, 'p' }, - { "joypad", 1, NULL, 'j' }, - { "help", 0, NULL, 'h' }, - { "misc", 0, NULL, 'm' }, - { "allmisc", 0, NULL, 'M' }, - { "timeout", 1, NULL, 't' }, - { "driver", 1, NULL, 'd' }, - { NULL, 0, NULL, 0 } - }; - - int option_index = 0; - for (;;) - { - int c = getopt_long(argc, argv, optstring, opts, &option_index); - if (c == -1) - break; - - switch (c) - { - case 'h': - print_help(); - exit(0); - - case 'i': - g_in_path = strdup(optarg); - break; - - case 't': - g_timeout = strtol(optarg, NULL, 0); - break; - - case 'd': - g_driver = strdup(optarg); - break; - - case 'o': - g_out_path = strdup(optarg); - break; - - case 'a': - g_auto_path = strdup(optarg); - break; - - case 'm': - g_meta_level = 1; - break; - - case 'M': - g_meta_level = 2; - break; - - case 'j': - g_joypad = strtol(optarg, NULL, 0); - if (g_joypad < 0) - { - fprintf(stderr, "Joypad number can't be negative.\n"); - exit(1); - } - break; - - case 'p': - g_player = strtol(optarg, NULL, 0); - if (g_player < 1) - { - fprintf(stderr, "User number must be at least 1.\n"); - exit(1); - } - else if (g_player > MAX_USERS) - { - fprintf(stderr, "User number must be from 1 to %d.\n", - MAX_USERS); - exit(1); - } - break; - - default: - break; - } - } - - if (optind < argc) - { - print_help(); - exit(1); - } - -} - -bool input_config_autoconfigure_joypad(autoconfig_params_t *params) -{ - (void)params; - return false; -} - -/* Need SDL_main on OSX. */ -#ifndef __APPLE__ -#undef main -#endif - -int main(int argc, char *argv[]) -{ - config_file_t *conf; - config_file_t *auto_conf = NULL; - - const char *index_list[] = { - "input_player1_joypad_index", - "input_player2_joypad_index", - "input_player3_joypad_index", - "input_player4_joypad_index", - "input_player5_joypad_index", - "input_player6_joypad_index", - "input_player7_joypad_index", - "input_player8_joypad_index", - }; - - parse_input(argc, argv); - - conf = config_file_new(g_in_path); - if (!conf) - { - fprintf(stderr, "Couldn't open config file ...\n"); - return 1; - } - - config_set_int(conf, index_list[g_player - 1], g_joypad); - - if (g_auto_path) - auto_conf = config_file_new(NULL); - - get_binds(conf, auto_conf, g_player - 1, g_joypad); - config_file_write(conf, g_out_path); - config_file_free(conf); - if (auto_conf) - { - fprintf(stderr, "Writing autoconfig profile to: %s.\n", g_auto_path); - config_file_write(auto_conf, g_auto_path); - config_file_free(auto_conf); - } - - free(g_in_path); - free(g_out_path); - free(g_auto_path); - return 0; -} - -void rarch_main_msg_queue_push(const char *msg, unsigned prio, unsigned duration, - bool flush) -{ -} - -bool video_driver_viewport_info(struct video_viewport *vp) -{ - return false; -} - -bool video_driver_read_viewport(uint8_t *buffer) -{ - return false; -} - -void input_config_autoconfigure_disconnect(unsigned id, const char *msg) -{ -} From 3c802d710fb2b0f773a7d9708a3fc2acd5c3f59d Mon Sep 17 00:00:00 2001 From: twinaphex Date: Wed, 11 Nov 2015 20:18:45 +0100 Subject: [PATCH 142/216] remove last joyconfig parts --- Makefile | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/Makefile b/Makefile index 7889461dcf..10c938604b 100644 --- a/Makefile +++ b/Makefile @@ -8,7 +8,6 @@ endif include config.mk TARGET = retroarch -JTARGET = tools/retroarch-joyconfig OBJDIR := obj-unix @@ -102,7 +101,7 @@ ifneq ($(SANITIZER),) LDFLAGS := -fsanitize=$(SANITIZER) $(LDLAGS) endif -all: $(TARGET) $(JTARGET) config.mk +all: $(TARGET) config.mk -include $(RARCH_OBJ:.o=.d) config.mk: configure qb/* @@ -154,29 +153,24 @@ install: $(TARGET) mkdir -p $(DESTDIR)$(PREFIX)/share/pixmaps 2>/dev/null || /bin/true install -m755 $(TARGET) $(DESTDIR)$(PREFIX)/bin install -m755 tools/cg2glsl.py $(DESTDIR)$(PREFIX)/bin/retroarch-cg2glsl - install -m755 $(JTARGET) $(DESTDIR)$(PREFIX)/bin install -m644 retroarch.cfg $(DESTDIR)$(GLOBAL_CONFIG_DIR)/retroarch.cfg install -m644 retroarch.desktop $(DESTDIR)$(PREFIX)/share/applications install -m644 docs/retroarch.1 $(DESTDIR)$(MAN_DIR) install -m644 docs/retroarch-cg2glsl.1 $(DESTDIR)$(MAN_DIR) - install -m644 docs/retroarch-joyconfig.1 $(DESTDIR)$(MAN_DIR) install -m644 media/retroarch.svg $(DESTDIR)$(PREFIX)/share/pixmaps uninstall: rm -f $(DESTDIR)$(PREFIX)/bin/retroarch - rm -f $(DESTDIR)$(PREFIX)/bin/retroarch-joyconfig rm -f $(DESTDIR)$(PREFIX)/bin/retroarch-cg2glsl rm -f $(DESTDIR)$(GLOBAL_CONFIG_DIR)/retroarch.cfg rm -f $(DESTDIR)$(PREFIX)/share/applications/retroarch.desktop rm -f $(DESTDIR)$(MAN_DIR)/retroarch.1 rm -f $(DESTDIR)$(MAN_DIR)/retroarch-cg2glsl.1 - rm -f $(DESTDIR)$(MAN_DIR)/retroarch-joyconfig.1 rm -f $(DESTDIR)$(PREFIX)/share/pixmaps/retroarch.svg clean: rm -rf $(OBJDIR) rm -f $(TARGET) - rm -f $(JTARGET) rm -f *.d .PHONY: all install uninstall clean From c33f4b9f8353f78fe30536a21cf1e9e4684a34be Mon Sep 17 00:00:00 2001 From: twinaphex Date: Wed, 11 Nov 2015 20:19:48 +0100 Subject: [PATCH 143/216] video_Thread_wrapper - add extern "C" --- gfx/video_thread_wrapper.h | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/gfx/video_thread_wrapper.h b/gfx/video_thread_wrapper.h index d5bd9de543..22d7ff756d 100644 --- a/gfx/video_thread_wrapper.h +++ b/gfx/video_thread_wrapper.h @@ -23,6 +23,10 @@ #include #include "font_driver.h" +#ifdef __cplusplus +extern "C" { +#endif + enum thread_cmd { CMD_NONE = 0, @@ -59,6 +63,7 @@ enum thread_cmd CMD_DUMMY = INT_MAX }; + typedef struct { enum thread_cmd type; @@ -256,5 +261,8 @@ void *rarch_threaded_video_get_ptr(const video_driver_t **drv); const char *rarch_threaded_video_get_ident(void); +#ifdef __cplusplus +} #endif +#endif From 5e6983d0daaa35bb33d85683859f96966729089b Mon Sep 17 00:00:00 2001 From: twinaphex Date: Wed, 11 Nov 2015 20:21:16 +0100 Subject: [PATCH 144/216] Add extern "C" for win32_handle_keyboard_event --- gfx/common/win32_common.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gfx/common/win32_common.h b/gfx/common/win32_common.h index 76ff1cd5fa..4b0e88054c 100644 --- a/gfx/common/win32_common.h +++ b/gfx/common/win32_common.h @@ -39,7 +39,7 @@ extern bool g_resized; extern bool g_quit; extern HWND g_hwnd; -LRESULT win32_handle_keyboard_event(HWND hwnd, UINT message, +extern "C" LRESULT win32_handle_keyboard_event(HWND hwnd, UINT message, WPARAM wparam, LPARAM lparam); LRESULT win32_menu_loop(HWND handle, WPARAM wparam); From 1da727cd540637a98558e07c4e383b9025ab7fcc Mon Sep 17 00:00:00 2001 From: twinaphex Date: Wed, 11 Nov 2015 20:23:19 +0100 Subject: [PATCH 145/216] convert keyboard_event_win32 to C++ --- gfx/common/win32_common.h | 2 +- griffin/griffin.c | 4 ---- griffin/griffin_cpp.cpp | 8 ++++++++ .../{keyboard_event_win32.c => keyboard_event_win32.cpp} | 0 4 files changed, 9 insertions(+), 5 deletions(-) rename input/drivers_keyboard/{keyboard_event_win32.c => keyboard_event_win32.cpp} (100%) diff --git a/gfx/common/win32_common.h b/gfx/common/win32_common.h index 4b0e88054c..76ff1cd5fa 100644 --- a/gfx/common/win32_common.h +++ b/gfx/common/win32_common.h @@ -39,7 +39,7 @@ extern bool g_resized; extern bool g_quit; extern HWND g_hwnd; -extern "C" LRESULT win32_handle_keyboard_event(HWND hwnd, UINT message, +LRESULT win32_handle_keyboard_event(HWND hwnd, UINT message, WPARAM wparam, LPARAM lparam); LRESULT win32_menu_loop(HWND handle, WPARAM wparam); diff --git a/griffin/griffin.c b/griffin/griffin.c index 7845d1e35a..b93bd20a04 100644 --- a/griffin/griffin.c +++ b/griffin/griffin.c @@ -415,10 +415,6 @@ INPUT (HID) KEYBOARD EVENT ============================================================ */ -#if defined(_WIN32) && !defined(_XBOX) -#include "../input/drivers_keyboard/keyboard_event_win32.c" -#endif - #ifdef HAVE_X11 #include "../input/drivers_keyboard/keyboard_event_x11.c" #endif diff --git a/griffin/griffin_cpp.cpp b/griffin/griffin_cpp.cpp index d81d425e2d..b28331f5c4 100644 --- a/griffin/griffin_cpp.cpp +++ b/griffin/griffin_cpp.cpp @@ -32,6 +32,14 @@ AUDIO #include "../audio/drivers/xaudio.cpp" #endif +/*============================================================ + KEYBOARD EVENT + ============================================================ */ + +#if defined(_WIN32) && !defined(_XBOX) +#include "../input/drivers_keyboard/keyboard_event_win32.cpp" +#endif + /*============================================================ UI COMMON CONTEXT ============================================================ */ diff --git a/input/drivers_keyboard/keyboard_event_win32.c b/input/drivers_keyboard/keyboard_event_win32.cpp similarity index 100% rename from input/drivers_keyboard/keyboard_event_win32.c rename to input/drivers_keyboard/keyboard_event_win32.cpp From 78b7980b12b76c0a2a159a7154b5e812bd1e511c Mon Sep 17 00:00:00 2001 From: twinaphex Date: Wed, 11 Nov 2015 20:30:51 +0100 Subject: [PATCH 146/216] Linker fix --- gfx/common/win32_common.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gfx/common/win32_common.cpp b/gfx/common/win32_common.cpp index 81b61895a5..3ccb48da3d 100644 --- a/gfx/common/win32_common.cpp +++ b/gfx/common/win32_common.cpp @@ -58,7 +58,7 @@ extern void *dinput; typedef REASON_CONTEXT POWER_REQUEST_CONTEXT, *PPOWER_REQUEST_CONTEXT, *LPPOWER_REQUEST_CONTEXT; -WINBASEAPI +extern "C" WINBASEAPI HANDLE WINAPI PowerCreateRequest ( From 6e2b9df32f6c3081a2c1814dc6d965819645b611 Mon Sep 17 00:00:00 2001 From: aliaspider Date: Wed, 11 Nov 2015 21:10:13 +0100 Subject: [PATCH 147/216] (3ds) fix non-griffin build. --- Makefile.ctr | 3 +++ runloop.c | 2 ++ 2 files changed, 5 insertions(+) diff --git a/Makefile.ctr b/Makefile.ctr index 1a89ed25fc..e369bebe51 100644 --- a/Makefile.ctr +++ b/Makefile.ctr @@ -53,6 +53,8 @@ else OBJS += libretro-common/formats/png/rpng.o OBJS += libretro-common/formats/png/rpng_encode.o OBJS += libretro-common/formats/bmp/rbmp_encode.o + OBJS += libretro-common/gfx/math/matrix_4x4.o + OBJS += libretro-common/gfx/math/matrix_3x3.o OBJS += gfx/drivers/ctr_gfx.o OBJS += gfx/drivers/nullgfx.o OBJS += gfx/font_renderer_driver.o @@ -208,6 +210,7 @@ else OBJS += menu/intl/menu_hash_us.o OBJS += menu/drivers/null.o OBJS += menu/drivers/menu_generic.o + OBJS += menu/drivers_display/menu_display_null.o OBJS += menu/drivers/rgui.o OBJS += command_event.o OBJS += deps/zlib/adler32.o diff --git a/runloop.c b/runloop.c index 88199ef6b0..16785a37bc 100644 --- a/runloop.c +++ b/runloop.c @@ -22,7 +22,9 @@ #include +#ifdef HAVE_CHEEVOS #include "cheevos.h" +#endif #include "configuration.h" #include "performance.h" #include "retroarch.h" From 05ba34f0d2f5e492c3596921b1cbdcee72e2b1ba Mon Sep 17 00:00:00 2001 From: aliaspider Date: Wed, 11 Nov 2015 21:11:22 +0100 Subject: [PATCH 148/216] nit. --- Makefile.ctr | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Makefile.ctr b/Makefile.ctr index e369bebe51..44f857144b 100644 --- a/Makefile.ctr +++ b/Makefile.ctr @@ -53,8 +53,8 @@ else OBJS += libretro-common/formats/png/rpng.o OBJS += libretro-common/formats/png/rpng_encode.o OBJS += libretro-common/formats/bmp/rbmp_encode.o - OBJS += libretro-common/gfx/math/matrix_4x4.o - OBJS += libretro-common/gfx/math/matrix_3x3.o + OBJS += libretro-common/gfx/math/matrix_4x4.o + OBJS += libretro-common/gfx/math/matrix_3x3.o OBJS += gfx/drivers/ctr_gfx.o OBJS += gfx/drivers/nullgfx.o OBJS += gfx/font_renderer_driver.o @@ -210,7 +210,7 @@ else OBJS += menu/intl/menu_hash_us.o OBJS += menu/drivers/null.o OBJS += menu/drivers/menu_generic.o - OBJS += menu/drivers_display/menu_display_null.o + OBJS += menu/drivers_display/menu_display_null.o OBJS += menu/drivers/rgui.o OBJS += command_event.o OBJS += deps/zlib/adler32.o From d65b930b09bb87a3dcb09681883241bbafbca596 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Wed, 11 Nov 2015 21:52:57 +0100 Subject: [PATCH 149/216] Cleanups --- menu/menu_display.c | 30 ------------------------------ 1 file changed, 30 deletions(-) diff --git a/menu/menu_display.c b/menu/menu_display.c index 360d723d66..b88bc97155 100644 --- a/menu/menu_display.c +++ b/menu/menu_display.c @@ -140,36 +140,6 @@ bool menu_display_font_init_first(const void **font_driver, return menu_disp->font_init_first(font_driver, font_handle, video_data, font_path, font_size); - - settings_t *settings = config_get_ptr(); - const struct retro_hw_render_callback *hw_render = - (const struct retro_hw_render_callback*)video_driver_callback(); - - if (settings->video.threaded && !hw_render->context_type) - { - thread_packet_t pkt; - driver_t *driver = driver_get_ptr(); - thread_video_t *thr = (thread_video_t*)driver->video_data; - - if (!thr) - return false; - - pkt.type = CMD_FONT_INIT; - pkt.data.font_init.method = font_init_first; - pkt.data.font_init.font_driver = (const void**)font_driver; - pkt.data.font_init.font_handle = font_handle; - pkt.data.font_init.video_data = video_data; - pkt.data.font_init.font_path = font_path; - pkt.data.font_init.font_size = font_size; - pkt.data.font_init.api = FONT_DRIVER_RENDER_OPENGL_API; - - thr->send_and_wait(thr, &pkt); - - return pkt.data.font_init.return_value; - } - - return font_init_first(font_driver, font_handle, video_data, - font_path, font_size, FONT_DRIVER_RENDER_OPENGL_API); } bool menu_display_font_bind_block(void *data, const void *font_data, void *userdata) From ff7e5ee0c847160fd9ca62310717309d0ce9d9f4 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Wed, 11 Nov 2015 21:59:51 +0100 Subject: [PATCH 150/216] Avoid redefining HAVE_STRL --- libretro-common/include/compat/strl.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/libretro-common/include/compat/strl.h b/libretro-common/include/compat/strl.h index ddb89c2f98..86d2a39930 100644 --- a/libretro-common/include/compat/strl.h +++ b/libretro-common/include/compat/strl.h @@ -35,8 +35,10 @@ extern "C" { #endif #ifdef __MACH__ +#ifndef HAVE_STRL #define HAVE_STRL #endif +#endif #ifndef HAVE_STRL /* Avoid possible naming collisions during link since From 61f0464b77bec4fa7574a6a3ece24459f6cb954d Mon Sep 17 00:00:00 2001 From: twinaphex Date: Wed, 11 Nov 2015 22:06:05 +0100 Subject: [PATCH 151/216] (win32_shader_dlg.c) Avoid warnings --- gfx/drivers_wm/win32_shader_dlg.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/gfx/drivers_wm/win32_shader_dlg.c b/gfx/drivers_wm/win32_shader_dlg.c index d78fa3afca..842c2b36bb 100644 --- a/gfx/drivers_wm/win32_shader_dlg.c +++ b/gfx/drivers_wm/win32_shader_dlg.c @@ -199,7 +199,7 @@ void shader_dlg_params_reload(void) g_shader_dlg.controls[i].type = SHADER_PARAM_CTRL_CHECKBOX; g_shader_dlg.controls[i].checkbox.hwnd = CreateWindowEx(0, "BUTTON", shader->parameters[i].desc, WS_CHILD | WS_VISIBLE | BS_AUTOCHECKBOX, pos_x, pos_y, SHADER_DLG_CTRL_WIDTH, SHADER_DLG_CHECKBOX_HEIGHT, - g_shader_dlg.hwnd, (HMENU)i, NULL, NULL); + g_shader_dlg.hwnd, (HMENU)(size_t)i, NULL, NULL); SendMessage(g_shader_dlg.controls[i].checkbox.hwnd, WM_SETFONT, (WPARAM)hFont, MAKELPARAM(TRUE, 0)); pos_y += SHADER_DLG_CHECKBOX_HEIGHT + SHADER_DLG_CTRL_MARGIN; } @@ -215,16 +215,16 @@ void shader_dlg_params_reload(void) g_shader_dlg.controls[i].type = SHADER_PARAM_CTRL_TRACKBAR; g_shader_dlg.controls[i].trackbar.label_title = CreateWindowEx(0, "STATIC", shader->parameters[i].desc, WS_CHILD | WS_VISIBLE | SS_LEFT, pos_x, pos_y, SHADER_DLG_CTRL_WIDTH, SHADER_DLG_LABEL_HEIGHT, g_shader_dlg.hwnd, - (HMENU)i, NULL, NULL); + (HMENU)(size_t)i, NULL, NULL); SendMessage(g_shader_dlg.controls[i].trackbar.label_title, WM_SETFONT, (WPARAM)hFont, MAKELPARAM(TRUE, 0)); pos_y += SHADER_DLG_LABEL_HEIGHT; g_shader_dlg.controls[i].trackbar.hwnd = CreateWindowEx(0, TRACKBAR_CLASS, "", WS_CHILD | WS_VISIBLE | TBS_HORZ | TBS_NOTICKS, pos_x + SHADER_DLG_TRACKBAR_LABEL_WIDTH, pos_y, - SHADER_DLG_TRACKBAR_WIDTH, SHADER_DLG_TRACKBAR_HEIGHT, g_shader_dlg.hwnd, (HMENU)i, NULL, NULL); + SHADER_DLG_TRACKBAR_WIDTH, SHADER_DLG_TRACKBAR_HEIGHT, g_shader_dlg.hwnd, (HMENU)(size_t)i, NULL, NULL); g_shader_dlg.controls[i].trackbar.label_val = CreateWindowEx(0, "STATIC", "", WS_CHILD | WS_VISIBLE | SS_LEFT, pos_x, - pos_y, SHADER_DLG_TRACKBAR_LABEL_WIDTH, SHADER_DLG_LABEL_HEIGHT, g_shader_dlg.hwnd, (HMENU)i, NULL, NULL); + pos_y, SHADER_DLG_TRACKBAR_LABEL_WIDTH, SHADER_DLG_LABEL_HEIGHT, g_shader_dlg.hwnd, (HMENU)(size_t)i, NULL, NULL); SendMessage(g_shader_dlg.controls[i].trackbar.label_val, WM_SETFONT, (WPARAM)hFont, MAKELPARAM(TRUE, 0)); SendMessage(g_shader_dlg.controls[i].trackbar.hwnd, TBM_SETBUDDY, (WPARAM)TRUE, From cb5d4b0569f5023bdd42d278ccfd7c81dc1d40bb Mon Sep 17 00:00:00 2001 From: twinaphex Date: Thu, 12 Nov 2015 01:22:28 +0100 Subject: [PATCH 152/216] Compile in win32_monitor_ functions for Xbox too but leave them stub --- gfx/common/win32_common.cpp | 19 ++++++++++++------- gfx/common/win32_common.h | 7 ++++--- gfx/d3d/d3d.cpp | 3 --- gfx/d3d/d3d.h | 2 -- gfx/drivers_context/d3d_ctx.cpp | 2 -- 5 files changed, 16 insertions(+), 17 deletions(-) diff --git a/gfx/common/win32_common.cpp b/gfx/common/win32_common.cpp index 3ccb48da3d..7ffe175e4d 100644 --- a/gfx/common/win32_common.cpp +++ b/gfx/common/win32_common.cpp @@ -96,13 +96,6 @@ static BOOL CALLBACK win32_monitor_enum_proc(HMONITOR hMonitor, return TRUE; } -void win32_monitor_init(void) -{ - win32_monitor_count = 0; - EnumDisplayMonitors(NULL, NULL, win32_monitor_enum_proc, 0); - - g_quit = false; -} void win32_monitor_from_window(HWND data, bool destroy) { @@ -247,6 +240,7 @@ static LRESULT CALLBACK WndProc(HWND hwnd, UINT message, bool win32_window_init(WNDCLASSEX *wndclass, bool fullscreen) { +#ifndef _XBOX wndclass->cbSize = sizeof(WNDCLASSEX); wndclass->style = CS_HREDRAW | CS_VREDRAW | CS_OWNDC; wndclass->lpfnWndProc = WndProc; @@ -261,6 +255,7 @@ bool win32_window_init(WNDCLASSEX *wndclass, bool fullscreen) if (!RegisterClassEx(wndclass)) return false; +#endif return true; } @@ -451,6 +446,16 @@ bool win32_get_metrics(void *data, #endif } +void win32_monitor_init(void) +{ +#ifndef _XBOX + win32_monitor_count = 0; + EnumDisplayMonitors(NULL, NULL, win32_monitor_enum_proc, 0); +#endif + + g_quit = false; +} + void win32_show_cursor(bool state) { #ifndef _XBOX diff --git a/gfx/common/win32_common.h b/gfx/common/win32_common.h index 76ff1cd5fa..95a11c7d89 100644 --- a/gfx/common/win32_common.h +++ b/gfx/common/win32_common.h @@ -44,7 +44,6 @@ LRESULT win32_handle_keyboard_event(HWND hwnd, UINT message, LRESULT win32_menu_loop(HWND handle, WPARAM wparam); -void win32_monitor_init(void); void win32_monitor_from_window(HWND data, bool destroy); @@ -52,11 +51,13 @@ void win32_monitor_get_info(void); void win32_monitor_info(void *data, void *hm_data, unsigned *mon_id); -bool win32_window_init(WNDCLASSEX *wndclass, bool fullscreen); - void create_gl_context(HWND hwnd); #endif +void win32_monitor_init(void); + +bool win32_window_init(WNDCLASSEX *wndclass, bool fullscreen); + bool win32_suppress_screensaver(void *data, bool enable); bool win32_get_metrics(void *data, diff --git a/gfx/d3d/d3d.cpp b/gfx/d3d/d3d.cpp index 0399fde913..9436bdeb1a 100644 --- a/gfx/d3d/d3d.cpp +++ b/gfx/d3d/d3d.cpp @@ -593,11 +593,8 @@ static bool d3d_construct(d3d_video_t *d3d, d3d->menu->vert_coords[3] = -1; #endif -#if defined(HAVE_WINDOW) && !defined(_XBOX) memset(&d3d->windowClass, 0, sizeof(d3d->windowClass)); - win32_window_init(&d3d->windowClass, true); -#endif #ifdef HAVE_MONITOR bool windowed_full; diff --git a/gfx/d3d/d3d.h b/gfx/d3d/d3d.h index 609da0e76e..6d6ae91245 100644 --- a/gfx/d3d/d3d.h +++ b/gfx/d3d/d3d.h @@ -98,9 +98,7 @@ typedef struct d3d_video bool quitting; struct video_viewport vp; -#ifdef HAVE_WINDOW WNDCLASSEX windowClass; -#endif HWND hWnd; LPDIRECT3D g_pD3D; LPDIRECT3DDEVICE dev; diff --git a/gfx/drivers_context/d3d_ctx.cpp b/gfx/drivers_context/d3d_ctx.cpp index 07c3ac78eb..4ccadaadca 100644 --- a/gfx/drivers_context/d3d_ctx.cpp +++ b/gfx/drivers_context/d3d_ctx.cpp @@ -177,9 +177,7 @@ static bool gfx_ctx_d3d_init(void *data) { (void)data; -#ifndef _XBOX win32_monitor_init(); -#endif return true; } From 823e2db596afed37de91e0db0efdb5a0db91a94b Mon Sep 17 00:00:00 2001 From: twinaphex Date: Thu, 12 Nov 2015 01:28:14 +0100 Subject: [PATCH 153/216] Create d3d_set_render_state --- gfx/d3d/d3d_wrapper.cpp | 20 ++++++++++++++++---- gfx/d3d/d3d_wrapper.h | 2 ++ gfx/d3d/render_chain_xdk.cpp | 6 +++--- gfx/drivers_context/d3d_ctx.cpp | 3 +-- 4 files changed, 22 insertions(+), 9 deletions(-) diff --git a/gfx/d3d/d3d_wrapper.cpp b/gfx/d3d/d3d_wrapper.cpp index a75bcaa6f9..b15cc5d9fc 100644 --- a/gfx/d3d/d3d_wrapper.cpp +++ b/gfx/d3d/d3d_wrapper.cpp @@ -418,6 +418,18 @@ void d3d_texture_blit(unsigned pixel_size, #endif } +void d3d_set_render_state(void *data, D3DRENDERSTATETYPE state, DWORD value) +{ + LPDIRECT3DDEVICE dev = (LPDIRECT3DDEVICE)data; + + if (!dev) + return; + if (!d3d_restore_device(dev)) + return; + + dev->SetRenderState(state, value); +} + void d3d_enable_blend_func(void *data) { LPDIRECT3DDEVICE dev = (LPDIRECT3DDEVICE)data; @@ -427,9 +439,9 @@ void d3d_enable_blend_func(void *data) if (!d3d_restore_device(dev)) return; - dev->SetRenderState(D3DRS_SRCBLEND, D3DBLEND_SRCALPHA); - dev->SetRenderState(D3DRS_DESTBLEND, D3DBLEND_INVSRCALPHA); - dev->SetRenderState(D3DRS_ALPHABLENDENABLE, true); + d3d_render_state(dev, D3DRS_SRCBLEND, D3DBLEND_SRCALPHA); + d3d_render_state(dev, D3DRS_DESTBLEND, D3DBLEND_INVSRCALPHA); + d3d_render_state(dev, D3DRS_ALPHABLENDENABLE, true); } void d3d_enable_alpha_blend_texture_func(void *data) @@ -474,7 +486,7 @@ void d3d_disable_blend_func(void *data) if (!d3d_restore_device(dev)) return; - dev->SetRenderState(D3DRS_ALPHABLENDENABLE, false); + d3d_render_state(dev, D3DRS_ALPHABLENDENABLE, false); } void d3d_set_vertex_declaration(void *data, void *vertex_data) diff --git a/gfx/d3d/d3d_wrapper.h b/gfx/d3d/d3d_wrapper.h index cf5fa69058..a3671332b5 100644 --- a/gfx/d3d/d3d_wrapper.h +++ b/gfx/d3d/d3d_wrapper.h @@ -105,6 +105,8 @@ void d3d_enable_alpha_blend_texture_func(void *data); void d3d_frame_postprocess(void *data); +void d3d_set_render_state(void *data, D3DRENDERSTATETYPE state, DWORD value); + #ifdef __cplusplus } #endif diff --git a/gfx/d3d/render_chain_xdk.cpp b/gfx/d3d/render_chain_xdk.cpp index 4a7315d883..bc6260affd 100644 --- a/gfx/d3d/render_chain_xdk.cpp +++ b/gfx/d3d/render_chain_xdk.cpp @@ -115,10 +115,10 @@ static bool renderchain_create_first_pass(void *data, d3d_set_sampler_address_u(d3dr, D3DSAMP_ADDRESSU, D3DTADDRESS_BORDER); d3d_set_sampler_address_v(d3dr, D3DSAMP_ADDRESSV, D3DTADDRESS_BORDER); #ifdef _XBOX1 - d3dr->SetRenderState(D3DRS_LIGHTING, FALSE); + d3d_set_render_state(d3dr, D3DRS_LIGHTING, 0); #endif - d3dr->SetRenderState(D3DRS_CULLMODE, D3DCULL_NONE); - d3dr->SetRenderState(D3DRS_ZENABLE, FALSE); + d3d_set_render_state(d3dr, D3DRS_CULLMODE, D3DCULL_NONE); + d3d_set_render_state(d3dr, D3DRS_ZENABLE, FALSE); if (!xdk_renderchain_init_shader_fvf(chain, chain)) return false; diff --git a/gfx/drivers_context/d3d_ctx.cpp b/gfx/drivers_context/d3d_ctx.cpp index 4ccadaadca..2f0e3eee8e 100644 --- a/gfx/drivers_context/d3d_ctx.cpp +++ b/gfx/drivers_context/d3d_ctx.cpp @@ -309,11 +309,10 @@ static void gfx_ctx_d3d_swap_interval(void *data, unsigned interval) { d3d_video_t *d3d = (d3d_video_t*)data; #ifdef _XBOX - LPDIRECT3DDEVICE d3dr = (LPDIRECT3DDEVICE)d3d->dev; unsigned d3d_interval = interval ? D3DPRESENT_INTERVAL_ONE : D3DPRESENT_INTERVAL_IMMEDIATE; - d3dr->SetRenderState(XBOX_PRESENTATIONINTERVAL, d3d_interval); + d3d_render_state(d3d->dev, XBOX_PRESENTATIONINTERVAL, d3d_interval); #else d3d_restore(d3d); #endif From 7a76d7e0a7655f9d89e63f392428d50049904d8b Mon Sep 17 00:00:00 2001 From: twinaphex Date: Thu, 12 Nov 2015 01:29:25 +0100 Subject: [PATCH 154/216] (D3D) Buildfix --- gfx/d3d/d3d_wrapper.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/gfx/d3d/d3d_wrapper.cpp b/gfx/d3d/d3d_wrapper.cpp index b15cc5d9fc..bedc42ea5a 100644 --- a/gfx/d3d/d3d_wrapper.cpp +++ b/gfx/d3d/d3d_wrapper.cpp @@ -439,9 +439,9 @@ void d3d_enable_blend_func(void *data) if (!d3d_restore_device(dev)) return; - d3d_render_state(dev, D3DRS_SRCBLEND, D3DBLEND_SRCALPHA); - d3d_render_state(dev, D3DRS_DESTBLEND, D3DBLEND_INVSRCALPHA); - d3d_render_state(dev, D3DRS_ALPHABLENDENABLE, true); + d3d_set_render_state(dev, D3DRS_SRCBLEND, D3DBLEND_SRCALPHA); + d3d_set_render_state(dev, D3DRS_DESTBLEND, D3DBLEND_INVSRCALPHA); + d3d_set_render_state(dev, D3DRS_ALPHABLENDENABLE, true); } void d3d_enable_alpha_blend_texture_func(void *data) @@ -486,7 +486,7 @@ void d3d_disable_blend_func(void *data) if (!d3d_restore_device(dev)) return; - d3d_render_state(dev, D3DRS_ALPHABLENDENABLE, false); + d3d_set_render_state(dev, D3DRS_ALPHABLENDENABLE, false); } void d3d_set_vertex_declaration(void *data, void *vertex_data) From e50339ee7939ec728f9cd7adc07b9ac8aed45814 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Thu, 12 Nov 2015 01:32:01 +0100 Subject: [PATCH 155/216] Call d3d_set_vertex_declaration --- gfx/d3d/d3d.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gfx/d3d/d3d.cpp b/gfx/d3d/d3d.cpp index 9436bdeb1a..b8c07dbc2f 100644 --- a/gfx/d3d/d3d.cpp +++ b/gfx/d3d/d3d.cpp @@ -1287,7 +1287,7 @@ static void d3d_overlay_render(d3d_video_t *d3d, overlay_t *overlay) #ifndef _XBOX1 d3d->dev->CreateVertexDeclaration(vElems, &vertex_decl); - d3d->dev->SetVertexDeclaration(vertex_decl); + d3d_set_vertex_declaration(d3d->dev, vertex_decl); vertex_decl->Release(); #endif From f610f29e343f7edddaae730e4dba4e371b7ee2c7 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Thu, 12 Nov 2015 01:38:13 +0100 Subject: [PATCH 156/216] Add d3d_vertex_declaration_new --- gfx/d3d/d3d_wrapper.cpp | 12 ++++++++++++ gfx/d3d/d3d_wrapper.h | 3 +++ 2 files changed, 15 insertions(+) diff --git a/gfx/d3d/d3d_wrapper.cpp b/gfx/d3d/d3d_wrapper.cpp index bedc42ea5a..fb2919f849 100644 --- a/gfx/d3d/d3d_wrapper.cpp +++ b/gfx/d3d/d3d_wrapper.cpp @@ -105,6 +105,18 @@ void d3d_texture_free(LPDIRECT3DTEXTURE tex) tex = NULL; } +bool d3d_vertex_declaration_new(LPDIRECT3DDEVICE dev, + const void *vertex_data, void **decl_data) +{ +#ifndef _XBOX1 + const D3DVERTEXELEMENT *vertex_elements = (const D3DVERTEXELEMENT*)vertex_data; + LPDIRECT3DVERTEXDECLARATION **vertex_decl = (LPDIRECT3DVERTEXDECLARATION**)decl_data; + if (SUCCEEDED(dev->CreateVertexDeclaration(vertex_elements, vertex_decl))) + return true; +#endif + return false; +} + LPDIRECT3DVERTEXBUFFER d3d_vertex_buffer_new(LPDIRECT3DDEVICE dev, unsigned length, unsigned usage, unsigned fvf, D3DPOOL pool, void *handle) diff --git a/gfx/d3d/d3d_wrapper.h b/gfx/d3d/d3d_wrapper.h index a3671332b5..fddd5a3174 100644 --- a/gfx/d3d/d3d_wrapper.h +++ b/gfx/d3d/d3d_wrapper.h @@ -93,6 +93,9 @@ void d3d_texture_blit(unsigned pixel_size, D3DLOCKED_RECT *lr, const void *frame, unsigned width, unsigned height, unsigned pitch); +bool d3d_vertex_declaration_new(LPDIRECT3DDEVICE dev, + const void *vertex_data, void **decl_data); + void d3d_set_viewport(LPDIRECT3DDEVICE dev, D3DVIEWPORT *vp); void d3d_enable_blend_func(void *data); From a4336fe89a381e0611a59efd56bc1a60a5466223 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Thu, 12 Nov 2015 01:44:34 +0100 Subject: [PATCH 157/216] (D3D) Buildfix --- gfx/d3d/d3d_wrapper.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gfx/d3d/d3d_wrapper.cpp b/gfx/d3d/d3d_wrapper.cpp index fb2919f849..306691325a 100644 --- a/gfx/d3d/d3d_wrapper.cpp +++ b/gfx/d3d/d3d_wrapper.cpp @@ -111,7 +111,7 @@ bool d3d_vertex_declaration_new(LPDIRECT3DDEVICE dev, #ifndef _XBOX1 const D3DVERTEXELEMENT *vertex_elements = (const D3DVERTEXELEMENT*)vertex_data; LPDIRECT3DVERTEXDECLARATION **vertex_decl = (LPDIRECT3DVERTEXDECLARATION**)decl_data; - if (SUCCEEDED(dev->CreateVertexDeclaration(vertex_elements, vertex_decl))) + if (SUCCEEDED(dev->CreateVertexDeclaration(vertex_elements, (IDirect3DVertexDeclaration9**)vertex_decl))) return true; #endif return false; From a09e8e0684b518aeafe915753d7b0afe1ee4b96e Mon Sep 17 00:00:00 2001 From: twinaphex Date: Thu, 12 Nov 2015 01:48:36 +0100 Subject: [PATCH 158/216] Start using wrappers for vertex declarations --- gfx/d3d/d3d.cpp | 4 ++-- gfx/d3d/d3d_wrapper.cpp | 8 ++++++++ gfx/d3d/d3d_wrapper.h | 2 ++ gfx/d3d/render_chain_cg.cpp | 5 +++-- gfx/d3d/render_chain_xdk.cpp | 2 +- 5 files changed, 16 insertions(+), 5 deletions(-) diff --git a/gfx/d3d/d3d.cpp b/gfx/d3d/d3d.cpp index b8c07dbc2f..1b8cb61d5d 100644 --- a/gfx/d3d/d3d.cpp +++ b/gfx/d3d/d3d.cpp @@ -1286,9 +1286,9 @@ static void d3d_overlay_render(d3d_video_t *d3d, overlay_t *overlay) d3d_enable_blend_func(d3d->dev); #ifndef _XBOX1 - d3d->dev->CreateVertexDeclaration(vElems, &vertex_decl); + d3d_vertex_declaration_new(d3d->dev, vElems, &vertex_decl); d3d_set_vertex_declaration(d3d->dev, vertex_decl); - vertex_decl->Release(); + d3d_vertex_declaration_free(vertex_decl); #endif d3d_set_stream_source(d3d->dev, 0, overlay->vert_buf, diff --git a/gfx/d3d/d3d_wrapper.cpp b/gfx/d3d/d3d_wrapper.cpp index 306691325a..0f2caefb43 100644 --- a/gfx/d3d/d3d_wrapper.cpp +++ b/gfx/d3d/d3d_wrapper.cpp @@ -117,6 +117,14 @@ bool d3d_vertex_declaration_new(LPDIRECT3DDEVICE dev, return false; } +void d3d_vertex_declaration_free(void *vertex_data) +{ +#ifndef _XBOX1 + LPDIRECT3DVERTEXDECLARATION vertex_decl = (LPDIRECT3DVERTEXDECLARATION)vertex_data; + vertex_decl->Release(); +#endif +} + LPDIRECT3DVERTEXBUFFER d3d_vertex_buffer_new(LPDIRECT3DDEVICE dev, unsigned length, unsigned usage, unsigned fvf, D3DPOOL pool, void *handle) diff --git a/gfx/d3d/d3d_wrapper.h b/gfx/d3d/d3d_wrapper.h index fddd5a3174..9152fadea9 100644 --- a/gfx/d3d/d3d_wrapper.h +++ b/gfx/d3d/d3d_wrapper.h @@ -96,6 +96,8 @@ void d3d_texture_blit(unsigned pixel_size, bool d3d_vertex_declaration_new(LPDIRECT3DDEVICE dev, const void *vertex_data, void **decl_data); +void d3d_vertex_declaration_free(void *vertex_data); + void d3d_set_viewport(LPDIRECT3DDEVICE dev, D3DVIEWPORT *vp); void d3d_enable_blend_func(void *data); diff --git a/gfx/d3d/render_chain_cg.cpp b/gfx/d3d/render_chain_cg.cpp index 7e954e0923..cde5511922 100644 --- a/gfx/d3d/render_chain_cg.cpp +++ b/gfx/d3d/render_chain_cg.cpp @@ -475,8 +475,8 @@ static bool cg_d3d9_renderchain_init_shader_fvf(void *data, void *pass_data) } } - if (FAILED(chain->dev->CreateVertexDeclaration( - decl, &pass->vertex_decl))) + if (!d3d_vertex_declaration_new(chain->dev, decl, + &pass->vertex_decl)) return false; return true; @@ -1372,6 +1372,7 @@ static void renderchain_render_pass( translate_filter(pass->info.pass->filter)); d3d_set_vertex_declaration(d3dr, pass->vertex_decl); + for (i = 0; i < 4; i++) d3d_set_stream_source(d3dr, i, pass->vertex_buf, 0, sizeof(Vertex)); diff --git a/gfx/d3d/render_chain_xdk.cpp b/gfx/d3d/render_chain_xdk.cpp index bc6260affd..3937d534d8 100644 --- a/gfx/d3d/render_chain_xdk.cpp +++ b/gfx/d3d/render_chain_xdk.cpp @@ -83,7 +83,7 @@ static bool xdk_renderchain_init_shader_fvf(void *data, void *pass_data) D3DDECL_END() }; - if (FAILED(d3dr->CreateVertexDeclaration(VertexElements, &chain->vertex_decl))) + if (!d3d_vertex_declaration_new(d3dr, VertexElements, &chain->vertex_decl)) return false; #endif From f929e9cee71f9ae75fad6eb5be189b98d41880fd Mon Sep 17 00:00:00 2001 From: twinaphex Date: Thu, 12 Nov 2015 01:55:18 +0100 Subject: [PATCH 159/216] Revert "Start using wrappers for vertex declarations" This reverts commit a09e8e0684b518aeafe915753d7b0afe1ee4b96e. --- gfx/d3d/d3d.cpp | 4 ++-- gfx/d3d/d3d_wrapper.cpp | 8 -------- gfx/d3d/d3d_wrapper.h | 2 -- gfx/d3d/render_chain_cg.cpp | 5 ++--- gfx/d3d/render_chain_xdk.cpp | 2 +- 5 files changed, 5 insertions(+), 16 deletions(-) diff --git a/gfx/d3d/d3d.cpp b/gfx/d3d/d3d.cpp index 1b8cb61d5d..b8c07dbc2f 100644 --- a/gfx/d3d/d3d.cpp +++ b/gfx/d3d/d3d.cpp @@ -1286,9 +1286,9 @@ static void d3d_overlay_render(d3d_video_t *d3d, overlay_t *overlay) d3d_enable_blend_func(d3d->dev); #ifndef _XBOX1 - d3d_vertex_declaration_new(d3d->dev, vElems, &vertex_decl); + d3d->dev->CreateVertexDeclaration(vElems, &vertex_decl); d3d_set_vertex_declaration(d3d->dev, vertex_decl); - d3d_vertex_declaration_free(vertex_decl); + vertex_decl->Release(); #endif d3d_set_stream_source(d3d->dev, 0, overlay->vert_buf, diff --git a/gfx/d3d/d3d_wrapper.cpp b/gfx/d3d/d3d_wrapper.cpp index 0f2caefb43..306691325a 100644 --- a/gfx/d3d/d3d_wrapper.cpp +++ b/gfx/d3d/d3d_wrapper.cpp @@ -117,14 +117,6 @@ bool d3d_vertex_declaration_new(LPDIRECT3DDEVICE dev, return false; } -void d3d_vertex_declaration_free(void *vertex_data) -{ -#ifndef _XBOX1 - LPDIRECT3DVERTEXDECLARATION vertex_decl = (LPDIRECT3DVERTEXDECLARATION)vertex_data; - vertex_decl->Release(); -#endif -} - LPDIRECT3DVERTEXBUFFER d3d_vertex_buffer_new(LPDIRECT3DDEVICE dev, unsigned length, unsigned usage, unsigned fvf, D3DPOOL pool, void *handle) diff --git a/gfx/d3d/d3d_wrapper.h b/gfx/d3d/d3d_wrapper.h index 9152fadea9..fddd5a3174 100644 --- a/gfx/d3d/d3d_wrapper.h +++ b/gfx/d3d/d3d_wrapper.h @@ -96,8 +96,6 @@ void d3d_texture_blit(unsigned pixel_size, bool d3d_vertex_declaration_new(LPDIRECT3DDEVICE dev, const void *vertex_data, void **decl_data); -void d3d_vertex_declaration_free(void *vertex_data); - void d3d_set_viewport(LPDIRECT3DDEVICE dev, D3DVIEWPORT *vp); void d3d_enable_blend_func(void *data); diff --git a/gfx/d3d/render_chain_cg.cpp b/gfx/d3d/render_chain_cg.cpp index cde5511922..7e954e0923 100644 --- a/gfx/d3d/render_chain_cg.cpp +++ b/gfx/d3d/render_chain_cg.cpp @@ -475,8 +475,8 @@ static bool cg_d3d9_renderchain_init_shader_fvf(void *data, void *pass_data) } } - if (!d3d_vertex_declaration_new(chain->dev, decl, - &pass->vertex_decl)) + if (FAILED(chain->dev->CreateVertexDeclaration( + decl, &pass->vertex_decl))) return false; return true; @@ -1372,7 +1372,6 @@ static void renderchain_render_pass( translate_filter(pass->info.pass->filter)); d3d_set_vertex_declaration(d3dr, pass->vertex_decl); - for (i = 0; i < 4; i++) d3d_set_stream_source(d3dr, i, pass->vertex_buf, 0, sizeof(Vertex)); diff --git a/gfx/d3d/render_chain_xdk.cpp b/gfx/d3d/render_chain_xdk.cpp index 3937d534d8..bc6260affd 100644 --- a/gfx/d3d/render_chain_xdk.cpp +++ b/gfx/d3d/render_chain_xdk.cpp @@ -83,7 +83,7 @@ static bool xdk_renderchain_init_shader_fvf(void *data, void *pass_data) D3DDECL_END() }; - if (!d3d_vertex_declaration_new(d3dr, VertexElements, &chain->vertex_decl)) + if (FAILED(d3dr->CreateVertexDeclaration(VertexElements, &chain->vertex_decl))) return false; #endif From 060a255561b236f3cef8e443c55ac6c33fe1ab15 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Thu, 12 Nov 2015 02:35:05 +0100 Subject: [PATCH 160/216] Start fleshing out d3d_construct --- gfx/d3d/d3d.cpp | 38 +++++++++++++++++++++++++++++++++++--- 1 file changed, 35 insertions(+), 3 deletions(-) diff --git a/gfx/d3d/d3d.cpp b/gfx/d3d/d3d.cpp index b8c07dbc2f..6359e91ba3 100644 --- a/gfx/d3d/d3d.cpp +++ b/gfx/d3d/d3d.cpp @@ -622,15 +622,47 @@ static bool d3d_construct(d3d_video_t *d3d, #ifndef _XBOX #ifdef HAVE_WINDOW + DWORD style; unsigned win_width, win_height; + float refresh_mod; + unsigned refresh; RECT rect = {0}; video_driver_get_size(&win_width, &win_height); - if (!info->fullscreen) + /* Windows only reports the refresh rates for modelines as + * an integer, so video.refresh_rate needs to be rounded. Also, account + * for black frame insertion using video.refresh_rate set to half + * of the display refresh rate, as well as higher vsync swap intervals. */ + refresh_mod = settings->video.black_frame_insertion ? 2.0f : 1.0f; + refresh = roundf(settings->video.refresh_rate * refresh_mod * settings->video.swap_interval); + + if (info->fullscreen) { - video_driver_get_size((unsigned*)&rect.right, (unsigned*)&rect.bottom); - AdjustWindowRect(&rect, WS_OVERLAPPEDWINDOW, FALSE); + if (windowed_full) + { + style = WS_EX_TOPMOST | WS_POPUP; + win_width = mon_rect.right - mon_rect.left; + win_height = mon_rect.bottom - mon_rect.top; + } + else + { + style = WS_POPUP | WS_VISIBLE; + + if (!set_fullscreen(win_width, win_height, refresh, current_mon.szDevice)) + goto error; + + /* Display settings might have changed, get new coordinates. */ + GetMonitorInfo(hm_to_use, (MONITORINFO*)¤t_mon); + mon_rect = current_mon.rcMonitor; + } + } + else + { + style = WS_OVERLAPPEDWINDOW | WS_CLIPSIBLINGS | WS_CLIPCHILDREN; + rect.right = win_width; + rect.bottom = win_height; + AdjustWindowRect(&rect, style, FALSE); win_width = rect.right - rect.left; win_height = rect.bottom - rect.top; } From 66727bba2e97ef71ef3fdfea9351c5f0d6471c55 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Thu, 12 Nov 2015 02:40:26 +0100 Subject: [PATCH 161/216] (D3D) More --- gfx/d3d/d3d.cpp | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/gfx/d3d/d3d.cpp b/gfx/d3d/d3d.cpp index 6359e91ba3..19a1adfc88 100644 --- a/gfx/d3d/d3d.cpp +++ b/gfx/d3d/d3d.cpp @@ -349,7 +349,7 @@ static void d3d_set_viewport(void *data, d3d->final_viewport = viewport; - if (d3d->renderchain_driver && d3d->renderchain_data) + if (d3d && d3d->renderchain_driver && d3d->renderchain_data) { if (d3d->renderchain_driver->set_font_rect) d3d->renderchain_driver->set_font_rect(d3d, NULL); @@ -650,7 +650,7 @@ static bool d3d_construct(d3d_video_t *d3d, style = WS_POPUP | WS_VISIBLE; if (!set_fullscreen(win_width, win_height, refresh, current_mon.szDevice)) - goto error; + {} /* Display settings might have changed, get new coordinates. */ GetMonitorInfo(hm_to_use, (MONITORINFO*)¤t_mon); @@ -668,8 +668,7 @@ static bool d3d_construct(d3d_video_t *d3d, } d3d->hWnd = CreateWindowEx(0, "RetroArch", "RetroArch", - info->fullscreen ? - (WS_EX_TOPMOST | WS_POPUP) : WS_OVERLAPPEDWINDOW, + style, info->fullscreen ? mon_rect.left : CW_USEDEFAULT, info->fullscreen ? mon_rect.top : CW_USEDEFAULT, win_width, win_height, From cb008b13f8042a5a88694e873e5f86f77ed42305 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Thu, 12 Nov 2015 02:45:16 +0100 Subject: [PATCH 162/216] (D3D) Use the same hwnd variable as WGL --- gfx/common/win32_common.cpp | 2 +- gfx/d3d/d3d.cpp | 28 ++++++++++++++-------------- gfx/d3d/d3d.h | 1 - gfx/drivers_context/d3d_ctx.cpp | 4 ++-- 4 files changed, 17 insertions(+), 18 deletions(-) diff --git a/gfx/common/win32_common.cpp b/gfx/common/win32_common.cpp index 7ffe175e4d..011670a02b 100644 --- a/gfx/common/win32_common.cpp +++ b/gfx/common/win32_common.cpp @@ -225,7 +225,7 @@ static LRESULT CALLBACK WndProc(HWND hwnd, UINT message, if (!strcmp(video_driver, "d3d")) { d3d_video_t *d3d = (d3d_video_t*)driver->video_data; - d3dr = d3d->hWnd; + d3dr = g_hwnd; } LRESULT ret = win32_menu_loop(d3dr, wparam); (void)ret; diff --git a/gfx/d3d/d3d.cpp b/gfx/d3d/d3d.cpp index 19a1adfc88..57d5f9e854 100644 --- a/gfx/d3d/d3d.cpp +++ b/gfx/d3d/d3d.cpp @@ -161,7 +161,7 @@ void d3d_make_d3dpp(void *data, #endif info->rgb32 ? D3DFMT_X8R8G8B8 : D3DFMT_LIN_R5G6B5; #else - d3dpp->hDeviceWindow = d3d->hWnd; + d3dpp->hDeviceWindow = g_hwnd; d3dpp->BackBufferFormat = !d3dpp->Windowed ? D3DFMT_X8R8G8B8 : D3DFMT_UNKNOWN; #endif @@ -247,7 +247,7 @@ static bool d3d_init_base(void *data, const video_info_t *info) if (FAILED(d3d->d3d_err = d3d->g_pD3D->CreateDevice( d3d->cur_mon_id, D3DDEVTYPE_HAL, - d3d->hWnd, + g_hwnd, D3DCREATE_HARDWARE_VERTEXPROCESSING, &d3dpp, &d3d->dev))) @@ -258,7 +258,7 @@ static bool d3d_init_base(void *data, const video_info_t *info) if (FAILED(d3d->d3d_err = d3d->g_pD3D->CreateDevice( d3d->cur_mon_id, D3DDEVTYPE_HAL, - d3d->hWnd, + g_hwnd, D3DCREATE_SOFTWARE_VERTEXPROCESSING, &d3dpp, &d3d->dev))) @@ -667,7 +667,7 @@ static bool d3d_construct(d3d_video_t *d3d, win_height = rect.bottom - rect.top; } - d3d->hWnd = CreateWindowEx(0, "RetroArch", "RetroArch", + g_hwnd = CreateWindowEx(0, "RetroArch", "RetroArch", style, info->fullscreen ? mon_rect.left : CW_USEDEFAULT, info->fullscreen ? mon_rect.top : CW_USEDEFAULT, @@ -676,7 +676,7 @@ static bool d3d_construct(d3d_video_t *d3d, driver->display_type = RARCH_DISPLAY_WIN32; driver->video_display = 0; - driver->video_window = (uintptr_t)d3d->hWnd; + driver->video_window = (uintptr_t)g_hwnd; #endif #endif @@ -696,16 +696,16 @@ static bool d3d_construct(d3d_video_t *d3d, { RECT rc_temp = {0, 0, (LONG)win_height, 0x7FFF}; - SetMenu(d3d->hWnd, LoadMenu(GetModuleHandle(NULL),MAKEINTRESOURCE(IDR_MENU))); - SendMessage(d3d->hWnd, WM_NCCALCSIZE, FALSE, (LPARAM)&rc_temp); + SetMenu(g_hwnd, LoadMenu(GetModuleHandle(NULL),MAKEINTRESOURCE(IDR_MENU))); + SendMessage(g_hwnd, WM_NCCALCSIZE, FALSE, (LPARAM)&rc_temp); win_height += rc_temp.top + rect.top; - SetWindowPos(d3d->hWnd, NULL, 0, 0, win_width, win_height, SWP_NOMOVE); + SetWindowPos(g_hwnd, NULL, 0, 0, win_width, win_height, SWP_NOMOVE); } - ShowWindow(d3d->hWnd, SW_RESTORE); - UpdateWindow(d3d->hWnd); - SetForegroundWindow(d3d->hWnd); - SetFocus(d3d->hWnd); + ShowWindow(g_hwnd, SW_RESTORE); + UpdateWindow(g_hwnd); + SetForegroundWindow(g_hwnd); + SetFocus(g_hwnd); } #endif @@ -890,7 +890,7 @@ static void d3d_free(void *data) d3d->g_pD3D->Release(); #ifdef HAVE_MONITOR - win32_monitor_from_window(d3d->hWnd, true); + win32_monitor_from_window(g_hwnd, true); #endif if (d3d) @@ -1528,7 +1528,7 @@ static bool d3d_frame(void *data, const void *frame, #ifndef _XBOX /* We cannot recover in fullscreen. */ - if (d3d->needs_restore && IsIconic(d3d->hWnd)) + if (d3d->needs_restore && IsIconic(g_hwnd)) return true; #endif if (d3d->needs_restore && !d3d_restore(d3d)) diff --git a/gfx/d3d/d3d.h b/gfx/d3d/d3d.h index 6d6ae91245..aeac8b959c 100644 --- a/gfx/d3d/d3d.h +++ b/gfx/d3d/d3d.h @@ -99,7 +99,6 @@ typedef struct d3d_video struct video_viewport vp; WNDCLASSEX windowClass; - HWND hWnd; LPDIRECT3D g_pD3D; LPDIRECT3DDEVICE dev; HRESULT d3d_err; diff --git a/gfx/drivers_context/d3d_ctx.cpp b/gfx/drivers_context/d3d_ctx.cpp index 2f0e3eee8e..1ab7fe2720 100644 --- a/gfx/drivers_context/d3d_ctx.cpp +++ b/gfx/drivers_context/d3d_ctx.cpp @@ -91,7 +91,7 @@ static void gfx_ctx_d3d_update_title(void *data) #ifndef _XBOX d3d_video_t *d3d = (d3d_video_t*)data; - SetWindowText(d3d->hWnd, buf); + SetWindowText(g_hwnd, buf); #endif } @@ -138,7 +138,7 @@ 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; + return GetFocus() == g_hwnd; } static bool gfx_ctx_d3d_suppress_screensaver(void *data, bool enable) From 0dce6479c116a562ae84c39f5559e47a722b3e04 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Thu, 12 Nov 2015 02:51:40 +0100 Subject: [PATCH 163/216] Create win32_window_create --- gfx/common/win32_common.cpp | 22 ++++++++++++++++++++++ gfx/common/win32_common.h | 4 ++++ gfx/d3d/d3d.cpp | 12 ++---------- gfx/drivers_context/wgl_ctx.cpp | 12 +----------- 4 files changed, 29 insertions(+), 21 deletions(-) diff --git a/gfx/common/win32_common.cpp b/gfx/common/win32_common.cpp index 011670a02b..71cad29ca8 100644 --- a/gfx/common/win32_common.cpp +++ b/gfx/common/win32_common.cpp @@ -259,6 +259,28 @@ bool win32_window_init(WNDCLASSEX *wndclass, bool fullscreen) return true; } +bool win32_window_create(void *data, unsigned style, + RECT *mon_rect, unsigned width, + unsigned height, bool fullscreen) +{ +#ifndef _XBOX + driver_t *driver = driver_get_ptr(); + g_hwnd = CreateWindowEx(0, "RetroArch", "RetroArch", + style, + info->fullscreen ? mon_rect.left : g_pos_x, + info->fullscreen ? mon_rect.top : g_pos_y, + win_width, win_height, + NULL, NULL, NULL, data); + if (!g_hwnd) + return false; + + driver->display_type = RARCH_DISPLAY_WIN32; + driver->video_display = 0; + driver->video_window = (uintptr_t)g_hwnd; +#endif + return true; +} + static bool win32_browser( HWND owner, char *filename, diff --git a/gfx/common/win32_common.h b/gfx/common/win32_common.h index 95a11c7d89..223408d614 100644 --- a/gfx/common/win32_common.h +++ b/gfx/common/win32_common.h @@ -58,6 +58,10 @@ void win32_monitor_init(void); bool win32_window_init(WNDCLASSEX *wndclass, bool fullscreen); +bool win32_window_create(void *data, unsigned style, + RECT *mon_rect, unsigned width, + unsigned height, bool fullscreen); + bool win32_suppress_screensaver(void *data, bool enable); bool win32_get_metrics(void *data, diff --git a/gfx/d3d/d3d.cpp b/gfx/d3d/d3d.cpp index 57d5f9e854..1abfe57cbe 100644 --- a/gfx/d3d/d3d.cpp +++ b/gfx/d3d/d3d.cpp @@ -667,16 +667,8 @@ static bool d3d_construct(d3d_video_t *d3d, win_height = rect.bottom - rect.top; } - g_hwnd = CreateWindowEx(0, "RetroArch", "RetroArch", - style, - info->fullscreen ? mon_rect.left : CW_USEDEFAULT, - info->fullscreen ? mon_rect.top : CW_USEDEFAULT, - win_width, win_height, - NULL, NULL, NULL, d3d); - - driver->display_type = RARCH_DISPLAY_WIN32; - driver->video_display = 0; - driver->video_window = (uintptr_t)g_hwnd; + win32_window_create(d3d, style, &mon_rect, win_width, + win_height, info->fullscreen); #endif #endif diff --git a/gfx/drivers_context/wgl_ctx.cpp b/gfx/drivers_context/wgl_ctx.cpp index c549b10676..da96d4b306 100644 --- a/gfx/drivers_context/wgl_ctx.cpp +++ b/gfx/drivers_context/wgl_ctx.cpp @@ -401,13 +401,7 @@ static bool gfx_ctx_wgl_set_video_mode(void *data, g_resize_height = height = rect.bottom - rect.top; } - g_hwnd = CreateWindowEx(0, "RetroArch", "RetroArch", style, - fullscreen ? mon_rect.left : g_pos_x, - fullscreen ? mon_rect.top : g_pos_y, - width, height, - NULL, NULL, NULL, NULL); - - if (!g_hwnd) + if (!win32_window_create(NULL, style, &mon_rect, width, height, fullscreen)) goto error; if (!fullscreen || windowed_full) @@ -443,10 +437,6 @@ static bool gfx_ctx_wgl_set_video_mode(void *data, gfx_ctx_wgl_swap_interval(data, g_interval); - driver->display_type = RARCH_DISPLAY_WIN32; - driver->video_display = 0; - driver->video_window = (uintptr_t)g_hwnd; - return true; error: From 92f68fd614f10224748b179e04b3ea9995d534d9 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Thu, 12 Nov 2015 02:53:01 +0100 Subject: [PATCH 164/216] (Win32) Buildfix --- gfx/common/win32_common.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/gfx/common/win32_common.cpp b/gfx/common/win32_common.cpp index 71cad29ca8..b6e5dd43f3 100644 --- a/gfx/common/win32_common.cpp +++ b/gfx/common/win32_common.cpp @@ -267,9 +267,9 @@ bool win32_window_create(void *data, unsigned style, driver_t *driver = driver_get_ptr(); g_hwnd = CreateWindowEx(0, "RetroArch", "RetroArch", style, - info->fullscreen ? mon_rect.left : g_pos_x, - info->fullscreen ? mon_rect.top : g_pos_y, - win_width, win_height, + fullscreen ? mon_rect->left : g_pos_x, + fullscreen ? mon_rect->top : g_pos_y, + width, height, NULL, NULL, NULL, data); if (!g_hwnd) return false; From 9961907d2ce4179b5bb4925f34fee91abbfab4df Mon Sep 17 00:00:00 2001 From: twinaphex Date: Thu, 12 Nov 2015 02:55:26 +0100 Subject: [PATCH 165/216] (Win32) Make g_pos_x/g_pos_y static --- gfx/common/win32_common.cpp | 4 ++-- gfx/common/win32_common.h | 2 -- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/gfx/common/win32_common.cpp b/gfx/common/win32_common.cpp index b6e5dd43f3..cb935141f7 100644 --- a/gfx/common/win32_common.cpp +++ b/gfx/common/win32_common.cpp @@ -44,8 +44,8 @@ bool dinput_handle_message(void *dinput, UINT message, WPARAM wParam, LPARAM lPa unsigned g_resize_width; unsigned g_resize_height; -unsigned g_pos_x = CW_USEDEFAULT; -unsigned g_pos_y = CW_USEDEFAULT; +static unsigned g_pos_x = CW_USEDEFAULT; +static unsigned g_pos_y = CW_USEDEFAULT; bool g_resized; bool g_quit; HWND g_hwnd; diff --git a/gfx/common/win32_common.h b/gfx/common/win32_common.h index 223408d614..9c95341fc5 100644 --- a/gfx/common/win32_common.h +++ b/gfx/common/win32_common.h @@ -33,8 +33,6 @@ extern unsigned g_resize_width; extern unsigned g_resize_height; -extern unsigned g_pos_x; -extern unsigned g_pos_y; extern bool g_resized; extern bool g_quit; extern HWND g_hwnd; From d2006c43c1b6024c3073e38583b7220f201efc7d Mon Sep 17 00:00:00 2001 From: twinaphex Date: Thu, 12 Nov 2015 02:57:56 +0100 Subject: [PATCH 166/216] Turn g_resized into static variable --- gfx/common/win32_common.cpp | 2 +- gfx/common/win32_common.h | 1 - 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/gfx/common/win32_common.cpp b/gfx/common/win32_common.cpp index cb935141f7..fe40272a61 100644 --- a/gfx/common/win32_common.cpp +++ b/gfx/common/win32_common.cpp @@ -46,7 +46,7 @@ unsigned g_resize_width; unsigned g_resize_height; static unsigned g_pos_x = CW_USEDEFAULT; static unsigned g_pos_y = CW_USEDEFAULT; -bool g_resized; +static bool g_resized; bool g_quit; HWND g_hwnd; diff --git a/gfx/common/win32_common.h b/gfx/common/win32_common.h index 9c95341fc5..ce500f4c0d 100644 --- a/gfx/common/win32_common.h +++ b/gfx/common/win32_common.h @@ -33,7 +33,6 @@ extern unsigned g_resize_width; extern unsigned g_resize_height; -extern bool g_resized; extern bool g_quit; extern HWND g_hwnd; From 9a82d2a956efafe7c42790a64d9242689b3b8ad6 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Thu, 12 Nov 2015 03:01:50 +0100 Subject: [PATCH 167/216] Create win32_monitor_set_fullscreen --- gfx/common/win32_common.cpp | 17 +++++++++++++++++ gfx/common/win32_common.h | 3 +++ gfx/d3d/d3d.cpp | 3 ++- gfx/drivers_context/wgl_ctx.cpp | 18 +----------------- 4 files changed, 23 insertions(+), 18 deletions(-) diff --git a/gfx/common/win32_common.cpp b/gfx/common/win32_common.cpp index fe40272a61..cb34e23d02 100644 --- a/gfx/common/win32_common.cpp +++ b/gfx/common/win32_common.cpp @@ -478,6 +478,23 @@ void win32_monitor_init(void) g_quit = false; } +bool win32_monitor_set_fullscreen(unsigned width, unsigned height, unsigned refresh, char *dev_name) +{ +#ifndef _XBOX + DEVMODE devmode; + + memset(&devmode, 0, sizeof(devmode)); + devmode.dmSize = sizeof(DEVMODE); + devmode.dmPelsWidth = width; + devmode.dmPelsHeight = height; + devmode.dmDisplayFrequency = refresh; + devmode.dmFields = DM_PELSWIDTH | DM_PELSHEIGHT | DM_DISPLAYFREQUENCY; + + RARCH_LOG("[WGL]: Setting fullscreen to %ux%u @ %uHz on device %s.\n", width, height, refresh, dev_name); + return ChangeDisplaySettingsEx(dev_name, &devmode, NULL, CDS_FULLSCREEN, NULL) == DISP_CHANGE_SUCCESSFUL; +#endif +} + void win32_show_cursor(bool state) { #ifndef _XBOX diff --git a/gfx/common/win32_common.h b/gfx/common/win32_common.h index ce500f4c0d..cd70aa8c3f 100644 --- a/gfx/common/win32_common.h +++ b/gfx/common/win32_common.h @@ -53,6 +53,9 @@ void create_gl_context(HWND hwnd); void win32_monitor_init(void); +bool win32_monitor_set_fullscreen(unsigned width, + unsigned height, unsigned refresh, char *dev_name); + bool win32_window_init(WNDCLASSEX *wndclass, bool fullscreen); bool win32_window_create(void *data, unsigned style, diff --git a/gfx/d3d/d3d.cpp b/gfx/d3d/d3d.cpp index 1abfe57cbe..33714e3613 100644 --- a/gfx/d3d/d3d.cpp +++ b/gfx/d3d/d3d.cpp @@ -649,7 +649,8 @@ static bool d3d_construct(d3d_video_t *d3d, { style = WS_POPUP | WS_VISIBLE; - if (!set_fullscreen(win_width, win_height, refresh, current_mon.szDevice)) + if (!win32_monitor_set_fullscreen(win_width, win_height, + refresh, current_mon.szDevice)) {} /* Display settings might have changed, get new coordinates. */ diff --git a/gfx/drivers_context/wgl_ctx.cpp b/gfx/drivers_context/wgl_ctx.cpp index da96d4b306..f86260f16e 100644 --- a/gfx/drivers_context/wgl_ctx.cpp +++ b/gfx/drivers_context/wgl_ctx.cpp @@ -322,22 +322,6 @@ static bool gfx_ctx_wgl_init(void *data) return true; } -static bool set_fullscreen(unsigned width, unsigned height, unsigned refresh, char *dev_name) -{ - DEVMODE devmode; - - memset(&devmode, 0, sizeof(devmode)); - devmode.dmSize = sizeof(DEVMODE); - devmode.dmPelsWidth = width; - devmode.dmPelsHeight = height; - devmode.dmDisplayFrequency = refresh; - devmode.dmFields = DM_PELSWIDTH | DM_PELSHEIGHT | DM_DISPLAYFREQUENCY; - - RARCH_LOG("[WGL]: Setting fullscreen to %ux%u @ %uHz on device %s.\n", width, height, refresh, dev_name); - return ChangeDisplaySettingsEx(dev_name, &devmode, NULL, CDS_FULLSCREEN, NULL) == DISP_CHANGE_SUCCESSFUL; -} - - static bool gfx_ctx_wgl_set_video_mode(void *data, unsigned width, unsigned height, bool fullscreen) @@ -382,7 +366,7 @@ static bool gfx_ctx_wgl_set_video_mode(void *data, { style = WS_POPUP | WS_VISIBLE; - if (!set_fullscreen(width, height, refresh, current_mon.szDevice)) + if (!win32_monitor_set_fullscreen(width, height, refresh, current_mon.szDevice)) goto error; /* Display settings might have changed, get new coordinates. */ From ad85db39657b309b23d891c3d095612c4c166e8a Mon Sep 17 00:00:00 2001 From: twinaphex Date: Thu, 12 Nov 2015 03:08:09 +0100 Subject: [PATCH 168/216] Start using g_resize_width/g_resize_height for D3D too --- gfx/d3d/d3d.cpp | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/gfx/d3d/d3d.cpp b/gfx/d3d/d3d.cpp index 33714e3613..7c6088409f 100644 --- a/gfx/d3d/d3d.cpp +++ b/gfx/d3d/d3d.cpp @@ -604,6 +604,8 @@ static bool d3d_construct(d3d_video_t *d3d, win32_monitor_info(¤t_mon, &hm_to_use, &d3d->cur_mon_id); mon_rect = current_mon.rcMonitor; + g_resize_width = info->width; + g_resize_height = info->height; windowed_full = settings->video.windowed_fullscreen; @@ -642,8 +644,8 @@ static bool d3d_construct(d3d_video_t *d3d, if (windowed_full) { style = WS_EX_TOPMOST | WS_POPUP; - win_width = mon_rect.right - mon_rect.left; - win_height = mon_rect.bottom - mon_rect.top; + g_resize_width = win_width = mon_rect.right - mon_rect.left; + g_resize_height = win_height = mon_rect.bottom - mon_rect.top; } else { @@ -664,8 +666,8 @@ static bool d3d_construct(d3d_video_t *d3d, rect.right = win_width; rect.bottom = win_height; AdjustWindowRect(&rect, style, FALSE); - win_width = rect.right - rect.left; - win_height = rect.bottom - rect.top; + g_resize_width = win_width = rect.right - rect.left; + g_resize_height = win_height = rect.bottom - rect.top; } win32_window_create(d3d, style, &mon_rect, win_width, From d3efdf8e5ab969124cbb3f7b2d515446640bda9c Mon Sep 17 00:00:00 2001 From: twinaphex Date: Thu, 12 Nov 2015 05:14:09 +0100 Subject: [PATCH 169/216] Move g_restore_desktop to win32_common --- gfx/common/win32_common.cpp | 1 + gfx/common/win32_common.h | 1 + gfx/drivers_context/wgl_ctx.cpp | 2 -- 3 files changed, 2 insertions(+), 2 deletions(-) diff --git a/gfx/common/win32_common.cpp b/gfx/common/win32_common.cpp index cb34e23d02..e10840ca42 100644 --- a/gfx/common/win32_common.cpp +++ b/gfx/common/win32_common.cpp @@ -44,6 +44,7 @@ bool dinput_handle_message(void *dinput, UINT message, WPARAM wParam, LPARAM lPa unsigned g_resize_width; unsigned g_resize_height; +bool g_restore_desktop; static unsigned g_pos_x = CW_USEDEFAULT; static unsigned g_pos_y = CW_USEDEFAULT; static bool g_resized; diff --git a/gfx/common/win32_common.h b/gfx/common/win32_common.h index cd70aa8c3f..43c149303b 100644 --- a/gfx/common/win32_common.h +++ b/gfx/common/win32_common.h @@ -34,6 +34,7 @@ extern unsigned g_resize_width; extern unsigned g_resize_height; extern bool g_quit; +extern bool g_restore_desktop; extern HWND g_hwnd; LRESULT win32_handle_keyboard_event(HWND hwnd, UINT message, diff --git a/gfx/drivers_context/wgl_ctx.cpp b/gfx/drivers_context/wgl_ctx.cpp index f86260f16e..6147e53727 100644 --- a/gfx/drivers_context/wgl_ctx.cpp +++ b/gfx/drivers_context/wgl_ctx.cpp @@ -77,8 +77,6 @@ static unsigned g_interval; static dylib_t dll_handle = NULL; /* Handle to OpenGL32.dll */ -static bool g_restore_desktop; - static void gfx_ctx_wgl_destroy(void *data); static BOOL (APIENTRY *p_swap_interval)(int); From 105236a543e3ea73cb4fdcf576aba01666a26f30 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Thu, 12 Nov 2015 05:16:06 +0100 Subject: [PATCH 170/216] Create win32_set_video_mode --- gfx/common/win32_common.cpp | 100 ++++++++++++++++++++++++++++++++ gfx/common/win32_common.h | 4 ++ gfx/drivers_context/wgl_ctx.cpp | 90 +--------------------------- 3 files changed, 105 insertions(+), 89 deletions(-) diff --git a/gfx/common/win32_common.cpp b/gfx/common/win32_common.cpp index e10840ca42..8e0a78000f 100644 --- a/gfx/common/win32_common.cpp +++ b/gfx/common/win32_common.cpp @@ -569,3 +569,103 @@ bool win32_suppress_screensaver(void *data, bool enable) return false; #endif } + +bool win32_set_video_mode(void *data, + unsigned width, unsigned height, + bool fullscreen) +{ +#ifndef _XBOX + DWORD style; + MSG msg; + RECT mon_rect; + unsigned mon_id; + MONITORINFOEX current_mon; + float refresh_mod; + unsigned refresh; + bool windowed_full; + RECT rect = {0}; + HMONITOR hm_to_use = NULL; + driver_t *driver = driver_get_ptr(); + settings_t *settings = config_get_ptr(); + + win32_monitor_info(¤t_mon, &hm_to_use, &mon_id); + + mon_rect = current_mon.rcMonitor; + g_resize_width = width; + g_resize_height = height; + + /* Windows only reports the refresh rates for modelines as + * an integer, so video.refresh_rate needs to be rounded. Also, account + * for black frame insertion using video.refresh_rate set to half + * of the display refresh rate, as well as higher vsync swap intervals. */ + refresh_mod = settings->video.black_frame_insertion ? 2.0f : 1.0f; + refresh = roundf(settings->video.refresh_rate * refresh_mod * settings->video.swap_interval); + + windowed_full = settings->video.windowed_fullscreen; + + if (fullscreen) + { + if (windowed_full) + { + style = WS_EX_TOPMOST | WS_POPUP; + g_resize_width = width = mon_rect.right - mon_rect.left; + g_resize_height = height = mon_rect.bottom - mon_rect.top; + } + else + { + style = WS_POPUP | WS_VISIBLE; + + if (!win32_monitor_set_fullscreen(width, height, refresh, current_mon.szDevice)) + goto error; + + /* Display settings might have changed, get new coordinates. */ + GetMonitorInfo(hm_to_use, (MONITORINFO*)¤t_mon); + mon_rect = current_mon.rcMonitor; + g_restore_desktop = true; + } + } + else + { + style = WS_OVERLAPPEDWINDOW | WS_CLIPSIBLINGS | WS_CLIPCHILDREN; + rect.right = width; + rect.bottom = height; + AdjustWindowRect(&rect, style, FALSE); + g_resize_width = width = rect.right - rect.left; + g_resize_height = height = rect.bottom - rect.top; + } + + if (!win32_window_create(NULL, style, &mon_rect, width, height, fullscreen)) + goto error; + + if (!fullscreen || windowed_full) + { + if (!fullscreen && settings->ui.menubar_enable) + { + RECT rc_temp = {0, 0, (LONG)height, 0x7FFF}; + SetMenu(g_hwnd, LoadMenu(GetModuleHandle(NULL),MAKEINTRESOURCE(IDR_MENU))); + SendMessage(g_hwnd, WM_NCCALCSIZE, FALSE, (LPARAM)&rc_temp); + g_resize_height = height += rc_temp.top + rect.top; + SetWindowPos(g_hwnd, NULL, 0, 0, width, height, SWP_NOMOVE); + } + + ShowWindow(g_hwnd, SW_RESTORE); + UpdateWindow(g_hwnd); + SetForegroundWindow(g_hwnd); + SetFocus(g_hwnd); + } + + win32_show_cursor(!fullscreen); + + /* Wait until context is created (or failed to do so ...) */ + while (!g_inited && !g_quit && GetMessage(&msg, g_hwnd, 0, 0)) + { + TranslateMessage(&msg); + DispatchMessage(&msg); + } + + if (g_quit) + return false; +#endif + + return true; +} diff --git a/gfx/common/win32_common.h b/gfx/common/win32_common.h index 43c149303b..9870c9f3c9 100644 --- a/gfx/common/win32_common.h +++ b/gfx/common/win32_common.h @@ -54,6 +54,10 @@ void create_gl_context(HWND hwnd); void win32_monitor_init(void); +bool win32_set_video_mode(void *data, + unsigned width, unsigned height, + bool fullscreen) + bool win32_monitor_set_fullscreen(unsigned width, unsigned height, unsigned refresh, char *dev_name); diff --git a/gfx/drivers_context/wgl_ctx.cpp b/gfx/drivers_context/wgl_ctx.cpp index 6147e53727..640cc84d1e 100644 --- a/gfx/drivers_context/wgl_ctx.cpp +++ b/gfx/drivers_context/wgl_ctx.cpp @@ -324,95 +324,7 @@ static bool gfx_ctx_wgl_set_video_mode(void *data, unsigned width, unsigned height, bool fullscreen) { - DWORD style; - MSG msg; - RECT mon_rect; - unsigned mon_id; - MONITORINFOEX current_mon; - float refresh_mod; - unsigned refresh; - bool windowed_full; - RECT rect = {0}; - HMONITOR hm_to_use = NULL; - driver_t *driver = driver_get_ptr(); - settings_t *settings = config_get_ptr(); - - win32_monitor_info(¤t_mon, &hm_to_use, &mon_id); - - mon_rect = current_mon.rcMonitor; - g_resize_width = width; - g_resize_height = height; - - /* Windows only reports the refresh rates for modelines as - * an integer, so video.refresh_rate needs to be rounded. Also, account - * for black frame insertion using video.refresh_rate set to half - * of the display refresh rate, as well as higher vsync swap intervals. */ - refresh_mod = settings->video.black_frame_insertion ? 2.0f : 1.0f; - refresh = roundf(settings->video.refresh_rate * refresh_mod * settings->video.swap_interval); - - windowed_full = settings->video.windowed_fullscreen; - - if (fullscreen) - { - if (windowed_full) - { - style = WS_EX_TOPMOST | WS_POPUP; - g_resize_width = width = mon_rect.right - mon_rect.left; - g_resize_height = height = mon_rect.bottom - mon_rect.top; - } - else - { - style = WS_POPUP | WS_VISIBLE; - - if (!win32_monitor_set_fullscreen(width, height, refresh, current_mon.szDevice)) - goto error; - - /* Display settings might have changed, get new coordinates. */ - GetMonitorInfo(hm_to_use, (MONITORINFO*)¤t_mon); - mon_rect = current_mon.rcMonitor; - g_restore_desktop = true; - } - } - else - { - style = WS_OVERLAPPEDWINDOW | WS_CLIPSIBLINGS | WS_CLIPCHILDREN; - rect.right = width; - rect.bottom = height; - AdjustWindowRect(&rect, style, FALSE); - g_resize_width = width = rect.right - rect.left; - g_resize_height = height = rect.bottom - rect.top; - } - - if (!win32_window_create(NULL, style, &mon_rect, width, height, fullscreen)) - goto error; - - if (!fullscreen || windowed_full) - { - if (!fullscreen && settings->ui.menubar_enable) - { - RECT rc_temp = {0, 0, (LONG)height, 0x7FFF}; - SetMenu(g_hwnd, LoadMenu(GetModuleHandle(NULL),MAKEINTRESOURCE(IDR_MENU))); - SendMessage(g_hwnd, WM_NCCALCSIZE, FALSE, (LPARAM)&rc_temp); - g_resize_height = height += rc_temp.top + rect.top; - SetWindowPos(g_hwnd, NULL, 0, 0, width, height, SWP_NOMOVE); - } - - ShowWindow(g_hwnd, SW_RESTORE); - UpdateWindow(g_hwnd); - SetForegroundWindow(g_hwnd); - SetFocus(g_hwnd); - } - - win32_show_cursor(!fullscreen); - - /* Wait until GL context is created (or failed to do so ...) */ - while (!g_inited && !g_quit && GetMessage(&msg, g_hwnd, 0, 0)) - { - TranslateMessage(&msg); - DispatchMessage(&msg); - } - - if (g_quit) + if (!win32_set_video_mode(data, width, height, fullscreen)) goto error; p_swap_interval = (BOOL (APIENTRY *)(int))wglGetProcAddress("wglSwapIntervalEXT"); From 8d0e375de0b23e15af95ecc34e43ad2f1e5b7025 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Thu, 12 Nov 2015 05:17:21 +0100 Subject: [PATCH 171/216] (Win32) Buildfixes --- gfx/common/win32_common.cpp | 1 + gfx/common/win32_common.h | 3 ++- gfx/drivers_context/wgl_ctx.cpp | 1 - 3 files changed, 3 insertions(+), 2 deletions(-) diff --git a/gfx/common/win32_common.cpp b/gfx/common/win32_common.cpp index 8e0a78000f..4fdad8f3cf 100644 --- a/gfx/common/win32_common.cpp +++ b/gfx/common/win32_common.cpp @@ -48,6 +48,7 @@ bool g_restore_desktop; static unsigned g_pos_x = CW_USEDEFAULT; static unsigned g_pos_y = CW_USEDEFAULT; static bool g_resized; +bool g_inited; bool g_quit; HWND g_hwnd; diff --git a/gfx/common/win32_common.h b/gfx/common/win32_common.h index 9870c9f3c9..f9c4015c18 100644 --- a/gfx/common/win32_common.h +++ b/gfx/common/win32_common.h @@ -34,6 +34,7 @@ extern unsigned g_resize_width; extern unsigned g_resize_height; extern bool g_quit; +extern bool g_inited; extern bool g_restore_desktop; extern HWND g_hwnd; @@ -56,7 +57,7 @@ void win32_monitor_init(void); bool win32_set_video_mode(void *data, unsigned width, unsigned height, - bool fullscreen) + bool fullscreen); bool win32_monitor_set_fullscreen(unsigned width, unsigned height, unsigned refresh, char *dev_name); diff --git a/gfx/drivers_context/wgl_ctx.cpp b/gfx/drivers_context/wgl_ctx.cpp index 640cc84d1e..9eca74682e 100644 --- a/gfx/drivers_context/wgl_ctx.cpp +++ b/gfx/drivers_context/wgl_ctx.cpp @@ -72,7 +72,6 @@ static HDC g_hdc; static unsigned g_major; static unsigned g_minor; -static bool g_inited; static unsigned g_interval; static dylib_t dll_handle = NULL; /* Handle to OpenGL32.dll */ From d4f1b6d14a37b52c76dcd5cb3fa55f8f026f75c0 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Thu, 12 Nov 2015 05:18:13 +0100 Subject: [PATCH 172/216] (Win32) Another buildfix --- gfx/common/win32_common.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gfx/common/win32_common.cpp b/gfx/common/win32_common.cpp index 4fdad8f3cf..b461b8b87a 100644 --- a/gfx/common/win32_common.cpp +++ b/gfx/common/win32_common.cpp @@ -617,7 +617,7 @@ bool win32_set_video_mode(void *data, style = WS_POPUP | WS_VISIBLE; if (!win32_monitor_set_fullscreen(width, height, refresh, current_mon.szDevice)) - goto error; + return false; /* Display settings might have changed, get new coordinates. */ GetMonitorInfo(hm_to_use, (MONITORINFO*)¤t_mon); From 95c1d4d53b6ef06f69cfa91cc36ee01fdacf94b3 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Thu, 12 Nov 2015 05:19:00 +0100 Subject: [PATCH 173/216] (Win32) Blind coding sure sucks --- gfx/common/win32_common.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gfx/common/win32_common.cpp b/gfx/common/win32_common.cpp index b461b8b87a..f68e1d48b1 100644 --- a/gfx/common/win32_common.cpp +++ b/gfx/common/win32_common.cpp @@ -636,7 +636,7 @@ bool win32_set_video_mode(void *data, } if (!win32_window_create(NULL, style, &mon_rect, width, height, fullscreen)) - goto error; + return false; if (!fullscreen || windowed_full) { From 4f37c1a487441227abf30dabda24d0d8f2ad77fd Mon Sep 17 00:00:00 2001 From: twinaphex Date: Thu, 12 Nov 2015 05:39:55 +0100 Subject: [PATCH 174/216] d3d_construct - some cleanups --- gfx/d3d/d3d.cpp | 24 ++++-------------------- 1 file changed, 4 insertions(+), 20 deletions(-) diff --git a/gfx/d3d/d3d.cpp b/gfx/d3d/d3d.cpp index 7c6088409f..2e69d3ab25 100644 --- a/gfx/d3d/d3d.cpp +++ b/gfx/d3d/d3d.cpp @@ -626,18 +626,15 @@ static bool d3d_construct(d3d_video_t *d3d, #ifdef HAVE_WINDOW DWORD style; unsigned win_width, win_height; - float refresh_mod; - unsigned refresh; RECT rect = {0}; - - video_driver_get_size(&win_width, &win_height); - /* Windows only reports the refresh rates for modelines as * an integer, so video.refresh_rate needs to be rounded. Also, account * for black frame insertion using video.refresh_rate set to half * of the display refresh rate, as well as higher vsync swap intervals. */ - refresh_mod = settings->video.black_frame_insertion ? 2.0f : 1.0f; - refresh = roundf(settings->video.refresh_rate * refresh_mod * settings->video.swap_interval); + float refresh_mod = settings->video.black_frame_insertion ? 2.0f : 1.0f; + unsigned refresh = roundf(settings->video.refresh_rate * refresh_mod * settings->video.swap_interval); + + video_driver_get_size(&win_width, &win_height); if (info->fullscreen) { @@ -672,19 +669,7 @@ static bool d3d_construct(d3d_video_t *d3d, win32_window_create(d3d, style, &mon_rect, win_width, win_height, info->fullscreen); -#endif -#endif - gfx_ctx_show_mouse(d3d, !info->fullscreen -#ifdef HAVE_OVERLAY - || d3d->overlays_enabled -#endif - ); - - -#ifndef _XBOX - -#ifdef HAVE_WINDOW if (!info->fullscreen || windowed_full) { if (!info->fullscreen && settings->ui.menubar_enable) @@ -719,7 +704,6 @@ static bool d3d_construct(d3d_video_t *d3d, if (!d3d_process_shader(d3d)) return false; #endif - #endif d3d->video_info = *info; From 3e85aefb809a769720a8da8fdde41298f95cc6f0 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Thu, 12 Nov 2015 05:45:46 +0100 Subject: [PATCH 175/216] (D3D) Update --- gfx/d3d/d3d.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gfx/d3d/d3d.cpp b/gfx/d3d/d3d.cpp index 2e69d3ab25..d6384a7521 100644 --- a/gfx/d3d/d3d.cpp +++ b/gfx/d3d/d3d.cpp @@ -678,7 +678,7 @@ static bool d3d_construct(d3d_video_t *d3d, SetMenu(g_hwnd, LoadMenu(GetModuleHandle(NULL),MAKEINTRESOURCE(IDR_MENU))); SendMessage(g_hwnd, WM_NCCALCSIZE, FALSE, (LPARAM)&rc_temp); - win_height += rc_temp.top + rect.top; + g_resize_height = win_height += rc_temp.top + rect.top; SetWindowPos(g_hwnd, NULL, 0, 0, win_width, win_height, SWP_NOMOVE); } From 9e0a86e446bfd27ab7f4b127f1d05107af5343b1 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Thu, 12 Nov 2015 06:13:23 +0100 Subject: [PATCH 176/216] Start ifdeffing some of the icade/small keyboard code for iOS --- input/drivers_keyboard/keyboard_event_apple.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/input/drivers_keyboard/keyboard_event_apple.c b/input/drivers_keyboard/keyboard_event_apple.c index 9f643a18e7..1f4d28e4d3 100644 --- a/input/drivers_keyboard/keyboard_event_apple.c +++ b/input/drivers_keyboard/keyboard_event_apple.c @@ -49,6 +49,7 @@ static const unsigned char MAC_NATIVE_TO_HID[128] = { #define HIDKEY(X) (X < 128) ? MAC_NATIVE_TO_HID[X] : 0 #endif +#if TARGET_OS_IPHONE static bool handle_small_keyboard(unsigned* code, bool down) { static uint8_t mapping[128]; @@ -125,8 +126,7 @@ static void handle_icade_event(unsigned keycode) driver_t *driver = driver_get_ptr(); cocoa_input_data_t *apple = (cocoa_input_data_t*)driver->input_data; - if (apple->icade_enabled && (keycode < 0x20) - && (icade_map[keycode].button >= 0)) + if ((keycode < 0x20) && (icade_map[keycode].button >= 0)) { const int button = icade_map[keycode].button; @@ -136,6 +136,7 @@ static void handle_icade_event(unsigned keycode) BIT32_SET(apple->icade_buttons, button); } } +#endif void cocoa_input_keyboard_event(bool down, unsigned code, uint32_t character, uint32_t mod, unsigned device) @@ -148,15 +149,14 @@ void cocoa_input_keyboard_event(bool down, code = HIDKEY(code); +#if TARGET_OS_IPHONE if (apple->icade_enabled) - { handle_icade_event(code); - return; - } if (apple->small_keyboard_enabled && - handle_small_keyboard(&code, down)) + handle_small_keyboard(&code, down)) character = 0; +#endif if (code == 0 || code >= MAX_KEYS) return; From 08a343fbd044557a97214349e41aa54a8dd86405 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Thu, 12 Nov 2015 06:15:28 +0100 Subject: [PATCH 177/216] More iOS ifdefs --- input/drivers/cocoa_input.c | 6 ++++++ input/drivers/cocoa_input.h | 7 ++++++- 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/input/drivers/cocoa_input.c b/input/drivers/cocoa_input.c index 61c459545d..862503f51d 100644 --- a/input/drivers/cocoa_input.c +++ b/input/drivers/cocoa_input.c @@ -125,6 +125,7 @@ const struct apple_key_name_map_entry apple_key_name_map[] = { "nul", 0x00}, }; +#if TARGET_OS_IPHONE void cocoa_input_enable_small_keyboard(bool on) { driver_t *driver = driver_get_ptr(); @@ -153,6 +154,7 @@ void cocoa_input_reset_icade_buttons(void) if (apple) apple->icade_buttons = 0; } +#endif int32_t cocoa_input_find_any_key(void) { @@ -177,8 +179,10 @@ static int cocoa_input_find_any_button_ret(cocoa_input_data_t *apple, unsigned buttons, unsigned port) { unsigned i; +#if TARGET_OS_IPHONE if (port == 0 && apple->icade_enabled) BIT32_SET(buttons, apple->icade_buttons); +#endif if (buttons) for (i = 0; i < 32; i++) @@ -277,8 +281,10 @@ static void cocoa_input_poll(void *data) if (apple->joypad) apple->joypad->poll(); +#if TARGET_OS_IPHONE if (apple->icade_enabled) BIT32_SET(apple->buttons[0], apple->icade_buttons); +#endif apple->mouse_x_last = apple->mouse_rel_x; apple->mouse_y_last = apple->mouse_rel_y; diff --git a/input/drivers/cocoa_input.h b/input/drivers/cocoa_input.h index be4553c2fa..da565b0863 100644 --- a/input/drivers/cocoa_input.h +++ b/input/drivers/cocoa_input.h @@ -55,23 +55,28 @@ typedef struct uint32_t key_state[MAX_KEYS]; uint32_t buttons[MAX_USERS]; - uint32_t mfi_buttons[MAX_USERS]; int16_t axes[MAX_USERS][4]; int8_t hats[NUM_HATS][2]; +#if TARGET_OS_IPHONE + uint32_t mfi_buttons[MAX_USERS]; + bool icade_enabled; bool small_keyboard_enabled; bool small_keyboard_active; uint32_t icade_buttons; +#endif const input_device_driver_t *joypad; } cocoa_input_data_t; +#if TARGET_OS_IPHONE void cocoa_input_enable_icade(bool on); void cocoa_input_enable_small_keyboard(bool on); void cocoa_input_reset_icade_buttons(void); +#endif #ifdef __cplusplus extern "C" { From 6ea11afe28411920084afae59431a8d2fb13a394 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Thu, 12 Nov 2015 06:28:05 +0100 Subject: [PATCH 178/216] (iOS) Add Small Keyboard/iCade Enable options --- configuration.c | 14 ++++++++++ configuration.h | 5 ++++ input/drivers_keyboard/keyboard_event_apple.c | 6 ++-- menu/intl/menu_hash_us.c | 8 ++++++ menu/menu_hash.h | 6 ++++ menu/menu_setting.c | 28 +++++++++++++++++++ ui/drivers/ui_cocoatouch.m | 9 +++--- 7 files changed, 69 insertions(+), 7 deletions(-) diff --git a/configuration.c b/configuration.c index 1a0c50dbd8..327a1f1a3d 100644 --- a/configuration.c +++ b/configuration.c @@ -460,6 +460,10 @@ static void config_set_defaults(void) settings->history_list_enable = def_history_list_enable; settings->load_dummy_on_core_shutdown = load_dummy_on_core_shutdown; +#if TARGET_OS_IPHONE + settings->input.icade_enable = true; + settings->input.small_keyboard_enable = false; +#endif #ifdef HAVE_FFMPEG settings->multimedia.builtin_mediaplayer_enable = true; #else @@ -1571,6 +1575,11 @@ static bool config_load_file(const char *path, bool set_defaults) CONFIG_GET_BOOL_BASE(conf, global, perfcnt_enable, "perfcnt_enable"); +#if TARGET_OS_IPHONE + CONFIG_GET_BOOL_BASE(conf, settings, input.small_keyboard_enable, "small_keyboard_enable"); + CONFIG_GET_BOOL_BASE(conf, settings, input.icade_enable, "icade_enable"); +#endif + config_get_path(conf, "recording_output_directory", global->record.output_dir, sizeof(global->record.output_dir)); config_get_path(conf, "recording_config_directory", global->record.config_dir, @@ -2780,6 +2789,11 @@ bool config_save_file(const char *path) config_set_bool(conf, "log_verbosity", global->verbosity); config_set_bool(conf, "perfcnt_enable", global->perfcnt_enable); +#if TARGET_OS_IPHONE + config_set_bool(conf, "small_keyboard_enable", settings->input.small_keyboard_enable); + config_set_bool(conf, "icade_enable", settings->input.icade_enable); +#endif + config_set_bool(conf, "core_set_supports_no_game_enable", settings->core.set_supports_no_game_enable); diff --git a/configuration.h b/configuration.h index a1026560ce..40946f11ac 100644 --- a/configuration.h +++ b/configuration.h @@ -250,6 +250,11 @@ typedef struct settings unsigned menu_toggle_gamepad_combo; bool back_as_menu_toggle_enable; + +#if TARGET_OS_IPHONE + bool icade_enable; + bool small_keyboard_enable; +#endif } input; struct diff --git a/input/drivers_keyboard/keyboard_event_apple.c b/input/drivers_keyboard/keyboard_event_apple.c index 1f4d28e4d3..e75545d7ed 100644 --- a/input/drivers_keyboard/keyboard_event_apple.c +++ b/input/drivers_keyboard/keyboard_event_apple.c @@ -151,9 +151,11 @@ void cocoa_input_keyboard_event(bool down, #if TARGET_OS_IPHONE if (apple->icade_enabled) + { handle_icade_event(code); - - if (apple->small_keyboard_enabled && + return; + } + else if (apple->small_keyboard_enabled && handle_small_keyboard(&code, down)) character = 0; #endif diff --git a/menu/intl/menu_hash_us.c b/menu/intl/menu_hash_us.c index 744fd063e5..f84aff0183 100644 --- a/menu/intl/menu_hash_us.c +++ b/menu/intl/menu_hash_us.c @@ -26,6 +26,10 @@ static const char *menu_hash_to_str_us_label(uint32_t hash) { switch (hash) { + case MENU_LABEL_INPUT_ICADE_ENABLE: + return "input_icade_enable"; + case MENU_LABEL_INPUT_SMALL_KEYBOARD_ENABLE: + return "input_small_keyboard_enable"; case MENU_LABEL_SAVE_CURRENT_CONFIG: return "save_current_config"; case MENU_LABEL_STATE_SLOT: @@ -690,6 +694,10 @@ const char *menu_hash_to_str_us(uint32_t hash) switch (hash) { + case MENU_LABEL_VALUE_INPUT_ICADE_ENABLE: + return "iCade Enable"; + case MENU_LABEL_VALUE_INPUT_SMALL_KEYBOARD_ENABLE: + return "Small Keyboard Enable"; case MENU_LABEL_VALUE_SAVE_CURRENT_CONFIG: return "Save Current Config"; case MENU_LABEL_VALUE_STATE_SLOT: diff --git a/menu/menu_hash.h b/menu/menu_hash.h index 400b027eb2..ea27bd774a 100644 --- a/menu/menu_hash.h +++ b/menu/menu_hash.h @@ -1077,6 +1077,12 @@ extern "C" { #define MENU_LABEL_SAVE_CURRENT_CONFIG 0x8840ba8bU #define MENU_LABEL_VALUE_SAVE_CURRENT_CONFIG 0x9a1eb42dU +#define MENU_LABEL_INPUT_SMALL_KEYBOARD_ENABLE 0xe6736fc3U +#define MENU_LABEL_VALUE_INPUT_SMALL_KEYBOARD_ENABLE 0xc5eefd76U + +#define MENU_LABEL_INPUT_ICADE_ENABLE 0xcd534dd0U +#define MENU_LABEL_VALUE_INPUT_ICADE_ENABLE 0x67b18ee2U + const char *menu_hash_to_str_de(uint32_t hash); int menu_hash_get_help_de(uint32_t hash, char *s, size_t len); diff --git a/menu/menu_setting.c b/menu/menu_setting.c index a2f0449212..f3f7290ec2 100644 --- a/menu/menu_setting.c +++ b/menu/menu_setting.c @@ -4931,6 +4931,34 @@ static bool setting_append_list_input_options( general_read_handler); menu_settings_list_current_add_range(list, list_info, 1, MAX_USERS, 1, true, true); +#if TARGET_OS_IPHONE + CONFIG_BOOL( + settings->input.icade_enable, + menu_hash_to_str(MENU_LABEL_INPUT_ICADE_ENABLE), + menu_hash_to_str(MENU_LABEL_VALUE_INPUT_ICADE_ENABLE), + true, + menu_hash_to_str(MENU_VALUE_OFF), + menu_hash_to_str(MENU_VALUE_ON), + group_info.name, + subgroup_info.name, + parent_group, + general_write_handler, + general_read_handler); + + CONFIG_BOOL( + settings->input.small_keyboard_enable, + menu_hash_to_str(MENU_LABEL_INPUT_SMALL_KEYBOARD_ENABLE), + menu_hash_to_str(MENU_LABEL_VALUE_INPUT_SMALL_KEYBOARD_ENABLE), + false, + menu_hash_to_str(MENU_VALUE_OFF), + menu_hash_to_str(MENU_VALUE_ON), + group_info.name, + subgroup_info.name, + parent_group, + general_write_handler, + general_read_handler); +#endif + #ifdef ANDROID CONFIG_BOOL( settings->input.back_as_menu_toggle_enable, diff --git a/ui/drivers/ui_cocoatouch.m b/ui/drivers/ui_cocoatouch.m index 368db72df8..1fefa43c43 100644 --- a/ui/drivers/ui_cocoatouch.m +++ b/ui/drivers/ui_cocoatouch.m @@ -390,7 +390,8 @@ enum - (void)refreshSystemConfig { - bool small_keyboard, is_icade, is_btstack; + settings_t *settings = config_get_ptr(); + bool is_btstack; /* Get enabled orientations */ apple_frontend_settings.orientation_flags = UIInterfaceOrientationMaskAll; @@ -401,12 +402,10 @@ enum apple_frontend_settings.orientation_flags = UIInterfaceOrientationMaskPortrait | UIInterfaceOrientationMaskPortraitUpsideDown; /* Set bluetooth mode */ - small_keyboard = !(strcmp(apple_frontend_settings.bluetooth_mode, "small_keyboard")); - is_icade = !(strcmp(apple_frontend_settings.bluetooth_mode, "icade")); is_btstack = !(strcmp(apple_frontend_settings.bluetooth_mode, "btstack")); - cocoa_input_enable_small_keyboard(small_keyboard); - cocoa_input_enable_icade(is_icade); + cocoa_input_enable_small_keyboard(settings->input.small_keyboard_enable); + cocoa_input_enable_icade(settings->input.icade_enable); btstack_set_poweron(is_btstack); } From 891de78611aef955b9da69018cd0cc51da9632aa Mon Sep 17 00:00:00 2001 From: aliaspider Date: Thu, 12 Nov 2015 14:53:46 +0100 Subject: [PATCH 179/216] enable selecting a video filter when HAVE_FILTERS_BUILTIN is defined. this still requires *.filt files to work. Todo: generate the filter list from the internal soft_plugs_builtin struct. --- menu/menu_setting.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/menu/menu_setting.c b/menu/menu_setting.c index a2f0449212..a4db56e43d 100644 --- a/menu/menu_setting.c +++ b/menu/menu_setting.c @@ -4515,7 +4515,6 @@ static bool setting_append_list_video_options( EVENT_CMD_VIDEO_APPLY_STATE_CHANGES); #endif -#ifndef HAVE_FILTERS_BUILTIN CONFIG_PATH( settings->video.softfilter_plugin, menu_hash_to_str(MENU_LABEL_VIDEO_FILTER), @@ -4529,7 +4528,6 @@ static bool setting_append_list_video_options( menu_settings_list_current_add_values(list, list_info, "filt"); menu_settings_list_current_add_cmd(list, list_info, EVENT_CMD_REINIT); settings_data_list_current_add_flags(list, list_info, SD_FLAG_ALLOW_EMPTY); -#endif #ifdef _XBOX1 CONFIG_UINT( From 8cb98acbd2ace9f4db3da833393b561002290fd7 Mon Sep 17 00:00:00 2001 From: aliaspider Date: Thu, 12 Nov 2015 14:54:56 +0100 Subject: [PATCH 180/216] fix video filters when built without HAVE_THREADS. --- gfx/video_filter.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gfx/video_filter.c b/gfx/video_filter.c index c8e2526f61..dca43bd448 100644 --- a/gfx/video_filter.c +++ b/gfx/video_filter.c @@ -216,6 +216,7 @@ static bool create_softfilter_graph(rarch_softfilter_t *filt, return false; } + filt->threads = threads; RARCH_LOG("Using %u threads for softfilter.\n", threads); filt->packets = (struct softfilter_work_packet*) @@ -231,7 +232,6 @@ static bool create_softfilter_graph(rarch_softfilter_t *filt, calloc(threads, sizeof(*filt->thread_data)); if (!filt->thread_data) return false; - filt->threads = threads; for (i = 0; i < threads; i++) { From 75b57f1567a7c758694ef0bec33902e4752ca0e6 Mon Sep 17 00:00:00 2001 From: aliaspider Date: Thu, 12 Nov 2015 14:57:26 +0100 Subject: [PATCH 181/216] (3ds) improve performance when using video filters by allocating the output buffer in linear memory. --- gfx/video_driver.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/gfx/video_driver.c b/gfx/video_driver.c index 00a96f0e45..1bdc9435f1 100644 --- a/gfx/video_driver.c +++ b/gfx/video_driver.c @@ -285,7 +285,11 @@ bool video_driver_set_shader(enum rarch_shader_type type, static void deinit_video_filter(void) { rarch_softfilter_free(video_state.filter.filter); +#ifdef _3DS + linearFree(video_state.filter.buffer); +#else free(video_state.filter.buffer); +#endif memset(&video_state.filter, 0, sizeof(video_state.filter)); } @@ -344,7 +348,11 @@ static void init_video_filter(enum retro_pixel_format colfmt) sizeof(uint32_t) : sizeof(uint16_t); /* TODO: Aligned output. */ +#ifdef _3DS + video_state.filter.buffer = linearMemAlign(width * height * video_state.filter.out_bpp, 0x80); +#else video_state.filter.buffer = malloc(width * height * video_state.filter.out_bpp); +#endif if (!video_state.filter.buffer) goto error; From 13699280b4409a682e9d74b21c6a482f0225211c Mon Sep 17 00:00:00 2001 From: aliaspider Date: Thu, 12 Nov 2015 15:00:53 +0100 Subject: [PATCH 182/216] (3ds) video driver: - fix frame dupes - bypass DMA for small frames. --- gfx/drivers/ctr_gfx.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/gfx/drivers/ctr_gfx.c b/gfx/drivers/ctr_gfx.c index 342025926d..8a2f49cedf 100644 --- a/gfx/drivers/ctr_gfx.c +++ b/gfx/drivers/ctr_gfx.c @@ -536,7 +536,8 @@ static bool ctr_frame(void* data, const void* frame, { if(((((u32)(frame)) >= 0x14000000 && ((u32)(frame)) < 0x40000000)) /* frame in linear memory */ && !((u32)frame & 0x7F) /* 128-byte aligned */ - && !((pitch) & 0xF)) /* 16-byte aligned */ + && !(pitch & 0xF) /* 16-byte aligned */ + && (pitch > 0x40)) { /* can copy the buffer directly with the GPU */ ctrGuCopyImage(false, frame, pitch / (ctr->rgb32? 4: 2), height, ctr->rgb32 ? CTRGU_RGBA8: CTRGU_RGB565, false, @@ -562,6 +563,12 @@ static bool ctr_frame(void* data, const void* frame, } + ctr->frame_coords->u = width; + ctr->frame_coords->v = height; + GSPGPU_FlushDataCache(ctr->frame_coords, sizeof(ctr_vertex_t)); + + ctrGuSetAttributeBuffersAddress(VIRT_TO_PHYS(ctr->frame_coords)); + ctrGuSetVertexShaderFloatUniform(0, (float*)&ctr->scale_vector, 1); } ctrGuSetTexture(GPU_TEXUNIT0, VIRT_TO_PHYS(ctr->texture_swizzled), ctr->texture_width, ctr->texture_height, @@ -570,13 +577,6 @@ static bool ctr_frame(void* data, const void* frame, GPU_TEXTURE_WRAP_S(GPU_CLAMP_TO_EDGE) | GPU_TEXTURE_WRAP_T(GPU_CLAMP_TO_EDGE), ctr->rgb32 ? GPU_RGBA8: GPU_RGB565); - ctr->frame_coords->u = width; - ctr->frame_coords->v = height; - GSPGPU_FlushDataCache(ctr->frame_coords, sizeof(ctr_vertex_t)); - - ctrGuSetAttributeBuffersAddress(VIRT_TO_PHYS(ctr->frame_coords)); - ctrGuSetVertexShaderFloatUniform(0, (float*)&ctr->scale_vector, 1); - /* ARGB --> RGBA */ if (ctr->rgb32) { From dfe5c33f347a9de1ac1265cafaaf1f3e949ffcbb Mon Sep 17 00:00:00 2001 From: aliaspider Date: Thu, 12 Nov 2015 15:15:40 +0100 Subject: [PATCH 183/216] (3ds) set a default video filter dir. --- frontend/drivers/platform_ctr.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/frontend/drivers/platform_ctr.c b/frontend/drivers/platform_ctr.c index 6311ae5976..ba11f400cf 100644 --- a/frontend/drivers/platform_ctr.c +++ b/frontend/drivers/platform_ctr.c @@ -75,6 +75,8 @@ static void frontend_ctr_get_environment_settings(int *argc, char *argv[], "playlists", sizeof(g_defaults.dir.playlist)); fill_pathname_join(g_defaults.dir.remap, g_defaults.dir.port, "remaps", sizeof(g_defaults.dir.remap)); + fill_pathname_join(g_defaults.dir.video_filter, g_defaults.dir.port, + "filters", sizeof(g_defaults.dir.remap)); fill_pathname_join(g_defaults.path.config, g_defaults.dir.port, "retroarch.cfg", sizeof(g_defaults.path.config)); From 340c15c517e217cc31d74747b9a2eca5996609a1 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Thu, 12 Nov 2015 17:54:38 +0100 Subject: [PATCH 184/216] Refactor small keyboard/icade code a bit --- input/drivers/cocoa_input.c | 26 +++---------------- input/drivers/cocoa_input.h | 7 ----- input/drivers_keyboard/keyboard_event_apple.c | 11 +++++--- ui/drivers/ui_cocoatouch.m | 3 --- 4 files changed, 11 insertions(+), 36 deletions(-) diff --git a/input/drivers/cocoa_input.c b/input/drivers/cocoa_input.c index 862503f51d..81e2a699ed 100644 --- a/input/drivers/cocoa_input.c +++ b/input/drivers/cocoa_input.c @@ -126,26 +126,6 @@ const struct apple_key_name_map_entry apple_key_name_map[] = }; #if TARGET_OS_IPHONE -void cocoa_input_enable_small_keyboard(bool on) -{ - driver_t *driver = driver_get_ptr(); - cocoa_input_data_t *apple = (cocoa_input_data_t*)driver->input_data; - if (apple) - apple->small_keyboard_enabled = on; -} - -void cocoa_input_enable_icade(bool on) -{ - driver_t *driver = driver_get_ptr(); - cocoa_input_data_t *apple = (cocoa_input_data_t*)driver->input_data; - - if (!apple) - return; - - apple->icade_enabled = on; - apple->icade_buttons = 0; -} - void cocoa_input_reset_icade_buttons(void) { driver_t *driver = driver_get_ptr(); @@ -178,9 +158,10 @@ int32_t cocoa_input_find_any_key(void) static int cocoa_input_find_any_button_ret(cocoa_input_data_t *apple, unsigned buttons, unsigned port) { + settings_t *settings = config_get_ptr(); unsigned i; #if TARGET_OS_IPHONE - if (port == 0 && apple->icade_enabled) + if (port == 0 && settings->input.icade_enable) BIT32_SET(buttons, apple->icade_buttons); #endif @@ -267,6 +248,7 @@ static void *cocoa_input_init(void) static void cocoa_input_poll(void *data) { uint32_t i; + settings_t *settings = config_get_ptr(); cocoa_input_data_t *apple = (cocoa_input_data_t*)data; for (i = 0; i < apple->touch_count; i++) @@ -282,7 +264,7 @@ static void cocoa_input_poll(void *data) apple->joypad->poll(); #if TARGET_OS_IPHONE - if (apple->icade_enabled) + if (settings->input.icade_enable) BIT32_SET(apple->buttons[0], apple->icade_buttons); #endif diff --git a/input/drivers/cocoa_input.h b/input/drivers/cocoa_input.h index da565b0863..818cac0a5e 100644 --- a/input/drivers/cocoa_input.h +++ b/input/drivers/cocoa_input.h @@ -60,9 +60,6 @@ typedef struct #if TARGET_OS_IPHONE uint32_t mfi_buttons[MAX_USERS]; - - bool icade_enabled; - bool small_keyboard_enabled; bool small_keyboard_active; uint32_t icade_buttons; #endif @@ -71,10 +68,6 @@ typedef struct } cocoa_input_data_t; #if TARGET_OS_IPHONE -void cocoa_input_enable_icade(bool on); - -void cocoa_input_enable_small_keyboard(bool on); - void cocoa_input_reset_icade_buttons(void); #endif diff --git a/input/drivers_keyboard/keyboard_event_apple.c b/input/drivers_keyboard/keyboard_event_apple.c index e75545d7ed..3c1775e3f6 100644 --- a/input/drivers_keyboard/keyboard_event_apple.c +++ b/input/drivers_keyboard/keyboard_event_apple.c @@ -142,6 +142,7 @@ void cocoa_input_keyboard_event(bool down, unsigned code, uint32_t character, uint32_t mod, unsigned device) { driver_t *driver = driver_get_ptr(); + settings_t *settings = config_get_ptr(); cocoa_input_data_t *apple = (cocoa_input_data_t*)driver->input_data; if (!apple) @@ -150,14 +151,16 @@ void cocoa_input_keyboard_event(bool down, code = HIDKEY(code); #if TARGET_OS_IPHONE - if (apple->icade_enabled) + if (settings->input.icade_enable) { handle_icade_event(code); return; } - else if (apple->small_keyboard_enabled && - handle_small_keyboard(&code, down)) - character = 0; + else if (settings->input.small_keyboard_enable) + { + if (handle_small_keyboard(&code, down)) + character = 0; + } #endif if (code == 0 || code >= MAX_KEYS) diff --git a/ui/drivers/ui_cocoatouch.m b/ui/drivers/ui_cocoatouch.m index 1fefa43c43..9957a61b8d 100644 --- a/ui/drivers/ui_cocoatouch.m +++ b/ui/drivers/ui_cocoatouch.m @@ -390,7 +390,6 @@ enum - (void)refreshSystemConfig { - settings_t *settings = config_get_ptr(); bool is_btstack; /* Get enabled orientations */ @@ -404,8 +403,6 @@ enum /* Set bluetooth mode */ is_btstack = !(strcmp(apple_frontend_settings.bluetooth_mode, "btstack")); - cocoa_input_enable_small_keyboard(settings->input.small_keyboard_enable); - cocoa_input_enable_icade(settings->input.icade_enable); btstack_set_poweron(is_btstack); } From d4a9221deb64295203cdb13db8a3a3ae4cf1a888 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Thu, 12 Nov 2015 22:08:05 +0100 Subject: [PATCH 185/216] (iOS) Show options --- menu/menu_displaylist.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/menu/menu_displaylist.c b/menu/menu_displaylist.c index c7696816de..ff4988689c 100644 --- a/menu/menu_displaylist.c +++ b/menu/menu_displaylist.c @@ -2607,6 +2607,12 @@ int menu_displaylist_push_list(menu_displaylist_info_t *info, unsigned type) case DISPLAYLIST_INPUT_SETTINGS_LIST: ret = menu_displaylist_parse_settings(menu, info, menu_hash_to_str(MENU_LABEL_INPUT_MAX_USERS), PARSE_ONLY_UINT, false); +#if TARGET_OS_IPHONE + ret = menu_displaylist_parse_settings(menu, info, + menu_hash_to_str(MENU_LABEL_INPUT_ICADE_ENABLE), PARSE_ONLY_BOOL, false); + ret = menu_displaylist_parse_settings(menu, info, + menu_hash_to_str(MENU_LABEL_INPUT_SMALL_KEYBOARD_ENABLE), PARSE_ONLY_BOOL, false); +#endif #ifdef ANDROID ret = menu_displaylist_parse_settings(menu, info, menu_hash_to_str(MENU_LABEL_INPUT_BACK_AS_MENU_TOGGLE_ENABLE), PARSE_ONLY_BOOL, false); From fde9676ac315cec16aa7fb58c79526b07fa8b5dd Mon Sep 17 00:00:00 2001 From: Twinaphex Date: Fri, 13 Nov 2015 01:39:19 +0100 Subject: [PATCH 186/216] Revert "Refactor small keyboard/icade code a bit" This reverts commit 340c15c517e217cc31d74747b9a2eca5996609a1. --- input/drivers/cocoa_input.c | 26 ++++++++++++++++--- input/drivers/cocoa_input.h | 7 +++++ input/drivers_keyboard/keyboard_event_apple.c | 11 +++----- ui/drivers/ui_cocoatouch.m | 3 +++ 4 files changed, 36 insertions(+), 11 deletions(-) diff --git a/input/drivers/cocoa_input.c b/input/drivers/cocoa_input.c index 81e2a699ed..862503f51d 100644 --- a/input/drivers/cocoa_input.c +++ b/input/drivers/cocoa_input.c @@ -126,6 +126,26 @@ const struct apple_key_name_map_entry apple_key_name_map[] = }; #if TARGET_OS_IPHONE +void cocoa_input_enable_small_keyboard(bool on) +{ + driver_t *driver = driver_get_ptr(); + cocoa_input_data_t *apple = (cocoa_input_data_t*)driver->input_data; + if (apple) + apple->small_keyboard_enabled = on; +} + +void cocoa_input_enable_icade(bool on) +{ + driver_t *driver = driver_get_ptr(); + cocoa_input_data_t *apple = (cocoa_input_data_t*)driver->input_data; + + if (!apple) + return; + + apple->icade_enabled = on; + apple->icade_buttons = 0; +} + void cocoa_input_reset_icade_buttons(void) { driver_t *driver = driver_get_ptr(); @@ -158,10 +178,9 @@ int32_t cocoa_input_find_any_key(void) static int cocoa_input_find_any_button_ret(cocoa_input_data_t *apple, unsigned buttons, unsigned port) { - settings_t *settings = config_get_ptr(); unsigned i; #if TARGET_OS_IPHONE - if (port == 0 && settings->input.icade_enable) + if (port == 0 && apple->icade_enabled) BIT32_SET(buttons, apple->icade_buttons); #endif @@ -248,7 +267,6 @@ static void *cocoa_input_init(void) static void cocoa_input_poll(void *data) { uint32_t i; - settings_t *settings = config_get_ptr(); cocoa_input_data_t *apple = (cocoa_input_data_t*)data; for (i = 0; i < apple->touch_count; i++) @@ -264,7 +282,7 @@ static void cocoa_input_poll(void *data) apple->joypad->poll(); #if TARGET_OS_IPHONE - if (settings->input.icade_enable) + if (apple->icade_enabled) BIT32_SET(apple->buttons[0], apple->icade_buttons); #endif diff --git a/input/drivers/cocoa_input.h b/input/drivers/cocoa_input.h index 818cac0a5e..da565b0863 100644 --- a/input/drivers/cocoa_input.h +++ b/input/drivers/cocoa_input.h @@ -60,6 +60,9 @@ typedef struct #if TARGET_OS_IPHONE uint32_t mfi_buttons[MAX_USERS]; + + bool icade_enabled; + bool small_keyboard_enabled; bool small_keyboard_active; uint32_t icade_buttons; #endif @@ -68,6 +71,10 @@ typedef struct } cocoa_input_data_t; #if TARGET_OS_IPHONE +void cocoa_input_enable_icade(bool on); + +void cocoa_input_enable_small_keyboard(bool on); + void cocoa_input_reset_icade_buttons(void); #endif diff --git a/input/drivers_keyboard/keyboard_event_apple.c b/input/drivers_keyboard/keyboard_event_apple.c index 3c1775e3f6..e75545d7ed 100644 --- a/input/drivers_keyboard/keyboard_event_apple.c +++ b/input/drivers_keyboard/keyboard_event_apple.c @@ -142,7 +142,6 @@ void cocoa_input_keyboard_event(bool down, unsigned code, uint32_t character, uint32_t mod, unsigned device) { driver_t *driver = driver_get_ptr(); - settings_t *settings = config_get_ptr(); cocoa_input_data_t *apple = (cocoa_input_data_t*)driver->input_data; if (!apple) @@ -151,16 +150,14 @@ void cocoa_input_keyboard_event(bool down, code = HIDKEY(code); #if TARGET_OS_IPHONE - if (settings->input.icade_enable) + if (apple->icade_enabled) { handle_icade_event(code); return; } - else if (settings->input.small_keyboard_enable) - { - if (handle_small_keyboard(&code, down)) - character = 0; - } + else if (apple->small_keyboard_enabled && + handle_small_keyboard(&code, down)) + character = 0; #endif if (code == 0 || code >= MAX_KEYS) diff --git a/ui/drivers/ui_cocoatouch.m b/ui/drivers/ui_cocoatouch.m index 9957a61b8d..1fefa43c43 100644 --- a/ui/drivers/ui_cocoatouch.m +++ b/ui/drivers/ui_cocoatouch.m @@ -390,6 +390,7 @@ enum - (void)refreshSystemConfig { + settings_t *settings = config_get_ptr(); bool is_btstack; /* Get enabled orientations */ @@ -403,6 +404,8 @@ enum /* Set bluetooth mode */ is_btstack = !(strcmp(apple_frontend_settings.bluetooth_mode, "btstack")); + cocoa_input_enable_small_keyboard(settings->input.small_keyboard_enable); + cocoa_input_enable_icade(settings->input.icade_enable); btstack_set_poweron(is_btstack); } From 834e4d848ecf20cd0ec42b77a25feed213f8a62d Mon Sep 17 00:00:00 2001 From: Twinaphex Date: Fri, 13 Nov 2015 01:39:39 +0100 Subject: [PATCH 187/216] Revert "(iOS) Add Small Keyboard/iCade Enable options" This reverts commit 6ea11afe28411920084afae59431a8d2fb13a394. --- configuration.c | 14 ---------- configuration.h | 5 ---- input/drivers_keyboard/keyboard_event_apple.c | 6 ++-- menu/intl/menu_hash_us.c | 8 ------ menu/menu_hash.h | 6 ---- menu/menu_setting.c | 28 ------------------- ui/drivers/ui_cocoatouch.m | 9 +++--- 7 files changed, 7 insertions(+), 69 deletions(-) diff --git a/configuration.c b/configuration.c index 327a1f1a3d..1a0c50dbd8 100644 --- a/configuration.c +++ b/configuration.c @@ -460,10 +460,6 @@ static void config_set_defaults(void) settings->history_list_enable = def_history_list_enable; settings->load_dummy_on_core_shutdown = load_dummy_on_core_shutdown; -#if TARGET_OS_IPHONE - settings->input.icade_enable = true; - settings->input.small_keyboard_enable = false; -#endif #ifdef HAVE_FFMPEG settings->multimedia.builtin_mediaplayer_enable = true; #else @@ -1575,11 +1571,6 @@ static bool config_load_file(const char *path, bool set_defaults) CONFIG_GET_BOOL_BASE(conf, global, perfcnt_enable, "perfcnt_enable"); -#if TARGET_OS_IPHONE - CONFIG_GET_BOOL_BASE(conf, settings, input.small_keyboard_enable, "small_keyboard_enable"); - CONFIG_GET_BOOL_BASE(conf, settings, input.icade_enable, "icade_enable"); -#endif - config_get_path(conf, "recording_output_directory", global->record.output_dir, sizeof(global->record.output_dir)); config_get_path(conf, "recording_config_directory", global->record.config_dir, @@ -2789,11 +2780,6 @@ bool config_save_file(const char *path) config_set_bool(conf, "log_verbosity", global->verbosity); config_set_bool(conf, "perfcnt_enable", global->perfcnt_enable); -#if TARGET_OS_IPHONE - config_set_bool(conf, "small_keyboard_enable", settings->input.small_keyboard_enable); - config_set_bool(conf, "icade_enable", settings->input.icade_enable); -#endif - config_set_bool(conf, "core_set_supports_no_game_enable", settings->core.set_supports_no_game_enable); diff --git a/configuration.h b/configuration.h index 40946f11ac..a1026560ce 100644 --- a/configuration.h +++ b/configuration.h @@ -250,11 +250,6 @@ typedef struct settings unsigned menu_toggle_gamepad_combo; bool back_as_menu_toggle_enable; - -#if TARGET_OS_IPHONE - bool icade_enable; - bool small_keyboard_enable; -#endif } input; struct diff --git a/input/drivers_keyboard/keyboard_event_apple.c b/input/drivers_keyboard/keyboard_event_apple.c index e75545d7ed..1f4d28e4d3 100644 --- a/input/drivers_keyboard/keyboard_event_apple.c +++ b/input/drivers_keyboard/keyboard_event_apple.c @@ -151,11 +151,9 @@ void cocoa_input_keyboard_event(bool down, #if TARGET_OS_IPHONE if (apple->icade_enabled) - { handle_icade_event(code); - return; - } - else if (apple->small_keyboard_enabled && + + if (apple->small_keyboard_enabled && handle_small_keyboard(&code, down)) character = 0; #endif diff --git a/menu/intl/menu_hash_us.c b/menu/intl/menu_hash_us.c index f84aff0183..744fd063e5 100644 --- a/menu/intl/menu_hash_us.c +++ b/menu/intl/menu_hash_us.c @@ -26,10 +26,6 @@ static const char *menu_hash_to_str_us_label(uint32_t hash) { switch (hash) { - case MENU_LABEL_INPUT_ICADE_ENABLE: - return "input_icade_enable"; - case MENU_LABEL_INPUT_SMALL_KEYBOARD_ENABLE: - return "input_small_keyboard_enable"; case MENU_LABEL_SAVE_CURRENT_CONFIG: return "save_current_config"; case MENU_LABEL_STATE_SLOT: @@ -694,10 +690,6 @@ const char *menu_hash_to_str_us(uint32_t hash) switch (hash) { - case MENU_LABEL_VALUE_INPUT_ICADE_ENABLE: - return "iCade Enable"; - case MENU_LABEL_VALUE_INPUT_SMALL_KEYBOARD_ENABLE: - return "Small Keyboard Enable"; case MENU_LABEL_VALUE_SAVE_CURRENT_CONFIG: return "Save Current Config"; case MENU_LABEL_VALUE_STATE_SLOT: diff --git a/menu/menu_hash.h b/menu/menu_hash.h index ea27bd774a..400b027eb2 100644 --- a/menu/menu_hash.h +++ b/menu/menu_hash.h @@ -1077,12 +1077,6 @@ extern "C" { #define MENU_LABEL_SAVE_CURRENT_CONFIG 0x8840ba8bU #define MENU_LABEL_VALUE_SAVE_CURRENT_CONFIG 0x9a1eb42dU -#define MENU_LABEL_INPUT_SMALL_KEYBOARD_ENABLE 0xe6736fc3U -#define MENU_LABEL_VALUE_INPUT_SMALL_KEYBOARD_ENABLE 0xc5eefd76U - -#define MENU_LABEL_INPUT_ICADE_ENABLE 0xcd534dd0U -#define MENU_LABEL_VALUE_INPUT_ICADE_ENABLE 0x67b18ee2U - const char *menu_hash_to_str_de(uint32_t hash); int menu_hash_get_help_de(uint32_t hash, char *s, size_t len); diff --git a/menu/menu_setting.c b/menu/menu_setting.c index e3117c9668..a4db56e43d 100644 --- a/menu/menu_setting.c +++ b/menu/menu_setting.c @@ -4929,34 +4929,6 @@ static bool setting_append_list_input_options( general_read_handler); menu_settings_list_current_add_range(list, list_info, 1, MAX_USERS, 1, true, true); -#if TARGET_OS_IPHONE - CONFIG_BOOL( - settings->input.icade_enable, - menu_hash_to_str(MENU_LABEL_INPUT_ICADE_ENABLE), - menu_hash_to_str(MENU_LABEL_VALUE_INPUT_ICADE_ENABLE), - true, - menu_hash_to_str(MENU_VALUE_OFF), - menu_hash_to_str(MENU_VALUE_ON), - group_info.name, - subgroup_info.name, - parent_group, - general_write_handler, - general_read_handler); - - CONFIG_BOOL( - settings->input.small_keyboard_enable, - menu_hash_to_str(MENU_LABEL_INPUT_SMALL_KEYBOARD_ENABLE), - menu_hash_to_str(MENU_LABEL_VALUE_INPUT_SMALL_KEYBOARD_ENABLE), - false, - menu_hash_to_str(MENU_VALUE_OFF), - menu_hash_to_str(MENU_VALUE_ON), - group_info.name, - subgroup_info.name, - parent_group, - general_write_handler, - general_read_handler); -#endif - #ifdef ANDROID CONFIG_BOOL( settings->input.back_as_menu_toggle_enable, diff --git a/ui/drivers/ui_cocoatouch.m b/ui/drivers/ui_cocoatouch.m index 1fefa43c43..368db72df8 100644 --- a/ui/drivers/ui_cocoatouch.m +++ b/ui/drivers/ui_cocoatouch.m @@ -390,8 +390,7 @@ enum - (void)refreshSystemConfig { - settings_t *settings = config_get_ptr(); - bool is_btstack; + bool small_keyboard, is_icade, is_btstack; /* Get enabled orientations */ apple_frontend_settings.orientation_flags = UIInterfaceOrientationMaskAll; @@ -402,10 +401,12 @@ enum apple_frontend_settings.orientation_flags = UIInterfaceOrientationMaskPortrait | UIInterfaceOrientationMaskPortraitUpsideDown; /* Set bluetooth mode */ + small_keyboard = !(strcmp(apple_frontend_settings.bluetooth_mode, "small_keyboard")); + is_icade = !(strcmp(apple_frontend_settings.bluetooth_mode, "icade")); is_btstack = !(strcmp(apple_frontend_settings.bluetooth_mode, "btstack")); - cocoa_input_enable_small_keyboard(settings->input.small_keyboard_enable); - cocoa_input_enable_icade(settings->input.icade_enable); + cocoa_input_enable_small_keyboard(small_keyboard); + cocoa_input_enable_icade(is_icade); btstack_set_poweron(is_btstack); } From 91d1dcf078f7a6424176abdf55ff21429a42a344 Mon Sep 17 00:00:00 2001 From: Twinaphex Date: Fri, 13 Nov 2015 01:40:52 +0100 Subject: [PATCH 188/216] (iOS) Another buildfix --- menu/menu_displaylist.c | 6 ------ 1 file changed, 6 deletions(-) diff --git a/menu/menu_displaylist.c b/menu/menu_displaylist.c index ff4988689c..c7696816de 100644 --- a/menu/menu_displaylist.c +++ b/menu/menu_displaylist.c @@ -2607,12 +2607,6 @@ int menu_displaylist_push_list(menu_displaylist_info_t *info, unsigned type) case DISPLAYLIST_INPUT_SETTINGS_LIST: ret = menu_displaylist_parse_settings(menu, info, menu_hash_to_str(MENU_LABEL_INPUT_MAX_USERS), PARSE_ONLY_UINT, false); -#if TARGET_OS_IPHONE - ret = menu_displaylist_parse_settings(menu, info, - menu_hash_to_str(MENU_LABEL_INPUT_ICADE_ENABLE), PARSE_ONLY_BOOL, false); - ret = menu_displaylist_parse_settings(menu, info, - menu_hash_to_str(MENU_LABEL_INPUT_SMALL_KEYBOARD_ENABLE), PARSE_ONLY_BOOL, false); -#endif #ifdef ANDROID ret = menu_displaylist_parse_settings(menu, info, menu_hash_to_str(MENU_LABEL_INPUT_BACK_AS_MENU_TOGGLE_ENABLE), PARSE_ONLY_BOOL, false); From cc0035e613016fc7d5db8eb54d8a930d0703440b Mon Sep 17 00:00:00 2001 From: Twinaphex Date: Fri, 13 Nov 2015 01:50:14 +0100 Subject: [PATCH 189/216] Revert "(iOS) Another buildfix" This reverts commit 91d1dcf078f7a6424176abdf55ff21429a42a344. --- menu/menu_displaylist.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/menu/menu_displaylist.c b/menu/menu_displaylist.c index c7696816de..ff4988689c 100644 --- a/menu/menu_displaylist.c +++ b/menu/menu_displaylist.c @@ -2607,6 +2607,12 @@ int menu_displaylist_push_list(menu_displaylist_info_t *info, unsigned type) case DISPLAYLIST_INPUT_SETTINGS_LIST: ret = menu_displaylist_parse_settings(menu, info, menu_hash_to_str(MENU_LABEL_INPUT_MAX_USERS), PARSE_ONLY_UINT, false); +#if TARGET_OS_IPHONE + ret = menu_displaylist_parse_settings(menu, info, + menu_hash_to_str(MENU_LABEL_INPUT_ICADE_ENABLE), PARSE_ONLY_BOOL, false); + ret = menu_displaylist_parse_settings(menu, info, + menu_hash_to_str(MENU_LABEL_INPUT_SMALL_KEYBOARD_ENABLE), PARSE_ONLY_BOOL, false); +#endif #ifdef ANDROID ret = menu_displaylist_parse_settings(menu, info, menu_hash_to_str(MENU_LABEL_INPUT_BACK_AS_MENU_TOGGLE_ENABLE), PARSE_ONLY_BOOL, false); From ba00560f2bb30c389e97d0fbb189a295b4e86c81 Mon Sep 17 00:00:00 2001 From: Twinaphex Date: Fri, 13 Nov 2015 01:50:22 +0100 Subject: [PATCH 190/216] Revert "Revert "(iOS) Add Small Keyboard/iCade Enable options"" This reverts commit 834e4d848ecf20cd0ec42b77a25feed213f8a62d. --- configuration.c | 14 ++++++++++ configuration.h | 5 ++++ input/drivers_keyboard/keyboard_event_apple.c | 6 ++-- menu/intl/menu_hash_us.c | 8 ++++++ menu/menu_hash.h | 6 ++++ menu/menu_setting.c | 28 +++++++++++++++++++ ui/drivers/ui_cocoatouch.m | 9 +++--- 7 files changed, 69 insertions(+), 7 deletions(-) diff --git a/configuration.c b/configuration.c index 1a0c50dbd8..327a1f1a3d 100644 --- a/configuration.c +++ b/configuration.c @@ -460,6 +460,10 @@ static void config_set_defaults(void) settings->history_list_enable = def_history_list_enable; settings->load_dummy_on_core_shutdown = load_dummy_on_core_shutdown; +#if TARGET_OS_IPHONE + settings->input.icade_enable = true; + settings->input.small_keyboard_enable = false; +#endif #ifdef HAVE_FFMPEG settings->multimedia.builtin_mediaplayer_enable = true; #else @@ -1571,6 +1575,11 @@ static bool config_load_file(const char *path, bool set_defaults) CONFIG_GET_BOOL_BASE(conf, global, perfcnt_enable, "perfcnt_enable"); +#if TARGET_OS_IPHONE + CONFIG_GET_BOOL_BASE(conf, settings, input.small_keyboard_enable, "small_keyboard_enable"); + CONFIG_GET_BOOL_BASE(conf, settings, input.icade_enable, "icade_enable"); +#endif + config_get_path(conf, "recording_output_directory", global->record.output_dir, sizeof(global->record.output_dir)); config_get_path(conf, "recording_config_directory", global->record.config_dir, @@ -2780,6 +2789,11 @@ bool config_save_file(const char *path) config_set_bool(conf, "log_verbosity", global->verbosity); config_set_bool(conf, "perfcnt_enable", global->perfcnt_enable); +#if TARGET_OS_IPHONE + config_set_bool(conf, "small_keyboard_enable", settings->input.small_keyboard_enable); + config_set_bool(conf, "icade_enable", settings->input.icade_enable); +#endif + config_set_bool(conf, "core_set_supports_no_game_enable", settings->core.set_supports_no_game_enable); diff --git a/configuration.h b/configuration.h index a1026560ce..40946f11ac 100644 --- a/configuration.h +++ b/configuration.h @@ -250,6 +250,11 @@ typedef struct settings unsigned menu_toggle_gamepad_combo; bool back_as_menu_toggle_enable; + +#if TARGET_OS_IPHONE + bool icade_enable; + bool small_keyboard_enable; +#endif } input; struct diff --git a/input/drivers_keyboard/keyboard_event_apple.c b/input/drivers_keyboard/keyboard_event_apple.c index 1f4d28e4d3..e75545d7ed 100644 --- a/input/drivers_keyboard/keyboard_event_apple.c +++ b/input/drivers_keyboard/keyboard_event_apple.c @@ -151,9 +151,11 @@ void cocoa_input_keyboard_event(bool down, #if TARGET_OS_IPHONE if (apple->icade_enabled) + { handle_icade_event(code); - - if (apple->small_keyboard_enabled && + return; + } + else if (apple->small_keyboard_enabled && handle_small_keyboard(&code, down)) character = 0; #endif diff --git a/menu/intl/menu_hash_us.c b/menu/intl/menu_hash_us.c index 744fd063e5..f84aff0183 100644 --- a/menu/intl/menu_hash_us.c +++ b/menu/intl/menu_hash_us.c @@ -26,6 +26,10 @@ static const char *menu_hash_to_str_us_label(uint32_t hash) { switch (hash) { + case MENU_LABEL_INPUT_ICADE_ENABLE: + return "input_icade_enable"; + case MENU_LABEL_INPUT_SMALL_KEYBOARD_ENABLE: + return "input_small_keyboard_enable"; case MENU_LABEL_SAVE_CURRENT_CONFIG: return "save_current_config"; case MENU_LABEL_STATE_SLOT: @@ -690,6 +694,10 @@ const char *menu_hash_to_str_us(uint32_t hash) switch (hash) { + case MENU_LABEL_VALUE_INPUT_ICADE_ENABLE: + return "iCade Enable"; + case MENU_LABEL_VALUE_INPUT_SMALL_KEYBOARD_ENABLE: + return "Small Keyboard Enable"; case MENU_LABEL_VALUE_SAVE_CURRENT_CONFIG: return "Save Current Config"; case MENU_LABEL_VALUE_STATE_SLOT: diff --git a/menu/menu_hash.h b/menu/menu_hash.h index 400b027eb2..ea27bd774a 100644 --- a/menu/menu_hash.h +++ b/menu/menu_hash.h @@ -1077,6 +1077,12 @@ extern "C" { #define MENU_LABEL_SAVE_CURRENT_CONFIG 0x8840ba8bU #define MENU_LABEL_VALUE_SAVE_CURRENT_CONFIG 0x9a1eb42dU +#define MENU_LABEL_INPUT_SMALL_KEYBOARD_ENABLE 0xe6736fc3U +#define MENU_LABEL_VALUE_INPUT_SMALL_KEYBOARD_ENABLE 0xc5eefd76U + +#define MENU_LABEL_INPUT_ICADE_ENABLE 0xcd534dd0U +#define MENU_LABEL_VALUE_INPUT_ICADE_ENABLE 0x67b18ee2U + const char *menu_hash_to_str_de(uint32_t hash); int menu_hash_get_help_de(uint32_t hash, char *s, size_t len); diff --git a/menu/menu_setting.c b/menu/menu_setting.c index a4db56e43d..e3117c9668 100644 --- a/menu/menu_setting.c +++ b/menu/menu_setting.c @@ -4929,6 +4929,34 @@ static bool setting_append_list_input_options( general_read_handler); menu_settings_list_current_add_range(list, list_info, 1, MAX_USERS, 1, true, true); +#if TARGET_OS_IPHONE + CONFIG_BOOL( + settings->input.icade_enable, + menu_hash_to_str(MENU_LABEL_INPUT_ICADE_ENABLE), + menu_hash_to_str(MENU_LABEL_VALUE_INPUT_ICADE_ENABLE), + true, + menu_hash_to_str(MENU_VALUE_OFF), + menu_hash_to_str(MENU_VALUE_ON), + group_info.name, + subgroup_info.name, + parent_group, + general_write_handler, + general_read_handler); + + CONFIG_BOOL( + settings->input.small_keyboard_enable, + menu_hash_to_str(MENU_LABEL_INPUT_SMALL_KEYBOARD_ENABLE), + menu_hash_to_str(MENU_LABEL_VALUE_INPUT_SMALL_KEYBOARD_ENABLE), + false, + menu_hash_to_str(MENU_VALUE_OFF), + menu_hash_to_str(MENU_VALUE_ON), + group_info.name, + subgroup_info.name, + parent_group, + general_write_handler, + general_read_handler); +#endif + #ifdef ANDROID CONFIG_BOOL( settings->input.back_as_menu_toggle_enable, diff --git a/ui/drivers/ui_cocoatouch.m b/ui/drivers/ui_cocoatouch.m index 368db72df8..1fefa43c43 100644 --- a/ui/drivers/ui_cocoatouch.m +++ b/ui/drivers/ui_cocoatouch.m @@ -390,7 +390,8 @@ enum - (void)refreshSystemConfig { - bool small_keyboard, is_icade, is_btstack; + settings_t *settings = config_get_ptr(); + bool is_btstack; /* Get enabled orientations */ apple_frontend_settings.orientation_flags = UIInterfaceOrientationMaskAll; @@ -401,12 +402,10 @@ enum apple_frontend_settings.orientation_flags = UIInterfaceOrientationMaskPortrait | UIInterfaceOrientationMaskPortraitUpsideDown; /* Set bluetooth mode */ - small_keyboard = !(strcmp(apple_frontend_settings.bluetooth_mode, "small_keyboard")); - is_icade = !(strcmp(apple_frontend_settings.bluetooth_mode, "icade")); is_btstack = !(strcmp(apple_frontend_settings.bluetooth_mode, "btstack")); - cocoa_input_enable_small_keyboard(small_keyboard); - cocoa_input_enable_icade(is_icade); + cocoa_input_enable_small_keyboard(settings->input.small_keyboard_enable); + cocoa_input_enable_icade(settings->input.icade_enable); btstack_set_poweron(is_btstack); } From 924642a7441e8b06ce220193f8388189917fe651 Mon Sep 17 00:00:00 2001 From: Twinaphex Date: Fri, 13 Nov 2015 01:50:34 +0100 Subject: [PATCH 191/216] Revert "Revert "Refactor small keyboard/icade code a bit"" This reverts commit fde9676ac315cec16aa7fb58c79526b07fa8b5dd. --- input/drivers/cocoa_input.c | 26 +++---------------- input/drivers/cocoa_input.h | 7 ----- input/drivers_keyboard/keyboard_event_apple.c | 11 +++++--- ui/drivers/ui_cocoatouch.m | 3 --- 4 files changed, 11 insertions(+), 36 deletions(-) diff --git a/input/drivers/cocoa_input.c b/input/drivers/cocoa_input.c index 862503f51d..81e2a699ed 100644 --- a/input/drivers/cocoa_input.c +++ b/input/drivers/cocoa_input.c @@ -126,26 +126,6 @@ const struct apple_key_name_map_entry apple_key_name_map[] = }; #if TARGET_OS_IPHONE -void cocoa_input_enable_small_keyboard(bool on) -{ - driver_t *driver = driver_get_ptr(); - cocoa_input_data_t *apple = (cocoa_input_data_t*)driver->input_data; - if (apple) - apple->small_keyboard_enabled = on; -} - -void cocoa_input_enable_icade(bool on) -{ - driver_t *driver = driver_get_ptr(); - cocoa_input_data_t *apple = (cocoa_input_data_t*)driver->input_data; - - if (!apple) - return; - - apple->icade_enabled = on; - apple->icade_buttons = 0; -} - void cocoa_input_reset_icade_buttons(void) { driver_t *driver = driver_get_ptr(); @@ -178,9 +158,10 @@ int32_t cocoa_input_find_any_key(void) static int cocoa_input_find_any_button_ret(cocoa_input_data_t *apple, unsigned buttons, unsigned port) { + settings_t *settings = config_get_ptr(); unsigned i; #if TARGET_OS_IPHONE - if (port == 0 && apple->icade_enabled) + if (port == 0 && settings->input.icade_enable) BIT32_SET(buttons, apple->icade_buttons); #endif @@ -267,6 +248,7 @@ static void *cocoa_input_init(void) static void cocoa_input_poll(void *data) { uint32_t i; + settings_t *settings = config_get_ptr(); cocoa_input_data_t *apple = (cocoa_input_data_t*)data; for (i = 0; i < apple->touch_count; i++) @@ -282,7 +264,7 @@ static void cocoa_input_poll(void *data) apple->joypad->poll(); #if TARGET_OS_IPHONE - if (apple->icade_enabled) + if (settings->input.icade_enable) BIT32_SET(apple->buttons[0], apple->icade_buttons); #endif diff --git a/input/drivers/cocoa_input.h b/input/drivers/cocoa_input.h index da565b0863..818cac0a5e 100644 --- a/input/drivers/cocoa_input.h +++ b/input/drivers/cocoa_input.h @@ -60,9 +60,6 @@ typedef struct #if TARGET_OS_IPHONE uint32_t mfi_buttons[MAX_USERS]; - - bool icade_enabled; - bool small_keyboard_enabled; bool small_keyboard_active; uint32_t icade_buttons; #endif @@ -71,10 +68,6 @@ typedef struct } cocoa_input_data_t; #if TARGET_OS_IPHONE -void cocoa_input_enable_icade(bool on); - -void cocoa_input_enable_small_keyboard(bool on); - void cocoa_input_reset_icade_buttons(void); #endif diff --git a/input/drivers_keyboard/keyboard_event_apple.c b/input/drivers_keyboard/keyboard_event_apple.c index e75545d7ed..3c1775e3f6 100644 --- a/input/drivers_keyboard/keyboard_event_apple.c +++ b/input/drivers_keyboard/keyboard_event_apple.c @@ -142,6 +142,7 @@ void cocoa_input_keyboard_event(bool down, unsigned code, uint32_t character, uint32_t mod, unsigned device) { driver_t *driver = driver_get_ptr(); + settings_t *settings = config_get_ptr(); cocoa_input_data_t *apple = (cocoa_input_data_t*)driver->input_data; if (!apple) @@ -150,14 +151,16 @@ void cocoa_input_keyboard_event(bool down, code = HIDKEY(code); #if TARGET_OS_IPHONE - if (apple->icade_enabled) + if (settings->input.icade_enable) { handle_icade_event(code); return; } - else if (apple->small_keyboard_enabled && - handle_small_keyboard(&code, down)) - character = 0; + else if (settings->input.small_keyboard_enable) + { + if (handle_small_keyboard(&code, down)) + character = 0; + } #endif if (code == 0 || code >= MAX_KEYS) diff --git a/ui/drivers/ui_cocoatouch.m b/ui/drivers/ui_cocoatouch.m index 1fefa43c43..9957a61b8d 100644 --- a/ui/drivers/ui_cocoatouch.m +++ b/ui/drivers/ui_cocoatouch.m @@ -390,7 +390,6 @@ enum - (void)refreshSystemConfig { - settings_t *settings = config_get_ptr(); bool is_btstack; /* Get enabled orientations */ @@ -404,8 +403,6 @@ enum /* Set bluetooth mode */ is_btstack = !(strcmp(apple_frontend_settings.bluetooth_mode, "btstack")); - cocoa_input_enable_small_keyboard(settings->input.small_keyboard_enable); - cocoa_input_enable_icade(settings->input.icade_enable); btstack_set_poweron(is_btstack); } From 536754d6f2a25c529449b2304fbb6d5cde8b164d Mon Sep 17 00:00:00 2001 From: twinaphex Date: Fri, 13 Nov 2015 02:42:46 +0100 Subject: [PATCH 192/216] Add iCade code to cocoa_input_is_pressed --- input/drivers/cocoa_input.c | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/input/drivers/cocoa_input.c b/input/drivers/cocoa_input.c index 81e2a699ed..8d6a249269 100644 --- a/input/drivers/cocoa_input.c +++ b/input/drivers/cocoa_input.c @@ -222,11 +222,23 @@ int32_t cocoa_input_find_any_axis(uint32_t port) static int16_t cocoa_input_is_pressed(cocoa_input_data_t *apple, unsigned port_num, const struct retro_keybind *binds, unsigned id) { +#if TARGET_OS_IPHONE + settings_t *settings = config_get_ptr(); +#endif + if (id < RARCH_BIND_LIST_END) { const struct retro_keybind *bind = &binds[id]; unsigned bit = input_keymaps_translate_rk_to_keysym(bind->key); - return bind->valid && apple->key_state[bit]; + if (!bind->valid) + return 0; + if (apple->key_state[bit]) + return 1; +#if TARGET_OS_IPHONE + if (settings->input.icade_enable) + if (apple->icade_buttons & (1 << bit)) + return 1; +#endif } return 0; } From 8ebad97fbdd5ea7f21ace400b5095e8f1b952383 Mon Sep 17 00:00:00 2001 From: Twinaphex Date: Fri, 13 Nov 2015 02:46:01 +0100 Subject: [PATCH 193/216] Revert "Add iCade code to cocoa_input_is_pressed" This reverts commit 536754d6f2a25c529449b2304fbb6d5cde8b164d. --- input/drivers/cocoa_input.c | 14 +------------- 1 file changed, 1 insertion(+), 13 deletions(-) diff --git a/input/drivers/cocoa_input.c b/input/drivers/cocoa_input.c index 8d6a249269..81e2a699ed 100644 --- a/input/drivers/cocoa_input.c +++ b/input/drivers/cocoa_input.c @@ -222,23 +222,11 @@ int32_t cocoa_input_find_any_axis(uint32_t port) static int16_t cocoa_input_is_pressed(cocoa_input_data_t *apple, unsigned port_num, const struct retro_keybind *binds, unsigned id) { -#if TARGET_OS_IPHONE - settings_t *settings = config_get_ptr(); -#endif - if (id < RARCH_BIND_LIST_END) { const struct retro_keybind *bind = &binds[id]; unsigned bit = input_keymaps_translate_rk_to_keysym(bind->key); - if (!bind->valid) - return 0; - if (apple->key_state[bit]) - return 1; -#if TARGET_OS_IPHONE - if (settings->input.icade_enable) - if (apple->icade_buttons & (1 << bit)) - return 1; -#endif + return bind->valid && apple->key_state[bit]; } return 0; } From 5b7f58bec55a87ae6841f62bdf959b62bfb7b182 Mon Sep 17 00:00:00 2001 From: Twinaphex Date: Fri, 13 Nov 2015 20:03:14 +0100 Subject: [PATCH 194/216] (iOS) Rewrite iCade code entirely - start out with iPega PG9017 profile --- input/drivers_keyboard/keyboard_event_apple.c | 105 +++++++++++++----- 1 file changed, 77 insertions(+), 28 deletions(-) diff --git a/input/drivers_keyboard/keyboard_event_apple.c b/input/drivers_keyboard/keyboard_event_apple.c index 3c1775e3f6..9bd9e79933 100644 --- a/input/drivers_keyboard/keyboard_event_apple.c +++ b/input/drivers_keyboard/keyboard_event_apple.c @@ -106,35 +106,82 @@ static bool handle_small_keyboard(unsigned* code, bool down) return false; } -static void handle_icade_event(unsigned keycode) +extern const struct rarch_key_map rarch_key_map_apple_hid[]; + +typedef struct icade_map { - static const struct + bool up; + enum retro_key key; +} icade_map_t; + +#define MAX_ICADE_PROFILES 2 +#define MAX_ICADE_KEYS 0x100 + +static icade_map_t icade_maps[MAX_ICADE_PROFILES][MAX_ICADE_KEYS]; + +static bool handle_icade_event(unsigned *code, bool *keydown) +{ + static bool initialized = false; + bool ret = false; + unsigned kb_type_idx = 1; + + if (!initialized) + { + unsigned i; + unsigned j = 0; + + for (j = 0; j < MAX_ICADE_PROFILES; j++) + { + for (i = 0; i < MAX_ICADE_KEYS; i++) + { + icade_maps[j][i].key = RETROK_UNKNOWN; + icade_maps[j][i].up = false; + } + } + + /* iPega PG-9017 */ + j = 1; + + icade_maps[j][input_keymaps_translate_rk_to_keysym(RETROK_a)].key = RETROK_LEFT; + icade_maps[j][input_keymaps_translate_rk_to_keysym(RETROK_c)].key = RETROK_RIGHT; + icade_maps[j][input_keymaps_translate_rk_to_keysym(RETROK_d)].key = RETROK_RIGHT; + icade_maps[j][input_keymaps_translate_rk_to_keysym(RETROK_e)].key = RETROK_UP; + icade_maps[j][input_keymaps_translate_rk_to_keysym(RETROK_f)].key = RETROK_z; + icade_maps[j][input_keymaps_translate_rk_to_keysym(RETROK_h)].key = RETROK_x; + icade_maps[j][input_keymaps_translate_rk_to_keysym(RETROK_i)].key = RETROK_q; + icade_maps[j][input_keymaps_translate_rk_to_keysym(RETROK_j)].key = RETROK_a; + icade_maps[j][input_keymaps_translate_rk_to_keysym(RETROK_k)].key = RETROK_w; + icade_maps[j][input_keymaps_translate_rk_to_keysym(RETROK_m)].key = RETROK_q; + icade_maps[j][input_keymaps_translate_rk_to_keysym(RETROK_n)].key = RETROK_a; + icade_maps[j][input_keymaps_translate_rk_to_keysym(RETROK_p)].key = RETROK_w; + icade_maps[j][input_keymaps_translate_rk_to_keysym(RETROK_q)].key = RETROK_LEFT; + icade_maps[j][input_keymaps_translate_rk_to_keysym(RETROK_r)].key = RETROK_x; + icade_maps[j][input_keymaps_translate_rk_to_keysym(RETROK_u)].key = RETROK_z; + icade_maps[j][input_keymaps_translate_rk_to_keysym(RETROK_w)].key = RETROK_UP; + icade_maps[j][input_keymaps_translate_rk_to_keysym(RETROK_x)].key = RETROK_DOWN; + icade_maps[j][input_keymaps_translate_rk_to_keysym(RETROK_z)].key = RETROK_DOWN; + + icade_maps[j][input_keymaps_translate_rk_to_keysym(RETROK_c)].up = true; + icade_maps[j][input_keymaps_translate_rk_to_keysym(RETROK_e)].up = true; + icade_maps[j][input_keymaps_translate_rk_to_keysym(RETROK_f)].up = true; + icade_maps[j][input_keymaps_translate_rk_to_keysym(RETROK_m)].up = true; + icade_maps[j][input_keymaps_translate_rk_to_keysym(RETROK_n)].up = true; + icade_maps[j][input_keymaps_translate_rk_to_keysym(RETROK_p)].up = true; + icade_maps[j][input_keymaps_translate_rk_to_keysym(RETROK_q)].up = true; + icade_maps[j][input_keymaps_translate_rk_to_keysym(RETROK_r)].up = true; + icade_maps[j][input_keymaps_translate_rk_to_keysym(RETROK_z)].up = true; + + initialized = true; + } + + if ((*code < 0x20) && (icade_maps[kb_type_idx][*code].key != RETROK_UNKNOWN)) { - bool up; - int button; - } icade_map[0x20] = - { - { false, -1 }, { false, -1 }, { false, -1 }, { false, -1 }, // 0 - { false, 2 }, { false, -1 }, { true , 3 }, { false, 3 }, // 4 - { true , 0 }, { true, 5 }, { true , 7 }, { false, 8 }, // 8 - { false, 6 }, { false, 9 }, { false, 10 }, { false, 11 }, // C - { true , 6 }, { true , 9 }, { false, 7 }, { true, 10 }, // 0 - { true , 2 }, { true , 8 }, { false, -1 }, { true , 4 }, // 4 - { false, 5 }, { true , 11 }, { false, 0 }, { false, 1 }, // 8 - { false, 4 }, { true , 1 }, { false, -1 }, { false, -1 } // C - }; - driver_t *driver = driver_get_ptr(); - cocoa_input_data_t *apple = (cocoa_input_data_t*)driver->input_data; - - if ((keycode < 0x20) && (icade_map[keycode].button >= 0)) - { - const int button = icade_map[keycode].button; - - if (icade_map[keycode].up) - BIT32_CLEAR(apple->icade_buttons, button); - else - BIT32_SET(apple->icade_buttons, button); + *keydown = icade_maps[kb_type_idx][*code].up ? false : true; + ret = true; + *code = input_keymaps_translate_rk_to_keysym(icade_maps[kb_type_idx][*code].key); } + + return ret; } #endif @@ -153,8 +200,10 @@ void cocoa_input_keyboard_event(bool down, #if TARGET_OS_IPHONE if (settings->input.icade_enable) { - handle_icade_event(code); - return; + if (handle_icade_event(&code, &down)) + character = 0; + else + code = 0; } else if (settings->input.small_keyboard_enable) { From b5d4aeb5da52e0a97deecc5880c416a1b121c41c Mon Sep 17 00:00:00 2001 From: twinaphex Date: Fri, 13 Nov 2015 20:04:44 +0100 Subject: [PATCH 195/216] (keyboard_event_apple.c) Style nits --- input/drivers_keyboard/keyboard_event_apple.c | 146 +++++++++--------- 1 file changed, 73 insertions(+), 73 deletions(-) diff --git a/input/drivers_keyboard/keyboard_event_apple.c b/input/drivers_keyboard/keyboard_event_apple.c index 9bd9e79933..8c252352cc 100644 --- a/input/drivers_keyboard/keyboard_event_apple.c +++ b/input/drivers_keyboard/keyboard_event_apple.c @@ -36,14 +36,14 @@ * check keycode.h for license. */ static const unsigned char MAC_NATIVE_TO_HID[128] = { - 4, 22, 7, 9, 11, 10, 29, 27, 6, 25,255, 5, 20, 26, 8, 21, - 28, 23, 30, 31, 32, 33, 35, 34, 46, 38, 36, 45, 37, 39, 48, 18, - 24, 47, 12, 19, 40, 15, 13, 52, 14, 51, 49, 54, 56, 17, 16, 55, - 43, 44, 53, 42,255, 41,231,227,225, 57,226,224,229,230,228,255, -108, 99,255, 85,255, 87,255, 83,255,255,255, 84, 88,255, 86,109, -110,103, 98, 89, 90, 91, 92, 93, 94, 95,111, 96, 97,255,255,255, - 62, 63, 64, 60, 65, 66,255, 68,255,104,107,105,255, 67,255, 69, -255,106,117, 74, 75, 76, 61, 77, 59, 78, 58, 80, 79, 81, 82,255 + 4, 22, 7, 9, 11, 10, 29, 27, 6, 25,255, 5, 20, 26, 8, 21, + 28, 23, 30, 31, 32, 33, 35, 34, 46, 38, 36, 45, 37, 39, 48, 18, + 24, 47, 12, 19, 40, 15, 13, 52, 14, 51, 49, 54, 56, 17, 16, 55, + 43, 44, 53, 42,255, 41,231,227,225, 57,226,224,229,230,228,255, + 108, 99,255, 85,255, 87,255, 83,255,255,255, 84, 88,255, 86,109, + 110,103, 98, 89, 90, 91, 92, 93, 94, 95,111, 96, 97,255,255,255, + 62, 63, 64, 60, 65, 66,255, 68,255,104,107,105,255, 67,255, 69, + 255,106,117, 74, 75, 76, 61, 77, 59, 78, 58, 80, 79, 81, 82,255 }; #define HIDKEY(X) (X < 128) ? MAC_NATIVE_TO_HID[X] : 0 @@ -74,7 +74,7 @@ static bool handle_small_keyboard(unsigned* code, bool down) driver_t *driver = driver_get_ptr(); cocoa_input_data_t *apple = (cocoa_input_data_t*)driver->input_data; unsigned translated_code = 0; - + if (!map_initialized) { int i; @@ -89,15 +89,15 @@ static bool handle_small_keyboard(unsigned* code, bool down) *code = 0; return true; } - + translated_code = (*code < 128) ? mapping[*code] : 0; - + /* Allow old keys to be released. */ if (!down && apple->key_state[*code]) return false; if ((!down && apple->key_state[translated_code]) || - apple->small_keyboard_active) + apple->small_keyboard_active) { *code = translated_code; return true; @@ -110,8 +110,8 @@ extern const struct rarch_key_map rarch_key_map_apple_hid[]; typedef struct icade_map { - bool up; - enum retro_key key; + bool up; + enum retro_key key; } icade_map_t; #define MAX_ICADE_PROFILES 2 @@ -121,67 +121,67 @@ static icade_map_t icade_maps[MAX_ICADE_PROFILES][MAX_ICADE_KEYS]; static bool handle_icade_event(unsigned *code, bool *keydown) { - static bool initialized = false; - bool ret = false; - unsigned kb_type_idx = 1; - - if (!initialized) - { - unsigned i; - unsigned j = 0; - - for (j = 0; j < MAX_ICADE_PROFILES; j++) - { - for (i = 0; i < MAX_ICADE_KEYS; i++) - { + static bool initialized = false; + bool ret = false; + unsigned kb_type_idx = 1; + + if (!initialized) + { + unsigned i; + unsigned j = 0; + + for (j = 0; j < MAX_ICADE_PROFILES; j++) + { + for (i = 0; i < MAX_ICADE_KEYS; i++) + { icade_maps[j][i].key = RETROK_UNKNOWN; icade_maps[j][i].up = false; - } - } - - /* iPega PG-9017 */ - j = 1; - - icade_maps[j][input_keymaps_translate_rk_to_keysym(RETROK_a)].key = RETROK_LEFT; - icade_maps[j][input_keymaps_translate_rk_to_keysym(RETROK_c)].key = RETROK_RIGHT; - icade_maps[j][input_keymaps_translate_rk_to_keysym(RETROK_d)].key = RETROK_RIGHT; - icade_maps[j][input_keymaps_translate_rk_to_keysym(RETROK_e)].key = RETROK_UP; - icade_maps[j][input_keymaps_translate_rk_to_keysym(RETROK_f)].key = RETROK_z; - icade_maps[j][input_keymaps_translate_rk_to_keysym(RETROK_h)].key = RETROK_x; - icade_maps[j][input_keymaps_translate_rk_to_keysym(RETROK_i)].key = RETROK_q; - icade_maps[j][input_keymaps_translate_rk_to_keysym(RETROK_j)].key = RETROK_a; - icade_maps[j][input_keymaps_translate_rk_to_keysym(RETROK_k)].key = RETROK_w; - icade_maps[j][input_keymaps_translate_rk_to_keysym(RETROK_m)].key = RETROK_q; - icade_maps[j][input_keymaps_translate_rk_to_keysym(RETROK_n)].key = RETROK_a; - icade_maps[j][input_keymaps_translate_rk_to_keysym(RETROK_p)].key = RETROK_w; - icade_maps[j][input_keymaps_translate_rk_to_keysym(RETROK_q)].key = RETROK_LEFT; - icade_maps[j][input_keymaps_translate_rk_to_keysym(RETROK_r)].key = RETROK_x; - icade_maps[j][input_keymaps_translate_rk_to_keysym(RETROK_u)].key = RETROK_z; - icade_maps[j][input_keymaps_translate_rk_to_keysym(RETROK_w)].key = RETROK_UP; - icade_maps[j][input_keymaps_translate_rk_to_keysym(RETROK_x)].key = RETROK_DOWN; - icade_maps[j][input_keymaps_translate_rk_to_keysym(RETROK_z)].key = RETROK_DOWN; - - icade_maps[j][input_keymaps_translate_rk_to_keysym(RETROK_c)].up = true; - icade_maps[j][input_keymaps_translate_rk_to_keysym(RETROK_e)].up = true; - icade_maps[j][input_keymaps_translate_rk_to_keysym(RETROK_f)].up = true; - icade_maps[j][input_keymaps_translate_rk_to_keysym(RETROK_m)].up = true; - icade_maps[j][input_keymaps_translate_rk_to_keysym(RETROK_n)].up = true; - icade_maps[j][input_keymaps_translate_rk_to_keysym(RETROK_p)].up = true; - icade_maps[j][input_keymaps_translate_rk_to_keysym(RETROK_q)].up = true; - icade_maps[j][input_keymaps_translate_rk_to_keysym(RETROK_r)].up = true; - icade_maps[j][input_keymaps_translate_rk_to_keysym(RETROK_z)].up = true; - - initialized = true; - } + } + } + + /* iPega PG-9017 */ + j = 1; + + icade_maps[j][input_keymaps_translate_rk_to_keysym(RETROK_a)].key = RETROK_LEFT; + icade_maps[j][input_keymaps_translate_rk_to_keysym(RETROK_c)].key = RETROK_RIGHT; + icade_maps[j][input_keymaps_translate_rk_to_keysym(RETROK_d)].key = RETROK_RIGHT; + icade_maps[j][input_keymaps_translate_rk_to_keysym(RETROK_e)].key = RETROK_UP; + icade_maps[j][input_keymaps_translate_rk_to_keysym(RETROK_f)].key = RETROK_z; + icade_maps[j][input_keymaps_translate_rk_to_keysym(RETROK_h)].key = RETROK_x; + icade_maps[j][input_keymaps_translate_rk_to_keysym(RETROK_i)].key = RETROK_q; + icade_maps[j][input_keymaps_translate_rk_to_keysym(RETROK_j)].key = RETROK_a; + icade_maps[j][input_keymaps_translate_rk_to_keysym(RETROK_k)].key = RETROK_w; + icade_maps[j][input_keymaps_translate_rk_to_keysym(RETROK_m)].key = RETROK_q; + icade_maps[j][input_keymaps_translate_rk_to_keysym(RETROK_n)].key = RETROK_a; + icade_maps[j][input_keymaps_translate_rk_to_keysym(RETROK_p)].key = RETROK_w; + icade_maps[j][input_keymaps_translate_rk_to_keysym(RETROK_q)].key = RETROK_LEFT; + icade_maps[j][input_keymaps_translate_rk_to_keysym(RETROK_r)].key = RETROK_x; + icade_maps[j][input_keymaps_translate_rk_to_keysym(RETROK_u)].key = RETROK_z; + icade_maps[j][input_keymaps_translate_rk_to_keysym(RETROK_w)].key = RETROK_UP; + icade_maps[j][input_keymaps_translate_rk_to_keysym(RETROK_x)].key = RETROK_DOWN; + icade_maps[j][input_keymaps_translate_rk_to_keysym(RETROK_z)].key = RETROK_DOWN; + + icade_maps[j][input_keymaps_translate_rk_to_keysym(RETROK_c)].up = true; + icade_maps[j][input_keymaps_translate_rk_to_keysym(RETROK_e)].up = true; + icade_maps[j][input_keymaps_translate_rk_to_keysym(RETROK_f)].up = true; + icade_maps[j][input_keymaps_translate_rk_to_keysym(RETROK_m)].up = true; + icade_maps[j][input_keymaps_translate_rk_to_keysym(RETROK_n)].up = true; + icade_maps[j][input_keymaps_translate_rk_to_keysym(RETROK_p)].up = true; + icade_maps[j][input_keymaps_translate_rk_to_keysym(RETROK_q)].up = true; + icade_maps[j][input_keymaps_translate_rk_to_keysym(RETROK_r)].up = true; + icade_maps[j][input_keymaps_translate_rk_to_keysym(RETROK_z)].up = true; + + initialized = true; + } if ((*code < 0x20) && (icade_maps[kb_type_idx][*code].key != RETROK_UNKNOWN)) { - *keydown = icade_maps[kb_type_idx][*code].up ? false : true; - ret = true; - *code = input_keymaps_translate_rk_to_keysym(icade_maps[kb_type_idx][*code].key); + *keydown = icade_maps[kb_type_idx][*code].up ? false : true; + ret = true; + *code = input_keymaps_translate_rk_to_keysym(icade_maps[kb_type_idx][*code].key); } - - return ret; + + return ret; } #endif @@ -201,9 +201,9 @@ void cocoa_input_keyboard_event(bool down, if (settings->input.icade_enable) { if (handle_icade_event(&code, &down)) - character = 0; + character = 0; else - code = 0; + code = 0; } else if (settings->input.small_keyboard_enable) { @@ -211,12 +211,12 @@ void cocoa_input_keyboard_event(bool down, character = 0; } #endif - + if (code == 0 || code >= MAX_KEYS) return; apple->key_state[code] = down; - + input_keyboard_event(down, input_keymaps_translate_keysym_to_rk(code), character, (enum retro_mod)mod, device); From f30f2713bffac7d708358e5de14d1ab05a2cad63 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Fri, 13 Nov 2015 21:15:40 +0100 Subject: [PATCH 196/216] (iCade) Add 8-bitty configuration --- input/drivers_keyboard/keyboard_event_apple.c | 76 ++++++++++++++----- 1 file changed, 58 insertions(+), 18 deletions(-) diff --git a/input/drivers_keyboard/keyboard_event_apple.c b/input/drivers_keyboard/keyboard_event_apple.c index 8c252352cc..b770561a06 100644 --- a/input/drivers_keyboard/keyboard_event_apple.c +++ b/input/drivers_keyboard/keyboard_event_apple.c @@ -114,7 +114,7 @@ typedef struct icade_map enum retro_key key; } icade_map_t; -#define MAX_ICADE_PROFILES 2 +#define MAX_ICADE_PROFILES 3 #define MAX_ICADE_KEYS 0x100 static icade_map_t icade_maps[MAX_ICADE_PROFILES][MAX_ICADE_KEYS]; @@ -142,36 +142,76 @@ static bool handle_icade_event(unsigned *code, bool *keydown) /* iPega PG-9017 */ j = 1; - icade_maps[j][input_keymaps_translate_rk_to_keysym(RETROK_a)].key = RETROK_LEFT; - icade_maps[j][input_keymaps_translate_rk_to_keysym(RETROK_c)].key = RETROK_RIGHT; - icade_maps[j][input_keymaps_translate_rk_to_keysym(RETROK_d)].key = RETROK_RIGHT; - icade_maps[j][input_keymaps_translate_rk_to_keysym(RETROK_e)].key = RETROK_UP; - icade_maps[j][input_keymaps_translate_rk_to_keysym(RETROK_f)].key = RETROK_z; - icade_maps[j][input_keymaps_translate_rk_to_keysym(RETROK_h)].key = RETROK_x; - icade_maps[j][input_keymaps_translate_rk_to_keysym(RETROK_i)].key = RETROK_q; - icade_maps[j][input_keymaps_translate_rk_to_keysym(RETROK_j)].key = RETROK_a; - icade_maps[j][input_keymaps_translate_rk_to_keysym(RETROK_k)].key = RETROK_w; - icade_maps[j][input_keymaps_translate_rk_to_keysym(RETROK_m)].key = RETROK_q; - icade_maps[j][input_keymaps_translate_rk_to_keysym(RETROK_n)].key = RETROK_a; - icade_maps[j][input_keymaps_translate_rk_to_keysym(RETROK_p)].key = RETROK_w; + icade_maps[j][input_keymaps_translate_rk_to_keysym(RETROK_a)].key = RETROK_LEFT; icade_maps[j][input_keymaps_translate_rk_to_keysym(RETROK_q)].key = RETROK_LEFT; - icade_maps[j][input_keymaps_translate_rk_to_keysym(RETROK_r)].key = RETROK_x; - icade_maps[j][input_keymaps_translate_rk_to_keysym(RETROK_u)].key = RETROK_z; + icade_maps[j][input_keymaps_translate_rk_to_keysym(RETROK_c)].key = RETROK_RIGHT; + icade_maps[j][input_keymaps_translate_rk_to_keysym(RETROK_d)].key = RETROK_RIGHT; + icade_maps[j][input_keymaps_translate_rk_to_keysym(RETROK_e)].key = RETROK_UP; icade_maps[j][input_keymaps_translate_rk_to_keysym(RETROK_w)].key = RETROK_UP; icade_maps[j][input_keymaps_translate_rk_to_keysym(RETROK_x)].key = RETROK_DOWN; icade_maps[j][input_keymaps_translate_rk_to_keysym(RETROK_z)].key = RETROK_DOWN; + icade_maps[j][input_keymaps_translate_rk_to_keysym(RETROK_f)].key = RETROK_z; + icade_maps[j][input_keymaps_translate_rk_to_keysym(RETROK_u)].key = RETROK_z; + icade_maps[j][input_keymaps_translate_rk_to_keysym(RETROK_i)].key = RETROK_q; + icade_maps[j][input_keymaps_translate_rk_to_keysym(RETROK_m)].key = RETROK_q; + icade_maps[j][input_keymaps_translate_rk_to_keysym(RETROK_j)].key = RETROK_a; + icade_maps[j][input_keymaps_translate_rk_to_keysym(RETROK_n)].key = RETROK_a; + icade_maps[j][input_keymaps_translate_rk_to_keysym(RETROK_k)].key = RETROK_w; + icade_maps[j][input_keymaps_translate_rk_to_keysym(RETROK_p)].key = RETROK_w; + icade_maps[j][input_keymaps_translate_rk_to_keysym(RETROK_h)].key = RETROK_x; + icade_maps[j][input_keymaps_translate_rk_to_keysym(RETROK_r)].key = RETROK_x; - icade_maps[j][input_keymaps_translate_rk_to_keysym(RETROK_c)].up = true; icade_maps[j][input_keymaps_translate_rk_to_keysym(RETROK_e)].up = true; + icade_maps[j][input_keymaps_translate_rk_to_keysym(RETROK_z)].up = true; + icade_maps[j][input_keymaps_translate_rk_to_keysym(RETROK_q)].up = true; + icade_maps[j][input_keymaps_translate_rk_to_keysym(RETROK_c)].up = true; icade_maps[j][input_keymaps_translate_rk_to_keysym(RETROK_f)].up = true; icade_maps[j][input_keymaps_translate_rk_to_keysym(RETROK_m)].up = true; icade_maps[j][input_keymaps_translate_rk_to_keysym(RETROK_n)].up = true; icade_maps[j][input_keymaps_translate_rk_to_keysym(RETROK_p)].up = true; - icade_maps[j][input_keymaps_translate_rk_to_keysym(RETROK_q)].up = true; icade_maps[j][input_keymaps_translate_rk_to_keysym(RETROK_r)].up = true; - icade_maps[j][input_keymaps_translate_rk_to_keysym(RETROK_z)].up = true; + + /* 8-bitty */ + j = 2; initialized = true; + icade_maps[j][input_keymaps_translate_rk_to_keysym(RETROK_a)].key = RETROK_LEFT; + icade_maps[j][input_keymaps_translate_rk_to_keysym(RETROK_q)].key = RETROK_LEFT; + icade_maps[j][input_keymaps_translate_rk_to_keysym(RETROK_c)].key = RETROK_RIGHT; + icade_maps[j][input_keymaps_translate_rk_to_keysym(RETROK_d)].key = RETROK_RIGHT; + icade_maps[j][input_keymaps_translate_rk_to_keysym(RETROK_e)].key = RETROK_UP; + icade_maps[j][input_keymaps_translate_rk_to_keysym(RETROK_w)].key = RETROK_UP; + icade_maps[j][input_keymaps_translate_rk_to_keysym(RETROK_x)].key = RETROK_DOWN; + icade_maps[j][input_keymaps_translate_rk_to_keysym(RETROK_z)].key = RETROK_DOWN; + icade_maps[j][input_keymaps_translate_rk_to_keysym(RETROK_h)].key = RETROK_q; + icade_maps[j][input_keymaps_translate_rk_to_keysym(RETROK_r)].key = RETROK_q; + icade_maps[j][input_keymaps_translate_rk_to_keysym(RETROK_j)].key = RETROK_w; + icade_maps[j][input_keymaps_translate_rk_to_keysym(RETROK_n)].key = RETROK_w; + icade_maps[j][input_keymaps_translate_rk_to_keysym(RETROK_i)].key = RETROK_a; + icade_maps[j][input_keymaps_translate_rk_to_keysym(RETROK_m)].key = RETROK_a; + icade_maps[j][input_keymaps_translate_rk_to_keysym(RETROK_k)].key = RETROK_z; + icade_maps[j][input_keymaps_translate_rk_to_keysym(RETROK_p)].key = RETROK_z; + icade_maps[j][input_keymaps_translate_rk_to_keysym(RETROK_y)].key = RETROK_RSHIFT; + icade_maps[j][input_keymaps_translate_rk_to_keysym(RETROK_t)].key = RETROK_RSHIFT; + icade_maps[j][input_keymaps_translate_rk_to_keysym(RETROK_u)].key = RETROK_RETURN; + icade_maps[j][input_keymaps_translate_rk_to_keysym(RETROK_f)].key = RETROK_RETURN; + icade_maps[j][input_keymaps_translate_rk_to_keysym(RETROK_l)].key = RETROK_x; + icade_maps[j][input_keymaps_translate_rk_to_keysym(RETROK_v)].key = RETROK_x; + icade_maps[j][input_keymaps_translate_rk_to_keysym(RETROK_o)].key = RETROK_s; + icade_maps[j][input_keymaps_translate_rk_to_keysym(RETROK_g)].key = RETROK_s; + + icade_maps[j][input_keymaps_translate_rk_to_keysym(RETROK_e)].up = true; + icade_maps[j][input_keymaps_translate_rk_to_keysym(RETROK_z)].up = true; + icade_maps[j][input_keymaps_translate_rk_to_keysym(RETROK_q)].up = true; + icade_maps[j][input_keymaps_translate_rk_to_keysym(RETROK_c)].up = true; + icade_maps[j][input_keymaps_translate_rk_to_keysym(RETROK_r)].up = true; + icade_maps[j][input_keymaps_translate_rk_to_keysym(RETROK_n)].up = true; + icade_maps[j][input_keymaps_translate_rk_to_keysym(RETROK_m)].up = true; + icade_maps[j][input_keymaps_translate_rk_to_keysym(RETROK_p)].up = true; + icade_maps[j][input_keymaps_translate_rk_to_keysym(RETROK_t)].up = true; + icade_maps[j][input_keymaps_translate_rk_to_keysym(RETROK_f)].up = true; + icade_maps[j][input_keymaps_translate_rk_to_keysym(RETROK_v)].up = true; + icade_maps[j][input_keymaps_translate_rk_to_keysym(RETROK_g)].up = true; } if ((*code < 0x20) && (icade_maps[kb_type_idx][*code].key != RETROK_UNKNOWN)) From fc097f47e87de9b3aa6b34f1aa837275091294c2 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Fri, 13 Nov 2015 21:25:43 +0100 Subject: [PATCH 197/216] (iPega PG-9017) Hook up X button --- input/drivers_keyboard/keyboard_event_apple.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/input/drivers_keyboard/keyboard_event_apple.c b/input/drivers_keyboard/keyboard_event_apple.c index b770561a06..6ff32ede25 100644 --- a/input/drivers_keyboard/keyboard_event_apple.c +++ b/input/drivers_keyboard/keyboard_event_apple.c @@ -160,6 +160,8 @@ static bool handle_icade_event(unsigned *code, bool *keydown) icade_maps[j][input_keymaps_translate_rk_to_keysym(RETROK_p)].key = RETROK_w; icade_maps[j][input_keymaps_translate_rk_to_keysym(RETROK_h)].key = RETROK_x; icade_maps[j][input_keymaps_translate_rk_to_keysym(RETROK_r)].key = RETROK_x; + icade_maps[j][input_keymaps_translate_rk_to_keysym(RETROK_j)].key = RETROK_s; + icade_maps[j][input_keymaps_translate_rk_to_keysym(RETROK_n)].key = RETROK_s; icade_maps[j][input_keymaps_translate_rk_to_keysym(RETROK_e)].up = true; icade_maps[j][input_keymaps_translate_rk_to_keysym(RETROK_z)].up = true; @@ -168,6 +170,7 @@ static bool handle_icade_event(unsigned *code, bool *keydown) icade_maps[j][input_keymaps_translate_rk_to_keysym(RETROK_f)].up = true; icade_maps[j][input_keymaps_translate_rk_to_keysym(RETROK_m)].up = true; icade_maps[j][input_keymaps_translate_rk_to_keysym(RETROK_n)].up = true; + icade_maps[j][input_keymaps_translate_rk_to_keysym(RETROK_n)].up = true; icade_maps[j][input_keymaps_translate_rk_to_keysym(RETROK_p)].up = true; icade_maps[j][input_keymaps_translate_rk_to_keysym(RETROK_r)].up = true; From 8e373af966c0c74262d583ba17137d9b144df574 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Fri, 13 Nov 2015 21:28:13 +0100 Subject: [PATCH 198/216] (iPega) Should fix X button --- input/drivers_keyboard/keyboard_event_apple.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/input/drivers_keyboard/keyboard_event_apple.c b/input/drivers_keyboard/keyboard_event_apple.c index 6ff32ede25..026f81c70d 100644 --- a/input/drivers_keyboard/keyboard_event_apple.c +++ b/input/drivers_keyboard/keyboard_event_apple.c @@ -160,8 +160,8 @@ static bool handle_icade_event(unsigned *code, bool *keydown) icade_maps[j][input_keymaps_translate_rk_to_keysym(RETROK_p)].key = RETROK_w; icade_maps[j][input_keymaps_translate_rk_to_keysym(RETROK_h)].key = RETROK_x; icade_maps[j][input_keymaps_translate_rk_to_keysym(RETROK_r)].key = RETROK_x; - icade_maps[j][input_keymaps_translate_rk_to_keysym(RETROK_j)].key = RETROK_s; - icade_maps[j][input_keymaps_translate_rk_to_keysym(RETROK_n)].key = RETROK_s; + icade_maps[j][input_keymaps_translate_rk_to_keysym(RETROK_y)].key = RETROK_s; + icade_maps[j][input_keymaps_translate_rk_to_keysym(RETROK_t)].key = RETROK_s; icade_maps[j][input_keymaps_translate_rk_to_keysym(RETROK_e)].up = true; icade_maps[j][input_keymaps_translate_rk_to_keysym(RETROK_z)].up = true; @@ -169,7 +169,7 @@ static bool handle_icade_event(unsigned *code, bool *keydown) icade_maps[j][input_keymaps_translate_rk_to_keysym(RETROK_c)].up = true; icade_maps[j][input_keymaps_translate_rk_to_keysym(RETROK_f)].up = true; icade_maps[j][input_keymaps_translate_rk_to_keysym(RETROK_m)].up = true; - icade_maps[j][input_keymaps_translate_rk_to_keysym(RETROK_n)].up = true; + icade_maps[j][input_keymaps_translate_rk_to_keysym(RETROK_t)].up = true; icade_maps[j][input_keymaps_translate_rk_to_keysym(RETROK_n)].up = true; icade_maps[j][input_keymaps_translate_rk_to_keysym(RETROK_p)].up = true; icade_maps[j][input_keymaps_translate_rk_to_keysym(RETROK_r)].up = true; From e0b5925c24b411c2a3569ab770cd6a9ba637937b Mon Sep 17 00:00:00 2001 From: twinaphex Date: Fri, 13 Nov 2015 21:42:58 +0100 Subject: [PATCH 199/216] Remove now unused icade code --- input/drivers/cocoa_input.c | 20 -------------------- input/drivers/cocoa_input.h | 5 ----- ui/drivers/cocoa/cocoatouch_menu.m | 2 -- ui/drivers/ui_cocoatouch.m | 2 -- 4 files changed, 29 deletions(-) diff --git a/input/drivers/cocoa_input.c b/input/drivers/cocoa_input.c index 81e2a699ed..1bb08e766a 100644 --- a/input/drivers/cocoa_input.c +++ b/input/drivers/cocoa_input.c @@ -125,17 +125,6 @@ const struct apple_key_name_map_entry apple_key_name_map[] = { "nul", 0x00}, }; -#if TARGET_OS_IPHONE -void cocoa_input_reset_icade_buttons(void) -{ - driver_t *driver = driver_get_ptr(); - cocoa_input_data_t *apple = (cocoa_input_data_t*)driver->input_data; - - if (apple) - apple->icade_buttons = 0; -} -#endif - int32_t cocoa_input_find_any_key(void) { unsigned i; @@ -160,10 +149,6 @@ static int cocoa_input_find_any_button_ret(cocoa_input_data_t *apple, { settings_t *settings = config_get_ptr(); unsigned i; -#if TARGET_OS_IPHONE - if (port == 0 && settings->input.icade_enable) - BIT32_SET(buttons, apple->icade_buttons); -#endif if (buttons) for (i = 0; i < 32; i++) @@ -263,11 +248,6 @@ static void cocoa_input_poll(void *data) if (apple->joypad) apple->joypad->poll(); -#if TARGET_OS_IPHONE - if (settings->input.icade_enable) - BIT32_SET(apple->buttons[0], apple->icade_buttons); -#endif - apple->mouse_x_last = apple->mouse_rel_x; apple->mouse_y_last = apple->mouse_rel_y; } diff --git a/input/drivers/cocoa_input.h b/input/drivers/cocoa_input.h index 818cac0a5e..a2a199699f 100644 --- a/input/drivers/cocoa_input.h +++ b/input/drivers/cocoa_input.h @@ -61,16 +61,11 @@ typedef struct #if TARGET_OS_IPHONE uint32_t mfi_buttons[MAX_USERS]; bool small_keyboard_active; - uint32_t icade_buttons; #endif const input_device_driver_t *joypad; } cocoa_input_data_t; -#if TARGET_OS_IPHONE -void cocoa_input_reset_icade_buttons(void); -#endif - #ifdef __cplusplus extern "C" { #endif diff --git a/ui/drivers/cocoa/cocoatouch_menu.m b/ui/drivers/cocoa/cocoatouch_menu.m index 9c0ca8a8b2..323ba02bb6 100644 --- a/ui/drivers/cocoa/cocoatouch_menu.m +++ b/ui/drivers/cocoa/cocoatouch_menu.m @@ -261,8 +261,6 @@ static void RunActionSheet(const char* title, const struct string_list* items, [self.bindTimer invalidate]; self.bindTimer = nil; - - cocoa_input_reset_icade_buttons(); } - (void)alertView:(UIAlertView*)alertView clickedButtonAtIndex:(NSInteger)buttonIndex diff --git a/ui/drivers/ui_cocoatouch.m b/ui/drivers/ui_cocoatouch.m index 9957a61b8d..1ca03c4614 100644 --- a/ui/drivers/ui_cocoatouch.m +++ b/ui/drivers/ui_cocoatouch.m @@ -347,9 +347,7 @@ enum - (void)navigationController:(UINavigationController *)navigationController willShowViewController:(UIViewController *)viewController animated:(BOOL)animated { - cocoa_input_reset_icade_buttons(); [self setToolbarHidden:![[viewController toolbarItems] count] animated:YES]; - [self refreshSystemConfig]; } From 1b05556b068238245df5866a669d05f58481ba49 Mon Sep 17 00:00:00 2001 From: Twinaphex Date: Fri, 13 Nov 2015 21:44:08 +0100 Subject: [PATCH 200/216] remove some unused variables --- input/drivers/cocoa_input.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/input/drivers/cocoa_input.c b/input/drivers/cocoa_input.c index 1bb08e766a..f63214c59a 100644 --- a/input/drivers/cocoa_input.c +++ b/input/drivers/cocoa_input.c @@ -147,7 +147,6 @@ int32_t cocoa_input_find_any_key(void) static int cocoa_input_find_any_button_ret(cocoa_input_data_t *apple, unsigned buttons, unsigned port) { - settings_t *settings = config_get_ptr(); unsigned i; if (buttons) @@ -233,7 +232,6 @@ static void *cocoa_input_init(void) static void cocoa_input_poll(void *data) { uint32_t i; - settings_t *settings = config_get_ptr(); cocoa_input_data_t *apple = (cocoa_input_data_t*)data; for (i = 0; i < apple->touch_count; i++) From 07785ed6407470ae3b04b2fb060da69b65a15067 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Fri, 13 Nov 2015 22:11:39 +0100 Subject: [PATCH 201/216] Add Keyboard Gamepad Mapping Type and Keyboard Gamepad Mapping Enable --- configuration.c | 15 ++++++++------ configuration.h | 3 ++- menu/cbs/menu_cbs_get_value.c | 38 +++++++++++++++++++++++++++++++++++ menu/intl/menu_hash_us.c | 6 +++++- menu/menu_displaylist.c | 6 ++++-- menu/menu_hash.h | 3 +++ menu/menu_setting.c | 18 ++++++++++++++--- 7 files changed, 76 insertions(+), 13 deletions(-) diff --git a/configuration.c b/configuration.c index 327a1f1a3d..f466ef3b27 100644 --- a/configuration.c +++ b/configuration.c @@ -461,9 +461,10 @@ static void config_set_defaults(void) settings->load_dummy_on_core_shutdown = load_dummy_on_core_shutdown; #if TARGET_OS_IPHONE - settings->input.icade_enable = true; - settings->input.small_keyboard_enable = false; + settings->input.small_keyboard_enable = false; #endif + settings->input.keyboard_gamepad_enable = true; + settings->input.keyboard_gamepad_mapping_type = 1; #ifdef HAVE_FFMPEG settings->multimedia.builtin_mediaplayer_enable = true; #else @@ -1576,9 +1577,10 @@ static bool config_load_file(const char *path, bool set_defaults) CONFIG_GET_BOOL_BASE(conf, global, perfcnt_enable, "perfcnt_enable"); #if TARGET_OS_IPHONE - CONFIG_GET_BOOL_BASE(conf, settings, input.small_keyboard_enable, "small_keyboard_enable"); - CONFIG_GET_BOOL_BASE(conf, settings, input.icade_enable, "icade_enable"); + CONFIG_GET_BOOL_BASE(conf, settings, input.small_keyboard_enable, "small_keyboard_enable"); #endif + CONFIG_GET_BOOL_BASE(conf, settings, input.keyboard_gamepad_enable, "keyboard_gamepad_enable"); + CONFIG_GET_INT_BASE(conf, settings, input.keyboard_gamepad_mapping_type, "keyboard_gamepad_mapping_type"); config_get_path(conf, "recording_output_directory", global->record.output_dir, sizeof(global->record.output_dir)); @@ -2790,9 +2792,10 @@ bool config_save_file(const char *path) config_set_bool(conf, "perfcnt_enable", global->perfcnt_enable); #if TARGET_OS_IPHONE - config_set_bool(conf, "small_keyboard_enable", settings->input.small_keyboard_enable); - config_set_bool(conf, "icade_enable", settings->input.icade_enable); + config_set_bool(conf, "small_keyboard_enable", settings->input.small_keyboard_enable); #endif + config_set_bool(conf, "keyboard_gamepad_enable", settings->input.keyboard_gamepad_enable); + config_set_int(conf, "keyboard_gamepad_mapping_type", settings->input.keyboard_gamepad_mapping_type); config_set_bool(conf, "core_set_supports_no_game_enable", settings->core.set_supports_no_game_enable); diff --git a/configuration.h b/configuration.h index 40946f11ac..25c824c1c4 100644 --- a/configuration.h +++ b/configuration.h @@ -252,9 +252,10 @@ typedef struct settings bool back_as_menu_toggle_enable; #if TARGET_OS_IPHONE - bool icade_enable; bool small_keyboard_enable; #endif + bool keyboard_gamepad_enable; + unsigned keyboard_gamepad_mapping_type; } input; struct diff --git a/menu/cbs/menu_cbs_get_value.c b/menu/cbs/menu_cbs_get_value.c index 2288dcfc87..7c1cdd5826 100644 --- a/menu/cbs/menu_cbs_get_value.c +++ b/menu/cbs/menu_cbs_get_value.c @@ -605,6 +605,40 @@ static void menu_action_setting_disp_set_label_menu_disk_index( snprintf(s, len, "%u", current + 1); } +static void menu_action_setting_disp_set_label_menu_input_keyboard_gamepad_mapping_type( + file_list_t* list, + unsigned *w, unsigned type, unsigned i, + const char *label, + char *s, size_t len, + const char *entry_label, + const char *path, + char *s2, size_t len2) +{ + settings_t *settings = config_get_ptr(); + unsigned width = 0, height = 0; + + *w = 19; + *s = '\0'; + + (void)width; + (void)height; + + strlcpy(s2, path, len2); + + switch (settings->input.keyboard_gamepad_mapping_type) + { + case 0: + strlcpy(s, "None", len); + break; + case 1: + strlcpy(s, "iPega PG-9017", len); + break; + case 2: + strlcpy(s, "8-bitty", len); + break; + } +} + static void menu_action_setting_disp_set_label_menu_video_resolution( file_list_t* list, unsigned *w, unsigned type, unsigned i, @@ -1052,6 +1086,10 @@ static int menu_cbs_init_bind_get_string_representation_compare_label( BIND_ACTION_GET_VALUE(cbs, menu_action_setting_disp_set_label_menu_video_resolution); break; + case MENU_LABEL_INPUT_KEYBOARD_GAMEPAD_MAPPING_TYPE: + BIND_ACTION_GET_VALUE(cbs, + menu_action_setting_disp_set_label_menu_input_keyboard_gamepad_mapping_type); + break; case MENU_LABEL_CONTENT_COLLECTION_LIST: case MENU_LABEL_LOAD_CONTENT_HISTORY: case MENU_LABEL_DOWNLOADED_FILE_DETECT_CORE_LIST: diff --git a/menu/intl/menu_hash_us.c b/menu/intl/menu_hash_us.c index f84aff0183..aaa4fd6eca 100644 --- a/menu/intl/menu_hash_us.c +++ b/menu/intl/menu_hash_us.c @@ -28,6 +28,8 @@ static const char *menu_hash_to_str_us_label(uint32_t hash) { case MENU_LABEL_INPUT_ICADE_ENABLE: return "input_icade_enable"; + case MENU_LABEL_INPUT_KEYBOARD_GAMEPAD_MAPPING_TYPE: + return "keyboard_gamepad_mapping_type"; case MENU_LABEL_INPUT_SMALL_KEYBOARD_ENABLE: return "input_small_keyboard_enable"; case MENU_LABEL_SAVE_CURRENT_CONFIG: @@ -695,7 +697,9 @@ const char *menu_hash_to_str_us(uint32_t hash) switch (hash) { case MENU_LABEL_VALUE_INPUT_ICADE_ENABLE: - return "iCade Enable"; + return "Keyboard Gamepad Mapping Enable"; + case MENU_LABEL_VALUE_INPUT_KEYBOARD_GAMEPAD_MAPPING_TYPE: + return "Keyboard Gamepad Mapping Type"; case MENU_LABEL_VALUE_INPUT_SMALL_KEYBOARD_ENABLE: return "Small Keyboard Enable"; case MENU_LABEL_VALUE_SAVE_CURRENT_CONFIG: diff --git a/menu/menu_displaylist.c b/menu/menu_displaylist.c index ff4988689c..f3de686515 100644 --- a/menu/menu_displaylist.c +++ b/menu/menu_displaylist.c @@ -2608,11 +2608,13 @@ int menu_displaylist_push_list(menu_displaylist_info_t *info, unsigned type) ret = menu_displaylist_parse_settings(menu, info, menu_hash_to_str(MENU_LABEL_INPUT_MAX_USERS), PARSE_ONLY_UINT, false); #if TARGET_OS_IPHONE - ret = menu_displaylist_parse_settings(menu, info, - menu_hash_to_str(MENU_LABEL_INPUT_ICADE_ENABLE), PARSE_ONLY_BOOL, false); ret = menu_displaylist_parse_settings(menu, info, menu_hash_to_str(MENU_LABEL_INPUT_SMALL_KEYBOARD_ENABLE), PARSE_ONLY_BOOL, false); #endif + ret = menu_displaylist_parse_settings(menu, info, + menu_hash_to_str(MENU_LABEL_INPUT_ICADE_ENABLE), PARSE_ONLY_BOOL, false); + ret = menu_displaylist_parse_settings(menu, info, + menu_hash_to_str(MENU_LABEL_INPUT_KEYBOARD_GAMEPAD_MAPPING_TYPE), PARSE_ONLY_UINT, false); #ifdef ANDROID ret = menu_displaylist_parse_settings(menu, info, menu_hash_to_str(MENU_LABEL_INPUT_BACK_AS_MENU_TOGGLE_ENABLE), PARSE_ONLY_BOOL, false); diff --git a/menu/menu_hash.h b/menu/menu_hash.h index ea27bd774a..eb32a6fc06 100644 --- a/menu/menu_hash.h +++ b/menu/menu_hash.h @@ -22,6 +22,9 @@ extern "C" { #endif +#define MENU_LABEL_VALUE_INPUT_KEYBOARD_GAMEPAD_MAPPING_TYPE 0x507c52f3U +#define MENU_LABEL_INPUT_KEYBOARD_GAMEPAD_MAPPING_TYPE 0x3665cbb0U + #define MENU_LABEL_CHEEVOS_DESCRIPTION 0x7e00e0f5U #define MENU_LABEL_VALUE_CHEEVOS_DESCRIPTION 0xab3975d6U diff --git a/menu/menu_setting.c b/menu/menu_setting.c index e3117c9668..e0338ca1d3 100644 --- a/menu/menu_setting.c +++ b/menu/menu_setting.c @@ -4929,12 +4929,11 @@ static bool setting_append_list_input_options( general_read_handler); menu_settings_list_current_add_range(list, list_info, 1, MAX_USERS, 1, true, true); -#if TARGET_OS_IPHONE CONFIG_BOOL( - settings->input.icade_enable, + settings->input.keyboard_gamepad_enable, menu_hash_to_str(MENU_LABEL_INPUT_ICADE_ENABLE), menu_hash_to_str(MENU_LABEL_VALUE_INPUT_ICADE_ENABLE), - true, + false, menu_hash_to_str(MENU_VALUE_OFF), menu_hash_to_str(MENU_VALUE_ON), group_info.name, @@ -4943,6 +4942,19 @@ static bool setting_append_list_input_options( general_write_handler, general_read_handler); + CONFIG_UINT( + settings->input.keyboard_gamepad_mapping_type, + menu_hash_to_str(MENU_LABEL_INPUT_KEYBOARD_GAMEPAD_MAPPING_TYPE), + menu_hash_to_str(MENU_LABEL_VALUE_INPUT_KEYBOARD_GAMEPAD_MAPPING_TYPE), + 1, + group_info.name, + subgroup_info.name, + parent_group, + general_write_handler, + general_read_handler); + menu_settings_list_current_add_range(list, list_info, 0, 2, 1, true, true); + +#if TARGET_OS_IPHONE CONFIG_BOOL( settings->input.small_keyboard_enable, menu_hash_to_str(MENU_LABEL_INPUT_SMALL_KEYBOARD_ENABLE), From 3282c16498839a2838fa9935fc68e113de45cf98 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Fri, 13 Nov 2015 22:12:49 +0100 Subject: [PATCH 202/216] (keyboard_event_apple) Hook up gamepad mapping type setting --- input/drivers_keyboard/keyboard_event_apple.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/input/drivers_keyboard/keyboard_event_apple.c b/input/drivers_keyboard/keyboard_event_apple.c index 026f81c70d..6a61e8882f 100644 --- a/input/drivers_keyboard/keyboard_event_apple.c +++ b/input/drivers_keyboard/keyboard_event_apple.c @@ -121,9 +121,10 @@ static icade_map_t icade_maps[MAX_ICADE_PROFILES][MAX_ICADE_KEYS]; static bool handle_icade_event(unsigned *code, bool *keydown) { + settings_t *settings = config_get_ptr(); static bool initialized = false; bool ret = false; - unsigned kb_type_idx = 1; + unsigned kb_type_idx = settings->input.keyboard_gamepad_mapping_type; if (!initialized) { From 983b488d597e02f4efa1b175ca48f08844c527aa Mon Sep 17 00:00:00 2001 From: Twinaphex Date: Fri, 13 Nov 2015 22:13:57 +0100 Subject: [PATCH 203/216] (iOS) Buildfix --- input/drivers_keyboard/keyboard_event_apple.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/input/drivers_keyboard/keyboard_event_apple.c b/input/drivers_keyboard/keyboard_event_apple.c index 6a61e8882f..8441ed731a 100644 --- a/input/drivers_keyboard/keyboard_event_apple.c +++ b/input/drivers_keyboard/keyboard_event_apple.c @@ -242,7 +242,7 @@ void cocoa_input_keyboard_event(bool down, code = HIDKEY(code); #if TARGET_OS_IPHONE - if (settings->input.icade_enable) + if (settings->input.keyboard_gamepad_enable) { if (handle_icade_event(&code, &down)) character = 0; From d72090f5e986de862aa1f2ac1d31530b538d1e95 Mon Sep 17 00:00:00 2001 From: Twinaphex Date: Sat, 14 Nov 2015 01:48:16 +0100 Subject: [PATCH 204/216] iCade codepaths work now for regular OSX too --- input/drivers/cocoa_input.h | 3 +- input/drivers_keyboard/keyboard_event_apple.c | 234 +++++++++--------- pkg/apple/RetroArch.xcodeproj/project.pbxproj | 26 +- ui/drivers/ui_cocoa.m | 18 +- 4 files changed, 150 insertions(+), 131 deletions(-) diff --git a/input/drivers/cocoa_input.h b/input/drivers/cocoa_input.h index a2a199699f..666e957e6f 100644 --- a/input/drivers/cocoa_input.h +++ b/input/drivers/cocoa_input.h @@ -71,7 +71,8 @@ extern "C" { #endif void cocoa_input_keyboard_event(bool down, unsigned code, - uint32_t character, uint32_t mod, unsigned device); + uint32_t character, uint32_t mod, unsigned device, + bool ignore_keyboard_gamepad); #ifdef __cplusplus } diff --git a/input/drivers_keyboard/keyboard_event_apple.c b/input/drivers_keyboard/keyboard_event_apple.c index 8441ed731a..54f3018077 100644 --- a/input/drivers_keyboard/keyboard_event_apple.c +++ b/input/drivers_keyboard/keyboard_event_apple.c @@ -105,13 +105,14 @@ static bool handle_small_keyboard(unsigned* code, bool down) return false; } +#endif extern const struct rarch_key_map rarch_key_map_apple_hid[]; typedef struct icade_map { - bool up; - enum retro_key key; + bool up; + enum retro_key key; } icade_map_t; #define MAX_ICADE_PROFILES 3 @@ -121,116 +122,116 @@ static icade_map_t icade_maps[MAX_ICADE_PROFILES][MAX_ICADE_KEYS]; static bool handle_icade_event(unsigned *code, bool *keydown) { - settings_t *settings = config_get_ptr(); - static bool initialized = false; - bool ret = false; - unsigned kb_type_idx = settings->input.keyboard_gamepad_mapping_type; - - if (!initialized) - { - unsigned i; - unsigned j = 0; - - for (j = 0; j < MAX_ICADE_PROFILES; j++) - { - for (i = 0; i < MAX_ICADE_KEYS; i++) - { - icade_maps[j][i].key = RETROK_UNKNOWN; - icade_maps[j][i].up = false; - } - } - - /* iPega PG-9017 */ - j = 1; - - icade_maps[j][input_keymaps_translate_rk_to_keysym(RETROK_a)].key = RETROK_LEFT; - icade_maps[j][input_keymaps_translate_rk_to_keysym(RETROK_q)].key = RETROK_LEFT; - icade_maps[j][input_keymaps_translate_rk_to_keysym(RETROK_c)].key = RETROK_RIGHT; - icade_maps[j][input_keymaps_translate_rk_to_keysym(RETROK_d)].key = RETROK_RIGHT; - icade_maps[j][input_keymaps_translate_rk_to_keysym(RETROK_e)].key = RETROK_UP; - icade_maps[j][input_keymaps_translate_rk_to_keysym(RETROK_w)].key = RETROK_UP; - icade_maps[j][input_keymaps_translate_rk_to_keysym(RETROK_x)].key = RETROK_DOWN; - icade_maps[j][input_keymaps_translate_rk_to_keysym(RETROK_z)].key = RETROK_DOWN; - icade_maps[j][input_keymaps_translate_rk_to_keysym(RETROK_f)].key = RETROK_z; - icade_maps[j][input_keymaps_translate_rk_to_keysym(RETROK_u)].key = RETROK_z; - icade_maps[j][input_keymaps_translate_rk_to_keysym(RETROK_i)].key = RETROK_q; - icade_maps[j][input_keymaps_translate_rk_to_keysym(RETROK_m)].key = RETROK_q; - icade_maps[j][input_keymaps_translate_rk_to_keysym(RETROK_j)].key = RETROK_a; - icade_maps[j][input_keymaps_translate_rk_to_keysym(RETROK_n)].key = RETROK_a; - icade_maps[j][input_keymaps_translate_rk_to_keysym(RETROK_k)].key = RETROK_w; - icade_maps[j][input_keymaps_translate_rk_to_keysym(RETROK_p)].key = RETROK_w; - icade_maps[j][input_keymaps_translate_rk_to_keysym(RETROK_h)].key = RETROK_x; - icade_maps[j][input_keymaps_translate_rk_to_keysym(RETROK_r)].key = RETROK_x; - icade_maps[j][input_keymaps_translate_rk_to_keysym(RETROK_y)].key = RETROK_s; - icade_maps[j][input_keymaps_translate_rk_to_keysym(RETROK_t)].key = RETROK_s; - - icade_maps[j][input_keymaps_translate_rk_to_keysym(RETROK_e)].up = true; - icade_maps[j][input_keymaps_translate_rk_to_keysym(RETROK_z)].up = true; - icade_maps[j][input_keymaps_translate_rk_to_keysym(RETROK_q)].up = true; - icade_maps[j][input_keymaps_translate_rk_to_keysym(RETROK_c)].up = true; - icade_maps[j][input_keymaps_translate_rk_to_keysym(RETROK_f)].up = true; - icade_maps[j][input_keymaps_translate_rk_to_keysym(RETROK_m)].up = true; - icade_maps[j][input_keymaps_translate_rk_to_keysym(RETROK_t)].up = true; - icade_maps[j][input_keymaps_translate_rk_to_keysym(RETROK_n)].up = true; - icade_maps[j][input_keymaps_translate_rk_to_keysym(RETROK_p)].up = true; - icade_maps[j][input_keymaps_translate_rk_to_keysym(RETROK_r)].up = true; - - /* 8-bitty */ - j = 2; - - initialized = true; - icade_maps[j][input_keymaps_translate_rk_to_keysym(RETROK_a)].key = RETROK_LEFT; - icade_maps[j][input_keymaps_translate_rk_to_keysym(RETROK_q)].key = RETROK_LEFT; - icade_maps[j][input_keymaps_translate_rk_to_keysym(RETROK_c)].key = RETROK_RIGHT; - icade_maps[j][input_keymaps_translate_rk_to_keysym(RETROK_d)].key = RETROK_RIGHT; - icade_maps[j][input_keymaps_translate_rk_to_keysym(RETROK_e)].key = RETROK_UP; - icade_maps[j][input_keymaps_translate_rk_to_keysym(RETROK_w)].key = RETROK_UP; - icade_maps[j][input_keymaps_translate_rk_to_keysym(RETROK_x)].key = RETROK_DOWN; - icade_maps[j][input_keymaps_translate_rk_to_keysym(RETROK_z)].key = RETROK_DOWN; - icade_maps[j][input_keymaps_translate_rk_to_keysym(RETROK_h)].key = RETROK_q; - icade_maps[j][input_keymaps_translate_rk_to_keysym(RETROK_r)].key = RETROK_q; - icade_maps[j][input_keymaps_translate_rk_to_keysym(RETROK_j)].key = RETROK_w; - icade_maps[j][input_keymaps_translate_rk_to_keysym(RETROK_n)].key = RETROK_w; - icade_maps[j][input_keymaps_translate_rk_to_keysym(RETROK_i)].key = RETROK_a; - icade_maps[j][input_keymaps_translate_rk_to_keysym(RETROK_m)].key = RETROK_a; - icade_maps[j][input_keymaps_translate_rk_to_keysym(RETROK_k)].key = RETROK_z; - icade_maps[j][input_keymaps_translate_rk_to_keysym(RETROK_p)].key = RETROK_z; - icade_maps[j][input_keymaps_translate_rk_to_keysym(RETROK_y)].key = RETROK_RSHIFT; - icade_maps[j][input_keymaps_translate_rk_to_keysym(RETROK_t)].key = RETROK_RSHIFT; - icade_maps[j][input_keymaps_translate_rk_to_keysym(RETROK_u)].key = RETROK_RETURN; - icade_maps[j][input_keymaps_translate_rk_to_keysym(RETROK_f)].key = RETROK_RETURN; - icade_maps[j][input_keymaps_translate_rk_to_keysym(RETROK_l)].key = RETROK_x; - icade_maps[j][input_keymaps_translate_rk_to_keysym(RETROK_v)].key = RETROK_x; - icade_maps[j][input_keymaps_translate_rk_to_keysym(RETROK_o)].key = RETROK_s; - icade_maps[j][input_keymaps_translate_rk_to_keysym(RETROK_g)].key = RETROK_s; - - icade_maps[j][input_keymaps_translate_rk_to_keysym(RETROK_e)].up = true; - icade_maps[j][input_keymaps_translate_rk_to_keysym(RETROK_z)].up = true; - icade_maps[j][input_keymaps_translate_rk_to_keysym(RETROK_q)].up = true; - icade_maps[j][input_keymaps_translate_rk_to_keysym(RETROK_c)].up = true; - icade_maps[j][input_keymaps_translate_rk_to_keysym(RETROK_r)].up = true; - icade_maps[j][input_keymaps_translate_rk_to_keysym(RETROK_n)].up = true; - icade_maps[j][input_keymaps_translate_rk_to_keysym(RETROK_m)].up = true; - icade_maps[j][input_keymaps_translate_rk_to_keysym(RETROK_p)].up = true; - icade_maps[j][input_keymaps_translate_rk_to_keysym(RETROK_t)].up = true; - icade_maps[j][input_keymaps_translate_rk_to_keysym(RETROK_f)].up = true; - icade_maps[j][input_keymaps_translate_rk_to_keysym(RETROK_v)].up = true; - icade_maps[j][input_keymaps_translate_rk_to_keysym(RETROK_g)].up = true; - } - - if ((*code < 0x20) && (icade_maps[kb_type_idx][*code].key != RETROK_UNKNOWN)) - { - *keydown = icade_maps[kb_type_idx][*code].up ? false : true; - ret = true; - *code = input_keymaps_translate_rk_to_keysym(icade_maps[kb_type_idx][*code].key); - } - - return ret; + settings_t *settings = config_get_ptr(); + static bool initialized = false; + bool ret = false; + unsigned kb_type_idx = settings->input.keyboard_gamepad_mapping_type; + + if (!initialized) + { + unsigned i; + unsigned j = 0; + + for (j = 0; j < MAX_ICADE_PROFILES; j++) + { + for (i = 0; i < MAX_ICADE_KEYS; i++) + { + icade_maps[j][i].key = RETROK_UNKNOWN; + icade_maps[j][i].up = false; + } + } + + /* iPega PG-9017 */ + j = 1; + + icade_maps[j][input_keymaps_translate_rk_to_keysym(RETROK_a)].key = RETROK_LEFT; + icade_maps[j][input_keymaps_translate_rk_to_keysym(RETROK_q)].key = RETROK_LEFT; + icade_maps[j][input_keymaps_translate_rk_to_keysym(RETROK_c)].key = RETROK_RIGHT; + icade_maps[j][input_keymaps_translate_rk_to_keysym(RETROK_d)].key = RETROK_RIGHT; + icade_maps[j][input_keymaps_translate_rk_to_keysym(RETROK_e)].key = RETROK_UP; + icade_maps[j][input_keymaps_translate_rk_to_keysym(RETROK_w)].key = RETROK_UP; + icade_maps[j][input_keymaps_translate_rk_to_keysym(RETROK_x)].key = RETROK_DOWN; + icade_maps[j][input_keymaps_translate_rk_to_keysym(RETROK_z)].key = RETROK_DOWN; + icade_maps[j][input_keymaps_translate_rk_to_keysym(RETROK_f)].key = RETROK_z; + icade_maps[j][input_keymaps_translate_rk_to_keysym(RETROK_u)].key = RETROK_z; + icade_maps[j][input_keymaps_translate_rk_to_keysym(RETROK_i)].key = RETROK_q; + icade_maps[j][input_keymaps_translate_rk_to_keysym(RETROK_m)].key = RETROK_q; + icade_maps[j][input_keymaps_translate_rk_to_keysym(RETROK_j)].key = RETROK_a; + icade_maps[j][input_keymaps_translate_rk_to_keysym(RETROK_n)].key = RETROK_a; + icade_maps[j][input_keymaps_translate_rk_to_keysym(RETROK_k)].key = RETROK_w; + icade_maps[j][input_keymaps_translate_rk_to_keysym(RETROK_p)].key = RETROK_w; + icade_maps[j][input_keymaps_translate_rk_to_keysym(RETROK_h)].key = RETROK_x; + icade_maps[j][input_keymaps_translate_rk_to_keysym(RETROK_r)].key = RETROK_x; + icade_maps[j][input_keymaps_translate_rk_to_keysym(RETROK_y)].key = RETROK_s; + icade_maps[j][input_keymaps_translate_rk_to_keysym(RETROK_t)].key = RETROK_s; + + icade_maps[j][input_keymaps_translate_rk_to_keysym(RETROK_e)].up = true; + icade_maps[j][input_keymaps_translate_rk_to_keysym(RETROK_z)].up = true; + icade_maps[j][input_keymaps_translate_rk_to_keysym(RETROK_q)].up = true; + icade_maps[j][input_keymaps_translate_rk_to_keysym(RETROK_c)].up = true; + icade_maps[j][input_keymaps_translate_rk_to_keysym(RETROK_f)].up = true; + icade_maps[j][input_keymaps_translate_rk_to_keysym(RETROK_m)].up = true; + icade_maps[j][input_keymaps_translate_rk_to_keysym(RETROK_t)].up = true; + icade_maps[j][input_keymaps_translate_rk_to_keysym(RETROK_n)].up = true; + icade_maps[j][input_keymaps_translate_rk_to_keysym(RETROK_p)].up = true; + icade_maps[j][input_keymaps_translate_rk_to_keysym(RETROK_r)].up = true; + + /* 8-bitty */ + j = 2; + + initialized = true; + icade_maps[j][input_keymaps_translate_rk_to_keysym(RETROK_a)].key = RETROK_LEFT; + icade_maps[j][input_keymaps_translate_rk_to_keysym(RETROK_q)].key = RETROK_LEFT; + icade_maps[j][input_keymaps_translate_rk_to_keysym(RETROK_c)].key = RETROK_RIGHT; + icade_maps[j][input_keymaps_translate_rk_to_keysym(RETROK_d)].key = RETROK_RIGHT; + icade_maps[j][input_keymaps_translate_rk_to_keysym(RETROK_e)].key = RETROK_UP; + icade_maps[j][input_keymaps_translate_rk_to_keysym(RETROK_w)].key = RETROK_UP; + icade_maps[j][input_keymaps_translate_rk_to_keysym(RETROK_x)].key = RETROK_DOWN; + icade_maps[j][input_keymaps_translate_rk_to_keysym(RETROK_z)].key = RETROK_DOWN; + icade_maps[j][input_keymaps_translate_rk_to_keysym(RETROK_h)].key = RETROK_q; + icade_maps[j][input_keymaps_translate_rk_to_keysym(RETROK_r)].key = RETROK_q; + icade_maps[j][input_keymaps_translate_rk_to_keysym(RETROK_j)].key = RETROK_w; + icade_maps[j][input_keymaps_translate_rk_to_keysym(RETROK_n)].key = RETROK_w; + icade_maps[j][input_keymaps_translate_rk_to_keysym(RETROK_i)].key = RETROK_a; + icade_maps[j][input_keymaps_translate_rk_to_keysym(RETROK_m)].key = RETROK_a; + icade_maps[j][input_keymaps_translate_rk_to_keysym(RETROK_k)].key = RETROK_z; + icade_maps[j][input_keymaps_translate_rk_to_keysym(RETROK_p)].key = RETROK_z; + icade_maps[j][input_keymaps_translate_rk_to_keysym(RETROK_y)].key = RETROK_RSHIFT; + icade_maps[j][input_keymaps_translate_rk_to_keysym(RETROK_t)].key = RETROK_RSHIFT; + icade_maps[j][input_keymaps_translate_rk_to_keysym(RETROK_u)].key = RETROK_RETURN; + icade_maps[j][input_keymaps_translate_rk_to_keysym(RETROK_f)].key = RETROK_RETURN; + icade_maps[j][input_keymaps_translate_rk_to_keysym(RETROK_l)].key = RETROK_x; + icade_maps[j][input_keymaps_translate_rk_to_keysym(RETROK_v)].key = RETROK_x; + icade_maps[j][input_keymaps_translate_rk_to_keysym(RETROK_o)].key = RETROK_s; + icade_maps[j][input_keymaps_translate_rk_to_keysym(RETROK_g)].key = RETROK_s; + + icade_maps[j][input_keymaps_translate_rk_to_keysym(RETROK_e)].up = true; + icade_maps[j][input_keymaps_translate_rk_to_keysym(RETROK_z)].up = true; + icade_maps[j][input_keymaps_translate_rk_to_keysym(RETROK_q)].up = true; + icade_maps[j][input_keymaps_translate_rk_to_keysym(RETROK_c)].up = true; + icade_maps[j][input_keymaps_translate_rk_to_keysym(RETROK_r)].up = true; + icade_maps[j][input_keymaps_translate_rk_to_keysym(RETROK_n)].up = true; + icade_maps[j][input_keymaps_translate_rk_to_keysym(RETROK_m)].up = true; + icade_maps[j][input_keymaps_translate_rk_to_keysym(RETROK_p)].up = true; + icade_maps[j][input_keymaps_translate_rk_to_keysym(RETROK_t)].up = true; + icade_maps[j][input_keymaps_translate_rk_to_keysym(RETROK_f)].up = true; + icade_maps[j][input_keymaps_translate_rk_to_keysym(RETROK_v)].up = true; + icade_maps[j][input_keymaps_translate_rk_to_keysym(RETROK_g)].up = true; + } + + if ((*code < 0x20) && (icade_maps[kb_type_idx][*code].key != RETROK_UNKNOWN)) + { + *keydown = icade_maps[kb_type_idx][*code].up ? false : true; + ret = true; + *code = input_keymaps_translate_rk_to_keysym(icade_maps[kb_type_idx][*code].key); + } + + return ret; } -#endif void cocoa_input_keyboard_event(bool down, - unsigned code, uint32_t character, uint32_t mod, unsigned device) + unsigned code, uint32_t character, uint32_t mod, unsigned device, + bool ignore_keyboard_gamepad) { driver_t *driver = driver_get_ptr(); settings_t *settings = config_get_ptr(); @@ -241,14 +242,15 @@ void cocoa_input_keyboard_event(bool down, code = HIDKEY(code); -#if TARGET_OS_IPHONE - if (settings->input.keyboard_gamepad_enable) + if (settings->input.keyboard_gamepad_enable && !ignore_keyboard_gamepad) { - if (handle_icade_event(&code, &down)) - character = 0; - else - code = 0; - } + unsigned orig_code = code; + if (handle_icade_event(&code, &down)) + character = 0; + else + code = orig_code; + } +#if TARGET_OS_IPHONE else if (settings->input.small_keyboard_enable) { if (handle_small_keyboard(&code, down)) diff --git a/pkg/apple/RetroArch.xcodeproj/project.pbxproj b/pkg/apple/RetroArch.xcodeproj/project.pbxproj index 5797e4b290..8025a3103e 100644 --- a/pkg/apple/RetroArch.xcodeproj/project.pbxproj +++ b/pkg/apple/RetroArch.xcodeproj/project.pbxproj @@ -23,6 +23,7 @@ 500845341B89300700CE6073 /* IOKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 84DD5EB41A89E737007336C1 /* IOKit.framework */; }; 5061C8A41AE47E510080AE14 /* libz.dylib in Frameworks */ = {isa = PBXBuildFile; fileRef = 5061C8A31AE47E510080AE14 /* libz.dylib */; }; 509F0C9D1AA23AFC00619ECC /* griffin_objc.m in Sources */ = {isa = PBXBuildFile; fileRef = 509F0C9C1AA23AFC00619ECC /* griffin_objc.m */; }; + 50A1B3011BF69A8F007D47CD /* Carbon.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 50A1B3001BF69A8F007D47CD /* Carbon.framework */; }; 840222FC1A889EE2009AB261 /* griffin.c in Sources */ = {isa = PBXBuildFile; fileRef = 840222FB1A889EE2009AB261 /* griffin.c */; }; 84DD5E9F1A88E45B007336C1 /* CoreVideo.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 84DD5E9E1A88E45B007336C1 /* CoreVideo.framework */; }; 84DD5EA31A89E2AA007336C1 /* AppKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 29B97324FDCFA39411CA2CEA /* AppKit.framework */; }; @@ -77,10 +78,11 @@ 089C165DFE840E0CC02AAC07 /* InfoPlist.strings */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.strings; name = InfoPlist.strings; path = OSX/en.lproj/InfoPlist.strings; sourceTree = ""; }; 1DDD58150DA1D0A300B32029 /* MainMenu.xib */ = {isa = PBXFileReference; lastKnownFileType = file.xib; name = MainMenu.xib; path = OSX/en.lproj/MainMenu.xib; sourceTree = ""; }; 29B97324FDCFA39411CA2CEA /* AppKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = AppKit.framework; path = /System/Library/Frameworks/AppKit.framework; sourceTree = ""; }; - 5008453A1B89300700CE6073 /* RetroArchCg.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = "RetroArchCg.app"; sourceTree = BUILT_PRODUCTS_DIR; }; - 5008453B1B89300700CE6073 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; name = "Info.plist"; path = "/../../pkg/apple/OSX/Info.plist"; sourceTree = SOURCE_ROOT; }; + 5008453A1B89300700CE6073 /* RetroArchCg.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = RetroArchCg.app; sourceTree = BUILT_PRODUCTS_DIR; }; + 5008453B1B89300700CE6073 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; name = Info.plist; path = /../../pkg/apple/OSX/Info.plist; sourceTree = SOURCE_ROOT; }; 5061C8A31AE47E510080AE14 /* libz.dylib */ = {isa = PBXFileReference; lastKnownFileType = "compiled.mach-o.dylib"; name = libz.dylib; path = usr/lib/libz.dylib; sourceTree = SDKROOT; }; 509F0C9C1AA23AFC00619ECC /* griffin_objc.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = griffin_objc.m; path = ../../griffin/griffin_objc.m; sourceTree = ""; }; + 50A1B3001BF69A8F007D47CD /* Carbon.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Carbon.framework; path = System/Library/Frameworks/Carbon.framework; sourceTree = SDKROOT; }; 840222FB1A889EE2009AB261 /* griffin.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = griffin.c; path = ../../griffin/griffin.c; sourceTree = SOURCE_ROOT; }; 84DD5E9E1A88E45B007336C1 /* CoreVideo.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreVideo.framework; path = /System/Library/Frameworks/CoreVideo.framework; sourceTree = ""; }; 84DD5EA61A89E406007336C1 /* CoreLocation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreLocation.framework; path = /System/Library/Frameworks/CoreLocation.framework; sourceTree = ""; }; @@ -90,7 +92,7 @@ 84DD5EB21A89E6C0007336C1 /* AudioUnit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = AudioUnit.framework; path = /System/Library/Frameworks/AudioUnit.framework; sourceTree = ""; }; 84DD5EB41A89E737007336C1 /* IOKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = IOKit.framework; path = ../../../../../../System/Library/Frameworks/IOKit.framework; sourceTree = ""; }; 84DD5EB71A89F1C7007336C1 /* retroarch.icns */ = {isa = PBXFileReference; lastKnownFileType = image.icns; name = retroarch.icns; path = ../../media/retroarch.icns; sourceTree = ""; }; - 8D1107310486CEB800E47090 /* Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; name = "Info.plist"; path = "OSX/Info.plist"; sourceTree = ""; }; + 8D1107310486CEB800E47090 /* Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; name = Info.plist; path = OSX/Info.plist; sourceTree = ""; }; 8D1107320486CEB800E47090 /* RetroArch.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = RetroArch.app; sourceTree = BUILT_PRODUCTS_DIR; }; /* End PBXFileReference section */ @@ -99,6 +101,7 @@ isa = PBXFrameworksBuildPhase; buildActionMask = 2147483647; files = ( + 50A1B3011BF69A8F007D47CD /* Carbon.framework in Frameworks */, 5008452C1B89300700CE6073 /* libz.dylib in Frameworks */, 5008452D1B89300700CE6073 /* CoreAudio.framework in Frameworks */, 5008452E1B89300700CE6073 /* AudioUnit.framework in Frameworks */, @@ -204,6 +207,7 @@ 29B97323FDCFA39411CA2CEA /* Frameworks */ = { isa = PBXGroup; children = ( + 50A1B3001BF69A8F007D47CD /* Carbon.framework */, 5061C8A31AE47E510080AE14 /* libz.dylib */, 1058C7A0FEA54F0111CA2CBB /* Linked Frameworks */, 1058C7A2FEA54F0111CA2CBB /* Other Frameworks */, @@ -378,12 +382,12 @@ "$(SRCROOT)/../../gfx/inc", "$(SRCROOT)/../../libretro-common/include", ); - INFOPLIST_FILE = "OSX/Info.plist"; + INFOPLIST_FILE = OSX/Info.plist; INSTALL_PATH = "$(HOME)/Applications"; MACOSX_DEPLOYMENT_TARGET = 10.5; OTHER_CFLAGS = ( "-DHAVE_GRIFFIN", - "-DHAVE_CHEEVOS", + "-DHAVE_CHEEVOS", "-DHAVE_IMAGEVIEWER", "-DHAVE_CORETEXT", "-DHAVE_IOHIDMANAGER", @@ -418,7 +422,7 @@ "-DHAVE_LIBRETRODB", ); PRECOMPS_INCLUDE_HEADERS_FROM_BUILT_PRODUCTS_DIR = YES; - PRODUCT_NAME = "RetroArchCg"; + PRODUCT_NAME = RetroArchCg; }; name = Debug; }; @@ -439,12 +443,12 @@ "$(SRCROOT)/../../gfx/inc", "$(SRCROOT)/../../libretro-common/include", ); - INFOPLIST_FILE = "OSX/Info.plist"; + INFOPLIST_FILE = OSX/Info.plist; INSTALL_PATH = "$(HOME)/Applications"; MACOSX_DEPLOYMENT_TARGET = 10.5; OTHER_CFLAGS = ( "-DHAVE_GRIFFIN", - "-DHAVE_CHEEVOS", + "-DHAVE_CHEEVOS", "-DHAVE_IMAGEVIEWER", "-DHAVE_IOHIDMANAGER", "-DHAVE_CORETEXT", @@ -479,7 +483,7 @@ "-DHAVE_LIBRETRODB", ); PRECOMPS_INCLUDE_HEADERS_FROM_BUILT_PRODUCTS_DIR = YES; - PRODUCT_NAME = "RetroArchCg"; + PRODUCT_NAME = RetroArchCg; }; name = Release; }; @@ -507,7 +511,7 @@ MACOSX_DEPLOYMENT_TARGET = 10.5; OTHER_CFLAGS = ( "-DHAVE_GRIFFIN", - "-DHAVE_CHEEVOS", + "-DHAVE_CHEEVOS", "-DHAVE_IMAGEVIEWER", "-DHAVE_CORETEXT", "-DHAVE_IOHIDMANAGER", @@ -567,7 +571,7 @@ MACOSX_DEPLOYMENT_TARGET = 10.5; OTHER_CFLAGS = ( "-DHAVE_GRIFFIN", - "-DHAVE_CHEEVOS", + "-DHAVE_CHEEVOS", "-DHAVE_IMAGEVIEWER", "-DHAVE_IOHIDMANAGER", "-DHAVE_CORETEXT", diff --git a/ui/drivers/ui_cocoa.m b/ui/drivers/ui_cocoa.m index 1d50516bcd..2f84f3a79c 100644 --- a/ui/drivers/ui_cocoa.m +++ b/ui/drivers/ui_cocoa.m @@ -43,12 +43,21 @@ void apple_rarch_exited(void) - (void)sendEvent:(NSEvent *)event { + unsigned kbt; NSEventType event_type; cocoa_input_data_t *apple = NULL; driver_t *driver = driver_get_ptr(); if (!driver) return; [super sendEvent:event]; + + EventRef ce = (EventRef)[event eventRef]; + if (ce) + { + GetEventParameter(ce, kEventParamKeyboardType, + typeUInt32, NULL, sizeof(kbt), NULL, &kbt); + NSLog(@"kbt is: %d", kbt); + } apple = (cocoa_input_data_t*)driver->input_data; event_type = event.type; @@ -85,11 +94,13 @@ void apple_rarch_exited(void) for (i = 1; i < ch.length; i++) cocoa_input_keyboard_event(event_type == NSKeyDown, - 0, [ch characterAtIndex:i], mod, RETRO_DEVICE_KEYBOARD); + 0, [ch characterAtIndex:i], mod, RETRO_DEVICE_KEYBOARD, + (kbt == 44) ? true : false); } cocoa_input_keyboard_event(event_type == NSKeyDown, - event.keyCode, character, mod, RETRO_DEVICE_KEYBOARD); + (uint32_t)event.keyCode, character, mod, RETRO_DEVICE_KEYBOARD, + (kbt == 44) ? true : false); } break; case NSFlagsChanged: @@ -100,7 +111,8 @@ void apple_rarch_exited(void) old_flags = new_flags; cocoa_input_keyboard_event(down, event.keyCode, - 0, event.modifierFlags, RETRO_DEVICE_KEYBOARD); + 0, event.modifierFlags, RETRO_DEVICE_KEYBOARD, + (kbt == 44) ? true : false); } break; case NSMouseMoved: From cf678b96cfd699915b5bfac98794a188d51945f9 Mon Sep 17 00:00:00 2001 From: Twinaphex Date: Sat, 14 Nov 2015 01:50:12 +0100 Subject: [PATCH 205/216] (OSX) Add Carbon.framework for non-Cg version --- pkg/apple/RetroArch.xcodeproj/project.pbxproj | 2 ++ 1 file changed, 2 insertions(+) diff --git a/pkg/apple/RetroArch.xcodeproj/project.pbxproj b/pkg/apple/RetroArch.xcodeproj/project.pbxproj index 8025a3103e..4ea0699f91 100644 --- a/pkg/apple/RetroArch.xcodeproj/project.pbxproj +++ b/pkg/apple/RetroArch.xcodeproj/project.pbxproj @@ -21,6 +21,7 @@ 500845321B89300700CE6073 /* AppKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 29B97324FDCFA39411CA2CEA /* AppKit.framework */; }; 500845331B89300700CE6073 /* CoreVideo.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 84DD5E9E1A88E45B007336C1 /* CoreVideo.framework */; }; 500845341B89300700CE6073 /* IOKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 84DD5EB41A89E737007336C1 /* IOKit.framework */; }; + 501540A51BF6BCB000222619 /* Carbon.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 50A1B3001BF69A8F007D47CD /* Carbon.framework */; }; 5061C8A41AE47E510080AE14 /* libz.dylib in Frameworks */ = {isa = PBXBuildFile; fileRef = 5061C8A31AE47E510080AE14 /* libz.dylib */; }; 509F0C9D1AA23AFC00619ECC /* griffin_objc.m in Sources */ = {isa = PBXBuildFile; fileRef = 509F0C9C1AA23AFC00619ECC /* griffin_objc.m */; }; 50A1B3011BF69A8F007D47CD /* Carbon.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 50A1B3001BF69A8F007D47CD /* Carbon.framework */; }; @@ -117,6 +118,7 @@ isa = PBXFrameworksBuildPhase; buildActionMask = 2147483647; files = ( + 501540A51BF6BCB000222619 /* Carbon.framework in Frameworks */, 5061C8A41AE47E510080AE14 /* libz.dylib in Frameworks */, 84DD5EA91A89E4BE007336C1 /* CoreAudio.framework in Frameworks */, 84DD5EB31A89E6C0007336C1 /* AudioUnit.framework in Frameworks */, From 8995b66f0577650f9cb2175d29bcc364d73d51e8 Mon Sep 17 00:00:00 2001 From: Twinaphex Date: Sat, 14 Nov 2015 02:08:51 +0100 Subject: [PATCH 206/216] Revert "(OSX) Add Carbon.framework for non-Cg version" This reverts commit cf678b96cfd699915b5bfac98794a188d51945f9. --- pkg/apple/RetroArch.xcodeproj/project.pbxproj | 2 -- 1 file changed, 2 deletions(-) diff --git a/pkg/apple/RetroArch.xcodeproj/project.pbxproj b/pkg/apple/RetroArch.xcodeproj/project.pbxproj index 4ea0699f91..8025a3103e 100644 --- a/pkg/apple/RetroArch.xcodeproj/project.pbxproj +++ b/pkg/apple/RetroArch.xcodeproj/project.pbxproj @@ -21,7 +21,6 @@ 500845321B89300700CE6073 /* AppKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 29B97324FDCFA39411CA2CEA /* AppKit.framework */; }; 500845331B89300700CE6073 /* CoreVideo.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 84DD5E9E1A88E45B007336C1 /* CoreVideo.framework */; }; 500845341B89300700CE6073 /* IOKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 84DD5EB41A89E737007336C1 /* IOKit.framework */; }; - 501540A51BF6BCB000222619 /* Carbon.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 50A1B3001BF69A8F007D47CD /* Carbon.framework */; }; 5061C8A41AE47E510080AE14 /* libz.dylib in Frameworks */ = {isa = PBXBuildFile; fileRef = 5061C8A31AE47E510080AE14 /* libz.dylib */; }; 509F0C9D1AA23AFC00619ECC /* griffin_objc.m in Sources */ = {isa = PBXBuildFile; fileRef = 509F0C9C1AA23AFC00619ECC /* griffin_objc.m */; }; 50A1B3011BF69A8F007D47CD /* Carbon.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 50A1B3001BF69A8F007D47CD /* Carbon.framework */; }; @@ -118,7 +117,6 @@ isa = PBXFrameworksBuildPhase; buildActionMask = 2147483647; files = ( - 501540A51BF6BCB000222619 /* Carbon.framework in Frameworks */, 5061C8A41AE47E510080AE14 /* libz.dylib in Frameworks */, 84DD5EA91A89E4BE007336C1 /* CoreAudio.framework in Frameworks */, 84DD5EB31A89E6C0007336C1 /* AudioUnit.framework in Frameworks */, From 6847501e99c99b29629192d97d46035806f4d983 Mon Sep 17 00:00:00 2001 From: Twinaphex Date: Sat, 14 Nov 2015 02:08:59 +0100 Subject: [PATCH 207/216] Revert "iCade codepaths work now for regular OSX too" This reverts commit d72090f5e986de862aa1f2ac1d31530b538d1e95. --- input/drivers/cocoa_input.h | 3 +- input/drivers_keyboard/keyboard_event_apple.c | 234 +++++++++--------- pkg/apple/RetroArch.xcodeproj/project.pbxproj | 26 +- ui/drivers/ui_cocoa.m | 18 +- 4 files changed, 131 insertions(+), 150 deletions(-) diff --git a/input/drivers/cocoa_input.h b/input/drivers/cocoa_input.h index 666e957e6f..a2a199699f 100644 --- a/input/drivers/cocoa_input.h +++ b/input/drivers/cocoa_input.h @@ -71,8 +71,7 @@ extern "C" { #endif void cocoa_input_keyboard_event(bool down, unsigned code, - uint32_t character, uint32_t mod, unsigned device, - bool ignore_keyboard_gamepad); + uint32_t character, uint32_t mod, unsigned device); #ifdef __cplusplus } diff --git a/input/drivers_keyboard/keyboard_event_apple.c b/input/drivers_keyboard/keyboard_event_apple.c index 54f3018077..8441ed731a 100644 --- a/input/drivers_keyboard/keyboard_event_apple.c +++ b/input/drivers_keyboard/keyboard_event_apple.c @@ -105,14 +105,13 @@ static bool handle_small_keyboard(unsigned* code, bool down) return false; } -#endif extern const struct rarch_key_map rarch_key_map_apple_hid[]; typedef struct icade_map { - bool up; - enum retro_key key; + bool up; + enum retro_key key; } icade_map_t; #define MAX_ICADE_PROFILES 3 @@ -122,116 +121,116 @@ static icade_map_t icade_maps[MAX_ICADE_PROFILES][MAX_ICADE_KEYS]; static bool handle_icade_event(unsigned *code, bool *keydown) { - settings_t *settings = config_get_ptr(); - static bool initialized = false; - bool ret = false; - unsigned kb_type_idx = settings->input.keyboard_gamepad_mapping_type; - - if (!initialized) - { - unsigned i; - unsigned j = 0; - - for (j = 0; j < MAX_ICADE_PROFILES; j++) - { - for (i = 0; i < MAX_ICADE_KEYS; i++) - { - icade_maps[j][i].key = RETROK_UNKNOWN; - icade_maps[j][i].up = false; - } - } - - /* iPega PG-9017 */ - j = 1; - - icade_maps[j][input_keymaps_translate_rk_to_keysym(RETROK_a)].key = RETROK_LEFT; - icade_maps[j][input_keymaps_translate_rk_to_keysym(RETROK_q)].key = RETROK_LEFT; - icade_maps[j][input_keymaps_translate_rk_to_keysym(RETROK_c)].key = RETROK_RIGHT; - icade_maps[j][input_keymaps_translate_rk_to_keysym(RETROK_d)].key = RETROK_RIGHT; - icade_maps[j][input_keymaps_translate_rk_to_keysym(RETROK_e)].key = RETROK_UP; - icade_maps[j][input_keymaps_translate_rk_to_keysym(RETROK_w)].key = RETROK_UP; - icade_maps[j][input_keymaps_translate_rk_to_keysym(RETROK_x)].key = RETROK_DOWN; - icade_maps[j][input_keymaps_translate_rk_to_keysym(RETROK_z)].key = RETROK_DOWN; - icade_maps[j][input_keymaps_translate_rk_to_keysym(RETROK_f)].key = RETROK_z; - icade_maps[j][input_keymaps_translate_rk_to_keysym(RETROK_u)].key = RETROK_z; - icade_maps[j][input_keymaps_translate_rk_to_keysym(RETROK_i)].key = RETROK_q; - icade_maps[j][input_keymaps_translate_rk_to_keysym(RETROK_m)].key = RETROK_q; - icade_maps[j][input_keymaps_translate_rk_to_keysym(RETROK_j)].key = RETROK_a; - icade_maps[j][input_keymaps_translate_rk_to_keysym(RETROK_n)].key = RETROK_a; - icade_maps[j][input_keymaps_translate_rk_to_keysym(RETROK_k)].key = RETROK_w; - icade_maps[j][input_keymaps_translate_rk_to_keysym(RETROK_p)].key = RETROK_w; - icade_maps[j][input_keymaps_translate_rk_to_keysym(RETROK_h)].key = RETROK_x; - icade_maps[j][input_keymaps_translate_rk_to_keysym(RETROK_r)].key = RETROK_x; - icade_maps[j][input_keymaps_translate_rk_to_keysym(RETROK_y)].key = RETROK_s; - icade_maps[j][input_keymaps_translate_rk_to_keysym(RETROK_t)].key = RETROK_s; - - icade_maps[j][input_keymaps_translate_rk_to_keysym(RETROK_e)].up = true; - icade_maps[j][input_keymaps_translate_rk_to_keysym(RETROK_z)].up = true; - icade_maps[j][input_keymaps_translate_rk_to_keysym(RETROK_q)].up = true; - icade_maps[j][input_keymaps_translate_rk_to_keysym(RETROK_c)].up = true; - icade_maps[j][input_keymaps_translate_rk_to_keysym(RETROK_f)].up = true; - icade_maps[j][input_keymaps_translate_rk_to_keysym(RETROK_m)].up = true; - icade_maps[j][input_keymaps_translate_rk_to_keysym(RETROK_t)].up = true; - icade_maps[j][input_keymaps_translate_rk_to_keysym(RETROK_n)].up = true; - icade_maps[j][input_keymaps_translate_rk_to_keysym(RETROK_p)].up = true; - icade_maps[j][input_keymaps_translate_rk_to_keysym(RETROK_r)].up = true; - - /* 8-bitty */ - j = 2; - - initialized = true; - icade_maps[j][input_keymaps_translate_rk_to_keysym(RETROK_a)].key = RETROK_LEFT; - icade_maps[j][input_keymaps_translate_rk_to_keysym(RETROK_q)].key = RETROK_LEFT; - icade_maps[j][input_keymaps_translate_rk_to_keysym(RETROK_c)].key = RETROK_RIGHT; - icade_maps[j][input_keymaps_translate_rk_to_keysym(RETROK_d)].key = RETROK_RIGHT; - icade_maps[j][input_keymaps_translate_rk_to_keysym(RETROK_e)].key = RETROK_UP; - icade_maps[j][input_keymaps_translate_rk_to_keysym(RETROK_w)].key = RETROK_UP; - icade_maps[j][input_keymaps_translate_rk_to_keysym(RETROK_x)].key = RETROK_DOWN; - icade_maps[j][input_keymaps_translate_rk_to_keysym(RETROK_z)].key = RETROK_DOWN; - icade_maps[j][input_keymaps_translate_rk_to_keysym(RETROK_h)].key = RETROK_q; - icade_maps[j][input_keymaps_translate_rk_to_keysym(RETROK_r)].key = RETROK_q; - icade_maps[j][input_keymaps_translate_rk_to_keysym(RETROK_j)].key = RETROK_w; - icade_maps[j][input_keymaps_translate_rk_to_keysym(RETROK_n)].key = RETROK_w; - icade_maps[j][input_keymaps_translate_rk_to_keysym(RETROK_i)].key = RETROK_a; - icade_maps[j][input_keymaps_translate_rk_to_keysym(RETROK_m)].key = RETROK_a; - icade_maps[j][input_keymaps_translate_rk_to_keysym(RETROK_k)].key = RETROK_z; - icade_maps[j][input_keymaps_translate_rk_to_keysym(RETROK_p)].key = RETROK_z; - icade_maps[j][input_keymaps_translate_rk_to_keysym(RETROK_y)].key = RETROK_RSHIFT; - icade_maps[j][input_keymaps_translate_rk_to_keysym(RETROK_t)].key = RETROK_RSHIFT; - icade_maps[j][input_keymaps_translate_rk_to_keysym(RETROK_u)].key = RETROK_RETURN; - icade_maps[j][input_keymaps_translate_rk_to_keysym(RETROK_f)].key = RETROK_RETURN; - icade_maps[j][input_keymaps_translate_rk_to_keysym(RETROK_l)].key = RETROK_x; - icade_maps[j][input_keymaps_translate_rk_to_keysym(RETROK_v)].key = RETROK_x; - icade_maps[j][input_keymaps_translate_rk_to_keysym(RETROK_o)].key = RETROK_s; - icade_maps[j][input_keymaps_translate_rk_to_keysym(RETROK_g)].key = RETROK_s; - - icade_maps[j][input_keymaps_translate_rk_to_keysym(RETROK_e)].up = true; - icade_maps[j][input_keymaps_translate_rk_to_keysym(RETROK_z)].up = true; - icade_maps[j][input_keymaps_translate_rk_to_keysym(RETROK_q)].up = true; - icade_maps[j][input_keymaps_translate_rk_to_keysym(RETROK_c)].up = true; - icade_maps[j][input_keymaps_translate_rk_to_keysym(RETROK_r)].up = true; - icade_maps[j][input_keymaps_translate_rk_to_keysym(RETROK_n)].up = true; - icade_maps[j][input_keymaps_translate_rk_to_keysym(RETROK_m)].up = true; - icade_maps[j][input_keymaps_translate_rk_to_keysym(RETROK_p)].up = true; - icade_maps[j][input_keymaps_translate_rk_to_keysym(RETROK_t)].up = true; - icade_maps[j][input_keymaps_translate_rk_to_keysym(RETROK_f)].up = true; - icade_maps[j][input_keymaps_translate_rk_to_keysym(RETROK_v)].up = true; - icade_maps[j][input_keymaps_translate_rk_to_keysym(RETROK_g)].up = true; - } - - if ((*code < 0x20) && (icade_maps[kb_type_idx][*code].key != RETROK_UNKNOWN)) - { - *keydown = icade_maps[kb_type_idx][*code].up ? false : true; - ret = true; - *code = input_keymaps_translate_rk_to_keysym(icade_maps[kb_type_idx][*code].key); - } - - return ret; + settings_t *settings = config_get_ptr(); + static bool initialized = false; + bool ret = false; + unsigned kb_type_idx = settings->input.keyboard_gamepad_mapping_type; + + if (!initialized) + { + unsigned i; + unsigned j = 0; + + for (j = 0; j < MAX_ICADE_PROFILES; j++) + { + for (i = 0; i < MAX_ICADE_KEYS; i++) + { + icade_maps[j][i].key = RETROK_UNKNOWN; + icade_maps[j][i].up = false; + } + } + + /* iPega PG-9017 */ + j = 1; + + icade_maps[j][input_keymaps_translate_rk_to_keysym(RETROK_a)].key = RETROK_LEFT; + icade_maps[j][input_keymaps_translate_rk_to_keysym(RETROK_q)].key = RETROK_LEFT; + icade_maps[j][input_keymaps_translate_rk_to_keysym(RETROK_c)].key = RETROK_RIGHT; + icade_maps[j][input_keymaps_translate_rk_to_keysym(RETROK_d)].key = RETROK_RIGHT; + icade_maps[j][input_keymaps_translate_rk_to_keysym(RETROK_e)].key = RETROK_UP; + icade_maps[j][input_keymaps_translate_rk_to_keysym(RETROK_w)].key = RETROK_UP; + icade_maps[j][input_keymaps_translate_rk_to_keysym(RETROK_x)].key = RETROK_DOWN; + icade_maps[j][input_keymaps_translate_rk_to_keysym(RETROK_z)].key = RETROK_DOWN; + icade_maps[j][input_keymaps_translate_rk_to_keysym(RETROK_f)].key = RETROK_z; + icade_maps[j][input_keymaps_translate_rk_to_keysym(RETROK_u)].key = RETROK_z; + icade_maps[j][input_keymaps_translate_rk_to_keysym(RETROK_i)].key = RETROK_q; + icade_maps[j][input_keymaps_translate_rk_to_keysym(RETROK_m)].key = RETROK_q; + icade_maps[j][input_keymaps_translate_rk_to_keysym(RETROK_j)].key = RETROK_a; + icade_maps[j][input_keymaps_translate_rk_to_keysym(RETROK_n)].key = RETROK_a; + icade_maps[j][input_keymaps_translate_rk_to_keysym(RETROK_k)].key = RETROK_w; + icade_maps[j][input_keymaps_translate_rk_to_keysym(RETROK_p)].key = RETROK_w; + icade_maps[j][input_keymaps_translate_rk_to_keysym(RETROK_h)].key = RETROK_x; + icade_maps[j][input_keymaps_translate_rk_to_keysym(RETROK_r)].key = RETROK_x; + icade_maps[j][input_keymaps_translate_rk_to_keysym(RETROK_y)].key = RETROK_s; + icade_maps[j][input_keymaps_translate_rk_to_keysym(RETROK_t)].key = RETROK_s; + + icade_maps[j][input_keymaps_translate_rk_to_keysym(RETROK_e)].up = true; + icade_maps[j][input_keymaps_translate_rk_to_keysym(RETROK_z)].up = true; + icade_maps[j][input_keymaps_translate_rk_to_keysym(RETROK_q)].up = true; + icade_maps[j][input_keymaps_translate_rk_to_keysym(RETROK_c)].up = true; + icade_maps[j][input_keymaps_translate_rk_to_keysym(RETROK_f)].up = true; + icade_maps[j][input_keymaps_translate_rk_to_keysym(RETROK_m)].up = true; + icade_maps[j][input_keymaps_translate_rk_to_keysym(RETROK_t)].up = true; + icade_maps[j][input_keymaps_translate_rk_to_keysym(RETROK_n)].up = true; + icade_maps[j][input_keymaps_translate_rk_to_keysym(RETROK_p)].up = true; + icade_maps[j][input_keymaps_translate_rk_to_keysym(RETROK_r)].up = true; + + /* 8-bitty */ + j = 2; + + initialized = true; + icade_maps[j][input_keymaps_translate_rk_to_keysym(RETROK_a)].key = RETROK_LEFT; + icade_maps[j][input_keymaps_translate_rk_to_keysym(RETROK_q)].key = RETROK_LEFT; + icade_maps[j][input_keymaps_translate_rk_to_keysym(RETROK_c)].key = RETROK_RIGHT; + icade_maps[j][input_keymaps_translate_rk_to_keysym(RETROK_d)].key = RETROK_RIGHT; + icade_maps[j][input_keymaps_translate_rk_to_keysym(RETROK_e)].key = RETROK_UP; + icade_maps[j][input_keymaps_translate_rk_to_keysym(RETROK_w)].key = RETROK_UP; + icade_maps[j][input_keymaps_translate_rk_to_keysym(RETROK_x)].key = RETROK_DOWN; + icade_maps[j][input_keymaps_translate_rk_to_keysym(RETROK_z)].key = RETROK_DOWN; + icade_maps[j][input_keymaps_translate_rk_to_keysym(RETROK_h)].key = RETROK_q; + icade_maps[j][input_keymaps_translate_rk_to_keysym(RETROK_r)].key = RETROK_q; + icade_maps[j][input_keymaps_translate_rk_to_keysym(RETROK_j)].key = RETROK_w; + icade_maps[j][input_keymaps_translate_rk_to_keysym(RETROK_n)].key = RETROK_w; + icade_maps[j][input_keymaps_translate_rk_to_keysym(RETROK_i)].key = RETROK_a; + icade_maps[j][input_keymaps_translate_rk_to_keysym(RETROK_m)].key = RETROK_a; + icade_maps[j][input_keymaps_translate_rk_to_keysym(RETROK_k)].key = RETROK_z; + icade_maps[j][input_keymaps_translate_rk_to_keysym(RETROK_p)].key = RETROK_z; + icade_maps[j][input_keymaps_translate_rk_to_keysym(RETROK_y)].key = RETROK_RSHIFT; + icade_maps[j][input_keymaps_translate_rk_to_keysym(RETROK_t)].key = RETROK_RSHIFT; + icade_maps[j][input_keymaps_translate_rk_to_keysym(RETROK_u)].key = RETROK_RETURN; + icade_maps[j][input_keymaps_translate_rk_to_keysym(RETROK_f)].key = RETROK_RETURN; + icade_maps[j][input_keymaps_translate_rk_to_keysym(RETROK_l)].key = RETROK_x; + icade_maps[j][input_keymaps_translate_rk_to_keysym(RETROK_v)].key = RETROK_x; + icade_maps[j][input_keymaps_translate_rk_to_keysym(RETROK_o)].key = RETROK_s; + icade_maps[j][input_keymaps_translate_rk_to_keysym(RETROK_g)].key = RETROK_s; + + icade_maps[j][input_keymaps_translate_rk_to_keysym(RETROK_e)].up = true; + icade_maps[j][input_keymaps_translate_rk_to_keysym(RETROK_z)].up = true; + icade_maps[j][input_keymaps_translate_rk_to_keysym(RETROK_q)].up = true; + icade_maps[j][input_keymaps_translate_rk_to_keysym(RETROK_c)].up = true; + icade_maps[j][input_keymaps_translate_rk_to_keysym(RETROK_r)].up = true; + icade_maps[j][input_keymaps_translate_rk_to_keysym(RETROK_n)].up = true; + icade_maps[j][input_keymaps_translate_rk_to_keysym(RETROK_m)].up = true; + icade_maps[j][input_keymaps_translate_rk_to_keysym(RETROK_p)].up = true; + icade_maps[j][input_keymaps_translate_rk_to_keysym(RETROK_t)].up = true; + icade_maps[j][input_keymaps_translate_rk_to_keysym(RETROK_f)].up = true; + icade_maps[j][input_keymaps_translate_rk_to_keysym(RETROK_v)].up = true; + icade_maps[j][input_keymaps_translate_rk_to_keysym(RETROK_g)].up = true; + } + + if ((*code < 0x20) && (icade_maps[kb_type_idx][*code].key != RETROK_UNKNOWN)) + { + *keydown = icade_maps[kb_type_idx][*code].up ? false : true; + ret = true; + *code = input_keymaps_translate_rk_to_keysym(icade_maps[kb_type_idx][*code].key); + } + + return ret; } +#endif void cocoa_input_keyboard_event(bool down, - unsigned code, uint32_t character, uint32_t mod, unsigned device, - bool ignore_keyboard_gamepad) + unsigned code, uint32_t character, uint32_t mod, unsigned device) { driver_t *driver = driver_get_ptr(); settings_t *settings = config_get_ptr(); @@ -242,15 +241,14 @@ void cocoa_input_keyboard_event(bool down, code = HIDKEY(code); - if (settings->input.keyboard_gamepad_enable && !ignore_keyboard_gamepad) - { - unsigned orig_code = code; - if (handle_icade_event(&code, &down)) - character = 0; - else - code = orig_code; - } #if TARGET_OS_IPHONE + if (settings->input.keyboard_gamepad_enable) + { + if (handle_icade_event(&code, &down)) + character = 0; + else + code = 0; + } else if (settings->input.small_keyboard_enable) { if (handle_small_keyboard(&code, down)) diff --git a/pkg/apple/RetroArch.xcodeproj/project.pbxproj b/pkg/apple/RetroArch.xcodeproj/project.pbxproj index 8025a3103e..5797e4b290 100644 --- a/pkg/apple/RetroArch.xcodeproj/project.pbxproj +++ b/pkg/apple/RetroArch.xcodeproj/project.pbxproj @@ -23,7 +23,6 @@ 500845341B89300700CE6073 /* IOKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 84DD5EB41A89E737007336C1 /* IOKit.framework */; }; 5061C8A41AE47E510080AE14 /* libz.dylib in Frameworks */ = {isa = PBXBuildFile; fileRef = 5061C8A31AE47E510080AE14 /* libz.dylib */; }; 509F0C9D1AA23AFC00619ECC /* griffin_objc.m in Sources */ = {isa = PBXBuildFile; fileRef = 509F0C9C1AA23AFC00619ECC /* griffin_objc.m */; }; - 50A1B3011BF69A8F007D47CD /* Carbon.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 50A1B3001BF69A8F007D47CD /* Carbon.framework */; }; 840222FC1A889EE2009AB261 /* griffin.c in Sources */ = {isa = PBXBuildFile; fileRef = 840222FB1A889EE2009AB261 /* griffin.c */; }; 84DD5E9F1A88E45B007336C1 /* CoreVideo.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 84DD5E9E1A88E45B007336C1 /* CoreVideo.framework */; }; 84DD5EA31A89E2AA007336C1 /* AppKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 29B97324FDCFA39411CA2CEA /* AppKit.framework */; }; @@ -78,11 +77,10 @@ 089C165DFE840E0CC02AAC07 /* InfoPlist.strings */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.strings; name = InfoPlist.strings; path = OSX/en.lproj/InfoPlist.strings; sourceTree = ""; }; 1DDD58150DA1D0A300B32029 /* MainMenu.xib */ = {isa = PBXFileReference; lastKnownFileType = file.xib; name = MainMenu.xib; path = OSX/en.lproj/MainMenu.xib; sourceTree = ""; }; 29B97324FDCFA39411CA2CEA /* AppKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = AppKit.framework; path = /System/Library/Frameworks/AppKit.framework; sourceTree = ""; }; - 5008453A1B89300700CE6073 /* RetroArchCg.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = RetroArchCg.app; sourceTree = BUILT_PRODUCTS_DIR; }; - 5008453B1B89300700CE6073 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; name = Info.plist; path = /../../pkg/apple/OSX/Info.plist; sourceTree = SOURCE_ROOT; }; + 5008453A1B89300700CE6073 /* RetroArchCg.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = "RetroArchCg.app"; sourceTree = BUILT_PRODUCTS_DIR; }; + 5008453B1B89300700CE6073 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; name = "Info.plist"; path = "/../../pkg/apple/OSX/Info.plist"; sourceTree = SOURCE_ROOT; }; 5061C8A31AE47E510080AE14 /* libz.dylib */ = {isa = PBXFileReference; lastKnownFileType = "compiled.mach-o.dylib"; name = libz.dylib; path = usr/lib/libz.dylib; sourceTree = SDKROOT; }; 509F0C9C1AA23AFC00619ECC /* griffin_objc.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = griffin_objc.m; path = ../../griffin/griffin_objc.m; sourceTree = ""; }; - 50A1B3001BF69A8F007D47CD /* Carbon.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Carbon.framework; path = System/Library/Frameworks/Carbon.framework; sourceTree = SDKROOT; }; 840222FB1A889EE2009AB261 /* griffin.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = griffin.c; path = ../../griffin/griffin.c; sourceTree = SOURCE_ROOT; }; 84DD5E9E1A88E45B007336C1 /* CoreVideo.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreVideo.framework; path = /System/Library/Frameworks/CoreVideo.framework; sourceTree = ""; }; 84DD5EA61A89E406007336C1 /* CoreLocation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreLocation.framework; path = /System/Library/Frameworks/CoreLocation.framework; sourceTree = ""; }; @@ -92,7 +90,7 @@ 84DD5EB21A89E6C0007336C1 /* AudioUnit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = AudioUnit.framework; path = /System/Library/Frameworks/AudioUnit.framework; sourceTree = ""; }; 84DD5EB41A89E737007336C1 /* IOKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = IOKit.framework; path = ../../../../../../System/Library/Frameworks/IOKit.framework; sourceTree = ""; }; 84DD5EB71A89F1C7007336C1 /* retroarch.icns */ = {isa = PBXFileReference; lastKnownFileType = image.icns; name = retroarch.icns; path = ../../media/retroarch.icns; sourceTree = ""; }; - 8D1107310486CEB800E47090 /* Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; name = Info.plist; path = OSX/Info.plist; sourceTree = ""; }; + 8D1107310486CEB800E47090 /* Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; name = "Info.plist"; path = "OSX/Info.plist"; sourceTree = ""; }; 8D1107320486CEB800E47090 /* RetroArch.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = RetroArch.app; sourceTree = BUILT_PRODUCTS_DIR; }; /* End PBXFileReference section */ @@ -101,7 +99,6 @@ isa = PBXFrameworksBuildPhase; buildActionMask = 2147483647; files = ( - 50A1B3011BF69A8F007D47CD /* Carbon.framework in Frameworks */, 5008452C1B89300700CE6073 /* libz.dylib in Frameworks */, 5008452D1B89300700CE6073 /* CoreAudio.framework in Frameworks */, 5008452E1B89300700CE6073 /* AudioUnit.framework in Frameworks */, @@ -207,7 +204,6 @@ 29B97323FDCFA39411CA2CEA /* Frameworks */ = { isa = PBXGroup; children = ( - 50A1B3001BF69A8F007D47CD /* Carbon.framework */, 5061C8A31AE47E510080AE14 /* libz.dylib */, 1058C7A0FEA54F0111CA2CBB /* Linked Frameworks */, 1058C7A2FEA54F0111CA2CBB /* Other Frameworks */, @@ -382,12 +378,12 @@ "$(SRCROOT)/../../gfx/inc", "$(SRCROOT)/../../libretro-common/include", ); - INFOPLIST_FILE = OSX/Info.plist; + INFOPLIST_FILE = "OSX/Info.plist"; INSTALL_PATH = "$(HOME)/Applications"; MACOSX_DEPLOYMENT_TARGET = 10.5; OTHER_CFLAGS = ( "-DHAVE_GRIFFIN", - "-DHAVE_CHEEVOS", + "-DHAVE_CHEEVOS", "-DHAVE_IMAGEVIEWER", "-DHAVE_CORETEXT", "-DHAVE_IOHIDMANAGER", @@ -422,7 +418,7 @@ "-DHAVE_LIBRETRODB", ); PRECOMPS_INCLUDE_HEADERS_FROM_BUILT_PRODUCTS_DIR = YES; - PRODUCT_NAME = RetroArchCg; + PRODUCT_NAME = "RetroArchCg"; }; name = Debug; }; @@ -443,12 +439,12 @@ "$(SRCROOT)/../../gfx/inc", "$(SRCROOT)/../../libretro-common/include", ); - INFOPLIST_FILE = OSX/Info.plist; + INFOPLIST_FILE = "OSX/Info.plist"; INSTALL_PATH = "$(HOME)/Applications"; MACOSX_DEPLOYMENT_TARGET = 10.5; OTHER_CFLAGS = ( "-DHAVE_GRIFFIN", - "-DHAVE_CHEEVOS", + "-DHAVE_CHEEVOS", "-DHAVE_IMAGEVIEWER", "-DHAVE_IOHIDMANAGER", "-DHAVE_CORETEXT", @@ -483,7 +479,7 @@ "-DHAVE_LIBRETRODB", ); PRECOMPS_INCLUDE_HEADERS_FROM_BUILT_PRODUCTS_DIR = YES; - PRODUCT_NAME = RetroArchCg; + PRODUCT_NAME = "RetroArchCg"; }; name = Release; }; @@ -511,7 +507,7 @@ MACOSX_DEPLOYMENT_TARGET = 10.5; OTHER_CFLAGS = ( "-DHAVE_GRIFFIN", - "-DHAVE_CHEEVOS", + "-DHAVE_CHEEVOS", "-DHAVE_IMAGEVIEWER", "-DHAVE_CORETEXT", "-DHAVE_IOHIDMANAGER", @@ -571,7 +567,7 @@ MACOSX_DEPLOYMENT_TARGET = 10.5; OTHER_CFLAGS = ( "-DHAVE_GRIFFIN", - "-DHAVE_CHEEVOS", + "-DHAVE_CHEEVOS", "-DHAVE_IMAGEVIEWER", "-DHAVE_IOHIDMANAGER", "-DHAVE_CORETEXT", diff --git a/ui/drivers/ui_cocoa.m b/ui/drivers/ui_cocoa.m index 2f84f3a79c..1d50516bcd 100644 --- a/ui/drivers/ui_cocoa.m +++ b/ui/drivers/ui_cocoa.m @@ -43,21 +43,12 @@ void apple_rarch_exited(void) - (void)sendEvent:(NSEvent *)event { - unsigned kbt; NSEventType event_type; cocoa_input_data_t *apple = NULL; driver_t *driver = driver_get_ptr(); if (!driver) return; [super sendEvent:event]; - - EventRef ce = (EventRef)[event eventRef]; - if (ce) - { - GetEventParameter(ce, kEventParamKeyboardType, - typeUInt32, NULL, sizeof(kbt), NULL, &kbt); - NSLog(@"kbt is: %d", kbt); - } apple = (cocoa_input_data_t*)driver->input_data; event_type = event.type; @@ -94,13 +85,11 @@ void apple_rarch_exited(void) for (i = 1; i < ch.length; i++) cocoa_input_keyboard_event(event_type == NSKeyDown, - 0, [ch characterAtIndex:i], mod, RETRO_DEVICE_KEYBOARD, - (kbt == 44) ? true : false); + 0, [ch characterAtIndex:i], mod, RETRO_DEVICE_KEYBOARD); } cocoa_input_keyboard_event(event_type == NSKeyDown, - (uint32_t)event.keyCode, character, mod, RETRO_DEVICE_KEYBOARD, - (kbt == 44) ? true : false); + event.keyCode, character, mod, RETRO_DEVICE_KEYBOARD); } break; case NSFlagsChanged: @@ -111,8 +100,7 @@ void apple_rarch_exited(void) old_flags = new_flags; cocoa_input_keyboard_event(down, event.keyCode, - 0, event.modifierFlags, RETRO_DEVICE_KEYBOARD, - (kbt == 44) ? true : false); + 0, event.modifierFlags, RETRO_DEVICE_KEYBOARD); } break; case NSMouseMoved: From a2cc0638db138623a4e6540875159b7e434b9666 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Sat, 14 Nov 2015 02:10:09 +0100 Subject: [PATCH 208/216] (menu_display.c) Get rid of type qualifier --- menu/menu_display.c | 2 +- menu/menu_display.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/menu/menu_display.c b/menu/menu_display.c index b88bc97155..f4fa474fdc 100644 --- a/menu/menu_display.c +++ b/menu/menu_display.c @@ -215,7 +215,7 @@ static bool menu_display_check_compatibility(enum menu_display_driver_type type) return false; } -const bool menu_display_driver_init_first(void) +bool menu_display_driver_init_first(void) { unsigned i; menu_display_t *disp = menu_display_get_ptr(); diff --git a/menu/menu_display.h b/menu/menu_display.h index 93859dace0..9548830201 100644 --- a/menu/menu_display.h +++ b/menu/menu_display.h @@ -139,7 +139,7 @@ void menu_display_msg_queue_push(const char *msg, unsigned prio, unsigned durati bool flush); -const bool menu_display_driver_init_first(void); +bool menu_display_driver_init_first(void); void menu_display_draw(unsigned x, unsigned y, unsigned width, unsigned height, From 4b63df35baa5d3c9337724682e35508a06555885 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Sat, 14 Nov 2015 03:18:00 +0100 Subject: [PATCH 209/216] (Android) Should cache DPI once and then just return the value without doing costly popen calls every time --- gfx/drivers_context/androidegl_ctx.c | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/gfx/drivers_context/androidegl_ctx.c b/gfx/drivers_context/androidegl_ctx.c index ba705aea97..206d62227b 100644 --- a/gfx/drivers_context/androidegl_ctx.c +++ b/gfx/drivers_context/androidegl_ctx.c @@ -438,9 +438,8 @@ static void dpi_get_density(char *s, size_t len) static bool android_gfx_ctx_get_metrics(void *data, enum display_metric_types type, float *value) { - int dpi; + static int dpi = -1; char density[PROP_VALUE_MAX] = {0}; - dpi_get_density(density, sizeof(density)); switch (type) { @@ -449,9 +448,13 @@ static bool android_gfx_ctx_get_metrics(void *data, case DISPLAY_METRIC_MM_HEIGHT: return false; case DISPLAY_METRIC_DPI: - if (density[0] == '\0') - return false; - dpi = atoi(density); + if (dpi == -1) + { + dpi_get_density(density, sizeof(density)); + if (density[0] == '\0') + return false; + dpi = atoi(density); + } *value = (float)dpi; break; case DISPLAY_METRIC_NONE: From 1ef96019663e72f222c2d9edbf567d92c998ca1f Mon Sep 17 00:00:00 2001 From: twinaphex Date: Sat, 14 Nov 2015 05:27:44 +0100 Subject: [PATCH 210/216] Revert "(GL) Cleanups" This reverts commit 36d5cc890b37a3f351877bb6b83851e4c5af57dd. --- gfx/drivers/gl.c | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/gfx/drivers/gl.c b/gfx/drivers/gl.c index 191695962b..ab254a99ec 100644 --- a/gfx/drivers/gl.c +++ b/gfx/drivers/gl.c @@ -899,16 +899,18 @@ static void gl_set_viewport(void *data, unsigned viewport_width, viewport_height = (unsigned)roundf(2.0f * viewport_height * delta); } } + + gl->vp.x = x; + gl->vp.y = y; + gl->vp.width = viewport_width; + gl->vp.height = viewport_height; } else { - x = 0; - y = 0; + gl->vp.x = gl->vp.y = 0; + gl->vp.width = viewport_width; + gl->vp.height = viewport_height; } - gl->vp.x = x; - gl->vp.y = y; - gl->vp.width = viewport_width; - gl->vp.height = viewport_height; #if defined(RARCH_MOBILE) /* In portrait mode, we want viewport to gravitate to top of screen. */ From 06c65e2829a293151d4705daab8d7b3714e7295b Mon Sep 17 00:00:00 2001 From: twinaphex Date: Sat, 14 Nov 2015 08:14:18 +0100 Subject: [PATCH 211/216] (X11) Move keybind map to input_keymaps.c --- input/drivers/x11_input.c | 139 ---------------------------------- input/input_keymaps.c | 155 +++++++++++++++++++++++++++++++++++++- 2 files changed, 152 insertions(+), 142 deletions(-) diff --git a/input/drivers/x11_input.c b/input/drivers/x11_input.c index 4df16f847f..273e28bc5d 100644 --- a/input/drivers/x11_input.c +++ b/input/drivers/x11_input.c @@ -46,145 +46,6 @@ typedef struct x11_input bool grab_mouse; } x11_input_t; -const struct rarch_key_map rarch_key_map_x11[] = { - { XK_BackSpace, RETROK_BACKSPACE }, - { XK_Tab, RETROK_TAB }, - { XK_Clear, RETROK_CLEAR }, - { XK_Return, RETROK_RETURN }, - { XK_Pause, RETROK_PAUSE }, - { XK_Escape, RETROK_ESCAPE }, - { XK_space, RETROK_SPACE }, - { XK_exclam, RETROK_EXCLAIM }, - { XK_quotedbl, RETROK_QUOTEDBL }, - { XK_numbersign, RETROK_HASH }, - { XK_dollar, RETROK_DOLLAR }, - { XK_ampersand, RETROK_AMPERSAND }, - { XK_apostrophe, RETROK_QUOTE }, - { XK_parenleft, RETROK_LEFTPAREN }, - { XK_parenright, RETROK_RIGHTPAREN }, - { XK_asterisk, RETROK_ASTERISK }, - { XK_plus, RETROK_PLUS }, - { XK_comma, RETROK_COMMA }, - { XK_minus, RETROK_MINUS }, - { XK_period, RETROK_PERIOD }, - { XK_slash, RETROK_SLASH }, - { XK_0, RETROK_0 }, - { XK_1, RETROK_1 }, - { XK_2, RETROK_2 }, - { XK_3, RETROK_3 }, - { XK_4, RETROK_4 }, - { XK_5, RETROK_5 }, - { XK_6, RETROK_6 }, - { XK_7, RETROK_7 }, - { XK_8, RETROK_8 }, - { XK_9, RETROK_9 }, - { XK_colon, RETROK_COLON }, - { XK_semicolon, RETROK_SEMICOLON }, - { XK_less, RETROK_LESS }, - { XK_equal, RETROK_EQUALS }, - { XK_greater, RETROK_GREATER }, - { XK_question, RETROK_QUESTION }, - { XK_at, RETROK_AT }, - { XK_bracketleft, RETROK_LEFTBRACKET }, - { XK_backslash, RETROK_BACKSLASH }, - { XK_bracketright, RETROK_RIGHTBRACKET }, - { XK_dead_circumflex, RETROK_CARET }, - { XK_underscore, RETROK_UNDERSCORE }, - { XK_grave, RETROK_BACKQUOTE }, - { XK_a, RETROK_a }, - { XK_b, RETROK_b }, - { XK_c, RETROK_c }, - { XK_d, RETROK_d }, - { XK_e, RETROK_e }, - { XK_f, RETROK_f }, - { XK_g, RETROK_g }, - { XK_h, RETROK_h }, - { XK_i, RETROK_i }, - { XK_j, RETROK_j }, - { XK_k, RETROK_k }, - { XK_l, RETROK_l }, - { XK_m, RETROK_m }, - { XK_n, RETROK_n }, - { XK_o, RETROK_o }, - { XK_p, RETROK_p }, - { XK_q, RETROK_q }, - { XK_r, RETROK_r }, - { XK_s, RETROK_s }, - { XK_t, RETROK_t }, - { XK_u, RETROK_u }, - { XK_v, RETROK_v }, - { XK_w, RETROK_w }, - { XK_x, RETROK_x }, - { XK_y, RETROK_y }, - { XK_z, RETROK_z }, - { XK_Delete, RETROK_DELETE }, - { XK_KP_0, RETROK_KP0 }, - { XK_KP_1, RETROK_KP1 }, - { XK_KP_2, RETROK_KP2 }, - { XK_KP_3, RETROK_KP3 }, - { XK_KP_4, RETROK_KP4 }, - { XK_KP_5, RETROK_KP5 }, - { XK_KP_6, RETROK_KP6 }, - { XK_KP_7, RETROK_KP7 }, - { XK_KP_8, RETROK_KP8 }, - { XK_KP_9, RETROK_KP9 }, - { XK_KP_Decimal, RETROK_KP_PERIOD }, - { XK_KP_Divide, RETROK_KP_DIVIDE }, - { XK_KP_Multiply, RETROK_KP_MULTIPLY }, - { XK_KP_Subtract, RETROK_KP_MINUS }, - { XK_KP_Add, RETROK_KP_PLUS }, - { XK_KP_Enter, RETROK_KP_ENTER }, - { XK_KP_Equal, RETROK_KP_EQUALS }, - { XK_Up, RETROK_UP }, - { XK_Down, RETROK_DOWN }, - { XK_Right, RETROK_RIGHT }, - { XK_Left, RETROK_LEFT }, - { XK_Insert, RETROK_INSERT }, - { XK_Home, RETROK_HOME }, - { XK_End, RETROK_END }, - { XK_Page_Up, RETROK_PAGEUP }, - { XK_Page_Down, RETROK_PAGEDOWN }, - { XK_F1, RETROK_F1 }, - { XK_F2, RETROK_F2 }, - { XK_F3, RETROK_F3 }, - { XK_F4, RETROK_F4 }, - { XK_F5, RETROK_F5 }, - { XK_F6, RETROK_F6 }, - { XK_F7, RETROK_F7 }, - { XK_F8, RETROK_F8 }, - { XK_F9, RETROK_F9 }, - { XK_F10, RETROK_F10 }, - { XK_F11, RETROK_F11 }, - { XK_F12, RETROK_F12 }, - { XK_F13, RETROK_F13 }, - { XK_F14, RETROK_F14 }, - { XK_F15, RETROK_F15 }, - { XK_Num_Lock, RETROK_NUMLOCK }, - { XK_Caps_Lock, RETROK_CAPSLOCK }, - { XK_Scroll_Lock, RETROK_SCROLLOCK }, - { XK_Shift_R, RETROK_RSHIFT }, - { XK_Shift_L, RETROK_LSHIFT }, - { XK_Control_R, RETROK_RCTRL }, - { XK_Control_L, RETROK_LCTRL }, - { XK_Alt_R, RETROK_RALT }, - { XK_Alt_L, RETROK_LALT }, - { XK_Meta_R, RETROK_RMETA }, - { XK_Meta_L, RETROK_LMETA }, - { XK_Super_L, RETROK_LSUPER }, - { XK_Super_R, RETROK_RSUPER }, - { XK_Mode_switch, RETROK_MODE }, - { XK_Multi_key, RETROK_COMPOSE }, - { XK_Help, RETROK_HELP }, - { XK_Print, RETROK_PRINT }, - { XK_Sys_Req, RETROK_SYSREQ }, - { XK_Break, RETROK_BREAK }, - { XK_Menu, RETROK_MENU }, - /*{ ?, RETROK_POWER },*/ - { XK_EuroSign, RETROK_EURO }, - { XK_Undo, RETROK_UNDO }, - - { 0, RETROK_UNKNOWN }, -}; static void *x_input_init(void) { diff --git a/input/input_keymaps.c b/input/input_keymaps.c index 8c425d64b4..fddf254848 100644 --- a/input/input_keymaps.c +++ b/input/input_keymaps.c @@ -18,16 +18,23 @@ #include #include +#ifdef HAVE_CONFIG_H +#include "../config.h" +#endif + #ifdef __linux__ #include #include #endif +#ifdef HAVE_X11 +#include +#include +#include +#endif + #include "input_keymaps.h" #include "../general.h" -#ifdef HAVE_CONFIG_H -#include "../config.h" -#endif #ifdef __APPLE__ #include "drivers/apple_keycode.h" @@ -265,6 +272,148 @@ const struct rarch_key_map rarch_key_map_rwebinput[] = { }; #endif +#ifdef HAVE_X11 +const struct rarch_key_map rarch_key_map_x11[] = { + { XK_BackSpace, RETROK_BACKSPACE }, + { XK_Tab, RETROK_TAB }, + { XK_Clear, RETROK_CLEAR }, + { XK_Return, RETROK_RETURN }, + { XK_Pause, RETROK_PAUSE }, + { XK_Escape, RETROK_ESCAPE }, + { XK_space, RETROK_SPACE }, + { XK_exclam, RETROK_EXCLAIM }, + { XK_quotedbl, RETROK_QUOTEDBL }, + { XK_numbersign, RETROK_HASH }, + { XK_dollar, RETROK_DOLLAR }, + { XK_ampersand, RETROK_AMPERSAND }, + { XK_apostrophe, RETROK_QUOTE }, + { XK_parenleft, RETROK_LEFTPAREN }, + { XK_parenright, RETROK_RIGHTPAREN }, + { XK_asterisk, RETROK_ASTERISK }, + { XK_plus, RETROK_PLUS }, + { XK_comma, RETROK_COMMA }, + { XK_minus, RETROK_MINUS }, + { XK_period, RETROK_PERIOD }, + { XK_slash, RETROK_SLASH }, + { XK_0, RETROK_0 }, + { XK_1, RETROK_1 }, + { XK_2, RETROK_2 }, + { XK_3, RETROK_3 }, + { XK_4, RETROK_4 }, + { XK_5, RETROK_5 }, + { XK_6, RETROK_6 }, + { XK_7, RETROK_7 }, + { XK_8, RETROK_8 }, + { XK_9, RETROK_9 }, + { XK_colon, RETROK_COLON }, + { XK_semicolon, RETROK_SEMICOLON }, + { XK_less, RETROK_LESS }, + { XK_equal, RETROK_EQUALS }, + { XK_greater, RETROK_GREATER }, + { XK_question, RETROK_QUESTION }, + { XK_at, RETROK_AT }, + { XK_bracketleft, RETROK_LEFTBRACKET }, + { XK_backslash, RETROK_BACKSLASH }, + { XK_bracketright, RETROK_RIGHTBRACKET }, + { XK_dead_circumflex, RETROK_CARET }, + { XK_underscore, RETROK_UNDERSCORE }, + { XK_grave, RETROK_BACKQUOTE }, + { XK_a, RETROK_a }, + { XK_b, RETROK_b }, + { XK_c, RETROK_c }, + { XK_d, RETROK_d }, + { XK_e, RETROK_e }, + { XK_f, RETROK_f }, + { XK_g, RETROK_g }, + { XK_h, RETROK_h }, + { XK_i, RETROK_i }, + { XK_j, RETROK_j }, + { XK_k, RETROK_k }, + { XK_l, RETROK_l }, + { XK_m, RETROK_m }, + { XK_n, RETROK_n }, + { XK_o, RETROK_o }, + { XK_p, RETROK_p }, + { XK_q, RETROK_q }, + { XK_r, RETROK_r }, + { XK_s, RETROK_s }, + { XK_t, RETROK_t }, + { XK_u, RETROK_u }, + { XK_v, RETROK_v }, + { XK_w, RETROK_w }, + { XK_x, RETROK_x }, + { XK_y, RETROK_y }, + { XK_z, RETROK_z }, + { XK_Delete, RETROK_DELETE }, + { XK_KP_0, RETROK_KP0 }, + { XK_KP_1, RETROK_KP1 }, + { XK_KP_2, RETROK_KP2 }, + { XK_KP_3, RETROK_KP3 }, + { XK_KP_4, RETROK_KP4 }, + { XK_KP_5, RETROK_KP5 }, + { XK_KP_6, RETROK_KP6 }, + { XK_KP_7, RETROK_KP7 }, + { XK_KP_8, RETROK_KP8 }, + { XK_KP_9, RETROK_KP9 }, + { XK_KP_Decimal, RETROK_KP_PERIOD }, + { XK_KP_Divide, RETROK_KP_DIVIDE }, + { XK_KP_Multiply, RETROK_KP_MULTIPLY }, + { XK_KP_Subtract, RETROK_KP_MINUS }, + { XK_KP_Add, RETROK_KP_PLUS }, + { XK_KP_Enter, RETROK_KP_ENTER }, + { XK_KP_Equal, RETROK_KP_EQUALS }, + { XK_Up, RETROK_UP }, + { XK_Down, RETROK_DOWN }, + { XK_Right, RETROK_RIGHT }, + { XK_Left, RETROK_LEFT }, + { XK_Insert, RETROK_INSERT }, + { XK_Home, RETROK_HOME }, + { XK_End, RETROK_END }, + { XK_Page_Up, RETROK_PAGEUP }, + { XK_Page_Down, RETROK_PAGEDOWN }, + { XK_F1, RETROK_F1 }, + { XK_F2, RETROK_F2 }, + { XK_F3, RETROK_F3 }, + { XK_F4, RETROK_F4 }, + { XK_F5, RETROK_F5 }, + { XK_F6, RETROK_F6 }, + { XK_F7, RETROK_F7 }, + { XK_F8, RETROK_F8 }, + { XK_F9, RETROK_F9 }, + { XK_F10, RETROK_F10 }, + { XK_F11, RETROK_F11 }, + { XK_F12, RETROK_F12 }, + { XK_F13, RETROK_F13 }, + { XK_F14, RETROK_F14 }, + { XK_F15, RETROK_F15 }, + { XK_Num_Lock, RETROK_NUMLOCK }, + { XK_Caps_Lock, RETROK_CAPSLOCK }, + { XK_Scroll_Lock, RETROK_SCROLLOCK }, + { XK_Shift_R, RETROK_RSHIFT }, + { XK_Shift_L, RETROK_LSHIFT }, + { XK_Control_R, RETROK_RCTRL }, + { XK_Control_L, RETROK_LCTRL }, + { XK_Alt_R, RETROK_RALT }, + { XK_Alt_L, RETROK_LALT }, + { XK_Meta_R, RETROK_RMETA }, + { XK_Meta_L, RETROK_LMETA }, + { XK_Super_L, RETROK_LSUPER }, + { XK_Super_R, RETROK_RSUPER }, + { XK_Mode_switch, RETROK_MODE }, + { XK_Multi_key, RETROK_COMPOSE }, + { XK_Help, RETROK_HELP }, + { XK_Print, RETROK_PRINT }, + { XK_Sys_Req, RETROK_SYSREQ }, + { XK_Break, RETROK_BREAK }, + { XK_Menu, RETROK_MENU }, + /*{ ?, RETROK_POWER },*/ + { XK_EuroSign, RETROK_EURO }, + { XK_Undo, RETROK_UNDO }, + + { 0, RETROK_UNKNOWN }, +}; +#endif + #ifdef __linux__ const struct rarch_key_map rarch_key_map_linux[] = { { KEY_BACKSPACE, RETROK_BACKSPACE }, From 33292634ec9a847ba374f51cc038cdc0a7a83d9f Mon Sep 17 00:00:00 2001 From: twinaphex Date: Sat, 14 Nov 2015 08:21:42 +0100 Subject: [PATCH 212/216] Move dinput keymap to input_keymaps.c --- input/drivers/dinput.c | 155 +++++++---------------------------------- input/input_keymaps.c | 113 ++++++++++++++++++++++++++++++ 2 files changed, 137 insertions(+), 131 deletions(-) diff --git a/input/drivers/dinput.c b/input/drivers/dinput.c index bd0edc91f7..b7e1c15812 100644 --- a/input/drivers/dinput.c +++ b/input/drivers/dinput.c @@ -79,110 +79,6 @@ struct dinput_input struct pointer_status pointer_head; /* dummy head for easier iteration */ }; -const struct rarch_key_map rarch_key_map_dinput[] = { - { DIK_LEFT, RETROK_LEFT }, - { DIK_RIGHT, RETROK_RIGHT }, - { DIK_UP, RETROK_UP }, - { DIK_DOWN, RETROK_DOWN }, - { DIK_RETURN, RETROK_RETURN }, - { DIK_TAB, RETROK_TAB }, - { DIK_INSERT, RETROK_INSERT }, - { DIK_DELETE, RETROK_DELETE }, - { DIK_RSHIFT, RETROK_RSHIFT }, - { DIK_LSHIFT, RETROK_LSHIFT }, - { DIK_LCONTROL, RETROK_LCTRL }, - { DIK_END, RETROK_END }, - { DIK_HOME, RETROK_HOME }, - { DIK_NEXT, RETROK_PAGEDOWN }, - { DIK_PRIOR, RETROK_PAGEUP }, - { DIK_LALT, RETROK_LALT }, - { DIK_SPACE, RETROK_SPACE }, - { DIK_ESCAPE, RETROK_ESCAPE }, - { DIK_BACKSPACE, RETROK_BACKSPACE }, - { DIK_NUMPADENTER, RETROK_KP_ENTER }, - { DIK_NUMPADPLUS, RETROK_KP_PLUS }, - { DIK_NUMPADMINUS, RETROK_KP_MINUS }, - { DIK_NUMPADSTAR, RETROK_KP_MULTIPLY }, - { DIK_DIVIDE, RETROK_KP_DIVIDE }, - { DIK_GRAVE, RETROK_BACKQUOTE }, - { DIK_PAUSE, RETROK_PAUSE }, - { DIK_NUMPAD0, RETROK_KP0 }, - { DIK_NUMPAD1, RETROK_KP1 }, - { DIK_NUMPAD2, RETROK_KP2 }, - { DIK_NUMPAD3, RETROK_KP3 }, - { DIK_NUMPAD4, RETROK_KP4 }, - { DIK_NUMPAD5, RETROK_KP5 }, - { DIK_NUMPAD6, RETROK_KP6 }, - { DIK_NUMPAD7, RETROK_KP7 }, - { DIK_NUMPAD8, RETROK_KP8 }, - { DIK_NUMPAD9, RETROK_KP9 }, - { DIK_0, RETROK_0 }, - { DIK_1, RETROK_1 }, - { DIK_2, RETROK_2 }, - { DIK_3, RETROK_3 }, - { DIK_4, RETROK_4 }, - { DIK_5, RETROK_5 }, - { DIK_6, RETROK_6 }, - { DIK_7, RETROK_7 }, - { DIK_8, RETROK_8 }, - { DIK_9, RETROK_9 }, - { DIK_F1, RETROK_F1 }, - { DIK_F2, RETROK_F2 }, - { DIK_F3, RETROK_F3 }, - { DIK_F4, RETROK_F4 }, - { DIK_F5, RETROK_F5 }, - { DIK_F6, RETROK_F6 }, - { DIK_F7, RETROK_F7 }, - { DIK_F8, RETROK_F8 }, - { DIK_F9, RETROK_F9 }, - { DIK_F10, RETROK_F10 }, - { DIK_F11, RETROK_F11 }, - { DIK_F12, RETROK_F12 }, - { DIK_A, RETROK_a }, - { DIK_B, RETROK_b }, - { DIK_C, RETROK_c }, - { DIK_D, RETROK_d }, - { DIK_E, RETROK_e }, - { DIK_F, RETROK_f }, - { DIK_G, RETROK_g }, - { DIK_H, RETROK_h }, - { DIK_I, RETROK_i }, - { DIK_J, RETROK_j }, - { DIK_K, RETROK_k }, - { DIK_L, RETROK_l }, - { DIK_M, RETROK_m }, - { DIK_N, RETROK_n }, - { DIK_O, RETROK_o }, - { DIK_P, RETROK_p }, - { DIK_Q, RETROK_q }, - { DIK_R, RETROK_r }, - { DIK_S, RETROK_s }, - { DIK_T, RETROK_t }, - { DIK_U, RETROK_u }, - { DIK_V, RETROK_v }, - { DIK_W, RETROK_w }, - { DIK_X, RETROK_x }, - { DIK_Y, RETROK_y }, - { DIK_Z, RETROK_z }, - { DIK_APOSTROPHE, RETROK_QUOTE }, - { DIK_COMMA, RETROK_COMMA }, - { DIK_MINUS, RETROK_MINUS }, - { DIK_SLASH, RETROK_SLASH }, - { DIK_SEMICOLON, RETROK_SEMICOLON }, - { DIK_EQUALS, RETROK_EQUALS }, - { DIK_LBRACKET, RETROK_LEFTBRACKET }, - { DIK_BACKSLASH, RETROK_BACKSLASH }, - { DIK_RBRACKET, RETROK_RIGHTBRACKET }, - { DIK_DECIMAL, RETROK_KP_PERIOD }, - { DIK_RCONTROL, RETROK_RCTRL }, - { DIK_RMENU, RETROK_RALT }, - { DIK_PERIOD, RETROK_PERIOD }, - { DIK_SCROLL, RETROK_SCROLLOCK }, - { DIK_CAPSLOCK, RETROK_CAPSLOCK }, - { DIK_NUMLOCK, RETROK_NUMLOCK }, - { 0, RETROK_UNKNOWN }, -}; - void dinput_destroy_context(void) { if (!g_dinput_ctx) @@ -200,15 +96,13 @@ bool dinput_init_context(void) CoInitialize(NULL); /* Who said we shouldn't have same call signature in a COM API? <_< */ -#ifdef __cplusplus if (FAILED(DirectInput8Create( - GetModuleHandle(NULL), DIRECTINPUT_VERSION, IID_IDirectInput8, - (void**)&g_dinput_ctx, NULL))) -#else - if (FAILED(DirectInput8Create( - GetModuleHandle(NULL), DIRECTINPUT_VERSION, &IID_IDirectInput8, - (void**)&g_dinput_ctx, NULL))) + GetModuleHandle(NULL), DIRECTINPUT_VERSION, +#ifndef __cplusplus + & #endif + IID_IDirectInput8, + (void**)&g_dinput_ctx, NULL))) { RARCH_ERR("Failed to init DirectInput.\n"); return false; @@ -233,30 +127,27 @@ static void *dinput_init(void) if (!di) return NULL; -#ifdef __cplusplus - if (FAILED(IDirectInput8_CreateDevice(g_dinput_ctx, GUID_SysKeyboard, &di->keyboard, NULL))) + if (FAILED(IDirectInput8_CreateDevice(g_dinput_ctx, +#ifndef __cplusplus + & +#endif + GUID_SysKeyboard, + &di->keyboard, NULL))) { RARCH_ERR("Failed to create keyboard device.\n"); di->keyboard = NULL; } - if (FAILED(IDirectInput8_CreateDevice(g_dinput_ctx, GUID_SysMouse, &di->mouse, NULL))) - { - RARCH_ERR("Failed to create mouse device.\n"); - di->mouse = NULL; - } -#else - if (FAILED(IDirectInput8_CreateDevice(g_dinput_ctx, &GUID_SysKeyboard, &di->keyboard, NULL))) - { - RARCH_ERR("Failed to create keyboard device.\n"); - di->keyboard = NULL; - } - if (FAILED(IDirectInput8_CreateDevice(g_dinput_ctx, &GUID_SysMouse, &di->mouse, NULL))) - { - RARCH_ERR("Failed to create mouse device.\n"); - di->mouse = NULL; - } + if (FAILED(IDirectInput8_CreateDevice(g_dinput_ctx, +#ifndef __cplusplus + & #endif + GUID_SysMouse, + &di->mouse, NULL))) + { + RARCH_ERR("Failed to create mouse device.\n"); + di->mouse = NULL; + } if (di->keyboard) { @@ -473,7 +364,7 @@ static int16_t dinput_mouse_state_screen(struct dinput_input *di, unsigned id) case RETRO_DEVICE_ID_MOUSE_Y: return di->mouse_y; default: - break; + break; } return dinput_mouse_state(di, id); @@ -533,8 +424,10 @@ static int16_t dinput_pointer_state(struct dinput_input *di, case RETRO_DEVICE_ID_POINTER_PRESSED: return pointer_down; default: - return 0; + break; } + + return 0; } static int16_t dinput_input_state(void *data, diff --git a/input/input_keymaps.c b/input/input_keymaps.c index fddf254848..c2cd4d206f 100644 --- a/input/input_keymaps.c +++ b/input/input_keymaps.c @@ -33,6 +33,13 @@ #include #endif +#ifdef HAVE_DINPUT +#undef DIRECTINPUT_VERSION +#define DIRECTINPUT_VERSION 0x0800 + +#include +#endif + #include "input_keymaps.h" #include "../general.h" @@ -166,6 +173,112 @@ const struct input_key_map input_config_key_map[] = { { NULL, RETROK_UNKNOWN }, }; +#ifdef HAVE_DINPUT +const struct rarch_key_map rarch_key_map_dinput[] = { + { DIK_LEFT, RETROK_LEFT }, + { DIK_RIGHT, RETROK_RIGHT }, + { DIK_UP, RETROK_UP }, + { DIK_DOWN, RETROK_DOWN }, + { DIK_RETURN, RETROK_RETURN }, + { DIK_TAB, RETROK_TAB }, + { DIK_INSERT, RETROK_INSERT }, + { DIK_DELETE, RETROK_DELETE }, + { DIK_RSHIFT, RETROK_RSHIFT }, + { DIK_LSHIFT, RETROK_LSHIFT }, + { DIK_LCONTROL, RETROK_LCTRL }, + { DIK_END, RETROK_END }, + { DIK_HOME, RETROK_HOME }, + { DIK_NEXT, RETROK_PAGEDOWN }, + { DIK_PRIOR, RETROK_PAGEUP }, + { DIK_LALT, RETROK_LALT }, + { DIK_SPACE, RETROK_SPACE }, + { DIK_ESCAPE, RETROK_ESCAPE }, + { DIK_BACKSPACE, RETROK_BACKSPACE }, + { DIK_NUMPADENTER, RETROK_KP_ENTER }, + { DIK_NUMPADPLUS, RETROK_KP_PLUS }, + { DIK_NUMPADMINUS, RETROK_KP_MINUS }, + { DIK_NUMPADSTAR, RETROK_KP_MULTIPLY }, + { DIK_DIVIDE, RETROK_KP_DIVIDE }, + { DIK_GRAVE, RETROK_BACKQUOTE }, + { DIK_PAUSE, RETROK_PAUSE }, + { DIK_NUMPAD0, RETROK_KP0 }, + { DIK_NUMPAD1, RETROK_KP1 }, + { DIK_NUMPAD2, RETROK_KP2 }, + { DIK_NUMPAD3, RETROK_KP3 }, + { DIK_NUMPAD4, RETROK_KP4 }, + { DIK_NUMPAD5, RETROK_KP5 }, + { DIK_NUMPAD6, RETROK_KP6 }, + { DIK_NUMPAD7, RETROK_KP7 }, + { DIK_NUMPAD8, RETROK_KP8 }, + { DIK_NUMPAD9, RETROK_KP9 }, + { DIK_0, RETROK_0 }, + { DIK_1, RETROK_1 }, + { DIK_2, RETROK_2 }, + { DIK_3, RETROK_3 }, + { DIK_4, RETROK_4 }, + { DIK_5, RETROK_5 }, + { DIK_6, RETROK_6 }, + { DIK_7, RETROK_7 }, + { DIK_8, RETROK_8 }, + { DIK_9, RETROK_9 }, + { DIK_F1, RETROK_F1 }, + { DIK_F2, RETROK_F2 }, + { DIK_F3, RETROK_F3 }, + { DIK_F4, RETROK_F4 }, + { DIK_F5, RETROK_F5 }, + { DIK_F6, RETROK_F6 }, + { DIK_F7, RETROK_F7 }, + { DIK_F8, RETROK_F8 }, + { DIK_F9, RETROK_F9 }, + { DIK_F10, RETROK_F10 }, + { DIK_F11, RETROK_F11 }, + { DIK_F12, RETROK_F12 }, + { DIK_A, RETROK_a }, + { DIK_B, RETROK_b }, + { DIK_C, RETROK_c }, + { DIK_D, RETROK_d }, + { DIK_E, RETROK_e }, + { DIK_F, RETROK_f }, + { DIK_G, RETROK_g }, + { DIK_H, RETROK_h }, + { DIK_I, RETROK_i }, + { DIK_J, RETROK_j }, + { DIK_K, RETROK_k }, + { DIK_L, RETROK_l }, + { DIK_M, RETROK_m }, + { DIK_N, RETROK_n }, + { DIK_O, RETROK_o }, + { DIK_P, RETROK_p }, + { DIK_Q, RETROK_q }, + { DIK_R, RETROK_r }, + { DIK_S, RETROK_s }, + { DIK_T, RETROK_t }, + { DIK_U, RETROK_u }, + { DIK_V, RETROK_v }, + { DIK_W, RETROK_w }, + { DIK_X, RETROK_x }, + { DIK_Y, RETROK_y }, + { DIK_Z, RETROK_z }, + { DIK_APOSTROPHE, RETROK_QUOTE }, + { DIK_COMMA, RETROK_COMMA }, + { DIK_MINUS, RETROK_MINUS }, + { DIK_SLASH, RETROK_SLASH }, + { DIK_SEMICOLON, RETROK_SEMICOLON }, + { DIK_EQUALS, RETROK_EQUALS }, + { DIK_LBRACKET, RETROK_LEFTBRACKET }, + { DIK_BACKSLASH, RETROK_BACKSLASH }, + { DIK_RBRACKET, RETROK_RIGHTBRACKET }, + { DIK_DECIMAL, RETROK_KP_PERIOD }, + { DIK_RCONTROL, RETROK_RCTRL }, + { DIK_RMENU, RETROK_RALT }, + { DIK_PERIOD, RETROK_PERIOD }, + { DIK_SCROLL, RETROK_SCROLLOCK }, + { DIK_CAPSLOCK, RETROK_CAPSLOCK }, + { DIK_NUMLOCK, RETROK_NUMLOCK }, + { 0, RETROK_UNKNOWN }, +}; +#endif + #ifdef EMSCRIPTEN const struct rarch_key_map rarch_key_map_rwebinput[] = { { 37, RETROK_LEFT }, From 81b741e359c724fb7503c72e0dd1946524cf71fc Mon Sep 17 00:00:00 2001 From: twinaphex Date: Sat, 14 Nov 2015 08:28:59 +0100 Subject: [PATCH 213/216] Move SDL keymap to input_keymaps.c --- input/drivers/sdl_input.c | 177 ------------------------------------ input/input_keymaps.c | 183 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 183 insertions(+), 177 deletions(-) diff --git a/input/drivers/sdl_input.c b/input/drivers/sdl_input.c index 22deb06dec..c25207a05c 100644 --- a/input/drivers/sdl_input.c +++ b/input/drivers/sdl_input.c @@ -41,183 +41,6 @@ typedef struct sdl_input int mouse_l, mouse_r, mouse_m, mouse_wu, mouse_wd, mouse_wl, mouse_wr; } sdl_input_t; -const struct rarch_key_map rarch_key_map_sdl[] = { - { SDLK_BACKSPACE, RETROK_BACKSPACE }, - { SDLK_TAB, RETROK_TAB }, - { SDLK_CLEAR, RETROK_CLEAR }, - { SDLK_RETURN, RETROK_RETURN }, - { SDLK_PAUSE, RETROK_PAUSE }, - { SDLK_ESCAPE, RETROK_ESCAPE }, - { SDLK_SPACE, RETROK_SPACE }, - { SDLK_EXCLAIM, RETROK_EXCLAIM }, - { SDLK_QUOTEDBL, RETROK_QUOTEDBL }, - { SDLK_HASH, RETROK_HASH }, - { SDLK_DOLLAR, RETROK_DOLLAR }, - { SDLK_AMPERSAND, RETROK_AMPERSAND }, - { SDLK_QUOTE, RETROK_QUOTE }, - { SDLK_LEFTPAREN, RETROK_LEFTPAREN }, - { SDLK_RIGHTPAREN, RETROK_RIGHTPAREN }, - { SDLK_ASTERISK, RETROK_ASTERISK }, - { SDLK_PLUS, RETROK_PLUS }, - { SDLK_COMMA, RETROK_COMMA }, - { SDLK_MINUS, RETROK_MINUS }, - { SDLK_PERIOD, RETROK_PERIOD }, - { SDLK_SLASH, RETROK_SLASH }, - { SDLK_0, RETROK_0 }, - { SDLK_1, RETROK_1 }, - { SDLK_2, RETROK_2 }, - { SDLK_3, RETROK_3 }, - { SDLK_4, RETROK_4 }, - { SDLK_5, RETROK_5 }, - { SDLK_6, RETROK_6 }, - { SDLK_7, RETROK_7 }, - { SDLK_8, RETROK_8 }, - { SDLK_9, RETROK_9 }, - { SDLK_COLON, RETROK_COLON }, - { SDLK_SEMICOLON, RETROK_SEMICOLON }, - { SDLK_LESS, RETROK_LESS }, - { SDLK_EQUALS, RETROK_EQUALS }, - { SDLK_GREATER, RETROK_GREATER }, - { SDLK_QUESTION, RETROK_QUESTION }, - { SDLK_AT, RETROK_AT }, - { SDLK_LEFTBRACKET, RETROK_LEFTBRACKET }, - { SDLK_BACKSLASH, RETROK_BACKSLASH }, - { SDLK_RIGHTBRACKET, RETROK_RIGHTBRACKET }, - { SDLK_CARET, RETROK_CARET }, - { SDLK_UNDERSCORE, RETROK_UNDERSCORE }, - { SDLK_BACKQUOTE, RETROK_BACKQUOTE }, - { SDLK_a, RETROK_a }, - { SDLK_b, RETROK_b }, - { SDLK_c, RETROK_c }, - { SDLK_d, RETROK_d }, - { SDLK_e, RETROK_e }, - { SDLK_f, RETROK_f }, - { SDLK_g, RETROK_g }, - { SDLK_h, RETROK_h }, - { SDLK_i, RETROK_i }, - { SDLK_j, RETROK_j }, - { SDLK_k, RETROK_k }, - { SDLK_l, RETROK_l }, - { SDLK_m, RETROK_m }, - { SDLK_n, RETROK_n }, - { SDLK_o, RETROK_o }, - { SDLK_p, RETROK_p }, - { SDLK_q, RETROK_q }, - { SDLK_r, RETROK_r }, - { SDLK_s, RETROK_s }, - { SDLK_t, RETROK_t }, - { SDLK_u, RETROK_u }, - { SDLK_v, RETROK_v }, - { SDLK_w, RETROK_w }, - { SDLK_x, RETROK_x }, - { SDLK_y, RETROK_y }, - { SDLK_z, RETROK_z }, - { SDLK_DELETE, RETROK_DELETE }, -#ifdef HAVE_SDL2 - { SDLK_KP_0, RETROK_KP0 }, - { SDLK_KP_1, RETROK_KP1 }, - { SDLK_KP_2, RETROK_KP2 }, - { SDLK_KP_3, RETROK_KP3 }, - { SDLK_KP_4, RETROK_KP4 }, - { SDLK_KP_5, RETROK_KP5 }, - { SDLK_KP_6, RETROK_KP6 }, - { SDLK_KP_7, RETROK_KP7 }, - { SDLK_KP_8, RETROK_KP8 }, - { SDLK_KP_9, RETROK_KP9 }, -#else - { SDLK_KP0, RETROK_KP0 }, - { SDLK_KP1, RETROK_KP1 }, - { SDLK_KP2, RETROK_KP2 }, - { SDLK_KP3, RETROK_KP3 }, - { SDLK_KP4, RETROK_KP4 }, - { SDLK_KP5, RETROK_KP5 }, - { SDLK_KP6, RETROK_KP6 }, - { SDLK_KP7, RETROK_KP7 }, - { SDLK_KP8, RETROK_KP8 }, - { SDLK_KP9, RETROK_KP9 }, -#endif - { SDLK_KP_PERIOD, RETROK_KP_PERIOD }, - { SDLK_KP_DIVIDE, RETROK_KP_DIVIDE }, - { SDLK_KP_MULTIPLY, RETROK_KP_MULTIPLY }, - { SDLK_KP_MINUS, RETROK_KP_MINUS }, - { SDLK_KP_PLUS, RETROK_KP_PLUS }, - { SDLK_KP_ENTER, RETROK_KP_ENTER }, - { SDLK_KP_EQUALS, RETROK_KP_EQUALS }, - { SDLK_UP, RETROK_UP }, - { SDLK_DOWN, RETROK_DOWN }, - { SDLK_RIGHT, RETROK_RIGHT }, - { SDLK_LEFT, RETROK_LEFT }, - { SDLK_INSERT, RETROK_INSERT }, - { SDLK_HOME, RETROK_HOME }, - { SDLK_END, RETROK_END }, - { SDLK_PAGEUP, RETROK_PAGEUP }, - { SDLK_PAGEDOWN, RETROK_PAGEDOWN }, - { SDLK_F1, RETROK_F1 }, - { SDLK_F2, RETROK_F2 }, - { SDLK_F3, RETROK_F3 }, - { SDLK_F4, RETROK_F4 }, - { SDLK_F5, RETROK_F5 }, - { SDLK_F6, RETROK_F6 }, - { SDLK_F7, RETROK_F7 }, - { SDLK_F8, RETROK_F8 }, - { SDLK_F9, RETROK_F9 }, - { SDLK_F10, RETROK_F10 }, - { SDLK_F11, RETROK_F11 }, - { SDLK_F12, RETROK_F12 }, - { SDLK_F13, RETROK_F13 }, - { SDLK_F14, RETROK_F14 }, - { SDLK_F15, RETROK_F15 }, -#ifdef HAVE_SDL2 - { SDLK_NUMLOCKCLEAR, RETROK_NUMLOCK }, -#else - { SDLK_NUMLOCK, RETROK_NUMLOCK }, -#endif - { SDLK_CAPSLOCK, RETROK_CAPSLOCK }, -#ifdef HAVE_SDL2 - { SDLK_SCROLLLOCK, RETROK_SCROLLOCK }, -#else - { SDLK_SCROLLOCK, RETROK_SCROLLOCK }, -#endif - { SDLK_RSHIFT, RETROK_RSHIFT }, - { SDLK_LSHIFT, RETROK_LSHIFT }, - { SDLK_RCTRL, RETROK_RCTRL }, - { SDLK_LCTRL, RETROK_LCTRL }, - { SDLK_RALT, RETROK_RALT }, - { SDLK_LALT, RETROK_LALT }, -#ifdef HAVE_SDL2 - /* { ?, RETROK_RMETA }, */ - /* { ?, RETROK_LMETA }, */ - { SDLK_LGUI, RETROK_LSUPER }, - { SDLK_RGUI, RETROK_RSUPER }, -#else - { SDLK_RMETA, RETROK_RMETA }, - { SDLK_LMETA, RETROK_LMETA }, - { SDLK_LSUPER, RETROK_LSUPER }, - { SDLK_RSUPER, RETROK_RSUPER }, -#endif - { SDLK_MODE, RETROK_MODE }, -#ifndef HAVE_SDL2 - { SDLK_COMPOSE, RETROK_COMPOSE }, -#endif - { SDLK_HELP, RETROK_HELP }, -#ifdef HAVE_SDL2 - { SDLK_PRINTSCREEN, RETROK_PRINT }, -#else - { SDLK_PRINT, RETROK_PRINT }, -#endif - { SDLK_SYSREQ, RETROK_SYSREQ }, - { SDLK_PAUSE, RETROK_BREAK }, - { SDLK_MENU, RETROK_MENU }, - { SDLK_POWER, RETROK_POWER }, - -#ifndef HAVE_SDL2 - { SDLK_EURO, RETROK_EURO }, -#endif - { SDLK_UNDO, RETROK_UNDO }, - - { 0, RETROK_UNKNOWN }, -}; - static void *sdl_input_init(void) { settings_t *settings; diff --git a/input/input_keymaps.c b/input/input_keymaps.c index c2cd4d206f..22dde84a38 100644 --- a/input/input_keymaps.c +++ b/input/input_keymaps.c @@ -22,6 +22,10 @@ #include "../config.h" #endif +#if defined(HAVE_SDL) || defined(HAVE_SDL2) +#include "SDL.h" +#endif + #ifdef __linux__ #include #include @@ -173,6 +177,185 @@ const struct input_key_map input_config_key_map[] = { { NULL, RETROK_UNKNOWN }, }; +#if defined(HAVE_SDL) || defined(HAVE_SDL2) +const struct rarch_key_map rarch_key_map_sdl[] = { + { SDLK_BACKSPACE, RETROK_BACKSPACE }, + { SDLK_TAB, RETROK_TAB }, + { SDLK_CLEAR, RETROK_CLEAR }, + { SDLK_RETURN, RETROK_RETURN }, + { SDLK_PAUSE, RETROK_PAUSE }, + { SDLK_ESCAPE, RETROK_ESCAPE }, + { SDLK_SPACE, RETROK_SPACE }, + { SDLK_EXCLAIM, RETROK_EXCLAIM }, + { SDLK_QUOTEDBL, RETROK_QUOTEDBL }, + { SDLK_HASH, RETROK_HASH }, + { SDLK_DOLLAR, RETROK_DOLLAR }, + { SDLK_AMPERSAND, RETROK_AMPERSAND }, + { SDLK_QUOTE, RETROK_QUOTE }, + { SDLK_LEFTPAREN, RETROK_LEFTPAREN }, + { SDLK_RIGHTPAREN, RETROK_RIGHTPAREN }, + { SDLK_ASTERISK, RETROK_ASTERISK }, + { SDLK_PLUS, RETROK_PLUS }, + { SDLK_COMMA, RETROK_COMMA }, + { SDLK_MINUS, RETROK_MINUS }, + { SDLK_PERIOD, RETROK_PERIOD }, + { SDLK_SLASH, RETROK_SLASH }, + { SDLK_0, RETROK_0 }, + { SDLK_1, RETROK_1 }, + { SDLK_2, RETROK_2 }, + { SDLK_3, RETROK_3 }, + { SDLK_4, RETROK_4 }, + { SDLK_5, RETROK_5 }, + { SDLK_6, RETROK_6 }, + { SDLK_7, RETROK_7 }, + { SDLK_8, RETROK_8 }, + { SDLK_9, RETROK_9 }, + { SDLK_COLON, RETROK_COLON }, + { SDLK_SEMICOLON, RETROK_SEMICOLON }, + { SDLK_LESS, RETROK_LESS }, + { SDLK_EQUALS, RETROK_EQUALS }, + { SDLK_GREATER, RETROK_GREATER }, + { SDLK_QUESTION, RETROK_QUESTION }, + { SDLK_AT, RETROK_AT }, + { SDLK_LEFTBRACKET, RETROK_LEFTBRACKET }, + { SDLK_BACKSLASH, RETROK_BACKSLASH }, + { SDLK_RIGHTBRACKET, RETROK_RIGHTBRACKET }, + { SDLK_CARET, RETROK_CARET }, + { SDLK_UNDERSCORE, RETROK_UNDERSCORE }, + { SDLK_BACKQUOTE, RETROK_BACKQUOTE }, + { SDLK_a, RETROK_a }, + { SDLK_b, RETROK_b }, + { SDLK_c, RETROK_c }, + { SDLK_d, RETROK_d }, + { SDLK_e, RETROK_e }, + { SDLK_f, RETROK_f }, + { SDLK_g, RETROK_g }, + { SDLK_h, RETROK_h }, + { SDLK_i, RETROK_i }, + { SDLK_j, RETROK_j }, + { SDLK_k, RETROK_k }, + { SDLK_l, RETROK_l }, + { SDLK_m, RETROK_m }, + { SDLK_n, RETROK_n }, + { SDLK_o, RETROK_o }, + { SDLK_p, RETROK_p }, + { SDLK_q, RETROK_q }, + { SDLK_r, RETROK_r }, + { SDLK_s, RETROK_s }, + { SDLK_t, RETROK_t }, + { SDLK_u, RETROK_u }, + { SDLK_v, RETROK_v }, + { SDLK_w, RETROK_w }, + { SDLK_x, RETROK_x }, + { SDLK_y, RETROK_y }, + { SDLK_z, RETROK_z }, + { SDLK_DELETE, RETROK_DELETE }, +#ifdef HAVE_SDL2 + { SDLK_KP_0, RETROK_KP0 }, + { SDLK_KP_1, RETROK_KP1 }, + { SDLK_KP_2, RETROK_KP2 }, + { SDLK_KP_3, RETROK_KP3 }, + { SDLK_KP_4, RETROK_KP4 }, + { SDLK_KP_5, RETROK_KP5 }, + { SDLK_KP_6, RETROK_KP6 }, + { SDLK_KP_7, RETROK_KP7 }, + { SDLK_KP_8, RETROK_KP8 }, + { SDLK_KP_9, RETROK_KP9 }, +#else + { SDLK_KP0, RETROK_KP0 }, + { SDLK_KP1, RETROK_KP1 }, + { SDLK_KP2, RETROK_KP2 }, + { SDLK_KP3, RETROK_KP3 }, + { SDLK_KP4, RETROK_KP4 }, + { SDLK_KP5, RETROK_KP5 }, + { SDLK_KP6, RETROK_KP6 }, + { SDLK_KP7, RETROK_KP7 }, + { SDLK_KP8, RETROK_KP8 }, + { SDLK_KP9, RETROK_KP9 }, +#endif + { SDLK_KP_PERIOD, RETROK_KP_PERIOD }, + { SDLK_KP_DIVIDE, RETROK_KP_DIVIDE }, + { SDLK_KP_MULTIPLY, RETROK_KP_MULTIPLY }, + { SDLK_KP_MINUS, RETROK_KP_MINUS }, + { SDLK_KP_PLUS, RETROK_KP_PLUS }, + { SDLK_KP_ENTER, RETROK_KP_ENTER }, + { SDLK_KP_EQUALS, RETROK_KP_EQUALS }, + { SDLK_UP, RETROK_UP }, + { SDLK_DOWN, RETROK_DOWN }, + { SDLK_RIGHT, RETROK_RIGHT }, + { SDLK_LEFT, RETROK_LEFT }, + { SDLK_INSERT, RETROK_INSERT }, + { SDLK_HOME, RETROK_HOME }, + { SDLK_END, RETROK_END }, + { SDLK_PAGEUP, RETROK_PAGEUP }, + { SDLK_PAGEDOWN, RETROK_PAGEDOWN }, + { SDLK_F1, RETROK_F1 }, + { SDLK_F2, RETROK_F2 }, + { SDLK_F3, RETROK_F3 }, + { SDLK_F4, RETROK_F4 }, + { SDLK_F5, RETROK_F5 }, + { SDLK_F6, RETROK_F6 }, + { SDLK_F7, RETROK_F7 }, + { SDLK_F8, RETROK_F8 }, + { SDLK_F9, RETROK_F9 }, + { SDLK_F10, RETROK_F10 }, + { SDLK_F11, RETROK_F11 }, + { SDLK_F12, RETROK_F12 }, + { SDLK_F13, RETROK_F13 }, + { SDLK_F14, RETROK_F14 }, + { SDLK_F15, RETROK_F15 }, +#ifdef HAVE_SDL2 + { SDLK_NUMLOCKCLEAR, RETROK_NUMLOCK }, +#else + { SDLK_NUMLOCK, RETROK_NUMLOCK }, +#endif + { SDLK_CAPSLOCK, RETROK_CAPSLOCK }, +#ifdef HAVE_SDL2 + { SDLK_SCROLLLOCK, RETROK_SCROLLOCK }, +#else + { SDLK_SCROLLOCK, RETROK_SCROLLOCK }, +#endif + { SDLK_RSHIFT, RETROK_RSHIFT }, + { SDLK_LSHIFT, RETROK_LSHIFT }, + { SDLK_RCTRL, RETROK_RCTRL }, + { SDLK_LCTRL, RETROK_LCTRL }, + { SDLK_RALT, RETROK_RALT }, + { SDLK_LALT, RETROK_LALT }, +#ifdef HAVE_SDL2 + /* { ?, RETROK_RMETA }, */ + /* { ?, RETROK_LMETA }, */ + { SDLK_LGUI, RETROK_LSUPER }, + { SDLK_RGUI, RETROK_RSUPER }, +#else + { SDLK_RMETA, RETROK_RMETA }, + { SDLK_LMETA, RETROK_LMETA }, + { SDLK_LSUPER, RETROK_LSUPER }, + { SDLK_RSUPER, RETROK_RSUPER }, +#endif + { SDLK_MODE, RETROK_MODE }, +#ifndef HAVE_SDL2 + { SDLK_COMPOSE, RETROK_COMPOSE }, +#endif + { SDLK_HELP, RETROK_HELP }, +#ifdef HAVE_SDL2 + { SDLK_PRINTSCREEN, RETROK_PRINT }, +#else + { SDLK_PRINT, RETROK_PRINT }, +#endif + { SDLK_SYSREQ, RETROK_SYSREQ }, + { SDLK_PAUSE, RETROK_BREAK }, + { SDLK_MENU, RETROK_MENU }, + { SDLK_POWER, RETROK_POWER }, + +#ifndef HAVE_SDL2 + { SDLK_EURO, RETROK_EURO }, +#endif + { SDLK_UNDO, RETROK_UNDO }, + + { 0, RETROK_UNKNOWN }, +}; +#endif + #ifdef HAVE_DINPUT const struct rarch_key_map rarch_key_map_dinput[] = { { DIK_LEFT, RETROK_LEFT }, From d59215a678e0bb70b314843661e5a07b3f8e6bc3 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Sat, 14 Nov 2015 08:50:10 +0100 Subject: [PATCH 214/216] Add linux_common.c --- Makefile.common | 1 + griffin/griffin.c | 1 + input/drivers/linux_common.c | 68 ++++++++++++++++++++++++++++++++++ input/drivers/linux_common.h | 29 +++++++++++++++ input/drivers/linuxraw_input.c | 59 ++++++----------------------- 5 files changed, 111 insertions(+), 47 deletions(-) create mode 100644 input/drivers/linux_common.c create mode 100644 input/drivers/linux_common.h diff --git a/Makefile.common b/Makefile.common index 30c1fb825f..5bb123061a 100644 --- a/Makefile.common +++ b/Makefile.common @@ -77,6 +77,7 @@ endif ifneq ($(findstring Linux,$(OS)),) LIBS += -lrt OBJ += input/drivers/linuxraw_input.o \ + input/drivers/linux_common.o \ input/drivers_joypad/linuxraw_joypad.o \ frontend/drivers/platform_linux.o endif diff --git a/griffin/griffin.c b/griffin/griffin.c index b93bd20a04..ed6638d0ae 100644 --- a/griffin/griffin.c +++ b/griffin/griffin.c @@ -367,6 +367,7 @@ INPUT #endif #if defined(__linux__) && !defined(ANDROID) +#include "../input/drivers/linux_common.c" #include "../input/drivers/linuxraw_input.c" #include "../input/drivers_joypad/linuxraw_joypad.c" #endif diff --git a/input/drivers/linux_common.c b/input/drivers/linux_common.c new file mode 100644 index 0000000000..0854d1766f --- /dev/null +++ b/input/drivers/linux_common.c @@ -0,0 +1,68 @@ +/* RetroArch - A frontend for libretro. + * Copyright (C) 2010-2014 - Hans-Kristian Arntzen + * + * 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 "linux_common.h" + +static struct termios oldTerm, newTerm; +static long oldKbmd = 0xffff; +static bool linux_stdin_claimed = false; + +void linux_terminal_restore_input(void) +{ + if (oldKbmd != 0xffff) + { + ioctl(0, KDSKBMODE, oldKbmd); + tcsetattr(0, TCSAFLUSH, &oldTerm); + oldKbmd = 0xffff; + } + + linux_stdin_claimed = false; +} + +bool linux_terminal_init(void) +{ + if (oldKbmd == 0xffff) + { + tcgetattr(0, &oldTerm); + newTerm = oldTerm; + newTerm.c_lflag &= ~(ECHO | ICANON | ISIG); + newTerm.c_iflag &= ~(ISTRIP | IGNCR | ICRNL | INLCR | IXOFF | IXON); + newTerm.c_cc[VMIN] = 0; + newTerm.c_cc[VTIME] = 0; + + if (ioctl(0, KDGKBMODE, &oldKbmd) != 0) + return false; + } + + tcsetattr(0, TCSAFLUSH, &newTerm); + + return true; +} + +void linux_terminal_claim_stdin(void) +{ + /* We need to disable use of stdin command interface if + * stdin is supposed to be used for input. */ + linux_stdin_claimed = true; +} + +bool linux_terminal_grab_stdin(void *data) +{ + return linux_stdin_claimed; +} diff --git a/input/drivers/linux_common.h b/input/drivers/linux_common.h new file mode 100644 index 0000000000..bc5413bfa1 --- /dev/null +++ b/input/drivers/linux_common.h @@ -0,0 +1,29 @@ +/* RetroArch - A frontend for libretro. + * Copyright (C) 2010-2014 - Hans-Kristian Arntzen + * + * 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 _LINUX_COMMON_H +#define _LINUX_COMMON_H + +#include + +void linux_terminal_restore_input(void); + +bool linux_terminal_init(void); + +void linux_terminal_claim_stdin(void); + +bool linux_terminal_grab_stdin(void *data); + +#endif diff --git a/input/drivers/linuxraw_input.c b/input/drivers/linuxraw_input.c index d3951c517f..79d89b9af8 100644 --- a/input/drivers/linuxraw_input.c +++ b/input/drivers/linuxraw_input.c @@ -19,21 +19,17 @@ #include #include #include -#include #include #include #include "../../general.h" +#include "linux_common.h" #include "../input_keymaps.h" #include "../input_common.h" #include "../input_joypad.h" -static long oldKbmd = 0xffff; -static bool linuxraw_stdin_claimed = false; -static struct termios oldTerm, newTerm; - typedef struct linuxraw_input { bool blocked; @@ -41,22 +37,9 @@ typedef struct linuxraw_input bool state[0x80]; } linuxraw_input_t; - -static void linuxraw_reset_kbmd(void) -{ - if (oldKbmd != 0xffff) - { - ioctl(0, KDSKBMODE, oldKbmd); - tcsetattr(0, TCSAFLUSH, &oldTerm); - oldKbmd = 0xffff; - } - - linuxraw_stdin_claimed = false; -} - static void linuxraw_exit_gracefully(int sig) { - linuxraw_reset_kbmd(); + linux_terminal_restore_input(); kill(getpid(), sig); } @@ -71,7 +54,7 @@ static void *linuxraw_input_init(void) if (!isatty(0)) return NULL; - if (linuxraw_stdin_claimed) + if (linux_terminal_grab_stdin(NULL)) { RARCH_WARN("stdin is already used for content loading. Cannot use stdin for input.\n"); return NULL; @@ -81,27 +64,16 @@ static void *linuxraw_input_init(void) if (!linuxraw) return NULL; - if (oldKbmd == 0xffff) + + if (!linux_terminal_init()) { - tcgetattr(0, &oldTerm); - newTerm = oldTerm; - newTerm.c_lflag &= ~(ECHO | ICANON | ISIG); - newTerm.c_iflag &= ~(ISTRIP | IGNCR | ICRNL | INLCR | IXOFF | IXON); - newTerm.c_cc[VMIN] = 0; - newTerm.c_cc[VTIME] = 0; - - if (ioctl(0, KDGKBMODE, &oldKbmd) != 0) - { - free(linuxraw); - return NULL; - } + free(linuxraw); + return NULL; } - tcsetattr(0, TCSAFLUSH, &newTerm); - if (ioctl(0, KDSKBMODE, K_MEDIUMRAW) != 0) { - linuxraw_reset_kbmd(); + linux_terminal_restore_input(); free(linuxraw); return NULL; } @@ -119,24 +91,17 @@ static void *linuxraw_input_init(void) sigaction(SIGQUIT, &sa, NULL); sigaction(SIGSEGV, &sa, NULL); - atexit(linuxraw_reset_kbmd); + atexit(linux_terminal_restore_input); linuxraw->joypad = input_joypad_init_driver( settings->input.joypad_driver, linuxraw); 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. */ - linuxraw_stdin_claimed = true; + linux_terminal_claim_stdin(); return linuxraw; } -static bool linuxraw_grab_stdin(void *data) -{ - return linuxraw_stdin_claimed; -} - static bool linuxraw_key_pressed(linuxraw_input_t *linuxraw, int key) { unsigned sym = input_keymaps_translate_rk_to_keysym((enum retro_key)key); @@ -225,7 +190,7 @@ static void linuxraw_input_free(void *data) if (linuxraw->joypad) linuxraw->joypad->destroy(); - linuxraw_reset_kbmd(); + linux_terminal_restore_input(); free(data); } @@ -319,7 +284,7 @@ input_driver_t input_linuxraw = { linuxraw_get_capabilities, "linuxraw", linuxraw_grab_mouse, - linuxraw_grab_stdin, + linux_terminal_grab_stdin, linuxraw_set_rumble, linuxraw_get_joypad_driver, linuxraw_keyboard_mapping_is_blocked, From 49dad39bf4fd2a9d50ab85fc915c1435ed5079fa Mon Sep 17 00:00:00 2001 From: twinaphex Date: Sat, 14 Nov 2015 09:01:41 +0100 Subject: [PATCH 215/216] (udev) Reuse linux_common code --- input/drivers/linux_common.c | 47 ++++++++++++++++++++++-------------- input/drivers/linux_common.h | 2 ++ input/drivers/udev_input.c | 39 ++++++------------------------ 3 files changed, 39 insertions(+), 49 deletions(-) diff --git a/input/drivers/linux_common.c b/input/drivers/linux_common.c index 0854d1766f..b571440746 100644 --- a/input/drivers/linux_common.c +++ b/input/drivers/linux_common.c @@ -23,34 +23,45 @@ static struct termios oldTerm, newTerm; static long oldKbmd = 0xffff; static bool linux_stdin_claimed = false; +void linux_terminal_flush(void) +{ + tcsetattr(0, TCSAFLUSH, &oldTerm); +} + void linux_terminal_restore_input(void) { - if (oldKbmd != 0xffff) - { - ioctl(0, KDSKBMODE, oldKbmd); - tcsetattr(0, TCSAFLUSH, &oldTerm); - oldKbmd = 0xffff; - } + if (oldKbmd == 0xffff) + return; + + ioctl(0, KDSKBMODE, oldKbmd); + linux_terminal_flush(); + oldKbmd = 0xffff; linux_stdin_claimed = false; } +/* Disables input */ + bool linux_terminal_init(void) { - if (oldKbmd == 0xffff) - { - tcgetattr(0, &oldTerm); - newTerm = oldTerm; - newTerm.c_lflag &= ~(ECHO | ICANON | ISIG); - newTerm.c_iflag &= ~(ISTRIP | IGNCR | ICRNL | INLCR | IXOFF | IXON); - newTerm.c_cc[VMIN] = 0; - newTerm.c_cc[VTIME] = 0; + if (oldKbmd != 0xffff) + return false; - if (ioctl(0, KDGKBMODE, &oldKbmd) != 0) - return false; - } + if (tcgetattr(0, &oldTerm) < 0) + return false; - tcsetattr(0, TCSAFLUSH, &newTerm); + newTerm = oldTerm; + newTerm.c_lflag &= ~(ECHO | ICANON | ISIG); + newTerm.c_iflag &= ~(ISTRIP | IGNCR | ICRNL | INLCR | IXOFF | IXON); + newTerm.c_cc[VMIN] = 0; + newTerm.c_cc[VTIME] = 0; + + /* Be careful about recovering the terminal. */ + if (ioctl(0, KDGKBMODE, &oldKbmd) < 0) + return false; + + if (tcsetattr(0, TCSAFLUSH, &newTerm) < 0) + return false; return true; } diff --git a/input/drivers/linux_common.h b/input/drivers/linux_common.h index bc5413bfa1..aa68238b88 100644 --- a/input/drivers/linux_common.h +++ b/input/drivers/linux_common.h @@ -18,6 +18,8 @@ #include +void linux_terminal_flush(void); + void linux_terminal_restore_input(void); bool linux_terminal_init(void); diff --git a/input/drivers/udev_input.c b/input/drivers/udev_input.c index 2edda346fd..ceb7d74d78 100644 --- a/input/drivers/udev_input.c +++ b/input/drivers/udev_input.c @@ -27,12 +27,13 @@ #include #include #include -#include #include #include #include +#include "linux_common.h" + #include "../input_common.h" #include "../input_joypad.h" #include "../input_keymaps.h" @@ -696,22 +697,9 @@ static bool open_devices(udev_input_t *udev, const char *type, device_handle_cb return true; } -static long oldkbmd = 0xffff; -static struct termios oldterm, newterm; - -static void restore_terminal_input(void) -{ - if (oldkbmd == 0xffff) - return; - - ioctl(0, KDSKBMODE, oldkbmd); - tcsetattr(0, TCSAFLUSH, &oldterm); - oldkbmd = 0xffff; -} - static void restore_terminal_signal(int sig) { - restore_terminal_input(); + linux_terminal_restore_input(); kill(getpid(), sig); } @@ -720,26 +708,15 @@ static void disable_terminal_input(void) struct sigaction sa = {{0}}; /* Avoid accidentally typing stuff. */ - if (!isatty(0) || oldkbmd != 0xffff) + if (!isatty(0)) return; - if (tcgetattr(0, &oldterm) < 0) + if (!linux_terminal_init()) return; - newterm = oldterm; - newterm.c_lflag &= ~(ECHO | ICANON | ISIG); - newterm.c_iflag &= ~(ISTRIP | IGNCR | ICRNL | INLCR | IXOFF | IXON); - newterm.c_cc[VMIN] = 0; - newterm.c_cc[VTIME] = 0; - - /* Be careful about recovering the terminal ... */ - if (ioctl(0, KDGKBMODE, &oldkbmd) < 0) - return; - if (tcsetattr(0, TCSAFLUSH, &newterm) < 0) - return; if (ioctl(0, KDSKBMODE, K_MEDIUMRAW) < 0) { - tcsetattr(0, TCSAFLUSH, &oldterm); + linux_terminal_flush(); return; } @@ -755,7 +732,7 @@ static void disable_terminal_input(void) sigaction(SIGQUIT, &sa, NULL); sigaction(SIGSEGV, &sa, NULL); - atexit(restore_terminal_input); + atexit(linux_terminal_restore_input); } static void *udev_input_init(void) @@ -944,7 +921,7 @@ input_driver_t input_udev = { udev_input_get_capabilities, "udev", udev_input_grab_mouse, - NULL, + linux_terminal_grab_stdin, udev_input_set_rumble, udev_input_get_joypad_driver, udev_input_keyboard_mapping_is_blocked, From 465a608a5624d4b3a63436e273b3c7df14cbff62 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Sat, 14 Nov 2015 09:04:01 +0100 Subject: [PATCH 216/216] More cleanups --- input/drivers/linux_common.c | 3 +++ input/drivers/linuxraw_input.c | 6 ------ input/drivers/udev_input.c | 3 --- 3 files changed, 3 insertions(+), 9 deletions(-) diff --git a/input/drivers/linux_common.c b/input/drivers/linux_common.c index b571440746..1b8863d334 100644 --- a/input/drivers/linux_common.c +++ b/input/drivers/linux_common.c @@ -63,6 +63,9 @@ bool linux_terminal_init(void) if (tcsetattr(0, TCSAFLUSH, &newTerm) < 0) return false; + if (ioctl(0, KDSKBMODE, K_MEDIUMRAW) < 0) + return false; + return true; } diff --git a/input/drivers/linuxraw_input.c b/input/drivers/linuxraw_input.c index 79d89b9af8..64198240c9 100644 --- a/input/drivers/linuxraw_input.c +++ b/input/drivers/linuxraw_input.c @@ -66,12 +66,6 @@ static void *linuxraw_input_init(void) if (!linux_terminal_init()) - { - free(linuxraw); - return NULL; - } - - if (ioctl(0, KDSKBMODE, K_MEDIUMRAW) != 0) { linux_terminal_restore_input(); free(linuxraw); diff --git a/input/drivers/udev_input.c b/input/drivers/udev_input.c index ceb7d74d78..93728c1dfe 100644 --- a/input/drivers/udev_input.c +++ b/input/drivers/udev_input.c @@ -712,9 +712,6 @@ static void disable_terminal_input(void) return; if (!linux_terminal_init()) - return; - - if (ioctl(0, KDSKBMODE, K_MEDIUMRAW) < 0) { linux_terminal_flush(); return;