E:/Download/ois-1.0RC1/src/mac/MacHelpers.cpp

Go to the documentation of this file.
00001 /*
00002  The zlib/libpng License
00003  
00004  Copyright (c) 2006 Chris Snyder 
00005  
00006  This software is provided 'as-is', without any express or implied warranty. In no event will
00007  the authors be held liable for any damages arising from the use of this software.
00008  
00009  Permission is granted to anyone to use this software for any purpose, including commercial 
00010  applications, and to alter it and redistribute it freely, subject to the following
00011  restrictions:
00012  
00013  1. The origin of this software must not be misrepresented; you must not claim that 
00014  you wrote the original software. If you use this software in a product, 
00015  an acknowledgment in the product documentation would be appreciated but is 
00016  not required.
00017  
00018  2. Altered source versions must be plainly marked as such, and must not be 
00019  misrepresented as being the original software.
00020  
00021  3. This notice may not be removed or altered from any source distribution.
00022 */
00023 
00024 #include "mac/MacHelpers.h"
00025 #include "mac/MacKeyboard.h"
00026 #include "mac/MacMouse.h"
00027 #include "OISException.h"
00028 
00029 #include <Carbon/Carbon.h>
00030 
00031 using namespace OIS;
00032     
00033 //-------------------------------------------------------------------//
00034 OSStatus KeyDownWrapper( EventHandlerCallRef nextHandler,
00035                         EventRef               theEvent,
00036                         void*                  callClass )
00037 {
00038     // TODO find a better way. This cast isn't very safe
00039     if (callClass != NULL) {
00040         ((MacKeyboard*)callClass)->_keyDownCallback( theEvent );
00041         
00042         // propagate the event down the chain
00043         return CallNextEventHandler( nextHandler, theEvent );
00044     }
00045     else {
00046         OIS_EXCEPT(E_General, "KeyDownWrapper >> Being called by something other than our event handler!");
00047         return noErr;
00048     }
00049 }
00050 
00051 
00052 //-------------------------------------------------------------------//
00053 OSStatus KeyUpWrapper( EventHandlerCallRef nextHandler,
00054                        EventRef               theEvent,
00055                        void*                  callClass )
00056 {
00057     if (callClass != NULL) {
00058         ((MacKeyboard*)callClass)->_keyUpCallback( theEvent );
00059         
00060         // propagate the event down the chain
00061         return CallNextEventHandler( nextHandler, theEvent );
00062     }
00063     else {
00064         OIS_EXCEPT(E_General, "KeyUpWrapper >> Being called by something other than our event handler!");
00065         return noErr;
00066     }
00067 }
00068 
00069 
00070 //-------------------------------------------------------------------//
00071 OSStatus KeyModWrapper( EventHandlerCallRef nextHandler,
00072                         EventRef               theEvent,
00073                         void*                  callClass )
00074 {
00075     if (callClass != NULL) {
00076         ((MacKeyboard*)callClass)->_modChangeCallback( theEvent );
00077         
00078         // propagate the event down the chain
00079         return CallNextEventHandler( nextHandler, theEvent );
00080         
00081     }
00082     else {
00083         OIS_EXCEPT(E_General, "KeyModWrapper >> Being called by something other than our event handler!");
00084         return noErr;
00085     }
00086 }
00087 
00088 
00089 //-------------------------------------------------------------------//
00090 OSStatus MouseMoveWrapper( EventHandlerCallRef nextHandler,
00091                            EventRef            theEvent,
00092                            void*               callClass )
00093 {
00094     if (callClass != NULL) {
00095         ((MacMouse*)callClass)->_mouseMoveCallback( theEvent );
00096         
00097         // propagate the event down the chain
00098         return CallNextEventHandler( nextHandler, theEvent );
00099         
00100     }
00101     else {
00102         OIS_EXCEPT(E_General, "MouseMoveWrapper >> Being called by something other than our event handler!");
00103         return noErr;
00104     }
00105 }
00106 
00107 
00108 //-------------------------------------------------------------------//
00109 OSStatus MouseScrollWrapper( EventHandlerCallRef nextHandler,
00110                              EventRef            theEvent,
00111                              void*               callClass )
00112 {
00113     if (callClass != NULL) {
00114         ((MacMouse*)callClass)->_mouseScrollCallback( theEvent );
00115         
00116         // propagate the event down the chain
00117         return CallNextEventHandler( nextHandler, theEvent );
00118         
00119     }
00120     else {
00121         OIS_EXCEPT(E_General, "MouseScrollWrapper >> Being called by something other than our event handler!");
00122         return noErr;
00123     }
00124 }
00125 
00126 
00127 //-------------------------------------------------------------------//
00128 OSStatus MouseButtonWrapper( EventHandlerCallRef nextHandler,
00129                              EventRef            theEvent,
00130                              void*               callClass )
00131 {
00132     if (callClass != NULL) {
00133         ((MacMouse*)callClass)->_mouseButtonCallback( theEvent );
00134         
00135         // propagate the event down the chain
00136         return CallNextEventHandler( nextHandler, theEvent );
00137         
00138     }
00139     else {
00140         OIS_EXCEPT(E_General, "MouseButtonWrapper >> Being called by something other than our event handler!");
00141         return noErr;
00142     }
00143 }
00144 

Generated on Sat Dec 1 20:13:51 2007 for OIS by  doxygen 1.5.4