Vishal Rai / Mbed 2 deprecated mouse_wired

Dependencies:   USBDevice mbed

Revision:
0:bf6a4988f38f
diff -r 000000000000 -r bf6a4988f38f main.cpp
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Mon Oct 28 11:45:30 2013 +0000
@@ -0,0 +1,49 @@
+// GAMING JOYSTICK for sniper elite....
+//mouse part
+// Submitted by-
+//  Minakshi, Vidisha, Arihant, Anshul, Manisha, Rupam, Vishal
+// National Institute of Technology Hamirpur, India 
+// this code simply send some characters which are used for the movement of player in the game 
+#include "mbed.h"
+ #include"USBMouse.h" //USBMouse library taken to send mouse movement commands in our program
+ USBMouse mouse1(ABS_MOUSE); // object of USBMouse library
+AnalogIn inputx(p15); // analog input is taken at pin p15 from the pin 'x' of accelerometer
+AnalogIn inputy(p17); // analog input is taken at pin p16 from the pin 'y' of accelerometer
+#include <math.h>
+int main(void)
+ {
+float cal_x=0,cal_y=0;
+float x=0,y=0;
+int i=1000;
+while(i--)
+{
+cal_x=inputx*100;  // initially at the starting of mbed, values from x pin of accelerometer is stored in variable cal_x
+cal_y=inputy*100;  // values from y pin of accelerometer is stored in variable cal_y
+} 
+ // the following two lines will move the cursor to the center of the screen
+   float x_center = (X_MAX_ABS - X_MIN_ABS)/2;
+   float y_center = (Y_MAX_ABS - Y_MIN_ABS)/2;
+   float x_screen = 0;
+   float y_screen = 0;
+   x_screen = x_center;
+   y_screen = y_center;
+   while (1)
+   { 
+       x=(cal_x - inputx*100); // in program running state x is storing the difference 
+        y=(cal_y - inputy*100);
+        if(x>=5 || x< -4)
+       {
+       x=abs(x)/x;
+       x_screen -= 0.15*x;}
+       }
+       if(y>=5 || y< -4)// 5,-4 is choosen w.r.t tilting of accelerometer  
+       {
+       y=abs(y)/y;
+       y_screen -= 0.15*y;}//0.15 is choosen keeping acc. to the sensitivity of game
+       
+       }
+        mouse1.move(x_screen, y_screen); // this command moves the move accordingly
+        }
+}
+       
+       
\ No newline at end of file