|
@@ -5,6 +5,9 @@ namespace BansheeEngine
|
|
|
Map<String, UINT32> VirtualButton::UniqueButtonIds;
|
|
Map<String, UINT32> VirtualButton::UniqueButtonIds;
|
|
|
UINT32 VirtualButton::NextButtonId = 0;
|
|
UINT32 VirtualButton::NextButtonId = 0;
|
|
|
|
|
|
|
|
|
|
+ Map<String, UINT32> VirtualAxis::UniqueAxisIds;
|
|
|
|
|
+ UINT32 VirtualAxis::NextAxisId = 0;
|
|
|
|
|
+
|
|
|
VIRTUAL_BUTTON_DESC::VIRTUAL_BUTTON_DESC()
|
|
VIRTUAL_BUTTON_DESC::VIRTUAL_BUTTON_DESC()
|
|
|
:buttonCode(BC_0), modifiers(VButtonModifier::None), repeatable(false)
|
|
:buttonCode(BC_0), modifiers(VButtonModifier::None), repeatable(false)
|
|
|
{ }
|
|
{ }
|
|
@@ -13,6 +16,17 @@ namespace BansheeEngine
|
|
|
:buttonCode(buttonCode), modifiers(modifiers), repeatable(repeatable)
|
|
:buttonCode(buttonCode), modifiers(modifiers), repeatable(repeatable)
|
|
|
{ }
|
|
{ }
|
|
|
|
|
|
|
|
|
|
+ VIRTUAL_AXIS_DESC::VIRTUAL_AXIS_DESC()
|
|
|
|
|
+ : type(AxisType::MainX), device(AxisDevice::Mouse), deviceIndex(0), deadZone(0.0001f),
|
|
|
|
|
+ sensitivity(1.0f), invert(false), smooth(true)
|
|
|
|
|
+ { }
|
|
|
|
|
+
|
|
|
|
|
+ VIRTUAL_AXIS_DESC::VIRTUAL_AXIS_DESC(AxisType type, AxisDevice device, float deadZone, UINT32 deviceIndex,
|
|
|
|
|
+ float sensitivity, bool invert, bool smooth)
|
|
|
|
|
+ :type(type), device(device), deadZone(deadZone), deviceIndex(deviceIndex), sensitivity(sensitivity),
|
|
|
|
|
+ invert(invert), smooth(smooth)
|
|
|
|
|
+ { }
|
|
|
|
|
+
|
|
|
VirtualButton::VirtualButton()
|
|
VirtualButton::VirtualButton()
|
|
|
:buttonIdentifier(0)
|
|
:buttonIdentifier(0)
|
|
|
{ }
|
|
{ }
|
|
@@ -30,6 +44,23 @@ namespace BansheeEngine
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ VirtualAxis::VirtualAxis()
|
|
|
|
|
+ :axisIdentifier(0)
|
|
|
|
|
+ { }
|
|
|
|
|
+
|
|
|
|
|
+ VirtualAxis::VirtualAxis(const String& name)
|
|
|
|
|
+ {
|
|
|
|
|
+ auto findIter = UniqueAxisIds.find(name);
|
|
|
|
|
+
|
|
|
|
|
+ if (findIter != UniqueAxisIds.end())
|
|
|
|
|
+ axisIdentifier = findIter->second;
|
|
|
|
|
+ else
|
|
|
|
|
+ {
|
|
|
|
|
+ axisIdentifier = NextAxisId;
|
|
|
|
|
+ UniqueAxisIds[name] = NextAxisId++;
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
InputConfiguration::InputConfiguration()
|
|
InputConfiguration::InputConfiguration()
|
|
|
:mRepeatInterval(300)
|
|
:mRepeatInterval(300)
|
|
|
{ }
|
|
{ }
|
|
@@ -84,7 +115,31 @@ namespace BansheeEngine
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- bool InputConfiguration::getButton(ButtonCode code, UINT32 modifiers, VirtualButton& btn, VIRTUAL_BUTTON_DESC& btnDesc) const
|
|
|
|
|
|
|
+ void InputConfiguration::registerAxis(const String& name, const VIRTUAL_AXIS_DESC& desc)
|
|
|
|
|
+ {
|
|
|
|
|
+ VirtualAxis axis(name);
|
|
|
|
|
+
|
|
|
|
|
+ if (axis.axisIdentifier >= (UINT32)mAxes.size())
|
|
|
|
|
+ mAxes.resize(axis.axisIdentifier + 1);
|
|
|
|
|
+
|
|
|
|
|
+ mAxes[axis.axisIdentifier].name = name;
|
|
|
|
|
+ mAxes[axis.axisIdentifier].desc = desc;
|
|
|
|
|
+ mAxes[axis.axisIdentifier].axis = axis;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ void InputConfiguration::unregisterAxis(const String& name)
|
|
|
|
|
+ {
|
|
|
|
|
+ for (UINT32 i = 0; i < (UINT32)mAxes.size(); i++)
|
|
|
|
|
+ {
|
|
|
|
|
+ if (mAxes[i].name == name)
|
|
|
|
|
+ {
|
|
|
|
|
+ mAxes.erase(mAxes.begin() + i);
|
|
|
|
|
+ i--;
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ bool InputConfiguration::_getButton(ButtonCode code, UINT32 modifiers, VirtualButton& btn, VIRTUAL_BUTTON_DESC& btnDesc) const
|
|
|
{
|
|
{
|
|
|
const Vector<VirtualButtonData>& btnData = mButtons[code & 0x0000FFFF];
|
|
const Vector<VirtualButtonData>& btnData = mButtons[code & 0x0000FFFF];
|
|
|
|
|
|
|
@@ -100,4 +155,13 @@ namespace BansheeEngine
|
|
|
|
|
|
|
|
return false;
|
|
return false;
|
|
|
}
|
|
}
|
|
|
|
|
+
|
|
|
|
|
+ bool InputConfiguration::_getAxis(const VirtualAxis& axis, VIRTUAL_AXIS_DESC& axisDesc) const
|
|
|
|
|
+ {
|
|
|
|
|
+ if (axis.axisIdentifier >= (UINT32)mAxes.size())
|
|
|
|
|
+ return false;
|
|
|
|
|
+
|
|
|
|
|
+ axisDesc = mAxes[axis.axisIdentifier].desc;
|
|
|
|
|
+ return true;
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|