SimpleLib_03272011
Embed:
(wiki syntax)
Show/hide line numbers
WiiClassicControllerReader.h
00001 /* 00002 * WiiClassicControllerReader. A program allowing the output of one or two 00003 * Wii Classic Controllers to be read via I2C and decoded for use, using the mbed 00004 * microcontroller and its associated libraries. 00005 * 00006 * Written by Alfredo Guerrero <alfredog83@gmail.com> for the mbedGC open-source 00007 * game console <http://www.mbedgc.com>. Based on the original code for 00008 * the WiiNunchuckReader written by Petras Saduikis <petras@petras.co.uk>. 00009 * 00010 * This file is part of WiiClassicControllerReader. 00011 * 00012 * WiiClassicControllerReader is free software: you can redistribute it and/or modify 00013 * it under the terms of the GNU General Public License as published by 00014 * the Free Software Foundation, either version 3 of the License, or 00015 * (at your option) any later version. 00016 * 00017 * WiiClassicControllerReader is distributed in the hope that it will be useful, 00018 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00019 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00020 * GNU General Public License for more details. 00021 * 00022 * You can find a copy of the GNU General Public License at <http://www.gnu.org/licenses/>. 00023 */ 00024 00025 #ifndef ALFREDOG83_WIICLASSICCONTROLLERREADER_H 00026 #define ALFREDOG83_WIICLASSICCONTROLLERREADER_H 00027 00028 #include <mbed.h> 00029 #include "WiiClassicControllerDefs.h" 00030 00031 typedef unsigned char BYTE; 00032 00033 class WiiClassicControllerReader 00034 { 00035 public: 00036 // constructors 00037 WiiClassicControllerReader(PinName sda, PinName scl); 00038 00039 // functions 00040 void RequestRead(); 00041 00042 // accessors 00043 int getLJoyX() const { return ljoyX; } 00044 int getLJoyY() const { return ljoyY; } 00045 int getRJoyX() const { return rjoyX; } 00046 int getRJoyY() const { return rjoyY; } 00047 int getButtonX() const { return buttonX; } 00048 int getButtonY() const { return buttonY; } 00049 int getButtonA() const { return buttonA; } 00050 int getButtonB() const { return buttonB; } 00051 int getButtonLT() const { return buttonLT; } 00052 int getButtonRT() const { return buttonRT; } 00053 int getButtonLC() const { return buttonLC; } 00054 int getButtonRC() const { return buttonRC; } 00055 int getButtonZL() const { return buttonZL; } 00056 int getButtonZR() const { return buttonZR; } 00057 int getButtonSELECT() const { return buttonSELECT; } 00058 int getButtonHOME() const { return buttonHOME; } 00059 int getButtonSTART() const { return buttonSTART; } 00060 int getButtonDU() const { return buttonDU; } 00061 int getButtonDD() const { return buttonDD; } 00062 int getButtonDL() const { return buttonDL; } 00063 int getButtonDR() const { return buttonDR; } 00064 int getBufferSize() const { return sizeof(readBuf); } 00065 char* getReadBuf() { return readBuf; } 00066 00067 private: 00068 // classic controls states 00069 int ljoyX; 00070 int ljoyY; 00071 int rjoyX; 00072 int rjoyY; 00073 int buttonY; 00074 int buttonX; 00075 int buttonB; 00076 int buttonA; 00077 int buttonLT; 00078 int buttonRT; 00079 int buttonLC; 00080 int buttonRC; 00081 int buttonZL; 00082 int buttonZR; 00083 int buttonSELECT; 00084 int buttonHOME; 00085 int buttonSTART; 00086 int buttonDU; 00087 int buttonDD; 00088 int buttonDL; 00089 int buttonDR; 00090 00091 // classic init state 00092 bool controllerInit; 00093 00094 // classic I2C port 00095 I2C controllerPort; 00096 00097 // read data 00098 char readBuf[CONTROLLER_READLEN]; 00099 00100 // functions 00101 bool ControllerInit(); 00102 bool ControllerRead(); 00103 void ControllerDecode(); 00104 }; 00105 00106 #endif
Generated on Fri Jul 15 2022 15:25:50 by
1.7.2