js_mac.cpp
Go to the documentation of this file.
00001 #include <iostream>
00002 #include "js.h"
00003 
00004 joystick::joystick(const char *dev)
00005 {
00006   m_fd = atoi(dev);
00007   int numJoystick;
00008   
00009   YsJoyReaderSetUpJoystick(numJoystick,m_dev,maxNumJoystick);
00010   std::cout << "numJoystick:" << numJoystick << std::endl;
00011   if (m_fd >= numJoystick) {
00012     m_fd = -1;
00013     return;
00014   }
00015   YsJoyReaderLoadJoystickCalibrationInfo(numJoystick,m_dev);
00016   
00017   int j, nbuttons=0, naxes=0; 
00018   for(j=0; j<YsJoyReaderMaxNumAxis; j++){
00019     if(m_dev[m_fd].axis[j].exist!=0){
00020       naxes++;
00021     }
00022   }
00023   for(j=0; j<YsJoyReaderMaxNumButton; j++){
00024     if(m_dev[m_fd].button[j].exist!=0){
00025       nbuttons++;
00026     }
00027   }
00028   std::cout << "axes:" << naxes << ", buttons:" << nbuttons << std::endl;
00029   m_buttons.resize(nbuttons);
00030   m_axes.resize(naxes);
00031 }
00032 
00033 joystick::~joystick()
00034 {
00035 }
00036 
00037 bool joystick::readEvent()
00038 {
00039   m_dev[m_fd].Read();
00040   int j;
00041   for(j=0; j<YsJoyReaderMaxNumAxis; j++){
00042     if(m_dev[m_fd].axis[j].exist!=0){
00043       m_axes[j] = m_dev[m_fd].axis[j].GetCalibratedValue();
00044     }
00045   }
00046   for(j=0; j<YsJoyReaderMaxNumButton; j++){
00047     if(m_dev[m_fd].button[j].exist!=0){
00048       m_buttons[j] = m_dev[m_fd].button[j].value;
00049     }
00050   }
00051   return false;
00052 }


hrpsys
Author(s): AIST, Fumio Kanehiro
autogenerated on Wed May 15 2019 05:02:18