- made joystick configuration menu operational.

This commit is contained in:
Christoph Oelckers 2019-12-14 19:21:49 +01:00
parent 6c1a8fb8c2
commit 957d997353
10 changed files with 53 additions and 52 deletions

View file

@ -197,9 +197,9 @@ if( MSVC )
# Function-level linking # Function-level linking
# Disable run-time type information # Disable run-time type information
if ( HAVE_VULKAN ) if ( HAVE_VULKAN )
set( ALL_C_FLAGS "/GF /Gy /GR- /permissive- /DHAVE_VULKAN" ) set( ALL_C_FLAGS "/GF /Gy /permissive- /DHAVE_VULKAN" )
else() else()
set( ALL_C_FLAGS "/GF /Gy /GR- /permissive-" ) set( ALL_C_FLAGS "/GF /Gy /permissive-" )
endif() endif()
# Use SSE 2 as minimum always as the true color drawers needs it for __vectorcall # Use SSE 2 as minimum always as the true color drawers needs it for __vectorcall

View file

@ -639,7 +639,6 @@ file( GLOB HEADER_FILES
# without being compiled. # without being compiled.
set( NOT_COMPILED_SOURCE_FILES set( NOT_COMPILED_SOURCE_FILES
${OTHER_SYSTEM_SOURCES} ${OTHER_SYSTEM_SOURCES}
build/src/sdlkeytrans.cpp
sc_man_scanner.h sc_man_scanner.h
common/utility/sc_man_scanner.re common/utility/sc_man_scanner.re
) )

View file

@ -105,8 +105,8 @@ void D_ProcessEvents (void)
ev = &events[eventtail]; ev = &events[eventtail];
if (ev->type == EV_None) if (ev->type == EV_None)
continue; continue;
if (ev->type == EV_DeviceChange) /*if (ev->type == EV_DeviceChange)
(void)0;//UpdateJoystickMenu(I_UpdateDeviceList()); UpdateJoystickMenu(I_UpdateDeviceList());*/
if (C_Responder (ev)) if (C_Responder (ev))
continue; // console ate the event continue; // console ate the event
if (M_Responder (ev)) if (M_Responder (ev))

View file

@ -299,7 +299,6 @@ void FResourceFile::PostProcessArchive(void *lumps, size_t lumpsize)
// each one so that we don't risk refiltering already filtered lumps. // each one so that we don't risk refiltering already filtered lumps.
uint32_t max = NumLumps; uint32_t max = NumLumps;
long len;
int lastpos = -1; int lastpos = -1;
FString file; FString file;

View file

@ -283,11 +283,11 @@ int GameMain()
// Just let the rest of the function execute. // Just let the rest of the function execute.
r = exit.Reason(); r = exit.Reason();
} }
I_ShutdownInput();
G_SaveConfig(); G_SaveConfig();
#ifndef NETCODE_DISABLE #ifndef NETCODE_DISABLE
if (gHaveNetworking) enet_deinitialize(); if (gHaveNetworking) enet_deinitialize();
#endif #endif
I_ShutdownInput();
return r; return r;
} }

View file

