More work on refactoring input devices (still wip).
This commit is contained in:
parent
891b0697dc
commit
a0b7b1003d
@ -317,7 +317,7 @@ InputDevice* DeviceManager::mapKeyboardInput(int button_id,
|
||||
{
|
||||
KeyboardDevice *keyboard = m_keyboards.get(n);
|
||||
|
||||
if (keyboard->processAndMapInput(button_id, mode, action))
|
||||
if (keyboard->processAndMapInput(action, Input::IT_KEYBOARD, button_id, mode))
|
||||
{
|
||||
if (m_single_player != NULL)
|
||||
{
|
||||
@ -363,7 +363,7 @@ InputDevice *DeviceManager::mapGamepadInput(Input::InputType type,
|
||||
|
||||
if (gPad != NULL)
|
||||
{
|
||||
if (gPad->processAndMapInput(type, button_id, value, mode, action))
|
||||
if (gPad->processAndMapInput(action, type, button_id, mode, value))
|
||||
{
|
||||
if (m_single_player != NULL)
|
||||
{
|
||||
|
@ -108,10 +108,10 @@ void GamePadDevice::resetAxisDirection(const int axis,
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
bool GamePadDevice::processAndMapInput(Input::InputType type, const int id,
|
||||
int* value, /* inout */
|
||||
bool GamePadDevice::processAndMapInput(PlayerAction* action /* out */,
|
||||
Input::InputType type, const int id,
|
||||
InputManager::InputDriverMode mode,
|
||||
PlayerAction* action /* out */)
|
||||
int* value/* inout */)
|
||||
{
|
||||
if (!m_configuration->isEnabled()) return false;
|
||||
|
||||
|
@ -78,10 +78,9 @@ public:
|
||||
*
|
||||
* \return Whether the pressed key/button is bound with an action
|
||||
*/
|
||||
bool processAndMapInput(Input::InputType type, const int id,
|
||||
int* value,
|
||||
InputManager::InputDriverMode mode,
|
||||
PlayerAction* action);
|
||||
bool processAndMapInput(PlayerAction* action, Input::InputType type,
|
||||
const int id,
|
||||
InputManager::InputDriverMode mode, int* value);
|
||||
|
||||
};
|
||||
|
||||
|
@ -16,16 +16,18 @@
|
||||
// along with this program; if not, write to the Free Software
|
||||
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
|
||||
#ifndef INPUT_DEVICE_HPP
|
||||
#define INPUT_DEVICE_HPP
|
||||
#ifndef HEADER_INPUT_DEVICE_HPP
|
||||
#define HEADER_INPUT_DEVICE_HPP
|
||||
|
||||
#include <string>
|
||||
|
||||
#include "input/device_config.hpp"
|
||||
#include "input/input.hpp"
|
||||
#include "input/input_manager.hpp"
|
||||
#include "states_screens/state_manager.hpp"
|
||||
#include "utils/no_copy.hpp"
|
||||
|
||||
#include <string>
|
||||
|
||||
/**
|
||||
* \brief Input device type
|
||||
* \ingroup input
|
||||
@ -60,13 +62,21 @@ public:
|
||||
|
||||
InputDevice();
|
||||
virtual ~InputDevice();
|
||||
bool processAndMapInput(PlayerAction* action, Input::InputType type, int id, InputManager::InputDriverMode mode);
|
||||
|
||||
bool processAndMapInput(PlayerAction* action, Input::InputType type, const int id,
|
||||
int* value, InputManager::InputDriverMode mode);
|
||||
|
||||
#ifdef NOTYET
|
||||
virtual bool processAndMapInput(Input::InputType type, const int id,
|
||||
virtual bool processAndMapInput(PlayerAction *action,
|
||||
Input::InputType type,
|
||||
|
||||
const int id,
|
||||
int* value,
|
||||
InputManager::InputDriverMode mode,
|
||||
PlayerAction* action);
|
||||
|
||||
PlayerAction* action) = 0;
|
||||
#endif
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
/** Sets which players uses this device; or pass NULL to say no player
|
||||
* uses it. */
|
||||
|
@ -39,10 +39,12 @@ KeyboardDevice::KeyboardDevice()
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
bool KeyboardDevice::processAndMapInput(const int id,
|
||||
InputManager::InputDriverMode mode,
|
||||
PlayerAction* action /* out */)
|
||||
bool KeyboardDevice::processAndMapInput(PlayerAction* action /* out */,
|
||||
Input::InputType type,
|
||||
const int id,
|
||||
InputManager::InputDriverMode mode)
|
||||
{
|
||||
assert(type==Input::IT_KEYBOARD);
|
||||
if (mode == InputManager::INGAME)
|
||||
{
|
||||
return m_configuration->getGameAction(Input::IT_KEYBOARD, id, 0,
|
||||
|
@ -22,6 +22,8 @@
|
||||
|
||||
#include "input/input_device.hpp"
|
||||
|
||||
#include "input/input.hpp"
|
||||
|
||||
class KeyboardConfig;
|
||||
|
||||
/**
|
||||
@ -46,8 +48,9 @@ public:
|
||||
* \param[out] action The action associated to this input (only check
|
||||
* this value if method returned true)
|
||||
*/
|
||||
bool processAndMapInput(const int id, InputManager::InputDriverMode mode,
|
||||
PlayerAction* action);
|
||||
bool processAndMapInput(PlayerAction* action, Input::InputType type,
|
||||
const int id,
|
||||
InputManager::InputDriverMode mode);
|
||||
|
||||
}; // KeyboardDevice
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user