OSDLController.cc

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

Generated on Fri Mar 30 14:46:59 2007 for OSDL by  doxygen 1.5.1