Changed directory structure to contain less symlinks so dependencies will get recalculated correctly by make

This commit is contained in:
pelya
2010-10-12 19:04:21 +03:00
parent a5ff12846e
commit 2e1a4992d3
1349 changed files with 33 additions and 48 deletions

View File

@@ -0,0 +1,47 @@
/*
SDL - Simple DirectMedia Layer
Copyright (C) 1997-2010 Sam Lantinga
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
Sam Lantinga
slouken@libsdl.org
*/
#include "SDL_config.h"
/* Clipboard event handling code for SDL */
#include "SDL_events.h"
#include "SDL_events_c.h"
#include "SDL_clipboardevents_c.h"
int
SDL_SendClipboardUpdate(void)
{
int posted;
/* Post the event, if desired */
posted = 0;
if (SDL_GetEventState(SDL_CLIPBOARDUPDATE) == SDL_ENABLE) {
SDL_Event event;
event.type = SDL_CLIPBOARDUPDATE;
posted = (SDL_PushEvent(&event) > 0);
}
return (posted);
}
/* vi: set ts=4 sw=4 expandtab: */

View File

@@ -0,0 +1,31 @@
/*
SDL - Simple DirectMedia Layer
Copyright (C) 1997-2010 Sam Lantinga
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
Sam Lantinga
slouken@libsdl.org
*/
#include "SDL_config.h"
#ifndef _SDL_clipboardevents_c_h
#define _SDL_clipboardevents_c_h
extern int SDL_SendClipboardUpdate(void);
#endif /* _SDL_clipboardevents_c_h */
/* vi: set ts=4 sw=4 expandtab: */

View File

@@ -0,0 +1,620 @@
/*
SDL - Simple DirectMedia Layer
Copyright (C) 1997-2010 Sam Lantinga
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
Sam Lantinga
slouken@libsdl.org
*/
#include "SDL_config.h"
/* General event handling code for SDL */
#include "SDL.h"
#include "SDL_events.h"
#include "SDL_syswm.h"
#include "SDL_thread.h"
#include "SDL_sysevents.h"
#include "SDL_events_c.h"
#include "../timer/SDL_timer_c.h"
#if !SDL_JOYSTICK_DISABLED
#include "../joystick/SDL_joystick_c.h"
#endif
/* Public data -- the event filter */
SDL_EventFilter SDL_EventOK = NULL;
void *SDL_EventOKParam;
typedef struct {
Uint32 bits[8];
} SDL_DisabledEventBlock;
static SDL_DisabledEventBlock *SDL_disabled_events[256];
static Uint32 SDL_userevents = SDL_USEREVENT;
/* Private data -- event queue */
#define MAXEVENTS 128
static struct
{
SDL_mutex *lock;
int active;
int head;
int tail;
SDL_Event event[MAXEVENTS];
int wmmsg_next;
struct SDL_SysWMmsg wmmsg[MAXEVENTS];
} SDL_EventQ;
/* Private data -- event locking structure */
static struct
{
SDL_mutex *lock;
int safe;
} SDL_EventLock;
/* Thread functions */
static SDL_Thread *SDL_EventThread = NULL; /* Thread handle */
static SDL_threadID event_thread; /* The event thread id */
void
SDL_Lock_EventThread(void)
{
if (SDL_EventThread && (SDL_ThreadID() != event_thread)) {
/* Grab lock and spin until we're sure event thread stopped */
SDL_mutexP(SDL_EventLock.lock);
while (!SDL_EventLock.safe) {
SDL_Delay(1);
}
}
}
void
SDL_Unlock_EventThread(void)
{
if (SDL_EventThread && (SDL_ThreadID() != event_thread)) {
SDL_mutexV(SDL_EventLock.lock);
}
}
static __inline__ SDL_bool
SDL_ShouldPollJoystick()
{
#if !SDL_JOYSTICK_DISABLED
if (SDL_numjoysticks &&
(!SDL_disabled_events[SDL_JOYAXISMOTION >> 8] ||
SDL_JoystickEventState(SDL_QUERY))) {
return SDL_TRUE;
}
#endif
return SDL_FALSE;
}
static int SDLCALL
SDL_GobbleEvents(void *unused)
{
event_thread = SDL_ThreadID();
while (SDL_EventQ.active) {
SDL_VideoDevice *_this = SDL_GetVideoDevice();
/* Get events from the video subsystem */
if (_this) {
_this->PumpEvents(_this);
}
#if !SDL_JOYSTICK_DISABLED
/* Check for joystick state change */
if (SDL_ShouldPollJoystick()) {
SDL_JoystickUpdate();
}
#endif
/* Give up the CPU for the rest of our timeslice */
SDL_EventLock.safe = 1;
if (SDL_timer_running) {
SDL_ThreadedTimerCheck();
}
SDL_Delay(1);
/* Check for event locking.
On the P of the lock mutex, if the lock is held, this thread
will wait until the lock is released before continuing. The
safe flag will be set, meaning that the other thread can go
about it's business. The safe flag is reset before the V,
so as soon as the mutex is free, other threads can see that
it's not safe to interfere with the event thread.
*/
SDL_mutexP(SDL_EventLock.lock);
SDL_EventLock.safe = 0;
SDL_mutexV(SDL_EventLock.lock);
}
SDL_SetTimerThreaded(0);
event_thread = 0;
return (0);
}
static int
SDL_StartEventThread(Uint32 flags)
{
/* Reset everything to zero */
SDL_EventThread = NULL;
SDL_memset(&SDL_EventLock, 0, sizeof(SDL_EventLock));
/* Create the lock and set ourselves active */
#if !SDL_THREADS_DISABLED
SDL_EventQ.lock = SDL_CreateMutex();
if (SDL_EventQ.lock == NULL) {
return (-1);
}
#endif /* !SDL_THREADS_DISABLED */
SDL_EventQ.active = 1;
if ((flags & SDL_INIT_EVENTTHREAD) == SDL_INIT_EVENTTHREAD) {
SDL_EventLock.lock = SDL_CreateMutex();
if (SDL_EventLock.lock == NULL) {
return (-1);
}
SDL_EventLock.safe = 0;
/* The event thread will handle timers too */
SDL_SetTimerThreaded(2);
#if (defined(__WIN32__) && !defined(_WIN32_WCE)) && !defined(HAVE_LIBC)
#undef SDL_CreateThread
SDL_EventThread =
SDL_CreateThread(SDL_GobbleEvents, NULL, NULL, NULL);
#else
SDL_EventThread = SDL_CreateThread(SDL_GobbleEvents, NULL);
#endif
if (SDL_EventThread == NULL) {
return (-1);
}
} else {
event_thread = 0;
}
return (0);
}
static void
SDL_StopEventThread(void)
{
SDL_EventQ.active = 0;
if (SDL_EventThread) {
SDL_WaitThread(SDL_EventThread, NULL);
SDL_EventThread = NULL;
SDL_DestroyMutex(SDL_EventLock.lock);
SDL_EventLock.lock = NULL;
}
if (SDL_EventQ.lock) {
SDL_DestroyMutex(SDL_EventQ.lock);
SDL_EventQ.lock = NULL;
}
}
SDL_threadID
SDL_EventThreadID(void)
{
return (event_thread);
}
/* Public functions */
void
SDL_StopEventLoop(void)
{
int i;
/* Halt the event thread, if running */
SDL_StopEventThread();
/* Shutdown event handlers */
SDL_KeyboardQuit();
SDL_MouseQuit();
SDL_QuitQuit();
/* Clean out EventQ */
SDL_EventQ.head = 0;
SDL_EventQ.tail = 0;
SDL_EventQ.wmmsg_next = 0;
/* Clear disabled event state */
for (i = 0; i < SDL_arraysize(SDL_disabled_events); ++i) {
if (SDL_disabled_events[i]) {
SDL_free(SDL_disabled_events[i]);
SDL_disabled_events[i] = NULL;
}
}
}
/* This function (and associated calls) may be called more than once */
int
SDL_StartEventLoop(Uint32 flags)
{
int retcode;
/* Clean out the event queue */
SDL_EventThread = NULL;
SDL_EventQ.lock = NULL;
SDL_StopEventLoop();
/* No filter to start with, process most event types */
SDL_EventOK = NULL;
SDL_EventState(SDL_SYSWMEVENT, SDL_DISABLE);
/* Initialize event handlers */
retcode = 0;
retcode += SDL_KeyboardInit();
retcode += SDL_MouseInit();
retcode += SDL_TouchInit();
retcode += SDL_QuitInit();
if (retcode < 0) {
/* We don't expect them to fail, but... */
return (-1);
}
/* Create the lock and event thread */
if (SDL_StartEventThread(flags) < 0) {
SDL_StopEventLoop();
return (-1);
}
return (0);
}
/* Add an event to the event queue -- called with the queue locked */
static int
SDL_AddEvent(SDL_Event * event)
{
int tail, added;
tail = (SDL_EventQ.tail + 1) % MAXEVENTS;
if (tail == SDL_EventQ.head) {
/* Overflow, drop event */
added = 0;
} else {
SDL_EventQ.event[SDL_EventQ.tail] = *event;
if (event->type == SDL_SYSWMEVENT) {
/* Note that it's possible to lose an event */
int next = SDL_EventQ.wmmsg_next;
SDL_EventQ.wmmsg[next] = *event->syswm.msg;
SDL_EventQ.event[SDL_EventQ.tail].syswm.msg =
&SDL_EventQ.wmmsg[next];
SDL_EventQ.wmmsg_next = (next + 1) % MAXEVENTS;
}
SDL_EventQ.tail = tail;
added = 1;
}
return (added);
}
/* Cut an event, and return the next valid spot, or the tail */
/* -- called with the queue locked */
static int
SDL_CutEvent(int spot)
{
if (spot == SDL_EventQ.head) {
SDL_EventQ.head = (SDL_EventQ.head + 1) % MAXEVENTS;
return (SDL_EventQ.head);
} else if ((spot + 1) % MAXEVENTS == SDL_EventQ.tail) {
SDL_EventQ.tail = spot;
return (SDL_EventQ.tail);
} else
/* We cut the middle -- shift everything over */
{
int here, next;
/* This can probably be optimized with SDL_memcpy() -- careful! */
if (--SDL_EventQ.tail < 0) {
SDL_EventQ.tail = MAXEVENTS - 1;
}
for (here = spot; here != SDL_EventQ.tail; here = next) {
next = (here + 1) % MAXEVENTS;
SDL_EventQ.event[here] = SDL_EventQ.event[next];
}
return (spot);
}
/* NOTREACHED */
}
/* Lock the event queue, take a peep at it, and unlock it */
int
SDL_PeepEvents(SDL_Event * events, int numevents, SDL_eventaction action,
Uint32 minType, Uint32 maxType)
{
int i, used;
/* Don't look after we've quit */
if (!SDL_EventQ.active) {
return (-1);
}
/* Lock the event queue */
used = 0;
if (SDL_mutexP(SDL_EventQ.lock) == 0) {
if (action == SDL_ADDEVENT) {
for (i = 0; i < numevents; ++i) {
used += SDL_AddEvent(&events[i]);
}
} else {
SDL_Event tmpevent;
int spot;
/* If 'events' is NULL, just see if they exist */
if (events == NULL) {
action = SDL_PEEKEVENT;
numevents = 1;
events = &tmpevent;
}
spot = SDL_EventQ.head;
while ((used < numevents) && (spot != SDL_EventQ.tail)) {
Uint32 type = SDL_EventQ.event[spot].type;
if (minType <= type && type <= maxType) {
events[used++] = SDL_EventQ.event[spot];
if (action == SDL_GETEVENT) {
spot = SDL_CutEvent(spot);
} else {
spot = (spot + 1) % MAXEVENTS;
}
} else {
spot = (spot + 1) % MAXEVENTS;
}
}
}
SDL_mutexV(SDL_EventQ.lock);
} else {
SDL_SetError("Couldn't lock event queue");
used = -1;
}
return (used);
}
SDL_bool
SDL_HasEvent(Uint32 type)
{
return (SDL_PeepEvents(NULL, 0, SDL_PEEKEVENT, type, type) > 0);
}
SDL_bool
SDL_HasEvents(Uint32 minType, Uint32 maxType)
{
return (SDL_PeepEvents(NULL, 0, SDL_PEEKEVENT, minType, maxType) > 0);
}
void
SDL_FlushEvent(Uint32 type)
{
SDL_FlushEvents(type, type);
}
void
SDL_FlushEvents(Uint32 minType, Uint32 maxType)
{
/* Don't look after we've quit */
if (!SDL_EventQ.active) {
return;
}
/* Make sure the events are current */
SDL_PumpEvents();
/* Lock the event queue */
if (SDL_mutexP(SDL_EventQ.lock) == 0) {
int spot = SDL_EventQ.head;
while (spot != SDL_EventQ.tail) {
Uint32 type = SDL_EventQ.event[spot].type;
if (minType <= type && type <= maxType) {
spot = SDL_CutEvent(spot);
} else {
spot = (spot + 1) % MAXEVENTS;
}
}
SDL_mutexV(SDL_EventQ.lock);
}
}
/* Run the system dependent event loops */
void
SDL_PumpEvents(void)
{
if (!SDL_EventThread) {
SDL_VideoDevice *_this = SDL_GetVideoDevice();
/* Get events from the video subsystem */
if (_this) {
_this->PumpEvents(_this);
}
#if !SDL_JOYSTICK_DISABLED
/* Check for joystick state change */
if (SDL_ShouldPollJoystick()) {
SDL_JoystickUpdate();
}
#endif
}
}
/* Public functions */
int
SDL_PollEvent(SDL_Event * event)
{
return SDL_WaitEventTimeout(event, 0);
}
int
SDL_WaitEvent(SDL_Event * event)
{
return SDL_WaitEventTimeout(event, -1);
}
int
SDL_WaitEventTimeout(SDL_Event * event, int timeout)
{
Uint32 expiration = 0;
if (timeout > 0)
expiration = SDL_GetTicks() + timeout;
for (;;) {
SDL_PumpEvents();
switch (SDL_PeepEvents(event, 1, SDL_GETEVENT, SDL_FIRSTEVENT, SDL_LASTEVENT)) {
case -1:
return 0;
case 1:
return 1;
case 0:
if (timeout == 0) {
/* Polling and no events, just return */
return 0;
}
if (timeout > 0 && ((int) (SDL_GetTicks() - expiration) >= 0)) {
/* Timeout expired and no events */
return 0;
}
SDL_Delay(10);
break;
}
}
}
int
SDL_PushEvent(SDL_Event * event)
{
if (SDL_EventOK && !SDL_EventOK(SDL_EventOKParam, event)) {
return 0;
}
if (SDL_PeepEvents(event, 1, SDL_ADDEVENT, 0, 0) <= 0) {
return -1;
}
SDL_GestureProcessEvent(event);
return 1;
}
void
SDL_SetEventFilter(SDL_EventFilter filter, void *userdata)
{
SDL_Event bitbucket;
/* Set filter and discard pending events */
SDL_EventOK = filter;
SDL_EventOKParam = userdata;
while (SDL_PollEvent(&bitbucket) > 0);
}
SDL_bool
SDL_GetEventFilter(SDL_EventFilter * filter, void **userdata)
{
if (filter) {
*filter = SDL_EventOK;
}
if (userdata) {
*userdata = SDL_EventOKParam;
}
return SDL_EventOK ? SDL_TRUE : SDL_FALSE;
}
void
SDL_FilterEvents(SDL_EventFilter filter, void *userdata)
{
if (SDL_mutexP(SDL_EventQ.lock) == 0) {
int spot;
spot = SDL_EventQ.head;
while (spot != SDL_EventQ.tail) {
if (filter(userdata, &SDL_EventQ.event[spot])) {
spot = (spot + 1) % MAXEVENTS;
} else {
spot = SDL_CutEvent(spot);
}
}
}
SDL_mutexV(SDL_EventQ.lock);
}
Uint8
SDL_EventState(Uint32 type, int state)
{
Uint8 current_state;
Uint8 hi = ((type >> 8) & 0xff);
Uint8 lo = (type & 0xff);
if (SDL_disabled_events[hi] &&
(SDL_disabled_events[hi]->bits[lo/32] & (1 << (lo&31)))) {
current_state = SDL_DISABLE;
} else {
current_state = SDL_ENABLE;
}
if (state != current_state)
{
switch (state) {
case SDL_DISABLE:
/* Disable this event type and discard pending events */
if (!SDL_disabled_events[hi]) {
SDL_disabled_events[hi] = (SDL_DisabledEventBlock*) SDL_calloc(1, sizeof(SDL_DisabledEventBlock));
if (!SDL_disabled_events[hi]) {
/* Out of memory, nothing we can do... */
break;
}
}
SDL_disabled_events[hi]->bits[lo/32] |= (1 << (lo&31));
SDL_FlushEvent(type);
break;
case SDL_ENABLE:
SDL_disabled_events[hi]->bits[lo/32] &= ~(1 << (lo&31));
break;
default:
/* Querying state... */
break;
}
}
return current_state;
}
Uint32
SDL_RegisterEvents(int numevents)
{
Uint32 event_base;
if (SDL_userevents+numevents <= SDL_LASTEVENT) {
event_base = SDL_userevents;
SDL_userevents += numevents;
} else {
event_base = (Uint32)-1;
}
return event_base;
}
/* This is a generic event handler.
*/
int
SDL_SendSysWMEvent(SDL_SysWMmsg * message)
{
int posted;
posted = 0;
if (SDL_GetEventState(SDL_SYSWMEVENT) == SDL_ENABLE) {
SDL_Event event;
SDL_memset(&event, 0, sizeof(event));
event.type = SDL_SYSWMEVENT;
event.syswm.msg = message;
posted = (SDL_PushEvent(&event) > 0);
}
/* Update internal event state */
return (posted);
}
/* vi: set ts=4 sw=4 expandtab: */

View File

@@ -0,0 +1,51 @@
/*
SDL - Simple DirectMedia Layer
Copyright (C) 1997-2010 Sam Lantinga
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
Sam Lantinga
slouken@libsdl.org
*/
#include "SDL_config.h"
/* Useful functions and variables from SDL_events.c */
#include "SDL_events.h"
#include "SDL_thread.h"
#include "SDL_mouse_c.h"
#include "SDL_keyboard_c.h"
#include "SDL_touch_c.h"
#include "SDL_windowevents_c.h"
#include "SDL_gesture_c.h"
/* Start and stop the event processing loop */
extern int SDL_StartEventLoop(Uint32 flags);
extern void SDL_StopEventLoop(void);
extern void SDL_QuitInterrupt(void);
extern void SDL_Lock_EventThread(void);
extern void SDL_Unlock_EventThread(void);
extern SDL_threadID SDL_EventThreadID(void);
extern int SDL_SendSysWMEvent(SDL_SysWMmsg * message);
extern int SDL_QuitInit(void);
extern int SDL_SendQuit(void);
extern void SDL_QuitQuit(void);
/* The event filter function */
extern SDL_EventFilter SDL_EventOK;
extern void *SDL_EventOKParam;
/* vi: set ts=4 sw=4 expandtab: */

View File

