Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: code/branches/cpp11/src/external/ois/mac/MacHelpers.cpp @ 10487

Last change on this file since 10487 was 5781, checked in by rgrieder, 15 years ago

Reverted trunk again. We might want to find a way to delete these revisions again (x3n's changes are still available as diff in the commit mails).

  • Property svn:eol-style set to native
File size: 5.2 KB
Line 
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
24#include "mac/MacHelpers.h"
25#include "mac/MacKeyboard.h"
26#include "mac/MacMouse.h"
27#include "OISException.h"
28
29#include <Carbon/Carbon.h>
30
31using namespace OIS;
32   
33//-------------------------------------------------------------------//
34OSStatus KeyDownWrapper( EventHandlerCallRef nextHandler,
35                        EventRef               theEvent,
36                        void*                  callClass )
37{
38    // TODO find a better way. This cast isn't very safe
39    if (callClass != NULL) {
40        ((MacKeyboard*)callClass)->_keyDownCallback( theEvent );
41       
42        // propagate the event down the chain
43        return CallNextEventHandler( nextHandler, theEvent );
44    }
45    else {
46        OIS_EXCEPT(E_General, "KeyDownWrapper >> Being called by something other than our event handler!");
47        return noErr;
48    }
49}
50
51
52//-------------------------------------------------------------------//
53OSStatus KeyUpWrapper( EventHandlerCallRef nextHandler,
54                       EventRef               theEvent,
55                       void*                  callClass )
56{
57    if (callClass != NULL) {
58        ((MacKeyboard*)callClass)->_keyUpCallback( theEvent );
59       
60        // propagate the event down the chain
61        return CallNextEventHandler( nextHandler, theEvent );
62    }
63    else {
64        OIS_EXCEPT(E_General, "KeyUpWrapper >> Being called by something other than our event handler!");
65        return noErr;
66    }
67}
68
69
70//-------------------------------------------------------------------//
71OSStatus KeyModWrapper( EventHandlerCallRef nextHandler,
72                        EventRef               theEvent,
73                        void*                  callClass )
74{
75    if (callClass != NULL) {
76        ((MacKeyboard*)callClass)->_modChangeCallback( theEvent );
77       
78        // propagate the event down the chain
79        return CallNextEventHandler( nextHandler, theEvent );
80       
81    }
82    else {
83        OIS_EXCEPT(E_General, "KeyModWrapper >> Being called by something other than our event handler!");
84        return noErr;
85    }
86}
87
88/*
89//-------------------------------------------------------------------//
90OSStatus MouseMoveWrapper( EventHandlerCallRef nextHandler,
91                           EventRef            theEvent,
92                           void*               callClass )
93{
94    if (callClass != NULL) {
95        ((MacMouse*)callClass)->_mouseMoveCallback( theEvent );
96       
97        // propagate the event down the chain
98        return CallNextEventHandler( nextHandler, theEvent );
99       
100    }
101    else {
102        OIS_EXCEPT(E_General, "MouseMoveWrapper >> Being called by something other than our event handler!");
103        return noErr;
104    }
105}
106
107
108//-------------------------------------------------------------------//
109OSStatus MouseScrollWrapper( EventHandlerCallRef nextHandler,
110                             EventRef            theEvent,
111                             void*               callClass )
112{
113    if (callClass != NULL) {
114        ((MacMouse*)callClass)->_mouseScrollCallback( theEvent );
115       
116        // propagate the event down the chain
117        return CallNextEventHandler( nextHandler, theEvent );
118       
119    }
120    else {
121        OIS_EXCEPT(E_General, "MouseScrollWrapper >> Being called by something other than our event handler!");
122        return noErr;
123    }
124}
125
126
127//-------------------------------------------------------------------//
128OSStatus MouseButtonWrapper( EventHandlerCallRef nextHandler,
129                             EventRef            theEvent,
130                             void*               callClass )
131{
132    if (callClass != NULL) {
133        ((MacMouse*)callClass)->_mouseButtonCallback( theEvent );
134       
135        // propagate the event down the chain
136        return CallNextEventHandler( nextHandler, theEvent );
137       
138    }
139    else {
140        OIS_EXCEPT(E_General, "MouseButtonWrapper >> Being called by something other than our event handler!");
141        return noErr;
142    }
143}
144*/
145
146//-------------------------------------------------------------------//
147OSStatus MouseWrapper( EventHandlerCallRef nextHandler, EventRef theEvent, void* callClass )
148{
149    if (callClass != NULL)
150        {
151        ((MacMouse*)callClass)->_mouseCallback( theEvent );
152
153        // propagate the event down the chain
154        return CallNextEventHandler( nextHandler, theEvent );       
155    }
156    else
157        OIS_EXCEPT(E_General, "MouseWrapper >> Being called by something other than our event handler!");
158}
Note: See TracBrowser for help on using the repository browser.