2017-10-29 10:28:14 +01: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/>.
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
# ifndef GUI_TRIGGER_H_
# define GUI_TRIGGER_H_
2020-08-13 13:07:16 +02:00
# include <stdint.h>
2020-08-13 13:07:31 +02:00
class GuiController ;
2017-10-29 10:28:14 +01:00
//!Menu input trigger management. Determine if action is neccessary based on input data by comparing controller input data to a specific trigger element.
2018-06-21 20:44:58 +02:00
class GuiTrigger {
2017-10-29 10:28:14 +01:00
public :
2018-06-21 20:44:58 +02:00
enum eClicked {
2017-10-29 10:28:14 +01:00
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 ,
VPAD_TOUCH = 0x80000000 ,
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
} ;
//!Constructor
GuiTrigger ( ) ;
2020-08-13 12:38:07 +02:00
2017-10-29 10:28:14 +01:00
//!Constructor
2018-06-21 20:44:58 +02:00
GuiTrigger ( uint32_t ch , uint32_t btns , bool clickEverywhere = false , bool holdEverywhere = false , bool selectionClickEverywhere = false ) ;
2020-08-13 12:38:07 +02:00
2017-10-29 10:28:14 +01:00
//!Destructor
virtual ~ GuiTrigger ( ) ;
2020-08-13 12:38:07 +02:00
2017-10-29 10:28:14 +01:00
//!Sets a simple trigger. Requires: element is selected, and trigger button is pressed
2018-06-21 20:44:58 +02:00
void setTrigger ( uint32_t ch , uint32_t btns ) ;
2017-10-29 10:28:14 +01:00
2018-06-21 20:44:58 +02:00
void setClickEverywhere ( bool b ) {
bClickEverywhere = b ;
}
2020-08-13 12:38:07 +02:00
2018-06-21 20:44:58 +02:00
void setHoldOnly ( bool b ) {
bHoldEverywhere = b ;
}
2020-08-13 12:38:07 +02:00
2018-06-21 20:44:58 +02:00
void setSelectionClickEverywhere ( bool b ) {
bSelectionClickEverywhere = b ;
}
2017-10-29 10:28:14 +01:00
2018-06-21 20:44:58 +02:00
bool isClickEverywhere ( ) const {
return bClickEverywhere ;
}
2020-08-13 12:38:07 +02:00
2018-06-21 20:44:58 +02:00
bool isHoldEverywhere ( ) const {
return bHoldEverywhere ;
}
2020-08-13 12:38:07 +02:00
2018-06-21 20:44:58 +02:00
bool isSelectionClickEverywhere ( ) const {
return bSelectionClickEverywhere ;
}
2017-10-29 10:28:14 +01:00
bool left ( const GuiController * controller ) const ;
2020-08-13 12:38:07 +02:00
2017-10-29 10:28:14 +01:00
bool right ( const GuiController * controller ) const ;
2020-08-13 12:38:07 +02:00
2017-10-29 10:28:14 +01:00
bool up ( const GuiController * controller ) const ;
2020-08-13 12:38:07 +02:00
2017-10-29 10:28:14 +01:00
bool down ( const GuiController * controller ) const ;
2020-08-13 12:38:07 +02:00
2018-06-21 20:44:58 +02:00
int32_t clicked ( const GuiController * controller ) const ;
2020-08-13 12:38:07 +02:00
2017-10-29 10:28:14 +01:00
bool held ( const GuiController * controller ) const ;
2020-08-13 12:38:07 +02:00
2017-10-29 10:28:14 +01:00
bool released ( const GuiController * controller ) const ;
2020-08-13 12:38:07 +02:00
2017-10-29 10:28:14 +01:00
private :
2018-06-21 20:44:58 +02:00
uint32_t chan ;
uint32_t btns ;
2017-10-29 10:28:14 +01:00
bool bClickEverywhere ;
bool bHoldEverywhere ;
bool bSelectionClickEverywhere ;
bool bLastTouched ;
} ;
# endif