pub struct EventPump { /* private fields */ }
Expand description
A thread-safe type that encapsulates SDL event-pumping functions.
Implementations§
Source§impl EventPump
impl EventPump
Sourcepub fn poll_event(&mut self) -> Option<Event>
pub fn poll_event(&mut self) -> Option<Event>
Polls for currently pending events.
If no events are pending, None
is returned.
Sourcepub fn poll_iter(&mut self) -> EventPollIterator<'_> ⓘ
pub fn poll_iter(&mut self) -> EventPollIterator<'_> ⓘ
Returns a polling iterator that calls poll_event()
.
The iterator will terminate once there are no more pending events.
§Example
let sdl_context = sdl3::init().unwrap();
let mut event_pump = sdl_context.event_pump().unwrap();
for event in event_pump.poll_iter() {
use sdl3::event::Event;
match event {
Event::KeyDown {..} => { /*...*/ }
_ => ()
}
}
Sourcepub fn pump_events(&mut self)
pub fn pump_events(&mut self)
Pumps the event loop, gathering events from the input devices.
Sourcepub fn wait_event(&mut self) -> Event
pub fn wait_event(&mut self) -> Event
Waits indefinitely for the next available event.
Sourcepub fn wait_event_timeout(&mut self, timeout: u32) -> Option<Event>
pub fn wait_event_timeout(&mut self, timeout: u32) -> Option<Event>
Waits until the specified timeout (in milliseconds) for the next available event.
Sourcepub fn wait_iter(&mut self) -> EventWaitIterator<'_> ⓘ
pub fn wait_iter(&mut self) -> EventWaitIterator<'_> ⓘ
Returns a waiting iterator that calls wait_event()
.
Note: The iterator will never terminate.
Sourcepub fn wait_timeout_iter(
&mut self,
timeout: u32,
) -> EventWaitTimeoutIterator<'_> ⓘ
pub fn wait_timeout_iter( &mut self, timeout: u32, ) -> EventWaitTimeoutIterator<'_> ⓘ
Returns a waiting iterator that calls wait_event_timeout()
.
Note: The iterator will never terminate, unless waiting for an event exceeds the specified timeout.
pub fn keyboard_state(&self) -> KeyboardState<'_>
pub fn mouse_state(&self) -> MouseState
pub fn relative_mouse_state(&self) -> RelativeMouseState
Trait Implementations§
Auto Trait Implementations§
impl Freeze for EventPump
impl RefUnwindSafe for EventPump
impl !Send for EventPump
impl Sync for EventPump
impl Unpin for EventPump
impl UnwindSafe for EventPump
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more