Beispiel #1
0
QBitArray InputDaemon::createUnplugEventBitArray(InputDevice *device)
{
    InputDeviceBitArrayStatus tempStatus(device, false);

    for (int i=0; i < device->getNumberRawAxes(); i++)
    {
        JoyAxis *axis = device->getActiveSetJoystick()->getJoyAxis(i);
        if (axis && axis->getThrottle() != JoyAxis::NormalThrottle)
        {
            tempStatus.changeAxesStatus(i, true);
        }
    }

    QBitArray unplugBitArray = tempStatus.generateFinalBitArray();
    return unplugBitArray;
}
Beispiel #2
0
void InputDevice::propogateSetAxisThrottleChange(int index, int originset)
{
    SetJoystick *currentSet = joystick_sets.value(originset);
    if (currentSet)
    {
        JoyAxis *axis = currentSet->getJoyAxis(index);
        if (axis)
        {
            int throttleSetting = axis->getThrottle();

            QHashIterator<int, SetJoystick*> iter(joystick_sets);
            while (iter.hasNext())
            {
                iter.next();
                SetJoystick *temp = iter.value();
                // Ignore change for set axis that initiated the change
                if (temp != currentSet)
                {
                    temp->getJoyAxis(index)->setThrottle(throttleSetting);
                }
            }
        }
    }
}
Beispiel #3
0
void InputDaemon::modifyUnplugEvents(QQueue<SDL_Event> *sdlEventQueue)
{
    QHashIterator<InputDevice*, InputDeviceBitArrayStatus*> genIter(releaseEventsGenerated);
    while (genIter.hasNext())
    {
        genIter.next();
        InputDevice *device = genIter.key();
        InputDeviceBitArrayStatus *generatedTemp = genIter.value();
        QBitArray tempBitArray = generatedTemp->generateFinalBitArray();
        //qDebug() << "ARRAY: " << tempBitArray;

        unsigned int bitArraySize = tempBitArray.size();
        //qDebug() << "ARRAY SIZE: " << bitArraySize;

        if (bitArraySize > 0 && tempBitArray.count(true) == bitArraySize)
        {
            if (pendingEventValues.contains(device))
            {
                InputDeviceBitArrayStatus *pendingTemp = pendingEventValues.value(device);
                QBitArray pendingBitArray = pendingTemp->generateFinalBitArray();
                QBitArray unplugBitArray = createUnplugEventBitArray(device);
                unsigned int pendingBitArraySize = pendingBitArray.size();

                if (bitArraySize == pendingBitArraySize &&
                    pendingBitArray == unplugBitArray)
                {
                    QQueue<SDL_Event> tempQueue;
                    while (!sdlEventQueue->isEmpty())
                    {
                        SDL_Event event = sdlEventQueue->dequeue();
                        switch (event.type)
                        {
                            case SDL_JOYBUTTONDOWN:
                            case SDL_JOYBUTTONUP:
                            {
                                tempQueue.enqueue(event);
                                break;
                            }
                            case SDL_JOYAXISMOTION:
                            {
                                if (event.jaxis.which != device->getSDLJoystickID())
                                {
                                    tempQueue.enqueue(event);
                                }
                                else
                                {
                                    InputDevice *joy = trackjoysticks.value(event.jaxis.which);

                                    if (joy)
                                    {
                                        JoyAxis *axis = joy->getActiveSetJoystick()->getJoyAxis(event.jaxis.axis);
                                        if (axis)
                                        {
                                            if (axis->getThrottle() != JoyAxis::NormalThrottle)
                                            {
                                                event.jaxis.value = axis->getProperReleaseValue();
                                            }
                                        }
                                    }

                                    tempQueue.enqueue(event);
                                }

                                break;
                            }
                            case SDL_JOYHATMOTION:
                            {
                                tempQueue.enqueue(event);
                                break;
                            }
                            case SDL_CONTROLLERAXISMOTION:
                            {
                                if (event.caxis.which != device->getSDLJoystickID())
                                {
                                    tempQueue.enqueue(event);
                                }
                                else
                                {
                                    InputDevice *joy = trackcontrollers.value(event.caxis.which);
                                    if (joy)
                                    {
                                        SetJoystick* set = joy->getActiveSetJoystick();
                                        JoyAxis *axis = set->getJoyAxis(event.caxis.axis);
                                        if (axis)
                                        {
                                            if (event.caxis.axis == SDL_CONTROLLER_AXIS_TRIGGERLEFT ||
                                                event.caxis.axis == SDL_CONTROLLER_AXIS_TRIGGERRIGHT)
                                            {
                                                event.caxis.value = axis->getProperReleaseValue();
                                            }
                                        }
                                    }

                                    tempQueue.enqueue(event);
                                }

                                break;
                            }
                            case SDL_CONTROLLERBUTTONDOWN:
                            case SDL_CONTROLLERBUTTONUP:
                            {

                                tempQueue.enqueue(event);
                                break;
                            }
                            case SDL_JOYDEVICEREMOVED:
                            case SDL_JOYDEVICEADDED:
                            {
                                tempQueue.enqueue(event);
                                break;
                            }
                            default:
                            {
                                tempQueue.enqueue(event);
                            }
                        }
                    }

                    sdlEventQueue->swap(tempQueue);
                }
            }
        }
    }
}