Merge pull request #1356 from fetzerch/bugfix-isostack
[vuplus_xbmc] / xbmc / input / linux / LinuxInputDevices.h
1 /*
2  *      Copyright (C) 2005-2009 Team XBMC
3  *      http://www.xbmc.org
4  *
5  *  This Program is free software; you can redistribute it and/or modify
6  *  it under the terms of the GNU General Public License as published by
7  *  the Free Software Foundation; either version 2, or (at your option)
8  *  any later version.
9  *
10  *  This Program is distributed in the hope that it will be useful,
11  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
12  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  *  GNU General Public License for more details.
14  *
15  *  You should have received a copy of the GNU General Public License
16  *  along with XBMC; see the file COPYING.  If not, write to
17  *  the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
18  *  http://www.gnu.org/copyleft/gpl.html
19  *
20  */
21 #ifndef LINUXINPUTDEVICES_H_
22 #define LINUXINPUTDEVICES_H_
23
24 #include <vector>
25 #include <string>
26 #include "windowing/XBMC_events.h"
27 #include "input/XBMC_keyboard.h"
28 #include "threads/SingleLock.h"
29
30 struct KeymapEntry
31 {
32   int code;
33   unsigned short base;
34   unsigned short shift;
35   unsigned short alt;
36   unsigned short altShift;
37 };
38
39 class CLinuxInputDevice
40 {
41 public:
42   CLinuxInputDevice(const std::string fileName, int index);
43   ~CLinuxInputDevice();
44   XBMC_Event ReadEvent();
45  
46 private:
47   void SetupKeyboardAutoRepeat(int fd);
48   XBMCKey TranslateKey(unsigned short code);
49   bool KeyEvent(const struct input_event& levt, XBMC_Event& devt);
50   bool RelEvent(const struct input_event& levt, XBMC_Event& devt);
51   bool AbsEvent(const struct input_event& levt, XBMC_Event& devt);
52   bool TranslateEvent(const struct input_event& levt, XBMC_Event& devt);
53   void SetLed(int led, int state);
54   void GetInfo(int fd);
55   bool Open();
56   void Close();
57   unsigned short KeyboardReadValue(unsigned char table, unsigned char index);
58   XBMCMod UpdateModifiers(XBMC_Event& devt);
59   bool GetKeymapEntry(KeymapEntry& entry);
60   int KeyboardGetSymbol(unsigned short value);
61
62   int m_fd;
63   int m_vt_fd;
64   bool m_hasLeds;
65   std::string m_fileName;
66   bool m_ledState[3];
67   int m_mouseX;
68   int m_mouseY;
69   int m_deviceIndex;
70   int m_keyMods;
71   int m_lastKeyMods;
72   char m_deviceName[256];
73   int m_deviceType;
74   int m_devicePreferredId;
75   int m_deviceCaps;
76   int m_deviceMinKeyCode;
77   int m_deviceMaxKeyCode;
78   int m_deviceMaxAxis;
79   bool m_bSkipNonKeyEvents;
80 };
81
82 class CLinuxInputDevices
83 {
84 public:
85   void InitAvailable();
86   XBMC_Event ReadEvent();
87   bool IsRemoteLowBattery();
88   bool IsRemoteNotPaired();
89 private:
90   CCriticalSection m_devicesListLock;
91   bool CheckDevice(const char *device);
92   std::vector<CLinuxInputDevice*> m_devices;
93 };
94
95 #endif /* LINUXINPUTDEVICES_H_ */