@@ -0,0 +1,663 @@
/*
SDL - Simple DirectMedia Layer
Copyright (C) 1997-2010 Sam Lantinga
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software Founation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
Sam Lantinga
slouken@libsdl.org
*/
#include "SDL_config.h"
/* General mouse handling code for SDL */
#include "SDL_events.h"
#include "SDL_events_c.h"
#include "SDL_gesture_c.h"
#include <memory.h>
#include <string.h>
#include <stdio.h>
#include <math.h>
//TODO: Replace with malloc
#define MAXPATHSIZE 1024
#define DOLLARNPOINTS 64
#define DOLLARSIZE 256
#define ENABLE_DOLLAR
#define PHI 0.618033989
typedef struct {
float x,y;
} SDL_FloatPoint;
typedef struct {
float length;
int numPoints;
SDL_FloatPoint p[MAXPATHSIZE];
} SDL_DollarPath;
typedef struct {
SDL_FloatPoint path[DOLLARNPOINTS];
unsigned long hash;
} SDL_DollarTemplate;
typedef struct {
SDL_GestureID id;
SDL_FloatPoint res;
SDL_FloatPoint centroid;
SDL_DollarPath dollarPath;
Uint16 numDownFingers;
int numDollarTemplates;
SDL_DollarTemplate *dollarTemplate;
SDL_bool recording;
} SDL_GestureTouch;
SDL_GestureTouch *SDL_gestureTouch;
int SDL_numGestureTouches = 0;
SDL_bool recordAll;
#if 0
static void PrintPath(SDL_FloatPoint *path) {
int i;
printf("Path:");
for(i=0;i<DOLLARNPOINTS;i++) {
printf(" (%f,%f)",path[i].x,path[i].y);
}
printf("\n");
}
#endif
int SDL_RecordGesture(SDL_TouchID touchId) {
int i;
if(touchId < 0) recordAll = SDL_TRUE;
for(i = 0;i < SDL_numGestureTouches; i++) {
if((touchId < 0) || (SDL_gestureTouch[i].id == touchId)) {
SDL_gestureTouch[i].recording = SDL_TRUE;
if(touchId >= 0)
return 1;
}
}
return (touchId < 0);
}
unsigned long SDL_HashDollar(SDL_FloatPoint* points) {
unsigned long hash = 5381;
int i;
for(i = 0;i < DOLLARNPOINTS; i++) {
hash = ((hash<<5) + hash) + (unsigned long)points[i].x;
hash = ((hash<<5) + hash) + (unsigned long)points[i].y;
}
return hash;
}
static int SaveTemplate(SDL_DollarTemplate *templ, SDL_RWops * src) {
if(src == NULL) return 0;
//No Longer storing the Hash, rehash on load
//if(SDL_RWops.write(src,&(templ->hash),sizeof(templ->hash),1) != 1) return 0;
if(SDL_RWwrite(src,templ->path,
sizeof(templ->path[0]),DOLLARNPOINTS) != DOLLARNPOINTS)
return 0;
return 1;
}
int SDL_SaveAllDollarTemplates(SDL_RWops *src) {
int i,j,rtrn = 0;
for(i = 0; i < SDL_numGestureTouches; i++) {
SDL_GestureTouch* touch = &SDL_gestureTouch[i];
for(j = 0;j < touch->numDollarTemplates; j++) {
rtrn += SaveTemplate(&touch->dollarTemplate[i],src);
}
}
return rtrn;
}
int SDL_SaveDollarTemplate(SDL_GestureID gestureId, SDL_RWops *src) {
int i,j;
for(i = 0; i < SDL_numGestureTouches; i++) {
SDL_GestureTouch* touch = &SDL_gestureTouch[i];
for(j = 0;j < touch->numDollarTemplates; j++) {
if(touch->dollarTemplate[i].hash == gestureId) {
return SaveTemplate(&touch->dollarTemplate[i],src);
}
}
}
SDL_SetError("Unknown gestureId");
return -1;
}
//path is an already sampled set of points
//Returns the index of the gesture on success, or -1
static int SDL_AddDollarGesture(SDL_GestureTouch* inTouch,SDL_FloatPoint* path) {
SDL_DollarTemplate* dollarTemplate;
SDL_DollarTemplate *templ;
int i = 0;
if(inTouch == NULL) {
if(SDL_numGestureTouches == 0) return -1;
for(i = 0;i < SDL_numGestureTouches; i++) {
inTouch = &SDL_gestureTouch[i];
dollarTemplate =
(SDL_DollarTemplate *)SDL_realloc(inTouch->dollarTemplate,
(inTouch->numDollarTemplates + 1) *
sizeof(SDL_DollarTemplate));
if(!dollarTemplate) {
SDL_OutOfMemory();
return -1;
}
inTouch->dollarTemplate = dollarTemplate;
templ =
&inTouch->dollarTemplate[inTouch->numDollarTemplates];
SDL_memcpy(templ->path,path,DOLLARNPOINTS*sizeof(SDL_FloatPoint));
templ->hash = SDL_HashDollar(templ->path);
inTouch->numDollarTemplates++;
}
return inTouch->numDollarTemplates - 1;
} else {
SDL_DollarTemplate* dollarTemplate =
( SDL_DollarTemplate *)SDL_realloc(inTouch->dollarTemplate,
(inTouch->numDollarTemplates + 1) *
sizeof(SDL_DollarTemplate));
if(!dollarTemplate) {
SDL_OutOfMemory();
return -1;
}
inTouch->dollarTemplate = dollarTemplate;
templ =
&inTouch->dollarTemplate[inTouch->numDollarTemplates];
SDL_memcpy(templ->path,path,DOLLARNPOINTS*sizeof(SDL_FloatPoint));
templ->hash = SDL_HashDollar(templ->path);
inTouch->numDollarTemplates++;
return inTouch->numDollarTemplates - 1;
}
return -1;
}
int SDL_LoadDollarTemplates(SDL_TouchID touchId, SDL_RWops *src) {
int i,loaded = 0;
SDL_GestureTouch *touch = NULL;
if(src == NULL) return 0;
if(touchId >= 0) {
for(i = 0;i < SDL_numGestureTouches; i++)
if(SDL_gestureTouch[i].id == touchId)
touch = &SDL_gestureTouch[i];
if(touch == NULL) return -1;
}
while(1) {
SDL_DollarTemplate templ;
if(SDL_RWread(src,templ.path,sizeof(templ.path[0]),DOLLARNPOINTS) <
DOLLARNPOINTS) break;
if(touchId >= 0) {
//printf("Adding loaded gesture to 1 touch\n");
if(SDL_AddDollarGesture(touch,templ.path)) loaded++;
}
else {
//printf("Adding to: %i touches\n",SDL_numGestureTouches);
for(i = 0;i < SDL_numGestureTouches; i++) {
touch = &SDL_gestureTouch[i];
//printf("Adding loaded gesture to + touches\n");
//TODO: What if this fails?
SDL_AddDollarGesture(touch,templ.path);
}
loaded++;
}
}
return loaded;
}
float dollarDifference(SDL_FloatPoint* points,SDL_FloatPoint* templ,float ang) {
// SDL_FloatPoint p[DOLLARNPOINTS];
float dist = 0;
SDL_FloatPoint p;
int i;
for(i = 0; i < DOLLARNPOINTS; i++) {
p.x = (float)(points[i].x * SDL_cos(ang) - points[i].y * SDL_sin(ang));
p.y = (float)(points[i].x * SDL_sin(ang) + points[i].y * SDL_cos(ang));
dist += (float)(SDL_sqrt((p.x-templ[i].x)*(p.x-templ[i].x)+
(p.y-templ[i].y)*(p.y-templ[i].y)));
}
return dist/DOLLARNPOINTS;
}
float bestDollarDifference(SDL_FloatPoint* points,SDL_FloatPoint* templ) {
//------------BEGIN DOLLAR BLACKBOX----------------//
//-TRANSLATED DIRECTLY FROM PSUDEO-CODE AVAILABLE AT-//
//-"http://depts.washington.edu/aimgroup/proj/dollar/"-//
double ta = -M_PI/4;
double tb = M_PI/4;
double dt = M_PI/90;
float x1 = (float)(PHI*ta + (1-PHI)*tb);
float f1 = dollarDifference(points,templ,x1);
float x2 = (float)((1-PHI)*ta + PHI*tb);
float f2 = dollarDifference(points,templ,x2);
while(SDL_fabs(ta-tb) > dt) {
if(f1 < f2) {
tb = x2;
x2 = x1;
f2 = f1;
x1 = (float)(PHI*ta + (1-PHI)*tb);
f1 = dollarDifference(points,templ,x1);
}
else {
ta = x1;
x1 = x2;
f1 = f2;
x2 = (float)((1-PHI)*ta + PHI*tb);
f2 = dollarDifference(points,templ,x2);
}
}
/*
if(f1 <= f2)
printf("Min angle (x1): %f\n",x1);
else if(f1 > f2)
printf("Min angle (x2): %f\n",x2);
*/
return SDL_min(f1,f2);
}
//DollarPath contains raw points, plus (possibly) the calculated length
int dollarNormalize(SDL_DollarPath path,SDL_FloatPoint *points) {
int i;
float interval;
float dist;
int numPoints = 0;
SDL_FloatPoint centroid;
float xmin,xmax,ymin,ymax;
float ang;
float w,h;
//Calculate length if it hasn't already been done
if(path.length <= 0) {
for(i=1;i<path.numPoints;i++) {
float dx = path.p[i ].x -
path.p[i-1].x;
float dy = path.p[i ].y -
path.p[i-1].y;
path.length += (float)(SDL_sqrt(dx*dx+dy*dy));
}
}
//Resample
interval = path.length/(DOLLARNPOINTS - 1);
dist = interval;
centroid.x = 0;centroid.y = 0;
//printf("(%f,%f)\n",path.p[path.numPoints-1].x,path.p[path.numPoints-1].y);
for(i = 1;i < path.numPoints;i++) {
float d = (float)(SDL_sqrt((path.p[i-1].x-path.p[i].x)*(path.p[i-1].x-path.p[i].x)+
(path.p[i-1].y-path.p[i].y)*(path.p[i-1].y-path.p[i].y)));
//printf("d = %f dist = %f/%f\n",d,dist,interval);
while(dist + d > interval) {
points[numPoints].x = path.p[i-1].x +
((interval-dist)/d)*(path.p[i].x-path.p[i-1].x);
points[numPoints].y = path.p[i-1].y +
((interval-dist)/d)*(path.p[i].y-path.p[i-1].y);
centroid.x += points[numPoints].x;
centroid.y += points[numPoints].y;
numPoints++;
dist -= interval;
}
dist += d;
}
if(numPoints < DOLLARNPOINTS-1) {
SDL_SetError("ERROR: NumPoints = %i\n",numPoints);
return 0;
}
//copy the last point
points[DOLLARNPOINTS-1] = path.p[path.numPoints-1];
numPoints = DOLLARNPOINTS;
centroid.x /= numPoints;
centroid.y /= numPoints;
//printf("Centroid (%f,%f)",centroid.x,centroid.y);
//Rotate Points so point 0 is left of centroid and solve for the bounding box
xmin = centroid.x;
xmax = centroid.x;
ymin = centroid.y;
ymax = centroid.y;
ang = (float)(SDL_atan2(centroid.y - points[0].y,
centroid.x - points[0].x));
for(i = 0;i<numPoints;i++) {
float px = points[i].x;
float py = points[i].y;
points[i].x = (float)((px - centroid.x)*SDL_cos(ang) -
(py - centroid.y)*SDL_sin(ang) + centroid.x);
points[i].y = (float)((px - centroid.x)*SDL_sin(ang) +
(py - centroid.y)*SDL_cos(ang) + centroid.y);
if(points[i].x < xmin) xmin = points[i].x;
if(points[i].x > xmax) xmax = points[i].x;
if(points[i].y < ymin) ymin = points[i].y;
if(points[i].y > ymax) ymax = points[i].y;
}
//Scale points to DOLLARSIZE, and translate to the origin
w = xmax-xmin;
h = ymax-ymin;
for(i=0;i<numPoints;i++) {
points[i].x = (points[i].x - centroid.x)*DOLLARSIZE/w;
points[i].y = (points[i].y - centroid.y)*DOLLARSIZE/h;
}
return numPoints;
}
float dollarRecognize(SDL_DollarPath path,int *bestTempl,SDL_GestureTouch* touch) {
SDL_FloatPoint points[DOLLARNPOINTS];
int numPoints = dollarNormalize(path,points);
int i;
float bestDiff = 10000;
//PrintPath(points);
*bestTempl = -1;
for(i = 0;i < touch->numDollarTemplates;i++) {
float diff = bestDollarDifference(points,touch->dollarTemplate[i].path);
if(diff < bestDiff) {bestDiff = diff; *bestTempl = i;}
}
return bestDiff;
}
int SDL_GestureAddTouch(SDL_Touch* touch) {
SDL_GestureTouch *gestureTouch = (SDL_GestureTouch *)SDL_realloc(SDL_gestureTouch,
(SDL_numGestureTouches + 1) *
sizeof(SDL_GestureTouch));
if(!gestureTouch) {
SDL_OutOfMemory();
return -1;
}
SDL_gestureTouch = gestureTouch;
SDL_gestureTouch[SDL_numGestureTouches].res.x = touch->xres;
SDL_gestureTouch[SDL_numGestureTouches].res.y = touch->yres;
SDL_gestureTouch[SDL_numGestureTouches].numDownFingers = 0;
SDL_gestureTouch[SDL_numGestureTouches].res.x = touch->xres;
SDL_gestureTouch[SDL_numGestureTouches].id = touch->id;
SDL_gestureTouch[SDL_numGestureTouches].numDollarTemplates = 0;
SDL_gestureTouch[SDL_numGestureTouches].recording = SDL_FALSE;
SDL_numGestureTouches++;
return 0;
}
int SDL_GestureRemoveTouch(SDL_TouchID id) {
int i;
for (i = 0; i < SDL_numGestureTouches; i++) {
if (SDL_gestureTouch[i].id == id) {
SDL_numGestureTouches--;
SDL_memcpy(&SDL_gestureTouch[i], &SDL_gestureTouch[SDL_numGestureTouches], sizeof(SDL_gestureTouch[i]));
return 1;
}
}
return -1;
}
SDL_GestureTouch * SDL_GetGestureTouch(SDL_TouchID id) {
int i;
for(i = 0;i < SDL_numGestureTouches; i++) {
//printf("%i ?= %i\n",SDL_gestureTouch[i].id,id);
if(SDL_gestureTouch[i].id == id) return &SDL_gestureTouch[i];
}
return NULL;
}
int SDL_SendGestureMulti(SDL_GestureTouch* touch,float dTheta,float dDist) {
SDL_Event event;
event.mgesture.type = SDL_MULTIGESTURE;
event.mgesture.touchId = touch->id;
event.mgesture.x = touch->centroid.x;
event.mgesture.y = touch->centroid.y;
event.mgesture.dTheta = dTheta;
event.mgesture.dDist = dDist;
event.mgesture.numFingers = touch->numDownFingers;
return SDL_PushEvent(&event) > 0;
}
int SDL_SendGestureDollar(SDL_GestureTouch* touch,
SDL_GestureID gestureId,float error) {
SDL_Event event;
event.dgesture.type = SDL_DOLLARGESTURE;
event.dgesture.touchId = touch->id;
/*
//TODO: Add this to give location of gesture?
event.mgesture.x = touch->centroid.x;
event.mgesture.y = touch->centroid.y;
*/
event.dgesture.gestureId = gestureId;
event.dgesture.error = error;
//A finger came up to trigger this event.
event.dgesture.numFingers = touch->numDownFingers + 1;
return SDL_PushEvent(&event) > 0;
}
int SDL_SendDollarRecord(SDL_GestureTouch* touch,SDL_GestureID gestureId) {
SDL_Event event;
event.dgesture.type = SDL_DOLLARRECORD;
event.dgesture.touchId = touch->id;
event.dgesture.gestureId = gestureId;
return SDL_PushEvent(&event) > 0;
}
void SDL_GestureProcessEvent(SDL_Event* event)
{
float x,y;
SDL_FloatPoint path[DOLLARNPOINTS];
int index;
int i;
float pathDx, pathDy;
SDL_FloatPoint lastP;
SDL_FloatPoint lastCentroid;
float lDist;
float Dist;
float dtheta;
float dDist;
if(event->type == SDL_FINGERMOTION ||
event->type == SDL_FINGERDOWN ||
event->type == SDL_FINGERUP) {
SDL_GestureTouch* inTouch = SDL_GetGestureTouch(event->tfinger.touchId);
//Shouldn't be possible
if(inTouch == NULL) return;
//printf("@ (%i,%i) with res: (%i,%i)\n",(int)event->tfinger.x,
// (int)event->tfinger.y,
// (int)inTouch->res.x,(int)inTouch->res.y);
x = ((float)event->tfinger.x)/(float)inTouch->res.x;
y = ((float)event->tfinger.y)/(float)inTouch->res.y;
//Finger Up
if(event->type == SDL_FINGERUP) {
inTouch->numDownFingers--;
#ifdef ENABLE_DOLLAR
if(inTouch->recording) {
inTouch->recording = SDL_FALSE;
dollarNormalize(inTouch->dollarPath,path);
//PrintPath(path);
if(recordAll) {
index = SDL_AddDollarGesture(NULL,path);
for(i = 0;i < SDL_numGestureTouches; i++)
SDL_gestureTouch[i].recording = SDL_FALSE;
}
else {
index = SDL_AddDollarGesture(inTouch,path);
}
if(index >= 0) {
SDL_SendDollarRecord(inTouch,inTouch->dollarTemplate[index].hash);
}
else {
SDL_SendDollarRecord(inTouch,-1);
}
}
else {
int bestTempl;
float error;
error = dollarRecognize(inTouch->dollarPath,
&bestTempl,inTouch);
if(bestTempl >= 0){
//Send Event
unsigned long gestureId = inTouch->dollarTemplate[bestTempl].hash;
SDL_SendGestureDollar(inTouch,gestureId,error);
//printf ("%s\n",);("Dollar error: %f\n",error);
}
}
#endif
//inTouch->gestureLast[j] = inTouch->gestureLast[inTouch->numDownFingers];
if(inTouch->numDownFingers > 0) {
inTouch->centroid.x = (inTouch->centroid.x*(inTouch->numDownFingers+1)-
x)/inTouch->numDownFingers;
inTouch->centroid.y = (inTouch->centroid.y*(inTouch->numDownFingers+1)-
y)/inTouch->numDownFingers;
}
}
else if(event->type == SDL_FINGERMOTION) {
float dx = ((float)event->tfinger.dx)/(float)inTouch->res.x;
float dy = ((float)event->tfinger.dy)/(float)inTouch->res.y;
//printf("dx,dy: (%f,%f)\n",dx,dy);
#ifdef ENABLE_DOLLAR
SDL_DollarPath* path = &inTouch->dollarPath;
if(path->numPoints < MAXPATHSIZE) {
path->p[path->numPoints].x = inTouch->centroid.x;
path->p[path->numPoints].y = inTouch->centroid.y;
pathDx =
(path->p[path->numPoints].x-path->p[path->numPoints-1].x);
pathDy =
(path->p[path->numPoints].y-path->p[path->numPoints-1].y);
path->length += (float)SDL_sqrt(pathDx*pathDx + pathDy*pathDy);
path->numPoints++;
}
#endif
lastP.x = x - dx;
lastP.y = y - dy;
lastCentroid = inTouch->centroid;
inTouch->centroid.x += dx/inTouch->numDownFingers;
inTouch->centroid.y += dy/inTouch->numDownFingers;
//printf("Centrid : (%f,%f)\n",inTouch->centroid.x,inTouch->centroid.y);
if(inTouch->numDownFingers > 1) {
SDL_FloatPoint lv; //Vector from centroid to last x,y position
SDL_FloatPoint v; //Vector from centroid to current x,y position
//lv = inTouch->gestureLast[j].cv;
lv.x = lastP.x - lastCentroid.x;
lv.y = lastP.y - lastCentroid.y;
lDist = (float)SDL_sqrt(lv.x*lv.x + lv.y*lv.y);
//printf("lDist = %f\n",lDist);
v.x = x - inTouch->centroid.x;
v.y = y - inTouch->centroid.y;
//inTouch->gestureLast[j].cv = v;
Dist = (float)SDL_sqrt(v.x*v.x+v.y*v.y);
// SDL_cos(dTheta) = (v . lv)/(|v| * |lv|)
//Normalize Vectors to simplify angle calculation
lv.x/=lDist;
lv.y/=lDist;
v.x/=Dist;
v.y/=Dist;
dtheta = (float)SDL_atan2(lv.x*v.y - lv.y*v.x,lv.x*v.x + lv.y*v.y);
dDist = (Dist - lDist);
if(lDist == 0) {dDist = 0;dtheta = 0;} //To avoid impossible values
//inTouch->gestureLast[j].dDist = dDist;
//inTouch->gestureLast[j].dtheta = dtheta;
//printf("dDist = %f, dTheta = %f\n",dDist,dtheta);
//gdtheta = gdtheta*.9 + dtheta*.1;
//gdDist = gdDist*.9 + dDist*.1
//knob.r += dDist/numDownFingers;
//knob.ang += dtheta;
//printf("thetaSum = %f, distSum = %f\n",gdtheta,gdDist);
//printf("id: %i dTheta = %f, dDist = %f\n",j,dtheta,dDist);
SDL_SendGestureMulti(inTouch,dtheta,dDist);
}
else {
//inTouch->gestureLast[j].dDist = 0;
//inTouch->gestureLast[j].dtheta = 0;
//inTouch->gestureLast[j].cv.x = 0;
//inTouch->gestureLast[j].cv.y = 0;
}
//inTouch->gestureLast[j].f.p.x = x;
//inTouch->gestureLast[j].f.p.y = y;
//break;
//pressure?
}
if(event->type == SDL_FINGERDOWN) {
inTouch->numDownFingers++;
inTouch->centroid.x = (inTouch->centroid.x*(inTouch->numDownFingers - 1)+
x)/inTouch->numDownFingers;
inTouch->centroid.y = (inTouch->centroid.y*(inTouch->numDownFingers - 1)+
y)/inTouch->numDownFingers;
//printf("Finger Down: (%f,%f). Centroid: (%f,%f\n",x,y,
// inTouch->centroid.x,inTouch->centroid.y);
#ifdef ENABLE_DOLLAR
inTouch->dollarPath.length = 0;
inTouch->dollarPath.p[0].x = x;
inTouch->dollarPath.p[0].y = y;
inTouch->dollarPath.numPoints = 1;
#endif
}
}
}
/* vi: set ts=4 sw=4 expandtab: */

View File

@@ -0,0 +1,35 @@
/*
SDL - Simple DirectMedia Layer
Copyright (C) 1997-2010 Sam Lantinga
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
Sam Lantinga
slouken@libsdl.org
*/
#include "SDL_config.h"
#ifndef _SDL_gesture_c_h
#define _SDL_gesture_c_h
extern void SDL_GestureProcessEvent(SDL_Event* event);
extern int SDL_RecordGesture(SDL_TouchID touchId);
extern int SDL_GestureAddTouch(SDL_Touch* touch);
#endif /* _SDL_gesture_c_h */
/* vi: set ts=4 sw=4 expandtab: */

View File

