#include "egl/fg_window_egl.h"
#include <slog2.h>
-#define LOGI(...) ((void)slog2fa(NULL, 1337, SLOG2_INFO, __VA_ARGS__))
-#define LOGW(...) ((void)slog2fa(NULL, 1337, SLOG2_WARNING, __VA_ARGS__))
+#define LOGI(...) ((void)slog2fa(NULL, 1337, SLOG2_INFO, __VA_ARGS__, SLOG2_FA_END))
+#define LOGW(...) ((void)slog2fa(NULL, 1337, SLOG2_WARNING, __VA_ARGS__, SLOG2_FA_END))
#include <sys/keycodes.h>
#include <input/screen_helpers.h>
#include <bps/bps.h>
return qnxKeycode;
}
-uint64_t fgPlatformSystemTime ( void )
+//From fg_main_x11
+fg_time_t fgPlatformSystemTime ( void )
{
- struct timespec now;
- clock_gettime(CLOCK_REALTIME, &now);
- return (1000 * now.tv_sec) + (now.tv_nsec / 1000000);
+#ifdef CLOCK_MONOTONIC
+ struct timespec now;
+ clock_gettime(CLOCK_MONOTONIC, &now);
+ return now.tv_nsec/1000000 + now.tv_sec*1000;
+#elif defined(HAVE_GETTIMEOFDAY)
+ struct timeval now;
+ gettimeofday( &now, NULL );
+ return now.tv_usec/1000 + now.tv_sec*1000;
+#endif
}
/*
* Does the magic required to relinquish the CPU until something interesting
* happens.
*/
-void fgPlatformSleepForEvents( uint64_t msec )
+void fgPlatformSleepForEvents( fg_time_t msec )
{
//XXX: Is this right? Is there a more direct way to access the context?
if(bps_get_event(&fgStructure.CurrentWindow->Window.pContext.event, (int)msec) != BPS_SUCCESS) {
{
mtouch_event_t touchEvent;
screen_get_mtouch_event(screenEvent, &touchEvent, 0);
- if(touchEvent.contact_id == 0) { //XXX Only support one contact for now
+ LOGI("fgPlatformProcessSingleEvent: SCREEN_EVENT_MTOUCH_*: Type: 0x%X, X: %d, Y: %d, Contact Id: %d", SLOG2_FA_SIGNED(eventType), SLOG2_FA_SIGNED(touchEvent.x), SLOG2_FA_SIGNED(touchEvent.y), SLOG2_FA_SIGNED(touchEvent.contact_id));
+ if(touchEvent.contact_id == 0) {
int size[2];
screen_get_window_property_iv(window->Window.Handle, SCREEN_PROPERTY_BUFFER_SIZE, size);
handle_left_mouse(touchEvent.x, touchEvent.y, size[1], eventType, window);
}
+
+ //Now handle mutlitouch (adapted from fg_main_windows)
+ if (eventType == SCREEN_EVENT_MTOUCH_TOUCH) {
+ INVOKE_WCB( *window, MultiEntry, ( touchEvent.contact_id, GLUT_ENTERED ) );
+ INVOKE_WCB( *window, MultiButton, ( touchEvent.contact_id, touchEvent.x, touchEvent.y, 0, GLUT_DOWN ) );
+ } else if (eventType == SCREEN_EVENT_MTOUCH_MOVE) {
+ INVOKE_WCB( *window, MultiMotion, ( touchEvent.contact_id, touchEvent.x, touchEvent.y ) );
+ //XXX No motion is performed without contact, thus MultiPassive is never used
+ } else if (eventType == SCREEN_EVENT_MTOUCH_RELEASE) {
+ INVOKE_WCB( *window, MultiButton, ( touchEvent.contact_id, touchEvent.x, touchEvent.y, 0, GLUT_UP ) );
+ INVOKE_WCB( *window, MultiEntry, ( touchEvent.contact_id, GLUT_LEFT ) );
+ }
break;
}
static int mouse_pressed = 0;
int buttons;
int position[2];
+ int wheel;
// A move event will be fired unless a button state changed.
bool move = true;
bool left_move = false;
// This is a mouse move event, it is applicable to a device with a usb mouse or simulator.
screen_get_event_property_iv(screenEvent, SCREEN_PROPERTY_BUTTONS, &buttons);
screen_get_event_property_iv(screenEvent, SCREEN_PROPERTY_SOURCE_POSITION, position);
+ screen_get_event_property_iv(screenEvent, SCREEN_PROPERTY_MOUSE_WHEEL, &wheel);
int size[2];
screen_get_window_property_iv(window->Window.Handle, SCREEN_PROPERTY_BUFFER_SIZE, size);
+ LOGI("fgPlatformProcessSingleEvent: SCREEN_EVENT_POINTER: Buttons: 0x%X, X: %d, Y: %d, Wheel: %d", SLOG2_FA_SIGNED(buttons), SLOG2_FA_SIGNED(position[0]), SLOG2_FA_SIGNED(position[1]), SLOG2_FA_SIGNED(wheel));
+
+ //XXX Should multitouch be handled?
+
// Handle left mouse. Interpret as touch if the left mouse event is not consumed.
if (buttons & SCREEN_LEFT_MOUSE_BUTTON) {
if (mouse_pressed & SCREEN_LEFT_MOUSE_BUTTON) {
if (left_move || move) {
handle_left_mouse(position[0], position[1], size[1], SCREEN_EVENT_MTOUCH_MOVE, window);
}
+
+ if (wheel) {
+ fgState.MouseWheelTicks -= wheel;
+ //TODO: Implement wheel support (based on fg_main_mswin... though it seems excessive)
+ }
break;
}
int value;
screen_get_event_property_iv(screenEvent, SCREEN_PROPERTY_KEY_FLAGS, &flags);
screen_get_event_property_iv(screenEvent, SCREEN_PROPERTY_KEY_SYM, &value);
- LOGI("fgPlatformProcessSingleEvent: SCREEN_EVENT_KEYBOARD. Flags: 0x%X, Sym: 0x%X", SLOG2_FA_SIGNED(flags), SLOG2_FA_SIGNED(value), SLOG2_FA_END);
+ LOGI("fgPlatformProcessSingleEvent: SCREEN_EVENT_KEYBOARD. Flags: 0x%X, Sym: 0x%X", SLOG2_FA_SIGNED(flags), SLOG2_FA_SIGNED(value));
// Suppress key repeats if desired
- if (!fgStructure.CurrentWindow->State.IgnoreKeyRepeat && (flags & KEY_REPEAT) == 0) {
+ if ((flags & KEY_REPEAT) == 0 || (fgState.KeyRepeat == GLUT_KEY_REPEAT_ON && !fgStructure.CurrentWindow->State.IgnoreKeyRepeat)) {
unsigned int keypress = 0;
unsigned char ascii = 0;
if ((keypress = key_special(value))) {
}
break;
}
+
+ case SCREEN_EVENT_PROPERTY:
+ case SCREEN_EVENT_IDLE:
+ break;
+
+ default:
+ LOGW("fgPlatformProcessSingleEvent: unknown screen event: 0x%X", SLOG2_FA_SIGNED(eventType));
+ break;
}
} else if (domain == navigator_get_domain()) {
- switch (bps_event_get_code(event)) {
+ int eventType = bps_event_get_code(event);
+ switch (eventType) {
case NAVIGATOR_WINDOW_STATE:
{
- LOGI("fgPlatformProcessSingleEvent: NAVIGATOR_WINDOW_STATE", SLOG2_FA_END);
+ LOGI("fgPlatformProcessSingleEvent: NAVIGATOR_WINDOW_STATE");
navigator_window_state_t state = navigator_event_get_window_state(event);
switch (state)
{
case NAVIGATOR_WINDOW_FULLSCREEN:
- LOGI("fgPlatformProcessSingleEvent: NAVIGATOR_WINDOW_STATE-NAVIGATOR_WINDOW_FULLSCREEN", SLOG2_FA_END);
+ LOGI("fgPlatformProcessSingleEvent: NAVIGATOR_WINDOW_STATE-NAVIGATOR_WINDOW_FULLSCREEN");
INVOKE_WCB(*window, AppStatus, (GLUT_APPSTATUS_RESUME));
break;
case NAVIGATOR_WINDOW_THUMBNAIL:
case NAVIGATOR_WINDOW_INVISIBLE:
- LOGI("fgPlatformProcessSingleEvent: NAVIGATOR_WINDOW_STATE-NAVIGATOR_WINDOW_THUMBNAIL/NAVIGATOR_WINDOW_INVISIBLE", SLOG2_FA_END);
+ LOGI("fgPlatformProcessSingleEvent: NAVIGATOR_WINDOW_STATE-NAVIGATOR_WINDOW_THUMBNAIL/NAVIGATOR_WINDOW_INVISIBLE");
INVOKE_WCB(*window, AppStatus, (GLUT_APPSTATUS_PAUSE));
break;
+ default:
+ LOGW("fgPlatformProcessSingleEvent: NAVIGATOR_WINDOW_STATE unknown: 0x%X", SLOG2_FA_SIGNED(state));
+ break;
}
break;
}
case NAVIGATOR_EXIT:
- LOGI("fgPlatformProcessSingleEvent: NAVIGATOR_EXIT", SLOG2_FA_END);
+ LOGI("fgPlatformProcessSingleEvent: NAVIGATOR_EXIT");
/* User closed the application for good, let's kill the window */
{
SFG_Window* window = fgStructure.CurrentWindow;
if (window != NULL) {
fgDestroyWindow(window);
} else {
- LOGI("NAVIGATOR_EXIT: No current window", SLOG2_FA_END);
+ LOGW("NAVIGATOR_EXIT: No current window");
}
}
break;
+
+ case NAVIGATOR_SWIPE_DOWN:
+ case NAVIGATOR_BACK:
+ case NAVIGATOR_WINDOW_ACTIVE:
+ case NAVIGATOR_DEVICE_LOCK_STATE:
+ case NAVIGATOR_WINDOW_COVER:
+ case NAVIGATOR_WINDOW_COVER_ENTER:
+ case NAVIGATOR_WINDOW_COVER_EXIT:
+ //XXX Should probably do something with these
+ break;
+
+ default:
+ LOGW("fgPlatformProcessSingleEvent: unknown navigator event: 0x%X", SLOG2_FA_SIGNED(eventType));
+ break;
}
}
}
void fgPlatformMainLoopPreliminaryWork ( void )
{
- LOGI("fgPlatformMainLoopPreliminaryWork\n", SLOG2_FA_END);
+ LOGI("fgPlatformMainLoopPreliminaryWork");
}