comparison docs/html/sdljoystickopen.html @ 0:74212992fb08

Initial revision
author Sam Lantinga <slouken@lokigames.com>
date Thu, 26 Apr 2001 16:45:43 +0000
parents
children 55f1f1b3e27d
comparison
equal deleted inserted replaced
-1:000000000000 0:74212992fb08
1 <HTML
2 ><HEAD
3 ><TITLE
4 >SDL_JoystickOpen</TITLE
5 ><META
6 NAME="GENERATOR"
7 CONTENT="Modular DocBook HTML Stylesheet Version 1.61
8 "><LINK
9 REL="HOME"
10 TITLE="SDL Library Documentation"
11 HREF="index.html"><LINK
12 REL="UP"
13 TITLE="Joystick"
14 HREF="joystick.html"><LINK
15 REL="PREVIOUS"
16 TITLE="SDL_JoystickName"
17 HREF="sdljoystickname.html"><LINK
18 REL="NEXT"
19 TITLE="SDL_JoystickOpened"
20 HREF="sdljoystickopened.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
31 WIDTH="100%"
32 BORDER="0"
33 CELLPADDING="0"
34 CELLSPACING="0"
35 ><TR
36 ><TH
37 COLSPAN="3"
38 ALIGN="center"
39 >SDL Library Documentation</TH
40 ></TR
41 ><TR
42 ><TD
43 WIDTH="10%"
44 ALIGN="left"
45 VALIGN="bottom"
46 ><A
47 HREF="sdljoystickname.html"
48 >Prev</A
49 ></TD
50 ><TD
51 WIDTH="80%"
52 ALIGN="center"
53 VALIGN="bottom"
54 ></TD
55 ><TD
56 WIDTH="10%"
57 ALIGN="right"
58 VALIGN="bottom"
59 ><A
60 HREF="sdljoystickopened.html"
61 >Next</A
62 ></TD
63 ></TR
64 ></TABLE
65 ><HR
66 ALIGN="LEFT"
67 WIDTH="100%"></DIV
68 ><H1
69 ><A
70 NAME="SDLJOYSTICKOPEN"
71 >SDL_JoystickOpen</A
72 ></H1
73 ><DIV
74 CLASS="REFNAMEDIV"
75 ><A
76 NAME="AEN5474"
77 ></A
78 ><H2
79 >Name</H2
80 >SDL_JoystickOpen&nbsp;--&nbsp;Opens a joystick for use.</DIV
81 ><DIV
82 CLASS="REFSYNOPSISDIV"
83 ><A
84 NAME="AEN5477"
85 ></A
86 ><H2
87 >Synopsis</H2
88 ><DIV
89 CLASS="FUNCSYNOPSIS"
90 ><A
91 NAME="AEN5478"
92 ></A
93 ><P
94 ></P
95 ><PRE
96 CLASS="FUNCSYNOPSISINFO"
97 >#include "SDL.h"</PRE
98 ><P
99 ><CODE
100 ><CODE
101 CLASS="FUNCDEF"
102 >SDL_Joystick *<B
103 CLASS="FSFUNC"
104 >SDL_JoystickOpen</B
105 ></CODE
106 >(int index);</CODE
107 ></P
108 ><P
109 ></P
110 ></DIV
111 ></DIV
112 ><DIV
113 CLASS="REFSECT1"
114 ><A
115 NAME="AEN5484"
116 ></A
117 ><H2
118 >Description</H2
119 ><P
120 >Opens a joystick for use within SDL. The <TT
121 CLASS="PARAMETER"
122 ><I
123 >index</I
124 ></TT
125 > refers to the N'th joystick in the system. A joystick must be opened before it game be used.</P
126 ></DIV
127 ><DIV
128 CLASS="REFSECT1"
129 ><A
130 NAME="AEN5488"
131 ></A
132 ><H2
133 >Return Value</H2
134 ><P
135 >Returns a <SPAN
136 CLASS="STRUCTNAME"
137 >SDL_Joystick</SPAN
138 > structure on success. <SPAN
139 CLASS="RETURNVALUE"
140 >NULL</SPAN
141 > on failure.</P
142 ></DIV
143 ><DIV
144 CLASS="REFSECT1"
145 ><A
146 NAME="AEN5493"
147 ></A
148 ><H2
149 >Examples</H2
150 ><P
151 ><PRE
152 CLASS="PROGRAMLISTING"
153 >SDL_Joystick *joy;
154 // Check for joystick
155 if(SDL_NumJoysticks()&#62;0){
156 // Open joystick
157 joy=SDL_JoystickOpen(0);
158
159 if(joy)
160 {
161 printf("Opened Joystick 0\n");
162 printf("Name: %s\n", SDL_JoystickName(0));
163 printf("Number of Axes: %s\n", SDL_JoystickNumAxes(joy));
164 printf("Number of Buttons: %s\n", SDL_JoystickNumButtons(joy));
165 printf("Number of Balls: %s\n", SDL_JoystickNumBalls(joy));
166 }
167 else
168 printf("Couldn't open Joystick 0\n");
169
170 // Close if opened
171 if(SDL_JoystickOpened(0))
172 SDL_JoystickClose(joy);
173 }</PRE
174 ></P
175 ></DIV
176 ><DIV
177 CLASS="REFSECT1"
178 ><A
179 NAME="AEN5497"
180 ></A
181 ><H2
182 >See Also</H2
183 ><P
184 ><A
185 HREF="sdljoystickclose.html"
186 ><TT
187 CLASS="FUNCTION"
188 >SDL_JoystickClose</TT
189 ></A
190 ></P
191 ></DIV
192 ><DIV
193 CLASS="NAVFOOTER"
194 ><HR
195 ALIGN="LEFT"
196 WIDTH="100%"><TABLE
197 WIDTH="100%"
198 BORDER="0"
199 CELLPADDING="0"
200 CELLSPACING="0"
201 ><TR
202 ><TD
203 WIDTH="33%"
204 ALIGN="left"
205 VALIGN="top"
206 ><A
207 HREF="sdljoystickname.html"
208 >Prev</A
209 ></TD
210 ><TD
211 WIDTH="34%"
212 ALIGN="center"
213 VALIGN="top"
214 ><A
215 HREF="index.html"
216 >Home</A
217 ></TD
218 ><TD
219 WIDTH="33%"
220 ALIGN="right"
221 VALIGN="top"
222 ><A
223 HREF="sdljoystickopened.html"
224 >Next</A
225 ></TD
226 ></TR
227 ><TR
228 ><TD
229 WIDTH="33%"
230 ALIGN="left"
231 VALIGN="top"
232 >SDL_JoystickName</TD
233 ><TD
234 WIDTH="34%"
235 ALIGN="center"
236 VALIGN="top"
237 ><A
238 HREF="joystick.html"
239 >Up</A
240 ></TD
241 ><TD
242 WIDTH="33%"
243 ALIGN="right"
244 VALIGN="top"
245 >SDL_JoystickOpened</TD
246 ></TR
247 ></TABLE
248 ></DIV
249 ></BODY
250 ></HTML
251 >