Input: remove InputEvent and InputListener and related code. Those are handled in System/Event
This commit is contained in:
parent
3c209ba01b
commit
cdaed77bf7
8 changed files with 0 additions and 161 deletions
|
|
@ -56,8 +56,6 @@ local platform_spec_module = Module("source/Platform/Win32", {
|
||||||
|
|
||||||
local input_module = Module("source/Input", {
|
local input_module = Module("source/Input", {
|
||||||
"InputDevice.cpp",
|
"InputDevice.cpp",
|
||||||
"InputEvent.cpp",
|
|
||||||
"InputListener.cpp",
|
|
||||||
"InputModule.cpp",
|
"InputModule.cpp",
|
||||||
"Keyboard.cpp",
|
"Keyboard.cpp",
|
||||||
"Mouse.cpp"
|
"Mouse.cpp"
|
||||||
|
|
|
||||||
|
|
@ -3,7 +3,6 @@
|
||||||
#define SPECTRE_GAME_H
|
#define SPECTRE_GAME_H
|
||||||
|
|
||||||
#include <Spectre/Graphics.h>
|
#include <Spectre/Graphics.h>
|
||||||
#include <Spectre/Input/InputEvent.h>
|
|
||||||
#include <Spectre/Game/FPSCounter.h>
|
#include <Spectre/Game/FPSCounter.h>
|
||||||
|
|
||||||
class InputModule;
|
class InputModule;
|
||||||
|
|
|
||||||
|
|
@ -1,54 +0,0 @@
|
||||||
|
|
||||||
#ifndef SPECTRE_INPUT_EVENT_H
|
|
||||||
#define SPECTRE_INPUT_EVENT_H
|
|
||||||
|
|
||||||
#include <string>
|
|
||||||
#include <vector>
|
|
||||||
#include <Spectre/Input/Mouse.h>
|
|
||||||
#include <Spectre/Input/Keyboard.h>
|
|
||||||
|
|
||||||
namespace sp {
|
|
||||||
|
|
||||||
typedef struct InputEvent
|
|
||||||
{
|
|
||||||
enum Type
|
|
||||||
{
|
|
||||||
None,
|
|
||||||
Key,
|
|
||||||
MouseButton,
|
|
||||||
MousePosition
|
|
||||||
};
|
|
||||||
|
|
||||||
struct KeyEvent {
|
|
||||||
Keyboard::Key code;
|
|
||||||
bool pressed; /* true if pressed, false if released. */
|
|
||||||
|
|
||||||
std::string getKeyName() const; /* Get the key name */
|
|
||||||
};
|
|
||||||
|
|
||||||
struct MouseButtonEvent {
|
|
||||||
Mouse::Button button;
|
|
||||||
bool pressed; /* true if pressed, false if released. */
|
|
||||||
|
|
||||||
std::string getName() const;
|
|
||||||
};
|
|
||||||
|
|
||||||
struct MouseEvent {
|
|
||||||
unsigned int x;
|
|
||||||
unsigned int y;
|
|
||||||
};
|
|
||||||
|
|
||||||
Type type;
|
|
||||||
union {
|
|
||||||
struct KeyEvent key;
|
|
||||||
struct MouseEvent mouse;
|
|
||||||
struct MouseButtonEvent mouseButton;
|
|
||||||
};
|
|
||||||
|
|
||||||
InputEvent(Type type = None);
|
|
||||||
|
|
||||||
} InputEvent;
|
|
||||||
|
|
||||||
} // namespace sp
|
|
||||||
|
|
||||||
#endif /* SPECTRE_INPUT_EVENT_H */
|
|
||||||
|
|
@ -1,17 +0,0 @@
|
||||||
|
|
||||||
#ifndef SPECTRE_INPUT_LISTENER_H
|
|
||||||
#define SPECTRE_INPUT_LISTENER_H
|
|
||||||
|
|
||||||
#include "InputEvent.h"
|
|
||||||
|
|
||||||
namespace sp {
|
|
||||||
|
|
||||||
class InputListener
|
|
||||||
{
|
|
||||||
public :
|
|
||||||
virtual void onInputEvent(const InputEvent& event);
|
|
||||||
};
|
|
||||||
|
|
||||||
} // namespace sp
|
|
||||||
|
|
||||||
#endif /* SPECTRE_INPUT_LISTENER_H */
|
|
||||||
|
|
@ -5,9 +5,6 @@
|
||||||
#include <deque>
|
#include <deque>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
#include "InputListener.h"
|
|
||||||
#include "InputEvent.h"
|
|
||||||
|
|
||||||
namespace sp {
|
namespace sp {
|
||||||
|
|
||||||
class Mouse;
|
class Mouse;
|
||||||
|
|
@ -28,12 +25,6 @@ public :
|
||||||
|
|
||||||
void addInputDevice(InputDevice *device);
|
void addInputDevice(InputDevice *device);
|
||||||
|
|
||||||
void registerListener(InputListener* listener);
|
|
||||||
|
|
||||||
void removeListener(InputListener* listener);
|
|
||||||
|
|
||||||
void postInputEvent(const InputEvent& event);
|
|
||||||
|
|
||||||
// NOTE: Update devices here! (for winapi, process keyboard/mouse messages)
|
// NOTE: Update devices here! (for winapi, process keyboard/mouse messages)
|
||||||
void update();
|
void update();
|
||||||
|
|
||||||
|
|
@ -48,11 +39,6 @@ protected :
|
||||||
|
|
||||||
Keyboard *m_keyboard;
|
Keyboard *m_keyboard;
|
||||||
|
|
||||||
// Buffered input queue.
|
|
||||||
std::deque<InputEvent> m_buffer;
|
|
||||||
|
|
||||||
std::vector<InputListener*> m_listeners;
|
|
||||||
|
|
||||||
PlatformInput *m_platform;
|
PlatformInput *m_platform;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,23 +0,0 @@
|
||||||
|
|
||||||
#include <Spectre/Input/Mouse.h>
|
|
||||||
#include <Spectre/Input/Keyboard.h>
|
|
||||||
#include <Spectre/Input/InputEvent.h>
|
|
||||||
|
|
||||||
namespace sp {
|
|
||||||
|
|
||||||
InputEvent::InputEvent(Type type) :
|
|
||||||
type (type)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
std::string InputEvent::KeyEvent::getKeyName() const
|
|
||||||
{
|
|
||||||
return Keyboard::getKeyName(code);
|
|
||||||
}
|
|
||||||
|
|
||||||
std::string InputEvent::MouseButtonEvent::getName() const
|
|
||||||
{
|
|
||||||
return Mouse::getButtonName(button);
|
|
||||||
}
|
|
||||||
|
|
||||||
} // namespace sp
|
|
||||||
|
|
@ -1,10 +0,0 @@
|
||||||
|
|
||||||
#include <Spectre/Input/InputListener.h>
|
|
||||||
|
|
||||||
namespace sp {
|
|
||||||
|
|
||||||
void InputListener::onInputEvent(const InputEvent& event)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
} // namespace sp
|
|
||||||
|
|
@ -2,7 +2,6 @@
|
||||||
#include <Platform/PlatformInput.h>
|
#include <Platform/PlatformInput.h>
|
||||||
#include <Spectre/Input/Keyboard.h>
|
#include <Spectre/Input/Keyboard.h>
|
||||||
#include <Spectre/Input/Mouse.h>
|
#include <Spectre/Input/Mouse.h>
|
||||||
#include <Spectre/Input/InputEvent.h>
|
|
||||||
#include <Spectre/Input/InputDevice.h>
|
#include <Spectre/Input/InputDevice.h>
|
||||||
#include <Spectre/Input/InputModule.h>
|
#include <Spectre/Input/InputModule.h>
|
||||||
|
|
||||||
|
|
@ -35,16 +34,6 @@ void InputModule::addInputDevice(InputDevice *device)
|
||||||
m_devices.push_back(device);
|
m_devices.push_back(device);
|
||||||
}
|
}
|
||||||
|
|
||||||
void InputModule::registerListener(InputListener* listener)
|
|
||||||
{
|
|
||||||
m_listeners.push_back(listener);
|
|
||||||
}
|
|
||||||
|
|
||||||
void InputModule::removeListener(InputListener* listener)
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
Mouse* InputModule::getMouse()
|
Mouse* InputModule::getMouse()
|
||||||
{
|
{
|
||||||
return m_mouse;
|
return m_mouse;
|
||||||
|
|
@ -55,13 +44,6 @@ Keyboard* InputModule::getKeyboard()
|
||||||
return m_keyboard;
|
return m_keyboard;
|
||||||
}
|
}
|
||||||
|
|
||||||
void InputModule::postInputEvent(const InputEvent& event)
|
|
||||||
{
|
|
||||||
if (m_buffer.size() < 128) {
|
|
||||||
m_buffer.push_back(event);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void InputModule::update()
|
void InputModule::update()
|
||||||
{
|
{
|
||||||
InputDeviceVec::iterator it;
|
InputDeviceVec::iterator it;
|
||||||
|
|
@ -70,28 +52,6 @@ void InputModule::update()
|
||||||
for(it = m_devices.begin(); it != m_devices.end(); it++) {
|
for(it = m_devices.begin(); it != m_devices.end(); it++) {
|
||||||
(*it)->update(this);
|
(*it)->update(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Dispatch all events to listeners.
|
|
||||||
dispatch();
|
|
||||||
}
|
|
||||||
|
|
||||||
void InputModule::dispatch()
|
|
||||||
{
|
|
||||||
std::deque<InputEvent>::iterator it;
|
|
||||||
|
|
||||||
for(it = m_buffer.begin(); it != m_buffer.end(); it++) {
|
|
||||||
|
|
||||||
const InputEvent& event = *it;
|
|
||||||
|
|
||||||
// Call listeners.
|
|
||||||
std::vector<InputListener*>::iterator it;
|
|
||||||
for(it = m_listeners.begin(); it != m_listeners.end(); it++) {
|
|
||||||
|
|
||||||
(*it)->onInputEvent(event);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
m_buffer.clear();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace sp
|
} // namespace sp
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue