Mercurial > sdl-ios-xcode
annotate src/video/cybergfx/SDL_cgxvideo.h @ 172:37e3ca9254c7
Date: Sat, 8 Sep 2001 04:42:23 +0200
From: Max Horn <max@quendi.de>
Subject: SDL/OSX: Joystick; Better key handling
I just finished implementing improved keyhandling for OS X (in fact
the code should be easily ported to the "normal" MacOS part of SDL, I
just had no chance yet). Works like this:
First init the mapping table statically like before. Them, it queries
the OS for the "official" key table, then iterates over all 127
scancode and gets the associates ascii code. It ignores everythng
below 32 (has to, as it would lead to many problems if we did not...
e.g. both ESC and NUM LOCk produce an ascii code 27 on my keyboard),
and all stuff above 127 is mapped to SDLK_WORLD_* simply in the order
it is encountered.
In addition, caps lock is now working, too.
The code work flawless for me, but since I only have one keyboard, I
may have not encountered some serious problem... but I am pretty
confident that it is better than the old code in most cases.
The joystick driver works fine for me, too. I think it can be added
to CVS already. It would simply be helpful if more people would test
it. Hm, I wonder if Maelstrom or GLTron has Joystick support? That
would be a wonderful test application :)
I also took the liberty of modifying some text files like BUGS,
README.CVS, README.MacOSX (which now contains the OS X docs I long
promised)
author | Sam Lantinga <slouken@libsdl.org> |
---|---|
date | Tue, 11 Sep 2001 19:00:18 +0000 |
parents | 75a95f82bc1f |
children | e8157fcb3114 |
rev | line source |
---|---|
0 | 1 /* |
2 SDL - Simple DirectMedia Layer | |
3 Copyright (C) 1997, 1998, 1999, 2000, 2001 Sam Lantinga | |
4 | |
5 This library is free software; you can redistribute it and/or | |
6 modify it under the terms of the GNU Library General Public | |
7 License as published by the Free Software Foundation; either | |
8 version 2 of the License, or (at your option) any later version. | |
9 | |
10 This library is distributed in the hope that it will be useful, | |
11 but WITHOUT ANY WARRANTY; without even the implied warranty of | |
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
13 Library General Public License for more details. | |
14 | |
15 You should have received a copy of the GNU Library General Public | |
16 License along with this library; if not, write to the Free | |
17 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | |
18 | |
19 Sam Lantinga | |
20 slouken@devolution.com | |
21 */ | |
22 | |
23 #ifdef SAVE_RCSID | |
24 static char rcsid = | |
25 "@(#) $Id$"; | |
26 #endif | |
27 | |
28 #ifndef _SDL_cgxvideo_h | |
29 #define _SDL_cgxvideo_h | |
30 | |
31 | |
32 #include <stdio.h> | |
33 #include <stdlib.h> | |
34 #include <string.h> | |
35 | |
36 #include <exec/exec.h> | |
37 #include <cybergraphx/cybergraphics.h> | |
38 #include <graphics/scale.h> | |
39 #include <graphics/gfx.h> | |
40 #include <intuition/intuition.h> | |
41 #ifdef __SASC | |
42 #include <proto/exec.h> | |
43 #include <proto/cybergraphics.h> | |
44 #include <proto/graphics.h> | |
45 #include <proto/intuition.h> | |
46 #include <proto/console.h> | |
47 #else | |
48 #include <inline/exec.h> | |
49 #include <inline/cybergraphics.h> | |
50 #include <inline/graphics.h> | |
51 #include <inline/intuition.h> | |
52 #include <inline/console.h> | |
53 #endif | |
54 | |
55 #include "mydebug.h" | |
56 #include "SDL_mouse.h" | |
57 #include "SDL_sysvideo.h" | |
58 | |
59 #define USE_CGX_WRITELUTPIXEL | |
60 | |
61 /* Hidden "this" pointer for the video functions */ | |
62 #define _THIS SDL_VideoDevice *this | |
63 | |
64 /* Private display data */ | |
65 struct SDL_PrivateVideoData { | |
66 struct Screen *Public_Display; /* Used for events and window management */ | |
67 struct Screen *GFX_Display; /* Used for graphics and colormap stuff */ | |
68 Uint32 SDL_VisualUnused; /* The visual used by our window */ | |
69 struct Window *SDL_Window; /* Shared by both displays (no X security?) */ | |
70 unsigned char *BlankCursor; /* The invisible cursor */ | |
71 | |
21
75a95f82bc1f
Updated the Amiga OS port of SDL (thanks Gabriele)
Sam Lantinga <slouken@lokigames.com>
parents:
0
diff
changeset
|
72 char *SDL_windowid; /* Flag: true if we have been passed a window */ |
75a95f82bc1f
Updated the Amiga OS port of SDL (thanks Gabriele)
Sam Lantinga <slouken@lokigames.com>
parents:
0
diff
changeset
|
73 |
0 | 74 /* The variables used for displaying graphics */ |
75 Uint8 *Ximage; /* The X image for our window */ | |
76 int swap_pixels; /* Flag: true if display is swapped endian */ | |
77 | |
78 /* The current width and height of the fullscreen mode */ | |
79 int current_w; | |
80 int current_h; | |
81 | |
82 /* Support for internal mouse warping */ | |
83 struct { | |
84 int x; | |
85 int y; | |
86 } mouse_last; | |
87 struct { | |
88 int numerator; | |
89 int denominator; | |
90 int threshold; | |
91 } mouse_accel; | |
92 int mouse_relative; | |
93 | |
94 /* The current list of available video modes */ | |
95 SDL_Rect **modelist; | |
96 | |
97 /* available visuals of interest to us, sorted deepest first */ | |
98 struct { | |
99 Uint32 visual; | |
100 int depth; /* number of significant bits/pixel */ | |
101 int bpp; /* pixel quantum in bits */ | |
102 } visuals[5]; /* at most entries for 8, 15, 16, 24 */ | |
103 int nvisuals; | |
104 | |
105 Uint32 vis; /* current visual in use */ | |
106 int depth; /* current visual depth (not bpp) */ | |
107 int BytesPerPixel; | |
108 int currently_fullscreen,same_format,dbuffer; | |
109 | |
110 /* Automatic mode switching support (entering/leaving fullscreen) */ | |
111 Uint32 switch_waiting; | |
112 Uint32 switch_time; | |
113 | |
114 /* Prevent too many XSync() calls */ | |
115 int blit_queued; | |
116 | |
117 /* Colormap handling */ | |
118 LONG Pens; | |
119 Sint32 *XPixels; /* A list of pixels that have been allocated, the size depends on the screen format */ | |
120 struct ScreenBuffer *SB[2]; | |
121 struct RastPort *RP; | |
122 short *iconcolors; /* List of colors used by the icon */ | |
123 }; | |
124 | |
125 /* Old variable names */ | |
126 #define local_X11 (this->hidden->local_X11) | |
127 #define SDL_Display (this->hidden->Public_Display) | |
128 #define GFX_Display (this->hidden->GFX_Display) | |
129 #define SDL_Screen DefaultScreen(this->hidden->Public_Display) | |
130 | |
131 #define SDL_Visual (this->hidden->vis) | |
132 | |
133 #define SDL_Root RootWindow(SDL_Display, SDL_Screen) | |
134 #define WMwindow (this->hidden->WMwindow) | |
135 #define FSwindow (this->hidden->FSwindow) | |
136 #define SDL_Window (this->hidden->SDL_Window) | |
137 #define WM_DELETE_WINDOW (this->hidden->WM_DELETE_WINDOW) | |
138 #define SDL_BlankCursor (this->hidden->BlankCursor) | |
21
75a95f82bc1f
Updated the Amiga OS port of SDL (thanks Gabriele)
Sam Lantinga <slouken@lokigames.com>
parents:
0
diff
changeset
|
139 #define SDL_windowid (this->hidden->SDL_windowid) |
0 | 140 #define SDL_Ximage (this->hidden->Ximage) |
141 #define SDL_GC (this->hidden->gc) | |
142 #define swap_pixels (this->hidden->swap_pixels) | |
143 #define current_w (this->hidden->current_w) | |
144 #define current_h (this->hidden->current_h) | |
145 #define mouse_last (this->hidden->mouse_last) | |
146 #define mouse_accel (this->hidden->mouse_accel) | |
147 #define mouse_relative (this->hidden->mouse_relative) | |
148 #define SDL_modelist (this->hidden->modelist) | |
149 #define SDL_RastPort (this->hidden->RP) | |
150 #define saved_mode (this->hidden->saved_mode) | |
151 #define saved_view (this->hidden->saved_view) | |
152 #define currently_fullscreen (this->hidden->currently_fullscreen) | |
153 #define blit_queued (this->hidden->blit_queued) | |
154 #define SDL_DisplayColormap (this->hidden->GFX_Display->ViewPort.ColorMap) | |
155 #define SDL_XPixels (this->hidden->XPixels) | |
156 #define SDL_iconcolors (this->hidden->iconcolors) | |
157 | |
21
75a95f82bc1f
Updated the Amiga OS port of SDL (thanks Gabriele)
Sam Lantinga <slouken@lokigames.com>
parents:
0
diff
changeset
|
158 /* Used to get the X cursor from a window-manager specific cursor */ |
75a95f82bc1f
Updated the Amiga OS port of SDL (thanks Gabriele)
Sam Lantinga <slouken@lokigames.com>
parents:
0
diff
changeset
|
159 // extern Cursor SDL_GetWMXCursor(WMcursor *cursor); |
75a95f82bc1f
Updated the Amiga OS port of SDL (thanks Gabriele)
Sam Lantinga <slouken@lokigames.com>
parents:
0
diff
changeset
|
160 |
0 | 161 extern int CGX_CreateWindow(_THIS, SDL_Surface *screen, |
162 int w, int h, int bpp, Uint32 flags); | |
163 extern int CGX_ResizeWindow(_THIS, | |
164 SDL_Surface *screen, int w, int h, Uint32 flags); | |
165 | |
166 extern void CGX_DestroyWindow(_THIS, SDL_Surface *screen); | |
167 | |
168 extern struct Library *CyberGfxBase; | |
169 extern struct IntuitionBase *IntuitionBase; | |
170 extern struct GfxBase *GfxBase; | |
171 extern struct ExecBase *SysBase; | |
172 extern struct DosLibrary *DOSBase; | |
173 | |
174 struct private_hwdata | |
175 { | |
176 struct BitMap *bmap; | |
177 APTR lock; | |
178 struct SDL_VideoDevice *videodata; | |
179 APTR mask; | |
180 }; | |
181 | |
182 int CGX_CheckHWBlit(_THIS,SDL_Surface *src,SDL_Surface *dst); | |
183 int CGX_FillHWRect(_THIS,SDL_Surface *dst,SDL_Rect *dstrect,Uint32 color); | |
184 int CGX_SetHWColorKey(_THIS,SDL_Surface *surface, Uint32 key); | |
185 #endif /* _SDL_x11video_h */ |