- [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 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 wheel = 0;
|
||||||
static int screen_zoom = 1;
|
static int screen_zoom = 1;
|
||||||
|
|
||||||
void init(const int zoom)
|
void init(const int zoom)
|
||||||
@@ -47,51 +47,61 @@ namespace input
|
|||||||
return keypressed;
|
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;
|
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;
|
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;
|
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;
|
wheel = dy;
|
||||||
}
|
}
|
||||||
|
|
||||||
int mouseX()
|
// Torna la posició X actual del ratolí
|
||||||
|
const int mouseX()
|
||||||
{
|
{
|
||||||
int x;
|
int x;
|
||||||
SDL_GetMouseState(&x, NULL);
|
SDL_GetMouseState(&x, NULL);
|
||||||
return x/screen_zoom;
|
return x/screen_zoom;
|
||||||
}
|
}
|
||||||
|
|
||||||
int mouseY()
|
// Torna la posició Y actual del ratolí
|
||||||
|
const int mouseY()
|
||||||
{
|
{
|
||||||
int y;
|
int y;
|
||||||
SDL_GetMouseState(NULL, &y);
|
SDL_GetMouseState(NULL, &y);
|
||||||
return y/screen_zoom;
|
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));
|
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;
|
return btnClicked == btn;
|
||||||
}
|
}
|
||||||
|
|
||||||
int mouseWheel()
|
// Obté el valor actual de la rodeta del ratolí
|
||||||
|
const int mouseWheel()
|
||||||
{
|
{
|
||||||
return wheel;
|
return wheel;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -25,17 +25,49 @@ namespace input
|
|||||||
/// @return Quina tecla està sent polsada
|
/// @return Quina tecla està sent polsada
|
||||||
const uint8_t whichKey();
|
const uint8_t whichKey();
|
||||||
|
|
||||||
|
/// @brief Torna el codi de la tecla que està sent polsada ara mateix
|
||||||
|
/// @brief (nomes una vegada, com keypress)
|
||||||
|
/// @return Quina tecla està sent polsada
|
||||||
const uint8_t getKeyPressed();
|
const uint8_t getKeyPressed();
|
||||||
|
|
||||||
void updateKey(uint8_t key);
|
/// @brief (US INTERN) Actualitza la tecla actualment polsada (keydown) desde jgame
|
||||||
void updateKeypressed(uint8_t key);
|
/// @param key tecla polsada
|
||||||
void updateClk(uint8_t btn);
|
void updateKey(const uint8_t key);
|
||||||
void updateWheel(uint8_t dy);
|
|
||||||
|
|
||||||
int mouseX();
|
/// @brief (US INTERN) Actualitza la tecla actualment polsada (keypress) desde jgame
|
||||||
int mouseY();
|
/// @param key tecla polsada
|
||||||
bool mouseBtn(int btn);
|
void updateKeypressed(const uint8_t key);
|
||||||
bool mouseClk(int btn);
|
|
||||||
int mouseWheel();
|
/// @brief (US INTERN) Actualitza el botó del ratolí actualment polsat desde jgame
|
||||||
|
/// @param btn botó polsat
|
||||||
|
void updateClk(const uint8_t btn);
|
||||||
|
|
||||||
|
/// @brief (US INTERN) Actualitza el valor de la roda del ratolí actual desde jgame
|
||||||
|
/// @param dy desplaçament de la rodeta
|
||||||
|
void updateWheel(const int dy);
|
||||||
|
|
||||||
|
/// @brief Torna la posició X actual del ratolí
|
||||||
|
/// @return valor de la coordenada X del ratolí
|
||||||
|
const int mouseX();
|
||||||
|
|
||||||
|
/// @brief Torna la posició Y actual del ratolí
|
||||||
|
/// @return valor de la coordenada Y del ratolí
|
||||||
|
const int mouseY();
|
||||||
|
|
||||||
|
/// @brief Determina si el botó del ratolí especificat està sent polsada ara mateix
|
||||||
|
/// @brief (Equivalent a keydown en tecles)
|
||||||
|
/// @param btn botó a consultar
|
||||||
|
/// @return true si està polsat, false si no
|
||||||
|
const bool mouseBtn(const int btn);
|
||||||
|
|
||||||
|
/// @brief Determina si el botó especificat ha sigut polsat, pero no tornarà a ser true fins
|
||||||
|
/// @brief que no se solte el botó i se torne a polsar (Equivalent a keypress en tecles).
|
||||||
|
/// @param btn botó a consultar
|
||||||
|
/// @return true si està polsat, false si no
|
||||||
|
const bool mouseClk(const int btn);
|
||||||
|
|
||||||
|
/// @brief Obté el valor actual de la rodeta del ratolí
|
||||||
|
/// @return 0 si no es mou, positiu si roda cap amunt, negatiu si roda cap avall
|
||||||
|
const int mouseWheel();
|
||||||
|
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user