|
|
@ -259,10 +259,20 @@ Menu *findMenu(const char *name);
|
|
|
|
X(pgupjustdown, rsPGUP) \
|
|
|
|
X(pgupjustdown, rsPGUP) \
|
|
|
|
X(pgdnjustdown, rsPGDN)
|
|
|
|
X(pgdnjustdown, rsPGDN)
|
|
|
|
|
|
|
|
|
|
|
|
#define MUHBUTTONS \
|
|
|
|
#define MUHMOUSEBUTTONS \
|
|
|
|
X(button1justdown, 1) \
|
|
|
|
X(mbutton1justdown, 1) \
|
|
|
|
X(button2justdown, 2) \
|
|
|
|
X(mbutton2justdown, 2) \
|
|
|
|
X(button3justdown, 3)
|
|
|
|
X(mbutton3justdown, 3)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#define MUHGAMEPAD \
|
|
|
|
|
|
|
|
X(crossjustdown, 1) \
|
|
|
|
|
|
|
|
X(circlejustdown, 2) \
|
|
|
|
|
|
|
|
X(trianglejustdown, 3) \
|
|
|
|
|
|
|
|
X(squarejustdown, 4) \
|
|
|
|
|
|
|
|
X(padleftjustdown, 5) \
|
|
|
|
|
|
|
|
X(padrightjustdown, 6) \
|
|
|
|
|
|
|
|
X(padupjustdown, 7) \
|
|
|
|
|
|
|
|
X(paddownjustdown, 8)
|
|
|
|
|
|
|
|
|
|
|
|
#define REPEATDELAY 700
|
|
|
|
#define REPEATDELAY 700
|
|
|
|
#define REPEATINTERVAL 50
|
|
|
|
#define REPEATINTERVAL 50
|
|
|
@ -274,12 +284,18 @@ static int repeattime;
|
|
|
|
static int lastkeydown;
|
|
|
|
static int lastkeydown;
|
|
|
|
static int *keyptr;
|
|
|
|
static int *keyptr;
|
|
|
|
|
|
|
|
|
|
|
|
static int buttondown[3];
|
|
|
|
static int mbuttondown[3];
|
|
|
|
static int lastbuttondown;
|
|
|
|
static int lastmbuttondown;
|
|
|
|
static int *buttonptr;
|
|
|
|
static int *mbuttonptr;
|
|
|
|
static int button1justdown, button2justdown, button3justdown;
|
|
|
|
static int mbutton1justdown, mbutton2justdown, mbutton3justdown;
|
|
|
|
static float mouseX, mouseY;
|
|
|
|
static float mouseX, mouseY;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
static bool padbuttondown[8];
|
|
|
|
|
|
|
|
static int lastpadbuttondown;
|
|
|
|
|
|
|
|
static bool *padbuttonptr;
|
|
|
|
|
|
|
|
static bool padleftjustdown, padrightjustdown, padupjustdown, paddownjustdown;
|
|
|
|
|
|
|
|
static bool crossjustdown, circlejustdown, trianglejustdown, squarejustdown;
|
|
|
|
|
|
|
|
|
|
|
|
static int menuOn;
|
|
|
|
static int menuOn;
|
|
|
|
static int menuInitialized;
|
|
|
|
static int menuInitialized;
|
|
|
|
static int screenWidth, screenHeight;
|
|
|
|
static int screenWidth, screenHeight;
|
|
|
@ -378,12 +394,12 @@ MenuEntry_##NAME::processInput(bool mouseOver, bool selected) \
|
|
|
|
v = *this->variable; \
|
|
|
|
v = *this->variable; \
|
|
|
|
oldv = v; \
|
|
|
|
oldv = v; \
|
|
|
|
\
|
|
|
|
\
|
|
|
|
if((selected && leftjustdown) || (mouseOver && button3justdown)){ \
|
|
|
|
if((selected && leftjustdown) || (selected && ( squarejustdown || padleftjustdown )) || (mouseOver && mbutton3justdown)){ \
|
|
|
|
v -= this->step; \
|
|
|
|
v -= this->step; \
|
|
|
|
if(v > oldv) \
|
|
|
|
if(v > oldv) \
|
|
|
|
underflow = 1; \
|
|
|
|
underflow = 1; \
|
|
|
|
} \
|
|
|
|
} \
|
|
|
|
if((selected && rightjustdown) || (mouseOver && button1justdown)){ \
|
|
|
|
if((selected && rightjustdown) || (selected && ( crossjustdown || padrightjustdown )) || (mouseOver && mbutton1justdown)){ \
|
|
|
|
v += this->step; \
|
|
|
|
v += this->step; \
|
|
|
|
if(v < oldv) \
|
|
|
|
if(v < oldv) \
|
|
|
|
overflow = 1; \
|
|
|
|
overflow = 1; \
|
|
|
@ -469,12 +485,12 @@ MenuEntry_##NAME::processInput(bool mouseOver, bool selected) \
|
|
|
|
v = *this->variable; \
|
|
|
|
v = *this->variable; \
|
|
|
|
oldv = v; \
|
|
|
|
oldv = v; \
|
|
|
|
\
|
|
|
|
\
|
|
|
|
if((selected && leftjustdown) || (mouseOver && button3justdown)){ \
|
|
|
|
if((selected && leftjustdown) || (selected && ( squarejustdown || padleftjustdown )) || (mouseOver && mbutton3justdown)){ \
|
|
|
|
v -= this->step; \
|
|
|
|
v -= this->step; \
|
|
|
|
if(v > oldv) \
|
|
|
|
if(v > oldv) \
|
|
|
|
underflow = 1; \
|
|
|
|
underflow = 1; \
|
|
|
|
} \
|
|
|
|
} \
|
|
|
|
if((selected && rightjustdown) || (mouseOver && button1justdown)){ \
|
|
|
|
if((selected && rightjustdown) || (selected && (crossjustdown || padrightjustdown )) || (mouseOver && mbutton1justdown)){ \
|
|
|
|
v += this->step; \
|
|
|
|
v += this->step; \
|
|
|
|
if(v < oldv) \
|
|
|
|
if(v < oldv) \
|
|
|
|
overflow = 1; \
|
|
|
|
overflow = 1; \
|
|
|
@ -505,7 +521,7 @@ void
|
|
|
|
MenuEntry_Cmd::processInput(bool mouseOver, bool selected)
|
|
|
|
MenuEntry_Cmd::processInput(bool mouseOver, bool selected)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
// Don't execute on button3
|
|
|
|
// Don't execute on button3
|
|
|
|
if(this->triggerFunc && (selected && (leftjustdown || rightjustdown) || (mouseOver && button1justdown)))
|
|
|
|
if(this->triggerFunc && (selected && (leftjustdown || rightjustdown || padleftjustdown || padrightjustdown || crossjustdown) || (mouseOver && mbutton1justdown)))
|
|
|
|
this->triggerFunc();
|
|
|
|
this->triggerFunc();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -867,22 +883,45 @@ processInput(void)
|
|
|
|
#define X(var, num) \
|
|
|
|
#define X(var, num) \
|
|
|
|
if(var){ \
|
|
|
|
if(var){ \
|
|
|
|
repeattime = downtime = CTimer::GetTimeInMilliseconds(); \
|
|
|
|
repeattime = downtime = CTimer::GetTimeInMilliseconds(); \
|
|
|
|
lastbuttondown = num; \
|
|
|
|
lastmbuttondown = num; \
|
|
|
|
buttonptr = &var; \
|
|
|
|
mbuttonptr = &var; \
|
|
|
|
}
|
|
|
|
}
|
|
|
|
MUHBUTTONS
|
|
|
|
MUHMOUSEBUTTONS
|
|
|
|
#undef X
|
|
|
|
#undef X
|
|
|
|
if(lastbuttondown){
|
|
|
|
if(lastmbuttondown){
|
|
|
|
if(buttondown[lastbuttondown-1]){
|
|
|
|
if(mbuttondown[lastmbuttondown-1]){
|
|
|
|
int curtime = CTimer::GetTimeInMilliseconds();
|
|
|
|
int curtime = CTimer::GetTimeInMilliseconds();
|
|
|
|
if(curtime - downtime > REPEATDELAY){
|
|
|
|
if(curtime - downtime > REPEATDELAY){
|
|
|
|
if(curtime - repeattime > REPEATINTERVAL){
|
|
|
|
if(curtime - repeattime > REPEATINTERVAL){
|
|
|
|
repeattime = curtime;
|
|
|
|
repeattime = curtime;
|
|
|
|
*buttonptr = 1;
|
|
|
|
*mbuttonptr = 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}else{
|
|
|
|
}else{
|
|
|
|
lastbuttondown = 0;
|
|
|
|
lastmbuttondown = 0;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Also for gampepad buttons
|
|
|
|
|
|
|
|
#define X(var, btnnum) \
|
|
|
|
|
|
|
|
if(var){ \
|
|
|
|
|
|
|
|
repeattime = downtime = CTimer::GetTimeInMilliseconds(); \
|
|
|
|
|
|
|
|
lastpadbuttondown = btnnum; \
|
|
|
|
|
|
|
|
padbuttonptr = &var; \
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
MUHGAMEPAD
|
|
|
|
|
|
|
|
#undef X
|
|
|
|
|
|
|
|
if(lastpadbuttondown){
|
|
|
|
|
|
|
|
if(padbuttondown[lastpadbuttondown-1]){
|
|
|
|
|
|
|
|
int curtime = CTimer::GetTimeInMilliseconds();
|
|
|
|
|
|
|
|
if(curtime - downtime > REPEATDELAY){
|
|
|
|
|
|
|
|
if(curtime - repeattime > REPEATINTERVAL){
|
|
|
|
|
|
|
|
repeattime = curtime;
|
|
|
|
|
|
|
|
*padbuttonptr = 1;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}else{
|
|
|
|
|
|
|
|
lastpadbuttondown = 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -930,9 +969,9 @@ processInput(void)
|
|
|
|
activeMenu->scroll(shift ? -5 : -1);
|
|
|
|
activeMenu->scroll(shift ? -5 : -1);
|
|
|
|
if(pgdnjustdown)
|
|
|
|
if(pgdnjustdown)
|
|
|
|
activeMenu->scroll(shift ? 5 : 1);
|
|
|
|
activeMenu->scroll(shift ? 5 : 1);
|
|
|
|
if(downjustdown)
|
|
|
|
if(downjustdown || paddownjustdown)
|
|
|
|
activeMenu->changeSelection(activeMenu->selection + (shift ? 5 : 1));
|
|
|
|
activeMenu->changeSelection(activeMenu->selection + (shift ? 5 : 1));
|
|
|
|
if(upjustdown)
|
|
|
|
if(upjustdown || padupjustdown)
|
|
|
|
activeMenu->changeSelection(activeMenu->selection - (shift ? 5 : 1));
|
|
|
|
activeMenu->changeSelection(activeMenu->selection - (shift ? 5 : 1));
|
|
|
|
|
|
|
|
|
|
|
|
if(CPad::NewMouseControllerState.WHEELUP){
|
|
|
|
if(CPad::NewMouseControllerState.WHEELUP){
|
|
|
@ -947,27 +986,29 @@ processInput(void)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if(mouseOverEntry == &scrollUpEntry){
|
|
|
|
if(mouseOverEntry == &scrollUpEntry){
|
|
|
|
if(button1justdown){
|
|
|
|
if(mbutton1justdown){
|
|
|
|
activeMenu = mouseOverEntry->menu;
|
|
|
|
activeMenu = mouseOverEntry->menu;
|
|
|
|
activeMenu->scroll(shift ? -5 : -1);
|
|
|
|
activeMenu->scroll(shift ? -5 : -1);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if(mouseOverEntry == &scrollDownEntry){
|
|
|
|
if(mouseOverEntry == &scrollDownEntry){
|
|
|
|
if(button1justdown){
|
|
|
|
if(mbutton1justdown){
|
|
|
|
activeMenu = mouseOverEntry->menu;
|
|
|
|
activeMenu = mouseOverEntry->menu;
|
|
|
|
activeMenu->scroll(shift ? 5 : 1);
|
|
|
|
activeMenu->scroll(shift ? 5 : 1);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// Have to call this before processInput below because menu entry can change
|
|
|
|
// Have to call this before processInput below because menu entry can change
|
|
|
|
if((button1justdown || button3justdown) && mouseOverEntry){
|
|
|
|
if((mbutton1justdown || mbutton3justdown) && mouseOverEntry){
|
|
|
|
activeMenu = mouseOverEntry->menu;
|
|
|
|
activeMenu = mouseOverEntry->menu;
|
|
|
|
activeMenu->changeSelection(mouseOverEntry);
|
|
|
|
activeMenu->changeSelection(mouseOverEntry);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if(KEYJUSTDOWN(rsENTER)){
|
|
|
|
if(KEYJUSTDOWN(rsENTER) || ( crossjustdown && activeMenu->selectedEntry->type == MENUSUB )){
|
|
|
|
if(activeMenu->selectedEntry && activeMenu->selectedEntry->type == MENUSUB)
|
|
|
|
if(activeMenu->selectedEntry && activeMenu->selectedEntry->type == MENUSUB)
|
|
|
|
activeMenu = ((MenuEntry_Sub*)activeMenu->selectedEntry)->submenu;
|
|
|
|
activeMenu = ((MenuEntry_Sub*)activeMenu->selectedEntry)->submenu;
|
|
|
|
}else if(KEYJUSTDOWN(rsBACKSP)){
|
|
|
|
}else if( circlejustdown && activeMenu->selectedEntry->type == MENUSUB ){
|
|
|
|
|
|
|
|
menuOn = !menuOn;
|
|
|
|
|
|
|
|
}else if(KEYJUSTDOWN(rsBACKSP) || circlejustdown){
|
|
|
|
if(activeMenu->parent)
|
|
|
|
if(activeMenu->parent)
|
|
|
|
activeMenu = activeMenu->parent;
|
|
|
|
activeMenu = activeMenu->parent;
|
|
|
|
}else{
|
|
|
|
}else{
|
|
|
@ -980,7 +1021,7 @@ processInput(void)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
void
|
|
|
|
updateMouse(void)
|
|
|
|
updatePad(void)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
CPad *pad = CPad::GetPad(0);
|
|
|
|
CPad *pad = CPad::GetPad(0);
|
|
|
|
int dirX = 1;
|
|
|
|
int dirX = 1;
|
|
|
@ -997,25 +1038,45 @@ updateMouse(void)
|
|
|
|
if(mouseX >= screenWidth) mouseX = screenWidth;
|
|
|
|
if(mouseX >= screenWidth) mouseX = screenWidth;
|
|
|
|
if(mouseY >= screenHeight) mouseY = screenHeight;
|
|
|
|
if(mouseY >= screenHeight) mouseY = screenHeight;
|
|
|
|
|
|
|
|
|
|
|
|
button1justdown = pad->NewMouseControllerState.LMB && !pad->OldMouseControllerState.LMB;
|
|
|
|
mbutton1justdown = pad->NewMouseControllerState.LMB && !pad->OldMouseControllerState.LMB;
|
|
|
|
button2justdown = pad->NewMouseControllerState.MMB && !pad->OldMouseControllerState.MMB;
|
|
|
|
mbutton2justdown = pad->NewMouseControllerState.MMB && !pad->OldMouseControllerState.MMB;
|
|
|
|
button3justdown = pad->NewMouseControllerState.RMB && !pad->OldMouseControllerState.RMB;
|
|
|
|
mbutton3justdown = pad->NewMouseControllerState.RMB && !pad->OldMouseControllerState.RMB;
|
|
|
|
buttondown[0] = pad->NewMouseControllerState.LMB;
|
|
|
|
mbuttondown[0] = pad->NewMouseControllerState.LMB;
|
|
|
|
buttondown[1] = pad->NewMouseControllerState.MMB;
|
|
|
|
mbuttondown[1] = pad->NewMouseControllerState.MMB;
|
|
|
|
buttondown[2] = pad->NewMouseControllerState.RMB;
|
|
|
|
mbuttondown[2] = pad->NewMouseControllerState.RMB;
|
|
|
|
|
|
|
|
|
|
|
|
// Zero the mouse position so the camera won't move
|
|
|
|
// Zero the mouse position so the camera won't move
|
|
|
|
pad->NewMouseControllerState.x = 0.0f;
|
|
|
|
pad->NewMouseControllerState.x = 0.0f;
|
|
|
|
pad->NewMouseControllerState.y = 0.0f;
|
|
|
|
pad->NewMouseControllerState.y = 0.0f;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
crossjustdown = pad->NewState.Cross && !pad->OldState.Cross && !KEYDOWN(rsRCTRL); //RCTRL also sets pad circle to true because of in-game mappings.
|
|
|
|
|
|
|
|
circlejustdown = pad->NewState.Circle && !pad->OldState.Circle && !KEYDOWN(rsLCTRL); //LCTRL also sets pad circle to true because of in-game mappings.
|
|
|
|
|
|
|
|
trianglejustdown = pad->NewState.Triangle && !pad->OldState.Triangle;
|
|
|
|
|
|
|
|
squarejustdown = pad->NewState.Square && !pad->OldState.Square;
|
|
|
|
|
|
|
|
padleftjustdown = (pad->NewState.LeftStickX < -30 && !padbuttondown[4]) || (pad->NewState.DPadLeft && !pad->OldState.DPadLeft);
|
|
|
|
|
|
|
|
padrightjustdown = (pad->NewState.LeftStickX > 30 && !padbuttondown[5]) || (pad->NewState.DPadRight && !pad->OldState.DPadRight);
|
|
|
|
|
|
|
|
padupjustdown = (pad->NewState.LeftStickY < -30 && !padbuttondown[6]) || (pad->NewState.DPadUp && !pad->OldState.DPadUp);
|
|
|
|
|
|
|
|
paddownjustdown = (pad->NewState.LeftStickY > 30 && !padbuttondown[7]) || (pad->NewState.DPadDown && !pad->OldState.DPadDown);
|
|
|
|
|
|
|
|
padbuttondown[0] = pad->NewState.Cross;
|
|
|
|
|
|
|
|
padbuttondown[1] = pad->NewState.Circle;
|
|
|
|
|
|
|
|
padbuttondown[2] = pad->NewState.Triangle;
|
|
|
|
|
|
|
|
padbuttondown[3] = pad->NewState.Square;
|
|
|
|
|
|
|
|
padbuttondown[4] = pad->NewState.LeftStickX < -30 || pad->NewState.DPadLeft;
|
|
|
|
|
|
|
|
padbuttondown[5] = pad->NewState.LeftStickX > 30 || pad->NewState.DPadRight;
|
|
|
|
|
|
|
|
padbuttondown[6] = pad->NewState.LeftStickY < -30 || pad->NewState.DPadUp;
|
|
|
|
|
|
|
|
padbuttondown[7] = pad->NewState.LeftStickY > 30 || pad->NewState.DPadDown;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
void
|
|
|
|
DebugMenuProcess(void)
|
|
|
|
DebugMenuProcess(void)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
// We only process some input here
|
|
|
|
// We only process some input here
|
|
|
|
|
|
|
|
|
|
|
|
CPad *pad = CPad::GetPad(0);
|
|
|
|
CPad *pad = CPad::GetPad(0);
|
|
|
|
if(CTRLJUSTDOWN('M'))
|
|
|
|
if(CTRLJUSTDOWN('M') ||
|
|
|
|
|
|
|
|
(pad->GetTriangleJustDown() && pad->GetRightShoulder1()) || //Toggle via Gamepad
|
|
|
|
|
|
|
|
((CPad::GetPad(0)->GetStartJustDown() || CPad::GetPad(0)->GetEscapeJustDown()) && menuOn)) //Kill menu if main menu opens
|
|
|
|
menuOn = !menuOn;
|
|
|
|
menuOn = !menuOn;
|
|
|
|
if(!menuOn)
|
|
|
|
if(!menuOn)
|
|
|
|
return;
|
|
|
|
return;
|
|
|
@ -1024,8 +1085,7 @@ DebugMenuProcess(void)
|
|
|
|
// TODO: this could happen earlier
|
|
|
|
// TODO: this could happen earlier
|
|
|
|
if(!menuInitialized)
|
|
|
|
if(!menuInitialized)
|
|
|
|
DebugMenuInit();
|
|
|
|
DebugMenuInit();
|
|
|
|
updateMouse();
|
|
|
|
updatePad();
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
void
|
|
|
|