summaryrefslogtreecommitdiffstats
path: root/src/plugins/generic
diff options
context:
space:
mode:
authorPaul Olav Tvete <paul.tvete@nokia.com>2010-10-13 13:34:38 (GMT)
committerPaul Olav Tvete <paul.tvete@nokia.com>2010-10-13 13:34:38 (GMT)
commitc118708a9886643db887a89b02f31a1879604116 (patch)
treeba71c89be3ed47b06947fb81d25bb32d9f14f445 /src/plugins/generic
parent5a8078cb2cf1c95e8d853b9b0bd8c8303f52aceb (diff)
downloadQt-c118708a9886643db887a89b02f31a1879604116.zip
Qt-c118708a9886643db887a89b02f31a1879604116.tar.gz
Qt-c118708a9886643db887a89b02f31a1879604116.tar.bz2
Don't clobber the tty by default
Add a ttymode option to LinuxInputKeyboard which turns on setting the keyboard mode and turns off Ctrl-C
Diffstat (limited to 'src/plugins/generic')
-rw-r--r--src/plugins/generic/linuxinput/qlinuxinput.cpp62
1 files changed, 34 insertions, 28 deletions
diff --git a/src/plugins/generic/linuxinput/qlinuxinput.cpp b/src/plugins/generic/linuxinput/qlinuxinput.cpp
index b3ef6bd..bd57fa3 100644
--- a/src/plugins/generic/linuxinput/qlinuxinput.cpp
+++ b/src/plugins/generic/linuxinput/qlinuxinput.cpp
@@ -404,12 +404,16 @@ QLinuxInputKeyboardHandler::QLinuxInputKeyboardHandler(const QString &key, const
int repeat_delay = -1;
int repeat_rate = -1;
+ bool ttymode = false;
+
QStringList args = specification.split(QLatin1Char(':'));
foreach (const QString &arg, args) {
if (arg.startsWith(QLatin1String("repeat-delay=")))
repeat_delay = arg.mid(13).toInt();
else if (arg.startsWith(QLatin1String("repeat-rate=")))
repeat_rate = arg.mid(12).toInt();
+ else if (arg.startsWith(QLatin1String("ttymode")))
+ ttymode = true;
else if (arg.startsWith(QLatin1String("/dev/")))
dev = arg;
}
@@ -427,34 +431,36 @@ QLinuxInputKeyboardHandler::QLinuxInputKeyboardHandler(const QString &key, const
notifier = new QSocketNotifier(m_fd, QSocketNotifier::Read, this);
connect(notifier, SIGNAL(activated(int)), this, SLOT(readKeycode()));
- // play nice in case we are started from a shell (e.g. for debugging)
- m_tty_fd = isatty(0) ? 0 : -1;
-
- if (m_tty_fd >= 0) {
- // save tty config for restore.
- tcgetattr(m_tty_fd, &m_tty_attr);
-
- struct ::termios termdata;
- tcgetattr(m_tty_fd, &termdata);
-
- // record the original mode so we can restore it again in the destructor.
- ::ioctl(m_tty_fd, KDGKBMODE, &m_orig_kbmode);
-
- // setting this tranlation mode is even needed in INPUT mode to prevent
- // the shell from also interpreting codes, if the process has a tty
- // attached: e.g. Ctrl+C wouldn't copy, but kill the application.
- ::ioctl(m_tty_fd, KDSKBMODE, K_MEDIUMRAW);
-
- // set the tty layer to pass-through
- termdata.c_iflag = (IGNPAR | IGNBRK) & (~PARMRK) & (~ISTRIP);
- termdata.c_oflag = 0;
- termdata.c_cflag = CREAD | CS8;
- termdata.c_lflag = 0;
- termdata.c_cc[VTIME]=0;
- termdata.c_cc[VMIN]=1;
- cfsetispeed(&termdata, 9600);
- cfsetospeed(&termdata, 9600);
- tcsetattr(m_tty_fd, TCSANOW, &termdata);
+ if (ttymode) {
+ // play nice in case we are started from a shell (e.g. for debugging)
+ m_tty_fd = isatty(0) ? 0 : -1;
+
+ if (m_tty_fd >= 0) {
+ // save tty config for restore.
+ tcgetattr(m_tty_fd, &m_tty_attr);
+
+ struct ::termios termdata;
+ tcgetattr(m_tty_fd, &termdata);
+
+ // record the original mode so we can restore it again in the destructor.
+ ::ioctl(m_tty_fd, KDGKBMODE, &m_orig_kbmode);
+
+ // setting this tranlation mode is even needed in INPUT mode to prevent
+ // the shell from also interpreting codes, if the process has a tty
+ // attached: e.g. Ctrl+C wouldn't copy, but kill the application.
+ ::ioctl(m_tty_fd, KDSKBMODE, K_MEDIUMRAW);
+
+ // set the tty layer to pass-through
+ termdata.c_iflag = (IGNPAR | IGNBRK) & (~PARMRK) & (~ISTRIP);
+ termdata.c_oflag = 0;
+ termdata.c_cflag = CREAD | CS8;
+ termdata.c_lflag = 0;
+ termdata.c_cc[VTIME]=0;
+ termdata.c_cc[VMIN]=1;
+ cfsetispeed(&termdata, 9600);
+ cfsetospeed(&termdata, 9600);
+ tcsetattr(m_tty_fd, TCSANOW, &termdata);
+ }
}
} else {
qWarning("Cannot open keyboard input device '%s': %s", qPrintable(dev), strerror(errno));