js_mac.cpp
Go to the documentation of this file.
1 #include <iostream>
2 #include "js.h"
3 
4 joystick::joystick(const char *dev)
5 {
6  m_fd = atoi(dev);
7  int numJoystick;
8 
9  YsJoyReaderSetUpJoystick(numJoystick,m_dev,maxNumJoystick);
10  std::cout << "numJoystick:" << numJoystick << std::endl;
11  if (m_fd >= numJoystick) {
12  m_fd = -1;
13  return;
14  }
15  YsJoyReaderLoadJoystickCalibrationInfo(numJoystick,m_dev);
16 
17  int j, nbuttons=0, naxes=0;
18  for(j=0; j<YsJoyReaderMaxNumAxis; j++){
19  if(m_dev[m_fd].axis[j].exist!=0){
20  naxes++;
21  }
22  }
23  for(j=0; j<YsJoyReaderMaxNumButton; j++){
24  if(m_dev[m_fd].button[j].exist!=0){
25  nbuttons++;
26  }
27  }
28  std::cout << "axes:" << naxes << ", buttons:" << nbuttons << std::endl;
29  m_buttons.resize(nbuttons);
30  m_axes.resize(naxes);
31 }
32 
34 {
35 }
36 
38 {
39  m_dev[m_fd].Read();
40  int j;
41  for(j=0; j<YsJoyReaderMaxNumAxis; j++){
42  if(m_dev[m_fd].axis[j].exist!=0){
43  m_axes[j] = m_dev[m_fd].axis[j].GetCalibratedValue();
44  }
45  }
46  for(j=0; j<YsJoyReaderMaxNumButton; j++){
47  if(m_dev[m_fd].button[j].exist!=0){
48  m_buttons[j] = m_dev[m_fd].button[j].value;
49  }
50  }
51  return false;
52 }
int YsJoyReaderLoadJoystickCalibrationInfo(int nJoystick, YsJoyReader joystick[])
std::vector< bool > m_buttons
Definition: js.h:21
int m_fd
Definition: js.h:19
bool readEvent()
Definition: js.cpp:40
const int YsJoyReaderMaxNumAxis
Definition: ysjoyreader.h:5
const int YsJoyReaderMaxNumButton
Definition: ysjoyreader.h:6
joystick(const char *dev)
Definition: js.cpp:10
def j(str, encoding="cp932")
~joystick()
Definition: js.cpp:33
int YsJoyReaderSetUpJoystick(int &nJoystick, YsJoyReader joystick[], int maxNumJoystick)
std::vector< float > m_axes
Definition: js.h:20


hrpsys
Author(s): AIST, Fumio Kanehiro
autogenerated on Thu May 6 2021 02:41:50