Can use input devices from x11 (serial input... unlikely to ever be used, but you never know) Fixed bug in fg_window_egl:fgPlatformSetWindow where a NULL window may be passed and cause a segfault Fixed bug where navigator events were never started Take into account DisplayMode when creating window buffers Proper fgPlatformSystemTime implementation (from fg_main_x11) Added support for mutlitouch (from fg_main_windows)
This commit is contained in:
parent
b9e26407cb
commit
5ec6164f24
@ -123,7 +123,6 @@ ELSEIF(ANDROID OR BLACKBERRY)
|
|||||||
src/android/fg_cursor_android.c
|
src/android/fg_cursor_android.c
|
||||||
src/android/fg_ext_android.c
|
src/android/fg_ext_android.c
|
||||||
src/android/fg_gamemode_android.c
|
src/android/fg_gamemode_android.c
|
||||||
src/android/fg_input_devices_android.c
|
|
||||||
src/android/fg_joystick_android.c
|
src/android/fg_joystick_android.c
|
||||||
src/android/fg_spaceball_android.c
|
src/android/fg_spaceball_android.c
|
||||||
src/android/fg_structure_android.c
|
src/android/fg_structure_android.c
|
||||||
@ -134,6 +133,7 @@ ELSEIF(ANDROID OR BLACKBERRY)
|
|||||||
src/android/native_app_glue/android_native_app_glue.h
|
src/android/native_app_glue/android_native_app_glue.h
|
||||||
src/android/fg_init_android.c
|
src/android/fg_init_android.c
|
||||||
src/android/fg_internal_android.h
|
src/android/fg_internal_android.h
|
||||||
|
src/android/fg_input_devices_android.c
|
||||||
src/android/fg_main_android.c
|
src/android/fg_main_android.c
|
||||||
src/android/fg_main_android.h
|
src/android/fg_main_android.h
|
||||||
src/android/fg_runtime_android.c
|
src/android/fg_runtime_android.c
|
||||||
@ -144,6 +144,7 @@ ELSEIF(ANDROID OR BLACKBERRY)
|
|||||||
LIST(APPEND FREEGLUT_SRCS
|
LIST(APPEND FREEGLUT_SRCS
|
||||||
src/blackberry/fg_init_blackberry.c
|
src/blackberry/fg_init_blackberry.c
|
||||||
src/blackberry/fg_internal_blackberry.h
|
src/blackberry/fg_internal_blackberry.h
|
||||||
|
src/x11/fg_input_devices_x11.c
|
||||||
src/blackberry/fg_main_blackberry.c
|
src/blackberry/fg_main_blackberry.c
|
||||||
src/blackberry/fg_main_blackberry.h
|
src/blackberry/fg_main_blackberry.h
|
||||||
src/blackberry/fg_state_blackberry.c
|
src/blackberry/fg_state_blackberry.c
|
||||||
|
@ -29,11 +29,15 @@
|
|||||||
#include "fg_init.h"
|
#include "fg_init.h"
|
||||||
#include "egl/fg_init_egl.h"
|
#include "egl/fg_init_egl.h"
|
||||||
#include <bps/bps.h>
|
#include <bps/bps.h>
|
||||||
|
#include <bps/navigator.h>
|
||||||
|
|
||||||
void fgPlatformInitialize()
|
void fgPlatformInitialize()
|
||||||
{
|
{
|
||||||
bps_initialize();
|
bps_initialize();
|
||||||
|
|
||||||
|
navigator_request_events(0);
|
||||||
|
//XXX rotation lock? navigator_rotation_lock(true);
|
||||||
|
|
||||||
fghPlatformInitializeEGL();
|
fghPlatformInitializeEGL();
|
||||||
|
|
||||||
/* Get start time */
|
/* Get start time */
|
||||||
@ -46,6 +50,8 @@ void fgPlatformCloseDisplay()
|
|||||||
{
|
{
|
||||||
fghPlatformCloseDisplayEGL();
|
fghPlatformCloseDisplayEGL();
|
||||||
|
|
||||||
|
navigator_stop_events(0);
|
||||||
|
|
||||||
bps_shutdown();
|
bps_shutdown();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -139,11 +139,18 @@ unsigned char key_ascii(int qnxKeycode)
|
|||||||
return qnxKeycode;
|
return qnxKeycode;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint64_t fgPlatformSystemTime ( void )
|
//From fg_main_x11
|
||||||
|
fg_time_t fgPlatformSystemTime ( void )
|
||||||
{
|
{
|
||||||
|
#ifdef CLOCK_MONOTONIC
|
||||||
struct timespec now;
|
struct timespec now;
|
||||||
clock_gettime(CLOCK_REALTIME, &now);
|
clock_gettime(CLOCK_MONOTONIC, &now);
|
||||||
return (1000 * now.tv_sec) + (now.tv_nsec / 1000000);
|
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
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -276,11 +283,23 @@ void fgPlatformProcessSingleEvent ( void )
|
|||||||
{
|
{
|
||||||
mtouch_event_t touchEvent;
|
mtouch_event_t touchEvent;
|
||||||
screen_get_mtouch_event(screenEvent, &touchEvent, 0);
|
screen_get_mtouch_event(screenEvent, &touchEvent, 0);
|
||||||
if(touchEvent.contact_id == 0) { //XXX Only support one contact for now
|
if(touchEvent.contact_id == 0) {
|
||||||
int size[2];
|
int size[2];
|
||||||
screen_get_window_property_iv(window->Window.Handle, SCREEN_PROPERTY_BUFFER_SIZE, size);
|
screen_get_window_property_iv(window->Window.Handle, SCREEN_PROPERTY_BUFFER_SIZE, size);
|
||||||
handle_left_mouse(touchEvent.x, touchEvent.y, size[1], eventType, window);
|
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;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -290,15 +309,19 @@ void fgPlatformProcessSingleEvent ( void )
|
|||||||
static int mouse_pressed = 0;
|
static int mouse_pressed = 0;
|
||||||
int buttons;
|
int buttons;
|
||||||
int position[2];
|
int position[2];
|
||||||
|
int wheel;
|
||||||
// A move event will be fired unless a button state changed.
|
// A move event will be fired unless a button state changed.
|
||||||
bool move = true;
|
bool move = true;
|
||||||
bool left_move = false;
|
bool left_move = false;
|
||||||
// This is a mouse move event, it is applicable to a device with a usb mouse or simulator.
|
// 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_BUTTONS, &buttons);
|
||||||
screen_get_event_property_iv(screenEvent, SCREEN_PROPERTY_SOURCE_POSITION, position);
|
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];
|
int size[2];
|
||||||
screen_get_window_property_iv(window->Window.Handle, SCREEN_PROPERTY_BUFFER_SIZE, size);
|
screen_get_window_property_iv(window->Window.Handle, SCREEN_PROPERTY_BUFFER_SIZE, size);
|
||||||
|
|
||||||
|
//XXX Should multitouch be handled?
|
||||||
|
|
||||||
// Handle left mouse. Interpret as touch if the left mouse event is not consumed.
|
// Handle left mouse. Interpret as touch if the left mouse event is not consumed.
|
||||||
if (buttons & SCREEN_LEFT_MOUSE_BUTTON) {
|
if (buttons & SCREEN_LEFT_MOUSE_BUTTON) {
|
||||||
if (mouse_pressed & SCREEN_LEFT_MOUSE_BUTTON) {
|
if (mouse_pressed & SCREEN_LEFT_MOUSE_BUTTON) {
|
||||||
@ -344,6 +367,11 @@ void fgPlatformProcessSingleEvent ( void )
|
|||||||
if (left_move || move) {
|
if (left_move || move) {
|
||||||
handle_left_mouse(position[0], position[1], size[1], SCREEN_EVENT_MTOUCH_MOVE, window);
|
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;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -30,7 +30,6 @@
|
|||||||
#include "fg_internal.h"
|
#include "fg_internal.h"
|
||||||
|
|
||||||
extern void fgPlatformProcessSingleEvent(void);
|
extern void fgPlatformProcessSingleEvent(void);
|
||||||
extern uint64_t fgPlatformSystemTime(void);
|
|
||||||
extern void fgPlatformSleepForEvents(uint64_t msec);
|
extern void fgPlatformSleepForEvents(uint64_t msec);
|
||||||
extern void fgPlatformMainLoopPreliminaryWork(void);
|
extern void fgPlatformMainLoopPreliminaryWork(void);
|
||||||
|
|
||||||
|
@ -98,7 +98,7 @@ void fgPlatformOpenWindow( SFG_Window* window, const char* title,
|
|||||||
}*/
|
}*/
|
||||||
|
|
||||||
/* Create window buffers */
|
/* Create window buffers */
|
||||||
if (screen_create_window_buffers(sWindow, 2)) {
|
if (screen_create_window_buffers(sWindow, (fgState.DisplayMode & GLUT_DOUBLE) ? 2 : 1)) {
|
||||||
screen_destroy_window(sWindow);
|
screen_destroy_window(sWindow);
|
||||||
screen_destroy_context(window->Window.pContext.screenContext);
|
screen_destroy_context(window->Window.pContext.screenContext);
|
||||||
fgError("Could not create window buffers");
|
fgError("Could not create window buffers");
|
||||||
|
@ -94,11 +94,13 @@ EGLContext fghCreateNewContextEGL( SFG_Window* window ) {
|
|||||||
|
|
||||||
void fgPlatformSetWindow ( SFG_Window *window )
|
void fgPlatformSetWindow ( SFG_Window *window )
|
||||||
{
|
{
|
||||||
|
if ( window != fgStructure.CurrentWindow && window) {
|
||||||
if (eglMakeCurrent(fgDisplay.pDisplay.egl.Display,
|
if (eglMakeCurrent(fgDisplay.pDisplay.egl.Display,
|
||||||
window->Window.pContext.egl.Surface,
|
window->Window.pContext.egl.Surface,
|
||||||
window->Window.pContext.egl.Surface,
|
window->Window.pContext.egl.Surface,
|
||||||
window->Window.Context) == EGL_FALSE)
|
window->Window.Context) == EGL_FALSE)
|
||||||
fgError("eglMakeCurrent: err=%x\n", eglGetError());
|
fgError("eglMakeCurrent: err=%x\n", eglGetError());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
Reference in New Issue
Block a user