platformInput.h
Engine/source/platform/platformInput.h
Classes:
Public Enumerations
enum
KEY_STATE { STATE_LOWER STATE_UPPER STATE_GOOFY }
Public Functions
TranslateKeyCodeToOS(U8 keycode)
TranslateOSKeyCode(U8 vcode)
Detailed Description
Public Enumerations
KEY_STATE
Enumerator
- STATE_LOWER
- STATE_UPPER
- STATE_GOOFY
Public Functions
TranslateKeyCodeToOS(U8 keycode)
TranslateOSKeyCode(U8 vcode)
1 2//----------------------------------------------------------------------------- 3// Copyright (c) 2012 GarageGames, LLC 4// 5// Permission is hereby granted, free of charge, to any person obtaining a copy 6// of this software and associated documentation files (the "Software"), to 7// deal in the Software without restriction, including without limitation the 8// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or 9// sell copies of the Software, and to permit persons to whom the Software is 10// furnished to do so, subject to the following conditions: 11// 12// The above copyright notice and this permission notice shall be included in 13// all copies or substantial portions of the Software. 14// 15// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 20// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS 21// IN THE SOFTWARE. 22//----------------------------------------------------------------------------- 23 24#ifndef _PLATFORMINPUT_H_ 25#define _PLATFORMINPUT_H_ 26 27#ifndef _SIMBASE_H_ 28#include "console/simBase.h" 29#endif 30 31#include "platform/input/event.h" 32 33//------------------------------------------------------------------------------ 34U8 TranslateOSKeyCode( U8 vcode ); 35U8 TranslateKeyCodeToOS(U8 keycode); 36 37//------------------------------------------------------------------------------ 38//------------------------------------------------------------------------------ 39class InputDevice : public SimObject 40{ 41protected: 42 char mName[30]; 43 44public: 45 struct ObjInfo 46 { 47 InputEventType mType; 48 InputObjectInstances mInst; 49 S32 mMin, mMax; 50 }; 51 52 inline const char* getDeviceName() 53 { 54 return mName; 55 } 56 57 virtual bool process() = 0; 58}; 59 60//------------------------------------------------------------------------------ 61 62class InputManager : public SimGroup 63{ 64protected: 65 bool mEnabled; 66 67public: 68 inline bool isEnabled() 69 { 70 return mEnabled; 71 } 72 73 virtual bool enable() = 0; 74 virtual void disable() = 0; 75 virtual void process() = 0; 76}; 77 78enum KEY_STATE 79{ 80 STATE_LOWER, 81 STATE_UPPER, 82 STATE_GOOFY 83}; 84 85//------------------------------------------------------------------------------ 86class Input 87{ 88protected: 89 static InputManager* smManager; 90 91 static bool smActive; 92 93 /// Current modifier keys. 94 static U8 smModifierKeys; 95 96 static bool smLastKeyboardActivated; 97 static bool smLastMouseActivated; 98 static bool smLastJoystickActivated; 99 100public: 101 static void init(); 102 static void destroy(); 103 104 static bool enable(); 105 static void disable(); 106 107 static void activate(); 108 static void deactivate(); 109 110 static U16 getAscii( U16 keyCode, KEY_STATE keyState ); 111 static U16 getKeyCode( U16 asciiCode ); 112 113 static bool isEnabled(); 114 static bool isActive(); 115 116 static void process(); 117 118 static InputManager* getManager(); 119 120 static U8 getModifierKeys() {return smModifierKeys;} 121 static void setModifierKeys(U8 mod) {smModifierKeys = mod;} 122#ifdef LOG_INPUT 123 static void log( const char* format, ... ); 124#endif 125 126 /// Global input routing JournaledSignal; post input events here for 127 /// processing. 128 static InputEvent smInputEvent; 129}; 130 131#endif // _H_PLATFORMINPUT_ 132