| 1265 | } |
| 1266 | |
| 1267 | void PhysXSample::parseSampleOutputAsset(const char* sampleName,PxU32 userInputCS, PxU32 inputEventCS) |
| 1268 | { |
| 1269 | char name[256]; |
| 1270 | char sBuffer[512]; |
| 1271 | |
| 1272 | SampleUserInput* sampleUserInput = mApplication.getPlatform()->getSampleUserInput(); |
| 1273 | if(!sampleUserInput) |
| 1274 | return; |
| 1275 | |
| 1276 | sprintf(name, "input/%s/%sInputMapping.ods", sampleName,mApplication.getPlatform()->getPlatformName()); |
| 1277 | if(getSampleOutputDirManager().getFilePath(name, sBuffer, false)) |
| 1278 | { |
| 1279 | SampleInputMappingAsset* inputAsset = NULL; |
| 1280 | SampleFramework::File* fp = NULL; |
| 1281 | PxToolkit::fopen_s(&fp, sBuffer, "r"); |
| 1282 | if(fp) |
| 1283 | { |
| 1284 | inputAsset = SAMPLE_NEW(SampleInputMappingAsset)(fp,sBuffer, false, userInputCS, inputEventCS); |
| 1285 | if(!inputAsset->isOk()) |
| 1286 | { |
| 1287 | DELETESINGLE(inputAsset); |
| 1288 | fp = NULL; |
| 1289 | } |
| 1290 | } |
| 1291 | |
| 1292 | if(inputAsset) |
| 1293 | { |
| 1294 | std::vector<SampleInputMapping> inputMappings; |
| 1295 | for (size_t i = inputAsset->getSampleInputData().size();i--;) |
| 1296 | { |
| 1297 | const SampleInputData& data = inputAsset->getSampleInputData()[i]; |
| 1298 | size_t userInputIndex; |
| 1299 | PxI32 userInputId = sampleUserInput->translateUserInputNameToId(data.m_UserInputName,userInputIndex); |
| 1300 | size_t inputEventIndex; |
| 1301 | PxI32 inputEventId = sampleUserInput->translateInputEventNameToId(data.m_InputEventName, inputEventIndex); |
| 1302 | if(userInputId >= 0 && inputEventId >= 0) |
| 1303 | { |
| 1304 | SampleInputMapping mapping; |
| 1305 | mapping.m_InputEventId = inputEventId; |
| 1306 | mapping.m_InputEventIndex = inputEventIndex; |
| 1307 | mapping.m_UserInputId = userInputId; |
| 1308 | mapping.m_UserInputIndex = userInputIndex; |
| 1309 | inputMappings.push_back(mapping); |
| 1310 | } |
| 1311 | else |
| 1312 | { |
| 1313 | //if we get here we read a command mapping from file that is no longer supported in code ... it should be ignored. |
| 1314 | } |
| 1315 | } |
| 1316 | |
| 1317 | for (size_t i = inputMappings.size(); i--;) |
| 1318 | { |
| 1319 | const SampleInputMapping& mapping = inputMappings[i]; |
| 1320 | sampleUserInput->unregisterInputEvent(mapping.m_InputEventId); |
| 1321 | } |
| 1322 | |
| 1323 | //now I have the default keys definition left, save it to the mapping |
| 1324 | const std::vector<UserInput>& userInputs = sampleUserInput->getUserInputList(); |
nothing calls this directly
no test coverage detected