Skip to content

Commit 1a464e2

Browse files
authored
Added pen tablet driver preference for Windows (contributed by williamchange)
Pen tablet driver preference for Windows
2 parents 50ef704 + 8d342a2 commit 1a464e2

6 files changed

Lines changed: 63 additions & 1 deletion

File tree

material_maker/globals.gd

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ const DEFAULT_CONFIG : Dictionary = {
5454
graph_line_curvature = 0.5,
5555
graph_line_style = 1,
5656
ui_use_native_file_dialogs = true,
57+
win_tablet_driver = 0,
5758
}
5859

5960

material_maker/main_window.gd

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,7 @@ const MENU : Array[Dictionary] = [
121121
{ menu="Help/About", command="about" }
122122
]
123123

124+
enum WinTabletDriver { WININK, WINTAB, DISABLED }
124125

125126
func _enter_tree() -> void:
126127
mm_globals.main_window = self
@@ -318,6 +319,15 @@ func on_config_changed() -> void:
318319
@warning_ignore("narrowing_conversion")
319320
preview_tesselation_detail = clamp(mm_globals.get_config("ui_3d_preview_tesselation_detail"), 16, 1024)
320321

322+
if OS.get_name() == "Windows":
323+
match mm_globals.get_config("win_tablet_driver"):
324+
WinTabletDriver.WININK:
325+
DisplayServer.tablet_set_current_driver("winink")
326+
WinTabletDriver.WINTAB:
327+
DisplayServer.tablet_set_current_driver("wintab")
328+
WinTabletDriver.DISABLED:
329+
DisplayServer.tablet_set_current_driver("dummy")
330+
321331
func get_panel(panel_name : String) -> Control:
322332
return layout.get_panel(panel_name)
323333

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
extends OptionButton
2+
3+
class_name EnumOption
4+
5+
@export var config_variable : String
6+
7+
func init_from_config(config : ConfigFile) -> void:
8+
if config.has_section_key("config", config_variable):
9+
selected = config.get_value("config", config_variable)
10+
if selected == -1:
11+
selected = 0
12+
13+
func update_config(config : ConfigFile) -> void:
14+
config.set_value("config", config_variable, selected)
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
uid://d3h4xmek7b2vq

material_maker/windows/preferences/preferences.gd

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,3 +77,8 @@ func _on_DownloadLanguage_closed():
7777
var locale = load("res://material_maker/locale/locale.gd").new()
7878
locale.read_translations()
7979
update_language_list()
80+
81+
82+
func _on_ready() -> void:
83+
$VBoxContainer/TabContainer/General/WinTabletDriverSpacer.visible = OS.get_name() == "Windows"
84+
$VBoxContainer/TabContainer/General/WinTabletDriver.visible = OS.get_name() == "Windows"

material_maker/windows/preferences/preferences.tscn

Lines changed: 32 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
1-
[gd_scene load_steps=5 format=3 uid="uid://c1j6a4jdggjm6"]
1+
[gd_scene load_steps=6 format=3 uid="uid://c1j6a4jdggjm6"]
22

33
[ext_resource type="PackedScene" uid="uid://drg0s4lftblx3" path="res://material_maker/windows/preferences/bool_option.tscn" id="1"]
44
[ext_resource type="Script" uid="uid://cwom8loyqsvf2" path="res://material_maker/windows/preferences/preferences.gd" id="2"]
55
[ext_resource type="PackedScene" uid="uid://3lo2jh781ten" path="res://material_maker/windows/preferences/float_option.tscn" id="3"]
66
[ext_resource type="Script" uid="uid://gmystrme5ayw" path="res://material_maker/windows/preferences/lang_option.gd" id="4"]
7+
[ext_resource type="Script" path="res://material_maker/windows/preferences/enum_option.gd" id="5_vp06c"]
78

89
[node name="Preferences" type="Window"]
910
oversampling_override = 1.0
@@ -149,6 +150,35 @@ Changes to this setting are only applied on application restart."
149150
text = "3D preview sun shadow (requires restart)"
150151
config_variable = "ui_3d_preview_sun_shadow"
151152

153+
[node name="WinTabletDriverSpacer" type="Control" parent="VBoxContainer/TabContainer/General"]
154+
custom_minimum_size = Vector2(0, 10)
155+
layout_mode = 2
156+
157+
[node name="WinTabletDriver" type="HBoxContainer" parent="VBoxContainer/TabContainer/General"]
158+
layout_mode = 2
159+
160+
[node name="Label" type="Label" parent="VBoxContainer/TabContainer/General/WinTabletDriver"]
161+
layout_mode = 2
162+
text = "Tablet Driver:"
163+
164+
[node name="EnumOption" type="OptionButton" parent="VBoxContainer/TabContainer/General/WinTabletDriver"]
165+
layout_mode = 2
166+
tooltip_text = "Pen tablet driver to use
167+
168+
Winink: Windows Ink API (Windows 8.1+)
169+
Wintab: Wacom Tablet API (Requires a compatible device driver)
170+
Disabled: Disables pen tablet input"
171+
selected = 0
172+
item_count = 3
173+
popup/item_0/text = "Winink"
174+
popup/item_0/id = 0
175+
popup/item_1/text = "Wintab"
176+
popup/item_1/id = 1
177+
popup/item_2/text = "Disabled"
178+
popup/item_2/id = 2
179+
script = ExtResource("5_vp06c")
180+
config_variable = "win_tablet_driver"
181+
152182
[node name="Space2" type="Control" parent="VBoxContainer/TabContainer/General"]
153183
custom_minimum_size = Vector2(0, 10)
154184
layout_mode = 2
@@ -309,6 +339,7 @@ text = "Cancel"
309339

310340
[connection signal="about_to_popup" from="." to="." method="_on_Preferences_about_to_show"]
311341
[connection signal="close_requested" from="." to="." method="_on_Cancel_pressed"]
342+
[connection signal="ready" from="." to="." method="_on_ready"]
312343
[connection signal="minimum_size_changed" from="VBoxContainer" to="." method="_on_VBoxContainer_minimum_size_changed"]
313344
[connection signal="pressed" from="VBoxContainer/TabContainer/General/HBoxContainer/InstallLanguage" to="." method="_on_InstallLanguage_pressed"]
314345
[connection signal="pressed" from="VBoxContainer/TabContainer/General/HBoxContainer/DownloadLanguage" to="." method="_on_DownloadLanguage_pressed"]

0 commit comments

Comments
 (0)