Mercurial > sdl-ios-xcode
annotate docs/html/sdljoybuttonevent.html @ 4139:568c9b3c0167 SDL-1.2
* Added configure option --enable-screensaver, to allow enabling the screensaver by default.
* Use XResetScreenSaver() instead of disabling screensaver entirely.
Full discussion summary from Erik on the SDL mailing list:
Current behaviour
=================
SDL changes the user's display power management settings without
permission from the user and without telling the user.
The interface that it uses to do so is DPMSDisable/DPMSEnable, which
should only ever be used by configuration utilities like KControl, never
by normal application programs, let alone by the libraries that they
use. Using an interface that is not at all intended for what SDL tries
to achieve means that it will not work as it should. Firstly, the power
management is completely disabled during the whole lifetime of the SDL
program, not only when it should be. Secondly, it makes SDL
non-reentrant, meaning that things will break when multiple SDL programs
are clients of the same X server simultaneously. Thirdly, no cleanup
mechanism ensures that the setting is restored if the client does not do
that (for example if it crashes).
In addition to that, this interface is broken on xorg,
[http://bugs.freedesktop.org/show_bug.cgi?id=13962], so what SDL tries
to do does not work at all on that implementation of the X Window
System. (The reason that the DPMSEnable works in KControl is that it
calls DPMSSetTimeout immediately after,
[http://websvn.kde.org/tags/KDE/3.5.9/kdebase/kcontrol/energy/energy.cpp?annotate=774532#l343]).
The problems that the current behaviour causes
==============================================
1. Information leak. When the user is away, someone might see what the
user has on the display when the user counts on the screensaver
preventing this. This does not even require physical access to the
workstation, it is enough to see it from a distance.
2. Draining battery. An SDL program that runs on a laptop will quickly
drain the battery while the user is away. The system will soon shut down
and require recharging before being usable again, while it should in
fact have consumed very little energy if the user's settings would have
been obeyed.
3. Wasting energy. Even if battery issues are not considered, energy as
such is wasted.
4. Display wear. The display may be worn out.
The problems that the current behaviour tries to solve
======================================================
1. Preventing screensaver while playing movies.
Many SDL applications are media players. They have reasons to prevent
screensavers from being activated while a movie is being played. When a
user clicks on the play button it can be interpreted as saying "play
this movie, but do not turn off the display while playing it, because I
will watch it even though I do not interact with the system".
2. Preventing screensaver when some input bypasses X.
Sometimes SDL uses input from another source than the X server, so
that the X server is bypassed. This obviously breaks the screensaver
handling. SDL tries to work around that.
3. Preventing screensaver when all input bypasses X.
There is something called Direct Graphics Access mode, where a
program takes control of both the display and the input devices from the
X server. This obviously means that the X server can not handle the
screensaver alone, since screensaver handling depends on input handling.
SDL does not do what it should to help the X server to handle the
screensaver. Nor does SDL take care of screeensaver handling itself. SDL
simply disables the screensaver completely.
How the problems should be solved
=================================
The correct way for an application program to prevent the screensaver
under X is to call XResetScreenSaver. This was recently discovered and
implemented by the mplayer developers,
[http://svn.mplayerhq.hu/mplayer?view=rev&revision=25637]. SDL needs to
wrap this in an API call (SDL_ResetScreenSaver) and implement it for the
other video targets (if they do not have a corresponding call, SDL
should do what it takes on that particular target, for example sending
fake key events).
1. When a movie is played, the player should reset the screensaver when
the animation is advanced to a new frame. The same applies to anything
similar, like slideshows.
2. When the X server is handling input, it must handle all input
(keyboards, mice, gamepads, ...). This is necessary, not only to be able
to handle the screensaver, but also so that it can send the events to
the correct (the currently active) client. If there is an input device
that the X server can not handle for some reason (such as lack of Plug
and Play capability), the program that handles the device as a
workaround must simulate what would happen if the X server would have
handled the device, by calling XResetScreenSaver when input is received
from the device.
3. When the X server is not handling the input, it depends on the
program that does to call XResetScreenSaver whenever an input event
occurs. Alternatively the program must handle the screensaver countdown
internally and call XActivateScreenSaver.
author | Sam Lantinga <slouken@libsdl.org> |
---|---|
date | Fri, 29 Feb 2008 13:55:44 +0000 |
parents | 355632dca928 |
children |
rev | line source |
---|---|
0 | 1 <HTML |
2 ><HEAD | |
3 ><TITLE | |
4 >SDL_JoyButtonEvent</TITLE | |
5 ><META | |
6 NAME="GENERATOR" | |
803
355632dca928
Updated SDL HTML documentation
Sam Lantinga <slouken@libsdl.org>
parents:
181
diff
changeset
|
7 CONTENT="Modular DocBook HTML Stylesheet Version 1.76b+ |
0 | 8 "><LINK |
9 REL="HOME" | |
10 TITLE="SDL Library Documentation" | |
11 HREF="index.html"><LINK | |
12 REL="UP" | |
13 TITLE="SDL Event Structures." | |
14 HREF="eventstructures.html"><LINK | |
15 REL="PREVIOUS" | |
16 TITLE="SDL_JoyAxisEvent" | |
17 HREF="sdljoyaxisevent.html"><LINK | |
18 REL="NEXT" | |
19 TITLE="SDL_JoyHatEvent" | |
20 HREF="sdljoyhatevent.html"></HEAD | |
21 ><BODY | |
22 CLASS="REFENTRY" | |
23 BGCOLOR="#FFF8DC" | |
24 TEXT="#000000" | |
25 LINK="#0000ee" | |
26 VLINK="#551a8b" | |
27 ALINK="#ff0000" | |
28 ><DIV | |
29 CLASS="NAVHEADER" | |
30 ><TABLE | |
803
355632dca928
Updated SDL HTML documentation
Sam Lantinga <slouken@libsdl.org>
parents:
181
diff
changeset
|
31 SUMMARY="Header navigation table" |
0 | 32 WIDTH="100%" |
33 BORDER="0" | |
34 CELLPADDING="0" | |
35 CELLSPACING="0" | |
36 ><TR | |
37 ><TH | |
38 COLSPAN="3" | |
39 ALIGN="center" | |
40 >SDL Library Documentation</TH | |
41 ></TR | |
42 ><TR | |
43 ><TD | |
44 WIDTH="10%" | |
45 ALIGN="left" | |
46 VALIGN="bottom" | |
47 ><A | |
48 HREF="sdljoyaxisevent.html" | |
803
355632dca928
Updated SDL HTML documentation
Sam Lantinga <slouken@libsdl.org>
parents:
181
diff
changeset
|
49 ACCESSKEY="P" |
0 | 50 >Prev</A |
51 ></TD | |
52 ><TD | |
53 WIDTH="80%" | |
54 ALIGN="center" | |
55 VALIGN="bottom" | |
56 ></TD | |
57 ><TD | |
58 WIDTH="10%" | |
59 ALIGN="right" | |
60 VALIGN="bottom" | |
61 ><A | |
62 HREF="sdljoyhatevent.html" | |
803
355632dca928
Updated SDL HTML documentation
Sam Lantinga <slouken@libsdl.org>
parents:
181
diff
changeset
|
63 ACCESSKEY="N" |
0 | 64 >Next</A |
65 ></TD | |
66 ></TR | |
67 ></TABLE | |
68 ><HR | |
69 ALIGN="LEFT" | |
70 WIDTH="100%"></DIV | |
71 ><H1 | |
72 ><A | |
73 NAME="SDLJOYBUTTONEVENT" | |
803
355632dca928
Updated SDL HTML documentation
Sam Lantinga <slouken@libsdl.org>
parents:
181
diff
changeset
|
74 ></A |
355632dca928
Updated SDL HTML documentation
Sam Lantinga <slouken@libsdl.org>
parents:
181
diff
changeset
|
75 >SDL_JoyButtonEvent</H1 |
0 | 76 ><DIV |
77 CLASS="REFNAMEDIV" | |
78 ><A | |
803
355632dca928
Updated SDL HTML documentation
Sam Lantinga <slouken@libsdl.org>
parents:
181
diff
changeset
|
79 NAME="AEN4258" |
0 | 80 ></A |
81 ><H2 | |
82 >Name</H2 | |
83 >SDL_JoyButtonEvent -- Joystick button event structure</DIV | |
84 ><DIV | |
85 CLASS="REFSECT1" | |
86 ><A | |
803
355632dca928
Updated SDL HTML documentation
Sam Lantinga <slouken@libsdl.org>
parents:
181
diff
changeset
|
87 NAME="AEN4261" |
0 | 88 ></A |
89 ><H2 | |
90 >Structure Definition</H2 | |
91 ><PRE | |
92 CLASS="PROGRAMLISTING" | |
93 >typedef struct{ | |
94 Uint8 type; | |
95 Uint8 which; | |
96 Uint8 button; | |
97 Uint8 state; | |
98 } SDL_JoyButtonEvent;</PRE | |
99 ></DIV | |
100 ><DIV | |
101 CLASS="REFSECT1" | |
102 ><A | |
803
355632dca928
Updated SDL HTML documentation
Sam Lantinga <slouken@libsdl.org>
parents:
181
diff
changeset
|
103 NAME="AEN4264" |
0 | 104 ></A |
105 ><H2 | |
106 >Structure Data</H2 | |
107 ><DIV | |
108 CLASS="INFORMALTABLE" | |
109 ><A | |
803
355632dca928
Updated SDL HTML documentation
Sam Lantinga <slouken@libsdl.org>
parents:
181
diff
changeset
|
110 NAME="AEN4266" |
0 | 111 ></A |
112 ><P | |
113 ></P | |
114 ><TABLE | |
115 BORDER="0" | |
116 CLASS="CALSTABLE" | |
117 ><TBODY | |
118 ><TR | |
119 ><TD | |
120 ALIGN="LEFT" | |
121 VALIGN="TOP" | |
122 ><TT | |
123 CLASS="STRUCTFIELD" | |
124 ><I | |
125 >type</I | |
126 ></TT | |
127 ></TD | |
128 ><TD | |
129 ALIGN="LEFT" | |
130 VALIGN="TOP" | |
131 ><TT | |
132 CLASS="LITERAL" | |
133 >SDL_JOYBUTTONDOWN</TT | |
134 > or <TT | |
135 CLASS="LITERAL" | |
136 >SDL_JOYBUTTONUP</TT | |
137 ></TD | |
138 ></TR | |
139 ><TR | |
140 ><TD | |
141 ALIGN="LEFT" | |
142 VALIGN="TOP" | |
143 ><TT | |
144 CLASS="STRUCTFIELD" | |
145 ><I | |
146 >which</I | |
147 ></TT | |
148 ></TD | |
149 ><TD | |
150 ALIGN="LEFT" | |
151 VALIGN="TOP" | |
152 >Joystick device index</TD | |
153 ></TR | |
154 ><TR | |
155 ><TD | |
156 ALIGN="LEFT" | |
157 VALIGN="TOP" | |
158 ><TT | |
159 CLASS="STRUCTFIELD" | |
160 ><I | |
161 >button</I | |
162 ></TT | |
163 ></TD | |
164 ><TD | |
165 ALIGN="LEFT" | |
166 VALIGN="TOP" | |
167 >Joystick button index</TD | |
168 ></TR | |
169 ><TR | |
170 ><TD | |
171 ALIGN="LEFT" | |
172 VALIGN="TOP" | |
173 ><TT | |
174 CLASS="STRUCTFIELD" | |
175 ><I | |
176 >state</I | |
177 ></TT | |
178 ></TD | |
179 ><TD | |
180 ALIGN="LEFT" | |
181 VALIGN="TOP" | |
182 ><TT | |
183 CLASS="LITERAL" | |
184 >SDL_PRESSED</TT | |
185 > or <TT | |
186 CLASS="LITERAL" | |
187 >SDL_RELEASED</TT | |
188 ></TD | |
189 ></TR | |
190 ></TBODY | |
191 ></TABLE | |
192 ><P | |
193 ></P | |
194 ></DIV | |
195 ></DIV | |
196 ><DIV | |
197 CLASS="REFSECT1" | |
198 ><A | |
803
355632dca928
Updated SDL HTML documentation
Sam Lantinga <slouken@libsdl.org>
parents:
181
diff
changeset
|
199 NAME="AEN4289" |
0 | 200 ></A |
201 ><H2 | |
202 >Description</H2 | |
203 ><P | |
204 ><SPAN | |
205 CLASS="STRUCTNAME" | |
206 >SDL_JoyButtonEvent</SPAN | |
207 > is a member of the <A | |
208 HREF="sdlevent.html" | |
209 ><SPAN | |
210 CLASS="STRUCTNAME" | |
211 >SDL_Event</SPAN | |
212 ></A | |
213 > union and is used when an event of type <TT | |
214 CLASS="LITERAL" | |
215 >SDL_JOYBUTTONDOWN</TT | |
216 > or <TT | |
217 CLASS="LITERAL" | |
218 >SDL_JOYBUTTONUP</TT | |
219 > is reported.</P | |
220 ><P | |
221 >A <TT | |
222 CLASS="LITERAL" | |
223 >SDL_JOYBUTTONDOWN</TT | |
224 > or <TT | |
225 CLASS="LITERAL" | |
226 >SDL_JOYBUTTONUP</TT | |
227 > event occurs when ever a user presses or releases a button on a joystick. The field <TT | |
228 CLASS="STRUCTFIELD" | |
229 ><I | |
230 >which</I | |
231 ></TT | |
232 > is the index of the joystick that reported the event and <TT | |
233 CLASS="STRUCTFIELD" | |
234 ><I | |
235 >button</I | |
236 ></TT | |
237 > is the index of the button (for a more detailed explaination see the <A | |
238 HREF="joystick.html" | |
239 >Joystick section</A | |
240 >). <TT | |
241 CLASS="STRUCTFIELD" | |
242 ><I | |
243 >state</I | |
244 ></TT | |
245 > is the current state or the button which is either <TT | |
246 CLASS="LITERAL" | |
247 >SDL_PRESSED</TT | |
248 > or <TT | |
249 CLASS="LITERAL" | |
250 >SDL_RELEASED</TT | |
251 >.</P | |
252 ></DIV | |
253 ><DIV | |
254 CLASS="REFSECT1" | |
255 ><A | |
803
355632dca928
Updated SDL HTML documentation
Sam Lantinga <slouken@libsdl.org>
parents:
181
diff
changeset
|
256 NAME="AEN4306" |
0 | 257 ></A |
258 ><H2 | |
259 >See Also</H2 | |
260 ><P | |
261 ><A | |
262 HREF="sdlevent.html" | |
263 ><SPAN | |
264 CLASS="STRUCTNAME" | |
265 >SDL_Event</SPAN | |
266 ></A | |
267 >, | |
268 <A | |
269 HREF="joystick.html" | |
270 >Joystick Functions</A | |
271 >, | |
272 <A | |
273 HREF="sdljoystickeventstate.html" | |
274 ><TT | |
275 CLASS="FUNCTION" | |
276 >SDL_JoystickEventState</TT | |
277 ></A | |
278 >, | |
279 <A | |
280 HREF="sdljoystickgetbutton.html" | |
281 ><TT | |
282 CLASS="FUNCTION" | |
283 >SDL_JoystickGetButton</TT | |
284 ></A | |
285 ></P | |
286 ></DIV | |
287 ><DIV | |
288 CLASS="NAVFOOTER" | |
289 ><HR | |
290 ALIGN="LEFT" | |
291 WIDTH="100%"><TABLE | |
803
355632dca928
Updated SDL HTML documentation
Sam Lantinga <slouken@libsdl.org>
parents:
181
diff
changeset
|
292 SUMMARY="Footer navigation table" |
0 | 293 WIDTH="100%" |
294 BORDER="0" | |
295 CELLPADDING="0" | |
296 CELLSPACING="0" | |
297 ><TR | |
298 ><TD | |
299 WIDTH="33%" | |
300 ALIGN="left" | |
301 VALIGN="top" | |
302 ><A | |
303 HREF="sdljoyaxisevent.html" | |
803
355632dca928
Updated SDL HTML documentation
Sam Lantinga <slouken@libsdl.org>
parents:
181
diff
changeset
|
304 ACCESSKEY="P" |
0 | 305 >Prev</A |
306 ></TD | |
307 ><TD | |
308 WIDTH="34%" | |
309 ALIGN="center" | |
310 VALIGN="top" | |
311 ><A | |
312 HREF="index.html" | |
803
355632dca928
Updated SDL HTML documentation
Sam Lantinga <slouken@libsdl.org>
parents:
181
diff
changeset
|
313 ACCESSKEY="H" |
0 | 314 >Home</A |
315 ></TD | |
316 ><TD | |
317 WIDTH="33%" | |
318 ALIGN="right" | |
319 VALIGN="top" | |
320 ><A | |
321 HREF="sdljoyhatevent.html" | |
803
355632dca928
Updated SDL HTML documentation
Sam Lantinga <slouken@libsdl.org>
parents:
181
diff
changeset
|
322 ACCESSKEY="N" |
0 | 323 >Next</A |
324 ></TD | |
325 ></TR | |
326 ><TR | |
327 ><TD | |
328 WIDTH="33%" | |
329 ALIGN="left" | |
330 VALIGN="top" | |
331 >SDL_JoyAxisEvent</TD | |
332 ><TD | |
333 WIDTH="34%" | |
334 ALIGN="center" | |
335 VALIGN="top" | |
336 ><A | |
337 HREF="eventstructures.html" | |
803
355632dca928
Updated SDL HTML documentation
Sam Lantinga <slouken@libsdl.org>
parents:
181
diff
changeset
|
338 ACCESSKEY="U" |
0 | 339 >Up</A |
340 ></TD | |
341 ><TD | |
342 WIDTH="33%" | |
343 ALIGN="right" | |
344 VALIGN="top" | |
345 >SDL_JoyHatEvent</TD | |
346 ></TR | |
347 ></TABLE | |
348 ></DIV | |
349 ></BODY | |
350 ></HTML | |
351 > |