This next step uses thedefine-foreign-function macro to define an FLI function, or interface function, to be used to call theGetCursorPos function. An interface function takes its arguments, converts them into a C format, calls the foreign function, receives the return values, and converts them into a suitable Lisp format.
(fli:define-foreign-function (get-cursor-position "GetCursorPos") ((lp-point lppoint)) :result-type bool)
In this example, the defined FLI function isget-cursor-position. It takes as its argument a pointer of typelppoint, converts this to a C format, and callsGetCursorPos. It takes the return value it receives fromGetCursorPos and converts it into the FLIbool type we defined earlier.
We have now defined all the types and functions required to get the cursor position. The next step is to allocate memory for an instance of thetagPOINT structure usingfli:allocate-foreign-object. The following line of code bindslocation to a pointer that points to such an instance.
(setq location (fli:allocate-foreign-object :type 'point))
Finally, we can use our interface functionget-cursor-position to get the cursor position:
(get-cursor-position location)