Exemple #1
0
InputDeviceFeatureSet RevolverTool::getSourceFeatures(const InputDeviceFeature& forwardedFeature)
	{
	/* Paranoia: Check if the forwarded feature is on the transformed device: */
	if(forwardedFeature.getDevice()!=transformedDevice)
		Misc::throwStdErr("RevolverTool::getSourceFeatures: Forwarded feature is not on transformed device");
	
	/* Create an empty feature set: */
	InputDeviceFeatureSet result;
	
	if(forwardedFeature.isButton())
		{
		/* Find the source button slot index: */
		int buttonSlotIndex=forwardedFeature.getIndex()/factory->numChambers+1;
		
		/* Add the button slot's feature to the result set: */
		result.push_back(input.getButtonSlotFeature(buttonSlotIndex));
		}
	
	if(forwardedFeature.isValuator())
		{
		/* Find the source valuator slot index: */
		int valuatorSlotIndex=forwardedFeature.getIndex()/factory->numChambers;
		
		/* Add the valuator slot's feature to the result set: */
		result.push_back(input.getValuatorSlotFeature(valuatorSlotIndex));
		}
	
	return result;
	}
InputDeviceFeatureSet ValuatorToButtonTool::getSourceFeatures(const InputDeviceFeature& forwardedFeature)
	{
	/* Paranoia: Check if the forwarded feature is on the transformed device: */
	if(forwardedFeature.getDevice()!=transformedDevice)
		Misc::throwStdErr("ValuatorToButtonTool::getSourceFeatures: Forwarded feature is not on transformed device");
	
	/* Return the valuator slot feeding the forwarded button slot: */
	InputDeviceFeatureSet result;
	result.push_back(input.getValuatorSlotFeature(forwardedFeature.getIndex()/2));
	
	return result;
	}
std::string InputDeviceManager::getFeatureName(const InputDeviceFeature& feature) const
	{
	/* Find the input device adapter owning the given device: */
	const InputDeviceAdapter* adapter=0;
	for(int i=0;adapter==0&&i<numInputDeviceAdapters;++i)
		{
		/* Search through all input devices: */
		for(int j=0;j<inputDeviceAdapters[i]->getNumInputDevices();++j)
			if(inputDeviceAdapters[i]->getInputDevice(j)==feature.getDevice())
				{
				adapter=inputDeviceAdapters[i];
				break;
				}
		}
	
	if(adapter!=0)
		{
		/* Return the feature name defined by the input device adapter: */
		return adapter->getFeatureName(feature);
		}
	else
		{
		/* Return a default feature name: */
		return InputDeviceAdapter::getDefaultFeatureName(feature);
		}
	}
Exemple #4
0
std::string InputDeviceAdapterPlayback::getFeatureName(const InputDeviceFeature& feature) const
	{
	/* Find the input device owning the given feature: */
	int featureBaseIndex=-1;
	for(int deviceIndex=0;deviceIndex<numInputDevices;++deviceIndex)
		{
		if(inputDevices[deviceIndex]==feature.getDevice())
			{
			featureBaseIndex=deviceFeatureBaseIndices[deviceIndex];
			break;
			}
		}
	if(featureBaseIndex<0)
		Misc::throwStdErr("InputDeviceAdapterPlayback::getFeatureName: Unknown device %s",feature.getDevice()->getDeviceName());
	
	/* Return the feature name: */
	return deviceFeatureNames[featureBaseIndex+feature.getFeatureIndex()];
	}
std::string InputDeviceAdapter::getDefaultFeatureName(const InputDeviceFeature& feature)
	{
	char featureName[40];
	featureName[0]='\0';
	
	/* Check if the feature is a button or a valuator: */
	if(feature.isButton())
		{
		/* Return a default button name: */
		snprintf(featureName,sizeof(featureName),"Button%d",feature.getIndex());
		}
	if(feature.isValuator())
		{
		/* Return a default valuator name: */
		snprintf(featureName,sizeof(featureName),"Valuator%d",feature.getIndex());
		}
	
	return std::string(featureName);
	}
