Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
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 bool ControllerWriteCmd(); 00068 bool ControllerReadCmd(); 00069 void ControllerDecode(); 00070 00071 private: 00072 // classic controls states 00073 int ljoyX; 00074 int ljoyY; 00075 int rjoyX; 00076 int rjoyY; 00077 int buttonY; 00078 int buttonX; 00079 int buttonB; 00080 int buttonA; 00081 int buttonLT; 00082 int buttonRT; 00083 int buttonLC; 00084 int buttonRC; 00085 int buttonZL; 00086 int buttonZR; 00087 int buttonSELECT; 00088 int buttonHOME; 00089 int buttonSTART; 00090 int buttonDU; 00091 int buttonDD; 00092 int buttonDL; 00093 int buttonDR; 00094 00095 // classic init state 00096 bool controllerInit; 00097 00098 // classic I2C port 00099 I2C controllerPort; 00100 00101 // read data 00102 char readBuf[CONTROLLER_READLEN]; 00103 00104 // functions 00105 bool ControllerInit(); 00106 bool ControllerRead(); 00107 //void ControllerDecode(); 00108 }; 00109 00110 #endif
Generated on Tue Jul 12 2022 12:29:06 by
1.7.2