uwick. W
/
MameController
Mamecontroller/joystick device wrapper library
joystick.h@1:89c1c7f9245a, 2014-12-01 (annotated)
- Committer:
- uswickra
- Date:
- Mon Dec 01 21:07:44 2014 +0000
- Revision:
- 1:89c1c7f9245a
- Parent:
- 0:4babde63a16e
- Child:
- 2:018f204f6037
included gpio joystick
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
uswickra | 0:4babde63a16e | 1 | #pragma once |
uswickra | 0:4babde63a16e | 2 | #include "mbed.h" |
uswickra | 0:4babde63a16e | 3 | #include "USBSerial.h" |
uswickra | 0:4babde63a16e | 4 | #include "signals.h" |
uswickra | 0:4babde63a16e | 5 | |
uswickra | 0:4babde63a16e | 6 | extern USBKeyboard keyboard; |
uswickra | 0:4babde63a16e | 7 | extern Serial uart; |
uswickra | 0:4babde63a16e | 8 | |
uswickra | 0:4babde63a16e | 9 | /* |
uswickra | 0:4babde63a16e | 10 | *Base Joystic controller class |
uswickra | 0:4babde63a16e | 11 | */ |
uswickra | 0:4babde63a16e | 12 | class Joystick |
uswickra | 0:4babde63a16e | 13 | { |
uswickra | 0:4babde63a16e | 14 | protected: |
uswickra | 0:4babde63a16e | 15 | SignalRouter router; |
uswickra | 0:4babde63a16e | 16 | public: |
uswickra | 0:4babde63a16e | 17 | Joystick(); |
uswickra | 0:4babde63a16e | 18 | /* |
uswickra | 0:4babde63a16e | 19 | * init and start Joystick |
uswickra | 0:4babde63a16e | 20 | * |
uswickra | 0:4babde63a16e | 21 | */ |
uswickra | 0:4babde63a16e | 22 | virtual void init()=0; |
uswickra | 0:4babde63a16e | 23 | |
uswickra | 0:4babde63a16e | 24 | /* |
uswickra | 0:4babde63a16e | 25 | * Following 3 functions will be responsible for joytick menu select operations |
uswickra | 0:4babde63a16e | 26 | * These are in-game menu actions |
uswickra | 0:4babde63a16e | 27 | */ |
uswickra | 0:4babde63a16e | 28 | virtual void pressMenuSelect1()=0; |
uswickra | 0:4babde63a16e | 29 | virtual void pressMenuSelect2()=0; |
uswickra | 0:4babde63a16e | 30 | virtual void pressMenuSelect3()=0; |
uswickra | 0:4babde63a16e | 31 | |
uswickra | 0:4babde63a16e | 32 | /* |
uswickra | 0:4babde63a16e | 33 | * Following functions will be responsible for game actions |
uswickra | 0:4babde63a16e | 34 | * These are used for in-game play |
uswickra | 0:4babde63a16e | 35 | */ |
uswickra | 0:4babde63a16e | 36 | |
uswickra | 0:4babde63a16e | 37 | /* |
uswickra | 0:4babde63a16e | 38 | * This function is invoked when joytick presses Button UP |
uswickra | 0:4babde63a16e | 39 | */ |
uswickra | 0:4babde63a16e | 40 | virtual void pressUp()=0; |
uswickra | 0:4babde63a16e | 41 | |
uswickra | 0:4babde63a16e | 42 | /* |
uswickra | 0:4babde63a16e | 43 | * This function is invoked when joytick presses Button Down |
uswickra | 0:4babde63a16e | 44 | */ |
uswickra | 0:4babde63a16e | 45 | virtual void pressDown()=0; |
uswickra | 0:4babde63a16e | 46 | |
uswickra | 0:4babde63a16e | 47 | /* |
uswickra | 0:4babde63a16e | 48 | * This function is invoked when joytick presses Button LEFT |
uswickra | 0:4babde63a16e | 49 | */ |
uswickra | 0:4babde63a16e | 50 | virtual void pressLeft()=0; |
uswickra | 0:4babde63a16e | 51 | |
uswickra | 0:4babde63a16e | 52 | /* |
uswickra | 0:4babde63a16e | 53 | * This function is invoked when joytick presses Button RIGHT |
uswickra | 0:4babde63a16e | 54 | */ |
uswickra | 0:4babde63a16e | 55 | virtual void pressRight()=0; |
uswickra | 0:4babde63a16e | 56 | |
uswickra | 0:4babde63a16e | 57 | /* |
uswickra | 0:4babde63a16e | 58 | * This function is invoked when joytick presses Button JMP |
uswickra | 0:4babde63a16e | 59 | */ |
uswickra | 0:4babde63a16e | 60 | virtual void pressJump()=0; |
uswickra | 0:4babde63a16e | 61 | |
uswickra | 0:4babde63a16e | 62 | /* |
uswickra | 0:4babde63a16e | 63 | * This function is invoked when joytick presses Button1 for FIRE |
uswickra | 0:4babde63a16e | 64 | */ |
uswickra | 0:4babde63a16e | 65 | virtual void pressFire1()=0; |
uswickra | 0:4babde63a16e | 66 | |
uswickra | 0:4babde63a16e | 67 | /* |
uswickra | 0:4babde63a16e | 68 | * This function is invoked when joytick presses Button2 for FIRE |
uswickra | 0:4babde63a16e | 69 | */ |
uswickra | 0:4babde63a16e | 70 | virtual void pressFire2()=0; |
uswickra | 0:4babde63a16e | 71 | }; |
uswickra | 0:4babde63a16e | 72 | |
uswickra | 0:4babde63a16e | 73 | /* |
uswickra | 0:4babde63a16e | 74 | * Serial joystic controller class |
uswickra | 0:4babde63a16e | 75 | * This is a terminal/uart input (not actual HW input) controlled Joystick |
uswickra | 0:4babde63a16e | 76 | * used as a testbed currently |
uswickra | 0:4babde63a16e | 77 | */ |
uswickra | 0:4babde63a16e | 78 | class SerialJoystick:public Joystick{ |
uswickra | 0:4babde63a16e | 79 | public: |
uswickra | 0:4babde63a16e | 80 | SerialJoystick(); |
uswickra | 0:4babde63a16e | 81 | void init(); |
uswickra | 0:4babde63a16e | 82 | void pressMenuSelect1(); |
uswickra | 0:4babde63a16e | 83 | void pressMenuSelect2(); |
uswickra | 0:4babde63a16e | 84 | void pressMenuSelect3(); |
uswickra | 0:4babde63a16e | 85 | void pressUp(); |
uswickra | 0:4babde63a16e | 86 | void pressDown(); |
uswickra | 0:4babde63a16e | 87 | void pressLeft(); |
uswickra | 0:4babde63a16e | 88 | void pressRight(); |
uswickra | 0:4babde63a16e | 89 | void pressJump(); |
uswickra | 0:4babde63a16e | 90 | void pressFire1(); |
uswickra | 0:4babde63a16e | 91 | void pressFire2(); |
uswickra | 1:89c1c7f9245a | 92 | }; |
uswickra | 1:89c1c7f9245a | 93 | |
uswickra | 1:89c1c7f9245a | 94 | class GPIOJoystick:public Joystick{ |
uswickra | 1:89c1c7f9245a | 95 | public: |
uswickra | 1:89c1c7f9245a | 96 | GPIOJoystick(); |
uswickra | 1:89c1c7f9245a | 97 | void init(); |
uswickra | 1:89c1c7f9245a | 98 | void pressMenuSelect1(); |
uswickra | 1:89c1c7f9245a | 99 | void pressMenuSelect2(); |
uswickra | 1:89c1c7f9245a | 100 | void pressMenuSelect3(); |
uswickra | 1:89c1c7f9245a | 101 | void pressUp(); |
uswickra | 1:89c1c7f9245a | 102 | void pressDown(); |
uswickra | 1:89c1c7f9245a | 103 | void pressLeft(); |
uswickra | 1:89c1c7f9245a | 104 | void pressRight(); |
uswickra | 1:89c1c7f9245a | 105 | void pressJump(); |
uswickra | 1:89c1c7f9245a | 106 | void pressFire1(); |
uswickra | 1:89c1c7f9245a | 107 | void pressFire2(); |
uswickra | 1:89c1c7f9245a | 108 | }; |