Continue working on QNX Photon with OpenGL ES support

--HG--
extra : convert_revision : svn%3Ac70aab31-4412-0410-b14c-859654838e24/trunk%403588
This commit is contained in:
Mike Gorchak 2009-04-28 04:30:52 +00:00
parent 173f682e1e
commit 79abe77b26
8 changed files with 3426 additions and 60 deletions

File diff suppressed because it is too large Load diff

View file

@ -27,28 +27,78 @@
#ifndef __SDL_PHOTON_H__
#define __SDL_PHOTON_H__
/* GF headers must be included first for the Photon GF functions */
#if defined(SDL_VIDEO_OPENGL_ES)
#include <gf/gf.h>
#include <GLES/egl.h>
#endif /* SDL_VIDEO_OPENGL_ES */
#include "SDL_config.h"
#include "../SDL_sysvideo.h"
#include <Ph.h>
#include <Pt.h>
#include <photon/PkKeyDef.h>
/* Maximum display devices, which can handle SDL Photon driver */
#define SDL_VIDEO_PHOTON_MAX_RIDS 16
typedef struct SDL_VideoData
{
PhRid_t rid[SDL_VIDEO_PHOTON_MAX_RIDS];
uint32_t avail_rids;
uint32_t current_device_id;
#if defined(SDL_VIDEO_OPENGL_ES)
gf_dev_t gfdev; /* GF device handle */
gf_dev_info_t gfdev_info; /* GF device information */
SDL_bool gfinitialized; /* GF device initialization status */
EGLDisplay egldisplay; /* OpenGL ES display connection */
uint32_t egl_refcount; /* OpenGL ES reference count */
uint32_t swapinterval; /* OpenGL ES default swap interval */
#endif /* SDL_VIDEO_OPENGL_ES */
} SDL_VideoData;
#define SDL_VIDEO_PHOTON_DEVICENAME_MAX 257
/* This is hardcoded value in photon/Pg.h */
#define SDL_VIDEO_PHOTON_DEVICENAME_MAX 41
#define SDL_VIDEO_PHOTON_MAX_CURSOR_SIZE 128
/* Maximum event message size with data payload */
#define SDL_VIDEO_PHOTON_EVENT_SIZE 8192
typedef struct SDL_DisplayData
{
uint32_t device_id;
uint32_t custom_refresh; /* Custom refresh rate for all modes */
SDL_DisplayMode current_mode; /* Current video mode */
uint8_t description[SDL_VIDEO_PHOTON_DEVICENAME_MAX];
/* Device description */
uint32_t caps; /* Device capabilities */
PhCursorDef_t* cursor; /* Global cursor settings */
SDL_bool cursor_visible; /* SDL_TRUE if cursor visible */
uint32_t cursor_size; /* Cursor size in memory w/ structure */
#if defined(SDL_VIDEO_OPENGL_ES)
gf_display_t display; /* GF display handle */
gf_display_info_t display_info; /* GF display information */
#endif /* SDL_VIDEO_OPENGL_ES */
} SDL_DisplayData;
/* Maximum amount of OpenGL ES framebuffer configurations */
#define SDL_VIDEO_GF_OPENGLES_CONFS 32
typedef struct SDL_WindowData
{
SDL_bool uses_gles; /* if true window must support OpenGL ES*/
SDL_bool uses_gles; /* if true window must support OpenGL ES*/
PtWidget_t* window; /* window handle */
#if defined(SDL_VIDEO_OPENGL_ES)
EGLConfig gles_configs[SDL_VIDEO_GF_OPENGLES_CONFS];
/* OpenGL ES framebuffer confs */
EGLint gles_config; /* OpenGL ES configuration index */
EGLContext gles_context; /* OpenGL ES context */
EGLint gles_attributes[256]; /* OpenGL ES attributes for context */
EGLSurface gles_surface; /* OpenGL ES target rendering surface */
gf_surface_t gfsurface; /* OpenGL ES GF's surface */
PdOffscreenContext_t* phsurface; /* OpenGL ES Photon's surface */
#endif /* SDL_VIDEO_OPENGL_ES */
} SDL_WindowData;
/****************************************************************************/
@ -62,22 +112,24 @@ typedef struct Photon_DeviceCaps
#define SDL_PHOTON_UNACCELERATED 0x00000000
#define SDL_PHOTON_ACCELERATED 0x00000001
#define SDL_PHOTON_UNACCELERATED_3D 0x00000000
#define SDL_PHOTON_ACCELERATED_3D 0x00000004
/****************************************************************************/
/* SDL_VideoDevice functions declaration */
/****************************************************************************/
/* Display and window functions */
int photon_videoinit(_THIS);
int photon_videoinit(_THIS);
void photon_videoquit(_THIS);
void photon_getdisplaymodes(_THIS);
int photon_setdisplaymode(_THIS, SDL_DisplayMode* mode);
int photon_setdisplaypalette(_THIS, SDL_Palette* palette);
int photon_getdisplaypalette(_THIS, SDL_Palette* palette);
int photon_setdisplaygammaramp(_THIS, Uint16* ramp);
int photon_getdisplaygammaramp(_THIS, Uint16* ramp);
int photon_createwindow(_THIS, SDL_Window* window);
int photon_createwindowfrom(_THIS, SDL_Window* window, const void* data);
int photon_setdisplaymode(_THIS, SDL_DisplayMode* mode);
int photon_setdisplaypalette(_THIS, SDL_Palette* palette);
int photon_getdisplaypalette(_THIS, SDL_Palette* palette);
int photon_setdisplaygammaramp(_THIS, Uint16* ramp);
int photon_getdisplaygammaramp(_THIS, Uint16* ramp);
int photon_createwindow(_THIS, SDL_Window* window);
int photon_createwindowfrom(_THIS, SDL_Window* window, const void* data);
void photon_setwindowtitle(_THIS, SDL_Window* window);
void photon_setwindowicon(_THIS, SDL_Window* window, SDL_Surface* icon);
void photon_setwindowposition(_THIS, SDL_Window* window);

