- [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;
|
||||
}
|
||||
|
||||
@@ -25,17 +25,49 @@ namespace input
|
||||
/// @return Quina tecla està sent polsada
|
||||
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();
|
||||
|
||||
void updateKey(uint8_t key);
|
||||
void updateKeypressed(uint8_t key);
|
||||
void updateClk(uint8_t btn);
|
||||
void updateWheel(uint8_t dy);
|
||||
/// @brief (US INTERN) Actualitza la tecla actualment polsada (keydown) desde jgame
|
||||
/// @param key tecla polsada
|
||||
void updateKey(const uint8_t key);
|
||||
|
||||
int mouseX();
|
||||
int mouseY();
|
||||
bool mouseBtn(int btn);
|
||||
bool mouseClk(int btn);
|
||||
int mouseWheel();
|
||||
/// @brief (US INTERN) Actualitza la tecla actualment polsada (keypress) desde jgame
|
||||
/// @param key tecla polsada
|
||||
void updateKeypressed(const uint8_t key);
|
||||
|
||||
/// @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