1
0
mirror of https://github.com/VDR4Arch/vdr.git synced 2023-10-10 13:36:52 +02:00

KBD active by default; no more 'ncurses' necessary for KBD

This commit is contained in:
Klaus Schmidinger 2002-12-08 14:30:32 +01:00
parent a40c8b8a98
commit fb16fbafaa
9 changed files with 94 additions and 53 deletions

View File

@ -501,3 +501,6 @@ Emil Naepflein <Emil.Naepflein@philosys.de>
Gerald Berwolf <genka@genka.de> Gerald Berwolf <genka@genka.de>
for suggesting to deactivate some templates in tools.h in case some plugin needs to for suggesting to deactivate some templates in tools.h in case some plugin needs to
use the STL use the STL
Thomas Sailer <sailer@scs.ch>
for pointing out how to set the terminal parameters to read from the keyboard

13
HISTORY
View File

@ -1837,7 +1837,7 @@ Video Disk Recorder Revision History
- The new plugin 'sky' can be used to integrate a Sky Digibox into the VDR system, - The new plugin 'sky' can be used to integrate a Sky Digibox into the VDR system,
using a Kfir MPEG2 encoder card (see PLUGINS/src/sky/README for details). using a Kfir MPEG2 encoder card (see PLUGINS/src/sky/README for details).
2002-12-07: Version 1.1.19 2002-12-08: Version 1.1.19
- The character '|' in description texts of EPG records is now interpreted as a - The character '|' in description texts of EPG records is now interpreted as a
newline character (suggested by Gerhard Steiner). newline character (suggested by Gerhard Steiner).
@ -1851,3 +1851,14 @@ Video Disk Recorder Revision History
in testing this). Since switching channels now no longer explicitly waits for a in testing this). Since switching channels now no longer explicitly waits for a
channel lock in the foreground thread, the "panic level" mechanism is no longer channel lock in the foreground thread, the "panic level" mechanism is no longer
used (maybe we don't need it nay more, anyway). used (maybe we don't need it nay more, anyway).
- The keyboard is now by default always active to control VDR. The 'make' option
REMOTE=KBD is therefore obsolete. When compiling VDR with REMOTE=RCU or REMOTE=LIRC,
the keyboard can thus now be active together with the remote control. If you want
to build VDR _without_ keyboard support you can set NO_KBD=1 in the 'make' call.
Since the keyboard codes are now different from the ones used previously (which
were mapped by the 'ncurses' library) you will need to go through the "Learning
keys" procedure again. To do so, either delete the file /video/remote.conf or
remove the KBD.* entries from it before starting this version of VDR.
(Thanks to Thomas Sailer for pointing out how to set the terminal parameters to
read from the keyboard).
- The 'ncurses' library is now only necessary when compiling VDR with DEBUG_OSD=1.

10
INSTALL
View File