View file

@ -0,0 +1,735 @@
/*
SDL - Simple DirectMedia Layer
Copyright (C) 1997-2009 Sam Lantinga
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
Sam Lantinga
slouken@libsdl.org
QNX Photon GUI SDL driver
Copyright (C) 2009 Mike Gorchak
(mike@malva.ua, lestat@i.com.ua)
*/
#include "SDL_photon_input.h"
#include "SDL_config.h"
#include "SDL_events.h"
#include "../../events/SDL_mouse_c.h"
#include "../../events/SDL_keyboard_c.h"
#include "SDL_photon_keycodes.h"
/* Mouse related functions */
SDL_Cursor* photon_createcursor(SDL_Surface* surface, int hot_x, int hot_y);
int photon_showcursor(SDL_Cursor* cursor);
void photon_movecursor(SDL_Cursor* cursor);
void photon_freecursor(SDL_Cursor* cursor);
void photon_warpmouse(SDL_Mouse* mouse, SDL_WindowID windowID, int x, int y);
void photon_freemouse(SDL_Mouse* mouse);
int32_t photon_addinputdevices(_THIS)
{
SDL_VideoData* phdata=(SDL_VideoData*)_this->driverdata;
SDL_DisplayData* didata=NULL;
struct SDL_Mouse photon_mouse;
SDL_MouseData* mdata=NULL;
SDL_Keyboard photon_keyboard;
SDLKey keymap[SDL_NUM_SCANCODES];
uint32_t it;
for (it=0; it<_this->num_displays; it++)
{
/* Clear SDL mouse structure */
SDL_memset(&photon_mouse, 0x00, sizeof(struct SDL_Mouse));
/* Allocate SDL_MouseData structure */
mdata=(SDL_MouseData*)SDL_calloc(1, sizeof(SDL_MouseData));
if (mdata==NULL)
{
SDL_OutOfMemory();
return -1;
}
/* Mark this mouse with ID 0 */
photon_mouse.id=it;
photon_mouse.driverdata=(void*)mdata;
photon_mouse.CreateCursor=photon_createcursor;
photon_mouse.ShowCursor=photon_showcursor;
photon_mouse.MoveCursor=photon_movecursor;
photon_mouse.FreeCursor=photon_freecursor;
photon_mouse.WarpMouse=photon_warpmouse;
photon_mouse.FreeMouse=photon_freemouse;
/* Get display data */
didata=(SDL_DisplayData*)_this->displays[it].driverdata;
/* Store SDL_DisplayData pointer in the mouse driver internals */
mdata->didata=didata;
/* Register mouse cursor in SDL */
SDL_AddMouse(&photon_mouse, "Photon mouse cursor", 0, 0, 1);
}
/* Photon maps all keyboards to one */
SDL_zero(photon_keyboard);
SDL_AddKeyboard(&photon_keyboard, -1);
/* Add default scancode to key mapping */
SDL_GetDefaultKeymap(keymap);
SDL_SetKeymap(0, 0, keymap, SDL_NUM_SCANCODES);
return 0;
}
int32_t photon_delinputdevices(_THIS)
{
/* Destroy all of the mice */
SDL_MouseQuit();
}
/*****************************************************************************/
/* Photon mouse related functions */
/*****************************************************************************/
SDL_Cursor* photon_createcursor(SDL_Surface* surface, int hot_x, int hot_y)
{
PhCursorDef_t* internal_cursor;
SDL_Cursor* sdl_cursor;
uint8_t* image0=NULL;
uint8_t* image1=NULL;
uint32_t it;
uint32_t jt;
uint32_t shape_color;
/* SDL converts monochrome cursor shape to 32bpp cursor shape */
/* and we must convert it back to monochrome, this routine handles */
/* 24/32bpp surfaces only */
if ((surface->format->BitsPerPixel!=32) && (surface->format->BitsPerPixel!=24))
{
SDL_SetError("Photon: Cursor shape is not 24/32bpp.");
return NULL;
}
/* Checking data parameters */
if ((surface->w==0) || (surface->h==0))
{
SDL_SetError("Photon: Cursor shape dimensions are zero");
return NULL;
}
/* Allocate memory for the internal cursor format */
internal_cursor=(PhCursorDef_t*)SDL_calloc(1, sizeof(PhCursorDef_t)+
((((surface->w+7)>>3)*surface->h)*2)-1);
if (internal_cursor==NULL)
{
SDL_OutOfMemory();
return NULL;
}
/* Allocate memory for the SDL cursor */
sdl_cursor=(SDL_Cursor*)SDL_calloc(1, sizeof(SDL_Cursor));
if (sdl_cursor==NULL)
{
SDL_free(internal_cursor);
SDL_OutOfMemory();
return NULL;
}
/* Set driverdata as photon cursor format */
image0=(uint8_t*)internal_cursor;
image0+=sizeof(PhCursorDef_t)-1;
image1=image0;
image1+=((surface->w+7)>>3)*surface->h;
sdl_cursor->driverdata=(void*)internal_cursor;
internal_cursor->hdr.len=(sizeof(PhCursorDef_t)-sizeof(PhRegionDataHdr_t))+
((((surface->w+7)>>3)*surface->h)*2)-1;
internal_cursor->hdr.type=Ph_RDATA_CURSOR;
internal_cursor->size1.x=surface->w;
internal_cursor->size1.y=surface->h;
internal_cursor->size2.x=surface->w;
internal_cursor->size2.y=surface->h;
internal_cursor->offset1.x=hot_x;
internal_cursor->offset1.y=hot_y;
internal_cursor->offset2.x=hot_x;
internal_cursor->offset2.y=hot_y;
internal_cursor->bytesperline1=((surface->w+7)>>3);
internal_cursor->bytesperline2=((surface->w+7)>>3);
internal_cursor->color1=(SDL_PHOTON_MOUSE_COLOR_BLACK) & 0x00FFFFFF;
internal_cursor->color2=(SDL_PHOTON_MOUSE_COLOR_WHITE) & 0x00FFFFFF;
/* Convert cursor from 32 bpp */
for (jt=0; jt<surface->h; jt++)
{
for (it=0; it<surface->w; it++)
{
shape_color=*((uint32_t*)((uint8_t*)surface->pixels+jt*surface->pitch+it*surface->format->BytesPerPixel));
switch(shape_color)
{
case SDL_PHOTON_MOUSE_COLOR_BLACK:
{
*(image0+jt*(internal_cursor->bytesperline1)+(it>>3))|=0x80>>(it%8);
*(image1+jt*(internal_cursor->bytesperline2)+(it>>3))&=~(0x80>>(it%8));
}
break;
case SDL_PHOTON_MOUSE_COLOR_WHITE:
{
*(image0+jt*(internal_cursor->bytesperline1)+(it>>3))&=~(0x80>>(it%8));
*(image1+jt*(internal_cursor->bytesperline2)+(it>>3))|=0x80>>(it%8);
}
break;
case SDL_PHOTON_MOUSE_COLOR_TRANS:
{
*(image0+jt*(internal_cursor->bytesperline1)+(it>>3))&=~(0x80>>(it%8));
*(image1+jt*(internal_cursor->bytesperline2)+(it>>3))&=~(0x80>>(it%8));
}
break;
default:
{
/* The same as transparent color, must not happen */
*(image0+jt*(internal_cursor->bytesperline1)+(it>>3))&=~(0x80>>(it%8));
*(image1+jt*(internal_cursor->bytesperline2)+(it>>3))&=~(0x80>>(it%8));
}
break;
}
}
}
return sdl_cursor;
}
int photon_showcursor(SDL_Cursor* cursor)
{
SDL_VideoDisplay* display;
SDL_DisplayData* didata;
SDL_Window* window;
SDL_WindowData* wdata;
SDL_WindowID window_id;
PhCursorDef_t* internal_cursor;
int32_t status;
/* Get current window id */
window_id=SDL_GetFocusWindow();
if (window_id<=0)
{
SDL_MouseData* mdata=NULL;
/* If there is no current window, then someone calls this function */
/* to set global mouse settings during SDL initialization */
if (cursor!=NULL)
{
/* Store cursor for future usage */
mdata=(SDL_MouseData*)cursor->mouse->driverdata;
didata=(SDL_DisplayData*)mdata->didata;
internal_cursor=(PhCursorDef_t*)cursor->driverdata;
if (didata->cursor_size>=(internal_cursor->hdr.len+sizeof(PhRegionDataHdr_t)))
{
SDL_memcpy(didata->cursor, internal_cursor, internal_cursor->hdr.len+sizeof(PhRegionDataHdr_t));
}
else
{
/* Partitial cursor image */
SDL_memcpy(didata->cursor, internal_cursor, didata->cursor_size);
}
didata->cursor_visible=SDL_TRUE;
return 0;
}
else
{
/* We can't get SDL_DisplayData at this point, return fake success */
return 0;
}
}
else
{
/* Sanity checks */
window=SDL_GetWindowFromID(window_id);
if (window!=NULL)
{
display=SDL_GetDisplayFromWindow(window);
if (display!=NULL)
{
didata=(SDL_DisplayData*)display->driverdata;
if (didata!=NULL)
{
wdata=(SDL_WindowData*)window->driverdata;
if (wdata==NULL)
{
return -1;
}
}
else
{
return -1;
}
}
else
{
return -1;
}
}
else
{
return -1;
}
}
/* return if window widget has been destroyed already */
if (wdata->window==NULL)
{
return;
}
/* Check if we need to set new shape or disable cursor shape */
if (cursor!=NULL)
{
/* Retrieve photon cursor shape */
internal_cursor=(PhCursorDef_t*)cursor->driverdata;
if (internal_cursor==NULL)
{
SDL_SetError("Photon: Internal cursor data is absent");
return -1;
}
/* Setup cursor type */
status=PtSetResource(wdata->window, Pt_ARG_CURSOR_TYPE, Ph_CURSOR_BITMAP, 0);
if (status!=0)
{
SDL_SetError("Photon: Failed to set cursor type to bitmap");
return -1;
}
/* Setup cursor color to default */
status=PtSetResource(wdata->window, Pt_ARG_CURSOR_COLOR, Ph_CURSOR_DEFAULT_COLOR, 0);
if (status!=0)
{
SDL_SetError("Photon: Failed to set cursor color");
return -1;
}
/* Setup cursor shape */
status=PtSetResource(wdata->window, Pt_ARG_BITMAP_CURSOR, internal_cursor,
internal_cursor->hdr.len+sizeof(PhRegionDataHdr_t));
if (status!=0)
{
SDL_SetError("Photon: Failed to set cursor color");
return -1;
}
/* Store current cursor for future usage */
if (didata->cursor_size>=(internal_cursor->hdr.len+sizeof(PhRegionDataHdr_t)))
{
SDL_memcpy(didata->cursor, internal_cursor, internal_cursor->hdr.len+sizeof(PhRegionDataHdr_t));
}
else
{
/* Partitial cursor image */
SDL_memcpy(didata->cursor, internal_cursor, didata->cursor_size);
}
/* Set cursor visible */
didata->cursor_visible=SDL_TRUE;
}
else
{
/* SDL requests to disable cursor */
status=PtSetResource(wdata->window, Pt_ARG_CURSOR_TYPE, Ph_CURSOR_NONE, 0);
if (status!=0)
{
SDL_SetError("Photon: Can't disable cursor");
return -1;
}
/* Set cursor invisible */
didata->cursor_visible=SDL_FALSE;
}
/* Flush all pending widget data */
PtFlush();
/* New cursor shape is set */
return 0;
}
void photon_movecursor(SDL_Cursor* cursor)
{
SDL_VideoDisplay* display;
SDL_DisplayData* didata;
SDL_Window* window;
SDL_WindowID window_id;
int32_t status;
/* Get current window id */
window_id=SDL_GetFocusWindow();
if (window_id<=0)
{
didata=(SDL_DisplayData*)cursor->mouse->driverdata;
}
else
{
/* Sanity checks */
window=SDL_GetWindowFromID(window_id);
if (window!=NULL)
{
display=SDL_GetDisplayFromWindow(window);
if (display!=NULL)
{
didata=(SDL_DisplayData*)display->driverdata;
if (didata==NULL)
{
return;
}
}
else
{
return;
}
}
else
{
return;
}
}
/* cursor->mouse->x, cursor->mouse->y */
}
void photon_freecursor(SDL_Cursor* cursor)
{
PhCursorDef_t* internal_cursor=NULL;
if (cursor!=NULL)
{
internal_cursor=(PhCursorDef_t*)cursor->driverdata;
if (internal_cursor!=NULL)
{
SDL_free(internal_cursor);
cursor->driverdata=NULL;
}
}
}
void photon_warpmouse(SDL_Mouse* mouse, SDL_WindowID windowID, int x, int y)
{
SDL_VideoDisplay* display;
SDL_DisplayData* didata;
SDL_Window* window;
int32_t status;
/* Sanity checks */
window=SDL_GetWindowFromID(windowID);
if (window!=NULL)
{
display=SDL_GetDisplayFromWindow(window);
if (display!=NULL)
{
didata=(SDL_DisplayData*)display->driverdata;
if (didata==NULL)
{
return;
}
}
else
{
return;
}
}
else
{
return;
}
}
void photon_freemouse(SDL_Mouse* mouse)
{
if (mouse->driverdata==NULL)
{
return;
}
/* Mouse framework doesn't deletes automatically our driverdata */
SDL_free(mouse->driverdata);
mouse->driverdata=NULL;
return;
}
SDL_scancode photon_to_sdl_keymap(uint32_t key)
{
SDL_scancode scancode=SDL_SCANCODE_UNKNOWN;
switch(key & 0x0000007F)
{
case PHOTON_SCANCODE_ESCAPE:
scancode=SDL_SCANCODE_ESCAPE;
break;
case PHOTON_SCANCODE_F1:
scancode=SDL_SCANCODE_F1;
break;
case PHOTON_SCANCODE_F2:
scancode=SDL_SCANCODE_F2;
break;
case PHOTON_SCANCODE_F3:
scancode=SDL_SCANCODE_F3;
break;
case PHOTON_SCANCODE_F4:
scancode=SDL_SCANCODE_F4;
break;
case PHOTON_SCANCODE_F5:
scancode=SDL_SCANCODE_F5;
break;
case PHOTON_SCANCODE_F6:
scancode=SDL_SCANCODE_F6;
break;
case PHOTON_SCANCODE_F7:
scancode=SDL_SCANCODE_F7;
break;
case PHOTON_SCANCODE_F8:
scancode=SDL_SCANCODE_F8;
break;
case PHOTON_SCANCODE_F9:
scancode=SDL_SCANCODE_F9;
break;
case PHOTON_SCANCODE_F10:
scancode=SDL_SCANCODE_F10;
break;
case PHOTON_SCANCODE_F11:
scancode=SDL_SCANCODE_F11;
break;
case PHOTON_SCANCODE_F12:
scancode=SDL_SCANCODE_F12;
break;
case PHOTON_SCANCODE_BACKQOUTE:
scancode=SDL_SCANCODE_GRAVE;
break;
case PHOTON_SCANCODE_1:
scancode=SDL_SCANCODE_1;
break;
case PHOTON_SCANCODE_2:
scancode=SDL_SCANCODE_2;
break;
case PHOTON_SCANCODE_3:
scancode=SDL_SCANCODE_3;
break;
case PHOTON_SCANCODE_4:
scancode=SDL_SCANCODE_4;
break;
case PHOTON_SCANCODE_5:
scancode=SDL_SCANCODE_5;
break;
case PHOTON_SCANCODE_6:
scancode=SDL_SCANCODE_6;
break;
case PHOTON_SCANCODE_7:
scancode=SDL_SCANCODE_7;
break;
case PHOTON_SCANCODE_8:
scancode=SDL_SCANCODE_8;
break;
case PHOTON_SCANCODE_9:
scancode=SDL_SCANCODE_9;
break;
case PHOTON_SCANCODE_0:
scancode=SDL_SCANCODE_0;
break;
case PHOTON_SCANCODE_MINUS:
scancode=SDL_SCANCODE_MINUS;
break;
case PHOTON_SCANCODE_EQUAL:
scancode=SDL_SCANCODE_EQUALS;
break;
case PHOTON_SCANCODE_BACKSPACE:
scancode=SDL_SCANCODE_BACKSPACE;
break;
case PHOTON_SCANCODE_TAB:
scancode=SDL_SCANCODE_TAB;
break;
case PHOTON_SCANCODE_Q:
scancode=SDL_SCANCODE_Q;
break;
case PHOTON_SCANCODE_W:
scancode=SDL_SCANCODE_W;
break;
case PHOTON_SCANCODE_E:
scancode=SDL_SCANCODE_E;
break;
case PHOTON_SCANCODE_R:
scancode=SDL_SCANCODE_R;
break;
case PHOTON_SCANCODE_T:
scancode=SDL_SCANCODE_T;
break;
case PHOTON_SCANCODE_Y:
scancode=SDL_SCANCODE_Y;
break;
case PHOTON_SCANCODE_U:
scancode=SDL_SCANCODE_U;
break;
case PHOTON_SCANCODE_I:
scancode=SDL_SCANCODE_I;
break;
case PHOTON_SCANCODE_O:
scancode=SDL_SCANCODE_O;
break;
case PHOTON_SCANCODE_P:
scancode=SDL_SCANCODE_P;
break;
case PHOTON_SCANCODE_LEFT_SQ_BR:
scancode=SDL_SCANCODE_LEFTBRACKET;
break;
case PHOTON_SCANCODE_RIGHT_SQ_BR:
scancode=SDL_SCANCODE_RIGHTBRACKET;
break;
case PHOTON_SCANCODE_ENTER:
scancode=SDL_SCANCODE_RETURN;
break;
case PHOTON_SCANCODE_CAPSLOCK:
scancode=SDL_SCANCODE_CAPSLOCK;
break;
case PHOTON_SCANCODE_A:
scancode=SDL_SCANCODE_A;
break;
case PHOTON_SCANCODE_S:
scancode=SDL_SCANCODE_S;
break;
case PHOTON_SCANCODE_D:
scancode=SDL_SCANCODE_D;
break;
case PHOTON_SCANCODE_F:
scancode=SDL_SCANCODE_F;
break;
case PHOTON_SCANCODE_G:
scancode=SDL_SCANCODE_G;
break;
case PHOTON_SCANCODE_H:
scancode=SDL_SCANCODE_H;
break;
case PHOTON_SCANCODE_J:
scancode=SDL_SCANCODE_J;
break;
case PHOTON_SCANCODE_K:
scancode=SDL_SCANCODE_K;
break;
case PHOTON_SCANCODE_L:
scancode=SDL_SCANCODE_L;
break;
case PHOTON_SCANCODE_SEMICOLON:
scancode=SDL_SCANCODE_SEMICOLON;
break;
case PHOTON_SCANCODE_QUOTE:
scancode=SDL_SCANCODE_APOSTROPHE;
break;
case PHOTON_SCANCODE_BACKSLASH:
scancode=SDL_SCANCODE_BACKSLASH;
break;
case PHOTON_SCANCODE_LEFT_SHIFT:
scancode=SDL_SCANCODE_LSHIFT;
break;
case PHOTON_SCANCODE_Z:
scancode=SDL_SCANCODE_Z;
break;
case PHOTON_SCANCODE_X:
scancode=SDL_SCANCODE_X;
break;
case PHOTON_SCANCODE_C:
scancode=SDL_SCANCODE_C;
break;
case PHOTON_SCANCODE_V:
scancode=SDL_SCANCODE_V;
break;
case PHOTON_SCANCODE_B:
scancode=SDL_SCANCODE_B;
break;
case PHOTON_SCANCODE_N:
scancode=SDL_SCANCODE_N;
break;
case PHOTON_SCANCODE_M:
scancode=SDL_SCANCODE_M;
break;
case PHOTON_SCANCODE_COMMA:
scancode=SDL_SCANCODE_COMMA;
break;
case PHOTON_SCANCODE_POINT:
scancode=SDL_SCANCODE_PERIOD;
break;
case PHOTON_SCANCODE_SLASH:
scancode=SDL_SCANCODE_SLASH;
break;
case PHOTON_SCANCODE_RIGHT_SHIFT:
scancode=SDL_SCANCODE_RSHIFT;
break;
case PHOTON_SCANCODE_CTRL:
scancode=SDL_SCANCODE_LCTRL;
break;
case PHOTON_SCANCODE_WFLAG:
scancode=SDL_SCANCODE_LGUI;
break;
case PHOTON_SCANCODE_ALT:
scancode=SDL_SCANCODE_LALT;
break;
case PHOTON_SCANCODE_SPACE:
scancode=SDL_SCANCODE_SPACE;
break;
case PHOTON_SCANCODE_MENU:
scancode=SDL_SCANCODE_MENU;
break;
case PHOTON_SCANCODE_PRNSCR:
scancode=SDL_SCANCODE_PRINTSCREEN;
break;
case PHOTON_SCANCODE_SCROLLLOCK:
scancode=SDL_SCANCODE_SCROLLLOCK;
break;
case PHOTON_SCANCODE_INSERT:
scancode=SDL_SCANCODE_INSERT;
break;
case PHOTON_SCANCODE_HOME:
scancode=SDL_SCANCODE_HOME;
break;
case PHOTON_SCANCODE_PAGEUP:
scancode=SDL_SCANCODE_PAGEUP;
break;
case PHOTON_SCANCODE_DELETE:
scancode=SDL_SCANCODE_DELETE;
break;
case PHOTON_SCANCODE_END:
scancode=SDL_SCANCODE_END;
break;
case PHOTON_SCANCODE_PAGEDOWN:
scancode=SDL_SCANCODE_PAGEDOWN;
break;
case PHOTON_SCANCODE_UP:
scancode=SDL_SCANCODE_UP;
break;
case PHOTON_SCANCODE_DOWN:
scancode=SDL_SCANCODE_DOWN;
break;
case PHOTON_SCANCODE_LEFT:
scancode=SDL_SCANCODE_LEFT;
break;
case PHOTON_SCANCODE_RIGHT:
scancode=SDL_SCANCODE_RIGHT;
break;
case PHOTON_SCANCODE_NUMLOCK:
scancode=SDL_SCANCODE_NUMLOCKCLEAR;
break;
default:
break;
}
return scancode;
}

