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: SpaceballButtons.C,v $ 00013 * $Author: johns $ $Locker: $ $State: Exp $ 00014 * $Revision: 1.5 $ $Date: 2019年01月17日 21:21:01 $ 00015 * 00016 ***************************************************************************/ 00017 00018 #include "VMDApp.h" 00019 #include "ResizeArray.h" 00020 #include "P_Buttons.h" 00021 #include "SpaceballButtons.h" 00022 #include "Inform.h" 00023 00024 SpaceballButtons::SpaceballButtons(VMDApp *vmdapp) { 00025 app = vmdapp; 00026 numButtons = 31; 00027 } 00028 00029 int SpaceballButtons::do_start(const SensorConfig *) { 00030 msgInfo << "Opening VMD console Spaceball device (buttons)." << sendmsg; 00031 return 1; 00032 } 00033 00034 void SpaceballButtons::update() { 00035 float tx, ty, tz, rx, ry, rz; 00036 tx=ty=tz=rx=ry=rz=0.0f; 00037 int buttons; 00038 buttons=0; 00039 00040 // query VMDApp spaceball for events 00041 if (app != NULL) { 00042 app->spaceball_get_tracker_status(tx, ty, tz, rx, ry, rz, buttons); 00043 } 00044 00045 stat[0] = 0; 00046 for(int i = 0; i < numButtons; i++) { 00047 stat[i] = (buttons >> i) & 1; 00048 stat[0] |= (buttons >> i) & 1; 00049 } 00050 } 00051