------------------------------------------------------------------------------
| 1245 | |
| 1246 | //------------------------------------------------------------------------------ |
| 1247 | bool ActionMap::processBind(const U32 argc, const char** argv, SimObject* object) |
| 1248 | { |
| 1249 | // Ok, the bind will come in the following format: |
| 1250 | // [device] [key or button] <[param spec] [param] ...> [fnName] |
| 1251 | // |
| 1252 | const char* pDeviceName = argv[0]; |
| 1253 | const char* pEvent = argv[1]; |
| 1254 | const char* pFnName = argv[argc - 1]; |
| 1255 | |
| 1256 | // Determine the device |
| 1257 | U32 deviceType; |
| 1258 | U32 deviceInst; |
| 1259 | |
| 1260 | if(!getDeviceTypeAndInstance(argv[0], deviceType, deviceInst)) |
| 1261 | { |
| 1262 | Con::printf("processBind: unknown device: %s", pDeviceName); |
| 1263 | return false; |
| 1264 | } |
| 1265 | |
| 1266 | // Ok, we now have the deviceType and instance. Create an event descriptor |
| 1267 | // for the bind... |
| 1268 | // |
| 1269 | EventDescriptor eventDescriptor; |
| 1270 | if (createEventDescriptor(pEvent, &eventDescriptor) == false) |
| 1271 | { |
| 1272 | Con::printf("Could not create a description for binding: %s", pEvent); |
| 1273 | return false; |
| 1274 | } |
| 1275 | |
| 1276 | // Event has now been described, and device determined. we need now to extract |
| 1277 | // any modifiers that the action map will apply to incoming events before |
| 1278 | // calling the bound function... |
| 1279 | // |
| 1280 | // DMMTODO |
| 1281 | U32 assignedFlags = 0; |
| 1282 | F32 deadZoneBegin = 0.0f; |
| 1283 | F32 deadZoneEnd = 0.0f; |
| 1284 | F32 scaleFactor = 1.0f; |
| 1285 | |
| 1286 | if (argc != 3) { |
| 1287 | // We have the following: "[DSIR]" [deadZone] [scale] |
| 1288 | // |
| 1289 | const char* pSpec = argv[2]; |
| 1290 | |
| 1291 | for (U32 i = 0; pSpec[i] != '\0'; i++) { |
| 1292 | switch (pSpec[i]) { |
| 1293 | case 'r': case 'R': |
| 1294 | assignedFlags |= Node::Ranged; |
| 1295 | break; |
| 1296 | case 's': case 'S': |
| 1297 | assignedFlags |= Node::HasScale; |
| 1298 | break; |
| 1299 | case 'd': case 'D': |
| 1300 | assignedFlags |= Node::HasDeadZone; |
| 1301 | break; |
| 1302 | case 'i': case 'I': |
| 1303 | assignedFlags |= Node::Inverted; |
| 1304 | break; |