UltraGrid
UltraGrid Low-Latency High-Resolution Transmission System
Loading...
Searching...
No Matches
keyboard_control.h
Go to the documentation of this file.
1
5/*
6 * Copyright (c) 2015-2019 CESNET, z. s. p. o.
7 * All rights reserved.
8 *
9 * Redistribution and use in source and binary forms, with or without
10 * modification, is permitted provided that the following conditions
11 * are met:
12 *
13 * 1. Redistributions of source code must retain the above copyright
14 * notice, this list of conditions and the following disclaimer.
15 *
16 * 2. Redistributions in binary form must reproduce the above copyright
17 * notice, this list of conditions and the following disclaimer in the
18 * documentation and/or other materials provided with the distribution.
19 *
20 * 3. Neither the name of CESNET nor the names of its contributors may be
21 * used to endorse or promote products derived from this software without
22 * specific prior written permission.
23 *
24 * THIS SOFTWARE IS PROVIDED BY THE AUTHORS AND CONTRIBUTORS
25 * "AS IS" AND ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING,
26 * BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
27 * AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
28 * EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
29 * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
30 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
31 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
32 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
33 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
34 * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
35 * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
36 */
37
38#ifndef keyboard_control_h_
39#define keyboard_control_h_
40
41#include "utils/macros.h"
42
43struct module;
44
45#ifndef __cplusplus
46#include <stddef.h> // for size_t
47#else
48#include <cinttypes>
49#include <cstddef> // for size_t
50#include <memory>
51
53public:
58
59 void start();
60 void stop();
61
62private:
63 class impl;
64 std::unique_ptr<impl> m_impl;
65};
66
67#endif // __cplusplus
68
69// values are byte represenations of escape sequences (without ESC itself)
70#define K_UP 0x1b5b41
71#define K_DOWN 0x1b5b42
72#define K_RIGHT 0x1b5b43
73#define K_LEFT 0x1b5b44
74#define K_PGUP 0x1b5b357e
75#define K_PGDOWN 0x1b5b367e
76#define K_CTRL(x) (1 + ((x) >= 'A' && (x) <= 'Z' ? (x) - 'A' + 'a' : (x)) - 'a')
77#define K_CTRL_UP 0x1b5b313b3541LL
78#define K_CTRL_DOWN 0x1b5b313b3542LL
79#define K_ALT(x) ('\033' << 8 | (x))
80
81#define MAX_KEYCODE_NAME_LEN 8
82
83// attribute used guaranties that the symbol is present even if not referenced (modular build)
85EXTERN_C void keycontrol_send_key(struct module *root, int64_t key) __attribute__((used));
86EXTERN_C bool keycontrol_register_key(struct module *sender_mod, int64_t key, const char *message, const char *description) __attribute__((used));
87EXTERN_C void get_keycode_name(int64_t ch, char *buf, size_t buflen) __attribute__((used));
88EXTERN_C void restore_old_tio(void);
89
90#endif // keyboard_control_h_
91
std::unique_ptr< impl > m_impl
keyboard_control & operator=(keyboard_control &&)=delete
keyboard_control(struct module *parent)
keyboard_control(keyboard_control &&)=delete
EXTERN_C void get_keycode_name(int64_t ch, char *buf, size_t buflen) __attribute__((used))
EXTERN_C void keycontrol_send_key(struct module *root, int64_t key) __attribute__((used))
EXTERN_C bool keycontrol_register_key(struct module *sender_mod, int64_t key, const char *message, const char *description) __attribute__((used))
Registers callback message for given key.
EXTERN_C void restore_old_tio(void)
#define EXTERN_C
Definition macros.h:71
struct __attribute__((packed))
Definition rtp.h:88
const char * parent
Definition settings.cpp:198
const char * description
Definition cineform.cpp:126
const char * key
Definition cineform.cpp:125