MCPcopy Create free account
hub / github.com/TorqueGameEngines/Torque3D / processBindCmd

Method processBindCmd

Engine/source/sim/actionMap.cpp:1180–1244  ·  view source on GitHub ↗

--------------------------------------------------------------------------

Source from the content-addressed store, hash-verified

1178
1179//--------------------------------------------------------------------------
1180bool ActionMap::processBindCmd(const char *device, const char *action, const char *makeCmd, const char *breakCmd)
1181{
1182 U32 deviceType;
1183 U32 deviceInst;
1184
1185 if(!getDeviceTypeAndInstance(device, deviceType, deviceInst))
1186 {
1187 Con::printf("processBindCmd: unknown device: %s", device);
1188 return false;
1189 }
1190
1191 // Ok, we now have the deviceType and instance. Create an event descriptor
1192 // for the bind...
1193 //
1194 EventDescriptor eventDescriptor;
1195 if (createEventDescriptor(action, &eventDescriptor) == false) {
1196 Con::printf("Could not create a description for binding: %s", action);
1197 return false;
1198 }
1199
1200 // SI_POV == SI_MOVE, and the POV works fine with bindCmd, so we have to add these manually.
1201 if( ( eventDescriptor.eventCode == SI_XAXIS ) ||
1202 ( eventDescriptor.eventCode == SI_YAXIS ) ||
1203 ( eventDescriptor.eventCode == SI_ZAXIS ) ||
1204 ( eventDescriptor.eventCode == SI_RXAXIS ) ||
1205 ( eventDescriptor.eventCode == SI_RYAXIS ) ||
1206 ( eventDescriptor.eventCode == SI_RZAXIS ) ||
1207 ( eventDescriptor.eventCode == SI_SLIDER ) ||
1208 ( eventDescriptor.eventCode == SI_XPOV ) ||
1209 ( eventDescriptor.eventCode == SI_YPOV ) ||
1210 ( eventDescriptor.eventCode == SI_XPOV2 ) ||
1211 ( eventDescriptor.eventCode == SI_YPOV2 ) )
1212 {
1213 Con::warnf( "ActionMap::processBindCmd - Cannot use 'bindCmd' with a move event type. Use 'bind' instead." );
1214 return false;
1215 }
1216
1217 // Create the full bind entry, and place it in the map
1218 //
1219 // DMMTODO
1220 Node* pBindNode = getNode(deviceType, deviceInst,
1221 eventDescriptor.flags,
1222 eventDescriptor.eventCode);
1223
1224 pBindNode->flags = Node::BindCmd;
1225 pBindNode->deadZoneBegin = 0;
1226 pBindNode->deadZoneEnd = 0;
1227 pBindNode->scaleFactor = 1;
1228
1229 if( pBindNode->makeConsoleCommand )
1230 dFree( pBindNode->makeConsoleCommand );
1231 if( pBindNode->breakConsoleCommand )
1232 dFree( pBindNode->breakConsoleCommand );
1233
1234 if(makeCmd[0])
1235 pBindNode->makeConsoleCommand = dStrdup(makeCmd);
1236 else
1237 pBindNode->makeConsoleCommand = dStrdup("");

Callers 1

actionMap.cppFile · 0.80

Calls 3

printfFunction · 0.85
warnfFunction · 0.50
dFreeFunction · 0.50

Tested by

no test coverage detected