E:/Download/ois-1.0RC1/includes/mac/MacHelpers.h

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 #ifndef OIS_MacHelpers_H
00024 #define OIS_MacHelpers_H
00025 
00026 #include "mac/MacPrereqs.h"
00027 #include "OISEvents.h"
00028 #include "OISKeyboard.h"
00029 #include "OISMouse.h"
00030 
00031 #include <Carbon/Carbon.h>
00032 
00033 // This is a hack needed to get the event handler working. 
00034 // The carbon lib expects a "OSStatus (*)(EventHandlerCallRef, EventRef, void*)",
00035 // so I cannot give it a class member function (unless it is static which is pointless)
00036 // Instead, I just pass the class* through the last paramter that gets passed to the
00037 // callback every time an event occurs. Then I dereference it and call the member function.
00038 OSStatus KeyDownWrapper( EventHandlerCallRef nextHandler, EventRef theEvent, void* callClass );
00039 
00040 OSStatus KeyUpWrapper( EventHandlerCallRef nextHandler, EventRef theEvent, void* callClass );
00041 
00042 OSStatus KeyModWrapper( EventHandlerCallRef nextHandler, EventRef theEvent, void* callClass );
00043 
00044 OSStatus MouseMoveWrapper( EventHandlerCallRef nextHandler, EventRef theEvent, void* callClass );
00045 
00046 OSStatus MouseButtonWrapper( EventHandlerCallRef nextHandler, EventRef theEvent, void* callClass );
00047 
00048 OSStatus MouseScrollWrapper( EventHandlerCallRef nextHandler, EventRef theEvent, void* callClass );
00049 
00050 
00051 // This is needed for keeping an event stack for keyboard and mouse
00052 namespace OIS
00053 {
00054     
00055     // used in the eventStack to store the type
00056     enum Mac_EventType { MAC_KEYUP = 0,
00057                          MAC_KEYDOWN = 1,
00058                          MAC_KEYREPEAT,
00059                          MAC_MOUSEDOWN,
00060                          MAC_MOUSEUP,
00061                          MAC_MOUSEMOVED,
00062                          MAC_MOUSESCROLL};
00063     typedef enum Mac_EventType MacEventType;
00064     
00065     
00066     // only used by MacKeyboard
00067     typedef class Mac_KeyStackEvent
00068     {
00069         friend class MacKeyboard;
00070         
00071         
00072     private:
00073         Mac_KeyStackEvent( KeyEvent event, MacEventType type ) : Event(event), Type(type) {}
00074         
00075         MacEventType Type;
00076         KeyEvent Event;
00077     } MacKeyStackEvent;
00078  
00079     
00080 
00081     // only used by MacMouse
00082     typedef class Mac_MouseStackEvent
00083     {
00084         friend class MacMouse;
00085         
00086     private:
00087         Mac_MouseStackEvent( MacEventType type, unsigned int time ) : Type(type), Time(time) {}
00088         
00089         unsigned int Time;
00090         MacEventType Type;
00091         MouseButtonID button;
00092         Axis axis;
00093         
00094     } MacMouseStackEvent;
00095         
00096 }
00097 
00098 
00099 #endif

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