42 lines
1.2 KiB
C
42 lines
1.2 KiB
C
|
|
// gKeyMapper - canonical key names shared by GUI and daemon.
|
||
|
|
//
|
||
|
|
// Canonical names are the lowercase GDK keysym names the GUI already writes
|
||
|
|
// (e.g. "f4", "escape", "page_up", "ctrl"). The daemon maps the same names to
|
||
|
|
// Linux input codes, so both halves of the project agree on the spelling.
|
||
|
|
#ifndef GKEYMAPPER_KEYS_H
|
||
|
|
#define GKEYMAPPER_KEYS_H
|
||
|
|
|
||
|
|
#include <string>
|
||
|
|
|
||
|
|
namespace gkeymapper {
|
||
|
|
|
||
|
|
// Modifier bits used by the shortcut grammar ("ctrl+c", "altgr+7").
|
||
|
|
enum ModifierBit : unsigned {
|
||
|
|
kModNone = 0,
|
||
|
|
kModCtrl = 1u << 0,
|
||
|
|
kModAlt = 1u << 1,
|
||
|
|
kModShift = 1u << 2,
|
||
|
|
kModSuper = 1u << 3,
|
||
|
|
kModAltGr = 1u << 4,
|
||
|
|
};
|
||
|
|
|
||
|
|
struct KeyDef {
|
||
|
|
const char* name; // canonical, lowercase; may also be a modifier name
|
||
|
|
int linux_code; // KEY_* from <linux/input-event-codes.h>
|
||
|
|
};
|
||
|
|
|
||
|
|
// All supported keys (regular keys and modifiers), no particular order.
|
||
|
|
const KeyDef* key_definitions();
|
||
|
|
int key_definition_count();
|
||
|
|
|
||
|
|
// Linux KEY_* code for a canonical name, or -1 if unknown.
|
||
|
|
int linux_key_code(const std::string& name);
|
||
|
|
|
||
|
|
// Modifier bit for "ctrl"/"alt"/"shift"/"super" ("meta" counts as super),
|
||
|
|
// 0 for everything else.
|
||
|
|
unsigned modifier_bit(const std::string& name);
|
||
|
|
|
||
|
|
} // namespace gkeymapper
|
||
|
|
|
||
|
|
#endif // GKEYMAPPER_KEYS_H
|