1 /* 2 * Copyright 2004-2009 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 <InterfaceDefs.h> 14 #include <Entry.h> 15 #include <Messenger.h> 16 17 18 class Keymap { 19 public: 20 Keymap(); 21 ~Keymap(); 22 23 void SetTarget(BMessenger target, 24 BMessage* modificationMessage); 25 26 status_t Load(entry_ref& ref); 27 status_t Save(entry_ref& ref); 28 29 void DumpKeymap(); 30 31 bool IsModifierKey(uint32 keyCode); 32 uint32 Modifier(uint32 keyCode); 33 uint32 KeyForModifier(uint32 modifier); 34 status_t SetModifier(uint32 keyCode, uint32 modifier); 35 36 uint8 IsDeadKey(uint32 keyCode, uint32 modifiers); 37 bool IsDeadSecondKey(uint32 keyCode, uint32 modifiers, 38 uint8 activeDeadKey); 39 void GetChars(uint32 keyCode, uint32 modifiers, 40 uint8 activeDeadKey, char** chars, 41 int32* numBytes); 42 status_t Use(); 43 bool Equals(const Keymap& map) const; 44 45 void SetKey(uint32 keyCode, uint32 modifiers, 46 int8 deadKey, const char* bytes, 47 int32 numBytes = -1); 48 49 const key_map& Map() const { return fKeys; } 50 key_map& Map() { return fKeys; } 51 52 Keymap& operator=(const Keymap& other); 53 54 private: 55 int32 _Offset(uint32 keyCode, uint32 modifiers, 56 uint32* _table = NULL); 57 58 char* fChars; 59 key_map fKeys; 60 uint32 fCharsSize; 61 char fName[B_FILE_NAME_LENGTH]; 62 63 BMessenger fTarget; 64 BMessage* fModificationMessage; 65 }; 66 67 68 #endif // KEYMAP_H 69