zenilib: Zeni::Gamestate_II Class Reference

zenilib 0.5.3.0

- Main Page
- Modules
- Namespaces
- Classes
- Files

- Class List
- Class Index
- Class Hierarchy
- Class Members

All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
Public Member Functions | List of all members
Zeni::Gamestate_II Class Reference
Zenilib

A new Gamestate base with an Integrated Input technique. More...

`#include <Gamestate_II.h>`

Inherits Zeni::Gamestate_Base.

## Public Member Functions

| Gamestate_II ()
void | fire_missed_events ()
virtual int | get_action (const Zeni_Input_ID &event)
virtual Zeni_Input_ID | get_event (const int &action)
const int & | get_joyball_max () const
const int & | get_joyball_min () const
const float & | get_joystick_max () const
const float & | get_joystick_min () const
const int & | get_mouse_max () const
const int & | get_mouse_min () const
const bool & | is_firing_missed_events () const
virtual void | on_event (const SDL_Event &event)
| First check for events. Called by Game as part of the main gameloop. More...
virtual void | on_event (const Zeni_Input_ID &id, const float &confidence, const int &action)
virtual void | on_push ()
| Called when the Gamestate is pushed onto the stack in Game. More...
virtual void | on_uncover ()
| Called when a Gamestate is popped off Game, making this Gamestate on top. More...
virtual void | set_action (const Zeni_Input_ID &event, const int &action)
void | set_firing_missed_events (const bool &firing)
| true if missed events should be handled normally; false if they should be discarded More...
void | set_joyball_max (const int &max)
| Should be (1, inf) and greater than min. More...
void | set_joyball_min (const int &min)
| Should be (0, inf) and less than max. More...
void | set_joystick_max (const float &max)
| Should be (0.0, 1.0] and greater than min. More...
void | set_joystick_min (const float &min)
| Should be [0.0, 1.0) and less than max. More...
void | set_mouse_max (const int &max)
| Should be (1, inf) and greater than min. More...
void | set_mouse_min (const int &min)
| Should be (0, inf) and less than max. More...
Public Member Functions inherited from Zeni::Gamestate_Base
| Gamestate_Base ()
virtual | ~Gamestate_Base ()
const bool & | is_pausable () const
virtual void | on_cover ()
| Called when a Gamestate is pushed on top of this Gamestate in Game. More...
virtual void | on_pop ()
| Called when the Gamestate is popped off the stack in Game. More...
virtual void | perform_logic ()
| Then perform logic. Called by Game as part of the main gameloop. More...
virtual void | prerender ()
| No actual rendering, but any logic strictly necessary for rendering. More...
virtual void | render ()
| Then render. Called by Game as part of the main gameloop. More...
void | set_pausable (const bool &pausable_)

## Additional Inherited Members

Static Public Member Functions inherited from Zeni::Gamestate_Base
static char | to_char (const SDL_Keysym &ks)
| Returns a character key corresponding to the current combination of keys pressed or the null character (0). More...
static SDL_Keycode | to_sym (const String &text_version)
| Convert a text representation to an actual sym. More...
static String | to_text (const SDL_Keycode &sym)
| Convert a sym to a text representation. More...
Protected Member Functions inherited from Zeni::Gamestate_Base
virtual void | on_active (const SDL_ActiveEvent &event)
| Override this input callback in your Gamestates. See SDL documentation for details. More...
virtual void | on_controller_axis (const SDL_ControllerAxisEvent &event)
| Override this input callback in your Gamestates. See SDL documentation for details. More...
virtual void | on_controller_button (const SDL_ControllerButtonEvent &event)
| Override this input callback in your Gamestates. See SDL documentation for details. More...
virtual void | on_controller_device (const SDL_ControllerDeviceEvent &event)
| Override this input callback in your Gamestates. See SDL documentation for details. More...
virtual void | on_key (const SDL_KeyboardEvent &event)
| Override this input callback in your Gamestates. See SDL documentation for details. More...
virtual void | on_mouse_button (const SDL_MouseButtonEvent &event)
| Override this input callback in your Gamestates. See SDL documentation for details. More...
virtual void | on_mouse_motion (const SDL_MouseMotionEvent &event)
| Override this input callback in your Gamestates. See SDL documentation for details. More...
virtual void | on_quit (const SDL_QuitEvent &event)
| Override this input callback in your Gamestates. See SDL documentation for details. More...
virtual void | on_system_wm_event (const SDL_SysWMEvent &event)
| Override this input callback in your Gamestates. See SDL documentation for details. More...
virtual void | on_user_event (const SDL_UserEvent &event)
| Override this input callback in your Gamestates. See SDL documentation for details. More...
virtual void | on_video_expose (const SDL_ExposeEvent &event)
| Override this input callback in your Gamestates. See SDL documentation for details. More...
virtual void | on_video_resize (const SDL_ResizeEvent &event)
| Override this input callback in your Gamestates. See SDL documentation for details. More...

