Renamed to program to Doom_Controller.
Dependencies: DebounceIn USBDevice mbed
Fork of BNO055_reader by
Revision 2:e585627bae99, committed 2015-09-20
- Comitter:
- simonscott
- Date:
- Sun Sep 20 01:37:50 2015 +0000
- Parent:
- 1:38cd433ff221
- Commit message:
- Added a couple more comments. No actual code changes.
Changed in this revision
main.cpp | Show annotated file Show diff for this revision Revisions of this file |
--- a/main.cpp Sun Sep 20 00:58:37 2015 +0000 +++ b/main.cpp Sun Sep 20 01:37:50 2015 +0000 @@ -1,3 +1,8 @@ +/** + * A "gun" game controller for playing first-person shooters like Doom II. + * Written by Ben, Inez and Simon for IDD 2015. + */ + #include "mbed.h" #include "USBMouseKeyboard.h" #include "DebounceIn.h" @@ -126,7 +131,7 @@ if(sys_error == 0 && sys_stat == 5) return true; else { - //pc.printf("SYS_ERR: %d SYS_STAT: %d\r\n", sys_error, sys_stat); + pc.printf("SYS_ERR: %d SYS_STAT: %d\r\n", sys_error, sys_stat); return false; } } @@ -241,6 +246,10 @@ if(e.pitch > 90 || e.pitch < -90) e.pitch = 0; + // Occassionally the heading goes into 180..360 degrees, need to wrap around + if(e.heading > 180) + e.heading = e.heading - 360;; + return e; } @@ -342,7 +351,8 @@ redLED = 1; greenLED = 0; } - + wait(0.001); + // If trigger state changed if (!trigger.read() != triggerPressed) { @@ -397,7 +407,8 @@ key_mouse.sendNB(&kbHIDReport); } - // move limits + // Limit how much we can move the mouse + // No motion beyond 90 degrees, deadband between -2 and +2 degrees, and parabolic beyond 20 degrees. float heading_limited; if(e.heading > 90) heading_limited = 90;