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 4:82ae1b65ba05, committed 2020-01-27
- Comitter:
- eencae
- Date:
- Mon Jan 27 15:27:28 2020 +0000
- Parent:
- 3:a715415d7351
- Commit message:
- Slight change to joystick
Changed in this revision
| Gamepad2/Gamepad.cpp | Show annotated file Show diff for this revision Revisions of this file |
--- a/Gamepad2/Gamepad.cpp Mon Jan 27 12:44:47 2020 +0000
+++ b/Gamepad2/Gamepad.cpp Mon Jan 27 15:27:28 2020 +0000
@@ -281,13 +281,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;
}
@@ -301,7 +297,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;
}