// Save variables to the console void CJoystickAxisBase::SaveToConsole(ILTClient *pClientDE) { // clear the old binding if (m_bBindingsRead) { if (m_nOrigAxis > JOYSTICK_AXIS_NONE) { strncpy(m_sTriggerName, m_aryAxisInfo[m_nOrigAxis].GetName(), INPUTNAME_LEN); m_sTriggerName[INPUTNAME_LEN-1] = '\0'; ClearRangeBind(pClientDE, m_sDeviceName, m_sTriggerName); } } // figure out the new trigger name strncpy(m_sTriggerName, m_aryAxisInfo[m_nAxis].GetName(), INPUTNAME_LEN); m_sTriggerName[INPUTNAME_LEN-1] = '\0'; // set the new dead zone if it has been adjusted or was never read in m_fDeadZone = ScaleToRange((float)m_nDeadZone, (float)DEADZONESLIDERLOW, (float)DEADZONESLIDERHIGH, 0.0f, 0.90f); if (m_nDeadZone == DEADZONESLIDERLOW) m_fDeadZone = 0.0f; // do the analog or digital binding if (m_nAxis > JOYSTICK_AXIS_NONE) { // clear any previous bindings to this axis ClearRangeBind(pClientDE, m_sDeviceName, m_sTriggerName); // write out the new actions in case they are not in the autoexec.cfg SaveNewActions(pClientDE); // save out analog options if (m_bAnalog) SaveToConsoleAnalog(pClientDE); // save out digital options else SaveToConsoleDigital(pClientDE); } // write out the dead zone console variable if ((m_sDeviceName[0] != '\0') && (m_sTriggerName[0] != '\0') && (m_sActionName[0] != '\0')) { float fDeadZone = m_fDeadZone; if (m_bAnalog) fDeadZone = m_fDeadZone * m_fScale; if (fDeadZone < 0.0f) fDeadZone = 0.0f; SetConsoleVar(pClientDE, m_sDeadZoneConsoleVar, fDeadZone); //pClientDE->CPrint("Saving Dead Zone : fDeadZone = %f m_fDeadZone = %f", fDeadZone, m_fDeadZone ); // BLB TEMP } g_pLTClient->WriteConfigFile("autoexec.cfg"); if (m_bBindingsRead) { GetJoystickBindingInfo(pClientDE); } }
// Load variables from the console void CMenuJoystickAxisBase::LoadFromConsole(CClientDE *pClientDE) { if (!m_bBindingsRead) { // try to read digital bindings GetJoystickBindingInfo(pClientDE); } // read in the dead zone console variable HCONSOLEVAR hVar = pClientDE->GetConsoleVar(m_sDeadZoneConsoleVar); if (m_bAnalog) { if (hVar != NULL) m_fDeadZone = pClientDE->GetVarValueFloat(hVar) / m_fScale; //pClientDE->CPrint("Read Dead Zone Analog : m_fDeadZone = %f m_fScale = %f ", m_fDeadZone, m_fScale ); // BLB TEMP } else { if (hVar != NULL) m_fDeadZone = pClientDE->GetVarValueFloat(hVar); //pClientDE->CPrint("Read Dead Zone Digital : m_fDeadZone = %f", m_fDeadZone ); // BLB TEMP } // convert all of the variables read in from the bindings to our internal controls variables if (m_bBindingsRead) { // figure out the index of the axis that we found m_nAxis = GetAxisIndex(pClientDE, m_sTriggerName); // scale the sensitivity slider bar from the rangescale values that we read in if (m_bAnalog) m_nSensitivity = (int)ScaleToRange(m_fScale, m_fScaleCenter-m_fScaleRangeDiv2, m_fScaleCenter+m_fScaleRangeDiv2, (float)SENSITIVITYSLIDERLOW, (float)SENSITIVITYSLIDERHIGH); // scale the dead zone that we read in to the dead zone slider bar m_nDeadZone = (int)ScaleToRange(m_fDeadZone, 0.0f, 0.90f, (float)DEADZONESLIDERLOW, (float)DEADZONESLIDERHIGH); // figure out if the bindings that were read in had inverted axis if (m_bAnalog) { if (m_fRangeScaleMin > m_fRangeScaleMax) m_bInvertAxis = DTRUE; else m_bInvertAxis = DFALSE; } else { if (stricmp(m_sActionName, m_sActionDigitalLow) == 0) { if (m_fRangeLow < m_fRangeLow2) m_bInvertAxis = DFALSE; else m_bInvertAxis = DTRUE; } else { if (m_fRangeLow <= m_fRangeLow2) m_bInvertAxis = DTRUE; else m_bInvertAxis = DFALSE; } } // figure out the correct value of the center offset flag from the data read in if ((long)m_fRangeScalePreCenterOffset != 100) m_bCenterOffset = DFALSE; else m_bCenterOffset = DTRUE; } // save off the original values m_nOrigAxis=m_nAxis; m_nOrigSensitivity=m_nSensitivity; m_nOrigDeadZone=m_nDeadZone; m_bOrigInvertAxis=m_bInvertAxis; m_bOrigCenterOffset=m_bCenterOffset; m_bOrigAnalog = m_bAnalog; // clear the old binding if (m_bBindingsRead) { if (m_nAxis > MENUJOYSTICK_AXIS_NONE) { strncpy(m_sTriggerName, m_aryAxisInfo[m_nAxis].GetName(), INPUTNAME_LEN); m_sTriggerName[INPUTNAME_LEN-1] = '\0'; ClearRangeBind(pClientDE, m_sDeviceName, m_sTriggerName); } } }