Merge branch 'bind-function-keys' into 'master'

Remove hardcoded Function keys for screenshot etc, add RECORD LOSSLESS to the profile controls

Closes #284

See merge request KartKrew/Kart!1093
This commit is contained in:
toaster 2023-04-11 16:16:23 +00:00
commit 06763da0e7
13 changed files with 76 additions and 57 deletions

View file

@ -913,7 +913,8 @@ boolean CON_Responder(event_t *ev)
// let go keyup events, don't eat them // let go keyup events, don't eat them
if (ev->type != ev_keydown && ev->type != ev_console) if (ev->type != ev_keydown && ev->type != ev_console)
{ {
if (ev->data1 == gamecontrol[0][gc_console][0] || ev->data1 == gamecontrol[0][gc_console][1]) if (ev->data1 == gamecontrol[0][gc_console][0] || ev->data1 == gamecontrol[0][gc_console][1]
|| ev->data1 == gamecontrol[0][gc_console][2] || ev->data1 == gamecontrol[0][gc_console][3])
consdown = false; consdown = false;
return false; return false;
} }
@ -933,7 +934,8 @@ boolean CON_Responder(event_t *ev)
INT32 i; INT32 i;
for (i = 0; i < num_gamecontrols; i++) for (i = 0; i < num_gamecontrols; i++)
{ {
if (gamecontrol[0][i][0] == ev->data1 || gamecontrol[0][i][1] == ev->data1) if (gamecontrol[0][i][0] == ev->data1 || gamecontrol[0][i][1] == ev->data1
|| gamecontrol[0][i][2] == ev->data1 || gamecontrol[0][i][3] == ev->data1)
break; break;
} }
@ -941,7 +943,8 @@ boolean CON_Responder(event_t *ev)
return false; return false;
} }
if (key == gamecontrol[0][gc_console][0] || key == gamecontrol[0][gc_console][1]) if (key == gamecontrol[0][gc_console][0] || key == gamecontrol[0][gc_console][1]
|| key == gamecontrol[0][gc_console][2] || key == gamecontrol[0][gc_console][3])
{ {
if (consdown) // ignore repeat if (consdown) // ignore repeat
return true; return true;

View file

@ -6757,6 +6757,8 @@ void NetUpdate(void)
I_unlock_mutex(k_menu_mutex); I_unlock_mutex(k_menu_mutex);
#endif #endif
CON_Ticker(); CON_Ticker();
M_ScreenshotTicker();
} }
FileSendTicker(); FileSendTicker();

View file