@@ -0,0 +1,924 @@
/*
SDL - Simple DirectMedia Layer
Copyright (C) 1997-2010 Sam Lantinga
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
Sam Lantinga
slouken@libsdl.org
*/
#include "SDL_config.h"
/* General keyboard handling code for SDL */
#include "SDL_timer.h"
#include "SDL_events.h"
#include "SDL_events_c.h"
#include "SDL_sysevents.h"
/* Global keyboard information */
typedef struct SDL_Keyboard SDL_Keyboard;
struct SDL_Keyboard
{
/* Data common to all keyboards */
SDL_Window *focus;
Uint16 modstate;
Uint8 keystate[SDL_NUM_SCANCODES];
SDLKey keymap[SDL_NUM_SCANCODES];
};
static SDL_Keyboard SDL_keyboard;
static const SDLKey SDL_default_keymap[SDL_NUM_SCANCODES] = {
0, 0, 0, 0,
'a',
'b',
'c',
'd',
'e',
'f',
'g',
'h',
'i',
'j',
'k',
'l',
'm',
'n',
'o',
'p',
'q',
'r',
's',
't',
'u',
'v',
'w',
'x',
'y',
'z',
'1',
'2',
'3',
'4',
'5',
'6',
'7',
'8',
'9',
'0',
SDLK_RETURN,
SDLK_ESCAPE,
SDLK_BACKSPACE,
SDLK_TAB,
SDLK_SPACE,
'-',
'=',
'[',
']',
'\\',
'#',
';',
'\'',
'`',
',',
'.',
'/',
SDLK_CAPSLOCK,
SDLK_F1,
SDLK_F2,
SDLK_F3,
SDLK_F4,
SDLK_F5,
SDLK_F6,
SDLK_F7,
SDLK_F8,
SDLK_F9,
SDLK_F10,
SDLK_F11,
SDLK_F12,
SDLK_PRINTSCREEN,
SDLK_SCROLLLOCK,
SDLK_PAUSE,
SDLK_INSERT,
SDLK_HOME,
SDLK_PAGEUP,
SDLK_DELETE,
SDLK_END,
SDLK_PAGEDOWN,
SDLK_RIGHT,
SDLK_LEFT,
SDLK_DOWN,
SDLK_UP,
SDLK_NUMLOCKCLEAR,
SDLK_KP_DIVIDE,
SDLK_KP_MULTIPLY,
SDLK_KP_MINUS,
SDLK_KP_PLUS,
SDLK_KP_ENTER,
SDLK_KP_1,
SDLK_KP_2,
SDLK_KP_3,
SDLK_KP_4,
SDLK_KP_5,
SDLK_KP_6,
SDLK_KP_7,
SDLK_KP_8,
SDLK_KP_9,
SDLK_KP_0,
SDLK_KP_PERIOD,
0,
SDLK_APPLICATION,
SDLK_POWER,
SDLK_KP_EQUALS,
SDLK_F13,
SDLK_F14,
SDLK_F15,
SDLK_F16,
SDLK_F17,
SDLK_F18,
SDLK_F19,
SDLK_F20,
SDLK_F21,
SDLK_F22,
SDLK_F23,
SDLK_F24,
SDLK_EXECUTE,
SDLK_HELP,
SDLK_MENU,
SDLK_SELECT,
SDLK_STOP,
SDLK_AGAIN,
SDLK_UNDO,
SDLK_CUT,
SDLK_COPY,
SDLK_PASTE,
SDLK_FIND,
SDLK_MUTE,
SDLK_VOLUMEUP,
SDLK_VOLUMEDOWN,
0, 0, 0,
SDLK_KP_COMMA,
SDLK_KP_EQUALSAS400,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
SDLK_ALTERASE,
SDLK_SYSREQ,
SDLK_CANCEL,
SDLK_CLEAR,
SDLK_PRIOR,
SDLK_RETURN2,
SDLK_SEPARATOR,
SDLK_OUT,
SDLK_OPER,
SDLK_CLEARAGAIN,
SDLK_CRSEL,
SDLK_EXSEL,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
SDLK_KP_00,
SDLK_KP_000,
SDLK_THOUSANDSSEPARATOR,
SDLK_DECIMALSEPARATOR,
SDLK_CURRENCYUNIT,
SDLK_CURRENCYSUBUNIT,
SDLK_KP_LEFTPAREN,
SDLK_KP_RIGHTPAREN,
SDLK_KP_LEFTBRACE,
SDLK_KP_RIGHTBRACE,
SDLK_KP_TAB,
SDLK_KP_BACKSPACE,
SDLK_KP_A,
SDLK_KP_B,
SDLK_KP_C,
SDLK_KP_D,
SDLK_KP_E,
SDLK_KP_F,
SDLK_KP_XOR,
SDLK_KP_POWER,
SDLK_KP_PERCENT,
SDLK_KP_LESS,
SDLK_KP_GREATER,
SDLK_KP_AMPERSAND,
SDLK_KP_DBLAMPERSAND,
SDLK_KP_VERTICALBAR,
SDLK_KP_DBLVERTICALBAR,
SDLK_KP_COLON,
SDLK_KP_HASH,
SDLK_KP_SPACE,
SDLK_KP_AT,
SDLK_KP_EXCLAM,
SDLK_KP_MEMSTORE,
SDLK_KP_MEMRECALL,
SDLK_KP_MEMCLEAR,
SDLK_KP_MEMADD,
SDLK_KP_MEMSUBTRACT,
SDLK_KP_MEMMULTIPLY,
SDLK_KP_MEMDIVIDE,
SDLK_KP_PLUSMINUS,
SDLK_KP_CLEAR,
SDLK_KP_CLEARENTRY,
SDLK_KP_BINARY,
SDLK_KP_OCTAL,
SDLK_KP_DECIMAL,
SDLK_KP_HEXADECIMAL,
0, 0,
SDLK_LCTRL,
SDLK_LSHIFT,
SDLK_LALT,
SDLK_LGUI,
SDLK_RCTRL,
SDLK_RSHIFT,
SDLK_RALT,
SDLK_RGUI,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
SDLK_MODE,
SDLK_AUDIONEXT,
SDLK_AUDIOPREV,
SDLK_AUDIOSTOP,
SDLK_AUDIOPLAY,
SDLK_AUDIOMUTE,
SDLK_MEDIASELECT,
SDLK_WWW,
SDLK_MAIL,
SDLK_CALCULATOR,
SDLK_COMPUTER,
SDLK_AC_SEARCH,
SDLK_AC_HOME,
SDLK_AC_BACK,
SDLK_AC_FORWARD,
SDLK_AC_STOP,
SDLK_AC_REFRESH,
SDLK_AC_BOOKMARKS,
SDLK_BRIGHTNESSDOWN,
SDLK_BRIGHTNESSUP,
SDLK_DISPLAYSWITCH,
SDLK_KBDILLUMTOGGLE,
SDLK_KBDILLUMDOWN,
SDLK_KBDILLUMUP,
SDLK_EJECT,
SDLK_SLEEP,
};
static const char *SDL_scancode_names[SDL_NUM_SCANCODES] = {
NULL, NULL, NULL, NULL,
"A",
"B",
"C",
"D",
"E",
"F",
"G",
"H",
"I",
"J",
"K",
"L",
"M",
"N",
"O",
"P",
"Q",
"R",
"S",
"T",
"U",
"V",
"W",
"X",
"Y",
"Z",
"1",
"2",
"3",
"4",
"5",
"6",
"7",
"8",
"9",
"0",
"Return",
"Escape",
"Backspace",
"Tab",
"Space",
"-",
"=",
"[",
"]",
"\\",
"#",
";",
"'",
"`",
",",
".",
"/",
"CapsLock",
"F1",
"F2",
"F3",
"F4",
"F5",
"F6",
"F7",
"F8",
"F9",
"F10",
"F11",
"F12",
"PrintScreen",
"ScrollLock",
"Pause",
"Insert",
"Home",
"PageUp",
"Delete",
"End",
"PageDown",
"Right",
"Left",
"Down",
"Up",
"Numlock",
"Keypad /",
"Keypad *",
"Keypad -",
"Keypad +",
"Keypad Enter",
"Keypad 1",
"Keypad 2",
"Keypad 3",
"Keypad 4",
"Keypad 5",
"Keypad 6",
"Keypad 7",
"Keypad 8",
"Keypad 9",
"Keypad 0",
"Keypad .",
NULL,
"Application",
"Power",
"Keypad =",
"F13",
"F14",
"F15",
"F16",
"F17",
"F18",
"F19",
"F20",
"F21",
"F22",
"F23",
"F24",
"Execute",
"Help",
"Menu",
"Select",
"Stop",
"Again",
"Undo",
"Cut",
"Copy",
"Paste",
"Find",
"Mute",
"VolumeUp",
"VolumeDown",
NULL, NULL, NULL,
"Keypad ,",
"Keypad = (AS400)",
NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
NULL, NULL, NULL, NULL, NULL, NULL,
"AltErase",
"SysReq",
"Cancel",
"Clear",
"Prior",
"Return",
"Separator",
"Out",
"Oper",
"Clear / Again",
"CrSel",
"ExSel",
NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
"Keypad 00",
"Keypad 000",
"ThousandsSeparator",
"DecimalSeparator",
"CurrencyUnit",
"CurrencySubUnit",
"Keypad (",
"Keypad )",
"Keypad {",
"Keypad }",
"Keypad Tab",
"Keypad Backspace",
"Keypad A",
"Keypad B",
"Keypad C",
"Keypad D",
"Keypad E",
"Keypad F",
"Keypad XOR",
"Keypad ^",
"Keypad %",
"Keypad <",
"Keypad >",
"Keypad &",
"Keypad &&",
"Keypad |",
"Keypad ||",
"Keypad :",
"Keypad #",
"Keypad Space",
"Keypad @",
"Keypad !",
"Keypad MemStore",
"Keypad MemRecall",
"Keypad MemClear",
"Keypad MemAdd",
"Keypad MemSubtract",
"Keypad MemMultiply",
"Keypad MemDivide",
"Keypad +/-",
"Keypad Clear",
"Keypad ClearEntry",
"Keypad Binary",
"Keypad Octal",
"Keypad Decimal",
"Keypad Hexadecimal",
NULL, NULL,
"Left Ctrl",
"Left Shift",
"Left Alt",
"Left GUI",
"Right Ctrl",
"Right Shift",
"Right Alt",
"Right GUI",
NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
NULL,
"ModeSwitch",
"AudioNext",
"AudioPrev",
"AudioStop",
"AudioPlay",
"AudioMute",
"MediaSelect",
"WWW",
"Mail",
"Calculator",
"Computer",
"AC Search",
"AC Home",
"AC Back",
"AC Forward",
"AC Stop",
"AC Refresh",
"AC Bookmarks",
"BrightnessDown",
"BrightnessUp",
"DisplaySwitch",
"KBDIllumToggle",
"KBDIllumDown",
"KBDIllumUp",
"Eject",
"Sleep",
};
/* Taken from SDL_iconv() */
static char *
SDL_UCS4ToUTF8(Uint32 ch, char *dst)
{
Uint8 *p = (Uint8 *) dst;
if (ch <= 0x7F) {
*p = (Uint8) ch;
++dst;
} else if (ch <= 0x7FF) {
p[0] = 0xC0 | (Uint8) ((ch >> 6) & 0x1F);
p[1] = 0x80 | (Uint8) (ch & 0x3F);
dst += 2;
} else if (ch <= 0xFFFF) {
p[0] = 0xE0 | (Uint8) ((ch >> 12) & 0x0F);
p[1] = 0x80 | (Uint8) ((ch >> 6) & 0x3F);
p[2] = 0x80 | (Uint8) (ch & 0x3F);
dst += 3;
} else if (ch <= 0x1FFFFF) {
p[0] = 0xF0 | (Uint8) ((ch >> 18) & 0x07);
p[1] = 0x80 | (Uint8) ((ch >> 12) & 0x3F);
p[2] = 0x80 | (Uint8) ((ch >> 6) & 0x3F);
p[3] = 0x80 | (Uint8) (ch & 0x3F);
dst += 4;
} else if (ch <= 0x3FFFFFF) {
p[0] = 0xF8 | (Uint8) ((ch >> 24) & 0x03);
p[1] = 0x80 | (Uint8) ((ch >> 18) & 0x3F);
p[2] = 0x80 | (Uint8) ((ch >> 12) & 0x3F);
p[3] = 0x80 | (Uint8) ((ch >> 6) & 0x3F);
p[4] = 0x80 | (Uint8) (ch & 0x3F);
dst += 5;
} else {
p[0] = 0xFC | (Uint8) ((ch >> 30) & 0x01);
p[1] = 0x80 | (Uint8) ((ch >> 24) & 0x3F);
p[2] = 0x80 | (Uint8) ((ch >> 18) & 0x3F);
p[3] = 0x80 | (Uint8) ((ch >> 12) & 0x3F);
p[4] = 0x80 | (Uint8) ((ch >> 6) & 0x3F);
p[5] = 0x80 | (Uint8) (ch & 0x3F);
dst += 6;
}
return dst;
}
/* Public functions */
int
SDL_KeyboardInit(void)
{
SDL_Keyboard *keyboard = &SDL_keyboard;
/* Set the default keymap */
SDL_memcpy(keyboard->keymap, SDL_default_keymap, sizeof(SDL_default_keymap));
return (0);
}
void
SDL_ResetKeyboard(void)
{
SDL_Keyboard *keyboard = &SDL_keyboard;
SDL_scancode scancode;
for (scancode = 0; scancode < SDL_NUM_SCANCODES; ++scancode) {
if (keyboard->keystate[scancode] == SDL_PRESSED) {
SDL_SendKeyboardKey(SDL_RELEASED, scancode);
}
}
}
void
SDL_GetDefaultKeymap(SDLKey * keymap)
{
SDL_memcpy(keymap, SDL_default_keymap, sizeof(SDL_default_keymap));
}
void
SDL_SetKeymap(int start, SDLKey * keys, int length)
{
SDL_Keyboard *keyboard = &SDL_keyboard;
if (start < 0 || start + length > SDL_NUM_SCANCODES) {
return;
}
SDL_memcpy(&keyboard->keymap[start], keys, sizeof(*keys) * length);
}
void
SDL_SetScancodeName(SDL_scancode scancode, const char *name)
{
SDL_scancode_names[scancode] = name;
}
SDL_Window *
SDL_GetKeyboardFocus(void)
{
SDL_Keyboard *keyboard = &SDL_keyboard;
return keyboard->focus;
}
void
SDL_SetKeyboardFocus(SDL_Window * window)
{
SDL_Keyboard *keyboard = &SDL_keyboard;
/* See if the current window has lost focus */
if (keyboard->focus && keyboard->focus != window) {
SDL_SendWindowEvent(keyboard->focus, SDL_WINDOWEVENT_FOCUS_LOST,
0, 0);
/* Ensures IME compositions are committed */
if (SDL_EventState(SDL_TEXTINPUT, SDL_QUERY)) {
SDL_VideoDevice *video = SDL_GetVideoDevice();
if (video && video->StopTextInput) {
video->StopTextInput(video);
}
}
}
keyboard->focus = window;
if (keyboard->focus) {
SDL_SendWindowEvent(keyboard->focus, SDL_WINDOWEVENT_FOCUS_GAINED,
0, 0);
if (SDL_EventState(SDL_TEXTINPUT, SDL_QUERY)) {
SDL_VideoDevice *video = SDL_GetVideoDevice();
if (video && video->StartTextInput) {
video->StartTextInput(video);
}
}
}
}
int
SDL_SendKeyboardKey(Uint8 state, SDL_scancode scancode)
{
SDL_Keyboard *keyboard = &SDL_keyboard;
int posted;
Uint16 modstate;
Uint32 type;
Uint8 repeat;
if (!scancode) {
return 0;
}
#if 0
printf("The '%s' key has been %s\n", SDL_GetScancodeName(scancode),
state == SDL_PRESSED ? "pressed" : "released");
#endif
if (state == SDL_PRESSED) {
modstate = keyboard->modstate;
switch (scancode) {
case SDL_SCANCODE_NUMLOCKCLEAR:
keyboard->modstate ^= KMOD_NUM;
break;
case SDL_SCANCODE_CAPSLOCK:
keyboard->modstate ^= KMOD_CAPS;
break;
case SDL_SCANCODE_LCTRL:
keyboard->modstate |= KMOD_LCTRL;
break;
case SDL_SCANCODE_RCTRL:
keyboard->modstate |= KMOD_RCTRL;
break;
case SDL_SCANCODE_LSHIFT:
keyboard->modstate |= KMOD_LSHIFT;
break;
case SDL_SCANCODE_RSHIFT:
keyboard->modstate |= KMOD_RSHIFT;
break;
case SDL_SCANCODE_LALT:
keyboard->modstate |= KMOD_LALT;
break;
case SDL_SCANCODE_RALT:
keyboard->modstate |= KMOD_RALT;
break;
case SDL_SCANCODE_LGUI:
keyboard->modstate |= KMOD_LGUI;
break;
case SDL_SCANCODE_RGUI:
keyboard->modstate |= KMOD_RGUI;
break;
case SDL_SCANCODE_MODE:
keyboard->modstate |= KMOD_MODE;
break;
default:
break;
}
} else {
switch (scancode) {
case SDL_SCANCODE_NUMLOCKCLEAR:
case SDL_SCANCODE_CAPSLOCK:
break;
case SDL_SCANCODE_LCTRL:
keyboard->modstate &= ~KMOD_LCTRL;
break;
case SDL_SCANCODE_RCTRL:
keyboard->modstate &= ~KMOD_RCTRL;
break;
case SDL_SCANCODE_LSHIFT:
keyboard->modstate &= ~KMOD_LSHIFT;
break;
case SDL_SCANCODE_RSHIFT:
keyboard->modstate &= ~KMOD_RSHIFT;
break;
case SDL_SCANCODE_LALT:
keyboard->modstate &= ~KMOD_LALT;
break;
case SDL_SCANCODE_RALT:
keyboard->modstate &= ~KMOD_RALT;
break;
case SDL_SCANCODE_LGUI:
keyboard->modstate &= ~KMOD_LGUI;
break;
case SDL_SCANCODE_RGUI:
keyboard->modstate &= ~KMOD_RGUI;
break;
case SDL_SCANCODE_MODE:
keyboard->modstate &= ~KMOD_MODE;
break;
default:
break;
}
modstate = keyboard->modstate;
}
/* Figure out what type of event this is */
switch (state) {
case SDL_PRESSED:
type = SDL_KEYDOWN;
break;
case SDL_RELEASED:
type = SDL_KEYUP;
break;
default:
/* Invalid state -- bail */
return 0;
}
/* Drop events that don't change state */
repeat = (state && keyboard->keystate[scancode]);
if (keyboard->keystate[scancode] == state && !repeat) {
#if 0
printf("Keyboard event didn't change state - dropped!\n");
#endif
return 0;
}
/* Update internal keyboard state */
keyboard->keystate[scancode] = state;
/* Post the event, if desired */
posted = 0;
if (SDL_GetEventState(type) == SDL_ENABLE) {
SDL_Event event;
event.key.type = type;
event.key.state = state;
event.key.repeat = repeat;
event.key.keysym.scancode = scancode;
event.key.keysym.sym = keyboard->keymap[scancode];
event.key.keysym.mod = modstate;
event.key.keysym.unicode = 0;
event.key.windowID = keyboard->focus ? keyboard->focus->id : 0;
posted = (SDL_PushEvent(&event) > 0);
}
return (posted);
}
int
SDL_SendKeyboardText(const char *text)
{
SDL_Keyboard *keyboard = &SDL_keyboard;
int posted;
/* Don't post text events for unprintable characters */
if ((unsigned char)*text < ' ' || *text == 127) {
return 0;
}
/* Post the event, if desired */
posted = 0;
if (SDL_GetEventState(SDL_TEXTINPUT) == SDL_ENABLE) {
SDL_Event event;
event.text.type = SDL_TEXTINPUT;
event.text.windowID = keyboard->focus ? keyboard->focus->id : 0;
SDL_utf8strlcpy(event.text.text, text, SDL_arraysize(event.text.text));
event.text.windowID = keyboard->focus ? keyboard->focus->id : 0;
posted = (SDL_PushEvent(&event) > 0);
}
return (posted);
}
int
SDL_SendEditingText(const char *text, int start, int length)
{
SDL_Keyboard *keyboard = &SDL_keyboard;
int posted;
/* Post the event, if desired */
posted = 0;
if (SDL_GetEventState(SDL_TEXTEDITING) == SDL_ENABLE) {
SDL_Event event;
event.edit.type = SDL_TEXTEDITING;
event.edit.windowID = keyboard->focus ? keyboard->focus->id : 0;
event.edit.start = start;
event.edit.length = length;
SDL_utf8strlcpy(event.edit.text, text, SDL_arraysize(event.edit.text));
posted = (SDL_PushEvent(&event) > 0);
}
return (posted);
}
void
SDL_KeyboardQuit(void)
{
}
Uint8 *
SDL_GetKeyboardState(int *numkeys)
{
SDL_Keyboard *keyboard = &SDL_keyboard;
if (numkeys != (int *) 0) {
*numkeys = SDL_NUM_SCANCODES;
}
return keyboard->keystate;
}
SDLMod
SDL_GetModState(void)
{
SDL_Keyboard *keyboard = &SDL_keyboard;
return keyboard->modstate;
}
void
SDL_SetModState(SDLMod modstate)
{
SDL_Keyboard *keyboard = &SDL_keyboard;
keyboard->modstate = modstate;
}
SDLKey
SDL_GetKeyFromScancode(SDL_scancode scancode)
{
SDL_Keyboard *keyboard = &SDL_keyboard;
return keyboard->keymap[scancode];
}
SDL_scancode
SDL_GetScancodeFromKey(SDLKey key)
{
SDL_Keyboard *keyboard = &SDL_keyboard;
SDL_scancode scancode;
for (scancode = SDL_SCANCODE_UNKNOWN; scancode < SDL_NUM_SCANCODES;
++scancode) {
if (keyboard->keymap[scancode] == key) {
return scancode;
}
}
return SDL_SCANCODE_UNKNOWN;
}
const char *
SDL_GetScancodeName(SDL_scancode scancode)
{
const char *name = SDL_scancode_names[scancode];
if (name)
return name;
else
return "";
}
const char *
SDL_GetKeyName(SDLKey key)
{
static char name[8];
char *end;
if (key & SDLK_SCANCODE_MASK) {
return
SDL_GetScancodeName((SDL_scancode) (key & ~SDLK_SCANCODE_MASK));
}
switch (key) {
case SDLK_RETURN:
return SDL_GetScancodeName(SDL_SCANCODE_RETURN);
case SDLK_ESCAPE:
return SDL_GetScancodeName(SDL_SCANCODE_ESCAPE);
case SDLK_BACKSPACE:
return SDL_GetScancodeName(SDL_SCANCODE_BACKSPACE);
case SDLK_TAB:
return SDL_GetScancodeName(SDL_SCANCODE_TAB);
case SDLK_SPACE:
return SDL_GetScancodeName(SDL_SCANCODE_SPACE);
case SDLK_DELETE:
return SDL_GetScancodeName(SDL_SCANCODE_DELETE);
default:
/* Unaccented letter keys on latin keyboards are normally
labeled in upper case (and probably on others like Greek or
Cyrillic too, so if you happen to know for sure, please
adapt this). */
if (key >= 'a' && key <= 'z') {
key -= 32;
}
end = SDL_UCS4ToUTF8((Uint32) key, name);
*end = '\0';
return name;
}
}
/* vi: set ts=4 sw=4 expandtab: */

View File

@@ -0,0 +1,65 @@
/*
SDL - Simple DirectMedia Layer
Copyright (C) 1997-2010 Sam Lantinga
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
Sam Lantinga
slouken@libsdl.org
*/
#include "SDL_config.h"
#ifndef _SDL_keyboard_c_h
#define _SDL_keyboard_c_h
#include "SDL_keysym.h"
#include "SDL_events.h"
/* Initialize the keyboard subsystem */
extern int SDL_KeyboardInit(void);
/* Clear the state of the keyboard */
extern void SDL_ResetKeyboard(void);
/* Get the default keymap */
extern void SDL_GetDefaultKeymap(SDLKey * keymap);
/* Set the mapping of scancode to key codes */
extern void SDL_SetKeymap(int start, SDLKey * keys, int length);
/* Set a platform-dependent key name, overriding the default platform-agnostic
name. Encoded as UTF-8. The string is not copied, thus the pointer given to
this function must stay valid forever (or at least until the call to
VideoQuit()). */
extern void SDL_SetScancodeName(SDL_scancode scancode, const char *name);
/* Set the keyboard focus window */
extern void SDL_SetKeyboardFocus(SDL_Window * window);
/* Send a keyboard key event */
extern int SDL_SendKeyboardKey(Uint8 state, SDL_scancode scancode);
/* Send keyboard text input */
extern int SDL_SendKeyboardText(const char *text);
/* Send editing text for selected range from start to end */
extern int SDL_SendEditingText(const char *text, int start, int end);
/* Shutdown the keyboard subsystem */
extern void SDL_KeyboardQuit(void);
#endif /* _SDL_keyboard_c_h */
/* vi: set ts=4 sw=4 expandtab: */

View File

