mirror of
https://gitlab.com/dosowisko.net/libsuperderpy.git
synced 2025-01-31 18:56:42 +01:00
don't crash on devices with no touchscreen
This commit is contained in:
parent
6ac268f50b
commit
a4ce032c8b
3 changed files with 10 additions and 5 deletions
|
@ -124,10 +124,12 @@ SYMBOL_EXPORT struct Game* libsuperderpy_init(int argc, char** argv, const char*
|
|||
return NULL;
|
||||
}
|
||||
|
||||
al_install_touch_input();
|
||||
game->_priv.touch = al_install_touch_input();
|
||||
|
||||
#ifdef LIBSUPERDERPY_MOUSE_EMULATION
|
||||
al_set_mouse_emulation_mode(ALLEGRO_MOUSE_EMULATION_TRANSPARENT);
|
||||
if (game->_priv.touch) {
|
||||
al_set_mouse_emulation_mode(ALLEGRO_MOUSE_EMULATION_TRANSPARENT);
|
||||
}
|
||||
#endif
|
||||
|
||||
al_set_new_display_flags(ALLEGRO_PROGRAMMABLE_PIPELINE | (game->config.fullscreen ? ALLEGRO_FULLSCREEN_WINDOW : ALLEGRO_WINDOWED) | ALLEGRO_RESIZABLE | ALLEGRO_OPENGL ); // TODO: make ALLEGRO_PROGRAMMABLE_PIPELINE game-optional
|
||||
|
@ -207,10 +209,12 @@ SYMBOL_EXPORT int libsuperderpy_run(struct Game *game) {
|
|||
al_register_event_source(game->_priv.event_queue, al_get_display_event_source(game->display));
|
||||
al_register_event_source(game->_priv.event_queue, al_get_mouse_event_source());
|
||||
al_register_event_source(game->_priv.event_queue, al_get_keyboard_event_source());
|
||||
al_register_event_source(game->_priv.event_queue, al_get_touch_input_event_source());
|
||||
if (game->_priv.touch) {
|
||||
al_register_event_source(game->_priv.event_queue, al_get_touch_input_event_source());
|
||||
#ifdef LIBSUPERDERPY_MOUSE_EMULATION
|
||||
al_register_event_source(game->_priv.event_queue, al_get_touch_input_mouse_emulation_event_source());
|
||||
al_register_event_source(game->_priv.event_queue, al_get_touch_input_mouse_emulation_event_source());
|
||||
#endif
|
||||
}
|
||||
al_register_event_source(game->_priv.event_queue, &(game->event_source));
|
||||
|
||||
al_clear_to_color(al_map_rgb(0,0,0));
|
||||
|
|
|
@ -122,6 +122,7 @@ struct Game {
|
|||
struct libsuperderpy_list *garbage;
|
||||
|
||||
bool draw;
|
||||
bool touch;
|
||||
|
||||
#ifdef ALLEGRO_MACOSX
|
||||
char cwd[MAXPATHLEN];
|
||||
|
|
|
@ -325,7 +325,7 @@ SYMBOL_EXPORT void PrintConsole(struct Game *game, char* format, ...) {
|
|||
char text[1024] = {};
|
||||
vsnprintf(text, 1024, format, vl);
|
||||
va_end(vl);
|
||||
ALLEGRO_DEBUG(text);
|
||||
ALLEGRO_DEBUG("%s", text);
|
||||
if (game->config.debug) { printf("%s\n", text); fflush(stdout); }
|
||||
if (!game->_priv.draw) return;
|
||||
if (!game->_priv.console) return;
|
||||
|
|
Loading…
Reference in a new issue