本文整理汇总了C++中EventQueue::postAxisEvent方法的典型用法代码示例。如果您正苦于以下问题:C++ EventQueue::postAxisEvent方法的具体用法?C++ EventQueue::postAxisEvent怎么用?C++ EventQueue::postAxisEvent使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类EventQueue
的用法示例。
在下文中一共展示了EventQueue::postAxisEvent方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: update
void update(EventQueue& _eventQueue)
{
int numButtons, numAxes;
const unsigned char* buttons = glfwGetJoystickButtons(m_handle.idx, &numButtons);
const float* axes = glfwGetJoystickAxes(m_handle.idx, &numAxes);
if (NULL == buttons || NULL == axes)
{
return;
}
if (numAxes > GamepadAxis::Count)
{
numAxes = GamepadAxis::Count;
}
if (numButtons > Key::Count - Key::GamepadA)
{
numButtons = Key::Count - Key::GamepadA;
}
WindowHandle defaultWindow = { 0 };
for (int ii = 0; ii < numAxes; ++ii)
{
GamepadAxis::Enum axis = translateGamepadAxis(ii);
int32_t value = (int32_t) (axes[ii] * 32768.f);
if (GamepadAxis::LeftY == axis || GamepadAxis::RightY == axis)
{
value = -value;
}
if (m_axes[ii] != value)
{
m_axes[ii] = value;
_eventQueue.postAxisEvent(defaultWindow
, m_handle
, axis
, value);
}
}
for (int ii = 0; ii < numButtons; ++ii)
{
Key::Enum key = translateGamepadButton(ii);
if (m_buttons[ii] != buttons[ii])
{
m_buttons[ii] = buttons[ii];
_eventQueue.postKeyEvent(defaultWindow
, key
, 0
, buttons[ii] != 0);
}
}
}