annotate src/video/cybergfx/SDL_cgxyuv.c @ 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
21
75a95f82bc1f Updated the Amiga OS port of SDL (thanks Gabriele)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
1 /*
75a95f82bc1f Updated the Amiga OS port of SDL (thanks Gabriele)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
2 SDL - Simple DirectMedia Layer
75a95f82bc1f Updated the Amiga OS port of SDL (thanks Gabriele)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
3 Copyright (C) 1997, 1998, 1999, 2000, 2001 Sam Lantinga
75a95f82bc1f Updated the Amiga OS port of SDL (thanks Gabriele)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
4
75a95f82bc1f Updated the Amiga OS port of SDL (thanks Gabriele)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
5 This library is free software; you can redistribute it and/or
75a95f82bc1f Updated the Amiga OS port of SDL (thanks Gabriele)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
6 modify it under the terms of the GNU Library General Public
75a95f82bc1f Updated the Amiga OS port of SDL (thanks Gabriele)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
7 License as published by the Free Software Foundation; either
75a95f82bc1f Updated the Amiga OS port of SDL (thanks Gabriele)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
8 version 2 of the License, or (at your option) any later version.
75a95f82bc1f Updated the Amiga OS port of SDL (thanks Gabriele)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
9
75a95f82bc1f Updated the Amiga OS port of SDL (thanks Gabriele)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
10 This library is distributed in the hope that it will be useful,
75a95f82bc1f Updated the Amiga OS port of SDL (thanks Gabriele)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
75a95f82bc1f Updated the Amiga OS port of SDL (thanks Gabriele)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
75a95f82bc1f Updated the Amiga OS port of SDL (thanks Gabriele)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
13 Library General Public License for more details.
75a95f82bc1f Updated the Amiga OS port of SDL (thanks Gabriele)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
14
75a95f82bc1f Updated the Amiga OS port of SDL (thanks Gabriele)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
15 You should have received a copy of the GNU Library General Public
75a95f82bc1f Updated the Amiga OS port of SDL (thanks Gabriele)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
16 License along with this library; if not, write to the Free
75a95f82bc1f Updated the Amiga OS port of SDL (thanks Gabriele)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
17 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
75a95f82bc1f Updated the Amiga OS port of SDL (thanks Gabriele)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
18
75a95f82bc1f Updated the Amiga OS port of SDL (thanks Gabriele)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
19 Sam Lantinga
75a95f82bc1f Updated the Amiga OS port of SDL (thanks Gabriele)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
20 slouken@devolution.com
75a95f82bc1f Updated the Amiga OS port of SDL (thanks Gabriele)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
21 */
75a95f82bc1f Updated the Amiga OS port of SDL (thanks Gabriele)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
22
75a95f82bc1f Updated the Amiga OS port of SDL (thanks Gabriele)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
23 #ifdef SAVE_RCSID
75a95f82bc1f Updated the Amiga OS port of SDL (thanks Gabriele)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
24 static char rcsid =
75a95f82bc1f Updated the Amiga OS port of SDL (thanks Gabriele)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
25 "@(#) $Id$";
75a95f82bc1f Updated the Amiga OS port of SDL (thanks Gabriele)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
26 #endif
75a95f82bc1f Updated the Amiga OS port of SDL (thanks Gabriele)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
27
75a95f82bc1f Updated the Amiga OS port of SDL (thanks Gabriele)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
28 /* This is the XFree86 Xv extension implementation of YUV video overlays */
75a95f82bc1f Updated the Amiga OS port of SDL (thanks Gabriele)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
29
75a95f82bc1f Updated the Amiga OS port of SDL (thanks Gabriele)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
30 #ifdef XFREE86_XV
75a95f82bc1f Updated the Amiga OS port of SDL (thanks Gabriele)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
31
75a95f82bc1f Updated the Amiga OS port of SDL (thanks Gabriele)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
32 #include <stdlib.h>
75a95f82bc1f Updated the Amiga OS port of SDL (thanks Gabriele)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
33 #include <string.h>
75a95f82bc1f Updated the Amiga OS port of SDL (thanks Gabriele)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
34 #include <X11/Xlib.h>
75a95f82bc1f Updated the Amiga OS port of SDL (thanks Gabriele)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
35 #include <sys/ipc.h>
75a95f82bc1f Updated the Amiga OS port of SDL (thanks Gabriele)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
36 #include <sys/shm.h>
75a95f82bc1f Updated the Amiga OS port of SDL (thanks Gabriele)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
37 #include <X11/extensions/XShm.h>
75a95f82bc1f Updated the Amiga OS port of SDL (thanks Gabriele)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
38 #include <X11/extensions/Xvlib.h>
75a95f82bc1f Updated the Amiga OS port of SDL (thanks Gabriele)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
39
75a95f82bc1f Updated the Amiga OS port of SDL (thanks Gabriele)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
40 #include "SDL_error.h"
75a95f82bc1f Updated the Amiga OS port of SDL (thanks Gabriele)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
41 #include "SDL_video.h"
75a95f82bc1f Updated the Amiga OS port of SDL (thanks Gabriele)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
42 #include "SDL_x11yuv_c.h"
75a95f82bc1f Updated the Amiga OS port of SDL (thanks Gabriele)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
43 #include "SDL_yuvfuncs.h"
75a95f82bc1f Updated the Amiga OS port of SDL (thanks Gabriele)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
44
75a95f82bc1f Updated the Amiga OS port of SDL (thanks Gabriele)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
45 /* The functions used to manipulate software video overlays */
75a95f82bc1f Updated the Amiga OS port of SDL (thanks Gabriele)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
46 static struct private_yuvhwfuncs x11_yuvfuncs = {
75a95f82bc1f Updated the Amiga OS port of SDL (thanks Gabriele)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
47 X11_LockYUVOverlay,
75a95f82bc1f Updated the Amiga OS port of SDL (thanks Gabriele)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
48 X11_UnlockYUVOverlay,
75a95f82bc1f Updated the Amiga OS port of SDL (thanks Gabriele)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
49 X11_DisplayYUVOverlay,
75a95f82bc1f Updated the Amiga OS port of SDL (thanks Gabriele)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
50 X11_FreeYUVOverlay
75a95f82bc1f Updated the Amiga OS port of SDL (thanks Gabriele)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
51 };
75a95f82bc1f Updated the Amiga OS port of SDL (thanks Gabriele)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
52
75a95f82bc1f Updated the Amiga OS port of SDL (thanks Gabriele)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
53 struct private_yuvhwdata {
75a95f82bc1f Updated the Amiga OS port of SDL (thanks Gabriele)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
54 int port;
75a95f82bc1f Updated the Amiga OS port of SDL (thanks Gabriele)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
55 XShmSegmentInfo yuvshm;
75a95f82bc1f Updated the Amiga OS port of SDL (thanks Gabriele)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
56 XvImage *image;
75a95f82bc1f Updated the Amiga OS port of SDL (thanks Gabriele)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
57 };
75a95f82bc1f Updated the Amiga OS port of SDL (thanks Gabriele)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
58
75a95f82bc1f Updated the Amiga OS port of SDL (thanks Gabriele)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
59
75a95f82bc1f Updated the Amiga OS port of SDL (thanks Gabriele)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
60 SDL_Overlay *X11_CreateYUVOverlay(_THIS, int width, int height, Uint32 format, SDL_Surface *display)
75a95f82bc1f Updated the Amiga OS port of SDL (thanks Gabriele)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
61 {
75a95f82bc1f Updated the Amiga OS port of SDL (thanks Gabriele)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
62 SDL_Overlay *overlay;
75a95f82bc1f Updated the Amiga OS port of SDL (thanks Gabriele)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
63 struct private_yuvhwdata *hwdata;
75a95f82bc1f Updated the Amiga OS port of SDL (thanks Gabriele)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
64 int xv_port;
75a95f82bc1f Updated the Amiga OS port of SDL (thanks Gabriele)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
65 int i, j;
75a95f82bc1f Updated the Amiga OS port of SDL (thanks Gabriele)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
66 int adaptors;
75a95f82bc1f Updated the Amiga OS port of SDL (thanks Gabriele)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
67 XvAdaptorInfo *ainfo;
75a95f82bc1f Updated the Amiga OS port of SDL (thanks Gabriele)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
68 XShmSegmentInfo *yuvshm;
75a95f82bc1f Updated the Amiga OS port of SDL (thanks Gabriele)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
69
75a95f82bc1f Updated the Amiga OS port of SDL (thanks Gabriele)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
70 xv_port = -1;
75a95f82bc1f Updated the Amiga OS port of SDL (thanks Gabriele)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
71 if ( (Success == XvQueryExtension(GFX_Display, &j, &j, &j, &j, &j)) &&
75a95f82bc1f Updated the Amiga OS port of SDL (thanks Gabriele)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
72 (Success == XvQueryAdaptors(GFX_Display,
75a95f82bc1f Updated the Amiga OS port of SDL (thanks Gabriele)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
73 RootWindow(GFX_Display, SDL_Screen),
75a95f82bc1f Updated the Amiga OS port of SDL (thanks Gabriele)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
74 &adaptors, &ainfo)) ) {
75a95f82bc1f Updated the Amiga OS port of SDL (thanks Gabriele)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
75 for ( i=0; (i<adaptors) && (xv_port == -1); ++i ) {
75a95f82bc1f Updated the Amiga OS port of SDL (thanks Gabriele)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
76 if ( (ainfo[i].type & XvInputMask) &&
75a95f82bc1f Updated the Amiga OS port of SDL (thanks Gabriele)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
77 (ainfo[i].type & XvImageMask) ) {
75a95f82bc1f Updated the Amiga OS port of SDL (thanks Gabriele)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
78 int num_formats;
75a95f82bc1f Updated the Amiga OS port of SDL (thanks Gabriele)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
79 XvImageFormatValues *formats;
75a95f82bc1f Updated the Amiga OS port of SDL (thanks Gabriele)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
80 formats = XvListImageFormats(GFX_Display,
75a95f82bc1f Updated the Amiga OS port of SDL (thanks Gabriele)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
81 ainfo[i].base_id, &num_formats);
75a95f82bc1f Updated the Amiga OS port of SDL (thanks Gabriele)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
82 for ( j=0; j<num_formats; ++j ) {
75a95f82bc1f Updated the Amiga OS port of SDL (thanks Gabriele)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
83 if ( (Uint32)formats[j].id == format ) {
75a95f82bc1f Updated the Amiga OS port of SDL (thanks Gabriele)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
84 xv_port = ainfo[i].base_id;
75a95f82bc1f Updated the Amiga OS port of SDL (thanks Gabriele)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
85 break;
75a95f82bc1f Updated the Amiga OS port of SDL (thanks Gabriele)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
86 }
75a95f82bc1f Updated the Amiga OS port of SDL (thanks Gabriele)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
87 }
75a95f82bc1f Updated the Amiga OS port of SDL (thanks Gabriele)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
88 }
75a95f82bc1f Updated the Amiga OS port of SDL (thanks Gabriele)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
89 }
75a95f82bc1f Updated the Amiga OS port of SDL (thanks Gabriele)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
90 }
75a95f82bc1f Updated the Amiga OS port of SDL (thanks Gabriele)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
91 if ( xv_port == -1 ) {
75a95f82bc1f Updated the Amiga OS port of SDL (thanks Gabriele)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
92 SDL_SetError("No available video ports for requested format");
75a95f82bc1f Updated the Amiga OS port of SDL (thanks Gabriele)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
93 return(NULL);
75a95f82bc1f Updated the Amiga OS port of SDL (thanks Gabriele)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
94 }
75a95f82bc1f Updated the Amiga OS port of SDL (thanks Gabriele)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
95
75a95f82bc1f Updated the Amiga OS port of SDL (thanks Gabriele)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
96 /* Create the overlay structure */
75a95f82bc1f Updated the Amiga OS port of SDL (thanks Gabriele)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
97 overlay = (SDL_Overlay *)malloc(sizeof *overlay);
75a95f82bc1f Updated the Amiga OS port of SDL (thanks Gabriele)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
98 if ( overlay == NULL ) {
75a95f82bc1f Updated the Amiga OS port of SDL (thanks Gabriele)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
99 SDL_OutOfMemory();
75a95f82bc1f Updated the Amiga OS port of SDL (thanks Gabriele)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
100 return(NULL);
75a95f82bc1f Updated the Amiga OS port of SDL (thanks Gabriele)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
101 }
75a95f82bc1f Updated the Amiga OS port of SDL (thanks Gabriele)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
102 memset(overlay, 0, (sizeof *overlay));
75a95f82bc1f Updated the Amiga OS port of SDL (thanks Gabriele)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
103
75a95f82bc1f Updated the Amiga OS port of SDL (thanks Gabriele)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
104 /* Fill in the basic members */
75a95f82bc1f Updated the Amiga OS port of SDL (thanks Gabriele)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
105 overlay->format = format;
75a95f82bc1f Updated the Amiga OS port of SDL (thanks Gabriele)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
106 overlay->w = width;
75a95f82bc1f Updated the Amiga OS port of SDL (thanks Gabriele)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
107 overlay->h = height;
75a95f82bc1f Updated the Amiga OS port of SDL (thanks Gabriele)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
108
75a95f82bc1f Updated the Amiga OS port of SDL (thanks Gabriele)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
109 /* Set up the YUV surface function structure */
75a95f82bc1f Updated the Amiga OS port of SDL (thanks Gabriele)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
110 overlay->hwfuncs = &x11_yuvfuncs;
75a95f82bc1f Updated the Amiga OS port of SDL (thanks Gabriele)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
111
75a95f82bc1f Updated the Amiga OS port of SDL (thanks Gabriele)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
112 /* Create the pixel data and lookup tables */
75a95f82bc1f Updated the Amiga OS port of SDL (thanks Gabriele)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
113 hwdata = (struct private_yuvhwdata *)malloc(sizeof *hwdata);
75a95f82bc1f Updated the Amiga OS port of SDL (thanks Gabriele)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
114 overlay->hwdata = hwdata;
75a95f82bc1f Updated the Amiga OS port of SDL (thanks Gabriele)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
115 if ( hwdata == NULL ) {
75a95f82bc1f Updated the Amiga OS port of SDL (thanks Gabriele)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
116 SDL_OutOfMemory();
75a95f82bc1f Updated the Amiga OS port of SDL (thanks Gabriele)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
117 SDL_FreeYUVOverlay(overlay);
75a95f82bc1f Updated the Amiga OS port of SDL (thanks Gabriele)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
118 return(NULL);
75a95f82bc1f Updated the Amiga OS port of SDL (thanks Gabriele)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
119 }
75a95f82bc1f Updated the Amiga OS port of SDL (thanks Gabriele)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
120 yuvshm = &hwdata->yuvshm;
75a95f82bc1f Updated the Amiga OS port of SDL (thanks Gabriele)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
121 memset(yuvshm, 0, sizeof(*yuvshm));
75a95f82bc1f Updated the Amiga OS port of SDL (thanks Gabriele)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
122 hwdata->port = xv_port;
75a95f82bc1f Updated the Amiga OS port of SDL (thanks Gabriele)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
123 hwdata->image = XvShmCreateImage(GFX_Display, xv_port, format,
75a95f82bc1f Updated the Amiga OS port of SDL (thanks Gabriele)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
124 0, width, height, yuvshm);
75a95f82bc1f Updated the Amiga OS port of SDL (thanks Gabriele)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
125 if ( hwdata->image == NULL ) {
75a95f82bc1f Updated the Amiga OS port of SDL (thanks Gabriele)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
126 SDL_OutOfMemory();
75a95f82bc1f Updated the Amiga OS port of SDL (thanks Gabriele)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
127 SDL_FreeYUVOverlay(overlay);
75a95f82bc1f Updated the Amiga OS port of SDL (thanks Gabriele)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
128 return(NULL);
75a95f82bc1f Updated the Amiga OS port of SDL (thanks Gabriele)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
129 }
75a95f82bc1f Updated the Amiga OS port of SDL (thanks Gabriele)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
130 yuvshm->shmid = shmget(IPC_PRIVATE, hwdata->image->data_size,
75a95f82bc1f Updated the Amiga OS port of SDL (thanks Gabriele)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
131 IPC_CREAT | 0777);
75a95f82bc1f Updated the Amiga OS port of SDL (thanks Gabriele)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
132 if ( yuvshm->shmid < 0 ) {
75a95f82bc1f Updated the Amiga OS port of SDL (thanks Gabriele)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
133 SDL_SetError("Unable to get %d bytes shared memory",
75a95f82bc1f Updated the Amiga OS port of SDL (thanks Gabriele)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
134 hwdata->image->data_size);
75a95f82bc1f Updated the Amiga OS port of SDL (thanks Gabriele)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
135 SDL_FreeYUVOverlay(overlay);
75a95f82bc1f Updated the Amiga OS port of SDL (thanks Gabriele)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
136 return(NULL);
75a95f82bc1f Updated the Amiga OS port of SDL (thanks Gabriele)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
137 }
75a95f82bc1f Updated the Amiga OS port of SDL (thanks Gabriele)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
138 yuvshm->shmaddr = (caddr_t) shmat(yuvshm->shmid, 0, 0);
75a95f82bc1f Updated the Amiga OS port of SDL (thanks Gabriele)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
139 yuvshm->readOnly = False;
75a95f82bc1f Updated the Amiga OS port of SDL (thanks Gabriele)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
140 hwdata->image->data = yuvshm->shmaddr;
75a95f82bc1f Updated the Amiga OS port of SDL (thanks Gabriele)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
141
75a95f82bc1f Updated the Amiga OS port of SDL (thanks Gabriele)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
142 XShmAttach(GFX_Display, yuvshm);
75a95f82bc1f Updated the Amiga OS port of SDL (thanks Gabriele)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
143 XSync(GFX_Display, False);
75a95f82bc1f Updated the Amiga OS port of SDL (thanks Gabriele)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
144 shmctl(yuvshm->shmid, IPC_RMID, 0);
75a95f82bc1f Updated the Amiga OS port of SDL (thanks Gabriele)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
145
75a95f82bc1f Updated the Amiga OS port of SDL (thanks Gabriele)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
146 /* We're all done.. */
75a95f82bc1f Updated the Amiga OS port of SDL (thanks Gabriele)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
147 return(overlay);
75a95f82bc1f Updated the Amiga OS port of SDL (thanks Gabriele)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
148 }
75a95f82bc1f Updated the Amiga OS port of SDL (thanks Gabriele)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
149
75a95f82bc1f Updated the Amiga OS port of SDL (thanks Gabriele)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
150 int X11_LockYUVOverlay(_THIS, SDL_Overlay *overlay)
75a95f82bc1f Updated the Amiga OS port of SDL (thanks Gabriele)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
151 {
75a95f82bc1f Updated the Amiga OS port of SDL (thanks Gabriele)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
152 overlay->pixels = overlay->hwdata->image->data;
75a95f82bc1f Updated the Amiga OS port of SDL (thanks Gabriele)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
153 /* What should the pitch be set to? */
75a95f82bc1f Updated the Amiga OS port of SDL (thanks Gabriele)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
154 return(0);
75a95f82bc1f Updated the Amiga OS port of SDL (thanks Gabriele)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
155 }
75a95f82bc1f Updated the Amiga OS port of SDL (thanks Gabriele)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
156
75a95f82bc1f Updated the Amiga OS port of SDL (thanks Gabriele)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
157 void X11_UnlockYUVOverlay(_THIS, SDL_Overlay *overlay)
75a95f82bc1f Updated the Amiga OS port of SDL (thanks Gabriele)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
158 {
75a95f82bc1f Updated the Amiga OS port of SDL (thanks Gabriele)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
159 overlay->pixels = NULL;
75a95f82bc1f Updated the Amiga OS port of SDL (thanks Gabriele)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
160 }
75a95f82bc1f Updated the Amiga OS port of SDL (thanks Gabriele)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
161
75a95f82bc1f Updated the Amiga OS port of SDL (thanks Gabriele)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
162 int X11_DisplayYUVOverlay(_THIS, SDL_Overlay *overlay, SDL_Rect *dstrect)
75a95f82bc1f Updated the Amiga OS port of SDL (thanks Gabriele)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
163 {
75a95f82bc1f Updated the Amiga OS port of SDL (thanks Gabriele)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
164 struct private_yuvhwdata *hwdata;
75a95f82bc1f Updated the Amiga OS port of SDL (thanks Gabriele)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
165
75a95f82bc1f Updated the Amiga OS port of SDL (thanks Gabriele)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
166 hwdata = overlay->hwdata;
75a95f82bc1f Updated the Amiga OS port of SDL (thanks Gabriele)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
167 XvShmPutImage(GFX_Display, hwdata->port, SDL_Window, SDL_GC,
75a95f82bc1f Updated the Amiga OS port of SDL (thanks Gabriele)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
168 hwdata->image, 0, 0, overlay->w, overlay->h,
75a95f82bc1f Updated the Amiga OS port of SDL (thanks Gabriele)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
169 dstrect->x, dstrect->y, dstrect->w, dstrect->h, False);
75a95f82bc1f Updated the Amiga OS port of SDL (thanks Gabriele)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
170 XSync(GFX_Display, False);
75a95f82bc1f Updated the Amiga OS port of SDL (thanks Gabriele)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
171 return(0);
75a95f82bc1f Updated the Amiga OS port of SDL (thanks Gabriele)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
172 }
75a95f82bc1f Updated the Amiga OS port of SDL (thanks Gabriele)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
173
75a95f82bc1f Updated the Amiga OS port of SDL (thanks Gabriele)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
174 void X11_FreeYUVOverlay(_THIS, SDL_Overlay *overlay)
75a95f82bc1f Updated the Amiga OS port of SDL (thanks Gabriele)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
175 {
75a95f82bc1f Updated the Amiga OS port of SDL (thanks Gabriele)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
176 struct private_yuvhwdata *hwdata;
75a95f82bc1f Updated the Amiga OS port of SDL (thanks Gabriele)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
177
75a95f82bc1f Updated the Amiga OS port of SDL (thanks Gabriele)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
178 hwdata = overlay->hwdata;
75a95f82bc1f Updated the Amiga OS port of SDL (thanks Gabriele)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
179 if ( hwdata ) {
75a95f82bc1f Updated the Amiga OS port of SDL (thanks Gabriele)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
180 if ( hwdata->yuvshm.shmaddr ) {
75a95f82bc1f Updated the Amiga OS port of SDL (thanks Gabriele)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
181 XShmDetach(GFX_Display, &hwdata->yuvshm);
75a95f82bc1f Updated the Amiga OS port of SDL (thanks Gabriele)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
182 shmdt(hwdata->yuvshm.shmaddr);
75a95f82bc1f Updated the Amiga OS port of SDL (thanks Gabriele)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
183 }
75a95f82bc1f Updated the Amiga OS port of SDL (thanks Gabriele)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
184 if ( hwdata->image ) {
75a95f82bc1f Updated the Amiga OS port of SDL (thanks Gabriele)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
185 XFree(hwdata->image);
75a95f82bc1f Updated the Amiga OS port of SDL (thanks Gabriele)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
186 }
75a95f82bc1f Updated the Amiga OS port of SDL (thanks Gabriele)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
187 free(hwdata);
75a95f82bc1f Updated the Amiga OS port of SDL (thanks Gabriele)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
188 }
75a95f82bc1f Updated the Amiga OS port of SDL (thanks Gabriele)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
189 }
75a95f82bc1f Updated the Amiga OS port of SDL (thanks Gabriele)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
190
75a95f82bc1f Updated the Amiga OS port of SDL (thanks Gabriele)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
191 #endif /* XFREE86_XV */