View file

@ -0,0 +1,50 @@
/*
SDL - Simple DirectMedia Layer
Copyright (C) 1997-2009 Sam Lantinga
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
Sam Lantinga
slouken@libsdl.org
QNX Photon GUI SDL driver
Copyright (C) 2009 Mike Gorchak
(mike@malva.ua, lestat@i.com.ua)
*/
#ifndef __SDL_PHOTON_INPUT_H__
#define __SDL_PHOTON_INPUT_H__
#include "SDL_config.h"
#include "SDL_video.h"
#include "../SDL_sysvideo.h"
#include "SDL_photon.h"
typedef struct SDL_MouseData
{
SDL_DisplayData* didata;
} SDL_MouseData;
int32_t photon_addinputdevices(_THIS);
int32_t photon_delinputdevices(_THIS);
#define SDL_PHOTON_MOUSE_COLOR_BLACK 0xFF000000
#define SDL_PHOTON_MOUSE_COLOR_WHITE 0xFFFFFFFF
#define SDL_PHOTON_MOUSE_COLOR_TRANS 0x00000000
SDL_scancode photon_to_sdl_keymap(uint32_t key);
#endif /* __SDL_GF_INPUT_H__ */

View file

@ -0,0 +1,123 @@
/*
SDL - Simple DirectMedia Layer
Copyright (C) 1997-2009 Sam Lantinga
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
Sam Lantinga
slouken@libsdl.org
QNX Photon GUI SDL driver
Copyright (C) 2009 Mike Gorchak
(mike@malva.ua, lestat@i.com.ua)
*/
#ifndef __SDL_PHOTON_KEYCODES_H__
#define __SDL_PHOTON_KEYCODES_H__
#define PHOTON_SCANCODE_ESCAPE 0x01
#define PHOTON_SCANCODE_F1 0x3B
#define PHOTON_SCANCODE_F2 0x3C
#define PHOTON_SCANCODE_F3 0x3D
#define PHOTON_SCANCODE_F4 0x3E
#define PHOTON_SCANCODE_F5 0x3F
#define PHOTON_SCANCODE_F6 0x40
#define PHOTON_SCANCODE_F7 0x41
#define PHOTON_SCANCODE_F8 0x42
#define PHOTON_SCANCODE_F9 0x43
#define PHOTON_SCANCODE_F10 0x44
#define PHOTON_SCANCODE_F11 0x57
#define PHOTON_SCANCODE_F12 0x58
#define PHOTON_SCANCODE_BACKQOUTE 0x29
#define PHOTON_SCANCODE_1 0x02
#define PHOTON_SCANCODE_2 0x03
#define PHOTON_SCANCODE_3 0x04
#define PHOTON_SCANCODE_4 0x05
#define PHOTON_SCANCODE_5 0x06
#define PHOTON_SCANCODE_6 0x07
#define PHOTON_SCANCODE_7 0x08
#define PHOTON_SCANCODE_8 0x09
#define PHOTON_SCANCODE_9 0x0A
#define PHOTON_SCANCODE_0 0x0B
#define PHOTON_SCANCODE_MINUS 0x0C
#define PHOTON_SCANCODE_EQUAL 0x0D
#define PHOTON_SCANCODE_BACKSPACE 0x0E
#define PHOTON_SCANCODE_TAB 0x0F
#define PHOTON_SCANCODE_Q 0x10
#define PHOTON_SCANCODE_W 0x11
#define PHOTON_SCANCODE_E 0x12
#define PHOTON_SCANCODE_R 0x13
#define PHOTON_SCANCODE_T 0x14
#define PHOTON_SCANCODE_Y 0x15
#define PHOTON_SCANCODE_U 0x16
#define PHOTON_SCANCODE_I 0x17
#define PHOTON_SCANCODE_O 0x18
#define PHOTON_SCANCODE_P 0x19
#define PHOTON_SCANCODE_LEFT_SQ_BR 0x1A
#define PHOTON_SCANCODE_RIGHT_SQ_BR 0x1B
#define PHOTON_SCANCODE_ENTER 0x1C
#define PHOTON_SCANCODE_CAPSLOCK 0x3A
#define PHOTON_SCANCODE_A 0x1E
#define PHOTON_SCANCODE_S 0x1F
#define PHOTON_SCANCODE_D 0x20
#define PHOTON_SCANCODE_F 0x21
#define PHOTON_SCANCODE_G 0x22
#define PHOTON_SCANCODE_H 0x23
#define PHOTON_SCANCODE_J 0x24
#define PHOTON_SCANCODE_K 0x25
#define PHOTON_SCANCODE_L 0x26
#define PHOTON_SCANCODE_SEMICOLON 0x27
#define PHOTON_SCANCODE_QUOTE 0x28
#define PHOTON_SCANCODE_BACKSLASH 0x2B
#define PHOTON_SCANCODE_LEFT_SHIFT 0x2A
#define PHOTON_SCANCODE_Z 0x2C
#define PHOTON_SCANCODE_X 0x2D
#define PHOTON_SCANCODE_C 0x2E
#define PHOTON_SCANCODE_V 0x2F
#define PHOTON_SCANCODE_B 0x30
#define PHOTON_SCANCODE_N 0x31
#define PHOTON_SCANCODE_M 0x32
#define PHOTON_SCANCODE_COMMA 0x33
#define PHOTON_SCANCODE_POINT 0x34
#define PHOTON_SCANCODE_SLASH 0x35
#define PHOTON_SCANCODE_RIGHT_SHIFT 0x36
#define PHOTON_SCANCODE_CTRL 0x1D
#define PHOTON_SCANCODE_WFLAG 0x5B
#define PHOTON_SCANCODE_ALT 0x38
#define PHOTON_SCANCODE_SPACE 0x39
#define PHOTON_SCANCODE_MENU 0x5D
#define PHOTON_SCANCODE_PRNSCR 0x54 /* only key pressed event, no release */
#define PHOTON_SCANCODE_SCROLLLOCK 0x46
/* #define PHOTON_SCANCODE_PAUSE 0x?? */ /* pause doesn't generates a scancode */
#define PHOTON_SCANCODE_INSERT 0x52
#define PHOTON_SCANCODE_HOME 0x47
#define PHOTON_SCANCODE_PAGEUP 0x49
#define PHOTON_SCANCODE_DELETE 0x53
#define PHOTON_SCANCODE_END 0x4F
#define PHOTON_SCANCODE_PAGEDOWN 0x51
#define PHOTON_SCANCODE_UP 0x48
#define PHOTON_SCANCODE_DOWN 0x50
#define PHOTON_SCANCODE_LEFT 0x4B
#define PHOTON_SCANCODE_RIGHT 0x4D
#define PHOTON_SCANCODE_NUMLOCK 0x45
#endif /* __SDL_PHOTON_KEYCODES_H__ */

