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

P_JoystickButtons.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_JoystickButtons.C,v $
00013  *      $Author: johns $        $Locker:  $             $State: Exp $
00014  *      $Revision: 1.18 $       $Date: 2019/01/17 21:21:00 $
00015  *
00016  ***************************************************************************
00017  * DESCRIPTION:
00018  * This is Paul's new Tracker code -- pgrayson@ks.uiuc.edu
00019  *
00020  *
00021  ***************************************************************************/
00022 
00023 #ifdef WINGMAN
00024 
00025 #include <stdio.h>
00026 #include "Inform.h"
00027 #include "ResizeArray.h"
00028 
00029 extern "C" {
00030 #include "wingforce.h"
00031 }
00032 #include "P_Buttons.h"
00033 #include "P_JoystickButtons.h"
00034 
00035 JoystickButtons::JoystickButtons() {
00036   joy = NULL;
00037 }
00038 
00039 int JoystickButtons::do_start(const SensorConfig *config) {
00040   if (joy) return 0;
00041   const char *name = config->getname();
00042   char joyname[100];
00043   if(name[0]!='/') snprintf(joyname,100,"/%s",name);
00044   else snprintf(joyname,100,"%s",name);
00045   fprintf(stderr,"Opening joystick: %s\n",joyname);
00046   joy = joy_open(joyname);
00047   return (joy != NULL);
00048 }
00049 
00050 JoystickButtons::~JoystickButtons() {
00051   joy_close(joy);
00052 }
00053 
00054 void JoystickButtons::update() {
00055   int x, y, t, hat, buttons;
00056   int i;
00057 
00058   if(joy==NULL) return;
00059 
00060   joy_getstatus(joy, &x, &y, &t, &hat, &buttons);
00061   
00062   for(i=0;i<MAX_BUTTONS;i++) {
00063     stat[i] = buttons%2;
00064     buttons >>= 1;
00065   }
00066 }
00067 
00068 #endif //WINGMAN

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