@@ -0,0 +1,523 @@
/*
SDL - Simple DirectMedia Layer
Copyright (C) 1997-2010 Sam Lantinga
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
Sam Lantinga
slouken@libsdl.org
*/
#include "SDL_config.h"
/* General mouse handling code for SDL */
#include "SDL_events.h"
#include "SDL_events_c.h"
#include "default_cursor.h"
#include "../video/SDL_sysvideo.h"
/* Global mouse information */
typedef struct SDL_Mouse SDL_Mouse;
struct SDL_Mouse
{
/* Create a cursor from a surface */
SDL_Cursor *(*CreateCursor) (SDL_Surface * surface, int hot_x, int hot_y);
/* Show the specified cursor, or hide if cursor is NULL */
int (*ShowCursor) (SDL_Cursor * cursor);
/* This is called when a mouse motion event occurs */
void (*MoveCursor) (SDL_Cursor * cursor);
/* Free a window manager cursor */
void (*FreeCursor) (SDL_Cursor * cursor);
/* Warp the mouse to (x,y) */
void (*WarpMouse) (SDL_Mouse * mouse, SDL_Window * window, int x, int y);
/* Data common to all mice */
SDL_Window *focus;
int x;
int y;
int xdelta;
int ydelta;
int last_x, last_y; /* the last reported x and y coordinates */
Uint8 buttonstate;
SDL_bool relative_mode;
SDL_Cursor *cursors;
SDL_Cursor *def_cursor;
SDL_Cursor *cur_cursor;
SDL_bool cursor_shown;
};
static SDL_Mouse SDL_mouse;
/* Public functions */
int
SDL_MouseInit(void)
{
return (0);
}
void
SDL_ResetMouse(void)
{
/* FIXME */
}
SDL_Window *
SDL_GetMouseFocus(void)
{
SDL_Mouse *mouse = &SDL_mouse;
return mouse->focus;
}
void
SDL_SetMouseFocus(SDL_Window * window)
{
SDL_Mouse *mouse = &SDL_mouse;
if (mouse->focus == window) {
return;
}
/* See if the current window has lost focus */
if (mouse->focus) {
SDL_SendWindowEvent(mouse->focus, SDL_WINDOWEVENT_LEAVE, 0, 0);
}
mouse->focus = window;
if (mouse->focus) {
SDL_SendWindowEvent(mouse->focus, SDL_WINDOWEVENT_ENTER, 0, 0);
}
}
int
SDL_SendMouseMotion(SDL_Window * window, int relative, int x, int y)
{
SDL_Mouse *mouse = &SDL_mouse;
int posted;
int xrel;
int yrel;
int x_max = 0, y_max = 0;
if (window) {
SDL_SetMouseFocus(window);
}
/* the relative motion is calculated regarding the system cursor last position */
if (relative) {
xrel = x;
yrel = y;
x = (mouse->last_x + x);
y = (mouse->last_y + y);
} else {
xrel = x - mouse->last_x;
yrel = y - mouse->last_y;
}
/* Drop events that don't change state */
if (!xrel && !yrel) {
#if 0
printf("Mouse event didn't change state - dropped!\n");
#endif
return 0;
}
/* Update internal mouse coordinates */
if (mouse->relative_mode == SDL_FALSE) {
mouse->x = x;
mouse->y = y;
} else {
mouse->x += xrel;
mouse->y += yrel;
}
SDL_GetWindowSize(mouse->focus, &x_max, &y_max);
/* make sure that the pointers find themselves inside the windows */
/* only check if mouse->xmax is set ! */
if (x_max && mouse->x > x_max) {
mouse->x = x_max;
} else if (mouse->x < 0) {
mouse->x = 0;
}
if (y_max && mouse->y > y_max) {
mouse->y = y_max;
} else if (mouse->y < 0) {
mouse->y = 0;
}
mouse->xdelta += xrel;
mouse->ydelta += yrel;
#if 0 /* FIXME */
/* Move the mouse cursor, if needed */
if (mouse->cursor_shown && !mouse->relative_mode &&
mouse->MoveCursor && mouse->cur_cursor) {
mouse->MoveCursor(mouse->cur_cursor);
}
#endif
/* Post the event, if desired */
posted = 0;
if (SDL_GetEventState(SDL_MOUSEMOTION) == SDL_ENABLE) {
SDL_Event event;
event.motion.type = SDL_MOUSEMOTION;
event.motion.windowID = mouse->focus ? mouse->focus->id : 0;
event.motion.state = mouse->buttonstate;
event.motion.x = mouse->x;
event.motion.y = mouse->y;
event.motion.xrel = xrel;
event.motion.yrel = yrel;
posted = (SDL_PushEvent(&event) > 0);
}
mouse->last_x = mouse->x;
mouse->last_y = mouse->y;
return posted;
}
int
SDL_SendMouseButton(SDL_Window * window, Uint8 state, Uint8 button)
{
SDL_Mouse *mouse = &SDL_mouse;
int posted;
Uint32 type;
if (window) {
SDL_SetMouseFocus(window);
}
/* Figure out which event to perform */
switch (state) {
case SDL_PRESSED:
if (mouse->buttonstate & SDL_BUTTON(button)) {
/* Ignore this event, no state change */
return 0;
}
type = SDL_MOUSEBUTTONDOWN;
mouse->buttonstate |= SDL_BUTTON(button);
break;
case SDL_RELEASED:
if (!(mouse->buttonstate & SDL_BUTTON(button))) {
/* Ignore this event, no state change */
return 0;
}
type = SDL_MOUSEBUTTONUP;
mouse->buttonstate &= ~SDL_BUTTON(button);
break;
default:
/* Invalid state -- bail */
return 0;
}
/* Post the event, if desired */
posted = 0;
if (SDL_GetEventState(type) == SDL_ENABLE) {
SDL_Event event;
event.type = type;
event.button.state = state;
event.button.button = button;
event.button.x = mouse->x;
event.button.y = mouse->y;
event.button.windowID = mouse->focus ? mouse->focus->id : 0;
posted = (SDL_PushEvent(&event) > 0);
}
return posted;
}
int
SDL_SendMouseWheel(SDL_Window * window, int x, int y)
{
SDL_Mouse *mouse = &SDL_mouse;
int posted;
if (window) {
SDL_SetMouseFocus(window);
}
if (!x && !y) {
return 0;
}
/* Post the event, if desired */
posted = 0;
if (SDL_GetEventState(SDL_MOUSEWHEEL) == SDL_ENABLE) {
SDL_Event event;
event.type = SDL_MOUSEWHEEL;
event.wheel.windowID = mouse->focus ? mouse->focus->id : 0;
event.wheel.x = x;
event.wheel.y = y;
posted = (SDL_PushEvent(&event) > 0);
}
return posted;
}
void
SDL_MouseQuit(void)
{
}
Uint8
SDL_GetMouseState(int *x, int *y)
{
SDL_Mouse *mouse = &SDL_mouse;
if (x) {
*x = mouse->x;
}
if (y) {
*y = mouse->y;
}
return mouse->buttonstate;
}
Uint8
SDL_GetRelativeMouseState(int *x, int *y)
{
SDL_Mouse *mouse = &SDL_mouse;
if (x) {
*x = mouse->xdelta;
}
if (y) {
*y = mouse->ydelta;
}
mouse->xdelta = 0;
mouse->ydelta = 0;
return mouse->buttonstate;
}
void
SDL_WarpMouseInWindow(SDL_Window * window, int x, int y)
{
SDL_Mouse *mouse = &SDL_mouse;
if (mouse->WarpMouse) {
mouse->WarpMouse(mouse, window, x, y);
} else {
SDL_SendMouseMotion(window, 0, x, y);
}
}
int
SDL_SetRelativeMouseMode(SDL_bool enabled)
{
SDL_Mouse *mouse = &SDL_mouse;
/* Flush pending mouse motion */
SDL_FlushEvent(SDL_MOUSEMOTION);
/* Set the relative mode */
mouse->relative_mode = enabled;
if (!enabled) {
/* Restore the expected mouse position */
SDL_WarpMouseInWindow(mouse->focus, mouse->x, mouse->y);
}
/* Update cursor visibility */
SDL_SetCursor(NULL);
return 0;
}
SDL_bool
SDL_GetRelativeMouseMode()
{
SDL_Mouse *mouse = &SDL_mouse;
return mouse->relative_mode;
}
SDL_Cursor *
SDL_CreateCursor(const Uint8 * data, const Uint8 * mask,
int w, int h, int hot_x, int hot_y)
{
SDL_Mouse *mouse = &SDL_mouse;
SDL_Surface *surface;
SDL_Cursor *cursor;
int x, y;
Uint32 *pixel;
Uint8 datab = 0, maskb = 0;
const Uint32 black = 0xFF000000;
const Uint32 white = 0xFFFFFFFF;
const Uint32 transparent = 0x00000000;
if (!mouse->CreateCursor) {
SDL_SetError("Cursors are not currently supported");
return NULL;
}
/* Sanity check the hot spot */
if ((hot_x < 0) || (hot_y < 0) || (hot_x >= w) || (hot_y >= h)) {
SDL_SetError("Cursor hot spot doesn't lie within cursor");
return NULL;
}
/* Make sure the width is a multiple of 8 */
w = ((w + 7) & ~7);
/* Create the surface from a bitmap */
surface =
SDL_CreateRGBSurface(0, w, h, 32, 0x00FF0000, 0x0000FF00, 0x000000FF,
0xFF000000);
if (!surface) {
return NULL;
}
for (y = 0; y < h; ++y) {
pixel = (Uint32 *) ((Uint8 *) surface->pixels + y * surface->pitch);
for (x = 0; x < w; ++x) {
if ((x % 8) == 0) {
datab = *data++;
maskb = *mask++;
}
if (maskb & 0x80) {
*pixel++ = (datab & 0x80) ? black : white;
} else {
*pixel++ = (datab & 0x80) ? black : transparent;
}
datab <<= 1;
maskb <<= 1;
}
}
cursor = mouse->CreateCursor(surface, hot_x, hot_y);
if (cursor) {
cursor->next = mouse->cursors;
mouse->cursors = cursor;
}
SDL_FreeSurface(surface);
return cursor;
}
/* SDL_SetCursor(NULL) can be used to force the cursor redraw,
if this is desired for any reason. This is used when setting
the video mode and when the SDL window gains the mouse focus.
*/
void
SDL_SetCursor(SDL_Cursor * cursor)
{
SDL_Mouse *mouse = &SDL_mouse;
/* Set the new cursor */
if (cursor) {
/* Make sure the cursor is still valid for this mouse */
SDL_Cursor *found;
for (found = mouse->cursors; found; found = found->next) {
if (found == cursor) {
break;
}
}
if (!found) {
SDL_SetError("Cursor not associated with the current mouse");
return;
}
mouse->cur_cursor = cursor;
} else {
cursor = mouse->cur_cursor;
}
if (cursor && mouse->cursor_shown && !mouse->relative_mode) {
if (mouse->ShowCursor) {
mouse->ShowCursor(cursor);
}
} else {
if (mouse->ShowCursor) {
mouse->ShowCursor(NULL);
}
}
}
SDL_Cursor *
SDL_GetCursor(void)
{
SDL_Mouse *mouse = &SDL_mouse;
if (!mouse) {
return NULL;
}
return mouse->cur_cursor;
}
void
SDL_FreeCursor(SDL_Cursor * cursor)
{
SDL_Mouse *mouse = &SDL_mouse;
SDL_Cursor *curr, *prev;
if (!cursor) {
return;
}
if (cursor == mouse->def_cursor) {
return;
}
if (cursor == mouse->cur_cursor) {
SDL_SetCursor(mouse->def_cursor);
}
for (prev = NULL, curr = mouse->cursors; curr;
prev = curr, curr = curr->next) {
if (curr == cursor) {
if (prev) {
prev->next = curr->next;
} else {
mouse->cursors = curr->next;
}
if (mouse->FreeCursor) {
mouse->FreeCursor(curr);
}
return;
}
}
}
int
SDL_ShowCursor(int toggle)
{
SDL_Mouse *mouse = &SDL_mouse;
SDL_bool shown;
if (!mouse) {
return 0;
}
shown = mouse->cursor_shown;
if (toggle >= 0) {
if (toggle) {
mouse->cursor_shown = SDL_TRUE;
} else {
mouse->cursor_shown = SDL_FALSE;
}
if (mouse->cursor_shown != shown) {
SDL_SetCursor(NULL);
}
}
return shown;
}
/* vi: set ts=4 sw=4 expandtab: */

View File

@@ -0,0 +1,56 @@
/*
SDL - Simple DirectMedia Layer
Copyright (C) 1997-2010 Sam Lantinga
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
Sam Lantinga
slouken@libsdl.org
*/
#include "SDL_config.h"
#ifndef _SDL_mouse_c_h
#define _SDL_mouse_c_h
struct SDL_Cursor
{
SDL_Cursor *next;
void *driverdata;
};
/* Initialize the mouse subsystem */
extern int SDL_MouseInit(void);
/* Clear the mouse state */
extern void SDL_ResetMouse(void);
/* Set the mouse focus window */
extern void SDL_SetMouseFocus(SDL_Window * window);
/* Send a mouse motion event */
extern int SDL_SendMouseMotion(SDL_Window * window, int relative, int x, int y);
/* Send a mouse button event */
extern int SDL_SendMouseButton(SDL_Window * window, Uint8 state, Uint8 button);
/* Send a mouse wheel event */
extern int SDL_SendMouseWheel(SDL_Window * window, int x, int y);
/* Shutdown the mouse subsystem */
extern void SDL_MouseQuit(void);
#endif /* _SDL_mouse_c_h */
/* vi: set ts=4 sw=4 expandtab: */

View File

@@ -0,0 +1,96 @@
/*
SDL - Simple DirectMedia Layer
Copyright (C) 1997-2010 Sam Lantinga
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
Sam Lantinga
slouken@libsdl.org
*/
#include "SDL_config.h"
/* General quit handling code for SDL */
#ifdef HAVE_SIGNAL_H
#include <signal.h>
#endif
#include "SDL_events.h"
#include "SDL_events_c.h"
#ifdef HAVE_SIGNAL_H
static void
SDL_HandleSIG(int sig)
{
/* Reset the signal handler */
signal(sig, SDL_HandleSIG);
/* Signal a quit interrupt */
SDL_SendQuit();
}
#endif /* HAVE_SIGNAL_H */
/* Public functions */
int
SDL_QuitInit(void)
{
#ifdef HAVE_SIGNAL_H
void (*ohandler) (int);
/* Both SIGINT and SIGTERM are translated into quit interrupts */
ohandler = signal(SIGINT, SDL_HandleSIG);
if (ohandler != SIG_DFL)
signal(SIGINT, ohandler);
ohandler = signal(SIGTERM, SDL_HandleSIG);
if (ohandler != SIG_DFL)
signal(SIGTERM, ohandler);
#endif /* HAVE_SIGNAL_H */
/* That's it! */
return (0);
}
void
SDL_QuitQuit(void)
{
#ifdef HAVE_SIGNAL_H
void (*ohandler) (int);
ohandler = signal(SIGINT, SIG_DFL);
if (ohandler != SDL_HandleSIG)
signal(SIGINT, ohandler);
ohandler = signal(SIGTERM, SIG_DFL);
if (ohandler != SDL_HandleSIG)
signal(SIGTERM, ohandler);
#endif /* HAVE_SIGNAL_H */
}
/* This function returns 1 if it's okay to close the application window */
int
SDL_SendQuit(void)
{
int posted;
posted = 0;
if (SDL_GetEventState(SDL_QUIT) == SDL_ENABLE) {
SDL_Event event;
event.type = SDL_QUIT;
posted = (SDL_PushEvent(&event) > 0);
}
return (posted);
}
/* vi: set ts=4 sw=4 expandtab: */

View File

@@ -0,0 +1,36 @@
/*
SDL - Simple DirectMedia Layer
Copyright (C) 1997-2010 Sam Lantinga
This library is SDL_free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
Sam Lantinga
slouken@libsdl.org
*/
#include "SDL_config.h"
#include "../video/SDL_sysvideo.h"
/* Useful functions and variables from SDL_sysevents.c */
#ifdef __BEOS__ /* The Be event loop runs in a separate thread */
#define MUST_THREAD_EVENTS
#endif
#ifdef __WIN32__ /* Win32 doesn't allow a separate event thread */
#define CANT_THREAD_EVENTS
#endif
/* vi: set ts=4 sw=4 expandtab: */

View File