## Detailed Description

A new Gamestate base with an Integrated Input technique.

All user input excluding mouse motion and joyhat events are abstracted away. A keydown, mousebuttondown, or joybuttondown event will yield a specfied action identifier with confidence 1.0f. The respective up event will yield the same action identifier with confidence 0.0f. Similarly, joyaxis movement will yield an action identifier with confidence -1.0f to 1.0f. This makes it easier to treat different types of input nearly identically, and to make it possible to use different control schemes. If no action id has been specified for a given input, it will report an action id of 0. It is then possible to tie an action to the input or to ignore it.

Author
  bazald

Contact: bazal.nosp@m.d@ze.nosp@m.nipex.nosp@m..com

Definition at line 58 of file Gamestate_II.h.

## Constructor & Destructor Documentation

Zeni::Gamestate_II::Gamestate_II | ( |  | ) |

Definition at line 48 of file Gamestate_II.cpp.

## Member Function Documentation

void Zeni::Gamestate_II::fire_missed_events | ( |  | ) |

Definition at line 153 of file Gamestate_II.cpp.

References Zeni::Game::get_controller_button_state(), Zeni::get_Game(), Zeni::Game::get_key_state(), Zeni::Game::get_mouse_button_state(), on_event(), SDL_CONTROLLERBUTTONDOWN, SDL_KEYDOWN, and SDL_MOUSEBUTTONDOWN.

Referenced by on_push(), and on_uncover().

int Zeni::Gamestate_II::get_action | ( | const Zeni_Input_ID & | event | ) |

virtual

Definition at line 134 of file Gamestate_II.cpp.

Zeni_Input_ID Zeni::Gamestate_II::get_event | ( | const int & | action | ) |

virtual

Definition at line 141 of file Gamestate_II.cpp.

const int & Zeni::Gamestate_II::get_joyball_max | ( |  | ) | const

inline

Definition at line 29 of file Gamestate_II.hxx.

const int & Zeni::Gamestate_II::get_joyball_min | ( |  | ) | const

inline

Definition at line 25 of file Gamestate_II.hxx.

const float & Zeni::Gamestate_II::get_joystick_max | ( |  | ) | const

inline

Definition at line 37 of file Gamestate_II.hxx.

const float & Zeni::Gamestate_II::get_joystick_min | ( |  | ) | const

inline

Definition at line 33 of file Gamestate_II.hxx.

const int & Zeni::Gamestate_II::get_mouse_max | ( |  | ) | const

inline

Definition at line 45 of file Gamestate_II.hxx.

const int & Zeni::Gamestate_II::get_mouse_min | ( |  | ) | const

inline

Definition at line 41 of file Gamestate_II.hxx.

const bool & Zeni::Gamestate_II::is_firing_missed_events | ( |  | ) | const

inline

Definition at line 49 of file Gamestate_II.hxx.

void Zeni::Gamestate_II::on_event | ( | const SDL_Event & | event | ) |

virtual

First check for events. Called by Game as part of the main gameloop.

Reimplemented from Zeni::Gamestate_Base.

