1
0
Fork 0
forked from fte/fteqw

Add proper support for touchscreen events to menusys.

This commit is contained in:
Shpoike 2024-04-14 04:45:33 +01:00
parent f61f98fe6f
commit 3ca6a3a515
24 changed files with 116 additions and 71 deletions

View file

@ -3540,6 +3540,10 @@ const float K_MOUSE9 = 522;
const float K_MOUSE10 = 523;
const float K_MWHEELUP = 515;
const float K_MWHEELDOWN = 516;
const float K_TOUCH = 600;
const float K_TOUCHSLIDE = 601;
const float K_TOUCHTAP = 602;
const float K_TOUCHLONG = 603;
const float K_LWIN = -239;
const float K_RWIN = -240;
const float K_APP = -241;

View file

@ -69,7 +69,11 @@ void(vector screensize) m_draw =
cltime = gettime(0);
items_draw(desktop, screensize);
};
float(float evtype, float scanx, float chary, float devid) Menu_InputEvent = {return items_keypress(desktop, evtype, scanx, chary, devid);};
float(float evtype, float scanx, float chary, float devid) Menu_InputEvent = {
if (scanx == K_TOUCH)
return TRUE; //always report this as handled. we'll not get fake mouse events then, and can handle K_TOUCHLONG/K_TOUCHTAP/etc without worry of conflicts.
return items_keypress(desktop, evtype, scanx, chary, devid);
};
void(float scan, float chr) m_keydown = {ui.mousepos = getmousepos();queryscreensize();items_keypress(desktop, IE_KEYDOWN, scan, chr, 0);}; //for DP compat.
void(float scan, float chr) m_keyup = {ui.mousepos = getmousepos();queryscreensize();items_keypress(desktop, IE_KEYUP, scan, chr, 0);}; //for DP compat.
void(float mode) m_toggle

View file

