Sophie

Sophie

distrib > Mandriva > 2010.0 > i586 > media > contrib-release > by-pkgid > 519a657156f8292188a5d8f560aa6169 > files > 21

pygame-doc-1.8.1-4mdv2010.0.i586.rpm


<html>
<title>joystick - Pygame Documentation</title>
<body bgcolor=#aaeebb text=#000000 link=#331111 vlink=#331111>


<table cellpadding=0 cellspacing=0 border=0 style='border: 3px solid black;' width='100%'>
<tr>
<td bgcolor='#c2fc20' style='padding: 6px;' align=center valign=center><a href='http://www.pygame.org/'><img src='../pygame_tiny.gif' border=0 width=200 height=60></a><br><b>pygame documentation</b></td>
<td bgcolor='#6aee28' style='border-left: 3px solid black; padding: 6px;' align=center valign=center>
	||&nbsp;
	<a href=http://www.pygame.org>Pygame Home</a> &nbsp;||&nbsp;
	<a href=../index.html>Help Contents</a> &nbsp;||
	<a href=index.html>Reference Index</a> &nbsp;||
	<br>&nbsp;<br>
	
<a href="cdrom.html">Cdrom</a>&nbsp;||&nbsp;
<a href="color.html">Color</a>&nbsp;||&nbsp;
<a href="cursors.html">Cursors</a>&nbsp;||&nbsp;
<a href="display.html">Display</a>&nbsp;||&nbsp;
<a href="draw.html">Draw</a>&nbsp;||&nbsp;
<a href="event.html">Event</a>&nbsp;||&nbsp;
<a href="font.html">Font</a>&nbsp;||&nbsp;
<a href="image.html">Image</a>&nbsp;||&nbsp;
<a href="joystick.html">Joystick</a>&nbsp;||&nbsp;
<a href="key.html">Key</a>&nbsp;||&nbsp;
<a href="mask.html">Mask</a>&nbsp;||&nbsp;
<a href="mixer.html">Mixer</a>&nbsp;||&nbsp;
<a href="mouse.html">Mouse</a>&nbsp;||&nbsp;
<a href="movie.html">Movie</a>&nbsp;||&nbsp;
<a href="music.html">Music</a>&nbsp;||&nbsp;
<a href="overlay.html">Overlay</a>&nbsp;||&nbsp;
<a href="pixelarray.html">Pixelarray</a>&nbsp;||&nbsp;
<a href="pygame.html">Pygame</a>&nbsp;||&nbsp;
<a href="rect.html">Rect</a>&nbsp;||&nbsp;
<a href="scrap.html">Scrap</a>&nbsp;||&nbsp;
<a href="sndarray.html">Sndarray</a>&nbsp;||&nbsp;
<a href="sprite.html">Sprite</a>&nbsp;||&nbsp;
<a href="surface.html">Surface</a>&nbsp;||&nbsp;
<a href="surfarray.html">Surfarray</a>&nbsp;||&nbsp;
<a href="time.html">Time</a>&nbsp;||&nbsp;
<a href="transform.html">Transform</a>
</td></tr></table>
<br>


<a name="pygame.joystick">
<big><b>pygame.joystick</big></b><br><ul>
  <i>pygame module for interacting with joystick devices</i><br>
<ul><small><table>
  <tr><td><a href="joystick.html#pygame.joystick.init">pygame.joystick.init</a> - <font size=-1>initialize the joystick module</font></td><td>initialize the joystick module</td></tr>
  <tr><td><a href="joystick.html#pygame.joystick.quit">pygame.joystick.quit</a> - <font size=-1>uninitialize the joystick module</font></td><td>uninitialize the joystick module</td></tr>
  <tr><td><a href="joystick.html#pygame.joystick.get_init">pygame.joystick.get_init</a> - <font size=-1>true if the joystick module is initialized</font></td><td>true if the joystick module is initialized</td></tr>
  <tr><td><a href="joystick.html#pygame.joystick.get_count">pygame.joystick.get_count</a> - <font size=-1>number of joysticks on the system</font></td><td>number of joysticks on the system</td></tr>
  <tr><td><a href="joystick.html#pygame.joystick.Joystick">pygame.joystick.Joystick</a> - <font size=-1>create a new Joystick object</font></td><td>create a new Joystick object</td></tr>
</table></small></ul>
<p>The joystick module manages the joystick devices on a computer (there can be more than one). Joystick devices include trackballs and video-game-style gamepads, and the module allows the use of multiple buttons and "hats". </p>
<!--COMMENTS:pygame.joystick--> &nbsp;<br> 