@ -26,17 +26,17 @@ installed.
IMPORTANT: See "Configuration files" below for information on how IMPORTANT: See "Configuration files" below for information on how
========= to set up the configuration files at the proper location! ========= to set up the configuration files at the proper location!
The 'vdr' program can be controlled via the PC keyboard or By default the 'vdr' program can be controlled via the PC keyboard. If you have
an infrared remote control unit. Define the REMOTE macro to one of the an infrared remote control unit you can define the REMOTE macro to one of the
following values 'make' call to activate the respective control mode: following values in the 'make' call to activate the respective control mode:
REMOTE=KBD control via the PC keyboard (default)
REMOTE=RCU control via the "Remote Control Unit" receiver REMOTE=RCU control via the "Remote Control Unit" receiver
(see http://www.cadsoft.de/vdr/remote.htm) (see http://www.cadsoft.de/vdr/remote.htm)
REMOTE=LIRC control via the "Linux Infrared Remote Control" REMOTE=LIRC control via the "Linux Infrared Remote Control"
(see http://www.lirc.org) (see http://www.lirc.org)
REMOTE=NONE no remote control (in case only SVDRP shall be used)
If you want to disable control via the PC keyboard, you can add NO_KBD=1
to the 'make' call.
Adding "DEBUG_OSD=1" will use the PC screen (or current window) Adding "DEBUG_OSD=1" will use the PC screen (or current window)
to display texts instead of the DVB card's on-screen display to display texts instead of the DVB card's on-screen display
interface. These modes are useful when testing new menus if you interface. These modes are useful when testing new menus if you

View File

@ -4,7 +4,7 @@
# See the main source file 'vdr.c' for copyright information and # See the main source file 'vdr.c' for copyright information and
# how to reach the author. # how to reach the author.
# #
# $Id: Makefile 1.52 2002/11/29 15:23:02 kls Exp $ # $Id: Makefile 1.53 2002/12/08 12:20:37 kls Exp $
.DELETE_ON_ERROR: .DELETE_ON_ERROR:
@ -38,12 +38,8 @@ OBJS = audio.o channels.o config.o cutter.o device.o diseqc.o dvbdevice.o dvbosd
OSDFONT = -adobe-helvetica-medium-r-normal--23-*-100-100-p-*-iso8859-1 OSDFONT = -adobe-helvetica-medium-r-normal--23-*-100-100-p-*-iso8859-1
FIXFONT = -adobe-courier-bold-r-normal--25-*-100-100-m-*-iso8859-1 FIXFONT = -adobe-courier-bold-r-normal--25-*-100-100-m-*-iso8859-1
ifndef REMOTE ifndef NO_KBD
REMOTE = KBD DEFINES += -DREMOTE_KBD
endif
ifeq ($(REMOTE), KBD)
NCURSESLIB = -lncurses
endif endif
DEFINES += -DREMOTE_$(REMOTE) DEFINES += -DREMOTE_$(REMOTE)

14
osd.c
View File

@ -4,7 +4,7 @@
* See the main source file 'vdr.c' for copyright information and * See the main source file 'vdr.c' for copyright information and
* how to reach the author. * how to reach the author.
* *
* $Id: osd.c 1.38 2002/11/16 14:20:26 kls Exp $ * $Id: osd.c 1.39 2002/12/08 13:17:13 kls Exp $
*/ */
#include "osd.h" #include "osd.h"
@ -26,15 +26,8 @@
void cOsd::Initialize(void) void cOsd::Initialize(void)
{ {
#if defined(DEBUG_OSD) || defined(REMOTE_KBD)
initscr();
keypad(stdscr, true);
nonl();
cbreak();
noecho();
timeout(10);
#endif
#if defined(DEBUG_OSD) #if defined(DEBUG_OSD)
initscr();
start_color(); start_color();
leaveok(stdscr, true); leaveok(stdscr, true);
#endif #endif
@ -43,7 +36,7 @@ void cOsd::Initialize(void)
void cOsd::Shutdown(void) void cOsd::Shutdown(void)
{ {
Close(); Close();
#if defined(DEBUG_OSD) || defined(REMOTE_KBD) #if defined(DEBUG_OSD)
endwin(); endwin();
#endif #endif
} }
@ -150,6 +143,7 @@ void cOsd::Clear(void)
#ifdef DEBUG_OSD #ifdef DEBUG_OSD
SetColor(clrBackground, clrBackground); SetColor(clrBackground, clrBackground);
Fill(0, 0, cols, rows, clrBackground); Fill(0, 0, cols, rows, clrBackground);
refresh();
#else #else
osd->Clear(); osd->Clear();
#endif #endif

4
osd.h
View File

@ -4,13 +4,13 @@
* See the main source file 'vdr.c' for copyright information and * See the main source file 'vdr.c' for copyright information and
* how to reach the author. * how to reach the author.
* *
* $Id: osd.h 1.37 2002/11/24 10:32:29 kls Exp $ * $Id: osd.h 1.38 2002/12/08 12:21:26 kls Exp $
*/ */
#ifndef __OSD_H #ifndef __OSD_H
#define __OSD_H #define __OSD_H
#if defined(DEBUG_OSD) || defined(REMOTE_KBD) #if defined(DEBUG_OSD)
#include <ncurses.h> #include <ncurses.h>
#endif #endif
#include "config.h" #include "config.h"

View File

@ -4,7 +4,7 @@
* See the main source file 'vdr.c' for copyright information and * See the main source file 'vdr.c' for copyright information and
* how to reach the author. * how to reach the author.
* *
* $Id: remote.c 1.33 2002/12/07 11:48:10 kls Exp $ * $Id: remote.c 1.34 2002/12/08 13:37:13 kls Exp $
*/ */
#include "remote.h" #include "remote.h"
@ -13,13 +13,7 @@
#include <string.h> #include <string.h>
#include <sys/types.h> #include <sys/types.h>
#include <sys/time.h> #include <sys/time.h>
#include <termios.h>
#include <unistd.h> #include <unistd.h>
#if defined REMOTE_KBD
#include <ncurses.h>
#endif
#include "tools.h" #include "tools.h"
// --- cRemote --------------------------------------------------------------- // --- cRemote ---------------------------------------------------------------
@ -155,30 +149,65 @@ cRemotes Remotes;
// --- cKbdRemote ------------------------------------------------------------ // --- cKbdRemote ------------------------------------------------------------
#if defined REMOTE_KBD
cKbdRemote::cKbdRemote(void) cKbdRemote::cKbdRemote(void)
:cRemote("KBD") :cRemote("KBD")
{ {
active = false;
tcgetattr(STDIN_FILENO, &savedTm);
struct termios tm;
if (tcgetattr(STDIN_FILENO, &tm) == 0) {
tm.c_iflag = 0;
tm.c_lflag &= ~(ICANON | ECHO);
tm.c_cc[VMIN] = 0;
tm.c_cc[VTIME] = 0;
tcsetattr(STDIN_FILENO, TCSANOW, &tm);
}
Start(); Start();
} }
cKbdRemote::~cKbdRemote() cKbdRemote::~cKbdRemote()
{ {
Cancel(); active = false;
Cancel(3);
tcsetattr(STDIN_FILENO, TCSANOW, &savedTm);
} }
void cKbdRemote::Action(void) void cKbdRemote::Action(void)
{ {
dsyslog("KBD remote control thread started (pid=%d)", getpid()); dsyslog("KBD remote control thread started (pid=%d)", getpid());
cPoller Poller(STDIN_FILENO); cPoller Poller(STDIN_FILENO);
for (;;) {//XXX active = true;
int Command = getch(); while (active) {
if (Command != EOF) if (Poller.Poll(100)) {
Put(Command); uint64 Command = 0;
Poller.Poll(100); uint i = 0;
} int t0 = time_ms();
while (active && i < sizeof(Command)) {
uchar ch;
int r = read(STDIN_FILENO, &ch, 1);
if (r == 1) {
Command <<= 8;
Command |= ch;
i++;
}
else if (r == 0) {
// don't know why, but sometimes special keys that start with
// 0x1B ('ESC') cause a short gap between the 0x1B and the rest
// of their codes, so we'll need to wait some 100ms to see if
// there is more coming up - or whether this really is the 'ESC'
// key (if somebody knows how to clean this up, please let me know):
if (Command == 0x1B && time_ms() - t0 < 100)
continue;
if (Command)
Put(Command);
break;
}
else {
LOG_ERROR;
break;
}
}
}
}
dsyslog("KBD remote control thread ended (pid=%d)", getpid()); dsyslog("KBD remote control thread ended (pid=%d)", getpid());
} }
#endif

View File

@ -4,13 +4,14 @@
* See the main source file 'vdr.c' for copyright information and * See the main source file 'vdr.c' for copyright information and
* how to reach the author. * how to reach the author.
* *
* $Id: remote.h 1.21 2002/12/01 10:39:10 kls Exp $ * $Id: remote.h 1.22 2002/12/08 13:37:02 kls Exp $
*/ */
#ifndef __REMOTE_H #ifndef __REMOTE_H
#define __REMOTE_H #define __REMOTE_H
#include <stdio.h> #include <stdio.h>
#include <termios.h>
#include <time.h> #include <time.h>
#include "keys.h" #include "keys.h"
#include "thread.h" #include "thread.h"
@ -50,16 +51,14 @@ class cRemotes : public cList<cRemote> {};
extern cRemotes Remotes; extern cRemotes Remotes;
#if defined REMOTE_KBD
class cKbdRemote : public cRemote, private cThread { class cKbdRemote : public cRemote, private cThread {
private: private:
bool active;
struct termios savedTm;
virtual void Action(void); virtual void Action(void);
public: public:
cKbdRemote(void); cKbdRemote(void);
virtual ~cKbdRemote(); virtual ~cKbdRemote();
}; };
#endif
#endif //__REMOTE_H #endif //__REMOTE_H

19
vdr.c
View File

@ -22,13 +22,14 @@
* *
* The project's page is at http://www.cadsoft.de/people/kls/vdr * The project's page is at http://www.cadsoft.de/people/kls/vdr
* *
* $Id: vdr.c 1.136 2002/12/01 10:44:48 kls Exp $ * $Id: vdr.c 1.137 2002/12/08 13:34:39 kls Exp $
*/ */
#include <getopt.h> #include <getopt.h>
#include <locale.h> #include <locale.h>
#include <signal.h> #include <signal.h>
#include <stdlib.h> #include <stdlib.h>
#include <termios.h>
#include <unistd.h> #include <unistd.h>
#include "audio.h" #include "audio.h"
#include "channels.h" #include "channels.h"
@ -77,6 +78,11 @@ static void Watchdog(int signum)
int main(int argc, char *argv[]) int main(int argc, char *argv[])
{ {
// Save terminal settings:
struct termios savedTm;
tcgetattr(STDIN_FILENO, &savedTm);
// Initiate locale: // Initiate locale:
setlocale(LC_ALL, ""); setlocale(LC_ALL, "");
@ -294,7 +300,7 @@ int main(int argc, char *argv[])
// Daemon mode: // Daemon mode:
if (DaemonMode) { if (DaemonMode) {
#if !defined(DEBUG_OSD) && !defined(REMOTE_KBD) #if !defined(DEBUG_OSD)
pid_t pid = fork(); pid_t pid = fork();
if (pid < 0) { if (pid < 0) {
fprintf(stderr, "%m\n"); fprintf(stderr, "%m\n");
@ -307,7 +313,7 @@ int main(int argc, char *argv[])
fclose(stdout); fclose(stdout);
fclose(stderr); fclose(stderr);
#else #else
fprintf(stderr, "vdr: can't run in daemon mode with DEBUG_OSD or REMOTE_KBD on!\n"); fprintf(stderr, "vdr: can't run in daemon mode with DEBUG_OSD on!\n");
return 2; return 2;
#endif #endif
} }
@ -378,8 +384,10 @@ int main(int argc, char *argv[])
new cRcuRemote("/dev/ttyS1"); new cRcuRemote("/dev/ttyS1");
#elif defined(REMOTE_LIRC) #elif defined(REMOTE_LIRC)
new cLircRemote("/dev/lircd"); new cLircRemote("/dev/lircd");
#elif defined(REMOTE_KBD) #endif
new cKbdRemote; #if defined(REMOTE_KBD)
if (!DaemonMode)
new cKbdRemote;
#endif #endif
Interface->LearnKeys(); Interface->LearnKeys();
@ -716,6 +724,7 @@ int main(int argc, char *argv[])
isyslog("exiting"); isyslog("exiting");
if (SysLogLevel > 0) if (SysLogLevel > 0)
closelog(); closelog();
tcsetattr(STDIN_FILENO, TCSANOW, &savedTm);
if (cThread::EmergencyExit()) { if (cThread::EmergencyExit()) {
esyslog("emergency exit!"); esyslog("emergency exit!");
return 1; return 1;