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 16 17 class BKeymap { 18 public: 19 BKeymap(); 20 virtual ~BKeymap(); 21 22 status_t SetTo(const char* path); 23 status_t SetTo(BDataIO& stream); 24 status_t SetToCurrent(); 25 status_t SetToDefault(); 26 void Unset(); 27 28 bool IsModifierKey(uint32 keyCode) const; 29 uint32 Modifier(uint32 keyCode) const; 30 uint32 KeyForModifier(uint32 modifier) const; 31 uint8 ActiveDeadKey(uint32 keyCode, 32 uint32 modifiers) const; 33 uint8 DeadKey(uint32 keyCode, uint32 modifiers, 34 bool* isEnabled = NULL) const; 35 bool IsDeadSecondKey(uint32 keyCode, 36 uint32 modifiers, 37 uint8 activeDeadKey) const; 38 void GetChars(uint32 keyCode, uint32 modifiers, 39 uint8 activeDeadKey, char** chars, 40 int32* numBytes) const; 41 42 const key_map& Map() const { return fKeys; } 43 44 bool operator==(const BKeymap& other) const; 45 bool operator!=(const BKeymap& other) const; 46 47 BKeymap& operator=(const BKeymap& other); 48 49 protected: 50 int32 Offset(uint32 keyCode, uint32 modifiers, 51 uint32* _table = NULL) const; 52 uint8 DeadKeyIndex(int32 offset) const; 53 54 protected: 55 char* fChars; 56 key_map fKeys; 57 uint32 fCharsSize; 58 }; 59 60 61 #endif // KEYMAP_H 62