@ -33,8 +33,8 @@
** **
*/ */
#include <SDL.h>
#include "compat.h" #include "compat.h"
#include <SDL.h>
//#include "doomtype.h" //#include "doomtype.h"
//#include "doomdef.h" //#include "doomdef.h"
@ -671,6 +671,13 @@ int32_t handleevents_pollsdl(void)
case SDL_JOYBUTTONDOWN: case SDL_JOYBUTTONDOWN:
case SDL_JOYBUTTONUP: case SDL_JOYBUTTONUP:
#if 0 // SDL_MAJOR_VERSION >= 2
if (joystick.isGameController)
break;
fallthrough__;
case SDL_CONTROLLERBUTTONDOWN:
case SDL_CONTROLLERBUTTONUP:
#endif
if (!GUICapture) if (!GUICapture)
{ {
evt.type = ev.type == SDL_JOYBUTTONDOWN ? EV_KeyDown : EV_KeyUp; evt.type = ev.type == SDL_JOYBUTTONDOWN ? EV_KeyDown : EV_KeyUp;

View file

@ -42,11 +42,11 @@
#include "c_bind.h" #include "c_bind.h"
#include "d_event.h" #include "d_event.h"
#include "d_gui.h" #include "d_gui.h"
#include "input/m_joy.h"
#define NO_IMP #define NO_IMP
#include "optionmenuitems.h" #include "optionmenuitems.h"
#if 0 // This requires the entire ZDoom backend to work.
static TArray<IJoystickConfig *> Joysticks; static TArray<IJoystickConfig *> Joysticks;
IJoystickConfig *SELECTED_JOYSTICK; IJoystickConfig *SELECTED_JOYSTICK;
@ -245,10 +245,10 @@ public:
mJoy = joy; mJoy = joy;
} }
bool Activate() bool Activate(FName caller) override
{ {
UpdateJoystickConfigMenu(mJoy); UpdateJoystickConfigMenu(mJoy);
return FOptionMenuItemSubmenu::Activate(); return FOptionMenuItemSubmenu::Activate(caller);
} }
}; };
@ -273,51 +273,50 @@ FOptionMenuDescriptor *UpdateJoystickConfigMenu(IJoystickConfig *joy)
} }
if (joy == NULL) if (joy == NULL)
{ {
opt->mTitle = "Configure Controller"; opt->mTitle = "$JOYMNU_TITLE";
it = new FOptionMenuItemStaticText("Invalid controller specified for menu", false); it = new FOptionMenuItemStaticText("$JOYMNU_INVALID");
opt->mItems.Push(it); opt->mItems.Push(it);
} }
else else
{ {
opt->mTitle.Format("Configure %s", joy->GetName().GetChars()); opt->mTitle.Format("%s", joy->GetName().GetChars());
SELECTED_JOYSTICK = joy; SELECTED_JOYSTICK = joy;
it = new FOptionMenuSliderJoySensitivity("Overall sensitivity", 0, 2, 0.1, 3); it = new FOptionMenuSliderJoySensitivity("$JOYMNU_OVRSENS", 0, 2, 0.1, 3);
opt->mItems.Push(it); opt->mItems.Push(it);
it = new FOptionMenuItemStaticText(" ", false); it = new FOptionMenuItemStaticText(" ");
opt->mItems.Push(it); opt->mItems.Push(it);
if (joy->GetNumAxes() > 0) if (joy->GetNumAxes() > 0)
{ {
it = new FOptionMenuItemStaticText("Axis Configuration", true); it = new FOptionMenuItemStaticText("$JOYMNU_AXIS");
opt->mItems.Push(it); opt->mItems.Push(it);
for (int i = 0; i < joy->GetNumAxes(); ++i) for (int i = 0; i < joy->GetNumAxes(); ++i)
{ {
it = new FOptionMenuItemStaticText(" ", false); it = new FOptionMenuItemStaticText(" ");
opt->mItems.Push(it); opt->mItems.Push(it);
it = new FOptionMenuItemJoyMap(joy->GetAxisName(i), i, "JoyAxisMapNames", false); it = new FOptionMenuItemJoyMap(joy->GetAxisName(i), i, "JoyAxisMapNames", false);
opt->mItems.Push(it); opt->mItems.Push(it);
it = new FOptionMenuSliderJoyScale("Overall sensitivity", i, 0, 4, 0.1, 3); it = new FOptionMenuSliderJoyScale("$JOYMNU_OVRSENS", i, 0, 4, 0.1, 3);
opt->mItems.Push(it); opt->mItems.Push(it);
it = new FOptionMenuItemInverter("Invert", i, false); it = new FOptionMenuItemInverter("$JOYMNU_INVERT", i, false);
opt->mItems.Push(it); opt->mItems.Push(it);
it = new FOptionMenuSliderJoyDeadZone("Dead Zone", i, 0, 0.9, 0.05, 3); it = new FOptionMenuSliderJoyDeadZone("$JOYMNU_DEADZONE", i, 0, 0.9, 0.05, 3);
opt->mItems.Push(it); opt->mItems.Push(it);
} }
} }
else else
{ {
it = new FOptionMenuItemStaticText("No configurable axes", false); it = new FOptionMenuItemStaticText("$JOYMNU_NOAXES");
opt->mItems.Push(it); opt->mItems.Push(it);
} }
} }
opt->mScrollPos = 0; opt->mScrollPos = 0;
opt->mSelectedItem = -1; opt->mSelectedItem = -1;
opt->mIndent = 0; opt->mIndent = 0;
opt->mPosition = -25;
opt->CalcIndent(); opt->CalcIndent();
return opt; return opt;
} }
@ -333,6 +332,7 @@ void UpdateJoystickMenu(IJoystickConfig *selected)
{ {
FOptionMenuDescriptor *opt = (FOptionMenuDescriptor *)*desc; FOptionMenuDescriptor *opt = (FOptionMenuDescriptor *)*desc;
FOptionMenuItem *it; FOptionMenuItem *it;
for(unsigned i=0;i<opt->mItems.Size();i++) for(unsigned i=0;i<opt->mItems.Size();i++)
{ {
delete opt->mItems[i]; delete opt->mItems[i];
@ -360,9 +360,9 @@ void UpdateJoystickMenu(IJoystickConfig *selected)
} }
// Todo: Block joystick for changing this one. // Todo: Block joystick for changing this one.
it = new FOptionMenuItemOption("Enable controller support", "use_joystick", "YesNo", NULL, false); it = new FOptionMenuItemOption("$JOYMNU_ENABLE", "use_joystick", "YesNo", NULL, false);
opt->mItems.Push(it); opt->mItems.Push(it);
#ifdef _WIN32 #if 0//def _WIN32
it = new FOptionMenuItemOption("Enable DirectInput controllers", "joy_dinput", "YesNo", NULL, false); it = new FOptionMenuItemOption("Enable DirectInput controllers", "joy_dinput", "YesNo", NULL, false);
opt->mItems.Push(it); opt->mItems.Push(it);
it = new FOptionMenuItemOption("Enable XInput controllers", "joy_xinput", "YesNo", NULL, false); it = new FOptionMenuItemOption("Enable XInput controllers", "joy_xinput", "YesNo", NULL, false);
@ -371,24 +371,24 @@ void UpdateJoystickMenu(IJoystickConfig *selected)
opt->mItems.Push(it); opt->mItems.Push(it);
#endif #endif
it = new FOptionMenuItemStaticText(" ", false); it = new FOptionMenuItemStaticText(" ");
opt->mItems.Push(it); opt->mItems.Push(it);
if (Joysticks.Size() == 0) if (Joysticks.Size() == 0)
{ {
it = new FOptionMenuItemStaticText("No controllers detected", false); it = new FOptionMenuItemStaticText("$JOYMNU_NOCON");
opt->mItems.Push(it); opt->mItems.Push(it);
if (!use_joystick) if (!use_joystick)
{ {
it = new FOptionMenuItemStaticText("Controller support must be", false); it = new FOptionMenuItemStaticText("$JOYMNU_DISABLED1");
opt->mItems.Push(it); opt->mItems.Push(it);
it = new FOptionMenuItemStaticText("enabled to detect any", false); it = new FOptionMenuItemStaticText("$JOYMNU_DISABLED1");
opt->mItems.Push(it); opt->mItems.Push(it);
} }
} }
else else
{ {
it = new FOptionMenuItemStaticText("Configure controllers:", false); it = new FOptionMenuItemStaticText("$JOYMNU_CONFIG");
opt->mItems.Push(it); opt->mItems.Push(it);
for (int i = 0; i < (int)Joysticks.Size(); ++i) for (int i = 0; i < (int)Joysticks.Size(); ++i)
@ -417,7 +417,7 @@ void UpdateJoystickMenu(IJoystickConfig *selected)
if (i == (int)Joysticks.Size()) if (i == (int)Joysticks.Size())
{ {
SELECTED_JOYSTICK = NULL; SELECTED_JOYSTICK = NULL;
if (DMenu::CurrentMenu != NULL && DMenu::CurrentMenu->IsKindOf(RUNTIME_CLASS(DJoystickConfigMenu))) if (DMenu::CurrentMenu != NULL && dynamic_cast<DJoystickConfigMenu*>(DMenu::CurrentMenu))
{ {
DMenu::CurrentMenu->Close(); DMenu::CurrentMenu->Close();
} }
@ -425,4 +425,9 @@ void UpdateJoystickMenu(IJoystickConfig *selected)
} }
} }
#endif static TMenuClassDescriptor<DJoystickConfigMenu> _im("JoystickConfigMenu");
void RegisterJoystickMenus()
{
menuClasses.Push(&_im);
}

View file

@ -53,6 +53,7 @@
#include "build.h" #include "build.h"
#include "baselayer.h" #include "baselayer.h"
#include "statistics.h" #include "statistics.h"
#include "input/m_joy.h"
void RegisterDukeMenus(); void RegisterDukeMenus();
void RegisterRedneckMenus(); void RegisterRedneckMenus();
@ -60,6 +61,8 @@ void RegisterBloodMenus();
void RegisterSWMenus(); void RegisterSWMenus();
void RegisterLoadsaveMenus(); void RegisterLoadsaveMenus();
void RegisterOptionMenus(); void RegisterOptionMenus();
void RegisterJoystickMenus();
void UpdateJoystickMenu(IJoystickConfig* joy);
extern bool rotatesprite_2doverride; extern bool rotatesprite_2doverride;
bool help_disabled, credits_disabled; bool help_disabled, credits_disabled;
int g_currentMenu; // accessible by CON scripts - contains the current menu's script ID if defined or INT_MAX if none given. int g_currentMenu; // accessible by CON scripts - contains the current menu's script ID if defined or INT_MAX if none given.
@ -953,8 +956,10 @@ void M_Init (void)
RegisterSWMenus(); RegisterSWMenus();
RegisterLoadsaveMenus(); RegisterLoadsaveMenus();
RegisterOptionMenus(); RegisterOptionMenus();
RegisterJoystickMenus();
timerSetCallback(M_Ticker); timerSetCallback(M_Ticker);
M_ParseMenuDefs(); M_ParseMenuDefs();
UpdateJoystickMenu(nullptr);
} }

