-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathInput.h
More file actions
34 lines (27 loc) 路 925 Bytes
/
Copy pathInput.h
File metadata and controls
34 lines (27 loc) 路 925 Bytes
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
#pragma once
#include <Windows.h>
#include <pybind11/embed.h>
/**
* @file
* @brief pybind11 module exposing keyboard/mouse polling to user scripts as
* `SplitgateInternal.Input.*`, so a script can gate behavior on a key (uses virtual-key codes,
* e.g. 0x01 = left mouse, 0x74 = F5).
*/
namespace py = pybind11;
namespace Scripts
{
namespace Modules
{
/// Registers the `Input` submodule (held / just-pressed polling by virtual-key code).
void Input(py::module_& m)
{
auto input = m.def_submodule("Input");
input.def("is_key_down", [](int vk)
{ return (GetAsyncKeyState(vk) & 0x8000) != 0; }, py::arg("vk"),
"True while the virtual-key is held down.");
input.def("is_key_pressed", [](int vk)
{ return (GetAsyncKeyState(vk) & 1) != 0; }, py::arg("vk"),
"True once per press (the low bit is set since the last poll).");
}
} // namespace Modules
} // namespace Scripts