<a name="pygame.joystick.init">
<big><b>pygame.joystick.init</big></b><br><ul>
  <i>initialize the joystick module</i><br>
  <tt>pygame.joystick.init(): return None</tt><br>
<p>This function is called automatically by <tt><a href="pygame.html#pygame.init">pygame.init</a> - <font size=-1>initialize all imported pygame modules</font></tt>. </p>
<p>It initializes the joystick module. This will scan the system for all joystick devices. The module must be initialized before any other functions will work. </p>
<p>It is safe to call this function more than once. </p>
<!--COMMENTS:pygame.joystick.init--> &nbsp;<br> 
<br></ul>


<a name="pygame.joystick.quit">
<big><b>pygame.joystick.quit</big></b><br><ul>
  <i>uninitialize the joystick module</i><br>
  <tt>pygame.joystick.quit(): return None</tt><br>
<p>Uninitialize the joystick module. After you call this any existing joystick objects will no longer work. </p>
<p>It is safe to call this function more than once. </p>
<!--COMMENTS:pygame.joystick.quit--> &nbsp;<br> 
<br></ul>


<a name="pygame.joystick.get_init">
<big><b>pygame.joystick.get_init</big></b><br><ul>
  <i>true if the joystick module is initialized</i><br>
  <tt>pygame.joystick.get_init(): return bool</tt><br>
<p>Test if the <tt><a href="joystick.html#pygame.joystick.init">pygame.joystick.init</a> - <font size=-1>initialize the joystick module</font></tt> function has been called. </p>
<!--COMMENTS:pygame.joystick.get_init--> &nbsp;<br> 
<br></ul>


<a name="pygame.joystick.get_count">
<big><b>pygame.joystick.get_count</big></b><br><ul>
  <i>number of joysticks on the system</i><br>
  <tt>pygame.joystick.get_count(): return count</tt><br>
<p>Return the number of joystick devices on the system. The count will be 0 if there are no joysticks on the system. </p>
<p>When you create Joystick objects using Joystick(id), you pass an integer that must be lower than this count. </p>
<!--COMMENTS:pygame.joystick.get_count--> &nbsp;<br> 
<br></ul>


<a name="pygame.joystick.Joystick">
<big><b>pygame.joystick.Joystick</big></b><br><ul>
  <i>create a new Joystick object</i><br>
  <tt>pygame.joystick.Joystick(id): return Joystick</tt><br>
<ul><small><table>
  <tr><td><a href="joystick.html#Joystick.init">Joystick.init</a> - <font size=-1>initialize the Joystick</font></td><td>initialize the Joystick</td></tr>
  <tr><td><a href="joystick.html#Joystick.quit">Joystick.quit</a> - <font size=-1>uninitialize the Joystick</font></td><td>uninitialize the Joystick</td></tr>
  <tr><td><a href="joystick.html#Joystick.get_init">Joystick.get_init</a> - <font size=-1>check if the Joystick is initialized</font></td><td>check if the Joystick is initialized</td></tr>
  <tr><td><a href="joystick.html#Joystick.get_id">Joystick.get_id</a> - <font size=-1>get the Joystick ID</font></td><td>get the Joystick ID</td></tr>
  <tr><td><a href="joystick.html#Joystick.get_name">Joystick.get_name</a> - <font size=-1>get the Joystick system name</font></td><td>get the Joystick system name</td></tr>
  <tr><td><a href="joystick.html#Joystick.get_numaxes">Joystick.get_numaxes</a> - <font size=-1>get the number of axes on a Joystick</font></td><td>get the number of axes on a Joystick</td></tr>
  <tr><td><a href="joystick.html#Joystick.get_axis">Joystick.get_axis</a> - <font size=-1>get the current position of an axis</font></td><td>get the current position of an axis</td></tr>
  <tr><td><a href="joystick.html#Joystick.get_numballs">Joystick.get_numballs</a> - <font size=-1>get the number of trackballs on a Joystick</font></td><td>get the number of trackballs on a Joystick</td></tr>
  <tr><td><a href="joystick.html#Joystick.get_ball">Joystick.get_ball</a> - <font size=-1>get the relative position of a trackball</font></td><td>get the relative position of a trackball</td></tr>
  <tr><td><a href="joystick.html#Joystick.get_numbuttons">Joystick.get_numbuttons</a> - <font size=-1>get the number of buttons on a Joystick</font></td><td>get the number of buttons on a Joystick</td></tr>
  <tr><td><a href="joystick.html#Joystick.get_button">Joystick.get_button</a> - <font size=-1>get the current button state</font></td><td>get the current button state</td></tr>
  <tr><td><a href="joystick.html#Joystick.get_numhats">Joystick.get_numhats</a> - <font size=-1>get the number of hat controls on a Joystick</font></td><td>get the number of hat controls on a Joystick</td></tr>
  <tr><td><a href="joystick.html#Joystick.get_hat">Joystick.get_hat</a> - <font size=-1>get the position of a joystick hat</font></td><td>get the position of a joystick hat</td></tr>
