home *** CD-ROM | disk | FTP | other *** search
/ Maximum CD 2009 February / maximum-cd-2009-02.iso / DiscContents / SMC_1.6_win32.exe / src / input / joystick.h < prev    next >
Encoding:
C/C++ Source or Header  |  2008-08-12  |  2.8 KB  |  106 lines

  1. /***************************************************************************
  2.  * joystick.h  -  header for the corresponding cpp file
  3.  *
  4.  * Copyright (C) 2003 - 2008 Florian Richter
  5.  ***************************************************************************/
  6. /*
  7.    This program is free software; you can redistribute it and/or modify
  8.    it under the terms of the GNU General Public License as published by
  9.    the Free Software Foundation; either version 3 of the License, or
  10.    (at your option) any later version.
  11.    
  12.    You should have received a copy of the GNU General Public License
  13.    along with this program.  If not, see <http://www.gnu.org/licenses/>.
  14. */
  15.  
  16. #ifndef SMC_JOYSTICK_H
  17. #define SMC_JOYSTICK_H
  18.  
  19. #include "../core/globals.h"
  20.  
  21. /* *** *** *** *** *** *** cJoystick *** *** *** *** *** *** *** *** *** *** *** */
  22.  
  23. class cJoystick
  24. {
  25. public:
  26.     cJoystick( void );
  27.     ~cJoystick( void );
  28.  
  29.     // Initializes the Joystick system
  30.     int Init( void );
  31.     // Closes the current Joystick
  32.     void Close( void );
  33.  
  34.     // Opens the specified Joystick
  35.     bool Stick_Open( unsigned int index );
  36.     // Closes the Stick
  37.     void Stick_Close( void );
  38.  
  39.     // Resets all Buttons and modifiers
  40.     void Reset_keys( void );
  41.  
  42.     // Handles the Joystick motion
  43.     void Handle_Motion( SDL_Event *ev );
  44.     // Handle Joystick Button down event
  45.     bool Handle_Button_Down_Event( SDL_Event *ev );
  46.     // Handle Joystick Button up event
  47.     bool Handle_Button_Up_Event( SDL_Event *ev );
  48.  
  49.     // Returns the current Joystick name
  50.     string Get_Name( void );
  51.     // Returns all available Joystick names
  52.     vector<string> Get_Names( void );
  53.  
  54.     // Sets the given button state
  55.     void Set_Button( Uint8 button, bool pressed );
  56.  
  57.     // Get the assigned shortcut
  58.     Uint8 *Get_Shortcut( input_identifier shortcut_id );
  59.     // Assign a shortcut
  60.     void Assign_Shortcut( input_identifier shortcut_id, Uint8 new_button );
  61.  
  62.     // check if the analog direction is pressed
  63.     bool Left( void );
  64.     bool Right( void );
  65.     bool Up( void );
  66.     bool Down( void );
  67.     // check if the given button is pushed
  68.     bool Button( Uint8 button );
  69.  
  70.     // current joystick pointer
  71.     SDL_Joystick *joystick;
  72.     // current Joystick name
  73.     string joy_name;
  74.  
  75.     // button state array
  76.     typedef vector<bool> ButtonList;
  77.     ButtonList buttons;
  78.     
  79.     // analog directions
  80.     bool left, right, up, down;
  81.  
  82.     // current opened joystick
  83.     int cur_stick;
  84.     // if true the current joystick is available/loaded
  85.     bool stick_open;
  86.     
  87.     // available buttons
  88.     unsigned int num_buttons;
  89.     // available axes
  90.     unsigned int num_axes;
  91.     // available balls
  92.     unsigned int num_balls;
  93.  
  94.     // if true print debug output
  95.     bool debug;
  96. };
  97.  
  98. /* *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** */
  99.  
  100. // global Joystick pointer
  101. extern cJoystick *pJoystick;
  102.  
  103. /* *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** */
  104.  
  105. #endif
  106.