zenilib  0.5.3.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
Gamestate_II.h
Go to the documentation of this file.
1 /* This file is part of the Zenipex Library (zenilib).
2  * Copyright (C) 2011 Mitchell Keith Bloch (bazald).
3  *
4  * zenilib is free software: you can redistribute it and/or modify
5  * it under the terms of the GNU Lesser General Public License as published by
6  * the Free Software Foundation, either version 3 of the License, or
7  * (at your option) any later version.
8  *
9  * zenilib is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12  * GNU Lesser General Public License for more details.
13  *
14  * You should have received a copy of the GNU Lesser General Public License
15  * along with zenilib. If not, see <http://www.gnu.org/licenses/>.
16  */
17 
38 #ifndef ZENI_GAMESTATE_II_H
39 #define ZENI_GAMESTATE_II_H
40 
41 #include <Zeni/Gamestate.h>
42 
43 namespace Zeni {
44 
45  struct ZENI_REST_DLL Zeni_Input_ID {
46 #ifndef ANDROID
47  Zeni_Input_ID(const Uint16 &type_ = SDL_KEYDOWN, const int &subid_ = 0, const int &which_ = 0);
48 #endif
49 
51  int subid;
52  int which;
53  mutable float previous_confidence;
54 
55  bool operator<(const Zeni_Input_ID &rhs) const;
56  };
57 
58  class ZENI_REST_DLL Gamestate_II : public Gamestate_Base {
59  Gamestate_II(const Gamestate_II &rhs);
60  Gamestate_II & operator=(const Gamestate_II &rhs);
61 
62  public:
63  Gamestate_II();
64 
65  // The control loop
66 
68 #ifndef ANDROID
69  virtual void on_event(const SDL_Event &event);
70 #endif
71  virtual void on_event(const Zeni_Input_ID &id, const float &confidence, const int &action);
72  virtual void on_push();
73  virtual void on_uncover();
74 
75  inline const int & get_joyball_min() const;
76  inline const int & get_joyball_max() const;
77  inline const float & get_joystick_min() const;
78  inline const float & get_joystick_max() const;
79  inline const int & get_mouse_min() const;
80  inline const int & get_mouse_max() const;
81  inline const bool & is_firing_missed_events() const;
82 
83  inline void set_joyball_min(const int &min);
84  inline void set_joyball_max(const int &max);
85  inline void set_joystick_min(const float &min);
86  inline void set_joystick_max(const float &max);
87  inline void set_mouse_min(const int &min);
88  inline void set_mouse_max(const int &max);
89  inline void set_firing_missed_events(const bool &firing);
90 
91  virtual int get_action(const Zeni_Input_ID &event);
92  virtual Zeni_Input_ID get_event(const int &action);
93  virtual void set_action(const Zeni_Input_ID &event, const int &action);
94 
95  void fire_missed_events();
96 
97  private:
98  void fire_event(const Zeni_Input_ID &id, const float &confidence);
99 
100  int m_joyball_min;
101  int m_joyball_max;
102  float m_joystick_min;
103  float m_joystick_max;
104  int m_mouse_min;
105  int m_mouse_max;
106 
107 #ifdef _WINDOWS
108 #pragma warning( push )
109 #pragma warning( disable : 4251 )
110 #endif
111  std::map<Zeni_Input_ID, int> m_ii;
112  std::map<int, Zeni_Input_ID> m_rii;
113 #ifdef _WINDOWS
114 #pragma warning( pop )
115 #endif
116 
117  bool m_firing_missed_events;
118  };
119 
120 }
121 
122 #endif
int subid
event.keysym.sym, event.button, event.axis, mouse axis (x==0, y==1)
Definition: Gamestate_II.h:51
bool operator<(const TiXmlString &a, const TiXmlString &b)
Definition: tinystr.h:273
Uint16 type
directly copied from SDL_Event; UP types are converted to DOWN types
Definition: Gamestate_II.h:50
A new Gamestate base with an Integrated Input technique.
Definition: Gamestate_II.h:58
int which
Joystick Identifier; ignored for other events (should be 0)
Definition: Gamestate_II.h:52
The base class for all gamestates.
Definition: Gamestate.h:82
uint16_t Uint16
An unsigned 16-bit integer type.
Definition: SDL_stdinc.h:137
General event structure.
Definition: SDL_events.h:495
#define min(x, y)
Definition: os.h:75
#define max(x, y)
Definition: os.h:79
cl_event event
Definition: glew.h:3556