1 /* 2 * Copyright 2004-2011 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 <Keymap.h> 14 15 #include <Entry.h> 16 #include <Messenger.h> 17 #include <String.h> 18 19 20 enum dead_key_index { 21 kDeadKeyAcute = 1, 22 kDeadKeyGrave, 23 kDeadKeyCircumflex, 24 kDeadKeyDiaeresis, 25 kDeadKeyTilde 26 }; 27 28 29 class Keymap : public BKeymap { 30 public: 31 Keymap(); 32 ~Keymap(); 33 34 void SetTarget(BMessenger target, 35 BMessage* modificationMessage); 36 37 status_t Load(const entry_ref& ref); 38 status_t Save(const entry_ref& ref); 39 40 void DumpKeymap(); 41 42 status_t SetModifier(uint32 keyCode, uint32 modifier); 43 44 void SetDeadKeyEnabled(uint32 keyCode, 45 uint32 modifiers, bool enabled); 46 void GetDeadKeyTrigger(dead_key_index deadKeyIndex, 47 BString& outTrigger); 48 void SetDeadKeyTrigger(dead_key_index deadKeyIndex, 49 const BString& trigger); 50 51 status_t RestoreSystemDefault(); 52 status_t Use(); 53 54 void SetKey(uint32 keyCode, uint32 modifiers, 55 int8 deadKey, const char* bytes, 56 int32 numBytes = -1); 57 58 void SetName(const char* name); 59 60 const key_map& Map() const { return fKeys; } 61 key_map& Map() { return fKeys; } 62 63 Keymap& operator=(const Keymap& other); 64 65 private: 66 bool _SetChars(int32 offset, const char* bytes, 67 int32 numBytes); 68 69 private: 70 char fName[B_FILE_NAME_LENGTH]; 71 72 BMessenger fTarget; 73 BMessage* fModificationMessage; 74 }; 75 76 77 #endif // KEYMAP_H 78