GCC Code Coverage Report


Directory: src/gate/
File: src/gate/cxx_inputs.cpp
Date: 2025-09-14 13:10:38
Exec Total Coverage
Lines: 0 35 0.0%
Functions: 0 6 0.0%
Branches: 0 24 0.0%

Line Branch Exec Source
1 /* GATE PROJECT LICENSE:
2 +----------------------------------------------------------------------------+
3 | Copyright(c) 2018-2025, Stefan Meislinger |
4 | All rights reserved. |
5 | |
6 | Redistribution and use in source and binary forms, with or without |
7 | modification, are permitted provided that the following conditions are met:|
8 | |
9 | 1. Redistributions of source code must retain the above copyright notice, |
10 | this list of conditions and the following disclaimer. |
11 | 2. Redistributions in binary form must reproduce the above copyright |
12 | notice, this list of conditions and the following disclaimer in the |
13 | documentation and/or other materials provided with the distribution. |
14 | |
15 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"|
16 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
17 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE |
18 | ARE DISCLAIMED.IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE |
19 | LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR |
20 | CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF |
21 | SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS |
22 | INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN |
23 | CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) |
24 | ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF |
25 | THE POSSIBILITY OF SUCH DAMAGE. |
26 +----------------------------------------------------------------------------+
27 */
28
29 #include "gate/inputs.hpp"
30 #include "gate/results.hpp"
31 #include "gate/exceptions.hpp"
32
33 namespace gate
34 {
35
36 void Keyboard::parseNativeKey(nativekey_t native_key, KeyEnum& key, states_t& keyStateBits)
37 {
38 gate_input_keycode_t kbd_key = 0;
39 gate_input_keystates_t kbd_states = 0;
40 result_t result = gate_keyboard_parse_native_key(native_key, &kbd_key, &kbd_states);
41 GATEXX_CHECK_EXCEPTION(result);
42 key = KeyEnum(kbd_key);
43 keyStateBits = kbd_states;
44 }
45 Keyboard::KeyEnum Keyboard::parseNativeKey(nativekey_t native_key)
46 {
47 KeyEnum key = Keyboard::Key_Unknown;
48 uint32_t state = 0;
49 Keyboard::parseNativeKey(native_key, key, state);
50 return key;
51 }
52 Keyboard::nativekey_t Keyboard::buildNativeKey(KeyEnum key, states_t keyStateBits)
53 {
54 nativekey_t native_key = 0;
55 result_t result = gate_keyboard_build_native_key(key, keyStateBits, &native_key);
56 GATEXX_CHECK_EXCEPTION(result);
57 return native_key;
58 }
59
60 size_t Keyboard::parseVT100Symbols(char const* symbols, size_t symbolsCount,
61 KeyEnum& key, states_t& keyStateBits, char_32_t& character)
62 {
63 gate_input_keycode_t k = 0;
64 gate_input_keystates_t s = 0;
65 gate_char32_t c = 0;
66 size_t used = gate_keyboard_parse_vt100_symbols(symbols, symbolsCount, &k, &s, &c);
67 /*
68 if(used == 0)
69 {
70 GATEXX_RAISE_EXCEPTION(results::InvalidData, "Failed to parse VT100 symbols", 0);
71 }
72 */
73 key = KeyEnum(k);
74 keyStateBits = s;
75 character = c;
76 return used;
77 }
78 size_t Keyboard::buildVT100Symbols(KeyEnum key, states_t keyStateBits,
79 char* symbolsBuffer, size_t symbolsBufferCapacity)
80 {
81 return gate_keyboard_build_vt100_symbols(key, keyStateBits, symbolsBuffer, symbolsBufferCapacity);
82 }
83 void Keyboard::buildVT100Symbols(KeyEnum key, states_t keyStateBits,
84 Stream& output)
85 {
86 char buffer[32];
87 size_t used = Keyboard::buildVT100Symbols(key, keyStateBits, buffer, sizeof(buffer));
88 if (used == 0)
89 {
90 GATEXX_RAISE_EXCEPTION(results::InvalidData, "Failed to build VT100 symbols", 0);
91 }
92 output.writeBlock(buffer, used);
93 }
94
95
96 } // end of namespace gate
97