Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Revision 23:8e1a30a69caa, committed 2020-01-27
- Comitter:
- eencae
- Date:
- Mon Jan 27 15:26:16 2020 +0000
- Parent:
- 22:72357412608d
- Child:
- 24:33639c2eacb3
- Commit message:
- Fixed joystick orientation.
Changed in this revision
| Gamepad.cpp | Show annotated file Show diff for this revision Revisions of this file |
--- 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;
}