mirror of
https://github.com/Maschell/libgui-sdl.git
synced 2024-11-16 13:09:20 +01:00
30 lines
828 B
C++
30 lines
828 B
C++
#pragma once
|
|
|
|
class SDLControllerMouse: public SDLController {
|
|
public:
|
|
explicit SDLControllerMouse(int32_t channel) : SDLController(channel) {
|
|
|
|
}
|
|
|
|
void before() override{
|
|
SDLController::before();
|
|
data.validPointer = true;
|
|
}
|
|
|
|
virtual bool update(SDL_Event *e, int32_t screenWidth, int32_t screenHeight) override {
|
|
if (e->type == SDL_MOUSEMOTION) {
|
|
data.y = e->motion.y;
|
|
data.x = e->motion.x;
|
|
} else if (e->type == SDL_MOUSEBUTTONDOWN && e->button.button == SDL_BUTTON_LEFT) {
|
|
data.touched = true;
|
|
} else if (e->type == SDL_MOUSEBUTTONUP && e->button.button == SDL_BUTTON_LEFT) {
|
|
data.touched = false;
|
|
}else{
|
|
LG_Log("Unknown event");
|
|
return false;
|
|
}
|
|
return true;
|
|
}
|
|
};
|
|
|