Library for ELEC2645 Gamepad PCB. University of Leeds Version 2 January 2020
Dependents: ELEC2645_Ticker_WAV ELEC2645_Project_username ELEC2645_Project_el18vgt ELEC2645_Project_el17oc11 ... more
Diff: Gamepad.cpp
- Revision:
- 23:8e1a30a69caa
- Parent:
- 22:72357412608d
--- a/Gamepad.cpp Mon Jan 27 13:58:59 2020 +0000 +++ b/Gamepad.cpp Mon Jan 27 15:26:16 2020 +0000 @@ -292,13 +292,9 @@ float x = 2.0f*( _horiz->read() - _x0 ); float y = 2.0f*( _vert->read() - _y0 ); - // Note: the x value here is inverted to ensure the positive x is to the - // right. This is simply due to how the potentiometer on the joystick - // I was using was connected up. It could have been corrected in hardware - // by swapping the power supply pins. Instead it is done in software so may - // need to be changed depending on your wiring setup + // Note: the y value here is inverted to ensure the positive y is up - Vector2D coord = {-x,y}; + Vector2D coord = {x,-y}; return coord; } @@ -312,7 +308,7 @@ float x = coord.x*sqrt(1.0f-pow(coord.y,2.0f)/2.0f); float y = coord.y*sqrt(1.0f-pow(coord.x,2.0f)/2.0f); - Vector2D mapped_coord = {-x,-y}; + Vector2D mapped_coord = {x,y}; return mapped_coord; }