Add pending_events function callback

This commit is contained in:
twinaphex 2016-06-07 18:02:37 +02:00
parent dbf59a72bd
commit 3f44ba59eb
4 changed files with 27 additions and 6 deletions

View File

@ -23,6 +23,14 @@
#include "cocoa_common.h"
#include "../../ui_companion_driver.h"
static bool ui_application_cocoa_pending_events(void)
{
NSEvent *event = [NSApp nextEventMatchingMask:NSAnyEventMask untilDate:[NSDate distantPast] inMode:NSDefaultRunLoopMode dequeue:YES];
if (!event)
return false;
return true;
}
static void ui_application_cocoa_process_events(void)
{
while (1)
@ -37,6 +45,7 @@ static void ui_application_cocoa_process_events(void)
}
const ui_application_t ui_application_cocoa = {
ui_application_cocoa_pending_events,
ui_application_cocoa_process_events,
"cocoa"
};

View File

@ -21,11 +21,17 @@
#include "../../ui_companion_driver.h"
static bool ui_application_null_pending_events(void)
{
return true;
}
static void ui_application_null_process_events(void)
{
}
const ui_application_t ui_application_null = {
ui_application_null_pending_events,
ui_application_null_process_events,
"null"
};

View File

@ -23,23 +23,28 @@
#include "../../ui_companion_driver.h"
static void ui_application_win32_process_events(void)
static bool ui_application_win32_pending_events(void)
{
MSG msg;
return PeekMessage(&msg, NULL, 0, 0, PM_NOREMOVE);
}
while (PeekMessage(&msg, NULL, 0, 0, PM_NOREMOVE))
static void ui_application_win32_process_events(void)
{
while (ui_application_win32_pending_events())
{
MSG msg2;
MSG msg;
if (PeekMessage(&msg2, 0, 0, 0, PM_REMOVE))
if (PeekMessage(&msg, 0, 0, 0, PM_REMOVE))
{
TranslateMessage(&msg2);
DispatchMessage (&msg2);
TranslateMessage(&msg);
DispatchMessage (&msg);
}
}
}
const ui_application_t ui_application_win32 = {
ui_application_win32_pending_events,
ui_application_win32_process_events,
"win32"
};

View File

@ -33,6 +33,7 @@ RETRO_BEGIN_DECLS
typedef struct ui_application
{
bool (*pending_events)(void);
void (*process_events)(void);
const char *ident;
} ui_application_t;