diff options
author | pk33 <pk33@pk33.space> | 2024-11-11 18:06:18 +0100 |
---|---|---|
committer | pk33 <pk33@pk33.space> | 2024-11-11 18:06:18 +0100 |
commit | 5a54774474f43ae29716751d6415563a59b92c7d (patch) | |
tree | 151e865845b09b85992d8be20d8cc771d4110448 /src/main.c | |
parent | 146a683b8d8315ef15dc1c9286f0983834f48d88 (diff) | |
download | engine33-5a54774474f43ae29716751d6415563a59b92c7d.tar.gz |
tidying up and basic input
Diffstat (limited to 'src/main.c')
-rw-r--r-- | src/main.c | 63 |
1 files changed, 45 insertions, 18 deletions
@@ -1,9 +1,11 @@ -#include "display.h" -#include "clock.h" -#include "logger.h" -#include "system.h" #include "signal.h" + +#include "display33.h" +#include "clock33.h" +#include "logger33.h" +#include "system33.h" #include "strings33.h" +#include "input33.h" #include "ui33.h" static void _term_sighandler( int sig ); @@ -14,37 +16,60 @@ int main(int argc, char *argv[]) Size fps, FPS; long timeOld, time; - if( e33_set_signal( SIGHUP, _term_sighandler ) == -1 ) { logw( "SIGHUP not handled"); } - if( e33_set_signal( SIGINT, _term_sighandler ) == -1 ) { logw( "SIGINT not handled"); } - if( e33_set_signal( SIGTERM, _term_sighandler ) == -1 ) { logw( "SIGTERM not handled"); } + if( e33_set_signal( SIGHUP, _term_sighandler ) == -1 ) { LOGW( "SIGHUP not handled"); } + if( e33_set_signal( SIGINT, _term_sighandler ) == -1 ) { LOGW( "SIGINT not handled"); } + if( e33_set_signal( SIGTERM, _term_sighandler ) == -1 ) { LOGW( "SIGTERM not handled"); } timeOld = clock_get_us(); time = 0; fps = 0; FPS = 0; - if( logger_init() ) { + if( logger33_init() ) { return EXIT_FAILURE; } - if( display_init() ) { + if( input33_init() ) { return EXIT_FAILURE; } - logd( "This is a test." ); + if( display33_init() ) { + return EXIT_FAILURE; + } while(1) { - display_vtswitcher_poll(1); + display33_vtswitcher_poll(1); if( __display.active ) { - qsuprintf( 5, 5, "fps: %d", FPS-1 ); + input33_poll(); + + QPRINTF( 5, 5, "fps: %d", FPS-1 ); + + if( KEYDOWN(KEY_K) ) { ui33_add_message("Pressed '%c'", 'K'); } + + if( MOUSEX ) { + __mouse.x += MOUSEX; + } + if( MOUSEY ) { + __mouse.y += MOUSEY; + } - ui_draw_messages(); - display_flip(); + + if( __mouse.x < 0 ) __mouse.x = 0; + if( __mouse.y < 0 ) __mouse.y = 0; + if( __mouse.x >= __display.surface.w ) __mouse.x = __display.surface.w-1; + if( __mouse.y >= __display.surface.h ) __mouse.y = __display.surface.h-1; + ui33_draw_mouse(); + + QPRINTF( 100, 5, "M: x(%d), y(%d)", __mouse.x, __mouse.y ); + + + ui33_draw_messages(); + display33_flip(); } @@ -60,8 +85,10 @@ int main(int argc, char *argv[]) ++fps; } - display_term(); - logger_term(); + + display33_term(); + logger33_term(); + input33_term(); return EXIT_SUCCESS; @@ -70,8 +97,8 @@ int main(int argc, char *argv[]) static void _term_sighandler( int sig ) { - display_term(); - logger_term(); + display33_term(); + logger33_term(); exit(0); } |