2020-02-27 12:01:09 +00:00
|
|
|
#include "event.h"
|
|
|
|
|
2020-02-26 16:18:38 +00:00
|
|
|
typedef struct window_s *window_t;
|
|
|
|
|
|
|
|
void initialize (void) = #0;
|
|
|
|
window_t create_window (int xpos, int ypos, int xlen, int ylen) = #0;
|
|
|
|
void destroy_window (window_t win) = #0;
|
2020-02-27 12:22:10 +00:00
|
|
|
void mvwprintf (window_t win, int x, int y, string fmt, ...) = #0;
|
2020-02-26 16:18:38 +00:00
|
|
|
|
2020-02-27 12:01:09 +00:00
|
|
|
int get_event (qwaq_event_t *event) = #0;
|
|
|
|
|
2020-02-26 16:18:38 +00:00
|
|
|
int main (int argc, string *argv)
|
|
|
|
{
|
2020-02-27 12:01:09 +00:00
|
|
|
int ch = 0;
|
|
|
|
qwaq_event_t event = { };
|
2020-02-26 16:18:38 +00:00
|
|
|
|
|
|
|
initialize ();
|
|
|
|
window_t win = create_window (20, 5, 50, 10);
|
2020-02-28 17:07:47 +00:00
|
|
|
mvwprintf (win, 0, 0, "Hi there! (q to quit)\n");
|
|
|
|
mvwprintf (win, 1, 1, "(?)Oo.\n");
|
|
|
|
mvwprintf (win, 1, 2, " \\_O>\n");
|
2020-02-26 16:18:38 +00:00
|
|
|
do {
|
2020-02-27 12:01:09 +00:00
|
|
|
if (get_event (&event)) {
|
|
|
|
if (event.event_type == qe_key) {
|
|
|
|
ch = event.e.key;
|
2020-02-27 12:22:10 +00:00
|
|
|
mvwprintf (win, 1, 1, "key: %d\n", ch);
|
2020-02-27 12:01:09 +00:00
|
|
|
} else if (event.event_type == qe_mouse) {
|
2020-02-28 13:27:29 +00:00
|
|
|
mvwprintf (win, 1, 2, "mouse: %2d %2d %08x\n",
|
2020-02-27 12:22:10 +00:00
|
|
|
event.e.mouse.x,
|
|
|
|
event.e.mouse.y,
|
|
|
|
event.e.mouse.buttons);
|
2020-02-27 12:01:09 +00:00
|
|
|
}
|
2020-02-26 16:18:38 +00:00
|
|
|
}
|
2020-02-27 12:22:10 +00:00
|
|
|
} while (ch != 'q' && ch != 'Q');
|
2020-02-29 02:44:43 +00:00
|
|
|
destroy_window (win);
|
|
|
|
get_event (&event);
|
2020-02-26 16:18:38 +00:00
|
|
|
return 0;
|
|
|
|
}
|