SimpleLib_03272011
Embed:
(wiki syntax)
Show/hide line numbers
WiiClassicControllerDefs.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_WIICLASSICCONTROLLERDEFS_H 00026 #define ALFREDOG83_WIICLASSICCONTROLLERDEFS_H 00027 00028 // I2C 00029 #define CONTROLLER_ADDR 0xA4 // I2C library doesn't right shift the address, so provided shifted 00030 #define CONTROLLER_REGADDR 0x40 // relevant register address 00031 #define CONTROLLER_READLEN 0x06 // always read this many bytes back 00032 00033 // bitmasks for individual buttons 00034 // LX, LY: left analog stick X, Y (0-63) 00035 // RX, RY: right analog stick X, Y (0-31) [RX separated among bytes 0-2] 00036 // RT, LT: right, left trigger (0-31) [LT separated among bytes 2-3] 00037 // B{ZR,ZL,A,B,X,Y,START,HOME,SELECT}: discrete buttons 00038 // BD{L,R,U,D}: D-pad direction buttons 00039 // LC,RC: digital button click of LT, RT when pressed down all the way 00040 #define MASK_LX 0x3F // LX<5:0> 00041 #define MASK_RX34 0xC0 // RX<4:3> 00042 #define MASK_LY 0x3F // LY<5:0> 00043 #define MASK_RY 0x1F // RY<4:0> 00044 #define MASK_LT34 0x60 // LT<4:3> 00045 #define MASK_RT 0x1F // RT<4:0> 00046 #define MASK_BDU 0x01 // DU 00047 #define MASK_RC_DL 0x02 // DL, RC 00048 #define MASK_BSTART_ZR 0x04 // ZR, START 00049 #define MASK_BHOME_X 0x08 // X, HOME 00050 #define MASK_BSELECT_A 0x10 // A, SELECT 00051 #define MASK_LC_Y 0x20 // LC, Y, LT<0> 00052 #define MASK_BDD_B 0x40 // B, DD, LT<1>, RX<1> 00053 #define MASK_BDR_ZL 0x80 // ZL, DR, LT<2>, RX<0>, RX<2> 00054 00055 // timing 00056 #define I2C_READ_DELAY 0.01 00057 00058 // I2C status 00059 #define I2C_OK 0 // zero on success (ACK), non-zero on fail (NACK) for read or write 00060 00061 #endif
Generated on Fri Jul 15 2022 15:25:50 by
1.7.2