Skip to content
Permalink
Browse files

Version 1.1 update

- added Inno Setup installer/uninstaller to simplify use
- removed option to start with Windows as it's the default behaviour
- inverted checkboxes, so selected means blocked (thanks ljford7!)
  • Loading branch information...
simonowen committed Jun 9, 2017
1 parent 02e4430 commit c9d5801242d9ee57a77975e22531cc63b4e44d2c
Showing with 155 additions and 108 deletions.
  1. +1 −0 .gitignore
  2. +3 −76 DashFix/DashFix.cpp
  3. BIN DashFix/DashFix.rc
  4. +3 −15 License.txt
  5. +23 −17 ReadMe.md
  6. +125 −0 install.iss
@@ -15,3 +15,4 @@
ipch/
[Dd]ebug/
[Rr]elease/
/DashFixSetup_*.exe
@@ -21,7 +21,6 @@

const auto APP_NAME{ TEXT("DashFix") };
const auto SETTINGS_KEY{ TEXT(R"(Software\SimonOwen\DashFix)") };
const auto STARTUP_KEY{ TEXT(R"(Software\Microsoft\Windows\CurrentVersion\Run)") };
const auto STEAM_KEY{ TEXT(R"(Software\Valve\Steam)") };

HWND g_hDlg{ NULL };
@@ -208,7 +207,7 @@ void PopulateControllerList(
auto pJoyName = SDL_JoystickName(pJoystick);
if (pJoyName && *pJoyName)
{
// Initially checked.
// Controller enabled by default.
joy_list[pJoyName] = TRUE;
}
}
@@ -266,7 +265,7 @@ void PopulateControllerList(
lvi.pszText = const_cast<char *>(lfi.psz);
index = SendMessage(hListView, LVM_INSERTITEMA, 0, reinterpret_cast<LPARAM>(&lvi));

ListView_SetCheckState(hListView, index, joy.second);
ListView_SetCheckState(hListView, index, !joy.second);
}
}
}
@@ -294,7 +293,7 @@ void SaveControllerList(
if (!SendMessage(hListView, LVM_GETITEMA, 0, reinterpret_cast<LPARAM>(&li)))
break;

DWORD dwData = ListView_GetCheckState(hListView, idx);
DWORD dwData = !ListView_GetCheckState(hListView, idx);
RegSetValueExA(
hkey,
szItem,
@@ -309,70 +308,6 @@ void SaveControllerList(

}

BOOL IsStartedWithWindows()
{
WCHAR szPath[MAX_PATH]{};

HKEY hkey;
if (RegCreateKey(
HKEY_CURRENT_USER,
STARTUP_KEY,
&hkey) == ERROR_SUCCESS)
{
DWORD cchValue{ _countof(szPath) };
DWORD dwType{ REG_SZ };

RegQueryValueEx(
hkey,
APP_NAME,
NULL,
&dwType,
reinterpret_cast<LPBYTE>(szPath),
&cchValue);

RegCloseKey(hkey);
}

// Return whether our Windows startup entry exists.
return szPath[0] ? TRUE : FALSE;
}

void SetStartedWithWindows(
_In_ BOOL fEnable)
{
HKEY hkey;
if (RegCreateKey(
HKEY_CURRENT_USER,
STARTUP_KEY,
&hkey) == ERROR_SUCCESS)
{
if (!fEnable)
{
// Disable starting with Windows.
RegDeleteValue(hkey, APP_NAME);
}
else
{
WCHAR szPath[MAX_PATH];
GetModuleFileName(NULL, szPath, _countof(szPath));

// Form a command string containing our path with a --startup parameter.
std::wstring command =
TEXT("\"") + std::wstring(szPath) + TEXT("\" --startup");

// Enable starting us with Windows.
RegSetValueEx(
hkey,
APP_NAME,
0, REG_SZ,
reinterpret_cast<const BYTE*>(command.c_str()),
command.length() * sizeof(command[0]));
}

RegCloseKey(hkey);
}
}

INT_PTR CALLBACK DialogProc(
_In_ HWND hDlg,
_In_ UINT uMsg,
@@ -395,10 +330,6 @@ INT_PTR CALLBACK DialogProc(
// Populate the controller list from connected devices and the registry.
PopulateControllerList(hwndList);

// Set the initial startup checkbox state.
if (IsStartedWithWindows())
SendDlgItemMessage(hDlg, IDC_STARTUP, BM_SETCHECK, BST_CHECKED, 0L);

return TRUE;
}

@@ -415,10 +346,6 @@ INT_PTR CALLBACK DialogProc(
// Save the controller checkbox states to the registry.
SaveControllerList(GetDlgItem(hDlg, IDL_CONTROLLERS));

// Set or delete the Windows startup key.
SetStartedWithWindows(
SendDlgItemMessage(hDlg, IDC_STARTUP, BM_GETCHECK, 0, 0L) == BST_CHECKED);

DestroyWindow(hDlg);
return TRUE;
}
BIN -344 Bytes (95%) DashFix/DashFix.rc
Binary file not shown.
@@ -1,19 +1,7 @@
Copyright (c) 2017 Simon Owen

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -1,4 +1,6 @@
# DashFix (OpenVR DashBoard Fixer) v1.0
# DashFix (OpenVR DashBoard Fixer) v1.1

## Introduction

Inputs from connected game controllers can interfere with OpenVR Dashboard
pointer navigation. The problem manifests itself as the inability to click
@@ -13,44 +15,48 @@ DashFix lets you ignore the unwanted inputs, and use the dashboard normally.

## Install

[Download the ".zip" file for the latest version](https://github.com/simonowen/dashfix/releases) and extract it wherever you'd like.
- Connect any problematic game controllers
- Download and run the [installer for the latest version](https://github.com/simonowen/dashfix/releases).
- Select the controllers to block from the list
- Click OK

## Usage
DashFix will continue running in the background, and start with Windows.

- Connect your game controllers
- Launch DashFix.exe
- Uncheck any controllers you don't want to use with the dashboard
- Optionally, select to have DashFix run on every Windows startup.
- The .exe only needs to run once until you shut down again, so checking this means you never have to manually run it. This also means if you want to "uninstall" the tool, just uncheck this, reboot, and delete the folder containing the .exe and .dll.
- Click OK
To change which controllers are blocked, re-launch DashFix from the Start
Menu shortcut. To deactivate it, uninstall from "Add or Remove Programs".

DashFix can be started before or after Steam, and re-run to change controller
selection. Don't worry, ignored controllers still work as normal in all other
games and applications.
## Upgrade

To upgrade an earlier version simply over-install with the latest version.

## Implementation
## Internals

DashFix injects a DLL into Steam.exe and vrdashboard.exe, hooking calls to
SDL_GetJoystickAxis so they return zero for some controllers. This process
injection technique could upset some runtime virus scanners.

Source code is available from the [DashFix project page](https://github.com/simonowen/dashfix) on GitHub.

Please let me know if you have any problems, or find other places where
controllers are interfering with normal use.


## Changelog

v1.0
### v1.1
- added installer/uninstaller to simplify use
- removed option to start with Windows as it's the default behaviour
- inverted checkboxes, so selected means blocked (thanks ljford7!)

### v1.0
- added individual controller selection
- added optional launch on Windows startup
- improved pre-hook checks and error handling
- added MIT license

v0.1
### v0.1
- first public test release, blocking all controllers

---

Simon Owen
Simon Owen
https://github.com/simonowen/dashfix
@@ -0,0 +1,125 @@
; Inno Setup script for DashFix installer

#define MyAppName "DashFix"
#define MyAppVersion "1.1"
#define MyAppPublisher "Simon Owen"
#define MyAppURL "https://github.com/simonowen/dashfix"
#define MyAppExeName "DashFix.exe"

[Setup]
; NOTE: The value of AppId uniquely identifies this application.
; Do not use the same AppId value in installers for other applications.
; (To generate a new GUID, click Tools | Generate GUID inside the IDE.)
AppId={{E693D1E7-CF41-48CE-8E10-8A7FB6D6AE03}
AppName={#MyAppName}
AppVersion={#MyAppVersion}
AppPublisher={#MyAppPublisher}
AppPublisherURL={#MyAppURL}
AppSupportURL={#MyAppURL}
AppUpdatesURL={#MyAppURL}
DefaultDirName={pf}\{#MyAppName}
DefaultGroupName={#MyAppName}
UninstallDisplayName={#MyAppName}
DisableProgramGroupPage=auto
InfoBeforeFile=License.txt
OutputDir=.
OutputBaseFilename=DashFixSetup_{#StringChange(MyAppVersion, '.', '')}
Compression=lzma
SolidCompression=yes
SignTool=signtool $f
SignedUninstaller=yes

[Languages]
Name: "english"; MessagesFile: "compiler:Default.isl"

[Messages]
SetupAppTitle=Setup {#MyAppName}
SetupWindowTitle=Setup - {#MyAppName} v{#MyAppVersion}

[Files]
Source: "Release\DashFix.exe"; DestDir: "{app}"; Flags: ignoreversion
Source: "Release\inject.dll"; DestDir: "{app}"; Flags: ignoreversion
Source: "ReadMe.md"; DestDir: "{app}"; Flags: ignoreversion
Source: "License.txt"; DestDir: "{app}"; Flags: ignoreversion

[Icons]
Name: "{commonprograms}\{#MyAppName}"; Filename: "{app}\{#MyAppExeName}"
Name: "{commonprograms}\{#MyAppName} Website"; Filename: "https://github.com/simonowen/dashfix"

[Registry]
Root: HKCU; Subkey: "Software\Microsoft\Windows\CurrentVersion\Run"; ValueType: string; ValueName: "{#MyAppName}"; ValueData: """{app}\{#MyAppExeName}"" --startup"; Flags: uninsdeletevalue
Root: HKCU; Subkey: "Software\SimonOwen"; Flags: uninsdeletekeyifempty
Root: HKCU; Subkey: "Software\SimonOwen\DashFix"; Flags: uninsdeletekey

[UninstallRun]
Filename: "taskkill.exe"; Parameters: "/f /im ""{#MyAppExeName}"""; Flags: runhidden

[Code]

function GetAppPid(const ExeName : string): Integer;
var
WbemLocator: Variant;
WbemServices: Variant;
WbemObjectSet: Variant;
begin
WbemLocator := CreateOleObject('WBEMScripting.SWBEMLocator');
WbemServices := WbemLocator.ConnectServer('.', 'root\CIMV2');
WbemObjectSet := WbemServices.ExecQuery(Format('SELECT ProcessId FROM Win32_Process Where Name="%s"',[ExeName]));
if WbemObjectSet.Count > 0 then
Result := WbemObjectSet.ItemIndex(0).ProcessId
else
Result := 0;
end;

function CloseSteamApps(const Operation: String): Boolean;
var
Response: Integer;
begin
Result := True

while Result and ((GetAppPid('Steam.exe') <> 0) or (GetAppPid('vrdashboard.exe') <> 0)) do
begin
Response := MsgBox('Please close Steam and SteamVR to ' + Operation + ' {#MyAppName}.', mbInformation, MB_OKCANCEL);
if Response = IDCANCEL then
Result := False
end;
end;

procedure CloseApplication(const ExeName: String);
var
ResultCode: Integer;
begin
Exec(ExpandConstant('taskkill.exe'), '/f /im ' + '"' + ExeName + '"', '', SW_HIDE, ewWaitUntilTerminated, ResultCode);
end;


function PrepareToInstall(var NeedsRestart: Boolean): String;
begin
Result := ''

if GetAppPid('DashFix.exe') <> 0 then
begin
if not CloseSteamApps('upgrade') then
Result := 'Steam or SteamVR are still running.'
else
CloseApplication('{#MyAppExeName}')
end;
end;

function NextButtonClick(CurPageID: Integer): Boolean;
var
ResultCode: Integer;
begin
Result := True;

if (CurPageID = wpFinished) and ((not WizardForm.YesRadio.Visible) or
(not WizardForm.YesRadio.Checked))
then
ExecAsOriginalUser(ExpandConstant('{app}\{#MyAppExeName}'), '', '',
SW_SHOWNORMAL, ewNoWait, ResultCode);
end;

function InitializeUninstall(): Boolean;
begin
Result := CloseSteamApps('uninstall')
end;

0 comments on commit c9d5801

Please sign in to comment.
You can’t perform that action at this time.