Merge pull request #1997 from arnova/fm_fixes_for_guimediawindow_too
[vuplus_xbmc] / xbmc / input / linux / LinuxInputDevices.h
1 /*
2  *      Copyright (C) 2005-2013 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, see
17  *  <http://www.gnu.org/licenses/>.
18  *
19  */
20 #ifndef LINUXINPUTDEVICES_H_
21 #define LINUXINPUTDEVICES_H_
22
23 #include <vector>
24 #include <string>
25 #include "windowing/XBMC_events.h"
26 #include "input/XBMC_keyboard.h"
27 #include "threads/SingleLock.h"
28
29 struct KeymapEntry
30 {
31   int code;
32   unsigned short base;
33   unsigned short shift;
34   unsigned short alt;
35   unsigned short altShift;
36 };
37
38 class CLinuxInputDevice
39 {
40 public:
41   CLinuxInputDevice(const std::string fileName, int index);
42   ~CLinuxInputDevice();
43   XBMC_Event ReadEvent();
44  
45 private:
46   void SetupKeyboardAutoRepeat(int fd);
47   XBMCKey TranslateKey(unsigned short code);
48   bool KeyEvent(const struct input_event& levt, XBMC_Event& devt);
49   bool RelEvent(const struct input_event& levt, XBMC_Event& devt);
50   bool AbsEvent(const struct input_event& levt, XBMC_Event& devt);
51   bool TranslateEvent(const struct input_event& levt, XBMC_Event& devt);
52   void SetLed(int led, int state);
53   void GetInfo(int fd);
54   bool Open();
55   void Close();
56   unsigned short KeyboardReadValue(unsigned char table, unsigned char index);
57   XBMCMod UpdateModifiers(XBMC_Event& devt);
58   bool GetKeymapEntry(KeymapEntry& entry);
59   int KeyboardGetSymbol(unsigned short value);
60
61   int m_fd;
62   int m_vt_fd;
63   bool m_hasLeds;
64   std::string m_fileName;
65   bool m_ledState[3];
66   int m_mouseX;
67   int m_mouseY;
68   int m_deviceIndex;
69   int m_keyMods;
70   int m_lastKeyMods;
71   char m_deviceName[256];
72   int m_deviceType;
73   int m_devicePreferredId;
74   int m_deviceCaps;
75   int m_deviceMinKeyCode;
76   int m_deviceMaxKeyCode;
77   int m_deviceMaxAxis;
78   bool m_bSkipNonKeyEvents;
79 };
80
81 class CLinuxInputDevices
82 {
83 public:
84   void InitAvailable();
85   XBMC_Event ReadEvent();
86   bool IsRemoteLowBattery();
87   bool IsRemoteNotPaired();
88 private:
89   CCriticalSection m_devicesListLock;
90   bool CheckDevice(const char *device);
91   std::vector<CLinuxInputDevice*> m_devices;
92 };
93
94 #endif /* LINUXINPUTDEVICES_H_ */