@@ -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
@@ -810,25 +822,25 @@ static int eventtap_event_getButtonState(lua_State* L) {
810822static int eventtap_event_setProperty (lua_State* L) {
811823 CGEventRef event = *(CGEventRef*)luaL_checkudata (L, 1 , EVENT_USERDATA_TAG);
812824 CGEventField field = (CGEventField)(luaL_checkinteger (L, 2 ));
813- if ((field == kCGMouseEventPressure ) || // These fields use a double (floating point number)
825+ if ((field == kCGEventGestureScrollY ) || // These fields use a double (floating point number)
826+ (field == kCGEventGestureSwipeProgress ) ||
827+ (field == kCGEventGestureSwipeVelocityX ) ||
828+ (field == kCGEventGestureSwipeVelocityY ) ||
829+ (field == kCGEventGestureZoomDeltaX ) ||
830+ (field == kCGMouseEventPressure ) ||
814831 (field == kCGScrollWheelEventFixedPtDeltaAxis1 ) ||
815832 (field == kCGScrollWheelEventFixedPtDeltaAxis2 ) ||
816833 (field == kCGScrollWheelEventFixedPtDeltaAxis3 ) ||
817834 (field == kCGTabletEventPointPressure ) ||
818- (field == kCGTabletEventTiltX ) ||
819- (field == kCGTabletEventTiltY ) ||
820835 (field == kCGTabletEventRotation ) ||
821- (field == kCGTabletEventTangentialPressure )) {
836+ (field == kCGTabletEventTangentialPressure ) ||
837+ (field == kCGTabletEventTiltX ) ||
838+ (field == kCGTabletEventTiltY )) {
822839 double value = luaL_checknumber (L, 3 ) ;
823840 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);
830841 } else {
831- [LuaSkin logError: @" hs.eventtap.event:setProperty() - Invalid value type." ];
842+ int64_t value = (int64_t )luaL_checkinteger (L, 3 );
843+ CGEventSetIntegerValueField (event, field, value);
832844 }
833845
834846 lua_settop (L,1 ) ;
@@ -1415,13 +1427,23 @@ static void pushtypestable(lua_State* L) {
14151427// / * The constants defined in this table are as follows:
14161428// / (I) in the description indicates that this property is returned or set as an integer
14171429// / (N) in the description indicates that this property is returned or set as a number (floating point)
1430+ // / * eventGestureHIDType -- (I) The HID gesture type
1431+ // / * eventGesturePhase -- (I) Gesture phase bitfield
1432+ // / * eventGestureScrollY -- (N) Scroll gesture Y coordinate
1433+ // / * eventGestureSwipeMotion -- (I) Swipe gesture motion direction
1434+ // / * eventGestureSwipeProgress -- (N) Swipe gesture distance
1435+ // / * eventGestureSwipeVelocityX -- (N) Swipe gesture X velocity
1436+ // / * eventGestureSwipeVelocityY -- (N) Swipe gesture Y velocity
1437+ // / * eventGestureZoomDeltaX -- (N) Zoom gesture delta X
1438+ // / * eventScrollGestureFlagBits -- (I) Gesture flags
14181439// / * eventSourceGroupID -- (I) The event source Unix effective GID.
14191440// / * eventSourceStateID -- (I) The event source state ID used to create this event.
14201441// / * eventSourceUnixProcessID -- (I) The event source Unix process ID.
14211442// / * eventSourceUserData -- (I) Event source user-supplied data, up to 64 bits.
14221443// / * eventSourceUserID -- (I) The event source Unix effective UID.
14231444// / * eventTargetProcessSerialNumber -- (I) The event target process serial number. The value is a 64-bit long word.
14241445// / * eventTargetUnixProcessID -- (I) The event target Unix process ID.
1446+ // / * eventTypeField -- (I) The event type
14251447// / * eventUnacceleratedPointerMovementX -- Undocumented, assumed Integer
14261448// / * eventUnacceleratedPointerMovementY -- Undocumented, assumed Integer
14271449// / * keyboardEventAutorepeat -- (I) Non-zero when this is an autorepeat of a key-down, and zero otherwise.
@@ -1538,6 +1560,17 @@ static void pushpropertiestable(lua_State* L) {
15381560 lua_pushinteger (L, kCGMouseEventWindowUnderMousePointerThatCanHandleThisEvent ) ; lua_setfield (L, -2 , " mouseEventWindowUnderMousePointerThatCanHandleThisEvent" ) ;
15391561 lua_pushinteger (L, kCGEventUnacceleratedPointerMovementX ) ; lua_setfield (L, -2 , " eventUnacceleratedPointerMovementX" ) ;
15401562 lua_pushinteger (L, kCGEventUnacceleratedPointerMovementY ) ; lua_setfield (L, -2 , " eventUnacceleratedPointerMovementY" ) ;
1563+
1564+ lua_pushinteger (L, kCGEventGestureHIDType ) ; lua_setfield (L, -2 , " eventGestureHIDType" ) ;
1565+ lua_pushinteger (L, kCGEventGesturePhase ) ; lua_setfield (L, -2 , " eventGesturePhase" ) ;
1566+ lua_pushinteger (L, kCGEventGestureScrollY ) ; lua_setfield (L, -2 , " eventGestureScrollY" ) ;
1567+ lua_pushinteger (L, kCGEventGestureSwipeMotion ) ; lua_setfield (L, -2 , " eventGestureSwipeMotion" ) ;
1568+ lua_pushinteger (L, kCGEventGestureSwipeProgress ) ; lua_setfield (L, -2 , " eventGestureSwipeProgress" ) ;
1569+ lua_pushinteger (L, kCGEventGestureSwipeVelocityX ) ; lua_setfield (L, -2 , " eventGestureSwipeVelocityX" ) ;
1570+ lua_pushinteger (L, kCGEventGestureSwipeVelocityY ) ; lua_setfield (L, -2 , " eventGestureSwipeVelocityY" ) ;
1571+ lua_pushinteger (L, kCGEventGestureZoomDeltaX ) ; lua_setfield (L, -2 , " eventGestureZoomDeltaX" ) ;
1572+ lua_pushinteger (L, kCGEventScrollGestureFlagBits ) ; lua_setfield (L, -2 , " eventScrollGestureFlagBits" ) ;
1573+ lua_pushinteger (L, kCGSEventTypeField ) ; lua_setfield (L, -2 , " eventTypeField" ) ;
15411574}
15421575
15431576// / hs.eventtap.event.rawFlagMasks[]
0 commit comments