]> git.mxchange.org Git - flightgear.git/blob - src/Input/FGLinuxEventInput.hxx
event input for Linux: substitude dbus+hal by udev
[flightgear.git] / src / Input / FGLinuxEventInput.hxx
1 // FGEventInput.hxx -- handle event driven input devices for the Linux O/S
2 //
3 // Written by Torsten Dreyer, started July 2009
4 //
5 // Copyright (C) 2009 Torsten Dreyer, Torsten (at) t3r _dot_ de
6 //
7 // This program is free software; you can redistribute it and/or
8 // modify it under the terms of the GNU General Public License as
9 // published by the Free Software Foundation; either version 2 of the
10 // License, or (at your option) any later version.
11 //
12 // This program is distributed in the hope that it will be useful, but
13 // WITHOUT ANY WARRANTY; without even the implied warranty of
14 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
15 // General Public License for more details.
16 //
17 // You should have received a copy of the GNU General Public License
18 // along with this program; if not, write to the Free Software
19 // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
20 //
21 // $Id$
22
23 #ifndef __FGLINUXEVENTINPUT_HXX
24 #define __FGLINUXEVENTINPUT_HXX
25
26 #include "FGEventInput.hxx"
27 #include <linux/input.h>
28
29 struct FGLinuxEventData : public FGEventData {
30   FGLinuxEventData( struct input_event & event, double dt, int modifiers ) :
31     FGEventData( (double)event.value, dt, modifiers ),
32     type(event.type),
33     code(event.code) {
34   }
35   unsigned type;
36   unsigned code;
37 };
38
39 /*
40  * A implementation for linux event devices
41  */
42 class FGLinuxInputDevice : public FGInputDevice {
43 public:
44   FGLinuxInputDevice();
45   FGLinuxInputDevice( std::string name, std::string devname );
46   virtual ~FGLinuxInputDevice();
47
48   virtual void Open();
49   virtual void Close();
50   virtual void Send( const char * eventName, double value );
51   virtual const char * TranslateEventName( FGEventData & eventData );
52
53   void SetDevname( const std::string name );
54   std::string GetDevname() const { return devname; }
55
56   int GetFd() { return fd; }
57
58   double Normalize( struct input_event & event );
59 private:
60   std::string devname;
61   int fd;
62
63   std::map<unsigned int,input_absinfo> absinfo;
64 };
65
66 class FGLinuxEventInput : public FGEventInput {
67 public:
68   FGLinuxEventInput();
69   virtual ~ FGLinuxEventInput();
70   virtual void update (double dt);
71   virtual void postinit();
72
73 protected:
74 };
75
76 #endif