예제 #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;
	}
예제 #2
0
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;
}
예제 #3
0
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);
	}
예제 #4
0
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;
}
예제 #5
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;
	}
예제 #6
0
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;
	}