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
diff options
context:
space:
mode:
authorBrecht Van Lommel <brechtvanlommel@gmail.com>2018-11-25 01:44:17 +0300
committerBrecht Van Lommel <brechtvanlommel@gmail.com>2018-11-25 01:44:17 +0300
commita2e209f20a44d14c1c56ba9f69b6589c318c7199 (patch)
tree8e6288017746946316c96973c48bd5e64a9bb7a3 /intern/ghost
parent13fa509187e0cc7e3b9df806dc2496b7516e2cd3 (diff)
parent33750e8abbade21813365a7dd62e036969d5006c (diff)
Merge branch 'master' into blender2.8
Diffstat (limited to 'intern/ghost')
-rw-r--r--intern/ghost/intern/GHOST_SystemX11.cpp80
1 files changed, 26 insertions, 54 deletions
diff --git a/intern/ghost/intern/GHOST_SystemX11.cpp b/intern/ghost/intern/GHOST_SystemX11.cpp
index 344e893bb08..e228a11dac2 100644
--- a/intern/ghost/intern/GHOST_SystemX11.cpp
+++ b/intern/ghost/intern/GHOST_SystemX11.cpp
@@ -2261,11 +2261,8 @@ int GHOST_X11_ApplicationIOErrorHandler(Display * /*display*/)
}
#ifdef WITH_X11_XINPUT
-/* These C functions are copied from Wine 1.1.13's wintab.c */
-#define BOOL int
-#define TRUE 1
-#define FALSE 0
+/* These C functions are copied from Wine 3.12's wintab.c */
static bool match_token(const char *haystack, const char *needle)
{
const char *p, *q;
@@ -2278,15 +2275,14 @@ static bool match_token(const char *haystack, const char *needle)
for (q = needle; *q && *p && tolower(*p) == tolower(*q); q++)
p++;
if (!*q && (isspace(*p) || !*p))
- return TRUE;
+ return true;
while (*p && !isspace(*p))
p++;
}
- return FALSE;
+ return false;
}
-
/* Determining if an X device is a Tablet style device is an imperfect science.
* We rely on common conventions around device names as well as the type reported
* by Wacom tablets. This code will likely need to be expanded for alternate tablet types
@@ -2297,35 +2293,10 @@ static bool match_token(const char *haystack, const char *needle)
* Wacoms x11 config "cursor" refers to its device slot (which we mirror with
* our gSysCursors) for puck like devices (tablet mice essentially).
*/
-#if 0 // unused
-static BOOL is_tablet_cursor(const char *name, const char *type)
-{
- int i;
- static const char *tablet_cursor_whitelist[] = {
- "wacom",
- "wizardpen",
- "acecad",
- "tablet",
- "cursor",
- "stylus",
- "eraser",
- "pad",
- NULL
- };
-
- for (i = 0; tablet_cursor_whitelist[i] != NULL; i++) {
- if (name && match_token(name, tablet_cursor_whitelist[i]))
- return TRUE;
- if (type && match_token(type, tablet_cursor_whitelist[i]))
- return TRUE;
- }
- return FALSE;
-}
-#endif
-static BOOL is_stylus(const char *name, const char *type)
+static GHOST_TTabletMode tablet_mode_from_name(const char *name, const char *type)
{
int i;
- static const char *tablet_stylus_whitelist[] = {
+ static const char* tablet_stylus_whitelist[] = {
"stylus",
"wizardpen",
"acecad",
@@ -2333,28 +2304,28 @@ static BOOL is_stylus(const char *name, const char *type)
NULL
};
- for (i = 0; tablet_stylus_whitelist[i] != NULL; i++) {
- if (name && match_token(name, tablet_stylus_whitelist[i]))
- return TRUE;
- if (type && match_token(type, tablet_stylus_whitelist[i]))
- return TRUE;
+ /* First check device type to avoid cases where name is "Pen and Eraser" and type is "ERASER" */
+ for (i=0; tablet_stylus_whitelist[i] != NULL; i++) {
+ if (type && match_token(type, tablet_stylus_whitelist[i])) {
+ return GHOST_kTabletModeStylus;
+ }
+ }
+ if (type && match_token(type, "eraser")) {
+ return GHOST_kTabletModeEraser;
+ }
+ for (i=0; tablet_stylus_whitelist[i] != NULL; i++) {
+ if (name && match_token(name, tablet_stylus_whitelist[i])) {
+ return GHOST_kTabletModeStylus;
+ }
+ }
+ if (name && match_token(name, "eraser")) {
+ return GHOST_kTabletModeEraser;
}
- return FALSE;
+ return GHOST_kTabletModeNone;
}
-static BOOL is_eraser(const char *name, const char *type)
-{
- if (name && match_token(name, "eraser"))
- return TRUE;
- if (type && match_token(type, "eraser"))
- return TRUE;
- return FALSE;
-}
-#undef BOOL
-#undef TRUE
-#undef FALSE
-/* end code copied from wine */
+/* End code copied from Wine. */
void GHOST_SystemX11::refreshXInputDevices()
{
@@ -2383,9 +2354,10 @@ void GHOST_SystemX11::refreshXInputDevices()
// printf("Tablet type:'%s', name:'%s', index:%d\n", device_type, device_info[i].name, i);
+ GHOST_TTabletMode tablet_mode = tablet_mode_from_name(device_info[i].name, device_type);
if ((m_xtablet.StylusDevice == NULL) &&
- (is_stylus(device_info[i].name, device_type) && (device_info[i].type != m_atom.TABLET)))
+ ((tablet_mode == GHOST_kTabletModeStylus) && (device_info[i].type != m_atom.TABLET)))
/* for libinput to work reliable, only lookup ValuatorClass in Tablet type:'STYLUS' */
{
// printf("\tfound stylus\n");
@@ -2423,7 +2395,7 @@ void GHOST_SystemX11::refreshXInputDevices()
}
}
else if ((m_xtablet.EraserDevice == NULL) &&
- (is_eraser(device_info[i].name, device_type)))
+ (tablet_mode == GHOST_kTabletModeEraser))
{
// printf("\tfound eraser\n");
m_xtablet.EraserID = device_info[i].id;