Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/source
diff options
context:
space:
mode:
authorChristopher Peerman <chris_82>2019-01-14 19:46:49 +0300
committerBrecht Van Lommel <brechtvanlommel@gmail.com>2019-01-14 22:48:11 +0300
commit46932079184754ace63b25f854e3f273fbf6f0c5 (patch)
tree2d17a33cccbb5e873b090d319add3485528ace54 /source
parenteaf282b375598e63876465735519ab3190bd3214 (diff)
Windows: add support for Windows Ink.
Before this Blender always needed the Wintab driver. This adds support for the native pressure API in Windows 8+, making it possible to get pressure sensitivity on e.g. Microsoft Surface hardware without any extra drivers. By default Blender will automatically use Wintab if available, and if not use Windows Ink instead. There is also a new user preference to explicitly specify which API to use if automatic detection fails. Fixes T57869: no pressure sensitivity with Surface pen or laptop. Code by Christopher Peerman with some tweaks by Brecht Van Lommel. Differential Revision: https://developer.blender.org/D4165
Diffstat (limited to 'source')
-rw-r--r--source/blender/makesdna/DNA_userdef_types.h12
-rw-r--r--source/blender/makesrna/intern/rna_userdef.c17
-rw-r--r--source/blender/windowmanager/WM_api.h1
-rw-r--r--source/blender/windowmanager/intern/wm_window.c20
4 files changed, 49 insertions, 1 deletions
diff --git a/source/blender/makesdna/DNA_userdef_types.h b/source/blender/makesdna/DNA_userdef_types.h
index a749fba5026..a653aaec671 100644
--- a/source/blender/makesdna/DNA_userdef_types.h
+++ b/source/blender/makesdna/DNA_userdef_types.h
@@ -694,13 +694,16 @@ typedef struct UserDef {
/** Seconds to zoom around current frame. */
float view_frame_seconds;
- char _pad1[4];
+ char _pad1[2];
/** Private, defaults to 20 for 72 DPI setting. */
short widget_unit;
short anisotropic_filter;
short use_16bit_textures, use_gpu_mipmap;
+ /** Tablet API to use (Windows only). */
+ short tablet_api;
+
/** Raw tablet pressure that maps to 100%. */
float pressure_threshold_max;
/** Curve non-linearity parameter. */
@@ -915,6 +918,13 @@ typedef enum eUserpref_UI_Flag2 {
USER_TRACKPAD_NATURAL = (1 << 2),
} eUserpref_UI_Flag2;
+/* UserDef.tablet_api */
+typedef enum eUserpref_TableAPI {
+ USER_TABLET_AUTOMATIC = 0,
+ USER_TABLET_NATIVE = 1,
+ USER_TABLET_WINTAB = 2,
+} eUserpref_TabletAPI;
+
/* UserDef.app_flag */
typedef enum eUserpref_APP_Flag {
USER_APP_LOCK_UI_LAYOUT = (1 << 0),
diff --git a/source/blender/makesrna/intern/rna_userdef.c b/source/blender/makesrna/intern/rna_userdef.c
index 15f20a6aba7..eea2595d2a7 100644
--- a/source/blender/makesrna/intern/rna_userdef.c
+++ b/source/blender/makesrna/intern/rna_userdef.c
@@ -236,6 +236,11 @@ static void rna_userdef_autokeymode_set(PointerRNA *ptr, int value)
}
}
+static void rna_userdef_tablet_api_update(Main *UNUSED(bmain), Scene *UNUSED(scene), PointerRNA *UNUSED(ptr))
+{
+ WM_init_tablet_api();
+}
+
#ifdef WITH_INPUT_NDOF
static void rna_userdef_ndof_deadzone_update(Main *UNUSED(bmain), Scene *UNUSED(scene), PointerRNA *ptr)
{
@@ -4608,6 +4613,13 @@ static void rna_def_userdef_input(BlenderRNA *brna)
};
#endif /* WITH_INPUT_NDOF */
+ static const EnumPropertyItem tablet_api[] = {
+ {USER_TABLET_AUTOMATIC, "AUTOMATIC", 0, "Automatic", "Automatically choose Wintab or Windows Ink depending on the device"},
+ {USER_TABLET_NATIVE, "WINDOWS_INK", 0, "Windows Ink", "Use native Windows Ink API, for modern tablet and pen devices. Requires Windows 8 or newer"},
+ {USER_TABLET_WINTAB, "WINTAB", 0, "Wintab", "Use Wintab driver for older tablets and Windows versions"},
+ {0, NULL, 0, NULL, NULL}
+ };
+
static const EnumPropertyItem view_zoom_styles[] = {
{USER_ZOOM_CONT, "CONTINUE", 0, "Continue", "Old style zoom, continues while moving mouse up or down"},
{USER_ZOOM_DOLLY, "DOLLY", 0, "Dolly", "Zoom in and out based on vertical mouse movement"},
@@ -4733,6 +4745,11 @@ static void rna_def_userdef_input(BlenderRNA *brna)
RNA_def_property_ui_text(prop, "Softness",
"Adjusts softness of the low pressure response onset using a gamma curve");
+ prop = RNA_def_property(srna, "tablet_api", PROP_ENUM, PROP_NONE);
+ RNA_def_property_enum_items(prop, tablet_api);
+ RNA_def_property_ui_text(prop, "Tablet API", "Select the tablet API to use for pressure sensitivity");
+ RNA_def_property_update(prop, 0, "rna_userdef_tablet_api_update");
+
#ifdef WITH_INPUT_NDOF
/* 3D mouse settings */
/* global options */
diff --git a/source/blender/windowmanager/WM_api.h b/source/blender/windowmanager/WM_api.h
index adf082982b7..9daed32ee33 100644
--- a/source/blender/windowmanager/WM_api.h
+++ b/source/blender/windowmanager/WM_api.h
@@ -91,6 +91,7 @@ void WM_init_state_fullscreen_set(void);
void WM_init_state_normal_set(void);
void WM_init_window_focus_set(bool do_it);
void WM_init_native_pixels(bool do_it);
+void WM_init_tablet_api(void);
void WM_init (struct bContext *C, int argc, const char **argv);
void WM_exit_ext (struct bContext *C, const bool do_python);
diff --git a/source/blender/windowmanager/intern/wm_window.c b/source/blender/windowmanager/intern/wm_window.c
index 281a556a62d..8b76b2a5d32 100644
--- a/source/blender/windowmanager/intern/wm_window.c
+++ b/source/blender/windowmanager/intern/wm_window.c
@@ -1690,6 +1690,8 @@ void wm_ghost_init(bContext *C)
}
GHOST_UseWindowFocus(wm_init_state.window_focus);
+
+ WM_init_tablet_api();
}
}
@@ -1979,6 +1981,24 @@ void WM_init_native_pixels(bool do_it)
wm_init_state.native_pixels = do_it;
}
+void WM_init_tablet_api(void)
+{
+ if (g_system) {
+ switch(U.tablet_api) {
+ case USER_TABLET_NATIVE:
+ GHOST_SetTabletAPI(g_system, GHOST_kTabletNative);
+ break;
+ case USER_TABLET_WINTAB:
+ GHOST_SetTabletAPI(g_system, GHOST_kTabletWintab);
+ break;
+ case USER_TABLET_AUTOMATIC:
+ default:
+ GHOST_SetTabletAPI(g_system, GHOST_kTabletAutomatic);
+ break;
+ }
+ }
+}
+
/* This function requires access to the GHOST_SystemHandle (g_system) */
void WM_cursor_warp(wmWindow *win, int x, int y)
{