-
-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Expand file tree
/
Copy pathinput.h
More file actions
107 lines (92 loc) · 3.88 KB
/
Copy pathinput.h
File metadata and controls
107 lines (92 loc) · 3.88 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
/**
* @file src/input.h
* @brief Declarations for gamepad, keyboard, and mouse input handling.
*/
#pragma once
// standard includes
#include <functional>
#include <optional>
// local includes
#include "platform/common.h"
#include "thread_safe.h"
namespace input {
struct input_t;
/**
* @brief Write a debug log representation of the input packet.
*
* @param input Raw input packet to format for logging.
*/
void print(void *input);
/**
* @brief Reset stream input state after a client disconnect or shutdown.
*
* @param input Shared stream input state to reset.
*/
void reset(std::shared_ptr<input_t> &input);
/**
* @brief Queue a raw input message for platform passthrough.
*/
void passthrough(std::shared_ptr<input_t> &input, std::vector<std::uint8_t> &&input_data);
/**
* @brief Initialize global input resources and platform backends.
*
* @return Cleanup handle for initialized input resources, or null if none are required.
*/
[[nodiscard]] std::unique_ptr<platf::deinit_t> init();
/**
* @brief Probe whether the platform can create virtual gamepads.
*
* @return True when at least one configured gamepad backend is available.
*/
bool probe_gamepads();
/**
* @brief Allocate and initialize platform input state for a stream.
*
* @param mail Mailbox used to exchange messages with worker threads.
* @return Shared input state bound to the stream mailbox.
*/
std::shared_ptr<input_t> alloc(safe::mail_t mail);
/**
* @brief Touchscreen coordinate bounds used to scale absolute input.
*/
struct touch_port_t: public platf::touch_port_t {
int env_width; ///< Width of the full capture environment in physical pixels.
int env_height; ///< Height of the full capture environment in physical pixels.
// Offset x and y coordinates of the client
float client_offsetX; ///< Horizontal client viewport offset used when scaling touch input.
float client_offsetY; ///< Vertical client viewport offset used when scaling touch input.
float scalar_inv; ///< Inverse scale factor from client coordinates to display coordinates.
float scalar_tpcoords; ///< Scale factor from client coordinates to touch-port coordinates.
int env_logical_width; ///< Width of the full capture environment after display scaling.
int env_logical_height; ///< Height of the full capture environment after display scaling.
/**
* @brief Check whether the touch-port bounds are initialized.
*/
explicit operator bool() const {
return width != 0 && height != 0 && env_width != 0 && env_height != 0;
}
};
/**
* @brief Normalize host coordinates against the encoded frame or its effective display content.
* @details When effective content is selected, symmetric letterbox or pillarbox padding is removed from the
* encoded extent and coordinates in that padding are clamped to the nearest content edge.
*
* @param touch_port Touch-port metadata for the active stream and captured display.
* @param coords Host-relative coordinates to normalize in place.
* @param use_effective_content Whether to exclude encoded letterbox or pillarbox regions from normalization.
* @return The selected logical touch port, or `std::nullopt` when dimensions are invalid.
*/
std::optional<platf::touch_port_t> monitor_touch_port(
const touch_port_t &touch_port,
std::pair<float, float> &coords,
bool use_effective_content
);
/**
* @brief Scale the ellipse axes according to the provided size.
* @param val The major and minor axis pair.
* @param rotation The rotation value from the touch/pen event.
* @param scalar The scalar cartesian coordinate pair.
* @return The major and minor axis pair.
*/
std::pair<float, float> scale_client_contact_area(const std::pair<float, float> &val, uint16_t rotation, const std::pair<float, float> &scalar);
} // namespace input