@@ -0,0 +1,568 @@
/*
SDL - Simple DirectMedia Layer
Copyright (C) 1997-2010 Sam Lantinga
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
Sam Lantinga
slouken@libsdl.org
*/
#include "SDL_config.h"
/* General touch handling code for SDL */
#include "SDL_events.h"
#include "SDL_events_c.h"
#include "../video/SDL_sysvideo.h"
#include <stdio.h>
static int SDL_num_touch = 0;
static SDL_Touch **SDL_touchPads = NULL;
/* Public functions */
int
SDL_TouchInit(void)
{
return (0);
}
SDL_Touch *
SDL_GetTouch(SDL_TouchID id)
{
int index = SDL_GetTouchIndexId(id);
if (index < 0 || index >= SDL_num_touch) {
return NULL;
}
return SDL_touchPads[index];
}
SDL_Touch *
SDL_GetTouchIndex(int index)
{
if (index < 0 || index >= SDL_num_touch) {
return NULL;
}
return SDL_touchPads[index];
}
int
SDL_GetFingerIndexId(SDL_Touch* touch,SDL_FingerID fingerid)
{
int i;
for(i = 0;i < touch->num_fingers;i++)
if(touch->fingers[i]->id == fingerid)
return i;
return -1;
}
SDL_Finger *
SDL_GetFinger(SDL_Touch* touch,SDL_FingerID id)
{
int index = SDL_GetFingerIndexId(touch,id);
if(index < 0 || index >= touch->num_fingers)
return NULL;
return touch->fingers[index];
}
int
SDL_GetTouchIndexId(SDL_TouchID id)
{
int index;
SDL_Touch *touch;
for (index = 0; index < SDL_num_touch; ++index) {
touch = SDL_touchPads[index];
if (touch->id == id) {
return index;
}
}
return -1;
}
int
SDL_AddTouch(const SDL_Touch * touch, char *name)
{
SDL_Touch **touchPads;
int index,length;
if (SDL_GetTouchIndexId(touch->id) != -1) {
SDL_SetError("Touch ID already in use");
}
/* Add the touch to the list of touch */
touchPads = (SDL_Touch **) SDL_realloc(SDL_touchPads,
(SDL_num_touch + 1) * sizeof(*touch));
if (!touchPads) {
SDL_OutOfMemory();
return -1;
}
SDL_touchPads = touchPads;
index = SDL_num_touch++;
SDL_touchPads[index] = (SDL_Touch *) SDL_malloc(sizeof(*SDL_touchPads[index]));
if (!SDL_touchPads[index]) {
SDL_OutOfMemory();
return -1;
}
*SDL_touchPads[index] = *touch;
/* we're setting the touch properties */
length = 0;
length = SDL_strlen(name);
SDL_touchPads[index]->focus = 0;
SDL_touchPads[index]->name = SDL_malloc((length + 2) * sizeof(char));
SDL_strlcpy(SDL_touchPads[index]->name, name, length + 1);
SDL_touchPads[index]->num_fingers = 0;
SDL_touchPads[index]->max_fingers = 1;
SDL_touchPads[index]->fingers = (SDL_Finger **) SDL_malloc(sizeof(SDL_Finger*));
SDL_touchPads[index]->fingers[0] = NULL;
SDL_touchPads[index]->buttonstate = 0;
SDL_touchPads[index]->relative_mode = SDL_FALSE;
SDL_touchPads[index]->flush_motion = SDL_FALSE;
SDL_touchPads[index]->xres = (1<<(16-1));
SDL_touchPads[index]->yres = (1<<(16-1));
//Do I want this here? Probably
SDL_GestureAddTouch(SDL_touchPads[index]);
return index;
}
void
SDL_DelTouch(SDL_TouchID id)
{
int index = SDL_GetTouchIndexId(id);
SDL_Touch *touch = SDL_GetTouch(id);
if (!touch) {
return;
}
SDL_free(touch->name);
if (touch->FreeTouch) {
touch->FreeTouch(touch);
}
SDL_free(touch);
SDL_num_touch--;
SDL_touchPads[index] = SDL_touchPads[SDL_num_touch];
}
void
SDL_TouchQuit(void)
{
int i;
for (i = SDL_num_touch-1; i > 0 ; --i) {
SDL_DelTouch(i);
}
SDL_num_touch = 0;
if (SDL_touchPads) {
SDL_free(SDL_touchPads);
SDL_touchPads = NULL;
}
}
int
SDL_GetNumTouch(void)
{
return SDL_num_touch;
}
SDL_Window *
SDL_GetTouchFocusWindow(SDL_TouchID id)
{
SDL_Touch *touch = SDL_GetTouch(id);
if (!touch) {
return 0;
}
return touch->focus;
}
void
SDL_SetTouchFocus(SDL_TouchID id, SDL_Window * window)
{
int index = SDL_GetTouchIndexId(id);
SDL_Touch *touch = SDL_GetTouch(id);
int i;
SDL_bool focus;
if (!touch || (touch->focus == window)) {
return;
}
/* See if the current window has lost focus */
if (touch->focus) {
focus = SDL_FALSE;
for (i = 0; i < SDL_num_touch; ++i) {
SDL_Touch *check;
if (i != index) {
check = SDL_touchPads[i];
if (check && check->focus == touch->focus) {
focus = SDL_TRUE;
break;
}
}
}
if (!focus) {
SDL_SendWindowEvent(touch->focus, SDL_WINDOWEVENT_LEAVE, 0, 0);
}
}
touch->focus = window;
if (touch->focus) {
focus = SDL_FALSE;
for (i = 0; i < SDL_num_touch; ++i) {
SDL_Touch *check;
if (i != index) {
check = SDL_touchPads[i];
if (check && check->focus == touch->focus) {
focus = SDL_TRUE;
break;
}
}
}
if (!focus) {
SDL_SendWindowEvent(touch->focus, SDL_WINDOWEVENT_ENTER, 0, 0);
}
}
}
int
SDL_AddFinger(SDL_Touch* touch,SDL_Finger *finger)
{
int index;
SDL_Finger **fingers;
//printf("Adding Finger...\n");
if (SDL_GetFingerIndexId(touch,finger->id) != -1) {
SDL_SetError("Finger ID already in use");
}
/* Add the touch to the list of touch */
if(touch->num_fingers >= touch->max_fingers){
//printf("Making room for it!\n");
fingers = (SDL_Finger **) SDL_realloc(touch->fingers,
(touch->num_fingers + 1) * sizeof(SDL_Finger *));
touch->max_fingers = touch->num_fingers+1;
if (!fingers) {
SDL_OutOfMemory();
return -1;
} else {
touch->max_fingers = touch->num_fingers+1;
touch->fingers = fingers;
}
}
index = touch->num_fingers;
//printf("Max_Fingers: %i Index: %i\n",touch->max_fingers,index);
touch->fingers[index] = (SDL_Finger *) SDL_malloc(sizeof(SDL_Finger));
if (!touch->fingers[index]) {
SDL_OutOfMemory();
return -1;
}
*(touch->fingers[index]) = *finger;
touch->num_fingers++;
return index;
}
int
SDL_DelFinger(SDL_Touch* touch,SDL_FingerID fingerid)
{
int index = SDL_GetFingerIndexId(touch,fingerid);
SDL_Finger* finger = SDL_GetFinger(touch,fingerid);
if (!finger) {
return -1;
}
SDL_free(finger);
touch->num_fingers--;
touch->fingers[index] = touch->fingers[touch->num_fingers];
return 0;
}
int
SDL_SendFingerDown(SDL_TouchID id, SDL_FingerID fingerid, SDL_bool down,
float xin, float yin, float pressurein)
{
int posted;
Uint16 x;
Uint16 y;
Uint16 pressure;
SDL_Finger *finger;
SDL_Touch* touch = SDL_GetTouch(id);
if(!touch) {
return SDL_TouchNotFoundError(id);
}
//scale to Integer coordinates
x = (Uint16)((xin+touch->x_min)*(touch->xres)/(touch->native_xres));
y = (Uint16)((yin+touch->y_min)*(touch->yres)/(touch->native_yres));
pressure = (Uint16)((yin+touch->pressure_min)*(touch->pressureres)/(touch->native_pressureres));
finger = SDL_GetFinger(touch,fingerid);
if(down) {
if(finger == NULL) {
SDL_Finger nf;
nf.id = fingerid;
nf.x = x;
nf.y = y;
nf.pressure = pressure;
nf.xdelta = 0;
nf.ydelta = 0;
nf.last_x = x;
nf.last_y = y;
nf.last_pressure = pressure;
nf.down = SDL_FALSE;
if(SDL_AddFinger(touch,&nf) < 0) return 0;
finger = SDL_GetFinger(touch,fingerid);
}
else if(finger->down) return 0;
if(xin < touch->x_min || yin < touch->y_min) return 0; //should defer if only a partial input
posted = 0;
if (SDL_GetEventState(SDL_FINGERDOWN) == SDL_ENABLE) {
SDL_Event event;
event.tfinger.type = SDL_FINGERDOWN;
event.tfinger.touchId = id;
event.tfinger.x = x;
event.tfinger.y = y;
event.tfinger.pressure = pressure;
event.tfinger.state = touch->buttonstate;
event.tfinger.windowID = touch->focus ? touch->focus->id : 0;
event.tfinger.fingerId = fingerid;
posted = (SDL_PushEvent(&event) > 0);
}
if(posted) finger->down = SDL_TRUE;
return posted;
}
else {
if(finger == NULL) {
SDL_SetError("Finger not found.");
return 0;
}
posted = 0;
if (SDL_GetEventState(SDL_FINGERUP) == SDL_ENABLE) {
SDL_Event event;
event.tfinger.type = SDL_FINGERUP;
event.tfinger.touchId = id;
event.tfinger.state = touch->buttonstate;
event.tfinger.windowID = touch->focus ? touch->focus->id : 0;
event.tfinger.fingerId = fingerid;
//I don't trust the coordinates passed on fingerUp
event.tfinger.x = finger->x;
event.tfinger.y = finger->y;
event.tfinger.dx = 0;
event.tfinger.dy = 0;
if(SDL_DelFinger(touch,fingerid) < 0) return 0;
posted = (SDL_PushEvent(&event) > 0);
}
return posted;
}
}
int
SDL_SendTouchMotion(SDL_TouchID id, SDL_FingerID fingerid, int relative,
float xin, float yin, float pressurein)
{
int index = SDL_GetTouchIndexId(id);
SDL_Touch *touch = SDL_GetTouch(id);
SDL_Finger *finger = SDL_GetFinger(touch,fingerid);
int posted;
Sint16 xrel, yrel;
float x_max = 0, y_max = 0;
Uint16 x;
Uint16 y;
Uint16 pressure;
if (!touch) {
return SDL_TouchNotFoundError(id);
}
//scale to Integer coordinates
x = (Uint16)((xin+touch->x_min)*(touch->xres)/(touch->native_xres));
y = (Uint16)((yin+touch->y_min)*(touch->yres)/(touch->native_yres));
pressure = (Uint16)((yin+touch->pressure_min)*(touch->pressureres)/(touch->native_pressureres));
if(touch->flush_motion) {
return 0;
}
if(finger == NULL || !finger->down) {
return SDL_SendFingerDown(id,fingerid,SDL_TRUE,xin,yin,pressurein);
} else {
/* the relative motion is calculated regarding the last position */
if (relative) {
xrel = x;
yrel = y;
x = (finger->last_x + x);
y = (finger->last_y + y);
} else {
if(xin < touch->x_min) x = finger->last_x; /*If movement is only in one axis,*/
if(yin < touch->y_min) y = finger->last_y; /*The other is marked as -1*/
if(pressurein < touch->pressure_min) pressure = finger->last_pressure;
xrel = x - finger->last_x;
yrel = y - finger->last_y;
//printf("xrel,yrel (%i,%i)\n",(int)xrel,(int)yrel);
}
/* Drop events that don't change state */
if (!xrel && !yrel) {
#if 0
printf("Touch event didn't change state - dropped!\n");
#endif
return 0;
}
/* Update internal touch coordinates */
finger->x = x;
finger->y = y;
/*Should scale to window? Normalize? Maintain Aspect?*/
//SDL_GetWindowSize(touch->focus, &x_max, &y_max);
/* make sure that the pointers find themselves inside the windows */
/* only check if touch->xmax is set ! */
/*
if (x_max && touch->x > x_max) {
touch->x = x_max;
} else if (touch->x < 0) {
touch->x = 0;
}
if (y_max && touch->y > y_max) {
touch->y = y_max;
} else if (touch->y < 0) {
touch->y = 0;
}
*/
finger->xdelta = xrel;
finger->ydelta = yrel;
finger->pressure = pressure;
/* Post the event, if desired */
posted = 0;
if (SDL_GetEventState(SDL_FINGERMOTION) == SDL_ENABLE) {
SDL_Event event;
event.tfinger.type = SDL_FINGERMOTION;
event.tfinger.touchId = id;
event.tfinger.fingerId = fingerid;
event.tfinger.x = x;
event.tfinger.y = y;
event.tfinger.dx = xrel;
event.tfinger.dy = yrel;
event.tfinger.pressure = pressure;
event.tfinger.state = touch->buttonstate;
event.tfinger.windowID = touch->focus ? touch->focus->id : 0;
posted = (SDL_PushEvent(&event) > 0);
}
finger->last_x = finger->x;
finger->last_y = finger->y;
finger->last_pressure = finger->pressure;
return posted;
}
}
int
SDL_SendTouchButton(SDL_TouchID id, Uint8 state, Uint8 button)
{
SDL_Touch *touch = SDL_GetTouch(id);
int posted;
Uint32 type;
if (!touch) {
return SDL_TouchNotFoundError(id);
}
/* Figure out which event to perform */
switch (state) {
case SDL_PRESSED:
if (touch->buttonstate & SDL_BUTTON(button)) {
/* Ignore this event, no state change */
return 0;
}
type = SDL_TOUCHBUTTONDOWN;
touch->buttonstate |= SDL_BUTTON(button);
break;
case SDL_RELEASED:
if (!(touch->buttonstate & SDL_BUTTON(button))) {
/* Ignore this event, no state change */
return 0;
}
type = SDL_TOUCHBUTTONUP;
touch->buttonstate &= ~SDL_BUTTON(button);
break;
default:
/* Invalid state -- bail */
return 0;
}
/* Post the event, if desired */
posted = 0;
if (SDL_GetEventState(type) == SDL_ENABLE) {
SDL_Event event;
event.type = type;
event.tbutton.touchId = touch->id;
event.tbutton.state = state;
event.tbutton.button = button;
event.tbutton.windowID = touch->focus ? touch->focus->id : 0;
posted = (SDL_PushEvent(&event) > 0);
}
return posted;
}
char *
SDL_GetTouchName(SDL_TouchID id)
{
SDL_Touch *touch = SDL_GetTouch(id);
if (!touch) {
return NULL;
}
return touch->name;
}
int SDL_TouchNotFoundError(SDL_TouchID id) {
//int i;
SDL_SetError("ERROR: Cannot send touch on non-existent device with id: %li make sure SDL_AddTouch has been called\n",id);
#if 0
printf("ERROR: There are %i touches installed with Id's:\n",SDL_num_touch);
for(i=0;i < SDL_num_touch;i++) {
printf("ERROR: %li\n",SDL_touchPads[i]->id);
}
#endif
return 0;
}
/* vi: set ts=4 sw=4 expandtab: */

View File

@@ -0,0 +1,79 @@
/*
SDL - Simple DirectMedia Layer
Copyright (C) 1997-2010 Sam Lantinga
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
Sam Lantinga
slouken@libsdl.org
*/
#include "SDL_config.h"
#include "../../include/SDL_touch.h"
#ifndef _SDL_touch_c_h
#define _SDL_touch_c_h
/* Initialize the touch subsystem */
extern int SDL_TouchInit(void);
/*Get the touch at an index */
extern SDL_Touch *SDL_GetTouchIndex(int index);
/* Get the touch with id = id */
extern SDL_Touch *SDL_GetTouch(SDL_TouchID id);
/*Get the finger at an index */
extern SDL_Finger *SDL_GetFingerIndex(SDL_Touch *touch, int index);
/* Get the finger with id = id */
extern SDL_Finger *SDL_GetFinger(SDL_Touch *touch,SDL_FingerID id);
/* Add a touch, possibly reattaching at a particular index (or -1),
returning the index of the touch, or -1 if there was an error. */
extern int SDL_AddTouch(const SDL_Touch * touch, char *name);
/* Remove a touch at an index, clearing the slot for later */
extern void SDL_DelTouch(SDL_TouchID id);
/* Set the touch focus window */
extern void SDL_SetTouchFocus(SDL_TouchID id, SDL_Window * window);
/* Send a touch motion event for a touch */
extern int SDL_SendTouchMotion(SDL_TouchID id, SDL_FingerID fingerid,
int relative, float x, float y, float z);
/* Send a touch down/up event for a touch */
extern int SDL_SendFingerDown(SDL_TouchID id, SDL_FingerID fingerid,
SDL_bool down, float x, float y, float pressure);
/* Send a touch button event for a touch */
extern int SDL_SendTouchButton(SDL_TouchID id, Uint8 state, Uint8 button);
/* Shutdown the touch subsystem */
extern void SDL_TouchQuit(void);
/* Get the index of a touch device */
extern int SDL_GetTouchIndexId(SDL_TouchID id);
/* Print a debug message for a nonexistent touch */
extern int SDL_TouchNotFoundError(SDL_TouchID id);
#endif /* _SDL_touch_c_h */
/* vi: set ts=4 sw=4 expandtab: */

View File

@@ -0,0 +1,165 @@
/*
SDL - Simple DirectMedia Layer
Copyright (C) 1997-2010 Sam Lantinga
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
Sam Lantinga
slouken@libsdl.org
*/
#include "SDL_config.h"
/* Window event handling code for SDL */
#include "SDL_events.h"
#include "SDL_events_c.h"
#include "SDL_mouse_c.h"
#include "../video/SDL_sysvideo.h"
static int
RemovePendingSizeEvents(void * userdata, SDL_Event *event)
{
SDL_Event *new_event = (SDL_Event *)userdata;
if (event->type == SDL_WINDOWEVENT &&
event->window.event == SDL_WINDOWEVENT_RESIZED &&
event->window.windowID == new_event->window.windowID) {
/* We're about to post a new size event, drop the old one */
return 0;
}
return 1;
}
int
SDL_SendWindowEvent(SDL_Window * window, Uint8 windowevent, int data1,
int data2)
{
int posted;
if (!window) {
return 0;
}
switch (windowevent) {
case SDL_WINDOWEVENT_SHOWN:
if (window->flags & SDL_WINDOW_SHOWN) {
return 0;
}
window->flags |= SDL_WINDOW_SHOWN;
SDL_OnWindowShown(window);
break;
case SDL_WINDOWEVENT_HIDDEN:
if (!(window->flags & SDL_WINDOW_SHOWN)) {
return 0;
}
window->flags &= ~SDL_WINDOW_SHOWN;
SDL_OnWindowHidden(window);
break;
case SDL_WINDOWEVENT_MOVED:
if (window->flags & SDL_WINDOW_FULLSCREEN) {
return 0;
}
if (data1 == SDL_WINDOWPOS_UNDEFINED) {
data1 = window->x;
}
if (data2 == SDL_WINDOWPOS_UNDEFINED) {
data2 = window->y;
}
if (data1 == window->x && data2 == window->y) {
return 0;
}
window->x = data1;
window->y = data2;
break;
case SDL_WINDOWEVENT_RESIZED:
if (window->flags & SDL_WINDOW_FULLSCREEN) {
return 0;
}
if (data1 == window->w && data2 == window->h) {
return 0;
}
window->w = data1;
window->h = data2;
SDL_OnWindowResized(window);
break;
case SDL_WINDOWEVENT_MINIMIZED:
if (window->flags & SDL_WINDOW_MINIMIZED) {
return 0;
}
window->flags |= SDL_WINDOW_MINIMIZED;
SDL_OnWindowMinimized(window);
break;
case SDL_WINDOWEVENT_MAXIMIZED:
if (window->flags & SDL_WINDOW_MAXIMIZED) {
return 0;
}
window->flags |= SDL_WINDOW_MAXIMIZED;
break;
case SDL_WINDOWEVENT_RESTORED:
if (!(window->flags & (SDL_WINDOW_MINIMIZED | SDL_WINDOW_MAXIMIZED))) {
return 0;
}
window->flags &= ~(SDL_WINDOW_MINIMIZED | SDL_WINDOW_MAXIMIZED);
SDL_OnWindowRestored(window);
break;
case SDL_WINDOWEVENT_ENTER:
if (window->flags & SDL_WINDOW_MOUSE_FOCUS) {
return 0;
}
window->flags |= SDL_WINDOW_MOUSE_FOCUS;
break;
case SDL_WINDOWEVENT_LEAVE:
if (!(window->flags & SDL_WINDOW_MOUSE_FOCUS)) {
return 0;
}
window->flags &= ~SDL_WINDOW_MOUSE_FOCUS;
break;
case SDL_WINDOWEVENT_FOCUS_GAINED:
if (window->flags & SDL_WINDOW_INPUT_FOCUS) {
return 0;
}
window->flags |= SDL_WINDOW_INPUT_FOCUS;
SDL_OnWindowFocusGained(window);
break;
case SDL_WINDOWEVENT_FOCUS_LOST:
if (!(window->flags & SDL_WINDOW_INPUT_FOCUS)) {
return 0;
}
window->flags &= ~SDL_WINDOW_INPUT_FOCUS;
SDL_OnWindowFocusLost(window);
break;
}
/* Post the event, if desired */
posted = 0;
if (SDL_GetEventState(SDL_WINDOWEVENT) == SDL_ENABLE) {
SDL_Event event;
event.type = SDL_WINDOWEVENT;
event.window.event = windowevent;
event.window.data1 = data1;
event.window.data2 = data2;
event.window.windowID = window->id;
/* Fixes queue overflow with resize events that aren't processed */
if (windowevent == SDL_WINDOWEVENT_RESIZED) {
SDL_FilterEvents(RemovePendingSizeEvents, &event);
}
posted = (SDL_PushEvent(&event) > 0);
}
return (posted);
}
/* vi: set ts=4 sw=4 expandtab: */

View File

@@ -0,0 +1,32 @@
/*
SDL - Simple DirectMedia Layer
Copyright (C) 1997-2010 Sam Lantinga
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
Sam Lantinga
slouken@libsdl.org
*/
#include "SDL_config.h"
#ifndef _SDL_windowevents_c_h
#define _SDL_windowevents_c_h
extern int SDL_SendWindowEvent(SDL_Window * window, Uint8 windowevent,
int data1, int data2);
#endif /* _SDL_windowevents_c_h */
/* vi: set ts=4 sw=4 expandtab: */

View File

@@ -0,0 +1,34 @@
/*
SDL - Simple DirectMedia Layer
Copyright (C) 1997-2010 Sam Lantinga
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
Sam Lantinga
slouken@libsdl.org
*/
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* A default blank 8x8 cursor */
#define BLANK_CWIDTH 8
#define BLANK_CHEIGHT 8
#define BLANK_CHOTX 0
#define BLANK_CHOTY 0
static const unsigned char blank_cdata[8] = { 0, 0, 0, 0, 0, 0, 0, 0 };
static const unsigned char blank_cmask[8] = { 0, 0, 0, 0, 0, 0, 0, 0 };
/* vi: set ts=4 sw=4 expandtab: */

View File

@@ -0,0 +1,115 @@
/*
SDL - Simple DirectMedia Layer
Copyright (C) 1997-2010 Sam Lantinga
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
Sam Lantinga
slouken@libsdl.org
*/
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* Default cursor - it happens to be the Mac cursor, but could be anything */
#define DEFAULT_CWIDTH 16
#define DEFAULT_CHEIGHT 16
#define DEFAULT_CHOTX 0
#define DEFAULT_CHOTY 0
/* Added a real MacOS cursor, at the request of Luc-Olivier de Charrière */
#define USE_MACOS_CURSOR
#ifdef USE_MACOS_CURSOR
static const unsigned char default_cdata[] = {
0x00, 0x00,
0x40, 0x00,
0x60, 0x00,
0x70, 0x00,
0x78, 0x00,
0x7C, 0x00,
0x7E, 0x00,
0x7F, 0x00,
0x7F, 0x80,
0x7C, 0x00,
0x6C, 0x00,
0x46, 0x00,
0x06, 0x00,
0x03, 0x00,
0x03, 0x00,
0x00, 0x00
};
static const unsigned char default_cmask[] = {
0xC0, 0x00,
0xE0, 0x00,
0xF0, 0x00,
0xF8, 0x00,
0xFC, 0x00,
0xFE, 0x00,
0xFF, 0x00,
0xFF, 0x80,
0xFF, 0xC0,
0xFF, 0xE0,
0xFE, 0x00,
0xEF, 0x00,
0xCF, 0x00,
0x87, 0x80,
0x07, 0x80,
0x03, 0x00
};
#else
static const unsigned char default_cdata[] = {
0x00, 0x00,
0x40, 0x00,
0x60, 0x00,
0x70, 0x00,
0x78, 0x00,
0x7C, 0x00,
0x7E, 0x00,
0x7F, 0x00,
0x7F, 0x80,
0x7C, 0x00,
0x6C, 0x00,
0x46, 0x00,
0x06, 0x00,
0x03, 0x00,
0x03, 0x00,
0x00, 0x00
};
static const unsigned char default_cmask[] = {
0x40, 0x00,
0xE0, 0x00,
0xF0, 0x00,
0xF8, 0x00,
0xFC, 0x00,
0xFE, 0x00,
0xFF, 0x00,
0xFF, 0x80,
0xFF, 0xC0,
0xFF, 0x80,
0xFE, 0x00,
0xEF, 0x00,
0x4F, 0x00,
0x07, 0x80,
0x07, 0x80,
0x03, 0x00
};
#endif /* TRUE_MACINTOSH_CURSOR */
/* vi: set ts=4 sw=4 expandtab: */

View File

