Mercurial > sdl-ios-xcode
annotate src/video/gem/SDL_gemwm.c @ 1748:5e86e34453d4
------- Comment #1 From Max Horn 2006-04-17 03:08 [reply] -------
Created an attachment (id=106) [edit]
Patch for src/joystick/win32/SDL_mmjoystick.c
I am not even a Windows user, so take the following with a grain of salt:
SDL_mmjoystick.c has a function GetJoystickName which obtains the joystick
name by looking at the registry. The way it does that seems very fishy to me.
Namely, it uses the parameter "index" to construct a registry value name (BTW,
those variables used in the code are really badly named). The value of "index"
in turn equals the current value of "numdevs", as called from
SDL_SYS_JoystickInit.
I read through the MSDN docs at
<http://msdn.microsoft.com/archive/default.asp?url=/archive/en-us/dnarinput/html/msdn_extdirect.asp>,
and I believe the simple fix is to replace line 183 of said file
SYS_JoystickName[numdevs] = GetJoystickName(numdevs, joycaps.szRegKey);
by the following:
SYS_JoystickName[numdevs] = GetJoystickName(SYS_JoystickID[i],
joycaps.szRegKey);
However, that is only *hiding* the real issue. Problem is, the list of
joysticks as returned by windows may contains "gaps", and the code deals
incorrectly with that. Namely those gaps occur if joysticks are
removed/(re)added, as the reporter observed.
The attached patch fixes this and another (off-by-one) issue in the code. But
since I have no Windows machine, I can't even test-compile it, so use with
caution.
author | Sam Lantinga <slouken@libsdl.org> |
---|---|
date | Sat, 29 Apr 2006 20:22:31 +0000 |
parents | d910939febfa |
children | 782fd950bd46 c121d94672cb 5d14acfdf84d |
rev | line source |
---|---|
281
c5010ab8ba35
Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1 /* |
c5010ab8ba35
Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2 SDL - Simple DirectMedia Layer |
1312
c9b51268668f
Updated copyright information and removed rcs id lines (problematic in branch merges)
Sam Lantinga <slouken@libsdl.org>
parents:
1080
diff
changeset
|
3 Copyright (C) 1997-2006 Sam Lantinga |
281
c5010ab8ba35
Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4 |
c5010ab8ba35
Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
5 This library is free software; you can redistribute it and/or |
1312
c9b51268668f
Updated copyright information and removed rcs id lines (problematic in branch merges)
Sam Lantinga <slouken@libsdl.org>
parents:
1080
diff
changeset
|
6 modify it under the terms of the GNU Lesser General Public |
281
c5010ab8ba35
Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
7 License as published by the Free Software Foundation; either |
1312
c9b51268668f
Updated copyright information and removed rcs id lines (problematic in branch merges)
Sam Lantinga <slouken@libsdl.org>
parents:
1080
diff
changeset
|
8 version 2.1 of the License, or (at your option) any later version. |
281
c5010ab8ba35
Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
9 |
c5010ab8ba35
Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
10 This library is distributed in the hope that it will be useful, |
c5010ab8ba35
Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
11 but WITHOUT ANY WARRANTY; without even the implied warranty of |
c5010ab8ba35
Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
1312
c9b51268668f
Updated copyright information and removed rcs id lines (problematic in branch merges)
Sam Lantinga <slouken@libsdl.org>
parents:
1080
diff
changeset
|
13 Lesser General Public License for more details. |
281
c5010ab8ba35
Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
14 |
1312
c9b51268668f
Updated copyright information and removed rcs id lines (problematic in branch merges)
Sam Lantinga <slouken@libsdl.org>
parents:
1080
diff
changeset
|
15 You should have received a copy of the GNU Lesser General Public |
c9b51268668f
Updated copyright information and removed rcs id lines (problematic in branch merges)
Sam Lantinga <slouken@libsdl.org>
parents:
1080
diff
changeset
|
16 License along with this library; if not, write to the Free Software |
c9b51268668f
Updated copyright information and removed rcs id lines (problematic in branch merges)
Sam Lantinga <slouken@libsdl.org>
parents:
1080
diff
changeset
|
17 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
281
c5010ab8ba35
Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
18 |
c5010ab8ba35
Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
19 Sam Lantinga |
c5010ab8ba35
Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
20 slouken@libsdl.org |
c5010ab8ba35
Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
21 */ |
1402
d910939febfa
Use consistent identifiers for the various platforms we support.
Sam Lantinga <slouken@libsdl.org>
parents:
1312
diff
changeset
|
22 #include "SDL_config.h" |
281
c5010ab8ba35
Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
23 |
c5010ab8ba35
Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
24 /* |
736
028e03e273c8
Use new C2P routine + corrections for iconification window
Patrice Mandin <patmandin@gmail.com>
parents:
557
diff
changeset
|
25 GEM SDL video driver |
028e03e273c8
Use new C2P routine + corrections for iconification window
Patrice Mandin <patmandin@gmail.com>
parents:
557
diff
changeset
|
26 Window manager functions |
028e03e273c8
Use new C2P routine + corrections for iconification window
Patrice Mandin <patmandin@gmail.com>
parents:
557
diff
changeset
|
27 |
028e03e273c8
Use new C2P routine + corrections for iconification window
Patrice Mandin <patmandin@gmail.com>
parents:
557
diff
changeset
|
28 Patrice Mandin |
028e03e273c8
Use new C2P routine + corrections for iconification window
Patrice Mandin <patmandin@gmail.com>
parents:
557
diff
changeset
|
29 */ |
281
c5010ab8ba35
Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
30 |
c5010ab8ba35
Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
31 /* Mint includes */ |
c5010ab8ba35
Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
32 #include <gem.h> |
c5010ab8ba35
Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
33 |
c5010ab8ba35
Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
34 #include "SDL_gemwm_c.h" |
c5010ab8ba35
Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
35 |
c5010ab8ba35
Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
36 /* Defines */ |
c5010ab8ba35
Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
37 |
c5010ab8ba35
Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
38 #define ICONWIDTH 64 |
c5010ab8ba35
Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
39 #define ICONHEIGHT 64 |
c5010ab8ba35
Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
40 |
c5010ab8ba35
Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
41 /* Functions */ |
c5010ab8ba35
Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
42 |
c5010ab8ba35
Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
43 void GEM_SetCaption(_THIS, const char *title, const char *icon) |
c5010ab8ba35
Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
44 { |
736
028e03e273c8
Use new C2P routine + corrections for iconification window
Patrice Mandin <patmandin@gmail.com>
parents:
557
diff
changeset
|
45 if (title) { |
281
c5010ab8ba35
Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
46 GEM_title_name = title; |
736
028e03e273c8
Use new C2P routine + corrections for iconification window
Patrice Mandin <patmandin@gmail.com>
parents:
557
diff
changeset
|
47 GEM_refresh_name = SDL_TRUE; |
281
c5010ab8ba35
Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
48 } |
c5010ab8ba35
Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
49 |
736
028e03e273c8
Use new C2P routine + corrections for iconification window
Patrice Mandin <patmandin@gmail.com>
parents:
557
diff
changeset
|
50 if (icon) { |
028e03e273c8
Use new C2P routine + corrections for iconification window
Patrice Mandin <patmandin@gmail.com>
parents:
557
diff
changeset
|
51 GEM_icon_name = icon; |
028e03e273c8
Use new C2P routine + corrections for iconification window
Patrice Mandin <patmandin@gmail.com>
parents:
557
diff
changeset
|
52 GEM_refresh_name = SDL_TRUE; |
281
c5010ab8ba35
Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
53 } |
c5010ab8ba35
Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
54 } |
c5010ab8ba35
Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
55 |
c5010ab8ba35
Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
56 void GEM_SetIcon(_THIS, SDL_Surface *icon, Uint8 *mask) |
c5010ab8ba35
Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
57 { |
736
028e03e273c8
Use new C2P routine + corrections for iconification window
Patrice Mandin <patmandin@gmail.com>
parents:
557
diff
changeset
|
58 SDL_Surface *sicon; |
028e03e273c8
Use new C2P routine + corrections for iconification window
Patrice Mandin <patmandin@gmail.com>
parents:
557
diff
changeset
|
59 SDL_Rect bounds; |
028e03e273c8
Use new C2P routine + corrections for iconification window
Patrice Mandin <patmandin@gmail.com>
parents:
557
diff
changeset
|
60 |
028e03e273c8
Use new C2P routine + corrections for iconification window
Patrice Mandin <patmandin@gmail.com>
parents:
557
diff
changeset
|
61 #if 0 |
028e03e273c8
Use new C2P routine + corrections for iconification window
Patrice Mandin <patmandin@gmail.com>
parents:
557
diff
changeset
|
62 if ((GEM_wfeatures & (1<<WF_ICONIFY))==0) { |
028e03e273c8
Use new C2P routine + corrections for iconification window
Patrice Mandin <patmandin@gmail.com>
parents:
557
diff
changeset
|
63 return; |
028e03e273c8
Use new C2P routine + corrections for iconification window
Patrice Mandin <patmandin@gmail.com>
parents:
557
diff
changeset
|
64 } |
028e03e273c8
Use new C2P routine + corrections for iconification window
Patrice Mandin <patmandin@gmail.com>
parents:
557
diff
changeset
|
65 #endif |
028e03e273c8
Use new C2P routine + corrections for iconification window
Patrice Mandin <patmandin@gmail.com>
parents:
557
diff
changeset
|
66 |
028e03e273c8
Use new C2P routine + corrections for iconification window
Patrice Mandin <patmandin@gmail.com>
parents:
557
diff
changeset
|
67 if (icon == NULL) { |
281
c5010ab8ba35
Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
68 return; |
736
028e03e273c8
Use new C2P routine + corrections for iconification window
Patrice Mandin <patmandin@gmail.com>
parents:
557
diff
changeset
|
69 } |
028e03e273c8
Use new C2P routine + corrections for iconification window
Patrice Mandin <patmandin@gmail.com>
parents:
557
diff
changeset
|
70 |
028e03e273c8
Use new C2P routine + corrections for iconification window
Patrice Mandin <patmandin@gmail.com>
parents:
557
diff
changeset
|
71 /* Convert icon to the screen format */ |
028e03e273c8
Use new C2P routine + corrections for iconification window
Patrice Mandin <patmandin@gmail.com>
parents:
557
diff
changeset
|
72 sicon = SDL_CreateRGBSurface(SDL_SWSURFACE, icon->w, icon->h, |
028e03e273c8
Use new C2P routine + corrections for iconification window
Patrice Mandin <patmandin@gmail.com>
parents:
557
diff
changeset
|
73 VDI_bpp, VDI_redmask, VDI_greenmask, VDI_bluemask, 0); |
028e03e273c8
Use new C2P routine + corrections for iconification window
Patrice Mandin <patmandin@gmail.com>
parents:
557
diff
changeset
|
74 if ( sicon == NULL ) { |
028e03e273c8
Use new C2P routine + corrections for iconification window
Patrice Mandin <patmandin@gmail.com>
parents:
557
diff
changeset
|
75 return; |
028e03e273c8
Use new C2P routine + corrections for iconification window
Patrice Mandin <patmandin@gmail.com>
parents:
557
diff
changeset
|
76 } |
281
c5010ab8ba35
Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
77 |
736
028e03e273c8
Use new C2P routine + corrections for iconification window
Patrice Mandin <patmandin@gmail.com>
parents:
557
diff
changeset
|
78 bounds.x = 0; |
028e03e273c8
Use new C2P routine + corrections for iconification window
Patrice Mandin <patmandin@gmail.com>
parents:
557
diff
changeset
|
79 bounds.y = 0; |
028e03e273c8
Use new C2P routine + corrections for iconification window
Patrice Mandin <patmandin@gmail.com>
parents:
557
diff
changeset
|
80 bounds.w = icon->w; |
028e03e273c8
Use new C2P routine + corrections for iconification window
Patrice Mandin <patmandin@gmail.com>
parents:
557
diff
changeset
|
81 bounds.h = icon->h; |
028e03e273c8
Use new C2P routine + corrections for iconification window
Patrice Mandin <patmandin@gmail.com>
parents:
557
diff
changeset
|
82 if ( SDL_LowerBlit(icon, &bounds, sicon, &bounds) < 0 ) { |
028e03e273c8
Use new C2P routine + corrections for iconification window
Patrice Mandin <patmandin@gmail.com>
parents:
557
diff
changeset
|
83 SDL_FreeSurface(sicon); |
028e03e273c8
Use new C2P routine + corrections for iconification window
Patrice Mandin <patmandin@gmail.com>
parents:
557
diff
changeset
|
84 return; |
028e03e273c8
Use new C2P routine + corrections for iconification window
Patrice Mandin <patmandin@gmail.com>
parents:
557
diff
changeset
|
85 } |
028e03e273c8
Use new C2P routine + corrections for iconification window
Patrice Mandin <patmandin@gmail.com>
parents:
557
diff
changeset
|
86 |
028e03e273c8
Use new C2P routine + corrections for iconification window
Patrice Mandin <patmandin@gmail.com>
parents:
557
diff
changeset
|
87 GEM_icon = sicon; |
281
c5010ab8ba35
Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
88 } |
c5010ab8ba35
Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
89 |
c5010ab8ba35
Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
90 int GEM_IconifyWindow(_THIS) |
c5010ab8ba35
Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
91 { |
c5010ab8ba35
Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
92 if ((GEM_wfeatures & (1<<WF_ICONIFY))==0) |
c5010ab8ba35
Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
93 return 0; |
c5010ab8ba35
Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
94 |
736
028e03e273c8
Use new C2P routine + corrections for iconification window
Patrice Mandin <patmandin@gmail.com>
parents:
557
diff
changeset
|
95 GEM_message[0] = WM_ICONIFY; |
028e03e273c8
Use new C2P routine + corrections for iconification window
Patrice Mandin <patmandin@gmail.com>
parents:
557
diff
changeset
|
96 GEM_message[1] = gl_apid; |
028e03e273c8
Use new C2P routine + corrections for iconification window
Patrice Mandin <patmandin@gmail.com>
parents:
557
diff
changeset
|
97 GEM_message[2] = 0; |
028e03e273c8
Use new C2P routine + corrections for iconification window
Patrice Mandin <patmandin@gmail.com>
parents:
557
diff
changeset
|
98 GEM_message[3] = GEM_handle; |
028e03e273c8
Use new C2P routine + corrections for iconification window
Patrice Mandin <patmandin@gmail.com>
parents:
557
diff
changeset
|
99 GEM_message[4] = 0; |
028e03e273c8
Use new C2P routine + corrections for iconification window
Patrice Mandin <patmandin@gmail.com>
parents:
557
diff
changeset
|
100 GEM_message[5] = GEM_desk_h-ICONHEIGHT; |
028e03e273c8
Use new C2P routine + corrections for iconification window
Patrice Mandin <patmandin@gmail.com>
parents:
557
diff
changeset
|
101 GEM_message[6] = ICONWIDTH; |
028e03e273c8
Use new C2P routine + corrections for iconification window
Patrice Mandin <patmandin@gmail.com>
parents:
557
diff
changeset
|
102 GEM_message[7] = ICONHEIGHT; |
281
c5010ab8ba35
Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
103 |
736
028e03e273c8
Use new C2P routine + corrections for iconification window
Patrice Mandin <patmandin@gmail.com>
parents:
557
diff
changeset
|
104 appl_write(gl_apid, sizeof(GEM_message), GEM_message); |
281
c5010ab8ba35
Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
105 |
c5010ab8ba35
Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
106 return 1; |
c5010ab8ba35
Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
107 } |
c5010ab8ba35
Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
108 |
c5010ab8ba35
Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
109 SDL_GrabMode GEM_GrabInput(_THIS, SDL_GrabMode mode) |
c5010ab8ba35
Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
110 { |
1068 | 111 return SDL_GRAB_OFF; |
281
c5010ab8ba35
Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
112 } |