</table></small></ul>
<p>Create a new joystick to access a physical device. The id argument must be a value from 0 to <tt>pygame.joystick.get_count()-1</tt>. </p>
<p>To access most of the Joystick methods, you'll need to init() the Joystick. This is separate from making sure the joystick module is initialized. When multiple Joysticks objects are created for the same physical joystick device <tt>(i.e.</tt>, they have the same <tt>ID</tt> number), the state and values for those Joystick objects will be shared. </p>
<p>The Joystick object allows you to get information about the types of controls on a joystick device. Once the device is initialized the Pygame event queue will start receiving events about its input. </p>
<p>You can call the <tt><a href="joystick.html#Joystick.get_name">Joystick.get_name</a> - <font size=-1>get the Joystick system name</font></tt> and <tt><a href="joystick.html#Joystick.get_id">Joystick.get_id</a> - <font size=-1>get the Joystick ID</font></tt> functions without initializing the Joystick object. </p>
<!--COMMENTS:pygame.joystick.Joystick--> &nbsp;<br> 


<a name="Joystick.init">
<big><b>Joystick.init</big></b><br><ul>
  <i>initialize the Joystick</i><br>
  <tt>Joystick.init(): return None</tt><br>
<p>The Joystick must be initialized to get most of the information about the controls. While the Joystick is initialized the Pygame event queue will receive events from the Joystick input. </p>
<p>It is safe to call this more than once. </p>
<!--COMMENTS:Joystick.init--> &nbsp;<br> 
<br></ul>


<a name="Joystick.quit">
<big><b>Joystick.quit</big></b><br><ul>
  <i>uninitialize the Joystick</i><br>
  <tt>Joystick.quit(): return None</tt><br>
<p>This will unitialize a Joystick. After this the Pygame event queue will no longer receive events from the device. </p>
<p>It is safe to call this more than once. </p>
<!--COMMENTS:Joystick.quit--> &nbsp;<br> 
<br></ul>


<a name="Joystick.get_init">
<big><b>Joystick.get_init</big></b><br><ul>
  <i>check if the Joystick is initialized</i><br>
  <tt>Joystick.get_init(): return bool</tt><br>
<p>Returns True if the init() method has already been called on this Joystick object. </p>
<!--COMMENTS:Joystick.get_init--> &nbsp;<br> 
<br></ul>


<a name="Joystick.get_id">
<big><b>Joystick.get_id</big></b><br><ul>
  <i>get the Joystick ID</i><br>
  <tt>Joystick.get_id(): return int</tt><br>
<p>Returns the integer <tt>ID</tt> that represents this device. This is the same value that was passed to the Joystick() constructor. This method can safely be called while the Joystick is not initialized. </p>
<!--COMMENTS:Joystick.get_id--> &nbsp;<br> 
<br></ul>


<a name="Joystick.get_name">
<big><b>Joystick.get_name</big></b><br><ul>
  <i>get the Joystick system name</i><br>
  <tt>Joystick.get_name(): return string</tt><br>
<p>Returns the system name for this joystick device. It is unknown what name the system will give to the Joystick, but it should be a unique name that identifies the device. This method can safely be called while the Joystick is not initialized. </p>
<!--COMMENTS:Joystick.get_name--> &nbsp;<br> 
<br></ul>


<a name="Joystick.get_numaxes">
<big><b>Joystick.get_numaxes</big></b><br><ul>
  <i>get the number of axes on a Joystick</i><br>
  <tt>Joystick.get_numaxes(): return int</tt><br>
<p>Returns the number of input axes are on a Joystick. There will usually be two for the position. Controls like rudders and throttles are treated as additional axes. </p>
<p>The <tt>pygame.JOYAXISMOTION</tt> events will be in the range from <tt>-1.0</tt> to <tt>1.0</tt>. <tt>A</tt> value of <tt>0.0</tt> means the axis is centered. Gamepad devices will usually be -1, 0, or 1 with no values in between. Older analog joystick axes will not always use the full -1 to 1 range, and the centered value will be some area around 0. Analog joysticks usually have a bit of noise in their axis, which will generate a lot of rapid small motion events. </p>
<!--COMMENTS:Joystick.get_numaxes--> &nbsp;<br> 
<br></ul>


