Changeset 7897 in orxonox.OLD for branches/gui/src/lib/event/event_handler.cc
- Timestamp:
- May 27, 2006, 6:02:19 AM (18 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/gui/src/lib/event/event_handler.cc
r7895 r7897 94 94 void EventHandler::setState(elState state) 95 95 { 96 /// When Changing the State, all the keys will be released. 97 /// This is done by sending each eventListener, that still 98 /// has an Event subscribed, a Release Event. 99 int keyCount; 100 Uint8 * pressedKeys = SDL_GetKeyState(&keyCount); 101 for (unsigned int i = 0; i < SDLK_LAST; i++) 102 { 103 if (pressedKeys[i]) 104 { 105 Event ev; 106 ev.bPressed = false; 107 ev.type = i; 108 if (unlikely(this->bUNICODE[this->state])) 109 ev.x = i; 110 this->dispachEvent( ev ); 111 } 112 } 113 96 114 this->state = state; 97 115 SDL_EnableUNICODE(this->bUNICODE[state]); … … 227 245 } 228 246 247 /** 248 * @brief returns true if at state and eventType there is something subscribed. 249 * @param state the state to check in. 250 * @param eventType the eventtype to check. 251 * @returns true if a event is subscibed. 252 */ 229 253 bool EventHandler::isSubscribed(elState state, int eventType) 230 254 { … … 260 284 261 285 286 /** 287 * @brief if the unicode characters should be recorded. 288 * @param state the State in whitch to set the new Value. 289 * @param enableUNICODE: enabled, or disabled. 290 */ 262 291 void EventHandler::withUNICODE(elState state, bool enableUNICODE) 263 292 { … … 267 296 } 268 297 298 /** 299 * @brief grabs InputEvents. 300 * @param grabEvents if the Events should be grabbed(true) or released(false) 301 */ 269 302 void EventHandler::grabEvents(bool grabEvents) 270 303 { … … 281 314 } 282 315 } 316 283 317 284 318 /** … … 287 321 * The event from the SDL framework are collected here and distributed to all listeners. 288 322 */ 289 void EventHandler::process() 323 void EventHandler::process() const 290 324 { 291 325 SDL_Event event; … … 355 389 break; 356 390 } 357 358 /* small debug routine: shows all events dispatched by the event handler */ 359 PRINT(4)("\n==========================| EventHandler::process () |===\n"); 360 PRINT(4)("= Got Event nr %i, for state %i\n", ev.type, this->state); 361 362 /// setting a temporary state in case of an EventListener's process changes the state. 363 elState currentState = this->state; 364 for (unsigned int i = 0; i < this->listeners[currentState][ev.type].size(); i++) 365 { 366 PRINT(4)("= Event dispatcher msg: This event has been consumed\n"); 367 PRINT(4)("= Got Event nr %i, for state %i %s::%s\n", ev.type, currentState, this->listeners[this->state][ev.type][i]->getClassName(), this->listeners[currentState][ev.type][i]->getName()); 368 PRINT(4)("=======================================================\n"); 369 this->listeners[currentState][ev.type][i]->process(ev); 370 } 371 /* else 372 { 373 PRINT(4)("= Event dispatcher msg: This event has NOT been consumed\n"); 374 PRINT(4)("=======================================================\n"); 375 }*/ 376 } 377 } 391 this->dispachEvent(ev); 392 } 393 } 394 395 396 /** 397 * @brief dispaches an Event. 398 * @param event the Event to dispach. 399 */ 400 void EventHandler::dispachEvent(const Event& event) const 401 { 402 /* small debug routine: shows all events dispatched by the event handler */ 403 PRINT(4)("\n==========================| EventHandler::process () |===\n"); 404 PRINT(4)("= Got Event nr %i, for state %i\n", event.type, this->state); 405 406 /// setting a temporary state in case of an EventListener's process changes the state. 407 elState currentState = this->state; 408 for (unsigned int i = 0; i < this->listeners[currentState][event.type].size(); i++) 409 { 410 PRINT(4)("= Event dispatcher msg: This event has been consumed\n"); 411 PRINT(4)("= Got Event nr %i, for state %i %s::%s\n", event.type, currentState, this->listeners[this->state][event.type][i]->getClassName(), this->listeners[currentState][event.type][i]->getName()); 412 PRINT(4)("=======================================================\n"); 413 this->listeners[currentState][event.type][i]->process(event); 414 } 415 /* else 416 { 417 PRINT(4)("= Event dispatcher msg: This event has NOT been consumed\n"); 418 PRINT(4)("=======================================================\n"); 419 }*/ 420 } 421 422 378 423 379 424 /**
Note: See TracChangeset
for help on using the changeset viewer.