this code provides the keyboard controlling power for various 3d games .. here it has been done for sniper elite
main.cpp@0:b5a6a85fc0d1, 2013-10-28 (annotated)
- Committer:
- rockstar
- Date:
- Mon Oct 28 11:47:58 2013 +0000
- Revision:
- 0:b5a6a85fc0d1
button wired control for sniper elite
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
rockstar | 0:b5a6a85fc0d1 | 1 | // GAMING JOYSTICK for sniper elite.... |
rockstar | 0:b5a6a85fc0d1 | 2 | //button part |
rockstar | 0:b5a6a85fc0d1 | 3 | // Submitted by- |
rockstar | 0:b5a6a85fc0d1 | 4 | // Minakshi, Vidisha, Arihant, Anshul, Manisha, Rupam, Vishal |
rockstar | 0:b5a6a85fc0d1 | 5 | // National Institute of Technology Hamirpur India |
rockstar | 0:b5a6a85fc0d1 | 6 | // this code simply send some characters which are used for the movement of player in the game |
rockstar | 0:b5a6a85fc0d1 | 7 | #include "mbed.h" |
rockstar | 0:b5a6a85fc0d1 | 8 | #include"USBKeyboard.h" // USBKeyboard library taken to send keyboard commands in our program |
rockstar | 0:b5a6a85fc0d1 | 9 | USBKeyboard mouse1; // object created of USBKeyboard library |
rockstar | 0:b5a6a85fc0d1 | 10 | DigitalIn forward(p5); // p5 pin is being declared to take analog input and named as forward |
rockstar | 0:b5a6a85fc0d1 | 11 | DigitalIn backward(p6); // used 3 more digital input at pins p6,p7,p8 |
rockstar | 0:b5a6a85fc0d1 | 12 | DigitalIn right(p7); |
rockstar | 0:b5a6a85fc0d1 | 13 | DigitalIn left(p8); |
rockstar | 0:b5a6a85fc0d1 | 14 | int main() |
rockstar | 0:b5a6a85fc0d1 | 15 | { |
rockstar | 0:b5a6a85fc0d1 | 16 | while(1) |
rockstar | 0:b5a6a85fc0d1 | 17 | { |
rockstar | 0:b5a6a85fc0d1 | 18 | if(forward) |
rockstar | 0:b5a6a85fc0d1 | 19 | { |
rockstar | 0:b5a6a85fc0d1 | 20 | mouse1.putc('w'); //if at p5 pin a high inpit is being received then pressing of 'w' will be send to computer through usb |
rockstar | 0:b5a6a85fc0d1 | 21 | // in game character w is for forward movement of player |
rockstar | 0:b5a6a85fc0d1 | 22 | } |
rockstar | 0:b5a6a85fc0d1 | 23 | if(backward) |
rockstar | 0:b5a6a85fc0d1 | 24 | { |
rockstar | 0:b5a6a85fc0d1 | 25 | mouse1.putc('s'); // here command of prssing 's' will be send |
rockstar | 0:b5a6a85fc0d1 | 26 | // s is for backward movement |
rockstar | 0:b5a6a85fc0d1 | 27 | } |
rockstar | 0:b5a6a85fc0d1 | 28 | if(left) |
rockstar | 0:b5a6a85fc0d1 | 29 | { |
rockstar | 0:b5a6a85fc0d1 | 30 | mouse1.putc('h');// here 'h' will bw send |
rockstar | 0:b5a6a85fc0d1 | 31 | // h is for shooting |
rockstar | 0:b5a6a85fc0d1 | 32 | } |
rockstar | 0:b5a6a85fc0d1 | 33 | if (right) |
rockstar | 0:b5a6a85fc0d1 | 34 | { |
rockstar | 0:b5a6a85fc0d1 | 35 | mouse1.putc('j'); //here 'j' will be send |
rockstar | 0:b5a6a85fc0d1 | 36 | // j is for snipe |
rockstar | 0:b5a6a85fc0d1 | 37 | } |
rockstar | 0:b5a6a85fc0d1 | 38 | } |
rockstar | 0:b5a6a85fc0d1 | 39 | } |