@@ -0,0 +1,160 @@
/*
SDL - Simple DirectMedia Layer
Copyright (C) 1997-2010 Sam Lantinga
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
Sam Lantinga
slouken@libsdl.org
*/
/* Mac virtual key code to SDL scancode mapping table
Sources:
- Inside Macintosh: Text <http://developer.apple.com/documentation/mac/Text/Text-571.html>
- Apple USB keyboard driver source <http://darwinsource.opendarwin.org/10.4.6.ppc/IOHIDFamily-172.8/IOHIDFamily/Cosmo_USB2ADB.c>
- experimentation on various ADB and USB ISO keyboards and one ADB ANSI keyboard
*/
/* *INDENT-OFF* */
static const SDL_scancode darwin_scancode_table[] = {
/* 0 */ SDL_SCANCODE_A,
/* 1 */ SDL_SCANCODE_S,
/* 2 */ SDL_SCANCODE_D,
/* 3 */ SDL_SCANCODE_F,
/* 4 */ SDL_SCANCODE_H,
/* 5 */ SDL_SCANCODE_G,
/* 6 */ SDL_SCANCODE_Z,
/* 7 */ SDL_SCANCODE_X,
/* 8 */ SDL_SCANCODE_C,
/* 9 */ SDL_SCANCODE_V,
/* 10 */ SDL_SCANCODE_NONUSBACKSLASH, /* SDL_SCANCODE_NONUSBACKSLASH on ANSI and JIS keyboards (if this key would exist there), SDL_SCANCODE_GRAVE on ISO. (The USB keyboard driver actually translates these usage codes to different virtual key codes depending on whether the keyboard is ISO/ANSI/JIS. That's why you have to help it identify the keyboard type when you plug in a PC USB keyboard. It's a historical thing - ADB keyboards are wired this way.) */
/* 11 */ SDL_SCANCODE_B,
/* 12 */ SDL_SCANCODE_Q,
/* 13 */ SDL_SCANCODE_W,
/* 14 */ SDL_SCANCODE_E,
/* 15 */ SDL_SCANCODE_R,
/* 16 */ SDL_SCANCODE_Y,
/* 17 */ SDL_SCANCODE_T,
/* 18 */ SDL_SCANCODE_1,
/* 19 */ SDL_SCANCODE_2,
/* 20 */ SDL_SCANCODE_3,
/* 21 */ SDL_SCANCODE_4,
/* 22 */ SDL_SCANCODE_6,
/* 23 */ SDL_SCANCODE_5,
/* 24 */ SDL_SCANCODE_EQUALS,
/* 25 */ SDL_SCANCODE_9,
/* 26 */ SDL_SCANCODE_7,
/* 27 */ SDL_SCANCODE_MINUS,
/* 28 */ SDL_SCANCODE_8,
/* 29 */ SDL_SCANCODE_0,
/* 30 */ SDL_SCANCODE_RIGHTBRACKET,
/* 31 */ SDL_SCANCODE_O,
/* 32 */ SDL_SCANCODE_U,
/* 33 */ SDL_SCANCODE_LEFTBRACKET,
/* 34 */ SDL_SCANCODE_I,
/* 35 */ SDL_SCANCODE_P,
/* 36 */ SDL_SCANCODE_RETURN,
/* 37 */ SDL_SCANCODE_L,
/* 38 */ SDL_SCANCODE_J,
/* 39 */ SDL_SCANCODE_APOSTROPHE,
/* 40 */ SDL_SCANCODE_K,
/* 41 */ SDL_SCANCODE_SEMICOLON,
/* 42 */ SDL_SCANCODE_BACKSLASH,
/* 43 */ SDL_SCANCODE_COMMA,
/* 44 */ SDL_SCANCODE_SLASH,
/* 45 */ SDL_SCANCODE_N,
/* 46 */ SDL_SCANCODE_M,
/* 47 */ SDL_SCANCODE_PERIOD,
/* 48 */ SDL_SCANCODE_TAB,
/* 49 */ SDL_SCANCODE_SPACE,
/* 50 */ SDL_SCANCODE_GRAVE, /* SDL_SCANCODE_GRAVE on ANSI and JIS keyboards, SDL_SCANCODE_NONUSBACKSLASH on ISO (see comment about virtual key code 10 above) */
/* 51 */ SDL_SCANCODE_BACKSPACE,
/* 52 */ SDL_SCANCODE_KP_ENTER, /* keyboard enter on portables */
/* 53 */ SDL_SCANCODE_ESCAPE,
/* 54 */ SDL_SCANCODE_RGUI,
/* 55 */ SDL_SCANCODE_LGUI,
/* 56 */ SDL_SCANCODE_LSHIFT,
/* 57 */ SDL_SCANCODE_CAPSLOCK,
/* 58 */ SDL_SCANCODE_LALT,
/* 59 */ SDL_SCANCODE_LCTRL,
/* 60 */ SDL_SCANCODE_RSHIFT,
/* 61 */ SDL_SCANCODE_RALT,
/* 62 */ SDL_SCANCODE_RCTRL,
/* 63 */ SDL_SCANCODE_RGUI, /* fn on portables, acts as a hardware-level modifier already, so we don't generate events for it, also XK_Meta_R */
/* 64 */ SDL_SCANCODE_UNKNOWN, /* unknown (unused?) */
/* 65 */ SDL_SCANCODE_KP_PERIOD,
/* 66 */ SDL_SCANCODE_UNKNOWN, /* unknown (unused?) */
/* 67 */ SDL_SCANCODE_KP_MULTIPLY,
/* 68 */ SDL_SCANCODE_UNKNOWN, /* unknown (unused?) */
/* 69 */ SDL_SCANCODE_KP_PLUS,
/* 70 */ SDL_SCANCODE_UNKNOWN, /* unknown (unused?) */
/* 71 */ SDL_SCANCODE_NUMLOCKCLEAR,
/* 72 */ SDL_SCANCODE_VOLUMEUP,
/* 73 */ SDL_SCANCODE_VOLUMEDOWN,
/* 74 */ SDL_SCANCODE_MUTE,
/* 75 */ SDL_SCANCODE_KP_DIVIDE,
/* 76 */ SDL_SCANCODE_KP_ENTER, /* keypad enter on external keyboards, fn-return on portables */
/* 77 */ SDL_SCANCODE_UNKNOWN, /* unknown (unused?) */
/* 78 */ SDL_SCANCODE_KP_MINUS,
/* 79 */ SDL_SCANCODE_UNKNOWN, /* unknown (unused?) */
/* 80 */ SDL_SCANCODE_UNKNOWN, /* unknown (unused?) */
/* 81 */ SDL_SCANCODE_KP_EQUALS,
/* 82 */ SDL_SCANCODE_KP_0,
/* 83 */ SDL_SCANCODE_KP_1,
/* 84 */ SDL_SCANCODE_KP_2,
/* 85 */ SDL_SCANCODE_KP_3,
/* 86 */ SDL_SCANCODE_KP_4,
/* 87 */ SDL_SCANCODE_KP_5,
/* 88 */ SDL_SCANCODE_KP_6,
/* 89 */ SDL_SCANCODE_KP_7,
/* 90 */ SDL_SCANCODE_UNKNOWN, /* unknown (unused?) */
/* 91 */ SDL_SCANCODE_KP_8,
/* 92 */ SDL_SCANCODE_KP_9,
/* 93 */ SDL_SCANCODE_INTERNATIONAL3, /* Cosmo_USB2ADB.c says "Yen (JIS)" */
/* 94 */ SDL_SCANCODE_INTERNATIONAL1, /* Cosmo_USB2ADB.c says "Ro (JIS)" */
/* 95 */ SDL_SCANCODE_KP_COMMA, /* Cosmo_USB2ADB.c says ", JIS only" */
/* 96 */ SDL_SCANCODE_F5,
/* 97 */ SDL_SCANCODE_F6,
/* 98 */ SDL_SCANCODE_F7,
/* 99 */ SDL_SCANCODE_F3,
/* 100 */ SDL_SCANCODE_F8,
/* 101 */ SDL_SCANCODE_F9,
/* 102 */ SDL_SCANCODE_LANG2, /* Cosmo_USB2ADB.c says "Eisu" */
/* 103 */ SDL_SCANCODE_F11,
/* 104 */ SDL_SCANCODE_LANG1, /* Cosmo_USB2ADB.c says "Kana" */
/* 105 */ SDL_SCANCODE_PRINTSCREEN, /* On ADB keyboards, this key is labeled "F13/print screen". Problem: USB has different usage codes for these two functions. On Apple USB keyboards, the key is labeled "F13" and sends the F13 usage code (SDL_SCANCODE_F13). I decided to use SDL_SCANCODE_PRINTSCREEN here nevertheless since SDL applications are more likely to assume the presence of a print screen key than an F13 key. */
/* 106 */ SDL_SCANCODE_F16,
/* 107 */ SDL_SCANCODE_SCROLLLOCK, /* F14/scroll lock, see comment about F13/print screen above */
/* 108 */ SDL_SCANCODE_UNKNOWN, /* unknown (unused?) */
/* 109 */ SDL_SCANCODE_F10,
/* 110 */ SDL_SCANCODE_APPLICATION, /* windows contextual menu key, fn-enter on portables */
/* 111 */ SDL_SCANCODE_F12,
/* 112 */ SDL_SCANCODE_UNKNOWN, /* unknown (unused?) */
/* 113 */ SDL_SCANCODE_PAUSE, /* F15/pause, see comment about F13/print screen above */
/* 114 */ SDL_SCANCODE_INSERT, /* the key is actually labeled "help" on Apple keyboards, and works as such in Mac OS, but it sends the "insert" usage code even on Apple USB keyboards */
/* 115 */ SDL_SCANCODE_HOME,
/* 116 */ SDL_SCANCODE_PAGEUP,
/* 117 */ SDL_SCANCODE_DELETE,
/* 118 */ SDL_SCANCODE_F4,
/* 119 */ SDL_SCANCODE_END,
/* 120 */ SDL_SCANCODE_F2,
/* 121 */ SDL_SCANCODE_PAGEDOWN,
/* 122 */ SDL_SCANCODE_F1,
/* 123 */ SDL_SCANCODE_LEFT,
/* 124 */ SDL_SCANCODE_RIGHT,
/* 125 */ SDL_SCANCODE_DOWN,
/* 126 */ SDL_SCANCODE_UP,
/* 127 */ SDL_SCANCODE_POWER
};
/* *INDENT-ON* */

View File

@@ -0,0 +1,264 @@
/*
SDL - Simple DirectMedia Layer
Copyright (C) 1997-2010 Sam Lantinga
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
Sam Lantinga
slouken@libsdl.org
*/
#include "../../include/SDL_scancode.h"
/* Linux virtual key code to SDLKey mapping table
Sources:
- Linux kernel source input.h
*/
/* *INDENT-OFF* */
static SDL_scancode const linux_scancode_table[] = {
/* 0 */ SDL_SCANCODE_UNKNOWN,
/* 1 */ SDL_SCANCODE_ESCAPE,
/* 2 */ SDL_SCANCODE_1,
/* 3 */ SDL_SCANCODE_2,
/* 4 */ SDL_SCANCODE_3,
/* 5 */ SDL_SCANCODE_4,
/* 6 */ SDL_SCANCODE_5,
/* 7 */ SDL_SCANCODE_6,
/* 8 */ SDL_SCANCODE_7,
/* 9 */ SDL_SCANCODE_8,
/* 10 */ SDL_SCANCODE_9,
/* 11 */ SDL_SCANCODE_0,
/* 12 */ SDL_SCANCODE_MINUS,
/* 13 */ SDL_SCANCODE_EQUALS,
/* 14 */ SDL_SCANCODE_BACKSPACE,
/* 15 */ SDL_SCANCODE_TAB,
/* 16 */ SDL_SCANCODE_Q,
/* 17 */ SDL_SCANCODE_W,
/* 18 */ SDL_SCANCODE_E,
/* 19 */ SDL_SCANCODE_R,
/* 20 */ SDL_SCANCODE_T,
/* 21 */ SDL_SCANCODE_Y,
/* 22 */ SDL_SCANCODE_U,
/* 23 */ SDL_SCANCODE_I,
/* 24 */ SDL_SCANCODE_O,
/* 25 */ SDL_SCANCODE_P,
/* 26 */ SDL_SCANCODE_LEFTBRACKET,
/* 27 */ SDL_SCANCODE_RIGHTBRACKET,
/* 28 */ SDL_SCANCODE_RETURN,
/* 29 */ SDL_SCANCODE_LCTRL,
/* 30 */ SDL_SCANCODE_A,
/* 31 */ SDL_SCANCODE_S,
/* 32 */ SDL_SCANCODE_D,
/* 33 */ SDL_SCANCODE_F,
/* 34 */ SDL_SCANCODE_G,
/* 35 */ SDL_SCANCODE_H,
/* 36 */ SDL_SCANCODE_J,
/* 37 */ SDL_SCANCODE_K,
/* 38 */ SDL_SCANCODE_L,
/* 39 */ SDL_SCANCODE_SEMICOLON,
/* 40 */ SDL_SCANCODE_APOSTROPHE,
/* 41 */ SDL_SCANCODE_GRAVE,
/* 42 */ SDL_SCANCODE_LSHIFT,
/* 43 */ SDL_SCANCODE_BACKSLASH,
/* 44 */ SDL_SCANCODE_Z,
/* 45 */ SDL_SCANCODE_X,
/* 46 */ SDL_SCANCODE_C,
/* 47 */ SDL_SCANCODE_V,
/* 48 */ SDL_SCANCODE_B,
/* 49 */ SDL_SCANCODE_N,
/* 50 */ SDL_SCANCODE_M,
/* 51 */ SDL_SCANCODE_COMMA,
/* 52 */ SDL_SCANCODE_PERIOD,
/* 53 */ SDL_SCANCODE_SLASH,
/* 54 */ SDL_SCANCODE_RSHIFT,
/* 55 */ SDL_SCANCODE_KP_MULTIPLY,
/* 56 */ SDL_SCANCODE_LALT,
/* 57 */ SDL_SCANCODE_SPACE,
/* 58 */ SDL_SCANCODE_CAPSLOCK,
/* 59 */ SDL_SCANCODE_F1,
/* 60 */ SDL_SCANCODE_F2,
/* 61 */ SDL_SCANCODE_F3,
/* 62 */ SDL_SCANCODE_F4,
/* 63 */ SDL_SCANCODE_F5,
/* 64 */ SDL_SCANCODE_F6,
/* 65 */ SDL_SCANCODE_F7,
/* 66 */ SDL_SCANCODE_F8,
/* 67 */ SDL_SCANCODE_F9,
/* 68 */ SDL_SCANCODE_F10,
/* 69 */ SDL_SCANCODE_NUMLOCKCLEAR,
/* 70 */ SDL_SCANCODE_SCROLLLOCK,
/* 71 */ SDL_SCANCODE_KP_7,
/* 72 */ SDL_SCANCODE_KP_8,
/* 73 */ SDL_SCANCODE_KP_9,
/* 74 */ SDL_SCANCODE_KP_MINUS,
/* 75 */ SDL_SCANCODE_KP_4,
/* 76 */ SDL_SCANCODE_KP_5,
/* 77 */ SDL_SCANCODE_KP_6,
/* 78 */ SDL_SCANCODE_KP_PLUS,
/* 79 */ SDL_SCANCODE_KP_1,
/* 80 */ SDL_SCANCODE_KP_2,
/* 81 */ SDL_SCANCODE_KP_3,
/* 82 */ SDL_SCANCODE_KP_0,
/* 83 */ SDL_SCANCODE_KP_PERIOD,
0,
/* 85 */ SDL_SCANCODE_UNKNOWN, /* KEY_ZENKAKUHANKAKU */
/* 86 */ SDL_SCANCODE_NONUSBACKSLASH, /* KEY_102ND */
/* 87 */ SDL_SCANCODE_F11,
/* 88 */ SDL_SCANCODE_F12,
/* 89 */ SDL_SCANCODE_INTERNATIONAL1, /* KEY_RO */
/* 90 */ SDL_SCANCODE_LANG3, /* KEY_KATAKANA */
/* 91 */ SDL_SCANCODE_LANG4, /* KEY_HIRAGANA */
/* 92 */ SDL_SCANCODE_INTERNATIONAL4, /* KEY_HENKAN */
/* 93 */ SDL_SCANCODE_INTERNATIONAL2, /* KEY_KATAKANAHIRAGANA */
/* 94 */ SDL_SCANCODE_INTERNATIONAL5, /* KEY_MUHENKAN */
/* 95 */ SDL_SCANCODE_INTERNATIONAL5, /* KEY_KPJPCOMMA */
/* 96 */ SDL_SCANCODE_KP_ENTER,
/* 97 */ SDL_SCANCODE_RCTRL,
/* 98 */ SDL_SCANCODE_KP_DIVIDE,
/* 99 */ SDL_SCANCODE_SYSREQ,
/* 100 */ SDL_SCANCODE_RALT,
/* 101 */ SDL_SCANCODE_UNKNOWN, /* KEY_LINEFEED */
/* 102 */ SDL_SCANCODE_HOME,
/* 103 */ SDL_SCANCODE_UP,
/* 104 */ SDL_SCANCODE_PAGEUP,
/* 105 */ SDL_SCANCODE_LEFT,
/* 106 */ SDL_SCANCODE_RIGHT,
/* 107 */ SDL_SCANCODE_END,
/* 108 */ SDL_SCANCODE_DOWN,
/* 109 */ SDL_SCANCODE_PAGEDOWN,
/* 110 */ SDL_SCANCODE_INSERT,
/* 111 */ SDL_SCANCODE_DELETE,
/* 112 */ SDL_SCANCODE_UNKNOWN, /* KEY_MACRO */
/* 113 */ SDL_SCANCODE_MUTE,
/* 114 */ SDL_SCANCODE_VOLUMEDOWN,
/* 115 */ SDL_SCANCODE_VOLUMEUP,
/* 116 */ SDL_SCANCODE_POWER,
/* 117 */ SDL_SCANCODE_KP_EQUALS,
/* 118 */ SDL_SCANCODE_KP_PLUSMINUS,
/* 119 */ SDL_SCANCODE_PAUSE,
0,
/* 121 */ SDL_SCANCODE_KP_COMMA,
/* 122 */ SDL_SCANCODE_LANG1, /* KEY_HANGUEL */
/* 123 */ SDL_SCANCODE_LANG2, /* KEY_HANJA */
/* 124 */ SDL_SCANCODE_INTERNATIONAL3, /* KEY_YEN */
/* 125 */ SDL_SCANCODE_LGUI,
/* 126 */ SDL_SCANCODE_RGUI,
/* 127 */ SDL_SCANCODE_UNKNOWN, /* KEY_COMPOSE */
/* 128 */ SDL_SCANCODE_STOP,
/* 129 */ SDL_SCANCODE_AGAIN,
/* 130 */ SDL_SCANCODE_UNKNOWN, /* KEY_PROPS */
/* 131 */ SDL_SCANCODE_UNDO,
/* 132 */ SDL_SCANCODE_UNKNOWN, /* KEY_FRONT */
/* 133 */ SDL_SCANCODE_COPY,
/* 134 */ SDL_SCANCODE_UNKNOWN, /* KEY_OPEN */
/* 135 */ SDL_SCANCODE_PASTE,
/* 136 */ SDL_SCANCODE_FIND,
/* 137 */ SDL_SCANCODE_CUT,
/* 138 */ SDL_SCANCODE_HELP,
/* 139 */ SDL_SCANCODE_MENU,
/* 140 */ SDL_SCANCODE_CALCULATOR,
/* 141 */ SDL_SCANCODE_UNKNOWN, /* KEY_SETUP */
/* 142 */ SDL_SCANCODE_SLEEP,
/* 143 */ SDL_SCANCODE_UNKNOWN, /* KEY_WAKEUP */
/* 144 */ SDL_SCANCODE_UNKNOWN, /* KEY_FILE */
/* 145 */ SDL_SCANCODE_UNKNOWN, /* KEY_SENDFILE */
/* 146 */ SDL_SCANCODE_UNKNOWN, /* KEY_DELETEFILE */
/* 147 */ SDL_SCANCODE_UNKNOWN, /* KEY_XFER */
/* 148 */ SDL_SCANCODE_UNKNOWN, /* KEY_PROG1 */
/* 149 */ SDL_SCANCODE_UNKNOWN, /* KEY_PROG2 */
/* 150 */ SDL_SCANCODE_UNKNOWN, /* KEY_WWW */
/* 151 */ SDL_SCANCODE_UNKNOWN, /* KEY_MSDOS */
/* 152 */ SDL_SCANCODE_UNKNOWN, /* KEY_COFFEE */
/* 153 */ SDL_SCANCODE_UNKNOWN, /* KEY_DIRECTION */
/* 154 */ SDL_SCANCODE_UNKNOWN, /* KEY_CYCLEWINDOWS */
/* 155 */ SDL_SCANCODE_MAIL,
/* 156 */ SDL_SCANCODE_AC_BOOKMARKS,
/* 157 */ SDL_SCANCODE_COMPUTER,
/* 158 */ SDL_SCANCODE_AC_BACK,
/* 159 */ SDL_SCANCODE_AC_FORWARD,
/* 160 */ SDL_SCANCODE_UNKNOWN, /* KEY_CLOSECD */
/* 161 */ SDL_SCANCODE_EJECT, /* KEY_EJECTCD */
/* 162 */ SDL_SCANCODE_UNKNOWN, /* KEY_EJECTCLOSECD */
/* 163 */ SDL_SCANCODE_AUDIONEXT, /* KEY_NEXTSONG */
/* 164 */ SDL_SCANCODE_AUDIOPLAY, /* KEY_PLAYPAUSE */
/* 165 */ SDL_SCANCODE_AUDIOPREV, /* KEY_PREVIOUSSONG */
/* 166 */ SDL_SCANCODE_UNKNOWN, /* KEY_STOPCD */
/* 167 */ SDL_SCANCODE_UNKNOWN, /* KEY_RECORD */
/* 168 */ SDL_SCANCODE_UNKNOWN, /* KEY_REWIND */
/* 169 */ SDL_SCANCODE_UNKNOWN, /* KEY_PHONE */
/* 170 */ SDL_SCANCODE_UNKNOWN, /* KEY_ISO */
/* 171 */ SDL_SCANCODE_UNKNOWN, /* KEY_CONFIG */
/* 172 */ SDL_SCANCODE_AC_HOME,
/* 173 */ SDL_SCANCODE_AC_REFRESH,
/* 174 */ SDL_SCANCODE_UNKNOWN, /* KEY_EXIT */
/* 175 */ SDL_SCANCODE_UNKNOWN, /* KEY_MOVE */
/* 176 */ SDL_SCANCODE_UNKNOWN, /* KEY_EDIT */
/* 177 */ SDL_SCANCODE_UNKNOWN, /* KEY_SCROLLUP */
/* 178 */ SDL_SCANCODE_UNKNOWN, /* KEY_SCROLLDOWN */
/* 179 */ SDL_SCANCODE_KP_LEFTPAREN,
/* 180 */ SDL_SCANCODE_KP_RIGHTPAREN,
/* 181 */ SDL_SCANCODE_UNKNOWN, /* KEY_NEW */
/* 182 */ SDL_SCANCODE_UNKNOWN, /* KEY_REDO */
/* 183 */ SDL_SCANCODE_F13,
/* 184 */ SDL_SCANCODE_F14,
/* 185 */ SDL_SCANCODE_F15,
/* 186 */ SDL_SCANCODE_F16,
/* 187 */ SDL_SCANCODE_F17,
/* 188 */ SDL_SCANCODE_F18,
/* 189 */ SDL_SCANCODE_F19,
/* 190 */ SDL_SCANCODE_F20,
/* 191 */ SDL_SCANCODE_F21,
/* 192 */ SDL_SCANCODE_F22,
/* 193 */ SDL_SCANCODE_F23,
/* 194 */ SDL_SCANCODE_F24,
0, 0, 0, 0,
/* 200 */ SDL_SCANCODE_UNKNOWN, /* KEY_PLAYCD */
/* 201 */ SDL_SCANCODE_UNKNOWN, /* KEY_PAUSECD */
/* 202 */ SDL_SCANCODE_UNKNOWN, /* KEY_PROG3 */
/* 203 */ SDL_SCANCODE_UNKNOWN, /* KEY_PROG4 */
0,
/* 205 */ SDL_SCANCODE_UNKNOWN, /* KEY_SUSPEND */
/* 206 */ SDL_SCANCODE_UNKNOWN, /* KEY_CLOSE */
/* 207 */ SDL_SCANCODE_UNKNOWN, /* KEY_PLAY */
/* 208 */ SDL_SCANCODE_UNKNOWN, /* KEY_FASTFORWARD */
/* 209 */ SDL_SCANCODE_UNKNOWN, /* KEY_BASSBOOST */
/* 210 */ SDL_SCANCODE_UNKNOWN, /* KEY_PRINT */
/* 211 */ SDL_SCANCODE_UNKNOWN, /* KEY_HP */
/* 212 */ SDL_SCANCODE_UNKNOWN, /* KEY_CAMERA */
/* 213 */ SDL_SCANCODE_UNKNOWN, /* KEY_SOUND */
/* 214 */ SDL_SCANCODE_UNKNOWN, /* KEY_QUESTION */
/* 215 */ SDL_SCANCODE_UNKNOWN, /* KEY_EMAIL */
/* 216 */ SDL_SCANCODE_UNKNOWN, /* KEY_CHAT */
/* 217 */ SDL_SCANCODE_AC_SEARCH,
/* 218 */ SDL_SCANCODE_UNKNOWN, /* KEY_CONNECT */
/* 219 */ SDL_SCANCODE_UNKNOWN, /* KEY_FINANCE */
/* 220 */ SDL_SCANCODE_UNKNOWN, /* KEY_SPORT */
/* 221 */ SDL_SCANCODE_UNKNOWN, /* KEY_SHOP */
/* 222 */ SDL_SCANCODE_ALTERASE,
/* 223 */ SDL_SCANCODE_CANCEL,
/* 224 */ SDL_SCANCODE_BRIGHTNESSDOWN,
/* 225 */ SDL_SCANCODE_BRIGHTNESSUP,
/* 226 */ SDL_SCANCODE_UNKNOWN, /* KEY_MEDIA */
/* 227 */ SDL_SCANCODE_DISPLAYSWITCH, /* KEY_SWITCHVIDEOMODE */
/* 228 */ SDL_SCANCODE_KBDILLUMTOGGLE,
/* 229 */ SDL_SCANCODE_KBDILLUMDOWN,
/* 230 */ SDL_SCANCODE_KBDILLUMUP,
/* 231 */ SDL_SCANCODE_UNKNOWN, /* KEY_SEND */
/* 232 */ SDL_SCANCODE_UNKNOWN, /* KEY_REPLY */
/* 233 */ SDL_SCANCODE_UNKNOWN, /* KEY_FORWARDMAIL */
/* 234 */ SDL_SCANCODE_UNKNOWN, /* KEY_SAVE */
/* 235 */ SDL_SCANCODE_UNKNOWN, /* KEY_DOCUMENTS */
/* 236 */ SDL_SCANCODE_UNKNOWN, /* KEY_BATTERY */
};
/* *INDENT-ON* */

View File

