mirror of https://github.com/mgba-emu/mgba.git
Only unpause from state operations when we paused manually
This commit is contained in:
parent
c3a5fb497a
commit
ef66e4a8c7
|
@ -256,6 +256,14 @@ void GBAThreadUnpause(struct GBAThread* threadContext) {
|
||||||
MutexUnlock(&threadContext->sync.videoFrameMutex);
|
MutexUnlock(&threadContext->sync.videoFrameMutex);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int GBAThreadIsPaused(struct GBAThread* threadContext) {
|
||||||
|
int isPaused;
|
||||||
|
MutexLock(&threadContext->stateMutex);
|
||||||
|
isPaused = threadContext->state == THREAD_PAUSED;
|
||||||
|
MutexUnlock(&threadContext->stateMutex);
|
||||||
|
return isPaused;
|
||||||
|
}
|
||||||
|
|
||||||
void GBAThreadTogglePause(struct GBAThread* threadContext) {
|
void GBAThreadTogglePause(struct GBAThread* threadContext) {
|
||||||
int frameOn = 1;
|
int frameOn = 1;
|
||||||
MutexLock(&threadContext->stateMutex);
|
MutexLock(&threadContext->stateMutex);
|
||||||
|
@ -278,7 +286,6 @@ void GBAThreadTogglePause(struct GBAThread* threadContext) {
|
||||||
MutexUnlock(&threadContext->sync.videoFrameMutex);
|
MutexUnlock(&threadContext->sync.videoFrameMutex);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
#ifdef USE_PTHREADS
|
#ifdef USE_PTHREADS
|
||||||
struct GBAThread* GBAThreadGetContext(void) {
|
struct GBAThread* GBAThreadGetContext(void) {
|
||||||
pthread_once(&_contextOnce, _createTLS);
|
pthread_once(&_contextOnce, _createTLS);
|
||||||
|
|
|
@ -66,6 +66,7 @@ void GBAThreadJoin(struct GBAThread* threadContext);
|
||||||
|
|
||||||
void GBAThreadPause(struct GBAThread* threadContext);
|
void GBAThreadPause(struct GBAThread* threadContext);
|
||||||
void GBAThreadUnpause(struct GBAThread* threadContext);
|
void GBAThreadUnpause(struct GBAThread* threadContext);
|
||||||
|
int GBAThreadIsPaused(struct GBAThread* threadContext);
|
||||||
void GBAThreadTogglePause(struct GBAThread* threadContext);
|
void GBAThreadTogglePause(struct GBAThread* threadContext);
|
||||||
struct GBAThread* GBAThreadGetContext(void);
|
struct GBAThread* GBAThreadGetContext(void);
|
||||||
|
|
||||||
|
|
|
@ -27,6 +27,7 @@ static void _pauseAfterFrame(struct GBAThread* context) {
|
||||||
|
|
||||||
static void _GBASDLHandleKeypress(struct GBAThread* context, const struct SDL_KeyboardEvent* event) {
|
static void _GBASDLHandleKeypress(struct GBAThread* context, const struct SDL_KeyboardEvent* event) {
|
||||||
enum GBAKey key = 0;
|
enum GBAKey key = 0;
|
||||||
|
int isPaused = GBAThreadIsPaused(context);
|
||||||
switch (event->keysym.sym) {
|
switch (event->keysym.sym) {
|
||||||
case SDLK_z:
|
case SDLK_z:
|
||||||
key = GBA_KEY_A;
|
key = GBA_KEY_A;
|
||||||
|
@ -69,9 +70,13 @@ static void _GBASDLHandleKeypress(struct GBAThread* context, const struct SDL_Ke
|
||||||
context->sync.audioWait = event->type != SDL_KEYDOWN;
|
context->sync.audioWait = event->type != SDL_KEYDOWN;
|
||||||
return;
|
return;
|
||||||
case SDLK_LEFTBRACKET:
|
case SDLK_LEFTBRACKET:
|
||||||
|
if (!isPaused) {
|
||||||
GBAThreadPause(context);
|
GBAThreadPause(context);
|
||||||
|
}
|
||||||
GBARewind(context, 10);
|
GBARewind(context, 10);
|
||||||
|
if (!isPaused) {
|
||||||
GBAThreadUnpause(context);
|
GBAThreadUnpause(context);
|
||||||
|
}
|
||||||
default:
|
default:
|
||||||
if (event->type == SDL_KEYDOWN) {
|
if (event->type == SDL_KEYDOWN) {
|
||||||
if (event->keysym.mod & KMOD_CTRL) {
|
if (event->keysym.mod & KMOD_CTRL) {
|
||||||
|
@ -100,9 +105,13 @@ static void _GBASDLHandleKeypress(struct GBAThread* context, const struct SDL_Ke
|
||||||
case SDLK_F8:
|
case SDLK_F8:
|
||||||
case SDLK_F9:
|
case SDLK_F9:
|
||||||
case SDLK_F10:
|
case SDLK_F10:
|
||||||
|
if (!isPaused) {
|
||||||
GBAThreadPause(context);
|
GBAThreadPause(context);
|
||||||
|
}
|
||||||
GBASaveState(context->gba, event->keysym.sym - SDLK_F1);
|
GBASaveState(context->gba, event->keysym.sym - SDLK_F1);
|
||||||
|
if (!isPaused) {
|
||||||
GBAThreadUnpause(context);
|
GBAThreadUnpause(context);
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
|
@ -119,9 +128,13 @@ static void _GBASDLHandleKeypress(struct GBAThread* context, const struct SDL_Ke
|
||||||
case SDLK_F8:
|
case SDLK_F8:
|
||||||
case SDLK_F9:
|
case SDLK_F9:
|
||||||
case SDLK_F10:
|
case SDLK_F10:
|
||||||
|
if (!isPaused) {
|
||||||
GBAThreadPause(context);
|
GBAThreadPause(context);
|
||||||
|
}
|
||||||
GBALoadState(context->gba, event->keysym.sym - SDLK_F1);
|
GBALoadState(context->gba, event->keysym.sym - SDLK_F1);
|
||||||
|
if (!isPaused) {
|
||||||
GBAThreadUnpause(context);
|
GBAThreadUnpause(context);
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
|
|
Loading…
Reference in New Issue