Merge pull request #2082 from xerpi/master

(Vita) Update vita2d driver
This commit is contained in:
Twinaphex 2015-08-31 15:35:09 +02:00
commit 1abfb8426a
8 changed files with 100 additions and 45 deletions

View File

@ -302,7 +302,11 @@ audio_driver_t audio_psp = {
psp_audio_set_nonblock_state, psp_audio_set_nonblock_state,
psp_audio_free, psp_audio_free,
psp_audio_use_float, psp_audio_use_float,
#ifdef VITA
"vita",
#else
"psp", "psp",
#endif
psp_write_avail, psp_write_avail,
psp_buffer_size, psp_buffer_size,
}; };

View File

@ -115,7 +115,11 @@ const char *config_get_default_audio(void)
case AUDIO_WII: case AUDIO_WII:
return "gx"; return "gx";
case AUDIO_PSP: case AUDIO_PSP:
#ifdef VITA
return "vita";
#else
return "psp"; return "psp";
#endif
case AUDIO_CTR: case AUDIO_CTR:
return "ctr"; return "ctr";
case AUDIO_RWEBAUDIO: case AUDIO_RWEBAUDIO:
@ -231,7 +235,11 @@ const char *config_get_default_input(void)
case INPUT_PS3: case INPUT_PS3:
return "ps3"; return "ps3";
case INPUT_PSP: case INPUT_PSP:
#ifdef VITA
return "vita";
#else
return "psp"; return "psp";
#endif
case INPUT_CTR: case INPUT_CTR:
return "ctr"; return "ctr";
case INPUT_SDL: case INPUT_SDL:
@ -287,7 +295,11 @@ const char *config_get_default_joypad(void)
case JOYPAD_XDK: case JOYPAD_XDK:
return "xdk"; return "xdk";
case JOYPAD_PSP: case JOYPAD_PSP:
#ifdef VITA
return "vita";
#else
return "psp"; return "psp";
#endif
case JOYPAD_CTR: case JOYPAD_CTR:
return "ctr"; return "ctr";
case JOYPAD_DINPUT: case JOYPAD_DINPUT:
@ -455,7 +467,7 @@ static void config_set_defaults(void)
#endif #endif
settings->multimedia.builtin_imageviewer_enable = true; settings->multimedia.builtin_imageviewer_enable = true;
settings->video.scale = scale; settings->video.scale = scale;
settings->video.fullscreen = global->force_fullscreen settings->video.fullscreen = global->force_fullscreen
? true : fullscreen; ? true : fullscreen;
settings->video.windowed_fullscreen = windowed_fullscreen; settings->video.windowed_fullscreen = windowed_fullscreen;
settings->video.monitor_index = monitor_index; 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; const char *extra_path = NULL;
char tmp_str[PATH_MAX_LENGTH] = {0}; char tmp_str[PATH_MAX_LENGTH] = {0};
char tmp_append_path[PATH_MAX_LENGTH] = {0}; /* Don't destroy append_config_path. */ 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; unsigned msg_color = 0;
config_file_t *conf = NULL; config_file_t *conf = NULL;
settings_t *settings = config_get_ptr(); settings_t *settings = config_get_ptr();
@ -1847,7 +1859,7 @@ bool config_load_override(void)
} }
/* Config directory: config_directory. /* Config directory: config_directory.
* Try config directory setting first, * Try config directory setting first,
* fallback to the location of the current configuration file. */ * fallback to the location of the current configuration file. */
if (settings->menu_config_directory[0] != '\0') if (settings->menu_config_directory[0] != '\0')
strlcpy(config_directory, settings->menu_config_directory, PATH_MAX_LENGTH); 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)) 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. */ * since it will be overwritten by the override when reloading. */
strlcpy(settings->libretro,buf,sizeof(settings->libretro)); strlcpy(settings->libretro,buf,sizeof(settings->libretro));
rarch_main_msg_queue_push("Configuration override loaded", 1, 100, true); rarch_main_msg_queue_push("Configuration override loaded", 1, 100, true);

View File

