@desklink/host 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (142) hide show
  1. package/LICENSE +202 -0
  2. package/NOTICE +44 -0
  3. package/README.md +266 -0
  4. package/bin/desklink-host.mjs +113 -0
  5. package/dist/bridge.d.ts +57 -0
  6. package/dist/bridge.d.ts.map +1 -0
  7. package/dist/bridge.js +208 -0
  8. package/dist/bridge.js.map +1 -0
  9. package/dist/engineProcess.d.ts +82 -0
  10. package/dist/engineProcess.d.ts.map +1 -0
  11. package/dist/engineProcess.js +243 -0
  12. package/dist/engineProcess.js.map +1 -0
  13. package/dist/index.d.ts +12 -0
  14. package/dist/index.d.ts.map +1 -0
  15. package/dist/index.js +12 -0
  16. package/dist/index.js.map +1 -0
  17. package/dist/protocol.d.ts +169 -0
  18. package/dist/protocol.d.ts.map +1 -0
  19. package/dist/protocol.js +18 -0
  20. package/dist/protocol.js.map +1 -0
  21. package/dist/resolveEngine.d.ts +34 -0
  22. package/dist/resolveEngine.d.ts.map +1 -0
  23. package/dist/resolveEngine.js +103 -0
  24. package/dist/resolveEngine.js.map +1 -0
  25. package/docs/BOUNDARY.md +145 -0
  26. package/docs/PROTOCOL.md +363 -0
  27. package/engine/Cargo.lock +3077 -0
  28. package/engine/Cargo.toml +37 -0
  29. package/engine/build.rs +107 -0
  30. package/engine/native/inputtino_shim.cpp +11 -0
  31. package/engine/native/vpx_shim.c +184 -0
  32. package/engine/native/wrapper.h +7 -0
  33. package/engine/src/capture.rs +510 -0
  34. package/engine/src/clipboard.rs +132 -0
  35. package/engine/src/convert.rs +299 -0
  36. package/engine/src/encoder.rs +204 -0
  37. package/engine/src/input.rs +355 -0
  38. package/engine/src/keymap.rs +338 -0
  39. package/engine/src/main.rs +614 -0
  40. package/engine/src/peer.rs +775 -0
  41. package/engine/src/portal.rs +115 -0
  42. package/engine/src/protocol.rs +331 -0
  43. package/engine/src/session.rs +2159 -0
  44. package/engine/src/x11.rs +244 -0
  45. package/engine/vendor/inputtino/.clang-format +166 -0
  46. package/engine/vendor/inputtino/.clang-tidy +30 -0
  47. package/engine/vendor/inputtino/.dockerignore +11 -0
  48. package/engine/vendor/inputtino/.github/workflows/mirror-repo.yml +14 -0
  49. package/engine/vendor/inputtino/.github/workflows/python-lint-format-test-typecheck.yml +124 -0
  50. package/engine/vendor/inputtino/.github/workflows/python-test-install.yaml +49 -0
  51. package/engine/vendor/inputtino/.github/workflows/rust.yml +40 -0
  52. package/engine/vendor/inputtino/CMakeLists.txt +187 -0
  53. package/engine/vendor/inputtino/LICENSE +21 -0
  54. package/engine/vendor/inputtino/README.md +110 -0
  55. package/engine/vendor/inputtino/bindings/python/.devcontainer/Dockerfile +23 -0
  56. package/engine/vendor/inputtino/bindings/python/.devcontainer/devcontainer.json +28 -0
  57. package/engine/vendor/inputtino/bindings/python/.python-version +1 -0
  58. package/engine/vendor/inputtino/bindings/python/CMakeLists.txt +23 -0
  59. package/engine/vendor/inputtino/bindings/python/CPPLINT.cfg +2 -0
  60. package/engine/vendor/inputtino/bindings/python/Makefile +49 -0
  61. package/engine/vendor/inputtino/bindings/python/README.md +215 -0
  62. package/engine/vendor/inputtino/bindings/python/pyproject.toml +178 -0
  63. package/engine/vendor/inputtino/bindings/python/src/inputtino/__init__.py +43 -0
  64. package/engine/vendor/inputtino/bindings/python/src/inputtino/_core.pyi +533 -0
  65. package/engine/vendor/inputtino/bindings/python/src/inputtino/base.py +63 -0
  66. package/engine/vendor/inputtino/bindings/python/src/inputtino/joypad.py +248 -0
  67. package/engine/vendor/inputtino/bindings/python/src/inputtino/keyboard.py +256 -0
  68. package/engine/vendor/inputtino/bindings/python/src/inputtino/mouse.py +106 -0
  69. package/engine/vendor/inputtino/bindings/python/src/inputtino/pentablet.py +73 -0
  70. package/engine/vendor/inputtino/bindings/python/src/inputtino/py.typed +0 -0
  71. package/engine/vendor/inputtino/bindings/python/src/inputtino/touchscreen.py +61 -0
  72. package/engine/vendor/inputtino/bindings/python/src/inputtino/trackpad.py +74 -0
  73. package/engine/vendor/inputtino/bindings/python/src/main.cpp +217 -0
  74. package/engine/vendor/inputtino/bindings/python/tests/__init__.py +0 -0
  75. package/engine/vendor/inputtino/bindings/python/tests/helpers.py +3 -0
  76. package/engine/vendor/inputtino/bindings/python/tests/test_base.py +60 -0
  77. package/engine/vendor/inputtino/bindings/python/tests/test_inputtino.py +5 -0
  78. package/engine/vendor/inputtino/bindings/python/tests/test_joypad.py +332 -0
  79. package/engine/vendor/inputtino/bindings/python/tests/test_keyboard.py +164 -0
  80. package/engine/vendor/inputtino/bindings/python/tests/test_mouse.py +185 -0
  81. package/engine/vendor/inputtino/bindings/python/tests/test_pentablet.py +198 -0
  82. package/engine/vendor/inputtino/bindings/python/tests/test_touchscreen.py +144 -0
  83. package/engine/vendor/inputtino/bindings/python/tests/test_trackpad.py +146 -0
  84. package/engine/vendor/inputtino/bindings/python/uv.lock +390 -0
  85. package/engine/vendor/inputtino/bindings/rust/Cargo.toml +6 -0
  86. package/engine/vendor/inputtino/bindings/rust/inputtino/.dockerignore +1 -0
  87. package/engine/vendor/inputtino/bindings/rust/inputtino/Cargo.toml +18 -0
  88. package/engine/vendor/inputtino/bindings/rust/inputtino/examples/keyboard.rs +33 -0
  89. package/engine/vendor/inputtino/bindings/rust/inputtino/examples/mouse.rs +17 -0
  90. package/engine/vendor/inputtino/bindings/rust/inputtino/src/common.rs +116 -0
  91. package/engine/vendor/inputtino/bindings/rust/inputtino/src/error.rs +17 -0
  92. package/engine/vendor/inputtino/bindings/rust/inputtino/src/joypad.rs +74 -0
  93. package/engine/vendor/inputtino/bindings/rust/inputtino/src/joypad_nintendo.rs +135 -0
  94. package/engine/vendor/inputtino/bindings/rust/inputtino/src/joypad_ps5.rs +280 -0
  95. package/engine/vendor/inputtino/bindings/rust/inputtino/src/joypad_xbox.rs +134 -0
  96. package/engine/vendor/inputtino/bindings/rust/inputtino/src/keyboard.rs +76 -0
  97. package/engine/vendor/inputtino/bindings/rust/inputtino/src/lib.rs +32 -0
  98. package/engine/vendor/inputtino/bindings/rust/inputtino/src/mouse.rs +178 -0
  99. package/engine/vendor/inputtino/bindings/rust/inputtino/tests/common.rs +38 -0
  100. package/engine/vendor/inputtino/bindings/rust/inputtino/tests/joypads.rs +150 -0
  101. package/engine/vendor/inputtino/bindings/rust/inputtino/tests/keyboard.rs +73 -0
  102. package/engine/vendor/inputtino/bindings/rust/inputtino/tests/mouse.rs +139 -0
  103. package/engine/vendor/inputtino/bindings/rust/inputtino-sys/.dockerignore +1 -0
  104. package/engine/vendor/inputtino/bindings/rust/inputtino-sys/Cargo.toml +12 -0
  105. package/engine/vendor/inputtino/bindings/rust/inputtino-sys/build.rs +48 -0
  106. package/engine/vendor/inputtino/bindings/rust/inputtino-sys/src/lib.rs +5 -0
  107. package/engine/vendor/inputtino/bindings/rust/inputtino-sys/wrapper.h +1 -0
  108. package/engine/vendor/inputtino/cmake/utils.cmake +9 -0
  109. package/engine/vendor/inputtino/docker/Dockerfile +70 -0
  110. package/engine/vendor/inputtino/include/inputtino/input.h +324 -0
  111. package/engine/vendor/inputtino/include/inputtino/input.hpp +466 -0
  112. package/engine/vendor/inputtino/include/inputtino/result.hpp +37 -0
  113. package/engine/vendor/inputtino/share/pkgconfig/libinputtino.pc.in +17 -0
  114. package/engine/vendor/inputtino/src/c-bindings/helpers.hpp +19 -0
  115. package/engine/vendor/inputtino/src/c-bindings/joypad_ps5.cpp +115 -0
  116. package/engine/vendor/inputtino/src/c-bindings/joypad_switch.cpp +63 -0
  117. package/engine/vendor/inputtino/src/c-bindings/joypad_xone.cpp +62 -0
  118. package/engine/vendor/inputtino/src/c-bindings/keyboard.cpp +42 -0
  119. package/engine/vendor/inputtino/src/c-bindings/mouse.cpp +67 -0
  120. package/engine/vendor/inputtino/src/c-bindings/pen_tablet.cpp +50 -0
  121. package/engine/vendor/inputtino/src/c-bindings/touchscreen.cpp +43 -0
  122. package/engine/vendor/inputtino/src/c-bindings/trackpad.cpp +49 -0
  123. package/engine/vendor/inputtino/src/uhid/README.adoc +63 -0
  124. package/engine/vendor/inputtino/src/uhid/include/crc32.hpp +38 -0
  125. package/engine/vendor/inputtino/src/uhid/include/uhid/protected_types.hpp +36 -0
  126. package/engine/vendor/inputtino/src/uhid/include/uhid/ps5.hpp +550 -0
  127. package/engine/vendor/inputtino/src/uhid/include/uhid/uhid.hpp +168 -0
  128. package/engine/vendor/inputtino/src/uhid/joypad_ps5.cpp +580 -0
  129. package/engine/vendor/inputtino/src/uinput/include/inputtino/keyboard.hpp +84 -0
  130. package/engine/vendor/inputtino/src/uinput/include/inputtino/protected_ps5_types.hpp +7 -0
  131. package/engine/vendor/inputtino/src/uinput/include/inputtino/protected_types.hpp +110 -0
  132. package/engine/vendor/inputtino/src/uinput/joypad_nintendo.cpp +190 -0
  133. package/engine/vendor/inputtino/src/uinput/joypad_ps.cpp +203 -0
  134. package/engine/vendor/inputtino/src/uinput/joypad_utils.hpp +246 -0
  135. package/engine/vendor/inputtino/src/uinput/joypad_xbox.cpp +190 -0
  136. package/engine/vendor/inputtino/src/uinput/keyboard.cpp +120 -0
  137. package/engine/vendor/inputtino/src/uinput/mouse.cpp +199 -0
  138. package/engine/vendor/inputtino/src/uinput/pentablet.cpp +162 -0
  139. package/engine/vendor/inputtino/src/uinput/touchscreen.cpp +140 -0
  140. package/engine/vendor/inputtino/src/uinput/trackpad.cpp +192 -0
  141. package/examples/reference-client.html +428 -0
  142. package/package.json +38 -0
