PGE Engine
 All Classes Namespaces Files Functions Variables Enumerations Enumerator Macros Pages
controller_joystick.h
1 /*
2  * Platformer Game Engine by Wohlstand, a free platform for game making
3  * Copyright (c) 2015 Vitaly Novichkov <admin@wohlnet.ru>
4  *
5  * This program is free software: you can redistribute it and/or modify
6  * it under the terms of the GNU General Public License as published by
7  * the Free Software Foundation, either version 3 of the License, or
8  * any later version.
9  *
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  * GNU General Public License for more details.
14  *
15  * You should have received a copy of the GNU General Public License
16  * along with this program. If not, see <http://www.gnu.org/licenses/>.
17  */
18 
19 #ifndef CONTROLLER_JOYSTICK_H
20 #define CONTROLLER_JOYSTICK_H
21 
22 #include "controller.h"
23 #include <SDL2/SDL.h>
24 #include <controls/controller_key_map.h>
25 
30 {
31 public:
36 
41 
46  void setJoystickDevice(SDL_Joystick* jctrl);
47 
52  SDL_Joystick* getJoystickDevice() const;
53 
59  void updateKey(bool &key, KM_Key &mkey);
60 
64  void update();
65 
66 
73  static bool bindJoystickKey(SDL_Joystick* joy, KM_Key &k);
74 
75 private:
77  SDL_Joystick* m_joystickController;
78 };
79 
80 #endif // CONTROLLER_JOYSTICK_H
void updateKey(bool &key, KM_Key &mkey)
Takes a state of specified joystick key.
Definition: controller_joystick.cpp:59
JoystickController()
Constructor.
Definition: controller_joystick.cpp:23
static bool bindJoystickKey(SDL_Joystick *joy, KM_Key &k)
Detects a pressed key type and it's from a given joystick device and writes info into a given key des...
Definition: controller_joystick.cpp:126
void setJoystickDevice(SDL_Joystick *jctrl)
Sets joystick device descriptor which will be used by this controller.
Definition: controller_joystick.cpp:49
~JoystickController()
Destructir.
Definition: controller_joystick.cpp:46
void update()
Read states of all control keys of a joystick device.
Definition: controller_joystick.cpp:101
Definition: controller_key_map.h:4
The Controller class provides proxy interface between controllable objects array and physical control...
Definition: controller.h:32
SDL_Joystick * getJoystickDevice() const
Returns current joystick device descriptor.
Definition: controller_joystick.cpp:54
A Joystick controller which reads key states from a joystick device.
Definition: controller_joystick.h:29