Example #1
0
/**
* @brief Calls an input callback method of the object on top of the stack.
* @param event The input event to forward.
* @return \c true if the event was handled and should stop being propagated.
*/
bool LuaContext::on_input(InputEvent& event) 
{
  // Call the Lua function(s) corresponding to this input event.
  bool handled = false;
  if (event.is_keyboard_event()) 
  {
    // Keyboard.
    if (event.is_keyboard_key_pressed()) 
	{
      handled = on_key_pressed(event) || handled;/*
      if (event.is_character_pressed()) 
	  {
        handled = on_character_pressed(event) || handled;
      }*/
    }
    /*
	else if (event.is_keyboard_key_released()) 
	{
      handled = on_key_released(event) || handled;
    }
	*/
  }
  //TODO Change this to mouse input events 
  /*
  else if (event.is_joypad_event()) 
  {
    // Joypad.
    if (event.is_joypad_button_pressed()) {
      handled = on_joypad_button_pressed(event) || handled;
    }
    else if (event.is_joypad_button_released()) {
      handled = on_joypad_button_released(event) || handled;
    }
    else if (event.is_joypad_axis_moved()) {
      handled = on_joypad_axis_moved(event) || handled;
    }
    else if (event.is_joypad_hat_moved()) {
      handled = on_joypad_hat_moved(event) || handled;
    }
  }*/

  return handled;
}