Files
NS_unknown_game/Frostbite2D/include/frostbite2D/event/touch_event.h
T
2026-06-08 19:58:35 +08:00

65 lines
1.8 KiB
C++

#pragma once
#include <frostbite2D/event/event.h>
#include <frostbite2D/types/type_math.h>
#include <SDL2/SDL_touch.h>
namespace frostbite2D {
class TouchEvent : public Event {
public:
TouchEvent(EventType type, uint32 timestamp, int64 touchId, int64 fingerId,
const Vec2& position, const Vec2& delta, float pressure)
: Event(timestamp)
, type_(type)
, touchId_(touchId)
, fingerId_(fingerId)
, position_(position)
, delta_(delta)
, pressure_(pressure) {}
EventType getType() const override {
return type_;
}
int64 getTouchId() const { return touchId_; }
int64 getFingerId() const { return fingerId_; }
const Vec2& getPosition() const { return position_; }
const Vec2& getDelta() const { return delta_; }
float getPressure() const { return pressure_; }
private:
EventType type_;
int64 touchId_;
int64 fingerId_;
Vec2 position_;
Vec2 delta_;
float pressure_;
};
class TouchDownEvent : public TouchEvent {
public:
TouchDownEvent(uint32 timestamp, int64 touchId, int64 fingerId,
const Vec2& position, float pressure)
: TouchEvent(EventType::TouchDown, timestamp, touchId, fingerId,
position, Vec2(0, 0), pressure) {}
};
class TouchUpEvent : public TouchEvent {
public:
TouchUpEvent(uint32 timestamp, int64 touchId, int64 fingerId,
const Vec2& position, float pressure)
: TouchEvent(EventType::TouchUp, timestamp, touchId, fingerId,
position, Vec2(0, 0), pressure) {}
};
class TouchMoveEvent : public TouchEvent {
public:
TouchMoveEvent(uint32 timestamp, int64 touchId, int64 fingerId,
const Vec2& position, const Vec2& delta, float pressure)
: TouchEvent(EventType::TouchMove, timestamp, touchId, fingerId,
position, delta, pressure) {}
};
}