- removed native option menu controls. Note that this commit will not compile!
This commit is contained in:
parent
fc4e1ffcdf
commit
2a5b26c27c
12 changed files with 229 additions and 1724 deletions
|
|
@ -128,177 +128,6 @@ DEFINE_ACTION_FUNCTION(IJoystickConfig, SetAxisMap)
|
|||
|
||||
DOptionMenuDescriptor *UpdateJoystickConfigMenu(IJoystickConfig *joy);
|
||||
|
||||
//=============================================================================
|
||||
//
|
||||
//
|
||||
//
|
||||
//=============================================================================
|
||||
|
||||
class DOptionMenuSliderJoySensitivity_ : public DOptionMenuSliderBase_
|
||||
{
|
||||
public:
|
||||
DOptionMenuSliderJoySensitivity_(const char *label, double min, double max, double step, int showval)
|
||||
: DOptionMenuSliderBase_(label, min, max, step, showval)
|
||||
{
|
||||
}
|
||||
|
||||
double GetSliderValue()
|
||||
{
|
||||
return SELECTED_JOYSTICK->GetSensitivity();
|
||||
}
|
||||
|
||||
void SetSliderValue(double val)
|
||||
{
|
||||
SELECTED_JOYSTICK->SetSensitivity(float(val));
|
||||
}
|
||||
};
|
||||
|
||||
//=============================================================================
|
||||
//
|
||||
//
|
||||
//
|
||||
//=============================================================================
|
||||
|
||||
class DOptionMenuSliderJoyScale_ : public DOptionMenuSliderBase_
|
||||
{
|
||||
int mAxis;
|
||||
int mNeg;
|
||||
|
||||
public:
|
||||
DOptionMenuSliderJoyScale_(const char *label, int axis, double min, double max, double step, int showval)
|
||||
: DOptionMenuSliderBase_(label, min, max, step, showval)
|
||||
{
|
||||
mAxis = axis;
|
||||
mNeg = 1;
|
||||
}
|
||||
|
||||
double GetSliderValue()
|
||||
{
|
||||
double d = SELECTED_JOYSTICK->GetAxisScale(mAxis);
|
||||
mNeg = d < 0? -1:1;
|
||||
return d;
|
||||
}
|
||||
|
||||
void SetSliderValue(double val)
|
||||
{
|
||||
SELECTED_JOYSTICK->SetAxisScale(mAxis, float(val * mNeg));
|
||||
}
|
||||
};
|
||||
|
||||
//=============================================================================
|
||||
//
|
||||
//
|
||||
//
|
||||
//=============================================================================
|
||||
|
||||
class DOptionMenuSliderJoyDeadZone_ : public DOptionMenuSliderBase_
|
||||
{
|
||||
int mAxis;
|
||||
int mNeg;
|
||||
|
||||
public:
|
||||
DOptionMenuSliderJoyDeadZone_(const char *label, int axis, double min, double max, double step, int showval)
|
||||
: DOptionMenuSliderBase_(label, min, max, step, showval)
|
||||
{
|
||||
mAxis = axis;
|
||||
mNeg = 1;
|
||||
}
|
||||
|
||||
double GetSliderValue()
|
||||
{
|
||||
double d = SELECTED_JOYSTICK->GetAxisDeadZone(mAxis);
|
||||
mNeg = d < 0? -1:1;
|
||||
return d;
|
||||
}
|
||||
|
||||
void SetSliderValue(double val)
|
||||
{
|
||||
SELECTED_JOYSTICK->SetAxisDeadZone(mAxis, float(val * mNeg));
|
||||
}
|
||||
};
|
||||
|
||||
//=============================================================================
|
||||
//
|
||||
//
|
||||
//
|
||||
//=============================================================================
|
||||
|
||||
class DOptionMenuItemJoyMap_ : public DOptionMenuItemOptionBase_
|
||||
{
|
||||
int mAxis;
|
||||
public:
|
||||
|
||||
DOptionMenuItemJoyMap_(const char *label, int axis, const char *values, int center)
|
||||
: DOptionMenuItemOptionBase_(label, "none", values, NULL, center)
|
||||
{
|
||||
mAxis = axis;
|
||||
}
|
||||
|
||||
int GetSelection()
|
||||
{
|
||||
double f = SELECTED_JOYSTICK->GetAxisMap(mAxis);
|
||||
FOptionValues **opt = OptionValues.CheckKey(mValues);
|
||||
if (opt != NULL && *opt != NULL)
|
||||
{
|
||||
// Map from joystick axis to menu selection.
|
||||
for(unsigned i = 0; i < (*opt)->mValues.Size(); i++)
|
||||
{
|
||||
if (fabs(f - (*opt)->mValues[i].Value) < FLT_EPSILON)
|
||||
{
|
||||
return i;
|
||||
}
|
||||
}
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
void SetSelection(int selection)
|
||||
{
|
||||
FOptionValues **opt = OptionValues.CheckKey(mValues);
|
||||
// Map from menu selection to joystick axis.
|
||||
if (opt == NULL || *opt == NULL || (unsigned)selection >= (*opt)->mValues.Size())
|
||||
{
|
||||
selection = JOYAXIS_None;
|
||||
}
|
||||
else
|
||||
{
|
||||
selection = (int)(*opt)->mValues[selection].Value;
|
||||
}
|
||||
SELECTED_JOYSTICK->SetAxisMap(mAxis, (EJoyAxis)selection);
|
||||
}
|
||||
};
|
||||
|
||||
//=============================================================================
|
||||
//
|
||||
//
|
||||
//
|
||||
//=============================================================================
|
||||
|
||||
class DOptionMenuItemInverter_ : public DOptionMenuItemOptionBase_
|
||||
{
|
||||
int mAxis;
|
||||
public:
|
||||
|
||||
DOptionMenuItemInverter_(const char *label, int axis, int center)
|
||||
: DOptionMenuItemOptionBase_(label, "none", "YesNo", NULL, center)
|
||||
{
|
||||
mAxis = axis;
|
||||
}
|
||||
|
||||
int GetSelection()
|
||||
{
|
||||
float f = SELECTED_JOYSTICK->GetAxisScale(mAxis);
|
||||
return f > 0? 0:1;
|
||||
}
|
||||
|
||||
void SetSelection(int Selection)
|
||||
{
|
||||
float f = fabsf(SELECTED_JOYSTICK->GetAxisScale(mAxis));
|
||||
if (Selection) f*=-1;
|
||||
SELECTED_JOYSTICK->SetAxisScale(mAxis, f);
|
||||
}
|
||||
};
|
||||
|
||||
class DJoystickConfigMenu : public DOptionMenu
|
||||
{
|
||||
DECLARE_CLASS(DJoystickConfigMenu, DOptionMenu)
|
||||
|
|
@ -306,33 +135,6 @@ class DJoystickConfigMenu : public DOptionMenu
|
|||
|
||||
IMPLEMENT_CLASS(DJoystickConfigMenu, false, false)
|
||||
|
||||
//=============================================================================
|
||||
//
|
||||
// Executes a CCMD, action is a CCMD name
|
||||
//
|
||||
//=============================================================================
|
||||
|
||||
class DOptionMenuItemJoyConfigMenu_ : public DOptionMenuItemSubmenu_
|
||||
{
|
||||
DECLARE_CLASS(DOptionMenuItemJoyConfigMenu_, DOptionMenuItemSubmenu_)
|
||||
IJoystickConfig *mJoy;
|
||||
public:
|
||||
DOptionMenuItemJoyConfigMenu_(const char *label = nullptr, IJoystickConfig *joy = nullptr)
|
||||
: DOptionMenuItemSubmenu_(label, "JoystickConfigMenu")
|
||||
{
|
||||
mJoy = joy;
|
||||
}
|
||||
|
||||
bool Activate()
|
||||
{
|
||||
UpdateJoystickConfigMenu(mJoy);
|
||||
return DOptionMenuItemSubmenu_::Activate();
|
||||
}
|
||||
};
|
||||
|
||||
IMPLEMENT_CLASS(DOptionMenuItemJoyConfigMenu_, false, false)
|
||||
|
||||
|
||||
/*=======================================
|
||||
*
|
||||
* Joystick Menu
|
||||
|
|
@ -345,12 +147,12 @@ DOptionMenuDescriptor *UpdateJoystickConfigMenu(IJoystickConfig *joy)
|
|||
if (desc != NULL && (*desc)->IsKindOf(RUNTIME_CLASS(DOptionMenuDescriptor)))
|
||||
{
|
||||
DOptionMenuDescriptor *opt = (DOptionMenuDescriptor *)*desc;
|
||||
DOptionMenuItem *it;
|
||||
DMenuItemBase *it;
|
||||
opt->mItems.Clear();
|
||||
if (joy == NULL)
|
||||
{
|
||||
opt->mTitle = "Configure Controller";
|
||||
it = new DOptionMenuItemStaticText_("Invalid controller specified for menu", false);
|
||||
it = CreateOptionMenuItemStaticText("Invalid controller specified for menu", false);
|
||||
opt->mItems.Push(it);
|
||||
}
|
||||
else
|
||||
|
|
@ -359,34 +161,34 @@ DOptionMenuDescriptor *UpdateJoystickConfigMenu(IJoystickConfig *joy)
|
|||
|
||||
SELECTED_JOYSTICK = joy;
|
||||
|
||||
it = new DOptionMenuSliderJoySensitivity_("Overall sensitivity", 0, 2, 0.1, 3);
|
||||
it = CreateOptionMenuSliderJoySensitivity("Overall sensitivity", 0, 2, 0.1, 3);
|
||||
opt->mItems.Push(it);
|
||||
it = new DOptionMenuItemStaticText_(" ", false);
|
||||
it = CreateOptionMenuItemStaticText(" ", false);
|
||||
opt->mItems.Push(it);
|
||||
|
||||
if (joy->GetNumAxes() > 0)
|
||||
{
|
||||
it = new DOptionMenuItemStaticText_("Axis Configuration", true);
|
||||
it = CreateOptionMenuItemStaticText("Axis Configuration", true);
|
||||
opt->mItems.Push(it);
|
||||
|
||||
for (int i = 0; i < joy->GetNumAxes(); ++i)
|
||||
{
|
||||
it = new DOptionMenuItemStaticText_(" ", false);
|
||||
it = CreateOptionMenuItemStaticText(" ", false);
|
||||
opt->mItems.Push(it);
|
||||
|
||||
it = new DOptionMenuItemJoyMap_(joy->GetAxisName(i), i, "JoyAxisMapNames", false);
|
||||
it = CreateOptionMenuItemJoyMap(joy->GetAxisName(i), i, "JoyAxisMapNames", false);
|
||||
opt->mItems.Push(it);
|
||||
it = new DOptionMenuSliderJoyScale_("Overall sensitivity", i, 0, 4, 0.1, 3);
|
||||
it = CreateOptionMenuSliderJoyScale("Overall sensitivity", i, 0, 4, 0.1, 3);
|
||||
opt->mItems.Push(it);
|
||||
it = new DOptionMenuItemInverter_("Invert", i, false);
|
||||
it = CreateOptionMenuItemInverter("Invert", i, false);
|
||||
opt->mItems.Push(it);
|
||||
it = new DOptionMenuSliderJoyDeadZone_("Dead Zone", i, 0, 0.9, 0.05, 3);
|
||||
it = CreateOptionMenuSliderJoyDeadZone("Dead Zone", i, 0, 0.9, 0.05, 3);
|
||||
opt->mItems.Push(it);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
it = new DOptionMenuItemStaticText_("No configurable axes", false);
|
||||
it = CreateOptionMenuItemStaticText("No configurable axes", false);
|
||||
opt->mItems.Push(it);
|
||||
}
|
||||
}
|
||||
|
|
@ -412,7 +214,7 @@ void UpdateJoystickMenu(IJoystickConfig *selected)
|
|||
if (desc != NULL && (*desc)->IsKindOf(RUNTIME_CLASS(DOptionMenuDescriptor)))
|
||||
{
|
||||
DOptionMenuDescriptor *opt = (DOptionMenuDescriptor *)*desc;
|
||||
DOptionMenuItem *it;
|
||||
DMenuItemBase *it;
|
||||
opt->mItems.Clear();
|
||||
|
||||
int i;
|
||||
|
|
@ -436,40 +238,40 @@ void UpdateJoystickMenu(IJoystickConfig *selected)
|
|||
}
|
||||
|
||||
// Todo: Block joystick for changing this one.
|
||||
it = new DOptionMenuItemOption_("Enable controller support", "use_joystick", "YesNo", NULL, false);
|
||||
it = CreateOptionMenuItemOption("Enable controller support", "use_joystick", "YesNo", NULL, false);
|
||||
opt->mItems.Push(it);
|
||||
#ifdef _WIN32
|
||||
it = new DOptionMenuItemOption_("Enable DirectInput controllers", "joy_dinput", "YesNo", NULL, false);
|
||||
it = CreateOptionMenuItemOption("Enable DirectInput controllers", "joy_dinput", "YesNo", NULL, false);
|
||||
opt->mItems.Push(it);
|
||||
it = new DOptionMenuItemOption_("Enable XInput controllers", "joy_xinput", "YesNo", NULL, false);
|
||||
it = CreateOptionMenuItemOption("Enable XInput controllers", "joy_xinput", "YesNo", NULL, false);
|
||||
opt->mItems.Push(it);
|
||||
it = new DOptionMenuItemOption_("Enable raw PlayStation 2 adapters", "joy_ps2raw", "YesNo", NULL, false);
|
||||
it = CreateOptionMenuItemOption("Enable raw PlayStation 2 adapters", "joy_ps2raw", "YesNo", NULL, false);
|
||||
opt->mItems.Push(it);
|
||||
#endif
|
||||
|
||||
it = new DOptionMenuItemStaticText_(" ", false);
|
||||
it = CreateOptionMenuItemStaticText(" ", false);
|
||||
opt->mItems.Push(it);
|
||||
|
||||
if (Joysticks.Size() == 0)
|
||||
{
|
||||
it = new DOptionMenuItemStaticText_("No controllers detected", false);
|
||||
it = CreateOptionMenuItemStaticText("No controllers detected", false);
|
||||
opt->mItems.Push(it);
|
||||
if (!use_joystick)
|
||||
{
|
||||
it = new DOptionMenuItemStaticText_("Controller support must be", false);
|
||||
it = CreateOptionMenuItemStaticText("Controller support must be", false);
|
||||
opt->mItems.Push(it);
|
||||
it = new DOptionMenuItemStaticText_("enabled to detect any", false);
|
||||
it = CreateOptionMenuItemStaticText("enabled to detect any", false);
|
||||
opt->mItems.Push(it);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
it = new DOptionMenuItemStaticText_("Configure controllers:", false);
|
||||
it = CreateOptionMenuItemStaticText("Configure controllers:", false);
|
||||
opt->mItems.Push(it);
|
||||
|
||||
for (int i = 0; i < (int)Joysticks.Size(); ++i)
|
||||
{
|
||||
it = new DOptionMenuItemJoyConfigMenu_(Joysticks[i]->GetName(), Joysticks[i]);
|
||||
it = CreateOptionMenuItemJoyConfigMenu(Joysticks[i]->GetName(), Joysticks[i]);
|
||||
opt->mItems.Push(it);
|
||||
if (i == itemnum) opt->mSelectedItem = opt->mItems.Size();
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue