00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027 #include "OSDLController.h"
00028
00029 #include "OSDLEvents.h"
00030
00031
00032 using std::string ;
00033
00034
00035 using namespace Ceylan::Log ;
00036
00037 using namespace OSDL::Events ;
00038 using namespace OSDL::MVC ;
00039
00040
00041
00042 #ifdef OSDL_USES_CONFIG_H
00043 #include <OSDLConfig.h>
00044 #endif // OSDL_USES_CONFIG_H
00045
00046
00047
00048 #if OSDL_VERBOSE_CONTROLLER
00049
00050 #include <iostream>
00051 #define OSDL_CONTROLLER_LOG( message ) std::cout << "[OSDL controller] " << message << std::endl ;
00052
00053 #else // OSDL_VERBOSE_CONTROLLER
00054
00055 #define OSDL_CONTROLLER_LOG( message )
00056
00057 #endif // OSDL_VERBOSE_CONTROLLER
00058
00059
00060
00061
00062 Controller::Controller() :
00063 Ceylan::Controller()
00064 {
00065
00066 }
00067
00068
00069 Controller::Controller( Ceylan::Model & model ) :
00070 Ceylan::Controller( model )
00071 {
00072
00073 }
00074
00075
00076 Controller::~Controller() throw()
00077 {
00078
00079 }
00080
00081
00082
00083
00084
00085
00086
00087
00088 void Controller::keyboardFocusGained( const FocusEvent & keyboardFocusEvent )
00089 {
00090
00091 #if OSDL_DEBUG
00092
00093 if ( keyboardFocusEvent.type != EventsModule::ApplicationFocusChanged )
00094 Ceylan::emergencyShutdown( "Controller::keyboardFocusGained: "
00095 "unexpected event received instead." ) ;
00096
00097 #endif // OSDL_DEBUG
00098
00099 OSDL_CONTROLLER_LOG( "OSDL controller: keyboard focus gained: "
00100 + EventsModule::DescribeEvent( keyboardFocusEvent ) ) ;
00101
00102 }
00103
00104
00105
00106 void Controller::keyboardFocusLost( const FocusEvent & keyboardFocusEvent )
00107 {
00108
00109 #if OSDL_DEBUG
00110
00111 if ( keyboardFocusEvent.type != EventsModule::ApplicationFocusChanged )
00112 Ceylan::emergencyShutdown( "Controller::keyboardFocusLost: "
00113 "unexpected event received instead." ) ;
00114
00115 #endif // OSDL_DEBUG
00116
00117 OSDL_CONTROLLER_LOG( "OSDL controller: keyboard focus lost: "
00118 + EventsModule::DescribeEvent( keyboardFocusEvent ) ) ;
00119
00120 }
00121
00122
00123
00124 void Controller::rawKeyPressed( const KeyboardEvent & keyboardPressedEvent )
00125 {
00126
00127 #if OSDL_DEBUG
00128
00129 if ( keyboardPressedEvent.type != EventsModule::KeyPressed )
00130 Ceylan::emergencyShutdown( "Controller::rawKeyPressed: "
00131 "unexpected event received instead." ) ;
00132
00133 #endif // OSDL_DEBUG
00134
00135 OSDL_CONTROLLER_LOG( "OSDL controller: raw key pressed: "
00136 + EventsModule::DescribeEvent( keyboardPressedEvent ) ) ;
00137
00138 }
00139
00140
00141
00142 void Controller::rawKeyReleased( const KeyboardEvent & keyboardReleasedEvent )
00143 {
00144
00145 #if OSDL_DEBUG
00146
00147 if ( keyboardReleasedEvent.type != EventsModule::KeyReleased )
00148 Ceylan::emergencyShutdown( "Controller::rawKeyReleased: "
00149 "unexpected event received instead." ) ;
00150
00151 #endif // OSDL_DEBUG
00152
00153 OSDL_CONTROLLER_LOG( "OSDL controller: raw key released: "
00154 + EventsModule::DescribeEvent( keyboardReleasedEvent ) ) ;
00155
00156 }
00157
00158
00159
00160 void Controller::unicodeSelected( const KeyboardEvent & keyboardPressedEvent )
00161 {
00162
00163 #if OSDL_DEBUG
00164
00165 if ( keyboardPressedEvent.type != EventsModule::KeyPressed )
00166 Ceylan::emergencyShutdown( "Controller::unicodeSelected: "
00167 "unexpected event received instead." ) ;
00168
00169 #endif // OSDL_DEBUG
00170
00171 OSDL_CONTROLLER_LOG( "OSDL controller: unicode selected: "
00172 + EventsModule::DescribeEvent( keyboardPressedEvent ) ) ;
00173
00174 }
00175
00176
00177
00178
00179
00180
00181
00182
00183 void Controller::mouseFocusGained( const FocusEvent & mouseFocusEvent )
00184 {
00185
00186 #if OSDL_DEBUG
00187
00188 if ( mouseFocusEvent.type != EventsModule::ApplicationFocusChanged )
00189 Ceylan::emergencyShutdown( "Controller::mouseFocusGained: "
00190 "unexpected event received instead." ) ;
00191
00192 #endif // OSDL_DEBUG
00193
00194 OSDL_CONTROLLER_LOG( "OSDL controller: mouse focus gained: "
00195 + EventsModule::DescribeEvent( mouseFocusEvent ) ) ;
00196
00197 }
00198
00199
00200
00201 void Controller::mouseFocusLost( const FocusEvent & mouseFocusEvent )
00202 {
00203
00204 #if OSDL_DEBUG
00205
00206 if ( mouseFocusEvent.type != EventsModule::ApplicationFocusChanged )
00207 Ceylan::emergencyShutdown( "Controller::mouseFocusLost: "
00208 "unexpected event received instead." ) ;
00209
00210 #endif // OSDL_DEBUG
00211
00212 OSDL_CONTROLLER_LOG( "OSDL controller: mouse focus lost: "
00213 + EventsModule::DescribeEvent( mouseFocusEvent ) ) ;
00214
00215 }
00216
00217
00218
00219 void Controller::mouseMoved( const MouseMotionEvent & mouseMotionEvent )
00220 {
00221
00222 #if OSDL_DEBUG
00223
00224 if ( mouseMotionEvent.type != EventsModule::MouseMoved )
00225 Ceylan::emergencyShutdown( "Controller::mouseMoved: "
00226 "unexpected event received instead." ) ;
00227
00228 #endif // OSDL_DEBUG
00229
00230 OSDL_CONTROLLER_LOG( "OSDL controller: mouseMoved: "
00231 + EventsModule::DescribeEvent( mouseMotionEvent ) ) ;
00232
00233 }
00234
00235
00236
00237 void Controller::mouseButtonPressed(
00238 const MouseButtonEvent & mouseButtonPressedEvent )
00239 {
00240
00241 #if OSDL_DEBUG
00242
00243 if ( mouseButtonPressedEvent.type != EventsModule::MouseButtonPressed )
00244 Ceylan::emergencyShutdown( "Controller::mouseButtonPressed: "
00245 "unexpected event received instead." ) ;
00246
00247 #endif // OSDL_DEBUG
00248
00249 OSDL_CONTROLLER_LOG( "OSDL controller: mouseButtonPressed: "
00250 + EventsModule::DescribeEvent( mouseButtonPressedEvent ) ) ;
00251
00252 }
00253
00254
00255
00256 void Controller::mouseButtonReleased(
00257 const MouseButtonEvent & mouseButtonReleasedEvent )
00258 {
00259
00260 #if OSDL_DEBUG
00261
00262 if ( mouseButtonReleasedEvent.type != EventsModule::MouseButtonReleased )
00263 Ceylan::emergencyShutdown( "Controller::mouseButtonReleased: "
00264 "unexpected event received instead." ) ;
00265
00266 #endif // OSDL_DEBUG
00267
00268 OSDL_CONTROLLER_LOG( "OSDL controller: mouseButtonReleased: "
00269 + EventsModule::DescribeEvent( mouseButtonReleasedEvent ) ) ;
00270
00271 }
00272
00273
00274
00275 void Controller::joystickAxisChanged(
00276 const JoystickAxisEvent & joystickAxisEvent )
00277 {
00278
00279 #if OSDL_DEBUG
00280
00281 if ( joystickAxisEvent.type != EventsModule::JoystickAxisChanged )
00282 Ceylan::emergencyShutdown( "Controller::joystickAxisChanged: "
00283 "unexpected event received instead." ) ;
00284
00285 #endif // OSDL_DEBUG
00286
00287 OSDL_CONTROLLER_LOG( "OSDL controller: joystickAxisChanged: "
00288 + EventsModule::DescribeEvent( joystickAxisEvent ) ) ;
00289
00290 }
00291
00292
00293
00294 void Controller::joystickTrackballChanged(
00295 const JoystickTrackballEvent & joystickTrackballEvent )
00296 {
00297
00298 #if OSDL_DEBUG
00299
00300 if ( joystickTrackballEvent.type != EventsModule::JoystickTrackballChanged )
00301 Ceylan::emergencyShutdown( "Controller::joystickTrackballChanged: "
00302 "unexpected event received instead." ) ;
00303
00304 #endif // OSDL_DEBUG
00305
00306 OSDL_CONTROLLER_LOG( "OSDL controller: joystickTrackballChanged: "
00307 + EventsModule::DescribeEvent( joystickTrackballEvent ) ) ;
00308
00309 }
00310
00311
00312
00313 void Controller::joystickHatChanged(
00314 const JoystickHatEvent & joystickHatChangedEvent )
00315 {
00316
00317 #if OSDL_DEBUG
00318
00319 if ( joystickHatChangedEvent.type !=
00320 EventsModule::JoystickHatPositionChanged )
00321 Ceylan::emergencyShutdown( "Controller::joystickHatPositionChanged: "
00322 "unexpected event received instead." ) ;
00323
00324 #endif // OSDL_DEBUG
00325
00326 OSDL_CONTROLLER_LOG( "OSDL controller: joystickHatPositionChanged: "
00327 + EventsModule::DescribeEvent( joystickHatChangedEvent ) ) ;
00328
00329 }
00330
00331
00332
00333 void Controller::joystickButtonPressed(
00334 const JoystickButtonEvent & joystickButtonPressedEvent )
00335 {
00336
00337 #if OSDL_DEBUG
00338
00339 if ( joystickButtonPressedEvent.type !=
00340 EventsModule::JoystickButtonPressed )
00341 Ceylan::emergencyShutdown( "Controller::joystickButtonPressed: "
00342 "unexpected event received instead." ) ;
00343
00344 #endif // OSDL_DEBUG
00345
00346 OSDL_CONTROLLER_LOG( "OSDL controller: joystickButtonPressed: "
00347 + EventsModule::DescribeEvent( joystickButtonPressedEvent ) ) ;
00348
00349 }
00350
00351
00352
00353 void Controller::joystickButtonReleased(
00354 const JoystickButtonEvent & joystickButtonReleasedEvent )
00355 {
00356
00357 #if OSDL_DEBUG
00358
00359 if ( joystickButtonReleasedEvent.type !=
00360 EventsModule::JoystickButtonReleased )
00361 Ceylan::emergencyShutdown( "Controller::joystickButtonReleased: "
00362 "unexpected event received instead." ) ;
00363
00364 #endif // OSDL_DEBUG
00365
00366 OSDL_CONTROLLER_LOG( "OSDL controller: joystickButtonReleased: "
00367 + EventsModule::DescribeEvent( joystickButtonReleasedEvent ) ) ;
00368
00369 }
00370
00371
00372
00373 void Controller::joystickLeft( AxisPosition leftExtent )
00374 {
00375
00376 OSDL_CONTROLLER_LOG( "Controller::joystickLeft: extent is "
00377 << leftExtent ) ;
00378
00379 }
00380
00381
00382
00383 void Controller::joystickRight( AxisPosition rightExtent )
00384 {
00385
00386 OSDL_CONTROLLER_LOG( "Controller::joystickRight: extent is "
00387 << rightExtent ) ;
00388
00389 }
00390
00391
00392
00393 void Controller::joystickUp( AxisPosition upExtent )
00394 {
00395
00396 OSDL_CONTROLLER_LOG( "Controller::joystickUp: extent is "
00397 << upExtent ) ;
00398
00399 }
00400
00401
00402
00403 void Controller::joystickDown( AxisPosition downExtent )
00404 {
00405
00406 OSDL_CONTROLLER_LOG( "Controller::joystickDown: extent is "
00407 << downExtent ) ;
00408
00409 }
00410
00411
00412
00413 void Controller::joystickFirstButtonPressed()
00414 {
00415
00416 OSDL_CONTROLLER_LOG( "Controller::joystickFirstButtonPressed" ) ;
00417
00418 }
00419
00420
00421
00422 void Controller::joystickFirstButtonReleased()
00423 {
00424
00425 OSDL_CONTROLLER_LOG( "Controller::joystickFirstButtonReleased" ) ;
00426
00427 }
00428
00429
00430
00431 void Controller::joystickSecondButtonPressed()
00432 {
00433
00434 OSDL_CONTROLLER_LOG( "Controller::joystickSecondButtonPressed" ) ;
00435
00436 }
00437
00438
00439
00440 void Controller::joystickSecondButtonReleased()
00441 {
00442
00443 OSDL_CONTROLLER_LOG( "Controller::joystickSecondButtonReleased" ) ;
00444
00445 }
00446
00447
00448 const Ceylan::Event & Controller::getEventFor(
00449 const Ceylan::CallerEventListener & listener )
00450 {
00451
00452 throw EventsException( "Controller::getEventFor is not expected "
00453 "to be called." ) ;
00454
00455 }
00456
00457
00458 const string Controller::toString( Ceylan::VerbosityLevels level ) const
00459 {
00460
00461 return "OSDL controller: " + Ceylan::Controller::toString( level ) ;
00462
00463 }
00464