<a name="Joystick.get_axis">
<big><b>Joystick.get_axis</big></b><br><ul>
  <i>get the current position of an axis</i><br>
  <tt>Joystick.get_axis(axis_number): return float</tt><br>
<p>Returns the current position of a joystick axis. The value will range from -1 to 1 with a value of 0 being centered. You may want to take into account some tolerance to handle jitter, and joystick drift may keep the joystick from centering at 0 or using the full range of position values. </p>
<p>The axis number must be an integer from zero to get_numaxes()-1. </p>
<!--COMMENTS:Joystick.get_axis--> &nbsp;<br> 
<br></ul>


<a name="Joystick.get_numballs">
<big><b>Joystick.get_numballs</big></b><br><ul>
  <i>get the number of trackballs on a Joystick</i><br>
  <tt>Joystick.get_numballs(): return int</tt><br>
<p>Returns the number of trackball devices on a Joystick. These devices work similar to a mouse but they have no absolute position; they only have relative amounts of movement. </p>
<p>The <tt>pygame.JOYBALLMOTION</tt> event will be sent when the trackball is rolled. It will report the amount of movement on the trackball. </p>
<!--COMMENTS:Joystick.get_numballs--> &nbsp;<br> 
<br></ul>


<a name="Joystick.get_ball">
<big><b>Joystick.get_ball</big></b><br><ul>
  <i>get the relative position of a trackball</i><br>
  <tt>Joystick.get_ball(ball_number): return x, y</tt><br>
<p>Returns the relative movement of a joystick button. The value is a x, y pair holding the relative movement since the last call to get_ball. </p>
<p>The ball number must be an integer from zero to get_numballs()-1. </p>
<!--COMMENTS:Joystick.get_ball--> &nbsp;<br> 
<br></ul>


<a name="Joystick.get_numbuttons">
<big><b>Joystick.get_numbuttons</big></b><br><ul>
  <i>get the number of buttons on a Joystick</i><br>
  <tt>Joystick.get_numbuttons(): return int</tt><br>
<p>Returns the number of pushable buttons on the joystick. These buttons have a boolean (on or off) state. </p>
<p>Buttons generate a <tt>pygame.JOYBUTTONDOWN</tt> and <tt>pygame.JOYBUTTONUP</tt> event when they are pressed and released. </p>
<!--COMMENTS:Joystick.get_numbuttons--> &nbsp;<br> 
<br></ul>


<a name="Joystick.get_button">
<big><b>Joystick.get_button</big></b><br><ul>
  <i>get the current button state</i><br>
  <tt>Joystick.get_button(button): return bool</tt><br>
<p>Returns the current state of a joystick button. </p>
<!--COMMENTS:Joystick.get_button--> &nbsp;<br> 
<br></ul>


<a name="Joystick.get_numhats">
<big><b>Joystick.get_numhats</big></b><br><ul>
  <i>get the number of hat controls on a Joystick</i><br>
  <tt>Joystick.get_numhats(): return int</tt><br>
<p>Returns the number of joystick hats on a Joystick. Hat devices are like miniature digital joysticks on a joystick. Each hat has two axes of input. </p>
<p>The <tt>pygame.JOYHATMOTION</tt> event is generated when the hat changes position. The position attribute for the event contains a pair of values that are either -1, 0, or 1. <tt>A</tt> position of (0, 0) means the hat is centered. </p>
<!--COMMENTS:Joystick.get_numhats--> &nbsp;<br> 
<br></ul>


<a name="Joystick.get_hat">
<big><b>Joystick.get_hat</big></b><br><ul>
  <i>get the position of a joystick hat</i><br>
  <tt>Joystick.get_hat(hat_number): return x, y</tt><br>
<p>Returns the current position of a position hat. The position is given as two values representing the <tt>X</tt> and <tt>Y</tt> position for the hat. (0, 0) means centered. <tt>A</tt> value of -1 means left/down and a value of 1 means right/up: so (-1, 0) means left; (1, 0) means right; (0, 1) means up; (1, 1) means upper-right; etc. </p>
<p>This value is digital, <tt>i.e.</tt>, each coordinate can be -1, 0 or 1 but never in-between. </p>
<p>The hat number must be between 0 and get_numhats()-1. </p>
<!--COMMENTS:Joystick.get_hat--> &nbsp;<br> 
<br></ul>
<br></ul>
<br></ul>

</body></html>