From 407c4eca8bbf6cc1b81308b0e1fd2db92a41b339 Mon Sep 17 00:00:00 2001 From: Spoike Date: Mon, 9 Jan 2023 05:12:59 +0000 Subject: [PATCH] Rework gamepad menu bindings, should be more intuitive now. git-svn-id: https://svn.code.sf.net/p/fteqw/code/trunk@6320 fc73d0e0-1445-4013-8a0c-d673dee63da5 --- CMakeLists.txt | 4 +- engine/client/cl_input.c | 6 + engine/client/cl_main.c | 1 + engine/client/client.h | 2 + engine/client/in_generic.c | 40 +++--- engine/client/in_sdl.c | 251 +++++++++++++++++++++++++++++-------- engine/client/in_win.c | 4 +- engine/client/keys.c | 52 ++++---- engine/client/keys.h | 12 +- engine/client/m_download.c | 22 ++-- engine/client/m_items.c | 38 +++--- engine/client/m_master.c | 22 ++-- engine/client/m_mp3.c | 6 +- engine/client/m_multi.c | 8 +- engine/client/m_options.c | 31 +++-- engine/client/m_single.c | 6 +- engine/client/menu.c | 17 +-- engine/client/pr_clcmd.c | 2 + engine/client/pr_menu.c | 15 ++- engine/client/sys_droid.c | 2 +- engine/client/sys_sdl.c | 4 +- engine/gl/gl_vidsdl.c | 9 ++ engine/server/sv_main.c | 4 +- 23 files changed, 393 insertions(+), 165 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index e2328dcac..a991a50b2 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -244,7 +244,7 @@ IF(${ANDROID}) engine/client/cd_null.c engine/gl/gl_viddroid.c ) -ELSEIF(${WIN32}) +ELSEIF(WIN32 AND NOT FTE_USE_SDL) INCLUDE_DIRECTORIES(engine/libs engine/libs/freetype2/include) # LINK_DIRECTORIES(engine/libs/mingw64-libs) @@ -289,7 +289,7 @@ ELSEIF(${WIN32}) engine/common/fs_win32.c engine/server/sv_sys_win.c ) -ELSEIF(${UNIX} AND NOT FTE_USE_SDL) #linux(ish) +ELSEIF(UNIX AND NOT FTE_USE_SDL) #linux(ish) #openbsd will have issues with snd_linux.c FIND_PACKAGE(GnuTLS) diff --git a/engine/client/cl_input.c b/engine/client/cl_input.c index 497037227..36cde239a 100644 --- a/engine/client/cl_input.c +++ b/engine/client/cl_input.c @@ -757,6 +757,12 @@ void IN_FireUp(void) IN_DoWeaponHide(); } +qboolean IN_WeaponWheelIsShown(void) +{ + if (!(in_wwheel.state[0]&1) || !weaponinfo_count) + return false; + return true; +} qboolean IN_WeaponWheelAccumulate(int pnum, float x, float y) //either mouse or controller { if (!(in_wwheel.state[pnum]&1) || !weaponinfo_count) diff --git a/engine/client/cl_main.c b/engine/client/cl_main.c index 375afeb72..b39f375d3 100644 --- a/engine/client/cl_main.c +++ b/engine/client/cl_main.c @@ -2619,6 +2619,7 @@ void CL_CheckServerInfo(void) //FIXME: we should probably tweak our movement code instead. cl.maxpitch = bound(-89.9, cl.maxpitch, 89.9); cl.minpitch = bound(-89.9, cl.minpitch, 89.9); + cl.disablemouse = atoi(InfoBuf_ValueForKey(&cl.serverinfo, "nomouse")); cl.hexen2pickups = atoi(InfoBuf_ValueForKey(&cl.serverinfo, "sv_pupglow")); diff --git a/engine/client/client.h b/engine/client/client.h index 6e775163a..b2d3897b9 100644 --- a/engine/client/client.h +++ b/engine/client/client.h @@ -983,6 +983,7 @@ typedef struct qboolean teamfortress; // *sigh*. This is used for teamplay stuff. This sucks. qboolean hexen2pickups; + qboolean disablemouse; //no mouse inputs (for controller-only games, though we do also allow keyboards if only because of joy2key type stuff) qboolean sendprespawn; int contentstage; @@ -1217,6 +1218,7 @@ void CL_UpdateWindowTitle(void); const char *IN_GetPreselectedViewmodelName(unsigned int pnum); qboolean IN_WeaponWheelAccumulate(int pnum, float x, float y); qboolean IN_DrawWeaponWheel(int pnum); +qboolean IN_WeaponWheelIsShown(void); //to decide when the game should be auto-paused. #endif void CL_InitInput (void); void CL_SendCmd (double frametime, qboolean mainloop); diff --git a/engine/client/in_generic.c b/engine/client/in_generic.c index 732c7ccb9..a9769723e 100644 --- a/engine/client/in_generic.c +++ b/engine/client/in_generic.c @@ -122,7 +122,16 @@ static cvar_t joy_movethreshold[3] = }; static cvar_t joy_exponent = CVARD("joyexponent", "3", "Scales joystick/controller sensitivity non-linearly to increase precision in the center.\nA value of 1 is linear."); -static cvar_t joy_radialdeadzone = CVARD("joyradialdeadzone", "1", "Treat controller dead zones as a pair, rather than per-axis."); +void joy_radialdeadzone_cb(cvar_t *var, char *oldvalue) +{ + if (!*var->string) + { +#if defined(__linux__) && defined(FTE_SDL) + var->ival = 2; //sdl2 provides its own deadzones on linux, by default. FIXME: check SDL_GetHint(SDL_HINT_LINUX_JOYSTICK_DEADZONES), default is "1" +#endif + } +} +static cvar_t joy_radialdeadzone = CVARCD("joyradialdeadzone", "", joy_radialdeadzone_cb, "Treat controller dead zones as a pair, rather than per-axis."); #define EVENTQUEUELENGTH 1024 @@ -427,9 +436,9 @@ void IN_Commands(void) break; } case IEV_KEYDOWN: -//Con_Printf("IEV_KEY%s %i: %i '%c'\n", (ev->type==IEV_KEYDOWN)?"DOWN":"RELEASE", ev->devid, ev->keyboard.scancode, ev->keyboard.unicode?ev->keyboard.unicode:' '); +//Con_Printf("IEV_KEY%s %i: %i '%c'\n", (ev->type==IEV_KEYDOWN)?"DOWN ":"RELEASE", ev->devid, ev->keyboard.scancode, ev->keyboard.unicode?ev->keyboard.unicode:' '); //on touchscreens, mouse1 is used as up/down state. we have to emulate actual mouse clicks based upon distance moved, so we can get movement events. - if (ev->keyboard.scancode == K_MOUSE1 && ev->devid < MAXPOINTERS && (ptr[ev->devid].type == M_TOUCH)) + if ((ev->keyboard.scancode == K_MOUSE1||ev->keyboard.scancode==K_TOUCH) && ev->devid < MAXPOINTERS && (ptr[ev->devid].type == M_TOUCH)) { if (ev->type == IEV_KEYDOWN) { @@ -454,9 +463,9 @@ void IN_Commands(void) if (ptr[ev->devid].held == 1 && ptr[ev->devid].moveddist < m_slidethreshold.value) { ptr[ev->devid].held = 2; //so we don't just flag it as held again - Key_Event(ev->devid, K_MOUSE1, 0, true); + Key_Event(ev->devid, ev->keyboard.scancode, 0, true); } - Key_Event(ev->devid, K_MOUSE1, 0, false); + Key_Event(ev->devid, ev->keyboard.scancode, 0, false); ptr[ev->devid].held = 0; } break; @@ -469,12 +478,6 @@ void IN_Commands(void) { if (topmenu && topmenu->joyaxis && topmenu->joyaxis(topmenu, ev->devid, ev->joy.axis, ev->joy.value)) joy[ev->devid].axis[ev->joy.axis] = 0; -#ifdef QUAKESTATS - else if (ev->joy.axis==GPAXIS_LT_RIGHT && IN_WeaponWheelAccumulate(ev->devid, ev->joy.value, 0)) - joy[ev->devid].axis[ev->joy.axis] = 0; - else if (ev->joy.axis==GPAXIS_LT_DOWN && IN_WeaponWheelAccumulate(ev->devid, 0, ev->joy.value)) - joy[ev->devid].axis[ev->joy.axis] = 0; -#endif #ifdef CSQC_DAT else if (CSQC_JoystickAxis(ev->joy.axis, ev->joy.value, ev->devid)) joy[ev->devid].axis[ev->joy.axis] = 0; @@ -842,7 +845,7 @@ void IN_MoveMouse(struct mouse_s *mouse, float *movements, int pnum, float frame #endif */ - if (!movements) + if (!movements || cl.disablemouse) { return; } @@ -931,6 +934,7 @@ void IN_MoveJoystick(struct joy_s *joy, float *movements, int pnum, float framet case -3: case -5: jstrafe[(-ax-1)/2] -= joy->axis[i] * joy_advaxisscale[i].value; + break; case 2: case 4: @@ -945,11 +949,17 @@ void IN_MoveJoystick(struct joy_s *joy, float *movements, int pnum, float framet } } - //uses a radial deadzone for x+y axis, and separate out the z axis, just because most controllers are 2d affairs with any 3rd axis being a separate knob. - //deadzone values are stolen from microsoft's xinput documentation. they seem quite large to me - I guess that means that xbox controllers are just dodgy imprecise crap with excessive amounts of friction and finger grease. + if (IN_WeaponWheelAccumulate(joy->qdeviceid, jstrafe[1]*50, -jstrafe[0]*50)) + jstrafe[0] = jstrafe[1] = 0; - if (joy_radialdeadzone.ival) + if (joy_radialdeadzone.ival == 2) + { //steam or SDL or something is doing deadzone and exponent stuff already. just use identity so we don't get double deadzones. + } + else if (joy_radialdeadzone.ival) { + //uses a radial deadzone for x+y axis, and separate out the z axis, just because most controllers are 2d affairs with any 3rd axis being a separate knob. + //deadzone values are stolen from microsoft's xinput documentation. they seem quite large to me - I guess that means that xbox controllers are just dodgy imprecise crap with excessive amounts of friction and finger grease. + mag = joydeadzone(sqrt(jlook[0]*jlook[0] + jlook[1]*jlook[1]), sqrt(joy_anglethreshold[0].value*joy_anglethreshold[0].value + joy_anglethreshold[1].value*joy_anglethreshold[1].value)); mag = pow(mag, joy_exponent.value); jlook[0] *= mag; diff --git a/engine/client/in_sdl.c b/engine/client/in_sdl.c index be1874c5e..4977fccbd 100644 --- a/engine/client/in_sdl.c +++ b/engine/client/in_sdl.c @@ -95,6 +95,45 @@ static uint32_t SDL_GiveFinger(SDL_JoystickID jid, SDL_TouchID tid, SDL_FingerID #if SDL_MAJOR_VERSION >= 2 #define MAX_JOYSTICKS 16 + +static struct +{ + int qaxis; + keynum_t pos, neg; +} gpaxismap[] = +{ + {/*SDL_CONTROLLER_AXIS_LEFTX*/ GPAXIS_LT_RIGHT, K_GP_LEFT_THUMB_RIGHT, K_GP_LEFT_THUMB_LEFT}, + {/*SDL_CONTROLLER_AXIS_LEFTY*/ GPAXIS_LT_DOWN, K_GP_LEFT_THUMB_DOWN, K_GP_LEFT_THUMB_UP}, + {/*SDL_CONTROLLER_AXIS_RIGHTX*/ GPAXIS_RT_RIGHT, K_GP_RIGHT_THUMB_RIGHT, K_GP_RIGHT_THUMB_LEFT}, + {/*SDL_CONTROLLER_AXIS_RIGHTY*/ GPAXIS_RT_DOWN, K_GP_RIGHT_THUMB_DOWN, K_GP_RIGHT_THUMB_UP}, + {/*SDL_CONTROLLER_AXIS_TRIGGERLEFT*/ GPAXIS_LT_TRIGGER, K_GP_LEFT_TRIGGER, 0}, + {/*SDL_CONTROLLER_AXIS_TRIGGERRIGHT*/ GPAXIS_RT_TRIGGER, K_GP_RIGHT_TRIGGER, 0}, +}; +static const int gpbuttonmap[] = +{ + K_GP_A, + K_GP_B, + K_GP_X, + K_GP_Y, + K_GP_BACK, + K_GP_GUIDE, + K_GP_START, + K_GP_LEFT_STICK, + K_GP_RIGHT_STICK, + K_GP_LEFT_SHOULDER, + K_GP_RIGHT_SHOULDER, + K_GP_DPAD_UP, + K_GP_DPAD_DOWN, + K_GP_DPAD_LEFT, + K_GP_DPAD_RIGHT, + K_GP_MISC1, + K_GP_PADDLE1, + K_GP_PADDLE2, + K_GP_PADDLE3, + K_GP_PADDLE4, + K_GP_TOUCHPAD +}; + static struct sdljoy_s { //fte doesn't distinguish between joysticks and controllers. @@ -104,8 +143,15 @@ static struct sdljoy_s SDL_GameController *controller; SDL_JoystickID id; unsigned int qdevid; + + //axis junk unsigned int axistobuttonp; unsigned int axistobuttonn; + float repeattime[countof(gpaxismap)]; + + //button junk + unsigned int buttonheld; + float buttonrepeat[countof(gpbuttonmap)]; } sdljoy[MAX_JOYSTICKS]; //the enumid is the value for the open function rather than the working id. @@ -167,6 +213,9 @@ static void J_JoystickAdded(int enumid) if (i == MAX_JOYSTICKS) return; + if (SDL_IsGameController(enumid)) //if its reported via the gamecontroller api then use that instead. don't open it twice. + return; + sdljoy[i].joystick = SDL_JoystickOpen(enumid); if (!sdljoy[i].joystick) return; @@ -188,46 +237,48 @@ static struct sdljoy_s *J_DevId(SDL_JoystickID jid) } static void J_ControllerAxis(SDL_JoystickID jid, int axis, int value) { - static struct - { - int qaxis; - keynum_t pos, neg; - } axismap[] = - { - {/*SDL_CONTROLLER_AXIS_LEFTX*/ GPAXIS_LT_RIGHT, K_GP_LEFT_THUMB_RIGHT, K_GP_LEFT_THUMB_LEFT}, - {/*SDL_CONTROLLER_AXIS_LEFTY*/ GPAXIS_LT_DOWN, K_GP_LEFT_THUMB_DOWN, K_GP_LEFT_THUMB_UP}, - {/*SDL_CONTROLLER_AXIS_RIGHTX*/ GPAXIS_RT_RIGHT, K_GP_RIGHT_THUMB_RIGHT, K_GP_RIGHT_THUMB_LEFT}, - {/*SDL_CONTROLLER_AXIS_RIGHTY*/ GPAXIS_RT_DOWN, K_GP_RIGHT_THUMB_DOWN, K_GP_RIGHT_THUMB_UP}, - {/*SDL_CONTROLLER_AXIS_TRIGGERLEFT*/ GPAXIS_LT_TRIGGER, K_GP_LEFT_TRIGGER, 0}, - {/*SDL_CONTROLLER_AXIS_TRIGGERRIGHT*/ GPAXIS_RT_TRIGGER, K_GP_RIGHT_TRIGGER, 0}, - }; - struct sdljoy_s *joy = J_DevId(jid); - if (joy && axis < sizeof(axismap)/sizeof(axismap[0]) && joy->qdevid != DEVID_UNSET) + + if (joy->qdevid == DEVID_UNSET) { - if (value > 0x4000 && axismap[axis].pos) + if (abs(value) < 0x4000) + return; //has to be big enough to handle any generous dead zone. + J_AllocateDevID(joy); + } + + if (joy && axis < countof(gpaxismap) && joy->qdevid != DEVID_UNSET) + { + if (value > 0x4000 && gpaxismap[axis].pos) { - IN_KeyEvent(joy->qdevid, true, axismap[axis].pos, 0); + if (!(joy->axistobuttonp & (1u<qdevid, true, gpaxismap[axis].pos, 0); + joy->repeattime[axis] = 1.0; + } joy->axistobuttonp |= 1u<axistobuttonp & (1u<qdevid, false, axismap[axis].pos, 0); + IN_KeyEvent(joy->qdevid, false, gpaxismap[axis].pos, 0); joy->axistobuttonp &= ~(1u<qdevid, true, axismap[axis].neg, 0); + if (!(joy->axistobuttonn & (1u<qdevid, true, gpaxismap[axis].neg, 0); + joy->repeattime[axis] = 1.0; + } joy->axistobuttonn |= 1u<axistobuttonn & (1u<qdevid, false, axismap[axis].neg, 0); + IN_KeyEvent(joy->qdevid, false, gpaxismap[axis].neg, 0); joy->axistobuttonn &= ~(1u<qdevid, axismap[axis].qaxis, value / 32767.0); + IN_JoystickAxisEvent(joy->qdevid, gpaxismap[axis].qaxis, value / 32767.0); } } static void J_JoystickAxis(SDL_JoystickID jid, int axis, int value) @@ -235,7 +286,7 @@ static void J_JoystickAxis(SDL_JoystickID jid, int axis, int value) static const int axismap[] = {0,1,3,4,2,5}; struct sdljoy_s *joy = J_DevId(jid); - if (joy && axis < sizeof(axismap)/sizeof(axismap[0]) && joy->qdevid != DEVID_UNSET) + if (joy && !joy->controller && axis < sizeof(axismap)/sizeof(axismap[0]) && joy->qdevid != DEVID_UNSET) IN_JoystickAxisEvent(joy->qdevid, axismap[axis], value / 32767.0); } //we don't do hats and balls and stuff. @@ -243,33 +294,8 @@ static void J_ControllerButton(SDL_JoystickID jid, int button, qboolean pressed) { //controllers have reliable button maps. //but that doesn't meant that fte has specific k_ names for those buttons, but the mapping should be reliable, at least until they get mapped to proper k_ values. - static const int buttonmap[] = - { - K_GP_A, - K_GP_B, - K_GP_X, - K_GP_Y, - K_GP_BACK, - K_GP_GUIDE, - K_GP_START, - K_GP_LEFT_STICK, - K_GP_RIGHT_STICK, - K_GP_LEFT_SHOULDER, - K_GP_RIGHT_SHOULDER, - K_GP_DPAD_UP, - K_GP_DPAD_DOWN, - K_GP_DPAD_LEFT, - K_GP_DPAD_RIGHT, - K_GP_MISC1, - K_GP_PADDLE1, - K_GP_PADDLE2, - K_GP_PADDLE3, - K_GP_PADDLE4, - K_GP_TOUCHPAD - }; - struct sdljoy_s *joy = J_DevId(jid); - if (joy && button < sizeof(buttonmap)/sizeof(buttonmap[0])) + if (joy && button < countof(gpbuttonmap)) { if (joy->qdevid == DEVID_UNSET) { @@ -277,7 +303,12 @@ static void J_ControllerButton(SDL_JoystickID jid, int button, qboolean pressed) return; J_AllocateDevID(joy); } - IN_KeyEvent(joy->qdevid, pressed, buttonmap[button], 0); + if (pressed) + joy->buttonheld |= (1u<buttonheld &= ~(1u<qdevid, pressed, gpbuttonmap[button], 0); + joy->buttonrepeat[button] = 1.0; } } static void J_JoystickButton(SDL_JoystickID jid, int button, qboolean pressed) @@ -335,7 +366,7 @@ static void J_JoystickButton(SDL_JoystickID jid, int button, qboolean pressed) }; struct sdljoy_s *joy = J_DevId(jid); - if (joy && button < sizeof(buttonmap)/sizeof(buttonmap[0])) + if (joy && !joy->controller && button < sizeof(buttonmap)/sizeof(buttonmap[0])) { if (joy->qdevid == DEVID_UNSET) { @@ -936,6 +967,71 @@ static unsigned int tbl_sdltoquake[] = /* stubbed */ qboolean INS_KeyToLocalName(int qkey, char *buf, size_t bufsize) { + const char *keyname; + + //too lazy to make+maintain a reverse MySDL_MapKey, so lets just make a reverse table with it instead. + static qboolean stupidtabsetup; + static SDL_Keycode stupidtable[K_MAX]; + if (!stupidtabsetup) + { + int i, k; + for (i = 0; i < SDL_NUM_SCANCODES; i++) + { + k = MySDL_MapKey(i); + if (k) + stupidtable[k] = i; + + //grr, oh well, at least we're not scanning 2 billion codes here + k = MySDL_MapKey(SDL_SCANCODE_TO_KEYCODE(i)); + if (k) + stupidtable[k] = SDL_SCANCODE_TO_KEYCODE(i); + } + stupidtabsetup = true; + } + + if (stupidtable[qkey]) + keyname = SDL_GetKeyName(stupidtable[qkey]); + else if (qkey >= K_GP_DIAMOND_DOWN && qkey < K_GP_TOUCHPAD) + { + SDL_GameControllerButton b; + switch(qkey) + { + case K_GP_DIAMOND_DOWN: b = SDL_CONTROLLER_BUTTON_A; break; + case K_GP_DIAMOND_RIGHT: b = SDL_CONTROLLER_BUTTON_B; break; + case K_GP_DIAMOND_LEFT: b = SDL_CONTROLLER_BUTTON_X; break; + case K_GP_DIAMOND_UP: b = SDL_CONTROLLER_BUTTON_Y; break; + case K_GP_BACK: b = SDL_CONTROLLER_BUTTON_BACK; break; + case K_GP_GUIDE: b = SDL_CONTROLLER_BUTTON_GUIDE; break; + case K_GP_START: b = SDL_CONTROLLER_BUTTON_START; break; + case K_GP_LEFT_STICK: b = SDL_CONTROLLER_BUTTON_LEFTSTICK; break; + case K_GP_RIGHT_STICK: b = SDL_CONTROLLER_BUTTON_RIGHTSTICK; break; + case K_GP_LEFT_SHOULDER: b = SDL_CONTROLLER_BUTTON_LEFTSHOULDER; break; + case K_GP_RIGHT_SHOULDER: b = SDL_CONTROLLER_BUTTON_RIGHTSHOULDER; break; + case K_GP_DPAD_UP: b = SDL_CONTROLLER_BUTTON_DPAD_UP; break; + case K_GP_DPAD_DOWN: b = SDL_CONTROLLER_BUTTON_DPAD_DOWN; break; + case K_GP_DPAD_LEFT: b = SDL_CONTROLLER_BUTTON_DPAD_LEFT; break; + case K_GP_DPAD_RIGHT: b = SDL_CONTROLLER_BUTTON_DPAD_RIGHT; break; +#if SDL_VERSION_ATLEAST(2, 0, 14) + case K_GP_MISC1: b = SDL_CONTROLLER_BUTTON_MISC1; break; + case K_GP_PADDLE1: b = SDL_CONTROLLER_BUTTON_PADDLE1; break; + case K_GP_PADDLE2: b = SDL_CONTROLLER_BUTTON_PADDLE2; break; + case K_GP_PADDLE3: b = SDL_CONTROLLER_BUTTON_PADDLE3; break; + case K_GP_PADDLE4: b = SDL_CONTROLLER_BUTTON_PADDLE4; break; + case K_GP_TOUCHPAD: b = SDL_CONTROLLER_BUTTON_TOUCHPAD; break; +#endif + default: + return false; + } + keyname = SDL_GameControllerGetStringForButton(b); + } + else + return false; + + if (keyname) + { + Q_strncpyz(buf, keyname, bufsize); + return true; + } return false; } @@ -998,7 +1094,7 @@ void Sys_SendKeyEvents(void) else #endif { - #if SDL_PATCHLEVEL >= 1 + #if SDL_VERSION_ATLEAST(2,0,1) SDL_GL_GetDrawableSize(sdlwindow, &vid.pixelwidth, &vid.pixelheight); //get the proper physical size. #else SDL_GetWindowSize(sdlwindow, &vid.pixelwidth, &vid.pixelheight); @@ -1070,6 +1166,11 @@ void Sys_SendKeyEvents(void) } break; #ifdef HAVE_SDL_TEXTINPUT + /*case SDL_TEXTEDITING: + { + event.edit; + } + break;*/ case SDL_TEXTINPUT: { unsigned int uc; @@ -1094,7 +1195,7 @@ void Sys_SendKeyEvents(void) { uint32_t thefinger = SDL_GiveFinger(-1, event.tfinger.touchId, event.tfinger.fingerId, event.type==SDL_FINGERUP); IN_MouseMove(thefinger, true, event.tfinger.x * vid.pixelwidth, event.tfinger.y * vid.pixelheight, 0, event.tfinger.pressure); - IN_KeyEvent(thefinger, event.type==SDL_FINGERDOWN, K_MOUSE1, 0); + IN_KeyEvent(thefinger, event.type==SDL_FINGERDOWN, K_TOUCH, 0); } break; case SDL_FINGERMOTION: @@ -1220,6 +1321,50 @@ void Sys_SendKeyEvents(void) #endif } } + + for (j = 0; j < MAX_JOYSTICKS; j++) + { + struct sdljoy_s *joy = &sdljoy[j]; + if (joy->qdevid == DEVID_UNSET || !joy->controller) + continue; + + if (joy->buttonheld) + { + for (axis = 0; axis < countof(gpbuttonmap); axis++) + { + if (joy->buttonheld & (1u<buttonrepeat[axis] -= host_frametime; + if (joy->buttonrepeat[axis] < 0) + { + IN_KeyEvent(joy->qdevid, true, gpbuttonmap[axis], 0); + joy->buttonrepeat[axis] = 0.25; + } + } + } + } + + for (axis = 0; axis < countof(gpaxismap); axis++) + { + if ((joy->axistobuttonp | joy->axistobuttonn) & (1u<repeattime[axis] -= host_frametime; + if (joy->repeattime[axis] < 0) + { + if (joy->axistobuttonp & (1u<qdevid, true, gpaxismap[axis].pos, 0); + joy->repeattime[axis] = 0.25; + } + if (joy->axistobuttonn & (1u<qdevid, true, gpaxismap[axis].neg, 0); + joy->repeattime[axis] = 0.25; + } + } + } + } + } } diff --git a/engine/client/in_win.c b/engine/client/in_win.c index efb0fe83f..990132df6 100644 --- a/engine/client/in_win.c +++ b/engine/client/in_win.c @@ -2137,10 +2137,10 @@ static qboolean INS_ReadJoystick (struct wjoy_s *joy) if (joy->devid != DEVID_UNSET) { IN_JoystickAxisEvent(joy->devid, GPAXIS_LT_RIGHT, xistate.Gamepad.sThumbLX / 32768.0); - IN_JoystickAxisEvent(joy->devid, GPAXIS_LT_DOWN, xistate.Gamepad.sThumbLY / 32768.0); + IN_JoystickAxisEvent(joy->devid, GPAXIS_LT_DOWN, -xistate.Gamepad.sThumbLY / 32768.0); IN_JoystickAxisEvent(joy->devid, GPAXIS_LT_TRIGGER, xistate.Gamepad.bLeftTrigger/255.0); IN_JoystickAxisEvent(joy->devid, GPAXIS_RT_RIGHT, xistate.Gamepad.sThumbRX / 32768.0); - IN_JoystickAxisEvent(joy->devid, GPAXIS_RT_DOWN, xistate.Gamepad.sThumbRY / 32768.0); + IN_JoystickAxisEvent(joy->devid, GPAXIS_RT_DOWN, -xistate.Gamepad.sThumbRY / 32768.0); IN_JoystickAxisEvent(joy->devid, GPAXIS_RT_TRIGGER, xistate.Gamepad.bRightTrigger/255.0); vibrator.wLeftMotorSpeed = xinput_leftvibrator.value * 0xffff; diff --git a/engine/client/keys.c b/engine/client/keys.c index 440e7888d..e2d6a5c73 100644 --- a/engine/client/keys.c +++ b/engine/client/keys.c @@ -198,6 +198,7 @@ keyname_t keynames[] = {"MWHEELDOWN", K_MWHEELDOWN}, {"MWHEELLEFT", K_MWHEELLEFT}, {"MWHEELRIGHT", K_MWHEELRIGHT}, + {"TOUCH", K_TOUCH}, {"LWIN", K_LWIN}, //windows name {"RWIN", K_RWIN}, //windows name @@ -280,7 +281,7 @@ keyname_t keynames[] = {"BACKQUOTE", '`'}, {"BACKSLASH", '\\'}, - {"GP_A", K_GP_A}, + {"GP_A", K_GP_A}, //note: xbox arrangement, not nintendo arrangement. {"GP_B", K_GP_B}, {"GP_X", K_GP_X}, {"GP_Y", K_GP_Y}, @@ -288,8 +289,8 @@ keyname_t keynames[] = {"GP_RSHOULDER", K_GP_RIGHT_SHOULDER}, {"GP_LTRIGGER", K_GP_LEFT_TRIGGER}, {"GP_RTRIGGER", K_GP_RIGHT_TRIGGER}, - {"GP_BACK", K_GP_BACK}, - {"GP_START", K_GP_START}, + {"GP_VIEW", K_GP_VIEW}, + {"GP_MENU", K_GP_MENU}, {"GP_LTHUMB", K_GP_LEFT_STICK}, {"GP_RTHUMB", K_GP_RIGHT_STICK}, {"GP_DPAD_UP", K_GP_DPAD_UP}, @@ -305,12 +306,18 @@ keyname_t keynames[] = {"GP_TOUCHPAD", K_GP_TOUCHPAD}, {"GP_UNKNOWN", K_GP_UNKNOWN}, + //older xbox names + {"GP_BACK", K_GP_BACK}, + {"GP_START", K_GP_START}, //names for playstation controllers {"GP_CROSS", K_GP_PS_CROSS}, {"GP_CIRCLE", K_GP_PS_CIRCLE}, {"GP_SQUARE", K_GP_PS_SQUARE}, {"GP_TRIANGLE", K_GP_PS_TRIANGLE}, - {"GP_MIC", K_GP_MISC1}, + {"GP_MIC", K_GP_MISC1}, + {"GP_SELECT", K_GP_VIEW}, + {"GP_SHARE", K_GP_VIEW}, + {"GP_OPTIONS", K_GP_START}, //axis->button emulation {"GP_LTHUMB_UP", K_GP_LEFT_THUMB_UP}, @@ -1252,7 +1259,7 @@ void Key_ConsoleRelease(console_t *con, int key, unsigned int unicode) } con->buttonsdown = CB_NONE; } - if (key == K_MOUSE1 && con->buttonsdown == CB_SCROLL)// || (key == K_MOUSE2 && con->buttonsdown == CB_SCROLL_R)) + if ((key == K_TOUCH || key == K_MOUSE1) && con->buttonsdown == CB_SCROLL)// || (key == K_MOUSE2 && con->buttonsdown == CB_SCROLL_R)) { con->buttonsdown = CB_NONE; if (fabs(con->mousedown[0] - con->mousecursor[0]) < 5 && fabs(con->mousedown[1] - con->mousecursor[1]) < 5) @@ -1654,7 +1661,7 @@ qboolean Key_EntryLine(console_t *con, unsigned char **line, int lineoffset, int *linepos = utf_left((*line)+lineoffset, (*line) + *linepos, !alt) - (*line); return true; } - if (key == K_RIGHTARROW || key == K_KP_RIGHTARROW) + if (key == K_RIGHTARROW || key == K_KP_RIGHTARROW || key == K_GP_DPAD_RIGHT) { if ((*line)[*linepos]) { @@ -1869,13 +1876,13 @@ qboolean Key_Console (console_t *con, int key, unsigned int unicode) } if (con->redirect) { - if (key == K_MOUSE1 || key == K_MOUSE2) + if (key == K_TOUCH || key == K_MOUSE1 || key == K_MOUSE2) ; else if (con->redirect(con, unicode, key)) return true; } - if (key == K_GP_BACK) + if (key == K_GP_VIEW || key == K_GP_MENU) { Key_Dest_Remove(kdm_console); Key_Dest_Remove(kdm_cwindows); @@ -1884,7 +1891,7 @@ qboolean Key_Console (console_t *con, int key, unsigned int unicode) return true; } - if ((key == K_MOUSE1 || key == K_MOUSE2)) + if (key == K_TOUCH || key == K_MOUSE1 || key == K_MOUSE2) { int olddown[2] = {con->mousedown[0],con->mousedown[1]}; if (con->flags & CONF_ISWINDOW) @@ -1922,7 +1929,7 @@ qboolean Key_Console (console_t *con, int key, unsigned int unicode) return true; con->flags &= ~CONF_KEEPSELECTION; - if (Key_IsTouchScreen()) //o.O mouse2+touchscreen? really? + if (key == K_TOUCH) con->buttonsdown = CB_COPY; else con->buttonsdown = CB_SCROLL_R; @@ -1947,7 +1954,7 @@ qboolean Key_Console (console_t *con, int key, unsigned int unicode) return true; } #endif - if (Key_IsTouchScreen() || con->mousecursor[0] > ((con->flags & CONF_ISWINDOW)?con->wnd_w-16:vid.width)-8) + if (key == K_TOUCH || con->mousecursor[0] > ((con->flags & CONF_ISWINDOW)?con->wnd_w-16:vid.width)-8) { //just scroll the console up/down con->buttonsdown = CB_SCROLL; } @@ -1990,7 +1997,7 @@ qboolean Key_Console (console_t *con, int key, unsigned int unicode) return true; } - if (key == K_PGUP || key == K_KP_PGUP || key==K_MWHEELUP) + if (key == K_PGUP || key == K_KP_PGUP || key==K_MWHEELUP || key == K_GP_LEFT_THUMB_UP) { conline_t *l; int i = 2; @@ -2016,7 +2023,7 @@ qboolean Key_Console (console_t *con, int key, unsigned int unicode) return true; } } - if (key == K_PGDN || key == K_KP_PGDN || key==K_MWHEELDOWN) + if (key == K_PGDN || key == K_KP_PGDN || key==K_MWHEELDOWN || key == K_GP_LEFT_THUMB_DOWN) { int i = 2; if (ctrl) @@ -2092,7 +2099,7 @@ qboolean Key_Console (console_t *con, int key, unsigned int unicode) return false; } - if (key == K_ENTER || key == K_KP_ENTER || key == K_GP_START) + if (key == K_ENTER || key == K_KP_ENTER || key == K_GP_DIAMOND_CONFIRM) { // backslash text are commands, else chat char demoji[8192]; const char *txt = Key_Demoji(demoji, sizeof(demoji), key_lines[edit_line]); @@ -2247,7 +2254,7 @@ void Key_Message (int key, int unicode) chat_bufferpos = 0; } - if (key == K_ENTER || key == K_KP_ENTER || key == K_GP_START) + if (key == K_ENTER || key == K_KP_ENTER || key == K_GP_DIAMOND_CONFIRM) { if (chat_buffer && chat_buffer[0]) { //send it straight into the command. @@ -2280,7 +2287,7 @@ void Key_Message (int key, int unicode) return; } - if (key == K_ESCAPE || key == K_GP_BACK) + if (key == K_ESCAPE || key == K_GP_DIAMOND_CANCEL) { Key_Dest_Remove(kdm_message); chat_bufferpos = 0; @@ -2898,6 +2905,7 @@ void Key_Init (void) } consolekeys[K_MWHEELUP] = true; consolekeys[K_MWHEELDOWN] = true; + consolekeys[K_TOUCH] = true; // // register our functions @@ -3076,7 +3084,7 @@ void Key_Event (unsigned int devid, int key, unsigned int unicode, qboolean down con = con_curwindow; else con = NULL; - if (con_mouseover && key >= K_MOUSE1 && key <= K_MWHEELDOWN) + if (con_mouseover && ((key >= K_MOUSE1 && key <= K_MWHEELDOWN) || key == K_TOUCH)) con = con_mouseover; if (con_curwindow && con_curwindow != con) con_curwindow->buttonsdown = CB_NONE; @@ -3142,7 +3150,7 @@ void Key_Event (unsigned int devid, int key, unsigned int unicode, qboolean down if (/*conkey &&*/Key_Dest_Has(kdm_console|kdm_cwindows)) { console_t *con = Key_Dest_Has(kdm_console)?con_current:con_curwindow; - if ((con_mouseover||!Key_Dest_Has(kdm_console)) && key >= K_MOUSE1 && key <= K_MWHEELDOWN) + if ((con_mouseover||!Key_Dest_Has(kdm_console)) && ((key >= K_MOUSE1 && key <= K_MWHEELDOWN)||key==K_TOUCH)) con = con_mouseover; if (con) { @@ -3236,8 +3244,10 @@ void Key_Event (unsigned int devid, int key, unsigned int unicode, qboolean down //gamepad buttons should get fallbacks out of the box, even if they're not initially listed on the binds menu. //these may be redefined later... - case K_GP_LEFT_SHOULDER: dc = "impulse 12"; goto defaultedbind; //matches QS's default.cfg - case K_GP_RIGHT_SHOULDER: dc = "impulse 10"; goto defaultedbind; //matches QS's default.cfg +// case K_GP_LEFT_SHOULDER: dc = "impulse 12"; goto defaultedbind; //matches QS's default.cfg +// case K_GP_RIGHT_SHOULDER: dc = "impulse 10"; goto defaultedbind; //matches QS's default.cfg + case K_GP_LEFT_SHOULDER: dc = "impulse 10"; goto defaultedbind; + case K_GP_RIGHT_SHOULDER: dc = "+weaponwheel"; goto defaultedbind; case K_GP_LEFT_TRIGGER: dc = "+button3"; goto defaultedbind; //matches QS's default.cfg case K_GP_RIGHT_TRIGGER: dc = "+attack"; goto defaultedbind; //matches QS's default.cfg case K_GP_START: dc = "togglemenu"; goto defaultedbind; @@ -3264,7 +3274,7 @@ void Key_Event (unsigned int devid, int key, unsigned int unicode, qboolean down } defaultedbind: - if (key == K_MOUSE1 && IN_MouseDevIsTouch(devid)) + if (key == K_TOUCH || (key == K_MOUSE1 && IN_MouseDevIsTouch(devid))) { char *button = SCR_ShowPics_ClickCommand(mousecursor_x, mousecursor_y); if (button) diff --git a/engine/client/keys.h b/engine/client/keys.h index f8e126c20..f7131554e 100644 --- a/engine/client/keys.h +++ b/engine/client/keys.h @@ -172,9 +172,13 @@ typedef enum { K_GP_DIAMOND_RIGHT, K_GP_DIAMOND_LEFT, K_GP_DIAMOND_UP, - K_GP_BACK, +//for their behaviours in the menus... we may want to put a conditional in here for japanese-style right-for-confirm, but for now I'm lazy and am sticking with western/xbox/steam mappings. +#define K_GP_DIAMOND_CONFIRM K_GP_DIAMOND_DOWN //roughly equivelent to k_return for menu behaviours +#define K_GP_DIAMOND_CANCEL K_GP_DIAMOND_RIGHT //roughly like escape, at least in menus +#define K_GP_DIAMOND_ALTCONFIRM K_GP_DIAMOND_UP //for more negative confirmations. + K_GP_VIEW, K_GP_GUIDE, - K_GP_START, + K_GP_MENU, K_GP_LEFT_STICK, K_GP_RIGHT_STICK, K_GP_LEFT_SHOULDER, @@ -232,6 +236,8 @@ typedef enum { K_RSHIFT, K_PRINTSCREEN, + K_TOUCH, + /* multimedia keyboard */ K_MM_BROWSER_BACK, K_MM_BROWSER_FAVORITES, @@ -251,6 +257,8 @@ typedef enum { K_GP_B = K_GP_DIAMOND_RIGHT, K_GP_X = K_GP_DIAMOND_LEFT, K_GP_Y = K_GP_DIAMOND_UP, + K_GP_BACK = K_GP_VIEW, + K_GP_START = K_GP_MENU, //ps buttons K_GP_PS_CROSS = K_GP_DIAMOND_DOWN, diff --git a/engine/client/m_download.c b/engine/client/m_download.c index 72235c576..b99ada448 100644 --- a/engine/client/m_download.c +++ b/engine/client/m_download.c @@ -5380,13 +5380,13 @@ static qboolean MD_Key (struct menucustom_s *c, struct emenu_s *m, int key, unsi p = c->dptr; if (key == 'c' && ctrl) Sys_SaveClipboard(CBT_CLIPBOARD, p->website); - else if (key == K_DEL || key == K_KP_DEL || key == K_BACKSPACE) + else if (key == K_DEL || key == K_KP_DEL || key == K_BACKSPACE || key == K_GP_DIAMOND_ALTCONFIRM) { if (!(p->flags & DPF_MARKED)) p->flags |= DPF_PURGE; //purge it when its already not marked (ie: when pressed twice) PM_UnmarkPackage(p, DPF_MARKED); //deactivate it } - else if (key == K_ENTER || key == K_KP_ENTER || key == K_GP_START || key == K_MOUSE1 || key == K_GP_A) + else if (key == K_ENTER || key == K_KP_ENTER || key == K_MOUSE1 || key == K_TOUCH || key == K_GP_DIAMOND_CONFIRM) { if (p->alternative && (p->flags & DPF_HIDDEN)) p = p->alternative; @@ -5554,7 +5554,7 @@ static qboolean MD_MapKey (struct menucustom_s *c, struct emenu_s *m, int key, u if (c->dint != downloadablessequence) return false; //probably stale - if (key == K_ENTER || key == K_KP_ENTER || key == K_GP_START || key == K_MOUSE1 || key == K_GP_A) + if (key == K_ENTER || key == K_KP_ENTER || key == K_GP_START || key == K_MOUSE1 || key == K_TOUCH || key == K_GP_DIAMOND_CONFIRM) for (dep = p->deps; dep; dep = dep->next) { if (dep == map) @@ -5628,7 +5628,7 @@ static void MD_Source_Draw (int x, int y, struct menucustom_s *c, struct emenu_s } static qboolean MD_Source_Key (struct menucustom_s *c, struct emenu_s *m, int key, unsigned int unicode) { - if (key == K_ENTER || key == K_KP_ENTER || key == K_GP_START || key == K_MOUSE1) + if (key == K_ENTER || key == K_KP_ENTER || key == K_GP_DIAMOND_CONFIRM || key == K_MOUSE1 || key == K_TOUCH) { if (pm_source[c->dint].flags & SRCFL_DISABLED) { @@ -5642,8 +5642,9 @@ static qboolean MD_Source_Key (struct menucustom_s *c, struct emenu_s *m, int ke } PM_WriteInstalledPackages(); PM_UpdatePackageList(true, 2); + return true; } - if (key == K_DEL || key == K_BACKSPACE) + if (key == K_DEL || key == K_BACKSPACE || key == K_GP_DIAMOND_ALTCONFIRM) { if (pm_source[c->dint].flags & SRCFL_ENABLED) { @@ -5659,6 +5660,7 @@ static qboolean MD_Source_Key (struct menucustom_s *c, struct emenu_s *m, int ke return false; //will just be re-added anyway... :( PM_WriteInstalledPackages(); PM_UpdatePackageList(true, 2); + return true; } return false; } @@ -5685,7 +5687,7 @@ static void MD_AutoUpdate_Draw (int x, int y, struct menucustom_s *c, struct eme } static qboolean MD_AutoUpdate_Key (struct menucustom_s *c, struct emenu_s *m, int key, unsigned int unicode) { - if (key == K_ENTER || key == K_KP_ENTER || key == K_GP_START || key == K_MOUSE1) + if (key == K_ENTER || key == K_KP_ENTER || key == K_GP_DIAMOND_CONFIRM || key == K_MOUSE1 || key == K_TOUCH) { char nv[8] = "0"; if (pkg_autoupdate.ival < UPD_TESTING && pkg_autoupdate.ival >= 0) @@ -5700,7 +5702,7 @@ static qboolean MD_AutoUpdate_Key (struct menucustom_s *c, struct emenu_s *m, in static qboolean MD_MarkUpdatesButton (union menuoption_s *mo,struct emenu_s *m,int key) { - if (key == K_ENTER || key == K_KP_ENTER || key == K_GP_START || key == K_MOUSE1) + if (key == K_ENTER || key == K_KP_ENTER || key == K_GP_DIAMOND_CONFIRM || key == K_MOUSE1 || key == K_TOUCH) { PM_MarkUpdates(); return true; @@ -5711,7 +5713,7 @@ static qboolean MD_MarkUpdatesButton (union menuoption_s *mo,struct emenu_s *m,i qboolean MD_PopMenu (union menuoption_s *mo,struct emenu_s *m,int key) { - if (key == K_ENTER || key == K_KP_ENTER || key == K_GP_START || key == K_MOUSE1) + if (key == K_ENTER || key == K_KP_ENTER || key == K_GP_DIAMOND_CONFIRM || key == K_MOUSE1 || key == K_TOUCH) { M_RemoveMenu(m); return true; @@ -5721,7 +5723,7 @@ qboolean MD_PopMenu (union menuoption_s *mo,struct emenu_s *m,int key) static qboolean MD_ApplyDownloads (union menuoption_s *mo,struct emenu_s *m,int key) { - if (key == K_ENTER || key == K_KP_ENTER || key == K_GP_START || key == K_MOUSE1) + if (key == K_ENTER || key == K_KP_ENTER || key == K_GP_DIAMOND_CONFIRM || key == K_MOUSE1 || key == K_TOUCH) { PM_PromptApplyChanges(); return true; @@ -5731,7 +5733,7 @@ static qboolean MD_ApplyDownloads (union menuoption_s *mo,struct emenu_s *m,int static qboolean MD_RevertUpdates (union menuoption_s *mo,struct emenu_s *m,int key) { - if (key == K_ENTER || key == K_KP_ENTER || key == K_GP_START || key == K_MOUSE1) + if (key == K_ENTER || key == K_KP_ENTER || key == K_GP_DIAMOND_CONFIRM || key == K_MOUSE1 || key == K_TOUCH) { PM_RevertChanges(); return true; diff --git a/engine/client/m_items.c b/engine/client/m_items.c index 6eefca967..60c372e8b 100644 --- a/engine/client/m_items.c +++ b/engine/client/m_items.c @@ -660,7 +660,7 @@ static void MenuDrawItems(int xpos, int ypos, menuoption_t *option, emenu_t *men } else { - if (!keydown[K_MOUSE1]) + if (!keydown[K_MOUSE1] && !keydown[K_TOUCH]) option->frame.mousedown = false; option->frame.frac = M_DrawScrollbar(xpos+option->frame.common.posx, ypos+option->common.posy, option->frame.common.width, option->frame.common.height, option->frame.frac, option->frame.mousedown); @@ -1380,7 +1380,7 @@ menucombo_t *MC_AddCombo(emenu_t *menu, int tx, int cx, int y, const char *capti optbufsize = sizeof(char*); numopts = 0; optlen = 0; - while(ops[numopts]) + if (ops) while(ops[numopts]) { optlen = strlen(ops[numopts]); if (maxoptlen < optlen) @@ -1621,7 +1621,7 @@ void MC_Slider_Key(menuslider_t *option, int key) else delta = 0.1; - if (key == K_LEFTARROW || key == K_KP_LEFTARROW || key == K_GP_DPAD_LEFT || key == K_GP_A || key == K_MWHEELDOWN) + if (key == K_LEFTARROW || key == K_KP_LEFTARROW || key == K_GP_DPAD_LEFT || key == K_GP_LEFT_THUMB_LEFT || key == K_GP_DIAMOND_CONFIRM || key == K_MWHEELDOWN) { range -= delta; if (option->min > option->max) @@ -1630,7 +1630,7 @@ void MC_Slider_Key(menuslider_t *option, int key) range = bound(option->min, range, option->max); option->current = range; } - else if (key == K_RIGHTARROW || key == K_KP_RIGHTARROW || key == K_GP_DPAD_RIGHT || key == K_GP_B || key == K_MWHEELUP) + else if (key == K_RIGHTARROW || key == K_KP_RIGHTARROW || key == K_GP_DPAD_RIGHT || key == K_GP_LEFT_THUMB_RIGHT || key == K_GP_DIAMOND_ALTCONFIRM || key == K_MWHEELUP) { range += delta; if (option->min > option->max) @@ -1639,7 +1639,7 @@ void MC_Slider_Key(menuslider_t *option, int key) range = bound(option->min, range, option->max); option->current = range; } - else if (key == K_MOUSE1 && mousecursor_x >= ix-8 && mousecursor_x < ex+8) + else if ((key == K_TOUCH || key == K_MOUSE1) && mousecursor_x >= ix-8 && mousecursor_x < ex+8) { range = (mousecursor_x - ix) / (ex - ix); range = option->min + range*(option->max-option->min); @@ -1649,7 +1649,7 @@ void MC_Slider_Key(menuslider_t *option, int key) range = bound(option->min, range, option->max); option->current = range; } - else if (key == K_ENTER || key == K_KP_ENTER || key == K_GP_START || key == K_MOUSE1) + else if (key == K_ENTER || key == K_KP_ENTER || key == K_GP_START || key == K_MOUSE1 || key == K_TOUCH) { if (range == option->max) range = option->min; @@ -1684,7 +1684,7 @@ void MC_Slider_Key(menuslider_t *option, int key) void MC_CheckBox_Key(menucheck_t *option, emenu_t *menu, int key) { - if (key != K_ENTER && key != K_KP_ENTER && key != K_GP_START && key != K_GP_A && key != K_GP_B && key != K_LEFTARROW && key != K_KP_LEFTARROW && key != K_GP_DPAD_LEFT && key != K_RIGHTARROW && key != K_KP_LEFTARROW && key != K_GP_DPAD_RIGHT && key != K_MWHEELUP && key != K_MWHEELDOWN && key != K_MOUSE1) + if (key != K_ENTER && key != K_KP_ENTER && key != K_GP_START && key != K_GP_DIAMOND_CONFIRM && key != K_GP_DIAMOND_ALTCONFIRM && key != K_LEFTARROW && key != K_KP_LEFTARROW && key != K_GP_DPAD_LEFT && key != K_GP_LEFT_THUMB_LEFT && key != K_RIGHTARROW && key != K_KP_LEFTARROW && key != K_GP_DPAD_RIGHT && key != K_GP_LEFT_THUMB_RIGHT && key != K_MWHEELUP && key != K_MWHEELDOWN && key != K_MOUSE1 && key != K_TOUCH) return; if (option->func) option->func(option, menu, CHK_TOGGLE); @@ -1750,7 +1750,7 @@ void MC_EditBox_Key(menuedit_t *edit, int key, unsigned int unicode) void MC_Combo_Key(menucombo_t *combo, int key) { - if (key == K_ENTER || key == K_KP_ENTER || key == K_GP_START || key == K_RIGHTARROW || key == K_KP_RIGHTARROW || key == K_GP_DPAD_RIGHT || key == K_GP_B || key == K_MWHEELDOWN || key == K_MOUSE1) + if (key == K_ENTER || key == K_KP_ENTER || key == K_GP_START || key == K_RIGHTARROW || key == K_KP_RIGHTARROW || key == K_GP_DPAD_RIGHT || key == K_GP_LEFT_THUMB_RIGHT ||key == K_GP_DIAMOND_ALTCONFIRM || key == K_MWHEELDOWN || key == K_MOUSE1 || key == K_TOUCH) { combo->selectedoption++; if (combo->selectedoption >= combo->numoptions) @@ -1761,7 +1761,7 @@ changed: Cvar_Set(combo->cvar, (char *)combo->values[combo->selectedoption]); S_LocalSound ("misc/menu2.wav"); } - else if (key == K_LEFTARROW || key == K_KP_LEFTARROW || key == K_GP_DPAD_LEFT || key == K_GP_A || key == K_MWHEELUP) + else if (key == K_LEFTARROW || key == K_KP_LEFTARROW || key == K_GP_DPAD_LEFT || key == K_GP_LEFT_THUMB_LEFT || key == K_GP_DIAMOND_CONFIRM || key == K_MWHEELUP) { combo->selectedoption--; if (combo->selectedoption < 0) @@ -1810,7 +1810,7 @@ static qboolean M_KeyEvent(menu_t *m, qboolean isdown, unsigned int devid, int k emenu_t *menu = (emenu_t*)m; if (isdown) { - if (key == K_MOUSE1) //mouse clicks are deferred until the release event. this is for touch screens and aiming. + if (key == K_MOUSE1 || key == K_TOUCH) //mouse clicks are deferred until the release event. this is for touch screens and aiming. { if (menu->mouseitem && menu->mouseitem->common.type == mt_frameend) menu->mouseitem->frame.mousedown = true; @@ -1825,7 +1825,7 @@ static qboolean M_KeyEvent(menu_t *m, qboolean isdown, unsigned int devid, int k } else { - if (key == K_MOUSE1 && menu_mousedown) + if ((key == K_MOUSE1 || key == K_TOUCH) && menu_mousedown) M_Complex_Key (menu, key, unicode); else if (key == K_LSHIFT || key == K_RSHIFT || key == K_LALT || key == K_RALT || key == K_LCTRL || key == K_RCTRL) M_Complex_Key (menu, key, unicode); @@ -2040,7 +2040,7 @@ void M_Complex_Key(emenu_t *currentmenu, int key, int unicode) if (currentmenu->key(key, currentmenu)) return; - if (currentmenu->selecteditem && currentmenu->selecteditem->common.type == mt_custom && (key == K_DOWNARROW || key == K_KP_DOWNARROW || key == K_GP_DPAD_DOWN || key == K_GP_A || key == K_GP_B || key == K_UPARROW || key == K_KP_UPARROW || key == K_GP_DPAD_UP || key == K_TAB || key == K_MWHEELUP || key == K_MWHEELDOWN || key == K_PGUP || key == K_PGDN)) + if (currentmenu->selecteditem && currentmenu->selecteditem->common.type == mt_custom && (key == K_DOWNARROW || key == K_KP_DOWNARROW || key == K_GP_DPAD_DOWN || key == K_GP_LEFT_THUMB_DOWN || key == K_GP_DIAMOND_CONFIRM || key == K_GP_DIAMOND_ALTCONFIRM || key == K_UPARROW || key == K_KP_UPARROW || key == K_GP_DPAD_UP || key == K_GP_LEFT_THUMB_UP || key == K_TAB || key == K_MWHEELUP || key == K_MWHEELDOWN || key == K_PGUP || key == K_PGDN)) if (currentmenu->selecteditem->custom.key) if (currentmenu->selecteditem->custom.key(¤tmenu->selecteditem->custom, currentmenu, key, unicode)) return; @@ -2089,6 +2089,8 @@ void M_Complex_Key(emenu_t *currentmenu, int key, int unicode) case K_MOUSE4: //back case K_ESCAPE: case K_GP_BACK: + case K_GP_START: + case K_GP_DIAMOND_CANCEL: //remove M_RemoveMenu(currentmenu); #ifdef HEXEN2 @@ -2102,6 +2104,7 @@ void M_Complex_Key(emenu_t *currentmenu, int key, int unicode) case K_DOWNARROW: case K_KP_DOWNARROW: case K_GP_DPAD_DOWN: + case K_GP_LEFT_THUMB_DOWN: godown: currentmenu->selecteditem = M_NextSelectableItem(currentmenu, currentmenu->selecteditem, true); goto gone; @@ -2109,6 +2112,7 @@ void M_Complex_Key(emenu_t *currentmenu, int key, int unicode) case K_UPARROW: case K_KP_UPARROW: case K_GP_DPAD_UP: + case K_GP_LEFT_THUMB_UP: goup: currentmenu->selecteditem = M_PrevSelectableItem(currentmenu, currentmenu->selecteditem, true); goto gone; @@ -2189,6 +2193,7 @@ void M_Complex_Key(emenu_t *currentmenu, int key, int unicode) goto goup; else goto godown; } + case K_TOUCH: case K_MOUSE1: case K_MOUSE3: case K_MOUSE5: @@ -2211,6 +2216,7 @@ void M_Complex_Key(emenu_t *currentmenu, int key, int unicode) if (currentmenu->cursoritem) currentmenu->cursoritem->common.posy = currentmenu->selecteditem->common.posy; + break; //require a double-click when selecting... } //fall through default: @@ -2233,7 +2239,7 @@ void M_Complex_Key(emenu_t *currentmenu, int key, int unicode) case mt_qbuttonbigfont: if (!currentmenu->selecteditem->button.command) currentmenu->selecteditem->button.key(currentmenu->selecteditem, currentmenu, key); - else if (key == K_ENTER || key == K_KP_ENTER || key == K_GP_START || key == K_GP_A || key == K_GP_B || key == K_MOUSE1) + else if (key == K_ENTER || key == K_KP_ENTER || key == K_GP_DIAMOND_CONFIRM || key == K_GP_DIAMOND_ALTCONFIRM || key == K_MOUSE1 || key == K_TOUCH) { Cbuf_AddText(currentmenu->selecteditem->button.command, RESTRICT_LOCAL); #ifdef HEXEN2 @@ -2255,9 +2261,9 @@ void M_Complex_Key(emenu_t *currentmenu, int key, int unicode) MC_Combo_Key(¤tmenu->selecteditem->combo, key); break; case mt_bind: - if (key == K_ENTER || key == K_KP_ENTER || key == K_GP_START || key == K_GP_A || key == K_GP_B || key == K_MOUSE1) + if (key == K_ENTER || key == K_KP_ENTER || key == K_GP_DIAMOND_CONFIRM || key == K_MOUSE1 || key == K_TOUCH) bindingactive = true; - else if (key == K_BACKSPACE || key == K_DEL) + else if (key == K_BACKSPACE || key == K_DEL || key == K_GP_DIAMOND_ALTCONFIRM) M_UnbindCommand (currentmenu->selecteditem->bind.command); default: break; @@ -2271,7 +2277,7 @@ void M_Complex_Key(emenu_t *currentmenu, int key, int unicode) qboolean MC_Main_Key (int key, emenu_t *menu) //here purly to restart demos. { - if (key == K_ESCAPE || key == K_GP_BACK || key == K_MOUSE2) + if (key == K_ESCAPE || key == K_GP_BACK || key == K_GP_DIAMOND_CANCEL || key == K_MOUSE2) { extern cvar_t con_stayhidden; diff --git a/engine/client/m_master.c b/engine/client/m_master.c index 0c3395930..4b35486d1 100644 --- a/engine/client/m_master.c +++ b/engine/client/m_master.c @@ -344,7 +344,7 @@ static qboolean SL_ServerKey (menucustom_t *ths, emenu_t *menu, int key, unsigne serverinfo_t *server; qboolean ctrl = keydown[K_LCTRL] || keydown[K_RCTRL]; - if (key == K_MOUSE1) + if (key == K_MOUSE1 || key == K_TOUCH) { oldselection = info->selectedpos; info->selectedpos = info->scrollpos + (mousecursor_y-info->servers_top)/8; @@ -386,7 +386,7 @@ static qboolean SL_ServerKey (menucustom_t *ths, emenu_t *menu, int key, unsigne } } - else if (key == K_ENTER || key == K_KP_ENTER || key == K_GP_START || (ctrl && (key == 's' || key == 'j')) || key == K_SPACE) + else if (key == K_ENTER || key == K_KP_ENTER || key == K_GP_DIAMOND_CONFIRM || (ctrl && (key == 's' || key == 'j')) || key == K_SPACE) { server = Master_SortedServer(info->selectedpos); if (server) @@ -775,12 +775,12 @@ static qboolean SL_Key (int key, emenu_t *menu) serverinfo_t *server = selectedserver.inuse?Master_InfoForServer(&selectedserver.adr, selectedserver.brokerid):NULL; qboolean ctrldown = keydown[K_LCTRL] || keydown[K_RCTRL]; - if (key == K_ESCAPE || key == K_GP_BACK || key == K_MOUSE2 || key == K_MOUSE4) + if (key == K_ESCAPE || key == K_GP_DIAMOND_CANCEL || key == K_MOUSE2 || key == K_MOUSE4) { serverpreview = SVPV_NO; return true; } - else if (key == K_MOUSE1) + else if (key == K_MOUSE1 || key == K_TOUCH) { if (mousecursor_x >= joinbutton.x && mousecursor_x < joinbutton.x+joinbutton.width) if (mousecursor_y >= joinbutton.y && mousecursor_y < joinbutton.y+joinbutton.height) @@ -839,14 +839,14 @@ static qboolean SL_Key (int key, emenu_t *menu) return true; } #endif - else if (key == 'b' || key == 'o' || key == 'j' || key == K_ENTER || key == K_KP_ENTER || key == K_GP_START) //join + else if (key == 'b' || key == 'o' || key == 'j' || key == K_ENTER || key == K_KP_ENTER || key == K_GP_DIAMOND_CONFIRM || key == K_GP_DIAMOND_ALTCONFIRM) //join { - if (key == 's' || key == 'o') + if (key == 's' || key == 'o' || key == K_GP_DIAMOND_ALTCONFIRM) { dospec: Cbuf_AddText("spectator 1\n", RESTRICT_LOCAL); } - else if (key == 'j') + else if (key == 'j' || key == K_GP_DIAMOND_CONFIRM) { dojoin: Cbuf_AddText("spectator 0\n", RESTRICT_LOCAL); @@ -1034,13 +1034,13 @@ static void SL_SliderDraw (int x, int y, menucustom_t *ths, emenu_t *menu) R2D_ImageColours(1,1,1,1); } - if (keydown[K_MOUSE1]) + if (keydown[K_MOUSE1] || keydown[K_TOUCH]) if (mousecursor_x >= ths->common.posx && mousecursor_x < ths->common.posx + ths->common.width) if (mousecursor_y >= ths->common.posy && mousecursor_y < ths->common.posy + ths->common.height) info->sliderpressed = true; if (info->sliderpressed) { - if (keydown[K_MOUSE1]) + if (keydown[K_MOUSE1] || keydown[K_TOUCH]) { float my; serverlist_t *info = (serverlist_t*)(menu + 1); @@ -1069,7 +1069,7 @@ static void SL_SliderDraw (int x, int y, menucustom_t *ths, emenu_t *menu) } static qboolean SL_SliderKey (menucustom_t *ths, emenu_t *menu, int key, unsigned int unicode) { - if (key == K_MOUSE1) + if (key == K_MOUSE1 || key == K_TOUCH) { float my; serverlist_t *info = (serverlist_t*)(menu + 1); @@ -1160,7 +1160,7 @@ static void SL_Remove (emenu_t *menu) static qboolean SL_DoRefresh (menuoption_t *opt, emenu_t *menu, int key) { - if (key == K_MOUSE1 || key == K_MOUSE1 || key == K_ENTER || key == K_KP_ENTER) + if (key == K_MOUSE1 || key == K_TOUCH || key == K_ENTER || key == K_KP_ENTER || key == K_GP_DIAMOND_CONFIRM) { MasterInfo_Refresh(false); isrefreshing = true; diff --git a/engine/client/m_mp3.c b/engine/client/m_mp3.c index 2144e3154..e2ff40f31 100644 --- a/engine/client/m_mp3.c +++ b/engine/client/m_mp3.c @@ -1238,7 +1238,7 @@ qboolean M_Media_Key (int key, emenu_t *menu) if (selectedoption < MEDIA_MIN) selectedoption = MEDIA_MIN; } - else if (key == K_DEL) + else if (key == K_DEL|| key == K_GP_DIAMOND_ALTCONFIRM) { if (selectedoption>=0) { @@ -1266,7 +1266,7 @@ qboolean M_Media_Key (int key, emenu_t *menu) } } } - else if (key == K_ENTER || key == K_KP_ENTER || key == K_GP_START || key == K_MOUSE1) + else if (key == K_ENTER || key == K_KP_ENTER || key == K_GP_DIAMOND_CONFIRM || key == K_MOUSE1 || key == K_TOUCH) { if (key == K_MOUSE1) { @@ -2760,7 +2760,7 @@ void QDECL Media_Send_KeyEvent(cin_t *cin, int button, int unicode, int event) return; if (cin->key) cin->key(cin, button, unicode, event); - else if (button == K_SPACE && !event) + else if ((button == K_SPACE || button == K_GP_DIAMOND_ALTCONFIRM) && !event) { if (cin->playstate == CINSTATE_PAUSE) Media_SetState(cin, CINSTATE_PLAY); diff --git a/engine/client/m_multi.c b/engine/client/m_multi.c index d2ffdc6a9..bf1daf373 100644 --- a/engine/client/m_multi.c +++ b/engine/client/m_multi.c @@ -234,7 +234,7 @@ qboolean SetupMenuColour (union menuoption_s *option,struct emenu_s *menu, int k //but we give the top free reign. //unless they hold shift, in which case it switches around //this allows for whatever you want - if (key == K_ENTER || key == K_KP_ENTER || key == K_GP_START || key == K_RIGHTARROW || key == K_KP_RIGHTARROW || key == K_MOUSE1 || key == K_GP_DPAD_RIGHT) + if (key == K_ENTER || key == K_KP_ENTER || key == K_GP_DIAMOND_CONFIRM || key == K_RIGHTARROW || key == K_KP_RIGHTARROW || key == K_MOUSE1 || key == K_TOUCH || key == K_GP_DPAD_RIGHT) { if ((keydown[K_LSHIFT] || keydown[K_RSHIFT]) ^ (ptr == &info->topcolour)) { @@ -321,13 +321,13 @@ qboolean MSetupQ2_ChangeSkin (struct menucustom_s *option,struct emenu_s *menu, setupmenu_t *info = menu->data; q2skinsearch_t *s = Z_Malloc(sizeof(*s)); COM_EnumerateFiles(va("players/%s/*_i.*", info->modeledit->values[info->modeledit->selectedoption]), q2skin_enumerate, s); - if (key == K_ENTER || key == K_KP_ENTER || key == K_GP_START || key == K_RIGHTARROW || key == K_KP_RIGHTARROW || key == K_GP_DPAD_RIGHT) + if (key == K_ENTER || key == K_KP_ENTER || key == K_RIGHTARROW || key == K_KP_RIGHTARROW || key == K_GP_DPAD_RIGHT || key == K_GP_DIAMOND_CONFIRM) { s->match ++; if (s->match>=s->entries) s->match=0; } - else if (key == K_LEFTARROW || key == K_KP_LEFTARROW || key == K_GP_DPAD_LEFT) + else if (key == K_LEFTARROW || key == K_KP_LEFTARROW || key == K_GP_DPAD_LEFT || key == K_GP_DIAMOND_ALTCONFIRM) { s->match --; if (s->match<=0) @@ -570,7 +570,7 @@ qboolean MultiBeginGame (union menuoption_s *option,struct emenu_s *menu, int ke { newmultimenu_t *info = menu->data; char quoted[1024]; - if (key != K_ENTER && key != K_KP_ENTER && key != K_GP_START && key != K_MOUSE1) + if (key != K_ENTER && key != K_KP_ENTER && key != K_GP_DIAMOND_CONFIRM && key != K_MOUSE1 && key != K_TOUCH) return false; if (cls.state) diff --git a/engine/client/m_options.c b/engine/client/m_options.c index 10c6d4026..7fd8ac40b 100644 --- a/engine/client/m_options.c +++ b/engine/client/m_options.c @@ -1510,7 +1510,7 @@ qboolean M_PresetApply (union menuoption_s *op, struct emenu_s *menu, int key) { fpsmenuinfo_t *info = (fpsmenuinfo_t*)menu->data; - if (key != K_ENTER && key != K_KP_ENTER && key != K_GP_START && key != K_MOUSE1) + if (key != K_ENTER && key != K_KP_ENTER && key != K_GP_DIAMOND_CONFIRM && key != K_MOUSE1 && key != K_TOUCH) return false; Cbuf_AddText("fps_preset ", RESTRICT_LOCAL); @@ -1663,14 +1663,18 @@ void M_Menu_Textures_f (void) { static const char *texturefilternames[] = { - "Nearest", + "Nearest (noise)", + "Nearest (harsh)", + "Nearest (soft)", "Bilinear", "Trilinear", NULL }; static const char *texturefiltervalues[] = { + "GL_NEAREST", "GL_NEAREST_MIPMAP_NEAREST", + "nll", "GL_LINEAR_MIPMAP_NEAREST", "GL_LINEAR_MIPMAP_LINEAR", NULL @@ -1767,7 +1771,7 @@ qboolean M_VideoApplyShadowLighting (union menuoption_s *op,struct emenu_s *menu { lightingmenuinfo_t *info = (lightingmenuinfo_t*)menu->data; - if (key != K_ENTER && key != K_KP_ENTER && key != K_GP_START && key != K_MOUSE1) + if (key != K_ENTER && key != K_KP_ENTER && key != K_GP_DIAMOND_CONFIRM && key != K_MOUSE1 && key != K_TOUCH) return false; #ifdef RTLIGHTS @@ -1948,6 +1952,9 @@ void M_Menu_Lighting_f (void) static const char *lightmapformatopts[] = { "Automatic", + "4bit", + "5bit (5551)", + "5bit (565)", "8bit (Greyscale)", "8bit (Misaligned)", "8bit (Aligned)", @@ -1960,6 +1967,9 @@ void M_Menu_Lighting_f (void) static const char *lightmapformatvalues[] = { "", + "rgba4", + "rgb5a1", + "rgb565", "l8", "rgb8", "bgrx8", @@ -1967,9 +1977,6 @@ void M_Menu_Lighting_f (void) "rgb9e5", "rgba16f", "rgba32f", -// "rgb4", -// "rgb565", -// "rgba5551", NULL }; @@ -2223,7 +2230,7 @@ qboolean M_Apply_SP_Cheats (union menuoption_s *op,struct emenu_s *menu,int key) { singleplayerinfo_t *info = menu->data; - if (key != K_ENTER && key != K_KP_ENTER && key != K_GP_START && key != K_MOUSE1) + if (key != K_ENTER && key != K_KP_ENTER && key != K_GP_DIAMOND_CONFIRM && key != K_MOUSE1 && key != K_TOUCH) return false; switch(info->skillcombo->selectedoption) @@ -2341,7 +2348,7 @@ qboolean M_Apply_SP_Cheats_Q2 (union menuoption_s *op,struct emenu_s *menu,int k { singleplayerq2info_t *info = menu->data; - if (key != K_ENTER && key != K_KP_ENTER && key != K_GP_START && key != K_MOUSE1) + if (key != K_ENTER && key != K_KP_ENTER && key != K_GP_DIAMOND_CONFIRM && key != K_MOUSE1 && key != K_TOUCH) return false; switch(info->skillcombo->selectedoption) @@ -2547,7 +2554,7 @@ qboolean M_Apply_SP_Cheats_H2 (union menuoption_s *op,struct emenu_s *menu,int k { singleplayerh2info_t *info = menu->data; - if (key != K_ENTER && key != K_KP_ENTER && key != K_GP_START && key != K_MOUSE1) + if (key != K_ENTER && key != K_KP_ENTER && key != K_GP_DIAMOND_CONFIRM && key != K_MOUSE1 && key != K_TOUCH) return false; #ifdef HAVE_SERVER @@ -2803,7 +2810,7 @@ qboolean M_VideoApply (union menuoption_s *op, struct emenu_s *menu, int key) extern cvar_t vid_desktopsettings; videomenuinfo_t *info = (videomenuinfo_t*)menu->data; - if (key != K_ENTER && key != K_KP_ENTER && key != K_GP_START && key != K_MOUSE1) + if (key != K_ENTER && key != K_KP_ENTER && key != K_GP_DIAMOND_CONFIRM && key != K_MOUSE1 && key != K_TOUCH) return false; // force update display options @@ -4374,7 +4381,7 @@ static void Mods_Draw(int x, int y, struct menucustom_s *c, struct emenu_s *m) static qboolean Mods_Key(struct menucustom_s *c, struct emenu_s *m, int key, unsigned int unicode) { int gameidx = c->dint; - if (key == K_MOUSE1 || key == K_ENTER || key == K_GP_A || key == K_GP_START) + if (key == K_ENTER || key == K_KP_ENTER || key == K_GP_DIAMOND_CONFIRM || key == K_MOUSE1 || key == K_TOUCH) { qboolean wasgameless = !*FS_GetGamedir(false); if (!Mods_GetMod(c->dint)) @@ -4440,7 +4447,7 @@ static qboolean Installer_Go(menuoption_t *opt, menu_t *menu, int key) { struct installermenudata *md = menu->data; - if (key == K_MOUSE1 || key == K_ENTER || key == K_GP_START) + if (key == K_ENTER || key == K_KP_ENTER || key == K_GP_DIAMOND_CONFIRM || key == K_MOUSE1 || key == K_TOUCH) { extern int startuppending; vfsfile_t *f; diff --git a/engine/client/m_single.c b/engine/client/m_single.c index f628c72d2..8254e13ef 100644 --- a/engine/client/m_single.c +++ b/engine/client/m_single.c @@ -646,12 +646,12 @@ static void M_DemoDraw(int x, int y, menucustom_t *control, emenu_t *menu) if (!item) info->firstitem = info->items; - if (!info->dragscroll && keydown[K_MOUSE1]) + if (!info->dragscroll && (keydown[K_MOUSE1] || keydown[K_TOUCH])) { info->dragscroll = 1; info->mousedownpos = mousecursor_y; } - if (info->dragscroll && keydown[K_MOUSE1]) + if (info->dragscroll && (keydown[K_MOUSE1] || keydown[K_TOUCH])) { if (info->mousedownpos >= mousecursor_y+8) { @@ -739,6 +739,7 @@ static qboolean M_DemoKey(menucustom_t *control, emenu_t *menu, int key, unsigne info->selected = info->selected->next; } break; + case K_TOUCH: case K_MOUSE1: if (info->dragscroll == 2) { @@ -761,6 +762,7 @@ static qboolean M_DemoKey(menucustom_t *control, emenu_t *menu, int key, unsigne //fallthrough case K_ENTER: case K_KP_ENTER: + case K_GP_DIAMOND_CONFIRM: if (info->selected) { if (info->selected->isdir) diff --git a/engine/client/menu.c b/engine/client/menu.c index 1118afeff..5893a9abb 100644 --- a/engine/client/menu.c +++ b/engine/client/menu.c @@ -443,7 +443,7 @@ static qboolean Prompt_MenuKeyEvent(struct menu_s *gm, qboolean isdown, unsigned void (*callback)(void *, promptbutton_t) = m->callback; void *ctx = m->ctx; - if (key == K_MOUSE1) + if (key == K_MOUSE1 || key == K_TOUCH) { //mouse events fire their action on release. if (isdown) { @@ -463,7 +463,7 @@ static qboolean Prompt_MenuKeyEvent(struct menu_s *gm, qboolean isdown, unsigned action = PROMPT_NO; else if (key == 'y' || key == 'Y') action = PROMPT_YES; - else if (key==K_RIGHTARROW || key==K_GP_DPAD_RIGHT || key==K_DOWNARROW || key==K_GP_DPAD_DOWN || (key == K_TAB && !keydown[K_LSHIFT] && !keydown[K_RSHIFT])) + else if (key==K_RIGHTARROW || key==K_GP_DPAD_RIGHT || key==K_GP_LEFT_THUMB_RIGHT || key==K_DOWNARROW || key==K_GP_DPAD_DOWN || key==K_GP_LEFT_THUMB_DOWN || key == K_GP_DIAMOND_ALTCONFIRM || (key == K_TAB && !keydown[K_LSHIFT] && !keydown[K_RSHIFT])) { int start = m->kbutton; for(;;) @@ -478,7 +478,7 @@ static qboolean Prompt_MenuKeyEvent(struct menu_s *gm, qboolean isdown, unsigned } return true; } - else if (key == K_LEFTARROW || key == K_GP_DPAD_LEFT || key==K_UPARROW || key==K_GP_DPAD_UP || key==K_TAB) + else if (key == K_LEFTARROW || key == K_GP_DPAD_LEFT || key==K_GP_LEFT_THUMB_LEFT || key==K_UPARROW || key==K_GP_DPAD_UP || key==K_GP_LEFT_THUMB_UP || key==K_TAB) { int start = m->kbutton; for(;;) @@ -493,12 +493,12 @@ static qboolean Prompt_MenuKeyEvent(struct menu_s *gm, qboolean isdown, unsigned } return true; } - else if (key == K_ESCAPE || key == K_GP_BACK || key == K_MOUSE2 || key == K_MOUSE4) + else if (key == K_ESCAPE || key == K_GP_BACK || key == K_MOUSE2 || key == K_MOUSE4 || key == K_GP_DIAMOND_CANCEL) action = PROMPT_CANCEL; - else if (key == K_ENTER || key == K_KP_ENTER || key == K_MOUSE1 || key == K_GP_A) + else if (key == K_ENTER || key == K_KP_ENTER || key == K_MOUSE1 || key == K_TOUCH || key == K_GP_DIAMOND_CONFIRM) { int button; - if (key == K_MOUSE1) + if (key == K_MOUSE1 || key == K_TOUCH) button = m->mbutton; else button = m->kbutton; @@ -1074,7 +1074,8 @@ qboolean M_Help_Key (int key, emenu_t *m) switch (key) { case K_ESCAPE: - case K_GP_BACK: + case K_GP_DIAMOND_CANCEL: + case K_GP_START: case K_MOUSE2: case K_MOUSE4: M_RemoveMenu(m); @@ -1085,6 +1086,7 @@ qboolean M_Help_Key (int key, emenu_t *m) case K_KP_RIGHTARROW: case K_GP_DPAD_RIGHT: case K_MOUSE1: + case K_GP_DIAMOND_CONFIRM: S_LocalSound ("misc/menu2.wav"); if (++help_page >= num_help_pages) help_page = 0; @@ -1094,6 +1096,7 @@ qboolean M_Help_Key (int key, emenu_t *m) case K_LEFTARROW: case K_KP_LEFTARROW: case K_GP_DPAD_LEFT: + case K_GP_DIAMOND_ALTCONFIRM: S_LocalSound ("misc/menu2.wav"); if (--help_page < 0) help_page = num_help_pages-1; diff --git a/engine/client/pr_clcmd.c b/engine/client/pr_clcmd.c index 4fde85e67..fd62f8119 100644 --- a/engine/client/pr_clcmd.c +++ b/engine/client/pr_clcmd.c @@ -89,6 +89,7 @@ int MP_TranslateFTEtoQCCodes(keynum_t code) // case K_MOUSE14: return 527; // case K_MOUSE15: return 528; // case K_MOUSE16: return 529; + case K_TOUCH: return 600; case K_JOY1: return 768; case K_JOY2: return 769; @@ -286,6 +287,7 @@ keynum_t MP_TranslateQCtoFTECodes(int code) // case 527: return K_MOUSE14; // case 528: return K_MOUSE15; // case 529: return K_MOUSE16; + case 600: return K_TOUCH; case 768: return K_JOY1; case 769: return K_JOY2; diff --git a/engine/client/pr_menu.c b/engine/client/pr_menu.c index 32cea0e0b..744e1f7fb 100644 --- a/engine/client/pr_menu.c +++ b/engine/client/pr_menu.c @@ -2892,12 +2892,23 @@ static qboolean MP_KeyEvent(menu_t *menu, qboolean isdown, unsigned int devid, i } PR_ExecuteProgram(menu_world.progs, mpfuncs.inputevent); result = G_FLOAT(OFS_RETURN); + if (!result && key == K_TOUCH) + { + G_FLOAT(OFS_PARM0) = isdown?CSIE_KEYDOWN:CSIE_KEYUP; + G_FLOAT(OFS_PARM1) = MP_TranslateFTEtoQCCodes(K_MOUSE1); + G_FLOAT(OFS_PARM2) = unicode; + G_FLOAT(OFS_PARM3) = devid; + PR_ExecuteProgram(menu_world.progs, mpfuncs.inputevent); + result = G_FLOAT(OFS_RETURN); + } qcinput_scan = 0; qcinput_unicode = 0; } else if (isdown && mpfuncs.keydown) { void *pr_globals = PR_globals(menu_world.progs, PR_CURRENT); + if (key == K_TOUCH) + key = K_MOUSE1; G_FLOAT(OFS_PARM0) = MP_TranslateFTEtoQCCodes(key); G_FLOAT(OFS_PARM1) = unicode; PR_ExecuteProgram(menu_world.progs, mpfuncs.keydown); @@ -2906,6 +2917,8 @@ static qboolean MP_KeyEvent(menu_t *menu, qboolean isdown, unsigned int devid, i else if (!isdown && mpfuncs.keyup) { void *pr_globals = PR_globals(menu_world.progs, PR_CURRENT); + if (key == K_TOUCH) + key = K_MOUSE1; G_FLOAT(OFS_PARM0) = MP_TranslateFTEtoQCCodes(key); G_FLOAT(OFS_PARM1) = unicode; PR_ExecuteProgram(menu_world.progs, mpfuncs.keyup); @@ -3129,7 +3142,7 @@ qboolean MP_Init (void) m->scale = 1; m->dirty = true; - menuqc.cursor = &key_customcursor[kc_menuqc]; + menuqc.cursor = m; menuqc.drawmenu = NULL; //menuqc sucks! menuqc.mousemove = MP_MouseMove; menuqc.keyevent = MP_KeyEvent; diff --git a/engine/client/sys_droid.c b/engine/client/sys_droid.c index 2c9bfd902..be6e6c463 100644 --- a/engine/client/sys_droid.c +++ b/engine/client/sys_droid.c @@ -590,7 +590,7 @@ static void FTENativeActivity_motion(JNIEnv *env, jobject this, jint ptrid, jint { case 2: //mouse down case 3: //mouse up - IN_KeyEvent(ptrid, act==2, K_MOUSE1, 0); + IN_KeyEvent(ptrid, act==2, K_TOUCH, 0); break; case 1: //relative motion case 0: //absolute motion (android sucks) diff --git a/engine/client/sys_sdl.c b/engine/client/sys_sdl.c index 477bf3120..c94103559 100644 --- a/engine/client/sys_sdl.c +++ b/engine/client/sys_sdl.c @@ -213,7 +213,7 @@ void Sys_Printf (char *fmt, ...) static quint64_t sdlperf_freq; #define CLOCKDEF_SDL_PERF QCLOCK(PERF, "perf", t=SDL_GetPerformanceCounter(), sdlperf_freq,sdlperf_freq=SDL_GetPerformanceFrequency()) -#ifdef CLOCK_MONOTONIC +#if defined(CLOCK_MONOTONIC) && (_POSIX_C_SOURCE >= 200112L) #define CLOCKDEF_LINUX_MONOTONIC QCLOCK(MONOTONIC, "monotonic", { \ struct timespec ts; \ clock_gettime(CLOCK_MONOTONIC, &ts); \ @@ -223,7 +223,7 @@ static quint64_t sdlperf_freq; #define CLOCKDEF_LINUX_MONOTONIC #endif -#ifdef CLOCK_REALTIME +#if defined(CLOCK_REALTIME) && (_POSIX_C_SOURCE >= 200112L) #define CLOCKDEF_LINUX_REALTIME QCLOCK(REALTIME, "realtime", { \ struct timespec ts; \ clock_gettime(CLOCK_REALTIME, &ts); \ diff --git a/engine/gl/gl_vidsdl.c b/engine/gl/gl_vidsdl.c index d79957e16..53148e817 100644 --- a/engine/gl/gl_vidsdl.c +++ b/engine/gl/gl_vidsdl.c @@ -313,6 +313,15 @@ static qboolean SDLVID_Init (rendererstate_t *info, unsigned char *palette, r_qr #if SDL_MAJOR_VERSION >= 2 int display = -1; SDL_DisplayMode modeinfo, *usemode; + + SDL_SetHint(SDL_HINT_TOUCH_MOUSE_EVENTS, "0"); //we understand touch events. we do NOT want to get confused with mouse motion constantly warping. + SDL_SetHint(SDL_HINT_IME_INTERNAL_EDITING, "1"); //our code doesn't handle displaying non-committed text. ask to not be expected to show it, where possible. +#ifdef SDL_HINT_IME_SUPPORT_EXTENDED_TEXT +// SDL_SetHint(SDL_HINT_IME_SUPPORT_EXTENDED_TEXT, "1");//says we don't have a limit. enable once we actually support this stuff. +#endif +#ifdef SDL_HINT_IME_SHOW_UI + SDL_SetHint(SDL_HINT_IME_SHOW_UI, "1"); //not much point having an IME if you can't see it... +#endif #endif SDL_Init(SDL_INIT_VIDEO | SDL_INIT_NOPARACHUTE); diff --git a/engine/server/sv_main.c b/engine/server/sv_main.c index 7438197c8..17e7b883b 100644 --- a/engine/server/sv_main.c +++ b/engine/server/sv_main.c @@ -5360,6 +5360,8 @@ float SV_Frame (void) svs.framenum = 0; delay = sv_maxtic.value; + if (delay < sv_mintic.value) + delay = sv_mintic.value; if (isDedicated && sv.allocated_client_slots == 0) delay = max(delay, 1); //when idle, don't keep waking up for no reason @@ -5378,7 +5380,7 @@ float SV_Frame (void) #endif #ifdef HAVE_CLIENT - isidle = !isDedicated && sv.allocated_client_slots == 1 && Key_Dest_Has(~kdm_game) && cls.state == ca_active && !cl.implicitpause; + isidle = !isDedicated && sv.allocated_client_slots == 1 && (Key_Dest_Has(~kdm_game) || IN_WeaponWheelIsShown()) && cls.state == ca_active && !cl.implicitpause; /*server is effectively paused in SP/coop if there are no clients/spectators*/ if (sv.spawned_client_slots == 0 && sv.spawned_observer_slots == 0 && !deathmatch.ival) isidle = true;