Orxonox  0.0.5 Codename: Arcturus
MacHelpers.h
Go to the documentation of this file.
1 /*
2  The zlib/libpng License
3 
4  Copyright (c) 2006 Chris Snyder
5 
6  This software is provided 'as-is', without any express or implied warranty. In no event will
7  the authors be held liable for any damages arising from the use of this software.
8 
9  Permission is granted to anyone to use this software for any purpose, including commercial
10  applications, and to alter it and redistribute it freely, subject to the following
11  restrictions:
12 
13  1. The origin of this software must not be misrepresented; you must not claim that
14  you wrote the original software. If you use this software in a product,
15  an acknowledgment in the product documentation would be appreciated but is
16  not required.
17 
18  2. Altered source versions must be plainly marked as such, and must not be
19  misrepresented as being the original software.
20 
21  3. This notice may not be removed or altered from any source distribution.
22 */
23 #ifndef OIS_MacHelpers_H
24 #define OIS_MacHelpers_H
25 
26 #include "mac/MacPrereqs.h"
27 #include "OISEvents.h"
28 #include "OISKeyboard.h"
29 #include "OISMouse.h"
30 
31 #include <Carbon/Carbon.h>
32 
33 // This is a hack needed to get the event handler working.
34 // The carbon lib expects a "OSStatus (*)(EventHandlerCallRef, EventRef, void*)",
35 // so I cannot give it a class member function (unless it is static which is pointless)
36 // Instead, I just pass the class* through the last paramter that gets passed to the
37 // callback every time an event occurs. Then I dereference it and call the member function.
38 OSStatus KeyDownWrapper( EventHandlerCallRef nextHandler, EventRef theEvent, void* callClass );
39 
40 OSStatus KeyUpWrapper( EventHandlerCallRef nextHandler, EventRef theEvent, void* callClass );
41 
42 OSStatus KeyModWrapper( EventHandlerCallRef nextHandler, EventRef theEvent, void* callClass );
43 
44 OSStatus MouseWrapper( EventHandlerCallRef nextHandler, EventRef theEvent, void* callClass );
45 
46 
47 // This is needed for keeping an event stack for keyboard and mouse
48 namespace OIS
49 {
50 
51  // used in the eventStack to store the type
60 
61 
62  // only used by MacKeyboard
63  typedef class Mac_KeyStackEvent
64  {
65  friend class MacKeyboard;
66 
67 
68  private:
69  Mac_KeyStackEvent( KeyEvent event, MacEventType type ) : Event(event), Type(type) {}
70 
71  MacEventType Type;
74 
75 
76 
77  // only used by MacMouse
78  typedef class Mac_MouseStackEvent
79  {
80  friend class MacMouse;
81 
82  private:
83  Mac_MouseStackEvent( MouseEvent event, MacEventType type, MouseButtonID button) : Event(event), Type(type), Button(button) {}
84 
85  MacEventType Type;
88 
90 
91 }
92 
93 
94 #endif
Definition: MacKeyboard.h:35
Definition: MacHelpers.h:54
OSStatus KeyUpWrapper(EventHandlerCallRef nextHandler, EventRef theEvent, void *callClass)
Definition: MacHelpers.cpp:53
Definition: MacHelpers.h:56
MouseButtonID Button
Definition: MacHelpers.h:87
class OIS::Mac_KeyStackEvent MacKeyStackEvent
MouseEvent Event
Definition: MacHelpers.h:86
Definition: MacHelpers.h:55
OSStatus KeyDownWrapper(EventHandlerCallRef nextHandler, EventRef theEvent, void *callClass)
Definition: MacHelpers.cpp:34
Mac_EventType
Definition: MacHelpers.h:52
Mac_KeyStackEvent(KeyEvent event, MacEventType type)
Definition: MacHelpers.h:69
Definition: MacHelpers.h:53
Definition: MacHelpers.h:63
Definition: MacHelpers.h:52
MouseButtonID
Button ID for mouse devices.
Definition: OISMouse.h:31
OSStatus MouseWrapper(EventHandlerCallRef nextHandler, EventRef theEvent, void *callClass)
Definition: MacHelpers.cpp:147
Definition: MacHelpers.h:57
Definition: MacHelpers.h:58
KeyEvent Event
Definition: MacHelpers.h:72
MacEventType Type
Definition: MacHelpers.h:85
Mac_MouseStackEvent(MouseEvent event, MacEventType type, MouseButtonID button)
Definition: MacHelpers.h:83
class OIS::Mac_MouseStackEvent MacMouseStackEvent
Type
Each Input class has a General Type variable, a form of RTTI.
Definition: OISPrereqs.h:138
enum Mac_EventType MacEventType
Definition: MacHelpers.h:59
Specialised for mouse events.
Definition: OISMouse.h:80
OSStatus KeyModWrapper(EventHandlerCallRef nextHandler, EventRef theEvent, void *callClass)
Definition: MacHelpers.cpp:71
Definition: EventHelpers.h:31
Specialised for key events.
Definition: OISKeyboard.h:183
Definition: MacMouse.h:12
MacEventType Type
Definition: MacHelpers.h:71
Definition: MacHelpers.h:78
Button can be a keyboard key, mouse button, etc.
Definition: OISPrereqs.h:175