The original snake game for the mbedgc
Dependencies: mbed EthernetNetIf HTTPClient
Fork of SimpleLib_03272011 by
mbedGC/WiiClassicControllerReader.h@0:011be8250218, 2011-04-02 (annotated)
- Committer:
- jp
- Date:
- Sat Apr 02 23:23:07 2011 +0000
- Revision:
- 0:011be8250218
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
jp | 0:011be8250218 | 1 | /* |
jp | 0:011be8250218 | 2 | * WiiClassicControllerReader. A program allowing the output of one or two |
jp | 0:011be8250218 | 3 | * Wii Classic Controllers to be read via I2C and decoded for use, using the mbed |
jp | 0:011be8250218 | 4 | * microcontroller and its associated libraries. |
jp | 0:011be8250218 | 5 | * |
jp | 0:011be8250218 | 6 | * Written by Alfredo Guerrero <alfredog83@gmail.com> for the mbedGC open-source |
jp | 0:011be8250218 | 7 | * game console <http://www.mbedgc.com>. Based on the original code for |
jp | 0:011be8250218 | 8 | * the WiiNunchuckReader written by Petras Saduikis <petras@petras.co.uk>. |
jp | 0:011be8250218 | 9 | * |
jp | 0:011be8250218 | 10 | * This file is part of WiiClassicControllerReader. |
jp | 0:011be8250218 | 11 | * |
jp | 0:011be8250218 | 12 | * WiiClassicControllerReader is free software: you can redistribute it and/or modify |
jp | 0:011be8250218 | 13 | * it under the terms of the GNU General Public License as published by |
jp | 0:011be8250218 | 14 | * the Free Software Foundation, either version 3 of the License, or |
jp | 0:011be8250218 | 15 | * (at your option) any later version. |
jp | 0:011be8250218 | 16 | * |
jp | 0:011be8250218 | 17 | * WiiClassicControllerReader is distributed in the hope that it will be useful, |
jp | 0:011be8250218 | 18 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
jp | 0:011be8250218 | 19 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
jp | 0:011be8250218 | 20 | * GNU General Public License for more details. |
jp | 0:011be8250218 | 21 | * |
jp | 0:011be8250218 | 22 | * You can find a copy of the GNU General Public License at <http://www.gnu.org/licenses/>. |
jp | 0:011be8250218 | 23 | */ |
jp | 0:011be8250218 | 24 | |
jp | 0:011be8250218 | 25 | #ifndef ALFREDOG83_WIICLASSICCONTROLLERREADER_H |
jp | 0:011be8250218 | 26 | #define ALFREDOG83_WIICLASSICCONTROLLERREADER_H |
jp | 0:011be8250218 | 27 | |
jp | 0:011be8250218 | 28 | #include <mbed.h> |
jp | 0:011be8250218 | 29 | #include "WiiClassicControllerDefs.h" |
jp | 0:011be8250218 | 30 | |
jp | 0:011be8250218 | 31 | typedef unsigned char BYTE; |
jp | 0:011be8250218 | 32 | |
jp | 0:011be8250218 | 33 | class WiiClassicControllerReader |
jp | 0:011be8250218 | 34 | { |
jp | 0:011be8250218 | 35 | public: |
jp | 0:011be8250218 | 36 | // constructors |
jp | 0:011be8250218 | 37 | WiiClassicControllerReader(PinName sda, PinName scl); |
jp | 0:011be8250218 | 38 | |
jp | 0:011be8250218 | 39 | // functions |
jp | 0:011be8250218 | 40 | void RequestRead(); |
jp | 0:011be8250218 | 41 | |
jp | 0:011be8250218 | 42 | // accessors |
jp | 0:011be8250218 | 43 | int getLJoyX() const { return ljoyX; } |
jp | 0:011be8250218 | 44 | int getLJoyY() const { return ljoyY; } |
jp | 0:011be8250218 | 45 | int getRJoyX() const { return rjoyX; } |
jp | 0:011be8250218 | 46 | int getRJoyY() const { return rjoyY; } |
jp | 0:011be8250218 | 47 | int getButtonX() const { return buttonX; } |
jp | 0:011be8250218 | 48 | int getButtonY() const { return buttonY; } |
jp | 0:011be8250218 | 49 | int getButtonA() const { return buttonA; } |
jp | 0:011be8250218 | 50 | int getButtonB() const { return buttonB; } |
jp | 0:011be8250218 | 51 | int getButtonLT() const { return buttonLT; } |
jp | 0:011be8250218 | 52 | int getButtonRT() const { return buttonRT; } |
jp | 0:011be8250218 | 53 | int getButtonLC() const { return buttonLC; } |
jp | 0:011be8250218 | 54 | int getButtonRC() const { return buttonRC; } |
jp | 0:011be8250218 | 55 | int getButtonZL() const { return buttonZL; } |
jp | 0:011be8250218 | 56 | int getButtonZR() const { return buttonZR; } |
jp | 0:011be8250218 | 57 | int getButtonSELECT() const { return buttonSELECT; } |
jp | 0:011be8250218 | 58 | int getButtonHOME() const { return buttonHOME; } |
jp | 0:011be8250218 | 59 | int getButtonSTART() const { return buttonSTART; } |
jp | 0:011be8250218 | 60 | int getButtonDU() const { return buttonDU; } |
jp | 0:011be8250218 | 61 | int getButtonDD() const { return buttonDD; } |
jp | 0:011be8250218 | 62 | int getButtonDL() const { return buttonDL; } |
jp | 0:011be8250218 | 63 | int getButtonDR() const { return buttonDR; } |
jp | 0:011be8250218 | 64 | int getBufferSize() const { return sizeof(readBuf); } |
jp | 0:011be8250218 | 65 | char* getReadBuf() { return readBuf; } |
jp | 0:011be8250218 | 66 | |
jp | 0:011be8250218 | 67 | private: |
jp | 0:011be8250218 | 68 | // classic controls states |
jp | 0:011be8250218 | 69 | int ljoyX; |
jp | 0:011be8250218 | 70 | int ljoyY; |
jp | 0:011be8250218 | 71 | int rjoyX; |
jp | 0:011be8250218 | 72 | int rjoyY; |
jp | 0:011be8250218 | 73 | int buttonY; |
jp | 0:011be8250218 | 74 | int buttonX; |
jp | 0:011be8250218 | 75 | int buttonB; |
jp | 0:011be8250218 | 76 | int buttonA; |
jp | 0:011be8250218 | 77 | int buttonLT; |
jp | 0:011be8250218 | 78 | int buttonRT; |
jp | 0:011be8250218 | 79 | int buttonLC; |
jp | 0:011be8250218 | 80 | int buttonRC; |
jp | 0:011be8250218 | 81 | int buttonZL; |
jp | 0:011be8250218 | 82 | int buttonZR; |
jp | 0:011be8250218 | 83 | int buttonSELECT; |
jp | 0:011be8250218 | 84 | int buttonHOME; |
jp | 0:011be8250218 | 85 | int buttonSTART; |
jp | 0:011be8250218 | 86 | int buttonDU; |
jp | 0:011be8250218 | 87 | int buttonDD; |
jp | 0:011be8250218 | 88 | int buttonDL; |
jp | 0:011be8250218 | 89 | int buttonDR; |
jp | 0:011be8250218 | 90 | |
jp | 0:011be8250218 | 91 | // classic init state |
jp | 0:011be8250218 | 92 | bool controllerInit; |
jp | 0:011be8250218 | 93 | |
jp | 0:011be8250218 | 94 | // classic I2C port |
jp | 0:011be8250218 | 95 | I2C controllerPort; |
jp | 0:011be8250218 | 96 | |
jp | 0:011be8250218 | 97 | // read data |
jp | 0:011be8250218 | 98 | char readBuf[CONTROLLER_READLEN]; |
jp | 0:011be8250218 | 99 | |
jp | 0:011be8250218 | 100 | // functions |
jp | 0:011be8250218 | 101 | bool ControllerInit(); |
jp | 0:011be8250218 | 102 | bool ControllerRead(); |
jp | 0:011be8250218 | 103 | void ControllerDecode(); |
jp | 0:011be8250218 | 104 | }; |
jp | 0:011be8250218 | 105 | |
jp | 0:011be8250218 | 106 | #endif |