File: fastevent.py

package info (click to toggle)
pygame 2.6.1-4
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 43,076 kB
  • sloc: ansic: 66,932; python: 48,797; javascript: 1,153; objc: 224; sh: 121; makefile: 59; cpp: 25
file content (88 lines) | stat: -rw-r--r-- 1,694 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
"""
A compatibility shim for pygame.fastevent based on pygame.event.
This module was deprecated in pygame 2.2, and is scheduled for removal in a
future pygame version. If you are using pygame.fastevent, please migrate to
using regular pygame.event module
"""

import pygame.event
import pygame.display
from pygame import error, register_quit
from pygame.event import Event

_ft_init = False


def _ft_init_check():
    """
    Raises error if module is not init
    """
    if not _ft_init:
        raise error("fastevent system not initialized")


def _quit_hook():
    """
    Hook that gets run to quit module
    """
    global _ft_init
    _ft_init = False


def init():
    """init() -> None
    initialize pygame.fastevent
    """
    global _ft_init
    if not pygame.display.get_init():
        raise error("video system not initialized")

    register_quit(_quit_hook)
    _ft_init = True


def get_init():
    """get_init() -> bool
    returns True if the fastevent module is currently initialized
    """
    return _ft_init


def pump():
    """pump() -> None
    internally process pygame event handlers
    """
    _ft_init_check()
    pygame.event.pump()


def wait():
    """wait() -> Event
    wait for an event
    """
    _ft_init_check()
    return pygame.event.wait()


def poll():
    """poll() -> Event
    get an available event
    """
    _ft_init_check()
    return pygame.event.poll()


def get():
    """get() -> list of Events
    get all events from the queue
    """
    _ft_init_check()
    return pygame.event.get()


def post(event: Event):
    """post(Event) -> None
    place an event on the queue
    """
    _ft_init_check()
    pygame.event.post(event)