Commit 483f2ba3 authored by Sam Lantinga's avatar Sam Lantinga

indent

--HG--
extra : convert_revision : svn%3Ac70aab31-4412-0410-b14c-859654838e24/trunk%403608
parent 3071101f
......@@ -174,7 +174,8 @@ void
drawBlank(int x, int y)
{
SDL_Rect rect = { x, y, GLYPH_SIZE_SCREEN, GLYPH_SIZE_SCREEN };
SDL_SetRenderDrawColor(bg_color.r, bg_color.g, bg_color.b, bg_color.unused);
SDL_SetRenderDrawColor(bg_color.r, bg_color.g, bg_color.b,
bg_color.unused);
SDL_RenderFill(&rect);
}
......@@ -254,7 +255,8 @@ main(int argc, char *argv[])
loadFont();
/* draw the background, we'll just paint over it */
SDL_SetRenderDrawColor(bg_color.r, bg_color.g, bg_color.b, bg_color.unused);
SDL_SetRenderDrawColor(bg_color.r, bg_color.g, bg_color.b,
bg_color.unused);
SDL_RenderFill(NULL);
SDL_RenderPresent();
......
......@@ -168,7 +168,7 @@ render(void)
{
int i;
SDL_SetRenderDrawColor(50, 50, 50, 255);
SDL_RenderFill(NULL); /* draw background (gray) */
SDL_RenderFill(NULL); /* draw background (gray) */
/* draw the drum buttons */
for (i = 0; i < NUM_DRUMS; i++) {
SDL_Color color =
......
......@@ -50,7 +50,7 @@ extern "C"
#ifndef GL_API
#define GL_API
#endif /* GL_API */
#endif /* GL_API */
/*
** License Applicability. Except to the extent portions of this file are
......@@ -347,10 +347,10 @@ extern "C"
/* OpenGL ES 1.0 defines, they gone in 1.1 and 2.0 */
#ifndef GL_MAX_ELEMENTS_VERTICES
#define GL_MAX_ELEMENTS_VERTICES 0x80E8
#endif /* GL_MAX_ELEMENTS_VERTICES */
#endif /* GL_MAX_ELEMENTS_VERTICES */
#ifndef GL_MAX_ELEMENTS_INDICES
#define GL_MAX_ELEMENTS_INDICES 0x80E9
#endif /* GL_MAX_ELEMENTS_INDICES */
#endif /* GL_MAX_ELEMENTS_INDICES */
/* GetTextureParameter */
/* GL_TEXTURE_MAG_FILTER */
......@@ -669,7 +669,7 @@ extern "C"
/* GL_OES_draw_texture */
#ifndef GL_OES_draw_texture
#define GL_TEXTURE_CROP_RECT_OES 0x8B9D
#endif /* GL_OES_draw_texture */
#endif /* GL_OES_draw_texture */
/* GL_OES_vertex_buffer_object */
#ifndef GL_OES_vertex_buffer_object
......@@ -687,7 +687,7 @@ extern "C"
#define GL_BUFFER_SIZE_OES 0x8764
#define GL_BUFFER_USAGE_OES 0x8765
#define GL_BUFFER_ACCESS_OES 0x88BB
#endif /* GL_OES_vertex_buffer_object */
#endif /* GL_OES_vertex_buffer_object */
/*************************************************************/
......@@ -973,8 +973,9 @@ extern "C"
/* GL_OES_query_matrix */
#ifndef GL_OES_query_matrix
#define GL_OES_query_matrix 1
GL_API GLbitfield GL_APIENTRY glQueryMatrixxOES(GLfixed mantissa[16], GLint exponent[16]);
#endif /* GL_OES_query_matrix */
GL_API GLbitfield GL_APIENTRY glQueryMatrixxOES(GLfixed mantissa[16],
GLint exponent[16]);
#endif /* GL_OES_query_matrix */
/* GL_OES_point_sprite */
#ifndef GL_OES_point_sprite
......@@ -984,26 +985,35 @@ extern "C"
/* GL_OES_draw_texture */
#ifndef GL_OES_draw_texture
#define GL_OES_draw_texture 1
GL_API void GL_APIENTRY glDrawTexsOES (GLshort x, GLshort y, GLshort z, GLshort width, GLshort height);
GL_API void GL_APIENTRY glDrawTexiOES (GLint x, GLint y, GLint z, GLint width, GLint height);
GL_API void GL_APIENTRY glDrawTexxOES (GLfixed x, GLfixed y, GLfixed z, GLfixed width, GLfixed height);
GL_API void GL_APIENTRY glDrawTexsvOES (const GLshort *coords);
GL_API void GL_APIENTRY glDrawTexivOES (const GLint *coords);
GL_API void GL_APIENTRY glDrawTexxvOES (const GLfixed *coords);
GL_API void GL_APIENTRY glDrawTexfOES (GLfloat x, GLfloat y, GLfloat z, GLfloat width, GLfloat height);
GL_API void GL_APIENTRY glDrawTexfvOES (const GLfloat *coords);
#endif /* GL_OES_draw_texture */
GL_API void GL_APIENTRY glDrawTexsOES(GLshort x, GLshort y, GLshort z,
GLshort width, GLshort height);
GL_API void GL_APIENTRY glDrawTexiOES(GLint x, GLint y, GLint z,
GLint width, GLint height);
GL_API void GL_APIENTRY glDrawTexxOES(GLfixed x, GLfixed y, GLfixed z,
GLfixed width, GLfixed height);
GL_API void GL_APIENTRY glDrawTexsvOES(const GLshort * coords);
GL_API void GL_APIENTRY glDrawTexivOES(const GLint * coords);
GL_API void GL_APIENTRY glDrawTexxvOES(const GLfixed * coords);
GL_API void GL_APIENTRY glDrawTexfOES(GLfloat x, GLfloat y, GLfloat z,
GLfloat width, GLfloat height);
GL_API void GL_APIENTRY glDrawTexfvOES(const GLfloat * coords);
#endif /* GL_OES_draw_texture */
/* GL_OES_single_precision */
#ifndef GL_OES_single_precision
#define GL_OES_single_precision 1
GL_API void GL_APIENTRY glDepthRangefOES (GLclampf zNear, GLclampf zFar);
GL_API void GL_APIENTRY glFrustumfOES (GLfloat left, GLfloat right, GLfloat bottom, GLfloat top, GLfloat zNear, GLfloat zFar);
GL_API void GL_APIENTRY glOrthofOES (GLfloat left, GLfloat right, GLfloat bottom, GLfloat top, GLfloat zNear, GLfloat zFar);
GL_API void GL_APIENTRY glClipPlanefOES (GLenum plane, const GLfloat *equation);
GL_API void GL_APIENTRY glGetClipPlanefOES (GLenum pname, GLfloat eqn[4]);
GL_API void GL_APIENTRY glClearDepthfOES (GLclampf depth);
#endif /* GL_OES_single_precision */
GL_API void GL_APIENTRY glDepthRangefOES(GLclampf zNear, GLclampf zFar);
GL_API void GL_APIENTRY glFrustumfOES(GLfloat left, GLfloat right,
GLfloat bottom, GLfloat top,
GLfloat zNear, GLfloat zFar);
GL_API void GL_APIENTRY glOrthofOES(GLfloat left, GLfloat right,
GLfloat bottom, GLfloat top,
GLfloat zNear, GLfloat zFar);
GL_API void GL_APIENTRY glClipPlanefOES(GLenum plane,
const GLfloat * equation);
GL_API void GL_APIENTRY glGetClipPlanefOES(GLenum pname, GLfloat eqn[4]);
GL_API void GL_APIENTRY glClearDepthfOES(GLclampf depth);
#endif /* GL_OES_single_precision */
/* GL_OES_vertex_buffer_object */
#ifndef GL_OES_vertex_buffer_object
......@@ -1012,10 +1022,12 @@ extern "C"
GL_API void APIENTRY glDeleteBuffersOES(GLsizei, const GLuint *);
GL_API void APIENTRY glGenBuffersOES(GLsizei, GLuint *);
GL_API GLboolean APIENTRY glIsBufferOES(GLuint);
GL_API void APIENTRY glBufferDataOES(GLenum, GLsizeiptr, const GLvoid *, GLenum);
GL_API void APIENTRY glBufferSubDataOES(GLenum, GLintptr, GLsizeiptr, const GLvoid *);
GL_API void APIENTRY glBufferDataOES(GLenum, GLsizeiptr, const GLvoid *,
GLenum);
GL_API void APIENTRY glBufferSubDataOES(GLenum, GLintptr, GLsizeiptr,
const GLvoid *);
GL_API void APIENTRY glGetBufferParameterivOES(GLenum, GLenum, GLint *);
#endif /* GL_OES_vertex_buffer_object */
#endif /* GL_OES_vertex_buffer_object */
#ifdef __cplusplus
}
......
......@@ -271,8 +271,8 @@ typedef enum
SDL_GL_MULTISAMPLESAMPLES,
SDL_GL_ACCELERATED_VISUAL,
SDL_GL_RETAINED_BACKING,
SDL_GL_CONTEXT_MAJOR_VERSION,
SDL_GL_CONTEXT_MINOR_VERSION
SDL_GL_CONTEXT_MAJOR_VERSION,
SDL_GL_CONTEXT_MINOR_VERSION
} SDL_GLattr;
......
......@@ -494,7 +494,7 @@ SDL_SetVideoMode(int width, int height, int bpp, Uint32 flags)
return NULL;
}
}
SDL_GetDesktopDisplayMode(&desktop_mode);
if (width == 0) {
......
......@@ -477,7 +477,8 @@ SDL_RunAudio(void *devicep)
/* Wait for an audio buffer to become available */
current_audio.impl.WaitDevice(device);
} else {
SDL_Delay((device->spec.samples * 1000) / device->spec.freq);
SDL_Delay((device->spec.samples * 1000) /
device->spec.freq);
}
}
......@@ -525,7 +526,7 @@ SDL_RunAudio(void *devicep)
/* Wait for an audio buffer to become available */
current_audio.impl.WaitDevice(device);
} else {
SDL_Delay((device->spec.samples * 1000) / device->spec.freq);
SDL_Delay((device->spec.samples * 1000) / device->spec.freq);
}
}
}
......
......@@ -59,888 +59,840 @@
struct BuggyCards
{
char* cardname;
char *cardname;
unsigned long bugtype;
};
#define QSA_WA_CARDS 3
#define QSA_MAX_CARD_NAME_LENGTH 33
struct BuggyCards buggycards[QSA_WA_CARDS]=
{
{"Sound Blaster Live!", QSA_MMAP_WORKAROUND},
{"Vortex 8820", QSA_MMAP_WORKAROUND},
{"Vortex 8830", QSA_MMAP_WORKAROUND},
struct BuggyCards buggycards[QSA_WA_CARDS] = {
{"Sound Blaster Live!", QSA_MMAP_WORKAROUND},
{"Vortex 8820", QSA_MMAP_WORKAROUND},
{"Vortex 8830", QSA_MMAP_WORKAROUND},
};
/* List of found devices */
#define QSA_MAX_DEVICES 32
#define QSA_MAX_NAME_LENGTH 81+16 /* Hardcoded in QSA, can't be changed */
#define QSA_MAX_NAME_LENGTH 81+16 /* Hardcoded in QSA, can't be changed */
typedef struct _QSA_Device
{
char name[QSA_MAX_NAME_LENGTH]; /* Long audio device name for SDL */
int cardno;
int deviceno;
char name[QSA_MAX_NAME_LENGTH]; /* Long audio device name for SDL */
int cardno;
int deviceno;
} QSA_Device;
QSA_Device qsa_playback_device[QSA_MAX_DEVICES];
uint32_t qsa_playback_devices;
uint32_t qsa_playback_devices;
QSA_Device qsa_capture_device[QSA_MAX_DEVICES];
uint32_t qsa_capture_devices;
uint32_t qsa_capture_devices;
static inline void QSA_SetError(const char* fn, int status)
static inline void
QSA_SetError(const char *fn, int status)
{
SDL_SetError("QSA: %s() failed: %s", fn, snd_strerror(status));
SDL_SetError("QSA: %s() failed: %s", fn, snd_strerror(status));
}
/* card names check to apply the workarounds */
static int QSA_CheckBuggyCards(_THIS, unsigned long checkfor)
static int
QSA_CheckBuggyCards(_THIS, unsigned long checkfor)
{
char scardname[QSA_MAX_CARD_NAME_LENGTH];
int it;
if (snd_card_get_name(this->hidden->cardno, scardname, QSA_MAX_CARD_NAME_LENGTH-1)<0)
{
return 0;
}
for (it=0; it<QSA_WA_CARDS; it++)
{
if (SDL_strcmp(buggycards[it].cardname, scardname)==0)
{
if (buggycards[it].bugtype==checkfor)
{
return 1;
}
}
}
return 0;
char scardname[QSA_MAX_CARD_NAME_LENGTH];
int it;
if (snd_card_get_name
(this->hidden->cardno, scardname, QSA_MAX_CARD_NAME_LENGTH - 1) < 0) {
return 0;
}
for (it = 0; it < QSA_WA_CARDS; it++) {
if (SDL_strcmp(buggycards[it].cardname, scardname) == 0) {
if (buggycards[it].bugtype == checkfor) {
return 1;
}
}
}
return 0;
}
static void QSA_ThreadInit(_THIS)
static void
QSA_ThreadInit(_THIS)
{
struct sched_param param;
int status;
struct sched_param param;
int status;
/* Increase default 10 priority to 25 to avoid jerky sound */
status=SchedGet(0, 0, &param);
param.sched_priority=param.sched_curpriority + 15;
status=SchedSet(0, 0, SCHED_NOCHANGE, &param);
/* Increase default 10 priority to 25 to avoid jerky sound */
status = SchedGet(0, 0, &param);
param.sched_priority = param.sched_curpriority + 15;
status = SchedSet(0, 0, SCHED_NOCHANGE, &param);
}
/* PCM channel parameters initialize function */
static void QSA_InitAudioParams(snd_pcm_channel_params_t* cpars)
static void
QSA_InitAudioParams(snd_pcm_channel_params_t * cpars)
{
SDL_memset(cpars, 0, sizeof(snd_pcm_channel_params_t));
cpars->channel=SND_PCM_CHANNEL_PLAYBACK;
cpars->mode=SND_PCM_MODE_BLOCK;
cpars->start_mode=SND_PCM_START_DATA;
cpars->stop_mode=SND_PCM_STOP_STOP;
cpars->format.format=SND_PCM_SFMT_S16_LE;
cpars->format.interleave=1;
cpars->format.rate=DEFAULT_CPARAMS_RATE;
cpars->format.voices=DEFAULT_CPARAMS_VOICES;
cpars->buf.block.frag_size=DEFAULT_CPARAMS_FRAG_SIZE;
cpars->buf.block.frags_min=DEFAULT_CPARAMS_FRAGS_MIN;
cpars->buf.block.frags_max=DEFAULT_CPARAMS_FRAGS_MAX;
SDL_memset(cpars, 0, sizeof(snd_pcm_channel_params_t));
cpars->channel = SND_PCM_CHANNEL_PLAYBACK;
cpars->mode = SND_PCM_MODE_BLOCK;
cpars->start_mode = SND_PCM_START_DATA;
cpars->stop_mode = SND_PCM_STOP_STOP;
cpars->format.format = SND_PCM_SFMT_S16_LE;
cpars->format.interleave = 1;
cpars->format.rate = DEFAULT_CPARAMS_RATE;
cpars->format.voices = DEFAULT_CPARAMS_VOICES;
cpars->buf.block.frag_size = DEFAULT_CPARAMS_FRAG_SIZE;
cpars->buf.block.frags_min = DEFAULT_CPARAMS_FRAGS_MIN;
cpars->buf.block.frags_max = DEFAULT_CPARAMS_FRAGS_MAX;
}
/* This function waits until it is possible to write a full sound buffer */
static void QSA_WaitDevice(_THIS)
static void
QSA_WaitDevice(_THIS)
{
fd_set wfds;
fd_set rfds;
int selectret;
struct timeval timeout;
if (!this->hidden->iscapture)
{
FD_ZERO(&wfds);
FD_SET(this->hidden->audio_fd, &wfds);
}
else
{
FD_ZERO(&rfds);
FD_SET(this->hidden->audio_fd, &rfds);
}
do {
/* Setup timeout for playing one fragment equal to 2 seconds */
/* If timeout occured than something wrong with hardware or driver */
/* For example, Vortex 8820 audio driver stucks on second DAC because */
/* it doesn't exist ! */
timeout.tv_sec=2;
timeout.tv_usec=0;
this->hidden->timeout_on_wait=0;
if (!this->hidden->iscapture)
{
selectret=select(this->hidden->audio_fd+1, NULL, &wfds, NULL, &timeout);
}
else
{
selectret=select(this->hidden->audio_fd+1, &rfds, NULL, NULL, &timeout);
}
switch(selectret)
{
case -1:
{
SDL_SetError("QSA: select() failed: %s\n", strerror(errno));
return;
}
break;
case 0:
{
SDL_SetError("QSA: timeout on buffer waiting occured\n");
this->hidden->timeout_on_wait=1;
return;
}
break;
default:
{
if (!this->hidden->iscapture)
{
if (FD_ISSET(this->hidden->audio_fd, &wfds))
{
return;
fd_set wfds;
fd_set rfds;
int selectret;
struct timeval timeout;
if (!this->hidden->iscapture) {
FD_ZERO(&wfds);
FD_SET(this->hidden->audio_fd, &wfds);
} else {
FD_ZERO(&rfds);
FD_SET(this->hidden->audio_fd, &rfds);
}
do {
/* Setup timeout for playing one fragment equal to 2 seconds */
/* If timeout occured than something wrong with hardware or driver */
/* For example, Vortex 8820 audio driver stucks on second DAC because */
/* it doesn't exist ! */
timeout.tv_sec = 2;
timeout.tv_usec = 0;
this->hidden->timeout_on_wait = 0;
if (!this->hidden->iscapture) {
selectret =
select(this->hidden->audio_fd + 1, NULL, &wfds, NULL,
&timeout);
} else {
selectret =
select(this->hidden->audio_fd + 1, &rfds, NULL, NULL,
&timeout);
}
switch (selectret) {
case -1:
{
SDL_SetError("QSA: select() failed: %s\n", strerror(errno));
return;
}
break;
case 0:
{
SDL_SetError("QSA: timeout on buffer waiting occured\n");
this->hidden->timeout_on_wait = 1;
return;
}
break;
default:
{
if (!this->hidden->iscapture) {
if (FD_ISSET(this->hidden->audio_fd, &wfds)) {
return;
}
}
else
{
if (FD_ISSET(this->hidden->audio_fd, &rfds))
{
return;
} else {
if (FD_ISSET(this->hidden->audio_fd, &rfds)) {
return;
}
}
}
break;
}
} while (1);
}
}
break;
}
} while (1);
}
static void QSA_PlayDevice(_THIS)
static void
QSA_PlayDevice(_THIS)
{
snd_pcm_channel_status_t cstatus;
int written;
int status;
int towrite;
void* pcmbuffer;
if ((!this->enabled) || (!this->hidden))
{
return;
}
towrite = this->spec.size;
pcmbuffer = this->hidden->pcm_buf;
/* Write the audio data, checking for EAGAIN (buffer full) and underrun */
do {
written=snd_pcm_plugin_write(this->hidden->audio_handle, pcmbuffer, towrite);
if (written!=towrite)
{
/* Check if samples playback got stuck somewhere in hardware or in */
/* the audio device driver */
if ((errno==EAGAIN) && (written==0))
{
if (this->hidden->timeout_on_wait!=0)
{
SDL_SetError("QSA: buffer playback timeout\n");
return;
}
}
/* Check for errors or conditions */
if ((errno==EAGAIN)||(errno==EWOULDBLOCK))
{
/* Let a little CPU time go by and try to write again */
SDL_Delay(1);
/* if we wrote some data */
towrite-=written;
pcmbuffer+=written*this->spec.channels;
continue;
}
else
{
if ((errno==EINVAL)||(errno==EIO))
{
SDL_memset(&cstatus, 0, sizeof(cstatus));
if (!this->hidden->iscapture)
{
cstatus.channel=SND_PCM_CHANNEL_PLAYBACK;
}
else
{
cstatus.channel=SND_PCM_CHANNEL_CAPTURE;
}
status=snd_pcm_plugin_status(this->hidden->audio_handle, &cstatus);
if (status<0)
{
QSA_SetError("snd_pcm_plugin_status", status);
return;
}
if ((cstatus.status==SND_PCM_STATUS_UNDERRUN) ||
(cstatus.status==SND_PCM_STATUS_READY))
{
if (!this->hidden->iscapture)
{
status=snd_pcm_plugin_prepare(this->hidden->audio_handle,
SND_PCM_CHANNEL_PLAYBACK);
}
else
{
status=snd_pcm_plugin_prepare(this->hidden->audio_handle,
SND_PCM_CHANNEL_CAPTURE);
}
if (status<0)
{
QSA_SetError("snd_pcm_plugin_prepare", status);
return;
}
}
continue;
snd_pcm_channel_status_t cstatus;
int written;
int status;
int towrite;
void *pcmbuffer;
if ((!this->enabled) || (!this->hidden)) {
return;
}
towrite = this->spec.size;
pcmbuffer = this->hidden->pcm_buf;
/* Write the audio data, checking for EAGAIN (buffer full) and underrun */
do {
written =
snd_pcm_plugin_write(this->hidden->audio_handle, pcmbuffer,
towrite);
if (written != towrite) {
/* Check if samples playback got stuck somewhere in hardware or in */
/* the audio device driver */
if ((errno == EAGAIN) && (written == 0)) {
if (this->hidden->timeout_on_wait != 0) {
SDL_SetError("QSA: buffer playback timeout\n");
return;
}
}
else
{
return;
/* Check for errors or conditions */
if ((errno == EAGAIN) || (errno == EWOULDBLOCK)) {
/* Let a little CPU time go by and try to write again */
SDL_Delay(1);
/* if we wrote some data */
towrite -= written;
pcmbuffer += written * this->spec.channels;
continue;
} else {
if ((errno == EINVAL) || (errno == EIO)) {
SDL_memset(&cstatus, 0, sizeof(cstatus));
if (!this->hidden->iscapture) {
cstatus.channel = SND_PCM_CHANNEL_PLAYBACK;
} else {
cstatus.channel = SND_PCM_CHANNEL_CAPTURE;
}
status =
snd_pcm_plugin_status(this->hidden->audio_handle,
&cstatus);
if (status < 0) {
QSA_SetError("snd_pcm_plugin_status", status);
return;
}
if ((cstatus.status == SND_PCM_STATUS_UNDERRUN) ||
(cstatus.status == SND_PCM_STATUS_READY)) {
if (!this->hidden->iscapture) {
status =
snd_pcm_plugin_prepare(this->hidden->
audio_handle,
SND_PCM_CHANNEL_PLAYBACK);
} else {
status =
snd_pcm_plugin_prepare(this->hidden->
audio_handle,
SND_PCM_CHANNEL_CAPTURE);
}
if (status < 0) {
QSA_SetError("snd_pcm_plugin_prepare", status);
return;
}
}
continue;
} else {
return;
}
}
}
}
else
{
/* we wrote all remaining data */
towrite -= written;
pcmbuffer += written * this->spec.channels;
}
} while ((towrite>0) && (this->enabled));
/* If we couldn't write, assume fatal error for now */
if (towrite!=0)
{
this->enabled=0;
}
} else {
/* we wrote all remaining data */
towrite -= written;
pcmbuffer += written * this->spec.channels;
}
} while ((towrite > 0) && (this->enabled));
/* If we couldn't write, assume fatal error for now */
if (towrite != 0) {
this->enabled = 0;
}
}
static Uint8* QSA_GetDeviceBuf(_THIS)
static Uint8 *
QSA_GetDeviceBuf(_THIS)
{
return this->hidden->pcm_buf;
return this->hidden->pcm_buf;
}
static void QSA_CloseDevice(_THIS)
static void
QSA_CloseDevice(_THIS)
{
if (this->hidden!=NULL)
{
if (this->hidden->audio_handle!=NULL)
{
if (!this->hidden->iscapture)
{
/* Finish playing available samples */
snd_pcm_plugin_flush(this->hidden->audio_handle, SND_PCM_CHANNEL_PLAYBACK);
}
else
{
/* Cancel unread samples during capture */
snd_pcm_plugin_flush(this->hidden->audio_handle, SND_PCM_CHANNEL_CAPTURE);
}
snd_pcm_close(this->hidden->audio_handle);
this->hidden->audio_handle=NULL;
}
if (this->hidden->pcm_buf!=NULL)
{
SDL_FreeAudioMem(this->hidden->pcm_buf);
this->hidden->pcm_buf=NULL;
}
SDL_free(this->hidden);
this->hidden=NULL;
}
if (this->hidden != NULL) {
if (this->hidden->audio_handle != NULL) {
if (!this->hidden->iscapture) {
/* Finish playing available samples */
snd_pcm_plugin_flush(this->hidden->audio_handle,
SND_PCM_CHANNEL_PLAYBACK);
} else {
/* Cancel unread samples during capture */
snd_pcm_plugin_flush(this->hidden->audio_handle,
SND_PCM_CHANNEL_CAPTURE);
}
snd_pcm_close(this->hidden->audio_handle);
this->hidden->audio_handle = NULL;
}
if (this->hidden->pcm_buf != NULL) {
SDL_FreeAudioMem(this->hidden->pcm_buf);
this->hidden->pcm_buf = NULL;
}
SDL_free(this->hidden);
this->hidden = NULL;
}
}
static int QSA_OpenDevice(_THIS, const char* devname, int iscapture)
static int
QSA_OpenDevice(_THIS, const char *devname, int iscapture)
{
int status=0;
int format=0;
SDL_AudioFormat test_format=0;
int found=0;
snd_pcm_channel_setup_t csetup;
snd_pcm_channel_params_t cparams;
/* Initialize all variables that we clean on shutdown */
this->hidden=(struct SDL_PrivateAudioData*)SDL_calloc(1, (sizeof(struct SDL_PrivateAudioData)));
if (this->hidden==NULL)
{
SDL_OutOfMemory();
return 0;
}
SDL_memset(this->hidden, 0, sizeof(struct SDL_PrivateAudioData));
/* Initialize channel transfer parameters to default */
QSA_InitAudioParams(&cparams);
/* Initialize channel direction: capture or playback */
this->hidden->iscapture=iscapture;
/* Find deviceid and cardid by device name for playback */
if ((!this->hidden->iscapture) && (devname!=NULL))
{
uint32_t device;
int32_t status;
/* Search in the playback devices */
device=0;
do {
status=SDL_strcmp(qsa_playback_device[device].name, devname);
if (status==0)
{
/* Found requested device */
this->hidden->deviceno=qsa_playback_device[device].deviceno;
this->hidden->cardno=qsa_playback_device[device].cardno;
break;
}
device++;
if (device>=qsa_playback_devices)
{
int status = 0;
int format = 0;
SDL_AudioFormat test_format = 0;
int found = 0;
snd_pcm_channel_setup_t csetup;
snd_pcm_channel_params_t cparams;
/* Initialize all variables that we clean on shutdown */
this->hidden =
(struct SDL_PrivateAudioData *) SDL_calloc(1,
(sizeof
(struct
SDL_PrivateAudioData)));
if (this->hidden == NULL) {
SDL_OutOfMemory();
return 0;
}
SDL_memset(this->hidden, 0, sizeof(struct SDL_PrivateAudioData));
/* Initialize channel transfer parameters to default */
QSA_InitAudioParams(&cparams);
/* Initialize channel direction: capture or playback */
this->hidden->iscapture = iscapture;
/* Find deviceid and cardid by device name for playback */
if ((!this->hidden->iscapture) && (devname != NULL)) {
uint32_t device;
int32_t status;
/* Search in the playback devices */
device = 0;
do {
status = SDL_strcmp(qsa_playback_device[device].name, devname);
if (status == 0) {
/* Found requested device */
this->hidden->deviceno = qsa_playback_device[device].deviceno;
this->hidden->cardno = qsa_playback_device[device].cardno;
break;
}
device++;
if (device >= qsa_playback_devices) {
QSA_CloseDevice(this);
SDL_SetError("No such playback device");
return 0;
}
} while (1);
}
/* Find deviceid and cardid by device name for capture */
if ((this->hidden->iscapture) && (devname != NULL)) {
/* Search in the capture devices */
uint32_t device;
int32_t status;
/* Searching in the playback devices */
device = 0;
do {
status = SDL_strcmp(qsa_capture_device[device].name, devname);
if (status == 0) {
/* Found requested device */
this->hidden->deviceno = qsa_capture_device[device].deviceno;
this->hidden->cardno = qsa_capture_device[device].cardno;
break;
}
device++;
if (device >= qsa_capture_devices) {
QSA_CloseDevice(this);
SDL_SetError("No such capture device");
return 0;
}
} while (1);
}
/* Check if SDL requested default audio device */
if (devname == NULL) {
/* Open system default audio device */
if (!this->hidden->iscapture) {
status = snd_pcm_open_preferred(&this->hidden->audio_handle,
&this->hidden->cardno,
&this->hidden->deviceno,
SND_PCM_OPEN_PLAYBACK);
} else {
status = snd_pcm_open_preferred(&this->hidden->audio_handle,
&this->hidden->cardno,
&this->hidden->deviceno,
SND_PCM_OPEN_CAPTURE);
}
} else {
/* Open requested audio device */
if (!this->hidden->iscapture) {
status =
snd_pcm_open(&this->hidden->audio_handle,
this->hidden->cardno, this->hidden->deviceno,
SND_PCM_OPEN_PLAYBACK);
} else {
status =
snd_pcm_open(&this->hidden->audio_handle,
this->hidden->cardno, this->hidden->deviceno,
SND_PCM_OPEN_CAPTURE);
}
}
/* Check if requested device is opened */
if (status < 0) {
this->hidden->audio_handle = NULL;
QSA_CloseDevice(this);
QSA_SetError("snd_pcm_open", status);
return 0;
}
if (!QSA_CheckBuggyCards(this, QSA_MMAP_WORKAROUND)) {
/* Disable QSA MMAP plugin for buggy audio drivers */
status =
snd_pcm_plugin_set_disable(this->hidden->audio_handle,
PLUGIN_DISABLE_MMAP);
if (status < 0) {
QSA_CloseDevice(this);
SDL_SetError("No such playback device");
QSA_SetError("snd_pcm_plugin_set_disable", status);
return 0;
}
} while(1);
}
/* Find deviceid and cardid by device name for capture */
if ((this->hidden->iscapture) && (devname!=NULL))
{
/* Search in the capture devices */
uint32_t device;
int32_t status;
/* Searching in the playback devices */
device=0;
do {
status=SDL_strcmp(qsa_capture_device[device].name, devname);
if (status==0)
{
/* Found requested device */
this->hidden->deviceno=qsa_capture_device[device].deviceno;
this->hidden->cardno=qsa_capture_device[device].cardno;
}
}
/* Try for a closest match on audio format */
format = 0;
/* can't use format as SND_PCM_SFMT_U8 = 0 in qsa */
found = 0;
for (test_format = SDL_FirstAudioFormat(this->spec.format); !found;) {
/* if match found set format to equivalent QSA format */
switch (test_format) {
case AUDIO_U8:
{
format = SND_PCM_SFMT_U8;
found = 1;
}
break;
}
device++;
if (device>=qsa_capture_devices)
{
QSA_CloseDevice(this);
SDL_SetError("No such capture device");
return 0;
}
} while(1);
}
/* Check if SDL requested default audio device */
if (devname==NULL)
{
/* Open system default audio device */
if (!this->hidden->iscapture)
{
status=snd_pcm_open_preferred(&this->hidden->audio_handle,
&this->hidden->cardno,
&this->hidden->deviceno, SND_PCM_OPEN_PLAYBACK);
}
else
{
status=snd_pcm_open_preferred(&this->hidden->audio_handle,
&this->hidden->cardno,
&this->hidden->deviceno, SND_PCM_OPEN_CAPTURE);
}
}
else
{
/* Open requested audio device */
if (!this->hidden->iscapture)
{
status=snd_pcm_open(&this->hidden->audio_handle, this->hidden->cardno,
this->hidden->deviceno, SND_PCM_OPEN_PLAYBACK);
}
else
{
status=snd_pcm_open(&this->hidden->audio_handle, this->hidden->cardno,
this->hidden->deviceno, SND_PCM_OPEN_CAPTURE);
}
}
/* Check if requested device is opened */
if (status<0)
{
this->hidden->audio_handle=NULL;
QSA_CloseDevice(this);
QSA_SetError("snd_pcm_open", status);
return 0;
}
if (!QSA_CheckBuggyCards(this, QSA_MMAP_WORKAROUND))
{
/* Disable QSA MMAP plugin for buggy audio drivers */
status=snd_pcm_plugin_set_disable(this->hidden->audio_handle, PLUGIN_DISABLE_MMAP);
if (status<0)
{
QSA_CloseDevice(this);
QSA_SetError("snd_pcm_plugin_set_disable", status);
return 0;
}
}
/* Try for a closest match on audio format */
format = 0;
/* can't use format as SND_PCM_SFMT_U8 = 0 in qsa */
found = 0;
for (test_format = SDL_FirstAudioFormat(this->spec.format); !found;)
{
/* if match found set format to equivalent QSA format */
switch (test_format)
{
case AUDIO_U8:
{
format=SND_PCM_SFMT_U8;
found=1;
}
break;
case AUDIO_S8:
{
format=SND_PCM_SFMT_S8;
found=1;
}
break;
case AUDIO_S16LSB:
{
format=SND_PCM_SFMT_S16_LE;
found=1;
}
break;
case AUDIO_S16MSB:
{
format=SND_PCM_SFMT_S16_BE;
found=1;
}
break;
case AUDIO_U16LSB:
{
format=SND_PCM_SFMT_U16_LE;
found=1;
}
break;
case AUDIO_U16MSB:
{
format=SND_PCM_SFMT_U16_BE;
found=1;
}
break;
case AUDIO_S32LSB:
{
format=SND_PCM_SFMT_S32_LE;
found=1;
}
break;
case AUDIO_S32MSB:
{
format=SND_PCM_SFMT_S32_BE;
found=1;
}
break;
case AUDIO_F32LSB:
{
format=SND_PCM_SFMT_FLOAT_LE;
found=1;
}
break;
case AUDIO_F32MSB:
{
format=SND_PCM_SFMT_FLOAT_BE;
found=1;
}
break;
default:
{
break;
}
}
if (!found)
{
test_format = SDL_NextAudioFormat();
}
}
/* assumes test_format not 0 on success */
if (test_format==0)
{
QSA_CloseDevice(this);
SDL_SetError("QSA: Couldn't find any hardware audio formats");
return 0;
}
this->spec.format=test_format;
/* Set the audio format */
cparams.format.format=format;
/* Set mono/stereo/4ch/6ch/8ch audio */
cparams.format.voices=this->spec.channels;
/* Set rate */
cparams.format.rate=this->spec.freq;
/* Setup the transfer parameters according to cparams */
status=snd_pcm_plugin_params(this->hidden->audio_handle, &cparams);
if (status<0)
{
QSA_CloseDevice(this);
QSA_SetError("snd_pcm_channel_params", status);
return 0;
}
/* Make sure channel is setup right one last time */
SDL_memset(&csetup, '\0', sizeof(csetup));
if (!this->hidden->iscapture)
{
csetup.channel=SND_PCM_CHANNEL_PLAYBACK;
}
else
{
csetup.channel=SND_PCM_CHANNEL_CAPTURE;
}
/* Setup an audio channel */
if (snd_pcm_plugin_setup(this->hidden->audio_handle, &csetup) < 0)
{
QSA_CloseDevice(this);
SDL_SetError("QSA: Unable to setup channel\n");
return 0;
}
/* Calculate the final parameters for this audio specification */
SDL_CalculateAudioSpec(&this->spec);
this->hidden->pcm_len = this->spec.size;
if (this->hidden->pcm_len==0)
{
this->hidden->pcm_len=csetup.buf.block.frag_size * this->spec.channels *
(snd_pcm_format_width(format) / 8);
}
/*
* Allocate memory to the audio buffer and initialize with silence
* (Note that buffer size must be a multiple of fragment size, so find
* closest multiple)
*/
this->hidden->pcm_buf=(Uint8*)SDL_AllocAudioMem(this->hidden->pcm_len);
if (this->hidden->pcm_buf==NULL)
{
QSA_CloseDevice(this);
SDL_OutOfMemory();
return 0;
}
SDL_memset(this->hidden->pcm_buf, this->spec.silence, this->hidden->pcm_len);
/* get the file descriptor */
if (!this->hidden->iscapture)
{
this->hidden->audio_fd=snd_pcm_file_descriptor(this->hidden->audio_handle,
SND_PCM_CHANNEL_PLAYBACK);
}
else
{
this->hidden->audio_fd=snd_pcm_file_descriptor(this->hidden->audio_handle,
SND_PCM_CHANNEL_CAPTURE);
}
if (this->hidden->audio_fd<0)
{
QSA_CloseDevice(this);
QSA_SetError("snd_pcm_file_descriptor", status);
return 0;
}
/* Prepare an audio channel */
if (!this->hidden->iscapture)
{
/* Prepare audio playback */
status=snd_pcm_plugin_prepare(this->hidden->audio_handle, SND_PCM_CHANNEL_PLAYBACK);
}
else
{
/* Prepare audio capture */
status=snd_pcm_plugin_prepare(this->hidden->audio_handle, SND_PCM_CHANNEL_CAPTURE);
}
if (status<0)
{
QSA_CloseDevice(this);
QSA_SetError("snd_pcm_plugin_prepare", status);
return 0;
}
/* We're really ready to rock and roll. :-) */
return 1;
}
int QSA_DetectDevices(int iscapture)
{
uint32_t it;
uint32_t cards;
uint32_t devices;
int32_t status;
/* Detect amount of available devices */
/* this value can be changed in the runtime */
cards=snd_cards();
/* If io-audio manager is not running we will get 0 as number */
/* of available audio devices */
if (cards==0)
{
/* We have no any available audio devices */
return 0;
}
/* Find requested devices by type */
if (!iscapture)
{
/* Playback devices enumeration requested */
for(it=0; it<cards; it++)
{
devices=0;
do {
status=snd_card_get_longname(it, qsa_playback_device[qsa_playback_devices].name, QSA_MAX_NAME_LENGTH);
if (status==EOK)
case AUDIO_S8:
{
snd_pcm_t* handle;
/* Add device number to device name */
sprintf(qsa_playback_device[qsa_playback_devices].name + SDL_strlen(qsa_playback_device[qsa_playback_devices].name), " d%d", devices);
/* Store associated card number id */
qsa_playback_device[qsa_playback_devices].cardno=it;
/* Check if this device id could play anything */
status=snd_pcm_open(&handle, it, devices, SND_PCM_OPEN_PLAYBACK);
if (status==EOK)
{
qsa_playback_device[qsa_playback_devices].deviceno=devices;
status=snd_pcm_close(handle);
if (status==EOK)
{
qsa_playback_devices++;
}
}
else
{
/* Check if we got end of devices list */
if (status==-ENOENT)
{
break;
}
}
format = SND_PCM_SFMT_S8;
found = 1;
}
else
break;
case AUDIO_S16LSB:
{
break;
format = SND_PCM_SFMT_S16_LE;
found = 1;
}
/* Check if we reached maximum devices count */
if (qsa_playback_devices>=QSA_MAX_DEVICES)
break;
case AUDIO_S16MSB:
{
break;
format = SND_PCM_SFMT_S16_BE;
found = 1;
}
devices++;
} while(1);
/* Check if we reached maximum devices count */
if (qsa_playback_devices>=QSA_MAX_DEVICES)
{
break;
}
}
}
else
{
/* Capture devices enumeration requested */
for(it=0; it<cards; it++)
{
devices=0;
do {
status=snd_card_get_longname(it, qsa_capture_device[qsa_capture_devices].name, QSA_MAX_NAME_LENGTH);
if (status==EOK)
case AUDIO_U16LSB:
{
snd_pcm_t* handle;
/* Add device number to device name */
sprintf(qsa_capture_device[qsa_capture_devices].name + SDL_strlen(qsa_capture_device[qsa_capture_devices].name), " d%d", devices);
/* Store associated card number id */
qsa_capture_device[qsa_capture_devices].cardno=it;
/* Check if this device id could play anything */
status=snd_pcm_open(&handle, it, devices, SND_PCM_OPEN_CAPTURE);
if (status==EOK)
{
qsa_capture_device[qsa_capture_devices].deviceno=devices;
status=snd_pcm_close(handle);
if (status==EOK)
{
qsa_capture_devices++;
}
}
else
{
/* Check if we got end of devices list */
if (status==-ENOENT)
{
break;
}
}
/* Check if we reached maximum devices count */
if (qsa_capture_devices>=QSA_MAX_DEVICES)
{
break;
}
format = SND_PCM_SFMT_U16_LE;
found = 1;
}
else
break;
case AUDIO_U16MSB:
{
break;
format = SND_PCM_SFMT_U16_BE;
found = 1;
}
break;
case AUDIO_S32LSB:
{
format = SND_PCM_SFMT_S32_LE;
found = 1;
}
break;
case AUDIO_S32MSB:
{
format = SND_PCM_SFMT_S32_BE;
found = 1;
}
break;
case AUDIO_F32LSB:
{
format = SND_PCM_SFMT_FLOAT_LE;
found = 1;
}
devices++;
} while(1);
/* Check if we reached maximum devices count */
if (qsa_capture_devices>=QSA_MAX_DEVICES)
{
break;
}
}
}
/* Return amount of available playback or capture devices */
if (!iscapture)
{
return qsa_playback_devices;
}
else
{
return qsa_capture_devices;
}
case AUDIO_F32MSB:
{
format = SND_PCM_SFMT_FLOAT_BE;
found = 1;
}
break;
default:
{
break;
}
}
if (!found) {
test_format = SDL_NextAudioFormat();
}
}
/* assumes test_format not 0 on success */
if (test_format == 0) {
QSA_CloseDevice(this);
SDL_SetError("QSA: Couldn't find any hardware audio formats");
return 0;
}
this->spec.format = test_format;
/* Set the audio format */
cparams.format.format = format;
/* Set mono/stereo/4ch/6ch/8ch audio */
cparams.format.voices = this->spec.channels;
/* Set rate */
cparams.format.rate = this->spec.freq;
/* Setup the transfer parameters according to cparams */
status = snd_pcm_plugin_params(this->hidden->audio_handle, &cparams);
if (status < 0) {
QSA_CloseDevice(this);
QSA_SetError("snd_pcm_channel_params", status);
return 0;
}
/* Make sure channel is setup right one last time */
SDL_memset(&csetup, '\0', sizeof(csetup));
if (!this->hidden->iscapture) {
csetup.channel = SND_PCM_CHANNEL_PLAYBACK;
} else {
csetup.channel = SND_PCM_CHANNEL_CAPTURE;
}
/* Setup an audio channel */
if (snd_pcm_plugin_setup(this->hidden->audio_handle, &csetup) < 0) {
QSA_CloseDevice(this);
SDL_SetError("QSA: Unable to setup channel\n");
return 0;
}
/* Calculate the final parameters for this audio specification */
SDL_CalculateAudioSpec(&this->spec);
this->hidden->pcm_len = this->spec.size;
if (this->hidden->pcm_len == 0) {
this->hidden->pcm_len =
csetup.buf.block.frag_size * this->spec.channels *
(snd_pcm_format_width(format) / 8);
}
/*
* Allocate memory to the audio buffer and initialize with silence
* (Note that buffer size must be a multiple of fragment size, so find
* closest multiple)
*/
this->hidden->pcm_buf =
(Uint8 *) SDL_AllocAudioMem(this->hidden->pcm_len);
if (this->hidden->pcm_buf == NULL) {
QSA_CloseDevice(this);
SDL_OutOfMemory();
return 0;
}
SDL_memset(this->hidden->pcm_buf, this->spec.silence,
this->hidden->pcm_len);
/* get the file descriptor */
if (!this->hidden->iscapture) {
this->hidden->audio_fd =
snd_pcm_file_descriptor(this->hidden->audio_handle,
SND_PCM_CHANNEL_PLAYBACK);
} else {
this->hidden->audio_fd =
snd_pcm_file_descriptor(this->hidden->audio_handle,
SND_PCM_CHANNEL_CAPTURE);
}
if (this->hidden->audio_fd < 0) {
QSA_CloseDevice(this);
QSA_SetError("snd_pcm_file_descriptor", status);
return 0;
}
/* Prepare an audio channel */
if (!this->hidden->iscapture) {
/* Prepare audio playback */
status =
snd_pcm_plugin_prepare(this->hidden->audio_handle,
SND_PCM_CHANNEL_PLAYBACK);
} else {
/* Prepare audio capture */
status =
snd_pcm_plugin_prepare(this->hidden->audio_handle,
SND_PCM_CHANNEL_CAPTURE);
}
if (status < 0) {
QSA_CloseDevice(this);
QSA_SetError("snd_pcm_plugin_prepare", status);
return 0;
}
/* We're really ready to rock and roll. :-) */
return 1;
}
const char* QSA_GetDeviceName(int index, int iscapture)
int
QSA_DetectDevices(int iscapture)
{
if (!iscapture)
{
if (index>=qsa_playback_devices)
{
return "No such playback device";
}
return qsa_playback_device[index].name;
}
else
{
if (index>=qsa_capture_devices)
{
return "No such capture device";
}
return qsa_capture_device[index].name;
}
uint32_t it;
uint32_t cards;
uint32_t devices;
int32_t status;
/* Detect amount of available devices */
/* this value can be changed in the runtime */
cards = snd_cards();
/* If io-audio manager is not running we will get 0 as number */
/* of available audio devices */
if (cards == 0) {
/* We have no any available audio devices */
return 0;
}
/* Find requested devices by type */
if (!iscapture) {
/* Playback devices enumeration requested */
for (it = 0; it < cards; it++) {
devices = 0;
do {
status =
snd_card_get_longname(it,
qsa_playback_device
[qsa_playback_devices].name,
QSA_MAX_NAME_LENGTH);
if (status == EOK) {
snd_pcm_t *handle;
/* Add device number to device name */
sprintf(qsa_playback_device[qsa_playback_devices].name +
SDL_strlen(qsa_playback_device
[qsa_playback_devices].name), " d%d",
devices);
/* Store associated card number id */
qsa_playback_device[qsa_playback_devices].cardno = it;
/* Check if this device id could play anything */
status =
snd_pcm_open(&handle, it, devices,
SND_PCM_OPEN_PLAYBACK);
if (status == EOK) {
qsa_playback_device[qsa_playback_devices].deviceno =
devices;
status = snd_pcm_close(handle);
if (status == EOK) {
qsa_playback_devices++;
}
} else {
/* Check if we got end of devices list */
if (status == -ENOENT) {
break;
}
}
} else {
break;
}
/* Check if we reached maximum devices count */
if (qsa_playback_devices >= QSA_MAX_DEVICES) {
break;
}
devices++;
} while (1);
/* Check if we reached maximum devices count */
if (qsa_playback_devices >= QSA_MAX_DEVICES) {
break;
}
}
} else {
/* Capture devices enumeration requested */
for (it = 0; it < cards; it++) {
devices = 0;
do {
status =
snd_card_get_longname(it,
qsa_capture_device
[qsa_capture_devices].name,
QSA_MAX_NAME_LENGTH);
if (status == EOK) {
snd_pcm_t *handle;
/* Add device number to device name */
sprintf(qsa_capture_device[qsa_capture_devices].name +
SDL_strlen(qsa_capture_device
[qsa_capture_devices].name), " d%d",
devices);
/* Store associated card number id */
qsa_capture_device[qsa_capture_devices].cardno = it;
/* Check if this device id could play anything */
status =
snd_pcm_open(&handle, it, devices,
SND_PCM_OPEN_CAPTURE);
if (status == EOK) {
qsa_capture_device[qsa_capture_devices].deviceno =
devices;
status = snd_pcm_close(handle);
if (status == EOK) {
qsa_capture_devices++;
}
} else {
/* Check if we got end of devices list */
if (status == -ENOENT) {
break;
}
}
/* Check if we reached maximum devices count */
if (qsa_capture_devices >= QSA_MAX_DEVICES) {
break;
}
} else {
break;
}
devices++;
} while (1);
/* Check if we reached maximum devices count */
if (qsa_capture_devices >= QSA_MAX_DEVICES) {
break;
}
}
}
/* Return amount of available playback or capture devices */
if (!iscapture) {
return qsa_playback_devices;
} else {
return qsa_capture_devices;
}
}
void QSA_WaitDone(_THIS)
const char *
QSA_GetDeviceName(int index, int iscapture)
{
if (!this->hidden->iscapture)
{
if (this->hidden->audio_handle!=NULL)
{
/* Wait till last fragment is played and stop channel */
snd_pcm_plugin_flush(this->hidden->audio_handle, SND_PCM_CHANNEL_PLAYBACK);
}
}
else
{
if (this->hidden->audio_handle!=NULL)
{
/* Discard all unread data and stop channel */
snd_pcm_plugin_flush(this->hidden->audio_handle, SND_PCM_CHANNEL_CAPTURE);
}
}
if (!iscapture) {
if (index >= qsa_playback_devices) {
return "No such playback device";
}
return qsa_playback_device[index].name;
} else {
if (index >= qsa_capture_devices) {
return "No such capture device";
}
return qsa_capture_device[index].name;
}
}
void QSA_Deinitialize(void)
void
QSA_WaitDone(_THIS)
{
/* Clear devices array on shutdown */
SDL_memset(qsa_playback_device, 0x00, sizeof(QSA_Device)*QSA_MAX_DEVICES);
SDL_memset(qsa_capture_device, 0x00, sizeof(QSA_Device)*QSA_MAX_DEVICES);
qsa_playback_devices=0;
qsa_capture_devices=0;
if (!this->hidden->iscapture) {
if (this->hidden->audio_handle != NULL) {
/* Wait till last fragment is played and stop channel */
snd_pcm_plugin_flush(this->hidden->audio_handle,
SND_PCM_CHANNEL_PLAYBACK);
}
} else {
if (this->hidden->audio_handle != NULL) {
/* Discard all unread data and stop channel */
snd_pcm_plugin_flush(this->hidden->audio_handle,
SND_PCM_CHANNEL_CAPTURE);
}
}
}
static int QSA_Init(SDL_AudioDriverImpl* impl)
void
QSA_Deinitialize(void)
{
snd_pcm_t* handle=NULL;
int32_t status=0;
/* Clear devices array */
SDL_memset(qsa_playback_device, 0x00, sizeof(QSA_Device)*QSA_MAX_DEVICES);
SDL_memset(qsa_capture_device, 0x00, sizeof(QSA_Device)*QSA_MAX_DEVICES);
qsa_playback_devices=0;
qsa_capture_devices=0;
/* Set function pointers */
/* DeviceLock and DeviceUnlock functions are used default, */
/* provided by SDL, which uses pthread_mutex for lock/unlock */
impl->DetectDevices=QSA_DetectDevices;
impl->GetDeviceName=QSA_GetDeviceName;
impl->OpenDevice=QSA_OpenDevice;
impl->ThreadInit=QSA_ThreadInit;
impl->WaitDevice=QSA_WaitDevice;
impl->PlayDevice=QSA_PlayDevice;
impl->GetDeviceBuf=QSA_GetDeviceBuf;
impl->CloseDevice=QSA_CloseDevice;
impl->WaitDone=QSA_WaitDone;
impl->Deinitialize=QSA_Deinitialize;
impl->LockDevice=NULL;
impl->UnlockDevice=NULL;
impl->OnlyHasDefaultOutputDevice=0;
impl->ProvidesOwnCallbackThread=0;
impl->SkipMixerLock=0;
impl->HasCaptureSupport=1;
impl->OnlyHasDefaultOutputDevice=0;
impl->OnlyHasDefaultInputDevice=0;
/* Check if io-audio manager is running or not */
status=snd_cards();
if (status==0)
{
/* if no, return immediately */
return 1;
}
/* At this point we are definitely has an audio device */
return 2;
/* Clear devices array on shutdown */
SDL_memset(qsa_playback_device, 0x00,
sizeof(QSA_Device) * QSA_MAX_DEVICES);
SDL_memset(qsa_capture_device, 0x00,
sizeof(QSA_Device) * QSA_MAX_DEVICES);
qsa_playback_devices = 0;
qsa_capture_devices = 0;
}
AudioBootStrap QSAAUDIO_bootstrap=
static int
QSA_Init(SDL_AudioDriverImpl * impl)
{
DRIVER_NAME, "QNX QSA Audio", QSA_Init, 0
snd_pcm_t *handle = NULL;
int32_t status = 0;
/* Clear devices array */
SDL_memset(qsa_playback_device, 0x00,
sizeof(QSA_Device) * QSA_MAX_DEVICES);
SDL_memset(qsa_capture_device, 0x00,
sizeof(QSA_Device) * QSA_MAX_DEVICES);
qsa_playback_devices = 0;
qsa_capture_devices = 0;
/* Set function pointers */
/* DeviceLock and DeviceUnlock functions are used default, */
/* provided by SDL, which uses pthread_mutex for lock/unlock */
impl->DetectDevices = QSA_DetectDevices;
impl->GetDeviceName = QSA_GetDeviceName;
impl->OpenDevice = QSA_OpenDevice;
impl->ThreadInit = QSA_ThreadInit;
impl->WaitDevice = QSA_WaitDevice;
impl->PlayDevice = QSA_PlayDevice;
impl->GetDeviceBuf = QSA_GetDeviceBuf;
impl->CloseDevice = QSA_CloseDevice;
impl->WaitDone = QSA_WaitDone;
impl->Deinitialize = QSA_Deinitialize;
impl->LockDevice = NULL;
impl->UnlockDevice = NULL;
impl->OnlyHasDefaultOutputDevice = 0;
impl->ProvidesOwnCallbackThread = 0;
impl->SkipMixerLock = 0;
impl->HasCaptureSupport = 1;
impl->OnlyHasDefaultOutputDevice = 0;
impl->OnlyHasDefaultInputDevice = 0;
/* Check if io-audio manager is running or not */
status = snd_cards();
if (status == 0) {
/* if no, return immediately */
return 1;
}
/* At this point we are definitely has an audio device */
return 2;
}
AudioBootStrap QSAAUDIO_bootstrap = {
DRIVER_NAME, "QNX QSA Audio", QSA_Init, 0
};
/* vi: set ts=4 sw=4 expandtab: */
......@@ -44,7 +44,7 @@ struct SDL_PrivateAudioData
/* The audio device handle */
int cardno;
int deviceno;
snd_pcm_t* audio_handle;
snd_pcm_t *audio_handle;
/* The audio file descriptor */
int audio_fd;
......@@ -53,7 +53,7 @@ struct SDL_PrivateAudioData
uint32_t timeout_on_wait;
/* Raw mixing buffer */
Uint8* pcm_buf;
Uint8 *pcm_buf;
Uint32 pcm_len;
};
......
......@@ -34,9 +34,10 @@
/* Empty function stub to get OpenGL ES 1.0 support without */
/* OpenGL ES extension GL_OES_draw_texture_supported */
GL_API void GL_APIENTRY glDrawTexiOES(GLint x, GLint y, GLint z, GLint width, GLint height)
GL_API void GL_APIENTRY
glDrawTexiOES(GLint x, GLint y, GLint z, GLint width, GLint height)
{
return;
return;
}
#endif /* __QNXNTO__ */
......@@ -105,8 +106,7 @@ SDL_RenderDriver GL_ES_RenderDriver = {
{
/* OpenGL ES 1.x supported formats list */
SDL_PIXELFORMAT_BGR24,
SDL_PIXELFORMAT_ABGR8888
},
SDL_PIXELFORMAT_ABGR8888},
0,
0}
};
......@@ -351,7 +351,7 @@ power_of_2(int input)
}
static int
GLES_CreateTexture(SDL_Renderer *renderer, SDL_Texture *texture)
GLES_CreateTexture(SDL_Renderer * renderer, SDL_Texture * texture)
{
GLES_RenderData *renderdata = (GLES_RenderData *) renderer->driverdata;
SDL_Window *window = SDL_GetWindowFromID(renderer->window);
......@@ -363,15 +363,15 @@ GLES_CreateTexture(SDL_Renderer *renderer, SDL_Texture *texture)
switch (texture->format) {
case SDL_PIXELFORMAT_BGR24:
internalFormat = GL_RGB;
format = GL_RGB;
type = GL_UNSIGNED_BYTE;
break;
internalFormat = GL_RGB;
format = GL_RGB;
type = GL_UNSIGNED_BYTE;
break;
case SDL_PIXELFORMAT_ABGR8888:
internalFormat = GL_RGBA;
format = GL_RGBA;
type = GL_UNSIGNED_BYTE;
break;
internalFormat = GL_RGBA;
format = GL_RGBA;
type = GL_UNSIGNED_BYTE;
break;
/*
These formats would be supported if SDL had the necessary pixel formats
case SDL_PIXELFORMAT_BGR565:
......@@ -389,7 +389,7 @@ GLES_CreateTexture(SDL_Renderer *renderer, SDL_Texture *texture)
format = GL_RGBA;
type = GL_UNSIGNED_SHORT_4_4_4_4;
break;
*/
*/
default:
SDL_SetError("Unsupported texture format");
return -1;
......@@ -533,8 +533,8 @@ GLES_SetTextureScaleMode(SDL_Renderer * renderer, SDL_Texture * texture)
}
static int
GLES_UpdateTexture(SDL_Renderer *renderer, SDL_Texture *texture,
const SDL_Rect *rect, const void *pixels, int pitch)
GLES_UpdateTexture(SDL_Renderer * renderer, SDL_Texture * texture,
const SDL_Rect * rect, const void *pixels, int pitch)
{
GLES_RenderData *renderdata = (GLES_RenderData *) renderer->driverdata;
GLES_TextureData *data = (GLES_TextureData *) texture->driverdata;
......@@ -858,7 +858,7 @@ GLES_RenderCopy(SDL_Renderer * renderer, SDL_Texture * texture,
}
static void
GLES_RenderPresent(SDL_Renderer *renderer)
GLES_RenderPresent(SDL_Renderer * renderer)
{
SDL_GL_SwapWindow(renderer->window);
}
......
......@@ -1496,10 +1496,9 @@ SDL_CreateRenderer(SDL_WindowID windowID, int index, Uint32 flags)
window->renderer = SDL_CurrentDisplay.render_drivers[index]
.CreateRenderer(window, flags);
if (window->renderer==NULL)
{
/* Assuming renderer set its error */
return -1;
if (window->renderer == NULL) {
/* Assuming renderer set its error */
return -1;
}
SDL_SelectRenderer(window->id);
......@@ -2719,7 +2718,7 @@ SDL_GL_GetAttribute(SDL_GLattr attr, int *value)
{
#if SDL_VIDEO_OPENGL || SDL_VIDEO_OPENGL_ES
void (APIENTRY * glGetIntegervFunc) (GLenum pname, GLint * params);
GLenum (APIENTRY * glGetErrorFunc) (void);
GLenum(APIENTRY * glGetErrorFunc) (void);
GLenum attrib = 0;
GLenum error = 0;
......@@ -2734,7 +2733,7 @@ SDL_GL_GetAttribute(SDL_GLattr attr, int *value)
}
/* Clear value in any case */
*value=0;
*value = 0;
switch (attr) {
case SDL_GL_RETAINED_BACKING:
......@@ -2842,28 +2841,26 @@ SDL_GL_GetAttribute(SDL_GLattr attr, int *value)
}
glGetIntegervFunc(attrib, (GLint *) value);
error=glGetErrorFunc();
if (error!=GL_NO_ERROR)
{
switch (error)
{
case GL_INVALID_ENUM:
{
SDL_SetError("OpenGL error: GL_INVALID_ENUM");
}
break;
case GL_INVALID_VALUE:
{
SDL_SetError("OpenGL error: GL_INVALID_VALUE");
}
break;
default:
{
SDL_SetError("OpenGL error: %08X", error);
}
break;
}
return -1;
error = glGetErrorFunc();
if (error != GL_NO_ERROR) {
switch (error) {
case GL_INVALID_ENUM:
{
SDL_SetError("OpenGL error: GL_INVALID_ENUM");
}
break;
case GL_INVALID_VALUE:
{
SDL_SetError("OpenGL error: GL_INVALID_VALUE");
}
break;
default:
{
SDL_SetError("OpenGL error: %08X", error);
}
break;
}
return -1;
}
return 0;
#else
......
......@@ -88,7 +88,7 @@ SDL_RenderDriver NDS_RenderDriver = {
SDL_PIXELFORMAT_INDEX8,
SDL_PIXELFORMAT_ABGR1555,
SDL_PIXELFORMAT_BGR555,
}, /* u32 texture_formats[20] */
}, /* u32 texture_formats[20] */
(256), /* int max_texture_width */
(256), /* int max_texture_height */
}
......@@ -107,8 +107,14 @@ typedef struct
{ NDSTX_BG, NDSTX_SPR } type; /* represented in a bg or sprite. */
int hw_index; /* index of sprite in OAM or bg from libnds */
int pitch, bpp; /* useful information about the texture */
struct { int x,y; } scale; /* x/y stretch (24.8 fixed point) */
struct { int x,y; } scroll; /* x/y offset */
struct
{
int x, y;
} scale; /* x/y stretch (24.8 fixed point) */
struct
{
int x, y;
} scroll; /* x/y offset */
int rotate; /* -32768 to 32767, texture rotation */
u16 *vram_pixels; /* where the pixel data is stored (a pointer into VRAM) */
u16 *vram_palette; /* where the palette data is stored if it's indexed. */
......@@ -197,9 +203,9 @@ NDS_CreateRenderer(SDL_Window * window, Uint32 flags)
renderer->info.max_texture_height =
NDS_RenderDriver.info.max_texture_height;
data->sub = 0; /* TODO: this is hard-coded to the "main" screen.
figure out how to detect whether to set it to
"sub" screen. window->id, perhaps? */
data->sub = 0; /* TODO: this is hard-coded to the "main" screen.
figure out how to detect whether to set it to
"sub" screen. window->id, perhaps? */
data->bg_taken[2] = data->bg_taken[3] = 0;
return renderer;
......@@ -310,9 +316,10 @@ NDS_CreateTexture(SDL_Renderer * renderer, SDL_Texture * texture)
txdat->dim.vdy = 0x100;
txdat->dim.pitch = pitch;
txdat->dim.bpp = bpp;
txdat->vram_pixels = (u16 *) (data->sub ? SPRITE_GFX_SUB : SPRITE_GFX);
txdat->vram_pixels =
(u16 *) (data->sub ? SPRITE_GFX_SUB : SPRITE_GFX);
/* FIXME: use tileIdx*boundary
to point to proper location */
to point to proper location */
} else {
SDL_SetError("Out of NDS sprites.");
}
......@@ -332,20 +339,26 @@ NDS_CreateTexture(SDL_Renderer * renderer, SDL_Texture * texture)
SDL_OutOfMemory();
return -1;
}
// hard-coded for 256x256 for now...
// TODO: a series of if-elseif-else's to find the closest but larger size.
if(!data->sub) {
if(bpp==8) {
txdat->hw_index = bgInit(whichbg, BgType_Bmp8, BgSize_B8_256x256, 0, 0);
if (!data->sub) {
if (bpp == 8) {
txdat->hw_index =
bgInit(whichbg, BgType_Bmp8, BgSize_B8_256x256, 0, 0);
} else {
txdat->hw_index = bgInit(whichbg, BgType_Bmp16, BgSize_B16_256x256, 0, 0);
txdat->hw_index =
bgInit(whichbg, BgType_Bmp16, BgSize_B16_256x256, 0,
0);
}
} else {
if(bpp==8) {
txdat->hw_index = bgInitSub(whichbg, BgType_Bmp8, BgSize_B8_256x256, 0, 0);
if (bpp == 8) {
txdat->hw_index =
bgInitSub(whichbg, BgType_Bmp8, BgSize_B8_256x256, 0,
0);
} else {
txdat->hw_index = bgInitSub(whichbg, BgType_Bmp16, BgSize_B16_256x256, 0, 0);
txdat->hw_index =
bgInitSub(whichbg, BgType_Bmp16, BgSize_B16_256x256,
0, 0);
}
}
......@@ -357,14 +370,14 @@ NDS_CreateTexture(SDL_Renderer * renderer, SDL_Texture * texture)
bgUpdate(bg3);
*/
txdat->type = NDSTX_BG;
txdat->pitch = (texture->w)*(bpp/8);
txdat->pitch = (texture->w) * (bpp / 8);
txdat->bpp = bpp;
txdat->rotate = 0;
txdat->scale.x = 0x100;
txdat->scale.y = 0x100;
txdat->scroll.x = 0;
txdat->scroll.y = 0;
txdat->vram_pixels = (u16*)bgGetGfxPtr(txdat->hw_index);
txdat->vram_pixels = (u16 *) bgGetGfxPtr(txdat->hw_index);
bgSetCenter(txdat->hw_index, 0, 0);
bgSetRotateScale(txdat->hw_index, txdat->rotate, txdat->scale.x,
......@@ -458,7 +471,7 @@ NDS_RenderFill(SDL_Renderer * renderer, Uint8 r, Uint8 g, Uint8 b,
int i, j;
printf("NDS_RenderFill: stub\n");
color = RGB8(r, g, b); /* macro in libnds that makes an ARGB1555 pixel */
color = RGB8(r, g, b); /* macro in libnds that makes an ARGB1555 pixel */
/* TODO: make a single-color sprite and stretch it.
calculate the "HDX" width modifier of the sprite by:
let S be the actual sprite's width (like, 32 pixels for example)
......
This source diff could not be displayed because it is too large. You can view the blob instead.
......@@ -29,8 +29,8 @@
/* 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>
#include <gf/gf.h>
#include <GLES/egl.h>
#endif /* SDL_VIDEO_OPENGL_ES */
#include "SDL_config.h"
......@@ -45,17 +45,17 @@
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 */
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;
/* This is hardcoded value in photon/Pg.h */
......@@ -67,19 +67,19 @@ typedef struct SDL_VideoData
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 */
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 */
......@@ -87,18 +87,18 @@ typedef struct SDL_DisplayData
typedef struct SDL_WindowData
{
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_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;
/****************************************************************************/
......@@ -106,8 +106,8 @@ typedef struct SDL_WindowData
/****************************************************************************/
typedef struct Photon_DeviceCaps
{
uint8_t* name;
uint32_t caps;
uint8_t *name;
uint32_t caps;
} Photon_DeviceCaps;
#define SDL_PHOTON_UNACCELERATED 0x00000000
......@@ -120,41 +120,42 @@ typedef struct Photon_DeviceCaps
/****************************************************************************/
/* 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);
void photon_setwindowtitle(_THIS, SDL_Window* window);
void photon_setwindowicon(_THIS, SDL_Window* window, SDL_Surface* icon);
void photon_setwindowposition(_THIS, SDL_Window* window);
void photon_setwindowsize(_THIS, SDL_Window* window);
void photon_showwindow(_THIS, SDL_Window* window);
void photon_hidewindow(_THIS, SDL_Window* window);
void photon_raisewindow(_THIS, SDL_Window* window);
void photon_maximizewindow(_THIS, SDL_Window* window);
void photon_minimizewindow(_THIS, SDL_Window* window);
void photon_restorewindow(_THIS, SDL_Window* window);
void photon_setwindowgrab(_THIS, SDL_Window* window);
void photon_destroywindow(_THIS, SDL_Window* window);
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);
void photon_setwindowsize(_THIS, SDL_Window * window);
void photon_showwindow(_THIS, SDL_Window * window);
void photon_hidewindow(_THIS, SDL_Window * window);
void photon_raisewindow(_THIS, SDL_Window * window);
void photon_maximizewindow(_THIS, SDL_Window * window);
void photon_minimizewindow(_THIS, SDL_Window * window);
void photon_restorewindow(_THIS, SDL_Window * window);
void photon_setwindowgrab(_THIS, SDL_Window * window);
void photon_destroywindow(_THIS, SDL_Window * window);
/* Window manager function */
SDL_bool photon_getwindowwminfo(_THIS, SDL_Window* window, struct SDL_SysWMinfo* info);
SDL_bool photon_getwindowwminfo(_THIS, SDL_Window * window,
struct SDL_SysWMinfo *info);
/* OpenGL/OpenGL ES functions */
int photon_gl_loadlibrary(_THIS, const char* path);
void* photon_gl_getprocaddres(_THIS, const char* proc);
int photon_gl_loadlibrary(_THIS, const char *path);
void *photon_gl_getprocaddres(_THIS, const char *proc);
void photon_gl_unloadlibrary(_THIS);
SDL_GLContext photon_gl_createcontext(_THIS, SDL_Window* window);
int photon_gl_makecurrent(_THIS, SDL_Window* window, SDL_GLContext context);
SDL_GLContext photon_gl_createcontext(_THIS, SDL_Window * window);
int photon_gl_makecurrent(_THIS, SDL_Window * window, SDL_GLContext context);
int photon_gl_setswapinterval(_THIS, int interval);
int photon_gl_getswapinterval(_THIS);
void photon_gl_swapwindow(_THIS, SDL_Window* window);
void photon_gl_swapwindow(_THIS, SDL_Window * window);
void photon_gl_deletecontext(_THIS, SDL_GLContext context);
/* Event handling function */
......
......@@ -34,727 +34,699 @@
#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_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;
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)
int32_t
photon_delinputdevices(_THIS)
{
/* Destroy all of the mice */
SDL_MouseQuit();
/* Destroy all of the mice */
SDL_MouseQuit();
}
/*****************************************************************************/
/* Photon mouse related functions */
/*****************************************************************************/
SDL_Cursor* photon_createcursor(SDL_Surface* surface, int hot_x, int hot_y)
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)
{
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;
{
*(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;
{
*(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;
{
*(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;
*(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)
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;
}
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);
}
else
{
return -1;
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
{
} 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;
}
}
/* 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)
void
photon_movecursor(SDL_Cursor * cursor)
{
SDL_VideoDisplay* display;
SDL_DisplayData* didata;
SDL_Window* window;
SDL_WindowData* wdata;
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)
{
wdata=(SDL_WindowData*)window->driverdata;
if (wdata==NULL)
{
return;
}
SDL_VideoDisplay *display;
SDL_DisplayData *didata;
SDL_Window *window;
SDL_WindowData *wdata;
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) {
wdata = (SDL_WindowData *) window->driverdata;
if (wdata == NULL) {
return;
}
} else {
return;
}
} else {
return;
}
else
{
return;
}
}
else
{
} else {
return;
}
}
else
{
return;
}
}
}
}
/* No need to move mouse cursor manually in the photon */
/* No need to move mouse cursor manually in the photon */
return;
return;
}
void photon_freecursor(SDL_Cursor* cursor)
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;
}
}
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)
void
photon_warpmouse(SDL_Mouse * mouse, SDL_WindowID windowID, int x, int y)
{
SDL_VideoDisplay* display;
SDL_DisplayData* didata;
SDL_Window* window;
SDL_WindowData* wdata;
int16_t wx;
int16_t wy;
/* Sanity checks */
window=SDL_GetWindowFromID(windowID);
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;
SDL_VideoDisplay *display;
SDL_DisplayData *didata;
SDL_Window *window;
SDL_WindowData *wdata;
int16_t wx;
int16_t wy;
/* Sanity checks */
window = SDL_GetWindowFromID(windowID);
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;
}
} else {
return;
}
}
else
{
} else {
return;
}
}
else
{
return;
}
}
else
{
return;
}
PtGetAbsPosition(wdata->window, &wx, &wy);
PhMoveCursorAbs(PhInputGroup(NULL), wx+x, wy+y);
return;
}
} else {
return;
}
PtGetAbsPosition(wdata->window, &wx, &wy);
PhMoveCursorAbs(PhInputGroup(NULL), wx + x, wy + y);
return;
}
void photon_freemouse(SDL_Mouse* mouse)
void
photon_freemouse(SDL_Mouse * mouse)
{
if (mouse->driverdata==NULL)
{
return;
}
if (mouse->driverdata == NULL) {
return;
}
/* Mouse framework doesn't deletes automatically our driverdata */
SDL_free(mouse->driverdata);
mouse->driverdata=NULL;
/* Mouse framework doesn't deletes automatically our driverdata */
SDL_free(mouse->driverdata);
mouse->driverdata = NULL;
return;
return;
}
SDL_scancode photon_to_sdl_keymap(uint32_t key)
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;
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;
}
......@@ -35,7 +35,7 @@
typedef struct SDL_MouseData
{
SDL_DisplayData* didata;
SDL_DisplayData *didata;
} SDL_MouseData;
int32_t photon_addinputdevices(_THIS);
......
......@@ -104,9 +104,11 @@
#define PHOTON_SCANCODE_SPACE 0x39
#define PHOTON_SCANCODE_MENU 0x5D
#define PHOTON_SCANCODE_PRNSCR 0x54 /* only key pressed event, no release */
#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 */
#if 0 /* pause doesn't generates a scancode */
#define PHOTON_SCANCODE_PAUSE 0x??
#endif
#define PHOTON_SCANCODE_INSERT 0x52
#define PHOTON_SCANCODE_HOME 0x47
#define PHOTON_SCANCODE_PAGEUP 0x49
......
......@@ -26,173 +26,173 @@
#include "SDL_photon_pixelfmt.h"
uint32_t photon_bits_to_sdl_pixelformat(uint32_t pixelfmt)
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;
}
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)
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;
}
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;
return 0;
}
uint32_t photon_image_to_sdl_pixelformat(uint32_t pixelfmt)
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;
}
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;
return 0;
}
uint32_t photon_sdl_to_image_pixelformat(uint32_t pixelfmt)
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;
}
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;
return 0;
}
/* vi: set ts=4 sw=4 expandtab: */
......@@ -34,308 +34,343 @@
#include "SDL_photon_render.h"
#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 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 void photon_renderpresent(SDL_Renderer* renderer);
static void photon_destroytexture(SDL_Renderer* renderer, SDL_Texture* texture);
static void photon_destroyrenderer(SDL_Renderer* renderer);
SDL_RenderDriver photon_renderdriver=
{
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 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 void photon_renderpresent(SDL_Renderer * renderer);
static void photon_destroytexture(SDL_Renderer * renderer,
SDL_Texture * texture);
static void photon_destroyrenderer(SDL_Renderer * renderer);
SDL_RenderDriver photon_renderdriver = {
photon_createrenderer,
{
"photon",
(SDL_RENDERER_SINGLEBUFFER | SDL_RENDERER_PRESENTCOPY |
SDL_RENDERER_PRESENTFLIP2 | SDL_RENDERER_PRESENTFLIP3 |
SDL_RENDERER_PRESENTVSYNC | SDL_RENDERER_PRESENTDISCARD |
SDL_RENDERER_ACCELERATED),
(SDL_TEXTUREMODULATE_NONE | SDL_TEXTUREMODULATE_COLOR |
SDL_TEXTUREMODULATE_ALPHA),
(SDL_BLENDMODE_NONE | SDL_BLENDMODE_MASK |
SDL_BLENDMODE_BLEND | SDL_BLENDMODE_ADD | SDL_BLENDMODE_MOD),
(SDL_TEXTURESCALEMODE_NONE | SDL_TEXTURESCALEMODE_SLOW),
13,
{
SDL_PIXELFORMAT_INDEX8,
SDL_PIXELFORMAT_RGB555,
SDL_PIXELFORMAT_RGB565,
SDL_PIXELFORMAT_RGB888,
SDL_PIXELFORMAT_BGR888,
SDL_PIXELFORMAT_ARGB8888,
SDL_PIXELFORMAT_RGBA8888,
SDL_PIXELFORMAT_ABGR8888,
SDL_PIXELFORMAT_BGRA8888,
SDL_PIXELFORMAT_YV12,
SDL_PIXELFORMAT_YUY2,
SDL_PIXELFORMAT_UYVY,
SDL_PIXELFORMAT_YVYU
},
0,
0
}
"photon",
(SDL_RENDERER_SINGLEBUFFER | SDL_RENDERER_PRESENTCOPY |
SDL_RENDERER_PRESENTFLIP2 | SDL_RENDERER_PRESENTFLIP3 |
SDL_RENDERER_PRESENTVSYNC | SDL_RENDERER_PRESENTDISCARD |
SDL_RENDERER_ACCELERATED),
(SDL_TEXTUREMODULATE_NONE | SDL_TEXTUREMODULATE_COLOR |
SDL_TEXTUREMODULATE_ALPHA),
(SDL_BLENDMODE_NONE | SDL_BLENDMODE_MASK |
SDL_BLENDMODE_BLEND | SDL_BLENDMODE_ADD | SDL_BLENDMODE_MOD),
(SDL_TEXTURESCALEMODE_NONE | SDL_TEXTURESCALEMODE_SLOW),
13,
{
SDL_PIXELFORMAT_INDEX8,
SDL_PIXELFORMAT_RGB555,
SDL_PIXELFORMAT_RGB565,
SDL_PIXELFORMAT_RGB888,
SDL_PIXELFORMAT_BGR888,
SDL_PIXELFORMAT_ARGB8888,
SDL_PIXELFORMAT_RGBA8888,
SDL_PIXELFORMAT_ABGR8888,
SDL_PIXELFORMAT_BGRA8888,
SDL_PIXELFORMAT_YV12,
SDL_PIXELFORMAT_YUY2,
SDL_PIXELFORMAT_UYVY,
SDL_PIXELFORMAT_YVYU},
0,
0}
};
static SDL_Renderer* photon_createrenderer(SDL_Window* window, Uint32 flags)
static SDL_Renderer *
photon_createrenderer(SDL_Window * window, Uint32 flags)
{
SDL_VideoDisplay* display = SDL_GetDisplayFromWindow(window);
SDL_DisplayData* didata = (SDL_DisplayData*)display->driverdata;
SDL_WindowData* wdata = (SDL_WindowData*)window->driverdata;
SDL_Renderer* renderer = NULL;
SDL_RenderData* rdata = NULL;
/* Allocate new renderer structure */
renderer=(SDL_Renderer*)SDL_calloc(1, sizeof(SDL_Renderer));
if (renderer==NULL)
{
SDL_OutOfMemory();
return NULL;
}
/* Allocate renderer data */
rdata=(SDL_RenderData*)SDL_calloc(1, sizeof(SDL_RenderData));
if (rdata==NULL)
{
SDL_free(renderer);
SDL_OutOfMemory();
return NULL;
}
renderer->DisplayModeChanged=photon_displaymodechanged;
renderer->ActivateRenderer=photon_activaterenderer;
renderer->CreateTexture=photon_createtexture;
renderer->QueryTexturePixels=photon_querytexturepixels;
renderer->SetTexturePalette=photon_settexturepalette;
renderer->GetTexturePalette=photon_gettexturepalette;
renderer->SetTextureAlphaMod=photon_settexturealphamod;
renderer->SetTextureColorMod=photon_settexturecolormod;
renderer->SetTextureBlendMode=photon_settextureblendmode;
renderer->SetTextureScaleMode=photon_settexturescalemode;
renderer->UpdateTexture=photon_updatetexture;
renderer->LockTexture=photon_locktexture;
renderer->UnlockTexture=photon_unlocktexture;
renderer->DirtyTexture=photon_dirtytexture;
renderer->RenderPoint=photon_renderpoint;
renderer->RenderLine=photon_renderline;
renderer->RenderFill=photon_renderfill;
renderer->RenderCopy=photon_rendercopy;
renderer->RenderPresent = photon_renderpresent;
renderer->DestroyTexture = photon_destroytexture;
renderer->DestroyRenderer = photon_destroyrenderer;
renderer->info = photon_renderdriver.info;
renderer->window = window->id;
renderer->driverdata = rdata;
/* Set render acceleration flag in case it is accelerated */
if ((didata->caps & SDL_PHOTON_ACCELERATED)==SDL_PHOTON_ACCELERATED)
{
renderer->info.flags=SDL_RENDERER_ACCELERATED;
}
else
{
renderer->info.flags&=~(SDL_RENDERER_ACCELERATED);
}
rdata->window=window;
/* Check if upper level requested synchronization on vsync signal */
if ((flags & SDL_RENDERER_PRESENTVSYNC)==SDL_RENDERER_PRESENTVSYNC)
{
rdata->enable_vsync=SDL_TRUE;
}
else
{
rdata->enable_vsync=SDL_FALSE;
}
/* Check what buffer copy/flip scheme is requested */
rdata->surfaces_count=0;
if ((flags & SDL_RENDERER_SINGLEBUFFER)==SDL_RENDERER_SINGLEBUFFER)
{
if ((flags & SDL_RENDERER_PRESENTDISCARD)==SDL_RENDERER_PRESENTDISCARD)
{
renderer->info.flags|=SDL_RENDERER_SINGLEBUFFER | SDL_RENDERER_PRESENTDISCARD;
}
else
{
renderer->info.flags|=SDL_RENDERER_SINGLEBUFFER | SDL_RENDERER_PRESENTCOPY;
}
rdata->surfaces_count=1;
rdata->surface_visible_idx=0;
rdata->surface_render_idx=0;
}
else
{
if ((flags & SDL_RENDERER_PRESENTFLIP2)==SDL_RENDERER_PRESENTFLIP2)
{
renderer->info.flags|=SDL_RENDERER_PRESENTFLIP2;
rdata->surfaces_count=2;
rdata->surface_visible_idx=0;
rdata->surface_render_idx=1;
}
else
{
if ((flags & SDL_RENDERER_PRESENTFLIP3)==SDL_RENDERER_PRESENTFLIP3)
{
renderer->info.flags|=SDL_RENDERER_PRESENTFLIP3;
rdata->surfaces_count=3;
rdata->surface_visible_idx=0;
rdata->surface_render_idx=1;
}
else
{
renderer->info.flags|=SDL_RENDERER_SINGLEBUFFER | SDL_RENDERER_PRESENTCOPY;
rdata->surfaces_count=1;
rdata->surface_visible_idx=0;
rdata->surface_render_idx=0;
}
}
}
return renderer;
SDL_VideoDisplay *display = SDL_GetDisplayFromWindow(window);
SDL_DisplayData *didata = (SDL_DisplayData *) display->driverdata;
SDL_WindowData *wdata = (SDL_WindowData *) window->driverdata;
SDL_Renderer *renderer = NULL;
SDL_RenderData *rdata = NULL;
/* Allocate new renderer structure */
renderer = (SDL_Renderer *) SDL_calloc(1, sizeof(SDL_Renderer));
if (renderer == NULL) {
SDL_OutOfMemory();
return NULL;
}
/* Allocate renderer data */
rdata = (SDL_RenderData *) SDL_calloc(1, sizeof(SDL_RenderData));
if (rdata == NULL) {
SDL_free(renderer);
SDL_OutOfMemory();
return NULL;
}
renderer->DisplayModeChanged = photon_displaymodechanged;
renderer->ActivateRenderer = photon_activaterenderer;
renderer->CreateTexture = photon_createtexture;
renderer->QueryTexturePixels = photon_querytexturepixels;
renderer->SetTexturePalette = photon_settexturepalette;
renderer->GetTexturePalette = photon_gettexturepalette;
renderer->SetTextureAlphaMod = photon_settexturealphamod;
renderer->SetTextureColorMod = photon_settexturecolormod;
renderer->SetTextureBlendMode = photon_settextureblendmode;
renderer->SetTextureScaleMode = photon_settexturescalemode;
renderer->UpdateTexture = photon_updatetexture;
renderer->LockTexture = photon_locktexture;
renderer->UnlockTexture = photon_unlocktexture;
renderer->DirtyTexture = photon_dirtytexture;
renderer->RenderPoint = photon_renderpoint;
renderer->RenderLine = photon_renderline;
renderer->RenderFill = photon_renderfill;
renderer->RenderCopy = photon_rendercopy;
renderer->RenderPresent = photon_renderpresent;
renderer->DestroyTexture = photon_destroytexture;
renderer->DestroyRenderer = photon_destroyrenderer;
renderer->info = photon_renderdriver.info;
renderer->window = window->id;
renderer->driverdata = rdata;
/* Set render acceleration flag in case it is accelerated */
if ((didata->caps & SDL_PHOTON_ACCELERATED) == SDL_PHOTON_ACCELERATED) {
renderer->info.flags = SDL_RENDERER_ACCELERATED;
} else {
renderer->info.flags &= ~(SDL_RENDERER_ACCELERATED);
}
rdata->window = window;
/* Check if upper level requested synchronization on vsync signal */
if ((flags & SDL_RENDERER_PRESENTVSYNC) == SDL_RENDERER_PRESENTVSYNC) {
rdata->enable_vsync = SDL_TRUE;
} else {
rdata->enable_vsync = SDL_FALSE;
}
/* Check what buffer copy/flip scheme is requested */
rdata->surfaces_count = 0;
if ((flags & SDL_RENDERER_SINGLEBUFFER) == SDL_RENDERER_SINGLEBUFFER) {
if ((flags & SDL_RENDERER_PRESENTDISCARD) ==
SDL_RENDERER_PRESENTDISCARD) {
renderer->info.flags |=
SDL_RENDERER_SINGLEBUFFER | SDL_RENDERER_PRESENTDISCARD;
} else {
renderer->info.flags |=
SDL_RENDERER_SINGLEBUFFER | SDL_RENDERER_PRESENTCOPY;
}
rdata->surfaces_count = 1;
rdata->surface_visible_idx = 0;
rdata->surface_render_idx = 0;
} else {
if ((flags & SDL_RENDERER_PRESENTFLIP2) == SDL_RENDERER_PRESENTFLIP2) {
renderer->info.flags |= SDL_RENDERER_PRESENTFLIP2;
rdata->surfaces_count = 2;
rdata->surface_visible_idx = 0;
rdata->surface_render_idx = 1;
} else {
if ((flags & SDL_RENDERER_PRESENTFLIP3) ==
SDL_RENDERER_PRESENTFLIP3) {
renderer->info.flags |= SDL_RENDERER_PRESENTFLIP3;
rdata->surfaces_count = 3;
rdata->surface_visible_idx = 0;
rdata->surface_render_idx = 1;
} else {
renderer->info.flags |=
SDL_RENDERER_SINGLEBUFFER | SDL_RENDERER_PRESENTCOPY;
rdata->surfaces_count = 1;
rdata->surface_visible_idx = 0;
rdata->surface_render_idx = 0;
}
}
}
return renderer;
}
void photon_addrenderdriver(_THIS)
void
photon_addrenderdriver(_THIS)
{
uint32_t it;
uint32_t it;
for (it=0; it<_this->num_displays; it++)
{
SDL_AddRenderDriver(it, &photon_renderdriver);
}
for (it = 0; it < _this->num_displays; it++) {
SDL_AddRenderDriver(it, &photon_renderdriver);
}
}
/****************************************************************************/
/* SDL render interface */
/****************************************************************************/
static int photon_displaymodechanged(SDL_Renderer* renderer)
static int
photon_displaymodechanged(SDL_Renderer * renderer)
{
SDL_RenderData* rdata=(SDL_RenderData*)renderer->driverdata;
SDL_RenderData *rdata = (SDL_RenderData *) renderer->driverdata;
/* Remove all allocated surfaces, they are no more valid */
/* Remove all allocated surfaces, they are no more valid */
/* TODO: Add video mode change detection and new parameters detection */
/* TODO: Add video mode change detection and new parameters detection */
return 0;
return 0;
}
static int photon_activaterenderer(SDL_Renderer* renderer)
static int
photon_activaterenderer(SDL_Renderer * renderer)
{
SDL_RenderData* rdata=(SDL_RenderData*)renderer->driverdata;
SDL_VideoDisplay* display = SDL_GetDisplayFromWindow(rdata->window);
SDL_DisplayData* didata = (SDL_DisplayData*)display->driverdata;
SDL_RenderData *rdata = (SDL_RenderData *) renderer->driverdata;
SDL_VideoDisplay *display = SDL_GetDisplayFromWindow(rdata->window);
SDL_DisplayData *didata = (SDL_DisplayData *) display->driverdata;
return 0;
return 0;
}
static int photon_createtexture(SDL_Renderer* renderer, SDL_Texture* texture)
static int
photon_createtexture(SDL_Renderer * renderer, SDL_Texture * texture)
{
SDL_RenderData* renderdata=(SDL_RenderData*)renderer->driverdata;
SDL_Window* window=SDL_GetWindowFromID(renderer->window);
SDL_VideoDisplay* display=SDL_GetDisplayFromWindow(window);
SDL_TextureData* tdata=NULL;
/* Allocate texture driver data */
tdata=(SDL_TextureData*)SDL_calloc(1, sizeof(SDL_TextureData));
if (tdata==NULL)
{
SDL_OutOfMemory();
return -1;
}
/* Set texture driver data */
texture->driverdata=tdata;
SDL_RenderData *renderdata = (SDL_RenderData *) renderer->driverdata;
SDL_Window *window = SDL_GetWindowFromID(renderer->window);
SDL_VideoDisplay *display = SDL_GetDisplayFromWindow(window);
SDL_TextureData *tdata = NULL;
/* Allocate texture driver data */
tdata = (SDL_TextureData *) SDL_calloc(1, sizeof(SDL_TextureData));
if (tdata == NULL) {
SDL_OutOfMemory();
return -1;
}
/* Set texture driver data */
texture->driverdata = tdata;
}
static int photon_querytexturepixels(SDL_Renderer* renderer, SDL_Texture* texture, void** pixels, int* pitch)
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_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_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_settexturecolormod(SDL_Renderer * renderer, SDL_Texture * texture)
{
}
static int photon_settexturealphamod(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_settextureblendmode(SDL_Renderer * renderer, SDL_Texture * texture)
{
}
static int photon_settexturescalemode(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_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_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_unlocktexture(SDL_Renderer * renderer, SDL_Texture * texture)
{
}
static void photon_dirtytexture(SDL_Renderer* renderer, SDL_Texture* texture, int numrects, const SDL_Rect* rects)
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_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_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_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_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_renderpresent(SDL_Renderer * renderer)
{
}
static void photon_destroytexture(SDL_Renderer* renderer, SDL_Texture* texture)
static void
photon_destroytexture(SDL_Renderer * renderer, SDL_Texture * texture)
{
}
static void photon_destroyrenderer(SDL_Renderer* renderer)
static void
photon_destroyrenderer(SDL_Renderer * renderer)
{
SDL_RenderData* rdata=(SDL_RenderData*)renderer->driverdata;
uint32_t it;
SDL_RenderData *rdata = (SDL_RenderData *) renderer->driverdata;
uint32_t it;
}
......
......@@ -35,11 +35,11 @@
typedef struct SDL_RenderData
{
SDL_Window* window; /* SDL window type */
SDL_bool enable_vsync; /* VSYNC flip synchronization enable */
uint32_t surface_visible_idx; /* Index of visible surface */
uint32_t surface_render_idx; /* Index of render surface */
uint32_t surfaces_count; /* Amount of allocated surfaces */
SDL_Window *window; /* SDL window type */
SDL_bool enable_vsync; /* VSYNC flip synchronization enable */
uint32_t surface_visible_idx; /* Index of visible surface */
uint32_t surface_render_idx; /* Index of render surface */
uint32_t surfaces_count; /* Amount of allocated surfaces */
} SDL_RenderData;
typedef struct SDL_TextureData
......
......@@ -37,539 +37,491 @@
#include "SDL_hiddi_joystick.h"
/* Mouse related functions */
SDL_Cursor* gf_createcursor(SDL_Surface* surface, int hot_x, int hot_y);
int gf_showcursor(SDL_Cursor* cursor);
void gf_movecursor(SDL_Cursor* cursor);
void gf_freecursor(SDL_Cursor* cursor);
void gf_warpmouse(SDL_Mouse* mouse, SDL_WindowID windowID, int x, int y);
void gf_freemouse(SDL_Mouse* mouse);
SDL_Cursor *gf_createcursor(SDL_Surface * surface, int hot_x, int hot_y);
int gf_showcursor(SDL_Cursor * cursor);
void gf_movecursor(SDL_Cursor * cursor);
void gf_freecursor(SDL_Cursor * cursor);
void gf_warpmouse(SDL_Mouse * mouse, SDL_WindowID windowID, int x, int y);
void gf_freemouse(SDL_Mouse * mouse);
/* HIDDI interacting functions */
static int32_t hiddi_connect_devices();
static int32_t hiddi_disconnect_devices();
int32_t gf_addinputdevices(_THIS)
int32_t
gf_addinputdevices(_THIS)
{
SDL_VideoData* gfdata=(SDL_VideoData*)_this->driverdata;
SDL_DisplayData* didata;
struct SDL_Mouse gf_mouse;
SDL_Keyboard gf_keyboard;
SDLKey keymap[SDL_NUM_SCANCODES];
SDL_MouseData* mdata;
uint32_t it;
for (it=0; it<_this->num_displays; it++)
{
/* Clear SDL mouse structure */
SDL_memset(&gf_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 */
gf_mouse.id=it;
gf_mouse.driverdata=(void*)mdata;
gf_mouse.CreateCursor=gf_createcursor;
gf_mouse.ShowCursor=gf_showcursor;
gf_mouse.MoveCursor=gf_movecursor;
gf_mouse.FreeCursor=gf_freecursor;
gf_mouse.WarpMouse=gf_warpmouse;
gf_mouse.FreeMouse=gf_freemouse;
/* Get display data */
didata=(SDL_DisplayData*)_this->displays[it].driverdata;
/* Store SDL_DisplayData pointer in the mouse driver internals */
mdata->didata=didata;
/* Set cursor pos to 0,0 to avoid cursor disappearing in some drivers */
gf_cursor_set_pos(didata->display, 0, 0, 0);
/* Register mouse cursor in SDL */
SDL_AddMouse(&gf_mouse, "GF mouse cursor", 0, 0, 1);
}
/* Keyboard could be one only */
SDL_zero(gf_keyboard);
SDL_AddKeyboard(&gf_keyboard, -1);
/* Add scancode to key mapping, HIDDI uses USB HID codes, so */
/* map will be exact one-to-one */
SDL_GetDefaultKeymap(keymap);
SDL_SetKeymap(0, 0, keymap, SDL_NUM_SCANCODES);
/* Connect to HID server and enumerate all input devices */
hiddi_connect_devices();
return 0;
SDL_VideoData *gfdata = (SDL_VideoData *) _this->driverdata;
SDL_DisplayData *didata;
struct SDL_Mouse gf_mouse;
SDL_Keyboard gf_keyboard;
SDLKey keymap[SDL_NUM_SCANCODES];
SDL_MouseData *mdata;
uint32_t it;
for (it = 0; it < _this->num_displays; it++) {
/* Clear SDL mouse structure */
SDL_memset(&gf_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 */
gf_mouse.id = it;
gf_mouse.driverdata = (void *) mdata;
gf_mouse.CreateCursor = gf_createcursor;
gf_mouse.ShowCursor = gf_showcursor;
gf_mouse.MoveCursor = gf_movecursor;
gf_mouse.FreeCursor = gf_freecursor;
gf_mouse.WarpMouse = gf_warpmouse;
gf_mouse.FreeMouse = gf_freemouse;
/* Get display data */
didata = (SDL_DisplayData *) _this->displays[it].driverdata;
/* Store SDL_DisplayData pointer in the mouse driver internals */
mdata->didata = didata;
/* Set cursor pos to 0,0 to avoid cursor disappearing in some drivers */
gf_cursor_set_pos(didata->display, 0, 0, 0);
/* Register mouse cursor in SDL */
SDL_AddMouse(&gf_mouse, "GF mouse cursor", 0, 0, 1);
}
/* Keyboard could be one only */
SDL_zero(gf_keyboard);
SDL_AddKeyboard(&gf_keyboard, -1);
/* Add scancode to key mapping, HIDDI uses USB HID codes, so */
/* map will be exact one-to-one */
SDL_GetDefaultKeymap(keymap);
SDL_SetKeymap(0, 0, keymap, SDL_NUM_SCANCODES);
/* Connect to HID server and enumerate all input devices */
hiddi_connect_devices();
return 0;
}
int32_t gf_delinputdevices(_THIS)
int32_t
gf_delinputdevices(_THIS)
{
/* Disconnect from HID server and release input devices */
hiddi_disconnect_devices();
/* Disconnect from HID server and release input devices */
hiddi_disconnect_devices();
/* Delete keyboard */
SDL_KeyboardQuit();
/* Delete keyboard */
SDL_KeyboardQuit();
/* Destroy all of the mice */
SDL_MouseQuit();
/* Destroy all of the mice */
SDL_MouseQuit();
}
/*****************************************************************************/
/* GF Mouse related functions */
/*****************************************************************************/
SDL_Cursor* gf_createcursor(SDL_Surface* surface, int hot_x, int hot_y)
SDL_Cursor *
gf_createcursor(SDL_Surface * surface, int hot_x, int hot_y)
{
gf_cursor_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("GF: Cursor shape is not 24/32bpp.");
return NULL;
}
/* Since GF is not checking data, we must check */
if ((surface->w==0) || (surface->h==0))
{
SDL_SetError("GF: Cursor shape dimensions are zero");
return NULL;
}
/* Allocate memory for the internal cursor format */
internal_cursor=(gf_cursor_t*)SDL_calloc(1, sizeof(gf_cursor_t));
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;
}
/* Allocate two monochrome images */
image0=(uint8_t*)SDL_calloc(1, ((surface->w+7)/8)*surface->h);
if (image0==NULL)
{
SDL_free(sdl_cursor);
SDL_free(internal_cursor);
SDL_OutOfMemory();
return NULL;
}
image1=(uint8_t*)SDL_calloc(1, ((surface->w+7)>>3)*surface->h);
if (image1==NULL)
{
SDL_free(image0);
SDL_free(sdl_cursor);
SDL_free(internal_cursor);
SDL_OutOfMemory();
return NULL;
}
/* Set driverdata as GF cursor format */
sdl_cursor->driverdata=(void*)internal_cursor;
internal_cursor->type=GF_CURSOR_BITMAP;
internal_cursor->hotspot.x=hot_x;
internal_cursor->hotspot.y=hot_y;
internal_cursor->cursor.bitmap.w=surface->w;
internal_cursor->cursor.bitmap.h=surface->h;
internal_cursor->cursor.bitmap.color0=SDL_GF_MOUSE_COLOR_BLACK;
internal_cursor->cursor.bitmap.color1=SDL_GF_MOUSE_COLOR_WHITE;
/* Setup cursor shape images */
internal_cursor->cursor.bitmap.stride=((surface->w+7)>>3);
internal_cursor->cursor.bitmap.image0=image0;
internal_cursor->cursor.bitmap.image1=image1;
/* 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)
{
gf_cursor_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("GF: Cursor shape is not 24/32bpp.");
return NULL;
}
/* Since GF is not checking data, we must check */
if ((surface->w == 0) || (surface->h == 0)) {
SDL_SetError("GF: Cursor shape dimensions are zero");
return NULL;
}
/* Allocate memory for the internal cursor format */
internal_cursor = (gf_cursor_t *) SDL_calloc(1, sizeof(gf_cursor_t));
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;
}
/* Allocate two monochrome images */
image0 = (uint8_t *) SDL_calloc(1, ((surface->w + 7) / 8) * surface->h);
if (image0 == NULL) {
SDL_free(sdl_cursor);
SDL_free(internal_cursor);
SDL_OutOfMemory();
return NULL;
}
image1 = (uint8_t *) SDL_calloc(1, ((surface->w + 7) >> 3) * surface->h);
if (image1 == NULL) {
SDL_free(image0);
SDL_free(sdl_cursor);
SDL_free(internal_cursor);
SDL_OutOfMemory();
return NULL;
}
/* Set driverdata as GF cursor format */
sdl_cursor->driverdata = (void *) internal_cursor;
internal_cursor->type = GF_CURSOR_BITMAP;
internal_cursor->hotspot.x = hot_x;
internal_cursor->hotspot.y = hot_y;
internal_cursor->cursor.bitmap.w = surface->w;
internal_cursor->cursor.bitmap.h = surface->h;
internal_cursor->cursor.bitmap.color0 = SDL_GF_MOUSE_COLOR_BLACK;
internal_cursor->cursor.bitmap.color1 = SDL_GF_MOUSE_COLOR_WHITE;
/* Setup cursor shape images */
internal_cursor->cursor.bitmap.stride = ((surface->w + 7) >> 3);
internal_cursor->cursor.bitmap.image0 = image0;
internal_cursor->cursor.bitmap.image1 = image1;
/* 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_GF_MOUSE_COLOR_BLACK:
{
*(image0+jt*(internal_cursor->cursor.bitmap.stride)+(it>>3))|=0x80>>(it%8);
*(image1+jt*(internal_cursor->cursor.bitmap.stride)+(it>>3))&=~(0x80>>(it%8));
}
break;
{
*(image0 + jt * (internal_cursor->cursor.bitmap.stride) +
(it >> 3)) |= 0x80 >> (it % 8);
*(image1 + jt * (internal_cursor->cursor.bitmap.stride) +
(it >> 3)) &= ~(0x80 >> (it % 8));
}
break;
case SDL_GF_MOUSE_COLOR_WHITE:
{
*(image0+jt*(internal_cursor->cursor.bitmap.stride)+(it>>3))&=~(0x80>>(it%8));
*(image1+jt*(internal_cursor->cursor.bitmap.stride)+(it>>3))|=0x80>>(it%8);
}
break;
{
*(image0 + jt * (internal_cursor->cursor.bitmap.stride) +
(it >> 3)) &= ~(0x80 >> (it % 8));
*(image1 + jt * (internal_cursor->cursor.bitmap.stride) +
(it >> 3)) |= 0x80 >> (it % 8);
}
break;
case SDL_GF_MOUSE_COLOR_TRANS:
{
*(image0+jt*(internal_cursor->cursor.bitmap.stride)+(it>>3))&=~(0x80>>(it%8));
*(image1+jt*(internal_cursor->cursor.bitmap.stride)+(it>>3))&=~(0x80>>(it%8));
}
break;
{
*(image0 + jt * (internal_cursor->cursor.bitmap.stride) +
(it >> 3)) &= ~(0x80 >> (it % 8));
*(image1 + jt * (internal_cursor->cursor.bitmap.stride) +
(it >> 3)) &= ~(0x80 >> (it % 8));
}
break;
default:
{
{
/* The same as transparent color, must not happen */
*(image0+jt*(internal_cursor->cursor.bitmap.stride)+(it>>3))&=~(0x80>>(it%8));
*(image1+jt*(internal_cursor->cursor.bitmap.stride)+(it>>3))&=~(0x80>>(it%8));
}
break;
}
}
}
return sdl_cursor;
*(image0 + jt * (internal_cursor->cursor.bitmap.stride) +
(it >> 3)) &= ~(0x80 >> (it % 8));
*(image1 + jt * (internal_cursor->cursor.bitmap.stride) +
(it >> 3)) &= ~(0x80 >> (it % 8));
}
break;
}
}
}
return sdl_cursor;
}
int gf_showcursor(SDL_Cursor* cursor)
int
gf_showcursor(SDL_Cursor * cursor)
{
SDL_VideoDisplay* display;
SDL_DisplayData* didata;
SDL_Window* window;
SDL_WindowID window_id;
gf_cursor_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)
{
mdata=(SDL_MouseData*)cursor->mouse->driverdata;
didata=(SDL_DisplayData*)mdata->didata;
if ((didata==NULL) || (mdata==NULL))
{
return;
}
}
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)
{
return -1;
SDL_VideoDisplay *display;
SDL_DisplayData *didata;
SDL_Window *window;
SDL_WindowID window_id;
gf_cursor_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) {
mdata = (SDL_MouseData *) cursor->mouse->driverdata;
didata = (SDL_DisplayData *) mdata->didata;
if ((didata == NULL) || (mdata == NULL)) {
return;
}
}
else
{
return -1;
}
}
else
{
return -1;
}
}
/* Check if we need to set new shape or disable cursor shape */
if (cursor!=NULL)
{
/* Retrieve GF cursor shape */
internal_cursor=(gf_cursor_t*)cursor->driverdata;
if (internal_cursor==NULL)
{
SDL_SetError("GF: Internal cursor data is absent");
return -1;
}
if ((internal_cursor->cursor.bitmap.image0==NULL) ||
(internal_cursor->cursor.bitmap.image1==NULL))
{
SDL_SetError("GF: Cursor shape is absent");
return -1;
}
/* Store last shown cursor to display data */
didata->cursor.type=internal_cursor->type;
didata->cursor.hotspot.x=internal_cursor->hotspot.x;
didata->cursor.hotspot.y=internal_cursor->hotspot.y;
if (internal_cursor->cursor.bitmap.w>SDL_VIDEO_GF_MAX_CURSOR_SIZE)
{
didata->cursor.cursor.bitmap.w=SDL_VIDEO_GF_MAX_CURSOR_SIZE;
}
else
{
didata->cursor.cursor.bitmap.w=internal_cursor->cursor.bitmap.w;
}
if (didata->cursor.cursor.bitmap.h>SDL_VIDEO_GF_MAX_CURSOR_SIZE)
{
didata->cursor.cursor.bitmap.h=SDL_VIDEO_GF_MAX_CURSOR_SIZE;
}
else
{
didata->cursor.cursor.bitmap.h=internal_cursor->cursor.bitmap.h;
}
didata->cursor.cursor.bitmap.color0=internal_cursor->cursor.bitmap.color0;
didata->cursor.cursor.bitmap.color1=internal_cursor->cursor.bitmap.color1;
didata->cursor.cursor.bitmap.stride=internal_cursor->cursor.bitmap.stride;
SDL_memcpy(didata->cursor.cursor.bitmap.image0,
internal_cursor->cursor.bitmap.image0,
((internal_cursor->cursor.bitmap.w+7)/(sizeof(uint8_t)*8))*internal_cursor->cursor.bitmap.h);
SDL_memcpy(didata->cursor.cursor.bitmap.image1,
internal_cursor->cursor.bitmap.image1,
((internal_cursor->cursor.bitmap.w+7)/(sizeof(uint8_t)*8))*internal_cursor->cursor.bitmap.h);
/* Setup cursor shape */
status=gf_cursor_set(didata->display, 0, internal_cursor);
if (status!=GF_ERR_OK)
{
if (status!=GF_ERR_NOSUPPORT)
{
SDL_SetError("GF: Can't set hardware cursor shape");
} 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) {
return -1;
}
} else {
return -1;
}
} else {
return -1;
}
}
/* Enable just set cursor */
status=gf_cursor_enable(didata->display, 0);
if (status!=GF_ERR_OK)
{
if (status!=GF_ERR_NOSUPPORT)
{
SDL_SetError("GF: Can't enable hardware cursor");
}
}
/* Check if we need to set new shape or disable cursor shape */
if (cursor != NULL) {
/* Retrieve GF cursor shape */
internal_cursor = (gf_cursor_t *) cursor->driverdata;
if (internal_cursor == NULL) {
SDL_SetError("GF: Internal cursor data is absent");
return -1;
}
}
/* Set cursor visible */
didata->cursor_visible=SDL_TRUE;
}
else
{
/* SDL requests to disable cursor */
status=gf_cursor_disable(didata->display, 0);
if (status!=GF_ERR_OK)
{
if (status!=GF_ERR_NOSUPPORT)
{
SDL_SetError("GF: Can't disable hardware cursor");
}
if ((internal_cursor->cursor.bitmap.image0 == NULL) ||
(internal_cursor->cursor.bitmap.image1 == NULL)) {
SDL_SetError("GF: Cursor shape is absent");
return -1;
}
}
}
/* Store last shown cursor to display data */
didata->cursor.type = internal_cursor->type;
didata->cursor.hotspot.x = internal_cursor->hotspot.x;
didata->cursor.hotspot.y = internal_cursor->hotspot.y;
if (internal_cursor->cursor.bitmap.w > SDL_VIDEO_GF_MAX_CURSOR_SIZE) {
didata->cursor.cursor.bitmap.w = SDL_VIDEO_GF_MAX_CURSOR_SIZE;
} else {
didata->cursor.cursor.bitmap.w = internal_cursor->cursor.bitmap.w;
}
if (didata->cursor.cursor.bitmap.h > SDL_VIDEO_GF_MAX_CURSOR_SIZE) {
didata->cursor.cursor.bitmap.h = SDL_VIDEO_GF_MAX_CURSOR_SIZE;
} else {
didata->cursor.cursor.bitmap.h = internal_cursor->cursor.bitmap.h;
}
didata->cursor.cursor.bitmap.color0 =
internal_cursor->cursor.bitmap.color0;
didata->cursor.cursor.bitmap.color1 =
internal_cursor->cursor.bitmap.color1;
didata->cursor.cursor.bitmap.stride =
internal_cursor->cursor.bitmap.stride;
SDL_memcpy(didata->cursor.cursor.bitmap.image0,
internal_cursor->cursor.bitmap.image0,
((internal_cursor->cursor.bitmap.w +
7) / (sizeof(uint8_t) * 8)) *
internal_cursor->cursor.bitmap.h);
SDL_memcpy(didata->cursor.cursor.bitmap.image1,
internal_cursor->cursor.bitmap.image1,
((internal_cursor->cursor.bitmap.w +
7) / (sizeof(uint8_t) * 8)) *
internal_cursor->cursor.bitmap.h);
/* Setup cursor shape */
status = gf_cursor_set(didata->display, 0, internal_cursor);
if (status != GF_ERR_OK) {
if (status != GF_ERR_NOSUPPORT) {
SDL_SetError("GF: Can't set hardware cursor shape");
return -1;
}
}
/* Enable just set cursor */
status = gf_cursor_enable(didata->display, 0);
if (status != GF_ERR_OK) {
if (status != GF_ERR_NOSUPPORT) {
SDL_SetError("GF: Can't enable hardware cursor");
return -1;
}
}
/* Set cursor visible */
didata->cursor_visible = SDL_TRUE;
} else {
/* SDL requests to disable cursor */
status = gf_cursor_disable(didata->display, 0);
if (status != GF_ERR_OK) {
if (status != GF_ERR_NOSUPPORT) {
SDL_SetError("GF: Can't disable hardware cursor");
return -1;
}
}
/* Set cursor invisible */
didata->cursor_visible=SDL_FALSE;
}
/* Set cursor invisible */
didata->cursor_visible = SDL_FALSE;
}
/* New cursor shape is set */
return 0;
/* New cursor shape is set */
return 0;
}
void gf_movecursor(SDL_Cursor* cursor)
void
gf_movecursor(SDL_Cursor * cursor)
{
SDL_VideoDisplay* display;
SDL_DisplayData* didata;
SDL_Window* window;
SDL_WindowID window_id;
int32_t status;
uint32_t xmax;
uint32_t ymax;
/* Get current window id */
window_id=SDL_GetFocusWindow();
if (window_id<=0)
{
didata=(SDL_DisplayData*)cursor->mouse->driverdata;
if (didata==NULL)
{
return;
}
}
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;
SDL_VideoDisplay *display;
SDL_DisplayData *didata;
SDL_Window *window;
SDL_WindowID window_id;
int32_t status;
uint32_t xmax;
uint32_t ymax;
/* Get current window id */
window_id = SDL_GetFocusWindow();
if (window_id <= 0) {
didata = (SDL_DisplayData *) cursor->mouse->driverdata;
if (didata == NULL) {
return;
}
} 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
{
} else {
return;
}
}
/* Add checks for out of screen bounds position */
if (cursor->mouse->x < 0) {
cursor->mouse->x = 0;
}
if (cursor->mouse->y < 0) {
cursor->mouse->y = 0;
}
/* Get window size to clamp maximum coordinates */
SDL_GetWindowSize(window_id, &xmax, &ymax);
if (cursor->mouse->x >= xmax) {
cursor->mouse->x = xmax - 1;
}
if (cursor->mouse->y >= ymax) {
cursor->mouse->y = ymax - 1;
}
status =
gf_cursor_set_pos(didata->display, 0, cursor->mouse->x,
cursor->mouse->y);
if (status != GF_ERR_OK) {
if (status != GF_ERR_NOSUPPORT) {
SDL_SetError("GF: Can't set hardware cursor position");
return;
}
}
else
{
return;
}
}
/* Add checks for out of screen bounds position */
if (cursor->mouse->x<0)
{
cursor->mouse->x=0;
}
if (cursor->mouse->y<0)
{
cursor->mouse->y=0;
}
/* Get window size to clamp maximum coordinates */
SDL_GetWindowSize(window_id, &xmax, &ymax);
if (cursor->mouse->x>=xmax)
{
cursor->mouse->x=xmax-1;
}
if (cursor->mouse->y>=ymax)
{
cursor->mouse->y=ymax-1;
}
status=gf_cursor_set_pos(didata->display, 0, cursor->mouse->x, cursor->mouse->y);
if (status!=GF_ERR_OK)
{
if (status!=GF_ERR_NOSUPPORT)
{
SDL_SetError("GF: Can't set hardware cursor position");
return;
}
}
}
}
}
void gf_freecursor(SDL_Cursor* cursor)
void
gf_freecursor(SDL_Cursor * cursor)
{
gf_cursor_t* internal_cursor;
if (cursor!=NULL)
{
internal_cursor=(gf_cursor_t*)cursor->driverdata;
if (internal_cursor!=NULL)
{
if (internal_cursor->cursor.bitmap.image0!=NULL)
{
SDL_free((uint8_t*)internal_cursor->cursor.bitmap.image0);
}
if (internal_cursor->cursor.bitmap.image1!=NULL)
{
SDL_free((uint8_t*)internal_cursor->cursor.bitmap.image1);
}
SDL_free(internal_cursor);
}
}
gf_cursor_t *internal_cursor;
if (cursor != NULL) {
internal_cursor = (gf_cursor_t *) cursor->driverdata;
if (internal_cursor != NULL) {
if (internal_cursor->cursor.bitmap.image0 != NULL) {
SDL_free((uint8_t *) internal_cursor->cursor.bitmap.image0);
}
if (internal_cursor->cursor.bitmap.image1 != NULL) {
SDL_free((uint8_t *) internal_cursor->cursor.bitmap.image1);
}
SDL_free(internal_cursor);
}
}
}
void gf_warpmouse(SDL_Mouse* mouse, SDL_WindowID windowID, int x, int y)
void
gf_warpmouse(SDL_Mouse * mouse, SDL_WindowID windowID, int x, int y)
{
SDL_VideoDisplay* display;
SDL_DisplayData* didata;
SDL_Window* window;
uint32_t xmax;
uint32_t ymax;
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)
{
SDL_VideoDisplay *display;
SDL_DisplayData *didata;
SDL_Window *window;
uint32_t xmax;
uint32_t ymax;
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;
}
}
else
{
return;
}
/* Add checks for out of screen bounds position */
if (x<0)
{
x=0;
}
if (y<0)
{
y=0;
}
/* Get window size to clamp maximum coordinates */
SDL_GetWindowSize(windowID, &xmax, &ymax);
if (x>=xmax)
{
x=xmax-1;
}
if (y>=ymax)
{
y=ymax-1;
}
status=gf_cursor_set_pos(didata->display, 0, x, y);
if (status!=GF_ERR_OK)
{
if (status!=GF_ERR_NOSUPPORT)
{
SDL_SetError("GF: Can't set hardware cursor position");
return;
}
}
}
} else {
return;
}
/* Add checks for out of screen bounds position */
if (x < 0) {
x = 0;
}
if (y < 0) {
y = 0;
}
/* Get window size to clamp maximum coordinates */
SDL_GetWindowSize(windowID, &xmax, &ymax);
if (x >= xmax) {
x = xmax - 1;
}
if (y >= ymax) {
y = ymax - 1;
}
status = gf_cursor_set_pos(didata->display, 0, x, y);
if (status != GF_ERR_OK) {
if (status != GF_ERR_NOSUPPORT) {
SDL_SetError("GF: Can't set hardware cursor position");
return;
}
}
}
void gf_freemouse(SDL_Mouse* mouse)
void
gf_freemouse(SDL_Mouse * mouse)
{
if (mouse->driverdata==NULL)
{
return;
}
if (mouse->driverdata == NULL) {
return;
}
/* Mouse framework doesn't deletes automatically our driverdata */
SDL_free(mouse->driverdata);
mouse->driverdata=NULL;
/* Mouse framework doesn't deletes automatically our driverdata */
SDL_free(mouse->driverdata);
mouse->driverdata = NULL;
return;
return;
}
/*****************************************************************************/
......@@ -577,619 +529,610 @@ void gf_freemouse(SDL_Mouse* mouse)
/*****************************************************************************/
static key_packet key_last_state[SDL_HIDDI_MAX_DEVICES];
static void hiddi_keyboard_handler(uint32_t devno, uint8_t* report_data, uint32_t report_len)
static void
hiddi_keyboard_handler(uint32_t devno, uint8_t * report_data,
uint32_t report_len)
{
key_packet* packet;
uint32_t it;
uint32_t jt;
packet=(key_packet*)report_data;
/* Check for special states */
switch (report_len)
{
case 8: /* 8 bytes of report length */
{
for (it=0; it<6; it++)
{
/* Check for keyboard overflow, when it can't handle */
/* many simultaneous pressed keys */
if (packet->codes[it]==HIDDI_KEY_OVERFLOW)
{
key_packet *packet;
uint32_t it;
uint32_t jt;
packet = (key_packet *) report_data;
/* Check for special states */
switch (report_len) {
case 8: /* 8 bytes of report length */
{
for (it = 0; it < 6; it++) {
/* Check for keyboard overflow, when it can't handle */
/* many simultaneous pressed keys */
if (packet->codes[it] == HIDDI_KEY_OVERFLOW) {
return;
}
}
}
break;
default:
{
/* Do not process unknown reports */
return;
}
break;
}
/* Check if modifier key was pressed */
if (packet->modifiers!=key_last_state[devno].modifiers)
{
if (((packet->modifiers & HIDDI_MKEY_LEFT_CTRL)==HIDDI_MKEY_LEFT_CTRL) &&
(key_last_state[devno].modifiers & HIDDI_MKEY_LEFT_CTRL)==0)
{
/* Left Ctrl key was pressed */
SDL_SendKeyboardKey(0, SDL_PRESSED, SDL_SCANCODE_LCTRL);
}
if (((packet->modifiers & HIDDI_MKEY_LEFT_CTRL)==0) &&
(key_last_state[devno].modifiers & HIDDI_MKEY_LEFT_CTRL)==HIDDI_MKEY_LEFT_CTRL)
{
/* Left Ctrl key was released */
SDL_SendKeyboardKey(0, SDL_RELEASED, SDL_SCANCODE_LCTRL);
}
if (((packet->modifiers & HIDDI_MKEY_LEFT_SHIFT)==HIDDI_MKEY_LEFT_SHIFT) &&
(key_last_state[devno].modifiers & HIDDI_MKEY_LEFT_SHIFT)==0)
{
/* Left Shift key was pressed */
SDL_SendKeyboardKey(0, SDL_PRESSED, SDL_SCANCODE_LSHIFT);
}
if (((packet->modifiers & HIDDI_MKEY_LEFT_SHIFT)==0) &&
(key_last_state[devno].modifiers & HIDDI_MKEY_LEFT_SHIFT)==HIDDI_MKEY_LEFT_SHIFT)
{
/* Left Shift key was released */
SDL_SendKeyboardKey(0, SDL_RELEASED, SDL_SCANCODE_LSHIFT);
}
if (((packet->modifiers & HIDDI_MKEY_LEFT_ALT)==HIDDI_MKEY_LEFT_ALT) &&
(key_last_state[devno].modifiers & HIDDI_MKEY_LEFT_ALT)==0)
{
/* Left Alt key was pressed */
SDL_SendKeyboardKey(0, SDL_PRESSED, SDL_SCANCODE_LALT);
}
if (((packet->modifiers & HIDDI_MKEY_LEFT_ALT)==0) &&
(key_last_state[devno].modifiers & HIDDI_MKEY_LEFT_ALT)==HIDDI_MKEY_LEFT_ALT)
{
/* Left Alt key was released */
SDL_SendKeyboardKey(0, SDL_RELEASED, SDL_SCANCODE_LALT);
}
if (((packet->modifiers & HIDDI_MKEY_LEFT_WFLAG)==HIDDI_MKEY_LEFT_WFLAG) &&
(key_last_state[devno].modifiers & HIDDI_MKEY_LEFT_WFLAG)==0)
{
/* Left Windows flag key was pressed */
SDL_SendKeyboardKey(0, SDL_PRESSED, SDL_SCANCODE_LGUI);
}
if (((packet->modifiers & HIDDI_MKEY_LEFT_WFLAG)==0) &&
(key_last_state[devno].modifiers & HIDDI_MKEY_LEFT_WFLAG)==HIDDI_MKEY_LEFT_WFLAG)
{
/* Left Windows flag key was released */
SDL_SendKeyboardKey(0, SDL_RELEASED, SDL_SCANCODE_LGUI);
}
if (((packet->modifiers & HIDDI_MKEY_RIGHT_CTRL)==HIDDI_MKEY_RIGHT_CTRL) &&
(key_last_state[devno].modifiers & HIDDI_MKEY_RIGHT_CTRL)==0)
{
/* Right Ctrl key was pressed */
SDL_SendKeyboardKey(0, SDL_PRESSED, SDL_SCANCODE_RCTRL);
}
if (((packet->modifiers & HIDDI_MKEY_RIGHT_CTRL)==0) &&
(key_last_state[devno].modifiers & HIDDI_MKEY_RIGHT_CTRL)==HIDDI_MKEY_RIGHT_CTRL)
{
/* Right Ctrl key was released */
SDL_SendKeyboardKey(0, SDL_RELEASED, SDL_SCANCODE_RCTRL);
}
if (((packet->modifiers & HIDDI_MKEY_RIGHT_SHIFT)==HIDDI_MKEY_RIGHT_SHIFT) &&
(key_last_state[devno].modifiers & HIDDI_MKEY_RIGHT_SHIFT)==0)
{
/* Right Shift key was pressed */
SDL_SendKeyboardKey(0, SDL_PRESSED, SDL_SCANCODE_RSHIFT);
}
if (((packet->modifiers & HIDDI_MKEY_RIGHT_SHIFT)==0) &&
(key_last_state[devno].modifiers & HIDDI_MKEY_RIGHT_SHIFT)==HIDDI_MKEY_RIGHT_SHIFT)
{
/* Right Shift key was released */
SDL_SendKeyboardKey(0, SDL_RELEASED, SDL_SCANCODE_RSHIFT);
}
if (((packet->modifiers & HIDDI_MKEY_RIGHT_ALT)==HIDDI_MKEY_RIGHT_ALT) &&
(key_last_state[devno].modifiers & HIDDI_MKEY_RIGHT_ALT)==0)
{
/* Right Alt key was pressed */
SDL_SendKeyboardKey(0, SDL_PRESSED, SDL_SCANCODE_RALT);
}
if (((packet->modifiers & HIDDI_MKEY_RIGHT_ALT)==0) &&
(key_last_state[devno].modifiers & HIDDI_MKEY_RIGHT_ALT)==HIDDI_MKEY_RIGHT_ALT)
{
/* Right Alt key was released */
SDL_SendKeyboardKey(0, SDL_RELEASED, SDL_SCANCODE_RALT);
}
if (((packet->modifiers & HIDDI_MKEY_RIGHT_WFLAG)==HIDDI_MKEY_RIGHT_WFLAG) &&
(key_last_state[devno].modifiers & HIDDI_MKEY_RIGHT_WFLAG)==0)
{
/* Right Windows flag key was pressed */
SDL_SendKeyboardKey(0, SDL_PRESSED, SDL_SCANCODE_RGUI);
}
if (((packet->modifiers & HIDDI_MKEY_RIGHT_WFLAG)==0) &&
(key_last_state[devno].modifiers & HIDDI_MKEY_RIGHT_WFLAG)==HIDDI_MKEY_RIGHT_WFLAG)
{
/* Right Windows flag key was released */
SDL_SendKeyboardKey(0, SDL_RELEASED, SDL_SCANCODE_RGUI);
}
}
/* Check each key in the press/release buffer */
switch (report_len)
{
case 8: /* 8 bytes of report length */
{
/* Check if at least one key was unpressed */
for (it=0; it<6; it++)
{
if (key_last_state[devno].codes[it]==HIDDI_KEY_UNPRESSED)
{
}
}
}
break;
default:
{
/* Do not process unknown reports */
return;
}
break;
}
/* Check if modifier key was pressed */
if (packet->modifiers != key_last_state[devno].modifiers) {
if (((packet->modifiers & HIDDI_MKEY_LEFT_CTRL) ==
HIDDI_MKEY_LEFT_CTRL)
&& (key_last_state[devno].modifiers & HIDDI_MKEY_LEFT_CTRL) == 0) {
/* Left Ctrl key was pressed */
SDL_SendKeyboardKey(0, SDL_PRESSED, SDL_SCANCODE_LCTRL);
}
if (((packet->modifiers & HIDDI_MKEY_LEFT_CTRL) == 0) &&
(key_last_state[devno].modifiers & HIDDI_MKEY_LEFT_CTRL) ==
HIDDI_MKEY_LEFT_CTRL) {
/* Left Ctrl key was released */
SDL_SendKeyboardKey(0, SDL_RELEASED, SDL_SCANCODE_LCTRL);
}
if (((packet->modifiers & HIDDI_MKEY_LEFT_SHIFT) ==
HIDDI_MKEY_LEFT_SHIFT)
&& (key_last_state[devno].modifiers & HIDDI_MKEY_LEFT_SHIFT) == 0) {
/* Left Shift key was pressed */
SDL_SendKeyboardKey(0, SDL_PRESSED, SDL_SCANCODE_LSHIFT);
}
if (((packet->modifiers & HIDDI_MKEY_LEFT_SHIFT) == 0) &&
(key_last_state[devno].modifiers & HIDDI_MKEY_LEFT_SHIFT) ==
HIDDI_MKEY_LEFT_SHIFT) {
/* Left Shift key was released */
SDL_SendKeyboardKey(0, SDL_RELEASED, SDL_SCANCODE_LSHIFT);
}
if (((packet->modifiers & HIDDI_MKEY_LEFT_ALT) == HIDDI_MKEY_LEFT_ALT)
&& (key_last_state[devno].modifiers & HIDDI_MKEY_LEFT_ALT) == 0) {
/* Left Alt key was pressed */
SDL_SendKeyboardKey(0, SDL_PRESSED, SDL_SCANCODE_LALT);
}
if (((packet->modifiers & HIDDI_MKEY_LEFT_ALT) == 0) &&
(key_last_state[devno].modifiers & HIDDI_MKEY_LEFT_ALT) ==
HIDDI_MKEY_LEFT_ALT) {
/* Left Alt key was released */
SDL_SendKeyboardKey(0, SDL_RELEASED, SDL_SCANCODE_LALT);
}
if (((packet->modifiers & HIDDI_MKEY_LEFT_WFLAG) ==
HIDDI_MKEY_LEFT_WFLAG)
&& (key_last_state[devno].modifiers & HIDDI_MKEY_LEFT_WFLAG) == 0) {
/* Left Windows flag key was pressed */
SDL_SendKeyboardKey(0, SDL_PRESSED, SDL_SCANCODE_LGUI);
}
if (((packet->modifiers & HIDDI_MKEY_LEFT_WFLAG) == 0) &&
(key_last_state[devno].modifiers & HIDDI_MKEY_LEFT_WFLAG) ==
HIDDI_MKEY_LEFT_WFLAG) {
/* Left Windows flag key was released */
SDL_SendKeyboardKey(0, SDL_RELEASED, SDL_SCANCODE_LGUI);
}
if (((packet->modifiers & HIDDI_MKEY_RIGHT_CTRL) ==
HIDDI_MKEY_RIGHT_CTRL)
&& (key_last_state[devno].modifiers & HIDDI_MKEY_RIGHT_CTRL) == 0) {
/* Right Ctrl key was pressed */
SDL_SendKeyboardKey(0, SDL_PRESSED, SDL_SCANCODE_RCTRL);
}
if (((packet->modifiers & HIDDI_MKEY_RIGHT_CTRL) == 0) &&
(key_last_state[devno].modifiers & HIDDI_MKEY_RIGHT_CTRL) ==
HIDDI_MKEY_RIGHT_CTRL) {
/* Right Ctrl key was released */
SDL_SendKeyboardKey(0, SDL_RELEASED, SDL_SCANCODE_RCTRL);
}
if (((packet->modifiers & HIDDI_MKEY_RIGHT_SHIFT) ==
HIDDI_MKEY_RIGHT_SHIFT)
&& (key_last_state[devno].modifiers & HIDDI_MKEY_RIGHT_SHIFT) ==
0) {
/* Right Shift key was pressed */
SDL_SendKeyboardKey(0, SDL_PRESSED, SDL_SCANCODE_RSHIFT);
}
if (((packet->modifiers & HIDDI_MKEY_RIGHT_SHIFT) == 0) &&
(key_last_state[devno].modifiers & HIDDI_MKEY_RIGHT_SHIFT) ==
HIDDI_MKEY_RIGHT_SHIFT) {
/* Right Shift key was released */
SDL_SendKeyboardKey(0, SDL_RELEASED, SDL_SCANCODE_RSHIFT);
}
if (((packet->modifiers & HIDDI_MKEY_RIGHT_ALT) ==
HIDDI_MKEY_RIGHT_ALT)
&& (key_last_state[devno].modifiers & HIDDI_MKEY_RIGHT_ALT) == 0) {
/* Right Alt key was pressed */
SDL_SendKeyboardKey(0, SDL_PRESSED, SDL_SCANCODE_RALT);
}
if (((packet->modifiers & HIDDI_MKEY_RIGHT_ALT) == 0) &&
(key_last_state[devno].modifiers & HIDDI_MKEY_RIGHT_ALT) ==
HIDDI_MKEY_RIGHT_ALT) {
/* Right Alt key was released */
SDL_SendKeyboardKey(0, SDL_RELEASED, SDL_SCANCODE_RALT);
}
if (((packet->modifiers & HIDDI_MKEY_RIGHT_WFLAG) ==
HIDDI_MKEY_RIGHT_WFLAG)
&& (key_last_state[devno].modifiers & HIDDI_MKEY_RIGHT_WFLAG) ==
0) {
/* Right Windows flag key was pressed */
SDL_SendKeyboardKey(0, SDL_PRESSED, SDL_SCANCODE_RGUI);
}
if (((packet->modifiers & HIDDI_MKEY_RIGHT_WFLAG) == 0) &&
(key_last_state[devno].modifiers & HIDDI_MKEY_RIGHT_WFLAG) ==
HIDDI_MKEY_RIGHT_WFLAG) {
/* Right Windows flag key was released */
SDL_SendKeyboardKey(0, SDL_RELEASED, SDL_SCANCODE_RGUI);
}
}
/* Check each key in the press/release buffer */
switch (report_len) {
case 8: /* 8 bytes of report length */
{
/* Check if at least one key was unpressed */
for (it = 0; it < 6; it++) {
if (key_last_state[devno].codes[it] == HIDDI_KEY_UNPRESSED) {
/* if stored keycode is zero, find another */
continue;
}
for (jt=0; jt<6; jt++)
{
}
for (jt = 0; jt < 6; jt++) {
/* Find stored keycode in the current pressed codes */
if (packet->codes[jt]==key_last_state[devno].codes[it])
{
/* If found then particular key state is not changed */
break;
if (packet->codes[jt] == key_last_state[devno].codes[it]) {
/* If found then particular key state is not changed */
break;
}
}
/* Check if pressed key can't longer be found */
if (jt==6)
{
SDL_SendKeyboardKey(0, SDL_RELEASED, key_last_state[devno].codes[it]);
}
}
/* Check if at least one new key was pressed */
for (it=0; it<6; it++)
{
if (packet->codes[it]==HIDDI_KEY_UNPRESSED)
{
}
/* Check if pressed key can't longer be found */
if (jt == 6) {
SDL_SendKeyboardKey(0, SDL_RELEASED,
key_last_state[devno].codes[it]);
}
}
/* Check if at least one new key was pressed */
for (it = 0; it < 6; it++) {
if (packet->codes[it] == HIDDI_KEY_UNPRESSED) {
continue;
}
for (jt=0; jt<6; jt++)
{
}
for (jt = 0; jt < 6; jt++) {
/* Find new keycode it the array of old pressed keys */
if (packet->codes[it]==key_last_state[devno].codes[jt])
{
break;
if (packet->codes[it] == key_last_state[devno].codes[jt]) {
break;
}
}
}
/* Check if new key was pressed */
if (jt==6)
{
/* Check if new key was pressed */
if (jt == 6) {
SDL_SendKeyboardKey(0, SDL_PRESSED, packet->codes[it]);
}
}
}
default: /* unknown keyboard report type */
{
/* Ignore all unknown reports */
}
break;
}
/* Store last state */
key_last_state[devno]=*packet;
}
}
}
default: /* unknown keyboard report type */
{
/* Ignore all unknown reports */
}
break;
}
/* Store last state */
key_last_state[devno] = *packet;
}
static uint32_t mouse_last_state_button[SDL_HIDDI_MAX_DEVICES];
static uint32_t collect_reports=0;
static uint32_t collect_reports = 0;
static void hiddi_mouse_handler(uint32_t devno, uint8_t* report_data, uint32_t report_len)
static void
hiddi_mouse_handler(uint32_t devno, uint8_t * report_data,
uint32_t report_len)
{
uint32_t it;
uint32_t sdlbutton;
/* We do not want to collect stored events */
if (collect_reports==0)
{
return;
}
/* Check for special states */
switch (report_len)
{
case 8: /* 8 bytes of report length, usually multi-button USB mice */
{
mouse_packet8* packet;
packet=(mouse_packet8*)report_data;
/* Send motion event if motion really was */
if ((packet->horizontal_precision!=0) || (packet->vertical_precision!=0))
{
SDL_SendMouseMotion(0, 1, packet->horizontal_precision, packet->vertical_precision, 0);
}
/* Send mouse button press/release events */
if (mouse_last_state_button[devno]!=packet->buttons)
{
/* Cycle all buttons status */
for (it=0; it<8; it++)
{
uint32_t it;
uint32_t sdlbutton;
/* We do not want to collect stored events */
if (collect_reports == 0) {
return;
}
/* Check for special states */
switch (report_len) {
case 8: /* 8 bytes of report length, usually multi-button USB mice */
{
mouse_packet8 *packet;
packet = (mouse_packet8 *) report_data;
/* Send motion event if motion really was */
if ((packet->horizontal_precision != 0)
|| (packet->vertical_precision != 0)) {
SDL_SendMouseMotion(0, 1, packet->horizontal_precision,
packet->vertical_precision, 0);
}
/* Send mouse button press/release events */
if (mouse_last_state_button[devno] != packet->buttons) {
/* Cycle all buttons status */
for (it = 0; it < 8; it++) {
/* convert hiddi button id to sdl button id */
switch(it)
{
case 0:
{
sdlbutton=SDL_BUTTON_LEFT;
}
break;
case 1:
{
sdlbutton=SDL_BUTTON_RIGHT;
}
break;
case 2:
{
sdlbutton=SDL_BUTTON_MIDDLE;
}
break;
default:
{
sdlbutton=it+1;
}
break;
switch (it) {
case 0:
{
sdlbutton = SDL_BUTTON_LEFT;
}
break;
case 1:
{
sdlbutton = SDL_BUTTON_RIGHT;
}
break;
case 2:
{
sdlbutton = SDL_BUTTON_MIDDLE;
}
break;
default:
{
sdlbutton = it + 1;
}
break;
}
/* Button pressed */
if (((packet->buttons & (0x01<<it))==(0x01<<it)) &&
((mouse_last_state_button[devno] & (0x01<<it))==0x00))
{
SDL_SendMouseButton(0, SDL_PRESSED, sdlbutton);
if (((packet->buttons & (0x01 << it)) == (0x01 << it)) &&
((mouse_last_state_button[devno] & (0x01 << it)) ==
0x00)) {
SDL_SendMouseButton(0, SDL_PRESSED, sdlbutton);
}
/* Button released */
if (((packet->buttons & (0x01<<it))==0x00) &&
((mouse_last_state_button[devno] & (0x01<<it))==(0x01<<it)))
{
SDL_SendMouseButton(0, SDL_RELEASED, sdlbutton);
if (((packet->buttons & (0x01 << it)) == 0x00) &&
((mouse_last_state_button[devno] & (0x01 << it)) ==
(0x01 << it))) {
SDL_SendMouseButton(0, SDL_RELEASED, sdlbutton);
}
}
mouse_last_state_button[devno]=packet->buttons;
}
/* Send mouse wheel events */
if (packet->wheel!=0)
{
/* Send vertical wheel event only */
SDL_SendMouseWheel(0, 0, packet->wheel);
}
}
break;
case 4: /* 4 bytes of report length, usually PS/2 mice */
{
mouse_packet4* packet;
packet=(mouse_packet4*)report_data;
/* Send motion event if motion really was */
if ((packet->horizontal!=0) || (packet->vertical!=0))
{
SDL_SendMouseMotion(0, 1, packet->horizontal, packet->vertical, 0);
}
/* Send mouse button press/release events */
if (mouse_last_state_button[devno]!=packet->buttons)
{
/* Cycle all buttons status */
for (it=0; it<8; it++)
{
}
mouse_last_state_button[devno] = packet->buttons;
}
/* Send mouse wheel events */
if (packet->wheel != 0) {
/* Send vertical wheel event only */
SDL_SendMouseWheel(0, 0, packet->wheel);
}
}
break;
case 4: /* 4 bytes of report length, usually PS/2 mice */
{
mouse_packet4 *packet;
packet = (mouse_packet4 *) report_data;
/* Send motion event if motion really was */
if ((packet->horizontal != 0) || (packet->vertical != 0)) {
SDL_SendMouseMotion(0, 1, packet->horizontal,
packet->vertical, 0);
}
/* Send mouse button press/release events */
if (mouse_last_state_button[devno] != packet->buttons) {
/* Cycle all buttons status */
for (it = 0; it < 8; it++) {
/* convert hiddi button id to sdl button id */
switch(it)
{
case 0:
{
sdlbutton=SDL_BUTTON_LEFT;
}
break;
case 1:
{
sdlbutton=SDL_BUTTON_RIGHT;
}
break;
case 2:
{
sdlbutton=SDL_BUTTON_MIDDLE;
}
break;
default:
{
sdlbutton=it+1;
}
break;
switch (it) {
case 0:
{
sdlbutton = SDL_BUTTON_LEFT;
}
break;
case 1:
{
sdlbutton = SDL_BUTTON_RIGHT;
}
break;
case 2:
{
sdlbutton = SDL_BUTTON_MIDDLE;
}
break;
default:
{
sdlbutton = it + 1;
}
break;
}
/* Button pressed */
if (((packet->buttons & (0x01<<it))==(0x01<<it)) &&
((mouse_last_state_button[devno] & (0x01<<it))==0x00))
{
SDL_SendMouseButton(0, SDL_PRESSED, sdlbutton);
if (((packet->buttons & (0x01 << it)) == (0x01 << it)) &&
((mouse_last_state_button[devno] & (0x01 << it)) ==
0x00)) {
SDL_SendMouseButton(0, SDL_PRESSED, sdlbutton);
}
/* Button released */
if (((packet->buttons & (0x01<<it))==0x00) &&
((mouse_last_state_button[devno] & (0x01<<it))==(0x01<<it)))
{
SDL_SendMouseButton(0, SDL_RELEASED, sdlbutton);
if (((packet->buttons & (0x01 << it)) == 0x00) &&
((mouse_last_state_button[devno] & (0x01 << it)) ==
(0x01 << it))) {
SDL_SendMouseButton(0, SDL_RELEASED, sdlbutton);
}
}
mouse_last_state_button[devno]=packet->buttons;
}
/* Send mouse wheel events */
if (packet->wheel!=0)
{
/* Send vertical wheel event only */
SDL_SendMouseWheel(0, 0, packet->wheel);
}
}
break;
}
}
mouse_last_state_button[devno] = packet->buttons;
}
/* Send mouse wheel events */
if (packet->wheel != 0) {
/* Send vertical wheel event only */
SDL_SendMouseWheel(0, 0, packet->wheel);
}
}
break;
}
}
/*****************************************************************************/
/* HIDDI interacting code */
/*****************************************************************************/
static hidd_device_ident_t hiddevice=
{
HIDD_CONNECT_WILDCARD, /* vendor id: any */
HIDD_CONNECT_WILDCARD, /* product id: any */
HIDD_CONNECT_WILDCARD, /* version: any */
static hidd_device_ident_t hiddevice = {
HIDD_CONNECT_WILDCARD, /* vendor id: any */
HIDD_CONNECT_WILDCARD, /* product id: any */
HIDD_CONNECT_WILDCARD, /* version: any */
};
static hidd_connect_parm_t hidparams={NULL, HID_VERSION, HIDD_VERSION, 0, 0, &hiddevice, NULL, 0};
static hidd_connect_parm_t hidparams =
{ NULL, HID_VERSION, HIDD_VERSION, 0, 0, &hiddevice, NULL, 0 };
static void hiddi_insertion(struct hidd_connection* connection, hidd_device_instance_t* device_instance);
static void hiddi_removal(struct hidd_connection* connection, hidd_device_instance_t* instance);
static void hiddi_report(struct hidd_connection* connection, struct hidd_report* report, void* report_data, uint32_t report_len, uint32_t flags, void* user);
static void hiddi_insertion(struct hidd_connection *connection,
hidd_device_instance_t * device_instance);
static void hiddi_removal(struct hidd_connection *connection,
hidd_device_instance_t * instance);
static void hiddi_report(struct hidd_connection *connection,
struct hidd_report *report, void *report_data,
uint32_t report_len, uint32_t flags, void *user);
static hidd_funcs_t hidfuncs={_HIDDI_NFUNCS, hiddi_insertion, hiddi_removal, hiddi_report, NULL};
static hidd_funcs_t hidfuncs =
{ _HIDDI_NFUNCS, hiddi_insertion, hiddi_removal, hiddi_report, NULL };
/* HID handle, singletone */
struct hidd_connection* connection=NULL;
struct hidd_connection *connection = NULL;
/* SDL detected input device types, singletone */
static uint32_t sdl_input_devices[SDL_HIDDI_MAX_DEVICES];
static int hiddi_register_for_reports(struct hidd_collection* col, hidd_device_instance_t* device_instance)
static int
hiddi_register_for_reports(struct hidd_collection *col,
hidd_device_instance_t * device_instance)
{
int it;
uint16_t num_col;
struct hidd_collection** hidd_collections;
struct hidd_report_instance* report_instance;
struct hidd_report* report;
int status=0;
hidview_device_t* device;
for (it=0 ; it<10 && !status; it++)
{
status=hidd_get_report_instance(col, it, HID_INPUT_REPORT, &report_instance);
if (status==EOK)
{
status=hidd_report_attach(connection, device_instance, report_instance, 0, sizeof(hidview_device_t), &report);
if (status==EOK)
{
device=hidd_report_extra(report);
device->report=report;
device->instance=report_instance;
}
}
}
hidd_get_collections(NULL, col, &hidd_collections, &num_col);
for (it=0; it<num_col; it++)
{
hiddi_register_for_reports(hidd_collections[it], device_instance);
}
return EOK;
int it;
uint16_t num_col;
struct hidd_collection **hidd_collections;
struct hidd_report_instance *report_instance;
struct hidd_report *report;
int status = 0;
hidview_device_t *device;
for (it = 0; it < 10 && !status; it++) {
status =
hidd_get_report_instance(col, it, HID_INPUT_REPORT,
&report_instance);
if (status == EOK) {
status =
hidd_report_attach(connection, device_instance,
report_instance, 0,
sizeof(hidview_device_t), &report);
if (status == EOK) {
device = hidd_report_extra(report);
device->report = report;
device->instance = report_instance;
}
}
}
hidd_get_collections(NULL, col, &hidd_collections, &num_col);
for (it = 0; it < num_col; it++) {
hiddi_register_for_reports(hidd_collections[it], device_instance);
}
return EOK;
}
static void hiddi_insertion(struct hidd_connection* connection, hidd_device_instance_t* device_instance)
static void
hiddi_insertion(struct hidd_connection *connection,
hidd_device_instance_t * device_instance)
{
uint32_t it;
struct hidd_collection** hidd_collections;
uint16_t num_col;
/* get root level collections */
hidd_get_collections(device_instance, NULL, &hidd_collections, &num_col);
for (it=0; it<num_col; it++)
{
hiddi_register_for_reports(hidd_collections[it], device_instance);
}
uint32_t it;
struct hidd_collection **hidd_collections;
uint16_t num_col;
/* get root level collections */
hidd_get_collections(device_instance, NULL, &hidd_collections, &num_col);
for (it = 0; it < num_col; it++) {
hiddi_register_for_reports(hidd_collections[it], device_instance);
}
}
static void hiddi_removal(struct hidd_connection* connection, hidd_device_instance_t* instance)
static void
hiddi_removal(struct hidd_connection *connection,
hidd_device_instance_t * instance)
{
hidd_reports_detach(connection, instance);
hidd_reports_detach(connection, instance);
}
static void hiddi_report(struct hidd_connection* connection, hidd_report_t* report, void* report_data, uint32_t report_len, uint32_t flags, void* user)
static void
hiddi_report(struct hidd_connection *connection, hidd_report_t * report,
void *report_data, uint32_t report_len, uint32_t flags,
void *user)
{
if (report->dev_inst->devno>=SDL_HIDDI_MAX_DEVICES)
{
/* Unknown HID device, with devno number out of supported range */
return;
}
/* Check device type which generates event */
switch (sdl_input_devices[report->dev_inst->devno])
{
case SDL_GF_HIDDI_NONE:
{
/* We do not handle other devices type*/
return;
}
break;
case SDL_GF_HIDDI_MOUSE:
{
/* Call mouse handler */
hiddi_mouse_handler(report->dev_inst->devno, report_data, report_len);
}
break;
case SDL_GF_HIDDI_KEYBOARD:
{
/* Call keyboard handler */
hiddi_keyboard_handler(report->dev_inst->devno, report_data, report_len);
}
break;
case SDL_GF_HIDDI_JOYSTICK:
{
/* Call joystick handler */
}
break;
}
if (report->dev_inst->devno >= SDL_HIDDI_MAX_DEVICES) {
/* Unknown HID device, with devno number out of supported range */
return;
}
/* Check device type which generates event */
switch (sdl_input_devices[report->dev_inst->devno]) {
case SDL_GF_HIDDI_NONE:
{
/* We do not handle other devices type */
return;
}
break;
case SDL_GF_HIDDI_MOUSE:
{
/* Call mouse handler */
hiddi_mouse_handler(report->dev_inst->devno, report_data,
report_len);
}
break;
case SDL_GF_HIDDI_KEYBOARD:
{
/* Call keyboard handler */
hiddi_keyboard_handler(report->dev_inst->devno, report_data,
report_len);
}
break;
case SDL_GF_HIDDI_JOYSTICK:
{
/* Call joystick handler */
}
break;
}
}
static hiddi_get_device_type(uint8_t* report_data, uint16_t report_length)
static
hiddi_get_device_type(uint8_t * report_data, uint16_t report_length)
{
hid_byte_t byte;
uint16_t usage_page=0;
uint16_t usage=0;
uint16_t data=0;
while (report_length && !(usage_page && usage))
{
if (hidp_analyse_byte(*report_data, &byte))
{
/* Error in parser, do nothing */
}
data=hidp_get_data((report_data+1), &byte);
switch (byte.HIDB_Type)
{
case HID_TYPE_GLOBAL:
if (!usage_page && byte.HIDB_Tag==HID_GLOBAL_USAGE_PAGE)
{
usage_page=data;
}
break;
case HID_TYPE_LOCAL:
if (!usage && byte.HIDB_Tag==HID_LOCAL_USAGE)
{
usage=data;
}
break;
}
report_data+=byte.HIDB_Length+1;
report_length-=byte.HIDB_Length+1;
}
switch (usage_page)
{
case HIDD_PAGE_DESKTOP:
{
switch (usage)
{
case HIDD_USAGE_MOUSE:
{
return SDL_GF_HIDDI_MOUSE;
}
break;
case HIDD_USAGE_JOYSTICK:
{
return SDL_GF_HIDDI_JOYSTICK;
}
break;
case HIDD_USAGE_KEYBOARD:
{
return SDL_GF_HIDDI_KEYBOARD;
}
break;
}
}
break;
case HIDD_PAGE_DIGITIZER:
{
/* Do not handle digitizers */
}
break;
case HIDD_PAGE_CONSUMER:
{
/* Do not handle consumer input devices */
}
break;
}
return SDL_GF_HIDDI_NONE;
hid_byte_t byte;
uint16_t usage_page = 0;
uint16_t usage = 0;
uint16_t data = 0;
while (report_length && !(usage_page && usage)) {
if (hidp_analyse_byte(*report_data, &byte)) {
/* Error in parser, do nothing */
}
data = hidp_get_data((report_data + 1), &byte);
switch (byte.HIDB_Type) {
case HID_TYPE_GLOBAL:
if (!usage_page && byte.HIDB_Tag == HID_GLOBAL_USAGE_PAGE) {
usage_page = data;
}
break;
case HID_TYPE_LOCAL:
if (!usage && byte.HIDB_Tag == HID_LOCAL_USAGE) {
usage = data;
}
break;
}
report_data += byte.HIDB_Length + 1;
report_length -= byte.HIDB_Length + 1;
}
switch (usage_page) {
case HIDD_PAGE_DESKTOP:
{
switch (usage) {
case HIDD_USAGE_MOUSE:
{
return SDL_GF_HIDDI_MOUSE;
}
break;
case HIDD_USAGE_JOYSTICK:
{
return SDL_GF_HIDDI_JOYSTICK;
}
break;
case HIDD_USAGE_KEYBOARD:
{
return SDL_GF_HIDDI_KEYBOARD;
}
break;
}
}
break;
case HIDD_PAGE_DIGITIZER:
{
/* Do not handle digitizers */
}
break;
case HIDD_PAGE_CONSUMER:
{
/* Do not handle consumer input devices */
}
break;
}
return SDL_GF_HIDDI_NONE;
}
static int32_t hiddi_connect_devices()
static int32_t
hiddi_connect_devices()
{
int32_t status;
uint32_t it;
uint8_t* report_data;
uint16_t report_length;
hidd_device_instance_t instance;
/* Cleanup initial keys and mice state */
SDL_memset(key_last_state, 0x00, sizeof(key_packet)*SDL_HIDDI_MAX_DEVICES);
SDL_memset(mouse_last_state_button, 0x00, sizeof(uint32_t)*SDL_HIDDI_MAX_DEVICES);
status=hidd_connect(&hidparams, &connection);
if (status!=EOK)
{
return -1;
}
for (it=0; it<SDL_HIDDI_MAX_DEVICES; it++)
{
/* Get device instance */
status=hidd_get_device_instance(connection, it, &instance);
if (status!=EOK)
{
continue;
}
status=hidd_get_report_desc(connection, &instance, &report_data, &report_length);
if (status!=EOK)
{
continue;
}
status=hiddi_get_device_type(report_data, report_length);
sdl_input_devices[it]=status;
free(report_data);
}
/* Disconnect from HID server */
status=hidd_disconnect(connection);
if (status!=EOK)
{
return -1;
}
/* Add handlers for HID devices */
hidparams.funcs=&hidfuncs;
status=hidd_connect(&hidparams, &connection);
if (status!=EOK)
{
return -1;
}
return 0;
int32_t status;
uint32_t it;
uint8_t *report_data;
uint16_t report_length;
hidd_device_instance_t instance;
/* Cleanup initial keys and mice state */
SDL_memset(key_last_state, 0x00,
sizeof(key_packet) * SDL_HIDDI_MAX_DEVICES);
SDL_memset(mouse_last_state_button, 0x00,
sizeof(uint32_t) * SDL_HIDDI_MAX_DEVICES);
status = hidd_connect(&hidparams, &connection);
if (status != EOK) {
return -1;
}
for (it = 0; it < SDL_HIDDI_MAX_DEVICES; it++) {
/* Get device instance */
status = hidd_get_device_instance(connection, it, &instance);
if (status != EOK) {
continue;
}
status =
hidd_get_report_desc(connection, &instance, &report_data,
&report_length);
if (status != EOK) {
continue;
}
status = hiddi_get_device_type(report_data, report_length);
sdl_input_devices[it] = status;
free(report_data);
}
/* Disconnect from HID server */
status = hidd_disconnect(connection);
if (status != EOK) {
return -1;
}
/* Add handlers for HID devices */
hidparams.funcs = &hidfuncs;
status = hidd_connect(&hidparams, &connection);
if (status != EOK) {
return -1;
}
return 0;
}
static int32_t hiddi_disconnect_devices()
static int32_t
hiddi_disconnect_devices()
{
int32_t status;
int32_t status;
hiddi_disable_mouse();
hiddi_disable_mouse();
/* Disconnect from HID server */
status=hidd_disconnect(connection);
if (status!=EOK)
{
return -1;
}
/* Disconnect from HID server */
status = hidd_disconnect(connection);
if (status != EOK) {
return -1;
}
}
void hiddi_enable_mouse()
void
hiddi_enable_mouse()
{
collect_reports=1;
collect_reports = 1;
}
void hiddi_disable_mouse()
void
hiddi_disable_mouse()
{
collect_reports=0;
collect_reports = 0;
}
......@@ -42,7 +42,7 @@
typedef struct SDL_MouseData
{
SDL_DisplayData* didata;
SDL_DisplayData *didata;
} SDL_MouseData;
int32_t gf_addinputdevices(_THIS);
......@@ -65,85 +65,85 @@ int32_t gf_delinputdevices(_THIS);
typedef struct _hid_byte
{
uint8_t HIDB_Length;
uint8_t HIDB_Type;
uint8_t HIDB_Tag;
uint8_t reserved[1];
uint8_t HIDB_Length;
uint8_t HIDB_Type;
uint8_t HIDB_Tag;
uint8_t reserved[1];
} hid_byte_t;
typedef struct _hidd_global_item
{
uint16_t usage_page;
uint16_t logical_min;
uint16_t logical_max;
uint16_t physical_min;
uint16_t physical_max;
uint16_t unit_expo;
uint16_t unit;
uint16_t report_size;
uint16_t report_id;
uint16_t report_count;
uint16_t usage_page;
uint16_t logical_min;
uint16_t logical_max;
uint16_t physical_min;
uint16_t physical_max;
uint16_t unit_expo;
uint16_t unit;
uint16_t report_size;
uint16_t report_id;
uint16_t report_count;
} hidd_global_item_t;
typedef struct _hidd_local_item
{
uint16_t type;
uint8_t reserved[2];
uint32_t value;
struct _hidd_local_item* next_local;
struct _hidd_local_item* alt_local;
uint16_t type;
uint8_t reserved[2];
uint32_t value;
struct _hidd_local_item *next_local;
struct _hidd_local_item *alt_local;
} hidd_local_item_t;
typedef struct _hidd_local_table
{
hidd_local_item_t* usage_info;
hidd_local_item_t* designator_info;
hidd_local_item_t* string_info;
uint8_t delimiter;
uint8_t reserved[3];
hidd_local_item_t *usage_info;
hidd_local_item_t *designator_info;
hidd_local_item_t *string_info;
uint8_t delimiter;
uint8_t reserved[3];
} hidd_local_table_t;
typedef struct _hidd_field
{
struct hidd_report_instance* report;
struct hidd_collection* collection;
uint16_t report_offset;
uint16_t flags;
hidd_global_item_t gitem;
hidd_local_table_t* ltable;
struct _hidd_field* next_field;
void* user;
struct hidd_report_instance *report;
struct hidd_collection *collection;
uint16_t report_offset;
uint16_t flags;
hidd_global_item_t gitem;
hidd_local_table_t *ltable;
struct _hidd_field *next_field;
void *user;
} hidd_field_t;
typedef struct hidd_report_instance
{
uint8_t report_id;
uint8_t reserved[1];
uint16_t report_type;
hidd_field_t* field;
uint16_t num_field;
uint16_t byte_len;
uint16_t bit_len;
uint8_t reserved2[2];
struct hidd_collection* collection;
struct hidd_report_instance* next_col_report;
struct hidd_report_instance* next_report;
uint8_t report_id;
uint8_t reserved[1];
uint16_t report_type;
hidd_field_t *field;
uint16_t num_field;
uint16_t byte_len;
uint16_t bit_len;
uint8_t reserved2[2];
struct hidd_collection *collection;
struct hidd_report_instance *next_col_report;
struct hidd_report_instance *next_report;
} hidd_report_instance_t;
typedef struct hidd_report
{
TAILQ_ENTRY(hidd_report) link;
hidd_report_instance_t* rinst;
hidd_device_instance_t* dev_inst;
uint32_t flags;
struct hidd_connection* connection;
void* user;
TAILQ_ENTRY(hidd_report) link;
hidd_report_instance_t *rinst;
hidd_device_instance_t *dev_inst;
uint32_t flags;
struct hidd_connection *connection;
void *user;
} hidd_report_t;
typedef struct hidview_device
{
struct hidd_report_instance* instance;
struct hidd_report* report;
struct hidd_report_instance *instance;
struct hidd_report *report;
} hidview_device_t;
/*****************************************************************************/
......
......@@ -30,21 +30,25 @@
/* This is OpenGL ES 1.0 helper functions from OpenGL ES 1.1 specification, */
/* which could be implemented independently from hardware, just wrappers */
GLAPI void APIENTRY glTexParameteri(GLenum target, GLenum pname, GLint param)
GLAPI void APIENTRY
glTexParameteri(GLenum target, GLenum pname, GLint param)
{
glTexParameterx(target, pname, (GLfixed)param);
return;
glTexParameterx(target, pname, (GLfixed) param);
return;
}
GLAPI void APIENTRY glTexParameteriv(GLenum target, GLenum pname, const GLint* params)
GLAPI void APIENTRY
glTexParameteriv(GLenum target, GLenum pname, const GLint * params)
{
/* Retrieve one parameter only */
glTexParameterx(target, pname, (GLfixed)*params);
return;
/* Retrieve one parameter only */
glTexParameterx(target, pname, (GLfixed) * params);
return;
}
GLAPI void APIENTRY glColor4ub(GLubyte red, GLubyte green, GLubyte blue, GLubyte alpha)
GLAPI void APIENTRY
glColor4ub(GLubyte red, GLubyte green, GLubyte blue, GLubyte alpha)
{
glColor4f(((GLfloat)red)/255.f, ((GLfloat)green)/255.f, ((GLfloat)blue)/255.f, ((GLfloat)alpha)/255.f);
return;
glColor4f(((GLfloat) red) / 255.f, ((GLfloat) green) / 255.f,
((GLfloat) blue) / 255.f, ((GLfloat) alpha) / 255.f);
return;
}
......@@ -31,7 +31,9 @@
#include <GLES/glext.h>
GLAPI void APIENTRY glTexParameteri(GLenum target, GLenum pname, GLint param);
GLAPI void APIENTRY glTexParameteriv(GLenum target, GLenum pname, const GLint* params);
GLAPI void APIENTRY glColor4ub(GLubyte red, GLubyte green, GLubyte blue, GLubyte alpha);
GLAPI void APIENTRY glTexParameteriv(GLenum target, GLenum pname,
const GLint * params);
GLAPI void APIENTRY glColor4ub(GLubyte red, GLubyte green, GLubyte blue,
GLubyte alpha);
#endif /* __SDL_GF_OPENGLES_H__ */
......@@ -27,148 +27,148 @@
#include "SDL_config.h"
#include "SDL_gf_pixelfmt.h"
gf_format_t qnxgf_sdl_to_gf_pixelformat(uint32_t pixelfmt)
gf_format_t
qnxgf_sdl_to_gf_pixelformat(uint32_t pixelfmt)
{
switch(pixelfmt)
{
case SDL_PIXELFORMAT_INDEX8:
{
return GF_FORMAT_PAL8;
}
break;
case SDL_PIXELFORMAT_ARGB1555:
{
return GF_FORMAT_PACK_ARGB1555;
}
break;
case SDL_PIXELFORMAT_ABGR1555:
{
return GF_FORMAT_PACK_ARGB1555;
}
break;
case SDL_PIXELFORMAT_RGB565:
{
return GF_FORMAT_PACK_RGB565;
}
break;
case SDL_PIXELFORMAT_RGB888:
{
return GF_FORMAT_BGR888;
}
break;
case SDL_PIXELFORMAT_BGRA8888:
{
return GF_FORMAT_BGRA8888;
}
break;
case SDL_PIXELFORMAT_ARGB8888:
{
return GF_FORMAT_ARGB8888;
}
break;
case SDL_PIXELFORMAT_YV12:
{
return GF_FORMAT_PLANAR_YUV_YV12;
}
break;
case SDL_PIXELFORMAT_YUY2:
{
return GF_FORMAT_PACK_YUV_YUY2;
}
break;
case SDL_PIXELFORMAT_UYVY:
{
return GF_FORMAT_PACK_YUV_UYVY;
}
break;
case SDL_PIXELFORMAT_YVYU:
{
return GF_FORMAT_PACK_YUV_YVYU;
}
break;
}
switch (pixelfmt) {
case SDL_PIXELFORMAT_INDEX8:
{
return GF_FORMAT_PAL8;
}
break;
case SDL_PIXELFORMAT_ARGB1555:
{
return GF_FORMAT_PACK_ARGB1555;
}
break;
case SDL_PIXELFORMAT_ABGR1555:
{
return GF_FORMAT_PACK_ARGB1555;
}
break;
case SDL_PIXELFORMAT_RGB565:
{
return GF_FORMAT_PACK_RGB565;
}
break;
case SDL_PIXELFORMAT_RGB888:
{
return GF_FORMAT_BGR888;
}
break;
case SDL_PIXELFORMAT_BGRA8888:
{
return GF_FORMAT_BGRA8888;
}
break;
case SDL_PIXELFORMAT_ARGB8888:
{
return GF_FORMAT_ARGB8888;
}
break;
case SDL_PIXELFORMAT_YV12:
{
return GF_FORMAT_PLANAR_YUV_YV12;
}
break;
case SDL_PIXELFORMAT_YUY2:
{
return GF_FORMAT_PACK_YUV_YUY2;
}
break;
case SDL_PIXELFORMAT_UYVY:
{
return GF_FORMAT_PACK_YUV_UYVY;
}
break;
case SDL_PIXELFORMAT_YVYU:
{
return GF_FORMAT_PACK_YUV_YVYU;
}
break;
}
return GF_FORMAT_INVALID;
return GF_FORMAT_INVALID;
}
uint32_t qnxgf_gf_to_sdl_pixelformat(gf_format_t pixelfmt)
uint32_t
qnxgf_gf_to_sdl_pixelformat(gf_format_t pixelfmt)
{
switch(pixelfmt)
{
case GF_FORMAT_PAL8:
{
return SDL_PIXELFORMAT_INDEX8;
}
break;
case GF_FORMAT_PKLE_ARGB1555:
{
return SDL_PIXELFORMAT_ARGB1555;
}
break;
case GF_FORMAT_PACK_ARGB1555:
{
return SDL_PIXELFORMAT_ARGB1555;
}
break;
case GF_FORMAT_PKBE_ARGB1555:
{
return SDL_PIXELFORMAT_ABGR1555;
}
break;
case GF_FORMAT_PKBE_RGB565:
{
return SDL_PIXELFORMAT_RGB565;
}
break;
case GF_FORMAT_PKLE_RGB565:
{
return SDL_PIXELFORMAT_RGB565;
}
break;
case GF_FORMAT_PACK_RGB565:
{
return SDL_PIXELFORMAT_RGB565;
}
break;
case GF_FORMAT_BGR888:
{
return SDL_PIXELFORMAT_RGB888;
}
break;
case GF_FORMAT_BGRA8888:
{
return SDL_PIXELFORMAT_BGRA8888;
}
break;
case GF_FORMAT_ARGB8888:
{
return SDL_PIXELFORMAT_ARGB8888;
}
break;
switch (pixelfmt) {
case GF_FORMAT_PAL8:
{
return SDL_PIXELFORMAT_INDEX8;
}
break;
case GF_FORMAT_PKLE_ARGB1555:
{
return SDL_PIXELFORMAT_ARGB1555;
}
break;
case GF_FORMAT_PACK_ARGB1555:
{
return SDL_PIXELFORMAT_ARGB1555;
}
break;
case GF_FORMAT_PKBE_ARGB1555:
{
return SDL_PIXELFORMAT_ABGR1555;
}
break;
case GF_FORMAT_PKBE_RGB565:
{
return SDL_PIXELFORMAT_RGB565;
}
break;
case GF_FORMAT_PKLE_RGB565:
{
return SDL_PIXELFORMAT_RGB565;
}
break;
case GF_FORMAT_PACK_RGB565:
{
return SDL_PIXELFORMAT_RGB565;
}
break;
case GF_FORMAT_BGR888:
{
return SDL_PIXELFORMAT_RGB888;
}
break;
case GF_FORMAT_BGRA8888:
{
return SDL_PIXELFORMAT_BGRA8888;
}
break;
case GF_FORMAT_ARGB8888:
{
return SDL_PIXELFORMAT_ARGB8888;
}
break;
case GF_FORMAT_PLANAR_YUV_YV12:
{
return SDL_PIXELFORMAT_YV12;
}
break;
case GF_FORMAT_PACK_YUV_YUY2:
{
return SDL_PIXELFORMAT_YUY2;
}
break;
case GF_FORMAT_PACK_YUV_UYVY:
{
return SDL_PIXELFORMAT_UYVY;
}
break;
case GF_FORMAT_PACK_YUV_YVYU:
{
return SDL_PIXELFORMAT_YVYU;
}
break;
}
case GF_FORMAT_PLANAR_YUV_YV12:
{
return SDL_PIXELFORMAT_YV12;
}
break;
case GF_FORMAT_PACK_YUV_YUY2:
{
return SDL_PIXELFORMAT_YUY2;
}
break;
case GF_FORMAT_PACK_YUV_UYVY:
{
return SDL_PIXELFORMAT_UYVY;
}
break;
case GF_FORMAT_PACK_YUV_YVYU:
{
return SDL_PIXELFORMAT_YVYU;
}
break;
}
return SDL_PIXELFORMAT_UNKNOWN;
return SDL_PIXELFORMAT_UNKNOWN;
}
/* vi: set ts=4 sw=4 expandtab: */
......@@ -32,7 +32,7 @@
#include <gf/gf.h>
gf_format_t qnxgf_sdl_to_gf_pixelformat(uint32_t pixelfmt);
uint32_t qnxgf_gf_to_sdl_pixelformat(gf_format_t pixelfmt);
uint32_t qnxgf_gf_to_sdl_pixelformat(gf_format_t pixelfmt);
#endif /* __SDL_GF_PIXELFMT_H__ */
......
......@@ -34,368 +34,392 @@
#include "SDL_gf_render.h"
#include "SDL_qnxgf.h"
static SDL_Renderer* gf_createrenderer(SDL_Window* window, Uint32 flags);
static int gf_displaymodechanged(SDL_Renderer* renderer);
static int gf_activaterenderer(SDL_Renderer* renderer);
static int gf_createtexture(SDL_Renderer* renderer, SDL_Texture* texture);
static int gf_querytexturepixels(SDL_Renderer* renderer, SDL_Texture* texture, void** pixels, int* pitch);
static int gf_settexturepalette(SDL_Renderer* renderer, SDL_Texture* texture, const SDL_Color* colors, int firstcolor, int ncolors);
static int gf_gettexturepalette(SDL_Renderer* renderer, SDL_Texture* texture, SDL_Color* colors, int firstcolor, int ncolors);
static int gf_settexturecolormod(SDL_Renderer* renderer, SDL_Texture* texture);
static int gf_settexturealphamod(SDL_Renderer* renderer, SDL_Texture* texture);
static int gf_settextureblendmode(SDL_Renderer* renderer, SDL_Texture* texture);
static int gf_settexturescalemode(SDL_Renderer* renderer, SDL_Texture* texture);
static int gf_updatetexture(SDL_Renderer* renderer, SDL_Texture* texture, const SDL_Rect* rect, const void* pixels, int pitch);
static int gf_locktexture(SDL_Renderer* renderer, SDL_Texture* texture, const SDL_Rect* rect, int markDirty, void** pixels, int* pitch);
static void gf_unlocktexture(SDL_Renderer* renderer, SDL_Texture* texture);
static void gf_dirtytexture(SDL_Renderer* renderer, SDL_Texture* texture, int numrects, const SDL_Rect* rects);
static int gf_renderpoint(SDL_Renderer* renderer, int x, int y);
static int gf_renderline(SDL_Renderer* renderer, int x1, int y1, int x2, int y2);
static int gf_renderfill(SDL_Renderer* renderer, const SDL_Rect* rect);
static int gf_rendercopy(SDL_Renderer* renderer, SDL_Texture* texture, const SDL_Rect* srcrect, const SDL_Rect* dstrect);
static void gf_renderpresent(SDL_Renderer* renderer);
static void gf_destroytexture(SDL_Renderer* renderer, SDL_Texture* texture);
static void gf_destroyrenderer(SDL_Renderer* renderer);
SDL_RenderDriver gf_renderdriver=
{
static SDL_Renderer *gf_createrenderer(SDL_Window * window, Uint32 flags);
static int gf_displaymodechanged(SDL_Renderer * renderer);
static int gf_activaterenderer(SDL_Renderer * renderer);
static int gf_createtexture(SDL_Renderer * renderer, SDL_Texture * texture);
static int gf_querytexturepixels(SDL_Renderer * renderer,
SDL_Texture * texture, void **pixels,
int *pitch);
static int gf_settexturepalette(SDL_Renderer * renderer,
SDL_Texture * texture,
const SDL_Color * colors, int firstcolor,
int ncolors);
static int gf_gettexturepalette(SDL_Renderer * renderer,
SDL_Texture * texture, SDL_Color * colors,
int firstcolor, int ncolors);
static int gf_settexturecolormod(SDL_Renderer * renderer,
SDL_Texture * texture);
static int gf_settexturealphamod(SDL_Renderer * renderer,
SDL_Texture * texture);
static int gf_settextureblendmode(SDL_Renderer * renderer,
SDL_Texture * texture);
static int gf_settexturescalemode(SDL_Renderer * renderer,
SDL_Texture * texture);
static int gf_updatetexture(SDL_Renderer * renderer, SDL_Texture * texture,
const SDL_Rect * rect, const void *pixels,
int pitch);
static int gf_locktexture(SDL_Renderer * renderer, SDL_Texture * texture,
const SDL_Rect * rect, int markDirty, void **pixels,
int *pitch);
static void gf_unlocktexture(SDL_Renderer * renderer, SDL_Texture * texture);
static void gf_dirtytexture(SDL_Renderer * renderer, SDL_Texture * texture,
int numrects, const SDL_Rect * rects);
static int gf_renderpoint(SDL_Renderer * renderer, int x, int y);
static int gf_renderline(SDL_Renderer * renderer, int x1, int y1, int x2,
int y2);
static int gf_renderfill(SDL_Renderer * renderer, const SDL_Rect * rect);
static int gf_rendercopy(SDL_Renderer * renderer, SDL_Texture * texture,
const SDL_Rect * srcrect, const SDL_Rect * dstrect);
static void gf_renderpresent(SDL_Renderer * renderer);
static void gf_destroytexture(SDL_Renderer * renderer, SDL_Texture * texture);
static void gf_destroyrenderer(SDL_Renderer * renderer);
SDL_RenderDriver gf_renderdriver = {
gf_createrenderer,
{
"qnxgf",
(SDL_RENDERER_SINGLEBUFFER | SDL_RENDERER_PRESENTCOPY |
SDL_RENDERER_PRESENTFLIP2 | SDL_RENDERER_PRESENTFLIP3 |
SDL_RENDERER_PRESENTVSYNC | SDL_RENDERER_PRESENTDISCARD |
SDL_RENDERER_ACCELERATED),
(SDL_TEXTUREMODULATE_NONE | SDL_TEXTUREMODULATE_COLOR |
SDL_TEXTUREMODULATE_ALPHA),
(SDL_BLENDMODE_NONE | SDL_BLENDMODE_MASK |
SDL_BLENDMODE_BLEND | SDL_BLENDMODE_ADD | SDL_BLENDMODE_MOD),
(SDL_TEXTURESCALEMODE_NONE | SDL_TEXTURESCALEMODE_SLOW),
13,
{
SDL_PIXELFORMAT_INDEX8,
SDL_PIXELFORMAT_RGB555,
SDL_PIXELFORMAT_RGB565,
SDL_PIXELFORMAT_RGB888,
SDL_PIXELFORMAT_BGR888,
SDL_PIXELFORMAT_ARGB8888,
SDL_PIXELFORMAT_RGBA8888,
SDL_PIXELFORMAT_ABGR8888,
SDL_PIXELFORMAT_BGRA8888,
SDL_PIXELFORMAT_YV12,
SDL_PIXELFORMAT_YUY2,
SDL_PIXELFORMAT_UYVY,
SDL_PIXELFORMAT_YVYU
},
0,
0
}
"qnxgf",
(SDL_RENDERER_SINGLEBUFFER | SDL_RENDERER_PRESENTCOPY |
SDL_RENDERER_PRESENTFLIP2 | SDL_RENDERER_PRESENTFLIP3 |
SDL_RENDERER_PRESENTVSYNC | SDL_RENDERER_PRESENTDISCARD |
SDL_RENDERER_ACCELERATED),
(SDL_TEXTUREMODULATE_NONE | SDL_TEXTUREMODULATE_COLOR |
SDL_TEXTUREMODULATE_ALPHA),
(SDL_BLENDMODE_NONE | SDL_BLENDMODE_MASK |
SDL_BLENDMODE_BLEND | SDL_BLENDMODE_ADD | SDL_BLENDMODE_MOD),
(SDL_TEXTURESCALEMODE_NONE | SDL_TEXTURESCALEMODE_SLOW),
13,
{
SDL_PIXELFORMAT_INDEX8,
SDL_PIXELFORMAT_RGB555,
SDL_PIXELFORMAT_RGB565,
SDL_PIXELFORMAT_RGB888,
SDL_PIXELFORMAT_BGR888,
SDL_PIXELFORMAT_ARGB8888,
SDL_PIXELFORMAT_RGBA8888,
SDL_PIXELFORMAT_ABGR8888,
SDL_PIXELFORMAT_BGRA8888,
SDL_PIXELFORMAT_YV12,
SDL_PIXELFORMAT_YUY2,
SDL_PIXELFORMAT_UYVY,
SDL_PIXELFORMAT_YVYU},
0,
0}
};
static SDL_Renderer* gf_createrenderer(SDL_Window* window, Uint32 flags)
static SDL_Renderer *
gf_createrenderer(SDL_Window * window, Uint32 flags)
{
SDL_VideoDisplay* display = SDL_GetDisplayFromWindow(window);
SDL_DisplayData* didata = (SDL_DisplayData*)display->driverdata;
SDL_WindowData* wdata = (SDL_WindowData*)window->driverdata;
SDL_Renderer* renderer = NULL;
SDL_RenderData* rdata = NULL;
uint32_t it;
int32_t jt;
int32_t status;
/* Check if it is OpenGL ES window */
if ((window->flags & SDL_WINDOW_OPENGL)==SDL_WINDOW_OPENGL)
{
/* No error, just no need to create 2D renderer for OpenGL ES window */
return NULL;
}
/* Allocate new renderer structure */
renderer=(SDL_Renderer*)SDL_calloc(1, sizeof(SDL_Renderer));
if (renderer==NULL)
{
SDL_OutOfMemory();
return NULL;
}
/* Allocate renderer data */
rdata=(SDL_RenderData*)SDL_calloc(1, sizeof(SDL_RenderData));
if (rdata==NULL)
{
SDL_free(renderer);
SDL_OutOfMemory();
return NULL;
}
renderer->DisplayModeChanged=gf_displaymodechanged;
renderer->ActivateRenderer=gf_activaterenderer;
renderer->CreateTexture=gf_createtexture;
renderer->QueryTexturePixels=gf_querytexturepixels;
renderer->SetTexturePalette=gf_settexturepalette;
renderer->GetTexturePalette=gf_gettexturepalette;
renderer->SetTextureAlphaMod=gf_settexturealphamod;
renderer->SetTextureColorMod=gf_settexturecolormod;
renderer->SetTextureBlendMode=gf_settextureblendmode;
renderer->SetTextureScaleMode=gf_settexturescalemode;
renderer->UpdateTexture=gf_updatetexture;
renderer->LockTexture=gf_locktexture;
renderer->UnlockTexture=gf_unlocktexture;
renderer->DirtyTexture=gf_dirtytexture;
renderer->RenderPoint=gf_renderpoint;
renderer->RenderLine=gf_renderline;
renderer->RenderFill=gf_renderfill;
renderer->RenderCopy=gf_rendercopy;
renderer->RenderPresent = gf_renderpresent;
renderer->DestroyTexture = gf_destroytexture;
renderer->DestroyRenderer = gf_destroyrenderer;
renderer->info = gf_renderdriver.info;
renderer->window = window->id;
renderer->driverdata = rdata;
/* Set render acceleration flag in case it is accelerated */
if ((didata->caps & SDL_GF_ACCELERATED)==SDL_GF_ACCELERATED)
{
renderer->info.flags=SDL_RENDERER_ACCELERATED;
}
else
{
renderer->info.flags&=~(SDL_RENDERER_ACCELERATED);
}
rdata->window=window;
/* Check if upper level requested synchronization on vsync signal */
if ((flags & SDL_RENDERER_PRESENTVSYNC)==SDL_RENDERER_PRESENTVSYNC)
{
rdata->enable_vsync=SDL_TRUE;
}
else
{
rdata->enable_vsync=SDL_FALSE;
}
/* Check what buffer copy/flip scheme is requested */
rdata->surfaces_count=0;
if ((flags & SDL_RENDERER_SINGLEBUFFER)==SDL_RENDERER_SINGLEBUFFER)
{
if ((flags & SDL_RENDERER_PRESENTDISCARD)==SDL_RENDERER_PRESENTDISCARD)
{
renderer->info.flags|=SDL_RENDERER_SINGLEBUFFER | SDL_RENDERER_PRESENTDISCARD;
}
else
{
renderer->info.flags|=SDL_RENDERER_SINGLEBUFFER | SDL_RENDERER_PRESENTCOPY;
}
rdata->surfaces_count=1;
rdata->surface_visible_idx=0;
rdata->surface_render_idx=0;
}
else
{
if ((flags & SDL_RENDERER_PRESENTFLIP2)==SDL_RENDERER_PRESENTFLIP2)
{
renderer->info.flags|=SDL_RENDERER_PRESENTFLIP2;
rdata->surfaces_count=2;
rdata->surface_visible_idx=0;
rdata->surface_render_idx=1;
}
else
{
if ((flags & SDL_RENDERER_PRESENTFLIP3)==SDL_RENDERER_PRESENTFLIP3)
{
renderer->info.flags|=SDL_RENDERER_PRESENTFLIP3;
rdata->surfaces_count=3;
rdata->surface_visible_idx=0;
rdata->surface_render_idx=1;
}
else
{
renderer->info.flags|=SDL_RENDERER_SINGLEBUFFER | SDL_RENDERER_PRESENTCOPY;
rdata->surfaces_count=1;
rdata->surface_visible_idx=0;
rdata->surface_render_idx=0;
}
}
}
/* Create layer surfaces, which could be visible */
for (it=0; it<rdata->surfaces_count; it++)
{
/* TODO: add palette creation */
/* Create displayable surfaces */
status=gf_surface_create_layer(&rdata->surface[it], &didata->layer, 1, 0,
didata->current_mode.w, didata->current_mode.h,
qnxgf_sdl_to_gf_pixelformat(didata->current_mode.format), NULL,
GF_SURFACE_CREATE_2D_ACCESSIBLE);
if (status!=GF_ERR_OK)
{
/* Free already allocated surfaces */
for (jt=it-1; jt>0; jt--)
{
gf_surface_free(rdata->surface[jt]);
rdata->surface[jt]=NULL;
}
SDL_free(rdata);
SDL_free(renderer);
if (status==GF_ERR_MEM)
{
SDL_SetError("unsufficient free video memory");
}
else
{
SDL_SetError("error during displayable surface creation");
}
return NULL;
}
/* Get detailed information about allocated surface */
gf_surface_get_info(rdata->surface[it], &rdata->surface_info[it]);
}
return renderer;
SDL_VideoDisplay *display = SDL_GetDisplayFromWindow(window);
SDL_DisplayData *didata = (SDL_DisplayData *) display->driverdata;
SDL_WindowData *wdata = (SDL_WindowData *) window->driverdata;
SDL_Renderer *renderer = NULL;
SDL_RenderData *rdata = NULL;
uint32_t it;
int32_t jt;
int32_t status;
/* Check if it is OpenGL ES window */
if ((window->flags & SDL_WINDOW_OPENGL) == SDL_WINDOW_OPENGL) {
/* No error, just no need to create 2D renderer for OpenGL ES window */
return NULL;
}
/* Allocate new renderer structure */
renderer = (SDL_Renderer *) SDL_calloc(1, sizeof(SDL_Renderer));
if (renderer == NULL) {
SDL_OutOfMemory();
return NULL;
}
/* Allocate renderer data */
rdata = (SDL_RenderData *) SDL_calloc(1, sizeof(SDL_RenderData));
if (rdata == NULL) {
SDL_free(renderer);
SDL_OutOfMemory();
return NULL;
}
renderer->DisplayModeChanged = gf_displaymodechanged;
renderer->ActivateRenderer = gf_activaterenderer;
renderer->CreateTexture = gf_createtexture;
renderer->QueryTexturePixels = gf_querytexturepixels;
renderer->SetTexturePalette = gf_settexturepalette;
renderer->GetTexturePalette = gf_gettexturepalette;
renderer->SetTextureAlphaMod = gf_settexturealphamod;
renderer->SetTextureColorMod = gf_settexturecolormod;
renderer->SetTextureBlendMode = gf_settextureblendmode;
renderer->SetTextureScaleMode = gf_settexturescalemode;
renderer->UpdateTexture = gf_updatetexture;
renderer->LockTexture = gf_locktexture;
renderer->UnlockTexture = gf_unlocktexture;
renderer->DirtyTexture = gf_dirtytexture;
renderer->RenderPoint = gf_renderpoint;
renderer->RenderLine = gf_renderline;
renderer->RenderFill = gf_renderfill;
renderer->RenderCopy = gf_rendercopy;
renderer->RenderPresent = gf_renderpresent;
renderer->DestroyTexture = gf_destroytexture;
renderer->DestroyRenderer = gf_destroyrenderer;
renderer->info = gf_renderdriver.info;
renderer->window = window->id;
renderer->driverdata = rdata;
/* Set render acceleration flag in case it is accelerated */
if ((didata->caps & SDL_GF_ACCELERATED) == SDL_GF_ACCELERATED) {
renderer->info.flags = SDL_RENDERER_ACCELERATED;
} else {
renderer->info.flags &= ~(SDL_RENDERER_ACCELERATED);
}
rdata->window = window;
/* Check if upper level requested synchronization on vsync signal */
if ((flags & SDL_RENDERER_PRESENTVSYNC) == SDL_RENDERER_PRESENTVSYNC) {
rdata->enable_vsync = SDL_TRUE;
} else {
rdata->enable_vsync = SDL_FALSE;
}
/* Check what buffer copy/flip scheme is requested */
rdata->surfaces_count = 0;
if ((flags & SDL_RENDERER_SINGLEBUFFER) == SDL_RENDERER_SINGLEBUFFER) {
if ((flags & SDL_RENDERER_PRESENTDISCARD) ==
SDL_RENDERER_PRESENTDISCARD) {
renderer->info.flags |=
SDL_RENDERER_SINGLEBUFFER | SDL_RENDERER_PRESENTDISCARD;
} else {
renderer->info.flags |=
SDL_RENDERER_SINGLEBUFFER | SDL_RENDERER_PRESENTCOPY;
}
rdata->surfaces_count = 1;
rdata->surface_visible_idx = 0;
rdata->surface_render_idx = 0;
} else {
if ((flags & SDL_RENDERER_PRESENTFLIP2) == SDL_RENDERER_PRESENTFLIP2) {
renderer->info.flags |= SDL_RENDERER_PRESENTFLIP2;
rdata->surfaces_count = 2;
rdata->surface_visible_idx = 0;
rdata->surface_render_idx = 1;
} else {
if ((flags & SDL_RENDERER_PRESENTFLIP3) ==
SDL_RENDERER_PRESENTFLIP3) {
renderer->info.flags |= SDL_RENDERER_PRESENTFLIP3;
rdata->surfaces_count = 3;
rdata->surface_visible_idx = 0;
rdata->surface_render_idx = 1;
} else {
renderer->info.flags |=
SDL_RENDERER_SINGLEBUFFER | SDL_RENDERER_PRESENTCOPY;
rdata->surfaces_count = 1;
rdata->surface_visible_idx = 0;
rdata->surface_render_idx = 0;
}
}
}
/* Create layer surfaces, which could be visible */
for (it = 0; it < rdata->surfaces_count; it++) {
/* TODO: add palette creation */
/* Create displayable surfaces */
status =
gf_surface_create_layer(&rdata->surface[it], &didata->layer, 1, 0,
didata->current_mode.w,
didata->current_mode.h,
qnxgf_sdl_to_gf_pixelformat(didata->
current_mode.
format), NULL,
GF_SURFACE_CREATE_2D_ACCESSIBLE);
if (status != GF_ERR_OK) {
/* Free already allocated surfaces */
for (jt = it - 1; jt > 0; jt--) {
gf_surface_free(rdata->surface[jt]);
rdata->surface[jt] = NULL;
}
SDL_free(rdata);
SDL_free(renderer);
if (status == GF_ERR_MEM) {
SDL_SetError("unsufficient free video memory");
} else {
SDL_SetError("error during displayable surface creation");
}
return NULL;
}
/* Get detailed information about allocated surface */
gf_surface_get_info(rdata->surface[it], &rdata->surface_info[it]);
}
return renderer;
}
void gf_addrenderdriver(_THIS)
void
gf_addrenderdriver(_THIS)
{
uint32_t it;
uint32_t it;
for (it=0; it<_this->num_displays; it++)
{
SDL_AddRenderDriver(it, &gf_renderdriver);
}
for (it = 0; it < _this->num_displays; it++) {
SDL_AddRenderDriver(it, &gf_renderdriver);
}
}
/****************************************************************************/
/* SDL render interface */
/****************************************************************************/
static int gf_displaymodechanged(SDL_Renderer* renderer)
static int
gf_displaymodechanged(SDL_Renderer * renderer)
{
SDL_RenderData* rdata=(SDL_RenderData*)renderer->driverdata;
SDL_RenderData *rdata = (SDL_RenderData *) renderer->driverdata;
/* Remove all allocated surfaces, they are no more valid */
/* Remove all allocated surfaces, they are no more valid */
/* TODO: Add video mode change detection and new parameters detection */
/* TODO: Add video mode change detection and new parameters detection */
return 0;
return 0;
}
static int gf_activaterenderer(SDL_Renderer* renderer)
static int
gf_activaterenderer(SDL_Renderer * renderer)
{
SDL_RenderData* rdata=(SDL_RenderData*)renderer->driverdata;
SDL_VideoDisplay* display = SDL_GetDisplayFromWindow(rdata->window);
SDL_DisplayData* didata = (SDL_DisplayData*)display->driverdata;
SDL_RenderData *rdata = (SDL_RenderData *) renderer->driverdata;
SDL_VideoDisplay *display = SDL_GetDisplayFromWindow(rdata->window);
SDL_DisplayData *didata = (SDL_DisplayData *) display->driverdata;
/* Setup current surface as visible */
/* Setup current surface as visible */
// gf_layer_set_surfaces(didata->layer, &rdata->surface[rdata->surface_visible_idx], 1);
/* Set visible surface when hardware in idle state */
/* Set visible surface when hardware in idle state */
// gf_layer_update(didata->layer, GF_LAYER_UPDATE_NO_WAIT_IDLE);
return 0;
return 0;
}
static int gf_createtexture(SDL_Renderer* renderer, SDL_Texture* texture)
static int
gf_createtexture(SDL_Renderer * renderer, SDL_Texture * texture)
{
SDL_RenderData* renderdata=(SDL_RenderData*)renderer->driverdata;
SDL_Window* window=SDL_GetWindowFromID(renderer->window);
SDL_VideoDisplay* display=SDL_GetDisplayFromWindow(window);
SDL_TextureData* tdata=NULL;
/* Allocate texture driver data */
tdata=(SDL_TextureData*)SDL_calloc(1, sizeof(SDL_TextureData));
if (tdata==NULL)
{
SDL_OutOfMemory();
return -1;
}
/* Set texture driver data */
texture->driverdata=tdata;
SDL_RenderData *renderdata = (SDL_RenderData *) renderer->driverdata;
SDL_Window *window = SDL_GetWindowFromID(renderer->window);
SDL_VideoDisplay *display = SDL_GetDisplayFromWindow(window);
SDL_TextureData *tdata = NULL;
/* Allocate texture driver data */
tdata = (SDL_TextureData *) SDL_calloc(1, sizeof(SDL_TextureData));
if (tdata == NULL) {
SDL_OutOfMemory();
return -1;
}
/* Set texture driver data */
texture->driverdata = tdata;
}
static int gf_querytexturepixels(SDL_Renderer* renderer, SDL_Texture* texture, void** pixels, int* pitch)
static int
gf_querytexturepixels(SDL_Renderer * renderer, SDL_Texture * texture,
void **pixels, int *pitch)
{
}
static int gf_settexturepalette(SDL_Renderer* renderer, SDL_Texture* texture, const SDL_Color* colors, int firstcolor, int ncolors)
static int
gf_settexturepalette(SDL_Renderer * renderer, SDL_Texture * texture,
const SDL_Color * colors, int firstcolor, int ncolors)
{
}
static int gf_gettexturepalette(SDL_Renderer* renderer, SDL_Texture* texture, SDL_Color* colors, int firstcolor, int ncolors)
static int
gf_gettexturepalette(SDL_Renderer * renderer, SDL_Texture * texture,
SDL_Color * colors, int firstcolor, int ncolors)
{
}
static int gf_settexturecolormod(SDL_Renderer* renderer, SDL_Texture* texture)
static int
gf_settexturecolormod(SDL_Renderer * renderer, SDL_Texture * texture)
{
}
static int gf_settexturealphamod(SDL_Renderer* renderer, SDL_Texture* texture)
static int
gf_settexturealphamod(SDL_Renderer * renderer, SDL_Texture * texture)
{
}
static int gf_settextureblendmode(SDL_Renderer* renderer, SDL_Texture* texture)
static int
gf_settextureblendmode(SDL_Renderer * renderer, SDL_Texture * texture)
{
}
static int gf_settexturescalemode(SDL_Renderer* renderer, SDL_Texture* texture)
static int
gf_settexturescalemode(SDL_Renderer * renderer, SDL_Texture * texture)
{
}
static int gf_updatetexture(SDL_Renderer* renderer, SDL_Texture* texture, const SDL_Rect* rect, const void* pixels, int pitch)
static int
gf_updatetexture(SDL_Renderer * renderer, SDL_Texture * texture,
const SDL_Rect * rect, const void *pixels, int pitch)
{
}
static int gf_locktexture(SDL_Renderer* renderer, SDL_Texture* texture, const SDL_Rect* rect, int markDirty, void** pixels, int* pitch)
static int
gf_locktexture(SDL_Renderer * renderer, SDL_Texture * texture,
const SDL_Rect * rect, int markDirty, void **pixels,
int *pitch)
{
}
static void gf_unlocktexture(SDL_Renderer* renderer, SDL_Texture* texture)
static void
gf_unlocktexture(SDL_Renderer * renderer, SDL_Texture * texture)
{
}
static void gf_dirtytexture(SDL_Renderer* renderer, SDL_Texture* texture, int numrects, const SDL_Rect* rects)
static void
gf_dirtytexture(SDL_Renderer * renderer, SDL_Texture * texture, int numrects,
const SDL_Rect * rects)
{
}
static int gf_renderpoint(SDL_Renderer* renderer, int x, int y)
static int
gf_renderpoint(SDL_Renderer * renderer, int x, int y)
{
}
static int gf_renderline(SDL_Renderer* renderer, int x1, int y1, int x2, int y2)
static int
gf_renderline(SDL_Renderer * renderer, int x1, int y1, int x2, int y2)
{
}
static int gf_renderfill(SDL_Renderer* renderer, const SDL_Rect* rect)
static int
gf_renderfill(SDL_Renderer * renderer, const SDL_Rect * rect)
{
}
static int gf_rendercopy(SDL_Renderer* renderer, SDL_Texture* texture, const SDL_Rect* srcrect, const SDL_Rect* dstrect)
static int
gf_rendercopy(SDL_Renderer * renderer, SDL_Texture * texture,
const SDL_Rect * srcrect, const SDL_Rect * dstrect)
{
}
static void gf_renderpresent(SDL_Renderer* renderer)
static void
gf_renderpresent(SDL_Renderer * renderer)
{
}
static void gf_destroytexture(SDL_Renderer* renderer, SDL_Texture* texture)
static void
gf_destroytexture(SDL_Renderer * renderer, SDL_Texture * texture)
{
}
static void gf_destroyrenderer(SDL_Renderer* renderer)
static void
gf_destroyrenderer(SDL_Renderer * renderer)
{
SDL_RenderData* rdata=(SDL_RenderData*)renderer->driverdata;
uint32_t it;
for (it=0; it<rdata->surfaces_count; it++)
{
if (rdata->surface[it]!=NULL)
{
gf_surface_free(rdata->surface[it]);
}
}
SDL_RenderData *rdata = (SDL_RenderData *) renderer->driverdata;
uint32_t it;
for (it = 0; it < rdata->surfaces_count; it++) {
if (rdata->surface[it] != NULL) {
gf_surface_free(rdata->surface[it]);
}
}
}
/* vi: set ts=4 sw=4 expandtab: */
......@@ -35,19 +35,19 @@
typedef struct SDL_RenderData
{
SDL_Window* window; /* SDL window type */
SDL_bool enable_vsync; /* VSYNC flip synchronization enable */
gf_surface_t surface[SDL_GF_MAX_SURFACES]; /* Surface handles */
gf_surface_info_t surface_info[SDL_GF_MAX_SURFACES]; /* Surface info */
uint32_t surface_visible_idx; /* Index of visible surface */
uint32_t surface_render_idx; /* Index of render surface */
uint32_t surfaces_count; /* Amount of allocated surfaces */
SDL_Window *window; /* SDL window type */
SDL_bool enable_vsync; /* VSYNC flip synchronization enable */
gf_surface_t surface[SDL_GF_MAX_SURFACES]; /* Surface handles */
gf_surface_info_t surface_info[SDL_GF_MAX_SURFACES]; /* Surface info */
uint32_t surface_visible_idx; /* Index of visible surface */
uint32_t surface_render_idx; /* Index of render surface */
uint32_t surfaces_count; /* Amount of allocated surfaces */
} SDL_RenderData;
typedef struct SDL_TextureData
{
gf_surface_t surface;
gf_surface_info_t surface_info;
gf_surface_t surface;
gf_surface_info_t surface_info;
} SDL_TextureData;
extern void gf_addrenderdriver(_THIS);
......
......@@ -32,9 +32,9 @@
/* PS/2 and USB keyboards are generating this packet */
typedef struct key_packet
{
uint8_t modifiers;
uint8_t data;
uint8_t codes[6];
uint8_t modifiers;
uint8_t data;
uint8_t codes[6];
} key_packet;
/* Key modifier codes */
......
......@@ -32,38 +32,38 @@
/* USB keyboard multimedia keys are generating this packet */
typedef struct mouse_packet2
{
uint8_t buttons;
int8_t wheel;
uint8_t buttons;
int8_t wheel;
} mouse_packet2;
/* PS/2 mice are generating this packet */
typedef struct mouse_packet4
{
uint8_t buttons;
int8_t horizontal;
int8_t vertical;
int8_t wheel;
uint8_t buttons;
int8_t horizontal;
int8_t vertical;
int8_t wheel;
} mouse_packet4;
/* USB keyboard with mice wheel onboard generating this packet */
typedef struct mouse_packet5
{
uint8_t buttons;
int8_t horizontal;
int8_t vertical;
int8_t wheel;
uint8_t state;
uint8_t buttons;
int8_t horizontal;
int8_t vertical;
int8_t wheel;
uint8_t state;
} mouse_packet5;
/* USB multi-button mice are generating this packet */
typedef struct mouse_packet8
{
uint8_t buttons;
int8_t horizontal;
int8_t vertical;
int8_t wheel;
int16_t horizontal_precision;
int16_t vertical_precision;
uint8_t buttons;
int8_t horizontal;
int8_t vertical;
int8_t wheel;
int16_t horizontal_precision;
int16_t vertical_precision;
} mouse_packet8;
#endif /* __SDL_HIDDI_MOUSE_H__ */
This source diff could not be displayed because it is too large. You can view the blob instead.
......@@ -33,19 +33,19 @@
#include <gf/gf3d.h>
#if defined(SDL_VIDEO_OPENGL_ES)
#include <GLES/egl.h>
#include <GLES/egl.h>
#endif /* SDL_VIDEO_OPENGL_ES */
typedef struct SDL_VideoData
{
gf_dev_t gfdev; /* GF device handle */
gf_dev_info_t gfdev_info; /* GF device information */
SDL_bool gfinitialized; /* GF device initialization status */
#if defined(SDL_VIDEO_OPENGL_ES)
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 */
gf_dev_t gfdev; /* GF device handle */
gf_dev_info_t gfdev_info; /* GF device information */
SDL_bool gfinitialized; /* GF device initialization status */
#if defined(SDL_VIDEO_OPENGL_ES)
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_GF_DEVICENAME_MAX 257
......@@ -53,18 +53,18 @@ typedef struct SDL_VideoData
typedef struct SDL_DisplayData
{
gf_display_info_t display_info; /* GF display information */
gf_display_t display; /* GF display handle */
uint32_t custom_refresh; /* Custom refresh rate for all modes */
SDL_DisplayMode current_mode; /* Current video mode */
uint8_t description[SDL_VIDEO_GF_DEVICENAME_MAX];
/* Device description */
uint32_t caps; /* Device capabilities */
SDL_bool layer_attached; /* Layer attach status */
gf_layer_t layer; /* Graphics layer to which attached */
gf_surface_t surface[3]; /* Visible surface on the display */
SDL_bool cursor_visible; /* SDL_TRUE if cursor visible */
gf_cursor_t cursor; /* Cursor shape which was set last */
gf_display_info_t display_info; /* GF display information */
gf_display_t display; /* GF display handle */
uint32_t custom_refresh; /* Custom refresh rate for all modes */
SDL_DisplayMode current_mode; /* Current video mode */
uint8_t description[SDL_VIDEO_GF_DEVICENAME_MAX];
/* Device description */
uint32_t caps; /* Device capabilities */
SDL_bool layer_attached; /* Layer attach status */
gf_layer_t layer; /* Graphics layer to which attached */
gf_surface_t surface[3]; /* Visible surface on the display */
SDL_bool cursor_visible; /* SDL_TRUE if cursor visible */
gf_cursor_t cursor; /* Cursor shape which was set last */
} SDL_DisplayData;
/* Maximum amount of OpenGL ES framebuffer configurations */
......@@ -72,23 +72,23 @@ typedef struct SDL_DisplayData
typedef struct SDL_WindowData
{
SDL_bool uses_gles; /* true if window support OpenGL ES */
#if defined(SDL_VIDEO_OPENGL_ES)
gf_3d_target_t target; /* OpenGL ES window target */
SDL_bool target_created; /* GF 3D target is created if true */
EGLConfig gles_configs[SDL_VIDEO_GF_OPENGLES_CONFS];
/* OpenGL ES framebuffer confs */
EGLint gles_config; /* Config index in the array of cfgs */
EGLContext gles_context; /* OpenGL ES context */
EGLint gles_attributes[256]; /* OpenGL ES attributes for context */
EGLSurface gles_surface; /* OpenGL ES target rendering surface */
#endif /* SDL_VIDEO_OPENGL_ES */
SDL_bool uses_gles; /* true if window support OpenGL ES */
#if defined(SDL_VIDEO_OPENGL_ES)
gf_3d_target_t target; /* OpenGL ES window target */
SDL_bool target_created; /* GF 3D target is created if true */
EGLConfig gles_configs[SDL_VIDEO_GF_OPENGLES_CONFS];
/* OpenGL ES framebuffer confs */
EGLint gles_config; /* Config index in the array of cfgs */
EGLContext gles_context; /* OpenGL ES context */
EGLint gles_attributes[256]; /* OpenGL ES attributes for context */
EGLSurface gles_surface; /* OpenGL ES target rendering surface */
#endif /* SDL_VIDEO_OPENGL_ES */
} SDL_WindowData;
typedef struct SDL_GLDriverData
{
#if defined(SDL_VIDEO_OPENGL_ES)
#endif /* SDL_VIDEO_OPENGL_ES */
#if defined(SDL_VIDEO_OPENGL_ES)
#endif /* SDL_VIDEO_OPENGL_ES */
} SDL_GLDriverData;
/****************************************************************************/
......@@ -96,59 +96,60 @@ typedef struct SDL_GLDriverData
/****************************************************************************/
typedef struct GF_DeviceCaps
{
uint8_t* name;
uint32_t caps;
uint8_t *name;
uint32_t caps;
} GF_DeviceCaps;
#define SDL_GF_UNACCELERATED 0x00000000 /* driver is unaccelerated */
#define SDL_GF_ACCELERATED 0x00000001 /* driver is accelerated */
#define SDL_GF_NOLOWRESOLUTION 0x00000000 /* no modes below 640x480 */
#define SDL_GF_LOWRESOLUTION 0x00000002 /* support modes <640x480 */
#define SDL_GF_UNACCELERATED_3D 0x00000000 /* software OpenGL ES */
#define SDL_GF_ACCELERATED_3D 0x00000004 /* hardware acc. OpenGL ES */
#define SDL_GF_NOVIDEOMEMORY 0x00000000 /* no video memory alloc. */
#define SDL_GF_VIDEOMEMORY 0x00000008 /* has video memory alloc. */
#define SDL_GF_UNACCELERATED 0x00000000 /* driver is unaccelerated */
#define SDL_GF_ACCELERATED 0x00000001 /* driver is accelerated */
#define SDL_GF_NOLOWRESOLUTION 0x00000000 /* no modes below 640x480 */
#define SDL_GF_LOWRESOLUTION 0x00000002 /* support modes <640x480 */
#define SDL_GF_UNACCELERATED_3D 0x00000000 /* software OpenGL ES */
#define SDL_GF_ACCELERATED_3D 0x00000004 /* hardware acc. OpenGL ES */
#define SDL_GF_NOVIDEOMEMORY 0x00000000 /* no video memory alloc. */
#define SDL_GF_VIDEOMEMORY 0x00000008 /* has video memory alloc. */
/****************************************************************************/
/* SDL_VideoDevice functions declaration */
/****************************************************************************/
/* Display and window functions */
int qnxgf_videoinit(_THIS);
int qnxgf_videoinit(_THIS);
void qnxgf_videoquit(_THIS);
void qnxgf_getdisplaymodes(_THIS);
int qnxgf_setdisplaymode(_THIS, SDL_DisplayMode* mode);
int qnxgf_setdisplaypalette(_THIS, SDL_Palette* palette);
int qnxgf_getdisplaypalette(_THIS, SDL_Palette* palette);
int qnxgf_setdisplaygammaramp(_THIS, Uint16* ramp);
int qnxgf_getdisplaygammaramp(_THIS, Uint16* ramp);
int qnxgf_createwindow(_THIS, SDL_Window* window);
int qnxgf_createwindowfrom(_THIS, SDL_Window* window, const void* data);
void qnxgf_setwindowtitle(_THIS, SDL_Window* window);
void qnxgf_setwindowicon(_THIS, SDL_Window* window, SDL_Surface* icon);
void qnxgf_setwindowposition(_THIS, SDL_Window* window);
void qnxgf_setwindowsize(_THIS, SDL_Window* window);
void qnxgf_showwindow(_THIS, SDL_Window* window);
void qnxgf_hidewindow(_THIS, SDL_Window* window);
void qnxgf_raisewindow(_THIS, SDL_Window* window);
void qnxgf_maximizewindow(_THIS, SDL_Window* window);
void qnxgf_minimizewindow(_THIS, SDL_Window* window);
void qnxgf_restorewindow(_THIS, SDL_Window* window);
void qnxgf_setwindowgrab(_THIS, SDL_Window* window);
void qnxgf_destroywindow(_THIS, SDL_Window* window);
int qnxgf_setdisplaymode(_THIS, SDL_DisplayMode * mode);
int qnxgf_setdisplaypalette(_THIS, SDL_Palette * palette);
int qnxgf_getdisplaypalette(_THIS, SDL_Palette * palette);
int qnxgf_setdisplaygammaramp(_THIS, Uint16 * ramp);
int qnxgf_getdisplaygammaramp(_THIS, Uint16 * ramp);
int qnxgf_createwindow(_THIS, SDL_Window * window);
int qnxgf_createwindowfrom(_THIS, SDL_Window * window, const void *data);
void qnxgf_setwindowtitle(_THIS, SDL_Window * window);
void qnxgf_setwindowicon(_THIS, SDL_Window * window, SDL_Surface * icon);
void qnxgf_setwindowposition(_THIS, SDL_Window * window);
void qnxgf_setwindowsize(_THIS, SDL_Window * window);
void qnxgf_showwindow(_THIS, SDL_Window * window);
void qnxgf_hidewindow(_THIS, SDL_Window * window);
void qnxgf_raisewindow(_THIS, SDL_Window * window);
void qnxgf_maximizewindow(_THIS, SDL_Window * window);
void qnxgf_minimizewindow(_THIS, SDL_Window * window);
void qnxgf_restorewindow(_THIS, SDL_Window * window);
void qnxgf_setwindowgrab(_THIS, SDL_Window * window);
void qnxgf_destroywindow(_THIS, SDL_Window * window);
/* Window manager function */
SDL_bool qnxgf_getwindowwminfo(_THIS, SDL_Window* window, struct SDL_SysWMinfo* info);
SDL_bool qnxgf_getwindowwminfo(_THIS, SDL_Window * window,
struct SDL_SysWMinfo *info);
/* OpenGL/OpenGL ES functions */
int qnxgf_gl_loadlibrary(_THIS, const char* path);
void* qnxgf_gl_getprocaddres(_THIS, const char* proc);
int qnxgf_gl_loadlibrary(_THIS, const char *path);
void *qnxgf_gl_getprocaddres(_THIS, const char *proc);
void qnxgf_gl_unloadlibrary(_THIS);
SDL_GLContext qnxgf_gl_createcontext(_THIS, SDL_Window* window);
int qnxgf_gl_makecurrent(_THIS, SDL_Window* window, SDL_GLContext context);
SDL_GLContext qnxgf_gl_createcontext(_THIS, SDL_Window * window);
int qnxgf_gl_makecurrent(_THIS, SDL_Window * window, SDL_GLContext context);
int qnxgf_gl_setswapinterval(_THIS, int interval);
int qnxgf_gl_getswapinterval(_THIS);
void qnxgf_gl_swapwindow(_THIS, SDL_Window* window);
void qnxgf_gl_swapwindow(_THIS, SDL_Window * window);
void qnxgf_gl_deletecontext(_THIS, SDL_GLContext context);
/* Event handling function */
......
......@@ -481,7 +481,7 @@ GDI_SetTextureBlendMode(SDL_Renderer * renderer, SDL_Texture * texture)
/* Crap, we've lost the original pixel data... *sigh* */
}
return 0;
#ifndef _WIN32_WCE /* WinCE has no alphablend */
#ifndef _WIN32_WCE /* WinCE has no alphablend */
case SDL_BLENDMODE_MASK:
case SDL_BLENDMODE_BLEND:
if (!data->premultiplied && data->pixels) {
......@@ -627,7 +627,7 @@ GDI_LockTexture(SDL_Renderer * renderer, SDL_Texture * texture,
pitch);
} else if (data->pixels) {
#ifndef _WIN32_WCE
/* WinCE has no GdiFlush */
/* WinCE has no GdiFlush */
GdiFlush();
#endif
*pixels =
......
......@@ -191,12 +191,12 @@ WIN_WindowProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
0, 0);
SDL_SendWindowEvent(data->windowID,
SDL_WINDOWEVENT_RESTORED, 0, 0);
#ifndef _WIN32_WCE /* WinCE misses IsZoomed() */
#ifndef _WIN32_WCE /* WinCE misses IsZoomed() */
if (IsZoomed(hwnd)) {
SDL_SendWindowEvent(data->windowID,
SDL_WINDOWEVENT_MAXIMIZED, 0, 0);
}
#endif
#endif
if (keyboard && keyboard->focus != data->windowID) {
SDL_SetKeyboardFocus(index, data->windowID);
}
......@@ -218,18 +218,18 @@ WIN_WindowProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
*/
#ifdef _WIN32_WCE
case WM_MOUSEMOVE:
SDL_SendMouseMotion(0, 0, LOWORD(lParam), HIWORD(lParam), 0);
break;
SDL_SendMouseMotion(0, 0, LOWORD(lParam), HIWORD(lParam), 0);
break;
case WM_LBUTTONDOWN:
SDL_SendMouseMotion(0, 0, LOWORD(lParam), HIWORD(lParam), 0);
SDL_SendMouseButton(0, SDL_PRESSED, SDL_BUTTON_LEFT);
break;
SDL_SendMouseMotion(0, 0, LOWORD(lParam), HIWORD(lParam), 0);
SDL_SendMouseButton(0, SDL_PRESSED, SDL_BUTTON_LEFT);
break;
case WM_LBUTTONUP:
SDL_SendMouseMotion(0, 0, LOWORD(lParam), HIWORD(lParam), 0);
SDL_SendMouseButton(0, SDL_RELEASED, SDL_BUTTON_LEFT);
break;
SDL_SendMouseMotion(0, 0, LOWORD(lParam), HIWORD(lParam), 0);
SDL_SendMouseButton(0, SDL_RELEASED, SDL_BUTTON_LEFT);
break;
#else /* _WIN32_WCE */
case WM_INPUT: /* mouse events */
......@@ -261,7 +261,7 @@ WIN_WindowProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
break;
}
}
GetCursorPos(&point);
ScreenToClient(hwnd, &point);
......@@ -314,7 +314,7 @@ WIN_WindowProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
}
return (0);
#endif /* _WIN32_WCE */
case WM_MOUSELEAVE:
{
int i;
......@@ -598,7 +598,7 @@ WIN_WindowProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
case WM_NCPAINT:
{
if (SDL_GetWindowFlags(data->windowID) & SDL_WINDOW_FOREIGN) {
return(0);
return (0);
}
break;
}
......
......@@ -28,7 +28,7 @@ int
WIN_SetDisplayGammaRamp(_THIS, Uint16 * ramp)
{
#ifdef _WIN32_WCE
return -1;
return -1;
#else
SDL_DisplayData *data = (SDL_DisplayData *) SDL_CurrentDisplay.driverdata;
HDC hdc;
......@@ -50,7 +50,7 @@ int
WIN_GetDisplayGammaRamp(_THIS, Uint16 * ramp)
{
#ifdef _WIN32_WCE
return -1;
return -1;
#else
SDL_DisplayData *data = (SDL_DisplayData *) SDL_CurrentDisplay.driverdata;
HDC hdc;
......
......@@ -55,10 +55,10 @@ WIN_GetDisplayMode(LPCTSTR deviceName, DWORD index, SDL_DisplayMode * mode)
mode->driverdata = data;
#ifdef _WIN32_WCE
/* In WinCE EnumDisplaySettings(ENUM_CURRENT_SETTINGS) doesn't take the user defined orientation
into account but GetSystemMetrixs does. */
if(index == ENUM_CURRENT_SETTINGS) {
mode->w = GetSystemMetrics(SM_CXSCREEN);
mode->h = GetSystemMetrics(SM_CYSCREEN);
into account but GetSystemMetrixs does. */
if (index == ENUM_CURRENT_SETTINGS) {
mode->w = GetSystemMetrics(SM_CXSCREEN);
mode->h = GetSystemMetrics(SM_CYSCREEN);
}
#endif
......@@ -211,12 +211,12 @@ WIN_SetDisplayMode(_THIS, SDL_DisplayMode * mode)
{
SDL_DisplayModeData *data = (SDL_DisplayModeData *) mode->driverdata;
LONG status;
#ifdef _WIN32_WCE
/* TODO: implement correctly.
On my Asus MyPAL, if I execute the code below
I get DISP_CHANGE_BADFLAGS and the Titlebar of the fullscreen window stays
visible ... (SDL_RaiseWindow() would fix that one)*/
visible ... (SDL_RaiseWindow() would fix that one) */
return 0;
#endif
......
......@@ -40,7 +40,11 @@
#define WGL_CONTEXT_FORWARD_COMPATIBLE_BIT_ARB 0x0002
#endif
typedef HGLRC (APIENTRYP PFNWGLCREATECONTEXTATTRIBSARBPROC) (HDC hDC, HGLRC hShareContext, const int * attribList);
typedef HGLRC(APIENTRYP PFNWGLCREATECONTEXTATTRIBSARBPROC) (HDC hDC,
HGLRC
hShareContext,
const int
*attribList);
int
WIN_GL_LoadLibrary(_THIS, const char *path)
......@@ -502,17 +506,19 @@ WIN_GL_CreateContext(_THIS, SDL_Window * window)
PFNWGLCREATECONTEXTATTRIBSARBPROC wglCreateContextAttribsARB;
HGLRC temp_context = _this->gl_data->wglCreateContext(hdc);
if (!temp_context) {
SDL_SetError("Could not create GL context");
SDL_SetError("Could not create GL context");
return NULL;
}
/* Make the context current */
if (WIN_GL_MakeCurrent(_this, window, temp_context) < 0) {
WIN_GL_DeleteContext(_this, temp_context);
return NULL;
}
wglCreateContextAttribsARB = (PFNWGLCREATECONTEXTATTRIBSARBPROC) _this->gl_data->wglGetProcAddress("wglCreateContextAttribsARB");
wglCreateContextAttribsARB =
(PFNWGLCREATECONTEXTATTRIBSARBPROC) _this->gl_data->
wglGetProcAddress("wglCreateContextAttribsARB");
if (!wglCreateContextAttribsARB) {
SDL_SetError("GL 3.x is not supported");
context = temp_context;
......@@ -520,7 +526,7 @@ WIN_GL_CreateContext(_THIS, SDL_Window * window)
int attribs[] = {
WGL_CONTEXT_MAJOR_VERSION_ARB, _this->gl_config.major_version,
WGL_CONTEXT_MINOR_VERSION_ARB, _this->gl_config.minor_version,
0
0
};
/* Create the GL 3.x context */
context = wglCreateContextAttribsARB(hdc, 0, attribs);
......@@ -528,7 +534,7 @@ WIN_GL_CreateContext(_THIS, SDL_Window * window)
_this->gl_data->wglDeleteContext(temp_context);
}
}
if (!context) {
SDL_SetError("Could not create GL context");
return NULL;
......
......@@ -242,8 +242,7 @@ WIN_CreateWindow(_THIS, SDL_Window * window)
}
g_hCtx[window->id] = videodata->WTOpenA(hwnd, &lc, TRUE);
}
#ifndef _WIN32_WCE /* has no RawInput */
#ifndef _WIN32_WCE /* has no RawInput */
/* we're telling the window, we want it to report raw input events from mice */
Rid.usUsagePage = 0x01;
Rid.usUsage = 0x02;
......
......@@ -77,7 +77,13 @@
static void X11_GL_InitExtensions(_THIS);
/* Typedef for the GL 3.0 context creation function */
typedef GLXContext ( * PFNGLXCREATECONTEXTATTRIBSARBPROC) (Display *dpy, GLXFBConfig config, GLXContext share_context, Bool direct, const int *attrib_list);
typedef GLXContext(*PFNGLXCREATECONTEXTATTRIBSARBPROC) (Display * dpy,
GLXFBConfig config,
GLXContext
share_context,
Bool direct,
const int
*attrib_list);
int
X11_GL_LoadLibrary(_THIS, const char *path)
......@@ -283,7 +289,7 @@ X11_GL_GetVisual(_THIS, Display * display, int screen)
/* 64 seems nice. */
int attribs[64];
int i = 0;
/* Setup our GLX attributes according to the gl_config. */
attribs[i++] = GLX_RGBA;
attribs[i++] = GLX_RED_SIZE;
......@@ -395,42 +401,64 @@ X11_GL_CreateContext(_THIS, SDL_Window * window)
v.visualid = XVisualIDFromVisual(xattr.visual);
vinfo = XGetVisualInfo(display, VisualScreenMask | VisualIDMask, &v, &n);
if (vinfo) {
if (_this->gl_config.major_version < 3) {
if (_this->gl_config.major_version < 3) {
context =
_this->gl_data->glXCreateContext(display, vinfo, NULL, True);
} else {
/* If we want a GL 3.0 context or later we need to get a temporary
context to grab the new context creation function */
GLXContext temp_context = _this->gl_data->glXCreateContext(display, vinfo, NULL, True);
GLXContext temp_context =
_this->gl_data->glXCreateContext(display, vinfo, NULL, True);
if (!temp_context) {
SDL_SetError("Could not create GL context");
SDL_SetError("Could not create GL context");
return NULL;
} else {
int attribs[] = {
GLX_CONTEXT_MAJOR_VERSION_ARB, _this->gl_config.major_version,
GLX_CONTEXT_MINOR_VERSION_ARB, _this->gl_config.minor_version,
0
GLX_CONTEXT_MAJOR_VERSION_ARB,
_this->gl_config.major_version,
GLX_CONTEXT_MINOR_VERSION_ARB,
_this->gl_config.minor_version,
0
};
/* Get a pointer to the context creation function for GL 3.0 */
PFNGLXCREATECONTEXTATTRIBSARBPROC glXCreateContextAttribs = (PFNGLXCREATECONTEXTATTRIBSARBPROC)_this->gl_data->glXGetProcAddress((GLubyte*)"glXCreateContextAttribsARB");
PFNGLXCREATECONTEXTATTRIBSARBPROC glXCreateContextAttribs =
(PFNGLXCREATECONTEXTATTRIBSARBPROC) _this->gl_data->
glXGetProcAddress((GLubyte *)
"glXCreateContextAttribsARB");
if (!glXCreateContextAttribs) {
SDL_SetError("GL 3.x is not supported");
context = temp_context;
} else {
/* Create a GL 3.x context */
GLXFBConfig *framebuffer_config = NULL;
int fbcount = 0;
GLXFBConfig* (*glXChooseFBConfig)(Display* disp, int screen, const int* attrib_list, int* nelements);
glXChooseFBConfig = (GLXFBConfig* (*)(Display*, int, const int*, int*))_this->gl_data->glXGetProcAddress((GLubyte*)"glXChooseFBConfig");
if (!glXChooseFBConfig || !(framebuffer_config = glXChooseFBConfig(display, DefaultScreen(display), NULL, &fbcount))) {
SDL_SetError("No good framebuffers found. GL 3.x disabled");
int fbcount = 0;
GLXFBConfig *(*glXChooseFBConfig) (Display * disp,
int screen,
const int *attrib_list,
int *nelements);
glXChooseFBConfig =
(GLXFBConfig *
(*)(Display *, int, const int *,
int *)) _this->gl_data->
glXGetProcAddress((GLubyte *) "glXChooseFBConfig");
if (!glXChooseFBConfig
|| !(framebuffer_config =
glXChooseFBConfig(display,
DefaultScreen(display), NULL,
&fbcount))) {
SDL_SetError
("No good framebuffers found. GL 3.x disabled");
context = temp_context;
} else {
context = glXCreateContextAttribs(display, framebuffer_config[0], NULL, True, attribs);
_this->gl_data->glXDestroyContext(display, temp_context);
} else {
context =
glXCreateContextAttribs(display,
framebuffer_config[0],
NULL, True, attribs);
_this->gl_data->glXDestroyContext(display,
temp_context);
}
}
}
......
......@@ -118,10 +118,10 @@ main(int argc, char *argv[])
/* you may want to change these according to the platform */
video_w = 320;
video_h = 480;
#ifdef __QNXNTO__
video_h = 640;
video_w = 480;
#endif /* __QNXNTO__ */
#ifdef __QNXNTO__
video_h = 640;
video_w = 480;
#endif /* __QNXNTO__ */
if (argv[1]) {
gl_library = argv[1];
......@@ -153,11 +153,11 @@ main(int argc, char *argv[])
pixels[3 * i + 2] = rand() % 250 - 125;
}
#ifdef __QNXNTO__
f.glViewport(0, 0, video_h, video_w);
#else
f.glViewport(0, 0, video_w, video_h);
#endif /* __QNXNTO__ */
#ifdef __QNXNTO__
f.glViewport(0, 0, video_h, video_w);
#else
f.glViewport(0, 0, video_w, video_h);
#endif /* __QNXNTO__ */
f.glMatrixMode(GL_PROJECTION);
f.glLoadIdentity();
......
......@@ -242,51 +242,54 @@ main(int argc, char *argv[])
printf("Extensions : %s\n", glGetString(GL_EXTENSIONS));
printf("\n");
status=SDL_GL_GetAttribute(SDL_GL_RED_SIZE, &value);
status = SDL_GL_GetAttribute(SDL_GL_RED_SIZE, &value);
if (!status) {
printf("SDL_GL_RED_SIZE: requested %d, got %d\n", 5, value);
} else {
printf("Failed to get SDL_GL_RED_SIZE: %s\n", SDL_GetError());
}
status=SDL_GL_GetAttribute(SDL_GL_GREEN_SIZE, &value);
status = SDL_GL_GetAttribute(SDL_GL_GREEN_SIZE, &value);
if (!status) {
printf("SDL_GL_GREEN_SIZE: requested %d, got %d\n", 5, value);
} else {
printf("Failed to get SDL_GL_GREEN_SIZE: %s\n", SDL_GetError());
}
status=SDL_GL_GetAttribute(SDL_GL_BLUE_SIZE, &value);
status = SDL_GL_GetAttribute(SDL_GL_BLUE_SIZE, &value);
if (!status) {
printf("SDL_GL_BLUE_SIZE: requested %d, got %d\n", 5, value);
} else {
printf("Failed to get SDL_GL_BLUE_SIZE: %s\n", SDL_GetError());
}
status=SDL_GL_GetAttribute(SDL_GL_DEPTH_SIZE, &value);
status = SDL_GL_GetAttribute(SDL_GL_DEPTH_SIZE, &value);
if (!status) {
printf("SDL_GL_DEPTH_SIZE: requested %d, got %d\n", 16, value);
} else {
printf("Failed to get SDL_GL_DEPTH_SIZE: %s\n", SDL_GetError());
}
if (fsaa) {
status=SDL_GL_GetAttribute(SDL_GL_MULTISAMPLEBUFFERS, &value);
status = SDL_GL_GetAttribute(SDL_GL_MULTISAMPLEBUFFERS, &value);
if (!status) {
printf("SDL_GL_MULTISAMPLEBUFFERS: requested 1, got %d\n", value);
} else {
printf("Failed to get SDL_GL_MULTISAMPLEBUFFERS: %s\n", SDL_GetError());
printf("Failed to get SDL_GL_MULTISAMPLEBUFFERS: %s\n",
SDL_GetError());
}
status=SDL_GL_GetAttribute(SDL_GL_MULTISAMPLESAMPLES, &value);
status = SDL_GL_GetAttribute(SDL_GL_MULTISAMPLESAMPLES, &value);
if (!status) {
printf("SDL_GL_MULTISAMPLESAMPLES: requested %d, got %d\n", fsaa, value);
printf("SDL_GL_MULTISAMPLESAMPLES: requested %d, got %d\n", fsaa,
value);
} else {
printf("Failed to get SDL_GL_MULTISAMPLESAMPLES: %s\n", SDL_GetError());
printf("Failed to get SDL_GL_MULTISAMPLESAMPLES: %s\n",
SDL_GetError());
}
}
if (accel) {
status=SDL_GL_GetAttribute(SDL_GL_ACCELERATED_VISUAL, &value);
if (!status)
{
status = SDL_GL_GetAttribute(SDL_GL_ACCELERATED_VISUAL, &value);
if (!status) {
printf("SDL_GL_ACCELERATED_VISUAL: requested 1, got %d\n", value);
} else {
printf("Failed to get SDL_GL_ACCELERATED_VISUAL: %s\n", SDL_GetError());
printf("Failed to get SDL_GL_ACCELERATED_VISUAL: %s\n",
SDL_GetError());
}
}
......
......@@ -14,7 +14,7 @@
#include "SDL_opengles.h"
static CommonState *state;
static SDL_GLContext *context=NULL;
static SDL_GLContext *context = NULL;
/* Call this instead of exit(), so we can clean up SDL: atexit() is evil. */
static void
......@@ -22,10 +22,8 @@ quit(int rc)
{
int i;
if (context!=NULL)
{
for (i=0; i<state->num_windows; i++)
{
if (context != NULL) {
for (i = 0; i < state->num_windows; i++) {
if (context[i]) {
SDL_GL_DeleteContext(context[i]);
}
......@@ -149,16 +147,14 @@ main(int argc, char *argv[])
quit(2);
}
context=SDL_calloc(state->num_windows, sizeof(SDL_GLContext));
if (context==NULL)
{
fprintf(stderr, "Out of memory!\n");
quit(2);
context = SDL_calloc(state->num_windows, sizeof(SDL_GLContext));
if (context == NULL) {
fprintf(stderr, "Out of memory!\n");
quit(2);
}
/* Create OpenGL ES contexts */
for (i=0; i<state->num_windows; i++)
{
for (i = 0; i < state->num_windows; i++) {
context[i] = SDL_GL_CreateContext(state->windows[i]);
if (!context[i]) {
fprintf(stderr, "SDL_GL_CreateContext(): %s\n", SDL_GetError());
......@@ -181,59 +177,65 @@ main(int argc, char *argv[])
printf("Extensions : %s\n", glGetString(GL_EXTENSIONS));
printf("\n");
status=SDL_GL_GetAttribute(SDL_GL_RED_SIZE, &value);
status = SDL_GL_GetAttribute(SDL_GL_RED_SIZE, &value);
if (!status) {
printf("SDL_GL_RED_SIZE: requested %d, got %d\n", 5, value);
} else {
fprintf(stderr, "Failed to get SDL_GL_RED_SIZE: %s\n", SDL_GetError());
fprintf(stderr, "Failed to get SDL_GL_RED_SIZE: %s\n",
SDL_GetError());
}
status=SDL_GL_GetAttribute(SDL_GL_GREEN_SIZE, &value);
status = SDL_GL_GetAttribute(SDL_GL_GREEN_SIZE, &value);
if (!status) {
printf("SDL_GL_GREEN_SIZE: requested %d, got %d\n", 5, value);
} else {
fprintf(stderr, "Failed to get SDL_GL_GREEN_SIZE: %s\n", SDL_GetError());
fprintf(stderr, "Failed to get SDL_GL_GREEN_SIZE: %s\n",
SDL_GetError());
}
status=SDL_GL_GetAttribute(SDL_GL_BLUE_SIZE, &value);
status = SDL_GL_GetAttribute(SDL_GL_BLUE_SIZE, &value);
if (!status) {
printf("SDL_GL_BLUE_SIZE: requested %d, got %d\n", 5, value);
} else {
fprintf(stderr, "Failed to get SDL_GL_BLUE_SIZE: %s\n", SDL_GetError());
fprintf(stderr, "Failed to get SDL_GL_BLUE_SIZE: %s\n",
SDL_GetError());
}
status=SDL_GL_GetAttribute(SDL_GL_DEPTH_SIZE, &value);
status = SDL_GL_GetAttribute(SDL_GL_DEPTH_SIZE, &value);
if (!status) {
printf("SDL_GL_DEPTH_SIZE: requested %d, got %d\n", 16, value);
} else {
fprintf(stderr, "Failed to get SDL_GL_DEPTH_SIZE: %s\n", SDL_GetError());
fprintf(stderr, "Failed to get SDL_GL_DEPTH_SIZE: %s\n",
SDL_GetError());
}
if (fsaa) {
status=SDL_GL_GetAttribute(SDL_GL_MULTISAMPLEBUFFERS, &value);
status = SDL_GL_GetAttribute(SDL_GL_MULTISAMPLEBUFFERS, &value);
if (!status) {
printf("SDL_GL_MULTISAMPLEBUFFERS: requested 1, got %d\n", value);
} else {
fprintf(stderr, "Failed to get SDL_GL_MULTISAMPLEBUFFERS: %s\n", SDL_GetError());
fprintf(stderr, "Failed to get SDL_GL_MULTISAMPLEBUFFERS: %s\n",
SDL_GetError());
}
status=SDL_GL_GetAttribute(SDL_GL_MULTISAMPLESAMPLES, &value);
status = SDL_GL_GetAttribute(SDL_GL_MULTISAMPLESAMPLES, &value);
if (!status) {
printf("SDL_GL_MULTISAMPLESAMPLES: requested %d, got %d\n", fsaa, value);
printf("SDL_GL_MULTISAMPLESAMPLES: requested %d, got %d\n", fsaa,
value);
} else {
fprintf(stderr, "Failed to get SDL_GL_MULTISAMPLESAMPLES: %s\n", SDL_GetError());
fprintf(stderr, "Failed to get SDL_GL_MULTISAMPLESAMPLES: %s\n",
SDL_GetError());
}
}
if (accel) {
status=SDL_GL_GetAttribute(SDL_GL_ACCELERATED_VISUAL, &value);
if (!status)
{
status = SDL_GL_GetAttribute(SDL_GL_ACCELERATED_VISUAL, &value);
if (!status) {
printf("SDL_GL_ACCELERATED_VISUAL: requested 1, got %d\n", value);
} else {
fprintf(stderr, "Failed to get SDL_GL_ACCELERATED_VISUAL: %s\n", SDL_GetError());
fprintf(stderr, "Failed to get SDL_GL_ACCELERATED_VISUAL: %s\n",
SDL_GetError());
}
}
/* Set rendering settings for each context */
for (i = 0; i < state->num_windows; ++i) {
status=SDL_GL_MakeCurrent(state->windows[i], context[i]);
if (status)
{
status = SDL_GL_MakeCurrent(state->windows[i], context[i]);
if (status) {
printf("SDL_GL_MakeCurrent(): %s\n", SDL_GetError());
/* Continue for next window */
......@@ -262,13 +264,12 @@ main(int argc, char *argv[])
}
for (i = 0; i < state->num_windows; ++i) {
int w, h;
status=SDL_GL_MakeCurrent(state->windows[i], context[i]);
if (status)
{
printf("SDL_GL_MakeCurrent(): %s\n", SDL_GetError());
status = SDL_GL_MakeCurrent(state->windows[i], context[i]);
if (status) {
printf("SDL_GL_MakeCurrent(): %s\n", SDL_GetError());
/* Continue for next window */
continue;
/* Continue for next window */
continue;
}
SDL_GetWindowSize(state->windows[i], &w, &h);
glViewport(0, 0, w, h);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment