- [FIX] La rodeta mai tornava nombres negatius
- Completats els comentaris documentals de la unitat jinput - La unitat jinput ja es const correct
This commit is contained in:
@@ -8,7 +8,7 @@ namespace input
|
||||
static uint8_t keypressed = 0;
|
||||
static uint8_t keydown = 0;
|
||||
static uint8_t btnClicked = 0;
|
||||
static uint8_t wheel = 0;
|
||||
static int wheel = 0;
|
||||
static int screen_zoom = 1;
|
||||
|
||||
void init(const int zoom)
|
||||
@@ -47,51 +47,61 @@ namespace input
|
||||
return keypressed;
|
||||
}
|
||||
|
||||
void updateKey(uint8_t key)
|
||||
// (US INTERN) Actualitza la tecla actualment polsada (keydown) desde jgame
|
||||
void updateKey(const uint8_t key)
|
||||
{
|
||||
keydown = key;
|
||||
}
|
||||
|
||||
void updateKeypressed(uint8_t key)
|
||||
// (US INTERN) Actualitza la tecla actualment polsada (keypress) desde jgame
|
||||
void updateKeypressed(const uint8_t key)
|
||||
{
|
||||
keypressed = key;
|
||||
}
|
||||
|
||||
void updateClk(uint8_t btn)
|
||||
// (US INTERN) Actualitza el botó del ratolí actualment polsat desde jgame
|
||||
void updateClk(const uint8_t btn)
|
||||
{
|
||||
btnClicked = btn;
|
||||
}
|
||||
|
||||
void updateWheel(uint8_t dy)
|
||||
// (US INTERN) Actualitza el valor de la roda del ratolí actual desde jgame
|
||||
void updateWheel(const int dy)
|
||||
{
|
||||
wheel = dy;
|
||||
}
|
||||
|
||||
int mouseX()
|
||||
// Torna la posició X actual del ratolí
|
||||
const int mouseX()
|
||||
{
|
||||
int x;
|
||||
SDL_GetMouseState(&x, NULL);
|
||||
return x/screen_zoom;
|
||||
}
|
||||
|
||||
int mouseY()
|
||||
// Torna la posició Y actual del ratolí
|
||||
const int mouseY()
|
||||
{
|
||||
int y;
|
||||
SDL_GetMouseState(NULL, &y);
|
||||
return y/screen_zoom;
|
||||
}
|
||||
|
||||
bool mouseBtn(int btn)
|
||||
// Determina si el botó del ratolí especificat està sent polsada ara mateix
|
||||
const bool mouseBtn(const int btn)
|
||||
{
|
||||
return (SDL_GetMouseState(NULL, NULL) & SDL_BUTTON(btn));
|
||||
}
|
||||
|
||||
bool mouseClk(int btn)
|
||||
// Determina si el botó especificat ha sigut polsat, pero no tornarà a ser true fins
|
||||
// que no se solte el botó i se torne a polsar (Equivalent a keypress en tecles).
|
||||
const bool mouseClk(const int btn)
|
||||
{
|
||||
return btnClicked == btn;
|
||||
}
|
||||
|
||||
int mouseWheel()
|
||||
// Obté el valor actual de la rodeta del ratolí
|
||||
const int mouseWheel()
|
||||
{
|
||||
return wheel;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user