View file

@ -43,4 +43,7 @@ xx(EndgameMenu)
xx(Mididevices) xx(Mididevices)
xx(Aldevices) xx(Aldevices)
xx(Alresamplers) xx(Alresamplers)
xx(AdvSoundOptions) xx(AdvSoundOptions)
xx(JoystickConfigMenu)
xx(JoystickOptions)

View file

@ -945,29 +945,12 @@ OptionMenu "MouseOptions" //protected
// //
//------------------------------------------------------------------------------------------- //-------------------------------------------------------------------------------------------
OptionMenu "JoystickOptions"//Defaults" //protected OptionMenu "JoystickOptions" //protected
{ {
Title "$JOYMNU_OPTIONS" Title "$JOYMNU_OPTIONS"
Option "$JOYMNU_ENABLE", "use_joystick", "YesNo" // This will be filled in by joystick code if devices get connected or disconnected
Option "$JOYMNU_NOMENU", "m_blockcontrollers", "YesNo"
/*IfOption(Windows)
{
Option "$JOYMNU_DINPUT", "joy_dinput", "YesNo"
Option "$JOYMNU_XINPUT", "joy_xinput", "YesNo"
Option "$JOYMNU_PS2", "joy_ps2raw", "YesNo"
}*/
StaticText ""
StaticTextSwitchable "$JOYMNU_NOCON", "$JOYMNU_CONFIG", "ConfigureMessage"
StaticTextSwitchable " ", "$JOYMNU_DISABLED1", "ConnectMessage1"
StaticTextSwitchable " ", "$JOYMNU_DISABLED2", "ConnectMessage2"
// The rest will be filled in by joystick code if devices get connected or disconnected
} }
OptionMenu "JoystickOptions1" //protected
{
Title "$JOYMNU_OPTIONS"
}
OptionValue "JoyAxisMapNames" OptionValue "JoyAxisMapNames"
{ {