Blender V5.3
GHOST_Wintab.cc
Go to the documentation of this file.
1/* SPDX-FileCopyrightText: 2021-2023 Blender Authors
2 *
3 * SPDX-License-Identifier: GPL-2.0-or-later */
4
8
9#include "GHOST_Wintab.hh"
10
11GHOST_Wintab *GHOST_Wintab::loadWintabUnsafe(HWND hwnd)
12{
13 /* Load Wintab library if available. */
14 auto handle = unique_hmodule(::LoadLibrary("Wintab32.dll"), &::FreeLibrary);
15 if (!handle) {
16 return nullptr;
17 }
18
19 /* Get Wintab functions. */
20
21 auto info = (GHOST_WIN32_WTInfo)::GetProcAddress(handle.get(), "WTInfoA");
22 if (!info) {
23 return nullptr;
24 }
25
26 auto open = (GHOST_WIN32_WTOpen)::GetProcAddress(handle.get(), "WTOpenA");
27 if (!open) {
28 return nullptr;
29 }
30
31 auto get = (GHOST_WIN32_WTGet)::GetProcAddress(handle.get(), "WTGetA");
32 if (!get) {
33 return nullptr;
34 }
35
36 auto set = (GHOST_WIN32_WTSet)::GetProcAddress(handle.get(), "WTSetA");
37 if (!set) {
38 return nullptr;
39 }
40
41 auto close = (GHOST_WIN32_WTClose)::GetProcAddress(handle.get(), "WTClose");
42 if (!close) {
43 return nullptr;
44 }
45
46 auto packetsGet = (GHOST_WIN32_WTPacketsGet)::GetProcAddress(handle.get(), "WTPacketsGet");
47 if (!packetsGet) {
48 return nullptr;
49 }
50
51 auto queueSizeGet = (GHOST_WIN32_WTQueueSizeGet)::GetProcAddress(handle.get(), "WTQueueSizeGet");
52 if (!queueSizeGet) {
53 return nullptr;
54 }
55
56 auto queueSizeSet = (GHOST_WIN32_WTQueueSizeSet)::GetProcAddress(handle.get(), "WTQueueSizeSet");
57 if (!queueSizeSet) {
58 return nullptr;
59 }
60
61 auto enable = (GHOST_WIN32_WTEnable)::GetProcAddress(handle.get(), "WTEnable");
62 if (!enable) {
63 return nullptr;
64 }
65
66 auto overlap = (GHOST_WIN32_WTOverlap)::GetProcAddress(handle.get(), "WTOverlap");
67 if (!overlap) {
68 return nullptr;
69 }
70
71 /* Build Wintab context. */
72
73 LOGCONTEXT lc = {{0}};
74 if (!info(WTI_DEFSYSCTX, 0, &lc)) {
75 return nullptr;
76 }
77
78 Coord tablet, system;
79 extractCoordinates(lc, tablet, system);
80 modifyContext(lc);
81
82 /* The Wintab spec says we must open the context disabled if we are using cursor masks. */
83 auto hctx = unique_hctx(open(hwnd, &lc, FALSE), close);
84 if (!hctx) {
85 return nullptr;
86 }
87
88 /* Wintab provides no way to determine the maximum queue size aside from checking if attempts
89 * to change the queue size are successful. */
90 const int maxQueue = 500;
91 /* < 0 should realistically never happen, but given we cast to size_t later on better safe than
92 * sorry. */
93 int queueSize = std::max(0, queueSizeGet(hctx.get()));
94
95 while (queueSize < maxQueue) {
96 int testSize = std::min(queueSize + 16, maxQueue);
97 if (queueSizeSet(hctx.get(), testSize)) {
98 queueSize = testSize;
99 }
100 else {
101 /* From Windows Wintab Documentation for WTQueueSizeSet:
102 * "If the return value is zero, the context has no queue because the function deletes the
103 * original queue before attempting to create a new one. The application must continue
104 * calling the function with a smaller queue size until the function returns a non - zero
105 * value."
106 *
107 * In our case we start with a known valid queue size and in the event of failure roll
108 * back to the last valid queue size. The Wintab spec dates back to 16 bit Windows, thus
109 * assumes memory recently deallocated may not be available, which is no longer a practical
110 * concern. */
111 if (!queueSizeSet(hctx.get(), queueSize)) {
112 /* If a previously valid queue size is no longer valid, there is likely something wrong in
113 * the Wintab implementation and we should not use it. */
114 return nullptr;
115 }
116 break;
117 }
118 }
119
120 int sanityQueueSize = queueSizeGet(hctx.get());
121 WINTAB_PRINTF("HCTX %p %s queueSize: %d, queueSizeGet: %d\n",
122 hctx.get(),
123 __func__,
124 queueSize,
125 sanityQueueSize);
126
127 WINTAB_PRINTF("Loaded Wintab context %p\n", hctx.get());
128
129 return new GHOST_Wintab(std::move(handle),
130 info,
131 get,
132 set,
133 packetsGet,
134 enable,
135 overlap,
136 std::move(hctx),
137 tablet,
138 system,
139 size_t(queueSize));
140}
141
142static int access_violation_exception_filter(unsigned int code, LPEXCEPTION_POINTERS pointers)
143{
144 if (code == EXCEPTION_ACCESS_VIOLATION) {
145 fprintf(stderr,
146 "Error loading Wintab library: Access Violation at 0x%p: 0x%p, 0x%p\n",
147 pointers->ExceptionRecord->ExceptionAddress,
148 (void *)pointers->ExceptionRecord->ExceptionInformation[0],
149 (void *)pointers->ExceptionRecord->ExceptionInformation[1]);
150 return EXCEPTION_EXECUTE_HANDLER;
151 }
152 return EXCEPTION_CONTINUE_SEARCH;
153}
154
155GHOST_Wintab *GHOST_Wintab::loadWintab(HWND hwnd)
156{
157 /* The only way to get the current handler is by setting a new one. */
158 LPTOP_LEVEL_EXCEPTION_FILTER current_filter = SetUnhandledExceptionFilter(nullptr);
159 SetUnhandledExceptionFilter(current_filter);
160
161 /* __except and __finally cannot be used together, as such a second nested __try block is needed.
162 */
163 __try {
164 __try {
165 return GHOST_Wintab::loadWintabUnsafe(hwnd);
166 }
167 __except (access_violation_exception_filter(GetExceptionCode(), GetExceptionInformation())) {
168 }
169 }
170 __finally {
171 /* Restore our handler in case the Wintab driver replaced it. Huion's driver is known to do
172 * this.
173 */
174 SetUnhandledExceptionFilter(current_filter);
175 }
176
177 return nullptr;
178}
179
180void GHOST_Wintab::modifyContext(LOGCONTEXT &lc)
181{
182 lc.lcPktData = PACKETDATA;
183 lc.lcPktMode = PACKETMODE;
184 lc.lcMoveMask = PACKETDATA;
185 lc.lcOptions |= CXO_CSRMESSAGES | CXO_MESSAGES;
186
187 /* Tablet scaling is handled manually because some drivers don't handle HIDPI or multi-display
188 * correctly; reset tablet scale factors to un-scaled tablet coordinates. */
189 lc.lcOutOrgX = lc.lcInOrgX;
190 lc.lcOutOrgY = lc.lcInOrgY;
191 lc.lcOutExtX = lc.lcInExtX;
192 lc.lcOutExtY = lc.lcInExtY;
193}
194
195void GHOST_Wintab::extractCoordinates(LOGCONTEXT &lc, Coord &tablet, Coord &system)
196{
197 tablet.x.org = lc.lcInOrgX;
198 tablet.x.ext = lc.lcInExtX;
199 tablet.y.org = lc.lcInOrgY;
200 tablet.y.ext = lc.lcInExtY;
201
202 system.x.org = lc.lcSysOrgX;
203 system.x.ext = lc.lcSysExtX;
204 system.y.org = lc.lcSysOrgY;
205 /* Wintab maps y origin to the tablet's bottom; invert y to match Windows y origin mapping to the
206 * screen top. */
207 system.y.ext = -lc.lcSysExtY;
208}
209
210GHOST_Wintab::GHOST_Wintab(unique_hmodule handle,
214 GHOST_WIN32_WTPacketsGet packetsGet,
216 GHOST_WIN32_WTOverlap overlap,
217 unique_hctx hctx,
218 Coord tablet,
219 Coord system,
220 size_t queueSize)
221 : handle_{std::move(handle)},
222 fp_info_{info},
223 fp_get_{get},
224 fp_set_{set},
225 fp_packets_get_{packetsGet},
226 fp_enable_{enable},
227 fp_overlap_{overlap},
228 context_{std::move(hctx)},
229 tablet_coord_{tablet},
230 system_coord_{system},
231 pkts_{queueSize}
232{
233 fp_info_(WTI_INTERFACE, IFC_NDEVICES, &num_devices_);
234 WINTAB_PRINTF("Wintab Devices: %d\n", num_devices_);
235
237
238 /* Debug info. */
239 printContextDebugInfo();
240}
241
243{
244 WINTAB_PRINTF("Closing Wintab context %p\n", context_.get());
245}
246
248{
249 fp_enable_(context_.get(), true);
250 enabled_ = true;
251}
252
254{
255 if (focused_) {
256 loseFocus();
257 }
258 fp_enable_(context_.get(), false);
259 enabled_ = false;
260}
261
263{
264 fp_overlap_(context_.get(), true);
265 focused_ = true;
266}
267
269{
270 if (last_tablet_data_.Active != GHOST_kTabletModeNone) {
271 leaveRange();
272 }
273
274 /* Mouse mode of tablet or display layout may change when Wintab or Window is inactive. Don't
275 * trust for mouse movement until re-verified. */
276 coord_trusted_ = false;
277
278 fp_overlap_(context_.get(), false);
279 focused_ = false;
280}
281
283{
284 /* Button state can't be tracked while out of range, reset it. */
285 buttons_ = 0;
286 /* Set to none to indicate tablet is inactive. */
287 last_tablet_data_ = GHOST_TABLET_DATA_NONE;
288 /* Clear the packet queue. */
289 fp_packets_get_(context_.get(), pkts_.size(), pkts_.data());
290}
291
293{
294 LOGCONTEXT lc = {{0}};
295
296 if (fp_info_(WTI_DEFSYSCTX, 0, &lc)) {
297 extractCoordinates(lc, tablet_coord_, system_coord_);
298 modifyContext(lc);
299
300 fp_set_(context_.get(), &lc);
301 }
302}
303
305{
306 AXIS Pressure, Orientation[3];
307
308 BOOL pressureSupport = fp_info_(WTI_DEVICES, DVC_NPRESSURE, &Pressure);
309 max_pressure_ = pressureSupport ? Pressure.axMax : 0;
310 WINTAB_PRINTF("HCTX %p %s maxPressure: %d\n", context_.get(), __func__, max_pressure_);
311
312 BOOL tiltSupport = fp_info_(WTI_DEVICES, DVC_ORIENTATION, &Orientation);
313 /* Check if tablet supports azimuth [0] and altitude [1], encoded in axResolution. */
314 if (tiltSupport && Orientation[0].axResolution && Orientation[1].axResolution) {
315 max_azimuth_ = Orientation[0].axMax;
316 max_altitude_ = Orientation[1].axMax;
317 }
318 else {
319 max_azimuth_ = max_altitude_ = 0;
320 }
321 WINTAB_PRINTF("HCTX %p %s maxAzimuth: %d, maxAltitude: %d\n",
322 context_.get(),
323 __func__,
324 max_azimuth_,
325 max_altitude_);
326}
327
329{
330 /* Update number of connected Wintab digitizers. */
331 if (LOWORD(lParam) == WTI_INTERFACE && HIWORD(lParam) == IFC_NDEVICES) {
332 fp_info_(WTI_INTERFACE, IFC_NDEVICES, &num_devices_);
333 WINTAB_PRINTF("HCTX %p %s numDevices: %d\n", context_.get(), __func__, num_devices_);
334 }
335}
336
338{
339 return num_devices_ > 0;
340}
341
343{
344 return last_tablet_data_;
345}
346
347void GHOST_Wintab::getInput(std::vector<GHOST_WintabInfoWin32> &outWintabInfo)
348{
349 const int numPackets = fp_packets_get_(context_.get(), pkts_.size(), pkts_.data());
350 outWintabInfo.reserve(numPackets);
351
352 for (int i = 0; i < numPackets; i++) {
353 const PACKET pkt = pkts_[i];
355
356 /* % 3 for multiple devices ("DualTrack"). */
357 switch (pkt.pkCursor % 3) {
358 case 0:
359 /* Puck - processed as mouse. */
360 out.tabletData.Active = GHOST_kTabletModeNone;
361 break;
362 case 1:
363 out.tabletData.Active = GHOST_kTabletModeStylus;
364 break;
365 case 2:
366 out.tabletData.Active = GHOST_kTabletModeEraser;
367 break;
368 }
369
370 out.x = pkt.pkX;
371 out.y = pkt.pkY;
372
373 if (max_pressure_ > 0) {
374 out.tabletData.Pressure = float(pkt.pkNormalPressure) / float(max_pressure_);
375 }
376
377 if ((max_azimuth_ > 0) && (max_altitude_ > 0)) {
378 /* From the wintab spec:
379 * orAzimuth: Specifies the clockwise rotation of the cursor about the z axis through a
380 * full circular range.
381 * orAltitude: Specifies the angle with the x-y plane through a signed, semicircular range.
382 * Positive values specify an angle upward toward the positive z axis; negative values
383 * specify an angle downward toward the negative z axis.
384 *
385 * wintab.h defines orAltitude as a `uint` but documents orAltitude as positive for upward
386 * angles and negative for downward angles. WACOM uses negative altitude values to show that
387 * the pen is inverted; therefore we cast orAltitude as an `int` and then use the absolute
388 * value.
389 */
390
391 ORIENTATION ort = pkt.pkOrientation;
392
393 /* Convert raw fixed point data to radians. */
394 float altRad = float((fabs(float(ort.orAltitude)) / float(max_altitude_)) * M_PI_2);
395 float azmRad = float((float(ort.orAzimuth) / float(max_azimuth_)) * M_PI * 2.0);
396
397 /* Find length of the stylus' projected vector on the XY plane. */
398 float vecLen = cos(altRad);
399
400 /* From there calculate X and Y components based on azimuth. */
401
402 /* Blender expects: -1.0f (left) to +1.0f (right). */
403 out.tabletData.Xtilt = sin(azmRad) * vecLen;
404
405 /* Blender expects: -1.0f (away from user) to +1.0f (toward user). */
406 out.tabletData.Ytilt = -float(sin(M_PI_2 - azmRad) * vecLen);
407 }
408
409 out.time = pkt.pkTime;
410
411 /* Some Wintab libraries don't handle relative button input, so we track button presses
412 * manually. */
413 DWORD buttonsChanged = buttons_ ^ pkt.pkButtons;
414 /* We only needed the prior button state to compare to current, so we can overwrite it now. */
415 buttons_ = pkt.pkButtons;
416
417 /* Iterate over button flag indices until all flags are clear. */
418 for (WORD buttonIndex = 0; buttonsChanged; buttonIndex++, buttonsChanged >>= 1) {
419 if (buttonsChanged & 1) {
420 GHOST_TButton button = mapWintabToGhostButton(pkt.pkCursor, buttonIndex);
421
422 if (button != GHOST_kButtonMaskNone) {
423 /* If this is not the first button found, push info for the prior Wintab button. */
424 if (out.button != GHOST_kButtonMaskNone) {
425 outWintabInfo.push_back(out);
426 }
427
428 out.button = button;
429
430 DWORD buttonFlag = 1 << buttonIndex;
431 out.type = pkt.pkButtons & buttonFlag ? GHOST_kEventButtonDown : GHOST_kEventButtonUp;
432 }
433 }
434 }
435
436 outWintabInfo.push_back(out);
437 }
438
439 if (!outWintabInfo.empty()) {
440 last_tablet_data_ = outWintabInfo.back().tabletData;
441 }
442}
443
444GHOST_TButton GHOST_Wintab::mapWintabToGhostButton(uint cursor, WORD physicalButton)
445{
446 const WORD numButtons = 32;
447 BYTE logicalButtons[numButtons] = {0};
448 BYTE systemButtons[numButtons] = {0};
449
450 if (!fp_info_(WTI_CURSORS + cursor, CSR_BUTTONMAP, &logicalButtons) ||
451 !fp_info_(WTI_CURSORS + cursor, CSR_SYSBTNMAP, &systemButtons))
452 {
454 }
455
456 if (physicalButton >= numButtons) {
458 }
459
460 BYTE lb = logicalButtons[physicalButton];
461
462 if (lb >= numButtons) {
464 }
465
466 switch (systemButtons[lb]) {
467 case SBN_LCLICK:
469 case SBN_RCLICK:
471 case SBN_MCLICK:
473 default:
475 }
476}
477
478void GHOST_Wintab::mapWintabToSysCoordinates(int x_in, int y_in, int &x_out, int &y_out)
479{
480 /* Maps from range [in.org, in.org + abs(in.ext)] to [out.org, out.org + abs(out.ext)], in
481 * reverse if in.ext and out.ext have differing sign. */
482 auto remap = [](int inPoint, Range in, Range out) -> int {
483 int absInExt = abs(in.ext);
484 int absOutExt = abs(out.ext);
485
486 /* Translate input from range [in.org, in.org + absInExt] to [0, absInExt] */
487 int inMagnitude = inPoint - in.org;
488
489 /* If signs of extents differ, reverse input over range. */
490 if ((in.ext < 0) != (out.ext < 0)) {
491 inMagnitude = absInExt - inMagnitude;
492 }
493
494 /* Scale from [0, absInExt] to [0, absOutExt]. */
495 int outMagnitude = inMagnitude * absOutExt / absInExt;
496
497 /* Translate from range [0, absOutExt] to [out.org, out.org + absOutExt]. */
498 int outPoint = outMagnitude + out.org;
499
500 return outPoint;
501 };
502
503 x_out = remap(x_in, tablet_coord_.x, system_coord_.x);
504 y_out = remap(y_in, tablet_coord_.y, system_coord_.y);
505}
506
508{
509 return coord_trusted_;
510}
511
512bool GHOST_Wintab::testCoordinates(int sysX, int sysY, int wtX, int wtY)
513{
514 /* Some (faulty) drivers can report (WTInfoA) that the tablet extent is
515 * zero. This will cause divide by zero in mapWintabToSysCoordinates. #150560 */
516 if (tablet_coord_.x.ext == 0 || tablet_coord_.y.ext == 0) {
517 coord_trusted_ = false;
518 return false;
519 }
520
521 mapWintabToSysCoordinates(wtX, wtY, wtX, wtY);
522
523 /* Allow off by one pixel tolerance in case of rounding error. */
524 if (abs(sysX - wtX) <= 1 && abs(sysY - wtY) <= 1) {
525 coord_trusted_ = true;
526 return true;
527 }
528 else {
529 coord_trusted_ = false;
530 return false;
531 }
532}
533
534bool GHOST_Wintab::debug_ = false;
535
537{
538 debug_ = debug;
539}
540
542{
543 return debug_;
544}
545
546void GHOST_Wintab::printContextDebugInfo()
547{
548 if (!debug_) {
549 return;
550 }
551
552 /* Print button maps. */
553 BYTE logicalButtons[32] = {0};
554 BYTE systemButtons[32] = {0};
555 for (int i = 0; i < 3; i++) {
556 printf("initializeWintab cursor %d buttons\n", i);
557 uint lbut = fp_info_(WTI_CURSORS + i, CSR_BUTTONMAP, &logicalButtons);
558 if (lbut) {
559 printf("%d", logicalButtons[0]);
560 for (int j = 1; j < lbut; j++) {
561 printf(", %d", logicalButtons[j]);
562 }
563 printf("\n");
564 }
565 else {
566 printf("logical button error\n");
567 }
568 uint sbut = fp_info_(WTI_CURSORS + i, CSR_SYSBTNMAP, &systemButtons);
569 if (sbut) {
570 printf("%d", systemButtons[0]);
571 for (int j = 1; j < sbut; j++) {
572 printf(", %d", systemButtons[j]);
573 }
574 printf("\n");
575 }
576 else {
577 printf("system button error\n");
578 }
579 }
580
581 /* Print context information. */
582
583 /* Print open context constraints. */
584 uint maxcontexts, opencontexts;
585 fp_info_(WTI_INTERFACE, IFC_NCONTEXTS, &maxcontexts);
586 fp_info_(WTI_STATUS, STA_CONTEXTS, &opencontexts);
587 printf("%u max contexts, %u open contexts\n", maxcontexts, opencontexts);
588
589 /* Print system information. */
590 printf("left: %d, top: %d, width: %d, height: %d\n",
591 ::GetSystemMetrics(SM_XVIRTUALSCREEN),
592 ::GetSystemMetrics(SM_YVIRTUALSCREEN),
593 ::GetSystemMetrics(SM_CXVIRTUALSCREEN),
594 ::GetSystemMetrics(SM_CYVIRTUALSCREEN));
595
596 auto printContextRanges = [](LOGCONTEXT &lc) {
597 printf("lcInOrgX: %ld, lcInOrgY: %ld, lcInExtX: %ld, lcInExtY: %ld\n",
598 lc.lcInOrgX,
599 lc.lcInOrgY,
600 lc.lcInExtX,
601 lc.lcInExtY);
602 printf("lcOutOrgX: %ld, lcOutOrgY: %ld, lcOutExtX: %ld, lcOutExtY: %ld\n",
603 lc.lcOutOrgX,
604 lc.lcOutOrgY,
605 lc.lcOutExtX,
606 lc.lcOutExtY);
607 printf("lcSysOrgX: %d, lcSysOrgY: %d, lcSysExtX: %d, lcSysExtY: %d\n",
608 lc.lcSysOrgX,
609 lc.lcSysOrgY,
610 lc.lcSysExtX,
611 lc.lcSysExtY);
612 };
613
614 LOGCONTEXT lc;
615
616 /* Print system context. */
617 fp_info_(WTI_DEFSYSCTX, 0, &lc);
618 printf("WTI_DEFSYSCTX\n");
619 printContextRanges(lc);
620
621 /* Print system context, manually populated. */
622 fp_info_(WTI_DEFSYSCTX, CTX_INORGX, &lc.lcInOrgX);
623 fp_info_(WTI_DEFSYSCTX, CTX_INORGY, &lc.lcInOrgY);
624 fp_info_(WTI_DEFSYSCTX, CTX_INEXTX, &lc.lcInExtX);
625 fp_info_(WTI_DEFSYSCTX, CTX_INEXTY, &lc.lcInExtY);
626 fp_info_(WTI_DEFSYSCTX, CTX_OUTORGX, &lc.lcOutOrgX);
627 fp_info_(WTI_DEFSYSCTX, CTX_OUTORGY, &lc.lcOutOrgY);
628 fp_info_(WTI_DEFSYSCTX, CTX_OUTEXTX, &lc.lcOutExtX);
629 fp_info_(WTI_DEFSYSCTX, CTX_OUTEXTY, &lc.lcOutExtY);
630 fp_info_(WTI_DEFSYSCTX, CTX_SYSORGX, &lc.lcSysOrgX);
631 fp_info_(WTI_DEFSYSCTX, CTX_SYSORGY, &lc.lcSysOrgY);
632 fp_info_(WTI_DEFSYSCTX, CTX_SYSEXTX, &lc.lcSysExtX);
633 fp_info_(WTI_DEFSYSCTX, CTX_SYSEXTY, &lc.lcSysExtY);
634 printf("WTI_DEFSYSCTX CTX_*\n");
635 printContextRanges(lc);
636
637 for (uint i = 0; i < num_devices_; i++) {
638 /* Print individual device system context. */
639 fp_info_(WTI_DSCTXS + i, 0, &lc);
640 printf("WTI_DSCTXS %u\n", i);
641 printContextRanges(lc);
642
643 /* Print individual device system context, manually populated. */
644 fp_info_(WTI_DSCTXS + i, CTX_INORGX, &lc.lcInOrgX);
645 fp_info_(WTI_DSCTXS + i, CTX_INORGY, &lc.lcInOrgY);
646 fp_info_(WTI_DSCTXS + i, CTX_INEXTX, &lc.lcInExtX);
647 fp_info_(WTI_DSCTXS + i, CTX_INEXTY, &lc.lcInExtY);
648 fp_info_(WTI_DSCTXS + i, CTX_OUTORGX, &lc.lcOutOrgX);
649 fp_info_(WTI_DSCTXS + i, CTX_OUTORGY, &lc.lcOutOrgY);
650 fp_info_(WTI_DSCTXS + i, CTX_OUTEXTX, &lc.lcOutExtX);
651 fp_info_(WTI_DSCTXS + i, CTX_OUTEXTY, &lc.lcOutExtY);
652 fp_info_(WTI_DSCTXS + i, CTX_SYSORGX, &lc.lcSysOrgX);
653 fp_info_(WTI_DSCTXS + i, CTX_SYSORGY, &lc.lcSysOrgY);
654 fp_info_(WTI_DSCTXS + i, CTX_SYSEXTX, &lc.lcSysExtX);
655 fp_info_(WTI_DSCTXS + i, CTX_SYSEXTY, &lc.lcSysExtY);
656 printf("WTI_DSCTX %u CTX_*\n", i);
657 printContextRanges(lc);
658
659 /* Print device axis. */
660 AXIS axis_x, axis_y;
661 fp_info_(WTI_DEVICES + i, DVC_X, &axis_x);
662 fp_info_(WTI_DEVICES + i, DVC_Y, &axis_y);
663 printf("WTI_DEVICES %u axis_x org: %ld, axis_y org: %ld axis_x ext: %ld, axis_y ext: %ld\n",
664 i,
665 axis_x.axMin,
666 axis_y.axMin,
667 axis_x.axMax - axis_x.axMin + 1,
668 axis_y.axMax - axis_y.axMin + 1);
669 }
670
671 /* Other stuff while we have a log-context. */
672 printf("sysmode %d\n", lc.lcSysMode);
673}
#define M_PI_2
#define M_PI
@ GHOST_kEventButtonUp
@ GHOST_kEventButtonDown
@ GHOST_kTabletModeEraser
@ GHOST_kTabletModeStylus
@ GHOST_kTabletModeNone
GHOST_TButton
@ GHOST_kButtonMaskRight
@ GHOST_kButtonMaskNone
@ GHOST_kButtonMaskLeft
@ GHOST_kButtonMaskMiddle
static int access_violation_exception_filter(unsigned int code, LPEXCEPTION_POINTERS pointers)
BOOL(API *) GHOST_WIN32_WTOverlap(HCTX, BOOL)
BOOL(API *) GHOST_WIN32_WTGet(HCTX, LPLOGCONTEXTA)
#define PACKETMODE
std::unique_ptr< std::remove_pointer_t< HCTX >, GHOST_WIN32_WTClose > unique_hctx
HCTX(API *) GHOST_WIN32_WTOpen(HWND, LPLOGCONTEXTA, BOOL)
BOOL(API *) GHOST_WIN32_WTClose(HCTX)
BOOL(API *) GHOST_WIN32_WTQueueSizeSet(HCTX, int)
#define WINTAB_PRINTF(x,...)
#define PACKETDATA
std::unique_ptr< std::remove_pointer_t< HMODULE >, decltype(&::FreeLibrary)> unique_hmodule
int(API *) GHOST_WIN32_WTPacketsGet(HCTX, int, LPVOID)
BOOL(API *) GHOST_WIN32_WTEnable(HCTX, BOOL)
int(API *) GHOST_WIN32_WTQueueSizeGet(HCTX)
BOOL(API *) GHOST_WIN32_WTSet(HCTX, LPLOGCONTEXTA)
UINT(API *) GHOST_WIN32_WTInfo(UINT, UINT, LPVOID)
void mapWintabToSysCoordinates(int x_in, int y_in, int &x_out, int &y_out)
GHOST_TabletData getLastTabletData()
bool devicesPresent()
void getInput(std::vector< GHOST_WintabInfoWin32 > &outWintabInfo)
void processInfoChange(LPARAM lParam)
void updateCursorInfo()
void remapCoordinates()
static GHOST_Wintab * loadWintab(HWND hwnd)
bool trustCoordinates()
static bool getDebug()
bool testCoordinates(int sysX, int sysY, int wtX, int wtY)
static void setDebug(bool debug)
#define printf
#define sin
#define cos
#define abs
ccl_device_inline dual3 fabs(const ccl_private dual3 &a)
Definition math_dual.h:241
std::shared_ptr< const T > get(const GenericKey &key, FunctionRef< std::unique_ptr< T >()> compute_fn)
unsigned int uint
Definition BKE_text.h:55
KERNEL_FEATURE_LIGHT_PASSES KERNEL_FEATURE_PATH_GUIDING float