Skip to content

Commit 754ea7d

Browse files
committed
osu! window, debug checkbox
- Added ability to change screen are to match with osu! or TabletDriverGUI window. - Added debug checkbox to console tab.
1 parent 0d9e92f commit 754ea7d

File tree

5 files changed

+164
-8
lines changed

5 files changed

+164
-8
lines changed

TabletDriverGUI/Configuration.cs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,8 +66,9 @@ public enum OutputModes
6666
public bool RunAtStartup;
6767

6868
public string DriverPath;
69-
public string DriverArguments;
69+
public string DriverArguments;
7070

71+
public bool DebuggingEnabled;
7172
public bool DeveloperMode;
7273

7374

@@ -115,6 +116,8 @@ public Configuration()
115116

116117
DriverPath = "bin/TabletDriverService.exe";
117118
DriverArguments = "config/init.cfg";
119+
120+
DebuggingEnabled = false;
118121
DeveloperMode = false;
119122
}
120123

TabletDriverGUI/MainWindow.Driver.cs

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -184,6 +184,17 @@ private void SendSettingsToDriver()
184184
driver.SendCommand("AntiSmoothing 0");
185185
}
186186

187+
188+
// Debugging
189+
if(config.DebuggingEnabled)
190+
{
191+
driver.SendCommand("Debug true");
192+
} else
193+
{
194+
driver.SendCommand("Debug false");
195+
}
196+
197+
187198
// Commands after settings
188199
if (config.CommandsAfter.Length > 0)
189200
{
@@ -346,6 +357,12 @@ private void ProcessStatusMessage(string variableName, string parameters)
346357
//
347358
private void OnDriverStarted(object sender, EventArgs e)
348359
{
360+
// Debugging commands
361+
if(config.DebuggingEnabled)
362+
{
363+
driver.SendCommand("HIDList");
364+
}
365+
349366
driver.SendCommand("GetCommands");
350367
driver.SendCommand("Echo");
351368
driver.SendCommand("Echo Driver version: " + Version);

TabletDriverGUI/MainWindow.Settings.cs

Lines changed: 75 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -202,7 +202,6 @@ private void LoadSettingsFromConfiguration()
202202
//
203203
checkBoxRunAtStartup.IsChecked = config.RunAtStartup;
204204

205-
206205
//
207206
// Custom commands
208207
//
@@ -222,6 +221,11 @@ private void LoadSettingsFromConfiguration()
222221
}
223222
textCommandsAfter.Text = tmp;
224223

224+
//
225+
// Debugging
226+
//
227+
checkBoxDebugging.IsChecked = config.DebuggingEnabled;
228+
225229

226230
// Update canvases
227231
UpdateCanvasElements();
@@ -410,6 +414,11 @@ private void UpdateSettingsToConfiguration()
410414
config.CommandsAfter = commandList.ToArray();
411415

412416

417+
//
418+
// Debugging
419+
//
420+
config.DebuggingEnabled = (bool)checkBoxDebugging.IsChecked;
421+
413422

414423
UpdateCanvasElements();
415424

@@ -953,7 +962,6 @@ private void CheckboxChanged(object sender, RoutedEventArgs e)
953962
{
954963
if (isLoadingSettings) return;
955964

956-
957965
// Disable tablet area settings when full area is forced
958966
if (checkBoxForceFullArea.IsChecked == true)
959967
{
@@ -1005,6 +1013,19 @@ private void CheckboxChanged(object sender, RoutedEventArgs e)
10051013
textDesktopHeight.IsEnabled = true;
10061014
}
10071015

1016+
// Debugging checkbox
1017+
if (sender == checkBoxDebugging)
1018+
{
1019+
if (checkBoxDebugging.IsChecked == true)
1020+
{
1021+
driver.SendCommand("Debug true");
1022+
}
1023+
else
1024+
{
1025+
driver.SendCommand("Debug false");
1026+
}
1027+
}
1028+
10081029
UpdateSettingsToConfiguration();
10091030

10101031
if (sender == checkBoxForceFullArea)
@@ -1064,6 +1085,21 @@ private void ComboBoxMonitor_MouseDown(object sender, MouseButtonEventArgs e)
10641085
comboBoxMonitor.Items.Add(System.Windows.Forms.Screen.PrimaryScreen.DeviceName);
10651086
}
10661087

1088+
// TabletDriverGUI window
1089+
comboBoxMonitor.Items.Add("This window");
1090+
1091+
// osu!.exe processes window
1092+
try
1093+
{
1094+
if (Process.GetProcessesByName("osu!").Length > 0)
1095+
{
1096+
comboBoxMonitor.Items.Add("osu! window");
1097+
}
1098+
}
1099+
catch (Exception)
1100+
{
1101+
}
1102+
10671103
}
10681104

10691105