@@ -0,0 +1,139 @@
1
+ #[macro_use]
2
+ extern crate approx;
3
+
4
+ use input::event::pointer::{Axis, ButtonState};
5
+ use input::event::{DeviceEvent, PointerEvent};
6
+ use input::{Event, Libinput};
7
+ use inputtino::{DeviceDefinition, Mouse, MouseButton};
8
+
9
+ mod common;
10
+ use crate::common::{NixInterface, SyncEvent};
11
+
12
+ #[test]
13
+ fn test_inputtino_mouse() {
14
+ let device = DeviceDefinition::new(
15
+ "Rusty Mouse",
16
+ 0xAB,
17
+ 0xCD,
18
+ 0xEF,
19
+ "Rusty Mouse Phys",
20
+ "Rusty Mouse Uniq",
21
+ );
22
+ let mouse = Mouse::new(&device).unwrap();
23
+ let nodes = mouse.get_nodes().unwrap();
24
+ {
25
+ assert_eq!(nodes.len(), 2);
26
+
27
+ // Check that the nodes start with /dev/input/event
28
+ assert!(nodes[0].to_str().unwrap().starts_with("/dev/input/event"));
29
+ assert!(nodes[1].to_str().unwrap().starts_with("/dev/input/event"));
30
+ }
31
+
32
+ let mut input = Libinput::new_from_path(NixInterface);
33
+ let dev_rel = input
34
+ .path_add_device(nodes[0].to_str().expect("valid utf-8"))
35
+ .expect("to get the device");
36
+ let dev_abs = input
37
+ .path_add_device(nodes[1].to_str().expect("valid utf-8"))
38
+ .expect("to get the device");
39
+
40
+ {
41
+ assert_eq!(dev_rel.name(), "Rusty Mouse");
42
+ assert_eq!(dev_abs.name(), "Rusty Mouse (absolute)");
43
+ assert_eq!(dev_rel.id_vendor(), 0xAB);
44
+ assert_eq!(dev_abs.id_vendor(), 0xAB);
45
+ assert_eq!(dev_rel.id_product(), 0xCD);
46
+ assert_eq!(dev_abs.id_product(), 0xCD);
47
+ for event in &mut input {
48
+ assert!(matches!(event, Event::Device(DeviceEvent::Added(_))));
49
+ }
50
+ }
51
+
52
+ {
53
+ // Test mouse relative motion
54
+ mouse.move_rel(10, 20);
55
+
56
+ let ev = input.wait_next_event().unwrap();
57
+ assert!(matches!(ev, Event::Pointer(PointerEvent::Motion(_))));
58
+ match ev {
59
+ Event::Pointer(PointerEvent::Motion(ev)) => {
60
+ assert_eq!(ev.dx_unaccelerated(), 10.0);
61
+ assert_eq!(ev.dy_unaccelerated(), 20.0);
62
+ }
63
+ _ => unreachable!(),
64
+ }
65
+ }
66
+
67
+ {
68
+ // Test mouse absolute motion
69
+ mouse.move_abs(100, 200, 1920, 1080);
70
+
71
+ let ev = input.wait_next_event().unwrap();
72
+ assert!(matches!(
73
+ ev,
74
+ Event::Pointer(PointerEvent::MotionAbsolute(_))
75
+ ));
76
+ match ev {
77
+ Event::Pointer(PointerEvent::MotionAbsolute(ev)) => {
78
+ assert_relative_eq!(ev.absolute_x_transformed(1920), 100.0, max_relative = 0.1);
79
+ assert_relative_eq!(ev.absolute_y_transformed(1080), 200.0, max_relative = 0.1);
80
+ }
81
+ _ => unreachable!(),
82
+ }
83
+ }
84
+
85
+ {
86
+ // Test mouse button press
87
+ mouse.press_button(MouseButton::LEFT);
88
+
89
+ let ev = input.wait_next_event().unwrap();
90
+ assert!(matches!(ev, Event::Pointer(PointerEvent::Button(_))));
91
+ match ev {
92
+ Event::Pointer(PointerEvent::Button(ev)) => {
93
+ assert_eq!(ev.button(), 272);
94
+ assert_eq!(ev.button_state(), ButtonState::Pressed);
95
+ }
96
+ _ => unreachable!(),
97
+ }
98
+ }
99
+
100
+ {
101
+ mouse.release_button(MouseButton::LEFT);
102
+
103
+ let ev = input.wait_next_event().unwrap();
104
+ assert!(matches!(ev, Event::Pointer(PointerEvent::Button(_))));
105
+ match ev {
106
+ Event::Pointer(PointerEvent::Button(ev)) => {
107
+ assert_eq!(ev.button(), 272);
108
+ assert_eq!(ev.button_state(), ButtonState::Released);
109
+ }
110
+ _ => unreachable!(),
111
+ }
112
+ }
113
+
114
+ {
115
+ mouse.scroll_vertical(100);
116
+
117
+ let ev = input.wait_next_event().unwrap();
118
+ assert!(matches!(ev, Event::Pointer(PointerEvent::ScrollWheel(_))));
119
+ match ev {
120
+ Event::Pointer(PointerEvent::ScrollWheel(ev)) => {
121
+ assert_eq!(ev.scroll_value_v120(Axis::Vertical), -100.0);
122
+ }
123
+ _ => unreachable!(),
124
+ }
125
+ }
126
+
127
+ {
128
+ mouse.scroll_horizontal(100);
129
+
130
+ let ev = input.wait_next_event().unwrap();
131
+ assert!(matches!(ev, Event::Pointer(PointerEvent::ScrollWheel(_))));
132
+ match ev {
133
+ Event::Pointer(PointerEvent::ScrollWheel(ev)) => {
134
+ assert_eq!(ev.scroll_value_v120(Axis::Horizontal), 100.0);
135
+ }
136
+ _ => unreachable!(),
137
+ }
138
+ }
139
+ }
@@ -0,0 +1,12 @@
1
+ [package]
2
+ name = "inputtino-sys"
3
+ version = "0.1.0"
4
+ edition = "2021"
5
+ license = "MIT"
6
+ homepage = "https://github.com/games-on-whales/inputtino"
7
+ authors = ["ABeltramo"]
8
+ description = "Rust bindings for inputtino"
9
+
10
+ [build-dependencies]
11
+ bindgen = "0.69.4"
12
+ cmake = "0.1.52"
@@ -0,0 +1,48 @@
1
+ use std::env;
2
+ use std::path::PathBuf;
3
+
4
+ use cmake::Config;
5
+
6
+ fn main() {
7
+ let mut bindings = bindgen::Builder::default()
8
+ .use_core()
9
+ .default_enum_style(bindgen::EnumVariation::Rust {
10
+ non_exhaustive: false,
11
+ })
12
+ .clang_arg("-DINPUTTINO_STATIC_DEFINE=1")
13
+ .header("wrapper.h");
14
+
15
+ let libdir_path = PathBuf::from("../../../")
16
+ // Canonicalize the path as `rustc-link-search` requires an absolute
17
+ // path.
18
+ .canonicalize()
19
+ .expect("cannot canonicalize path");
20
+
21
+ // Compile the library using CMake
22
+ let dst = Config::new(libdir_path)
23
+ .define("BUILD_SHARED_LIBS", "OFF")
24
+ .define("LIBINPUTTINO_INSTALL", "ON")
25
+ .define("BUILD_TESTING", "OFF")
26
+ .define("BUILD_SERVER", "OFF")
27
+ .define("BUILD_C_BINDINGS", "ON")
28
+ .profile("Release")
29
+ .define("CMAKE_CONFIGURATION_TYPES", "Release")
30
+ .build();
31
+
32
+ println!("cargo:rustc-link-search=native={}/lib", dst.display());
33
+ println!("cargo:rustc-link-search=native={}/lib64", dst.display());
34
+ bindings = bindings.clang_arg(format!("-I{}/include/", dst.display()));
35
+
36
+ // Dependencies
37
+ println!("cargo:rustc-link-lib=evdev");
38
+ println!("cargo:rustc-link-lib=stdc++");
39
+ println!("cargo:rustc-link-lib=c++");
40
+ println!("cargo:rustc-link-lib=static=libinputtino");
41
+
42
+ let out = bindings.generate().expect("Unable to generate bindings");
43
+
44
+ // Write the bindings to the $OUT_DIR/bindings.rs file.
45
+ let out_path = PathBuf::from(env::var("OUT_DIR").unwrap()).join("bindings.rs");
46
+ out.write_to_file(out_path)
47
+ .expect("Couldn't write bindings!");
48
+ }
@@ -0,0 +1,5 @@
1
+ #![allow(non_upper_case_globals)]
2
+ #![allow(non_camel_case_types)]
3
+ #![allow(non_snake_case)]
4
+
5
+ include!(concat!(env!("OUT_DIR"), "/bindings.rs"));
@@ -0,0 +1 @@
1
+ #include <inputtino/input.h>
@@ -0,0 +1,9 @@
1
+ # set_if_undefined(<variable> [<value>]...)
2
+ #
3
+ # Set variable if it is not defined.
4
+ # Taken from: https://github.com/pananton/cpp-lib-template/
5
+ macro(set_if_undefined variable)
6
+ if(NOT DEFINED "${variable}")
7
+ set("${variable}" ${ARGN})
8
+ endif()
9
+ endmacro()
@@ -0,0 +1,70 @@
1
+ ARG BASE_IMAGE=ghcr.io/games-on-whales/base:edge
2
+
3
+ ####################################
4
+ FROM $BASE_IMAGE AS build-libinputtino
5
+
6
+ ENV DEBIAN_FRONTEND=noninteractive
7
+
8
+ RUN apt-get update -y && \
9
+ apt-get install -y --no-install-recommends \
10
+ ca-certificates \
11
+ ccache \
12
+ ninja-build \
13
+ cmake \
14
+ clang \
15
+ pkg-config \
16
+ git \
17
+ libevdev-dev \
18
+ && rm -rf /var/lib/apt/lists/*
19
+
20
+
21
+ COPY . /inputtino/
22
+ WORKDIR /inputtino
23
+
24
+ ENV CCACHE_DIR=/cache/ccache
25
+ ENV CMAKE_BUILD_DIR=/cache/cmake-build
26
+ RUN --mount=type=cache,target=/cache/ccache \
27
+ cmake -B$CMAKE_BUILD_DIR \
28
+ -DCMAKE_INSTALL_PREFIX:PATH=/usr \
29
+ -DCMAKE_BUILD_TYPE=Release \
30
+ -DBUILD_TESTING=OFF \
31
+ -DBUILD_C_BINDINGS=ON \
32
+ -DLIBINPUTTINO_INSTALL=ON \
33
+ -DBUILD_SHARED_LIBS=ON \
34
+ -G Ninja && \
35
+ ninja -C $CMAKE_BUILD_DIR install
36
+
37
+ ####################################
38
+ FROM $BASE_IMAGE AS base-libinputtino
39
+
40
+ RUN apt-get update -y && \
41
+ apt-get install -y --no-install-recommends libevdev2 \
42
+ && rm -rf /var/lib/apt/lists/*
43
+
44
+ COPY --from=build-libinputtino /usr/include/inputtino /usr/include/inputtino
45
+ COPY --from=build-libinputtino /usr/share/pkgconfig/libinputtino.pc /usr/share/pkgconfig/libinputtino.pc
46
+ COPY --from=build-libinputtino /usr/lib/x86_64-linux-gnu/liblibinputtino* /usr/lib/x86_64-linux-gnu/
47
+
48
+ ####################################
49
+ FROM base-libinputtino AS build-rust-bindings
50
+
51
+ ENV DEBIAN_FRONTEND=noninteractive
52
+
53
+ RUN apt-get update -y && \
54
+ apt-get install -y --no-install-recommends \
55
+ ca-certificates \
56
+ pkg-config \
57
+ build-essential \
58
+ clang \
59
+ curl \
60
+ && curl https://sh.rustup.rs -sSf | bash -s -- -y \
61
+ && rm -rf /var/lib/apt/lists/*
62
+
63
+ ENV PATH="${HOME}/.cargo/bin:${PATH}"
64
+
65
+ COPY ./bindings/rust /inputtino-rust
66
+ WORKDIR /inputtino-rust
67
+
68
+
69
+ RUN cargo build --release
70
+
@@ -0,0 +1,324 @@
1
+ /**
2
+ * C API for the inputtino library
3
+ */
4
+ #ifndef __INPUTTINO_H__
5
+ #define __INPUTTINO_H__
6
+
7
+ #ifndef INPUTTINO_STATIC_DEFINE
8
+ # include <inputtino/export_shared.h>
9
+ #else
10
+ # include <inputtino/export_static.h>
11
+ #endif
12
+ #include <stdbool.h>
13
+ #include <stdint.h>
14
+
15
+ #ifdef __cplusplus
16
+ extern "C" {
17
+ #endif
18
+
19
+ typedef struct InputtinoDeviceDefinition {
20
+ const char *name;
21
+ unsigned short vendor_id;
22
+ unsigned short product_id;
23
+ unsigned short version;
24
+
25
+ const char * device_phys;
26
+ const char * device_uniq;
27
+ } InputtinoDeviceDefinition;
28
+
29
+ typedef void (*InputtinoErrorHandlerFn)(const char *error_message, void *user_data);
30
+
31
+ typedef struct InputtinoErrorHandler {
32
+ InputtinoErrorHandlerFn eh;
33
+ void *user_data;
34
+ } InputtinoErrorHandler;
35
+
36
+ /*
37
+ * MOUSE
38
+ */
39
+ struct InputtinoMouse;
40
+ typedef struct InputtinoMouse InputtinoMouse;
41
+
42
+ LIBINPUTTINO_EXPORT InputtinoMouse *inputtino_mouse_create(const InputtinoDeviceDefinition *device, const InputtinoErrorHandler *eh);
43
+
44
+ LIBINPUTTINO_EXPORT char **inputtino_mouse_get_nodes(InputtinoMouse *mouse, int *num_nodes);
45
+
46
+ LIBINPUTTINO_EXPORT void inputtino_mouse_move(InputtinoMouse *mouse, int delta_x, int delta_y);
47
+
48
+ LIBINPUTTINO_EXPORT void inputtino_mouse_move_absolute(InputtinoMouse *mouse, int x, int y, int screen_width, int screen_height);
49
+
50
+ enum INPUTTINO_MOUSE_BUTTON {
51
+ LEFT,
52
+ MIDDLE,
53
+ RIGHT,
54
+ SIDE,
55
+ EXTRA
56
+ };
57
+
58
+ LIBINPUTTINO_EXPORT void inputtino_mouse_press_button(InputtinoMouse *mouse, enum INPUTTINO_MOUSE_BUTTON button);
59
+
60
+ LIBINPUTTINO_EXPORT void inputtino_mouse_release_button(InputtinoMouse *mouse, enum INPUTTINO_MOUSE_BUTTON button);
61
+
62
+ LIBINPUTTINO_EXPORT void inputtino_mouse_scroll_vertical(InputtinoMouse *mouse, int high_res_distance);
63
+
64
+ LIBINPUTTINO_EXPORT void inputtino_mouse_scroll_horizontal(InputtinoMouse *mouse, int high_res_distance);
65
+
66
+ LIBINPUTTINO_EXPORT void inputtino_mouse_destroy(InputtinoMouse *mouse);
67
+
68
+ /*
69
+ * TRACKPAD
70
+ */
71
+
72
+ struct InputtinoTrackpad;
73
+ typedef struct InputtinoTrackpad InputtinoTrackpad;
74
+
75
+ LIBINPUTTINO_EXPORT InputtinoTrackpad *inputtino_trackpad_create(const InputtinoDeviceDefinition *device, const InputtinoErrorHandler *eh);
76
+
77
+ LIBINPUTTINO_EXPORT char **inputtino_trackpad_get_nodes(InputtinoTrackpad *trackpad, int *num_nodes);
78
+
79
+ LIBINPUTTINO_EXPORT void inputtino_trackpad_place_finger(
80
+ InputtinoTrackpad *trackpad, int finger_nr, float x, float y, float pressure, int orientation);
81
+
82
+ LIBINPUTTINO_EXPORT void inputtino_trackpad_release_finger(InputtinoTrackpad *trackpad, int finger_nr);
83
+
84
+ LIBINPUTTINO_EXPORT void inputtino_trackpad_set_left_btn(InputtinoTrackpad *trackpad, bool pressed);
85
+
86
+ LIBINPUTTINO_EXPORT void inputtino_trackpad_destroy(InputtinoTrackpad *trackpad);
87
+
88
+ /*
89
+ * TOUCHSCREEN
90
+ */
91
+
92
+ struct InputtinoTouchscreen;
93
+ typedef struct InputtinoTouchscreen InputtinoTouchscreen;
94
+
95
+ LIBINPUTTINO_EXPORT InputtinoTouchscreen *inputtino_touchscreen_create(const InputtinoDeviceDefinition *device,
96
+ const InputtinoErrorHandler *eh);
97
+
98
+ LIBINPUTTINO_EXPORT char **inputtino_touchscreen_get_nodes(InputtinoTouchscreen *touchscreen, int *num_nodes);
99
+
100
+ LIBINPUTTINO_EXPORT void inputtino_touchscreen_place_finger(
101
+ InputtinoTouchscreen *touchscreen, int finger_nr, float x, float y, float pressure, int orientation);
102
+
103
+ LIBINPUTTINO_EXPORT void inputtino_touchscreen_release_finger(InputtinoTouchscreen *touchscreen, int finger_nr);
104
+
105
+ LIBINPUTTINO_EXPORT void inputtino_touchscreen_destroy(InputtinoTouchscreen *touchscreen);
106
+
107
+ /*
108
+ * PENTABLET
109
+ */
110
+
111
+ struct InputtinoPenTablet;
112
+ typedef struct InputtinoPenTablet InputtinoPenTablet;
113
+
114
+ LIBINPUTTINO_EXPORT InputtinoPenTablet *inputtino_pen_tablet_create(const InputtinoDeviceDefinition *device,
115
+ const InputtinoErrorHandler *eh);
116
+
117
+ LIBINPUTTINO_EXPORT char **inputtino_pen_tablet_get_nodes(InputtinoPenTablet *pen_tablet, int *num_nodes);
118
+
119
+ enum INPUTTINO_PEN_TOOL_TYPE {
120
+ PEN,
121
+ ERASER,
122
+ BRUSH,
123
+ PENCIL,
124
+ AIRBRUSH,
125
+ TOUCH,
126
+ SAME_AS_BEFORE /* Real devices don't need to report the tool type when it's still the same */
127
+ };
128
+
129
+ LIBINPUTTINO_EXPORT void inputtino_pen_tablet_place_tool(InputtinoPenTablet *pen_tablet,
130
+ enum INPUTTINO_PEN_TOOL_TYPE tool_type,
131
+ float x,
132
+ float y,
133
+ float pressure,
134
+ float distance,
135
+ float tilt_x,
136
+ float tilt_y);
137
+
138
+ enum INPUTTINO_PEN_BTN_TYPE {
139
+ PRIMARY,
140
+ SECONDARY,
141
+ TERTIARY
142
+ };
143
+
144
+ LIBINPUTTINO_EXPORT void
145
+ inputtino_pen_tablet_set_button(InputtinoPenTablet *pen_tablet, enum INPUTTINO_PEN_BTN_TYPE button, bool pressed);
146
+
147
+ LIBINPUTTINO_EXPORT void inputtino_pen_tablet_destroy(InputtinoPenTablet *pen_tablet);
148
+
149
+ /*
150
+ * KEYBOARD
151
+ */
152
+
153
+ struct InputtinoKeyboard;
154
+ typedef struct InputtinoKeyboard InputtinoKeyboard;
155
+
156
+ LIBINPUTTINO_EXPORT InputtinoKeyboard *inputtino_keyboard_create(const InputtinoDeviceDefinition *device, const InputtinoErrorHandler *eh);
157
+
158
+ LIBINPUTTINO_EXPORT char **inputtino_keyboard_get_nodes(InputtinoKeyboard *keyboard, int *num_nodes);
159
+
160
+ LIBINPUTTINO_EXPORT void inputtino_keyboard_press(InputtinoKeyboard *keyboard, short key_code);
161
+
162
+ LIBINPUTTINO_EXPORT void inputtino_keyboard_release(InputtinoKeyboard *keyboard, short key_code);
163
+
164
+ LIBINPUTTINO_EXPORT void inputtino_keyboard_destroy(InputtinoKeyboard *keyboard);
165
+
166
+ /*
167
+ * Joypads
168
+ */
169
+
170
+ enum INPUTTINO_JOYPAD_BTN : int {
171
+ DPAD_UP = 0x0001,
172
+ DPAD_DOWN = 0x0002,
173
+ DPAD_LEFT = 0x0004,
174
+ DPAD_RIGHT = 0x0008,
175
+
176
+ START = 0x0010,
177
+ BACK = 0x0020,
178
+ HOME = 0x0400,
179
+
180
+ LEFT_STICK = 0x0040,
181
+ RIGHT_STICK = 0x0080,
182
+ LEFT_BUTTON = 0x0100,
183
+ RIGHT_BUTTON = 0x0200,
184
+
185
+ SPECIAL_FLAG = 0x0400,
186
+ PADDLE1_FLAG = 0x010000,
187
+ PADDLE2_FLAG = 0x020000,
188
+ PADDLE3_FLAG = 0x040000,
189
+ PADDLE4_FLAG = 0x080000,
190
+ TOUCHPAD_FLAG = 0x100000, // Touchpad buttons on Sony controllers
191
+ MISC_FLAG = 0x200000, // Share/Mic/Capture/Mute buttons on various controllers
192
+
193
+ A = 0x1000,
194
+ B = 0x2000,
195
+ X = 0x4000,
196
+ Y = 0x8000
197
+ };
198
+
199
+ enum INPUTTINO_JOYPAD_STICK_POSITION {
200
+ RS,
201
+ LS
202
+ };
203
+
204
+ typedef void (*InputtinoJoypadRumbleFn)(int low_freq, int high_freq, void *user_data);
205
+
206
+ /*
207
+ * XOne Joypad
208
+ */
209
+
210
+ struct InputtinoXOneJoypad;
211
+ typedef struct InputtinoXOneJoypad InputtinoXOneJoypad;
212
+
213
+ LIBINPUTTINO_EXPORT InputtinoXOneJoypad *inputtino_joypad_xone_create(const InputtinoDeviceDefinition *device,
214
+ const InputtinoErrorHandler *eh);
215
+
216
+ LIBINPUTTINO_EXPORT char **inputtino_joypad_xone_get_nodes(InputtinoXOneJoypad *joypad, int *num_nodes);
217
+
218
+ LIBINPUTTINO_EXPORT void inputtino_joypad_xone_set_pressed_buttons(InputtinoXOneJoypad *joypad, int newly_pressed);
219
+
220
+ LIBINPUTTINO_EXPORT void inputtino_joypad_xone_set_triggers(InputtinoXOneJoypad *joypad, short left_trigger, short right_trigger);
221
+
222
+ LIBINPUTTINO_EXPORT void inputtino_joypad_xone_set_stick(InputtinoXOneJoypad *joypad,
223
+ enum INPUTTINO_JOYPAD_STICK_POSITION stick_type,
224
+ short x,
225
+ short y);
226
+
227
+ LIBINPUTTINO_EXPORT void
228
+ inputtino_joypad_xone_set_on_rumble(InputtinoXOneJoypad *joypad, InputtinoJoypadRumbleFn rumble_fn, void *user_data);
229
+
230
+ LIBINPUTTINO_EXPORT void inputtino_joypad_xone_destroy(InputtinoXOneJoypad *joypad);
231
+
232
+ /*
233
+ * Nintendo Switch Joypad
234
+ */
235
+
236
+ struct InputtinoSwitchJoypad;
237
+ typedef struct InputtinoSwitchJoypad InputtinoSwitchJoypad;
238
+
239
+ LIBINPUTTINO_EXPORT InputtinoSwitchJoypad *inputtino_joypad_switch_create(const InputtinoDeviceDefinition *device,
240
+ const InputtinoErrorHandler *eh);
241
+
242
+ LIBINPUTTINO_EXPORT char **inputtino_joypad_switch_get_nodes(InputtinoSwitchJoypad *joypad, int *num_nodes);
243
+
244
+ LIBINPUTTINO_EXPORT void inputtino_joypad_switch_set_pressed_buttons(InputtinoSwitchJoypad *joypad, int newly_pressed);
245
+
246
+ LIBINPUTTINO_EXPORT void
247
+ inputtino_joypad_switch_set_triggers(InputtinoSwitchJoypad *joypad, short left_trigger, short right_trigger);
248
+
249
+ LIBINPUTTINO_EXPORT void inputtino_joypad_switch_set_stick(InputtinoSwitchJoypad *joypad,
250
+ enum INPUTTINO_JOYPAD_STICK_POSITION stick_type,
251
+ short x,
252
+ short y);
253
+
254
+ LIBINPUTTINO_EXPORT void inputtino_joypad_switch_set_on_rumble(InputtinoSwitchJoypad *joypad,
255
+ InputtinoJoypadRumbleFn rumble_fn,
256
+ void *user_data);
257
+
258
+ LIBINPUTTINO_EXPORT void inputtino_joypad_switch_destroy(InputtinoSwitchJoypad *joypad);
259
+
260
+ /*
261
+ * PS5 Joypad
262
+ */
263
+
264
+ struct InputtinoPS5Joypad;
265
+ typedef struct InputtinoPS5Joypad InputtinoPS5Joypad;
266
+
267
+ LIBINPUTTINO_EXPORT InputtinoPS5Joypad *inputtino_joypad_ps5_create(const InputtinoDeviceDefinition *device,
268
+ const InputtinoErrorHandler *eh);
269
+
270
+ LIBINPUTTINO_EXPORT char **inputtino_joypad_ps5_get_nodes(InputtinoPS5Joypad *joypad, int *num_nodes);
271
+
272
+ LIBINPUTTINO_EXPORT void inputtino_joypad_ps5_set_pressed_buttons(InputtinoPS5Joypad *joypad, int newly_pressed);
273
+
274
+ LIBINPUTTINO_EXPORT void inputtino_joypad_ps5_set_triggers(InputtinoPS5Joypad *joypad, short left_trigger, short right_trigger);
275
+
276
+ LIBINPUTTINO_EXPORT void inputtino_joypad_ps5_set_stick(InputtinoPS5Joypad *joypad,
277
+ enum INPUTTINO_JOYPAD_STICK_POSITION stick_type,
278
+ short x,
279
+ short y);
280
+
281
+ LIBINPUTTINO_EXPORT void
282
+ inputtino_joypad_ps5_set_on_rumble(InputtinoPS5Joypad *joypad, InputtinoJoypadRumbleFn rumble_fn, void *user_data);
283
+
284
+ LIBINPUTTINO_EXPORT void
285
+ inputtino_joypad_ps5_place_finger(InputtinoPS5Joypad *joypad, int finger_nr, unsigned short x, unsigned short y);
286
+
287
+ LIBINPUTTINO_EXPORT void inputtino_joypad_ps5_release_finger(InputtinoPS5Joypad *joypad, int finger_nr);
288
+
289
+ enum INPUTTINO_JOYPAD_MOTION_TYPE : unsigned short {
290
+ ACCELERATION = 0x01,
291
+ GYROSCOPE = 0x02
292
+ };
293
+
294
+ LIBINPUTTINO_EXPORT void inputtino_joypad_ps5_set_motion(
295
+ InputtinoPS5Joypad *joypad, enum INPUTTINO_JOYPAD_MOTION_TYPE motion_type, float x, float y, float z);
296
+
297
+ enum BATTERY_STATE : unsigned short {
298
+ BATTERY_DISCHARGING = 0x0,
299
+ BATTERY_CHARGHING = 0x1,
300
+ BATTERY_FULL = 0x2,
301
+ VOLTAGE_OR_TEMPERATURE_OUT_OF_RANGE = 0xA,
302
+ TEMPERATURE_ERROR = 0xB,
303
+ CHARGHING_ERROR = 0xF
304
+ };
305
+
306
+ LIBINPUTTINO_EXPORT void
307
+ inputtino_joypad_ps5_set_battery(InputtinoPS5Joypad *joypad, enum BATTERY_STATE battery_state, unsigned short level);
308
+
309
+ typedef void (*InputtinoJoypadLEDFn)(int r, int g, int b, void *user_data);
310
+
311
+ LIBINPUTTINO_EXPORT void inputtino_joypad_ps5_set_on_led(InputtinoPS5Joypad *joypad, InputtinoJoypadLEDFn led_fn, void *user_data);
312
+
313
+ typedef void (*InputtinoJoypadTriggerFn)(uint8_t type_left,
314
+ uint8_t event_flags, uint8_t type_right, const uint8_t *left, const uint8_t *right, void *user_data);
315
+
316
+ LIBINPUTTINO_EXPORT void inputtino_joypad_ps5_set_on_trigger_effect(InputtinoPS5Joypad *joypad, InputtinoJoypadTriggerFn trigger_effect_fn, void *user_data);
317
+
318
+ LIBINPUTTINO_EXPORT void inputtino_joypad_ps5_destroy(InputtinoPS5Joypad *joypad);
319
+
320
+ #ifdef __cplusplus
321
+ } // extern "C"
322
+ #endif
323
+
324
+ #endif