xref: /haiku/src/bin/keymap/Keymap.h (revision b0623e48efa646b8d1a4c6f51e09d696d9803276)
1 /*
2  *	Copyright (c) 2004-2006, Haiku, Inc.
3  *
4  *  This software is part of the Haiku distribution and is covered
5  *  by the Haiku license.
6  *
7  *  Author: Jérôme Duval
8  */
9 #ifndef KEYMAP_H
10 #define KEYMAP_H
11 
12 
13 #include <InterfaceDefs.h>
14 #include <Entry.h>
15 
16 #include <stdio.h>
17 
18 
19 class Keymap {
20 	public:
21 		Keymap();
22 		~Keymap();
23 
24 		status_t LoadCurrent();
25 		status_t Load(entry_ref &ref);
26 		status_t Save(entry_ref &ref);
27 		status_t LoadSource(FILE *f);
28 		status_t LoadSourceFromRef(entry_ref &ref);
29 		void SaveAsCurrent();
30 		void SaveAsHeader(entry_ref &ref);
31 		status_t Use();
32 		void Dump();
33 		bool IsModifierKey(uint32 keyCode);
34 		uint8 IsDeadKey(uint32 keyCode, uint32 modifiers);
35 		bool IsDeadSecondKey(uint32 keyCode, uint32 modifiers, uint8 activeDeadKey);
36 		void GetChars(uint32 keyCode, uint32 modifiers, uint8 activeDeadKey,
37 			char** chars, int32* numBytes);
38 		void RestoreSystemDefault();
39 		static void GetKey(char *chars, int32 offset, char* string);
40 
41 	private:
42 		void ComputeChars(const char *buffer, struct re_registers &regs, int i, int &offset);
43 		void ComputeTables(const char *buffer, struct re_registers &regs, uint32 &table);
44 
45 		char *fChars;
46 		key_map fKeys;
47 		uint32 fCharsSize;
48 };
49 
50 #define KEYMAP_ERROR_UNKNOWN_VERSION	(B_ERRORS_END + 1)
51 
52 #endif // KEYMAP_H
53