@@ -2,14 +2,16 @@ from typing import (
2
2
Any ,
3
3
Dict ,
4
4
List ,
5
+ Tuple ,
5
6
Optional ,
6
7
Union ,
7
8
Literal ,
8
9
overload ,
9
10
Type ,
10
11
)
11
12
12
- from ._common import Sequence
13
+ from pygame ._common import Sequence
14
+ from pygame .window import Window
13
15
14
16
class _EventMeta (type ): ...
15
17
@@ -24,17 +26,17 @@ class Event(metaclass=_EventMeta):
24
26
) -> None : ...
25
27
@overload
26
28
def __init__ (
27
- self , type : int , dict : Dict [str , Any ] = ..., / , ** kwargs : Any
29
+ self , dict : Dict [str , Any ] = ..., / , ** kwargs : Any
28
30
) -> None : ...
29
31
def __getattribute__ (self , name : str ) -> Any : ...
30
32
def __setattr__ (self , name : str , value : Any ) -> None : ...
31
33
def __delattr__ (self , name : str ) -> None : ...
32
34
def __bool__ (self ) -> bool : ...
33
35
34
- # TODO: fill with arguments.
35
-
36
36
class ActiveEvent (Event ):
37
37
type : Literal [32768 ] = 32768
38
+ gain : int
39
+ state : int
38
40
39
41
class AppTerminating (Event ):
40
42
type : Literal [257 ] = 257
@@ -59,9 +61,19 @@ class ClipboardUpdate(Event):
59
61
60
62
class KeyDown (Event ):
61
63
type : Literal [768 ] = 768
64
+ unicode : str
65
+ key : int
66
+ mod : int
67
+ scancode : int
68
+ window : Optional [Window ]
62
69
63
70
class KeyUp (Event ):
64
71
type : Literal [769 ] = 769
72
+ unicode : str
73
+ key : int
74
+ mod : int
75
+ scancode : int
76
+ window : Optional [Window ]
65
77
66
78
class KeyMapChanged (Event ):
67
79
type : Literal [772 ] = 772
@@ -72,36 +84,82 @@ class LocaleChanged(Event):
72
84
73
85
class MouseMotion (Event ):
74
86
type : Literal [1024 ] = 1024
87
+ pos : Tuple [int , int ]
88
+ rel : Tuple [int , int ]
89
+ buttons : tuple [int , int , int ]
90
+ touch : bool
91
+ window : Optional [Window ]
75
92
76
93
class MouseButtonDown (Event ):
77
94
type : Literal [1025 ] = 1025
95
+ pos : Tuple [int , int ]
96
+ button : int
97
+ touch : bool
98
+ window : Optional [Window ]
78
99
79
100
class MouseButtonUp (Event ):
80
101
type : Literal [1026 ] = 1026
102
+ pos : Tuple [int , int ]
103
+ button : int
104
+ touch : bool
105
+ window : Optional [Window ]
81
106
82
107
class JoyAxisMotion (Event ):
83
108
type : Literal [1536 ] = 1536
109
+ joy : int
110
+ instance_id : int
111
+ axis : int
112
+ value : float
84
113
85
114
class JoyBallMotion (Event ):
86
115
type : Literal [1537 ] = 1537
116
+ joy : int
117
+ instance_id : int
118
+ ball : int
119
+ rel : Tuple [int , int ]
87
120
88
121
class JoyHatMotion (Event ):
89
122
type : Literal [1538 ] = 1538
123
+ joy : int
124
+ instance_id : int
125
+ hat : int
126
+ value : Tuple [int , int ]
90
127
91
128
class JoyButtonUp (Event ):
92
129
type : Literal [1540 ] = 1540
130
+ joy : int
131
+ instance_id : int
132
+ button : int
93
133
94
134
class JoyButtonDown (Event ):
95
135
type : Literal [1539 ] = 1539
136
+ joy : int
137
+ instance_id : int
138
+ button : int
96
139
97
140
class Quit (Event ):
98
141
type : Literal [256 ] = 256
99
142
100
143
class SysWMEvent (Event ):
144
+ """
145
+ Attributes are OS-depended:
146
+ hwnd, msg, wparam, lparam - Windows.
147
+ event - Unix / OpenBSD
148
+ For other OSes and in some cases for Unix / OpenBSD
149
+ this event won't have any attributes.
150
+ """
101
151
type : Literal [513 ] = 513
152
+ hwnd : int
153
+ msg : int
154
+ wparam : int
155
+ lparam : int
156
+ event : bytes
102
157
103
158
class VideoResize (Event ):
104
159
type : Literal [32769 ] = 32769
160
+ size : Tuple [int , int ]
161
+ w : int
162
+ h : int
105
163
106
164
class VideoExpose (Event ):
107
165
type : Literal [32770 ] = 32770
@@ -116,83 +174,171 @@ class NoEvent(Event):
116
174
type : Literal [0 ] = 0
117
175
118
176
class FingerMotion (Event ):
177
+ """Attribute "window" avalible only for SDL 2.0.14+"""
119
178
type : Literal [1794 ] = 1794
179
+ touch_id : int
180
+ finger_id : int
181
+ x : float
182
+ y : float
183
+ dx : float
184
+ dy : float
185
+ pressure : float
186
+ window : Optional [Window ]
120
187
121
188
class FingerDown (Event ):
189
+ """Attribute "window" avalible only for SDL 2.0.14+"""
122
190
type : Literal [1792 ] = 1792
191
+ touch_id : int
192
+ finger_id : int
193
+ x : float
194
+ y : float
195
+ dx : float
196
+ dy : float
197
+ pressure : float
198
+ window : Optional [Window ]
123
199
124
200
class FingerUp (Event ):
201
+ """Attribute "window" avalible only for SDL 2.0.14+"""
125
202
type : Literal [1793 ] = 1793
203
+ touch_id : int
204
+ finger_id : int
205
+ x : float
206
+ y : float
207
+ dx : float
208
+ dy : float
209
+ pressure : float
210
+ window : Optional [Window ]
126
211
127
212
class MultiGesture (Event ):
128
213
type : Literal [2050 ] = 2050
214
+ touch_id : int
215
+ x : float
216
+ y : float
217
+ rotated : float
218
+ pinched : float
219
+ num_fingers : int
129
220
130
221
class MouseWheel (Event ):
131
222
type : Literal [1027 ] = 1027
223
+ flipped : bool
224
+ x : int
225
+ y : int
226
+ precise_x : float
227
+ precise_y : float
228
+ touch : bool
229
+ window : Optional [Window ]
132
230
133
231
class TextInput (Event ):
134
232
type : Literal [771 ] = 771
233
+ text : str
234
+ window : Optional [Window ]
135
235
136
236
class TextEditing (Event ):
137
237
type : Literal [770 ] = 770
238
+ text : str
239
+ start : int
240
+ length : int
241
+ window : Optional [Window ]
138
242
139
243
class DropFile (Event ):
140
244
type : Literal [4096 ] = 4096
245
+ file : str
246
+ window : Optional [Window ]
141
247
142
248
class DropText (Event ):
143
249
type : Literal [4097 ] = 4097
250
+ text : str
251
+ window : Optional [Window ]
144
252
145
253
class DropBegin (Event ):
146
254
type : Literal [4098 ] = 4098
255
+ window : Optional [Window ]
147
256
148
257
class DropComplete (Event ):
149
258
type : Literal [4099 ] = 4099
259
+ window : Optional [Window ]
150
260
151
261
class ControllerAxisMotion (Event ):
152
262
type : Literal [1616 ] = 1616
263
+ instance_id : int
264
+ axis : int
265
+ value : int
153
266
154
267
class ControllerButtonDown (Event ):
155
268
type : Literal [1617 ] = 1617
269
+ instance_id : int
270
+ button : int
156
271
157
272
class ControllerButtonUp (Event ):
158
273
type : Literal [1618 ] = 1618
274
+ instance_id : int
275
+ button : int
159
276
160
277
class ControllerDeviceAdded (Event ):
161
278
type : Literal [1619 ] = 1619
279
+ device_index : int
280
+ guid : str
162
281
163
282
class ControllerDeviceRemoved (Event ):
164
283
type : Literal [1620 ] = 1620
284
+ instance_id : int
165
285
166
286
class ControllerDeviceMapped (Event ):
167
287
type : Literal [1621 ] = 1621
288
+ instance_id : int
168
289
169
290
class JoyDeviceAdded (Event ):
170
291
type : Literal [1541 ] = 1541
292
+ device_index : int
293
+ guid : str
171
294
172
295
class JoyDeviceRemoved (Event ):
173
296
type : Literal [1542 ] = 1542
297
+ instance_id : int
174
298
175
299
class ControllerTouchpadDown (Event ):
176
300
"""Only for SDL 2.0.14+"""
177
301
type : Literal [1622 ] = 1622
302
+ instance_id : int
303
+ touch_id : int
304
+ finger_id : int
305
+ x : float
306
+ y : float
307
+ pressure : float
178
308
179
309
class ControllerTouchpadMotion (Event ):
180
310
"""Only for SDL 2.0.14+"""
181
311
type : Literal [1623 ] = 1623
312
+ instance_id : int
313
+ touch_id : int
314
+ finger_id : int
315
+ x : float
316
+ y : float
317
+ pressure : float
182
318
183
319
class ControllerTouchpadUp (Event ):
184
320
"""Only for SDL 2.0.14+"""
185
321
type : Literal [1624 ] = 1624
322
+ instance_id : int
323
+ touch_id : int
324
+ finger_id : int
325
+ x : float
326
+ y : float
327
+ pressure : float
186
328
187
329
class ControllerSensorUpdate (Event ):
188
330
"""Only for SDL 2.0.14+"""
189
331
type : Literal [1625 ] = 1625
190
332
191
333
class AudioDeviceAdded (Event ):
192
334
type : Literal [4352 ] = 4352
335
+ which : int
336
+ iscapture : int
193
337
194
338
class AudioDeviceRemoved (Event ):
195
339
type : Literal [4353 ] = 4353
340
+ which : int
341
+ iscapture : int
196
342
197
343
class RenderTargetsReset (Event ):
198
344
type : Literal [8192 ] = 8192
@@ -202,57 +348,82 @@ class RenderDeviceReset(Event):
202
348
203
349
class WindowShown (Event ):
204
350
type : Literal [32774 ] = 32774
351
+ window : Optional [Window ]
205
352
206
353
class WindowHidden (Event ):
207
354
type : Literal [32775 ] = 32775
355
+ window : Optional [Window ]
208
356
209
357
class WindowExposed (Event ):
210
358
type : Literal [32776 ] = 32776
359
+ window : Optional [Window ]
211
360
212
361
class WindowMoved (Event ):
213
362
type : Literal [32777 ] = 32777
363
+ x : int
364
+ y : int
365
+ window : Optional [Window ]
214
366
215
367
class WindowResized (Event ):
216
368
type : Literal [32778 ] = 32778
369
+ x : int
370
+ y : int
371
+ window : Optional [Window ]
217
372
218
373
class WindowSizeChanged (Event ):
219
374
type : Literal [32779 ] = 32779
375
+ x : int
376
+ y : int
377
+ window : Optional [Window ]
220
378
221
379
class WindowMinimized (Event ):
222
380
type : Literal [32780 ] = 32780
381
+ window : Optional [Window ]
223
382
224
383
class WindowMaximized (Event ):
225
384
type : Literal [32781 ] = 32781
385
+ window : Optional [Window ]
226
386
227
387
class WindowRestored (Event ):
228
388
type : Literal [32782 ] = 32782
389
+ window : Optional [Window ]
229
390
230
391
class WindowEnter (Event ):
231
392
type : Literal [32783 ] = 32783
393
+ window : Optional [Window ]
232
394
233
395
class WindowLeave (Event ):
234
396
type : Literal [32784 ] = 32784
397
+ window : Optional [Window ]
235
398
236
399
class WindowFocusGained (Event ):
237
400
type : Literal [32785 ] = 32785
401
+ window : Optional [Window ]
238
402
239
403
class WindowFocusLost (Event ):
240
404
type : Literal [32786 ] = 32786
405
+ window : Optional [Window ]
241
406
242
407
class WindowClose (Event ):
243
408
type : Literal [32787 ] = 32787
409
+ window : Optional [Window ]
244
410
245
411
class WindowTakeFocus (Event ):
246
412
type : Literal [32788 ] = 32788
413
+ window : Optional [Window ]
247
414
248
415
class WindowHitTest (Event ):
249
416
type : Literal [32789 ] = 32789
417
+ window : Optional [Window ]
250
418
251
419
class WindowICCProfChanged (Event ):
252
420
type : Literal [32790 ] = 32790
421
+ window : Optional [Window ]
253
422
254
423
class WindowDisplayChanged (Event ):
255
424
type : Literal [32791 ] = 32791
425
+ display_index : int
426
+ window : Optional [Window ]
256
427
257
428
_EventTypes = Union [int , Sequence [int ]]
258
429
0 commit comments