Skip to content

Commit c422bc7

Browse files
committed
Use SDL3 struct attributes for controller events
Names were changed from SDL2 and were causing crashes
1 parent e8c615a commit c422bc7

File tree

3 files changed

+11
-10
lines changed

3 files changed

+11
-10
lines changed

.vscode/settings.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -71,11 +71,8 @@
7171
"bysource",
7272
"caeldera",
7373
"CAPSLOCK",
74-
"caxis",
75-
"cbutton",
7674
"ccoef",
7775
"cdef",
78-
"cdevice",
7976
"cffi",
8077
"cflags",
8178
"CFLAGS",
@@ -169,6 +166,9 @@
169166
"fwidth",
170167
"GAMECONTROLLER",
171168
"gamepad",
169+
"gaxis",
170+
"gbutton",
171+
"gdevice",
172172
"genindex",
173173
"getbbox",
174174
"GFORCE",

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ This project adheres to [Semantic Versioning](https://semver.org/) since version
1313
### Fixed
1414

1515
- `SDL_RENDER_SCALE_QUALITY` is now respected again since the change to SDL3.
16+
- Fixed crash on controller events.
1617

1718
## [19.4.1] - 2025-08-27
1819

tcod/event.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1060,9 +1060,9 @@ def __init__(self, type: str, which: int, axis: tcod.sdl.joystick.ControllerAxis
10601060
def from_sdl_event(cls, sdl_event: Any) -> ControllerAxis:
10611061
return cls(
10621062
"CONTROLLERAXISMOTION",
1063-
sdl_event.caxis.which,
1064-
tcod.sdl.joystick.ControllerAxis(sdl_event.caxis.axis),
1065-
sdl_event.caxis.value,
1063+
sdl_event.gaxis.which,
1064+
tcod.sdl.joystick.ControllerAxis(sdl_event.gaxis.axis),
1065+
sdl_event.gaxis.value,
10661066
)
10671067

10681068
def __repr__(self) -> str:
@@ -1099,9 +1099,9 @@ def from_sdl_event(cls, sdl_event: Any) -> ControllerButton:
10991099
}[sdl_event.type]
11001100
return cls(
11011101
type,
1102-
sdl_event.cbutton.which,
1103-
tcod.sdl.joystick.ControllerButton(sdl_event.cbutton.button),
1104-
bool(sdl_event.cbutton.down),
1102+
sdl_event.gbutton.which,
1103+
tcod.sdl.joystick.ControllerButton(sdl_event.gbutton.button),
1104+
bool(sdl_event.gbutton.down),
11051105
)
11061106

11071107
def __repr__(self) -> str:
@@ -1130,7 +1130,7 @@ def from_sdl_event(cls, sdl_event: Any) -> ControllerDevice:
11301130
lib.SDL_EVENT_GAMEPAD_REMOVED: "CONTROLLERDEVICEREMOVED",
11311131
lib.SDL_EVENT_GAMEPAD_REMAPPED: "CONTROLLERDEVICEREMAPPED",
11321132
}[sdl_event.type]
1133-
return cls(type, sdl_event.cdevice.which)
1133+
return cls(type, sdl_event.gdevice.which)
11341134

11351135

11361136
@functools.cache

0 commit comments

Comments
 (0)