mirror of
https://github.com/eclipse/upm.git
synced 2025-07-02 01:41:12 +03:00
This is a combination of 2 commits.
aio: mraa_aio_read (v1.0.0) can now return -1, treat that in sensors using it Adds alot of exceptions if the aio read goes wrong Signed-off-by: Brendan Le Foll <brendan.le.foll@intel.com> Signed-off-by: Noel Eck <noel.eck@intel.com>
This commit is contained in:

committed by
Noel Eck

parent
f6816797bb
commit
e51c5f3018
@ -75,6 +75,7 @@ Joystick12::~Joystick12() {
|
||||
|
||||
float Joystick12::getXInput() {
|
||||
float in = mraa_aio_read (m_joystickCtxX);
|
||||
if (in == -1.0) return -1;
|
||||
if (in < X_left) return -1;
|
||||
if (in < X_center) return -(X_center - in) / (X_center - X_left);
|
||||
if (in == X_center) return 0;
|
||||
@ -86,6 +87,7 @@ float Joystick12::getXInput() {
|
||||
|
||||
float Joystick12::getYInput() {
|
||||
float in = mraa_aio_read (m_joystickCtxY);
|
||||
if (in == -1.0) return -1;
|
||||
if (in < Y_left) return -1;
|
||||
if (in < Y_center) return -(Y_center - in) / (Y_center - Y_left);
|
||||
if (in == Y_center) return 0;
|
||||
|
Reference in New Issue
Block a user