View file

@ -0,0 +1,198 @@
/*
SDL - Simple DirectMedia Layer
Copyright (C) 1997-2009 Sam Lantinga
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
Sam Lantinga
slouken@libsdl.org
QNX Photon GUI SDL driver
Copyright (C) 2009 Mike Gorchak
(mike@malva.ua, lestat@i.com.ua)
*/
#include "SDL_photon_pixelfmt.h"
uint32_t photon_bits_to_sdl_pixelformat(uint32_t pixelfmt)
{
switch(pixelfmt)
{
case 8:
{
return SDL_PIXELFORMAT_INDEX8;
}
break;
case 15:
{
return SDL_PIXELFORMAT_ARGB1555;
}
break;
case 16:
{
return SDL_PIXELFORMAT_RGB565;
}
break;
case 24:
{
return SDL_PIXELFORMAT_RGB888;
}
break;
case 32:
{
return SDL_PIXELFORMAT_ARGB8888;
}
break;
}
}
uint32_t photon_sdl_to_bits_pixelformat(uint32_t pixelfmt)
{
switch(pixelfmt)
{
case SDL_PIXELFORMAT_INDEX8:
{
return 8;
}
break;
case SDL_PIXELFORMAT_ARGB1555:
{
return 15;
}
break;
case SDL_PIXELFORMAT_ABGR1555:
{
return 15;
}
break;
case SDL_PIXELFORMAT_RGB565:
{
return 16;
}
break;
case SDL_PIXELFORMAT_RGB888:
{
return 24;
}
break;
case SDL_PIXELFORMAT_BGRA8888:
{
return 32;
}
break;
case SDL_PIXELFORMAT_ARGB8888:
{
return 32;
}
break;
case SDL_PIXELFORMAT_YV12:
{
return 8;
}
break;
case SDL_PIXELFORMAT_YUY2:
{
return 16;
}
break;
case SDL_PIXELFORMAT_UYVY:
{
return 16;
}
break;
case SDL_PIXELFORMAT_YVYU:
{
return 16;
}
break;
}
return 0;
}
uint32_t photon_image_to_sdl_pixelformat(uint32_t pixelfmt)
{
switch(pixelfmt)
{
case Pg_IMAGE_PALETTE_BYTE:
{
return SDL_PIXELFORMAT_INDEX8;
}
break;
case Pg_IMAGE_DIRECT_8888:
{
return SDL_PIXELFORMAT_BGRA8888;
}
break;
case Pg_IMAGE_DIRECT_888:
{
return SDL_PIXELFORMAT_RGB888;
}
break;
case Pg_IMAGE_DIRECT_565:
{
return SDL_PIXELFORMAT_RGB565;
}
break;
case Pg_IMAGE_DIRECT_555:
{
return SDL_PIXELFORMAT_RGB555;
}
break;
case Pg_IMAGE_DIRECT_1555:
{
return SDL_PIXELFORMAT_ARGB1555;
}
break;
}
return 0;
}
uint32_t photon_sdl_to_image_pixelformat(uint32_t pixelfmt)
{
switch(pixelfmt)
{
case SDL_PIXELFORMAT_INDEX8:
{
return Pg_IMAGE_PALETTE_BYTE;
}
break;
case SDL_PIXELFORMAT_BGRA8888:
{
return Pg_IMAGE_DIRECT_8888;
}
break;
case SDL_PIXELFORMAT_RGB888:
{
return Pg_IMAGE_DIRECT_888;
}
break;
case SDL_PIXELFORMAT_RGB565:
{
return Pg_IMAGE_DIRECT_565;
}
break;
case SDL_PIXELFORMAT_ARGB1555:
{
return Pg_IMAGE_DIRECT_1555;
}
break;
}
return 0;
}
/* vi: set ts=4 sw=4 expandtab: */

