NSEvent有一个获取事件的方法subtype
:
获取自定义事件信息
——data1
——data2——
子类型
是否可以subtype
在不先将其转换为 NSEvent 的情况下从 CGEvent 访问它?
CGEventRef eventCG = ...;
NSEvent *eventNS = [NSEvent eventWithCGEvent:eventCG];
short subtypeNS = eventNS.subtype;
short subtypeCG = ???;
CGEvent文档提到了鼠标事件子类型,似乎与来自IOLLEvent.h
. 但是,我对查找系统定义的 CGEvents 的子类型特别感兴趣。
这些将是NX_SUBTYPE_AUX_CONTROL_BUTTONS
下面的 等或 CG 替代品。
/* sub types for mouse and move events */
#define NX_SUBTYPE_DEFAULT 0
#define NX_SUBTYPE_TABLET_POINT 1
#define NX_SUBTYPE_TABLET_PROXIMITY 2
#define NX_SUBTYPE_MOUSE_TOUCH 3
/* sub types for system defined events */
#define NX_SUBTYPE_POWER_KEY 1
#define NX_SUBTYPE_AUX_MOUSE_BUTTONS 7
/*
* NX_SUBTYPE_AUX_CONTROL_BUTTONS usage
*
* The incoming NXEvent for other mouse button down/up has event.type
* NX_SYSDEFINED and event.data.compound.subtype NX_SUBTYPE_AUX_MOUSE_BUTTONS.
* Within the event.data.compound.misc.L[0] contains bits for all the buttons
* that have changed state, and event.data.compound.misc.L[1] contains the
* current button state as a bitmask, with 1 representing down, and 0
* representing up. Bit 0 is the left button, bit one is the right button,
* bit 2 is the center button and so forth.
*/
#define NX_SUBTYPE_AUX_CONTROL_BUTTONS 8
#define NX_SUBTYPE_EJECT_KEY 10
#define NX_SUBTYPE_SLEEP_EVENT 11
#define NX_SUBTYPE_RESTART_EVENT 12
#define NX_SUBTYPE_SHUTDOWN_EVENT 13
#define NX_SUBTYPE_STICKYKEYS_ON 100
#define NX_SUBTYPE_STICKYKEYS_OFF 101
#define NX_SUBTYPE_STICKYKEYS_SHIFT 102
#define NX_SUBTYPE_STICKYKEYS_CONTROL 103
#define NX_SUBTYPE_STICKYKEYS_ALTERNATE 104
#define NX_SUBTYPE_STICKYKEYS_COMMAND 105
#define NX_SUBTYPE_STICKYKEYS_RELEASE 106
#define NX_SUBTYPE_STICKYKEYS_TOGGLEMOUSEDRIVING 107