- Quatre mamonaes que he fet en el portatil

This commit is contained in:
2025-08-15 18:17:09 +02:00
parent 78a4c84db2
commit 0530c255c1
3 changed files with 28 additions and 0 deletions

View File

@@ -172,6 +172,12 @@ int main(int argc, char *argv[])
bool result = true;
if (e.type == SDL_QUIT) { zx_system::shutdown(); break; }
if (e.type == SDL_JOYDEVICEADDED) {
printf("JOYSTICK CONECTAT: %i\n", e.jdevice.which);
}
if (e.type == SDL_JOYDEVICEREMOVED) {
printf("JOYSTICK DESCONECTAT: %i\n", e.jdevice.which);
}
if (e.type == SDL_MOUSEBUTTONDOWN) result = ui::window::sendEvent(e.button.windowID, &e);
if (e.type == SDL_MOUSEBUTTONUP) result = ui::window::sendEvent(e.button.windowID, &e);
if (e.type == SDL_MOUSEMOTION) result = ui::window::sendEvent(e.motion.windowID, &e);

18
ui.cpp
View File

@@ -30,6 +30,8 @@ namespace ui
bool clicked = false;
void (*dialog)(void) = nullptr;
SDL_Texture * createtexture(SDL_Renderer *renderer)
{
SDL_Texture *texture = SDL_CreateTextureFromSurface(renderer, SDL_LoadBMP("font.bmp"));
@@ -131,4 +133,20 @@ namespace ui
return clicked;
}
void setDialog(void(*dialog)(void))
{
ui:dialog = dialog;
}
bool hasDialog()
{
return dialog != nullptr;
}
void callDialog()
{
if (dialog) dialog();
}
}

4
ui.h
View File

@@ -40,4 +40,8 @@ namespace ui
void setClicked(const bool value);
const bool getClicked();
void setDialog(void(*dialog)(void));
bool hasDialog();
void callDialog();
}