- [NEW] mbtnp() added

This commit is contained in:
2023-01-27 19:50:49 +01:00
parent 5e4f0559c4
commit c335edee57
4 changed files with 19 additions and 1 deletions

View File

@@ -79,6 +79,7 @@ Uint8 key_just_pressed = 0;
int mouse_x, mouse_y, mouse_wheel;
Uint32 mouse_buttons;
uint8_t mouse_just_pressed = 0;
SDL_GameController *gamepad = NULL;
int8_t pad_just_pressed = SDL_CONTROLLER_BUTTON_INVALID;
@@ -274,6 +275,7 @@ int main(int argc,char*argv[]){
Uint32 dt=SDL_GetTicks();
key_just_pressed = 0;
pad_just_pressed = SDL_CONTROLLER_BUTTON_INVALID;
mouse_just_pressed = 0;
while(!should_exit) {
mouse_wheel = 0;
while(SDL_PollEvent(&mini_eve)) {
@@ -311,6 +313,9 @@ int main(int argc,char*argv[]){
key_just_pressed = mini_eve.key.keysym.scancode;
#endif
}
if (mini_eve.type == SDL_MOUSEBUTTONUP) {
mouse_just_pressed = mini_eve.button.button;
}
if (mini_eve.type == SDL_MOUSEWHEEL) {
mouse_wheel = mini_eve.wheel.y;
}
@@ -330,6 +335,7 @@ int main(int argc,char*argv[]){
loop();
}
key_just_pressed = 0;
mouse_just_pressed = 0;
pad_just_pressed = SDL_CONTROLLER_BUTTON_INVALID;
}
SDL_LockTexture(mini_bak, NULL, (void**)&pixels, &pitch);
@@ -929,6 +935,10 @@ bool mbtn(uint8_t i) {
return mouse_buttons & SDL_BUTTON(i);
}
bool mbtnp(uint8_t i) {
return mouse_just_pressed == i;
}
float time() {
return float(SDL_GetTicks())/1000.0f;
}