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
, andTouchRing
. 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:
- Create a context for the tablet of interest.
- Register with the distributed notification center to receive the overridden controls’ data from user actions.
- Query for number of controls by control type (ExpressKeys, TouchStrip, > or TouchRing).
- Query for number of functions of each control.
- Enumerate the functions to find out which are available for override.
- Set override flag for a control function that’s available.
- Handle the control data notifications to implement functionality that the application desires for the control function.
- 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 thekeyAEObjectClass
Param of the Apple Event filled with aDescType
ofcContext
, thekeyAEInsertHere
Param filled with an object specifier of the index of the tablet (cWTDTablet
) and thekeyASPrepositionFor
Param filled with a DescType ofpContextTypeBlank
.To destroy a context, send to the Tablet Driver an Apple Event of class / Type {
kAECore
,kAEDelete
} with thekeyDirect
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.)
精彩评论