wlmaker
Loading...
Searching...
No Matches
Classes | Macros | Functions | Variables
keyboard.c File Reference
#include "keyboard.h"
#include <ctype.h>
#include <ini.h>
#include <libbase/libbase.h>
#include <libbase/plist.h>
#include <stdbool.h>
#include <stdint.h>
#include <stdlib.h>
#include <string.h>
#include <wayland-server-core.h>
#include <wayland-server-protocol.h>
#include <wlr/types/wlr_keyboard.h>
#include <wlr/types/wlr_seat.h>
#include <xkbcommon/xkbcommon.h>
#include "toolkit/toolkit.h"
Include dependency graph for keyboard.c:

Classes

struct  _wlmim_keyboard_t
 

Functions

static bspl_dict_t * _wlmim_keyboard_populate_rules (bspl_dict_t *dict_ptr, struct xkb_rule_names *rules_ptr)
 
static int _wlmim_keyboard_config_ini_handler (void *user_ptr, const char *section_ptr, const char *name_ptr, const char *value_ptr)
 
static void handle_key (struct wl_listener *listener_ptr, void *data_ptr)
 
static void handle_modifiers (struct wl_listener *listener_ptr, void *data_ptr)
 
wlmim_keyboard_twlmim_keyboard_create (wlmim_t *input_manager_ptr, struct xkb_keymap *xkb_keymap_ptr, const struct wlmim_keyboard_options *options_ptr, struct wlr_keyboard *wlr_keyboard_ptr, struct wlr_seat *wlr_seat_ptr, wlmtk_element_t *root_element_ptr)
 
void wlmim_keyboard_destroy (wlmim_keyboard_t *keyboard_ptr)
 
void wlmim_keyboard_configure (wlmim_keyboard_t *keyboard_ptr, struct xkb_keymap *xkb_keymap_ptr, const struct wlmim_keyboard_options *options_ptr)
 
struct xkb_keymap * wlmim_keyboard_xkb_from_config (bspl_dict_t *dict_ptr)
 
static void _wlmim_keyboard_test_parse (bs_test_t *test_ptr)
 
static void _wlmim_keyboard_test_rmlvo (bs_test_t *test_ptr)
 
static void _wlmim_keyboard_test_file (bs_test_t *test_ptr)
 

Variables

const bspl_enum_desc_t wlmim_keyboard_modifiers []
 
static const bspl_desc_t _wlmim_keyboard_repeat_options_desc []
 
const bspl_desc_t wlmim_keyboard_options_desc []
 
static const bs_test_case_t _wlmim_keyboard_test_cases []
 
const bs_test_set_t wlmim_keyboard_test_set
 

Detailed Description

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

https://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Function Documentation

◆ _wlmim_keyboard_config_ini_handler()

int _wlmim_keyboard_config_ini_handler ( void *  user_ptr,
const char *  section_ptr,
const char *  name_ptr,
const char *  value_ptr 
)
static

inih parser callback. Fills XKB config file values into the dict.

Parameters
user_ptrPoints to a bspl_dict_t.
section_ptr
name_ptr
value_ptr
Returns
0 on success.

◆ _wlmim_keyboard_populate_rules()

bspl_dict_t * _wlmim_keyboard_populate_rules ( bspl_dict_t *  dict_ptr,
struct xkb_rule_names *  rules_ptr 
)
static

Populates the XKB rules struct from the config dict.

Parameters
dict_ptr
rules_ptr
Returns
A referenced bspl_dict_t holding rules details, or NULL on error.

◆ _wlmim_keyboard_test_file()

void _wlmim_keyboard_test_file ( bs_test_t *  test_ptr)
static

Tests keyboard rules are loaded from XKB configuration file.

◆ _wlmim_keyboard_test_parse()

void _wlmim_keyboard_test_parse ( bs_test_t *  test_ptr)
static

Tests parsing the dict.

◆ _wlmim_keyboard_test_rmlvo()

void _wlmim_keyboard_test_rmlvo ( bs_test_t *  test_ptr)
static

Tests keyboard rules are loaded from a given RMLVO dict.

◆ handle_key()

void handle_key ( struct wl_listener *  listener_ptr,
void *  data_ptr 
)
static

Handles key signals, ie. key presses.

Parameters
listener_ptr
data_ptrPoints to a wlr_keyboard_key_event.

◆ handle_modifiers()

void handle_modifiers ( struct wl_listener *  listener_ptr,
void *  data_ptr 
)
static

Handles modifiers signals, ie. updates to the modifiers.

Parameters
listener_ptr
data_ptrPoints to wlr_keyboard.

◆ wlmim_keyboard_configure()

