Main Page   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Namespace Members   Compound Members   File Members   Related Pages  

P_VRPNButtons.C

Go to the documentation of this file.
00001 /***************************************************************************
00002  *cr                                                                       
00003  *cr            (C) Copyright 1995-2019 The Board of Trustees of the           
00004  *cr                        University of Illinois                       
00005  *cr                         All Rights Reserved                        
00006  *cr                                                                   
00007  ***************************************************************************/
00008 
00009 /***************************************************************************
00010  * RCS INFORMATION:
00011  *
00012  *      $RCSfile: P_VRPNButtons.C,v $
00013  *      $Author: johns $        $Locker:  $             $State: Exp $
00014  *      $Revision: 1.28 $       $Date: 2019/01/17 21:21:01 $
00015  *
00016  ***************************************************************************
00017  * DESCRIPTION:
00018  * This is Paul's new Tracker code -- pgrayson@ks.uiuc.edu
00019  *
00020  *
00021  ***************************************************************************/
00022 
00023 #if defined(VMDVRPN)
00024 
00025 #include "P_VRPNButtons.h"
00026 #include "vrpn_Tracker.h"
00027 #include "utilities.h"
00028 
00029 /* Newer revs of VRPN require a calling convention macro */
00030 #if !defined(VRPN_CALLBACK)
00031 #define VRPN_CALLBACK 
00032 #endif
00033 
00034 /*** VRPN Event Handler Function ***/
00035 static void VRPN_CALLBACK handle_vrpn_button(void *userdata, const vrpn_BUTTONCB b) {
00036   int *stat = (int *)userdata;
00037   stat[b.button] = b.state;
00038 }
00039 
00040 VRPNButtons::VRPNButtons() {
00041   btn = NULL;
00042 }
00043 
00044 int VRPNButtons::do_start(const SensorConfig *config) {
00045   if (btn) return 0;
00046   char myUSL[100];
00047   config->make_vrpn_address(myUSL);
00048   btn = new vrpn_Button_Remote(myUSL);
00049   btn->register_change_handler(stat, handle_vrpn_button);
00050   return 1;
00051 }
00052 
00053 void VRPNButtons::update() {
00054   btn->mainloop();
00055 }
00056 
00057 VRPNButtons::~VRPNButtons(void) {
00058   if(btn) {
00059     //    btn->unregister_change_handler(&mycon->buttondata,handle_vrpn_button);
00060     //    delete btn; // VRPN has broken destructors
00061   }
00062 }
00063 
00064 #endif
00065 

Generated on Fri Oct 11 02:44:28 2024 for VMD (current) by doxygen1.2.14 written by Dimitri van Heesch, © 1997-2002