Merge pull request #7911 from fjtrujy/feature/PS2OpenRGUIMenu

[PS2] Open RetroArch menu from Core
This commit is contained in:
Twinaphex 2019-01-07 01:42:01 +01:00 committed by GitHub
commit 9b46caa6db
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 110 additions and 106 deletions

View File

@ -86,21 +86,22 @@ static void audioCreateThread(ps2_audio_t *ps2)
ps2->running = true; ps2->running = true;
ps2->worker_thread = CreateThread(&thread); ps2->worker_thread = CreateThread(&thread);
if (ps2->worker_thread >= 0) if (ps2->worker_thread >= 0) {
{
ret = StartThread(ps2->worker_thread, NULL); ret = StartThread(ps2->worker_thread, NULL);
if (ret < 0) if (ret < 0) {
printf("sound_init: StartThread returned %d\n", ret); printf("sound_init: StartThread returned %d\n", ret);
} }
else } else {
printf("CreateThread failed: %d\n", ps2->worker_thread); printf("CreateThread failed: %d\n", ps2->worker_thread);
}
} }
static void audioStopNDeleteThread(ps2_audio_t *ps2) static void audioStopNDeleteThread(ps2_audio_t *ps2)
{ {
ps2->running = false; ps2->running = false;
if (ps2->worker_thread) if (ps2->worker_thread) {
ps2->worker_thread = 0; ps2->worker_thread = 0;
}
} }
static void audioConfigure(ps2_audio_t *ps2, unsigned rate) static void audioConfigure(ps2_audio_t *ps2, unsigned rate)
@ -114,8 +115,7 @@ static void audioConfigure(ps2_audio_t *ps2, unsigned rate)
err = audsrv_set_format(&format); err = audsrv_set_format(&format);
if (err) if (err){
{
printf("set format returned %d\n", err); printf("set format returned %d\n", err);
printf("audsrv returned error string: %s\n", audsrv_get_error_string()); printf("audsrv returned error string: %s\n", audsrv_get_error_string());
} }
@ -164,18 +164,15 @@ static void ps2_audio_free(void *data)
if(!ps2) if(!ps2)
return; return;
if(ps2->running) if(ps2->running){
{
audioStopNDeleteThread(ps2); audioStopNDeleteThread(ps2);
if (ps2->lock) if (ps2->lock){
{
iDeleteSema(ps2->lock); iDeleteSema(ps2->lock);
ps2->lock = 0; ps2->lock = 0;
} }
if (ps2->cond_lock) if (ps2->cond_lock){
{
iDeleteSema(ps2->cond_lock); iDeleteSema(ps2->cond_lock);
ps2->cond_lock = 0; ps2->cond_lock = 0;
} }
@ -192,14 +189,14 @@ static ssize_t ps2_audio_write(void *data, const void *buf, size_t size)
if (!ps2->running) if (!ps2->running)
return -1; return -1;
if (ps2->nonblocking) if (ps2->nonblocking){
{
if (fifo_write_avail(ps2->buffer) < size) if (fifo_write_avail(ps2->buffer) < size)
return 0; return 0;
} }
while (fifo_write_avail(ps2->buffer) < size) while (fifo_write_avail(ps2->buffer) < size) {
WaitSema(ps2->cond_lock); WaitSema(ps2->cond_lock);
}
WaitSema(ps2->lock); WaitSema(ps2->lock);
fifo_write(ps2->buffer, buf, size); fifo_write(ps2->buffer, buf, size);
@ -213,8 +210,9 @@ static bool ps2_audio_alive(void *data)
bool alive = false; bool alive = false;
ps2_audio_t* ps2 = (ps2_audio_t*)data; ps2_audio_t* ps2 = (ps2_audio_t*)data;
if (ps2) if (ps2) {
alive = ps2->running; alive = ps2->running;
}
return alive; return alive;
} }
@ -224,8 +222,7 @@ static bool ps2_audio_stop(void *data)
bool stop = true; bool stop = true;
ps2_audio_t* ps2 = (ps2_audio_t*)data; ps2_audio_t* ps2 = (ps2_audio_t*)data;
if (ps2) if (ps2) {
{
audioStopNDeleteThread(ps2); audioStopNDeleteThread(ps2);
audsrv_stop_audio(); audsrv_stop_audio();
} }
@ -235,14 +232,14 @@ static bool ps2_audio_stop(void *data)
static bool ps2_audio_start(void *data, bool is_shutdown) static bool ps2_audio_start(void *data, bool is_shutdown)
{ {
bool start = true;
ps2_audio_t* ps2 = (ps2_audio_t*)data; ps2_audio_t* ps2 = (ps2_audio_t*)data;
bool start = true;
if(ps2) if (ps2) {
{ if (!ps2->running && !ps2->worker_thread) {
if (!ps2->running && !ps2->worker_thread)
audioCreateThread(ps2); audioCreateThread(ps2);
} }
}
return start; return start;
} }
@ -250,8 +247,10 @@ static bool ps2_audio_start(void *data, bool is_shutdown)
static void ps2_audio_set_nonblock_state(void *data, bool toggle) static void ps2_audio_set_nonblock_state(void *data, bool toggle)
{ {
ps2_audio_t* ps2 = (ps2_audio_t*)data; ps2_audio_t* ps2 = (ps2_audio_t*)data;
if (ps2)
if (ps2) {
ps2->nonblocking = toggle; ps2->nonblocking = toggle;
}
} }
static bool ps2_audio_use_float(void *data) static bool ps2_audio_use_float(void *data)
@ -263,8 +262,7 @@ static size_t ps2_audio_write_avail(void *data)
{ {
ps2_audio_t* ps2 = (ps2_audio_t*)data; ps2_audio_t* ps2 = (ps2_audio_t*)data;
if (ps2 && ps2->running) if (ps2 && ps2->running) {
{
size_t size; size_t size;
WaitSema(ps2->lock); WaitSema(ps2->lock);
size = AUDIO_BUFFER - fifo_read_avail(ps2->buffer); size = AUDIO_BUFFER - fifo_read_avail(ps2->buffer);

View File

@ -401,6 +401,8 @@ static bool default_screenshots_in_content_dir = false;
#if defined(__CELLOS_LV2__) || defined(_XBOX1) || defined(_XBOX360) #if defined(__CELLOS_LV2__) || defined(_XBOX1) || defined(_XBOX360)
static unsigned menu_toggle_gamepad_combo = INPUT_TOGGLE_L3_R3; static unsigned menu_toggle_gamepad_combo = INPUT_TOGGLE_L3_R3;
#elif defined(PS2)
static unsigned menu_toggle_gamepad_combo = INPUT_TOGGLE_HOLD_START;
#elif defined(VITA) #elif defined(VITA)
static unsigned menu_toggle_gamepad_combo = INPUT_TOGGLE_L1_R1_START_SELECT; static unsigned menu_toggle_gamepad_combo = INPUT_TOGGLE_L1_R1_START_SELECT;
#elif defined(SWITCH) #elif defined(SWITCH)

View File

@ -62,14 +62,12 @@ static GSGLOBAL *init_GSGlobal(void) {
dmaKit_init(D_CTRL_RELE_OFF,D_CTRL_MFD_OFF, D_CTRL_STS_UNSPEC, dmaKit_init(D_CTRL_RELE_OFF,D_CTRL_MFD_OFF, D_CTRL_STS_UNSPEC,
D_CTRL_STD_OFF, D_CTRL_RCYC_8, 1 << DMA_CHANNEL_GIF); D_CTRL_STD_OFF, D_CTRL_RCYC_8, 1 << DMA_CHANNEL_GIF);
// Initialize the DMAC /* Initialize the DMAC */
dmaKit_chan_init(DMA_CHANNEL_GIF); dmaKit_chan_init(DMA_CHANNEL_GIF);
gsKit_init_screen(gsGlobal); gsKit_init_screen(gsGlobal);
gsKit_mode_switch(gsGlobal, GS_ONESHOT); gsKit_mode_switch(gsGlobal, GS_ONESHOT);
gsKit_clear(gsGlobal, GS_BLACK);
return gsGlobal; return gsGlobal;
} }
@ -144,7 +142,7 @@ if (color_correction) {
static void vram_alloc(GSGLOBAL *gsGlobal, GSTEXTURE *texture) { static void vram_alloc(GSGLOBAL *gsGlobal, GSTEXTURE *texture) {
uint32_t size = gsKit_texture_size(texture->Width, texture->Height, texture->PSM); uint32_t size = gsKit_texture_size(texture->Width, texture->Height, texture->PSM);
texture->Vram=gsKit_vram_alloc(gsGlobal, size, GSKIT_ALLOC_USERBUFFER); texture->Vram = gsKit_vram_alloc(gsGlobal, size, GSKIT_ALLOC_USERBUFFER);
if(texture->Vram == GSKIT_ALLOC_ERROR) { if(texture->Vram == GSKIT_ALLOC_ERROR) {
printf("VRAM Allocation Failed. Will not upload texture.\n"); printf("VRAM Allocation Failed. Will not upload texture.\n");
} }
@ -225,13 +223,15 @@ static bool ps2_gfx_frame(void *data, const void *frame,
static float fps = 0.0; static float fps = 0.0;
#endif #endif
ps2_video_t *ps2 = (ps2_video_t*)data; ps2_video_t *ps2 = (ps2_video_t*)data;
bool texture_empty = true;
if (!width || !height) if (!width || !height)
return false; return false;
if (frame_count%120==0) { if (frame_count%120==0) {
printf("ps2_gfx_frame %d\n", frame_count); printf("ps2_gfx_frame %lu\n", frame_count);
} }
gsKit_clear(ps2->gsGlobal, GS_BLACK);
gsKit_vram_clear(ps2->gsGlobal); gsKit_vram_clear(ps2->gsGlobal);
if (frame) { if (frame) {
@ -241,7 +241,7 @@ static bool ps2_gfx_frame(void *data, const void *frame,
prim_texture(ps2->gsGlobal, ps2->coreTexture, 1, ps2->force_aspect); prim_texture(ps2->gsGlobal, ps2->coreTexture, 1, ps2->force_aspect);
} }
bool texture_empty = !ps2->menuTexture->Width || !ps2->menuTexture->Height; texture_empty = !ps2->menuTexture->Width || !ps2->menuTexture->Height;
if (ps2->menuVisible && !texture_empty) { if (ps2->menuVisible && !texture_empty) {
vram_alloc(ps2->gsGlobal, ps2->menuTexture); vram_alloc(ps2->gsGlobal, ps2->menuTexture);
gsKit_texture_upload(ps2->gsGlobal, ps2->menuTexture); gsKit_texture_upload(ps2->gsGlobal, ps2->menuTexture);

View File

@ -32,6 +32,7 @@ static char padBuf[256] __attribute__((aligned(64)));
static uint64_t pad_state[PS2_MAX_PADS]; static uint64_t pad_state[PS2_MAX_PADS];
extern uint64_t lifecycle_state;
static const char *ps2_joypad_name(unsigned pad) static const char *ps2_joypad_name(unsigned pad)
{ {
@ -45,6 +46,8 @@ static bool ps2_joypad_init(void *data)
for (i = 0; i < players_count; i++) for (i = 0; i < players_count; i++)
{ {
int ret, port, slot;
bool auto_configure = input_autoconfigure_connect( ps2_joypad_name(i), bool auto_configure = input_autoconfigure_connect( ps2_joypad_name(i),
NULL, NULL,
ps2_joypad.ident, ps2_joypad.ident,
@ -57,9 +60,6 @@ static bool ps2_joypad_init(void *data)
padInit(i); padInit(i);
int ret;
int port, slot;
port = 0; // 0 -> Connector 1, 1 -> Connector 2 port = 0; // 0 -> Connector 1, 1 -> Connector 2
slot = 0; // Always zero if not using multitap slot = 0; // Always zero if not using multitap
@ -101,15 +101,13 @@ static void ps2_joypad_poll(void)
unsigned players_count = PS2_MAX_PADS; unsigned players_count = PS2_MAX_PADS;
struct padButtonStatus buttons; struct padButtonStatus buttons;
for (player = 0; player < players_count; player++) for (player = 0; player < players_count; player++) {
{
unsigned j, k; unsigned j, k;
unsigned i = player; unsigned i = player;
unsigned p = player; unsigned p = player;
int ret = padRead(player, player, &buttons); // port, slot, buttons int ret = padRead(player, player, &buttons); // port, slot, buttons
if (ret != 0) if (ret != 0) {
{
int32_t state_tmp = 0xffff ^ buttons.btns; int32_t state_tmp = 0xffff ^ buttons.btns;
pad_state[i] = 0; pad_state[i] = 0;

View File

@ -70,24 +70,7 @@ static time_t _gmtotime_t (
return seconds_from_1970; return seconds_from_1970;
} }
/* Protected methods in libc */ time_t ps2_time(time_t *t) {
void _ps2sdk_time_init(void)
{
SDL_Init(SDL_INIT_TIMER);
}
/* Protected methods in libc */
void _ps2sdk_time_deinit(void)
{
SDL_QuitSubSystem(SDL_INIT_TIMER);
}
clock_t clock(void)
{
return SDL_GetTicks();
}
time_t time(time_t *t) {
time_t tim; time_t tim;
sceCdCLOCK clocktime; /* defined in libcdvd.h */ sceCdCLOCK clocktime; /* defined in libcdvd.h */
@ -106,3 +89,26 @@ time_t time(time_t *t) {
return tim; return tim;
} }
/* Protected methods in libc */
void _ps2sdk_time_init(void)
{
SDL_Init(SDL_INIT_TIMER);
}
/* Protected methods in libc */
void _ps2sdk_time_deinit(void)
{
SDL_QuitSubSystem(SDL_INIT_TIMER);
}
clock_t clock(void)
{
return SDL_GetTicks();
}
time_t time(time_t *t) {
time_t tim = -1;
/* TODO: This function need to be implemented again because the SDK one is not working fine */
return time;
}