gmsh-TingyuanDoc  0.1
An Open-Source Timing-driven Analytical Mixed-size FPGA Placer
GamePad.h
Go to the documentation of this file.
1 // Gmsh - Copyright (C) 1997-2022 C. Geuzaine, J.-F. Remacle
2 //
3 // See the LICENSE.txt file in the Gmsh root directory for license information.
4 // Please report all issues on https://gitlab.onelab.info/gmsh/gmsh/issues.
5 //
6 // Contributed by Gilles Marckmann <gilles.marckmann@ec-nantes.fr>
7 
8 #ifndef GAMEPAD_H
9 #define GAMEPAD_H
10 
11 #define GP_RANGE 1.0
12 #define GP_DEV 16
13 #define GP_BUTTONS 32
14 #define GP_AXES 6
15 
16 #include "GmshConfig.h"
17 
18 #if defined(WIN32)
19 #include <windows.h>
20 #include <mmsystem.h>
21 #elif defined(HAVE_LINUX_JOYSTICK)
22 #include <linux/joystick.h>
23 #include <fcntl.h>
24 #define GAMEPAD_DEV "/dev/input/js0"
25 #endif
26 
27 class GamePad {
28 public:
29  bool active;
31  bool event_read;
32  double frequency;
33  GamePad();
34  ~GamePad();
35  double axe[GP_AXES];
37  bool toggle(const int _nbut);
38  int read_event();
39  void affiche();
40  int button_map[10];
41  int axe_map[8];
42 
43 private:
44  char name[256];
45 #if defined(WIN32)
46  int gamepad_fd;
47  JOYCAPS caps;
48  JOYINFOEX infoex;
49  JOYINFO info;
50  int axes;
51  int buttons;
52 #elif defined(HAVE_LINUX_JOYSTICK)
53  int gamepad_fd;
54  js_event event;
55  __u32 version;
56  __u8 axes;
57  __u8 buttons;
58 #else
59  int axes;
60  int buttons;
61 #endif
62 };
63 
64 #endif
GamePad::active
bool active
Definition: GamePad.h:29
GamePad::event_read
bool event_read
Definition: GamePad.h:31
GamePad
Definition: GamePad.h:27
GamePad::button_map
int button_map[10]
Definition: GamePad.h:40
GP_AXES
#define GP_AXES
Definition: GamePad.h:14
GamePad::read_event
int read_event()
Definition: GamePad.cpp:159
GamePad::button
bool button[GP_BUTTONS]
Definition: GamePad.h:36
GamePad::axe_map
int axe_map[8]
Definition: GamePad.h:41
GamePad::affiche
void affiche()
Definition: GamePad.cpp:231
GamePad::axes
int axes
Definition: GamePad.h:59
GamePad::~GamePad
~GamePad()
Definition: GamePad.cpp:142
GP_BUTTONS
#define GP_BUTTONS
Definition: GamePad.h:13
GamePad::axe
double axe[GP_AXES]
Definition: GamePad.h:35
GamePad::frequency
double frequency
Definition: GamePad.h:32
GamePad::toggle_status
bool toggle_status[GP_BUTTONS]
Definition: GamePad.h:30
GamePad::GamePad
GamePad()
Definition: GamePad.cpp:63
GamePad::name
char name[256]
Definition: GamePad.h:44
GamePad::buttons
int buttons
Definition: GamePad.h:60
GamePad::toggle
bool toggle(const int _nbut)
Definition: GamePad.cpp:151