Skip to content
This repository was archived by the owner on Sep 21, 2020. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
74 changes: 74 additions & 0 deletions TabletDriverService/CommandHandler.Device.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -402,5 +402,79 @@ void CommandHandler::CreateDeviceCommands() {
return true;

}));

AddAlias("StringContains", "DeviceStringContains");
AddHelp("DeviceStringContains", "Usage:");
AddHelp("DeviceStringContains", " DeviceStringContains <string id> \"<match>\"");
AddHelp("DeviceStringContains", " DeviceStringContains Manufacturer \"<match>\"");
AddHelp("DeviceStringContains", " DeviceStringContains Product \"<match>\"");
AddHelp("DeviceStringContains", " DeviceStringContains SerialNumber \"<match>\"");
AddCommand(new Command("DeviceStringContains", [&](CommandLine *cmd) {
if (cmd->valueCount <= 1) {
ExecuteCommand("Help", "DeviceStringContains");
return false;
}
if (tablet == NULL) return false;

int stringId = cmd->GetInt(0, 0);
std::string stringName = cmd->GetStringLower(0, "");
std::string matchString = cmd->GetString(1, "");
std::string deviceString = "";

// Manufacturer
if (stringName.compare(0, 3, "man") == 0) {
stringName = "Manufacturer";
deviceString = tablet->GetDeviceManufacturerName();
}

// Product name
else if (stringName.compare(0, 3, "pro") == 0) {
stringName = "Product";
deviceString = tablet->GetDeviceProductName();
}

// Serial number
else if (stringName.compare(0, 3, "ser") == 0) {
stringName = "SerialNumber";
deviceString = tablet->GetDeviceSerialNumber();
}

// Request device string
else {
stringName = std::to_string(stringId);
if (stringId == 0) {
LOG_ERROR("Invalid string id!\n");
return false;
}
try {
deviceString = tablet->GetDeviceString(stringId);
}
catch (std::exception&e) {
LOG_ERROR("%s\n", e.what());
}
}

// Does the string contain the matching term?
if (deviceString.find(matchString) != std::string::npos) {
LOG_INFO("Device string (%s) '%s' contains '%s'\n",
stringName.c_str(),
deviceString.c_str(),
matchString.c_str()
);
return true;
}

// Does not contain the matching term
else {
LOG_INFO("Device string (%s) '%s' does not contain '%s'. Tablet invalid!\n",
stringName.c_str(),
deviceString.c_str(),
matchString.c_str()
);
delete tablet;
tablet = NULL;
return false;
}
return true;
}));
}
2 changes: 1 addition & 1 deletion TabletDriverService/config/gaomon.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
#
HIDTablet 0x256C 0x006D 0xFF00 0x0001
USBTablet "{62F12D4C-3431-4EFD-8DD7-8E9AAB18D30C}"
CheckString 201 "OEM02_T18e_190329"
StringContains 201 "OEM02_T18e_"
Name "Gaomon S620"
ReportId 0x00
ReportLength 16
Expand Down