1 <HTML 2 ><HEAD 3 ><TITLE 4 >SDL_JoystickGetAxis</TITLE 5 ><META 6 NAME="GENERATOR" 7 CONTENT="Modular DocBook HTML Stylesheet Version 1.76b+ 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_JoystickUpdate" 17 HREF="sdljoystickupdate.html"><LINK 18 REL="NEXT" 19 TITLE="SDL_JoystickGetHat" 20 HREF="sdljoystickgethat.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 SUMMARY="Header navigation table" 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="sdljoystickupdate.html" 49 ACCESSKEY="P" 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="sdljoystickgethat.html" 63 ACCESSKEY="N" 64 >Next</A 65 ></TD 66 ></TR 67 ></TABLE 68 ><HR 69 ALIGN="LEFT" 70 WIDTH="100%"></DIV 71 ><H1 72 ><A 73 NAME="SDLJOYSTICKGETAXIS" 74 ></A 75 >SDL_JoystickGetAxis</H1 76 ><DIV 77 CLASS="REFNAMEDIV" 78 ><A 79 NAME="AEN6320" 80 ></A 81 ><H2 82 >Name</H2 83 >SDL_JoystickGetAxis -- Get the current state of an axis</DIV 84 ><DIV 85 CLASS="REFSYNOPSISDIV" 86 ><A 87 NAME="AEN6323" 88 ></A 89 ><H2 90 >Synopsis</H2 91 ><DIV 92 CLASS="FUNCSYNOPSIS" 93 ><A 94 NAME="AEN6324" 95 ></A 96 ><P 97 ></P 98 ><PRE 99 CLASS="FUNCSYNOPSISINFO" 100 >#include "SDL.h"</PRE 101 ><P 102 ><CODE 103 ><CODE 104 CLASS="FUNCDEF" 105 >Sint16 <B 106 CLASS="FSFUNC" 107 >SDL_JoystickGetAxis</B 108 ></CODE 109 >(SDL_Joystick *joystick, int axis);</CODE 110 ></P 111 ><P 112 ></P 113 ></DIV 114 ></DIV 115 ><DIV 116 CLASS="REFSECT1" 117 ><A 118 NAME="AEN6330" 119 ></A 120 ><H2 121 >Description</H2 122 ><P 123 ><TT 124 CLASS="FUNCTION" 125 >SDL_JoystickGetAxis</TT 126 > returns the current state of the given <TT 127 CLASS="PARAMETER" 128 ><I 129 >axis</I 130 ></TT 131 > on the given <TT 132 CLASS="PARAMETER" 133 ><I 134 >joystick</I 135 ></TT 136 >.</P 137 ><P 138 >On most modern joysticks the X axis is usually represented by <TT 139 CLASS="PARAMETER" 140 ><I 141 >axis</I 142 ></TT 143 > 0 and the Y axis by <TT 144 CLASS="PARAMETER" 145 ><I 146 >axis</I 147 ></TT 148 > 1. The value returned by <TT 149 CLASS="FUNCTION" 150 >SDL_JoystickGetAxis</TT 151 > is a signed integer (-32768 to 32768) representing the current position of the <TT 152 CLASS="PARAMETER" 153 ><I 154 >axis</I 155 ></TT 156 >, it maybe necessary to impose certain tolerances on these values to account for jitter. It is worth noting that some joysticks use axes 2 and 3 for extra buttons.</P 157 ></DIV 158 ><DIV 159 CLASS="REFSECT1" 160 ><A 161 NAME="AEN6341" 162 ></A 163 ><H2 164 >Return Value</H2 165 ><P 166 >Returns a 16-bit signed integer representing the current position of the <TT 167 CLASS="PARAMETER" 168 ><I 169 >axis</I 170 ></TT 171 >.</P 172 ></DIV 173 ><DIV 174 CLASS="REFSECT1" 175 ><A 176 NAME="AEN6345" 177 ></A 178 ><H2 179 >Examples</H2 180 ><P 181 ><PRE 182 CLASS="PROGRAMLISTING" 183 >Sint16 x_move, y_move; 184 SDL_Joystick *joy1; 185 . 186 . 187 x_move=SDL_JoystickGetAxis(joy1, 0); 188 y_move=SDL_JoystickGetAxis(joy1, 1);</PRE 189 ></P 190 ></DIV 191 ><DIV 192 CLASS="REFSECT1" 193 ><A 194 NAME="AEN6349" 195 ></A 196 ><H2 197 >See Also</H2 198 ><P 199 ><A 200 HREF="sdljoysticknumaxes.html" 201 ><TT 202 CLASS="FUNCTION" 203 >SDL_JoystickNumAxes</TT 204 ></A 205 ></P 206 ></DIV 207 ><DIV 208 CLASS="NAVFOOTER" 209 ><HR 210 ALIGN="LEFT" 211 WIDTH="100%"><TABLE 212 SUMMARY="Footer navigation table" 213 WIDTH="100%" 214 BORDER="0" 215 CELLPADDING="0" 216 CELLSPACING="0" 217 ><TR 218 ><TD 219 WIDTH="33%" 220 ALIGN="left" 221 VALIGN="top" 222 ><A 223 HREF="sdljoystickupdate.html" 224 ACCESSKEY="P" 225 >Prev</A 226 ></TD 227 ><TD 228 WIDTH="34%" 229 ALIGN="center" 230 VALIGN="top" 231 ><A 232 HREF="index.html" 233 ACCESSKEY="H" 234 >Home</A 235 ></TD 236 ><TD 237 WIDTH="33%" 238 ALIGN="right" 239 VALIGN="top" 240 ><A 241 HREF="sdljoystickgethat.html" 242 ACCESSKEY="N" 243 >Next</A 244 ></TD 245 ></TR 246 ><TR 247 ><TD 248 WIDTH="33%" 249 ALIGN="left" 250 VALIGN="top" 251 >SDL_JoystickUpdate</TD 252 ><TD 253 WIDTH="34%" 254 ALIGN="center" 255 VALIGN="top" 256 ><A 257 HREF="joystick.html" 258 ACCESSKEY="U" 259 >Up</A 260 ></TD 261 ><TD 262 WIDTH="33%" 263 ALIGN="right" 264 VALIGN="top" 265 >SDL_JoystickGetHat</TD 266 ></TR 267 ></TABLE 268 ></DIV 269 ></BODY 270 ></HTML 271 >