PokittoLib is the library needed for programming the Pokitto DIY game console (www.pokitto.com)
Dependents: YATTT sd_map_test cPong SnowDemo ... more
PokittoButtons.h
00001 /**************************************************************************/ 00002 /*! 00003 @file PokittoButtons.h 00004 @author Jonne Valola 00005 00006 @section LICENSE 00007 00008 Software License Agreement (BSD License) 00009 00010 Copyright (c) 2016, Jonne Valola 00011 All rights reserved. 00012 00013 Redistribution and use in source and binary forms, with or without 00014 modification, are permitted provided that the following conditions are met: 00015 1. Redistributions of source code must retain the above copyright 00016 notice, this list of conditions and the following disclaimer. 00017 2. Redistributions in binary form must reproduce the above copyright 00018 notice, this list of conditions and the following disclaimer in the 00019 documentation and/or other materials provided with the distribution. 00020 3. Neither the name of the copyright holders nor the 00021 names of its contributors may be used to endorse or promote products 00022 derived from this software without specific prior written permission. 00023 00024 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY 00025 EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 00026 WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 00027 DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE FOR ANY 00028 DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 00029 (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 00030 LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 00031 ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 00032 (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 00033 SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 00034 */ 00035 /**************************************************************************/ 00036 00037 00038 #ifndef POKITTOBUTTONS_H 00039 #define POKITTOBUTTONS_H 00040 00041 #include <stdint.h> 00042 #include "Pokitto_settings.h " 00043 #include "GBcompatibility.h" 00044 #include "PokittoGlobs.h " 00045 00046 #ifndef POK_SIM 00047 #include "HWButtons.h " 00048 #define CHWLONGPRESSTIMEOUT 100 00049 #else 00050 #include "PokittoSimulator.h" 00051 #define CHWLONGPRESSTIMEOUT 1000 00052 #endif // POK_SIM 00053 00054 00055 namespace Pokitto { 00056 00057 class Buttons { 00058 public: 00059 // Original functions 00060 static uint8_t buttons_state, buttons_held, buttons_released; 00061 static void initButtons(); 00062 static void pollButtons(); 00063 static uint8_t leftBtn(); 00064 static uint8_t rightBtn(); 00065 static uint8_t upBtn(); 00066 static uint8_t downBtn(); 00067 static uint8_t aBtn(); 00068 static uint8_t bBtn(); 00069 static uint8_t cBtn(); 00070 static uint8_t leftHeld(); 00071 static uint8_t rightHeld(); 00072 static uint8_t upHeld(); 00073 static uint8_t downHeld(); 00074 static uint8_t aHeld(); 00075 static uint8_t bHeld(); 00076 static uint8_t cHeld(); 00077 00078 static uint8_t leftReleased(); 00079 static uint8_t rightReleased(); 00080 static uint8_t upReleased(); 00081 static uint8_t downReleased(); 00082 static uint8_t aReleased(); 00083 static uint8_t bReleased(); 00084 static uint8_t cReleased(); 00085 00086 // GB compatibility functions 00087 static void begin(); 00088 static void update(); 00089 static bool pressed(uint8_t button); 00090 static bool released(uint8_t button); 00091 static bool held(uint8_t button, uint8_t time); 00092 static bool repeat(uint8_t button, uint8_t period); 00093 static uint8_t timeHeld(uint8_t button); 00094 static uint8_t pins[NUM_BTN]; 00095 static uint8_t states[NUM_BTN]; 00096 static uint8_t heldStates[NUM_BTN]; // additional, not GB based 00097 private: 00098 static uint16_t cHWLongPress; //forced hardware detection of C long press 00099 }; 00100 00101 } 00102 00103 #endif // POKITTOBUTTONS_H 00104 00105 00106 00107 00108 00109 00110
Generated on Tue Jul 12 2022 11:20:34 by 1.7.2