Merge pull request #473 from Montellese/onplaybackspeedchanged
[vuplus_xbmc] / xbmc / peripherals / devices / PeripheralCecAdapter.h
1 #pragma once
2 /*
3  *      Copyright (C) 2005-2011 Team XBMC
4  *      http://xbmc.org
5  *
6  *  This Program is free software; you can redistribute it and/or modify
7  *  it under the terms of the GNU General Public License as published by
8  *  the Free Software Foundation; either version 2, or (at your option)
9  *  any later version.
10  *
11  *  This Program is distributed in the hope that it will be useful,
12  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
13  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  *  GNU General Public License for more details.
15  *
16  *  You should have received a copy of the GNU General Public License
17  *  along with XBMC; see the file COPYING.  If not, write to
18  *  the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
19  *  http://www.gnu.org/copyleft/gpl.html
20  *
21  */
22
23 #include "PeripheralHID.h"
24 #include "interfaces/AnnouncementManager.h"
25 #include "threads/Thread.h"
26 #include "threads/CriticalSection.h"
27 #include <queue>
28
29 namespace CEC
30 {
31   class ICECAdapter;
32 };
33
34 namespace PERIPHERALS
35 {
36   typedef struct
37   {
38     WORD         iButton;
39     unsigned int iButtonPressed;
40     unsigned int iButtonReleased;
41   } CecButtonPress;
42
43
44   class CPeripheralCecAdapter : public CPeripheralHID, public ANNOUNCEMENT::IAnnouncer, private CThread
45   {
46   public:
47     CPeripheralCecAdapter(const PeripheralType type, const PeripheralBusType busType, const CStdString &strLocation, const CStdString &strDeviceName, int iVendorId, int iProductId);
48     virtual ~CPeripheralCecAdapter(void);
49
50     virtual void Announce(ANNOUNCEMENT::EAnnouncementFlag flag, const char *sender, const char *message, const CVariant &data);
51     virtual bool PowerOnCecDevices(void);
52     virtual bool StandbyCecDevices(void);
53
54     virtual bool SendPing(void);
55     virtual bool StartBootloader(void);
56
57     virtual void OnSettingChanged(const CStdString &strChangedSetting);
58
59     virtual WORD GetButton(void);
60     virtual unsigned int GetHoldTime(void);
61     virtual void ResetButton(void);
62
63   protected:
64     virtual void FlushLog(void);
65     virtual bool GetNextKey(void);
66     virtual bool InitialiseFeature(const PeripheralFeature feature);
67     virtual void Process(void);
68     virtual void ProcessNextCommand(void);
69     static bool FindConfigLocation(CStdString &strString);
70     static bool TranslateComPort(CStdString &strPort);
71
72     CEC::ICECAdapter* m_cecAdapter;
73     bool              m_bStarted;
74     bool              m_bHasButton;
75     bool              m_bIsReady;
76     CecButtonPress    m_button;
77     CCriticalSection  m_critSection;
78   };
79 }