MXVK Vulkan Framework 0.35.0
C++20 Vulkan rendering framework for practical 2D and 3D application development with SDL3.
Loading...
Searching...
No Matches
input.py
Go to the documentation of this file.
1## @file input.py
2## @brief Joystick and game-controller convenience wrappers.
3
4from ._native import mxvk
5
6
7class Joystick:
8 ## @brief An opened SDL joystick.
9
10 def __init__(self, index: int = 0) -> None:
11 ## @brief Open joystick @p index.
13 self.native.open(index)
14
15 @classmethod
16 def count(cls) -> int:
17 ## @brief Return the number of connected joysticks.
18 return mxvk.Joystick.count()
19
20 def button(self, index: int) -> bool:
21 ## @brief Return whether button @p index is pressed.
22 return self.native.button(index)
23
24 def axis(self, index: int) -> int:
25 ## @brief Return the signed raw value for axis @p index.
26 return self.native.axis(index)
27
28 def close(self) -> None:
29 ## @brief Close the joystick handle.
30 if self.native is not None:
31 self.native.close()
32 self.native = None
33
34
36 ## @brief An opened SDL game controller.
37
38 def __init__(self, index: int = 0) -> None:
39 ## @brief Open controller @p index.
41 self.native.open(index)
42
43 @classmethod
44 def count(cls) -> int:
45 ## @brief Return the number of discoverable controllers.
46 return mxvk.Controller.count()
47
48 def button(self, button: int) -> bool:
49 ## @brief Return whether SDL gamepad @p button is pressed.
50 return self.native.button(button)
51
52 def axis(self, axis: int) -> int:
53 ## @brief Return the signed raw value for gamepad @p axis.
54 return self.native.axis(axis)
55
56 def close(self) -> None:
57 ## @brief Close the controller handle.
58 if self.native is not None:
59 self.native.close()
60 self.native = None
RAII wrapper for SDL_Gamepad (standard layout mapping).
RAII wrapper for a raw SDL_Joystick device.
bool button(self, int button)
Definition input.py:48
None __init__(self, int index=0)
An opened SDL game controller.
Definition input.py:38
native
Open controller index.
Definition input.py:40
int axis(self, int axis)
Definition input.py:52
None __init__(self, int index=0)
An opened SDL joystick.
Definition input.py:10
native
Open joystick index.
Definition input.py:12
bool button(self, int index)
Definition input.py:20
int axis(self, int index)
Definition input.py:24