float getAxisValue(AxisMap::AxisType axis_type, const AxisMap& map, const DirectInputJoyStick::JoystickState& di_state, const std::string& device_pid_vid) { float val = getMappedValue(axis_type, map, di_state, device_pid_vid); //normalize min to max --> 0 to 1 val = (val - map.min_val) / (map.max_val - map.min_val); switch (map.direction) { case AxisMap::AxisDirection::Auto: if ( ((device_pid_vid == "" || device_pid_vid == "VID_0483&PID_5710") && (axis_type == AxisMap::AxisType::LeftZ || axis_type == AxisMap::AxisType::RightY)) || ((device_pid_vid != "" && device_pid_vid != "VID_0483&PID_5710") && (axis_type == AxisMap::AxisType::LeftY)) ) val = 1 - val; break; case AxisMap::AxisDirection::Normal: break; case AxisMap::AxisDirection::Reverse: val = 1 - val; break; default: throw std::invalid_argument("Unsupported map.direction in getAxisValue"); } //normalize 0 to 1 --> -1 to 1 val = 2*val - 1; return val; }
SoundEvent *SoundConfig::getSoundEvent(unsigned int worldId, float positionX, float positionY, float angle, float velocity, float spin, float inertia, float contactImpulse) const { float p0 = getMappedValue(0, positionX, positionY, angle, velocity, spin, inertia, contactImpulse); float p1 = getMappedValue(1, positionX, positionY, angle, velocity, spin, inertia, contactImpulse); float p2 = getMappedValue(2, positionX, positionY, angle, velocity, spin, inertia, contactImpulse); float p3 = getMappedValue(3, positionX, positionY, angle, velocity, spin, inertia, contactImpulse); float p4 = getMappedValue(4, positionX, positionY, angle, velocity, spin, inertia, contactImpulse); float p5 = getMappedValue(5, positionX, positionY, angle, velocity, spin, inertia, contactImpulse); float p6 = getMappedValue(6, positionX, positionY, angle, velocity, spin, inertia, contactImpulse); return new ImpulseSoundEvent(worldId, sampleId, p0, p1, p2, p3, p4, p5, p6); }
bool OBJECT_WAREHOUSE_CLASS::addMappedValue(char *name_ptr, char *value_ptr, UINT16 group, UINT16 element, LOG_CLASS *logger_ptr, bool userDefined) // DESCRIPTION : Method to add a Name / Value mapping to the mapping list. // PRECONDITIONS : // POSTCONDITIONS : // EXCEPTIONS : // NOTES : //<<=========================================================================== { if (logger_ptr) { logger_ptr->text(LOG_DEBUG, 1, "OBJECT_WAREHOUSE_CLASS::addMappedValue(name_ptr:= %s value_ptr:= %s)", name_ptr, value_ptr); } char *existingValue_ptr; // check if Value has already been defined if ((existingValue_ptr = getMappedValue(name_ptr, logger_ptr)) != NULL) { if (strcmp(existingValue_ptr, value_ptr) != 0) { // Name previously given to different Value // - modify the Name / Value mapping modifyMappedValue(name_ptr, value_ptr, group, element, logger_ptr); } } else { // instaniate a new Name / Value mapping WAREHOUSE_MAPPING_CLASS mapping(name_ptr, value_ptr, group, element, userDefined); // add Name / Value mapping mappingM.add(mapping); } // return result return true; }
/** * The objective is to read the FIX representation in a string and invoke the Mapper on this * Sample code: * std::string strFieldName = nos.getField( FIX::FIELD::FieldName); * std::string mappedValue = mapper.sideFrom( strFieldName); * Codec::encode( mappedValue, pos, size); */ void Functions::mappingFrom(const MappingTable &mappingTable, const string &fixFieldName, const Field &field, stringstream &sourceCode) { string strFIXValueVarName = getFIXValue( fixFieldName, field, sourceCode); string strMappedValueVarName = getMappedValue( mappingTable, strFIXValueVarName, field, sourceCode); encode(strMappedValueVarName, fixFieldName, field, sourceCode); }
float RangeSlider::getRValue() const { return getMappedValue(rValue_); }
char *OBJECT_WAREHOUSE_CLASS::setLabelledValue(char *name_ptr, UINT16 group, UINT16 element, LOG_CLASS *logger_ptr) // DESCRIPTION : Method to checked if we are dealing with a labelled // : value. A labelled value is used to initialise the mapping // : of a Name to a Value. Each time a labelled Name is given, // : the Name / Value mapping must be reset so that a new Value // : can be mapped to the Name. // PRECONDITIONS : // POSTCONDITIONS : // EXCEPTIONS : // NOTES : //<<=========================================================================== { char *mapping_ptr = NULL; UINT length = strlen(NEWKEYWORD); char value[MAX_STRING_LEN]; // check for "NEW:" mapping if ((strlen(name_ptr) > length) && (strncmp(name_ptr, NEWKEYWORD, length) == 0)) { // get the VR from the definitions if (DEFINITION->GetAttributeVr(group, element) == ATTR_VR_UI) { // create a new UID createUID(value, IMPLEMENTATION_CLASS_UID); } else { // generate a new Value - using the current time struct tm *currentTime_ptr; time_t clock; // get time is seconds and convert to struct tm time(&clock); currentTime_ptr = localtime(&clock); sprintf(value, "1%02d%02d%02d%02d", currentTime_ptr->tm_hour, currentTime_ptr->tm_min, currentTime_ptr->tm_sec, uniq8odd()); } // add the mapping to the list mapping_ptr = name_ptr + length; addMappedValue(mapping_ptr, value, group, element, logger_ptr); // return new Name / Value mapping mapping_ptr = getMappedValue(mapping_ptr, logger_ptr); } else { length = strlen(LABELKEYWORD); // check for a "LABEL:" mapping if ((strlen(name_ptr) > length) && (strncmp(name_ptr, LABELKEYWORD, length) == 0)) { char name[MAX_STRING_LEN]; // we've got a labelled name mapping_ptr = name_ptr + length; // copy the label name [and value] UINT i = 0; UINT index = 0; strcpy(value, UNDEFINED_MAPPING); while (*mapping_ptr != '\0') { if (*mapping_ptr == COLON) { if (index == 0) { // occurence of first colon indicates transition from // name to value name[i] = '\0'; i = 0; index++; mapping_ptr++; continue; } } switch (index) { case 0: name[i++] = *mapping_ptr; break; case 1: value[i++] = *mapping_ptr; break; } mapping_ptr++; } // terminate last copied string and setup return pointer if (index == 0) { name[i] = '\0'; mapping_ptr = name; } else { value[i] = '\0'; mapping_ptr = value; } // let's check if we need to remove an existing Name / Value mapping for this label i = 0; while (i < mappingM.getSize()) { // got match ? if (strcmp(mappingM[i].getName(), name) == 0) { // got an old mapping - remove it mappingM.removeAt(i); } // move to next entry i++; } // save label mapping - but first see if the value specified is already a label that // should be mapped char *existingMapping_ptr = getMappedValue(value, logger_ptr); if (existingMapping_ptr != NULL) { addMappedValue(name, existingMapping_ptr, group, element, logger_ptr); mapping_ptr = existingMapping_ptr; } else { addMappedValue(name, value, group, element, logger_ptr); mapping_ptr = refreshMappedName(name, logger_ptr); } } else { // just check for normal (unlabelled) Name / Value mapping mapping_ptr = getMappedValue(name_ptr, logger_ptr); } } if ((mapping_ptr) && (logger_ptr)) { logger_ptr->text(LOG_DEBUG, 1, "OBJECT_WAREHOUSE_CLASS::setLabelledValue(name_ptr:= %s) -> mapping_ptr:= %s", name_ptr, mapping_ptr); } // return mapped label return mapping_ptr; }