Converted the odd double spaces into 4 space tabs
This commit is contained in:
parent
62fa02baf8
commit
39eb9e3342
@ -33,26 +33,26 @@
|
|||||||
|
|
||||||
void fgPlatformInitialize()
|
void fgPlatformInitialize()
|
||||||
{
|
{
|
||||||
bps_initialize();
|
bps_initialize();
|
||||||
|
|
||||||
navigator_request_events(0);
|
navigator_request_events(0);
|
||||||
//XXX rotation lock? navigator_rotation_lock(true);
|
//XXX rotation lock? navigator_rotation_lock(true);
|
||||||
|
|
||||||
fghPlatformInitializeEGL();
|
fghPlatformInitializeEGL();
|
||||||
|
|
||||||
/* Get start time */
|
/* Get start time */
|
||||||
fgState.Time = fgSystemTime();
|
fgState.Time = fgSystemTime();
|
||||||
|
|
||||||
fgState.Initialised = GL_TRUE;
|
fgState.Initialised = GL_TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
void fgPlatformCloseDisplay()
|
void fgPlatformCloseDisplay()
|
||||||
{
|
{
|
||||||
fghPlatformCloseDisplayEGL();
|
fghPlatformCloseDisplayEGL();
|
||||||
|
|
||||||
navigator_stop_events(0);
|
navigator_stop_events(0);
|
||||||
|
|
||||||
bps_shutdown();
|
bps_shutdown();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -40,17 +40,17 @@
|
|||||||
typedef struct tagSFG_PlatformDisplay SFG_PlatformDisplay;
|
typedef struct tagSFG_PlatformDisplay SFG_PlatformDisplay;
|
||||||
struct tagSFG_PlatformDisplay
|
struct tagSFG_PlatformDisplay
|
||||||
{
|
{
|
||||||
struct tagSFG_PlatformDisplayEGL egl;
|
struct tagSFG_PlatformDisplayEGL egl;
|
||||||
EGLNativeWindowType single_native_window;
|
EGLNativeWindowType single_native_window;
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef struct tagSFG_PlatformContext SFG_PlatformContext;
|
typedef struct tagSFG_PlatformContext SFG_PlatformContext;
|
||||||
/* SFG_PlatformContext is used for SFG_Window.Window */
|
/* SFG_PlatformContext is used for SFG_Window.Window */
|
||||||
struct tagSFG_PlatformContext
|
struct tagSFG_PlatformContext
|
||||||
{
|
{
|
||||||
struct tagSFG_PlatformContextEGL egl;
|
struct tagSFG_PlatformContextEGL egl;
|
||||||
screen_context_t screenContext;
|
screen_context_t screenContext;
|
||||||
bps_event_t* event;
|
bps_event_t* event;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
@ -76,34 +76,34 @@ struct touchscreen {
|
|||||||
* interspersed
|
* interspersed
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* We'll put these values in and that should
|
* We'll put these values in and that should
|
||||||
* allow the code to at least compile when there is
|
* allow the code to at least compile when there is
|
||||||
* no support. The JS open routine should error out
|
* no support. The JS open routine should error out
|
||||||
* and shut off all the code downstream anyway and if
|
* and shut off all the code downstream anyway and if
|
||||||
* the application doesn't use a joystick we'll be fine.
|
* the application doesn't use a joystick we'll be fine.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
struct JS_DATA_TYPE
|
struct JS_DATA_TYPE
|
||||||
{
|
{
|
||||||
int buttons;
|
int buttons;
|
||||||
int x;
|
int x;
|
||||||
int y;
|
int y;
|
||||||
};
|
};
|
||||||
|
|
||||||
# define JS_RETURN (sizeof(struct JS_DATA_TYPE))
|
#define JS_RETURN (sizeof(struct JS_DATA_TYPE))
|
||||||
|
|
||||||
/* XXX It might be better to poll the operating system for the numbers of buttons and
|
/* XXX It might be better to poll the operating system for the numbers of buttons and
|
||||||
* XXX axes and then dynamically allocate the arrays.
|
* XXX axes and then dynamically allocate the arrays.
|
||||||
*/
|
*/
|
||||||
# define _JS_MAX_AXES 16
|
#define _JS_MAX_AXES 16
|
||||||
typedef struct tagSFG_PlatformJoystick SFG_PlatformJoystick;
|
typedef struct tagSFG_PlatformJoystick SFG_PlatformJoystick;
|
||||||
struct tagSFG_PlatformJoystick
|
struct tagSFG_PlatformJoystick
|
||||||
{
|
{
|
||||||
struct JS_DATA_TYPE js;
|
struct JS_DATA_TYPE js;
|
||||||
|
|
||||||
char fname [ 128 ];
|
char fname [ 128 ];
|
||||||
int fd;
|
int fd;
|
||||||
};
|
};
|
||||||
|
|
||||||
/* Window's state description. This structure should be kept portable. */
|
/* Window's state description. This structure should be kept portable. */
|
||||||
|
@ -56,87 +56,87 @@ static struct touchscreen touchscreen;
|
|||||||
|
|
||||||
unsigned int key_special(int qnxKeycode)
|
unsigned int key_special(int qnxKeycode)
|
||||||
{
|
{
|
||||||
switch(qnxKeycode) {
|
switch(qnxKeycode) {
|
||||||
case KEYCODE_F1:
|
case KEYCODE_F1:
|
||||||
return GLUT_KEY_F1;
|
return GLUT_KEY_F1;
|
||||||
case KEYCODE_F2:
|
case KEYCODE_F2:
|
||||||
return GLUT_KEY_F2;
|
return GLUT_KEY_F2;
|
||||||
case KEYCODE_F3:
|
case KEYCODE_F3:
|
||||||
return GLUT_KEY_F3;
|
return GLUT_KEY_F3;
|
||||||
case KEYCODE_F4:
|
case KEYCODE_F4:
|
||||||
return GLUT_KEY_F4;
|
return GLUT_KEY_F4;
|
||||||
case KEYCODE_F5:
|
case KEYCODE_F5:
|
||||||
return GLUT_KEY_F5;
|
return GLUT_KEY_F5;
|
||||||
case KEYCODE_F6:
|
case KEYCODE_F6:
|
||||||
return GLUT_KEY_F6;
|
return GLUT_KEY_F6;
|
||||||
case KEYCODE_F7:
|
case KEYCODE_F7:
|
||||||
return GLUT_KEY_F7;
|
return GLUT_KEY_F7;
|
||||||
case KEYCODE_F8:
|
case KEYCODE_F8:
|
||||||
return GLUT_KEY_F8;
|
return GLUT_KEY_F8;
|
||||||
case KEYCODE_F9:
|
case KEYCODE_F9:
|
||||||
return GLUT_KEY_F9;
|
return GLUT_KEY_F9;
|
||||||
case KEYCODE_F10:
|
case KEYCODE_F10:
|
||||||
return GLUT_KEY_F10;
|
return GLUT_KEY_F10;
|
||||||
case KEYCODE_F11:
|
case KEYCODE_F11:
|
||||||
return GLUT_KEY_F11;
|
return GLUT_KEY_F11;
|
||||||
case KEYCODE_F12:
|
case KEYCODE_F12:
|
||||||
return GLUT_KEY_F12;
|
return GLUT_KEY_F12;
|
||||||
case KEYCODE_PG_UP:
|
case KEYCODE_PG_UP:
|
||||||
return GLUT_KEY_PAGE_UP;
|
return GLUT_KEY_PAGE_UP;
|
||||||
case KEYCODE_PG_DOWN:
|
case KEYCODE_PG_DOWN:
|
||||||
return GLUT_KEY_PAGE_DOWN;
|
return GLUT_KEY_PAGE_DOWN;
|
||||||
case KEYCODE_HOME:
|
case KEYCODE_HOME:
|
||||||
return GLUT_KEY_HOME;
|
return GLUT_KEY_HOME;
|
||||||
case KEYCODE_END:
|
case KEYCODE_END:
|
||||||
return GLUT_KEY_END;
|
return GLUT_KEY_END;
|
||||||
case KEYCODE_INSERT:
|
case KEYCODE_INSERT:
|
||||||
return GLUT_KEY_INSERT;
|
return GLUT_KEY_INSERT;
|
||||||
case KEYCODE_UP:
|
case KEYCODE_UP:
|
||||||
//case KEYCODE_KP_UP:
|
//case KEYCODE_KP_UP:
|
||||||
return GLUT_KEY_UP;
|
return GLUT_KEY_UP;
|
||||||
case KEYCODE_DOWN:
|
case KEYCODE_DOWN:
|
||||||
//case KEYCODE_KP_DOWN:
|
//case KEYCODE_KP_DOWN:
|
||||||
return GLUT_KEY_DOWN;
|
return GLUT_KEY_DOWN;
|
||||||
case KEYCODE_LEFT:
|
case KEYCODE_LEFT:
|
||||||
//case KEYCODE_KP_LEFT:
|
//case KEYCODE_KP_LEFT:
|
||||||
return GLUT_KEY_LEFT;
|
return GLUT_KEY_LEFT;
|
||||||
case KEYCODE_RIGHT:
|
case KEYCODE_RIGHT:
|
||||||
//case KEYCODE_KP_RIGHT:
|
//case KEYCODE_KP_RIGHT:
|
||||||
return GLUT_KEY_RIGHT;
|
return GLUT_KEY_RIGHT;
|
||||||
case KEYCODE_NUM_LOCK:
|
case KEYCODE_NUM_LOCK:
|
||||||
return GLUT_KEY_NUM_LOCK;
|
return GLUT_KEY_NUM_LOCK;
|
||||||
case KEYCODE_LEFT_ALT:
|
case KEYCODE_LEFT_ALT:
|
||||||
return GLUT_KEY_ALT_L;
|
return GLUT_KEY_ALT_L;
|
||||||
case KEYCODE_RIGHT_ALT:
|
case KEYCODE_RIGHT_ALT:
|
||||||
return GLUT_KEY_ALT_R;
|
return GLUT_KEY_ALT_R;
|
||||||
case KEYCODE_LEFT_SHIFT:
|
case KEYCODE_LEFT_SHIFT:
|
||||||
return GLUT_KEY_SHIFT_L;
|
return GLUT_KEY_SHIFT_L;
|
||||||
case KEYCODE_RIGHT_SHIFT:
|
case KEYCODE_RIGHT_SHIFT:
|
||||||
return GLUT_KEY_SHIFT_R;
|
return GLUT_KEY_SHIFT_R;
|
||||||
case KEYCODE_LEFT_CTRL:
|
case KEYCODE_LEFT_CTRL:
|
||||||
return GLUT_KEY_CTRL_L;
|
return GLUT_KEY_CTRL_L;
|
||||||
case KEYCODE_RIGHT_CTRL:
|
case KEYCODE_RIGHT_CTRL:
|
||||||
return GLUT_KEY_CTRL_R;
|
return GLUT_KEY_CTRL_R;
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned char key_ascii(int qnxKeycode)
|
unsigned char key_ascii(int qnxKeycode)
|
||||||
{
|
{
|
||||||
if (qnxKeycode >= KEYCODE_PC_KEYS && qnxKeycode <= UNICODE_PRIVATE_USE_AREA_LAST) {
|
if (qnxKeycode >= KEYCODE_PC_KEYS && qnxKeycode <= UNICODE_PRIVATE_USE_AREA_LAST) {
|
||||||
switch (qnxKeycode) {
|
switch (qnxKeycode) {
|
||||||
case KEYCODE_BACKSPACE:
|
case KEYCODE_BACKSPACE:
|
||||||
return 0x0008;
|
return 0x0008;
|
||||||
case KEYCODE_TAB:
|
case KEYCODE_TAB:
|
||||||
return 0x0009;
|
return 0x0009;
|
||||||
case KEYCODE_KP_ENTER:
|
case KEYCODE_KP_ENTER:
|
||||||
case KEYCODE_RETURN:
|
case KEYCODE_RETURN:
|
||||||
return 0x000A;
|
return 0x000A;
|
||||||
case KEYCODE_ESCAPE:
|
case KEYCODE_ESCAPE:
|
||||||
return 0x001B;
|
return 0x001B;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return qnxKeycode;
|
return qnxKeycode;
|
||||||
}
|
}
|
||||||
|
|
||||||
//From fg_main_x11
|
//From fg_main_x11
|
||||||
@ -159,326 +159,326 @@ fg_time_t fgPlatformSystemTime ( void )
|
|||||||
*/
|
*/
|
||||||
void fgPlatformSleepForEvents( fg_time_t msec )
|
void fgPlatformSleepForEvents( fg_time_t msec )
|
||||||
{
|
{
|
||||||
//XXX: Is this right? Is there a more direct way to access the context?
|
//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) {
|
if(bps_get_event(&fgStructure.CurrentWindow->Window.pContext.event, (int)msec) != BPS_SUCCESS) {
|
||||||
LOGW("BPS couldn't get event");
|
LOGW("BPS couldn't get event");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void handle_left_mouse(int x, int y, int height, int eventType, SFG_Window* window)
|
void handle_left_mouse(int x, int y, int height, int eventType, SFG_Window* window)
|
||||||
{
|
{
|
||||||
bool handled = false;
|
bool handled = false;
|
||||||
/* Virtual arrows PAD */
|
/* Virtual arrows PAD */
|
||||||
/* Don't interfere with existing mouse move event */
|
/* Don't interfere with existing mouse move event */
|
||||||
if (!touchscreen.in_mmotion) {
|
if (!touchscreen.in_mmotion) {
|
||||||
struct vpad_state prev_vpad = touchscreen.vpad;
|
struct vpad_state prev_vpad = touchscreen.vpad;
|
||||||
touchscreen.vpad.left = touchscreen.vpad.right = touchscreen.vpad.up = touchscreen.vpad.down = false;
|
touchscreen.vpad.left = touchscreen.vpad.right = touchscreen.vpad.up = touchscreen.vpad.down = false;
|
||||||
|
|
||||||
if (eventType == SCREEN_EVENT_MTOUCH_TOUCH || eventType == SCREEN_EVENT_MTOUCH_MOVE) {
|
if (eventType == SCREEN_EVENT_MTOUCH_TOUCH || eventType == SCREEN_EVENT_MTOUCH_MOVE) {
|
||||||
if ((x > 0 && x < 100) && (y > (height - 100) && y < height))
|
if ((x > 0 && x < 100) && (y > (height - 100) && y < height))
|
||||||
{
|
{
|
||||||
touchscreen.vpad.left = true;
|
touchscreen.vpad.left = true;
|
||||||
}
|
}
|
||||||
if ((x > 200 && x < 300) && (y > (height - 100) && y < height))
|
if ((x > 200 && x < 300) && (y > (height - 100) && y < height))
|
||||||
{
|
{
|
||||||
touchscreen.vpad.right = true;
|
touchscreen.vpad.right = true;
|
||||||
}
|
}
|
||||||
if ((x > 100 && x < 200) && (y > (height - 100) && y < height))
|
if ((x > 100 && x < 200) && (y > (height - 100) && y < height))
|
||||||
{
|
{
|
||||||
touchscreen.vpad.down = true;
|
touchscreen.vpad.down = true;
|
||||||
}
|
}
|
||||||
if ((x > 100 && x < 200) && (y > (height - 200) && y < (height - 100)))
|
if ((x > 100 && x < 200) && (y > (height - 200) && y < (height - 100)))
|
||||||
{
|
{
|
||||||
touchscreen.vpad.up = true;
|
touchscreen.vpad.up = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (eventType == SCREEN_EVENT_MTOUCH_TOUCH &&
|
if (eventType == SCREEN_EVENT_MTOUCH_TOUCH &&
|
||||||
(touchscreen.vpad.left || touchscreen.vpad.right || touchscreen.vpad.down || touchscreen.vpad.up)) {
|
(touchscreen.vpad.left || touchscreen.vpad.right || touchscreen.vpad.down || touchscreen.vpad.up)) {
|
||||||
touchscreen.vpad.on = true;
|
touchscreen.vpad.on = true;
|
||||||
}
|
}
|
||||||
if (eventType == SCREEN_EVENT_MTOUCH_RELEASE) {
|
if (eventType == SCREEN_EVENT_MTOUCH_RELEASE) {
|
||||||
touchscreen.vpad.on = false;
|
touchscreen.vpad.on = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (prev_vpad.left != touchscreen.vpad.left
|
if (prev_vpad.left != touchscreen.vpad.left
|
||||||
|| prev_vpad.right != touchscreen.vpad.right
|
|| prev_vpad.right != touchscreen.vpad.right
|
||||||
|| prev_vpad.up != touchscreen.vpad.up
|
|| prev_vpad.up != touchscreen.vpad.up
|
||||||
|| prev_vpad.down != touchscreen.vpad.down
|
|| prev_vpad.down != touchscreen.vpad.down
|
||||||
|| prev_vpad.on != touchscreen.vpad.on) {
|
|| prev_vpad.on != touchscreen.vpad.on) {
|
||||||
if (FETCH_WCB(*window, Special)) {
|
if (FETCH_WCB(*window, Special)) {
|
||||||
if (prev_vpad.left == false && touchscreen.vpad.left == true) {
|
if (prev_vpad.left == false && touchscreen.vpad.left == true) {
|
||||||
INVOKE_WCB(*window, Special, (GLUT_KEY_LEFT, x, y));
|
INVOKE_WCB(*window, Special, (GLUT_KEY_LEFT, x, y));
|
||||||
}
|
}
|
||||||
else if (prev_vpad.right == false && touchscreen.vpad.right == true) {
|
else if (prev_vpad.right == false && touchscreen.vpad.right == true) {
|
||||||
INVOKE_WCB(*window, Special, (GLUT_KEY_RIGHT, x, y));
|
INVOKE_WCB(*window, Special, (GLUT_KEY_RIGHT, x, y));
|
||||||
}
|
}
|
||||||
else if (prev_vpad.up == false && touchscreen.vpad.up == true) {
|
else if (prev_vpad.up == false && touchscreen.vpad.up == true) {
|
||||||
INVOKE_WCB(*window, Special, (GLUT_KEY_UP, x, y));
|
INVOKE_WCB(*window, Special, (GLUT_KEY_UP, x, y));
|
||||||
}
|
}
|
||||||
else if (prev_vpad.down == false && touchscreen.vpad.down == true) {
|
else if (prev_vpad.down == false && touchscreen.vpad.down == true) {
|
||||||
INVOKE_WCB(*window, Special, (GLUT_KEY_DOWN, x, y));
|
INVOKE_WCB(*window, Special, (GLUT_KEY_DOWN, x, y));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (FETCH_WCB(*window, SpecialUp)) {
|
if (FETCH_WCB(*window, SpecialUp)) {
|
||||||
if (prev_vpad.left == true && touchscreen.vpad.left == false) {
|
if (prev_vpad.left == true && touchscreen.vpad.left == false) {
|
||||||
INVOKE_WCB(*window, SpecialUp, (GLUT_KEY_LEFT, x, y));
|
INVOKE_WCB(*window, SpecialUp, (GLUT_KEY_LEFT, x, y));
|
||||||
}
|
}
|
||||||
if (prev_vpad.right == true && touchscreen.vpad.right == false) {
|
if (prev_vpad.right == true && touchscreen.vpad.right == false) {
|
||||||
INVOKE_WCB(*window, SpecialUp, (GLUT_KEY_RIGHT, x, y));
|
INVOKE_WCB(*window, SpecialUp, (GLUT_KEY_RIGHT, x, y));
|
||||||
}
|
}
|
||||||
if (prev_vpad.up == true && touchscreen.vpad.up == false) {
|
if (prev_vpad.up == true && touchscreen.vpad.up == false) {
|
||||||
INVOKE_WCB(*window, SpecialUp, (GLUT_KEY_UP, x, y));
|
INVOKE_WCB(*window, SpecialUp, (GLUT_KEY_UP, x, y));
|
||||||
}
|
}
|
||||||
if (prev_vpad.down == true && touchscreen.vpad.down == false) {
|
if (prev_vpad.down == true && touchscreen.vpad.down == false) {
|
||||||
INVOKE_WCB(*window, SpecialUp, (GLUT_KEY_DOWN, x, y));
|
INVOKE_WCB(*window, SpecialUp, (GLUT_KEY_DOWN, x, y));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
handled = true;
|
handled = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Normal mouse events */
|
/* Normal mouse events */
|
||||||
if (!handled && !touchscreen.vpad.on) {
|
if (!handled && !touchscreen.vpad.on) {
|
||||||
window->State.MouseX = x;
|
window->State.MouseX = x;
|
||||||
window->State.MouseY = y;
|
window->State.MouseY = y;
|
||||||
|
|
||||||
if(eventType == SCREEN_EVENT_MTOUCH_MOVE) {
|
if(eventType == SCREEN_EVENT_MTOUCH_MOVE) {
|
||||||
INVOKE_WCB(*window, Motion, (x, y));
|
INVOKE_WCB(*window, Motion, (x, y));
|
||||||
} else if(FETCH_WCB(*window, Mouse)) {
|
} else if(FETCH_WCB(*window, Mouse)) {
|
||||||
touchscreen.in_mmotion = eventType == SCREEN_EVENT_MTOUCH_TOUCH;
|
touchscreen.in_mmotion = eventType == SCREEN_EVENT_MTOUCH_TOUCH;
|
||||||
int glutTouchType = eventType == SCREEN_EVENT_MTOUCH_TOUCH ? GLUT_DOWN : GLUT_UP;
|
int glutTouchType = eventType == SCREEN_EVENT_MTOUCH_TOUCH ? GLUT_DOWN : GLUT_UP;
|
||||||
INVOKE_WCB(*window, Mouse, (GLUT_LEFT_BUTTON, glutTouchType, x, y));
|
INVOKE_WCB(*window, Mouse, (GLUT_LEFT_BUTTON, glutTouchType, x, y));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void fgPlatformProcessSingleEvent ( void )
|
void fgPlatformProcessSingleEvent ( void )
|
||||||
{
|
{
|
||||||
int domain;
|
int domain;
|
||||||
bps_event_t** eventPtr = &fgStructure.CurrentWindow->Window.pContext.event; //XXX Is there a more direct way to access the context?
|
bps_event_t** eventPtr = &fgStructure.CurrentWindow->Window.pContext.event; //XXX Is there a more direct way to access the context?
|
||||||
bps_event_t* event;
|
bps_event_t* event;
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
if(*eventPtr != NULL) {
|
if(*eventPtr != NULL) {
|
||||||
SFG_Window* window = fgStructure.CurrentWindow;
|
SFG_Window* window = fgStructure.CurrentWindow;
|
||||||
if (window != NULL && window->Window.Handle != NULL) {
|
if (window != NULL && window->Window.Handle != NULL) {
|
||||||
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);
|
||||||
fghOnReshapeNotify(window,size[0],size[1],GL_FALSE);
|
fghOnReshapeNotify(window,size[0],size[1],GL_FALSE);
|
||||||
}
|
}
|
||||||
|
|
||||||
event = *eventPtr;
|
event = *eventPtr;
|
||||||
domain = bps_event_get_domain(event);
|
domain = bps_event_get_domain(event);
|
||||||
if (domain == screen_get_domain()) {
|
if (domain == screen_get_domain()) {
|
||||||
int eventType;
|
int eventType;
|
||||||
screen_event_t screenEvent = screen_event_get_event(event);
|
screen_event_t screenEvent = screen_event_get_event(event);
|
||||||
screen_get_event_property_iv(screenEvent, SCREEN_PROPERTY_TYPE, &eventType);
|
screen_get_event_property_iv(screenEvent, SCREEN_PROPERTY_TYPE, &eventType);
|
||||||
switch (eventType) {
|
switch (eventType) {
|
||||||
|
|
||||||
//Mostly from fg_main_android
|
//Mostly from fg_main_android
|
||||||
case SCREEN_EVENT_MTOUCH_TOUCH:
|
case SCREEN_EVENT_MTOUCH_TOUCH:
|
||||||
case SCREEN_EVENT_MTOUCH_RELEASE:
|
case SCREEN_EVENT_MTOUCH_RELEASE:
|
||||||
case SCREEN_EVENT_MTOUCH_MOVE:
|
case SCREEN_EVENT_MTOUCH_MOVE:
|
||||||
{
|
{
|
||||||
mtouch_event_t touchEvent;
|
mtouch_event_t touchEvent;
|
||||||
screen_get_mtouch_event(screenEvent, &touchEvent, 0);
|
screen_get_mtouch_event(screenEvent, &touchEvent, 0);
|
||||||
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));
|
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) {
|
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)
|
//Now handle mutlitouch (adapted from fg_main_windows)
|
||||||
if (eventType == SCREEN_EVENT_MTOUCH_TOUCH) {
|
if (eventType == SCREEN_EVENT_MTOUCH_TOUCH) {
|
||||||
INVOKE_WCB( *window, MultiEntry, ( touchEvent.contact_id, GLUT_ENTERED ) );
|
INVOKE_WCB( *window, MultiEntry, ( touchEvent.contact_id, GLUT_ENTERED ) );
|
||||||
INVOKE_WCB( *window, MultiButton, ( touchEvent.contact_id, touchEvent.x, touchEvent.y, 0, GLUT_DOWN ) );
|
INVOKE_WCB( *window, MultiButton, ( touchEvent.contact_id, touchEvent.x, touchEvent.y, 0, GLUT_DOWN ) );
|
||||||
} else if (eventType == SCREEN_EVENT_MTOUCH_MOVE) {
|
} else if (eventType == SCREEN_EVENT_MTOUCH_MOVE) {
|
||||||
INVOKE_WCB( *window, MultiMotion, ( touchEvent.contact_id, touchEvent.x, touchEvent.y ) );
|
INVOKE_WCB( *window, MultiMotion, ( touchEvent.contact_id, touchEvent.x, touchEvent.y ) );
|
||||||
//XXX No motion is performed without contact, thus MultiPassive is never used
|
//XXX No motion is performed without contact, thus MultiPassive is never used
|
||||||
} else if (eventType == SCREEN_EVENT_MTOUCH_RELEASE) {
|
} else if (eventType == SCREEN_EVENT_MTOUCH_RELEASE) {
|
||||||
INVOKE_WCB( *window, MultiButton, ( touchEvent.contact_id, touchEvent.x, touchEvent.y, 0, GLUT_UP ) );
|
INVOKE_WCB( *window, MultiButton, ( touchEvent.contact_id, touchEvent.x, touchEvent.y, 0, GLUT_UP ) );
|
||||||
INVOKE_WCB( *window, MultiEntry, ( touchEvent.contact_id, GLUT_LEFT ) );
|
INVOKE_WCB( *window, MultiEntry, ( touchEvent.contact_id, GLUT_LEFT ) );
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
case SCREEN_EVENT_POINTER:
|
case SCREEN_EVENT_POINTER:
|
||||||
{
|
{
|
||||||
//Based off/part taken from GamePlay3d PlatformBlackBerry
|
//Based off/part taken from GamePlay3d PlatformBlackBerry
|
||||||
static int mouse_pressed = 0;
|
static int mouse_pressed = 0;
|
||||||
int buttons;
|
int buttons;
|
||||||
int position[2];
|
int position[2];
|
||||||
int wheel;
|
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);
|
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);
|
||||||
|
|
||||||
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));
|
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?
|
//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) {
|
||||||
left_move = true;
|
left_move = true;
|
||||||
} else {
|
} else {
|
||||||
move = false;
|
move = false;
|
||||||
mouse_pressed |= SCREEN_LEFT_MOUSE_BUTTON;
|
mouse_pressed |= SCREEN_LEFT_MOUSE_BUTTON;
|
||||||
handle_left_mouse(position[0], position[1], size[1], SCREEN_EVENT_MTOUCH_TOUCH, window);
|
handle_left_mouse(position[0], position[1], size[1], SCREEN_EVENT_MTOUCH_TOUCH, window);
|
||||||
}
|
}
|
||||||
} else if (mouse_pressed & SCREEN_LEFT_MOUSE_BUTTON) {
|
} else if (mouse_pressed & SCREEN_LEFT_MOUSE_BUTTON) {
|
||||||
move = false;
|
move = false;
|
||||||
mouse_pressed &= ~SCREEN_LEFT_MOUSE_BUTTON;
|
mouse_pressed &= ~SCREEN_LEFT_MOUSE_BUTTON;
|
||||||
handle_left_mouse(position[0], position[1], size[1], SCREEN_EVENT_MTOUCH_RELEASE, window);
|
handle_left_mouse(position[0], position[1], size[1], SCREEN_EVENT_MTOUCH_RELEASE, window);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Handle right mouse.
|
// Handle right mouse.
|
||||||
if (buttons & SCREEN_RIGHT_MOUSE_BUTTON) {
|
if (buttons & SCREEN_RIGHT_MOUSE_BUTTON) {
|
||||||
if ((mouse_pressed & SCREEN_RIGHT_MOUSE_BUTTON) == 0) {
|
if ((mouse_pressed & SCREEN_RIGHT_MOUSE_BUTTON) == 0) {
|
||||||
move = false;
|
move = false;
|
||||||
mouse_pressed |= SCREEN_RIGHT_MOUSE_BUTTON;
|
mouse_pressed |= SCREEN_RIGHT_MOUSE_BUTTON;
|
||||||
INVOKE_WCB(*window, Mouse, (GLUT_RIGHT_BUTTON, GLUT_DOWN, position[0], position[1]));
|
INVOKE_WCB(*window, Mouse, (GLUT_RIGHT_BUTTON, GLUT_DOWN, position[0], position[1]));
|
||||||
}
|
}
|
||||||
} else if (mouse_pressed & SCREEN_RIGHT_MOUSE_BUTTON) {
|
} else if (mouse_pressed & SCREEN_RIGHT_MOUSE_BUTTON) {
|
||||||
move = false;
|
move = false;
|
||||||
mouse_pressed &= ~SCREEN_RIGHT_MOUSE_BUTTON;
|
mouse_pressed &= ~SCREEN_RIGHT_MOUSE_BUTTON;
|
||||||
INVOKE_WCB(*window, Mouse, (GLUT_RIGHT_BUTTON, GLUT_UP, position[0], position[1]));
|
INVOKE_WCB(*window, Mouse, (GLUT_RIGHT_BUTTON, GLUT_UP, position[0], position[1]));
|
||||||
}
|
}
|
||||||
|
|
||||||
// Handle middle mouse.
|
// Handle middle mouse.
|
||||||
if (buttons & SCREEN_MIDDLE_MOUSE_BUTTON) {
|
if (buttons & SCREEN_MIDDLE_MOUSE_BUTTON) {
|
||||||
if ((mouse_pressed & SCREEN_MIDDLE_MOUSE_BUTTON) == 0) {
|
if ((mouse_pressed & SCREEN_MIDDLE_MOUSE_BUTTON) == 0) {
|
||||||
move = false;
|
move = false;
|
||||||
mouse_pressed |= SCREEN_MIDDLE_MOUSE_BUTTON;
|
mouse_pressed |= SCREEN_MIDDLE_MOUSE_BUTTON;
|
||||||
INVOKE_WCB(*window, Mouse, (GLUT_MIDDLE_BUTTON, GLUT_DOWN, position[0], position[1]));
|
INVOKE_WCB(*window, Mouse, (GLUT_MIDDLE_BUTTON, GLUT_DOWN, position[0], position[1]));
|
||||||
}
|
}
|
||||||
} else if (mouse_pressed & SCREEN_MIDDLE_MOUSE_BUTTON) {
|
} else if (mouse_pressed & SCREEN_MIDDLE_MOUSE_BUTTON) {
|
||||||
move = false;
|
move = false;
|
||||||
mouse_pressed &= ~SCREEN_MIDDLE_MOUSE_BUTTON;
|
mouse_pressed &= ~SCREEN_MIDDLE_MOUSE_BUTTON;
|
||||||
INVOKE_WCB(*window, Mouse, (GLUT_MIDDLE_BUTTON, GLUT_UP, position[0], position[1]));
|
INVOKE_WCB(*window, Mouse, (GLUT_MIDDLE_BUTTON, GLUT_UP, position[0], position[1]));
|
||||||
}
|
}
|
||||||
|
|
||||||
// Fire a move event if none of the buttons changed.
|
// Fire a move event if none of the buttons changed.
|
||||||
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) {
|
if (wheel) {
|
||||||
fgState.MouseWheelTicks -= wheel;
|
fgState.MouseWheelTicks -= wheel;
|
||||||
//TODO: Implement wheel support (based on fg_main_mswin... though it seems excessive)
|
//TODO: Implement wheel support (based on fg_main_mswin... though it seems excessive)
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
//Based off fg_main_android
|
//Based off fg_main_android
|
||||||
case SCREEN_EVENT_KEYBOARD:
|
case SCREEN_EVENT_KEYBOARD:
|
||||||
{
|
{
|
||||||
int flags;
|
int flags;
|
||||||
int value;
|
int value;
|
||||||
screen_get_event_property_iv(screenEvent, SCREEN_PROPERTY_KEY_FLAGS, &flags);
|
screen_get_event_property_iv(screenEvent, SCREEN_PROPERTY_KEY_FLAGS, &flags);
|
||||||
screen_get_event_property_iv(screenEvent, SCREEN_PROPERTY_KEY_SYM, &value);
|
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));
|
LOGI("fgPlatformProcessSingleEvent: SCREEN_EVENT_KEYBOARD. Flags: 0x%X, Sym: 0x%X", SLOG2_FA_SIGNED(flags), SLOG2_FA_SIGNED(value));
|
||||||
// Suppress key repeats if desired
|
// Suppress key repeats if desired
|
||||||
if ((flags & KEY_REPEAT) == 0 || (fgState.KeyRepeat == GLUT_KEY_REPEAT_ON && !fgStructure.CurrentWindow->State.IgnoreKeyRepeat)) {
|
if ((flags & KEY_REPEAT) == 0 || (fgState.KeyRepeat == GLUT_KEY_REPEAT_ON && !fgStructure.CurrentWindow->State.IgnoreKeyRepeat)) {
|
||||||
unsigned int keypress = 0;
|
unsigned int keypress = 0;
|
||||||
unsigned char ascii = 0;
|
unsigned char ascii = 0;
|
||||||
if ((keypress = key_special(value))) {
|
if ((keypress = key_special(value))) {
|
||||||
if(flags & KEY_DOWN) {
|
if(flags & KEY_DOWN) {
|
||||||
INVOKE_WCB(*window, Special, (keypress, window->State.MouseX, window->State.MouseY));
|
INVOKE_WCB(*window, Special, (keypress, window->State.MouseX, window->State.MouseY));
|
||||||
} else {
|
} else {
|
||||||
INVOKE_WCB(*window, SpecialUp, (keypress, window->State.MouseX, window->State.MouseY));
|
INVOKE_WCB(*window, SpecialUp, (keypress, window->State.MouseX, window->State.MouseY));
|
||||||
}
|
}
|
||||||
} else if((flags & KEY_SYM_VALID) && (ascii = key_ascii(value))) {
|
} else if((flags & KEY_SYM_VALID) && (ascii = key_ascii(value))) {
|
||||||
if(flags & KEY_DOWN) {
|
if(flags & KEY_DOWN) {
|
||||||
INVOKE_WCB(*window, Keyboard, (ascii, window->State.MouseX, window->State.MouseY));
|
INVOKE_WCB(*window, Keyboard, (ascii, window->State.MouseX, window->State.MouseY));
|
||||||
} else {
|
} else {
|
||||||
INVOKE_WCB(*window, KeyboardUp, (ascii, window->State.MouseX, window->State.MouseY));
|
INVOKE_WCB(*window, KeyboardUp, (ascii, window->State.MouseX, window->State.MouseY));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
case SCREEN_EVENT_PROPERTY:
|
case SCREEN_EVENT_PROPERTY:
|
||||||
case SCREEN_EVENT_IDLE:
|
case SCREEN_EVENT_IDLE:
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
LOGW("fgPlatformProcessSingleEvent: unknown screen event: 0x%X", SLOG2_FA_SIGNED(eventType));
|
LOGW("fgPlatformProcessSingleEvent: unknown screen event: 0x%X", SLOG2_FA_SIGNED(eventType));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
} else if (domain == navigator_get_domain()) {
|
} else if (domain == navigator_get_domain()) {
|
||||||
int eventType = bps_event_get_code(event);
|
int eventType = bps_event_get_code(event);
|
||||||
switch (eventType) {
|
switch (eventType) {
|
||||||
|
|
||||||
case NAVIGATOR_WINDOW_STATE:
|
case NAVIGATOR_WINDOW_STATE:
|
||||||
{
|
{
|
||||||
LOGI("fgPlatformProcessSingleEvent: NAVIGATOR_WINDOW_STATE");
|
LOGI("fgPlatformProcessSingleEvent: NAVIGATOR_WINDOW_STATE");
|
||||||
navigator_window_state_t state = navigator_event_get_window_state(event);
|
navigator_window_state_t state = navigator_event_get_window_state(event);
|
||||||
switch (state)
|
switch (state)
|
||||||
{
|
{
|
||||||
case NAVIGATOR_WINDOW_FULLSCREEN:
|
case NAVIGATOR_WINDOW_FULLSCREEN:
|
||||||
LOGI("fgPlatformProcessSingleEvent: NAVIGATOR_WINDOW_STATE-NAVIGATOR_WINDOW_FULLSCREEN");
|
LOGI("fgPlatformProcessSingleEvent: NAVIGATOR_WINDOW_STATE-NAVIGATOR_WINDOW_FULLSCREEN");
|
||||||
INVOKE_WCB(*window, AppStatus, (GLUT_APPSTATUS_RESUME));
|
INVOKE_WCB(*window, AppStatus, (GLUT_APPSTATUS_RESUME));
|
||||||
break;
|
break;
|
||||||
case NAVIGATOR_WINDOW_THUMBNAIL:
|
case NAVIGATOR_WINDOW_THUMBNAIL:
|
||||||
case NAVIGATOR_WINDOW_INVISIBLE:
|
case NAVIGATOR_WINDOW_INVISIBLE:
|
||||||
LOGI("fgPlatformProcessSingleEvent: NAVIGATOR_WINDOW_STATE-NAVIGATOR_WINDOW_THUMBNAIL/NAVIGATOR_WINDOW_INVISIBLE");
|
LOGI("fgPlatformProcessSingleEvent: NAVIGATOR_WINDOW_STATE-NAVIGATOR_WINDOW_THUMBNAIL/NAVIGATOR_WINDOW_INVISIBLE");
|
||||||
INVOKE_WCB(*window, AppStatus, (GLUT_APPSTATUS_PAUSE));
|
INVOKE_WCB(*window, AppStatus, (GLUT_APPSTATUS_PAUSE));
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
LOGW("fgPlatformProcessSingleEvent: NAVIGATOR_WINDOW_STATE unknown: 0x%X", SLOG2_FA_SIGNED(state));
|
LOGW("fgPlatformProcessSingleEvent: NAVIGATOR_WINDOW_STATE unknown: 0x%X", SLOG2_FA_SIGNED(state));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
case NAVIGATOR_EXIT:
|
case NAVIGATOR_EXIT:
|
||||||
LOGI("fgPlatformProcessSingleEvent: NAVIGATOR_EXIT");
|
{
|
||||||
/* User closed the application for good, let's kill the window */
|
LOGI("fgPlatformProcessSingleEvent: NAVIGATOR_EXIT");
|
||||||
{
|
/* User closed the application for good, let's kill the window */
|
||||||
SFG_Window* window = fgStructure.CurrentWindow;
|
SFG_Window* window = fgStructure.CurrentWindow;
|
||||||
if (window != NULL) {
|
if (window != NULL) {
|
||||||
fgDestroyWindow(window);
|
fgDestroyWindow(window);
|
||||||
} else {
|
} else {
|
||||||
LOGW("NAVIGATOR_EXIT: No current window");
|
LOGW("NAVIGATOR_EXIT: No current window");
|
||||||
}
|
}
|
||||||
}
|
break;
|
||||||
break;
|
}
|
||||||
|
|
||||||
case NAVIGATOR_SWIPE_DOWN:
|
case NAVIGATOR_SWIPE_DOWN:
|
||||||
case NAVIGATOR_BACK:
|
case NAVIGATOR_BACK:
|
||||||
case NAVIGATOR_WINDOW_ACTIVE:
|
case NAVIGATOR_WINDOW_ACTIVE:
|
||||||
case NAVIGATOR_DEVICE_LOCK_STATE:
|
case NAVIGATOR_DEVICE_LOCK_STATE:
|
||||||
case NAVIGATOR_WINDOW_COVER:
|
case NAVIGATOR_WINDOW_COVER:
|
||||||
case NAVIGATOR_WINDOW_COVER_ENTER:
|
case NAVIGATOR_WINDOW_COVER_ENTER:
|
||||||
case NAVIGATOR_WINDOW_COVER_EXIT:
|
case NAVIGATOR_WINDOW_COVER_EXIT:
|
||||||
//XXX Should probably do something with these
|
//XXX Should probably do something with these
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
LOGW("fgPlatformProcessSingleEvent: unknown navigator event: 0x%X", SLOG2_FA_SIGNED(eventType));
|
LOGW("fgPlatformProcessSingleEvent: unknown navigator event: 0x%X", SLOG2_FA_SIGNED(eventType));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} while(bps_get_event(eventPtr, 1) == BPS_SUCCESS && *eventPtr != NULL);
|
} while(bps_get_event(eventPtr, 1) == BPS_SUCCESS && *eventPtr != NULL);
|
||||||
|
|
||||||
/* Reset event to reduce chances of triggering something */
|
/* Reset event to reduce chances of triggering something */
|
||||||
*eventPtr = NULL;
|
*eventPtr = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
void fgPlatformMainLoopPreliminaryWork ( void )
|
void fgPlatformMainLoopPreliminaryWork ( void )
|
||||||
{
|
{
|
||||||
LOGI("fgPlatformMainLoopPreliminaryWork");
|
LOGI("fgPlatformMainLoopPreliminaryWork");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -62,38 +62,39 @@ int fgPlatformGlutDeviceGet ( GLenum eWhat )
|
|||||||
|
|
||||||
int fgPlatformGlutGet ( GLenum eWhat )
|
int fgPlatformGlutGet ( GLenum eWhat )
|
||||||
{
|
{
|
||||||
switch (eWhat) {
|
switch (eWhat) {
|
||||||
/* One full-screen window only */
|
/* One full-screen window only */
|
||||||
case GLUT_WINDOW_X:
|
case GLUT_WINDOW_X:
|
||||||
case GLUT_WINDOW_Y:
|
case GLUT_WINDOW_Y:
|
||||||
case GLUT_WINDOW_BORDER_WIDTH:
|
case GLUT_WINDOW_BORDER_WIDTH:
|
||||||
case GLUT_WINDOW_HEADER_HEIGHT:
|
case GLUT_WINDOW_HEADER_HEIGHT:
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
case GLUT_WINDOW_WIDTH:
|
case GLUT_WINDOW_WIDTH:
|
||||||
case GLUT_WINDOW_HEIGHT:
|
case GLUT_WINDOW_HEIGHT:
|
||||||
{
|
{
|
||||||
if ( fgStructure.CurrentWindow == NULL )
|
if ( fgStructure.CurrentWindow == NULL )
|
||||||
return 0;
|
return 0;
|
||||||
int size[2];
|
int size[2];
|
||||||
if ( screen_get_window_property_iv(fgStructure.CurrentWindow->Window.Handle, SCREEN_PROPERTY_BUFFER_SIZE, size) != 0 )
|
if ( screen_get_window_property_iv(fgStructure.CurrentWindow->Window.Handle, SCREEN_PROPERTY_BUFFER_SIZE, size) != 0 )
|
||||||
return 0;
|
return 0;
|
||||||
switch ( eWhat )
|
switch ( eWhat )
|
||||||
{
|
{
|
||||||
case GLUT_WINDOW_WIDTH:
|
case GLUT_WINDOW_WIDTH:
|
||||||
return size[0];
|
return size[0];
|
||||||
case GLUT_WINDOW_HEIGHT:
|
case GLUT_WINDOW_HEIGHT:
|
||||||
return size[1];
|
return size[1];
|
||||||
}
|
}
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
case GLUT_WINDOW_COLORMAP_SIZE:
|
case GLUT_WINDOW_COLORMAP_SIZE:
|
||||||
/* 0 for RGBA/non-indexed mode */
|
/* 0 for RGBA/non-indexed mode */
|
||||||
/* Under BlackBerry and GLES more generally, no indexed-mode */
|
/* Under BlackBerry and GLES more generally, no indexed-mode */
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
return fghPlatformGlutGetEGL(eWhat);
|
return fghPlatformGlutGetEGL(eWhat);
|
||||||
}
|
}
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
@ -43,84 +43,84 @@ void fgPlatformOpenWindow( SFG_Window* window, const char* title,
|
|||||||
GLboolean sizeUse, int w, int h,
|
GLboolean sizeUse, int w, int h,
|
||||||
GLboolean gameMode, GLboolean isSubWindow )
|
GLboolean gameMode, GLboolean isSubWindow )
|
||||||
{
|
{
|
||||||
/* TODO: only one full-screen window possible? */
|
/* TODO: only one full-screen window possible? */
|
||||||
if (fgDisplay.pDisplay.single_native_window != NULL) {
|
if (fgDisplay.pDisplay.single_native_window != NULL) {
|
||||||
fgWarning("You can't have more than one window on BlackBerry");
|
fgWarning("You can't have more than one window on BlackBerry");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
window->Window.pContext.event = NULL; //XXX Should probably be done elsewhere. Done here so there is no event at the moment
|
window->Window.pContext.event = NULL; //XXX Should probably be done elsewhere. Done here so there is no event at the moment
|
||||||
|
|
||||||
/* Create window */
|
/* Create window */
|
||||||
if (screen_create_context(&window->Window.pContext.screenContext, 0)) {
|
if (screen_create_context(&window->Window.pContext.screenContext, 0)) {
|
||||||
fgError("Could not create screen context");
|
fgError("Could not create screen context");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
screen_window_t sWindow;
|
screen_window_t sWindow;
|
||||||
if (screen_create_window(&sWindow, window->Window.pContext.screenContext)) {
|
if (screen_create_window(&sWindow, window->Window.pContext.screenContext)) {
|
||||||
screen_destroy_context(window->Window.pContext.screenContext);
|
screen_destroy_context(window->Window.pContext.screenContext);
|
||||||
fgError("Could not create window");
|
fgError("Could not create window");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
fgDisplay.pDisplay.single_native_window = sWindow;
|
fgDisplay.pDisplay.single_native_window = sWindow;
|
||||||
|
|
||||||
/* Set window properties */
|
/* Set window properties */
|
||||||
int screenFormat = SCREEN_FORMAT_RGBA8888; //XXX Should this be determined by config?
|
int screenFormat = SCREEN_FORMAT_RGBA8888; //XXX Should this be determined by config?
|
||||||
#ifdef GL_ES_VERSION_2_0
|
#ifdef GL_ES_VERSION_2_0
|
||||||
int screenUsage = SCREEN_USAGE_OPENGL_ES2;
|
int screenUsage = SCREEN_USAGE_OPENGL_ES2;
|
||||||
#elif GL_VERSION_ES_CM_1_0 || GL_VERSION_ES_CL_1_0 || GL_VERSION_ES_CM_1_1 || GL_VERSION_ES_CL_1_1
|
#elif GL_VERSION_ES_CM_1_0 || GL_VERSION_ES_CL_1_0 || GL_VERSION_ES_CM_1_1 || GL_VERSION_ES_CL_1_1
|
||||||
int screenUsage = SCREEN_USAGE_OPENGL_ES1;
|
int screenUsage = SCREEN_USAGE_OPENGL_ES1;
|
||||||
#endif
|
#endif
|
||||||
#ifndef __X86__
|
#ifndef __X86__
|
||||||
screenUsage |= SCREEN_USAGE_DISPLAY; // Physical device copy directly into physical display
|
screenUsage |= SCREEN_USAGE_DISPLAY; // Physical device copy directly into physical display
|
||||||
#endif
|
#endif
|
||||||
if (screen_set_window_property_iv(sWindow, SCREEN_PROPERTY_FORMAT, &screenFormat)) {
|
if (screen_set_window_property_iv(sWindow, SCREEN_PROPERTY_FORMAT, &screenFormat)) {
|
||||||
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 set window format");
|
fgError("Could not set window format");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (screen_set_window_property_iv(sWindow, SCREEN_PROPERTY_USAGE, &screenUsage)) {
|
if (screen_set_window_property_iv(sWindow, SCREEN_PROPERTY_USAGE, &screenUsage)) {
|
||||||
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 set window usage");
|
fgError("Could not set window usage");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Could set size based on what is specified for window. Work on another time
|
/* Could set size based on what is specified for window. Work on another time
|
||||||
int size[2];
|
int size[2];
|
||||||
size[0] = w;
|
size[0] = w;
|
||||||
size[1] = h;
|
size[1] = h;
|
||||||
if (screen_set_window_property_iv(sWindow, SCREEN_PROPERTY_BUFFER_SIZE, size)) {
|
if (screen_set_window_property_iv(sWindow, SCREEN_PROPERTY_BUFFER_SIZE, size)) {
|
||||||
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 set window buffer size");
|
fgError("Could not set window buffer size");
|
||||||
return;
|
return;
|
||||||
}*/
|
}*/
|
||||||
|
|
||||||
/* Create window buffers */
|
/* Create window buffers */
|
||||||
if (screen_create_window_buffers(sWindow, (fgState.DisplayMode & GLUT_DOUBLE) ? 2 : 1)) {
|
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");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Request window events */
|
/* Request window events */
|
||||||
screen_request_events(window->Window.pContext.screenContext);
|
screen_request_events(window->Window.pContext.screenContext);
|
||||||
|
|
||||||
/* Save window and set state */
|
/* Save window and set state */
|
||||||
window->Window.Handle = fgDisplay.pDisplay.single_native_window;
|
window->Window.Handle = fgDisplay.pDisplay.single_native_window;
|
||||||
window->State.WorkMask |= GLUT_INIT_WORK;
|
window->State.WorkMask |= GLUT_INIT_WORK;
|
||||||
window->State.IsFullscreen = GL_TRUE; //XXX Always fullscreen for now
|
window->State.IsFullscreen = GL_TRUE; //XXX Always fullscreen for now
|
||||||
|
|
||||||
/* Create context */
|
/* Create context */
|
||||||
fghChooseConfig(&window->Window.pContext.egl.Config);
|
fghChooseConfig(&window->Window.pContext.egl.Config);
|
||||||
window->Window.Context = fghCreateNewContextEGL(window);
|
window->Window.Context = fghCreateNewContextEGL(window);
|
||||||
|
|
||||||
/* Create EGL window */
|
/* Create EGL window */
|
||||||
fghPlatformOpenWindowEGL(window);
|
fghPlatformOpenWindowEGL(window);
|
||||||
|
|
||||||
window->State.Visible = GL_TRUE;
|
window->State.Visible = GL_TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -128,7 +128,7 @@ void fgPlatformOpenWindow( SFG_Window* window, const char* title,
|
|||||||
*/
|
*/
|
||||||
void fgPlatformReshapeWindow ( SFG_Window *window, int width, int height )
|
void fgPlatformReshapeWindow ( SFG_Window *window, int width, int height )
|
||||||
{
|
{
|
||||||
fprintf(stderr, "fgPlatformReshapeWindow: STUB\n");
|
fprintf(stderr, "fgPlatformReshapeWindow: STUB\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -136,13 +136,13 @@ void fgPlatformReshapeWindow ( SFG_Window *window, int width, int height )
|
|||||||
*/
|
*/
|
||||||
void fgPlatformCloseWindow( SFG_Window* window )
|
void fgPlatformCloseWindow( SFG_Window* window )
|
||||||
{
|
{
|
||||||
fghPlatformCloseWindowEGL(window);
|
fghPlatformCloseWindowEGL(window);
|
||||||
|
|
||||||
screen_stop_events(window->Window.pContext.screenContext);
|
screen_stop_events(window->Window.pContext.screenContext);
|
||||||
|
|
||||||
screen_destroy_window((screen_window_t)window->Window.Handle);
|
screen_destroy_window((screen_window_t)window->Window.Handle);
|
||||||
|
|
||||||
screen_destroy_context(window->Window.pContext.screenContext);
|
screen_destroy_context(window->Window.pContext.screenContext);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -150,7 +150,7 @@ void fgPlatformCloseWindow( SFG_Window* window )
|
|||||||
*/
|
*/
|
||||||
void fgPlatformShowWindow( void )
|
void fgPlatformShowWindow( void )
|
||||||
{
|
{
|
||||||
fprintf(stderr, "fgPlatformShowWindow: STUB\n");
|
fprintf(stderr, "fgPlatformShowWindow: STUB\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -158,7 +158,7 @@ void fgPlatformShowWindow( void )
|
|||||||
*/
|
*/
|
||||||
void fgPlatformHideWindow( SFG_Window *window )
|
void fgPlatformHideWindow( SFG_Window *window )
|
||||||
{
|
{
|
||||||
fprintf(stderr, "fgPlatformHideWindow: STUB\n");
|
fprintf(stderr, "fgPlatformHideWindow: STUB\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -166,7 +166,8 @@ void fgPlatformHideWindow( SFG_Window *window )
|
|||||||
*/
|
*/
|
||||||
void fgPlatformIconifyWindow( SFG_Window *window )
|
void fgPlatformIconifyWindow( SFG_Window *window )
|
||||||
{
|
{
|
||||||
fprintf(stderr, "fgPlatformGlutIconifyWindow: STUB\n");
|
//XXX This is possible via Cascades, but can't seem to find a C-level API
|
||||||
|
fprintf(stderr, "fgPlatformGlutIconifyWindow: STUB\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -174,7 +175,7 @@ void fgPlatformIconifyWindow( SFG_Window *window )
|
|||||||
*/
|
*/
|
||||||
void fgPlatformGlutSetWindowTitle( const char* title )
|
void fgPlatformGlutSetWindowTitle( const char* title )
|
||||||
{
|
{
|
||||||
fprintf(stderr, "fgPlatformGlutSetWindowTitle: STUB\n");
|
fprintf(stderr, "fgPlatformGlutSetWindowTitle: STUB\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -182,14 +183,15 @@ void fgPlatformGlutSetWindowTitle( const char* title )
|
|||||||
*/
|
*/
|
||||||
void fgPlatformGlutSetIconTitle( const char* title )
|
void fgPlatformGlutSetIconTitle( const char* title )
|
||||||
{
|
{
|
||||||
fprintf(stderr, "fgPlatformGlutSetIconTitle: STUB\n");}
|
fprintf(stderr, "fgPlatformGlutSetIconTitle: STUB\n");
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Change the specified window's position
|
* Change the specified window's position
|
||||||
*/
|
*/
|
||||||
void fgPlatformPositionWindow( SFG_Window *window, int x, int y )
|
void fgPlatformPositionWindow( SFG_Window *window, int x, int y )
|
||||||
{
|
{
|
||||||
fprintf(stderr, "fgPlatformPositionWindow: STUB\n");
|
fprintf(stderr, "fgPlatformPositionWindow: STUB\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -197,7 +199,7 @@ void fgPlatformPositionWindow( SFG_Window *window, int x, int y )
|
|||||||
*/
|
*/
|
||||||
void fgPlatformPushWindow( SFG_Window *window )
|
void fgPlatformPushWindow( SFG_Window *window )
|
||||||
{
|
{
|
||||||
fprintf(stderr, "fgPlatformPushWindow: STUB\n");
|
fprintf(stderr, "fgPlatformPushWindow: STUB\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -205,7 +207,7 @@ void fgPlatformPushWindow( SFG_Window *window )
|
|||||||
*/
|
*/
|
||||||
void fgPlatformPopWindow( SFG_Window *window )
|
void fgPlatformPopWindow( SFG_Window *window )
|
||||||
{
|
{
|
||||||
fprintf(stderr, "fgPlatformPopWindow: STUB\n");
|
fprintf(stderr, "fgPlatformPopWindow: STUB\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -213,5 +215,5 @@ void fgPlatformPopWindow( SFG_Window *window )
|
|||||||
*/
|
*/
|
||||||
void fgPlatformFullScreenToggle( SFG_Window *win )
|
void fgPlatformFullScreenToggle( SFG_Window *win )
|
||||||
{
|
{
|
||||||
fprintf(stderr, "fgPlatformFullScreenToggle: STUB\n");
|
fprintf(stderr, "fgPlatformFullScreenToggle: STUB\n");
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user