aboutsummaryrefslogtreecommitdiffstats
path: root/distrib/sdl-1.2.15/src/video/ggi
diff options
context:
space:
mode:
Diffstat (limited to 'distrib/sdl-1.2.15/src/video/ggi')
-rw-r--r--distrib/sdl-1.2.15/src/video/ggi/SDL_ggievents.c264
-rwxr-xr-xdistrib/sdl-1.2.15/src/video/ggi/SDL_ggievents_c.h29
-rw-r--r--distrib/sdl-1.2.15/src/video/ggi/SDL_ggikeys.h135
-rw-r--r--distrib/sdl-1.2.15/src/video/ggi/SDL_ggimouse.c32
-rwxr-xr-xdistrib/sdl-1.2.15/src/video/ggi/SDL_ggimouse_c.h26
-rw-r--r--distrib/sdl-1.2.15/src/video/ggi/SDL_ggivideo.c378
-rw-r--r--distrib/sdl-1.2.15/src/video/ggi/SDL_ggivideo.h48
7 files changed, 912 insertions, 0 deletions
diff --git a/distrib/sdl-1.2.15/src/video/ggi/SDL_ggievents.c b/distrib/sdl-1.2.15/src/video/ggi/SDL_ggievents.c
new file mode 100644
index 0000000..d963fe1
--- /dev/null
+++ b/distrib/sdl-1.2.15/src/video/ggi/SDL_ggievents.c
@@ -0,0 +1,264 @@
+/*
+ SDL - Simple DirectMedia Layer
+ Copyright (C) 1997-2012 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"
+
+/* Handle the event stream, converting GGI events into SDL events */
+
+#include <sys/types.h>
+#include <sys/time.h>
+#include <unistd.h>
+#include <fcntl.h>
+#include <termios.h>
+
+#include <ggi/keyboard.h>
+
+#include "SDL_ggikeys.h"
+
+#include "SDL.h"
+#include "../SDL_sysvideo.h"
+#include "../../events/SDL_sysevents.h"
+#include "../../events/SDL_events_c.h"
+#include "SDL_ggivideo.h"
+#include "SDL_ggievents_c.h"
+
+/* The translation tables from a GGI keycode to a SDL keysym */
+static SDLKey keymap[128];
+static SDL_keysym *GGI_TranslateKey(ggi_event *ev, SDL_keysym *keysym);
+
+static int posted = 0;
+
+void GGI_PumpEvents(_THIS)
+{
+ struct timeval *tvp, tv = { 0, 0 };
+ ggi_event ev;
+
+ tvp = &tv;
+
+/* ggiFlush(VIS); */
+
+ while (ggiEventPoll(VIS, emAll, tvp))
+/* while (ggiEventPoll(VIS, (emKeyboard | emPointer | emCommand), tvp)) */
+ {
+ int queueevent_mouse = 0, queueevent_kbd = 0;
+ static int buttons = 0;
+ static int mouse_x = 0, mouse_y = 0, mouse_z = 0;
+ int x = 0, y = 0, z = 0, rx = 0, ry = 0, rz = 0;
+ int pressed_mouse, pressed_kbd;
+ SDL_keysym keysym;
+
+ posted = 0;
+
+ /* FIXME: We do not actually want all events, only
+ * mouse and keyboard events. Having to handle all
+ * events will slow things down. */
+
+ ggiEventRead(VIS, &ev, emAll);
+/* ggiEventRead(VIS, &ev, (emKeyboard | emPointer | emCommand)); */
+
+ switch (ev.any.type)
+ {
+ case evPtrRelative:
+ x = ev.pmove.x;
+ y = ev.pmove.y;
+ z = ev.pmove.wheel;
+ posted += SDL_PrivateMouseMotion(0, 1, x, y);
+ break;
+ case evPtrAbsolute:
+ if (mouse_x != ev.pmove.x || mouse_y != ev.pmove.y || mouse_z != ev.pmove.wheel)
+ {
+ x = ev.pmove.x - mouse_x;
+ y = ev.pmove.y - mouse_y;
+ z = ev.pmove.wheel - mouse_z;
+ mouse_x = ev.pmove.x;
+ mouse_y = ev.pmove.y;
+ mouse_z = ev.pmove.wheel;
+ posted += SDL_PrivateMouseMotion(0, 1, x, y);
+ }
+ break;
+ case evPtrButtonPress:
+ posted += SDL_PrivateMouseButton(SDL_PRESSED, ev.pbutton.button, 0, 0);
+ break;
+ case evPtrButtonRelease:
+ posted += SDL_PrivateMouseButton(SDL_RELEASED, ev.pbutton.button, 0, 0);
+ break;
+ case evKeyPress:
+ case evKeyRepeat:
+ posted += SDL_PrivateKeyboard(SDL_PRESSED, GGI_TranslateKey(&ev, &keysym));
+ break;
+ case evKeyRelease:
+ posted += SDL_PrivateKeyboard(SDL_RELEASED, GGI_TranslateKey(&ev, &keysym));
+ break;
+ case evCommand:
+ fprintf(stderr, "Command event %x recieved\n", ev.cmd.code);
+ break;
+ default:
+ fprintf(stderr, "Unhandled event type %d\n", ev.any.type);
+ break;
+ }
+ }
+
+}
+
+void GGI_InitOSKeymap(_THIS)
+{
+ int i;
+
+ /* Initialize the GGI key translation table */
+ for ( i=0; i<SDL_arraysize(keymap); ++i )
+ keymap[i] = SDLK_UNKNOWN;
+
+ keymap[SCANCODE_ESCAPE] = SDLK_ESCAPE;
+ keymap[SCANCODE_1] = SDLK_1;
+ keymap[SCANCODE_2] = SDLK_2;
+ keymap[SCANCODE_3] = SDLK_3;
+ keymap[SCANCODE_4] = SDLK_4;
+ keymap[SCANCODE_5] = SDLK_5;
+ keymap[SCANCODE_6] = SDLK_6;
+ keymap[SCANCODE_7] = SDLK_7;
+ keymap[SCANCODE_8] = SDLK_8;
+ keymap[SCANCODE_9] = SDLK_9;
+ keymap[SCANCODE_0] = SDLK_0;
+ keymap[SCANCODE_MINUS] = SDLK_MINUS;
+ keymap[SCANCODE_EQUAL] = SDLK_EQUALS;
+ keymap[SCANCODE_BACKSPACE] = SDLK_BACKSPACE;
+ keymap[SCANCODE_TAB] = SDLK_TAB;
+ keymap[SCANCODE_Q] = SDLK_q;
+ keymap[SCANCODE_W] = SDLK_w;
+ keymap[SCANCODE_E] = SDLK_e;
+ keymap[SCANCODE_R] = SDLK_r;
+ keymap[SCANCODE_T] = SDLK_t;
+ keymap[SCANCODE_Y] = SDLK_y;
+ keymap[SCANCODE_U] = SDLK_u;
+ keymap[SCANCODE_I] = SDLK_i;
+ keymap[SCANCODE_O] = SDLK_o;
+ keymap[SCANCODE_P] = SDLK_p;
+ keymap[SCANCODE_BRACKET_LEFT] = SDLK_LEFTBRACKET;
+ keymap[SCANCODE_BRACKET_RIGHT] = SDLK_RIGHTBRACKET;
+ keymap[SCANCODE_ENTER] = SDLK_RETURN;
+ keymap[SCANCODE_LEFTCONTROL] = SDLK_LCTRL;
+ keymap[SCANCODE_A] = SDLK_a;
+ keymap[SCANCODE_S] = SDLK_s;
+ keymap[SCANCODE_D] = SDLK_d;
+ keymap[SCANCODE_F] = SDLK_f;
+ keymap[SCANCODE_G] = SDLK_g;
+ keymap[SCANCODE_H] = SDLK_h;
+ keymap[SCANCODE_J] = SDLK_j;
+ keymap[SCANCODE_K] = SDLK_k;
+ keymap[SCANCODE_L] = SDLK_l;
+ keymap[SCANCODE_SEMICOLON] = SDLK_SEMICOLON;
+ keymap[SCANCODE_APOSTROPHE] = SDLK_QUOTE;
+ keymap[SCANCODE_GRAVE] = SDLK_BACKQUOTE;
+ keymap[SCANCODE_LEFTSHIFT] = SDLK_LSHIFT;
+ keymap[SCANCODE_BACKSLASH] = SDLK_BACKSLASH;
+ keymap[SCANCODE_Z] = SDLK_z;
+ keymap[SCANCODE_X] = SDLK_x;
+ keymap[SCANCODE_C] = SDLK_c;
+ keymap[SCANCODE_V] = SDLK_v;
+ keymap[SCANCODE_B] = SDLK_b;
+ keymap[SCANCODE_N] = SDLK_n;
+ keymap[SCANCODE_M] = SDLK_m;
+ keymap[SCANCODE_COMMA] = SDLK_COMMA;
+ keymap[SCANCODE_PERIOD] = SDLK_PERIOD;
+ keymap[SCANCODE_SLASH] = SDLK_SLASH;
+ keymap[SCANCODE_RIGHTSHIFT] = SDLK_RSHIFT;
+ keymap[SCANCODE_KEYPADMULTIPLY] = SDLK_KP_MULTIPLY;
+ keymap[SCANCODE_LEFTALT] = SDLK_LALT;
+ keymap[SCANCODE_SPACE] = SDLK_SPACE;
+ keymap[SCANCODE_CAPSLOCK] = SDLK_CAPSLOCK;
+ keymap[SCANCODE_F1] = SDLK_F1;
+ keymap[SCANCODE_F2] = SDLK_F2;
+ keymap[SCANCODE_F3] = SDLK_F3;
+ keymap[SCANCODE_F4] = SDLK_F4;
+ keymap[SCANCODE_F5] = SDLK_F5;
+ keymap[SCANCODE_F6] = SDLK_F6;
+ keymap[SCANCODE_F7] = SDLK_F7;
+ keymap[SCANCODE_F8] = SDLK_F8;
+ keymap[SCANCODE_F9] = SDLK_F9;
+ keymap[SCANCODE_F10] = SDLK_F10;
+ keymap[SCANCODE_NUMLOCK] = SDLK_NUMLOCK;
+ keymap[SCANCODE_SCROLLLOCK] = SDLK_SCROLLOCK;
+ keymap[SCANCODE_KEYPAD7] = SDLK_KP7;
+ keymap[SCANCODE_CURSORUPLEFT] = SDLK_KP7;
+ keymap[SCANCODE_KEYPAD8] = SDLK_KP8;
+ keymap[SCANCODE_CURSORUP] = SDLK_KP8;
+ keymap[SCANCODE_KEYPAD9] = SDLK_KP9;
+ keymap[SCANCODE_CURSORUPRIGHT] = SDLK_KP9;
+ keymap[SCANCODE_KEYPADMINUS] = SDLK_KP_MINUS;
+ keymap[SCANCODE_KEYPAD4] = SDLK_KP4;
+ keymap[SCANCODE_CURSORLEFT] = SDLK_KP4;
+ keymap[SCANCODE_KEYPAD5] = SDLK_KP5;
+ keymap[SCANCODE_KEYPAD6] = SDLK_KP6;
+ keymap[SCANCODE_CURSORRIGHT] = SDLK_KP6;
+ keymap[SCANCODE_KEYPADPLUS] = SDLK_KP_PLUS;
+ keymap[SCANCODE_KEYPAD1] = SDLK_KP1;
+ keymap[SCANCODE_CURSORDOWNLEFT] = SDLK_KP1;
+ keymap[SCANCODE_KEYPAD2] = SDLK_KP2;
+ keymap[SCANCODE_CURSORDOWN] = SDLK_KP2;
+ keymap[SCANCODE_KEYPAD3] = SDLK_KP3;
+ keymap[SCANCODE_CURSORDOWNRIGHT] = SDLK_KP3;
+ keymap[SCANCODE_KEYPAD0] = SDLK_KP0;
+ keymap[SCANCODE_KEYPADPERIOD] = SDLK_KP_PERIOD;
+ keymap[SCANCODE_LESS] = SDLK_LESS;
+ keymap[SCANCODE_F11] = SDLK_F11;
+ keymap[SCANCODE_F12] = SDLK_F12;
+ keymap[SCANCODE_KEYPADENTER] = SDLK_KP_ENTER;
+ keymap[SCANCODE_RIGHTCONTROL] = SDLK_RCTRL;
+ keymap[SCANCODE_CONTROL] = SDLK_RCTRL;
+ keymap[SCANCODE_KEYPADDIVIDE] = SDLK_KP_DIVIDE;
+ keymap[SCANCODE_PRINTSCREEN] = SDLK_PRINT;
+ keymap[SCANCODE_RIGHTALT] = SDLK_RALT;
+ keymap[SCANCODE_BREAK] = SDLK_BREAK;
+ keymap[SCANCODE_BREAK_ALTERNATIVE] = SDLK_UNKNOWN;
+ keymap[SCANCODE_HOME] = SDLK_HOME;
+ keymap[SCANCODE_CURSORBLOCKUP] = SDLK_UP;
+ keymap[SCANCODE_PAGEUP] = SDLK_PAGEUP;
+ keymap[SCANCODE_CURSORBLOCKLEFT] = SDLK_LEFT;
+ keymap[SCANCODE_CURSORBLOCKRIGHT] = SDLK_RIGHT;
+ keymap[SCANCODE_END] = SDLK_END;
+ keymap[SCANCODE_CURSORBLOCKDOWN] = SDLK_DOWN;
+ keymap[SCANCODE_PAGEDOWN] = SDLK_PAGEDOWN;
+ keymap[SCANCODE_INSERT] = SDLK_INSERT;
+ keymap[SCANCODE_REMOVE] = SDLK_DELETE;
+ keymap[119] = SDLK_PAUSE;
+ keymap[SCANCODE_RIGHTWIN] = SDLK_RSUPER;
+ keymap[SCANCODE_LEFTWIN] = SDLK_LSUPER;
+ keymap[127] = SDLK_MENU;
+}
+
+
+
+static SDL_keysym *GGI_TranslateKey(gii_event *ev, SDL_keysym *keysym)
+{
+ /* Set the keysym information */
+ keysym->scancode = ev->key.button;
+ keysym->sym = keymap[ev->key.button];
+ keysym->mod = KMOD_NONE;
+
+ /* If UNICODE is on, get the UNICODE value for the key */
+ keysym->unicode = 0;
+ if (SDL_TranslateUNICODE)
+ {
+ keysym->unicode = GII_UNICODE(ev->key.sym);
+ }
+
+ return keysym;
+}
diff --git a/distrib/sdl-1.2.15/src/video/ggi/SDL_ggievents_c.h b/distrib/sdl-1.2.15/src/video/ggi/SDL_ggievents_c.h
new file mode 100755
index 0000000..2c66106
--- /dev/null
+++ b/distrib/sdl-1.2.15/src/video/ggi/SDL_ggievents_c.h
@@ -0,0 +1,29 @@
+/*
+ SDL - Simple DirectMedia Layer
+ Copyright (C) 1997-2012 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 "SDL_ggivideo.h"
+
+/* Functions to be exported */
+extern void GGI_InitOSKeymap(_THIS);
+extern void GGI_PumpEvents(_THIS);
+
diff --git a/distrib/sdl-1.2.15/src/video/ggi/SDL_ggikeys.h b/distrib/sdl-1.2.15/src/video/ggi/SDL_ggikeys.h
new file mode 100644
index 0000000..2868ee6
--- /dev/null
+++ b/distrib/sdl-1.2.15/src/video/ggi/SDL_ggikeys.h
@@ -0,0 +1,135 @@
+
+#define SCANCODE_ESCAPE 1
+
+#define SCANCODE_1 2
+#define SCANCODE_2 3
+#define SCANCODE_3 4
+#define SCANCODE_4 5
+#define SCANCODE_5 6
+#define SCANCODE_6 7
+#define SCANCODE_7 8
+#define SCANCODE_8 9
+#define SCANCODE_9 10
+#define SCANCODE_0 11
+
+#define SCANCODE_MINUS 12
+#define SCANCODE_EQUAL 13
+
+#define SCANCODE_BACKSPACE 14
+#define SCANCODE_TAB 15
+
+#define SCANCODE_Q 16
+#define SCANCODE_W 17
+#define SCANCODE_E 18
+#define SCANCODE_R 19
+#define SCANCODE_T 20
+#define SCANCODE_Y 21
+#define SCANCODE_U 22
+#define SCANCODE_I 23
+#define SCANCODE_O 24
+#define SCANCODE_P 25
+#define SCANCODE_BRACKET_LEFT 26
+#define SCANCODE_BRACKET_RIGHT 27
+
+#define SCANCODE_ENTER 28
+
+#define SCANCODE_LEFTCONTROL 29
+
+#define SCANCODE_A 30
+#define SCANCODE_S 31
+#define SCANCODE_D 32
+#define SCANCODE_F 33
+#define SCANCODE_G 34
+#define SCANCODE_H 35
+#define SCANCODE_J 36
+#define SCANCODE_K 37
+#define SCANCODE_L 38
+#define SCANCODE_SEMICOLON 39
+#define SCANCODE_APOSTROPHE 40
+#define SCANCODE_GRAVE 41
+
+#define SCANCODE_LEFTSHIFT 42
+#define SCANCODE_BACKSLASH 43
+
+#define SCANCODE_Z 44
+#define SCANCODE_X 45
+#define SCANCODE_C 46
+#define SCANCODE_V 47
+#define SCANCODE_B 48
+#define SCANCODE_N 49
+#define SCANCODE_M 50
+#define SCANCODE_COMMA 51
+#define SCANCODE_PERIOD 52
+#define SCANCODE_SLASH 53
+
+#define SCANCODE_RIGHTSHIFT 54
+#define SCANCODE_KEYPADMULTIPLY 55
+
+#define SCANCODE_LEFTALT 56
+#define SCANCODE_SPACE 57
+#define SCANCODE_CAPSLOCK 58
+
+#define SCANCODE_F1 59
+#define SCANCODE_F2 60
+#define SCANCODE_F3 61
+#define SCANCODE_F4 62
+#define SCANCODE_F5 63
+#define SCANCODE_F6 64
+#define SCANCODE_F7 65
+#define SCANCODE_F8 66
+#define SCANCODE_F9 67
+#define SCANCODE_F10 68
+
+#define SCANCODE_NUMLOCK 69
+#define SCANCODE_SCROLLLOCK 70
+
+#define SCANCODE_KEYPAD7 71
+#define SCANCODE_CURSORUPLEFT 71
+#define SCANCODE_KEYPAD8 72
+#define SCANCODE_CURSORUP 72
+#define SCANCODE_KEYPAD9 73
+#define SCANCODE_CURSORUPRIGHT 73
+#define SCANCODE_KEYPADMINUS 74
+#define SCANCODE_KEYPAD4 75
+#define SCANCODE_CURSORLEFT 75
+#define SCANCODE_KEYPAD5 76
+#define SCANCODE_KEYPAD6 77
+#define SCANCODE_CURSORRIGHT 77
+#define SCANCODE_KEYPADPLUS 78
+#define SCANCODE_KEYPAD1 79
+#define SCANCODE_CURSORDOWNLEFT 79
+#define SCANCODE_KEYPAD2 80
+#define SCANCODE_CURSORDOWN 80
+#define SCANCODE_KEYPAD3 81
+#define SCANCODE_CURSORDOWNRIGHT 81
+#define SCANCODE_KEYPAD0 82
+#define SCANCODE_KEYPADPERIOD 83
+
+#define SCANCODE_LESS 86
+
+#define SCANCODE_F11 87
+#define SCANCODE_F12 88
+
+#define SCANCODE_KEYPADENTER 96
+#define SCANCODE_RIGHTCONTROL 97
+#define SCANCODE_CONTROL 97
+#define SCANCODE_KEYPADDIVIDE 98
+#define SCANCODE_PRINTSCREEN 99
+#define SCANCODE_RIGHTALT 100
+#define SCANCODE_BREAK 101 /* Beware: is 119 */
+#define SCANCODE_BREAK_ALTERNATIVE 119 /* on some keyboards! */
+
+#define SCANCODE_HOME 102
+#define SCANCODE_CURSORBLOCKUP 90 /* Cursor key block */
+#define SCANCODE_PAGEUP 104
+#define SCANCODE_CURSORBLOCKLEFT 92 /* Cursor key block */
+#define SCANCODE_CURSORBLOCKRIGHT 94 /* Cursor key block */
+#define SCANCODE_END 107
+#define SCANCODE_CURSORBLOCKDOWN 108 /* Cursor key block */
+#define SCANCODE_PAGEDOWN 109
+#define SCANCODE_INSERT 110
+#define SCANCODE_REMOVE 111
+
+#define SCANCODE_RIGHTWIN 126
+#define SCANCODE_LEFTWIN 125
+
diff --git a/distrib/sdl-1.2.15/src/video/ggi/SDL_ggimouse.c b/distrib/sdl-1.2.15/src/video/ggi/SDL_ggimouse.c
new file mode 100644
index 0000000..52c5337
--- /dev/null
+++ b/distrib/sdl-1.2.15/src/video/ggi/SDL_ggimouse.c
@@ -0,0 +1,32 @@
+/*
+ SDL - Simple DirectMedia Layer
+ Copyright (C) 1997-2012 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 "SDL_mouse.h"
+#include "../../events/SDL_events_c.h"
+#include "SDL_ggimouse_c.h"
+
+
+/* The implementation dependent data for the window manager cursor */
+struct WMcursor {
+ int unused;
+};
diff --git a/distrib/sdl-1.2.15/src/video/ggi/SDL_ggimouse_c.h b/distrib/sdl-1.2.15/src/video/ggi/SDL_ggimouse_c.h
new file mode 100755
index 0000000..c0ce295
--- /dev/null
+++ b/distrib/sdl-1.2.15/src/video/ggi/SDL_ggimouse_c.h
@@ -0,0 +1,26 @@
+/*
+ SDL - Simple DirectMedia Layer
+ Copyright (C) 1997-2012 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 "SDL_ggivideo.h"
+
+/* Functions to be exported */
diff --git a/distrib/sdl-1.2.15/src/video/ggi/SDL_ggivideo.c b/distrib/sdl-1.2.15/src/video/ggi/SDL_ggivideo.c
new file mode 100644
index 0000000..face495
--- /dev/null
+++ b/distrib/sdl-1.2.15/src/video/ggi/SDL_ggivideo.c
@@ -0,0 +1,378 @@
+/*
+ SDL - Simple DirectMedia Layer
+ Copyright (C) 1997-2012 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"
+
+/* GGI-based SDL video driver implementation.
+*/
+
+#include <fcntl.h>
+#include <unistd.h>
+#include <sys/mman.h>
+
+#include <ggi/ggi.h>
+#include <ggi/gii.h>
+
+#include "SDL_video.h"
+#include "SDL_mouse.h"
+#include "../SDL_sysvideo.h"
+#include "../SDL_pixels_c.h"
+#include "../../events/SDL_events_c.h"
+#include "SDL_ggivideo.h"
+#include "SDL_ggimouse_c.h"
+#include "SDL_ggievents_c.h"
+
+
+struct private_hwdata
+{
+ ggi_visual_t vis;
+};
+
+ggi_visual_t VIS;
+
+/* Initialization/Query functions */
+static int GGI_VideoInit(_THIS, SDL_PixelFormat *vformat);
+static SDL_Rect **GGI_ListModes(_THIS, SDL_PixelFormat *format, Uint32 flags);
+static SDL_Surface *GGI_SetVideoMode(_THIS, SDL_Surface *current, int width, int height, int bpp, Uint32 flags);
+static int GGI_SetColors(_THIS, int firstcolor, int ncolors,
+ SDL_Color *colors);
+static void GGI_VideoQuit(_THIS);
+
+/* Hardware surface functions */
+static int GGI_AllocHWSurface(_THIS, SDL_Surface *surface);
+static int GGI_LockHWSurface(_THIS, SDL_Surface *surface);
+static void GGI_UnlockHWSurface(_THIS, SDL_Surface *surface);
+static void GGI_FreeHWSurface(_THIS, SDL_Surface *surface);
+
+/* GGI driver bootstrap functions */
+
+static int GGI_Available(void)
+{
+ ggi_visual_t *vis;
+
+ vis = NULL;
+ if (ggiInit() == 0) {
+ vis = ggiOpen(NULL);
+ if (vis != NULL) {
+ ggiClose(vis);
+ }
+ }
+ return (vis != NULL);
+}
+
+static void GGI_DeleteDevice(SDL_VideoDevice *device)
+{
+ SDL_free(device->hidden);
+ SDL_free(device);
+}
+
+static SDL_VideoDevice *GGI_CreateDevice(int devindex)
+{
+ SDL_VideoDevice *device;
+
+ /* Initialize all variables that we clean on shutdown */
+ device = (SDL_VideoDevice *)SDL_malloc(sizeof(SDL_VideoDevice));
+ if ( device ) {
+ SDL_memset(device, 0, (sizeof *device));
+ device->hidden = (struct SDL_PrivateVideoData *)
+ SDL_malloc((sizeof *device->hidden));
+ }
+ if ( (device == NULL) || (device->hidden == NULL) ) {
+ SDL_OutOfMemory();
+ if ( device ) {
+ SDL_free(device);
+ }
+ return(0);
+ }
+ SDL_memset(device->hidden, 0, (sizeof *device->hidden));
+
+ /* Set the function pointers */
+ device->VideoInit = GGI_VideoInit;
+ device->ListModes = GGI_ListModes;
+ device->SetVideoMode = GGI_SetVideoMode;
+ device->SetColors = GGI_SetColors;
+ device->UpdateRects = NULL;
+ device->VideoQuit = GGI_VideoQuit;
+ device->AllocHWSurface = GGI_AllocHWSurface;
+ device->CheckHWBlit = NULL;
+ device->FillHWRect = NULL;
+ device->SetHWColorKey = NULL;
+ device->SetHWAlpha = NULL;
+ device->LockHWSurface = GGI_LockHWSurface;
+ device->UnlockHWSurface = GGI_UnlockHWSurface;
+ device->FlipHWSurface = NULL;
+ device->FreeHWSurface = GGI_FreeHWSurface;
+ device->SetCaption = NULL;
+ device->SetIcon = NULL;
+ device->IconifyWindow = NULL;
+ device->GrabInput = NULL;
+ device->GetWMInfo = NULL;
+ device->InitOSKeymap = GGI_InitOSKeymap;
+ device->PumpEvents = GGI_PumpEvents;
+
+ device->free = GGI_DeleteDevice;
+
+ return device;
+}
+
+VideoBootStrap GGI_bootstrap = {
+ "ggi", "General Graphics Interface (GGI)",
+ GGI_Available, GGI_CreateDevice
+};
+
+
+static SDL_Rect video_mode;
+static SDL_Rect *SDL_modelist[4] = { NULL, NULL, NULL, NULL };
+
+int GGI_VideoInit(_THIS, SDL_PixelFormat *vformat)
+{
+ ggi_mode mode =
+ {
+ 1,
+ { GGI_AUTO, GGI_AUTO },
+ { GGI_AUTO, GGI_AUTO },
+ { 0, 0 },
+ GT_AUTO,
+ { GGI_AUTO, GGI_AUTO }
+ };
+ struct private_hwdata *priv;
+ ggi_color pal[256], map[256];
+ const ggi_directbuffer *db;
+ int err, num_bufs;
+ ggi_pixel white, black;
+
+ priv = SDL_malloc(sizeof(struct private_hwdata));
+ if (priv == NULL)
+ {
+ SDL_SetError("Unhandled GGI mode type!\n");
+ GGI_VideoQuit(NULL);
+ }
+
+ if (ggiInit() != 0)
+ {
+ SDL_SetError("Unable to initialize GGI!\n");
+ GGI_VideoQuit(NULL);
+ }
+
+ VIS = ggiOpen(NULL);
+ if (VIS == NULL)
+ {
+ SDL_SetError("Unable to open default GGI visual!\n");
+ ggiExit();
+ GGI_VideoQuit(NULL);
+ }
+
+ ggiSetFlags(VIS, GGIFLAG_ASYNC);
+
+ /* Validate mode, autodetecting any GGI_AUTO or GT_AUTO fields */
+ ggiCheckMode(VIS, &mode);
+
+ /* At this point we should have a valid mode - try to set it */
+ err = ggiSetMode(VIS, &mode);
+
+ /* If we couldn't set _any_ modes, something is very wrong */
+ if (err)
+ {
+ SDL_SetError("Can't set a mode!\n");
+ ggiClose(VIS);
+ ggiExit();
+ GGI_VideoQuit(NULL);
+ }
+
+ /* Determine the current screen size */
+ this->info.current_w = mode.virt.x;
+ this->info.current_h = mode.virt.y;
+
+ /* Set a palette for palletized modes */
+ if (GT_SCHEME(mode.graphtype) == GT_PALETTE)
+ {
+ ggiSetColorfulPalette(VIS);
+ ggiGetPalette(VIS, 0, 1 << vformat->BitsPerPixel, pal);
+ }
+
+ /* Now we try to get the DirectBuffer info, which determines whether
+ * SDL can access hardware surfaces directly. */
+
+ num_bufs = ggiDBGetNumBuffers(VIS);
+
+ if (num_bufs > 0)
+ {
+ db = ggiDBGetBuffer(VIS, 0); /* Only handle one DB for now */
+
+ vformat->BitsPerPixel = db->buffer.plb.pixelformat->depth;
+
+ vformat->Rmask = db->buffer.plb.pixelformat->red_mask;
+ vformat->Gmask = db->buffer.plb.pixelformat->green_mask;
+ vformat->Bmask = db->buffer.plb.pixelformat->blue_mask;
+
+ /* Fill in our hardware acceleration capabilities */
+
+ this->info.wm_available = 0;
+ this->info.hw_available = 1;
+ this->info.video_mem = db->buffer.plb.stride * mode.virt.y;
+ }
+
+ video_mode.x = 0;
+ video_mode.y = 0;
+ video_mode.w = mode.virt.x;
+ video_mode.h = mode.virt.y;
+ SDL_modelist[((vformat->BitsPerPixel + 7) / 8) - 1] = &video_mode;
+
+ /* We're done! */
+ return(0);
+}
+
+static SDL_Rect **GGI_ListModes(_THIS, SDL_PixelFormat *format, Uint32 flags)
+{
+ return(&SDL_modelist[((format->BitsPerPixel + 7) / 8) - 1]);
+}
+
+/* Various screen update functions available */
+static void GGI_DirectUpdate(_THIS, int numrects, SDL_Rect *rects);
+
+SDL_Surface *GGI_SetVideoMode(_THIS, SDL_Surface *current, int width, int height, int bpp, Uint32 flags)
+{
+ ggi_mode mode =
+ {
+ 1,
+ { GGI_AUTO, GGI_AUTO },
+ { GGI_AUTO, GGI_AUTO },
+ { 0, 0 },
+ GT_AUTO,
+ { GGI_AUTO, GGI_AUTO }
+ };
+ const ggi_directbuffer *db;
+ ggi_color pal[256];
+ int err;
+
+ fprintf(stderr, "GGI_SetVideoMode()\n");
+
+ mode.visible.x = mode.virt.x = width;
+ mode.visible.y = mode.virt.y = height;
+
+ /* Translate requested SDL bit depth into a GGI mode */
+ switch (bpp)
+ {
+ case 1: mode.graphtype = GT_1BIT; break;
+ case 2: mode.graphtype = GT_2BIT; break;
+ case 4: mode.graphtype = GT_4BIT; break;
+ case 8: mode.graphtype = GT_8BIT; break;
+ case 15: mode.graphtype = GT_15BIT; break;
+ case 16: mode.graphtype = GT_16BIT; break;
+ case 24: mode.graphtype = GT_24BIT; break;
+ case 32: mode.graphtype = GT_32BIT; break;
+ default:
+ SDL_SetError("Unknown SDL bit depth, using GT_AUTO....\n");
+ mode.graphtype = GT_AUTO;
+ }
+
+ /* Validate mode, autodetecting any GGI_AUTO or GT_AUTO fields */
+ ggiCheckMode(VIS, &mode);
+
+ /* At this point we should have a valid mode - try to set it */
+ err = ggiSetMode(VIS, &mode);
+
+ /* If we couldn't set _any_ modes, something is very wrong */
+ if (err)
+ {
+ SDL_SetError("Can't set a mode!\n");
+ ggiClose(VIS);
+ ggiExit();
+ GGI_VideoQuit(NULL);
+ }
+
+ /* Set a palette for palletized modes */
+ if (GT_SCHEME(mode.graphtype) == GT_PALETTE)
+ {
+ ggiSetColorfulPalette(VIS);
+ ggiGetPalette(VIS, 0, 1 << bpp, pal);
+ }
+
+ db = ggiDBGetBuffer(VIS, 0);
+
+ /* Set up the new mode framebuffer */
+ current->flags = (SDL_FULLSCREEN | SDL_HWSURFACE);
+ current->w = mode.virt.x;
+ current->h = mode.virt.y;
+ current->pitch = db->buffer.plb.stride;
+ current->pixels = db->read;
+
+ /* Set the blit function */
+ this->UpdateRects = GGI_DirectUpdate;
+
+ /* We're done */
+ return(current);
+}
+
+static int GGI_AllocHWSurface(_THIS, SDL_Surface *surface)
+{
+ return(-1);
+}
+static void GGI_FreeHWSurface(_THIS, SDL_Surface *surface)
+{
+ return;
+}
+static int GGI_LockHWSurface(_THIS, SDL_Surface *surface)
+{
+ return(0);
+}
+static void GGI_UnlockHWSurface(_THIS, SDL_Surface *surface)
+{
+ return;
+}
+
+static void GGI_DirectUpdate(_THIS, int numrects, SDL_Rect *rects)
+{
+ int i;
+
+/* ggiFlush(VIS); */
+
+ for (i = 0; i < numrects; i++)
+ {
+ ggiFlushRegion(VIS, rects[i].x, rects[i].y, rects[i].w, rects[i].h);
+ }
+ return;
+}
+
+int GGI_SetColors(_THIS, int firstcolor, int ncolors, SDL_Color *colors)
+{
+ int i;
+ ggi_color pal[256];
+
+ /* Set up the colormap */
+ for (i = 0; i < ncolors; i++)
+ {
+ pal[i].r = (colors[i].r << 8) | colors[i].r;
+ pal[i].g = (colors[i].g << 8) | colors[i].g;
+ pal[i].b = (colors[i].b << 8) | colors[i].b;
+ }
+
+ ggiSetPalette(VIS, firstcolor, ncolors, pal);
+
+ return 1;
+}
+
+void GGI_VideoQuit(_THIS)
+{
+}
+void GGI_FinalQuit(void)
+{
+}
diff --git a/distrib/sdl-1.2.15/src/video/ggi/SDL_ggivideo.h b/distrib/sdl-1.2.15/src/video/ggi/SDL_ggivideo.h
new file mode 100644
index 0000000..014dd09
--- /dev/null
+++ b/distrib/sdl-1.2.15/src/video/ggi/SDL_ggivideo.h
@@ -0,0 +1,48 @@
+/*
+ SDL - Simple DirectMedia Layer
+ Copyright (C) 1997-2012 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_ggivideo_h
+#define _SDL_ggivideo_h
+
+#include <ggi/ggi.h>
+
+#include "SDL_mouse.h"
+#include "../SDL_sysvideo.h"
+
+#define _THIS SDL_VideoDevice *this
+
+/* Private display data */
+
+struct SDL_PrivateVideoData
+{
+ ggi_visual_t *ggivis;
+};
+
+extern ggi_visual_t VIS; /* FIXME: use the private data struct */
+
+extern int SDL_OpenKeyboard(void);
+extern void SDL_CloseKeyboard(void);
+extern int SDL_OpenMouse(void);
+extern void SDL_CloseMouse(void);
+
+#endif /* _SDL_ggivideo_h */