From 70b02a044b03a24bccca138a0e175d37d70685d3 Mon Sep 17 00:00:00 2001 From: havoc Date: Thu, 19 May 2011 01:33:42 +0000 Subject: [PATCH] added JOY_UP/DOWN/LEFT/RIGHT keys which are a more general form of the joy_axiskeyevents cvar (which when set to 1 will turn these into UPARROW/DOWNARROW/etc as before, but this way a menu qc can respond to them correctly) git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@11157 d7cf8633-e32d-0410-b094-e92efae38249 ::stable-branch::merge=db717d093453e95a1fc005d7c884b12562d7ca9f --- keys.c | 5 +++++ keys.h | 6 ++++++ vid_shared.c | 4 ++-- 3 files changed, 13 insertions(+), 2 deletions(-) diff --git a/keys.c b/keys.c index c955570c..ea6e2d59 100644 --- a/keys.c +++ b/keys.c @@ -498,6 +498,11 @@ static const keyname_t keynames[] = { {"X360_RIGHT_THUMB_LEFT", K_X360_RIGHT_THUMB_LEFT}, {"X360_RIGHT_THUMB_RIGHT", K_X360_RIGHT_THUMB_RIGHT}, + {"JOY_UP", K_JOY_UP}, + {"JOY_DOWN", K_JOY_DOWN}, + {"JOY_LEFT", K_JOY_LEFT}, + {"JOY_RIGHT", K_JOY_RIGHT}, + {"SEMICOLON", ';'}, // because a raw semicolon separates commands {"TILDE", '~'}, {"BACKQUOTE", '`'}, diff --git a/keys.h b/keys.h index a02acf2f..c2587aed 100644 --- a/keys.h +++ b/keys.h @@ -214,6 +214,12 @@ typedef enum keynum_e K_X360_RIGHT_THUMB_LEFT, K_X360_RIGHT_THUMB_RIGHT, + // generic joystick emulation for menu + K_JOY_UP, + K_JOY_DOWN, + K_JOY_LEFT, + K_JOY_RIGHT, + K_MIDINOTE0 = 896, // to this, the note number is added K_MIDINOTE1, K_MIDINOTE2, diff --git a/vid_shared.c b/vid_shared.c index 24a15094..ada1a260 100644 --- a/vid_shared.c +++ b/vid_shared.c @@ -1193,7 +1193,7 @@ void VID_Shared_BuildJoyState_Begin(vid_joystate_t *joystate) void VID_Shared_BuildJoyState_Finish(vid_joystate_t *joystate) { float f, r; - if (!joy_axiskeyevents.integer || joystate->is360) + if (joystate->is360) return; // emulate key events for thumbstick f = VID_JoyState_GetAxis(joystate, joy_axisforward.integer, 1, joy_axiskeyevents_deadzone.value) * joy_sensitivityforward.value; @@ -1242,7 +1242,7 @@ static int joybuttonkey[MAXJOYBUTTON][2] = { {K_JOY1, K_ENTER}, {K_JOY2, K_ESCAPE}, {K_JOY3, 0}, {K_JOY4, 0}, {K_JOY5, 0}, {K_JOY6, 0}, {K_JOY7, 0}, {K_JOY8, 0}, {K_JOY9, 0}, {K_JOY10, 0}, {K_JOY11, 0}, {K_JOY12, 0}, {K_JOY13, 0}, {K_JOY14, 0}, {K_JOY15, 0}, {K_JOY16, 0}, {K_AUX1, 0}, {K_AUX2, 0}, {K_AUX3, 0}, {K_AUX4, 0}, {K_AUX5, 0}, {K_AUX6, 0}, {K_AUX7, 0}, {K_AUX8, 0}, {K_AUX9, 0}, {K_AUX10, 0}, {K_AUX11, 0}, {K_AUX12, 0}, {K_AUX13, 0}, {K_AUX14, 0}, {K_AUX15, 0}, {K_AUX16, 0}, - {K_UPARROW, K_UPARROW}, {K_DOWNARROW, K_DOWNARROW}, {K_RIGHTARROW, K_RIGHTARROW}, {K_LEFTARROW, K_LEFTARROW}, + {K_JOY_UP, K_UPARROW}, {K_JOY_DOWN, K_DOWNARROW}, {K_JOY_RIGHT, K_RIGHTARROW}, {K_JOY_LEFT, K_LEFTARROW}, }; static int joybuttonkey360[][2] = -- 2.39.2