summaryrefslogtreecommitdiff
path: root/src/common/keyboard.h
blob: 50ddbb3d089653db63cb8fb5dd2783695fd8adff (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
#ifndef YASL_COMMON_KEYBOARD_H
#define YASL_COMMON_KEYBOARD_H

#include "yasl/yasl.h"

enum yasl_key yasl_key_from_evdev(uint32_t code);
enum yasl_key yasl_key_from_xkb_name(const char name[4]);
enum yasl_key yasl_key_from_cocoa(uint32_t code);

/* Layout labels omit controls, invalid Unicode, and Cocoa function-key PUA. */
static inline uint32_t yasl_key_label(uint32_t cp)
{
    return cp >= 0x20 && cp != 0x7f && cp <= 0x10ffff &&
        !(cp >= 0x80 && cp <= 0x9f) && !(cp >= 0xd800 && cp <= 0xdfff) &&
        !(cp >= 0xf700 && cp <= 0xf7ff) ? cp : 0;
}

#endif