@@ -0,0 +1,287 @@
/*
SDL - Simple DirectMedia Layer
Copyright (C) 1997-2010 Sam Lantinga
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
Sam Lantinga
slouken@libsdl.org
*/
#include "../../include/SDL_scancode.h"
/* Win32 virtual key code to SDL scancode mapping table
Sources:
- msdn.microsoft.com
*/
/* *INDENT-OFF* */
static const SDL_scancode win32_scancode_table[] = {
/* 0, 0x00 */ SDL_SCANCODE_UNKNOWN,
/* 1, 0x01 */ SDL_SCANCODE_UNKNOWN,
/* 2, 0x02 */ SDL_SCANCODE_UNKNOWN,
/* 3, 0x03 */ SDL_SCANCODE_UNKNOWN,
/* 4, 0x04 */ SDL_SCANCODE_UNKNOWN,
/* 5, 0x05 */ SDL_SCANCODE_UNKNOWN,
/* 6, 0x06 */ SDL_SCANCODE_UNKNOWN,
/* 7, 0x07 */ SDL_SCANCODE_UNKNOWN,
/* 8, 0x08 */ SDL_SCANCODE_BACKSPACE,
/* 9, 0x09 */ SDL_SCANCODE_TAB,
/* 10, 0x0a */ SDL_SCANCODE_KP_ENTER, /* Not a VKEY, SDL specific */
/* 11, 0x0b */ SDL_SCANCODE_UNKNOWN,
/* 12, 0x0c */ SDL_SCANCODE_CLEAR,
/* 13, 0x0d */ SDL_SCANCODE_RETURN,
/* 14, 0x0e */ SDL_SCANCODE_UNKNOWN,
/* 15, 0x0f */ SDL_SCANCODE_UNKNOWN,
/* 16, 0x10 */ SDL_SCANCODE_UNKNOWN,
/* 17, 0x11 */ SDL_SCANCODE_UNKNOWN,
/* 18, 0x12 */ SDL_SCANCODE_APPLICATION,
/* 19, 0x13 */ SDL_SCANCODE_PAUSE,
/* 20, 0x14 */ SDL_SCANCODE_CAPSLOCK,
/* 21, 0x15 */ SDL_SCANCODE_UNKNOWN,
/* 22, 0x16 */ SDL_SCANCODE_UNKNOWN,
/* 23, 0x17 */ SDL_SCANCODE_UNKNOWN,
/* 24, 0x18 */ SDL_SCANCODE_UNKNOWN,
/* 25, 0x19 */ SDL_SCANCODE_UNKNOWN,
/* 26, 0x1a */ SDL_SCANCODE_UNKNOWN,
/* 27, 0x1b */ SDL_SCANCODE_ESCAPE,
/* 28, 0x1c */ SDL_SCANCODE_UNKNOWN,
/* 29, 0x1d */ SDL_SCANCODE_UNKNOWN,
/* 30, 0x1e */ SDL_SCANCODE_UNKNOWN,
/* 31, 0x1f */ SDL_SCANCODE_MODE,
/* 32, 0x20 */ SDL_SCANCODE_SPACE,
/* 33, 0x21 */ SDL_SCANCODE_PAGEUP,
/* 34, 0x22 */ SDL_SCANCODE_PAGEDOWN,
/* 35, 0x23 */ SDL_SCANCODE_END,
/* 36, 0x24 */ SDL_SCANCODE_HOME,
/* 37, 0x25 */ SDL_SCANCODE_LEFT,
/* 38, 0x26 */ SDL_SCANCODE_UP,
/* 39, 0x27 */ SDL_SCANCODE_RIGHT,
/* 40, 0x28 */ SDL_SCANCODE_DOWN,
/* 41, 0x29 */ SDL_SCANCODE_SELECT,
/* 42, 0x2a */ SDL_SCANCODE_UNKNOWN, /* VK_PRINT */
/* 43, 0x2b */ SDL_SCANCODE_EXECUTE,
/* 44, 0x2c */ SDL_SCANCODE_PRINTSCREEN,
/* 45, 0x2d */ SDL_SCANCODE_INSERT,
/* 46, 0x2e */ SDL_SCANCODE_DELETE,
/* 47, 0x2f */ SDL_SCANCODE_HELP,
/* 48, 0x30 */ SDL_SCANCODE_0,
/* 49, 0x31 */ SDL_SCANCODE_1,
/* 50, 0x32 */ SDL_SCANCODE_2,
/* 51, 0x33 */ SDL_SCANCODE_3,
/* 52, 0x34 */ SDL_SCANCODE_4,
/* 53, 0x35 */ SDL_SCANCODE_5,
/* 54, 0x36 */ SDL_SCANCODE_6,
/* 55, 0x37 */ SDL_SCANCODE_7,
/* 56, 0x38 */ SDL_SCANCODE_8,
/* 57, 0x39 */ SDL_SCANCODE_9,
/* 58, 0x3a */ SDL_SCANCODE_UNKNOWN,
/* 59, 0x3b */ SDL_SCANCODE_UNKNOWN,
/* 60, 0x3c */ SDL_SCANCODE_UNKNOWN,
/* 61, 0x3d */ SDL_SCANCODE_UNKNOWN,
/* 62, 0x3e */ SDL_SCANCODE_UNKNOWN,
/* 63, 0x3f */ SDL_SCANCODE_UNKNOWN,
/* 64, 0x40 */ SDL_SCANCODE_UNKNOWN,
/* 65, 0x41 */ SDL_SCANCODE_A,
/* 66, 0x42 */ SDL_SCANCODE_B,
/* 67, 0x43 */ SDL_SCANCODE_C,
/* 68, 0x44 */ SDL_SCANCODE_D,
/* 69, 0x45 */ SDL_SCANCODE_E,
/* 70, 0x46 */ SDL_SCANCODE_F,
/* 71, 0x47 */ SDL_SCANCODE_G,
/* 72, 0x48 */ SDL_SCANCODE_H,
/* 73, 0x49 */ SDL_SCANCODE_I,
/* 74, 0x4a */ SDL_SCANCODE_J,
/* 75, 0x4b */ SDL_SCANCODE_K,
/* 76, 0x4c */ SDL_SCANCODE_L,
/* 77, 0x4d */ SDL_SCANCODE_M,
/* 78, 0x4e */ SDL_SCANCODE_N,
/* 79, 0x4f */ SDL_SCANCODE_O,
/* 80, 0x50 */ SDL_SCANCODE_P,
/* 81, 0x51 */ SDL_SCANCODE_Q,
/* 82, 0x52 */ SDL_SCANCODE_R,
/* 83, 0x53 */ SDL_SCANCODE_S,
/* 84, 0x54 */ SDL_SCANCODE_T,
/* 85, 0x55 */ SDL_SCANCODE_U,
/* 86, 0x56 */ SDL_SCANCODE_V,
/* 87, 0x57 */ SDL_SCANCODE_W,
/* 88, 0x58 */ SDL_SCANCODE_X,
/* 89, 0x59 */ SDL_SCANCODE_Y,
/* 90, 0x5a */ SDL_SCANCODE_Z,
/* 91, 0x5b */ SDL_SCANCODE_LGUI,
/* 92, 0x5c */ SDL_SCANCODE_RGUI,
/* 93, 0x5d */ SDL_SCANCODE_APPLICATION,
/* 94, 0x5e */ SDL_SCANCODE_UNKNOWN,
/* 95, 0x5f */ SDL_SCANCODE_UNKNOWN,
/* 96, 0x60 */ SDL_SCANCODE_KP_0,
/* 97, 0x61 */ SDL_SCANCODE_KP_1,
/* 98, 0x62 */ SDL_SCANCODE_KP_2,
/* 99, 0x63 */ SDL_SCANCODE_KP_3,
/* 100, 0x64 */ SDL_SCANCODE_KP_4,
/* 101, 0x65 */ SDL_SCANCODE_KP_5,
/* 102, 0x66 */ SDL_SCANCODE_KP_6,
/* 103, 0x67 */ SDL_SCANCODE_KP_7,
/* 104, 0x68 */ SDL_SCANCODE_KP_8,
/* 105, 0x69 */ SDL_SCANCODE_KP_9,
/* 106, 0x6a */ SDL_SCANCODE_KP_MULTIPLY,
/* 107, 0x6b */ SDL_SCANCODE_KP_PLUS,
/* 108, 0x6c */ SDL_SCANCODE_SEPARATOR,
/* 109, 0x6d */ SDL_SCANCODE_KP_MINUS,
/* 110, 0x6e */ SDL_SCANCODE_KP_DECIMAL,
/* 111, 0x6f */ SDL_SCANCODE_KP_DIVIDE,
/* 112, 0x70 */ SDL_SCANCODE_F1,
/* 113, 0x71 */ SDL_SCANCODE_F2,
/* 114, 0x72 */ SDL_SCANCODE_F3,
/* 115, 0x73 */ SDL_SCANCODE_F4,
/* 116, 0x74 */ SDL_SCANCODE_F5,
/* 117, 0x75 */ SDL_SCANCODE_F6,
/* 118, 0x76 */ SDL_SCANCODE_F7,
/* 119, 0x77 */ SDL_SCANCODE_F8,
/* 120, 0x78 */ SDL_SCANCODE_F9,
/* 121, 0x79 */ SDL_SCANCODE_F10,
/* 122, 0x7a */ SDL_SCANCODE_F11,
/* 123, 0x7b */ SDL_SCANCODE_F12,
/* 124, 0x7c */ SDL_SCANCODE_F13,
/* 125, 0x7d */ SDL_SCANCODE_F14,
/* 126, 0x7e */ SDL_SCANCODE_F15,
/* 127, 0x7f */ SDL_SCANCODE_F16,
/* 128, 0x80 */ SDL_SCANCODE_F17, /* or SDL_SCANCODE_AUDIONEXT */
/* 129, 0x81 */ SDL_SCANCODE_F18, /* or SDL_SCANCODE_AUDIOPREV */
/* 130, 0x82 */ SDL_SCANCODE_F19, /* or SDL_SCANCODE_AUDIOSTOP */
/* 131, 0x83 */ SDL_SCANCODE_F20, /* or SDL_SCANCODE_AUDIOPLAY */
/* 132, 0x84 */ SDL_SCANCODE_F21, /* or SDL_SCANCODE_MAIL */
/* 133, 0x85 */ SDL_SCANCODE_F22, /* or SDL_SCANCODE_MEDIASELECT */
/* 134, 0x86 */ SDL_SCANCODE_F23, /* or SDL_SCANCODE_WWW */
/* 135, 0x87 */ SDL_SCANCODE_F24, /* or SDL_SCANCODE_CALCULATOR */
/* 136, 0x88 */ SDL_SCANCODE_UNKNOWN,
/* 137, 0x89 */ SDL_SCANCODE_UNKNOWN,
/* 138, 0x8a */ SDL_SCANCODE_UNKNOWN,
/* 139, 0x8b */ SDL_SCANCODE_UNKNOWN,
/* 140, 0x8c */ SDL_SCANCODE_UNKNOWN,
/* 141, 0x8d */ SDL_SCANCODE_UNKNOWN,
/* 142, 0x8e */ SDL_SCANCODE_UNKNOWN,
/* 143, 0x8f */ SDL_SCANCODE_UNKNOWN,
/* 144, 0x90 */ SDL_SCANCODE_NUMLOCKCLEAR,
/* 145, 0x91 */ SDL_SCANCODE_SCROLLLOCK,
/* 146, 0x92 */ SDL_SCANCODE_KP_EQUALS,
/* 147, 0x93 */ SDL_SCANCODE_UNKNOWN,
/* 148, 0x94 */ SDL_SCANCODE_UNKNOWN,
/* 149, 0x95 */ SDL_SCANCODE_UNKNOWN,
/* 150, 0x96 */ SDL_SCANCODE_UNKNOWN,
/* 151, 0x97 */ SDL_SCANCODE_UNKNOWN,
/* 152, 0x98 */ SDL_SCANCODE_UNKNOWN,
/* 153, 0x99 */ SDL_SCANCODE_UNKNOWN,
/* 154, 0x9a */ SDL_SCANCODE_UNKNOWN,
/* 155, 0x9b */ SDL_SCANCODE_UNKNOWN,
/* 156, 0x9c */ SDL_SCANCODE_UNKNOWN,
/* 157, 0x9d */ SDL_SCANCODE_UNKNOWN,
/* 158, 0x9e */ SDL_SCANCODE_UNKNOWN,
/* 159, 0x9f */ SDL_SCANCODE_UNKNOWN,
/* 160, 0xa0 */ SDL_SCANCODE_LSHIFT,
/* 161, 0xa1 */ SDL_SCANCODE_RSHIFT,
/* 162, 0xa2 */ SDL_SCANCODE_LCTRL,
/* 163, 0xa3 */ SDL_SCANCODE_RCTRL,
/* 164, 0xa4 */ SDL_SCANCODE_LALT,
/* 165, 0xa5 */ SDL_SCANCODE_RALT,
/* 166, 0xa6 */ SDL_SCANCODE_AC_BACK,
/* 167, 0xa7 */ SDL_SCANCODE_AC_FORWARD,
/* 168, 0xa8 */ SDL_SCANCODE_AC_REFRESH,
/* 169, 0xa9 */ SDL_SCANCODE_AC_STOP,
/* 170, 0xaa */ SDL_SCANCODE_AC_SEARCH,
/* 171, 0xab */ SDL_SCANCODE_AC_BOOKMARKS,
/* 172, 0xac */ SDL_SCANCODE_AC_HOME,
/* 173, 0xad */ SDL_SCANCODE_AUDIOMUTE,
/* 174, 0xae */ SDL_SCANCODE_VOLUMEDOWN,
/* 175, 0xaf */ SDL_SCANCODE_VOLUMEUP,
/* 176, 0xb0 */ SDL_SCANCODE_AUDIONEXT,
/* 177, 0xb1 */ SDL_SCANCODE_AUDIOPREV,
/* 178, 0xb2 */ SDL_SCANCODE_AUDIOSTOP,
/* 179, 0xb3 */ SDL_SCANCODE_AUDIOPLAY,
/* 180, 0xb4 */ SDL_SCANCODE_MAIL,
/* 181, 0xb5 */ SDL_SCANCODE_MEDIASELECT,
/* 182, 0xb6 */ SDL_SCANCODE_UNKNOWN, /* VK_LAUNCH_APP1 */
/* 183, 0xb7 */ SDL_SCANCODE_UNKNOWN, /* VK_LAUNCH_APP2 */
/* 184, 0xb8 */ SDL_SCANCODE_UNKNOWN,
/* 185, 0xb9 */ SDL_SCANCODE_UNKNOWN,
/* 186, 0xba */ SDL_SCANCODE_SEMICOLON,
/* 187, 0xbb */ SDL_SCANCODE_EQUALS,
/* 188, 0xbc */ SDL_SCANCODE_COMMA,
/* 189, 0xbd */ SDL_SCANCODE_MINUS,
/* 190, 0xbe */ SDL_SCANCODE_PERIOD,
/* 191, 0xbf */ SDL_SCANCODE_SLASH,
/* 192, 0xc0 */ SDL_SCANCODE_GRAVE,
/* 193, 0xc1 */ SDL_SCANCODE_UNKNOWN,
/* 194, 0xc2 */ SDL_SCANCODE_UNKNOWN,
/* 195, 0xc3 */ SDL_SCANCODE_UNKNOWN,
/* 196, 0xc4 */ SDL_SCANCODE_UNKNOWN,
/* 197, 0xc5 */ SDL_SCANCODE_UNKNOWN,
/* 198, 0xc6 */ SDL_SCANCODE_UNKNOWN,
/* 199, 0xc7 */ SDL_SCANCODE_UNKNOWN,
/* 200, 0xc8 */ SDL_SCANCODE_UNKNOWN,
/* 201, 0xc9 */ SDL_SCANCODE_UNKNOWN,
/* 202, 0xca */ SDL_SCANCODE_UNKNOWN,
/* 203, 0xcb */ SDL_SCANCODE_UNKNOWN,
/* 204, 0xcc */ SDL_SCANCODE_UNKNOWN,
/* 205, 0xcd */ SDL_SCANCODE_UNKNOWN,
/* 206, 0xce */ SDL_SCANCODE_UNKNOWN,
/* 207, 0xcf */ SDL_SCANCODE_UNKNOWN,
/* 208, 0xd0 */ SDL_SCANCODE_UNKNOWN,
/* 209, 0xd1 */ SDL_SCANCODE_UNKNOWN,
/* 210, 0xd2 */ SDL_SCANCODE_UNKNOWN,
/* 211, 0xd3 */ SDL_SCANCODE_UNKNOWN,
/* 212, 0xd4 */ SDL_SCANCODE_UNKNOWN,
/* 213, 0xd5 */ SDL_SCANCODE_UNKNOWN,
/* 214, 0xd6 */ SDL_SCANCODE_UNKNOWN,
/* 215, 0xd7 */ SDL_SCANCODE_UNKNOWN,
/* 216, 0xd8 */ SDL_SCANCODE_UNKNOWN,
/* 217, 0xd9 */ SDL_SCANCODE_UNKNOWN,
/* 218, 0xda */ SDL_SCANCODE_UNKNOWN,
/* 219, 0xdb */ SDL_SCANCODE_LEFTBRACKET,
/* 220, 0xdc */ SDL_SCANCODE_BACKSLASH,
/* 221, 0xdd */ SDL_SCANCODE_RIGHTBRACKET,
/* 222, 0xde */ SDL_SCANCODE_APOSTROPHE,
/* 223, 0xdf */ SDL_SCANCODE_UNKNOWN,
/* 224, 0xe0 */ SDL_SCANCODE_UNKNOWN,
/* 225, 0xe1 */ SDL_SCANCODE_UNKNOWN,
/* 226, 0xe2 */ SDL_SCANCODE_NONUSBACKSLASH,
/* 227, 0xe3 */ SDL_SCANCODE_UNKNOWN,
/* 228, 0xe4 */ SDL_SCANCODE_UNKNOWN,
/* 229, 0xe5 */ SDL_SCANCODE_UNKNOWN,
/* 230, 0xe6 */ SDL_SCANCODE_UNKNOWN,
/* 231, 0xe7 */ SDL_SCANCODE_UNKNOWN,
/* 232, 0xe8 */ SDL_SCANCODE_UNKNOWN,
/* 233, 0xe9 */ SDL_SCANCODE_UNKNOWN,
/* 234, 0xea */ SDL_SCANCODE_UNKNOWN,
/* 235, 0xeb */ SDL_SCANCODE_UNKNOWN,
/* 236, 0xec */ SDL_SCANCODE_UNKNOWN,
/* 237, 0xed */ SDL_SCANCODE_UNKNOWN,
/* 238, 0xee */ SDL_SCANCODE_UNKNOWN,
/* 239, 0xef */ SDL_SCANCODE_UNKNOWN,
/* 240, 0xf0 */ SDL_SCANCODE_UNKNOWN,
/* 241, 0xf1 */ SDL_SCANCODE_UNKNOWN,
/* 242, 0xf2 */ SDL_SCANCODE_UNKNOWN,
/* 243, 0xf3 */ SDL_SCANCODE_UNKNOWN,
/* 244, 0xf4 */ SDL_SCANCODE_UNKNOWN,
/* 245, 0xf5 */ SDL_SCANCODE_UNKNOWN,
/* 246, 0xf6 */ SDL_SCANCODE_SYSREQ,
/* 247, 0xf7 */ SDL_SCANCODE_CRSEL,
/* 248, 0xf8 */ SDL_SCANCODE_EXSEL,
/* 249, 0xf9 */ SDL_SCANCODE_UNKNOWN, /* VK_EREOF */
/* 250, 0xfa */ SDL_SCANCODE_UNKNOWN, /* VK_PLAY */
/* 251, 0xfb */ SDL_SCANCODE_UNKNOWN, /* VK_ZOOM */
/* 252, 0xfc */ SDL_SCANCODE_UNKNOWN,
/* 253, 0xfd */ SDL_SCANCODE_UNKNOWN, /* VK_PA1 */
/* 254, 0xfe */ SDL_SCANCODE_CLEAR,
/* 255, 0xff */ SDL_SCANCODE_UNKNOWN,
};
/* *INDENT-ON* */

View File

