2013-03-05 4 views
25

나는 창문에서 작업하지만 여기 맥에서 붙어있다. Canon SDK가 있고 그 위에 JNA 래퍼를 만들었습니다. Windows에서 잘 작동하며 Mac에서 도움이 필요합니다. sdk에는 콜백 함수를 등록 할 수있는 함수가 있습니다. 기본적으로 카메라에서 이벤트가 발생하면 콜백 함수를 호출합니다. 창에OS에서 이벤트 가져 오기

는, 등록 후, 나는 이벤트를 얻을 User32을 사용하고하여 이벤트를 전달해야합니다 API에서

private static final User32 lib = User32.INSTANCE; 
boolean hasMessage = lib.PeekMessage(msg, null, 0, 0, 1); // peek and remove 
if(hasMessage){ 
    lib.TranslateMessage(msg); 
    lib.DispatchMessage(msg); //message gets dispatched and hence the callback function is called 
} 

, 나는 맥에서 비슷한 클래스를 찾을 수 없습니다. 나는 이것에 대해 어떻게 가야합니까 ??

추 신 : 유닉스 용 JNAapi은 광범위하며 어떤 것을 찾아야할지 모르겠습니다. reference 도움이

+0

GCEventRef, https://developer.apple.com/library/mac/documentation/Carbon/Reference/QuartzEventServicesRef/Reference/reference .html –

+0

유닉스를위한 JNA의 플랫폼 매핑의 대부분은 X11을위한 것이며, OS X에 대해서는 그다지 구체적이지 않습니다. [Rococoa] (http://code.google.com/p/rococoa/)는 훨씬 더 많은 것을 가지고 있습니다 OS X 매핑의 – technomage

+0

@technomage 이제 코드를 다시 작성해야하기 때문에 Rococoa로 이동할 수 없습니다. Windows는 이미 잘 작동합니다. 메시지를 얻으려면 약간의 기술이 필요합니다. – Jatin

답변

3

이 솔루션은 코코아 프레임 워크를 사용하고 있습니다. 코코아는 더 이상 사용되지 않으며 다른 대체 솔루션에 대해서는 알지 못합니다. 그러나 아래는 매력과 같습니다.

마지막으로 나는 Carbon 프레임 워크를 사용하여 해결책을 찾았습니다. 여기 내 MCarbon 인터페이스는 내가 필요한 호출을 정의합니다.

public interface MCarbon extends Library { 
    MCarbon INSTANCE = (MCarbon) Native.loadLibrary("Carbon", MCarbon.class); 
    Pointer GetCurrentEventQueue(); 
    int SendEventToEventTarget(Pointer inEvent, Pointer intarget); 
    int RemoveEventFromQueue(Pointer inQueue, Pointer inEvent); 
    void ReleaseEvent(Pointer inEvent); 
    Pointer AcquireFirstMatchingEventInQueue(Pointer inQueue,NativeLong inNumTypes,EventTypeSpec[] inList, NativeLong inOptions); 
    //... so on 
    } 

문제에 대한 해결책은 아래의 기능을 사용하여 해결된다 :

NativeLong ReceiveNextEvent(NativeLong inNumTypes, EventTypeSpec[] inList, double inTimeout, byte inPullEvent, Pointer outEvent); 

이 작업을 수행합니다. 문서에 따라 - 또한

This routine tries to fetch the next event of a specified type. 
If no events in the event queue match, this routine will run the 
current event loop until an event that matches arrives, or the 
timeout expires. Except for timers firing, your application is 
blocked waiting for events to arrive when inside this function. 

하지 ReceiveNextEvent 경우, MCarbon 클래스에서 언급 한 바와 같이 다음 다른 기능은 위 유용 할 것이다.

Carbon 프레임 워크 documentation은 문제를 해결하는 데 더 많은 통찰력과 유연성을 제공한다고 생각합니다. Carbon 외에도 공개 토론에서 사람들은 Cocoa을 사용하여 해결에 대해 언급했지만 아무도 알고 있지 않습니다.

편집 : technomarge 덕분에, 자세한 내용은 당신은 아마 체크 아웃 할 것이다 here

+0

차가움. 너무 나쁜 카본은 사용되지 않습니다. –

+0

@AmigableClarkKant 다른 대안이 있습니까? – Jatin

+0

죄송합니다. 아는 것은 아닙니다. (그러나있을 수 있습니다.) –

관련 문제