View file

@ -0,0 +1,42 @@
/*
SDL - Simple DirectMedia Layer
Copyright (C) 1997-2009 Sam Lantinga
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
Sam Lantinga
slouken@libsdl.org
QNX Photon GUI SDL driver
Copyright (C) 2009 Mike Gorchak
(mike@malva.ua, lestat@i.com.ua)
*/
#include "SDL_config.h"
#include "../SDL_sysvideo.h"
#include <Ph.h>
#ifndef __SDL_PHOTON_PIXELFMT_H__
#define __SDL_PHOTON_PIXELFMT_H__
uint32_t photon_bits_to_sdl_pixelformat(uint32_t pixelfmt);
uint32_t photon_sdl_to_bits_pixelformat(uint32_t pixelfmt);
uint32_t photon_image_to_sdl_pixelformat(uint32_t pixelfmt);
uint32_t photon_sdl_to_image_pixelformat(uint32_t pixelfmt);
#endif /* __SDL_PHOTON_PIXELFMT_H__ */
/* vi: set ts=4 sw=4 expandtab: */

View file

@ -35,24 +35,24 @@
#include "SDL_photon.h"
static SDL_Renderer* photon_createrenderer(SDL_Window* window, Uint32 flags);
static int photon_displaymodechanged(SDL_Renderer* renderer);
static int photon_activaterenderer(SDL_Renderer* renderer);
static int photon_createtexture(SDL_Renderer* renderer, SDL_Texture* texture);
static int photon_querytexturepixels(SDL_Renderer* renderer, SDL_Texture* texture, void** pixels, int* pitch);
static int photon_settexturepalette(SDL_Renderer* renderer, SDL_Texture* texture, const SDL_Color* colors, int firstcolor, int ncolors);
static int photon_gettexturepalette(SDL_Renderer* renderer, SDL_Texture* texture, SDL_Color* colors, int firstcolor, int ncolors);
static int photon_settexturecolormod(SDL_Renderer* renderer, SDL_Texture* texture);
static int photon_settexturealphamod(SDL_Renderer* renderer, SDL_Texture* texture);
static int photon_settextureblendmode(SDL_Renderer* renderer, SDL_Texture* texture);
static int photon_settexturescalemode(SDL_Renderer* renderer, SDL_Texture* texture);
static int photon_updatetexture(SDL_Renderer* renderer, SDL_Texture* texture, const SDL_Rect* rect, const void* pixels, int pitch);
static int photon_locktexture(SDL_Renderer* renderer, SDL_Texture* texture, const SDL_Rect* rect, int markDirty, void** pixels, int* pitch);
static int photon_displaymodechanged(SDL_Renderer* renderer);
static int photon_activaterenderer(SDL_Renderer* renderer);
static int photon_createtexture(SDL_Renderer* renderer, SDL_Texture* texture);
static int photon_querytexturepixels(SDL_Renderer* renderer, SDL_Texture* texture, void** pixels, int* pitch);
static int photon_settexturepalette(SDL_Renderer* renderer, SDL_Texture* texture, const SDL_Color* colors, int firstcolor, int ncolors);
static int photon_gettexturepalette(SDL_Renderer* renderer, SDL_Texture* texture, SDL_Color* colors, int firstcolor, int ncolors);
static int photon_settexturecolormod(SDL_Renderer* renderer, SDL_Texture* texture);
static int photon_settexturealphamod(SDL_Renderer* renderer, SDL_Texture* texture);
static int photon_settextureblendmode(SDL_Renderer* renderer, SDL_Texture* texture);
static int photon_settexturescalemode(SDL_Renderer* renderer, SDL_Texture* texture);
static int photon_updatetexture(SDL_Renderer* renderer, SDL_Texture* texture, const SDL_Rect* rect, const void* pixels, int pitch);
static int photon_locktexture(SDL_Renderer* renderer, SDL_Texture* texture, const SDL_Rect* rect, int markDirty, void** pixels, int* pitch);
static void photon_unlocktexture(SDL_Renderer* renderer, SDL_Texture* texture);
static void photon_dirtytexture(SDL_Renderer* renderer, SDL_Texture* texture, int numrects, const SDL_Rect* rects);
static int photon_renderpoint(SDL_Renderer* renderer, int x, int y);
static int photon_renderline(SDL_Renderer* renderer, int x1, int y1, int x2, int y2);
static int photon_renderfill(SDL_Renderer* renderer, const SDL_Rect* rect);
static int photon_rendercopy(SDL_Renderer* renderer, SDL_Texture* texture, const SDL_Rect* srcrect, const SDL_Rect* dstrect);
static int photon_renderpoint(SDL_Renderer* renderer, int x, int y);
static int photon_renderline(SDL_Renderer* renderer, int x1, int y1, int x2, int y2);
static int photon_renderfill(SDL_Renderer* renderer, const SDL_Rect* rect);
static int photon_rendercopy(SDL_Renderer* renderer, SDL_Texture* texture, const SDL_Rect* srcrect, const SDL_Rect* dstrect);
static void photon_renderpresent(SDL_Renderer* renderer);
static void photon_destroytexture(SDL_Renderer* renderer, SDL_Texture* texture);
static void photon_destroyrenderer(SDL_Renderer* renderer);