Browse Source

Add joystick connected event

master
Riyyi 5 years ago
parent
commit
11883bd17b
  1. 5
      inferno/src/inferno/event/event.h
  2. 55
      inferno/src/inferno/event/joystickevent.h

5
inferno/src/inferno/event/event.h

@ -21,6 +21,9 @@ namespace Inferno {
MouseButtonRelease, MouseButtonRelease,
MousePosition, MousePosition,
MouseScroll, MouseScroll,
JoystickConnected,
JoystickDisconnected,
}; };
enum EventCategory { enum EventCategory {
@ -33,6 +36,8 @@ namespace Inferno {
MouseEventCategory = BIT(3), MouseEventCategory = BIT(3),
MouseButtonEventCategory = BIT(4), MouseButtonEventCategory = BIT(4),
JoystickEventCatergory = BIT(5),
}; };
class Event { class Event {

55
inferno/src/inferno/event/joystickevent.h

@ -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
Loading…
Cancel
Save