Changeset 6771 in orxonox.OLD for trunk/src/lib/event
- Timestamp:
- Jan 26, 2006, 2:39:31 PM (19 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/lib/event/event_handler.cc
r6769 r6771 156 156 PRINTF(4)("Subscribing event type: %i\n", eventType); 157 157 if( state == ES_ALL ) 158 159 160 161 162 163 164 158 { 159 for(unsigned int i = 0; i < ES_NUMBER; i++) 160 if( likely(this->listeners[i][eventType] == NULL)) 161 this->listeners[i][eventType] = el; 162 else 163 PRINTF(2)("%s of class %s tried to subscribe to event %i @ state %i but this event has already been subscribed\n", el->getName(), el->getClassName(), eventType, state); 164 } 165 165 else 166 166 if( likely(this->listeners[state][eventType] == NULL)) 167 168 169 167 { 168 this->listeners[state][eventType] = el; 169 } 170 170 else 171 171 PRINTF(2)("% of class %s tried to subscribe to event %i @ state %i but this event has already been subscribed\n", el->getName(), el->getClassName(), eventType, state); … … 203 203 return; 204 204 if( state == ES_ALL) 205 206 207 208 209 210 211 212 213 214 215 else 216 217 218 219 220 221 222 205 { 206 for(unsigned int i = 0; i < ES_NUMBER; i++) 207 { 208 for(unsigned int j = 0; j < EV_NUMBER; j++) 209 { 210 if( this->listeners[i][j] == el ) 211 this->listeners[i][j] = NULL; 212 } 213 } 214 } 215 else 216 { 217 for(int j = 0; j < EV_NUMBER; j++) 218 { 219 if( this->listeners[state][j] == el ) 220 this->listeners[state][j] = NULL; 221 } 222 } 223 223 } 224 224 … … 231 231 { 232 232 if( state == ES_ALL) 233 { 234 for(int i = 0; i < ES_NUMBER; ++i) 235 { 236 for(int j = 0; j < EV_NUMBER; ++j) 237 { 238 this->listeners[i][j] = NULL; 239 } 240 } 241 } 242 else 233 { 234 for(int i = 0; i < ES_NUMBER; ++i) 243 235 { 244 236 for(int j = 0; j < EV_NUMBER; ++j) 245 { 246 this->listeners[state][j] = NULL; 247 } 248 } 237 { 238 this->listeners[i][j] = NULL; 239 } 240 } 241 } 242 else 243 { 244 for(int j = 0; j < EV_NUMBER; ++j) 245 { 246 this->listeners[state][j] = NULL; 247 } 248 } 249 249 } 250 250 … … 262 262 SDL_WM_GrabInput(SDL_GRAB_OFF); 263 263 else 264 ;//SDL_WM_GrabInput(SDL_GRAB_ON);264 SDL_WM_GrabInput(SDL_GRAB_ON); 265 265 } 266 266 … … 276 276 EventListener* listener = NULL; 277 277 while( SDL_PollEvent (&event)) 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 278 { 279 switch( event.type) 280 { 281 case SDL_KEYDOWN: 282 ev.bPressed = true; 283 ev.type = event.key.keysym.sym; 284 if (unlikely(this->bUNICODE)) 285 ev.x = event.key.keysym.unicode; 286 break; 287 case SDL_KEYUP: 288 ev.bPressed = false; 289 ev.type = event.key.keysym.sym; 290 if (unlikely(this->bUNICODE)) 291 ev.x = event.key.keysym.unicode; 292 break; 293 case SDL_MOUSEMOTION: 294 ev.bPressed = false; 295 ev.type = EV_MOUSE_MOTION; 296 ev.x = event.motion.x; 297 ev.y = event.motion.y; 298 ev.xRel = event.motion.xrel; 299 ev.yRel = event.motion.yrel; 300 break; 301 case SDL_MOUSEBUTTONUP: 302 ev.bPressed = false; 303 ev.type = event.button.button + SDLK_LAST; 304 break; 305 case SDL_MOUSEBUTTONDOWN: 306 ev.bPressed = true; 307 ev.type = event.button.button + SDLK_LAST; 308 break; 309 case SDL_JOYAXISMOTION: 310 ev.bPressed = false; 311 ev.type = EV_JOY_AXIS_MOTION; 312 break; 313 case SDL_JOYBALLMOTION: 314 ev.bPressed = false; 315 ev.type = EV_JOY_BALL_MOTION; 316 break; 317 case SDL_JOYHATMOTION: 318 ev.bPressed = false; 319 ev.type = EV_JOY_HAT_MOTION; 320 break; 321 case SDL_JOYBUTTONDOWN: 322 ev.bPressed = true; 323 ev.type = EV_JOY_BUTTON; 324 break; 325 case SDL_JOYBUTTONUP: 326 ev.bPressed = true; 327 ev.type = EV_JOY_BUTTON; 328 break; 329 case SDL_VIDEORESIZE: 330 ev.resize = event.resize; 331 ev.type = EV_VIDEO_RESIZE; 332 break; 333 case SDL_QUIT: 334 ev.type = EV_MAIN_QUIT; 335 break; 336 default: 337 ev.type = EV_UNKNOWN; 338 break; 339 } 340 341 /* small debug routine: shows all events dispatched by the event handler */ 342 PRINT(4)("\n==========================| EventHandler::process () |===\n"); 343 PRINT(4)("= Got Event nr %i, for state %i", ev.type, this->state); 344 345 listener = this->listeners[this->state][ev.type]; 346 if( listener != NULL) 347 { 348 PRINT(4)("= Event dispatcher msg: This event has been consumed\n"); 349 PRINT(4)("=======================================================\n"); 350 listener->process(ev); 351 } 352 else 353 { 354 PRINT(4)("= Event dispatcher msg: This event has NOT been consumed\n"); 355 PRINT(4)("=======================================================\n"); 356 } 357 } 358 358 } 359 359
Note: See TracChangeset
for help on using the changeset viewer.