Skip to content

Commit 1bda003

Browse files
committed
Open file feature added
1 parent a02f9b3 commit 1bda003

4 files changed

Lines changed: 50 additions & 3 deletions

File tree

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@ A small program that runs in the background and sends the configured key(s) when
55
Supports capturing screenshots and videos directly without any other program involved so the button prompts do not change in the game after pressing the Xbox/Share button on the controller to take the screenshot/video.\
66
Can also capture screenshots and videos using keys on the keyboard.
77

8+
Can also open any file using keyboard key and/or controller button so the button prompts do not change in the game.
9+
810
Configure the program using the config.ini file.
911

1012
Works with the Xbox Series X|S Controller that has the Share button.

config.ini

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,14 @@
1010
; Disable: 0 (default)
1111
debug = 0
1212

13+
; Open file by setting key
14+
; Default: C:\Windows\explorer.exe
15+
file_location = C:\Windows\explorer.exe
16+
17+
; Open file using key on keyboard
18+
; Default: 0 (Disabled)
19+
file_key = 0
20+
1321
[screen_capture]
1422
; Take screenshot/record video by setting key
1523

@@ -322,4 +330,5 @@ xbox_duration = 1
322330
; 110 F23
323331
; 118 F24
324332
; 901 Take screenshot
325-
; 902 Record video start/stop
333+
; 902 Record video start/stop
334+
; 903 Open file

index.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ <h1>Xbox Controller Button Remapper <a href="https://github.com/Adam777Z/xbox-co
3737
<p>A small program that runs in the background and sends the configured key(s) when the Xbox button and/or Share button is pressed on the controller.</p>
3838
<p>Supports capturing screenshots and videos directly without any other program involved so the button prompts do not change in the game after pressing the Xbox/Share button on the controller to take the screenshot/video.<br>
3939
Can also capture screenshots and videos using keys on the keyboard.</p>
40+
<p>Can also open any file using keyboard key and/or controller button so the button prompts do not change in the game.</p>
4041
<p>Configure the program using the config.ini file.</p>
4142
<p>Works with the Xbox Series X|S Controller that has the Share button.</p>
4243
<p>Make sure that the controller is updated to the latest firmware version. (Instructions: <a href="https://support.xbox.com/en-US/help/hardware-network/controller/update-xbox-wireless-controller" target="_blank" rel="nofollow noopener noreferrer">Update your Xbox Wireless Controller</a>)</p>

main.cpp

Lines changed: 37 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,10 @@ static std::vector<Controller> controllers;
6868
handy::io::INIFile ini;
6969
bool debug = false;
7070

71+
std::wstring file_location = L"C:\\Windows\\explorer.exe";
72+
int file_key = 0;
73+
int OpenFileHotKeyID = 3;
74+
7175
std::wstring folder = L"";
7276
std::wstring file_path = L"";
7377

@@ -871,9 +875,9 @@ static void initialize_sdl()
871875

872876
static void key_down(int code)
873877
{
874-
if (code == 901 || code == 902)
878+
if (code == 901 || code == 902 || code == 903)
875879
{
876-
// Take screenshot / record video on button release only
880+
// Take screenshot / record video / open file on button release only
877881
return;
878882
}
879883

@@ -910,6 +914,12 @@ static void key_up(int code)
910914
capture_video();
911915
return;
912916
}
917+
else if (code == 903)
918+
{
919+
//ShellExecute(NULL, L"open", file_location.c_str(), NULL, NULL, SW_HIDE);
920+
ShellExecute(NULL, L"open", file_location.c_str(), NULL, NULL, SW_SHOWNORMAL);
921+
return;
922+
}
913923

914924
INPUT inp{};
915925
inp.type = INPUT_KEYBOARD;
@@ -1246,6 +1256,16 @@ int WINAPI wWinMain(_In_ HINSTANCE hInstance, _In_opt_ HINSTANCE hPrevInstance,
12461256
SDL_Log("%s: Debug mode enabled.\n", get_date_time().c_str());
12471257
}
12481258

1259+
file_location = ini.getString(L"settings", L"file_location", L"C:\\Windows\\explorer.exe");
1260+
1261+
file_key = ini.getInteger(L"settings", L"file_key", 0);
1262+
1263+
if (file_key != 0)
1264+
{
1265+
UINT file_key_vk = MapVirtualKey(file_key, MAPVK_VSC_TO_VK_EX);
1266+
RegisterHotKey(hWnd, OpenFileHotKeyID, MOD_NOREPEAT, file_key_vk);
1267+
}
1268+
12491269
captures_location = ini.getString(L"screen_capture", L"location", L"C:\\Screenshots");
12501270

12511271
screenshot_key = ini.getInteger(L"screen_capture", L"screenshot_key", 0);
@@ -1312,6 +1332,16 @@ int WINAPI wWinMain(_In_ HINSTANCE hInstance, _In_opt_ HINSTANCE hPrevInstance,
13121332

13131333
capture_video();
13141334
}
1335+
else if (msg.wParam == OpenFileHotKeyID)
1336+
{
1337+
if (debug)
1338+
{
1339+
SDL_Log("%s: Open file HotKey pressed.\n", get_date_time().c_str());
1340+
}
1341+
1342+
//ShellExecute(NULL, L"open", file_location.c_str(), NULL, NULL, SW_HIDE);
1343+
ShellExecute(NULL, L"open", file_location.c_str(), NULL, NULL, SW_SHOWNORMAL);
1344+
}
13151345
}
13161346
}
13171347

@@ -1433,6 +1463,11 @@ LRESULT CALLBACK WindowProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
14331463

14341464
CoUninitialize();
14351465

1466+
if (file_key != 0)
1467+
{
1468+
UnregisterHotKey(hWnd, OpenFileHotKeyID);
1469+
}
1470+
14361471
if (screenshot_key != 0)
14371472
{
14381473
UnregisterHotKey(hWnd, ScreenshotHotKeyID);

0 commit comments

Comments
 (0)