Panda3D
Loading...
Searching...
No Matches
evdevInputDevice.h
Go to the documentation of this file.
1/**
2 * PANDA 3D SOFTWARE
3 * Copyright (c) Carnegie Mellon University. All rights reserved.
4 *
5 * All use of this software is subject to the terms of the revised BSD
6 * license. You should have received a copy of this license along
7 * with this source code in a file named "LICENSE."
8 *
9 * @file evdevInputDevice.h
10 * @author rdb
11 * @date 2015-08-24
12 */
13
14#ifndef EVDEVINPUTDEVICE_H
15#define EVDEVINPUTDEVICE_H
16
17#include "inputDevice.h"
18
19#ifdef PHAVE_LINUX_INPUT_H
20
21class LinuxInputDeviceManager;
22
23/**
24 * This is a type of device that uses the Linux /dev/input/event# API to read
25 * data from a raw mouse or other input device. Unlike the joystick API, the
26 * evdev API supports sending force feedback (ie. rumble) events.
27 *
28 * @since 1.10.0
29 */
30class EXPCL_PANDA_DEVICE EvdevInputDevice : public InputDevice {
31public:
32 EvdevInputDevice(LinuxInputDeviceManager *manager, size_t index);
33 virtual ~EvdevInputDevice();
34
35 bool reactivate_steam_controller();
36
37private:
38 virtual void do_set_vibration(double strong, double weak);
39 virtual void do_poll();
40
41 bool init_device();
42 bool process_events();
43
44private:
45 LinuxInputDeviceManager *_manager;
46
47 int _fd;
48 int _quirks;
49 size_t _index;
50
51 bool _can_write;
52 int _ff_id;
53 bool _ff_playing;
54 int _ff_strong;
55 int _ff_weak;
56
57 pvector<int> _axis_indices;
58 pvector<int> _button_indices;
59
60 // These are used for D-pad emulation.
61 int _dpad_x_axis;
62 int _dpad_y_axis;
63 int _dpad_left_button;
64 int _dpad_up_button;
65
66 // This is used for axis emulation.
67 int _ltrigger_axis;
68 int _ltrigger_code;
69 int _rtrigger_code;
70
71public:
72 static ButtonHandle map_button(int code,
73 DeviceClass device_class = DeviceClass::unknown,
74 int quirks = 0);
75
76public:
77 static TypeHandle get_class_type() {
78 return _type_handle;
79 }
80 static void init_type() {
81 InputDevice::init_type();
82 register_type(_type_handle, "EvdevInputDevice",
83 InputDevice::get_class_type());
84 }
85 virtual TypeHandle get_type() const {
86 return get_class_type();
87 }
88 virtual TypeHandle force_init_type() {init_type(); return get_class_type();}
89
90private:
91 static TypeHandle _type_handle;
92};
93
94#include "evdevInputDevice.I"
95
96#endif // PHAVE_LINUX_INPUT_H
97
98#endif // EVDEVINPUTDEVICE_H
A ButtonHandle represents a single button from any device, including keyboard buttons and mouse butto...
This is a structure representing a single input device.
Definition inputDevice.h:53
void map_button(size_t index, ButtonHandle handle)
Associates the indicated ButtonHandle with the button of the indicated index number.
TypeHandle is the identifier used to differentiate C++ class types.
Definition typeHandle.h:81
This is our own Panda specialization on the default STL vector.
Definition pvector.h:42
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
void register_type(TypeHandle &type_handle, const std::string &name)
This inline function is just a convenient way to call TypeRegistry::register_type(),...