this code provides the keyboard controlling power for various 3d games .. here it has been done for sniper elite

Dependencies:   USBDevice mbed

main.cpp

Committer:
rockstar
Date:
2013-10-28
Revision:
0:b5a6a85fc0d1

File content as of revision 0:b5a6a85fc0d1:

// GAMING JOYSTICK for sniper elite....
//button 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"USBKeyboard.h" // USBKeyboard library taken to send keyboard commands in our program
USBKeyboard mouse1; //   object created of USBKeyboard library
DigitalIn forward(p5); // p5 pin is being declared to take analog input and named as forward
DigitalIn backward(p6); // used 3 more digital input at pins p6,p7,p8
DigitalIn right(p7);
DigitalIn left(p8);
int main()
{
while(1)
{
if(forward)
       {
       mouse1.putc('w'); //if at p5 pin a high inpit is being received then pressing of 'w' will be send to computer through usb
       // in game character w is for forward movement of player 
       }
if(backward)
       {
       mouse1.putc('s'); // here command of prssing 's' will be send  
       // s is for backward movement
       }
if(left)
       {
       mouse1.putc('h');// here 'h' will bw send
       // h is for shooting
       }
if (right)
       {
       mouse1.putc('j'); //here 'j' will be send
       // j is for snipe
       }
}
}