/src/ois/includes/mac/MacHelpers.h

https://bitbucket.org/cabalistic/ogredeps/ · C++ Header · 75 lines · 31 code · 14 blank · 30 comment · 0 complexity · 31aad27e5f8bdb6fe4e13a27370dab34 MD5 · raw file

  1. /*
  2. The zlib/libpng License
  3. Copyright (c) 2006 Chris Snyder
  4. This software is provided 'as-is', without any express or implied warranty. In no event will
  5. the authors be held liable for any damages arising from the use of this software.
  6. Permission is granted to anyone to use this software for any purpose, including commercial
  7. applications, and to alter it and redistribute it freely, subject to the following
  8. restrictions:
  9. 1. The origin of this software must not be misrepresented; you must not claim that
  10. you wrote the original software. If you use this software in a product,
  11. an acknowledgment in the product documentation would be appreciated but is
  12. not required.
  13. 2. Altered source versions must be plainly marked as such, and must not be
  14. misrepresented as being the original software.
  15. 3. This notice may not be removed or altered from any source distribution.
  16. */
  17. #ifndef OIS_MacHelpers_H
  18. #define OIS_MacHelpers_H
  19. #include "mac/MacPrereqs.h"
  20. #include "OISEvents.h"
  21. #include "OISKeyboard.h"
  22. #include "OISMouse.h"
  23. #include <Carbon/Carbon.h>
  24. // This is a hack needed to get the event handler working.
  25. // The carbon lib expects a "OSStatus (*)(EventHandlerCallRef, EventRef, void*)",
  26. // so I cannot give it a class member function (unless it is static which is pointless)
  27. // Instead, I just pass the class* through the last paramter that gets passed to the
  28. // callback every time an event occurs. Then I dereference it and call the member function.
  29. OSStatus KeyDownWrapper( EventHandlerCallRef nextHandler, EventRef theEvent, void* callClass );
  30. OSStatus KeyUpWrapper( EventHandlerCallRef nextHandler, EventRef theEvent, void* callClass );
  31. OSStatus KeyModWrapper( EventHandlerCallRef nextHandler, EventRef theEvent, void* callClass );
  32. OSStatus MouseWrapper( EventHandlerCallRef nextHandler, EventRef theEvent, void* callClass );
  33. // This is needed for keeping an event stack for keyboard and mouse
  34. namespace OIS
  35. {
  36. // used in the eventStack to store the type
  37. enum Mac_EventType { MAC_KEYUP = 0,
  38. MAC_KEYDOWN = 1,
  39. MAC_KEYREPEAT,
  40. MAC_MOUSEDOWN,
  41. MAC_MOUSEUP,
  42. MAC_MOUSEMOVED,
  43. MAC_MOUSESCROLL};
  44. typedef enum Mac_EventType MacEventType;
  45. // only used by MacKeyboard
  46. typedef class Mac_KeyStackEvent
  47. {
  48. friend class MacKeyboard;
  49. private:
  50. Mac_KeyStackEvent( KeyEvent event, MacEventType type ) : Type(type), Event(event) {}
  51. MacEventType Type;
  52. KeyEvent Event;
  53. } MacKeyStackEvent;
  54. }
  55. #endif