@@ -0,0 +1,422 @@
/*
SDL - Simple DirectMedia Layer
Copyright (C) 1997-2010 Sam Lantinga
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
Sam Lantinga
slouken@libsdl.org
*/
#include "../../include/SDL_scancode.h"
/* XFree86 key code to SDL scancode mapping table
Sources:
- atKeyNames.h from XFree86 source code
*/
/* *INDENT-OFF* */
static const SDL_scancode xfree86_scancode_table[] = {
/* 0 */ SDL_SCANCODE_UNKNOWN,
/* 1 */ SDL_SCANCODE_ESCAPE,
/* 2 */ SDL_SCANCODE_1,
/* 3 */ SDL_SCANCODE_2,
/* 4 */ SDL_SCANCODE_3,
/* 5 */ SDL_SCANCODE_4,
/* 6 */ SDL_SCANCODE_5,
/* 7 */ SDL_SCANCODE_6,
/* 8 */ SDL_SCANCODE_7,
/* 9 */ SDL_SCANCODE_8,
/* 10 */ SDL_SCANCODE_9,
/* 11 */ SDL_SCANCODE_0,
/* 12 */ SDL_SCANCODE_MINUS,
/* 13 */ SDL_SCANCODE_EQUALS,
/* 14 */ SDL_SCANCODE_BACKSPACE,
/* 15 */ SDL_SCANCODE_TAB,
/* 16 */ SDL_SCANCODE_Q,
/* 17 */ SDL_SCANCODE_W,
/* 18 */ SDL_SCANCODE_E,
/* 19 */ SDL_SCANCODE_R,
/* 20 */ SDL_SCANCODE_T,
/* 21 */ SDL_SCANCODE_Y,
/* 22 */ SDL_SCANCODE_U,
/* 23 */ SDL_SCANCODE_I,
/* 24 */ SDL_SCANCODE_O,
/* 25 */ SDL_SCANCODE_P,
/* 26 */ SDL_SCANCODE_LEFTBRACKET,
/* 27 */ SDL_SCANCODE_RIGHTBRACKET,
/* 28 */ SDL_SCANCODE_RETURN,
/* 29 */ SDL_SCANCODE_LCTRL,
/* 30 */ SDL_SCANCODE_A,
/* 31 */ SDL_SCANCODE_S,
/* 32 */ SDL_SCANCODE_D,
/* 33 */ SDL_SCANCODE_F,
/* 34 */ SDL_SCANCODE_G,
/* 35 */ SDL_SCANCODE_H,
/* 36 */ SDL_SCANCODE_J,
/* 37 */ SDL_SCANCODE_K,
/* 38 */ SDL_SCANCODE_L,
/* 39 */ SDL_SCANCODE_SEMICOLON,
/* 40 */ SDL_SCANCODE_APOSTROPHE,
/* 41 */ SDL_SCANCODE_GRAVE,
/* 42 */ SDL_SCANCODE_LSHIFT,
/* 43 */ SDL_SCANCODE_BACKSLASH,
/* 44 */ SDL_SCANCODE_Z,
/* 45 */ SDL_SCANCODE_X,
/* 46 */ SDL_SCANCODE_C,
/* 47 */ SDL_SCANCODE_V,
/* 48 */ SDL_SCANCODE_B,
/* 49 */ SDL_SCANCODE_N,
/* 50 */ SDL_SCANCODE_M,
/* 51 */ SDL_SCANCODE_COMMA,
/* 52 */ SDL_SCANCODE_PERIOD,
/* 53 */ SDL_SCANCODE_SLASH,
/* 54 */ SDL_SCANCODE_RSHIFT,
/* 55 */ SDL_SCANCODE_KP_MULTIPLY,
/* 56 */ SDL_SCANCODE_LALT,
/* 57 */ SDL_SCANCODE_SPACE,
/* 58 */ SDL_SCANCODE_CAPSLOCK,
/* 59 */ SDL_SCANCODE_F1,
/* 60 */ SDL_SCANCODE_F2,
/* 61 */ SDL_SCANCODE_F3,
/* 62 */ SDL_SCANCODE_F4,
/* 63 */ SDL_SCANCODE_F5,
/* 64 */ SDL_SCANCODE_F6,
/* 65 */ SDL_SCANCODE_F7,
/* 66 */ SDL_SCANCODE_F8,
/* 67 */ SDL_SCANCODE_F9,
/* 68 */ SDL_SCANCODE_F10,
/* 69 */ SDL_SCANCODE_NUMLOCKCLEAR,
/* 70 */ SDL_SCANCODE_SCROLLLOCK,
/* 71 */ SDL_SCANCODE_KP_7,
/* 72 */ SDL_SCANCODE_KP_8,
/* 73 */ SDL_SCANCODE_KP_9,
/* 74 */ SDL_SCANCODE_KP_MINUS,
/* 75 */ SDL_SCANCODE_KP_4,
/* 76 */ SDL_SCANCODE_KP_5,
/* 77 */ SDL_SCANCODE_KP_6,
/* 78 */ SDL_SCANCODE_KP_PLUS,
/* 79 */ SDL_SCANCODE_KP_1,
/* 80 */ SDL_SCANCODE_KP_2,
/* 81 */ SDL_SCANCODE_KP_3,
/* 82 */ SDL_SCANCODE_KP_0,
/* 83 */ SDL_SCANCODE_KP_PERIOD,
/* 84 */ SDL_SCANCODE_SYSREQ,
/* 85 */ SDL_SCANCODE_MODE,
/* 86 */ SDL_SCANCODE_NONUSBACKSLASH,
/* 87 */ SDL_SCANCODE_F11,
/* 88 */ SDL_SCANCODE_F12,
/* 89 */ SDL_SCANCODE_HOME,
/* 90 */ SDL_SCANCODE_UP,
/* 91 */ SDL_SCANCODE_PAGEUP,
/* 92 */ SDL_SCANCODE_LEFT,
/* 93 */ SDL_SCANCODE_BRIGHTNESSDOWN, /* on PowerBook G4 / KEY_Begin */
/* 94 */ SDL_SCANCODE_RIGHT,
/* 95 */ SDL_SCANCODE_END,
/* 96 */ SDL_SCANCODE_DOWN,
/* 97 */ SDL_SCANCODE_PAGEDOWN,
/* 98 */ SDL_SCANCODE_INSERT,
/* 99 */ SDL_SCANCODE_DELETE,
/* 100 */ SDL_SCANCODE_KP_ENTER,
/* 101 */ SDL_SCANCODE_RCTRL,
/* 102 */ SDL_SCANCODE_PAUSE,
/* 103 */ SDL_SCANCODE_PRINTSCREEN,
/* 104 */ SDL_SCANCODE_KP_DIVIDE,
/* 105 */ SDL_SCANCODE_RALT,
/* 106 */ SDL_SCANCODE_UNKNOWN, /* BREAK */
/* 107 */ SDL_SCANCODE_LGUI,
/* 108 */ SDL_SCANCODE_RGUI,
/* 109 */ SDL_SCANCODE_APPLICATION,
/* 110 */ SDL_SCANCODE_F13,
/* 111 */ SDL_SCANCODE_F14,
/* 112 */ SDL_SCANCODE_F15,
/* 113 */ SDL_SCANCODE_F16,
/* 114 */ SDL_SCANCODE_F17,
/* 115 */ SDL_SCANCODE_UNKNOWN,
/* 116 */ SDL_SCANCODE_UNKNOWN, /* is translated to XK_ISO_Level3_Shift by my X server, but I have no keyboard that generates this code, so I don't know what the correct SDL_SCANCODE_* for it is */
/* 117 */ SDL_SCANCODE_UNKNOWN,
/* 118 */ SDL_SCANCODE_KP_EQUALS,
/* 119 */ SDL_SCANCODE_UNKNOWN,
/* 120 */ SDL_SCANCODE_UNKNOWN,
/* 121 */ SDL_SCANCODE_UNKNOWN,
/* 122 */ SDL_SCANCODE_UNKNOWN,
/* 123 */ SDL_SCANCODE_UNKNOWN,
/* 124 */ SDL_SCANCODE_UNKNOWN,
/* 125 */ SDL_SCANCODE_INTERNATIONAL3, /* Yen */
/* 126 */ SDL_SCANCODE_UNKNOWN,
/* 127 */ SDL_SCANCODE_UNKNOWN,
/* 128 */ SDL_SCANCODE_UNKNOWN,
/* 129 */ SDL_SCANCODE_UNKNOWN,
/* 130 */ SDL_SCANCODE_UNKNOWN,
/* 131 */ SDL_SCANCODE_UNKNOWN,
/* 132 */ SDL_SCANCODE_POWER,
/* 133 */ SDL_SCANCODE_MUTE,
/* 134 */ SDL_SCANCODE_VOLUMEDOWN,
/* 135 */ SDL_SCANCODE_VOLUMEUP,
/* 136 */ SDL_SCANCODE_HELP,
/* 137 */ SDL_SCANCODE_STOP,
/* 138 */ SDL_SCANCODE_AGAIN,
/* 139 */ SDL_SCANCODE_UNKNOWN, /* PROPS */
/* 140 */ SDL_SCANCODE_UNDO,
/* 141 */ SDL_SCANCODE_UNKNOWN, /* FRONT */
/* 142 */ SDL_SCANCODE_COPY,
/* 143 */ SDL_SCANCODE_UNKNOWN, /* OPEN */
/* 144 */ SDL_SCANCODE_PASTE,
/* 145 */ SDL_SCANCODE_FIND,
/* 146 */ SDL_SCANCODE_CUT,
};
/* for wireless usb keyboard (manufacturer TRUST) without numpad. */
static const SDL_scancode xfree86_scancode_table2[] = {
/* 0 */ SDL_SCANCODE_UNKNOWN,
/* 1 */ SDL_SCANCODE_ESCAPE,
/* 2 */ SDL_SCANCODE_1,
/* 3 */ SDL_SCANCODE_2,
/* 4 */ SDL_SCANCODE_3,
/* 5 */ SDL_SCANCODE_4,
/* 6 */ SDL_SCANCODE_5,
/* 7 */ SDL_SCANCODE_6,
/* 8 */ SDL_SCANCODE_7,
/* 9 */ SDL_SCANCODE_8,
/* 10 */ SDL_SCANCODE_9,
/* 11 */ SDL_SCANCODE_0,
/* 12 */ SDL_SCANCODE_MINUS,
/* 13 */ SDL_SCANCODE_EQUALS,
/* 14 */ SDL_SCANCODE_BACKSPACE,
/* 15 */ SDL_SCANCODE_TAB,
/* 16 */ SDL_SCANCODE_Q,
/* 17 */ SDL_SCANCODE_W,
/* 18 */ SDL_SCANCODE_E,
/* 19 */ SDL_SCANCODE_R,
/* 20 */ SDL_SCANCODE_T,
/* 21 */ SDL_SCANCODE_Y,
/* 22 */ SDL_SCANCODE_U,
/* 23 */ SDL_SCANCODE_I,
/* 24 */ SDL_SCANCODE_O,
/* 25 */ SDL_SCANCODE_P,
/* 26 */ SDL_SCANCODE_LEFTBRACKET,
/* 27 */ SDL_SCANCODE_RIGHTBRACKET,
/* 28 */ SDL_SCANCODE_RETURN,
/* 29 */ SDL_SCANCODE_LCTRL,
/* 30 */ SDL_SCANCODE_A,
/* 31 */ SDL_SCANCODE_S,
/* 32 */ SDL_SCANCODE_D,
/* 33 */ SDL_SCANCODE_F,
/* 34 */ SDL_SCANCODE_G,
/* 35 */ SDL_SCANCODE_H,
/* 36 */ SDL_SCANCODE_J,
/* 37 */ SDL_SCANCODE_K,
/* 38 */ SDL_SCANCODE_L,
/* 39 */ SDL_SCANCODE_SEMICOLON,
/* 40 */ SDL_SCANCODE_APOSTROPHE,
/* 41 */ SDL_SCANCODE_GRAVE,
/* 42 */ SDL_SCANCODE_LSHIFT,
/* 43 */ SDL_SCANCODE_BACKSLASH,
/* 44 */ SDL_SCANCODE_Z,
/* 45 */ SDL_SCANCODE_X,
/* 46 */ SDL_SCANCODE_C,
/* 47 */ SDL_SCANCODE_V,
/* 48 */ SDL_SCANCODE_B,
/* 49 */ SDL_SCANCODE_N,
/* 50 */ SDL_SCANCODE_M,
/* 51 */ SDL_SCANCODE_COMMA,
/* 52 */ SDL_SCANCODE_PERIOD,
/* 53 */ SDL_SCANCODE_SLASH,
/* 54 */ SDL_SCANCODE_RSHIFT,
/* 55 */ SDL_SCANCODE_KP_MULTIPLY,
/* 56 */ SDL_SCANCODE_LALT,
/* 57 */ SDL_SCANCODE_SPACE,
/* 58 */ SDL_SCANCODE_CAPSLOCK,
/* 59 */ SDL_SCANCODE_F1,
/* 60 */ SDL_SCANCODE_F2,
/* 61 */ SDL_SCANCODE_F3,
/* 62 */ SDL_SCANCODE_F4,
/* 63 */ SDL_SCANCODE_F5,
/* 64 */ SDL_SCANCODE_F6,
/* 65 */ SDL_SCANCODE_F7,
/* 66 */ SDL_SCANCODE_F8,
/* 67 */ SDL_SCANCODE_F9,
/* 68 */ SDL_SCANCODE_F10,
/* 69 */ SDL_SCANCODE_NUMLOCKCLEAR,
/* 70 */ SDL_SCANCODE_SCROLLLOCK,
/* 71 */ SDL_SCANCODE_KP_7,
/* 72 */ SDL_SCANCODE_KP_8,
/* 73 */ SDL_SCANCODE_KP_9,
/* 74 */ SDL_SCANCODE_KP_MINUS,
/* 75 */ SDL_SCANCODE_KP_4,
/* 76 */ SDL_SCANCODE_KP_5,
/* 77 */ SDL_SCANCODE_KP_6,
/* 78 */ SDL_SCANCODE_KP_PLUS,
/* 79 */ SDL_SCANCODE_KP_1,
/* 80 */ SDL_SCANCODE_KP_2,
/* 81 */ SDL_SCANCODE_KP_3,
/* 82 */ SDL_SCANCODE_KP_0,
/* 83 */ SDL_SCANCODE_KP_PERIOD,
/* 84 */ SDL_SCANCODE_SYSREQ, /* ???? */
/* 85 */ SDL_SCANCODE_MODE, /* ???? */
/* 86 */ SDL_SCANCODE_NONUSBACKSLASH,
/* 87 */ SDL_SCANCODE_F11,
/* 88 */ SDL_SCANCODE_F12,
/* 89 */ SDL_SCANCODE_UNKNOWN,
/* 90 */ SDL_SCANCODE_UNKNOWN, /* Katakana */
/* 91 */ SDL_SCANCODE_UNKNOWN, /* Hiragana */
/* 92 */ SDL_SCANCODE_UNKNOWN, /* Henkan_Mode */
/* 93 */ SDL_SCANCODE_UNKNOWN, /* Hiragana_Katakana */
/* 94 */ SDL_SCANCODE_UNKNOWN, /* Muhenkan */
/* 95 */ SDL_SCANCODE_UNKNOWN,
/* 96 */ SDL_SCANCODE_KP_ENTER,
/* 97 */ SDL_SCANCODE_RCTRL,
/* 98 */ SDL_SCANCODE_KP_DIVIDE,
/* 99 */ SDL_SCANCODE_PRINTSCREEN,
/* 100 */ SDL_SCANCODE_RALT, /* ISO_Level3_Shift, ALTGR, RALT */
/* 101 */ SDL_SCANCODE_UNKNOWN, /* Linefeed */
/* 102 */ SDL_SCANCODE_HOME,
/* 103 */ SDL_SCANCODE_UP,
/* 104 */ SDL_SCANCODE_PAGEUP,
/* 105 */ SDL_SCANCODE_LEFT,
/* 106 */ SDL_SCANCODE_RIGHT,
/* 107 */ SDL_SCANCODE_END,
/* 108 */ SDL_SCANCODE_DOWN,
/* 109 */ SDL_SCANCODE_PAGEDOWN,
/* 110 */ SDL_SCANCODE_INSERT,
/* 111 */ SDL_SCANCODE_DELETE,
/* 112 */ SDL_SCANCODE_UNKNOWN,
/* 113 */ SDL_SCANCODE_MUTE,
/* 114 */ SDL_SCANCODE_VOLUMEDOWN,
/* 115 */ SDL_SCANCODE_VOLUMEUP,
/* 116 */ SDL_SCANCODE_POWER,
/* 117 */ SDL_SCANCODE_KP_EQUALS,
/* 118 */ SDL_SCANCODE_UNKNOWN, /* plusminus */
/* 119 */ SDL_SCANCODE_PAUSE,
/* 120 */ SDL_SCANCODE_UNKNOWN, /* XF86LaunchA */
/* 121 */ SDL_SCANCODE_UNKNOWN, /* KP_Decimal */
/* 122 */ SDL_SCANCODE_UNKNOWN, /* Hangul */
/* 123 */ SDL_SCANCODE_UNKNOWN, /* Hangul_Hanja */
/* 124 */ SDL_SCANCODE_UNKNOWN,
/* 125 */ SDL_SCANCODE_LGUI,
/* 126 */ SDL_SCANCODE_RGUI,
/* 127 */ SDL_SCANCODE_APPLICATION,
/* 128 */ SDL_SCANCODE_CANCEL,
/* 129 */ SDL_SCANCODE_AGAIN,
/* 130 */ SDL_SCANCODE_UNKNOWN, /* SunProps */
/* 131 */ SDL_SCANCODE_UNDO,
/* 132 */ SDL_SCANCODE_UNKNOWN, /* SunFront */
/* 133 */ SDL_SCANCODE_COPY,
/* 134 */ SDL_SCANCODE_UNKNOWN, /* SunOpen */
/* 135 */ SDL_SCANCODE_PASTE,
/* 136 */ SDL_SCANCODE_FIND,
/* 137 */ SDL_SCANCODE_CUT,
/* 138 */ SDL_SCANCODE_HELP,
/* 139 */ SDL_SCANCODE_UNKNOWN, /* XF86MenuKB */
/* 140 */ SDL_SCANCODE_CALCULATOR,
/* 141 */ SDL_SCANCODE_UNKNOWN,
/* 142 */ SDL_SCANCODE_SLEEP,
/* 143 */ SDL_SCANCODE_UNKNOWN, /* XF86WakeUp */
/* 144 */ SDL_SCANCODE_UNKNOWN, /* XF86Explorer */
/* 145 */ SDL_SCANCODE_UNKNOWN, /* XF86Send */
/* 146 */ SDL_SCANCODE_UNKNOWN,
/* 147 */ SDL_SCANCODE_UNKNOWN, /* XF86Xfer */
/* 148 */ SDL_SCANCODE_UNKNOWN, /* XF86Launch1 */
/* 149 */ SDL_SCANCODE_UNKNOWN, /* XF86Launch2 */
/* 150 */ SDL_SCANCODE_WWW,
/* 151 */ SDL_SCANCODE_UNKNOWN, /* XF86DOS */
/* 152 */ SDL_SCANCODE_UNKNOWN, /* XF86ScreenSaver */
/* 153 */ SDL_SCANCODE_UNKNOWN,
/* 154 */ SDL_SCANCODE_UNKNOWN, /* XF86RotateWindows */
/* 155 */ SDL_SCANCODE_MAIL,
/* 156 */ SDL_SCANCODE_UNKNOWN, /* XF86Favorites */
/* 157 */ SDL_SCANCODE_COMPUTER,
/* 158 */ SDL_SCANCODE_AC_BACK,
/* 159 */ SDL_SCANCODE_AC_FORWARD,
/* 160 */ SDL_SCANCODE_UNKNOWN,
/* 161 */ SDL_SCANCODE_EJECT,
/* 162 */ SDL_SCANCODE_EJECT,
/* 163 */ SDL_SCANCODE_AUDIONEXT,
/* 164 */ SDL_SCANCODE_AUDIOPLAY,
/* 165 */ SDL_SCANCODE_AUDIOPREV,
/* 166 */ SDL_SCANCODE_AUDIOSTOP,
/* 167 */ SDL_SCANCODE_UNKNOWN, /* XF86AudioRecord */
/* 168 */ SDL_SCANCODE_UNKNOWN, /* XF86AudioRewind */
/* 169 */ SDL_SCANCODE_UNKNOWN, /* XF86Phone */
/* 170 */ SDL_SCANCODE_UNKNOWN,
/* 171 */ SDL_SCANCODE_UNKNOWN, /* XF86Tools */
/* 172 */ SDL_SCANCODE_AC_HOME,
/* 173 */ SDL_SCANCODE_AC_REFRESH,
/* 174 */ SDL_SCANCODE_UNKNOWN, /* XF86Close */
/* 175 */ SDL_SCANCODE_UNKNOWN,
/* 176 */ SDL_SCANCODE_UNKNOWN,
/* 177 */ SDL_SCANCODE_UNKNOWN, /* XF86ScrollUp */
/* 178 */ SDL_SCANCODE_UNKNOWN, /* XF86ScrollDown */
/* 179 */ SDL_SCANCODE_UNKNOWN, /* parenleft */
/* 180 */ SDL_SCANCODE_UNKNOWN, /* parenright */
/* 181 */ SDL_SCANCODE_UNKNOWN, /* XF86New */
/* 182 */ SDL_SCANCODE_AGAIN,
/* 183 */ SDL_SCANCODE_UNKNOWN, /* XF86Tools */
/* 184 */ SDL_SCANCODE_UNKNOWN, /* XF86Launch5 */
/* 185 */ SDL_SCANCODE_UNKNOWN, /* XF86MenuKB */
/* 186 */ SDL_SCANCODE_UNKNOWN,
/* 187 */ SDL_SCANCODE_UNKNOWN,
/* 188 */ SDL_SCANCODE_UNKNOWN,
/* 189 */ SDL_SCANCODE_UNKNOWN,
/* 190 */ SDL_SCANCODE_UNKNOWN,
/* 191 */ SDL_SCANCODE_UNKNOWN,
/* 192 */ SDL_SCANCODE_UNKNOWN, /* XF86TouchpadToggle */
/* 193 */ SDL_SCANCODE_UNKNOWN,
/* 194 */ SDL_SCANCODE_UNKNOWN,
/* 195 */ SDL_SCANCODE_MODE,
/* 196 */ SDL_SCANCODE_UNKNOWN,
/* 197 */ SDL_SCANCODE_UNKNOWN,
/* 198 */ SDL_SCANCODE_UNKNOWN,
/* 199 */ SDL_SCANCODE_UNKNOWN,
/* 200 */ SDL_SCANCODE_AUDIOPLAY,
/* 201 */ SDL_SCANCODE_UNKNOWN, /* XF86AudioPause */
/* 202 */ SDL_SCANCODE_UNKNOWN, /* XF86Launch3 */
/* 203 */ SDL_SCANCODE_UNKNOWN, /* XF86Launch4 */
/* 204 */ SDL_SCANCODE_UNKNOWN, /* XF86LaunchB */
/* 205 */ SDL_SCANCODE_UNKNOWN, /* XF86Suspend */
/* 206 */ SDL_SCANCODE_UNKNOWN, /* XF86Close */
/* 207 */ SDL_SCANCODE_AUDIOPLAY,
/* 208 */ SDL_SCANCODE_AUDIONEXT,
/* 209 */ SDL_SCANCODE_UNKNOWN,
/* 210 */ SDL_SCANCODE_PRINTSCREEN,
/* 211 */ SDL_SCANCODE_UNKNOWN,
/* 212 */ SDL_SCANCODE_UNKNOWN, /* XF86WebCam */
/* 213 */ SDL_SCANCODE_UNKNOWN,
/* 214 */ SDL_SCANCODE_UNKNOWN,
/* 215 */ SDL_SCANCODE_MAIL,
/* 216 */ SDL_SCANCODE_UNKNOWN,
/* 217 */ SDL_SCANCODE_AC_SEARCH,
/* 218 */ SDL_SCANCODE_UNKNOWN,
/* 219 */ SDL_SCANCODE_UNKNOWN, /* XF86Finance */
/* 220 */ SDL_SCANCODE_UNKNOWN,
/* 221 */ SDL_SCANCODE_UNKNOWN, /* XF86Shop */
/* 222 */ SDL_SCANCODE_UNKNOWN,
/* 223 */ SDL_SCANCODE_STOP,
/* 224 */ SDL_SCANCODE_BRIGHTNESSDOWN,
/* 225 */ SDL_SCANCODE_BRIGHTNESSUP,
/* 226 */ SDL_SCANCODE_MEDIASELECT,
/* 227 */ SDL_SCANCODE_DISPLAYSWITCH,
/* 228 */ SDL_SCANCODE_KBDILLUMTOGGLE,
/* 229 */ SDL_SCANCODE_KBDILLUMDOWN,
/* 230 */ SDL_SCANCODE_KBDILLUMUP,
/* 231 */ SDL_SCANCODE_UNKNOWN, /* XF86Send */
/* 232 */ SDL_SCANCODE_UNKNOWN, /* XF86Reply */
/* 233 */ SDL_SCANCODE_UNKNOWN, /* XF86MailForward */
/* 234 */ SDL_SCANCODE_UNKNOWN, /* XF86Save */
/* 235 */ SDL_SCANCODE_UNKNOWN, /* XF86Documents */
/* 236 */ SDL_SCANCODE_UNKNOWN, /* XF86Battery */
/* 237 */ SDL_SCANCODE_UNKNOWN, /* XF86Bluetooth */
/* 238 */ SDL_SCANCODE_UNKNOWN, /* XF86WLAN */
};
/* *INDENT-ON* */