MCPcopy Create free account
hub / github.com/kiibohd/controller / cliFunc_capSelect

Function cliFunc_capSelect

Macro/PartialMap/macro.c:1280–1356  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1278}
1279
1280void cliFunc_capSelect( char* args )
1281{
1282 // Parse code from argument
1283 char* curArgs;
1284 char* arg1Ptr;
1285 char* arg2Ptr = args;
1286
1287 // Total number of args to scan (must do a lookup if a keyboard capability is selected)
1288 var_uint_t totalArgs = 2; // Always at least two args
1289 var_uint_t cap = 0;
1290
1291 // Arguments used for keyboard capability function
1292 var_uint_t argSetCount = 0;
1293 uint8_t *argSet = (uint8_t*)args;
1294
1295 // Process all args
1296 for ( var_uint_t c = 0; argSetCount < totalArgs; c++ )
1297 {
1298 curArgs = arg2Ptr;
1299 CLI_argumentIsolation( curArgs, &arg1Ptr, &arg2Ptr );
1300
1301 // Stop processing args if no more are found
1302 // Extra arguments are ignored
1303 if ( *arg1Ptr == '\0' )
1304 break;
1305
1306 // For the first argument, choose the capability
1307 if ( c == 0 ) switch ( arg1Ptr[0] )
1308 {
1309 // Keyboard Capability
1310 case 'K':
1311 // Determine capability index
1312 cap = numToInt( &arg1Ptr[1] );
1313
1314 // Lookup the number of args
1315 totalArgs += CapabilitiesList[ cap ].argCount;
1316 continue;
1317 }
1318
1319 // Because allocating memory isn't doable, and the argument count is arbitrary
1320 // The argument pointer is repurposed as the argument list (much smaller anyways)
1321 argSet[ argSetCount++ ] = (uint8_t)numToInt( arg1Ptr );
1322
1323 // Once all the arguments are prepared, call the keyboard capability function
1324 if ( argSetCount == totalArgs )
1325 {
1326 // Indicate that the capability was called
1327 print( NL );
1328 info_print("K");
1329 printInt8( cap );
1330 print(" - ");
1331 printHex( argSet[0] );
1332 print(" - ");
1333 printHex( argSet[1] );
1334 print(" - ");
1335 printHex( argSet[2] );
1336 print( "..." NL );
1337

Callers

nothing calls this directly

Calls 3

CLI_argumentIsolationFunction · 0.85
numToIntFunction · 0.85
printInt8Function · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…