java - Process custom device event in Eclipse RCP -


i have eclipse rcp product working keyboard , mouse. want support custom hardware in product. enable device in eclipse rcp product, have written jni code. jni code initializes device & driver (which working correctly). after calling jni method rcp application code starts receiving events in display.readanddispatch() method. don't understand is, how events widget class. swt widgets have windowproc methods handles events. these methods handles predefined events , private (package private) methods, can't event override them.

at http://www.eclipse.org/articles/article-writing%20your%20own%20widget/writing%20your%20own%20widget.htm page, in native widget section, explained adding hook windowproc method in c++ code. tried doing in following way:

jniexport jint jnicall java_com_aiit_iadss_framework_event_spacemouseeventmanager_initinternal     (jnienv *env, jobject obj, jlong hwnd )  {         fprintf(stderr, "initializing space mouse module!");          //code init device & driver          if( res > 0 )         {             //the initialization successful. setup 3d mouse event listener             wm_3dmouse = registerwindowmessage (_t("spacewaremessage00"));              //adding hook on rcp application window windowproc             oldproc = (wndproc) setwindowlongptr((hwnd) hwnd, gwlp_wndproc, (long) windowproc);         }         return res; }  lresult callback windowproc( hwnd hwnd, uint msg, wparam wparam, lparam lparam ) {     int            num;      /* number of button returned */     //sispwevent     event;    /* 3dxware event */      //sigeteventdata edata;    /* 3dxware event data */      if( msg == wm_3dmouse )     {         fprintf( stderr, "space mouse event caught!");         return (true);     }     //call windowproc handle other events     return callwindowproc( oldproc, hwnd, msg, wparam, lparam ); } 

when run above code, jvm crashes access violation code. can please me solving issue?

ok, did adding windowproc handler in java code below:

callback winproccallback = new callback( myeventprocessingclass.class, "windowproc", 4 );         myeventprocessingclass.oldwinproc = os.setwindowlongptr( shellhandle, os.gwlp_wndproc,                 winproccallback.getaddress() ); 

and windowproc method implemented as:

public static long windowproc( long hwnd, long msg, long wparam, long lparam ) {     if( msg == 'my device event id' )     {         //process & return 1;     }     return os.callwindowproc( spacemouseserviceimpl.oldwinproc, hwnd, (int) msg, wparam, lparam ); } 

this way able process custom event in code.


Comments

Popular posts from this blog

php - Wordpress website dashboard page or post editor content is not showing but front end data is showing properly -

How to get the ip address of VM and use it to configure SSH connection dynamically in Ansible -

javascript - Get parameter of GET request -