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; }
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; }
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 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; }
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; }