2023-09-13 10:22:02 +00:00
|
|
|
/*************************************************************************
|
|
|
|
*
|
|
|
|
* Orca
|
|
|
|
* Copyright 2023 Martin Fouilleul and the Orca project contributors
|
|
|
|
* See LICENSE.txt for licensing information
|
|
|
|
*
|
|
|
|
**************************************************************************/
|
|
|
|
#include "orca.h"
|
|
|
|
|
|
|
|
int main()
|
|
|
|
{
|
|
|
|
oc_init();
|
|
|
|
|
|
|
|
oc_rect rect = { .x = 100, .y = 100, .w = 200, .h = 200 };
|
|
|
|
oc_window window = oc_window_create(rect, OC_STR8("test"), 0);
|
|
|
|
|
|
|
|
oc_window_bring_to_front(window);
|
|
|
|
oc_window_focus(window);
|
|
|
|
|
|
|
|
oc_window_center(window);
|
|
|
|
|
|
|
|
oc_log_info("keycode for enter = %i\n", OC_KEY_ENTER);
|
|
|
|
|
|
|
|
while(!oc_should_quit())
|
|
|
|
{
|
2023-09-14 09:54:38 +00:00
|
|
|
oc_arena_scope scratch = oc_scratch_begin();
|
2023-09-13 10:22:02 +00:00
|
|
|
oc_pump_events(0);
|
|
|
|
oc_event* event = 0;
|
2023-09-13 16:10:47 +00:00
|
|
|
while((event = oc_next_event(scratch.arena)) != 0)
|
2023-09-13 10:22:02 +00:00
|
|
|
{
|
|
|
|
switch(event->type)
|
|
|
|
{
|
|
|
|
case OC_EVENT_WINDOW_CLOSE:
|
|
|
|
{
|
|
|
|
oc_request_quit();
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case OC_EVENT_KEYBOARD_KEY:
|
|
|
|
{
|
|
|
|
if(event->key.action == OC_KEY_PRESS)
|
|
|
|
{
|
|
|
|
if(event->key.keyCode < 128)
|
|
|
|
{
|
|
|
|
oc_log_info("Key:\n\tscanCode = %i\n\tkeyCode = %i (%c)\n",
|
|
|
|
event->key.scanCode,
|
|
|
|
event->key.keyCode,
|
|
|
|
event->key.keyCode);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
oc_log_info("Key:\n\tscanCode = %i\n\tkeyCode = %i\n",
|
|
|
|
event->key.scanCode,
|
|
|
|
event->key.keyCode);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2023-09-13 16:10:47 +00:00
|
|
|
oc_scratch_end(scratch);
|
2023-09-13 10:22:02 +00:00
|
|
|
}
|
|
|
|
oc_terminate();
|
|
|
|
return (0);
|
|
|
|
}
|