@ -128,7 +128,7 @@ float(vector pos, float scan, float char, float down, float idx) mitem_cvargrid:
cursorpos = max(cursorpos-1, 0);
else if (scan == K_RIGHTARROW && cursorpos>=0)
cursorpos+=1;
else if (scan == K_MOUSE1)
else if (scan == K_MOUSE1 || scan == K_TOUCHTAP)
{
startedit(idx);
if (cursorpos>=0)

View file

@ -57,7 +57,7 @@ class mitem_saveoption : mitem_text
{
if (!down)
return FALSE;
if (scan == K_ENTER || (scan == K_MOUSE1 && mouseinbox(pos, this.item_size)))
if (ISCONFIRMKEY(scan) || ((scan == K_MOUSE1 || scan == K_TOUCHTAP) && mouseinbox(pos, this.item_size)))
{
if (item_flags & IF_KFOCUSED)
{

View file

@ -133,11 +133,16 @@ nonstatic void(mitem_desktop desktop) M_Main =
local string it = (random()<0.9)?"progs/quaddama.mdl":"progs/invulner.mdl";
m.add(spawn (mitem_spinnymodel, item_text: it), RS_X_MIN_PARENT_MID|RS_Y_MIN_PARENT_MID | RS_X_MAX_PARENT_MID|RS_Y_MAX_PARENT_MID, [-160, 12*-16/2], [0, 12*16/2]);
#ifdef CSQC
m.add(spawn(mitem_text, item_text:strcat("CSQC: ", cvar_string("pr_engine")), item_scale:8), RS_X_MIN_PARENT_MIN|RS_Y_MIN_PARENT_MAX|RS_X_MAX_PARENT_MAX|RS_Y_MAX_PARENT_MAX,[0,-8],[0,0]);
#ifdef REVISION
#define MENUSYS_REVISION REVISION
#else
m.add(spawn(mitem_text, item_text:strcat("MQC: ", cvar_string("pr_engine")), item_scale:8), RS_X_MIN_PARENT_MIN|RS_Y_MIN_PARENT_MAX|RS_X_MAX_PARENT_MAX|RS_Y_MAX_PARENT_MAX,[0,-8],[0,0]);
#define MENUSYS_REVISION "<UNKNOWN>"
#endif
#ifdef CSQC
#define MODLEPOSTFIX "-CSQC"
#else
#define MODLEPOSTFIX "-MQC"
#endif
m.add(spawn(mitem_text, item_text:strcat("MenuSys "MENUSYS_REVISION MODLEPOSTFIX"; ", cvar_string("pr_engine")), item_scale:8), RS_X_MIN_PARENT_MIN|RS_Y_MIN_PARENT_MAX|RS_X_MAX_PARENT_MAX|RS_Y_MAX_PARENT_MAX,[0,-8],[0,0]);
addmenuback(m);
};

View file

@ -269,13 +269,14 @@ class mitem_maplist : mitem_grid
};
virtual float(vector pos, float scan, float chr, float down, float idx) grid_keypress =
{
if ((scan == K_ENTER || scan == K_MOUSE1) && down)
{
string map = bufstr_get(names, idx);
map = enginemapname(map);
set("map", map);
return TRUE;
}
if (down)
if (ISCONFIRMKEY(scan) || ((scan == K_MOUSE1 || scan == K_TOUCHTAP) && mouseinbox(pos, this.item_size)))
{
string map = bufstr_get(names, idx);
map = enginemapname(map);
set("map", map);
return TRUE;
}
return FALSE;
};
// virtual void(float olditem, float newitem) grid_selectionchanged;

View file

@ -35,6 +35,10 @@ nonstatic void(mitem_desktop desktop) M_Options_Effects =
fr.add(menuitemcheck_spawn(_("Show Framerate"), cv3("showfps", "scr_showfps", "show_fps"), '280 8'), fl, [0, pos], [0, 8]); pos += 8;
fr.add(menuitemcheck_spawn(_("High Res Textures"), "gl_load24bit", '280 8'), fl, [0, pos], [0, 8]); pos += 8;
fr.add(menuitemcombo_spawn(_("Replacement Models"), "r_replacemodels", '280 8', _(
"\"\" \"Off\""
"\"md3 md2 md5mesh\" \"On\""
)), fl, [0, pos], [0, 8]); pos += 8;
fr.add(menuitemcombo_spawn(_("Texture Mode"), "gl_texturemode", '280 8', _(
"GL_NEAREST \"Nearest\" "

View file

@ -71,7 +71,7 @@ nonstatic void(mitem_desktop desktop) M_Options_Video =
fr.add(spawn(mitem_text, item_text:_("Apply / Restart"), item_command:"vid_restart", item_scale:8, item_flags:IF_RIGHTALIGN), RS_X_MIN_PARENT_MIN|RS_Y_MIN_PARENT_MIN | RS_X_MAX_PARENT_MID|RS_Y_MAX_OWN_MIN, [0, pos], [-8, 8]); pos += 8;
pos += 8;
if (cvar_type("vid_renderer")) fr.add(menuitemcombo_spawn(_("Renderer"), "vid_renderer", '280 8', cvar_string("_vid_renderer_opts")), fl, [0, pos], [0, 8]); pos += 8;
if (cvar_type("vid_renderer")) fr.add(menuitemcombo_spawn(_("Renderer"), "vid_renderer", '280 8', strcat("\"\" \"Default\" ", cvar_string("_vid_renderer_opts"))), fl, [0, pos], [0, 8]); pos += 8;
//add the options
if (!dp_workarounds)

View file

@ -33,7 +33,7 @@ nonstatic void(mitem_desktop desktop) M_Quit =
{
m.add(spawn(mitem_text, item_text:"Really Quit?", item_scale:16, item_flags:IF_CENTERALIGN), RS_X_MIN_PARENT_MID|RS_Y_MIN_PARENT_MID | RS_X_MAX_PARENT_MID|RS_Y_MAX_PARENT_MID, [-160, pos-(8+16)], [0, pos-8]); pos += 16;
m.add(spawn(mitem_text, item_text:"Yes, I'm late for work.", item_command:"m_pop;quit", item_scale:16, item_flags:IF_CENTERALIGN), RS_X_MIN_PARENT_MID|RS_Y_MIN_PARENT_MID | RS_X_MAX_PARENT_MID|RS_Y_MAX_PARENT_MID, [-160, pos], [0, pos+16]); pos += 16;
m.add(spawn(mitem_text, item_text:"Yes, I'm a quitter.", item_command:"m_pop;quit", item_scale:16, item_flags:IF_CENTERALIGN), RS_X_MIN_PARENT_MID|RS_Y_MIN_PARENT_MID | RS_X_MAX_PARENT_MID|RS_Y_MAX_PARENT_MID, [-160, pos], [0, pos+16]); pos += 16;
m.add(spawn(mitem_text, item_text:"No, keep playing!", item_command:"m_pop;m_main", item_scale:16, item_flags:IF_CENTERALIGN), RS_X_MIN_PARENT_MID|RS_Y_MIN_PARENT_MID | RS_X_MAX_PARENT_MID|RS_Y_MAX_PARENT_MID, [-160, pos], [0, pos+16]); pos += 16;
}

View file

@ -170,9 +170,9 @@ class mitem_servers : mitem
/*just sink all inputs*/
if (!down)
return FALSE;
if (scan != K_MOUSE1)
if (scan != K_MOUSE1 && scan != K_TOUCHTAP)
dbltime = cltime - 10;
if (scan == K_MOUSE1)
if (scan == K_MOUSE1 || scan == K_TOUCHTAP)
{
float news = ui.mousepos[1] - (pos_y+8);
news = floor(news / 8);
@ -217,25 +217,25 @@ class mitem_servers : mitem
dbltime = cltime + 0.5;
}
else if (scan == K_ENTER)
else if (ISCONFIRMKEY(scan))
{ //connect normally
addr = gethostcachestring(gethostcacheindexforkey("cname"), server_selected);
if (addr)
localcmd(sprintf("m_pop;%sconnect \"%s\"\n", getgamedircmd(), addr));
}
else if (scan == 's')
else if (scan == 's' || scan == K_GP_X)
{ //s = join as a spectator
addr = gethostcachestring(gethostcacheindexforkey("cname"), server_selected);
if (addr)
localcmd(sprintf("m_pop;%sobserve \"%s\"\n", getgamedircmd(), addr));
}
else if (scan == 'j')
{ //s = join as a spectator
{ //j = join as a player
addr = gethostcachestring(gethostcacheindexforkey("cname"), server_selected);
if (addr)
localcmd(sprintf("m_pop;%sjoin \"%s\"\n", getgamedircmd(), addr));
}
else if (scan == K_UPARROW || scan == K_MWHEELUP)
else if (ISUPARROW(scan) || scan == K_MWHEELUP)
{
this.server_selected -= 1;
if (this.server_selected < 0)
@ -246,7 +246,7 @@ class mitem_servers : mitem
}
dobound = TRUE;
}
else if (scan == K_DOWNARROW || scan == K_MWHEELDOWN)
else if (ISDOWNARROW(scan) || scan == K_MWHEELDOWN)
{
this.server_selected += 1;
if (this.server_selected >= gethostcachevalue(SLIST_HOSTCACHEVIEWCOUNT))
@ -287,7 +287,7 @@ class mitem_servers : mitem
this.server_selected = 0;
dobound = TRUE;
}
else if (char == 'r' || char == 'R' || scan == K_F5)
else if (char == 'r' || char == 'R' || scan == K_F5 || scan == K_GP_Y)
{
refreshhostcache();
resorthostcache();

View file

@ -117,7 +117,7 @@ void(vector pos, float idx) mitem_updategrid::grid_draw =
text = strcat("pkg quiet_", action, " \"", text, "\"\n");
localcmd(text);
}
else if (scan == K_RIGHTARROW || scan==K_ENTER || scan == K_MOUSE1)
else if (scan == K_RIGHTARROW || scan==K_ENTER || scan == K_MOUSE1 || scan == K_TOUCHTAP)
{
text = getpackagemanagerinfo(idx, GPMI_NAME);
if (!text)

View file

@ -74,7 +74,7 @@ float(vector pos, float scan, float char, float down) mitem_bind::item_keypress
if (self.item_flags & IF_INTERACT)
{
if (scan == K_ESCAPE)
if (scan == K_ESCAPE || scan == K_GP_START) //keys that cannot/shouldnot be bound can be used to cancel here.
{
}
else if (scan)
@ -86,12 +86,12 @@ float(vector pos, float scan, float char, float down) mitem_bind::item_keypress
}
else
{
if (scan == K_ENTER || (scan == K_MOUSE1 && mouseinbox(pos, self.item_size)))
if (scan == K_ENTER || scan == K_GP_A || ((scan == K_TOUCHTAP || scan == K_MOUSE1) && mouseinbox(pos, self.item_size)))
{
self.item_flags |= IF_INTERACT;
return TRUE;
}
if (scan == K_DEL || scan == K_BACKSPACE)
if (scan == K_DEL || scan == K_GP_Y || scan == K_BACKSPACE)
{
#ifdef CSQC
float c = tokenize(findkeysforcommandex(self.item_command));

View file

@ -8,14 +8,14 @@ class mitem_check : mitem
if (!down)
return FALSE;
if (scan == K_ENTER || scan == K_SPACE || scan == K_LEFTARROW || scan == K_RIGHTARROW || scan == K_MOUSE1)
if (ISCONFIRMKEY(scan) || scan == K_SPACE || ISLEFTARROW(scan) || ISRIGHTARROW(scan) || scan == K_MOUSE1 || scan == K_TOUCHTAP)
{
pos_x += this.item_size_x / 2;
// if (ui.mousepos[0] > pos_x || scan != K_MOUSE1) //don't do anything if they clicked the bit on the left to select it
set(item_command, ftos(!stof(get(item_command))));
return TRUE;
}
else if (scan == K_DEL && down && cvar_type(item_command))
else if ((scan == K_DEL || scan == K_GP_Y) && down && cvar_type(item_command))
set(item_command, cvar_defstring(item_command));
return FALSE;
};

View file

@ -237,7 +237,7 @@ float(vector pos, float scan, float char, float down) mitem_colours::item_keypre
local float curval = rgbtohsv(hextorgb(get(item_command)))[0];
if (scan == K_MOUSE1)
if (scan == K_TOUCHTAP || scan == K_MOUSE1)
{
float width = item_size_x / 2;
pos_x += width;
@ -256,11 +256,11 @@ float(vector pos, float scan, float char, float down) mitem_colours::item_keypre
set(item_command, rgbtohex(hsvtorgb([(curval), 1, 1])));
ui.mgrabs = this;
}
else if (scan == K_LEFTARROW || scan == K_SPACE)
else if (ISLEFTARROW(scan) || scan == K_SPACE)
{
set(item_command, rgbtohex(hsvtorgb([curval - (1/64.0), 1, 1]))); //yay autorepeat
}
else if (scan == K_RIGHTARROW || scan == K_ENTER)
else if (ISRIGHTARROW(scan) || scan == K_ENTER)
{
set(item_command, rgbtohex(hsvtorgb([curval + (1/64.0), 1, 1])));
}

View file

@ -241,7 +241,7 @@ void(vector pos) mitem_combo_popup::item_draw =
};
float(vector pos, float scan, float char, float down) mitem_combo_popup::item_keypress =
{
if (pslider && scan == K_MOUSE1)
if (pslider && (scan == K_TOUCHTAP || scan == K_MOUSE1))
{
vector sliderpos = pos + [item_size_x-pslider.item_size_x,0];
if (mouseinbox(pos + [item_size_x-pslider.item_size_x,0], pslider.item_size))
@ -269,7 +269,7 @@ float(vector pos, float scan, float char, float down) mitem_combo::item_keypress
}
}
if (scan == K_ESCAPE || scan == K_MOUSE2)
if (scan == K_ESCAPE || scan == K_MOUSE2 || scan == K_GP_B || scan == K_GP_BACK)
{
if (cpopup)
{
@ -278,28 +278,28 @@ float(vector pos, float scan, float char, float down) mitem_combo::item_keypress
}
return FALSE;
}
else if (scan == K_MWHEELUP || (scan == K_UPARROW && cpopup))
else if (scan == K_MWHEELUP || (cpopup && ISUPARROW(scan)) || (!cpopup && spos < 0 && ISLEFTARROW(scan)))
{
i -= 2;
if (i < 0)
i = c - 2;
curval = argv(i);
}
else if (scan == K_MWHEELDOWN || (scan == K_DOWNARROW && cpopup))
else if (scan == K_MWHEELDOWN || (cpopup && ISDOWNARROW(scan)) || (!cpopup && spos < 0 && ISRIGHTARROW(scan)))
{
i += 2;
if (i >= c)
i = 0;
curval = argv(i);
}
else if (scan == K_MOUSE1 || scan == K_ENTER)
else if (scan == K_TOUCHTAP || scan == K_MOUSE1 || ISCONFIRMKEY(scan))
{
if (scan == K_ENTER && cpopup)
if (ISCONFIRMKEY(scan) && cpopup)
{
cpopup.item_remove();
return TRUE;
}
visrows = ((c>18)?18/2:c/2);
if (!cpopup)
{
@ -321,7 +321,7 @@ float(vector pos, float scan, float char, float down) mitem_combo::item_keypress
cpopup.item_flags |= IF_SELECTABLE;
cpopup.totop();
if (scan == K_MOUSE1 && (cpopup.item_flags & IF_MFOCUSED))
if ((scan == K_TOUCHTAP || scan == K_MOUSE1) && (cpopup.item_flags & IF_MFOCUSED))
{
//if they clicked inside the popup, change the selected item.
f = ui.mousepos[1] - (pos_y + item_size_y);
@ -334,7 +334,7 @@ float(vector pos, float scan, float char, float down) mitem_combo::item_keypress
cpopup.item_flags &~= IF_SELECTABLE;
cpopup.item_size = cpopup.maxs = '0 0';
item_parent.item_focuschange(this, IF_MFOCUSED|IF_KFOCUSED);
cpopup.item_remove();
}
}

View file

@ -27,7 +27,7 @@ float(string fontname, string fontmaps, string sizes, float slot, optional float
void() mitem_desktop::mitem_desktop =
{
#define menu_font_win autocvar(menu_font_win, "cour")
#define menu_font autocvar(menu_font, "cour")
#define menu_font autocvar(menu_font, "Courier New")
#define menu_font_fallback autocvar(gl_font, "")
queryscreensize();
@ -93,7 +93,7 @@ float(vector pos, float scan, float char, float down) mitem_desktop::item_keypre
{
down &= 1;
//if we're grabbing, then cancel if they press escape, otherwise block other items from taking the keys.
if (scan >= K_MOUSE1 && scan <= K_MOUSE5)
if (scan == K_TOUCHTAP || (scan >= K_MOUSE1 && scan <= K_MOUSE5))
return 2; //block other wigits, don't cancel the event so the engine still does its thing
else
{
@ -125,7 +125,7 @@ float(vector pos, float scan, float char, float down) mitem_desktop::item_keypre
if (mitem_frame::item_keypress(pos, scan, char, down))
return TRUE;
if (scan == K_MOUSE1 && down)
if ((scan == K_TOUCHTAP || scan == K_MOUSE1) && down)
{
#if defined(CSQC) && defined(FTE_SPLITSCREEN)
__using(numclientseats)
@ -290,6 +290,11 @@ void(float force) items_updategrabs =
setcursormode(TRUE, autocvar(cl_cursor, "gfx/cursor.lmp"), autocvar(cl_cursorbias, 4.0)*'1 1', autocvar(cl_cursorscale, 1.0)); //because we can
else
setcursormode(TRUE); //because DP sucks.
//evilness. make sure we fit the screen by forcing the screen size upwards. this may also affect reported video mode choices as well as being just extra scaling.
if (autocvar(vid_minsize, '640 480').x < 640 ||
autocvar(vid_minsize, '640 480').y < 480)
cvar_set("vid_minsize", "640 480");
}
}
else if (oldgrabstate || force)
@ -371,7 +376,7 @@ float(mitem_desktop desktop, float evtype, float scanx, float chary, float devid
return TRUE;
}
#endif
if (scanx >= K_MOUSE1 && scanx <= K_MOUSE5)
if (scanx == K_TOUCHTAP || (scanx >= K_MOUSE1 && scanx <= K_MOUSE5))
{
if (ui.mgrabs)
{
@ -400,7 +405,14 @@ float(mitem_desktop desktop, float evtype, float scanx, float chary, float devid
}
if (desktop && desktop.item_keypress)
result = desktop.item_keypress(desktop.item_position, scanx, chary, evtype == IE_KEYDOWN||evtype == IE_PASTE);
if (scanx >= K_MOUSE1 && scanx <= K_MOUSE5)
if (scanx == K_TOUCHTAP)
{
if (evtype == IE_KEYDOWN)
ui.mousedown |= 1<<23;
else
ui.mousedown &~= 1<<23;
}
else if (scanx >= K_MOUSE1 && scanx <= K_MOUSE5)
{
if (evtype == IE_KEYDOWN)
ui.mousedown |= pow(1, scanx-K_MOUSE1);

View file

@ -62,6 +62,7 @@ float(vector pos, float scan, float chr, float down) mitem_edit::item_keypress =
if (scan == K_ESCAPE)
return FALSE;
//FIXME: onscreen keyboard?
else if (scan == K_LEFTARROW)
spos = max(spos-1, 0);
else if (scan == K_RIGHTARROW)
@ -70,7 +71,7 @@ float(vector pos, float scan, float chr, float down) mitem_edit::item_keypress =
spos = 0;
else if (scan == K_END)
spos = strlen(curval);
else if (scan == K_MOUSE1)
else if (scan == K_TOUCHTAP || scan == K_MOUSE1)
{
float valuepos = pos_x+(item_size_x/2)+1;
if (ui.mousepos[0] > valuepos-8)

View file

@ -18,14 +18,14 @@ class mitem_exmenu : mitem_frame
if (!ret && down)
{
ret = TRUE;
if (scan == K_MOUSE2 || scan == K_ESCAPE)
if (scan == K_MOUSE2 || scan == K_TOUCHLONG || scan == K_ESCAPE || scan == K_GP_BACK || scan == K_GP_B)
{
localcmd(strcat(item_command, "\n")); //console command to exec if someone clicks the close button.
item_remove();
}
else if (scan == K_UPARROW && down)
else if (ISUPARROW(scan))
menu_selectnextitem(this, TRUE);
else if (scan == K_DOWNARROW && down)
else if (ISDOWNARROW(scan))
menu_selectnextitem(this, FALSE);
else if (scan >= K_F1 && scan <= K_F12) //allow f1-f12 to work, but every other button event gets canceled.
ret = FALSE;

View file

@ -358,7 +358,7 @@ float(vector pos, float scan, float char, float down) mitem_vslider::item_keypre
{
if (down != 1)
{
if (scan == K_MOUSE1 && ui.mgrabs == this)
if ((scan == K_TOUCHTAP || scan == K_MOUSE1) && ui.mgrabs == this)
ui.mgrabs = __NULL__;
return FALSE;
}
@ -366,7 +366,7 @@ float(vector pos, float scan, float char, float down) mitem_vslider::item_keypre
val = bound(minv, val+stride, maxv);
else if (scan == K_MWHEELUP)
val = bound(minv, val-stride, maxv);
else if (scan == K_MOUSE1)
else if (scan == K_TOUCHTAP || scan == K_MOUSE1)
ui.mgrabs = this;
else
return FALSE;
@ -545,7 +545,7 @@ float(vector pos, float scan, float char, float down) mitem_frame::item_keypress
pos[0] += item_framesize[0];
pos[1] += item_framesize[1];
if (scan >= K_MOUSE1 && scan <= K_MOUSE5 && scan != K_MWHEELUP && scan != K_MWHEELDOWN)
if ((scan >= K_MOUSE1 && scan <= K_MOUSE5 && scan != K_MWHEELUP && scan != K_MWHEELDOWN) || scan == K_TOUCHTAP)
{
if (item_exclusive)
ch = item_exclusive;

View file

@ -55,11 +55,11 @@ float(vector pos, float scan, float char, float down) mitem_grid::item_keypress
float ch;
float handled = FALSE;
if (scan >= K_MOUSE1 && scan <= K_MOUSE5 && scan != K_MWHEELUP && scan != K_MWHEELDOWN)
if (scan >= K_MOUSE1 && scan <= K_MOUSE5 && scan != K_MWHEELUP && scan != K_MWHEELDOWN && scan != K_TOUCHTAP)
{
ch = grid_mactive;
if (ch != grid_kactive)
if (down && scan == K_MOUSE1) //keyboard focus follows on mouse click.
if (down && (scan == K_TOUCHTAP || scan == K_MOUSE1)) //keyboard focus follows on mouse click.
{
item_focuschange((ch>=0)?__NULL__:vslider, IF_KFOCUSED);
grid_selectionchanged(grid_kactive, ch);
@ -116,9 +116,15 @@ float(vector pos, float scan, float char, float down) mitem_grid::item_keypress
ch = min(grid_numchildren-1, grid_kactive+5);
break;
case K_UPARROW:
case K_GP_DPAD_UP:
case K_GP_LTHUMB_UP:
case K_GP_RTHUMB_UP:
ch = max(grid_kactive-1, 0);
break;
case K_DOWNARROW:
case K_GP_DPAD_DOWN:
case K_GP_LTHUMB_DOWN:
case K_GP_RTHUMB_DOWN:
ch = min(grid_kactive+1, grid_numchildren-1);
break;
}

View file

@ -68,7 +68,7 @@ float(vector pos, float scan, float char, float down) mitem_hslider::item_keypre
if (down&2)
{
//we have grabs, and mouse was released?
if (scan == K_MOUSE1 && !(down&1))
if ((scan == K_TOUCHTAP || scan == K_MOUSE1) && !(down&1))
{ //we're done here.
ui.mgrabs = __NULL__;
return TRUE;
@ -83,7 +83,7 @@ float(vector pos, float scan, float char, float down) mitem_hslider::item_keypre
if (ui.mousepos[0] > pos_x + item_size[0]/2)
scan = ((scan == K_MWHEELDOWN)?K_LEFTARROW:K_RIGHTARROW);
}
if (scan == K_MOUSE1 && down)
if ((scan == K_TOUCHTAP || scan == K_MOUSE1) && down)
{
pos_x += item_size_x / 2;
if (ui.mousepos[0] < pos_x)
@ -95,23 +95,23 @@ float(vector pos, float scan, float char, float down) mitem_hslider::item_keypre
set(item_command, sprintf("%g", curval));
ui.mgrabs = this;
}
else if (scan == K_DEL && down && cvar_type(item_command))
else if ((scan == K_DEL || scan == K_GP_Y) && down && cvar_type(item_command))
set(item_command, cvar_defstring(item_command));
else if ((scan == K_LEFTARROW || scan == K_MWHEELUP) && down)
else if ((ISLEFTARROW(scan) || scan == K_MWHEELUP) && down)
{
if (item_slidercontrols_x > item_slidercontrols_y)
set(item_command, sprintf("%g", min(curval - item_slidercontrols_z, item_slidercontrols_x)));
else
set(item_command, sprintf("%g", max(curval - item_slidercontrols_z, item_slidercontrols_x)));
}
else if ((scan == K_RIGHTARROW || scan == K_MWHEELDOWN) && down)
else if ((ISRIGHTARROW(scan) || scan == K_MWHEELDOWN) && down)
{
if (item_slidercontrols_x > item_slidercontrols_y)
set(item_command, sprintf("%g", max(curval + item_slidercontrols_z, item_slidercontrols_y)));
else
set(item_command, sprintf("%g", min(curval + item_slidercontrols_z, item_slidercontrols_y)));
}
else if ((scan == K_ENTER || scan == K_SPACE) && down)
else if ((ISCONFIRMKEY(scan) || scan == K_SPACE) && down)
{
//keyenter:
if (item_slidercontrols_x > item_slidercontrols_y)
@ -133,7 +133,7 @@ float(vector pos, float scan, float char, float down) mitem_hslider::item_keypre
return FALSE;
return TRUE;
}
else if (scan == K_MOUSE1 && ui.mgrabs == this)
else if ((scan == K_TOUCHTAP || scan == K_MOUSE1) && ui.mgrabs == this)
ui.mgrabs = __NULL__;
return FALSE;
};

View file

@ -20,9 +20,9 @@ class mitem_tab : mitem_frame
{
virtual float(vector pos, float scan, float char, float down) item_keypress =
{
if (scan == K_UPARROW && down)
if (down && ISUPARROW(scan))
menu_selectnextitem(this, TRUE);
else if (scan == K_DOWNARROW && down)
else if (down && ISDOWNARROW(scan))
menu_selectnextitem(this, FALSE);
else if (super::item_keypress(pos, scan, char, down))
return TRUE;
@ -99,7 +99,7 @@ float(vector pos, float scan, float char, float down) mitem_tabs::item_keypress
local vector sz;
local float result;
if (down && (scan == K_MOUSE1 || scan == K_MOUSE2 || scan == K_MOUSE3))
if (down && (scan == K_TOUCHTAP || scan == K_MOUSE1 || scan == K_MOUSE2 || scan == K_MOUSE3))
{
sz = [8,16];
//to highlight the active tab, we draw the top line 1 pixel higher, and no bottom line
@ -121,7 +121,7 @@ float(vector pos, float scan, float char, float down) mitem_tabs::item_keypress
result = ch.item_keypress(pos + [item_framesize[0], item_framesize[1]] + ch.item_position, scan, char, down);
if (!result && down)
{
if (scan == K_TAB || scan == K_RIGHTARROW)
if ((scan == K_TAB && !ui.shiftheld) || scan == K_GP_RSHOULDER || scan == K_RIGHTARROW)
{
ch = ch.item_next;
if (!ch)
@ -129,7 +129,7 @@ float(vector pos, float scan, float char, float down) mitem_tabs::item_keypress
item_focuschange(ch, IF_KFOCUSED);
result = TRUE;
}
// else if (scan == K_LEFTARROW)
// else if ((scan == K_TAB && ui.shiftheld) || scan == K_GP_LSHOULDER || scan == K_LEFTARROW)
// {
// ch = ch.item_next;
// if (!ch)

View file

@ -70,6 +70,14 @@ __strip var float dp_workarounds;
#define MENUBACK_ALPHA 0.8
#endif
//input helpers - gamepads need 3 different 'keys' for natural movement through menus. :(
#define ISUPARROW(scan) (scan == K_UPARROW || scan == K_GP_DPAD_UP || scan == K_GP_LTHUMB_UP || scan == K_GP_RTHUMB_UP)
#define ISDOWNARROW(scan) (scan == K_DOWNARROW || scan == K_GP_DPAD_DOWN || scan == K_GP_LTHUMB_DOWN || scan == K_GP_RTHUMB_DOWN)
#define ISLEFTARROW(scan) (scan == K_LEFTARROW || scan == K_GP_DPAD_LEFT || scan == K_GP_LTHUMB_LEFT || scan == K_GP_RTHUMB_LEFT)
#define ISRIGHTARROW(scan) (scan == K_RIGHTARROW || scan == K_GP_DPAD_RIGHT || scan == K_GP_LTHUMB_RIGHT || scan == K_GP_RTHUMB_RIGHT)
#define ISCONFIRMKEY(scan) (scan == K_ENTER || scan == K_GP_A || scan == K_GP_START)
#define ISCANCELKEY(scan) (scan == K_ENTER || scan == K_GP_B || scan == K_GP_VIEW)
//#ifdef TARGET_FTE
//#pragma TARGET FTE
//#endif

View file

@ -99,7 +99,7 @@ class mitem_text : mitem
{
if (!down)
return FALSE;
if (scan == K_ENTER || (scan == K_MOUSE1 && mouseinbox(pos, this.item_size)))
if (ISCONFIRMKEY(scan) || ((scan == K_TOUCHTAP || scan == K_MOUSE1) && mouseinbox(pos, this.item_size)))
{
item_parent.item_execcommand(this, this.item_command);
// localcmd(strcat(this.item_command, "\n"));
@ -218,7 +218,7 @@ class mitem_label : mitem
{
if (!down)
return FALSE;
if (scan == K_ENTER || (scan == K_MOUSE1 && mouseinbox(pos, this.item_size)))
if (ISCONFIRMKEY(scan) || ((scan == K_TOUCHTAP || scan == K_MOUSE1) && mouseinbox(pos, this.item_size)))
{
item_parent.item_execcommand(this, this.item_command);
// localcmd(strcat(this.item_command, "\n"));
@ -272,7 +272,7 @@ class mitem_button : mitem
{
if (!down)
return FALSE;
if (scan == K_ENTER || (scan == K_MOUSE1 && mouseinbox(pos, this.item_size)))
if (ISCONFIRMKEY(scan) || (scan == K_MOUSE1 && mouseinbox(pos, this.item_size)))
item_parent.item_execcommand(this, item_command);
else
return FALSE;