Add joystick connected event
This commit is contained in:
@@ -21,6 +21,9 @@ namespace Inferno {
|
||||
MouseButtonRelease,
|
||||
MousePosition,
|
||||
MouseScroll,
|
||||
|
||||
JoystickConnected,
|
||||
JoystickDisconnected,
|
||||
};
|
||||
|
||||
enum EventCategory {
|
||||
@@ -33,6 +36,8 @@ namespace Inferno {
|
||||
|
||||
MouseEventCategory = BIT(3),
|
||||
MouseButtonEventCategory = BIT(4),
|
||||
|
||||
JoystickEventCatergory = BIT(5),
|
||||
};
|
||||
|
||||
class Event {
|
||||
|
||||
@@ -0,0 +1,55 @@
|
||||
#ifndef JOYSTICKEVENT_H
|
||||
#define JOYSTICKEVENT_H
|
||||
|
||||
#include "inferno/event/event.h"
|
||||
|
||||
namespace Inferno {
|
||||
|
||||
class JoystickEvent : public Event {
|
||||
public:
|
||||
inline int getID() const { return m_id; }
|
||||
|
||||
EVENT_CLASS_CATEGORY(InputEventCategory | JoystickEventCatergory)
|
||||
|
||||
protected:
|
||||
JoystickEvent(int id) :
|
||||
m_id(id) {}
|
||||
|
||||
private:
|
||||
int m_id;
|
||||
};
|
||||
|
||||
class JoystickConnectedEvent : public JoystickEvent {
|
||||
public:
|
||||
JoystickConnectedEvent(int id) :
|
||||
JoystickEvent(id) {}
|
||||
|
||||
virtual std::string toString() const override
|
||||
{
|
||||
std::stringstream ss;
|
||||
ss << "JoystickConnected: " << getID();
|
||||
return ss.str();
|
||||
}
|
||||
|
||||
EVENT_CLASS_TYPE(JoystickConnected)
|
||||
};
|
||||
|
||||
class JoystickDisconnectedEvent : public JoystickEvent {
|
||||
public:
|
||||
JoystickDisconnectedEvent(int id) :
|
||||
JoystickEvent(id) {}
|
||||
|
||||
virtual std::string toString() const override
|
||||
{
|
||||
std::stringstream ss;
|
||||
ss << "JoystickDisconnected: " << getID();
|
||||
return ss.str();
|
||||
}
|
||||
|
||||
EVENT_CLASS_TYPE(JoystickDisconnected)
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
|
||||
#endif // JOYSTICKEVENT_H
|
||||
Reference in New Issue
Block a user