1 /* 2 * Copyright 2004-2010, Haiku, Inc. All Rights Reserved. 3 * Distributed under the terms of the MIT License. 4 * 5 * Authors: 6 * Jérôme Duval 7 * Axel Dörfler, axeld@pinc-software.de. 8 */ 9 #ifndef _KEYMAP_H 10 #define _KEYMAP_H 11 12 13 #include <DataIO.h> 14 #include <InterfaceDefs.h> 15 #include <ObjectList.h> 16 17 18 class BKeymap { 19 public: 20 BKeymap(); 21 virtual ~BKeymap(); 22 23 status_t SetTo(const char* path); 24 status_t SetTo(BDataIO& stream); 25 status_t SetToCurrent(); 26 status_t SetToDefault(); 27 void Unset(); 28 29 bool IsModifierKey(uint32 keyCode) const; 30 uint32 Modifier(uint32 keyCode) const; 31 uint32 KeyForModifier(uint32 modifier) const; 32 uint8 ActiveDeadKey(uint32 keyCode, 33 uint32 modifiers) const; 34 uint8 DeadKey(uint32 keyCode, uint32 modifiers, 35 bool* isEnabled = NULL) const; 36 bool IsDeadSecondKey(uint32 keyCode, 37 uint32 modifiers, 38 uint8 activeDeadKey) const; 39 void GetChars(uint32 keyCode, uint32 modifiers, 40 uint8 activeDeadKey, char** chars, 41 int32* numBytes) const; 42 status_t GetModifiedCharacters(const char* in, 43 int32 inModifiers, int32 outModifiers, 44 BObjectList<const char>* _outList); 45 46 const key_map& Map() const { return fKeys; } 47 48 bool operator==(const BKeymap& other) const; 49 bool operator!=(const BKeymap& other) const; 50 51 BKeymap& operator=(const BKeymap& other); 52 53 protected: 54 int32 Offset(uint32 keyCode, uint32 modifiers, 55 uint32* _table = NULL) const; 56 uint8 DeadKeyIndex(int32 offset) const; 57 58 protected: 59 char* fChars; 60 key_map fKeys; 61 uint32 fCharsSize; 62 }; 63 64 65 #endif // KEYMAP_H 66