开发者

Detect if user presses button on a Wacom tablet

开发者 https://www.devze.com 2023-01-14 06:13 出处:网络
I was wondering if it is possible in Cocoa/Carbon to detect whether a key combination (e. g. Ctrl + Z) comes from a Wacom button or the keyboard itself.

I was wondering if it is possible in Cocoa/Carbon to detect whether a key combination (e. g. Ctrl + Z) comes from a Wacom button or the keyboard itself.

T开发者_Go百科hanks best xonic


I can only assume a Wacom tablet's driver is faking keyboard events that are bound to specific buttons. If this is the case, I don't think you'll be able to distinguish them as -pointingDeviceID, -tabletID, and friends are only valid for mouse events (which a keyboard event - faked or real - is not).


For the "Express Keys", Wacom provides custom events with the driver version 6.1+

From the Wacom developer docs:

WacomTabletDriver version 6.1.0 provides a set of Apple Events that enable applications to take control of tablet controls. There are three types of tablet controls: ExpressKeys, TouchStrip, and TouchRing. Each control has one or more functions associated with it. Do not make assumption of the number of controls of a specific tablet or the number of functions associated with a control. Always use the APIs to query for the information.

An application needs to do the following to override tablet controls:

  1. Create a context for the tablet of interest.
  2. Register with the distributed notification center to receive the overridden controls’ data from user actions.
  3. Query for number of controls by control type (ExpressKeys, TouchStrip, > or TouchRing).
  4. Query for number of functions of each control.
  5. Enumerate the functions to find out which are available for override.
  6. Set override flag for a control function that’s available.
  7. Handle the control data notifications to implement functionality that the application desires for the control function.
  8. Must destroy the context upon the application’s termination or when the application is done with it.

To create an override context for a tablet, send to the Tablet Driver an Apple Event of class / type {kAECoreSuite, kAECreateElement} with the keyAEObjectClass Param of the Apple Event filled with a DescType of cContext, the keyAEInsertHere Param filled with an object specifier of the index of the tablet (cWTDTablet) and the keyASPrepositionFor Param filled with a DescType of pContextTypeBlank.

To destroy a context, send to the Tablet Driver an Apple Event of class / Type {kAECore, kAEDelete} with the keyDirect Apple Event Parameter filled with an object specifier of the context’s (cContext) uniqueID (formUniqueID).

Most of this only makes sense in context of the documentation page where lots of C structs and helper functions are defined for both Carbon and Cocoa. (This particular part in the docs is pretty far down.)

0

精彩评论

暂无评论...
验证码 换一张
取 消