@ -248,10 +248,6 @@ void D_ProcessEvents(void)
HandleGamepadDeviceEvents(ev); HandleGamepadDeviceEvents(ev);
// Screenshots over everything so that they can be taken anywhere.
if (M_ScreenshotResponder(ev))
continue; // ate the event
if (gameaction == ga_nothing && gamestate == GS_TITLESCREEN) if (gameaction == ga_nothing && gamestate == GS_TITLESCREEN)
{ {
if (cht_Responder(ev)) if (cht_Responder(ev))

View file

@ -750,7 +750,8 @@ static const char *gamecontrolname[num_gamecontrols] =
"teamtalk", "teamtalk",
"rankings", "rankings",
"screenshot", "screenshot",
"recordgif", "startmovie",
"startlossless",
}; };
#define NUMKEYNAMES (sizeof (keynames)/sizeof (keyname_t)) #define NUMKEYNAMES (sizeof (keynames)/sizeof (keyname_t))
@ -889,20 +890,23 @@ void G_DefineDefaultControls(void)
{ {
// These defaults are less bad than they used to be. // These defaults are less bad than they used to be.
// Keyboard controls // Keyboard controls
gamecontroldefault[gc_up ][0] = KEY_UPARROW; gamecontroldefault[gc_up ][0] = KEY_UPARROW;
gamecontroldefault[gc_down ][0] = KEY_DOWNARROW; gamecontroldefault[gc_down ][0] = KEY_DOWNARROW;
gamecontroldefault[gc_left ][0] = KEY_LEFTARROW; gamecontroldefault[gc_left ][0] = KEY_LEFTARROW;
gamecontroldefault[gc_right ][0] = KEY_RIGHTARROW; gamecontroldefault[gc_right ][0] = KEY_RIGHTARROW;
gamecontroldefault[gc_a ][0] = 'f'; gamecontroldefault[gc_a ][0] = 'f';
gamecontroldefault[gc_b ][0] = 'a'; gamecontroldefault[gc_b ][0] = 'a';
gamecontroldefault[gc_c ][0] = 'v'; gamecontroldefault[gc_c ][0] = 'v';
gamecontroldefault[gc_x ][0] = 's'; gamecontroldefault[gc_x ][0] = 's';
gamecontroldefault[gc_y ][0] = 'x'; gamecontroldefault[gc_y ][0] = 'x';
gamecontroldefault[gc_z ][0] = 'c'; gamecontroldefault[gc_z ][0] = 'c';
gamecontroldefault[gc_l ][0] = KEY_SPACE; gamecontroldefault[gc_l ][0] = KEY_SPACE;
gamecontroldefault[gc_r ][0] = 'd'; gamecontroldefault[gc_r ][0] = 'd';
gamecontroldefault[gc_start ][0] = KEY_ESCAPE; gamecontroldefault[gc_start ][0] = KEY_ESCAPE;
gamecontroldefault[gc_rankings][0] = KEY_TAB; gamecontroldefault[gc_rankings ][0] = KEY_TAB;
gamecontroldefault[gc_screenshot ][0] = KEY_F8;
gamecontroldefault[gc_startmovie ][0] = KEY_F9;
gamecontroldefault[gc_startlossless][0] = KEY_F10;
// Gamepad controls // Gamepad controls
gamecontroldefault[gc_up ][1] = KEY_HAT1+0; // D-Pad Up gamecontroldefault[gc_up ][1] = KEY_HAT1+0; // D-Pad Up

View file

@ -84,7 +84,8 @@ typedef enum
gc_teamtalk, gc_teamtalk,
gc_rankings, gc_rankings,
gc_screenshot, gc_screenshot,
gc_recordgif, gc_startmovie,
gc_startlossless,
num_gamecontrols, num_gamecontrols,

View file

@ -1215,7 +1215,8 @@ boolean HU_Responder(event_t *ev)
if (!chat_on) if (!chat_on)
{ {
// enter chat mode // enter chat mode
if ((ev->data1 == gamecontrol[0][gc_talk][0] || ev->data1 == gamecontrol[0][gc_talk][1]) if ((ev->data1 == gamecontrol[0][gc_talk][0] || ev->data1 == gamecontrol[0][gc_talk][1]
|| ev->data1 == gamecontrol[0][gc_talk][2] || ev->data1 == gamecontrol[0][gc_talk][3])
&& netgame && !OLD_MUTE) // check for old chat mute, still let the players open the chat incase they want to scroll otherwise. && netgame && !OLD_MUTE) // check for old chat mute, still let the players open the chat incase they want to scroll otherwise.
{ {
chat_on = true; chat_on = true;
@ -1225,7 +1226,8 @@ boolean HU_Responder(event_t *ev)
typelines = 1; typelines = 1;
return true; return true;
} }
if ((ev->data1 == gamecontrol[0][gc_teamtalk][0] || ev->data1 == gamecontrol[0][gc_teamtalk][1]) if ((ev->data1 == gamecontrol[0][gc_teamtalk][0] || ev->data1 == gamecontrol[0][gc_teamtalk][1]
|| ev->data1 == gamecontrol[0][gc_teamtalk][2] || ev->data1 == gamecontrol[0][gc_teamtalk][3])
&& netgame && !OLD_MUTE) && netgame && !OLD_MUTE)
{ {
chat_on = true; chat_on = true;

View file

@ -541,7 +541,10 @@ typedef enum
MBT_Z = 1<<5, MBT_Z = 1<<5,
MBT_L = 1<<6, MBT_L = 1<<6,
MBT_R = 1<<7, MBT_R = 1<<7,
MBT_START = 1<<8 MBT_START = 1<<8,
MBT_SCREENSHOT = 1<<9,
MBT_STARTMOVIE = 1<<10,
MBT_STARTLOSSLESS = 1<<11,
} menuButtonCode_t; } menuButtonCode_t;
struct menucmd_t struct menucmd_t

View file

@ -754,10 +754,18 @@ void M_UpdateMenuCMD(UINT8 i)
menucmd[i].buttonsHeld = menucmd[i].buttons; menucmd[i].buttonsHeld = menucmd[i].buttons;
menucmd[i].buttons = 0; menucmd[i].buttons = 0;
if (G_PlayerInputDown(i, gc_up, mp)) { menucmd[i].dpad_ud--; } if (G_PlayerInputDown(i, gc_screenshot, mp)) { menucmd[i].buttons |= MBT_SCREENSHOT; }
if (G_PlayerInputDown(i, gc_startmovie, mp)) { menucmd[i].buttons |= MBT_STARTMOVIE; }
if (G_PlayerInputDown(i, gc_startlossless, mp)) { menucmd[i].buttons |= MBT_STARTLOSSLESS; }
// Screenshot et al take priority
if (menucmd[i].buttons != 0)
return;
if (G_PlayerInputDown(i, gc_up, mp)) { menucmd[i].dpad_ud--; }
if (G_PlayerInputDown(i, gc_down, mp)) { menucmd[i].dpad_ud++; } if (G_PlayerInputDown(i, gc_down, mp)) { menucmd[i].dpad_ud++; }
if (G_PlayerInputDown(i, gc_left, mp)) { menucmd[i].dpad_lr--; } if (G_PlayerInputDown(i, gc_left, mp)) { menucmd[i].dpad_lr--; }
if (G_PlayerInputDown(i, gc_right, mp)) { menucmd[i].dpad_lr++; } if (G_PlayerInputDown(i, gc_right, mp)) { menucmd[i].dpad_lr++; }
if (G_PlayerInputDown(i, gc_a, mp)) { menucmd[i].buttons |= MBT_A; } if (G_PlayerInputDown(i, gc_a, mp)) { menucmd[i].buttons |= MBT_A; }
@ -768,6 +776,7 @@ void M_UpdateMenuCMD(UINT8 i)
if (G_PlayerInputDown(i, gc_z, mp)) { menucmd[i].buttons |= MBT_Z; } if (G_PlayerInputDown(i, gc_z, mp)) { menucmd[i].buttons |= MBT_Z; }
if (G_PlayerInputDown(i, gc_l, mp)) { menucmd[i].buttons |= MBT_L; } if (G_PlayerInputDown(i, gc_l, mp)) { menucmd[i].buttons |= MBT_L; }
if (G_PlayerInputDown(i, gc_r, mp)) { menucmd[i].buttons |= MBT_R; } if (G_PlayerInputDown(i, gc_r, mp)) { menucmd[i].buttons |= MBT_R; }
if (G_PlayerInputDown(i, gc_start, mp)) { menucmd[i].buttons |= MBT_START; } if (G_PlayerInputDown(i, gc_start, mp)) { menucmd[i].buttons |= MBT_START; }
if (menucmd[i].dpad_ud == 0 && menucmd[i].dpad_lr == 0 && menucmd[i].buttons == 0) if (menucmd[i].dpad_ud == 0 && menucmd[i].dpad_lr == 0 && menucmd[i].buttons == 0)

View file

@ -425,7 +425,9 @@ void PR_LoadProfiles(void)
{ {
#ifdef DEVELOP #ifdef DEVELOP
// Profile update 1-->2: Add gc_rankings. // Profile update 1-->2: Add gc_rankings.
if (j == gc_rankings && version < 2) // Profile update 3-->5: Add gc_startlossless.
if ((j == gc_rankings && version < 2) ||
(j == gc_startlossless && version < 5))
{ {
for (k = 0; k < MAXINPUTMAPPING; k++) for (k = 0; k < MAXINPUTMAPPING; k++)
{ {

View file

@ -31,7 +31,7 @@ extern "C" {
#define SKINNAMESIZE 16 #define SKINNAMESIZE 16
#define PROFILENAMELEN 6 #define PROFILENAMELEN 6
#define PROFILEVER 4 #define PROFILEVER 5
#define MAXPROFILES 16 #define MAXPROFILES 16
#define PROFILESFILE "ringprofiles.prf" #define PROFILESFILE "ringprofiles.prf"
#define PROFILE_GUEST 0 #define PROFILE_GUEST 0

View file

@ -1846,24 +1846,16 @@ failure:
#endif #endif
} }
boolean M_ScreenshotResponder(event_t *ev) void M_ScreenshotTicker(void)
{ {
INT32 ch = -1; const UINT8 pid = 0; // TODO: should splitscreen players be allowed to use this too?
if (dedicated || ev->type != ev_keydown)
return false;
ch = ev->data1; if (M_MenuButtonPressed(pid, MBT_SCREENSHOT))
if (ch >= NUMKEYS && menuactive) // If it's not a keyboard key, then don't allow it in the menus!
return false;
switch (ch)
{ {
case KEY_F8:
M_ScreenShot(); M_ScreenShot();
break; }
else if (M_MenuButtonPressed(pid, MBT_STARTMOVIE))
case KEY_F9: {
if (moviemode) if (moviemode)
{ {
M_StopMovie(); M_StopMovie();
@ -1872,9 +1864,9 @@ boolean M_ScreenshotResponder(event_t *ev)
{ {
M_StartMovie(MM_AVRECORDER); M_StartMovie(MM_AVRECORDER);
} }
break; }
else if (M_MenuButtonPressed(pid, MBT_STARTLOSSLESS))
case KEY_F10: {
if (moviemode) if (moviemode)
{ {
M_StopMovie(); M_StopMovie();
@ -1883,13 +1875,7 @@ boolean M_ScreenshotResponder(event_t *ev)
{ {
M_StartMovie(static_cast<moviemode_t>(cv_lossless_recorder.value)); M_StartMovie(static_cast<moviemode_t>(cv_lossless_recorder.value));
} }
break;
default:
return false;
} }
return true;
} }
void M_MinimapGenerate(void) void M_MinimapGenerate(void)

View file

@ -98,7 +98,7 @@ void M_ScreenShot(void);
#ifdef HWRENDER #ifdef HWRENDER
void M_DoLegacyGLScreenShot(void); void M_DoLegacyGLScreenShot(void);
#endif #endif
boolean M_ScreenshotResponder(event_t *ev); void M_ScreenshotTicker(void);
void M_MinimapGenerate(void); void M_MinimapGenerate(void);

View file

@ -53,11 +53,14 @@ menuitem_t OPTIONS_ProfileControls[] = {
{IT_HEADER, "OPTIONAL CONTROLS", "Take a screenshot, chat...", {IT_HEADER, "OPTIONAL CONTROLS", "Take a screenshot, chat...",
NULL, {NULL}, 0, 0}, NULL, {NULL}, 0, 0},
{IT_CONTROL, "SCREENSHOT", "Also usable with F8 on Keyboard.", {IT_CONTROL, "SCREENSHOT", "Take a high resolution screenshot.",
NULL, {.routine = M_ProfileSetControl}, gc_screenshot, 0}, NULL, {.routine = M_ProfileSetControl}, gc_screenshot, 0},
{IT_CONTROL, "GIF CAPTURE", "Also usable with F9 on Keyboard.", {IT_CONTROL, "RECORD VIDEO", "Record a video with sound.",
NULL, {.routine = M_ProfileSetControl}, gc_recordgif, 0}, NULL, {.routine = M_ProfileSetControl}, gc_startmovie, 0},
{IT_CONTROL, "RECORD LOSSLESS", "Record a pixel perfect GIF.",
NULL, {.routine = M_ProfileSetControl}, gc_startlossless, 0},
{IT_CONTROL, "OPEN CHAT", "Opens chatbox in online games.", {IT_CONTROL, "OPEN CHAT", "Opens chatbox in online games.",
NULL, {.routine = M_ProfileSetControl}, gc_talk, 0}, NULL, {.routine = M_ProfileSetControl}, gc_talk, 0},
@ -313,6 +316,10 @@ void M_MapProfileControl(event_t *ev)
INT32 controln = currentMenu->menuitems[itemOn].mvar1; // gc_ INT32 controln = currentMenu->menuitems[itemOn].mvar1; // gc_
UINT8 where = n; // By default, we'll save the bind where we're supposed to map. UINT8 where = n; // By default, we'll save the bind where we're supposed to map.
INT32 i; INT32 i;
INT32 *DeviceGameKeyDownArray = G_GetDeviceGameKeyDownArray(ev->device);
if (!DeviceGameKeyDownArray)
return;
//SetDeviceOnPress(); // Update player gamepad assignments //SetDeviceOnPress(); // Update player gamepad assignments
@ -410,6 +417,10 @@ void M_MapProfileControl(event_t *ev)
// Set menu delay regardless of what we're doing to avoid stupid stuff. // Set menu delay regardless of what we're doing to avoid stupid stuff.
M_SetMenuDelay(0); M_SetMenuDelay(0);
// Reset this input so (keyboard keys at least) are not
// buffered and caught by menucmd.
DeviceGameKeyDownArray[c] = 0;
// Check if this particular key (c) is already bound in any slot. // Check if this particular key (c) is already bound in any slot.
// If that's the case, simply do nothing. // If that's the case, simply do nothing.
for (i = 0; i < MAXINPUTMAPPING; i++) for (i = 0; i < MAXINPUTMAPPING; i++)