InputDeviceFeatureSet WandNavigationTool::getSourceFeatures(const InputDeviceFeature& forwardedFeature)
	{
	/* Paranoia: Check if the forwarded feature is on the transformed device: */
	if(forwardedFeature.getDevice()!=buttonDevice)
		Misc::throwStdErr("WandNavigationTool::getSourceFeatures: Forwarded feature is not on transformed device");
	
	/* Return the source feature: */
	InputDeviceFeatureSet result;
	result.push_back(input.getButtonSlotFeature(1));
	return result;
	}
InputDeviceFeatureSet ScrollTool::getSourceFeatures(const InputDeviceFeature& forwardedFeature)
	{
	/* Paranoia: Check if the forwarded feature is on the transformed device: */
	if(forwardedFeature.getDevice()!=valuatorDevice)
		Misc::throwStdErr("ScrollTool::getSourceFeatures: Forwarded feature is not on transformed device");
	
	/* Return the source feature: */
	InputDeviceFeatureSet result;
	result.push_back(input.getValuatorSlotFeature(0));
	return result;
	}
InputDeviceFeatureSet TransformTool::getForwardedFeatures(const InputDeviceFeature& sourceFeature)
{
    /* Find the input assignment slot for the given feature: */
    int slotIndex=input.findFeature(sourceFeature);

    /* Check if the source feature belongs to this tool: */
    if(slotIndex<0)
        Misc::throwStdErr("TransformTool::getForwardedFeatures: Source feature is not part of tool's input assignment");

    /* Create an empty feature set: */
    InputDeviceFeatureSet result;

    /* Check if the feature is a button or valuator: */
    if(sourceFeature.isButton())
    {
        /* Get the slot's button slot index: */
        int buttonSlotIndex=input.getButtonSlotIndex(slotIndex);

        /* Check if the button is part of the forwarded subset: */
        if(buttonSlotIndex>=numPrivateButtons)
        {
            /* Add the forwarded feature to the result set: */
            result.push_back(InputDeviceFeature(transformedDevice,InputDevice::BUTTON,buttonSlotIndex-numPrivateButtons));
        }
    }

    if(sourceFeature.isValuator())
    {
        /* Get the slot's valuator slot index: */
        int valuatorSlotIndex=input.getValuatorSlotIndex(slotIndex);

        /* Check if the valuator is part of the forwarded subset: */
        if(valuatorSlotIndex>=numPrivateValuators)
        {
            /* Add the forwarded feature to the result set: */
            result.push_back(InputDeviceFeature(transformedDevice,InputDevice::VALUATOR,valuatorSlotIndex-numPrivateValuators));
        }
    }

    return result;
}
Exemple #9
0
InputDeviceFeatureSet RevolverTool::getForwardedFeatures(const InputDeviceFeature& sourceFeature)
	{
	/* Find the input assignment slot for the given feature: */
	int slotIndex=input.findFeature(sourceFeature);
	
	/* Check if the source feature belongs to this tool: */
	if(slotIndex<0)
		Misc::throwStdErr("RevolverTool::getForwardedFeatures: Source feature is not part of tool's input assignment");
	
	/* Create an empty feature set: */
	InputDeviceFeatureSet result;
	
	/* Check if the feature is a button or valuator: */
	if(sourceFeature.isButton())
		{
		/* Get the slot's button slot index: */
		int buttonSlotIndex=input.getButtonSlotIndex(slotIndex);
		
		/* Check if the button is part of the forwarded subset: */
		if(buttonSlotIndex>=1)
			{
			/* Add the forwarded feature for the current chamber to the result set: */
			int baseButtonIndex=(buttonSlotIndex-1)*factory->numChambers;
			result.push_back(InputDeviceFeature(transformedDevice,InputDevice::BUTTON,baseButtonIndex+currentChamber));
			}
		}
	
	if(sourceFeature.isValuator())
		{
		/* Get the slot's valuator slot index: */
		int valuatorSlotIndex=input.getValuatorSlotIndex(slotIndex);
		
		/* Add the forwarded feature for the current chamber to the result set: */
		int baseValuatorIndex=valuatorSlotIndex*factory->numChambers;
		result.push_back(InputDeviceFeature(transformedDevice,InputDevice::VALUATOR,baseValuatorIndex+currentChamber));
		}
	
	return result;
	}
