本文整理汇总了C++中JoyButton类的典型用法代码示例。如果您正苦于以下问题:C++ JoyButton类的具体用法?C++ JoyButton怎么用?C++ JoyButton使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了JoyButton类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: changeSetButtonAssociation
void InputDevice::changeSetButtonAssociation(int button_index, int originset, int newset, int mode)
{
JoyButton *button = joystick_sets.value(newset)->getJoyButton(button_index);
JoyButton::SetChangeCondition tempmode = (JoyButton::SetChangeCondition)mode;
button->setChangeSetSelection(originset);
button->setChangeSetCondition(tempmode, true);
}
示例2: propogateSetButtonNameChange
void SetJoystick::propogateSetButtonNameChange()
{
JoyButton *button = static_cast<JoyButton*>(sender());
disconnect(button, SIGNAL(buttonNameChanged()), this, SLOT(propogateSetButtonNameChange()));
emit setButtonNameChange(button->getJoyNumber());
connect(button, SIGNAL(buttonNameChanged()), this, SLOT(propogateSetButtonNameChange()));
}
示例3: iter
/**
* @brief Perform mouse events for all buttons and slots.
*/
void JoyButtonMouseHelper::mouseEvent()
{
//qDebug() << "ENTER";
if (!JoyButton::hasCursorEvents() && !JoyButton::hasSpringEvents())
{
//qDebug() << "GO THROUGH LIST";
QList<JoyButton*> *buttonList = JoyButton::getPendingMouseButtons();
QListIterator<JoyButton*> iter(*buttonList);
while (iter.hasNext())
{
JoyButton *temp = iter.next();
temp->mouseEvent();
}
}
//if (JoyButton::hasCursorEvents())
//{
//qDebug() << "CURSOR EVENT: ";
moveMouseCursor();
//}
if (JoyButton::hasSpringEvents())
{
moveSpringMouse();
}
}
示例4: iterAxes
/**
* @brief Perform a release of all elements of a set. Stick and vdpad
* releases will be handled by the associated button or axis.
*/
void SetJoystick::release()
{
QHashIterator<int, JoyAxis*> iterAxes(axes);
while (iterAxes.hasNext())
{
JoyAxis *axis = iterAxes.next().value();
axis->clearPendingEvent();
axis->joyEvent(axis->getCurrentThrottledDeadValue(), true);
}
QHashIterator<int, JoyDPad*> iterDPads(hats);
while (iterDPads.hasNext())
{
JoyDPad *dpad = iterDPads.next().value();
dpad->clearPendingEvent();
dpad->joyEvent(0, true);
}
QHashIterator<int, JoyButton*> iterButtons(buttons);
while (iterButtons.hasNext())
{
JoyButton *button = iterButtons.next().value();
button->clearPendingEvent();
button->joyEvent(false, true);
}
}
示例5: propogateSetButtonRelease
void SetJoystick::propogateSetButtonRelease(int button)
{
JoyButton *jButton = static_cast<JoyButton*>(sender());
if (!jButton->getIgnoreEventState())
{
emit setButtonRelease(index, button);
}
}
示例6: getActiveSetJoystick
void InputDevice::updateSetButtonNames(int index)
{
JoyButton *button = getActiveSetJoystick()->getJoyButton(index);
if (button)
{
setButtonName(index, button->getButtonName());
}
}
示例7: stickIter
void SetJoystick::copyAssignments(SetJoystick *destSet)
{
for (int i=0; i < device->getNumberAxes(); i++)
{
JoyAxis *sourceAxis = axes.value(i);
JoyAxis *destAxis = destSet->axes.value(i);
if (sourceAxis && destAxis)
{
sourceAxis->copyAssignments(destAxis);
}
}
QHashIterator<int, JoyControlStick*> stickIter(sticks);
while (stickIter.hasNext())
{
stickIter.next();
int index = stickIter.key();
JoyControlStick *sourceStick = stickIter.value();
JoyControlStick *destStick = destSet->sticks.value(index);
if (sourceStick && destStick)
{
sourceStick->copyAssignments(destStick);
}
}
for (int i=0; i < device->getNumberHats(); i++)
{
JoyDPad *sourceDPad = hats.value(i);
JoyDPad *destDPad = destSet->hats.value(i);
if (sourceDPad && destDPad)
{
sourceDPad->copyAssignments(destDPad);
}
}
QHashIterator<int, VDPad*> vdpadIter(vdpads);
while (vdpadIter.hasNext())
{
vdpadIter.next();
int index = vdpadIter.key();
VDPad *sourceVDpad = vdpadIter.value();
VDPad *destVDPad = destSet->vdpads.value(index);
if (sourceVDpad && destVDPad)
{
sourceVDpad->copyAssignments(destVDPad);
}
}
for (int i=0; i < device->getNumberButtons(); i++)
{
JoyButton *sourceButton = buttons.value(i);
JoyButton *destButton = destSet->buttons.value(i);
if (sourceButton && destButton)
{
sourceButton->copyAssignments(destButton);
}
}
}
示例8: getJoyStick
void SetJoystick::writeConfig(QXmlStreamWriter *xml)
{
if (!isSetEmpty())
{
xml->writeStartElement("set");
xml->writeAttribute("index", QString::number(index+1));
if (!name.isEmpty())
{
xml->writeTextElement("name", name);
}
for (int i=0; i < getNumberSticks(); i++)
{
JoyControlStick *stick = getJoyStick(i);
stick->writeConfig(xml);
}
for (int i=0; i < getNumberVDPads(); i++)
{
VDPad *vdpad = getVDPad(i);
if (vdpad)
{
vdpad->writeConfig(xml);
}
}
for (int i=0; i < getNumberAxes(); i++)
{
JoyAxis *axis = getJoyAxis(i);
if (!axis->isPartControlStick() && axis->hasControlOfButtons())
{
axis->writeConfig(xml);
}
}
for (int i=0; i < getNumberHats(); i++)
{
JoyDPad *dpad = getJoyDPad(i);
dpad->writeConfig(xml);
}
for (int i=0; i < getNumberButtons(); i++)
{
JoyButton *button = getJoyButton(i);
if (button && !button->isPartVDPad())
{
button->writeConfig(xml);
}
}
xml->writeEndElement();
}
}
示例9: iter
bool SetJoystick::isSetEmpty()
{
bool result = true;
QHashIterator<int, JoyButton*> iter(buttons);
while (iter.hasNext() && result)
{
JoyButton *button = iter.next().value();
if (!button->isDefault())
{
result = false;
}
}
QHashIterator<int, JoyAxis*> iter2(axes);
while (iter2.hasNext() && result)
{
JoyAxis *axis = iter2.next().value();
if (!axis->isDefault())
{
result = false;
}
}
QHashIterator<int, JoyDPad*> iter3(hats);
while (iter3.hasNext() && result)
{
JoyDPad *dpad = iter3.next().value();
if (!dpad->isDefault())
{
result = false;
}
}
QHashIterator<int, JoyControlStick*> iter4(sticks);
while (iter4.hasNext() && result)
{
JoyControlStick *stick = iter4.next().value();
if (!stick->isDefault())
{
result = false;
}
}
QHashIterator<int, VDPad*> iter5(vdpads);
while (iter5.hasNext() && result)
{
VDPad *vdpad = iter5.next().value();
if (!vdpad->isDefault())
{
result = false;
}
}
return result;
}
示例10: iter
void JoyControlStick::resetButtons()
{
QHashIterator<JoyStickDirections, JoyControlStickButton*> iter(buttons);
while (iter.hasNext())
{
JoyButton *button = iter.next().value();
if (button)
{
button->reset();
}
}
}
示例11: iter
void InputDevice::setButtonName(int index, QString tempName)
{
QHashIterator<int, SetJoystick*> iter(joystick_sets);
while (iter.hasNext())
{
SetJoystick *tempSet = iter.next().value();
disconnect(tempSet, SIGNAL(setButtonNameChange(int)), this, SLOT(updateSetButtonNames(int)));
JoyButton *button = tempSet->getJoyButton(index);
if (button)
{
button->setButtonName(tempName);
}
connect(tempSet, SIGNAL(setButtonNameChange(int)), this, SLOT(updateSetButtonNames(int)));
}
}
示例12: while
void InputDaemon::secondInputPass(QQueue<SDL_Event> *sdlEventQueue)
{
QHash<SDL_JoystickID, InputDevice*> activeDevices;
while (!sdlEventQueue->isEmpty())
{
SDL_Event event = sdlEventQueue->dequeue();
switch (event.type)
{
//qDebug() << QTime::currentTime() << " :";
case SDL_JOYBUTTONDOWN:
case SDL_JOYBUTTONUP:
{
#ifdef USE_SDL_2
InputDevice *joy = trackjoysticks.value(event.jbutton.which);
#else
InputDevice *joy = joysticks->value(event.jbutton.which);
#endif
if (joy)
{
SetJoystick* set = joy->getActiveSetJoystick();
JoyButton *button = set->getJoyButton(event.jbutton.button);
if (button)
{
//button->joyEvent(event.type == SDL_JOYBUTTONDOWN ? true : false);
button->queuePendingEvent(event.type == SDL_JOYBUTTONDOWN ? true : false);
if (!activeDevices.contains(event.jbutton.which))
{
activeDevices.insert(event.jbutton.which, joy);
}
}
}
#ifdef USE_SDL_2
else if (trackcontrollers.contains(event.jbutton.which))
{
GameController *gamepad = trackcontrollers.value(event.jbutton.which);
gamepad->rawButtonEvent(event.jbutton.button, event.type == SDL_JOYBUTTONDOWN ? true : false);
}
#endif
break;
}
case SDL_JOYAXISMOTION:
{
#ifdef USE_SDL_2
InputDevice *joy = trackjoysticks.value(event.jaxis.which);
#else
InputDevice *joy = joysticks->value(event.jaxis.which);
#endif
if (joy)
{
SetJoystick* set = joy->getActiveSetJoystick();
JoyAxis *axis = set->getJoyAxis(event.jaxis.axis);
if (axis)
{
//axis->joyEvent(event.jaxis.value);
axis->queuePendingEvent(event.jaxis.value);
if (!activeDevices.contains(event.jaxis.which))
{
activeDevices.insert(event.jaxis.which, joy);
}
}
joy->rawAxisEvent(event.jaxis.which, event.jaxis.value);
}
#ifdef USE_SDL_2
else if (trackcontrollers.contains(event.jaxis.which))
{
GameController *gamepad = trackcontrollers.value(event.jaxis.which);
gamepad->rawAxisEvent(event.jaxis.axis, event.jaxis.value);
}
#endif
break;
}
case SDL_JOYHATMOTION:
{
#ifdef USE_SDL_2
InputDevice *joy = trackjoysticks.value(event.jhat.which);
#else
InputDevice *joy = joysticks->value(event.jhat.which);
#endif
if (joy)
{
SetJoystick* set = joy->getActiveSetJoystick();
JoyDPad *dpad = set->getJoyDPad(event.jhat.hat);
if (dpad)
{
//dpad->joyEvent(event.jhat.value);
dpad->joyEvent(event.jhat.value);
if (!activeDevices.contains(event.jhat.which))
{
activeDevices.insert(event.jhat.which, joy);
//.........这里部分代码省略.........
示例13: getSDLName
void GameController::writeConfig(QXmlStreamWriter *xml)
{
xml->writeStartElement(getXmlName());
xml->writeAttribute("configversion", QString::number(PadderCommon::LATESTCONFIGFILEVERSION));
xml->writeAttribute("appversion", PadderCommon::programVersion);
xml->writeComment("The SDL name for a joystick is included for informational purposes only.");
xml->writeTextElement("sdlname", getSDLName());
#ifdef USE_SDL_2
xml->writeComment("The GUID for a joystick is included for informational purposes only.");
xml->writeTextElement("guid", getGUIDString());
#endif
if (!profileName.isEmpty())
{
xml->writeTextElement("profilename", profileName);
}
xml->writeStartElement("names"); // <names>
SetJoystick *tempSet = getActiveSetJoystick();
for (int i=0; i < getNumberButtons(); i++)
{
JoyButton *button = tempSet->getJoyButton(i);
if (button && !button->getButtonName().isEmpty())
{
xml->writeStartElement("buttonname");
xml->writeAttribute("index", QString::number(button->getRealJoyNumber()));
xml->writeCharacters(button->getButtonName());
xml->writeEndElement();
}
}
for (int i=0; i < getNumberAxes(); i++)
{
JoyAxis *axis = tempSet->getJoyAxis(i);
if (axis)
{
if (!axis->getAxisName().isEmpty())
{
xml->writeStartElement("axisname");
xml->writeAttribute("index", QString::number(axis->getRealJoyIndex()));
xml->writeCharacters(axis->getAxisName());
xml->writeEndElement();
}
JoyAxisButton *naxisbutton = axis->getNAxisButton();
if (!naxisbutton->getButtonName().isEmpty())
{
xml->writeStartElement("axisbuttonname");
xml->writeAttribute("index", QString::number(axis->getRealJoyIndex()));
xml->writeAttribute("button", QString::number(naxisbutton->getRealJoyNumber()));
xml->writeCharacters(naxisbutton->getButtonName());
xml->writeEndElement();
}
JoyAxisButton *paxisbutton = axis->getPAxisButton();
if (!paxisbutton->getButtonName().isEmpty())
{
xml->writeStartElement("axisbuttonname");
xml->writeAttribute("index", QString::number(axis->getRealJoyIndex()));
xml->writeAttribute("button", QString::number(paxisbutton->getRealJoyNumber()));
xml->writeCharacters(paxisbutton->getButtonName());
xml->writeEndElement();
}
}
}
for (int i=0; i < getNumberSticks(); i++)
{
JoyControlStick *stick = tempSet->getJoyStick(i);
if (stick)
{
if (!stick->getStickName().isEmpty())
{
xml->writeStartElement("controlstickname");
xml->writeAttribute("index", QString::number(stick->getRealJoyIndex()));
xml->writeCharacters(stick->getStickName());
xml->writeEndElement();
}
QHash<JoyControlStick::JoyStickDirections, JoyControlStickButton*> *buttons = stick->getButtons();
QHashIterator<JoyControlStick::JoyStickDirections, JoyControlStickButton*> iter(*buttons);
while (iter.hasNext())
{
JoyControlStickButton *button = iter.next().value();
if (button && !button->getButtonName().isEmpty())
{
xml->writeStartElement("controlstickbuttonname");
xml->writeAttribute("index", QString::number(stick->getRealJoyIndex()));
xml->writeAttribute("button", QString::number(button->getRealJoyNumber()));
xml->writeCharacters(button->getButtonName());
xml->writeEndElement();
}
}
}
}
for (int i=0; i < getNumberVDPads(); i++)
{
//.........这里部分代码省略.........
示例14: QObject
InputDaemon::InputDaemon(QHash<SDL_JoystickID, InputDevice*> *joysticks, bool graphical, QObject *parent) :
#else
InputDaemon::InputDaemon(QHash<int, InputDevice*> *joysticks, bool graphical, QObject *parent) :
#endif
QObject(parent)
{
this->joysticks = joysticks;
this->stopped = false;
this->graphical = graphical;
eventWorker = new SDLEventReader(joysticks);
thread = new QThread();
eventWorker->moveToThread(thread);
if (graphical)
{
connect(thread, SIGNAL(started()), eventWorker, SLOT(performWork()));
connect(eventWorker, SIGNAL(eventRaised()), this, SLOT(run()));
thread->start();
}
refreshJoysticks();
}
InputDaemon::~InputDaemon()
{
if (eventWorker)
{
quit();
}
if (thread)
{
thread->quit();
thread->wait();
delete thread;
thread = 0;
}
}
void InputDaemon::run ()
{
SDL_Event event;
#ifdef USE_SDL_2
event.type = SDL_FIRSTEVENT;
#else
event.type = SDL_NOEVENT;
#endif
if (!stopped)
{
event = eventWorker->getCurrentEvent();
do
{
switch (event.type)
{
case SDL_JOYBUTTONDOWN:
{
#ifdef USE_SDL_2
InputDevice *joy = trackjoysticks.value(event.jbutton.which);
#else
InputDevice *joy = joysticks->value(event.jbutton.which);
#endif
if (joy)
{
SetJoystick* set = joy->getActiveSetJoystick();
JoyButton *button = set->getJoyButton(event.jbutton.button);
if (button)
{
button->joyEvent(true);
}
}
break;
}
case SDL_JOYBUTTONUP:
{
#ifdef USE_SDL_2
InputDevice *joy = trackjoysticks.value(event.jbutton.which);
#else
InputDevice *joy = joysticks->value(event.jbutton.which);
#endif
if (joy)
{
SetJoystick* set = joy->getActiveSetJoystick();
JoyButton *button = set->getJoyButton(event.jbutton.button);
if (button)
{
button->joyEvent(false);
}
}
break;
}
case SDL_JOYAXISMOTION:
//.........这里部分代码省略.........
示例15: getSDLName
void InputDevice::writeConfig(QXmlStreamWriter *xml)
{
xml->writeStartElement(getXmlName());
xml->writeAttribute("configversion", QString::number(PadderCommon::LATESTCONFIGFILEVERSION));
xml->writeAttribute("appversion", PadderCommon::programVersion);
xml->writeComment("The SDL name for a joystick is included for informational purposes only.");
xml->writeTextElement("sdlname", getSDLName());
for (int i=0; i < getNumberSticks(); i++)
{
JoyControlStick *stick = getActiveSetJoystick()->getJoyStick(i);
xml->writeStartElement("stickAxisAssociation");
xml->writeAttribute("index", QString::number(stick->getRealJoyIndex()));
xml->writeAttribute("xAxis", QString::number(stick->getAxisX()->getRealJoyIndex()));
xml->writeAttribute("yAxis", QString::number(stick->getAxisY()->getRealJoyIndex()));
xml->writeEndElement();
}
for (int i=0; i < getNumberVDPads(); i++)
{
VDPad *vdpad = getActiveSetJoystick()->getVDPad(i);
xml->writeStartElement("vdpadButtonAssociations");
xml->writeAttribute("index", QString::number(vdpad->getRealJoyNumber()));
JoyButton *button = vdpad->getVButton(JoyDPadButton::DpadUp);
if (button)
{
xml->writeStartElement("vdpadButtonAssociation");
if (typeid(*button) == typeid(JoyAxisButton))
{
JoyAxisButton *axisbutton = static_cast<JoyAxisButton*>(button);
xml->writeAttribute("axis", QString::number(axisbutton->getAxis()->getRealJoyIndex()));
xml->writeAttribute("button", QString::number(button->getJoyNumber()));
}
else
{
xml->writeAttribute("axis", QString::number(0));
xml->writeAttribute("button", QString::number(button->getRealJoyNumber()));
}
xml->writeAttribute("direction", QString::number(JoyDPadButton::DpadUp));
xml->writeEndElement();
}
button = vdpad->getVButton(JoyDPadButton::DpadDown);
if (button)
{
xml->writeStartElement("vdpadButtonAssociation");
if (typeid(*button) == typeid(JoyAxisButton))
{
JoyAxisButton *axisbutton = static_cast<JoyAxisButton*>(button);
xml->writeAttribute("axis", QString::number(axisbutton->getAxis()->getRealJoyIndex()));
xml->writeAttribute("button", QString::number(button->getJoyNumber()));
}
else
{
xml->writeAttribute("axis", QString::number(0));
xml->writeAttribute("button", QString::number(button->getRealJoyNumber()));
}
xml->writeAttribute("direction", QString::number(JoyDPadButton::DpadDown));
xml->writeEndElement();
}
button = vdpad->getVButton(JoyDPadButton::DpadLeft);
if (button)
{
xml->writeStartElement("vdpadButtonAssociation");
if (typeid(*button) == typeid(JoyAxisButton))
{
JoyAxisButton *axisbutton = static_cast<JoyAxisButton*>(button);
xml->writeAttribute("axis", QString::number(axisbutton->getAxis()->getRealJoyIndex()));
xml->writeAttribute("button", QString::number(button->getJoyNumber()));
}
else
{
xml->writeAttribute("axis", QString::number(0));
xml->writeAttribute("button", QString::number(button->getRealJoyNumber()));
}
xml->writeAttribute("direction", QString::number(JoyDPadButton::DpadLeft));
xml->writeEndElement();
}
button = vdpad->getVButton(JoyDPadButton::DpadRight);
if (button)
{
xml->writeStartElement("vdpadButtonAssociation");
if (typeid(*button) == typeid(JoyAxisButton))
{
JoyAxisButton *axisbutton = static_cast<JoyAxisButton*>(button);
xml->writeAttribute("axis", QString::number(axisbutton->getAxis()->getRealJoyIndex()));
xml->writeAttribute("button", QString::number(button->getJoyNumber()));
}
else
//.........这里部分代码省略.........