- [NEW] mouse.discard()

This commit is contained in:
2025-06-20 13:49:59 +02:00
parent f154e1a36b
commit 7bff57c6fa
4 changed files with 20 additions and 1 deletions

View File

@@ -103,6 +103,7 @@ Uint8 key_just_pressed = 0;
int mouse_x, mouse_y, mouse_wheel;
Uint32 mouse_buttons;
uint8_t mouse_just_pressed = 0;
bool mouse_discard = false;
SDL_Gamepad *gamepad = NULL;
int8_t pad_just_pressed = SDL_GAMEPAD_BUTTON_INVALID;
@@ -484,7 +485,10 @@ int main(int argc,char*argv[]){
#endif
}
if (mini_eve.type == SDL_EVENT_MOUSE_BUTTON_UP) {
mouse_just_pressed = mini_eve.button.button;
if (mouse_discard)
mouse_discard = false;
else
mouse_just_pressed = mini_eve.button.button;
}
if (mini_eve.type == SDL_EVENT_MOUSE_WHEEL) {
mouse_wheel = mini_eve.wheel.y;
@@ -1188,6 +1192,7 @@ int mwheel() {
}
bool mbtn(uint8_t i) {
if (mouse_discard) return false;
return mouse_buttons & SDL_BUTTON_MASK(i);
}
@@ -1195,6 +1200,10 @@ bool mbtnp(uint8_t i) {
return mouse_just_pressed == i;
}
void mdiscard() {
mouse_discard = true;
}
float time() {
return float(SDL_GetTicks())/1000.0f;
}