@ -198,7 +198,6 @@ static int frontend_vita_get_rating(void)
static enum frontend_powerstate frontend_vita_get_powerstate(int *seconds, int *percent) static enum frontend_powerstate frontend_vita_get_powerstate(int *seconds, int *percent)
{ {
enum frontend_powerstate ret = FRONTEND_POWERSTATE_NONE; enum frontend_powerstate ret = FRONTEND_POWERSTATE_NONE;
int battery = 1;
int plugged = scePowerIsPowerOnline(); int plugged = scePowerIsPowerOnline();
int charging = scePowerIsBatteryCharging(); int charging = scePowerIsBatteryCharging();

View File

@ -36,6 +36,9 @@ typedef struct vita_menu_frame
typedef struct vita_video typedef struct vita_video
{ {
vita2d_texture *texture; vita2d_texture *texture;
SceGxmTextureFormat format;
int width;
int height;
bool vsync; bool vsync;
bool rgb32; bool rgb32;
@ -63,20 +66,18 @@ static void *vita2d_gfx_init(const video_info_t *video,
if (!vita) if (!vita)
return NULL; return NULL;
RARCH_LOG("vita2d_gfx_init: w: %i h: %i\n", video->width, video->height);
vita2d_init(); vita2d_init();
vita2d_set_clear_color(RGBA8(0x40, 0x40, 0x40, 0xFF)); vita2d_set_clear_color(RGBA8(0x40, 0x40, 0x40, 0xFF));
vita2d_set_vblank_wait(video->vsync); vita2d_set_vblank_wait(video->vsync);
if (vita->rgb32) if (vita->rgb32)
{ vita->format = SCE_GXM_TEXTURE_FORMAT_X8U8U8U8_1RGB;
vita->texture = vita2d_create_empty_texture(video->width, video->height);
RARCH_LOG("Creating RGBA8 texture: w: %i h: %i\n", video->width, video->height);
}
else else
{ vita->format = SCE_GXM_TEXTURE_FORMAT_R5G6B5;
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->texture = NULL;
}
vita->menu.frame = NULL; vita->menu.frame = NULL;
vita->menu.active = 0; 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 width, unsigned height, uint64_t frame_count,
unsigned pitch, const char *msg) unsigned pitch, const char *msg)
{ {
int i, j;
void *tex_p;
vita_video_t *vita = (vita_video_t *)data; vita_video_t *vita = (vita_video_t *)data;
(void)frame; (void)frame;
(void)width; (void)width;
@ -107,9 +110,37 @@ static bool vita2d_gfx_frame(void *data, const void *frame,
(void)pitch; (void)pitch;
(void)msg; (void)msg;
void *tex_p = vita2d_texture_get_datap(vita->texture); if (frame)
unsigned int tex_stride = vita2d_texture_get_stride(vita->texture); {
const unsigned int *frame_p = 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("w: %i h: %i pitch: %i\n", width, height, pitch);
// RARCH_LOG("msg: %s\n", msg); // RARCH_LOG("msg: %s\n", msg);
@ -117,22 +148,17 @@ static bool vita2d_gfx_frame(void *data, const void *frame,
vita2d_start_drawing(); vita2d_start_drawing();
vita2d_clear_screen(); vita2d_clear_screen();
/* int i, j; if (frame && vita->texture)
for (i = 0; i < height; i++) vita2d_draw_texture_scale(vita->texture,
{ SCREEN_W/2 - (vita->width/2)*2,
for (j = 0; j < width; j++) SCREEN_H/2 - (vita->height/2)*2,
{ 2.0f, 2.0f);
*(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 (vita->menu.active && vita->menu.frame) if (vita->menu.active && vita->menu.frame)
vita2d_draw_texture(vita->menu.frame, vita2d_draw_texture_scale(vita->menu.frame,
SCREEN_W/2 - vita->menu.width/2, SCREEN_W/2 - (vita->menu.width/2)*2,
SCREEN_H/2 - vita->menu.height/2); SCREEN_H/2 - (vita->menu.height/2)*2,
2.0f, 2.0f);
vita2d_end_drawing(); vita2d_end_drawing();
vita2d_swap_buffers(); 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) 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) 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 = struct retro_system_av_info *av_info =
video_viewport_get_system_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; int i, j;
void *tex_p; void *tex_p;
unsigned int stride;
vita_video_t *vita = (vita_video_t*)data; vita_video_t *vita = (vita_video_t*)data;
(void)alpha; (void)alpha;
@ -275,7 +301,6 @@ static void vita_set_texture_frame(void *data, const void *frame, bool rgb32,
vita->menu.frame = NULL; vita->menu.frame = NULL;
} }
if (!vita->menu.frame) if (!vita->menu.frame)
{ {
if (rgb32) if (rgb32)
@ -285,7 +310,7 @@ static void vita_set_texture_frame(void *data, const void *frame, bool rgb32,
} }
else 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); RARCH_LOG("Creating Frame R5G6B5 texture: w: %i h: %i\n", width, height);
} }
vita->menu.width = width; 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); tex_p = vita2d_texture_get_datap(vita->menu.frame);
stride = vita2d_texture_get_stride(vita->menu.frame);
if (rgb32) if (rgb32)
{ {
@ -365,5 +389,5 @@ video_driver_t video_vita2d = {
#ifdef HAVE_OVERLAY #ifdef HAVE_OVERLAY
NULL, /* overlay_interface */ NULL, /* overlay_interface */
#endif #endif
vita2d_gfx_get_poke_interface, vita2d_gfx_get_poke_interface,
}; };

View File

@ -1,7 +1,7 @@
/* RetroArch - A frontend for libretro. /* RetroArch - A frontend for libretro.
* Copyright (C) 2010-2014 - Hans-Kristian Arntzen * Copyright (C) 2010-2014 - Hans-Kristian Arntzen
* Copyright (C) 2011-2015 - Daniel De Matteis * Copyright (C) 2011-2015 - Daniel De Matteis
* *
* RetroArch is free software: you can redistribute it and/or modify it under the terms * 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- * 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. * 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[] = 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), DECL_AUTOCONF_DEVICE("PSP Controller", "psp", PSPINPUT_DEFAULT_BINDS),
#endif
NULL NULL
}; };

View File

@ -1,7 +1,7 @@
/* RetroArch - A frontend for libretro. /* RetroArch - A frontend for libretro.
* Copyright (C) 2010-2014 - Hans-Kristian Arntzen * Copyright (C) 2010-2014 - Hans-Kristian Arntzen
* Copyright (C) 2011-2015 - Daniel De Matteis * Copyright (C) 2011-2015 - Daniel De Matteis
* *
* RetroArch is free software: you can redistribute it and/or modify it under the terms * 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- * 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. * 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)); psp_input_t *psp = (psp_input_t*)calloc(1, sizeof(*psp));
if (!psp) if (!psp)
return NULL; return NULL;
psp->joypad = input_joypad_init_driver( psp->joypad = input_joypad_init_driver(
settings->input.joypad_driver, psp); settings->input.joypad_driver, psp);
@ -171,7 +171,11 @@ input_driver_t input_psp = {
NULL, NULL,
NULL, NULL,
psp_input_get_capabilities, psp_input_get_capabilities,
#ifdef VITA
"vita",
#else
"psp", "psp",
#endif
psp_input_grab_mouse, psp_input_grab_mouse,
NULL, NULL,

View File

@ -1,7 +1,7 @@
/* RetroArch - A frontend for libretro. /* RetroArch - A frontend for libretro.
* Copyright (C) 2010-2014 - Hans-Kristian Arntzen * Copyright (C) 2010-2014 - Hans-Kristian Arntzen
* Copyright (C) 2011-2015 - Daniel De Matteis * Copyright (C) 2011-2015 - Daniel De Matteis
* *
* RetroArch is free software: you can redistribute it and/or modify it under the terms * 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- * 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. * 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) static const char *psp_joypad_name(unsigned pad)
{ {
#ifdef VITA
return "Vita Controller";
#else
return "PSP Controller"; return "PSP Controller";
#endif
} }
static void psp_joypad_autodetect_add(unsigned autoconf_pad) static void psp_joypad_autodetect_add(unsigned autoconf_pad)
@ -125,7 +129,7 @@ static void psp_joypad_poll(void)
#endif #endif
(void)ret; (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; analog_state[0][1][0] = analog_state[0][1][1] = 0;
pad_state = 0; pad_state = 0;
pad_state |= (STATE_BUTTON(state_tmp) & PSP_CTRL_LEFT) ? (UINT64_C(1) << RETRO_DEVICE_ID_JOYPAD_LEFT) : 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, psp_joypad_poll,
NULL, NULL,
psp_joypad_name, psp_joypad_name,
#ifdef VITA
"vita",
#else
"psp", "psp",
#endif
}; };

View File

@ -140,7 +140,7 @@ static void input_autoconfigure_joypad_add(
else else
snprintf(msg, sizeof(msg), "%s configured", snprintf(msg, sizeof(msg), "%s configured",
params->name); params->name);
if(!remote_is_bound) if(!remote_is_bound)
rarch_main_msg_queue_push(msg, 0, 60, false); rarch_main_msg_queue_push(msg, 0, 60, false);
remote_is_bound = true; remote_is_bound = true;
@ -222,7 +222,7 @@ static bool input_autoconfigure_joypad_from_conf_dir(
} }
if(index >= 0 && current_best > 0) if(index >= 0 && current_best > 0)
{ {
conf = config_file_new(list->elems[index].data); conf = config_file_new(list->elems[index].data);
RARCH_LOG("Autodetect: selected configuration: %s\n", conf->path); RARCH_LOG("Autodetect: selected configuration: %s\n", conf->path);
input_autoconfigure_joypad_add(conf, params); input_autoconfigure_joypad_add(conf, params);
@ -232,7 +232,7 @@ static bool input_autoconfigure_joypad_from_conf_dir(
else else
{ {
RARCH_LOG("Autodetect: no profiles found for %s (%d/%d)", params->name, params->vid, params->pid); 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); rarch_main_msg_queue_push(msg, 0, 60, false);
ret = 0; ret = 0;
} }