Dependencies:   mbed

Committer:
alfredog83
Date:
Sat Feb 12 18:01:06 2011 +0000
Revision:
0:4e399a907c98

        

Who changed what in which revision?

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