25 #if defined(_DEBUG) && defined(_WINDOWS)
26 #define DEBUG_NEW new(_NORMAL_BLOCK, __FILE__, __LINE__)
37 previous_confidence(0.0
f)
55 m_firing_missed_events(
false)
64 float confidence = (float(event.
caxis.
value) + 0.5f) / 32767.5
f;
65 const float ac = float(
fabs(confidence));
66 const float nm = confidence < 0.0f ? -1.0f : 1.0f;
67 confidence = nm *
std::min(
std::max(ac - m_joystick_min, 0.0
f) / (m_joystick_max - m_joystick_min), 1.0
f);
75 const float confidence =
event.jbutton.state ==
SDL_PRESSED ? 1.0f : 0.0f;
83 const float confidence =
event.key.state ==
SDL_PRESSED ? 1.0f : 0.0f;
91 const int nm =
event.motion.xrel < 0.0f ? -1 : 1;
92 const float confidence = nm *
std::min(
std::max(
float(ac - m_mouse_min), 0.0
f) / (m_mouse_max - m_mouse_min), 1.0
f);
98 const int nm =
event.motion.yrel < 0.0f ? -1 : 1;
99 const float confidence = nm *
std::min(
std::max(
float(ac - m_mouse_min), 0.0
f) / (m_mouse_max - m_mouse_min), 1.0
f);
107 const float confidence =
event.button.state ==
SDL_PRESSED ? 1.0f : 0.0f;
135 std::map<Zeni_Input_ID, int>::const_iterator it = m_ii.find(event);
142 std::map<int, Zeni_Input_ID>::const_iterator it = m_rii.find(action);
143 if(it != m_rii.end())
149 m_ii[
event] = action;
150 m_rii[action] =
event;
156 for(std::map<Zeni_Input_ID, int>::iterator it = m_ii.begin(), iend = m_ii.end(); it != iend; ++it) {
157 switch(it->first.type) {
161 const float confidence = gr.
get_key_state(it->first.subid) ? 1.0f : 0.0f;
163 if(m_firing_missed_events && it->first.previous_confidence != confidence)
164 on_event(it->first, confidence, it->second);
166 it->first.previous_confidence = confidence;
174 if(m_firing_missed_events && it->first.previous_confidence != confidence)
175 on_event(it->first, confidence, it->second);
177 it->first.previous_confidence = confidence;
185 if(m_firing_missed_events && it->first.previous_confidence != confidence)
186 on_event(it->first, confidence, it->second);
188 it->first.previous_confidence = confidence;
199 void Gamestate_II::fire_event(
const Zeni_Input_ID &
id,
const float &confidence) {
200 std::map<Zeni_Input_ID, int>::iterator it = m_ii.find(
id);
201 if(it != m_ii.end()) {
202 float &pc = it->first.previous_confidence;
203 if(pc != confidence) {
205 on_event(
id, confidence, it->second);
SDL_MouseMotionEvent motion
virtual void on_uncover()
Called when a Gamestate is popped off Game, making this Gamestate on top.
SDL_ControllerAxisEvent caxis
GLint GLenum GLsizei GLsizei GLsizei GLint GLenum GLenum type
virtual void set_action(const Zeni_Input_ID &event, const int &action)
bool get_key_state(const int &key) const
Get the state of a key.
void fire_missed_events()
virtual Zeni_Input_ID get_event(const int &action)
bool get_mouse_button_state(const int &button) const
Get the state of a mouse button.
#define ZENI_DEFAULT_II_JOYBALL_MAX
Game & get_Game()
Get access to the singleton.
#define ZENI_DEFAULT_II_MOUSE_MIN
#define ZENI_DEFAULT_II_MOUSE_MAX
virtual void on_push()
Called when the Gamestate is pushed onto the stack in Game.
virtual void on_event(const SDL_Event &event)
First check for events. Called by Game as part of the main gameloop.
virtual int get_action(const Zeni_Input_ID &event)
virtual void on_event(const SDL_Event &event)
First check for events. Called by Game as part of the main gameloop.
SDL_ControllerButtonEvent cbutton
#define ZENI_DEFAULT_II_JOYSTICK_MAX
SDL_MouseButtonEvent button
uint16_t Uint16
An unsigned 16-bit integer type.
bool get_controller_button_state(const int &which, const SDL_GameControllerButton &button) const
Get the state of a joystick button.
#define ZENI_DEFAULT_II_JOYSTICK_MIN
#define ZENI_DEFAULT_II_JOYBALL_MIN
void push_Popup_Menu_State()