Supprot new Device(G27 Racing Wheel)
[profile/ivi/ico-vic-carsimulator.git] / src / CJoyStick.h
1 /*
2  * Copyright (c) 2013, TOYOTA MOTOR CORPORATION.
3  *
4  * This program is licensed under the terms and conditions of the 
5  * Apache License, version 2.0.  The full text of the Apache License is at
6  * http://www.apache.org/licenses/LICENSE-2.0
7  *
8  */
9
10 /**
11  * @brief   Gets the value of the joystick operation
12  * @file    CJoyStick.h
13  */
14
15 #ifndef CJOYSTICK_H_
16 #define CJOYSTICK_H_
17
18 #include <fcntl.h>
19 #include <linux/joystick.h>
20 #include <stdio.h>
21 #include <unistd.h>
22 #include <string.h>
23 #include <poll.h>
24 #include <string>
25 #include <vector>
26
27 #define D_DEV_DIR_PATH      "/dev/input/"
28 #define D_DEV_NAME_PARTS_JS "js"
29 #define D_DEV_NAME_G25      "Driving Force GT"
30 #define D_DEV_NAME_G27      "G27 Racing Wheel"
31
32 class CJoyStick
33 {
34   public:
35             CJoyStick();
36     virtual ~CJoyStick();
37
38     virtual int Open();
39     virtual int Close();
40     virtual int Read(int *number, int *value);
41     virtual int ReadData();
42
43     int GetAxisCount() const;
44     int GetButtonsCount() const;
45
46     enum TYPE
47     {
48         AXIS = 0,
49         BUTTONS
50     };
51     int  deviceOpen(const std::string& dirNM, const std::string& fileParts,
52                     const std::string& deviceNM, std::string& getDevice);
53     void getDevices(const std::string& dir,
54                     const std::vector<std::string>& matching,
55                     std::vector<std::string>& filesList) const;
56     virtual bool getDeviceName(int fd, char* devNM, size_t sz);
57
58
59 protected:
60     char m_strJoyStick[64];
61     int m_nJoyStickID;
62
63     unsigned char m_ucAxes;
64     unsigned char m_ucButtons;
65     char m_strDevName[80];
66
67     fd_set m_stSet;
68     struct pollfd fds;
69 };
70
71 #endif /* CJOYSTICK_H_ */
72 /**
73  * End of File.(CJoyStick.h)
74  */