@@ -1092,13 +1128,50 @@ private void ComboBoxMonitor_SelectionChanged(object sender, SelectionChangedEve
10921128
else if (index > 0)
10931129
{
10941130
index--;
1131+
1132+
// Monitors
10951133
if (index >= 0 && index < screens.Length)
10961134
{
10971135
textScreenAreaX.Text = Utils.GetNumberString(screens[index].Bounds.X - minX);
10981136
textScreenAreaY.Text = Utils.GetNumberString(screens[index].Bounds.Y - minY);
10991137
textScreenAreaWidth.Text = Utils.GetNumberString(screens[index].Bounds.Width);
11001138
textScreenAreaHeight.Text = Utils.GetNumberString(screens[index].Bounds.Height);
11011139
}
1140+
1141+
// TabletDriverGUI window
1142+
else if (comboBoxMonitor.SelectedValue.ToString() == "This window")
1143+
{
1144+
textScreenAreaX.Text = Utils.GetNumberString(Application.Current.MainWindow.Left - minX);
1145+
textScreenAreaY.Text = Utils.GetNumberString(Application.Current.MainWindow.Top - minY);
1146+
textScreenAreaWidth.Text = Utils.GetNumberString(Application.Current.MainWindow.Width);
1147+
textScreenAreaHeight.Text = Utils.GetNumberString(Application.Current.MainWindow.Height);
1148+
}
1149+
1150+
// osu! window
1151+
else if (comboBoxMonitor.SelectedValue.ToString() == "osu! window")
1152+
{
1153+
try
1154+
{
1155+
Process[] processes = Process.GetProcessesByName("osu!");
1156+
1157+
if (processes.Length > 0)
1158+
{
1159+
IntPtr osuHandle = processes[0].MainWindowHandle;
1160+
NativeMethods.RECT rect;
1161+
NativeMethods.GetWindowRect(osuHandle, out rect);
1162+
1163+
textScreenAreaX.Text = Utils.GetNumberString(rect.X - minX);
1164+
textScreenAreaY.Text = Utils.GetNumberString(rect.Y - minY);
1165+
textScreenAreaWidth.Text = Utils.GetNumberString(rect.Width);
1166+
textScreenAreaHeight.Text = Utils.GetNumberString(rect.Height - 1);
1167+
1168+
}
1169+
}
1170+
catch (Exception)
1171+
{
1172+
1173+
}
1174+
}
11021175
}
11031176
UpdateSettingsToConfiguration();
11041177
}

TabletDriverGUI/MainWindow.xaml

Lines changed: 24 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -743,7 +743,11 @@
743743
</TabItem>
744744
<TabItem Name="tabConsole" Header="Console">
745745
<Grid Margin="0,2,0,0">
746-
<ScrollViewer Name="scrollConsole" Margin="5,5,5,30"
746+
<Grid.RowDefinitions>
747+
<RowDefinition Height="*"/>
748+
<RowDefinition Height="Auto" />
749+
</Grid.RowDefinitions>
750+
<ScrollViewer Grid.Row="0" Name="scrollConsole" Margin="5,0,5,0"
747751
VerticalScrollBarVisibility="Auto"
748752
HorizontalScrollBarVisibility="Auto">
749753

@@ -780,16 +784,31 @@
780784
</TextBlock>
781785
</ScrollViewer>
782786

783-
<!-- Console input -->
784-
<TextBox Name="textConsoleInput" Margin="5,0,5,5" VerticalAlignment="Bottom" Height="20" TextWrapping="Wrap" Text=""
787+
<Grid Grid.Row="1" Height="25" Margin="5,0,5,0">
788+
<Grid.ColumnDefinitions>
789+
<ColumnDefinition Width="*"/>
790+
<ColumnDefinition Width="Auto"/>
791+
</Grid.ColumnDefinitions>
792+
793+
<!-- Console input -->
794+
<TextBox Grid.Column="0" Name="textConsoleInput" Height="20" TextWrapping="Wrap" Text=""
795+
VerticalContentAlignment="Center"
796+
Padding="0"
785797
FontFamily="Courier New" Background="White" Foreground="Black"
786798
FontSize="12"
787799
TabIndex="2"
788800
PreviewKeyDown="TextConsoleInput_PreviewKeyDown"
789-
KeyDown="TextConsoleInput_KeyDown" Grid.ColumnSpan="2"
801+
KeyDown="TextConsoleInput_KeyDown"
790802
/>
791-
803+
<CheckBox Grid.Column="1" Name="checkBoxDebugging"
804+
Height="16"
805+
Margin="5,1,0,0"
806+
Checked="CheckboxChanged"
807+
Unchecked="CheckboxChanged"
808+
>Debug</CheckBox>
809+
</Grid>
792810
</Grid>
811+
793812
</TabItem>
794813
</TabControl>
795814

TabletDriverGUI/NativeMethods.cs

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,56 @@ namespace TabletDriverGUI
55
{
66
public class NativeMethods
77
{
8+
[StructLayout(LayoutKind.Sequential)]
9+
public struct RECT
10+
{
11+
public int Left, Top, Right, Bottom;
12+
13+
public RECT(int left, int top, int right, int bottom)
14+
{
15+
Left = left;
16+
Top = top;
17+
Right = right;
18+
Bottom = bottom;
19+
}
20+
21+
public RECT(System.Drawing.Rectangle r) : this(r.Left, r.Top, r.Right, r.Bottom) { }
22+
23+
public int X
24+
{
25+
get { return Left; }
26+
set { Right -= (Left - value); Left = value; }
27+
}
28+
29+
public int Y
30+
{
31+
get { return Top; }
32+
set { Bottom -= (Top - value); Top = value; }
33+
}
34+
35+
public int Height
36+
{
37+
get { return Bottom - Top; }
38+
set { Bottom = value + Top; }
39+
}
40+
41+
public int Width
42+
{
43+
get { return Right - Left; }
44+
set { Right = value + Left; }
45+
}
46+
}
47+
848
public const int HWND_BROADCAST = 0xffff;
949
public static readonly int WM_SHOWTABLETDRIVERGUI = RegisterWindowMessage("WM_SHOWTABLETDRIVERGUI");
1050

1151
[DllImport("user32")]
1252
public static extern bool PostMessage(IntPtr hwnd, int msg, IntPtr wparam, IntPtr lparam);
1353
[DllImport("user32")]
1454
public static extern int RegisterWindowMessage(string message);
55+
56+
[DllImport("user32.dll", SetLastError = true)]
57+
public static extern bool GetWindowRect(IntPtr hwnd, out RECT lpRect);
58+
1559
}
1660
}

0 commit comments

Comments
 (0)