Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: code/branches/lastmanstanding3/src/external/ois/mac/MacKeyboard.h @ 8424

Last change on this file since 8424 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: 3.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#ifndef OIS_MacKeyboard_H
24#define OIS_MacKeyboard_H
25
26#include "OISKeyboard.h"
27#include "mac/MacHelpers.h"
28#include "mac/MacPrereqs.h"
29
30#include <Carbon/Carbon.h>
31
32namespace OIS
33{
34   
35    class MacKeyboard : public Keyboard
36    {
37    public:
38        MacKeyboard( InputManager* creator, bool buffered, bool repeat );
39        virtual ~MacKeyboard();
40       
41        // Sets buffered mode
42        virtual void setBuffered( bool buffered );
43       
44        // unbuffered keydown check
45        virtual bool isKeyDown( KeyCode key ) const;
46       
47        // This will send listener events if buffered is on.
48        // Note that in the mac implementation, unbuffered input is
49        // automatically updated without calling this.
50        virtual void capture();
51       
52        // Copies the current key buffer
53        virtual void copyKeyStates( char keys[256] ) const;
54       
55        // Returns a description of the given key
56        virtual std::string& getAsString( KeyCode key );
57       
58        virtual Interface* queryInterface( Interface::IType type ) { return 0; }
59       
60       
61        // Public but reserved for internal use:
62        virtual void _initialize();
63        void _keyDownCallback( EventRef theEvent );
64        void _keyUpCallback( EventRef theEvent );
65        void _modChangeCallback( EventRef theEvent );
66       
67
68    protected:
69        // just to get this out of the way
70        void populateKeyConversion();
71       
72        // updates the keybuffer and optionally the eventStack
73        void injectEvent(KeyCode kc, unsigned int time, MacEventType type, unsigned int txt = 0 );
74               
75        typedef std::map<UInt32, KeyCode> VirtualtoOIS_KeyMap;
76        VirtualtoOIS_KeyMap keyConversion;
77       
78        std::string getString;
79       
80        char KeyBuffer[256];
81        UInt32 prevModMask;
82       
83       
84        // "universal procedure pointers" - required reference for callbacks
85        EventHandlerUPP keyDownUPP;
86        EventHandlerUPP keyUpUPP;
87        EventHandlerUPP keyModUPP;
88       
89        // so we can delete the handlers on destruction
90        EventHandlerRef keyDownEventRef;
91        EventHandlerRef keyUpEventRef;
92        EventHandlerRef keyModEventRef;
93       
94        // buffered events, fifo stack
95        typedef std::list<MacKeyStackEvent> eventStack;
96        eventStack pendingEvents;
97       
98        bool useRepeat;
99       
100    };
101}
102#endif
Note: See TracBrowser for help on using the repository browser.