Definition at line 60 of file Gamestate_II.cpp.

References SDL_ControllerAxisEvent::axis, SDL_MouseButtonEvent::button, SDL_ControllerButtonEvent::button, SDL_Event::button, SDL_Event::caxis, SDL_Event::cbutton, fabs(), SDL_Event::key, SDL_KeyboardEvent::keysym, max, min, SDL_Event::motion, Zeni::Gamestate_Base::on_event(), SDL_CONTROLLERAXISMOTION, SDL_CONTROLLERBUTTONDOWN, SDL_CONTROLLERBUTTONUP, SDL_KEYDOWN, SDL_KEYUP, SDL_MOUSEBUTTONDOWN, SDL_MOUSEBUTTONUP, SDL_MOUSEMOTION, SDL_PRESSED, SDL_Keysym::sym, SDL_Event::type, SDL_ControllerAxisEvent::value, SDL_ControllerAxisEvent::which, SDL_ControllerButtonEvent::which, SDL_MouseMotionEvent::xrel, and SDL_MouseMotionEvent::yrel.

Referenced by fire_missed_events().

void Zeni::Gamestate_II::on_event | ( | const Zeni_Input_ID & | id,
|  | const float & | confidence,
|  | const int & | action
| ) |  |

virtual

Definition at line 119 of file Gamestate_II.cpp.

References Zeni::get_Game(), Zeni::Game::push_Popup_Menu_State(), SDL_KEYDOWN, and SDLK_ESCAPE.

void Zeni::Gamestate_II::on_push | ( |  | ) |

virtual

Called when the Gamestate is pushed onto the stack in Game.

Reimplemented from Zeni::Gamestate_Base.

Definition at line 126 of file Gamestate_II.cpp.

References fire_missed_events().

void Zeni::Gamestate_II::on_uncover | ( |  | ) |

virtual

Called when a Gamestate is popped off Game, making this Gamestate on top.

Reimplemented from Zeni::Gamestate_Base.

Definition at line 130 of file Gamestate_II.cpp.

References fire_missed_events().

void Zeni::Gamestate_II::set_action | ( | const Zeni_Input_ID & | event,
|  | const int & | action
| ) |  |

virtual

Definition at line 148 of file Gamestate_II.cpp.

void Zeni::Gamestate_II::set_firing_missed_events | ( | const bool & | firing | ) |

inline

true if missed events should be handled normally; false if they should be discarded

Definition at line 95 of file Gamestate_II.hxx.

void Zeni::Gamestate_II::set_joyball_max | ( | const int & | max | ) |

inline

Should be (1, inf) and greater than min.

Definition at line 60 of file Gamestate_II.hxx.

References max.

void Zeni::Gamestate_II::set_joyball_min | ( | const int & | min | ) |

inline

Should be (0, inf) and less than max.

Definition at line 53 of file Gamestate_II.hxx.

References min.

void Zeni::Gamestate_II::set_joystick_max | ( | const float & | max | ) |

inline

Should be (0.0, 1.0] and greater than min.

Definition at line 74 of file Gamestate_II.hxx.

References max.

void Zeni::Gamestate_II::set_joystick_min | ( | const float & | min | ) |

inline

Should be [0.0, 1.0) and less than max.

Definition at line 67 of file Gamestate_II.hxx.

References min.

void Zeni::Gamestate_II::set_mouse_max | ( | const int & | max | ) |

inline

Should be (1, inf) and greater than min.

Definition at line 88 of file Gamestate_II.hxx.

References max.

void Zeni::Gamestate_II::set_mouse_min | ( | const int & | min | ) |

inline

Should be (0, inf) and less than max.

Definition at line 81 of file Gamestate_II.hxx.

References min.

The documentation for this class was generated from the following files:

- zenilib/jni/external/zenilib/zeni_rest/Zeni/Gamestate_II.h
- zenilib/jni/external/zenilib/zeni_rest/Gamestate_II.cpp
- zenilib/jni/external/zenilib/zeni_rest/Zeni/Gamestate_II.hxx