2022-12-21 11:03:55 +00:00
|
|
|
/************************************************************//**
|
|
|
|
*
|
|
|
|
* @file: main.cpp
|
|
|
|
* @author: Martin Fouilleul
|
|
|
|
* @date: 30/07/2022
|
|
|
|
* @revision:
|
|
|
|
*
|
|
|
|
*****************************************************************/
|
|
|
|
#include<stdlib.h>
|
|
|
|
#include<string.h>
|
|
|
|
|
2022-12-22 17:24:43 +00:00
|
|
|
#include"milepost.h"
|
2022-12-21 11:03:55 +00:00
|
|
|
|
2022-12-21 18:43:31 +00:00
|
|
|
#define LOG_SUBSYSTEM "Main"
|
|
|
|
|
2022-12-21 11:03:55 +00:00
|
|
|
int main()
|
|
|
|
{
|
|
|
|
LogLevel(LOG_LEVEL_DEBUG);
|
|
|
|
|
|
|
|
mp_init();
|
|
|
|
|
|
|
|
mp_rect rect = {.x = 100, .y = 100, .w = 800, .h = 600};
|
|
|
|
mp_window window = mp_window_create(rect, "test", 0);
|
2022-12-21 18:43:31 +00:00
|
|
|
|
2022-12-23 19:46:42 +00:00
|
|
|
mp_window_bring_to_front(window);
|
2022-12-24 14:33:32 +00:00
|
|
|
mp_window_focus(window);
|
2022-12-21 11:03:55 +00:00
|
|
|
|
|
|
|
while(!mp_should_quit())
|
|
|
|
{
|
|
|
|
mp_pump_events(0);
|
|
|
|
mp_event event = {0};
|
|
|
|
while(mp_next_event(&event))
|
|
|
|
{
|
|
|
|
switch(event.type)
|
|
|
|
{
|
2022-12-23 19:46:42 +00:00
|
|
|
case MP_EVENT_WINDOW_CLOSE:
|
2022-12-21 11:03:55 +00:00
|
|
|
{
|
2022-12-23 19:46:42 +00:00
|
|
|
mp_request_quit();
|
2022-12-21 11:03:55 +00:00
|
|
|
} break;
|
|
|
|
|
2022-12-23 19:46:42 +00:00
|
|
|
case MP_EVENT_WINDOW_RESIZE:
|
2022-12-21 11:03:55 +00:00
|
|
|
{
|
2022-12-23 19:46:42 +00:00
|
|
|
printf("resized, rect = {%f, %f, %f, %f}\n",
|
|
|
|
event.frame.rect.x,
|
|
|
|
event.frame.rect.y,
|
|
|
|
event.frame.rect.w,
|
|
|
|
event.frame.rect.h);
|
2022-12-21 11:03:55 +00:00
|
|
|
} break;
|
|
|
|
|
2022-12-23 19:46:42 +00:00
|
|
|
case MP_EVENT_WINDOW_MOVE:
|
|
|
|
{
|
|
|
|
printf("moved, rect = {%f, %f, %f, %f}\n",
|
|
|
|
event.frame.rect.x,
|
|
|
|
event.frame.rect.y,
|
|
|
|
event.frame.rect.w,
|
|
|
|
event.frame.rect.h);
|
|
|
|
} break;
|
|
|
|
|
|
|
|
case MP_EVENT_MOUSE_MOVE:
|
|
|
|
{
|
|
|
|
printf("mouse moved, pos = {%f, %f}, delta = {%f, %f}\n",
|
|
|
|
event.move.x,
|
|
|
|
event.move.y,
|
|
|
|
event.move.deltaX,
|
|
|
|
event.move.deltaY);
|
|
|
|
} break;
|
|
|
|
|
|
|
|
case MP_EVENT_MOUSE_WHEEL:
|
|
|
|
{
|
|
|
|
printf("mouse wheel, delta = {%f, %f}\n",
|
|
|
|
event.move.deltaX,
|
|
|
|
event.move.deltaY);
|
|
|
|
} break;
|
|
|
|
|
|
|
|
case MP_EVENT_MOUSE_ENTER:
|
2022-12-21 11:03:55 +00:00
|
|
|
{
|
2022-12-23 19:46:42 +00:00
|
|
|
printf("mouse enter\n");
|
|
|
|
} break;
|
|
|
|
|
|
|
|
case MP_EVENT_MOUSE_LEAVE:
|
|
|
|
{
|
|
|
|
printf("mouse leave\n");
|
|
|
|
} break;
|
|
|
|
|
|
|
|
case MP_EVENT_MOUSE_BUTTON:
|
|
|
|
{
|
|
|
|
printf("mouse button %i: %i\n",
|
|
|
|
event.key.code,
|
|
|
|
event.key.action == MP_KEY_PRESS ? 1 : 0);
|
|
|
|
} break;
|
|
|
|
|
|
|
|
case MP_EVENT_KEYBOARD_KEY:
|
|
|
|
{
|
|
|
|
printf("key %i: %s\n",
|
|
|
|
event.key.code,
|
|
|
|
event.key.action == MP_KEY_PRESS ? "press" : (event.key.action == MP_KEY_RELEASE ? "release" : "repeat"));
|
|
|
|
} break;
|
|
|
|
|
|
|
|
case MP_EVENT_KEYBOARD_CHAR:
|
|
|
|
{
|
|
|
|
printf("entered char %s\n", event.character.sequence);
|
2022-12-21 11:03:55 +00:00
|
|
|
} break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
mp_terminate();
|
|
|
|
|
|
|
|
return(0);
|
|
|
|
}
|