22 #ifndef MEDIASTATION_EVENTS_H 23 #define MEDIASTATION_EVENTS_H 25 #include "common/events.h" 26 #include "common/hash-ptr.h" 27 #include "common/ptr.h" 28 #include "common/str.h" 29 #include "common/queue.h" 31 #include "mediastation/mediascript/scriptconstants.h" 32 #include "mediastation/mediascript/scriptvalue.h" 37 kEventClassInvalid = 0x00,
38 kEventClassSystem = 0x01,
39 kEventClassMouse = 0x02,
40 kEventClassKeyboard = 0x04,
41 kEventClassDisplay = 0x08,
42 kEventClassTimerService = 0x10,
43 kEventClassScriptTimer = 0x20,
44 kEventClassActor = 0x40
46 const char *eventClassToStr(EventClass eventClass);
52 enum EventClassHandlerType {
53 kNoEventClassHandler = 0x00,
54 kStageDirectorEventClassHandler = 0x06,
55 kDisplayUpdateEventClassHandler = 0x08,
56 kTimerServiceClassHandler = 0x10,
57 kActorEventClassHandler = 0x40,
61 EventClass eventClass = kEventClassInvalid;
62 EventType type = kEventTypeInvalid;
64 Event(EventClass eventClass_, EventType eventType_)
65 : eventClass(eventClass_), type(eventType_) {}
67 virtual Event *clone()
const = 0;
72 uint disableScreenAutoUpdateToken = 0;
75 :
Event(kEventClassDisplay, eventType_), disableScreenAutoUpdateToken(token_) {}
84 uint32 triggerTime = 0;
88 :
Event(kEventClassTimerService, kTimerServiceAlarmEvent), triggerTime(triggerTime_), entry(entry_) {}
98 :
Event(kEventClassScriptTimer, kTimerScriptEvent), entry(entry_) {}
107 ActorEvent(uint16 actorId_, EventType eventType_)
108 :
Event(kEventClassActor, eventType_), actorId(actorId_) {}
110 :
Event(kEventClassActor, eventType_), actorId(actorId_), arg(arg_) {}
117 bool disableScreenAutoUpdate =
false;
119 ScreenBranchEvent(uint16 actorId_, uint16 screenId_,
bool disableScreenAutoUpdate_)
120 :
ActorEvent(actorId_, kScreenBranchEvent), screenId(screenId_), disableScreenAutoUpdate(disableScreenAutoUpdate_) {}
129 :
Event(kEventClassMouse, eventType_), position(position_) {}
134 enum SpecialCharCodes {
135 kBackspaceCharCode = 0x08,
136 kLeftArrowCharCode = 0x100,
137 kRightArrowCharCode = 0x101,
138 kUpArrowCharCode = 0x102,
139 kDownArrowCharCode = 0x103,
140 kCursorCharCode = 0x104,
147 :
Event(kEventClassKeyboard, eventType_), state(state_) {}
155 uint16 getMediaStationCharCode()
const;
158 enum PreDisplaySyncState {
159 kPreDisplaySyncForceScreenUpdate = 0,
160 kPreDisplaySyncNoScreenUpdateRequested = 1,
161 kPreDisplaySyncStateBlockScreenUpdate = 2
169 virtual PreDisplaySyncState preDisplaySync() = 0;
171 void registerForSyncCalls();
172 void unregisterForSyncCalls();
181 void queueEvent(
const Event &event);
192 void dispatchImtEvents();
193 PreDisplaySyncState preDisplaySync();
194 void updateDisplay();
198 void dispatchImtEvent(
const Event &event);
205 uint32 currentReceiverTime();
206 virtual void timerEvent(
const TimerEvent &event) = 0;
215 void setDuration(uint32 duration) { _duration = duration; }
216 uint32 calculateFirstExpirationTime(uint32 currentTime);
217 uint32 calculateNextExpirationTime(uint32 currentTime);
218 uint32 deltaTimeAtExpiration()
const;
219 uint32 expirationTime()
const {
return _expirationTime; }
220 bool shouldReschedule()
const {
return _shouldRepeat; }
223 bool operator==(
const TimerEntry &other)
const;
224 bool operator<(
const TimerEntry &other)
const;
225 bool operator>(
const TimerEntry &other)
const;
229 uint32 _expirationTime = 0;
230 uint32 _actualExpirationTime = 0;
231 uint32 _duration = 0;
232 bool _shouldRepeat =
false;
240 void startTimer(
TimerEntry &entry, uint32 duration);
241 void startTimer(
TimerEntry &entry,
double duration);
243 void queueExpiredTimerEvents();
Definition: keyboard.h:294