forked from panda3d/panda3d
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathevdevInputDevice.h
More file actions
98 lines (78 loc) · 2.24 KB
/
evdevInputDevice.h
File metadata and controls
98 lines (78 loc) · 2.24 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
/**
* PANDA 3D SOFTWARE
* Copyright (c) Carnegie Mellon University. All rights reserved.
*
* All use of this software is subject to the terms of the revised BSD
* license. You should have received a copy of this license along
* with this source code in a file named "LICENSE."
*
* @file evdevInputDevice.h
* @author rdb
* @date 2015-08-24
*/
#ifndef EVDEVINPUTDEVICE_H
#define EVDEVINPUTDEVICE_H
#include "inputDevice.h"
#ifdef PHAVE_LINUX_INPUT_H
class LinuxInputDeviceManager;
/**
* This is a type of device that uses the Linux /dev/input/event# API to read
* data from a raw mouse or other input device. Unlike the joystick API, the
* evdev API supports sending force feedback (ie. rumble) events.
*
* @since 1.10.0
*/
class EXPCL_PANDA_DEVICE EvdevInputDevice : public InputDevice {
public:
EvdevInputDevice(LinuxInputDeviceManager *manager, size_t index);
virtual ~EvdevInputDevice();
bool reactivate_steam_controller();
private:
virtual void do_set_vibration(double strong, double weak);
virtual void do_poll();
bool init_device();
bool process_events();
private:
LinuxInputDeviceManager *_manager;
int _fd;
int _quirks;
size_t _index;
bool _can_write;
int _ff_id;
bool _ff_playing;
int _ff_strong;
int _ff_weak;
pvector<int> _axis_indices;
pvector<int> _button_indices;
// These are used for D-pad emulation.
int _dpad_x_axis;
int _dpad_y_axis;
int _dpad_left_button;
int _dpad_up_button;
// This is used for axis emulation.
int _ltrigger_axis;
int _ltrigger_code;
int _rtrigger_code;
public:
static ButtonHandle map_button(int code,
DeviceClass device_class = DeviceClass::unknown,
int quirks = 0);
public:
static TypeHandle get_class_type() {
return _type_handle;
}
static void init_type() {
InputDevice::init_type();
register_type(_type_handle, "EvdevInputDevice",
InputDevice::get_class_type());
}
virtual TypeHandle get_type() const {
return get_class_type();
}
virtual TypeHandle force_init_type() {init_type(); return get_class_type();}
private:
static TypeHandle _type_handle;
};
#include "evdevInputDevice.I"
#endif // PHAVE_LINUX_INPUT_H
#endif // EVDEVINPUTDEVICE_H