mirror of
https://github.com/kichikuou/system3-sdl2.git
synced 2026-10-11 16:58:11 +03:00
Android: Add system menu
The system menu opens with 3-finger touch. Currently, it can only exit the game.
This commit is contained in:
@@ -47,6 +47,15 @@ void NACT::output_console(const char *format, ...)
|
||||
#endif
|
||||
}
|
||||
|
||||
void NACT::on_syswmevent(SDL_SysWMmsg* msg)
|
||||
bool NACT::handle_platform_event(const SDL_Event& e)
|
||||
{
|
||||
if (e.type == SDL_FINGERDOWN && SDL_GetNumTouchFingers(e.tfinger.touchId) == 3) {
|
||||
JNILocalFrame jni(16);
|
||||
if (jni.env()) {
|
||||
jmethodID mid = jni.GetMethodID("popupMenu", "()V");
|
||||
jni.env()->CallVoidMethod(jni.context(), mid);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -42,6 +42,7 @@ void NACT::output_console(const char *format, ...)
|
||||
#endif
|
||||
}
|
||||
|
||||
void NACT::on_syswmevent(SDL_SysWMmsg* msg)
|
||||
bool NACT::handle_platform_event(const SDL_Event& e)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -24,6 +24,7 @@ void NACT::output_console(const char *format, ...)
|
||||
#endif
|
||||
}
|
||||
|
||||
void NACT::on_syswmevent(SDL_SysWMmsg* msg)
|
||||
bool NACT::handle_platform_event(const SDL_Event& e)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
+1
-1
@@ -43,7 +43,7 @@ public:
|
||||
|
||||
#ifdef _WIN32
|
||||
void select_sound(BGMDevice dev);
|
||||
void on_mci_notify(SDL_SysWMmsg* msg);
|
||||
void on_mci_notify(const SDL_SysWMmsg* msg);
|
||||
#endif
|
||||
#ifdef __EMSCRIPTEN__
|
||||
void select_synthesizer(bool use_fm);
|
||||
|
||||
+1
-1
@@ -267,7 +267,7 @@ public:
|
||||
|
||||
private:
|
||||
void pump_events();
|
||||
void on_syswmevent(SDL_SysWMmsg* msg);
|
||||
bool handle_platform_event(const SDL_Event& e);
|
||||
};
|
||||
|
||||
class NACT_Sys1 final : public NACT {
|
||||
|
||||
@@ -19,6 +19,9 @@ void NACT::pump_events()
|
||||
{
|
||||
SDL_Event e;
|
||||
while (SDL_PollEvent(&e)) {
|
||||
if (handle_platform_event(e))
|
||||
continue;
|
||||
|
||||
switch (e.type) {
|
||||
case SDL_QUIT:
|
||||
terminate = true;
|
||||
@@ -40,10 +43,6 @@ void NACT::pump_events()
|
||||
case SDL_APP_DIDENTERFOREGROUND:
|
||||
ags->flush_screen(false);
|
||||
break;
|
||||
|
||||
case SDL_SYSWMEVENT:
|
||||
on_syswmevent(e.syswm.msg);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+2
-2
@@ -200,7 +200,7 @@ public:
|
||||
return playing;
|
||||
}
|
||||
|
||||
bool on_mci_notify(SDL_SysWMmsg* msg) {
|
||||
bool on_mci_notify(const SDL_SysWMmsg* msg) {
|
||||
if (msg->msg.win.lParam != mci_thread->device_id())
|
||||
return true;
|
||||
switch (msg->msg.win.wParam) {
|
||||
@@ -421,7 +421,7 @@ bool MAKO::check_pcm()
|
||||
return !PlaySound(null_wav, NULL, SND_ASYNC | SND_MEMORY | SND_NOSTOP);
|
||||
}
|
||||
|
||||
void MAKO::on_mci_notify(SDL_SysWMmsg* msg)
|
||||
void MAKO::on_mci_notify(const SDL_SysWMmsg* msg)
|
||||
{
|
||||
if (!music)
|
||||
return;
|
||||
|
||||
@@ -130,8 +130,12 @@ void NACT::output_console(const char *format, ...)
|
||||
#endif
|
||||
}
|
||||
|
||||
void NACT::on_syswmevent(SDL_SysWMmsg* msg)
|
||||
bool NACT::handle_platform_event(const SDL_Event& e)
|
||||
{
|
||||
if (e.type != SDL_SYSWMEVENT)
|
||||
return false;
|
||||
const SDL_SysWMmsg* msg = e.syswm.msg;
|
||||
|
||||
switch (msg->msg.win.msg) {
|
||||
case WM_COMMAND:
|
||||
switch (msg->msg.win.wParam) {
|
||||
@@ -171,4 +175,5 @@ void NACT::on_syswmevent(SDL_SysWMmsg* msg)
|
||||
mako->on_mci_notify(msg);
|
||||
break;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user