- Mouse wheel
This commit is contained in:
@@ -39,6 +39,10 @@ int main(int argc, char *argv[])
|
|||||||
{
|
{
|
||||||
input::updateClk(e.button.button);
|
input::updateClk(e.button.button);
|
||||||
}
|
}
|
||||||
|
if (e.type==SDL_MOUSEWHEEL)
|
||||||
|
{
|
||||||
|
input::updateWheel(e.wheel.y);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (SDL_GetTicks()-current_ticks >= game::ticks_per_frame)
|
if (SDL_GetTicks()-current_ticks >= game::ticks_per_frame)
|
||||||
@@ -47,6 +51,7 @@ int main(int argc, char *argv[])
|
|||||||
input::updateKey(SDL_SCANCODE_UNKNOWN);
|
input::updateKey(SDL_SCANCODE_UNKNOWN);
|
||||||
input::updateKeypressed(SDL_SCANCODE_UNKNOWN);
|
input::updateKeypressed(SDL_SCANCODE_UNKNOWN);
|
||||||
input::updateClk(0);
|
input::updateClk(0);
|
||||||
|
input::updateWheel(0);
|
||||||
current_ticks = SDL_GetTicks();
|
current_ticks = SDL_GetTicks();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -8,6 +8,7 @@ namespace input
|
|||||||
static uint8_t keypressed = 0;
|
static uint8_t keypressed = 0;
|
||||||
static uint8_t keydown = 0;
|
static uint8_t keydown = 0;
|
||||||
static uint8_t btnClicked = 0;
|
static uint8_t btnClicked = 0;
|
||||||
|
static uint8_t wheel = 0;
|
||||||
static int screen_zoom = 1;
|
static int screen_zoom = 1;
|
||||||
|
|
||||||
void init(const int zoom)
|
void init(const int zoom)
|
||||||
@@ -55,6 +56,11 @@ namespace input
|
|||||||
btnClicked = btn;
|
btnClicked = btn;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void updateWheel(uint8_t dy)
|
||||||
|
{
|
||||||
|
wheel = dy;
|
||||||
|
}
|
||||||
|
|
||||||
int mouseX()
|
int mouseX()
|
||||||
{
|
{
|
||||||
int x;
|
int x;
|
||||||
@@ -79,4 +85,8 @@ namespace input
|
|||||||
return btnClicked == btn;
|
return btnClicked == btn;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int mouseWheel()
|
||||||
|
{
|
||||||
|
return wheel;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -28,10 +28,12 @@ namespace input
|
|||||||
void updateKey(uint8_t key);
|
void updateKey(uint8_t key);
|
||||||
void updateKeypressed(uint8_t key);
|
void updateKeypressed(uint8_t key);
|
||||||
void updateClk(uint8_t btn);
|
void updateClk(uint8_t btn);
|
||||||
|
void updateWheel(uint8_t dy);
|
||||||
|
|
||||||
int mouseX();
|
int mouseX();
|
||||||
int mouseY();
|
int mouseY();
|
||||||
bool mouseBtn(int btn);
|
bool mouseBtn(int btn);
|
||||||
bool mouseClk(int btn);
|
bool mouseClk(int btn);
|
||||||
|
int mouseWheel();
|
||||||
|
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user