@@ -793,6 +793,18 @@ static int eventtap_event_getButtonState(lua_State* L) {
793793 return 1 ;
794794}
795795
796+ // Undocumented event fields
797+ static const CGEventField kCGEventGestureHIDType = (CGEventField)110 ;
798+ static const CGEventField kCGEventGesturePhase = (CGEventField)132 ;
799+ static const CGEventField kCGEventGestureScrollY = (CGEventField)119 ;
800+ static const CGEventField kCGEventGestureSwipeMotion = (CGEventField)123 ;
801+ static const CGEventField kCGEventGestureSwipeProgress = (CGEventField)124 ;
802+ static const CGEventField kCGEventGestureSwipeVelocityX = (CGEventField)129 ;
803+ static const CGEventField kCGEventGestureSwipeVelocityY = (CGEventField)130 ;
804+ static const CGEventField kCGEventGestureZoomDeltaX = (CGEventField)139 ;
805+ static const CGEventField kCGEventScrollGestureFlagBits = (CGEventField)135 ;
806+ static const CGEventField kCGSEventTypeField = (CGEventField)55 ;
807+
796808// / hs.eventtap.event:setProperty(prop, value)
797809// / Method
798810// / Sets a property of the event
@@ -806,29 +818,28 @@ static int eventtap_event_getButtonState(lua_State* L) {
806818// /
807819// / Notes:
808820// / * The properties are `CGEventField` values, as documented at https://developer.apple.com/library/mac/documentation/Carbon/Reference/QuartzEventServicesRef/index.html#//apple_ref/c/tdef/CGEventField
809- // / * Integer values use `CGEventSetIntegerValueField` and number values use `CGEventSetDoubleValueField`.
810821static int eventtap_event_setProperty (lua_State* L) {
811822 CGEventRef event = *(CGEventRef*)luaL_checkudata (L, 1 , EVENT_USERDATA_TAG);
812823 CGEventField field = (CGEventField)(luaL_checkinteger (L, 2 ));
813- if ((field == kCGMouseEventPressure ) || // These fields use a double (floating point number)
824+ if ((field == kCGEventGestureScrollY ) || // These fields use a double (floating point number)
825+ (field == kCGEventGestureSwipeProgress ) ||
826+ (field == kCGEventGestureSwipeVelocityX ) ||
827+ (field == kCGEventGestureSwipeVelocityY ) ||
828+ (field == kCGEventGestureZoomDeltaX ) ||
829+ (field == kCGMouseEventPressure ) ||
814830 (field == kCGScrollWheelEventFixedPtDeltaAxis1 ) ||
815831 (field == kCGScrollWheelEventFixedPtDeltaAxis2 ) ||
816832 (field == kCGScrollWheelEventFixedPtDeltaAxis3 ) ||
817833 (field == kCGTabletEventPointPressure ) ||
818- (field == kCGTabletEventTiltX ) ||
819- (field == kCGTabletEventTiltY ) ||
820834 (field == kCGTabletEventRotation ) ||
821- (field == kCGTabletEventTangentialPressure )) {
835+ (field == kCGTabletEventTangentialPressure ) ||
836+ (field == kCGTabletEventTiltX ) ||
837+ (field == kCGTabletEventTiltY )) {
822838 double value = luaL_checknumber (L, 3 ) ;
823839 CGEventSetDoubleValueField (event, field, value);
824- } else if (lua_isinteger (L, 3 )) {
825- int64_t value = (int64_t )lua_tointeger (L, 3 );
826- CGEventSetIntegerValueField (event, field, value);
827- } else if (lua_isnumber (L, 3 )) {
828- double value = lua_tonumber (L, 3 ) ;
829- CGEventSetDoubleValueField (event, field, value);
830840 } else {
831- [LuaSkin logError: @" hs.eventtap.event:setProperty() - Invalid value type." ];
841+ int64_t value = (int64_t )luaL_checkinteger (L, 3 );
842+ CGEventSetIntegerValueField (event, field, value);
832843 }
833844
834845 lua_settop (L,1 ) ;
@@ -1415,13 +1426,23 @@ static void pushtypestable(lua_State* L) {
14151426// / * The constants defined in this table are as follows:
14161427// / (I) in the description indicates that this property is returned or set as an integer
14171428// / (N) in the description indicates that this property is returned or set as a number (floating point)
1429+ // / * eventGestureHIDType -- (I) The HID gesture type
1430+ // / * eventGesturePhase -- (I) Gesture phase bitfield
1431+ // / * eventGestureScrollY -- (N) Scroll gesture Y coordinate
1432+ // / * eventGestureSwipeMotion -- (I) Swipe gesture motion direction
1433+ // / * eventGestureSwipeProgress -- (N) Swipe gesture distance
1434+ // / * eventGestureSwipeVelocityX -- (N) Swipe gesture X velocity
1435+ // / * eventGestureSwipeVelocityY -- (N) Swipe gesture Y velocity
1436+ // / * eventGestureZoomDeltaX -- (N) Zoom gesture delta X
1437+ // / * eventScrollGestureFlagBits -- (I) Gesture flags
14181438// / * eventSourceGroupID -- (I) The event source Unix effective GID.
14191439// / * eventSourceStateID -- (I) The event source state ID used to create this event.
14201440// / * eventSourceUnixProcessID -- (I) The event source Unix process ID.
14211441// / * eventSourceUserData -- (I) Event source user-supplied data, up to 64 bits.
14221442// / * eventSourceUserID -- (I) The event source Unix effective UID.
14231443// / * eventTargetProcessSerialNumber -- (I) The event target process serial number. The value is a 64-bit long word.
14241444// / * eventTargetUnixProcessID -- (I) The event target Unix process ID.
1445+ // / * eventTypeField -- (I) The event type
14251446// / * eventUnacceleratedPointerMovementX -- Undocumented, assumed Integer
14261447// / * eventUnacceleratedPointerMovementY -- Undocumented, assumed Integer
14271448// / * keyboardEventAutorepeat -- (I) Non-zero when this is an autorepeat of a key-down, and zero otherwise.
@@ -1538,6 +1559,17 @@ static void pushpropertiestable(lua_State* L) {
15381559 lua_pushinteger (L, kCGMouseEventWindowUnderMousePointerThatCanHandleThisEvent ) ; lua_setfield (L, -2 , " mouseEventWindowUnderMousePointerThatCanHandleThisEvent" ) ;
15391560 lua_pushinteger (L, kCGEventUnacceleratedPointerMovementX ) ; lua_setfield (L, -2 , " eventUnacceleratedPointerMovementX" ) ;
15401561 lua_pushinteger (L, kCGEventUnacceleratedPointerMovementY ) ; lua_setfield (L, -2 , " eventUnacceleratedPointerMovementY" ) ;
1562+
1563+ lua_pushinteger (L, kCGEventGestureHIDType ) ; lua_setfield (L, -2 , " eventGestureHIDType" ) ;
1564+ lua_pushinteger (L, kCGEventGesturePhase ) ; lua_setfield (L, -2 , " eventGesturePhase" ) ;
1565+ lua_pushinteger (L, kCGEventGestureScrollY ) ; lua_setfield (L, -2 , " eventGestureScrollY" ) ;
1566+ lua_pushinteger (L, kCGEventGestureSwipeMotion ) ; lua_setfield (L, -2 , " eventGestureSwipeMotion" ) ;
1567+ lua_pushinteger (L, kCGEventGestureSwipeProgress ) ; lua_setfield (L, -2 , " eventGestureSwipeProgress" ) ;
1568+ lua_pushinteger (L, kCGEventGestureSwipeVelocityX ) ; lua_setfield (L, -2 , " eventGestureSwipeVelocityX" ) ;
1569+ lua_pushinteger (L, kCGEventGestureSwipeVelocityY ) ; lua_setfield (L, -2 , " eventGestureSwipeVelocityY" ) ;
1570+ lua_pushinteger (L, kCGEventGestureZoomDeltaX ) ; lua_setfield (L, -2 , " eventGestureZoomDeltaX" ) ;
1571+ lua_pushinteger (L, kCGEventScrollGestureFlagBits ) ; lua_setfield (L, -2 , " eventScrollGestureFlagBits" ) ;
1572+ lua_pushinteger (L, kCGSEventTypeField ) ; lua_setfield (L, -2 , " eventTypeField" ) ;
15411573}
15421574
15431575// / hs.eventtap.event.rawFlagMasks[]
0 commit comments