Skip to content

Commit dd48270

Browse files
authored
Merge pull request #3300 from pygame-community/ankith26-sdl2-stubs
Fix/improve _sdl2 stubs
2 parents 565cae6 + c28a07b commit dd48270

File tree

4 files changed

+12
-11
lines changed

4 files changed

+12
-11
lines changed

buildconfig/stubs/pygame/_sdl2/controller.pyi

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,9 @@ class Controller:
2323
def as_joystick(self) -> JoystickType: ...
2424
def get_axis(self, axis: int) -> int: ...
2525
def get_button(self, button: int) -> bool: ...
26-
def get_mapping(self) -> dict: ...
27-
def set_mapping(self, mapping: dict) -> int: ...
28-
def rumble(self, ___) -> bool: ...
29-
def stop_rumble(
26+
def get_mapping(self) -> dict[str, str]: ...
27+
def set_mapping(self, mapping: dict[str, str]) -> int: ...
28+
def rumble(
3029
self, low_frequency: float, high_frequency: float, duration: int
3130
) -> bool: ...
31+
def stop_rumble(self) -> None: ...
Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
from typing import Union
1+
from typing import Union, Optional
22

33
def get_num_devices() -> int: ...
4-
def get_device(index: int) -> int: ...
5-
def get_num_fingers(device_id: int) -> int: ...
6-
def get_finger(touchid: int, index: int) -> dict[str, Union[int, float]]: ...
4+
def get_device(index: int, /) -> int: ...
5+
def get_num_fingers(device_id: int, /) -> int: ...
6+
def get_finger(touchid: int, index: int) -> Optional[dict[str, Union[int, float]]]: ...

docs/reST/ref/touch.rst

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,14 +44,15 @@
4444
.. function:: get_finger
4545

4646
| :sl:`get information about an active finger`
47-
| :sg:`get_finger(touchid, index) -> int`
47+
| :sg:`get_finger(touchid, index) -> dict | None`
4848
4949
:param int touchid: The touch device id.
5050
:param int index: The index of the finger to return
5151
information about, between 0 and the
5252
:func:`number of active fingers <pygame._sdl2.touch.get_num_fingers()>`.
5353

54-
Return a dict for the finger ``index`` active on ``touchid``.
54+
Return a dict for the finger ``index`` active on ``touchid``, or ``None`` if the
55+
object does not exist.
5556
The dict contains these keys:
5657

5758
::

src_c/doc/touch_doc.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,4 @@
33
#define DOC_SDL2_TOUCH_GETNUMDEVICES "get_num_devices() -> int\nget the number of touch devices"
44
#define DOC_SDL2_TOUCH_GETDEVICE "get_device(index) -> touchid\nget the a touch device id for a given index"
55
#define DOC_SDL2_TOUCH_GETNUMFINGERS "get_num_fingers(touchid) -> int\nthe number of active fingers for a given touch device"
6-
#define DOC_SDL2_TOUCH_GETFINGER "get_finger(touchid, index) -> int\nget information about an active finger"
6+
#define DOC_SDL2_TOUCH_GETFINGER "get_finger(touchid, index) -> dict | None\nget information about an active finger"

0 commit comments

Comments
 (0)