Skip to content
Open
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
15 changes: 15 additions & 0 deletions HidUtil/HidUtil.vcxproj
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="..\packages\Microsoft.Windows.CppWinRT.2.0.240405.15\build\native\Microsoft.Windows.CppWinRT.props" Condition="Exists('..\packages\Microsoft.Windows.CppWinRT.2.0.240405.15\build\native\Microsoft.Windows.CppWinRT.props')" />
<ItemGroup Label="ProjectConfigurations">
<ProjectConfiguration Include="Debug|ARM64">
<Configuration>Debug</Configuration>
Expand Down Expand Up @@ -120,12 +121,26 @@
</ItemDefinitionGroup>
<ItemGroup>
<ClCompile Include="Main.cpp" />
<ClCompile Include="WbemCore.cpp" />
<ClCompile Include="WbemExecute.cpp" />
</ItemGroup>
<ItemGroup>
<ClInclude Include="HID.hpp" />
<ClInclude Include="TailLight.hpp" />
<ClInclude Include="Wbem.h" />
</ItemGroup>
<ItemGroup>
<None Include="packages.config" />
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
<Import Project="..\packages\Microsoft.Windows.CppWinRT.2.0.240405.15\build\native\Microsoft.Windows.CppWinRT.targets" Condition="Exists('..\packages\Microsoft.Windows.CppWinRT.2.0.240405.15\build\native\Microsoft.Windows.CppWinRT.targets')" />
</ImportGroup>
<Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">
<PropertyGroup>
<ErrorText>This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}.</ErrorText>
</PropertyGroup>
<Error Condition="!Exists('..\packages\Microsoft.Windows.CppWinRT.2.0.240405.15\build\native\Microsoft.Windows.CppWinRT.props')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\Microsoft.Windows.CppWinRT.2.0.240405.15\build\native\Microsoft.Windows.CppWinRT.props'))" />
<Error Condition="!Exists('..\packages\Microsoft.Windows.CppWinRT.2.0.240405.15\build\native\Microsoft.Windows.CppWinRT.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\Microsoft.Windows.CppWinRT.2.0.240405.15\build\native\Microsoft.Windows.CppWinRT.targets'))" />
</Target>
</Project>
6 changes: 6 additions & 0 deletions HidUtil/HidUtil.vcxproj.filters
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,15 @@
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup>
<ClCompile Include="Main.cpp" />
<ClCompile Include="WbemExecute.cpp" />
<ClCompile Include="WbemCore.cpp" />
</ItemGroup>
<ItemGroup>
<ClInclude Include="HID.hpp" />
<ClInclude Include="TailLight.hpp" />
<ClInclude Include="Wbem.h" />
</ItemGroup>
<ItemGroup>
<None Include="packages.config" />
</ItemGroup>
</Project>
42 changes: 35 additions & 7 deletions HidUtil/Main.cpp
Original file line number Diff line number Diff line change
@@ -1,18 +1,46 @@
#include "HID.hpp"
#include "TailLight.hpp"
#include "Wbem.h"

#define SWITCH_BIST "/bist"
#define CB_SWITCH_BIST_ONLY (sizeof(SWITCH_BIST) - 1)

void PrintUsage() {
wprintf(L"IntelliMouse tail-light shifter .\n");
wprintf(L"Usage:\n\"HidUtil.exe [/bist] [<red> <green> <blue>\""
" (example: \"HidUtil.exe 0 0 255\" or\n \"HidUtil.exe /bist\"]).\n");
}

int main(int argc, char* argv[]) {
if (argc < 4) {
wprintf(L"IntelliMouse tail-light shifter.\n");
wprintf(L"Usage: \"HidUtil.exe <red> <green> <blue>\" (example: \"HidUtil.exe 0 0 255\").\n");

BYTE red = 0;
BYTE green = 0;
BYTE blue = 0;

if (argc == 2 && lstrlenA(argv[1]) == CB_SWITCH_BIST_ONLY) {
if (memcmp(argv[1], SWITCH_BIST, CB_SWITCH_BIST_ONLY) == 0) {
if (SUCCEEDED(ConnectToWbem())) {
return 0;
}
else {
return -4;
}
}
else {
PrintUsage();
return -1;
}
}
else if (argc == 4) {
red = (BYTE)atoi(argv[1]);
green = (BYTE)atoi(argv[2]);
blue = (BYTE)atoi(argv[3]);
}
else {
PrintUsage();
return -1;
}

auto red = (BYTE)atoi(argv[1]);
auto green = (BYTE)atoi(argv[2]);
auto blue = (BYTE)atoi(argv[3]);

HID::Query query;
query.VendorID = 0x045E; // Microsoft
query.ProductID = 0x082A; // Pro IntelliMouse
Expand Down
34 changes: 34 additions & 0 deletions HidUtil/Wbem.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
#pragma once
#include <Windows.h>
#include <dontuse.h>
#include <comutil.h>
#include <wbemcli.h>
#include <winrt/base.h>

HRESULT
ConnectToWbem();

HRESULT
SetInterfaceSecurity(
_In_ IUnknown* InterfaceObj,
_In_opt_ PWSTR UserId,
_In_opt_ PWSTR Password,
_In_opt_ PWSTR DomainName
);

HRESULT
ExecuteMethod_NoArgs_ReturnsValue(
_In_ winrt::com_ptr<IWbemServices>* pWbemServices,
_In_ winrt::com_ptr<IWbemClassObject>* pClassObj,
_In_ const BSTR InstancePath,
_In_ const OLECHAR* psz,
_Out_ HRESULT& wmiMethodRet
);

HRESULT
ExecuteBISTOnAllDevices(
_In_ winrt::com_ptr<IWbemServices>* pWbemServices,
_In_opt_ PWSTR UserId,
_In_opt_ PWSTR Password,
_In_opt_ PWSTR DomainName
);
Loading