1d04310459
This method fills out the passed-in BList of modified utf-8 characters for a given utf-8 character and set of modifiers. For example if you pass in "=" and B_SHIFT_KEY the list will get filled out with each character in the shift map that has "=" in the normal map. Each supported keymap modifier combination is available. The reason this is useful will soon become apparent. A BList is used because the character might be mapped multiple times, for example if you have a Mac keyboard you've got two "=" keys, one in 0x1d and one in 0x6a. The caller is responsible for creating the BList and destroying it as well as freeing the resulting character strings.
67 lines
1.6 KiB
C++
67 lines
1.6 KiB
C++
/*
|
|
* Copyright 2004-2010, Haiku, Inc. All Rights Reserved.
|
|
* Distributed under the terms of the MIT License.
|
|
*
|
|
* Authors:
|
|
* Jérôme Duval
|
|
* Axel Dörfler, axeld@pinc-software.de.
|
|
*/
|
|
#ifndef _KEYMAP_H
|
|
#define _KEYMAP_H
|
|
|
|
|
|
#include <DataIO.h>
|
|
#include <InterfaceDefs.h>
|
|
|
|
|
|
class BList;
|
|
|
|
class BKeymap {
|
|
public:
|
|
BKeymap();
|
|
virtual ~BKeymap();
|
|
|
|
status_t SetTo(const char* path);
|
|
status_t SetTo(BDataIO& stream);
|
|
status_t SetToCurrent();
|
|
status_t SetToDefault();
|
|
void Unset();
|
|
|
|
bool IsModifierKey(uint32 keyCode) const;
|
|
uint32 Modifier(uint32 keyCode) const;
|
|
uint32 KeyForModifier(uint32 modifier) const;
|
|
uint8 ActiveDeadKey(uint32 keyCode,
|
|
uint32 modifiers) const;
|
|
uint8 DeadKey(uint32 keyCode, uint32 modifiers,
|
|
bool* isEnabled = NULL) const;
|
|
bool IsDeadSecondKey(uint32 keyCode,
|
|
uint32 modifiers,
|
|
uint8 activeDeadKey) const;
|
|
void GetChars(uint32 keyCode, uint32 modifiers,
|
|
uint8 activeDeadKey, char** chars,
|
|
int32* numBytes) const;
|
|
status_t GetModifiedCharacters(const char* normal,
|
|
int32 modifiers,
|
|
BList* _modifiedCharacters);
|
|
|
|
const key_map& Map() const { return fKeys; }
|
|
|
|
bool operator==(const BKeymap& other) const;
|
|
bool operator!=(const BKeymap& other) const;
|
|
|
|
BKeymap& operator=(const BKeymap& other);
|
|
|
|
protected:
|
|
int32 Offset(uint32 keyCode, uint32 modifiers,
|
|
uint32* _table = NULL) const;
|
|
uint8 DeadKeyIndex(int32 offset) const;
|
|
|
|
protected:
|
|
char* fChars;
|
|
key_map fKeys;
|
|
uint32 fCharsSize;
|
|
};
|
|
|
|
|
|
#endif // KEYMAP_H
|