Need help with getting data from a DllCall. I'm bad at programming

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
tqphan
Posts: 26
Joined: 04 Mar 2019, 14:44

Need help with getting data from a DllCall. I'm bad at programming

31 Oct 2020, 15:18

I'm making a DllCall to a function that requires a callback. The signature of the callback is as followed:

Code: Select all

typedef void (*tobii_gaze_point_callback_t)( tobii_gaze_point_t const* gaze_point, void* user_data );
So the two parameters for the callback are a pointer to a structure and another pointer to whatever that won't be used. I need the data from the first parameter. The structure is defined as follows:

Code: Select all

typedef struct tobii_gaze_point_t 
{
    int64_t timestamp_us;
    tobii_validity_t validity;
    float position_xy[ 2 ];
} tobii_gaze_point_t;
The first member of the structure is a "long long" which is an int64. The second member of the structure is an enum which is just an int (I think). The final member of the structure an array of 2 floats.



I register the callback with

Code: Select all

gaze_point_callback_address := RegisterCallback("gaze_point_callback", "Fast", 2)
.

I successfully call the dll and registered my callback and my callback function is being called. I'm having trouble extracting the data given to me.

My AHK callback fuction is as followed:

Code: Select all

gaze_point_callback(gaze_point, user_data)
{
    time_stamp := NumGet(gaze_point, 0, "Int64")
    validity := NumGet(gaze_point, 4, "Int")
    OutputDebug, %time_stamp%
}
I'm getting garbage numbers that doesn't make sense. Am I extracting data incorrectly? Also I am unsure how to extract the 2 floats. Please help !
teadrinker
Posts: 4412
Joined: 29 Mar 2015, 09:41
Contact:

Re: Need help with getting data from a DllCall. I'm bad at programming

31 Oct 2020, 16:10

If gaze_point is a pointer, should be

Code: Select all

gaze_point_callback(gaze_point, user_data)
{
    time_stamp := NumGet(gaze_point + 0, "Int64")
    validity := NumGet(gaze_point + 8, "Int")
    OutputDebug, %time_stamp%
}
tqphan
Posts: 26
Joined: 04 Mar 2019, 14:44

Re: Need help with getting data from a DllCall. I'm bad at programming

31 Oct 2020, 16:16

Thank you, sir! I'm getting the numbers that expected now.

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: peter_ahk and 336 guests