2020-08-30 00:41:54 +02:00
/***************************************************************************
* Copyright ( C ) 2015 Dimok
*
* This program is free software : you can redistribute it and / or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation , either version 3 of the License , or
* ( at your option ) any later version .
*
* This program is distributed in the hope that it will be useful ,
* but WITHOUT ANY WARRANTY ; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE . See the
* GNU General Public License for more details .
*
* You should have received a copy of the GNU General Public License
* along with this program . If not , see < http : //www.gnu.org/licenses/>.
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
# pragma once
2020-08-30 12:46:49 +02:00
# include <cstdint>
2020-08-30 00:41:54 +02:00
class GuiController ;
2020-09-04 18:36:19 +02:00
//!Menu input trigger management. Determine if action is necessary based on input data by comparing controller input data to a specific trigger element.
2020-08-30 00:41:54 +02:00
class GuiTrigger {
public :
enum eClicked {
CLICKED_NONE = 0x00 ,
CLICKED_TOUCH = 0x01 ,
CLICKED_BUTTON = 0x02 ,
} ;
enum eChannels {
CHANNEL_1 = 0x01 ,
CHANNEL_2 = 0x02 ,
CHANNEL_3 = 0x04 ,
CHANNEL_4 = 0x08 ,
CHANNEL_5 = 0x10 ,
CHANNEL_ALL = 0xFF
} ;
enum eButtons {
BUTTON_NONE = 0x0000 ,
TOUCHED = 0x80000000 ,
VPAD_TOUCH = TOUCHED ,
BUTTON_Z = 0x20000 ,
BUTTON_C = 0x10000 ,
BUTTON_A = 0x8000 ,
BUTTON_B = 0x4000 ,
BUTTON_X = 0x2000 ,
BUTTON_Y = 0x1000 ,
BUTTON_1 = BUTTON_Y ,
BUTTON_2 = BUTTON_X ,
BUTTON_LEFT = 0x0800 ,
BUTTON_RIGHT = 0x0400 ,
BUTTON_UP = 0x0200 ,
BUTTON_DOWN = 0x0100 ,
BUTTON_ZL = 0x0080 ,
BUTTON_ZR = 0x0040 ,
BUTTON_L = 0x0020 ,
BUTTON_R = 0x0010 ,
BUTTON_PLUS = 0x0008 ,
BUTTON_MINUS = 0x0004 ,
BUTTON_HOME = 0x0002 ,
BUTTON_SYNC = 0x0001 ,
STICK_R_LEFT = 0x04000000 ,
STICK_R_RIGHT = 0x02000000 ,
STICK_R_UP = 0x01000000 ,
STICK_R_DOWN = 0x00800000 ,
STICK_L_LEFT = 0x40000000 ,
STICK_L_RIGHT = 0x20000000 ,
STICK_L_UP = 0x10000000 ,
STICK_L_DOWN = 0x08000000 ,
BUTTON_STICK_L = BUTTON_Z ,
BUTTON_STICK_R = BUTTON_C ,
} ;
//!Constructor
GuiTrigger ( ) ;
//!Constructor
GuiTrigger ( uint32_t ch , uint32_t btns , bool clickEverywhere = false , bool holdEverywhere = false , bool selectionClickEverywhere = false ) ;
//!Destructor
virtual ~ GuiTrigger ( ) ;
//!Sets a simple trigger. Requires: element is selected, and trigger button is pressed
void setTrigger ( uint32_t ch , uint32_t btns ) ;
void setClickEverywhere ( bool b ) {
bClickEverywhere = b ;
}
void setHoldOnly ( bool b ) {
bHoldEverywhere = b ;
}
void setSelectionClickEverywhere ( bool b ) {
bSelectionClickEverywhere = b ;
}
2020-09-04 18:36:19 +02:00
[ [ nodiscard ] ] bool isClickEverywhere ( ) const {
2020-08-30 00:41:54 +02:00
return bClickEverywhere ;
}
2020-09-04 18:36:19 +02:00
[ [ nodiscard ] ] bool isHoldEverywhere ( ) const {
2020-08-30 00:41:54 +02:00
return bHoldEverywhere ;
}
2020-09-04 18:36:19 +02:00
[ [ nodiscard ] ] bool isSelectionClickEverywhere ( ) const {
2020-08-30 00:41:54 +02:00
return bSelectionClickEverywhere ;
}
bool left ( const GuiController * controller ) const ;
bool right ( const GuiController * controller ) const ;
bool up ( const GuiController * controller ) const ;
bool down ( const GuiController * controller ) const ;
int32_t clicked ( const GuiController * controller ) const ;
bool held ( const GuiController * controller ) const ;
bool released ( const GuiController * controller ) const ;
private :
uint32_t chan ;
uint32_t btns ;
bool bClickEverywhere ;
bool bHoldEverywhere ;
bool bSelectionClickEverywhere ;
bool bLastTouched ;
} ;