2 Copyright 2004-2005 Chris Tallon
4 This file is part of VOMP.
6 VOMP 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 of the License, or
9 (at your option) any later version.
11 VOMP 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.
16 You should have received a copy of the GNU General Public License
17 along with VOMP; if not, write to the Free Software
18 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
21 #include "remotemvp.h"
25 RemoteMVP::RemoteMVP()
34 RemoteMVP::~RemoteMVP()
38 int RemoteMVP::init(char* devName)
40 if (initted) return 0;
43 device = open(devName, O_RDONLY);
53 int RemoteMVP::shutdown()
55 if (!initted) return 0;
62 int RemoteMVP::getDevice()
64 if (!initted) return 0;
68 UCHAR RemoteMVP::getButtonPress(int waitType)
71 how = 1 - start new wait
72 how = 2 - continue wait
77 struct timeval* passToSelect = NULL;
85 else if (waitType == 1)
91 else if (waitType == 2)
93 if ((tv.tv_sec == 0) && (tv.tv_usec == 0)) // protection in case timer = 0
100 else if (waitType == 3)
107 FD_SET(device, &readfds);
109 retval = select(device + 1, &readfds, NULL, NULL, &tv);
110 // 0 = nothing happened
111 // 1 = data arrived (actually num of descriptors that changed)
112 // other value = signal or error
113 if (retval == 0) return NA_NONE;
114 if (retval == -1) return NA_SIGNAL;
116 int count = read(device, &input, 4);
119 input = (0X00FF0000 & input) >> 16;
120 Log::getInstance()->log("Remote", Log::DEBUG, "Button %i", input);
122 if (remoteType == OLDREMOTE)
124 if (input == VOLUMEDOWN) return DF_LEFT;
125 if (input == VOLUMEUP) return DF_RIGHT;
126 if (input == CHANNELUP) return DF_UP;
127 if (input == CHANNELDOWN) return DF_DOWN;
130 return (UCHAR) TranslateHWC(input);
135 void RemoteMVP::clearBuffer()
137 while(getButtonPress(3) != NA_NONE);