From 96146e5313f799d9595f1d6e0e6ba20052c13edf Mon Sep 17 00:00:00 2001 From: Sergi Granell Date: Mon, 31 Aug 2015 15:26:37 +0200 Subject: [PATCH] (Vita) Update vita2d driver (Vita/PSP) Name some stuff to vita --- audio/drivers/psp_audio.c | 4 ++ configuration.c | 20 +++++-- frontend/drivers/platform_vita.c | 1 - gfx/drivers/vita2d_gfx.c | 88 ++++++++++++++++++++----------- input/autoconf/builtin_psp.c | 6 ++- input/drivers/psp_input.c | 8 ++- input/drivers_joypad/psp_joypad.c | 12 ++++- input/input_autodetect.c | 6 +-- 8 files changed, 100 insertions(+), 45 deletions(-) diff --git a/audio/drivers/psp_audio.c b/audio/drivers/psp_audio.c index 5876114bc0..98d786e5b7 100644 --- a/audio/drivers/psp_audio.c +++ b/audio/drivers/psp_audio.c @@ -302,7 +302,11 @@ audio_driver_t audio_psp = { psp_audio_set_nonblock_state, psp_audio_free, psp_audio_use_float, +#ifdef VITA + "vita", +#else "psp", +#endif psp_write_avail, psp_buffer_size, }; diff --git a/configuration.c b/configuration.c index 0a64d335d8..5233e951a6 100644 --- a/configuration.c +++ b/configuration.c @@ -115,7 +115,11 @@ const char *config_get_default_audio(void) case AUDIO_WII: return "gx"; case AUDIO_PSP: +#ifdef VITA + return "vita"; +#else return "psp"; +#endif case AUDIO_CTR: return "ctr"; case AUDIO_RWEBAUDIO: @@ -231,7 +235,11 @@ const char *config_get_default_input(void) case INPUT_PS3: return "ps3"; case INPUT_PSP: +#ifdef VITA + return "vita"; +#else return "psp"; +#endif case INPUT_CTR: return "ctr"; case INPUT_SDL: @@ -287,7 +295,11 @@ const char *config_get_default_joypad(void) case JOYPAD_XDK: return "xdk"; case JOYPAD_PSP: +#ifdef VITA + return "vita"; +#else return "psp"; +#endif case JOYPAD_CTR: return "ctr"; case JOYPAD_DINPUT: @@ -455,7 +467,7 @@ static void config_set_defaults(void) #endif settings->multimedia.builtin_imageviewer_enable = true; settings->video.scale = scale; - settings->video.fullscreen = global->force_fullscreen + settings->video.fullscreen = global->force_fullscreen ? true : fullscreen; settings->video.windowed_fullscreen = windowed_fullscreen; settings->video.monitor_index = monitor_index; @@ -1177,7 +1189,7 @@ static bool config_load_file(const char *path, bool set_defaults) const char *extra_path = NULL; char tmp_str[PATH_MAX_LENGTH] = {0}; char tmp_append_path[PATH_MAX_LENGTH] = {0}; /* Don't destroy append_config_path. */ - int vp_width = 0, vp_height = 0, vp_x = 0, vp_y = 0; + int vp_width = 0, vp_height = 0, vp_x = 0, vp_y = 0; unsigned msg_color = 0; config_file_t *conf = NULL; settings_t *settings = config_get_ptr(); @@ -1847,7 +1859,7 @@ bool config_load_override(void) } /* Config directory: config_directory. - * Try config directory setting first, + * Try config directory setting first, * fallback to the location of the current configuration file. */ if (settings->menu_config_directory[0] != '\0') strlcpy(config_directory, settings->menu_config_directory, PATH_MAX_LENGTH); @@ -1939,7 +1951,7 @@ bool config_load_override(void) if (config_load_file(global->path.config, false)) { - /* Restore the libretro_path we're using + /* Restore the libretro_path we're using * since it will be overwritten by the override when reloading. */ strlcpy(settings->libretro,buf,sizeof(settings->libretro)); rarch_main_msg_queue_push("Configuration override loaded", 1, 100, true); diff --git a/frontend/drivers/platform_vita.c b/frontend/drivers/platform_vita.c index 46a3b3e3e7..064a9d3437 100644 --- a/frontend/drivers/platform_vita.c +++ b/frontend/drivers/platform_vita.c @@ -198,7 +198,6 @@ static int frontend_vita_get_rating(void) static enum frontend_powerstate frontend_vita_get_powerstate(int *seconds, int *percent) { enum frontend_powerstate ret = FRONTEND_POWERSTATE_NONE; - int battery = 1; int plugged = scePowerIsPowerOnline(); int charging = scePowerIsBatteryCharging(); diff --git a/gfx/drivers/vita2d_gfx.c b/gfx/drivers/vita2d_gfx.c index 3f721bbaca..549334ddd3 100644 --- a/gfx/drivers/vita2d_gfx.c +++ b/gfx/drivers/vita2d_gfx.c @@ -36,6 +36,9 @@ typedef struct vita_menu_frame typedef struct vita_video { vita2d_texture *texture; + SceGxmTextureFormat format; + int width; + int height; bool vsync; bool rgb32; @@ -63,20 +66,18 @@ static void *vita2d_gfx_init(const video_info_t *video, if (!vita) return NULL; + RARCH_LOG("vita2d_gfx_init: w: %i h: %i\n", video->width, video->height); + vita2d_init(); vita2d_set_clear_color(RGBA8(0x40, 0x40, 0x40, 0xFF)); vita2d_set_vblank_wait(video->vsync); if (vita->rgb32) - { - vita->texture = vita2d_create_empty_texture(video->width, video->height); - RARCH_LOG("Creating RGBA8 texture: w: %i h: %i\n", video->width, video->height); - } + vita->format = SCE_GXM_TEXTURE_FORMAT_X8U8U8U8_1RGB; else - { - vita->texture = vita2d_create_empty_texture_format(video->width, video->height, SCE_GXM_TEXTURE_FORMAT_R5G6B5); - RARCH_LOG("Creating R5G6B5 texture: w: %i h: %i\n", video->width, video->height); - } + vita->format = SCE_GXM_TEXTURE_FORMAT_R5G6B5; + + vita->texture = NULL; vita->menu.frame = NULL; vita->menu.active = 0; @@ -100,6 +101,8 @@ static bool vita2d_gfx_frame(void *data, const void *frame, unsigned width, unsigned height, uint64_t frame_count, unsigned pitch, const char *msg) { + int i, j; + void *tex_p; vita_video_t *vita = (vita_video_t *)data; (void)frame; (void)width; @@ -107,9 +110,37 @@ static bool vita2d_gfx_frame(void *data, const void *frame, (void)pitch; (void)msg; - void *tex_p = vita2d_texture_get_datap(vita->texture); - unsigned int tex_stride = vita2d_texture_get_stride(vita->texture); - const unsigned int *frame_p = frame; + if (frame) + { + if (width != vita->width && height != vita->height && vita->texture) + { + vita2d_free_texture(vita->texture); + vita->texture = NULL; + } + + if (!vita->texture) + { + vita->width = width; + vita->height = height; + vita->texture = vita2d_create_empty_texture_format(width, height, vita->format); + } + + tex_p = vita2d_texture_get_datap(vita->texture); + + if (vita->format == SCE_GXM_TEXTURE_FORMAT_A8B8G8R8) + { + for (i = 0; i < height; i++) + for (j = 0; j < width; j++) + *(unsigned int *)(tex_p + (j + i*height) * 4) = *(unsigned int *)(frame + (j + i*height) * 4); + } + else + { + /*for (i = 0; i < height; i++) + for (j = 0; j < width; j++) + *(unsigned short *)(tex_p + (j + i*height) * 2) = *(unsigned short *)(frame + (j + i*height) * 2);*/ + memcpy(tex_p, frame, width*height*2); + } + } // RARCH_LOG("w: %i h: %i pitch: %i\n", width, height, pitch); // RARCH_LOG("msg: %s\n", msg); @@ -117,22 +148,17 @@ static bool vita2d_gfx_frame(void *data, const void *frame, vita2d_start_drawing(); vita2d_clear_screen(); - /* int i, j; - for (i = 0; i < height; i++) - { - for (j = 0; j < width; j++) - { - *(unsigned int *)(tex_p + i*4 + j * tex_stride) = frame_p[i + j * width]; - } - } */ - // memcpy(tex_p, frame, height*pitch); - - // vita2d_draw_texture(vita->texture, 0, 0); + if (frame && vita->texture) + vita2d_draw_texture_scale(vita->texture, + SCREEN_W/2 - (vita->width/2)*2, + SCREEN_H/2 - (vita->height/2)*2, + 2.0f, 2.0f); if (vita->menu.active && vita->menu.frame) - vita2d_draw_texture(vita->menu.frame, - SCREEN_W/2 - vita->menu.width/2, - SCREEN_H/2 - vita->menu.height/2); + vita2d_draw_texture_scale(vita->menu.frame, + SCREEN_W/2 - (vita->menu.width/2)*2, + SCREEN_H/2 - (vita->menu.height/2)*2, + 2.0f, 2.0f); vita2d_end_drawing(); vita2d_swap_buffers(); @@ -222,12 +248,13 @@ static bool vita2d_gfx_read_viewport(void *data, uint8_t *buffer) static void vita_set_filtering(void *data, unsigned index, bool smooth) { - vita_video_t *psp = (vita_video_t*)data; + (void)data; + (void)index; + (void)smooth; } static void vita_set_aspect_ratio(void *data, unsigned aspectratio_index) { - vita_video_t *vid = (vita_video_t*)data; struct retro_system_av_info *av_info = video_viewport_get_system_av_info(); @@ -264,7 +291,6 @@ static void vita_set_texture_frame(void *data, const void *frame, bool rgb32, { int i, j; void *tex_p; - unsigned int stride; vita_video_t *vita = (vita_video_t*)data; (void)alpha; @@ -275,7 +301,6 @@ static void vita_set_texture_frame(void *data, const void *frame, bool rgb32, vita->menu.frame = NULL; } - if (!vita->menu.frame) { if (rgb32) @@ -285,7 +310,7 @@ static void vita_set_texture_frame(void *data, const void *frame, bool rgb32, } else { - vita->menu.frame = vita2d_create_empty_texture_format(width, height, SCE_GXM_TEXTURE_FORMAT_R5G6B5); + vita->menu.frame = vita2d_create_empty_texture_format(width, height, SCE_GXM_TEXTURE_FORMAT_U4U4U4U4_RGBA); RARCH_LOG("Creating Frame R5G6B5 texture: w: %i h: %i\n", width, height); } vita->menu.width = width; @@ -293,7 +318,6 @@ static void vita_set_texture_frame(void *data, const void *frame, bool rgb32, } tex_p = vita2d_texture_get_datap(vita->menu.frame); - stride = vita2d_texture_get_stride(vita->menu.frame); if (rgb32) { @@ -365,5 +389,5 @@ video_driver_t video_vita2d = { #ifdef HAVE_OVERLAY NULL, /* overlay_interface */ #endif - vita2d_gfx_get_poke_interface, + vita2d_gfx_get_poke_interface, }; diff --git a/input/autoconf/builtin_psp.c b/input/autoconf/builtin_psp.c index 564b530688..93198a1d2d 100644 --- a/input/autoconf/builtin_psp.c +++ b/input/autoconf/builtin_psp.c @@ -1,7 +1,7 @@ /* RetroArch - A frontend for libretro. * Copyright (C) 2010-2014 - Hans-Kristian Arntzen * Copyright (C) 2011-2015 - Daniel De Matteis - * + * * RetroArch is free software: you can redistribute it and/or modify it under the terms * of the GNU General Public License as published by the Free Software Found- * ation, either version 3 of the License, or (at your option) any later version. @@ -42,7 +42,11 @@ DECL_AXIS(r_y_minus, +3) const char* const input_builtin_autoconfs[] = { +#ifdef VITA + DECL_AUTOCONF_DEVICE("Vita Controller", "vita", PSPINPUT_DEFAULT_BINDS), +#else DECL_AUTOCONF_DEVICE("PSP Controller", "psp", PSPINPUT_DEFAULT_BINDS), +#endif NULL }; diff --git a/input/drivers/psp_input.c b/input/drivers/psp_input.c index d5f3767d50..62b043253f 100644 --- a/input/drivers/psp_input.c +++ b/input/drivers/psp_input.c @@ -1,7 +1,7 @@ /* RetroArch - A frontend for libretro. * Copyright (C) 2010-2014 - Hans-Kristian Arntzen * Copyright (C) 2011-2015 - Daniel De Matteis - * + * * RetroArch is free software: you can redistribute it and/or modify it under the terms * of the GNU General Public License as published by the Free Software Found- * ation, either version 3 of the License, or (at your option) any later version. @@ -93,7 +93,7 @@ static void* psp_input_initialize(void) psp_input_t *psp = (psp_input_t*)calloc(1, sizeof(*psp)); if (!psp) return NULL; - + psp->joypad = input_joypad_init_driver( settings->input.joypad_driver, psp); @@ -171,7 +171,11 @@ input_driver_t input_psp = { NULL, NULL, psp_input_get_capabilities, +#ifdef VITA + "vita", +#else "psp", +#endif psp_input_grab_mouse, NULL, diff --git a/input/drivers_joypad/psp_joypad.c b/input/drivers_joypad/psp_joypad.c index b1584bfc98..7ff9559896 100644 --- a/input/drivers_joypad/psp_joypad.c +++ b/input/drivers_joypad/psp_joypad.c @@ -1,7 +1,7 @@ /* RetroArch - A frontend for libretro. * Copyright (C) 2010-2014 - Hans-Kristian Arntzen * Copyright (C) 2011-2015 - Daniel De Matteis - * + * * RetroArch is free software: you can redistribute it and/or modify it under the terms * of the GNU General Public License as published by the Free Software Found- * ation, either version 3 of the License, or (at your option) any later version. @@ -23,7 +23,11 @@ extern uint64_t lifecycle_state; static const char *psp_joypad_name(unsigned pad) { +#ifdef VITA + return "Vita Controller"; +#else return "PSP Controller"; +#endif } static void psp_joypad_autodetect_add(unsigned autoconf_pad) @@ -125,7 +129,7 @@ static void psp_joypad_poll(void) #endif (void)ret; - analog_state[0][0][0] = analog_state[0][0][1] = + analog_state[0][0][0] = analog_state[0][0][1] = analog_state[0][1][0] = analog_state[0][1][1] = 0; pad_state = 0; pad_state |= (STATE_BUTTON(state_tmp) & PSP_CTRL_LEFT) ? (UINT64_C(1) << RETRO_DEVICE_ID_JOYPAD_LEFT) : 0; @@ -188,5 +192,9 @@ input_device_driver_t psp_joypad = { psp_joypad_poll, NULL, psp_joypad_name, +#ifdef VITA + "vita", +#else "psp", +#endif }; diff --git a/input/input_autodetect.c b/input/input_autodetect.c index aa25b32354..529ac8cfa6 100644 --- a/input/input_autodetect.c +++ b/input/input_autodetect.c @@ -140,7 +140,7 @@ static void input_autoconfigure_joypad_add( else snprintf(msg, sizeof(msg), "%s configured", params->name); - + if(!remote_is_bound) rarch_main_msg_queue_push(msg, 0, 60, false); remote_is_bound = true; @@ -222,7 +222,7 @@ static bool input_autoconfigure_joypad_from_conf_dir( } if(index >= 0 && current_best > 0) - { + { conf = config_file_new(list->elems[index].data); RARCH_LOG("Autodetect: selected configuration: %s\n", conf->path); input_autoconfigure_joypad_add(conf, params); @@ -232,7 +232,7 @@ static bool input_autoconfigure_joypad_from_conf_dir( else { RARCH_LOG("Autodetect: no profiles found for %s (%d/%d)", params->name, params->vid, params->pid); - snprintf(msg, sizeof(msg), "%s (%d/%d) not configured", params->name, params->vid, params->pid); + snprintf(msg, sizeof(msg), "%s (%ld/%ld) not configured", params->name, params->vid, params->pid); rarch_main_msg_queue_push(msg, 0, 60, false); ret = 0; }