pico-sdl
Loading...
Searching...
No Matches
Input

Event handling. More...

Functions

void pico_input_delay (int ms)
 Stops the program until the given number of milliseconds have passed.
void pico_input_event (Pico_Event *evt, int type)
 Stops the program until an event occurs.
int pico_input_event_ask (Pico_Event *evt, int type)
 Checks if an event has occured.
int pico_input_event_timeout (Pico_Event *evt, int type, int timeout)
 Stops the program until an event occurs or a timeout is reached.

Detailed Description

Event handling.

Function Documentation

◆ pico_input_delay()

void pico_input_delay ( int ms)

Stops the program until the given number of milliseconds have passed.

// file: delay.c
#include <pico.h>
int main() {
printf("Waiting for 2 seconds...\n");
printf("Done waiting. Exitting...\n");
return 0;
}
void pico_init(int on)
Initializes and terminates pico.
void pico_input_delay(int ms)
Stops the program until the given number of milliseconds have passed.
Parameters
msmilliseconds to wait
Examples
delay.c.

◆ pico_input_event()

void pico_input_event ( Pico_Event * evt,
int type )

Stops the program until an event occurs.

// file: event.c
#include <pico.h>
int main() {
SDL_Event event;
printf("Waiting for an event...\n");
pico_input_event(&event, 0);
printf("Event detected! Type: %d\n", event.type);
return 0;
}
void pico_input_event(Pico_Event *evt, int type)
Stops the program until an event occurs.
Parameters
evtwhere to save the event data, or NULL to ignore
typetype of event to wait for (Pico_EventType)
See also
pico_input_event_ask
pico_input_event_timeout
Examples
event.c.

◆ pico_input_event_ask()

int pico_input_event_ask ( Pico_Event * evt,
int type )

Checks if an event has occured.

Parameters
evtwhere to save the event data, or NULL to ignore
typetype of event to check the occurence (Pico_EventType)
Returns
1 if the given type of event has occurred, or 0 otherwise
See also
pico_input_event
pico_input_event_timeout

◆ pico_input_event_timeout()

int pico_input_event_timeout ( Pico_Event * evt,
int type,
int timeout )

Stops the program until an event occurs or a timeout is reached.

// file: event_timeout.c
#include <pico.h>
int main() {
SDL_Event event;
printf("Waiting for an event for the next 2 seconds...\n");
int happened = pico_input_event_timeout(&event, 0, 5000);
if (happened) {
printf("Event detected! Type: %d\n", event.type);
}
else {
printf("No event detected in those 2 seconds\n");
}
return 0;
}
int pico_input_event_timeout(Pico_Event *evt, int type, int timeout)
Stops the program until an event occurs or a timeout is reached.
Parameters
evtwhere to save the event data, or NULL to ignore
typetype of event to wait for (Pico_EventType)
timeouttime limit to wait for (milliseconds)
Returns
1 if the given type of event has occurred, or 0 otherwise
See also
pico_input_event
pico_input_event_ask
Examples
event_loop.c, and event_timeout.c.