2000-02-19 13:36:48 +01:00
|
|
|
/*
|
|
|
|
* interface.c: Abstract user interface layer
|
|
|
|
*
|
2000-04-24 09:46:05 +02:00
|
|
|
* See the main source file 'vdr.c' for copyright information and
|
2000-02-19 13:36:48 +01:00
|
|
|
* how to reach the author.
|
|
|
|
*
|
2003-10-05 09:51:02 +02:00
|
|
|
* $Id: interface.c 1.65 2003/10/05 09:48:13 kls Exp $
|
2000-02-19 13:36:48 +01:00
|
|
|
*/
|
|
|
|
|
|
|
|
#include "interface.h"
|
2000-11-01 11:45:05 +01:00
|
|
|
#include <ctype.h>
|
2002-08-11 10:47:11 +02:00
|
|
|
#include <stdlib.h>
|
2000-02-19 13:36:48 +01:00
|
|
|
#include <unistd.h>
|
2000-11-11 10:39:27 +01:00
|
|
|
#include "i18n.h"
|
2002-05-18 14:03:22 +02:00
|
|
|
#include "osd.h"
|
2002-05-19 15:50:11 +02:00
|
|
|
#include "status.h"
|
2000-09-03 11:40:00 +02:00
|
|
|
|
2000-10-08 12:24:30 +02:00
|
|
|
cInterface *Interface = NULL;
|
2000-02-19 13:36:48 +01:00
|
|
|
|
2000-10-08 12:24:30 +02:00
|
|
|
cInterface::cInterface(int SVDRPport)
|
2000-02-19 13:36:48 +01:00
|
|
|
{
|
|
|
|
open = 0;
|
|
|
|
cols[0] = 0;
|
2000-11-01 11:45:05 +01:00
|
|
|
width = height = 0;
|
2001-09-01 09:04:37 +02:00
|
|
|
interrupted = false;
|
2000-09-19 17:48:42 +02:00
|
|
|
SVDRP = NULL;
|
|
|
|
if (SVDRPport)
|
|
|
|
SVDRP = new cSVDRP(SVDRPport);
|
|
|
|
}
|
|
|
|
|
2000-10-08 12:24:30 +02:00
|
|
|
cInterface::~cInterface()
|
2000-09-19 17:48:42 +02:00
|
|
|
{
|
|
|
|
delete SVDRP;
|
2000-02-19 13:36:48 +01:00
|
|
|
}
|
|
|
|
|
2000-04-23 15:38:16 +02:00
|
|
|
void cInterface::Open(int NumCols, int NumLines)
|
2000-02-19 13:36:48 +01:00
|
|
|
{
|
2001-07-27 11:51:42 +02:00
|
|
|
if (!open++) {
|
|
|
|
if (NumCols == 0)
|
|
|
|
NumCols = Setup.OSDwidth;
|
|
|
|
if (NumLines == 0)
|
|
|
|
NumLines = Setup.OSDheight;
|
2002-05-18 14:03:22 +02:00
|
|
|
cOsd::Open(width = NumCols, height = NumLines);
|
2001-07-27 11:51:42 +02:00
|
|
|
}
|
2000-02-19 13:36:48 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
void cInterface::Close(void)
|
|
|
|
{
|
2000-04-15 17:38:11 +02:00
|
|
|
if (open == 1)
|
|
|
|
Clear();
|
2000-11-01 11:45:05 +01:00
|
|
|
if (!--open) {
|
2002-05-18 14:03:22 +02:00
|
|
|
cOsd::Close();
|
2000-11-01 11:45:05 +01:00
|
|
|
width = height = 0;
|
|
|
|
}
|
2000-02-19 13:36:48 +01:00
|
|
|
}
|
|
|
|
|
2000-04-23 15:38:16 +02:00
|
|
|
eKeys cInterface::GetKey(bool Wait)
|
2000-02-19 13:36:48 +01:00
|
|
|
{
|
2003-04-27 12:36:21 +02:00
|
|
|
if (!cRemote::HasKeys())
|
|
|
|
Flush();
|
2001-02-18 14:18:13 +01:00
|
|
|
if (SVDRP) {
|
2002-10-20 12:49:16 +02:00
|
|
|
if (SVDRP->Process())
|
|
|
|
Wait = false;
|
2001-02-18 14:18:13 +01:00
|
|
|
if (!open) {
|
|
|
|
char *message = SVDRP->GetMessage();
|
|
|
|
if (message) {
|
|
|
|
Info(message);
|
2002-08-11 13:32:23 +02:00
|
|
|
free(message);
|
2001-02-18 14:18:13 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2002-09-29 13:40:45 +02:00
|
|
|
return cRemote::Get(Wait ? 1000 : 10);
|
2000-09-17 09:36:50 +02:00
|
|
|
}
|
|
|
|
|
2000-04-22 13:51:48 +02:00
|
|
|
eKeys cInterface::Wait(int Seconds, bool KeepChar)
|
2000-03-11 11:22:37 +01:00
|
|
|
{
|
2001-09-01 15:23:27 +02:00
|
|
|
if (Seconds == 0)
|
|
|
|
Seconds = Setup.OSDMessageTime;
|
2000-11-11 12:21:38 +01:00
|
|
|
Flush();
|
2000-10-08 09:25:20 +02:00
|
|
|
eKeys Key = kNone;
|
|
|
|
time_t timeout = time(NULL) + Seconds;
|
|
|
|
for (;;) {
|
|
|
|
Key = GetKey();
|
2001-09-01 09:04:37 +02:00
|
|
|
if ((Key != kNone && (RAWKEY(Key) != kOk || RAWKEY(Key) == Key)) || time(NULL) > timeout || interrupted)
|
2000-10-08 09:25:20 +02:00
|
|
|
break;
|
|
|
|
}
|
2000-10-08 16:34:17 +02:00
|
|
|
if (KeepChar && ISRAWKEY(Key))
|
2002-09-29 13:40:45 +02:00
|
|
|
cRemote::Put(Key);
|
2001-09-01 09:04:37 +02:00
|
|
|
interrupted = false;
|
2000-04-22 13:51:48 +02:00
|
|
|
return Key;
|
2000-03-11 11:22:37 +01:00
|
|
|
}
|
|
|
|
|
2000-02-19 13:36:48 +01:00
|
|
|
void cInterface::Clear(void)
|
|
|
|
{
|
2000-03-11 11:22:37 +01:00
|
|
|
if (open)
|
2002-05-18 14:03:22 +02:00
|
|
|
cOsd::Clear();
|
2002-06-16 13:26:00 +02:00
|
|
|
cStatus::MsgOsdClear();
|
2000-03-11 11:22:37 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
void cInterface::ClearEol(int x, int y, eDvbColor Color)
|
|
|
|
{
|
|
|
|
if (open)
|
2002-05-18 14:03:22 +02:00
|
|
|
cOsd::ClrEol(x, y, Color);
|
2000-02-19 13:36:48 +01:00
|
|
|
}
|
|
|
|
|
2000-11-01 15:41:33 +01:00
|
|
|
void cInterface::Fill(int x, int y, int w, int h, eDvbColor Color)
|
|
|
|
{
|
|
|
|
if (open)
|
2002-05-18 14:03:22 +02:00
|
|
|
cOsd::Fill(x, y, w, h, Color);
|
2000-11-01 15:41:33 +01:00
|
|
|
}
|
|
|
|
|
2000-12-09 11:13:00 +01:00
|
|
|
void cInterface::SetBitmap(int x, int y, const cBitmap &Bitmap)
|
|
|
|
{
|
|
|
|
if (open)
|
2002-05-18 14:03:22 +02:00
|
|
|
cOsd::SetBitmap(x, y, Bitmap);
|
2000-12-09 11:13:00 +01:00
|
|
|
}
|
|
|
|
|
2000-11-01 15:41:33 +01:00
|
|
|
void cInterface::Flush(void)
|
|
|
|
{
|
|
|
|
if (open)
|
2002-05-18 14:03:22 +02:00
|
|
|
cOsd::Flush();
|
2000-11-01 15:41:33 +01:00
|
|
|
}
|
|
|
|
|
2000-02-19 13:36:48 +01:00
|
|
|
void cInterface::SetCols(int *c)
|
|
|
|
{
|
|
|
|
for (int i = 0; i < MaxCols; i++) {
|
|
|
|
cols[i] = *c++;
|
|
|
|
if (cols[i] == 0)
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2000-11-18 15:46:00 +01:00
|
|
|
eDvbFont cInterface::SetFont(eDvbFont Font)
|
|
|
|
{
|
2002-05-18 14:03:22 +02:00
|
|
|
return cOsd::SetFont(Font);
|
2000-11-18 15:46:00 +01:00
|
|
|
}
|
|
|
|
|
2000-11-01 11:45:05 +01:00
|
|
|
char *cInterface::WrapText(const char *Text, int Width, int *Height)
|
|
|
|
{
|
|
|
|
// Wraps the Text to make it fit into the area defined by the given Width
|
|
|
|
// (which is given in character cells).
|
|
|
|
// The actual number of lines resulting from this operation is returned in
|
|
|
|
// Height.
|
|
|
|
// The returned string is newly created on the heap and the caller
|
|
|
|
// is responsible for deleting it once it is no longer used.
|
|
|
|
// Wrapping is done by inserting the necessary number of newline
|
|
|
|
// characters into the string.
|
|
|
|
|
|
|
|
int Lines = 1;
|
|
|
|
char *t = strdup(Text);
|
|
|
|
char *Blank = NULL;
|
|
|
|
char *Delim = NULL;
|
|
|
|
int w = 0;
|
|
|
|
|
2002-05-18 14:03:22 +02:00
|
|
|
Width *= cOsd::CellWidth();
|
2000-11-01 11:45:05 +01:00
|
|
|
|
|
|
|
while (*t && t[strlen(t) - 1] == '\n')
|
|
|
|
t[strlen(t) - 1] = 0; // skips trailing newlines
|
|
|
|
|
|
|
|
for (char *p = t; *p; ) {
|
2002-12-06 14:21:00 +01:00
|
|
|
if (*p == '|')
|
|
|
|
*p = '\n';
|
2000-11-01 11:45:05 +01:00
|
|
|
if (*p == '\n') {
|
|
|
|
Lines++;
|
|
|
|
w = 0;
|
|
|
|
Blank = Delim = NULL;
|
|
|
|
p++;
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
else if (isspace(*p))
|
|
|
|
Blank = p;
|
2002-05-18 14:03:22 +02:00
|
|
|
int cw = cOsd::Width(*p);
|
2000-11-01 11:45:05 +01:00
|
|
|
if (w + cw > Width) {
|
|
|
|
if (Blank) {
|
|
|
|
*Blank = '\n';
|
|
|
|
p = Blank;
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
// Here's the ugly part, where we don't have any whitespace to
|
|
|
|
// punch in a newline, so we need to make room for it:
|
|
|
|
if (Delim)
|
|
|
|
p = Delim + 1; // let's fall back to the most recent delimiter
|
2002-08-11 13:32:23 +02:00
|
|
|
char *s = MALLOC(char, strlen(t) + 2); // The additional '\n' plus the terminating '\0'
|
2000-11-01 11:45:05 +01:00
|
|
|
int l = p - t;
|
|
|
|
strncpy(s, t, l);
|
|
|
|
s[l] = '\n';
|
|
|
|
strcpy(s + l + 1, p);
|
2002-08-11 13:32:23 +02:00
|
|
|
free(t);
|
2000-11-01 11:45:05 +01:00
|
|
|
t = s;
|
|
|
|
p = t + l;
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
w += cw;
|
|
|
|
if (strchr("-.,:;!?_", *p)) {
|
|
|
|
Delim = p;
|
|
|
|
Blank = NULL;
|
|
|
|
}
|
|
|
|
p++;
|
|
|
|
}
|
|
|
|
|
|
|
|
*Height = Lines;
|
|
|
|
return t;
|
|
|
|
}
|
|
|
|
|
2000-03-11 11:22:37 +01:00
|
|
|
void cInterface::Write(int x, int y, const char *s, eDvbColor FgColor, eDvbColor BgColor)
|
2000-02-19 13:36:48 +01:00
|
|
|
{
|
2000-03-11 11:22:37 +01:00
|
|
|
if (open)
|
2002-05-18 14:03:22 +02:00
|
|
|
cOsd::Text(x, y, s, FgColor, BgColor);
|
2000-02-19 13:36:48 +01:00
|
|
|
}
|
|
|
|
|
2000-09-09 14:57:43 +02:00
|
|
|
void cInterface::WriteText(int x, int y, const char *s, eDvbColor FgColor, eDvbColor BgColor)
|
2000-02-19 13:36:48 +01:00
|
|
|
{
|
|
|
|
if (open) {
|
2000-03-11 11:22:37 +01:00
|
|
|
ClearEol(x, y, BgColor);
|
2000-02-19 13:36:48 +01:00
|
|
|
int col = 0;
|
|
|
|
for (;;) {
|
2000-03-11 11:22:37 +01:00
|
|
|
const char *t = strchr(s, '\t');
|
|
|
|
const char *p = s;
|
2000-02-19 13:36:48 +01:00
|
|
|
char buf[1000];
|
|
|
|
if (t && col < MaxCols && cols[col] > 0) {
|
|
|
|
unsigned int n = t - s;
|
|
|
|
if (n >= sizeof(buf))
|
|
|
|
n = sizeof(buf) - 1;
|
|
|
|
strncpy(buf, s, n);
|
|
|
|
buf[n] = 0;
|
|
|
|
p = buf;
|
|
|
|
s = t + 1;
|
|
|
|
}
|
2000-03-11 11:22:37 +01:00
|
|
|
Write(x, y, p, FgColor, BgColor);
|
2000-02-19 13:36:48 +01:00
|
|
|
if (p == s)
|
|
|
|
break;
|
|
|
|
x += cols[col++];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2000-03-11 11:22:37 +01:00
|
|
|
void cInterface::Title(const char *s)
|
|
|
|
{
|
|
|
|
ClearEol(0, 0, clrCyan);
|
2000-11-05 13:04:23 +01:00
|
|
|
const char *t = strchr(s, '\t');
|
|
|
|
if (t) {
|
|
|
|
char buffer[Width() + 1];
|
|
|
|
unsigned int n = t - s;
|
|
|
|
if (n >= sizeof(buffer))
|
|
|
|
n = sizeof(buffer) - 1;
|
2001-08-25 13:27:26 +02:00
|
|
|
strn0cpy(buffer, s, n + 1);
|
2000-11-05 13:04:23 +01:00
|
|
|
Write(1, 0, buffer, clrBlack, clrCyan);
|
|
|
|
t++;
|
2002-05-18 14:03:22 +02:00
|
|
|
Write(-(cOsd::WidthInCells(t) + 1), 0, t, clrBlack, clrCyan);
|
2000-11-05 13:04:23 +01:00
|
|
|
}
|
|
|
|
else {
|
|
|
|
int x = (Width() - strlen(s)) / 2;
|
|
|
|
if (x < 0)
|
|
|
|
x = 0;
|
|
|
|
Write(x, 0, s, clrBlack, clrCyan);
|
|
|
|
}
|
2002-06-16 13:26:00 +02:00
|
|
|
cStatus::MsgOsdTitle(s);
|
2000-03-11 11:22:37 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
void cInterface::Status(const char *s, eDvbColor FgColor, eDvbColor BgColor)
|
|
|
|
{
|
2001-07-22 12:33:45 +02:00
|
|
|
int Line = (abs(height) == 1) ? 0 : -2;
|
|
|
|
ClearEol(0, Line, s ? BgColor : clrBackground);
|
2002-01-27 16:00:31 +01:00
|
|
|
if (s) {
|
2003-04-06 12:51:50 +02:00
|
|
|
int x = (Width() - int(strlen(s))) / 2;
|
2002-01-27 16:00:31 +01:00
|
|
|
if (x < 0)
|
|
|
|
x = 0;
|
|
|
|
Write(x, Line, s, FgColor, BgColor);
|
|
|
|
}
|
2002-06-16 13:26:00 +02:00
|
|
|
cStatus::MsgOsdStatusMessage(s);
|
2000-03-11 11:22:37 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
void cInterface::Info(const char *s)
|
2000-02-19 13:36:48 +01:00
|
|
|
{
|
2001-07-27 11:51:42 +02:00
|
|
|
Open(Setup.OSDwidth, -1);
|
2002-05-13 16:35:49 +02:00
|
|
|
isyslog("info: %s", s);
|
2001-07-28 15:03:22 +02:00
|
|
|
Status(s, clrBlack, clrGreen);
|
2000-03-11 11:22:37 +01:00
|
|
|
Wait();
|
|
|
|
Status(NULL);
|
2000-02-19 13:36:48 +01:00
|
|
|
Close();
|
|
|
|
}
|
|
|
|
|
2000-03-11 11:22:37 +01:00
|
|
|
void cInterface::Error(const char *s)
|
2000-02-19 13:36:48 +01:00
|
|
|
{
|
2001-07-27 11:51:42 +02:00
|
|
|
Open(Setup.OSDwidth, -1);
|
2002-05-13 16:35:49 +02:00
|
|
|
esyslog("ERROR: %s", s);
|
2000-03-11 11:22:37 +01:00
|
|
|
Status(s, clrWhite, clrRed);
|
|
|
|
Wait();
|
|
|
|
Status(NULL);
|
2000-02-19 13:36:48 +01:00
|
|
|
Close();
|
|
|
|
}
|
|
|
|
|
2001-09-01 09:04:37 +02:00
|
|
|
bool cInterface::Confirm(const char *s, int Seconds, bool WaitForTimeout)
|
2000-03-11 11:22:37 +01:00
|
|
|
{
|
2001-12-01 12:03:52 +01:00
|
|
|
Open(Setup.OSDwidth, -1);
|
2002-05-13 16:35:49 +02:00
|
|
|
isyslog("confirm: %s", s);
|
2001-07-28 15:03:22 +02:00
|
|
|
Status(s, clrBlack, clrYellow);
|
2001-09-01 09:04:37 +02:00
|
|
|
eKeys k = Wait(Seconds);
|
|
|
|
bool result = WaitForTimeout ? k == kNone : k == kOk;
|
2000-03-11 11:22:37 +01:00
|
|
|
Status(NULL);
|
|
|
|
Close();
|
2002-05-13 16:35:49 +02:00
|
|
|
isyslog("%sconfirmed", result ? "" : "not ");
|
2000-03-11 11:22:37 +01:00
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
|
|
|
void cInterface::HelpButton(int Index, const char *Text, eDvbColor FgColor, eDvbColor BgColor)
|
|
|
|
{
|
2002-01-26 11:13:48 +01:00
|
|
|
if (open) {
|
2000-11-01 11:45:05 +01:00
|
|
|
const int w = Width() / 4;
|
2002-05-18 14:03:22 +02:00
|
|
|
cOsd::Fill(Index * w, -1, w, 1, Text ? BgColor : clrBackground);
|
2002-01-26 11:13:48 +01:00
|
|
|
if (Text) {
|
|
|
|
int l = (w - int(strlen(Text))) / 2;
|
|
|
|
if (l < 0)
|
|
|
|
l = 0;
|
2002-05-18 14:03:22 +02:00
|
|
|
cOsd::Text(Index * w + l, -1, Text, FgColor, BgColor);
|
2002-01-26 11:13:48 +01:00
|
|
|
}
|
2000-03-11 11:22:37 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void cInterface::Help(const char *Red, const char *Green, const char *Yellow, const char *Blue)
|
|
|
|
{
|
|
|
|
HelpButton(0, Red, clrBlack, clrRed);
|
|
|
|
HelpButton(1, Green, clrBlack, clrGreen);
|
|
|
|
HelpButton(2, Yellow, clrBlack, clrYellow);
|
|
|
|
HelpButton(3, Blue, clrWhite, clrBlue);
|
2002-06-16 13:26:00 +02:00
|
|
|
cStatus::MsgOsdHelpKeys(Red, Green, Yellow, Blue);
|
2000-03-11 11:22:37 +01:00
|
|
|
}
|
|
|
|
|
2003-10-05 09:51:02 +02:00
|
|
|
bool cInterface::QueryKeys(cRemote *Remote)
|
2000-02-19 13:36:48 +01:00
|
|
|
{
|
2000-11-11 10:39:27 +01:00
|
|
|
WriteText(1, 3, tr("Phase 1: Detecting RC code type"));
|
|
|
|
WriteText(1, 5, tr("Press any key on the RC unit"));
|
2000-11-11 12:21:38 +01:00
|
|
|
Flush();
|
2002-09-29 13:40:45 +02:00
|
|
|
if (Remote->Initialize()) {
|
|
|
|
WriteText(1, 5, tr("RC code detected!"));
|
|
|
|
WriteText(1, 6, tr("Do not press any key..."));
|
|
|
|
Flush();
|
|
|
|
sleep(3);
|
|
|
|
ClearEol(0, 5);
|
|
|
|
ClearEol(0, 6);
|
|
|
|
|
|
|
|
WriteText(1, 3, tr("Phase 2: Learning specific key codes"));
|
|
|
|
eKeys NewKey = kUp;
|
|
|
|
while (NewKey != kNone) {
|
|
|
|
char *Prompt;
|
|
|
|
asprintf(&Prompt, tr("Press key for '%s'"), tr(cKey::ToString(NewKey)));
|
|
|
|
WriteText(1, 5, Prompt);
|
|
|
|
free(Prompt);
|
|
|
|
cRemote::Clear();
|
|
|
|
Flush();
|
|
|
|
for (eKeys k = NewKey; k == NewKey; ) {
|
|
|
|
char *NewCode = NULL;
|
|
|
|
eKeys Key = cRemote::Get(100, &NewCode);
|
|
|
|
switch (Key) {
|
2002-10-27 16:02:27 +01:00
|
|
|
case kUp: if (NewKey > kUp) {
|
|
|
|
NewKey = eKeys(NewKey - 1);
|
|
|
|
cKey *last = Keys.Last();
|
|
|
|
if (last && last->Key() == NewKey)
|
|
|
|
Keys.Del(last);
|
|
|
|
}
|
2002-09-29 13:40:45 +02:00
|
|
|
break;
|
|
|
|
case kDown: WriteText(1, 5, tr("Press 'Up' to confirm"));
|
|
|
|
WriteText(1, 6, tr("Press 'Down' to continue"));
|
|
|
|
ClearEol(0, 7);
|
|
|
|
ClearEol(0, 8);
|
|
|
|
ClearEol(0, 9);
|
2002-09-30 15:57:23 +02:00
|
|
|
Flush();
|
2002-09-29 13:40:45 +02:00
|
|
|
for (;;) {
|
|
|
|
Key = cRemote::Get(100);
|
|
|
|
if (Key == kUp) {
|
|
|
|
Clear();
|
2003-10-05 09:51:02 +02:00
|
|
|
return true;
|
2000-02-19 13:36:48 +01:00
|
|
|
}
|
2002-09-29 13:40:45 +02:00
|
|
|
else if (Key == kDown) {
|
|
|
|
ClearEol(0, 6);
|
|
|
|
k = kNone; // breaks the outer for() loop
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case kMenu: NewKey = eKeys(NewKey + 1);
|
|
|
|
break;
|
|
|
|
case kNone: if (NewCode) {
|
|
|
|
dsyslog("new %s code: %s = %s", Remote->Name(), NewCode, cKey::ToString(NewKey));
|
|
|
|
Keys.Add(new cKey(Remote->Name(), NewCode, NewKey));
|
|
|
|
NewKey = eKeys(NewKey + 1);
|
|
|
|
free(NewCode);
|
2000-02-19 13:36:48 +01:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
default: break;
|
|
|
|
}
|
|
|
|
}
|
2002-09-29 13:40:45 +02:00
|
|
|
if (NewKey > kUp)
|
|
|
|
WriteText(1, 7, tr("(press 'Up' to go back)"));
|
|
|
|
else
|
|
|
|
ClearEol(0, 7);
|
|
|
|
if (NewKey > kDown)
|
|
|
|
WriteText(1, 8, tr("(press 'Down' to end key definition)"));
|
|
|
|
else
|
|
|
|
ClearEol(0, 8);
|
|
|
|
if (NewKey > kMenu)
|
|
|
|
WriteText(1, 9, tr("(press 'Menu' to skip this key)"));
|
|
|
|
else
|
|
|
|
ClearEol(0, 9);
|
|
|
|
}
|
2003-10-05 09:51:02 +02:00
|
|
|
return true;
|
2002-09-29 13:40:45 +02:00
|
|
|
}
|
2003-10-05 09:51:02 +02:00
|
|
|
return false;
|
2000-02-19 13:36:48 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
void cInterface::LearnKeys(void)
|
|
|
|
{
|
2002-09-29 13:40:45 +02:00
|
|
|
for (cRemote *Remote = Remotes.First(); Remote; Remote = Remotes.Next(Remote)) {
|
2003-04-12 14:37:57 +02:00
|
|
|
if (!Remote->Ready()) {
|
|
|
|
esyslog("ERROR: remote control %s not ready!", Remote->Name());
|
|
|
|
continue;
|
|
|
|
}
|
2002-09-29 13:40:45 +02:00
|
|
|
bool known = Keys.KnowsRemote(Remote->Name());
|
|
|
|
dsyslog("remote control %s - %s", Remote->Name(), known ? "keys known" : "learning keys");
|
|
|
|
if (!known) {
|
|
|
|
Open();
|
2002-10-26 12:56:53 +02:00
|
|
|
char Headline[Width()];
|
|
|
|
snprintf(Headline, sizeof(Headline), tr("Learning Remote Control Keys (%s)"), Remote->Name());
|
|
|
|
Clear();
|
|
|
|
cRemote::Clear();
|
|
|
|
WriteText(1, 1, Headline);
|
2002-11-01 10:53:07 +01:00
|
|
|
cRemote::SetLearning(Remote);
|
2003-10-05 09:51:02 +02:00
|
|
|
bool rc = QueryKeys(Remote);
|
2002-11-01 10:53:07 +01:00
|
|
|
cRemote::SetLearning(NULL);
|
2002-10-26 12:56:53 +02:00
|
|
|
Clear();
|
2003-10-05 09:51:02 +02:00
|
|
|
if (!rc) {
|
|
|
|
Close();
|
|
|
|
return;
|
|
|
|
}
|
2002-10-26 12:56:53 +02:00
|
|
|
WriteText(1, 1, Headline);
|
|
|
|
WriteText(1, 3, tr("Phase 3: Saving key codes"));
|
|
|
|
WriteText(1, 5, tr("Press 'Up' to save, 'Down' to cancel"));
|
2002-09-29 13:40:45 +02:00
|
|
|
for (;;) {
|
2002-10-26 12:56:53 +02:00
|
|
|
eKeys key = GetKey();
|
|
|
|
if (key == kUp) {
|
|
|
|
Keys.Save();
|
|
|
|
Close();
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
else if (key == kDown) {
|
|
|
|
Keys.Load();
|
|
|
|
Close();
|
|
|
|
break;
|
|
|
|
}
|
2000-02-19 13:36:48 +01:00
|
|
|
}
|
2002-09-29 13:40:45 +02:00
|
|
|
}
|
2000-02-19 13:36:48 +01:00
|
|
|
}
|
|
|
|
}
|