Browse Source

python: expose application is_key_pressed() queries.

next
Vladimír Vondruš 1 year ago
parent
commit
45811bb52e
  1. 2
      doc/python/pages/changelog.rst
  2. 7
      src/python/magnum/platform/application.h

2
doc/python/pages/changelog.rst

@ -146,6 +146,8 @@ Changelog
:ref:`platform.glfw.Application.main_loop_iteration` :ref:`platform.glfw.Application.main_loop_iteration`
- Exposed :ref:`platform.sdl2.Application.cursor` and - Exposed :ref:`platform.sdl2.Application.cursor` and
:ref:`platform.sdl2.Application.warp_cursor`, same for GLFW :ref:`platform.sdl2.Application.warp_cursor`, same for GLFW
- Exposed :ref:`platform.sdl2.Application.is_key_pressed()` and
:ref:`platform.glfw.Application.is_key_pressed()`
- Exposed all :ref:`platform.sdl2.Application.Configuration.WindowFlags` and - Exposed all :ref:`platform.sdl2.Application.Configuration.WindowFlags` and
:ref:`platform.glfw.Application.Configuration.WindowFlags` :ref:`platform.glfw.Application.Configuration.WindowFlags`
- Exposed the new :ref:`text.AbstractShaper`, :ref:`text.RendererCore`, - Exposed the new :ref:`text.AbstractShaper`, :ref:`text.RendererCore`,

7
src/python/magnum/platform/application.h

@ -79,6 +79,9 @@ template<class T, class Trampoline, class Holder> void application(py::class_<T,
.def(py::init(), "Constructor"); .def(py::init(), "Constructor");
/** @todo others */ /** @todo others */
/* Is needed for is_key_pressed(), so has to be declared before */
py::enum_<typename T::Key> key{c, "Key", "Key"};
c c
/* Constructor */ /* Constructor */
.def(py::init<const typename T::Configuration&, const typename T::GLConfiguration&>(), py::arg("configuration") = typename T::Configuration{}, py::arg("gl_configuration") = typename T::GLConfiguration{}, .def(py::init<const typename T::Configuration&, const typename T::GLConfiguration&>(), py::arg("configuration") = typename T::Configuration{}, py::arg("gl_configuration") = typename T::GLConfiguration{},
@ -96,6 +99,8 @@ template<class T, class Trampoline, class Holder> void application(py::class_<T,
.def_property_readonly("window_size", &T::windowSize, "Window size") .def_property_readonly("window_size", &T::windowSize, "Window size")
.def_property_readonly("framebuffer_size", &T::framebufferSize, "Framebuffer size") .def_property_readonly("framebuffer_size", &T::framebufferSize, "Framebuffer size")
.def_property_readonly("dpi_scaling", static_cast<Vector2(T::*)() const>(&T::dpiScaling), "DPI scaling") .def_property_readonly("dpi_scaling", static_cast<Vector2(T::*)() const>(&T::dpiScaling), "DPI scaling")
/* Keyboard handling */
.def("is_key_pressed", &T::isKeyPressed, "Whether a key is pressed", py::arg("key"))
/* Mouse handling */ /* Mouse handling */
.def_property("cursor", &T::cursor, &T::setCursor, "Cursor type") .def_property("cursor", &T::cursor, &T::setCursor, "Cursor type")
.def("warp_cursor", &T::warpCursor, "Warp mouse cursor to given coordinates") .def("warp_cursor", &T::warpCursor, "Warp mouse cursor to given coordinates")
@ -120,7 +125,7 @@ template<class T, class Trampoline, class Holder> void application(py::class_<T,
.value("SUPER", T::Modifier::Super); .value("SUPER", T::Modifier::Super);
corrade::enumOperators(modifiers); corrade::enumOperators(modifiers);
py::enum_<typename T::Key>{c, "Key", "Key"} key
.value("UNKNOWN", T::Key::Unknown) .value("UNKNOWN", T::Key::Unknown)
.value("LEFT_SHIFT", T::Key::LeftShift) .value("LEFT_SHIFT", T::Key::LeftShift)
.value("RIGHT_SHIFT", T::Key::RightShift) .value("RIGHT_SHIFT", T::Key::RightShift)

Loading…
Cancel
Save