Exemplo n.º 1
0
void Gamepad::bindGamepadControls(Container* container)
{
    std::vector<Control*> controls = container->getControls();
    std::vector<Control*>::iterator itr = controls.begin();

    for (; itr != controls.end(); itr++)
    {
        Control* control = *itr;
        GP_ASSERT(control);

        if (control->isContainer())
        {
            bindGamepadControls((Container*) control);
        }
        else if (std::strcmp("JoystickControl", control->getTypeName()) == 0)
        {
            JoystickControl* joystick = (JoystickControl*)control;
            joystick->setConsumeInputEvents(true);
            _uiJoysticks[joystick->getIndex()] = joystick;
            _joystickCount++;
        }
        else if (std::strcmp("Button", control->getTypeName()) == 0)
        {
            Button* button = (Button*)control;
            button->setConsumeInputEvents(true);
            button->setCanFocus(false);
            _uiButtons[button->getDataBinding()] = button;
            _buttonCount++;
        }
    }
}
Exemplo n.º 2
0
void Gamepad::getJoystickValues(unsigned int joystickId, kmVec2* outValue) const
{
    if (joystickId >= _joystickCount)
        return;

    if (_form)
    {
        JoystickControl* joystick = _uiJoysticks[joystickId];
        if (joystick)
        {
            const kmVec2& value = joystick->getValue();
            //outValue->set(value.x, value.y);
			kmVec2Fill(outValue, value.x, value.y);
        }
        else
        {
            //outValue->set(0.0f, 0.0f);
			kmVec2Fill(outValue, 0.0f, 0.0f);
        }
    }
    else
    {
        //outValue->set(_joysticks[joystickId]);
		kmVec2Fill(outValue, _joysticks[joystickId].x, _joysticks[joystickId].y);
    }
}
Exemplo n.º 3
0
void Gamepad::getJoystickValues(unsigned int joystickId, Vector2* outValue) const
{
    if (joystickId >= _joystickCount)
        return;

    if (_form)
    {
        JoystickControl* joystick = _uiJoysticks[joystickId];
        if (joystick)
        {
            const Vector2& value = joystick->getValue();
            outValue->set(value.x, value.y);
        }
        else
        {
            outValue->set(0.0f, 0.0f);
        }
    }
    else
    {
        outValue->set(_joysticks[joystickId]);
    }
}