xref: /haiku/src/bin/keymap/Keymap.h (revision 746cac055adc6ac3308c7bc2d29040fb95689cc9)
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 #include <regex.h>
18 
19 
20 class Keymap {
21 	public:
22 		Keymap();
23 		~Keymap();
24 
25 		status_t LoadCurrent();
26 		status_t Load(entry_ref &ref);
27 		status_t Save(entry_ref &ref);
28 		status_t LoadSource(FILE *f);
29 		status_t LoadSourceFromRef(entry_ref &ref);
30 		void SaveAsCurrent();
31 		void SaveAsHeader(entry_ref &ref, const char *mapname);
32 		status_t Use();
33 		void Dump();
34 		bool IsModifierKey(uint32 keyCode);
35 		uint8 IsDeadKey(uint32 keyCode, uint32 modifiers);
36 		bool IsDeadSecondKey(uint32 keyCode, uint32 modifiers, uint8 activeDeadKey);
37 		void GetChars(uint32 keyCode, uint32 modifiers, uint8 activeDeadKey,
38 			char** chars, int32* numBytes);
39 		void RestoreSystemDefault();
40 		static void GetKey(char *chars, int32 offset, char* string);
41 
42 	private:
43 		void ComputeChars(const char *buffer, struct re_registers &regs, int i, int &offset);
44 		void ComputeTables(const char *buffer, struct re_registers &regs, uint32 &table);
45 
46 		char *fChars;
47 		key_map fKeys;
48 		uint32 fCharsSize;
49 };
50 
51 #define KEYMAP_ERROR_UNKNOWN_VERSION	(B_ERRORS_END + 1)
52 
53 #endif // KEYMAP_H
54