InputDeviceFeatureSet ButtonToValuatorTool::getSourceFeatures(const InputDeviceFeature& forwardedFeature)
	{
	/* Paranoia: Check if the forwarded feature is on the transformed device: */
	if(forwardedFeature.getDevice()!=transformedDevice)
		Misc::throwStdErr("ButtonToValuatorTool::getSourceFeatures: Forwarded feature is not on transformed device");
	
	/* The source features are all button slots: */
	InputDeviceFeatureSet result;
	for(int i=0;i<input.getNumButtonSlots();++i)
		result.push_back(input.getButtonSlotFeature(i));
	
	return result;
	}
InputDeviceFeatureSet TransformTool::getSourceFeatures(const InputDeviceFeature& forwardedFeature)
{
    /* Paranoia: Check if the forwarded feature is on the transformed device: */
    if(forwardedFeature.getDevice()!=transformedDevice)
        Misc::throwStdErr("TransformTool::getSourceFeatures: Forwarded feature is not on transformed device");

    /* Create an empty feature set: */
    InputDeviceFeatureSet result;

    if(forwardedFeature.isButton())
    {
        /* Add the slot's feature to the result set: */
        result.push_back(input.getButtonSlotFeature(forwardedFeature.getIndex()+numPrivateButtons));
    }

    if(forwardedFeature.isValuator())
    {
        /* Add the slot's feature to the result set: */
        result.push_back(input.getValuatorSlotFeature(forwardedFeature.getIndex()+numPrivateValuators));
    }

    return result;
}
std::string InputDeviceAdapterDeviceDaemon::getFeatureName(const InputDeviceFeature& feature) const
	{
	/* Find the input device owning the given feature: */
	bool deviceFound=false;
	int buttonIndexBase=0;
	int valuatorIndexBase=0;
	for(int deviceIndex=0;deviceIndex<numInputDevices;++deviceIndex)
		{
		if(inputDevices[deviceIndex]==feature.getDevice())
			{
			deviceFound=true;
			break;
			}
		
		/* Go to the next device: */
		buttonIndexBase+=inputDevices[deviceIndex]->getNumButtons();
		valuatorIndexBase+=inputDevices[deviceIndex]->getNumValuators();
		}
	if(!deviceFound)
		Misc::throwStdErr("InputDeviceAdapterDeviceDaemon::getFeatureName: Unknown device %s",feature.getDevice()->getDeviceName());
	
	/* Check whether the feature is a button or a valuator: */
	std::string result;
	if(feature.isButton())
		{
		/* Return the button feature's name: */
		result=buttonNames[buttonIndexBase+feature.getIndex()];
		}
	if(feature.isValuator())
		{
		/* Return the valuator feature's name: */
		result=valuatorNames[valuatorIndexBase+feature.getIndex()];
		}
	
	return result;
	}
std::string InputDeviceAdapterMouse::getFeatureName(const InputDeviceFeature& feature) const
{
    std::string result;

    /* Calculate the feature's modifier mask: */
    int featureModifierMask=0x0;
    if(feature.isButton())
        featureModifierMask=feature.getIndex()/(numButtons+numButtonKeys);
    if(feature.isValuator())
        featureModifierMask=feature.getIndex();

    /* Create the feature's modifier prefix: */
    for(int i=0; i<numModifierKeys; ++i)
        if(featureModifierMask&(0x1<<i))
        {
            /* Append the modifier key's name to the prefix: */
            result.append(getKeyName(modifierKeyCodes[i]));
            result.push_back('+');
        }

    /* Append the feature's name: */
    if(feature.isButton())
    {
        int buttonIndex=feature.getIndex()%(numButtons+numButtonKeys);

        /* Check if the button is a mouse button or a button key: */
        if(buttonIndex<numButtons)
        {
            /* Append a mouse button name: */
            char buttonName[40];
            snprintf(buttonName,sizeof(buttonName),"Mouse%d",buttonIndex+1);
            result.append(buttonName);
        }
        else
        {
            /* Append a button key name: */
            result.append(getKeyName(buttonKeyCodes[buttonIndex-numButtons]));
        }
    }
    if(feature.isValuator())
        result.append("MouseWheel");

    return result;
}