Skip to content

Commit c3694c8

Browse files
committed
Added listview
1 parent b9bb2ff commit c3694c8

File tree

7 files changed

+267
-52
lines changed

7 files changed

+267
-52
lines changed

CMakeLists.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ set(SRC_INC
2020
include/Window.hxx
2121
include/MainWindow.hxx
2222
include/ColorPicker.hxx
23+
include/DualSenseInfo.hxx
2324
)
2425

2526
set(SRC
@@ -44,6 +45,7 @@ set(ASSETS "$<TARGET_FILE_DIR:${APP}>/assets")
4445

4546
add_executable(${APP} WIN32 ${SRC} ${SRC_INC})
4647
target_link_directories(${APP} PUBLIC lib/)
48+
target_link_libraries(${APP} comctl32.lib)
4749
target_link_libraries(${APP} hidapi.lib)
4850
target_link_libraries(${APP} setupapi)
4951
target_link_libraries(${APP} ViGEmClient.lib)

include/ColorPicker.hxx

Lines changed: 4 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,13 @@
11
#pragma once
22

33

4-
#include "Core.hxx"
5-
#include "Window.hxx"
64
#include <sigslot/signal.hpp>
75

8-
namespace BrokenBytes::DualSense4Windows::UI {
9-
10-
struct Color {
11-
uint8_t R;
12-
uint8_t G;
13-
uint8_t B;
6+
#include "Core.hxx"
7+
#include "Window.hxx"
8+
#include "DualSenseInfo.hxx"
149

15-
COLORREF RGB_VALUE() const {
16-
return RGB(R, G, B);
17-
}
18-
};
19-
10+
namespace BrokenBytes::DualSense4Windows::UI {
2011
class ColorPicker : public Window {
2112
public:
2213
sigslot::signal<Color> ColorChanged;

include/DualSenseInfo.hxx

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
#pragma once
2+
#include <string>
3+
#include "Core.hxx"
4+
5+
6+
namespace BrokenBytes::DualSense4Windows::UI {
7+
struct Color {
8+
uint8_t R;
9+
uint8_t G;
10+
uint8_t B;
11+
12+
COLORREF RGB_VALUE() const {
13+
return RGB(R, G, B);
14+
}
15+
};
16+
17+
enum class ConnectionType {
18+
USB,
19+
Bluetooth
20+
};
21+
22+
enum class Mode {
23+
XBox,
24+
DS4,
25+
Native
26+
};
27+
28+
struct DualSenseInfo {
29+
char* Path;
30+
std::wstring Name;
31+
ConnectionType Connection;
32+
Mode Mode;
33+
Color Color;
34+
};
35+
}

include/MainWindow.hxx

Lines changed: 10 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,13 @@
1111
namespace BrokenBytes::DualSense4Windows::UI {
1212

1313
enum class Dimensions : uint16_t {
14-
VSpacer = 1,
14+
VSpacer = 8,
1515
HSpacer = 1,
1616
NameWidth = 30,
1717
ConnectionWidth = 10,
1818
ColorSize = 15,
1919
HideWidth = 10,
20-
BaseHeight = 5
20+
BaseHeight = 16
2121
};
2222

2323
class MainWindow : public Window {
@@ -46,18 +46,14 @@ namespace BrokenBytes::DualSense4Windows::UI {
4646

4747
private:
4848
std::vector<char*> _devices;
49-
std::map<char*, std::array<void*, 4>> _controls;
50-
51-
/// <summary>
52-
/// Adds the controls for a given DualSense
53-
/// </summary>
54-
/// <param name="id">The path of the DualSense</param>
55-
void AddControls(char* id);
56-
57-
/// <summary>
58-
/// Removes the controls for a given DualSense
59-
/// </summary>
60-
/// <param name="id">The path of the DualSense</param>
49+
std::vector<DualSenseInfo> _info;
50+
HWND _tabView;
51+
HWND _listView;
52+
std::map<std::wstring, HWND> _tabs;
53+
54+
HWND CreateTabControl();
55+
HWND CreateListViewControl();
56+
void AddControls(char* id, int index);
6157
void RemoveControls(char* id);
6258
};
6359
}

include/Window.hxx

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,11 @@
1313
namespace BrokenBytes::DualSense4Windows::UI {
1414
constexpr LPCWSTR WINDOW_DEFAULT = L"WINDOW_DEFAULT";
1515

16+
constexpr int FONT_TAB = 19;
17+
constexpr int FONT_HEADLINE = 23;
18+
constexpr int FONT_LABEL = 21;
19+
constexpr int FONT_BTN = 22;
20+
1621
class Window {
1722
public:
1823
Window(
@@ -44,8 +49,8 @@ namespace BrokenBytes::DualSense4Windows::UI {
4449
GetModuleHandle(nullptr),
4550
nullptr
4651
);
47-
SendMessageW(_handle, WM_THEMECHANGED, 0, 0);
4852
SetWindowLongPtr(_handle, GWLP_USERDATA, reinterpret_cast<LONG_PTR>(this));
53+
SetFont(Handle(), FONT_HEADLINE);
4954

5055
if (_handle == nullptr) {
5156
return;
@@ -155,6 +160,23 @@ namespace BrokenBytes::DualSense4Windows::UI {
155160
_isRegistered = true;
156161
}
157162

163+
/// <summary>
164+
/// Sets the default font for the given window
165+
/// </summary>
166+
/// <param name="handle"></param>
167+
void SetFont(HWND handle, int size) {
168+
HFONT hFont = CreateFont(size, 0, 0, 0, FW_DONTCARE, FALSE, FALSE, FALSE, ANSI_CHARSET,
169+
OUT_TT_PRECIS, CLIP_DEFAULT_PRECIS, HIGH_LEVEL,
170+
DEFAULT_PITCH | FF_DONTCARE, TEXT("Roboto"));
171+
SendMessage(
172+
handle,
173+
WM_SETFONT,
174+
reinterpret_cast<WPARAM>(hFont),
175+
true
176+
);
177+
}
178+
179+
158180
/// <summary>
159181
/// Sets the handle of this Window
160182
/// </summary>

src/ColorPicker.cxx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,11 +103,11 @@ namespace BrokenBytes::DualSense4Windows::UI {
103103
NULL);
104104

105105
SetResizable(false);
106-
SetWindowPos(Handle(), HWND_TOPMOST, 0, 0, WIDTH, HEIGHT, SWP_SHOWWINDOW | SWP_NOSIZE | SWP_NOMOVE);
107106
}
108107

109108
void ColorPicker::Show() {
110109
Window::Show();
110+
SetWindowPos(Handle(), HWND_TOPMOST, 0, 0, WIDTH, HEIGHT, SWP_SHOWWINDOW | SWP_NOSIZE | SWP_NOMOVE);
111111
}
112112

113113
void ColorPicker::SetColor(uint8_t r, uint8_t g, uint8_t b) {

0 commit comments

Comments
 (0)