void wlmim_keyboard_configure ( wlmim_keyboard_t keyboard_ptr,
struct xkb_keymap *  xkb_keymap_ptr,
const struct wlmim_keyboard_options options_ptr 
)

Configures the active xkb_keymap and repeat settings.

Parameters
keyboard_ptr
xkb_keymap_ptr
options_ptr

◆ wlmim_keyboard_create()

wlmim_keyboard_t * wlmim_keyboard_create ( wlmim_t input_manager_ptr,
struct xkb_keymap *  xkb_keymap_ptr,
const struct wlmim_keyboard_options options_ptr,
struct wlr_keyboard *  wlr_keyboard_ptr,
struct wlr_seat *  wlr_seat_ptr,
wlmtk_element_t root_element_ptr 
)

Creates a handle for a registered keyboard.

Parameters
input_manager_ptr
xkb_keymap_ptr
options_ptr
wlr_keyboard_ptr
wlr_seat_ptr
root_element_ptr
Returns
The handle or NULL on error. Free via wlmim_keyboard_destroy().

◆ wlmim_keyboard_destroy()

void wlmim_keyboard_destroy ( wlmim_keyboard_t keyboard_ptr)

Destroys the keyboard handle.

Parameters
keyboard_ptr

◆ wlmim_keyboard_xkb_from_config()

struct xkb_keymap * wlmim_keyboard_xkb_from_config ( bspl_dict_t *  dict_ptr)

Creates a struct xkb_keymap from the keyboard configuration dict.

Parameters
dict_ptrPlist dict of the Keyboard configuration. If NULL, NULL is returned.
Returns
Pointer to a created struct xkb_keymap (to be released by calling xkb_keymap_unref()), or NULL on error.

Variable Documentation

◆ _wlmim_keyboard_repeat_options_desc

const bspl_desc_t _wlmim_keyboard_repeat_options_desc[]
static
Initial value:
= {
BSPL_DESC_UINT64(
"Delay", true, struct wlmim_keyboard_options,
repeat.delay, repeat.delay, 300),
BSPL_DESC_UINT64(
"Rate", true, struct wlmim_keyboard_options,
repeat.rate, repeat.rate, 25),
}
Definition keyboard.h:41
uint64_t rate
Definition keyboard.h:45
uint64_t delay
Definition keyboard.h:47

Plist descriptor for the "Repat" dict within the "Keyboard" dict.

◆ _wlmim_keyboard_test_cases

const bs_test_case_t _wlmim_keyboard_test_cases[]
static
Initial value:
= {
{ true, "parse", _wlmim_keyboard_test_parse },
{ true, "rmlvo", _wlmim_keyboard_test_rmlvo },
{ true, "file", _wlmim_keyboard_test_file },
}
static void _wlmim_keyboard_test_file(bs_test_t *test_ptr)
Definition keyboard.c:523
static void _wlmim_keyboard_test_parse(bs_test_t *test_ptr)
Definition keyboard.c:483
static void _wlmim_keyboard_test_rmlvo(bs_test_t *test_ptr)
Definition keyboard.c:502

Test cases for the keyboard.

◆ wlmim_keyboard_modifiers

const bspl_enum_desc_t wlmim_keyboard_modifiers[]
Initial value:
= {
BSPL_ENUM("Shift", WLR_MODIFIER_SHIFT),
BSPL_ENUM("Ctrl", WLR_MODIFIER_CTRL),
BSPL_ENUM("Alt", WLR_MODIFIER_ALT),
BSPL_ENUM("Mod2", WLR_MODIFIER_MOD2),
BSPL_ENUM("Mod3", WLR_MODIFIER_MOD3),
BSPL_ENUM("Logo", WLR_MODIFIER_LOGO),
BSPL_ENUM("Mod5", WLR_MODIFIER_MOD5),
BSPL_ENUM_SENTINEL(),
}

Keyboard modifiers, as enum to lookup.

◆ wlmim_keyboard_options_desc

const bspl_desc_t wlmim_keyboard_options_desc[]
Initial value:
= {
BSPL_DESC_DICT("Repeat", false,
struct wlmim_keyboard_options, repeat, repeat,
}
static const bspl_desc_t _wlmim_keyboard_repeat_options_desc[]
Definition keyboard.c:93

BSPL descriptor for decoding the keyboard dict.

◆ wlmim_keyboard_test_set

const bs_test_set_t wlmim_keyboard_test_set
Initial value:
= BS_TEST_SET(
true, "keyboard", _wlmim_keyboard_test_cases)
static const bs_test_case_t _wlmim_keyboard_test_cases[]
Definition keyboard.c:471

Unit test set.