Skip to content

Instantly share code, notes, and snippets.

@kairess
Created November 20, 2017 04:25
Show Gist options
  • Save kairess/454569a93eff7a8dbfb83a8de2874856 to your computer and use it in GitHub Desktop.
Save kairess/454569a93eff7a8dbfb83a8de2874856 to your computer and use it in GitHub Desktop.
// VREX_WIN Client
// 1. 변수선언
private IntPtr client;
// x,y coord;
static float x_coord;
static float y_coord;
// UI Text Content
private static String logContent = "";
// 2. DLL 함수 선언
[DllImport("VREX_WIN", EntryPoint = "CreateClient", CharSet = CharSet.Unicode)]
static extern IntPtr CreateClient();
[DllImport("VREX_WIN", EntryPoint = "RegCallback", CharSet = CharSet.Unicode)]
static extern void setCallback(IntPtr client, Callback callback);
[DllImport("VREX_WIN", EntryPoint = "Start", CharSet = CharSet.Unicode)]
static extern void startEyetrack(IntPtr client);
// 3. callback delegate 선언
delegate void Callback(float a, float b);
// 4. 콜백함수 static으로 선언
static void gazePoint(float x, float y)
{
x_coord = x + 216; // 변환식
y_coord = 1200 - y + 240; // 변환식
logContent = "raw=" + x + "," + y + ", transed=" + x_coord + "," + y_coord;
}
// Use this for initialization
private void Awake()
{
// 5. 콜백함수 생성
Callback callback = new Callback(gazePoint);
// 6. 클라이언트 생성
client = CreateClient();
// 7. 콜백 등록
setCallback(client,callback);
// 8. 시작
startEyetrack(client);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment