* Cursor: fixed invalid returned position when cursor was pointing to anything over X or Y screen resolution/2.
This commit is contained in:
parent
4efe5ad6f9
commit
37070c559d
20
Cursor.cpp
20
Cursor.cpp
|
@ -3,6 +3,7 @@
|
||||||
* ******************************************************************/
|
* ******************************************************************/
|
||||||
|
|
||||||
#include "Cursor.h"
|
#include "Cursor.h"
|
||||||
|
#include "Camera.h"
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
|
|
||||||
/* *******************************************************************
|
/* *******************************************************************
|
||||||
|
@ -37,9 +38,10 @@
|
||||||
* \brief Constructor for Cursor class.
|
* \brief Constructor for Cursor class.
|
||||||
*
|
*
|
||||||
*********************************************************************/
|
*********************************************************************/
|
||||||
Cursor::Cursor(void) :
|
Cursor::Cursor(const Camera& c) :
|
||||||
_x(CURSOR_DEFAULT_X),
|
_x(CURSOR_DEFAULT_X),
|
||||||
_y(CURSOR_DEFAULT_Y)
|
_y(CURSOR_DEFAULT_Y),
|
||||||
|
_cam(c)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -73,6 +75,16 @@ void Cursor::move(const int8_t x, const int8_t y)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
uint8_t Cursor::getScreenX(void)
|
||||||
|
{
|
||||||
|
return _x;
|
||||||
|
}
|
||||||
|
|
||||||
|
uint8_t Cursor::getScreenY(void)
|
||||||
|
{
|
||||||
|
return _y;
|
||||||
|
}
|
||||||
|
|
||||||
/*****************************************************************//**
|
/*****************************************************************//**
|
||||||
*
|
*
|
||||||
* \brief This function simply returns cursor X position.
|
* \brief This function simply returns cursor X position.
|
||||||
|
@ -82,7 +94,7 @@ void Cursor::move(const int8_t x, const int8_t y)
|
||||||
*********************************************************************/
|
*********************************************************************/
|
||||||
uint8_t Cursor::getX(void)
|
uint8_t Cursor::getX(void)
|
||||||
{
|
{
|
||||||
return _x;
|
return _cam.getRealX(_x);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*****************************************************************//**
|
/*****************************************************************//**
|
||||||
|
@ -94,7 +106,7 @@ uint8_t Cursor::getX(void)
|
||||||
*********************************************************************/
|
*********************************************************************/
|
||||||
uint8_t Cursor::getY(void)
|
uint8_t Cursor::getY(void)
|
||||||
{
|
{
|
||||||
return _y;
|
return _cam.getRealY(_y);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*****************************************************************//**
|
/*****************************************************************//**
|
||||||
|
|
9
Cursor.h
9
Cursor.h
|
@ -5,6 +5,7 @@
|
||||||
* Includes
|
* Includes
|
||||||
* ******************************************************************/
|
* ******************************************************************/
|
||||||
|
|
||||||
|
#include "Camera.h"
|
||||||
#include <stdbool.h>
|
#include <stdbool.h>
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
|
|
||||||
|
@ -16,6 +17,9 @@
|
||||||
* Global types definition
|
* Global types definition
|
||||||
* ******************************************************************/
|
* ******************************************************************/
|
||||||
|
|
||||||
|
/* Forward declaration. */
|
||||||
|
class Camera;
|
||||||
|
|
||||||
/* *******************************************************************
|
/* *******************************************************************
|
||||||
* Global variables declaration
|
* Global variables declaration
|
||||||
* ******************************************************************/
|
* ******************************************************************/
|
||||||
|
@ -31,16 +35,19 @@
|
||||||
class Cursor
|
class Cursor
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
explicit Cursor(void);
|
explicit Cursor(const Camera& c);
|
||||||
void move(const int8_t x = 0, const int8_t y = 0);
|
void move(const int8_t x = 0, const int8_t y = 0);
|
||||||
uint8_t getX(void);
|
uint8_t getX(void);
|
||||||
uint8_t getY(void);
|
uint8_t getY(void);
|
||||||
|
uint8_t getScreenX(void);
|
||||||
|
uint8_t getScreenY(void);
|
||||||
bool isXCentered(void);
|
bool isXCentered(void);
|
||||||
bool isYCentered(void);
|
bool isYCentered(void);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
uint8_t _x;
|
uint8_t _x;
|
||||||
uint8_t _y;
|
uint8_t _y;
|
||||||
|
const Camera& _cam;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif /* CURSOR_H__ */
|
#endif /* CURSOR_H__ */
|
||||||
|
|
Loading…
Reference in New Issue