LibGame  v0.4.0
The LG Game Engine - Copyright (C) 2024 ETMSoftware
lg_touchscreen.c File Reference

Functions

void lg_get_motion_and_shot_from_touchscreen (int sprite_x, int sprite_y, int *motion_x, int *motion_y, int zone_side, zboolean *shot)
 
void lg_wait_for_finger_down (float *x, float *y)
 
void lg_wait_for_finger_motion (float *dx, float *dy)
 
zboolean lg_get_finger_position (zboolean down_flag, float *x, float *y)
 
zboolean lg_get_finger_state_and_pos (float *x, float *y)
 
zboolean lg_get_finger_motion (float *dx, float *dy)
 
lg_finger_down_loc lg_get_finger_down_loc ()
 
lg_finger_down_loc lg_finger_loc_from_pos (float x, float y)
 
unsigned long lg_return_finger_down_code_push_back_event ()
 
void lg_flush_touchscreen_buf ()
 

Detailed Description

Touchscreen event types:

  • SDL_FINGERMOTION
  • SDL_FINGERDOWN
  • SDL_FINGERUP

Touchscreen events always happen in down/motion/up sequences

VARO: SDL y axis goes down, whereas OpenGL y axis goes up

TODO: complete the doc

Function Documentation

◆ lg_get_motion_and_shot_from_touchscreen()

void lg_get_motion_and_shot_from_touchscreen ( int  sprite_x,
int  sprite_y,
int *  motion_x,
int *  motion_y,
int  zone_side,
zboolean *  shot 
)

Touch in top-left zone = shot motion_x = 0 / +1 / -1, motion_y = 0 / +1 / -1, shot = TRUE/FALSE,

◆ lg_wait_for_finger_down()

void lg_wait_for_finger_down ( float *  x,
float *  y 
)

Wait for finger down and set x and y (location) in range [0.0f -> 1.0f] (set *x if x != NULL and set *y if y != NULL)

◆ lg_wait_for_finger_motion()

void lg_wait_for_finger_motion ( float *  dx,
float *  dy 
)

Wait for finger motion and set dx and dy in range [-1.0f -> 1.0f] (set *dx if dx != NULL and set *dy if dy != NULL)

◆ lg_get_finger_position()

zboolean lg_get_finger_position ( zboolean  down_flag,
float *  x,
float *  y 
)

Return TRUE if finger down (or finger up if down_flag = FALSE) detected, FALSE otherwise - Non-blocking If down (or up), set x and y in range [0.0f -> 1.0f] (set *x if x != NULL and set *y if y != NULL)

◆ lg_get_finger_state_and_pos()

zboolean lg_get_finger_state_and_pos ( float *  x,
float *  y 
)

If finger down happened, and no finger up has happened yet, set x and y in range [0.0f -> 1.0f], then return TRUE (set *x if x != NULL and set *y if y != NULL) - Non-blocking Return FALSE otherwise

◆ lg_get_finger_motion()

zboolean lg_get_finger_motion ( float *  dx,
float *  dy 
)

Return TRUE if finger motion detected, FALSE otherwise - Non-blocking If motion, set dx and dy in range [-1.0f -> 1.0f] (set *dx if dx != NULL and set *dy if dy != NULL)

◆ lg_get_finger_down_loc()

lg_finger_down_loc lg_get_finger_down_loc ( )

Return left, h_center, right, top, v_center, bottom, or none - Non-blocking

◆ lg_finger_loc_from_pos()

lg_finger_down_loc lg_finger_loc_from_pos ( float  x,
float  y 
)

Return left, h_center, right, top, v_center, bottom, or none

◆ lg_return_finger_down_code_push_back_event()

unsigned long lg_return_finger_down_code_push_back_event ( )

0 means no finger down - Push back event in the queue so that it can be read again

◆ lg_flush_touchscreen_buf()

void lg_flush_touchscreen_buf ( )

(self-explanatory)