1- #include " stdafx .h"
1+ #include " precompiled .h"
22#include " CommandHandler.h"
33
44#define LOG_MODULE " "
@@ -85,7 +85,7 @@ void CommandHandler::CreateOtherCommands() {
8585 AddAlias (" Mode" , " OutputMode" );
8686 AddCommand (new Command (" OutputMode" , [&](CommandLine *cmd) {
8787
88- string mode = cmd->GetStringLower (0 , " " );
88+ std:: string mode = cmd->GetStringLower (0 , " " );
8989
9090 // Absolute mouse
9191 if (mode.compare (0 , 3 , " abs" ) == 0 ) {
@@ -339,6 +339,29 @@ void CommandHandler::CreateOtherCommands() {
339339 }));
340340
341341
342+ //
343+ // Command: ForceLowLatencyAudio
344+ //
345+ // Forces low latency audio on Windows 10
346+ //
347+ AddCommand (new Command (" ForceLowLatencyAudio" , [&](CommandLine *cmd) {
348+ if (!ExecuteCommand (" TabletValid" )) return false ;
349+
350+ int result = tabletHandler->inputEmulator .ForceLowLatencyAudio ();
351+ if (result > 0 ) {
352+ LOG_INFO (" Low latency audio forced!\n " );
353+ }
354+ else if (result == 0 ) {
355+ LOG_INFO (" Low latency audio is already forced!\n " );
356+ }
357+ else {
358+ LOG_ERROR (" Low latency audio error! Maybe you are not running this on Windows 10?\n " );
359+ }
360+
361+ return true ;
362+ }));
363+
364+
342365 //
343366 // Command: Debug
344367 //
@@ -359,7 +382,7 @@ void CommandHandler::CreateOtherCommands() {
359382 // Start/stop logging messages to a log file
360383 //
361384 AddCommand (new Command (" Log" , [&](CommandLine *cmd) {
362- string logPath = cmd->GetString (0 , " log.txt" );
385+ std:: string logPath = cmd->GetString (0 , " log.txt" );
363386 if (!cmd->GetBoolean (0 , true )) {
364387 logger.CloseLogFile ();
365388 LOG_INFO (" Log file '%s' closed.\n " , logger.logFilename .c_str ());
@@ -469,15 +492,15 @@ void CommandHandler::CreateOtherCommands() {
469492
470493 // Pen buttons
471494 for (int i = 0 ; i < tablet->settings .buttonCount ; i++) {
472- stringIndex += sprintf_s (stringBuffer + stringIndex, maxLength - stringIndex, " '%s' " , tablet->settings .buttonMap [i].c_str ());
495+ stringIndex += sprintf_s (stringBuffer + stringIndex, maxLength - stringIndex, " '%s' " , tablet->settings .buttonMap [i].ToString (). c_str ());
473496 }
474497 LOG_INFO (" Pen button map = %s\n " , stringBuffer);
475498
476499 // Aux buttons
477500 if (tablet->settings .auxButtonCount > 0 ) {
478501 stringIndex = 0 ;
479502 for (int i = 0 ; i < tablet->settings .auxButtonCount ; i++) {
480- stringIndex += sprintf_s (stringBuffer + stringIndex, maxLength - stringIndex, " '%s' " , tablet->settings .auxButtonMap [i].c_str ());
503+ stringIndex += sprintf_s (stringBuffer + stringIndex, maxLength - stringIndex, " '%s' " , tablet->settings .auxButtonMap [i].ToString (). c_str ());
481504 }
482505 LOG_INFO (" Aux button map = %s\n " , stringBuffer);
483506 }
@@ -486,9 +509,9 @@ void CommandHandler::CreateOtherCommands() {
486509
487510 // Init strings
488511 if (tablet->initStrings .size () > 0 ) {
489- string stringIds = " " ;
512+ std:: string stringIds = " " ;
490513 for (int stringId : tablet->initStrings ) {
491- stringIds += to_string (stringId) + " " ;
514+ stringIds += std:: to_string (stringId) + " " ;
492515 }
493516 LOG_INFO (" Init string ids: %s\n " , stringIds.c_str ());
494517 }
@@ -620,7 +643,7 @@ void CommandHandler::CreateOtherCommands() {
620643 // Reads commands from a file and stops if tablet is redefined.
621644 //
622645 AddCommand (new Command (" Include" , [&](CommandLine *cmd) {
623- string filename = cmd->GetString (0 , " " );
646+ std:: string filename = cmd->GetString (0 , " " );
624647 if (filename == " " ) {
625648 LOG_ERROR (" Invalid filename '%s'!\n " , filename.c_str ());
626649 return false ;
@@ -646,13 +669,13 @@ void CommandHandler::CreateOtherCommands() {
646669 AddCommand (new Command (" ListCommands" , [&](CommandLine *cmd) {
647670
648671 LOG_INFO (" Commands: \n " );
649- for (pair<string, Command*> cmdPair : commands) {
650- string commandName = cmdPair.second ->name ;
651- string lowerCaseName = commandName;
652- transform (lowerCaseName.begin (), lowerCaseName.end (), lowerCaseName.begin (), ::tolower);
672+ for (std:: pair<std:: string, Command*> cmdPair : commands) {
673+ std:: string commandName = cmdPair.second ->name ;
674+ std:: string lowerCaseName = commandName;
675+ std:: transform (lowerCaseName.begin (), lowerCaseName.end (), lowerCaseName.begin (), ::tolower);
653676
654- string aliasString = " " ;
655- for (pair<string, string> aliasPair : aliases) {
677+ std:: string aliasString = " " ;
678+ for (std:: pair<std:: string, std:: string> aliasPair : aliases) {
656679 if (aliasPair.second == lowerCaseName) {
657680 aliasString += " , " + aliasNames[aliasPair.first ];
658681 }
@@ -671,19 +694,19 @@ void CommandHandler::CreateOtherCommands() {
671694 //
672695 AddCommand (new Command (" GetCommands" , [&](CommandLine *cmd) {
673696
674- string commandsString = " " ;
697+ std:: string commandsString = " " ;
675698
676699 LOG_STATUS (" COMMANDS_CLEAR 1\n " );
677700
678- for (pair<string, Command*> cmdPair : commands) {
679- string commandName = cmdPair.second ->name ;
680- string lowerCaseName = commandName;
681- transform (lowerCaseName.begin (), lowerCaseName.end (), lowerCaseName.begin (), ::tolower);
701+ for (std:: pair<std:: string, Command*> cmdPair : commands) {
702+ std:: string commandName = cmdPair.second ->name ;
703+ std:: string lowerCaseName = commandName;
704+ std:: transform (lowerCaseName.begin (), lowerCaseName.end (), lowerCaseName.begin (), ::tolower);
682705
683706 commandsString += commandName + " " ;
684707
685- string aliasString = " " ;
686- for (pair<string, string> aliasPair : aliases) {
708+ std:: string aliasString = " " ;
709+ for (std:: pair<std:: string, std:: string> aliasPair : aliases) {
687710 if (aliasPair.second == lowerCaseName) {
688711 commandsString += aliasNames[aliasPair.first ] + " " ;
689712 }
@@ -702,16 +725,16 @@ void CommandHandler::CreateOtherCommands() {
702725 }));
703726
704727 //
705- // Command: ListKeys
728+ // Command: ListInputs
706729 //
707- // List all keys
730+ // List all input actions
708731 //
709- AddCommand (new Command (" ListKeys " , [&](CommandLine *cmd) {
732+ AddCommand (new Command (" ListInputs " , [&](CommandLine *cmd) {
710733
711- LOG_INFO (" Keys :\n " );
712- for (string key : tabletHandler->inputEmulator .keys ) {
713- if (tabletHandler->inputEmulator .keyMap .count (key) > 0 ) {
714- string name = tabletHandler->inputEmulator .keyMap [key]->name ;
734+ LOG_INFO (" Input actions :\n " );
735+ for (std:: string key : tabletHandler->inputEmulator .inputs ) {
736+ if (tabletHandler->inputEmulator .inputMap .count (key) > 0 ) {
737+ std:: string name = tabletHandler->inputEmulator .inputMap [key]->description ;
715738 LOG_INFO (" % -20s %s\n " , key.c_str (), name.c_str ());
716739 }
717740 }
@@ -727,12 +750,12 @@ void CommandHandler::CreateOtherCommands() {
727750 //
728751 AddHelp (" Help" , " ..." );
729752 AddCommand (new Command (" Help" , [&](CommandLine *cmd) {
730- string commandName = cmd->GetStringLower (0 , " " );
753+ std:: string commandName = cmd->GetStringLower (0 , " " );
731754 if (aliases.count (commandName) > 0 ) {
732755 commandName = aliases[commandName];
733756 }
734757 if (help.count (commandName)) {
735- string helpText = help[commandName];
758+ std:: string helpText = help[commandName];
736759 LOG_INFO (" Help:\n\n %s\n " , helpText.c_str ());
737760 }
738761 else {
0 commit comments