rinputd_1.0.5/0000775000175000017500000000000011736736624013457 5ustar cndouglacndouglarinputd_1.0.5/common/0000775000175000017500000000000011736727464014751 5ustar cndouglacndouglarinputd_1.0.5/common/Connection.h0000664000175000017500000000572511736727464017232 0ustar cndouglacndougla/* * Copyright (C) 2009 Chase Douglas * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 as published * by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License along * with this program; if not, write to the Free Software Foundation, Inc., * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the * OpenSSL library under certain conditions as described in each * individual source file, and distribute linked combinations * including the two. * You must obey the GNU General Public License in all respects * for all of the code used other than OpenSSL. If you modify * file(s) with this exception, you may extend this exception to your * version of the file(s), but you are not obligated to do so. If you * do not wish to do so, delete this exception statement from your * version. */ #ifndef CONNECTION_H #define CONNECTION_H #include #include class QSslConfiguration; enum ConnectionType { CLIENT, SERVER }; enum ConnectionState { BARE, ENCRYPTED, AUTHENTICATING, AUTHENTICATED }; class Connection : public QObject { Q_OBJECT public: Connection(int sock, QSslConfiguration &configuration); Connection(QString &hostname, quint16 port); ~Connection(); virtual void startEncryption(); virtual void startAuthentication(); void startCommunication(); QHostAddress peerAddress(); qint64 bytesAvailable(); qint64 peek(char *data, qint64 maxSize); qint64 read(char *data, qint64 maxSize); QByteArray read(qint64 maxSize); QByteArray readAll(); bool write(const QByteArray &message); void disconnectLater(); private: bool sockWrite(const char *data, qint64 maxSize); bool sockWrite(const char *data); bool sockWrite(const QByteArray &byteArray); QSslSocket socket; ConnectionState state; bool communicating; ConnectionType type; quint8 credentialsSize; QByteArray buffer; public slots: void checkPassResult(bool ok); void disconnect(); protected slots: void sockConnected(); void sockDisconnected(); void sockReadyRead(); void sockError(); void sslErrors(const QList &errors); virtual void sockEncrypted(); void bytesWritten(qint64 size); signals: void connected(); void encrypted(); void checkPass(const QByteArray &user, const QByteArray &pass); void authenticated(); void readyRead(); void disconnectSignal(); void disconnected(); }; #endif // CONNECTION_H rinputd_1.0.5/common/macros.h0000664000175000017500000000315711736727464016414 0ustar cndouglacndougla/* * Copyright (C) 2009 Chase Douglas * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 as published * by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License along * with this program; if not, write to the Free Software Foundation, Inc., * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the * OpenSSL library under certain conditions as described in each * individual source file, and distribute linked combinations * including the two. * You must obey the GNU General Public License in all respects * for all of the code used other than OpenSSL. If you modify * file(s) with this exception, you may extend this exception to your * version of the file(s), but you are not obligated to do so. If you * do not wish to do so, delete this exception statement from your * version. */ #ifndef MACROS_H #define MACROS_H #include #define CONFIG_SET(x, y) QCoreApplication::instance()->setProperty((x), (QVariant(y))) #define CONFIG_VALID(x) QCoreApplication::instance()->property(x).isValid() #define CONFIG(x) QCoreApplication::instance()->property(x) #endif // MACROS_H rinputd_1.0.5/common/Connection.cpp0000664000175000017500000003005111736727464017553 0ustar cndouglacndougla/* * Copyright (C) 2009 Chase Douglas * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 as published * by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License along * with this program; if not, write to the Free Software Foundation, Inc., * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the * OpenSSL library under certain conditions as described in each * individual source file, and distribute linked combinations * including the two. * You must obey the GNU General Public License in all respects * for all of the code used other than OpenSSL. If you modify * file(s) with this exception, you may extend this exception to your * version of the file(s), but you are not obligated to do so. If you * do not wish to do so, delete this exception statement from your * version. */ #include #include #include #include #include #include #include #include "Connection.h" #include "macros.h" Connection::Connection(int sock, QSslConfiguration &configuration) : state(BARE), communicating(FALSE), type(SERVER), credentialsSize(0) { socket.setSocketDescriptor(sock); socket.setSslConfiguration(configuration); connect(&socket, SIGNAL(connected()), SLOT(sockConnected())); connect(&socket, SIGNAL(disconnected()), SLOT(sockDisconnected())); connect(&socket, SIGNAL(error(QAbstractSocket::SocketError)), SLOT(sockError())); connect(&socket, SIGNAL(sslErrors(const QList &)), SLOT(sslErrors(const QList &))); connect(&socket, SIGNAL(encrypted()), SLOT(sockEncrypted())); connect(&socket, SIGNAL(readyRead()), SLOT(sockReadyRead())); connect(&socket, SIGNAL(bytesWritten(qint64)), SLOT(bytesWritten(qint64))); connect(this, SIGNAL(disconnectSignal()), SLOT(disconnect())); int yes = 1; if (setsockopt(sock, SOL_SOCKET, SO_KEEPALIVE, &yes, sizeof(yes))) { qWarning("Warning: Keepalive socket option set failed, dead connections will persist: %s", strerror(errno)); } int time = 1; #ifdef TCP_KEEPIDLE if (setsockopt(sock, SOL_TCP, TCP_KEEPIDLE, &time, sizeof(time))) { #else if (setsockopt(sock, IPPROTO_TCP, TCP_KEEPALIVE, &time, sizeof(time))) { #endif qWarning("Warning: Keepalive idle time could not be set: %s", strerror(errno)); } } Connection::Connection(QString &hostname, quint16 port) : state(BARE), communicating(FALSE), type(CLIENT) { connect(&socket, SIGNAL(connected()), SLOT(sockConnected())); connect(&socket, SIGNAL(disconnected()), SLOT(sockDisconnected())); connect(&socket, SIGNAL(error(QAbstractSocket::SocketError)), SLOT(sockError())); connect(&socket, SIGNAL(sslErrors(const QList &)), SLOT(sslErrors(const QList &))); connect(&socket, SIGNAL(encrypted()), SLOT(sockEncrypted())); connect(&socket, SIGNAL(readyRead()), SLOT(sockReadyRead())); connect(&socket, SIGNAL(bytesWritten(qint64)), SLOT(bytesWritten(qint64))); connect(this, SIGNAL(disconnectSignal()), SLOT(disconnect())); int yes = 1; if (setsockopt(socket.socketDescriptor(), SOL_SOCKET, SO_KEEPALIVE, &yes, sizeof(yes))) { qWarning("Warning: Keepalive socket option set failed, dead connections will persist: %s", strerror(errno)); } int time = 1; #ifdef TCP_KEEPIDLE if (setsockopt(socket.socketDescriptor(), SOL_TCP, TCP_KEEPIDLE, &time, sizeof(time))) { #else if (setsockopt(socket.socketDescriptor(), IPPROTO_TCP, TCP_KEEPALIVE, &time, sizeof(time))) { #endif qWarning("Warning: Keepalive idle time could not be set: %s", strerror(errno)); } socket.connectToHost(hostname, port); } void Connection::sockConnected() { emit connected(); } void Connection::sockDisconnected() { qWarning("%s disconnected", qPrintable(socket.peerAddress().toString())); emit disconnected(); } void Connection::startEncryption() { if (type == CLIENT) { socket.startClientEncryption(); } else { socket.startServerEncryption(); } qDebug("Starting encryption for %s", qPrintable(socket.peerAddress().toString())); } void Connection::sockEncrypted() { state = ENCRYPTED; qDebug("Connection from %s is encrypted", qPrintable(socket.peerAddress().toString())); emit encrypted(); } void Connection::startAuthentication() { state = AUTHENTICATING; if (type == CLIENT) { QByteArray message; message.append('\0'); message.append(CONFIG("user").toString()); message.append('\0'); message.append(CONFIG("pass").toString()); message.append('\0'); if (message.length() > 255) { qCritical("Error: Credentials are too long"); disconnect(); return; } message.prepend((unsigned char)message.length()); sockWrite(message); } qDebug("Starting authentication with %s", qPrintable(socket.peerAddress().toString())); } void Connection::startCommunication() { communicating = TRUE; if (socket.bytesAvailable()) { sockReadyRead(); } qDebug("Starting communication with %s", qPrintable(socket.peerAddress().toString())); } QHostAddress Connection::peerAddress() { return socket.peerAddress(); } void Connection::sockReadyRead() { if (state == AUTHENTICATING) { if (type == CLIENT) { char message; qint64 ret = socket.read(&message, 1); if (ret < 0) { qCritical("Error: Failed to receive authentication message from server %s", qPrintable(socket.peerAddress().toString())); disconnect(); } else if (ret == 1 && message == 'a') { state = AUTHENTICATED; qWarning("Authenticated to server %s", qPrintable(socket.peerAddress().toString())); emit authenticated(); } else { qCritical("Error: Failed to authenticate to server %s", qPrintable(socket.peerAddress().toString())); } } else { if (!credentialsSize) { qint64 ret = socket.read((char *)&credentialsSize, 1); if (ret < 0 || ret > 1) { qCritical("Failed to read size of credentials from client %s", qPrintable(socket.peerAddress().toString())); disconnect(); return; } if (ret == 0) { return; } if (credentialsSize < 5) { qCritical("Size of credentials from client %s invalid", qPrintable(socket.peerAddress().toString())); disconnect(); return; } } buffer += socket.read(credentialsSize - buffer.length()); if (buffer.length() == credentialsSize) { qDebug("Read credentials from client %s", qPrintable(socket.peerAddress().toString())); if (buffer.at(0) != '\0' || buffer.count('\0') != 3) { qCritical("Error: Credentials format incorrect"); disconnect(); return; } buffer.remove(0, 1); int index = buffer.indexOf('\0'); if (index < 0) { qCritical("Error: Credentials format incorrect"); buffer.clear(); disconnect(); return; } if (buffer.at(buffer.length() - 1) != '\0') { qCritical("Error: Credentials format incorrect"); disconnect(); return; } buffer.remove(buffer.length() - 1, 1); QByteArray user(buffer.left(index)); QByteArray pass(buffer.right(buffer.length() - (index + 1))); buffer.fill(0); emit checkPass(user, pass); user.fill(0); pass.fill(0); } } } else if (communicating) { emit readyRead(); } } void Connection::sockError() { if (socket.error() == QAbstractSocket::RemoteHostClosedError) { return; } qCritical("Error from %s: %s", qPrintable(socket.peerAddress().toString()), qPrintable(socket.errorString())); if (socket.error() == QAbstractSocket::ConnectionRefusedError) { emit disconnected(); } else { disconnect(); } } void Connection::sslErrors(const QList &errors) { bool ignore = TRUE; for (int i = 0; i < errors.count(); i++) { switch(errors[i].error()) { case QSslError::HostNameMismatch: case QSslError::SelfSignedCertificate: qCritical("Security Layer Warning for %s: %s", qPrintable(socket.peerAddress().toString()), qPrintable(errors[i].errorString())); break; default: qCritical("An SSL error from %s occurred: %s", qPrintable(socket.peerAddress().toString()), qPrintable(errors[i].errorString())); ignore = FALSE; break; } } if (ignore) { socket.ignoreSslErrors(); } else { qCritical("Exiting connection due to error(s)"); disconnect(); } } void Connection::bytesWritten(qint64 size) { qDebug("%lld bytes written to %s", size, qPrintable(socket.peerAddress().toString())); } void Connection::checkPassResult(bool ok) { if (ok) { state = AUTHENTICATED; sockWrite("a"); qWarning("Client %s authenticated", qPrintable(socket.peerAddress().toString())); emit authenticated(); } else { sockWrite("i"); qCritical("Error: Client %s failed to authenticate", qPrintable(socket.peerAddress().toString())); disconnect(); } } bool Connection::sockWrite(const char *data, qint64 maxSize) { qint64 written = 0; qDebug("Writing %lld bytes: '%s'", maxSize, data); while (written < maxSize) { qint64 ret; ret = socket.write(data + written, maxSize - written); if (ret < 0) { qWarning("Failed to send complete data buffer"); return false; } written += ret; } return true; } bool Connection::sockWrite(const char *data) { return sockWrite(data, qstrlen(data)); } bool Connection::sockWrite(const QByteArray &byteArray) { return sockWrite(byteArray.data(), byteArray.length()); } qint64 Connection::bytesAvailable() { if (state == AUTHENTICATING) { return 0; } return socket.bytesAvailable(); } qint64 Connection::peek(char *data, qint64 maxSize) { if (state == AUTHENTICATING) { return 0; } return socket.peek(data, maxSize); } qint64 Connection::read(char *data, qint64 maxSize) { if (state == AUTHENTICATING) { return 0; } return socket.read(data, maxSize); } QByteArray Connection::read(qint64 maxSize) { if (state == AUTHENTICATING) { return QByteArray(); } return socket.read(maxSize); } QByteArray Connection::readAll() { if (state == AUTHENTICATING) { return QByteArray(); } return socket.readAll(); } bool Connection::write(const QByteArray &message) { if (state == AUTHENTICATING) { return false; } return sockWrite(message); } void Connection::disconnect() { qWarning("Closing connection to %s", qPrintable(socket.peerAddress().toString())); socket.flush(); socket.disconnectFromHost(); } void Connection::disconnectLater() { emit disconnectSignal(); } Connection::~Connection() { disconnect(); } rinputd_1.0.5/common/rinput.h0000664000175000017500000006030311736727464016445 0ustar cndouglacndougla#ifndef RINPUT_H #define RINPUT_H /* * Copyright (c) 1999-2002 Vojtech Pavlik * Copyright (c) 2009 Chase Douglas * * This program is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 as published by * the Free Software Foundation. */ /* * This file is derived from linux/input.h from Linux 2.6.28 */ #include #include #define RINPUT_PROTOCOL_VERSION 1 /* * Event types */ #define RINPUT_EV_SYN 0x00 #define RINPUT_EV_KEY 0x01 #define RINPUT_EV_REL 0x02 #define RINPUT_EV_ABS 0x03 #define RINPUT_EV_MSC 0x04 #define RINPUT_EV_SW 0x05 #define RINPUT_EV_LED 0x11 #define RINPUT_EV_SND 0x12 #define RINPUT_EV_UTF8 0x80 typedef enum rinput_type { RINPUT_VERSION = 0, RINPUT_SET_CAPABILITY = 1, RINPUT_SET_ABS_PARAM = 2, RINPUT_CREATE = 3, RINPUT_DESTROY = 4, RINPUT_EVENT = 5, RINPUT_ERROR = 6 } rinput_type_t; typedef enum rinput_abs_param_type { RINPUT_ABS_PARAM_MAX = 0, RINPUT_ABS_PARAM_MIN = 1, RINPUT_ABS_PARAM_FUZZ = 2, RINPUT_ABS_PARAM_FLAT = 3 } rinput_abs_param_type_t; typedef struct rinput_capability { uint16_t type; uint16_t code; } rinput_capability_t; typedef struct rinput_abs_param { uint16_t axis; uint16_t type; int32_t value; } rinput_abs_param_t; typedef struct rinput_event { uint16_t type; uint16_t code; int32_t value; } rinput_event_t; typedef struct rinput_utf8 { uint16_t type; int16_t value; uint8_t character[4]; } rinput_utf8_t; typedef enum rinput_error_type { RINPUT_INTERNAL_ERROR = 0, RINPUT_INPUT_DEVICE_ALLOC_FAILED = 1, RINPUT_MESSAGE_TYPE_INVALID = 2, RINPUT_CAPABILITY_TYPE_INVALID = 3, RINPUT_SET_CAPABILITY_FAILED = 4, RINPUT_ABS_AXIS_INVALID = 5, RINPUT_ABS_PARAM_TYPE_INVALID = 6, RINPUT_INPUT_DEVICE_CREATE_FAILED = 7, RINPUT_INPUT_EVENTS_FAILED = 8, RINPUT_REVOKED_AUTHORIZATION = 9 } rinput_error_type_t; typedef struct rinput_error { rinput_error_type_t type; uint16_t code1; uint16_t code2; } rinput_error_t; typedef struct rinput_message { rinput_type_t type; union { uint32_t protocol_version; rinput_capability_t capability; rinput_abs_param_t abs_param; rinput_event_t event; rinput_utf8_t utf8; rinput_error_t error; } data; } rinput_message_t; static inline void hton_rinput(rinput_message_t *message) { switch (message->type) { case RINPUT_VERSION: message->data.protocol_version = htonl(message->data.protocol_version); break; case RINPUT_SET_CAPABILITY: message->data.capability.type = htons(message->data.capability.type); message->data.capability.code = htons(message->data.capability.code); break; case RINPUT_SET_ABS_PARAM: message->data.abs_param.axis = htons(message->data.abs_param.axis); message->data.abs_param.type = htons(message->data.abs_param.type); message->data.abs_param.value = htonl(message->data.abs_param.value); break; case RINPUT_EVENT: if (message->data.event.type != RINPUT_EV_UTF8) { message->data.event.value = htonl(message->data.event.value); } message->data.event.type = htons(message->data.event.type); message->data.event.code = htons(message->data.event.code); break; case RINPUT_ERROR: message->data.error.type = (rinput_error_type_t)htonl(message->data.error.type); message->data.error.code1 = htons(message->data.error.code1); message->data.error.code2 = htons(message->data.error.code2); break; case RINPUT_CREATE: case RINPUT_DESTROY: break; } message->type = (rinput_type_t)htonl(message->type); } static inline void ntoh_rinput(rinput_message_t *message) { message->type = (rinput_type_t)ntohl(message->type); switch (message->type) { case RINPUT_VERSION: message->data.protocol_version = ntohl(message->data.protocol_version); break; case RINPUT_SET_CAPABILITY: message->data.capability.type = ntohs(message->data.capability.type); message->data.capability.code = ntohs(message->data.capability.code); break; case RINPUT_SET_ABS_PARAM: message->data.abs_param.axis = ntohs(message->data.abs_param.axis); message->data.abs_param.type = ntohs(message->data.abs_param.type); message->data.abs_param.value = ntohl(message->data.abs_param.value); break; case RINPUT_EVENT: message->data.event.type = ntohs(message->data.event.type); message->data.event.code = ntohs(message->data.event.code); if (message->data.event.type != RINPUT_EV_UTF8) { message->data.event.value = ntohl(message->data.event.value); } break; case RINPUT_ERROR: message->data.error.type = (rinput_error_type_t)ntohl(message->data.error.type); message->data.error.code1 = ntohs(message->data.error.code1); message->data.error.code2 = ntohs(message->data.error.code2); break; case RINPUT_CREATE: case RINPUT_DESTROY: break; } } /* * Keys and buttons * * Most of the keys/buttons are modeled after USB HUT 1.12 * (see http://www.usb.org/developers/hidpage). * Abbreviations in the comments: * AC - Application Control * AL - Application Launch Button * SC - System Control */ #define RINPUT_KEY_RESERVED 0 #define RINPUT_KEY_ESC 1 #define RINPUT_KEY_1 2 #define RINPUT_KEY_2 3 #define RINPUT_KEY_3 4 #define RINPUT_KEY_4 5 #define RINPUT_KEY_5 6 #define RINPUT_KEY_6 7 #define RINPUT_KEY_7 8 #define RINPUT_KEY_8 9 #define RINPUT_KEY_9 10 #define RINPUT_KEY_0 11 #define RINPUT_KEY_MINUS 12 #define RINPUT_KEY_EQUAL 13 #define RINPUT_KEY_BACKSPACE 14 #define RINPUT_KEY_TAB 15 #define RINPUT_KEY_Q 16 #define RINPUT_KEY_W 17 #define RINPUT_KEY_E 18 #define RINPUT_KEY_R 19 #define RINPUT_KEY_T 20 #define RINPUT_KEY_Y 21 #define RINPUT_KEY_U 22 #define RINPUT_KEY_I 23 #define RINPUT_KEY_O 24 #define RINPUT_KEY_P 25 #define RINPUT_KEY_LEFTBRACE 26 #define RINPUT_KEY_RIGHTBRACE 27 #define RINPUT_KEY_ENTER 28 #define RINPUT_KEY_LEFTCTRL 29 #define RINPUT_KEY_A 30 #define RINPUT_KEY_S 31 #define RINPUT_KEY_D 32 #define RINPUT_KEY_F 33 #define RINPUT_KEY_G 34 #define RINPUT_KEY_H 35 #define RINPUT_KEY_J 36 #define RINPUT_KEY_K 37 #define RINPUT_KEY_L 38 #define RINPUT_KEY_SEMICOLON 39 #define RINPUT_KEY_APOSTROPHE 40 #define RINPUT_KEY_GRAVE 41 #define RINPUT_KEY_LEFTSHIFT 42 #define RINPUT_KEY_BACKSLASH 43 #define RINPUT_KEY_Z 44 #define RINPUT_KEY_X 45 #define RINPUT_KEY_C 46 #define RINPUT_KEY_V 47 #define RINPUT_KEY_B 48 #define RINPUT_KEY_N 49 #define RINPUT_KEY_M 50 #define RINPUT_KEY_COMMA 51 #define RINPUT_KEY_DOT 52 #define RINPUT_KEY_SLASH 53 #define RINPUT_KEY_RIGHTSHIFT 54 #define RINPUT_KEY_KPASTERISK 55 #define RINPUT_KEY_LEFTALT 56 #define RINPUT_KEY_SPACE 57 #define RINPUT_KEY_CAPSLOCK 58 #define RINPUT_KEY_F1 59 #define RINPUT_KEY_F2 60 #define RINPUT_KEY_F3 61 #define RINPUT_KEY_F4 62 #define RINPUT_KEY_F5 63 #define RINPUT_KEY_F6 64 #define RINPUT_KEY_F7 65 #define RINPUT_KEY_F8 66 #define RINPUT_KEY_F9 67 #define RINPUT_KEY_F10 68 #define RINPUT_KEY_NUMLOCK 69 #define RINPUT_KEY_SCROLLLOCK 70 #define RINPUT_KEY_KP7 71 #define RINPUT_KEY_KP8 72 #define RINPUT_KEY_KP9 73 #define RINPUT_KEY_KPMINUS 74 #define RINPUT_KEY_KP4 75 #define RINPUT_KEY_KP5 76 #define RINPUT_KEY_KP6 77 #define RINPUT_KEY_KPPLUS 78 #define RINPUT_KEY_KP1 79 #define RINPUT_KEY_KP2 80 #define RINPUT_KEY_KP3 81 #define RINPUT_KEY_KP0 82 #define RINPUT_KEY_KPDOT 83 #define RINPUT_KEY_ZENKAKUHANKAKU 85 #define RINPUT_KEY_102ND 86 #define RINPUT_KEY_F11 87 #define RINPUT_KEY_F12 88 #define RINPUT_KEY_RO 89 #define RINPUT_KEY_KATAKANA 90 #define RINPUT_KEY_HIRAGANA 91 #define RINPUT_KEY_HENKAN 92 #define RINPUT_KEY_KATAKANAHIRAGANA 93 #define RINPUT_KEY_MUHENKAN 94 #define RINPUT_KEY_KPJPCOMMA 95 #define RINPUT_KEY_KPENTER 96 #define RINPUT_KEY_RIGHTCTRL 97 #define RINPUT_KEY_KPSLASH 98 #define RINPUT_KEY_SYSRQ 99 #define RINPUT_KEY_RIGHTALT 100 #define RINPUT_KEY_LINEFEED 101 #define RINPUT_KEY_HOME 102 #define RINPUT_KEY_UP 103 #define RINPUT_KEY_PAGEUP 104 #define RINPUT_KEY_LEFT 105 #define RINPUT_KEY_RIGHT 106 #define RINPUT_KEY_END 107 #define RINPUT_KEY_DOWN 108 #define RINPUT_KEY_PAGEDOWN 109 #define RINPUT_KEY_INSERT 110 #define RINPUT_KEY_DELETE 111 #define RINPUT_KEY_MACRO 112 #define RINPUT_KEY_MUTE 113 #define RINPUT_KEY_VOLUMEDOWN 114 #define RINPUT_KEY_VOLUMEUP 115 #define RINPUT_KEY_POWER 116 /* SC System Power Down */ #define RINPUT_KEY_KPEQUAL 117 #define RINPUT_KEY_KPPLUSMINUS 118 #define RINPUT_KEY_PAUSE 119 #define RINPUT_KEY_SCALE 120 /* AL Compiz Scale (Expose) */ #define RINPUT_KEY_KPCOMMA 121 #define RINPUT_KEY_HANGEUL 122 #define RINPUT_KEY_HANGUEL KEY_HANGEUL #define RINPUT_KEY_HANJA 123 #define RINPUT_KEY_YEN 124 #define RINPUT_KEY_LEFTMETA 125 #define RINPUT_KEY_RIGHTMETA 126 #define RINPUT_KEY_COMPOSE 127 #define RINPUT_KEY_STOP 128 /* AC Stop */ #define RINPUT_KEY_AGAIN 129 #define RINPUT_KEY_PROPS 130 /* AC Properties */ #define RINPUT_KEY_UNDO 131 /* AC Undo */ #define RINPUT_KEY_FRONT 132 #define RINPUT_KEY_COPY 133 /* AC Copy */ #define RINPUT_KEY_OPEN 134 /* AC Open */ #define RINPUT_KEY_PASTE 135 /* AC Paste */ #define RINPUT_KEY_FIND 136 /* AC Search */ #define RINPUT_KEY_CUT 137 /* AC Cut */ #define RINPUT_KEY_HELP 138 /* AL Integrated Help Center */ #define RINPUT_KEY_MENU 139 /* Menu (show menu) */ #define RINPUT_KEY_CALC 140 /* AL Calculator */ #define RINPUT_KEY_SETUP 141 #define RINPUT_KEY_SLEEP 142 /* SC System Sleep */ #define RINPUT_KEY_WAKEUP 143 /* System Wake Up */ #define RINPUT_KEY_FILE 144 /* AL Local Machine Browser */ #define RINPUT_KEY_SENDFILE 145 #define RINPUT_KEY_DELETEFILE 146 #define RINPUT_KEY_XFER 147 #define RINPUT_KEY_PROG1 148 #define RINPUT_KEY_PROG2 149 #define RINPUT_KEY_WWW 150 /* AL Internet Browser */ #define RINPUT_KEY_MSDOS 151 #define RINPUT_KEY_COFFEE 152 /* AL Terminal Lock/Screensaver */ #define RINPUT_KEY_SCREENLOCK KEY_COFFEE #define RINPUT_KEY_DIRECTION 153 #define RINPUT_KEY_CYCLEWINDOWS 154 #define RINPUT_KEY_MAIL 155 #define RINPUT_KEY_BOOKMARKS 156 /* AC Bookmarks */ #define RINPUT_KEY_COMPUTER 157 #define RINPUT_KEY_BACK 158 /* AC Back */ #define RINPUT_KEY_FORWARD 159 /* AC Forward */ #define RINPUT_KEY_CLOSECD 160 #define RINPUT_KEY_EJECTCD 161 #define RINPUT_KEY_EJECTCLOSECD 162 #define RINPUT_KEY_NEXTSONG 163 #define RINPUT_KEY_PLAYPAUSE 164 #define RINPUT_KEY_PREVIOUSSONG 165 #define RINPUT_KEY_STOPCD 166 #define RINPUT_KEY_RECORD 167 #define RINPUT_KEY_REWIND 168 #define RINPUT_KEY_PHONE 169 /* Media Select Telephone */ #define RINPUT_KEY_ISO 170 #define RINPUT_KEY_CONFIG 171 /* AL Consumer Control Configuration */ #define RINPUT_KEY_HOMEPAGE 172 /* AC Home */ #define RINPUT_KEY_REFRESH 173 /* AC Refresh */ #define RINPUT_KEY_EXIT 174 /* AC Exit */ #define RINPUT_KEY_MOVE 175 #define RINPUT_KEY_EDIT 176 #define RINPUT_KEY_SCROLLUP 177 #define RINPUT_KEY_SCROLLDOWN 178 #define RINPUT_KEY_KPLEFTPAREN 179 #define RINPUT_KEY_KPRIGHTPAREN 180 #define RINPUT_KEY_NEW 181 /* AC New */ #define RINPUT_KEY_REDO 182 /* AC Redo/Repeat */ #define RINPUT_KEY_F13 183 #define RINPUT_KEY_F14 184 #define RINPUT_KEY_F15 185 #define RINPUT_KEY_F16 186 #define RINPUT_KEY_F17 187 #define RINPUT_KEY_F18 188 #define RINPUT_KEY_F19 189 #define RINPUT_KEY_F20 190 #define RINPUT_KEY_F21 191 #define RINPUT_KEY_F22 192 #define RINPUT_KEY_F23 193 #define RINPUT_KEY_F24 194 #define RINPUT_KEY_PLAYCD 200 #define RINPUT_KEY_PAUSECD 201 #define RINPUT_KEY_PROG3 202 #define RINPUT_KEY_PROG4 203 #define RINPUT_KEY_DASHBOARD 204 /* AL Dashboard */ #define RINPUT_KEY_SUSPEND 205 #define RINPUT_KEY_CLOSE 206 /* AC Close */ #define RINPUT_KEY_PLAY 207 #define RINPUT_KEY_FASTFORWARD 208 #define RINPUT_KEY_BASSBOOST 209 #define RINPUT_KEY_PRINT 210 /* AC Print */ #define RINPUT_KEY_HP 211 #define RINPUT_KEY_CAMERA 212 #define RINPUT_KEY_SOUND 213 #define RINPUT_KEY_QUESTION 214 #define RINPUT_KEY_EMAIL 215 #define RINPUT_KEY_CHAT 216 #define RINPUT_KEY_SEARCH 217 #define RINPUT_KEY_CONNECT 218 #define RINPUT_KEY_FINANCE 219 /* AL Checkbook/Finance */ #define RINPUT_KEY_SPORT 220 #define RINPUT_KEY_SHOP 221 #define RINPUT_KEY_ALTERASE 222 #define RINPUT_KEY_CANCEL 223 /* AC Cancel */ #define RINPUT_KEY_BRIGHTNESSDOWN 224 #define RINPUT_KEY_BRIGHTNESSUP 225 #define RINPUT_KEY_MEDIA 226 #define RINPUT_KEY_SWITCHVIDEOMODE 227 /* Cycle between available video outputs (Monitor/LCD/TV-out/etc) */ #define RINPUT_KEY_KBDILLUMTOGGLE 228 #define RINPUT_KEY_KBDILLUMDOWN 229 #define RINPUT_KEY_KBDILLUMUP 230 #define RINPUT_KEY_SEND 231 /* AC Send */ #define RINPUT_KEY_REPLY 232 /* AC Reply */ #define RINPUT_KEY_FORWARDMAIL 233 /* AC Forward Msg */ #define RINPUT_KEY_SAVE 234 /* AC Save */ #define RINPUT_KEY_DOCUMENTS 235 #define RINPUT_KEY_BATTERY 236 #define RINPUT_KEY_BLUETOOTH 237 #define RINPUT_KEY_WLAN 238 #define RINPUT_KEY_UWB 239 #define RINPUT_KEY_UNKNOWN 240 #define RINPUT_KEY_VIDEO_NEXT 241 /* drive next video source */ #define RINPUT_KEY_VIDEO_PREV 242 /* drive previous video source */ #define RINPUT_KEY_BRIGHTNESS_CYCLE 243 /* brightness up, after max is min */ #define RINPUT_KEY_BRIGHTNESS_ZERO 244 /* brightness off, use ambient */ #define RINPUT_KEY_DISPLAY_OFF 245 /* display device to off state */ #define RINPUT_KEY_WIMAX 246 /* Range 248 - 255 is reserved for special needs of AT keyboard driver */ #define RINPUT_BTN_MISC 0x100 #define RINPUT_BTN_0 0x100 #define RINPUT_BTN_1 0x101 #define RINPUT_BTN_2 0x102 #define RINPUT_BTN_3 0x103 #define RINPUT_BTN_4 0x104 #define RINPUT_BTN_5 0x105 #define RINPUT_BTN_6 0x106 #define RINPUT_BTN_7 0x107 #define RINPUT_BTN_8 0x108 #define RINPUT_BTN_9 0x109 #define RINPUT_BTN_MOUSE 0x110 #define RINPUT_BTN_LEFT 0x110 #define RINPUT_BTN_RIGHT 0x111 #define RINPUT_BTN_MIDDLE 0x112 #define RINPUT_BTN_SIDE 0x113 #define RINPUT_BTN_EXTRA 0x114 #define RINPUT_BTN_FORWARD 0x115 #define RINPUT_BTN_BACK 0x116 #define RINPUT_BTN_TASK 0x117 #define RINPUT_BTN_JOYSTICK 0x120 #define RINPUT_BTN_TRIGGER 0x120 #define RINPUT_BTN_THUMB 0x121 #define RINPUT_BTN_THUMB2 0x122 #define RINPUT_BTN_TOP 0x123 #define RINPUT_BTN_TOP2 0x124 #define RINPUT_BTN_PINKIE 0x125 #define RINPUT_BTN_BASE 0x126 #define RINPUT_BTN_BASE2 0x127 #define RINPUT_BTN_BASE3 0x128 #define RINPUT_BTN_BASE4 0x129 #define RINPUT_BTN_BASE5 0x12a #define RINPUT_BTN_BASE6 0x12b #define RINPUT_BTN_DEAD 0x12f #define RINPUT_BTN_GAMEPAD 0x130 #define RINPUT_BTN_A 0x130 #define RINPUT_BTN_B 0x131 #define RINPUT_BTN_C 0x132 #define RINPUT_BTN_X 0x133 #define RINPUT_BTN_Y 0x134 #define RINPUT_BTN_Z 0x135 #define RINPUT_BTN_TL 0x136 #define RINPUT_BTN_TR 0x137 #define RINPUT_BTN_TL2 0x138 #define RINPUT_BTN_TR2 0x139 #define RINPUT_BTN_SELECT 0x13a #define RINPUT_BTN_START 0x13b #define RINPUT_BTN_MODE 0x13c #define RINPUT_BTN_THUMBL 0x13d #define RINPUT_BTN_THUMBR 0x13e #define RINPUT_BTN_DIGI 0x140 #define RINPUT_BTN_TOOL_PEN 0x140 #define RINPUT_BTN_TOOL_RUBBER 0x141 #define RINPUT_BTN_TOOL_BRUSH 0x142 #define RINPUT_BTN_TOOL_PENCIL 0x143 #define RINPUT_BTN_TOOL_AIRBRUSH 0x144 #define RINPUT_BTN_TOOL_FINGER 0x145 #define RINPUT_BTN_TOOL_MOUSE 0x146 #define RINPUT_BTN_TOOL_LENS 0x147 #define RINPUT_BTN_TOUCH 0x14a #define RINPUT_BTN_STYLUS 0x14b #define RINPUT_BTN_STYLUS2 0x14c #define RINPUT_BTN_TOOL_DOUBLETAP 0x14d #define RINPUT_BTN_TOOL_TRIPLETAP 0x14e #define RINPUT_BTN_WHEEL 0x150 #define RINPUT_BTN_GEAR_DOWN 0x150 #define RINPUT_BTN_GEAR_UP 0x151 #define RINPUT_KEY_OK 0x160 #define RINPUT_KEY_SELECT 0x161 #define RINPUT_KEY_GOTO 0x162 #define RINPUT_KEY_CLEAR 0x163 #define RINPUT_KEY_POWER2 0x164 #define RINPUT_KEY_OPTION 0x165 #define RINPUT_KEY_INFO 0x166 /* AL OEM Features/Tips/Tutorial */ #define RINPUT_KEY_TIME 0x167 #define RINPUT_KEY_VENDOR 0x168 #define RINPUT_KEY_ARCHIVE 0x169 #define RINPUT_KEY_PROGRAM 0x16a /* Media Select Program Guide */ #define RINPUT_KEY_CHANNEL 0x16b #define RINPUT_KEY_FAVORITES 0x16c #define RINPUT_KEY_EPG 0x16d #define RINPUT_KEY_PVR 0x16e /* Media Select Home */ #define RINPUT_KEY_MHP 0x16f #define RINPUT_KEY_LANGUAGE 0x170 #define RINPUT_KEY_TITLE 0x171 #define RINPUT_KEY_SUBTITLE 0x172 #define RINPUT_KEY_ANGLE 0x173 #define RINPUT_KEY_ZOOM 0x174 #define RINPUT_KEY_MODE 0x175 #define RINPUT_KEY_KEYBOARD 0x176 #define RINPUT_KEY_SCREEN 0x177 #define RINPUT_KEY_PC 0x178 /* Media Select Computer */ #define RINPUT_KEY_TV 0x179 /* Media Select TV */ #define RINPUT_KEY_TV2 0x17a /* Media Select Cable */ #define RINPUT_KEY_VCR 0x17b /* Media Select VCR */ #define RINPUT_KEY_VCR2 0x17c /* VCR Plus */ #define RINPUT_KEY_SAT 0x17d /* Media Select Satellite */ #define RINPUT_KEY_SAT2 0x17e #define RINPUT_KEY_CD 0x17f /* Media Select CD */ #define RINPUT_KEY_TAPE 0x180 /* Media Select Tape */ #define RINPUT_KEY_RADIO 0x181 #define RINPUT_KEY_TUNER 0x182 /* Media Select Tuner */ #define RINPUT_KEY_PLAYER 0x183 #define RINPUT_KEY_TEXT 0x184 #define RINPUT_KEY_DVD 0x185 /* Media Select DVD */ #define RINPUT_KEY_AUX 0x186 #define RINPUT_KEY_MP3 0x187 #define RINPUT_KEY_AUDIO 0x188 #define RINPUT_KEY_VIDEO 0x189 #define RINPUT_KEY_DIRECTORY 0x18a #define RINPUT_KEY_LIST 0x18b #define RINPUT_KEY_MEMO 0x18c /* Media Select Messages */ #define RINPUT_KEY_CALENDAR 0x18d #define RINPUT_KEY_RED 0x18e #define RINPUT_KEY_GREEN 0x18f #define RINPUT_KEY_YELLOW 0x190 #define RINPUT_KEY_BLUE 0x191 #define RINPUT_KEY_CHANNELUP 0x192 /* Channel Increment */ #define RINPUT_KEY_CHANNELDOWN 0x193 /* Channel Decrement */ #define RINPUT_KEY_FIRST 0x194 #define RINPUT_KEY_LAST 0x195 /* Recall Last */ #define RINPUT_KEY_AB 0x196 #define RINPUT_KEY_NEXT 0x197 #define RINPUT_KEY_RESTART 0x198 #define RINPUT_KEY_SLOW 0x199 #define RINPUT_KEY_SHUFFLE 0x19a #define RINPUT_KEY_BREAK 0x19b #define RINPUT_KEY_PREVIOUS 0x19c #define RINPUT_KEY_DIGITS 0x19d #define RINPUT_KEY_TEEN 0x19e #define RINPUT_KEY_TWEN 0x19f #define RINPUT_KEY_VIDEOPHONE 0x1a0 /* Media Select Video Phone */ #define RINPUT_KEY_GAMES 0x1a1 /* Media Select Games */ #define RINPUT_KEY_ZOOMIN 0x1a2 /* AC Zoom In */ #define RINPUT_KEY_ZOOMOUT 0x1a3 /* AC Zoom Out */ #define RINPUT_KEY_ZOOMRESET 0x1a4 /* AC Zoom */ #define RINPUT_KEY_WORDPROCESSOR 0x1a5 /* AL Word Processor */ #define RINPUT_KEY_EDITOR 0x1a6 /* AL Text Editor */ #define RINPUT_KEY_SPREADSHEET 0x1a7 /* AL Spreadsheet */ #define RINPUT_KEY_GRAPHICSEDITOR 0x1a8 /* AL Graphics Editor */ #define RINPUT_KEY_PRESENTATION 0x1a9 /* AL Presentation App */ #define RINPUT_KEY_DATABASE 0x1aa /* AL Database App */ #define RINPUT_KEY_NEWS 0x1ab /* AL Newsreader */ #define RINPUT_KEY_VOICEMAIL 0x1ac /* AL Voicemail */ #define RINPUT_KEY_ADDRESSBOOK 0x1ad /* AL Contacts/Address Book */ #define RINPUT_KEY_MESSENGER 0x1ae /* AL Instant Messaging */ #define RINPUT_KEY_DISPLAYTOGGLE 0x1af /* Turn display (LCD) on and off */ #define RINPUT_KEY_SPELLCHECK 0x1b0 /* AL Spell Check */ #define RINPUT_KEY_LOGOFF 0x1b1 /* AL Logoff */ #define RINPUT_KEY_DOLLAR 0x1b2 #define RINPUT_KEY_EURO 0x1b3 #define RINPUT_KEY_FRAMEBACK 0x1b4 /* Consumer - transport controls */ #define RINPUT_KEY_FRAMEFORWARD 0x1b5 #define RINPUT_KEY_CONTEXT_MENU 0x1b6 /* GenDesc - system context menu */ #define RINPUT_KEY_MEDIA_REPEAT 0x1b7 /* Consumer - transport control */ #define RINPUT_KEY_DEL_EOL 0x1c0 #define RINPUT_KEY_DEL_EOS 0x1c1 #define RINPUT_KEY_INS_LINE 0x1c2 #define RINPUT_KEY_DEL_LINE 0x1c3 #define RINPUT_KEY_FN 0x1d0 #define RINPUT_KEY_FN_ESC 0x1d1 #define RINPUT_KEY_FN_F1 0x1d2 #define RINPUT_KEY_FN_F2 0x1d3 #define RINPUT_KEY_FN_F3 0x1d4 #define RINPUT_KEY_FN_F4 0x1d5 #define RINPUT_KEY_FN_F5 0x1d6 #define RINPUT_KEY_FN_F6 0x1d7 #define RINPUT_KEY_FN_F7 0x1d8 #define RINPUT_KEY_FN_F8 0x1d9 #define RINPUT_KEY_FN_F9 0x1da #define RINPUT_KEY_FN_F10 0x1db #define RINPUT_KEY_FN_F11 0x1dc #define RINPUT_KEY_FN_F12 0x1dd #define RINPUT_KEY_FN_1 0x1de #define RINPUT_KEY_FN_2 0x1df #define RINPUT_KEY_FN_D 0x1e0 #define RINPUT_KEY_FN_E 0x1e1 #define RINPUT_KEY_FN_F 0x1e2 #define RINPUT_KEY_FN_S 0x1e3 #define RINPUT_KEY_FN_B 0x1e4 #define RINPUT_KEY_BRL_DOT1 0x1f1 #define RINPUT_KEY_BRL_DOT2 0x1f2 #define RINPUT_KEY_BRL_DOT3 0x1f3 #define RINPUT_KEY_BRL_DOT4 0x1f4 #define RINPUT_KEY_BRL_DOT5 0x1f5 #define RINPUT_KEY_BRL_DOT6 0x1f6 #define RINPUT_KEY_BRL_DOT7 0x1f7 #define RINPUT_KEY_BRL_DOT8 0x1f8 #define RINPUT_KEY_BRL_DOT9 0x1f9 #define RINPUT_KEY_BRL_DOT10 0x1fa #define RINPUT_KEY_NUMERIC_0 0x200 /* used by phones, remote controls, */ #define RINPUT_KEY_NUMERIC_1 0x201 /* and other keypads */ #define RINPUT_KEY_NUMERIC_2 0x202 #define RINPUT_KEY_NUMERIC_3 0x203 #define RINPUT_KEY_NUMERIC_4 0x204 #define RINPUT_KEY_NUMERIC_5 0x205 #define RINPUT_KEY_NUMERIC_6 0x206 #define RINPUT_KEY_NUMERIC_7 0x207 #define RINPUT_KEY_NUMERIC_8 0x208 #define RINPUT_KEY_NUMERIC_9 0x209 #define RINPUT_KEY_NUMERIC_STAR 0x20a #define RINPUT_KEY_NUMERIC_POUND 0x20b /* We avoid low common keys in module aliases so they don't get huge. */ #define RINPUT_KEY_MIN_INTERESTING KEY_MUTE #define RINPUT_KEY_MAX 0x2ff #define RINPUT_KEY_CNT (RINPUT_KEY_MAX+1) /* * Relative axes */ #define RINPUT_REL_X 0x00 #define RINPUT_REL_Y 0x01 #define RINPUT_REL_Z 0x02 #define RINPUT_REL_RX 0x03 #define RINPUT_REL_RY 0x04 #define RINPUT_REL_RZ 0x05 #define RINPUT_REL_HWHEEL 0x06 #define RINPUT_REL_DIAL 0x07 #define RINPUT_REL_WHEEL 0x08 #define RINPUT_REL_MISC 0x09 #define RINPUT_REL_MAX 0x0f #define RINPUT_REL_CNT (RINPUT_REL_MAX+1) /* * Absolute axes */ #define RINPUT_ABS_X 0x00 #define RINPUT_ABS_Y 0x01 #define RINPUT_ABS_Z 0x02 #define RINPUT_ABS_RX 0x03 #define RINPUT_ABS_RY 0x04 #define RINPUT_ABS_RZ 0x05 #define RINPUT_ABS_THROTTLE 0x06 #define RINPUT_ABS_RUDDER 0x07 #define RINPUT_ABS_WHEEL 0x08 #define RINPUT_ABS_GAS 0x09 #define RINPUT_ABS_BRAKE 0x0a #define RINPUT_ABS_HAT0X 0x10 #define RINPUT_ABS_HAT0Y 0x11 #define RINPUT_ABS_HAT1X 0x12 #define RINPUT_ABS_HAT1Y 0x13 #define RINPUT_ABS_HAT2X 0x14 #define RINPUT_ABS_HAT2Y 0x15 #define RINPUT_ABS_HAT3X 0x16 #define RINPUT_ABS_HAT3Y 0x17 #define RINPUT_ABS_PRESSURE 0x18 #define RINPUT_ABS_DISTANCE 0x19 #define RINPUT_ABS_TILT_X 0x1a #define RINPUT_ABS_TILT_Y 0x1b #define RINPUT_ABS_TOOL_WIDTH 0x1c #define RINPUT_ABS_VOLUME 0x20 #define RINPUT_ABS_MISC 0x28 #define RINPUT_ABS_MAX 0x3f #define RINPUT_ABS_CNT (RINPUT_ABS_MAX+1) /* * Switch events */ #define RINPUT_SW_LID 0x00 /* set = lid shut */ #define RINPUT_SW_TABLET_MODE 0x01 /* set = tablet mode */ #define RINPUT_SW_HEADPHONE_INSERT 0x02 /* set = inserted */ #define RINPUT_SW_RFKILL_ALL 0x03 /* rfkill master switch, type "any" set = radio enabled */ #define RINPUT_SW_RADIO SW_RFKILL_ALL /* deprecated */ #define RINPUT_SW_MICROPHONE_INSERT 0x04 /* set = inserted */ #define RINPUT_SW_DOCK 0x05 /* set = plugged into dock */ #define RINPUT_SW_MAX 0x0f #define RINPUT_SW_CNT (RINPUT_SW_MAX+1) /* * Misc events */ #define RINPUT_MSC_SERIAL 0x00 #define RINPUT_MSC_PULSELED 0x01 #define RINPUT_MSC_GESTURE 0x02 #define RINPUT_MSC_RAW 0x03 #define RINPUT_MSC_SCAN 0x04 #define RINPUT_MSC_MAX 0x07 #define RINPUT_MSC_CNT (RINPUT_MSC_MAX+1) /* * LEDs */ #define RINPUT_LED_NUML 0x00 #define RINPUT_LED_CAPSL 0x01 #define RINPUT_LED_SCROLLL 0x02 #define RINPUT_LED_COMPOSE 0x03 #define RINPUT_LED_KANA 0x04 #define RINPUT_LED_SLEEP 0x05 #define RINPUT_LED_SUSPEND 0x06 #define RINPUT_LED_MUTE 0x07 #define RINPUT_LED_MISC 0x08 #define RINPUT_LED_MAIL 0x09 #define RINPUT_LED_CHARGING 0x0a #define RINPUT_LED_MAX 0x0f #define RINPUT_LED_CNT (RINPUT_LED_MAX+1) /* * Sounds */ #define RINPUT_SND_CLICK 0x00 #define RINPUT_SND_BELL 0x01 #define RINPUT_SND_TONE 0x02 #define RINPUT_SND_MAX 0x07 #define RINPUT_SND_CNT (RINPUT_SND_MAX+1) #endif // RINPUT_H rinputd_1.0.5/common/CMakeLists.txt0000664000175000017500000000061711736727464017515 0ustar cndouglacndouglafind_package(Qt4) set(QT_DONT_USE_QTGUI TRUE) set(QT_USE_QTNETWORK TRUE) include(${QT_USE_FILE}) set(common_SRCS Connection.cpp ) set(common_MOC_HDRS Connection.h ) qt4_automoc(${common_SRCS}) qt4_wrap_cpp(common_MOC_SRCS ${common_MOC_HDRS}) add_library(common ${common_SRCS} ${common_MOC_SRCS}) if (NOT APPLE) install(FILES rinput.h DESTINATION include COMPONENT include) endif () rinputd_1.0.5/README0000664000175000017500000000376511736727464014354 0ustar cndouglacndouglaThis package comprises the server daemon for the rinput system. Use this package in conjunction with an rinput client to enable remote input control of a computer. For a list of known clients, see the Clients section at the end of this README file. Prerequisites: * CMake >= 2.6 * Qt >= 4.6 (Prebuilt OS X binaries are compiled with Cocoa Qt libraries) Linux: * Avahi client, common, and qt4 libraries (unless Avahi support is disabled) * Cyrus SASL 2 library OS X: * OS X development tools and SDK Configuration: Run 'cmake .' at the top level of the source directory to configure rinputd for building. If you are building for OS X, both the 'Xcode' and 'Unix Makefiles' generators work. Configure Options: CMake configuration options can be set using the ccmake command line tool. If you are building for Linux and do not want Avahi support (for multicast DNS) you must set the USE_AVAHI variable to 'OFF'. Building: If building for Linux or using the 'Unix Makefiles' generator for OS X, run 'make'. If using the 'Xcode' generator for OS X, open rinputd.xcodeproj in Xcode and build it using the Xcode interface. Installing: If installing on Linux, run 'make install'. You will then need to generate an SSL certificate for rinputd and place it in /etc/rinput/rinput.crt and /etc/rinput/rinput.key. You may use one of the provided init scripts in the init.d directory for automated starting and stopping of the rinputd daemon. Lastly, use saslpasswd2 to add remote input authorized users: $ sudo saslpasswd2 -c -u rinput If installing on OS X, install the generated 'Remote Input Server.pkg' in the rinputd directory. After installation, rinputd will be automatically started once for each user logged in to the physical console. Use the users' shortnames and login passwords to authenticate and control the desktop. Only the locally logged in console user may authenticate. Clients: * Remotux: An iPhone OS app. Provides full keyboard and mouse control. rinputd_1.0.5/rinputd/0000775000175000017500000000000011736735353015142 5ustar cndouglacndouglarinputd_1.0.5/rinputd/main.cpp0000664000175000017500000001763111736735313016576 0ustar cndouglacndougla/* * Copyright (C) 2009 Chase Douglas * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 as published * by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License along * with this program; if not, write to the Free Software Foundation, Inc., * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the * OpenSSL library under certain conditions as described in each * individual source file, and distribute linked combinations * including the two. * You must obey the GNU General Public License in all respects * for all of the code used other than OpenSSL. If you modify * file(s) with this exception, you may extend this exception to your * version of the file(s), but you are not obligated to do so. If you * do not wish to do so, delete this exception statement from your * version. */ #include #include #include #include #include #include #include #include #include #include #include #include "Server.h" #include "config.h" #include "macros.h" #ifdef __APPLE__ #include "MacAuthThread.h" #endif #if defined __APPLE__ || defined USE_AVAHI #define BROADCAST #endif static void usage(char *name) { qCritical( "Usage: %s [options]\n" "Options:\n" " -r|--realm \t\tRealm to authenticate clients against (rinput)\n" " -c|--cert \tSSL certificate file (/etc/rinput/rinput.crt)\n" " -k|--key \t\tSSL private key file (/etc/rinput/rinput.key)\n" " -p|--port \t\tPort to listen for clients on, 0 for any (8771)\n" #ifdef BROADCAST " -n|--no-broadcast\t\tDo not advertise rinput service through mDNS\n" #endif #ifndef __APPLE__ " -f|--foreground\t\tDo not fork, run in foreground\n" #endif " -v|--verbose\t\t\tVerbose output\n" " -q|--quiet\t\t\tQuiet output\n", name ); } static void normalMsgHandler(QtMsgType type, const char *msg) { switch (type) { case QtDebugMsg: case QtWarningMsg: break; case QtCriticalMsg: fprintf(stderr, "%s\n", msg); break; case QtFatalMsg: fprintf(stderr, "%s\n", msg); abort(); } } static void warningMsgHandler(QtMsgType type, const char *msg) { switch (type) { case QtDebugMsg: break; case QtWarningMsg: fprintf(stderr, "%s\n", msg); break; case QtCriticalMsg: fprintf(stderr, "%s\n", msg); break; case QtFatalMsg: fprintf(stderr, "%s\n", msg); abort(); } } static void debugMsgHandler(QtMsgType type, const char *msg) { switch (type) { case QtDebugMsg: fprintf(stderr, "%s\n", msg); break; case QtWarningMsg: fprintf(stderr, "%s\n", msg); break; case QtCriticalMsg: fprintf(stderr, "%s\n", msg); break; case QtFatalMsg: fprintf(stderr, "%s\n", msg); abort(); } } int main(int argc, char *argv[]) { QCoreApplication a(argc, argv); QStringList args(a.arguments()); args.removeFirst(); QString realm("rinput"); QString certFilename("/etc/rinput/rinput.crt"); QString keyFilename("/etc/rinput/rinput.key"); quint16 port = 8771; bool broadcast = TRUE; int verbosity = 1; #ifndef __APPLE__ bool foreground = FALSE; #endif forever { static const struct option longOptions[] = { {"help", no_argument, 0, 'h'}, {"realm", required_argument, 0, 'r'}, {"cert", required_argument, 0, 'c'}, {"key", required_argument, 0, 'k'}, {"port", required_argument, 0, 'p'}, #ifdef BROADCAST {"no-broadcast", no_argument, 0, 'n'}, #endif {"verbose", no_argument, 0, 'v'}, {"quiet", no_argument, 0, 'q'}, #ifndef __APPLE__ {"foreground", no_argument, 0, 'f'}, #endif {0, 0, 0, 0} }; switch (getopt_long(argc, argv, "hr:c:k:p:vq" #ifdef BROADCAST "n" #endif #ifndef __APPLE__ "f" #endif , longOptions, NULL)) { case 'h': usage(argv[0]); return -1; case 'r': realm = optarg; break; case 'c': certFilename = optarg; break; case 'k': keyFilename = optarg; break; case 'p': { QByteArray portString(optarg); bool ok; port = portString.toUShort(&ok); if (!ok) { qCritical("Error: Port number invalid"); return -1; } break; } #ifdef BROADCAST case 'n': broadcast = FALSE; break; #endif case 'v': if (verbosity != 1) { qCritical("Error: Verbose and quiet are mutually exclusive and may each only be used once"); return -1; } verbosity++; break; case 'q': if (verbosity != 1) { qCritical("Error: Verbose and quiet are mutually exclusive and may each only be used once"); return -1; } verbosity--; break; #ifndef __APPLE__ case 'f': foreground = TRUE; break; #endif case -1: goto done; case '?': usage(argv[0]); return -1; default: qFatal("getopt_long failed to return a valid value"); break; } } done: #ifndef __APPLE__ if (!foreground) { if (daemon(0, 1)) { qCritical("Failed to become a daemon: %s", strerror(errno)); return -1; } } #endif switch(verbosity) { case 0: qInstallMsgHandler(normalMsgHandler); break; case 1: qInstallMsgHandler(warningMsgHandler); break; default: qInstallMsgHandler(debugMsgHandler); break; } QFile certFile(certFilename); if (!certFile.open(QIODevice::ReadOnly)) { qCritical("Could not open certificate file"); return -1; } QFile keyFile(keyFilename); if (!keyFile.open(QIODevice::ReadOnly)) { qCritical("Could not open private key file"); return -1; } QSslCertificate cert(&certFile); if (cert.isNull()) { qCritical("Certificate file invalid"); return -1; } QSslKey *key = new QSslKey(&keyFile, QSsl::Rsa); if (key->isNull()) { keyFile.reset(); key = new QSslKey(&keyFile, QSsl::Dsa); if (key->isNull()) { qCritical("Key file invalid"); return -1; } } #ifdef __APPLE__ MacAuthThread authThread; if (!authThread.setup()) { return -1; } authThread.start(); #endif Server server(port, realm, cert, *key, broadcast); if (!server.isListening()) { return -1; } delete key; return a.exec(); } rinputd_1.0.5/rinputd/MacAuthThread.mm0000664000175000017500000001745111736727464020163 0ustar cndouglacndougla/* * Copyright (C) 2009 Chase Douglas * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 as published * by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License along * with this program; if not, write to the Free Software Foundation, Inc., * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the * OpenSSL library under certain conditions as described in each * individual source file, and distribute linked combinations * including the two. * You must obey the GNU General Public License in all respects * for all of the code used other than OpenSSL. If you modify * file(s) with this exception, you may extend this exception to your * version of the file(s), but you are not obligated to do so. If you * do not wish to do so, delete this exception statement from your * version. */ #include #include #import #include "Connection.h" #include "MacAuthThread.h" #include "rinput.h" static MacAuthThread *macAuthThread = NULL; static QMutex macAuthThreadLock; static void dynamicStoreCallback(SCDynamicStoreRef store, CFArrayRef changedKeys, void *info) { macAuthThread->consoleUserChanged(); } static inline void setupRights(AuthorizationRef auth) { // Check if right already exists if (AuthorizationRightGet("com.rinputd.control", NULL) != errAuthorizationSuccess) { // Right doesn't exist, so create it NSDictionary *right = [NSDictionary dictionaryWithObjectsAndKeys: @"rule", @"class", @"authenticate-session-owner-or-admin", @"rule", [NSNumber numberWithBool:false], @"shared", [NSNumber numberWithInt:0], @"timeout", nil]; OSStatus error = AuthorizationRightSet(auth, "com.rinputd.control", (CFDictionaryRef)right, NULL, NULL, NULL); if (error != noErr) { qCritical("Error: Failed to set authorization right: %d", (int)error); } } } MacAuthThread::MacAuthThread() : auth(NULL), dynamicStore(NULL), storeRunLoopSource(NULL), runLoop(NULL) {} // Initialize internal state of authorization thread // Objects referenced here are released when thread exits bool MacAuthThread::setup() { // Ensure only one MacAuthThread is initialized QMutexLocker locker(&macAuthThreadLock); if (macAuthThread) { return FALSE; } // Initialize authorization services structures OSStatus error = AuthorizationCreate(NULL, NULL, kAuthorizationFlagDefaults, &auth); if (error != noErr) { qCritical("Error: Failed to create authorization reference: %d", (int)error); return FALSE; } setupRights(auth); rightItem.valueLength = 0; rightItem.value = NULL; rightItem.flags = 0; rights.count = 1; rights.items = &rightItem; environmentItems[0].name = kAuthorizationEnvironmentUsername; environmentItems[0].flags = 0; environmentItems[1].name = kAuthorizationEnvironmentPassword; environmentItems[1].flags = 0; environment.count = 2; environment.items = environmentItems; // Set up callback for notifications of user switches SCDynamicStoreContext context; context.version = 0; context.info = NULL; context.retain = NULL; context.release = NULL; context.copyDescription = NULL; dynamicStore = SCDynamicStoreCreate(kCFAllocatorDefault, CFSTR("com.rinputd"), dynamicStoreCallback, &context); NSArray *keys = [[NSArray alloc] initWithObjects:(NSString *)SCDynamicStoreKeyCreateConsoleUser(kCFAllocatorDefault), nil]; if (!SCDynamicStoreSetNotificationKeys(dynamicStore, (CFArrayRef)keys, NULL)) { qCritical("Error: Failed to set console user system configuration notification key"); [keys release]; CFRelease(dynamicStore); CFRelease(auth); return FALSE; } [keys release]; storeRunLoopSource = SCDynamicStoreCreateRunLoopSource(kCFAllocatorDefault, dynamicStore, 0); if (!storeRunLoopSource) { qCritical("Error: Failed to create run loop source"); CFRelease(dynamicStore); return FALSE; } macAuthThread = this; return TRUE; } void MacAuthThread::run() { if (!storeRunLoopSource || !dynamicStore || !auth) { qCritical("Error: MacAuthThread started without proper initialization"); return; } runLoop = CFRunLoopGetCurrent(); CFRunLoopAddSource(runLoop, storeRunLoopSource, kCFRunLoopCommonModes); CFRunLoopRun(); CFRelease(storeRunLoopSource); CFRelease(dynamicStore); CFRelease(auth); } void MacAuthThread::consoleUserChanged() { QMutexLocker locker(&mutex); QMutableVectorIterator connectionsIterator(connections); while (connectionsIterator.hasNext()) { Connection *connection = connectionsIterator.next(); qWarning("Revoking authorization for client %s", qPrintable(connection->peerAddress().toString())); rinput_message_t message = { RINPUT_ERROR }; message.data.error.type = RINPUT_REVOKED_AUTHORIZATION; hton_rinput(&message); connection->write(QByteArray::fromRawData((const char *)&message, sizeof(message))); connection->disconnectLater(); connectionsIterator.remove(); } } bool MacAuthThread::_authorized(Connection &connection, const QByteArray &user, const QByteArray &pass) { QMutexLocker locker(&mutex); // Check if current console user is this process' owner uid_t uid; CFStringRef consoleUser = SCDynamicStoreCopyConsoleUser(NULL, &uid, NULL); CFRelease(consoleUser); if (uid != getuid()) { return FALSE; // Can't allow this process to control someone else's console } // Verify that user has the right to control this console environment.items[0].valueLength = user.length(); environment.items[0].value = const_cast(user.data()); environment.items[1].valueLength = pass.length(); environment.items[1].value = const_cast(pass.data()); rights.items[0].name = "com.rinputd.control"; OSStatus error = AuthorizationCopyRights(auth, &rights, &environment, kAuthorizationFlagExtendRights | kAuthorizationFlagDestroyRights, NULL); if (error == errAuthorizationSuccess) { connections.append(&connection); return TRUE; } else if (error != errAuthorizationDenied && error != errAuthorizationInteractionNotAllowed) { qCritical("Error: Authentication processing for right com.rinputd.control.console failed: %d", (int)error); } return FALSE; } MacAuthThread::~MacAuthThread() { // Stop thread, resources used there will be freed by the thread if (runLoop) { CFRunLoopStop(runLoop); } QMutexLocker locker(&mutex); // Close all open connections QMutableVectorIterator connectionsIterator(connections); while (connectionsIterator.hasNext()) { Connection *connection = connectionsIterator.next(); connection->disconnectLater(); connectionsIterator.remove(); } } bool MacAuthThread::authorized(Connection &connection, const QByteArray &user, const QByteArray &pass) { return macAuthThread->_authorized(connection, user, pass); } rinputd_1.0.5/rinputd/LinuxInputDevice.cpp0000664000175000017500000003770211736735353021116 0ustar cndouglacndougla/* * Copyright (C) 2009 Chase Douglas * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 as published * by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License along * with this program; if not, write to the Free Software Foundation, Inc., * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the * OpenSSL library under certain conditions as described in each * individual source file, and distribute linked combinations * including the two. * You must obey the GNU General Public License in all respects * for all of the code used other than OpenSSL. If you modify * file(s) with this exception, you may extend this exception to your * version of the file(s), but you are not obligated to do so. If you * do not wish to do so, delete this exception statement from your * version. */ #include #include #include #include #include #include #include #include #include #include "Connection.h" #include "LinuxInputDevice.h" #include "rinput.h" LinuxInputDevice::LinuxInputDevice(Connection *_connection) : InputDevice::InputDevice(_connection), uinput(-1), readNotifier(NULL) { QByteArray name("Remote Input Device ("); name.append(connection->peerAddress().toString().toAscii().data()); name.append(')'); memset(&uiudev, 0, sizeof(uiudev)); strncpy(uiudev.name, name.data(), UINPUT_MAX_NAME_SIZE); uiudev.id.version = 1; uiudev.id.bustype = BUS_VIRTUAL; } bool LinuxInputDevice::create() { static const char *uinputFiles[] = { "/dev/uinput", "/dev/input/uinput" }; bool success = FALSE; for (unsigned int i = 0; i < sizeof(uinputFiles) / sizeof(char *); i++) { if ((uinput = open(uinputFiles[i], O_RDWR | O_NDELAY)) >= 0) { success = TRUE; break; } } if (!success) { qCritical("Error: Failed to open uinput device file"); rinput_message_t errorMessage = { RINPUT_ERROR, { RINPUT_INPUT_DEVICE_ALLOC_FAILED } }; hton_rinput(&errorMessage); connection->write(QByteArray((const char *)&errorMessage, sizeof(errorMessage))); return FALSE; } readNotifier = new QSocketNotifier(uinput, QSocketNotifier::Read, this); connect(readNotifier, SIGNAL(activated(int)), SLOT(uinputReadyRead())); return TRUE; } void LinuxInputDevice::handleMessage(rinput_message_t &message) { rinput_message_t errorMessage = { RINPUT_ERROR }; switch (message.type) { case RINPUT_SET_CAPABILITY: { int request; errorMessage.data.error.type = RINPUT_SET_CAPABILITY_FAILED; errorMessage.data.error.code1 = message.data.capability.type; errorMessage.data.error.code2 = message.data.capability.code; /* * If a future kernel redefines event codes or types, rinputd will translate here. */ if (message.data.capability.type == RINPUT_EV_UTF8) { break; } switch (message.data.capability.type) { case RINPUT_EV_KEY: request = UI_SET_KEYBIT; break; case RINPUT_EV_REL: request = UI_SET_RELBIT; break; case RINPUT_EV_ABS: request = UI_SET_ABSBIT; break; case RINPUT_EV_MSC: request = UI_SET_MSCBIT; break; case RINPUT_EV_SW: request = UI_SET_SWBIT; break; case RINPUT_EV_LED: request = UI_SET_LEDBIT; break; case RINPUT_EV_SND: request = UI_SET_SNDBIT; break; default: qDebug("Warning: Remote requested unsupported input capability"); errorMessage.data.error.type = RINPUT_CAPABILITY_TYPE_INVALID; hton_rinput(&errorMessage); connection->write(QByteArray((const char *)&errorMessage, sizeof(errorMessage))); return; } if (capabilities.size() <= message.data.capability.type || !capabilities.testBit(message.data.capability.type)) { if (ioctl(uinput, UI_SET_EVBIT, message.data.capability.type) < 0) { qDebug("Error: Failed to set uinput bit: %s", strerror(errno)); errorMessage.data.error.type = RINPUT_SET_CAPABILITY_FAILED; hton_rinput(&errorMessage); connection->write(QByteArray((const char *)&errorMessage, sizeof(errorMessage))); break; } if (capabilities.size() <= message.data.capability.type) { capabilities.resize(message.data.capability.type + 1); } capabilities.setBit(message.data.capability.type); } if (ioctl(uinput, request, message.data.capability.code) < 0) { qWarning("Warning: Failed to set uinput bit: %s", strerror(errno)); errorMessage.data.error.type = RINPUT_SET_CAPABILITY_FAILED; hton_rinput(&errorMessage); connection->write(QByteArray((const char *)&errorMessage, sizeof(errorMessage))); } break; } case RINPUT_SET_ABS_PARAM: if (message.data.abs_param.axis > RINPUT_ABS_MAX) { qWarning("Error: Remote requested unsupported absolute axis"); errorMessage.data.error.type = RINPUT_ABS_AXIS_INVALID; errorMessage.data.error.code1 = message.data.abs_param.axis; hton_rinput(&errorMessage); connection->write(QByteArray((const char *)&errorMessage, sizeof(errorMessage))); break; } switch (message.data.abs_param.type) { case RINPUT_ABS_PARAM_MAX: uiudev.absmax[message.data.abs_param.axis] = message.data.abs_param.value; break; case RINPUT_ABS_PARAM_MIN: uiudev.absmin[message.data.abs_param.axis] = message.data.abs_param.value; break; case RINPUT_ABS_PARAM_FUZZ: uiudev.absfuzz[message.data.abs_param.axis] = message.data.abs_param.value; break; case RINPUT_ABS_PARAM_FLAT: uiudev.absflat[message.data.abs_param.axis] = message.data.abs_param.value; break; default: qWarning("Error: Remote requested unsupported absolute parameter type"); errorMessage.data.error.type = RINPUT_ABS_PARAM_TYPE_INVALID; errorMessage.data.error.code1 = message.data.abs_param.type; hton_rinput(&errorMessage); connection->write(QByteArray((const char *)&errorMessage, sizeof(errorMessage))); break; } break; case RINPUT_CREATE: if (created) { qWarning("Warning: Remote trying to recreate device"); break; } if (write(uinput, &uiudev, sizeof(uiudev)) < (int)sizeof(uiudev)) { qCritical("Error: Failed to write full uinput specifications to device"); message.data.error.type = RINPUT_INPUT_DEVICE_CREATE_FAILED; hton_rinput(&errorMessage); connection->write(QByteArray((const char *)&errorMessage, sizeof(errorMessage))); connection->disconnect(); break; } if (ioctl(uinput, UI_DEV_CREATE) < 0) { qCritical("Error: Failed to create uinput device: %s", strerror(errno)); message.data.error.type = RINPUT_INPUT_DEVICE_CREATE_FAILED; hton_rinput(&errorMessage); connection->write(QByteArray((const char *)&errorMessage, sizeof(errorMessage))); connection->disconnect(); break; } // Echo back create message to indicate success errorMessage.type = RINPUT_CREATE; hton_rinput(&errorMessage); connection->write(QByteArray((const char *)&errorMessage, sizeof(errorMessage))); created = true; break; case RINPUT_DESTROY: if (!created) { qDebug("Warning: Remote trying to destroy device before creation"); break; } if (ioctl(uinput, UI_DEV_DESTROY) < 0) { qWarning("Warning: Failed to destroy uinput device"); } delete readNotifier; close(uinput); uinput = -1; created = false; connection->disconnect(); break; case RINPUT_EVENT: { struct input_event event; /* * If a future kernel redefines event codes or types, rinputd will translate here. */ if (message.data.event.type == RINPUT_EV_UTF8) { if (message.data.utf8.value) { handleUTF8Event(message.data.utf8); } break; } event.type = message.data.event.type; event.code = message.data.event.code; event.value = message.data.event.value; if (event.type == RINPUT_EV_KEY && event.value == 256) { event.value = 1; handleEvent(event); static const struct input_event synEvent = { { 0, 0}, EV_SYN }; handleEvent(synEvent); event.type = message.data.event.type; event.code = message.data.event.code; event.value = 0; handleEvent(event); } else { handleEvent(event); } break; } default: qWarning("Error: Remote message type invalid"); message.data.error.type = RINPUT_MESSAGE_TYPE_INVALID; errorMessage.data.error.code1 = message.type; hton_rinput(&errorMessage); connection->write(QByteArray((const char *)&errorMessage, sizeof(errorMessage))); break; } } void LinuxInputDevice::handleEvent(const struct input_event &event) { int ret = write(uinput, &event, sizeof(struct input_event)); if (ret < (int)sizeof(struct input_event)) { if (ret < 0) { qWarning("Error: Failed to write input events"); } else { qWarning("Warning: Not all input events handled"); } rinput_message_t errorMessage = { RINPUT_ERROR, { RINPUT_INPUT_EVENTS_FAILED } }; errorMessage.data.error.code1 = event.type; errorMessage.data.error.code2 = event.code; hton_rinput(&errorMessage); connection->write(QByteArray((const char *)&errorMessage, sizeof(errorMessage))); } } // Translate from UTF8 to Unicode, then simulate: // 1. CTRL+SHIFT+U // 2. Enter hexadecimal Unicode representation // 3. Space void LinuxInputDevice::handleUTF8Event(rinput_utf8_t &utf8) { // Get length of UTF8 character from first character format int length = 1; if (utf8.character[0] >= 0xC2 && utf8.character[0] <= 0xDF) { length = 2; } else if (utf8.character[0] >= 0xE0 && utf8.character[0] <= 0xEF) { length = 3; } else if (utf8.character[0] >= 0xF0 && utf8.character[0] <= 0xF4) { length = 4; } // Translate from UTF8 to Unicode QString string(QString::fromUtf8((const char *)utf8.character, length)); if (string.length() != 1) { rinput_message_t errorMessage = { RINPUT_ERROR, { RINPUT_INPUT_EVENTS_FAILED } }; errorMessage.data.error.code1 = RINPUT_EV_UTF8; hton_rinput(&errorMessage); connection->write(QByteArray((const char *)&errorMessage, sizeof(errorMessage))); return; } // Simulate unicode character entry sequence struct input_event event; event.type = EV_KEY; event.code = KEY_LEFTCTRL; event.value = 1; handleEvent(event); event.code = KEY_LEFTSHIFT; event.value = 1; handleEvent(event); event.code = KEY_U; event.value = 1; handleEvent(event); event.value = 0; handleEvent(event); event.code = KEY_LEFTSHIFT; event.value = 0; handleEvent(event); event.code = KEY_LEFTCTRL; event.value = 0; handleEvent(event); // Translate from Unicode to hex digit keys for (const ushort *unicode = string.utf16(); *unicode != 0; unicode++) { for (int shift = 12; shift >= 0; shift -= 4) { switch ((*unicode >> shift) & 0xF) { case 0: event.code = KEY_0; break; case 1: event.code = KEY_1; break; case 2: event.code = KEY_2; break; case 3: event.code = KEY_3; break; case 4: event.code = KEY_4; break; case 5: event.code = KEY_5; break; case 6: event.code = KEY_6; break; case 7: event.code = KEY_7; break; case 8: event.code = KEY_8; break; case 9: event.code = KEY_9; break; case 10: event.code = KEY_A; break; case 11: event.code = KEY_B; break; case 12: event.code = KEY_C; break; case 13: event.code = KEY_D; break; case 14: event.code = KEY_E; break; default: event.code = KEY_F; break; } event.value = 1; handleEvent(event); event.value = 0; handleEvent(event); } } // Enter space to finish entry event.code = KEY_SPACE; event.value = 1; handleEvent(event); event.value = 0; handleEvent(event); } void LinuxInputDevice::uinputReadyRead() { struct pollfd pollfd = { uinput, POLLIN }; do { rinput_message_t message = { RINPUT_EVENT }; struct input_event event; int ret = read(uinput, &event, sizeof(event)); if (ret < (signed)sizeof(event)) { qCritical("Error: Could not read input event from uinput: %s", strerror(errno)); return; } qDebug("Read input event from uinput: type: %hu, code: %hu, value: %d", event.type, event.code, event.value); message.data.event.type = event.type; message.data.event.code = event.code; message.data.event.value = event.value; hton_rinput(&message); connection->write(QByteArray((const char *)&message, sizeof(message))); } while (poll(&pollfd, 1, 0) == 1); } LinuxInputDevice::~LinuxInputDevice() { if (created) { ioctl(uinput, UI_DEV_DESTROY); } if (uinput >= 0) { close(uinput); } } rinputd_1.0.5/rinputd/rinputd.80000664000175000017500000000352511736727464016731 0ustar cndouglacndougla.TH RINPUTD 8 "August 29, 2009" .SH NAME rinputd \- Remote Input Server Daemon .SH SYNOPSIS \fBrinputd\fP [ \-\-realm \fIrealm\fP ] [ \-\-cert \fIcert\fP ] [ \-\-key \fIkey\fP ] [ \-\-port \fIport\fP ] [ \-\-no\-broadcast ] [ \-\-verbose | \-\-quiet ] .SH DESCRIPTION \fBrinputd\fP is a server daemon which listens for remote input clients. Clients connect over a secure SSL socket and authenticate with the server through the Cyrus SASL password database \fB/etc/sasldb2\fR. The client may then initialize an input device through the \fBuinput\fR user input event interface. After initialization, the client may send input events such as key presses or mouse movements. .SS Options .TP \fB\-r, \-\-realm \fIrealm\fR SASL realm to authenticate against. Defaults to \fBrinput\fP. .TP \fB\-c, \-\-cert \fIcert\fR SSL certificate file for the secure connection. Defaults to \fB/etc/rinput/rinput.crt\fP. .TP \fB\-k, \-\-key \fIkey\fR SSL private key file for the secure connection. Defaults to \fB/etc/rinput/rinput.key\fP. .TP \fB\-p, \-\-port \fIport\fR Port to listen for clients on. Set to 0 to listen on any available port. Defaults to \fB8771\fP. .TP \fB\-n, \-\-no\-broadcast\fR Don't broadcast \fBrinputd\fR service on local network through multicast DNS. This option is only available in Mac OS X or if compiled with Avahi support.\fP .TP \fB\-q, \-\-quiet\fR Limit output to \fBrinputd\fR internal errors.\fP .TP \fB\-v, \-\-verbose\fR Print out debugging information. Not useful for general purposes.\fP .TP \fB\-f, \-\-foreground\fR Do not fork to become a daemon, remain in the foreground.\fP .SH FILES .TP \fI/dev/input/uinput\fR User input device on Linux .TP \fI/etc/rinput/rinput.crt\fR Default certificate file for the secure connection.\fP .TP \fI/etc/rinput/rinput.key\fR Default private key file for the secure connection.\fP .SH "SEE ALSO" evdev(4) on Linux rinputd_1.0.5/rinputd/LinuxInputDevice.h0000664000175000017500000000401311736727464020554 0ustar cndouglacndougla/* * Copyright (C) 2009 Chase Douglas * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 as published * by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License along * with this program; if not, write to the Free Software Foundation, Inc., * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the * OpenSSL library under certain conditions as described in each * individual source file, and distribute linked combinations * including the two. * You must obey the GNU General Public License in all respects * for all of the code used other than OpenSSL. If you modify * file(s) with this exception, you may extend this exception to your * version of the file(s), but you are not obligated to do so. If you * do not wish to do so, delete this exception statement from your * version. */ #ifndef LINUXINPUTDEVICE_H #define LINUXINPUTDEVICE_H #include #include #include #include #include "InputDevice.h" class QSocketNotifier; class Connection; class LinuxInputDevice : public InputDevice { Q_OBJECT public: LinuxInputDevice(Connection *_connection); ~LinuxInputDevice(); bool create(); private slots: void uinputReadyRead(); private: void handleMessage(rinput_message_t &message); void handleEvent(const struct input_event &event); void handleUTF8Event(rinput_utf8_t &message); int uinput; QSocketNotifier *readNotifier; QBitArray capabilities; struct uinput_user_dev uiudev; }; #endif // LINUXINPUTDEVICE_H rinputd_1.0.5/rinputd/MacInputDevice.mm0000664000175000017500000007416311736727464020354 0ustar cndouglacndougla/* * Copyright (C) 2009 Chase Douglas * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 as published * by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License along * with this program; if not, write to the Free Software Foundation, Inc., * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the * OpenSSL library under certain conditions as described in each * individual source file, and distribute linked combinations * including the two. * You must obey the GNU General Public License in all respects * for all of the code used other than OpenSSL. If you modify * file(s) with this exception, you may extend this exception to your * version of the file(s), but you are not obligated to do so. If you * do not wish to do so, delete this exception statement from your * version. */ #include #import #import #import #include "Connection.h" #include "MacInputDevice.h" #include "rinput.h" static inline CGKeyCode translateUniversalKey(uint16_t code); static inline CGKeyCode translateANSIKbKey(uint16_t code); MacInputDevice::MacInputDevice(Connection *_connection) : InputDevice::InputDevice(_connection), created(FALSE), eventSource(NULL), dragLock(FALSE) { memset(&buttonState, 0, sizeof(buttonState)); multiTapTimer.setSingleShot(TRUE); // It's ok if this fails, nothing terrible will happen eventSource = CGEventSourceCreate(kCGEventSourceStateHIDSystemState); // This doesn't seem to do anything CGEventSourceSetPixelsPerLine(eventSource, 30); } // Nothing would cause a failure here bool MacInputDevice::create() { return TRUE; } void MacInputDevice::handleMessage(rinput_message_t &message) { rinput_message_t errorMessage = { RINPUT_ERROR }; switch (message.type) { case RINPUT_VERSION: case RINPUT_DESTROY: break; case RINPUT_SET_CAPABILITY: errorMessage.data.error.type = RINPUT_SET_CAPABILITY_FAILED; errorMessage.data.error.code1 = message.data.capability.type; errorMessage.data.error.code2 = message.data.capability.code; switch (message.data.capability.type) { case RINPUT_EV_KEY: if (translateUniversalKey(message.data.capability.code) != 0xFF) { break; } if (translateANSIKbKey(message.data.capability.code) != 0xFF) { break; } if (message.data.capability.code == RINPUT_BTN_LEFT || message.data.capability.code == RINPUT_BTN_RIGHT || message.data.capability.code == RINPUT_BTN_MIDDLE || message.data.capability.code == RINPUT_KEY_MUTE || message.data.capability.code == RINPUT_KEY_VOLUMEUP || message.data.capability.code == RINPUT_KEY_VOLUMEDOWN) { break; } qDebug("Warning: Remote key capability %hu unsupported", message.data.capability.code); hton_rinput(&errorMessage); connection->write(QByteArray((const char *)&errorMessage, sizeof(errorMessage))); break; case RINPUT_EV_REL: if (message.data.capability.code == RINPUT_REL_X || message.data.capability.code == RINPUT_REL_Y || message.data.capability.code == RINPUT_REL_WHEEL || message.data.capability.code == RINPUT_REL_HWHEEL) { break; } qDebug("Warning: Remote relative capability %hu unsupported", message.data.capability.code); hton_rinput(&errorMessage); connection->write(QByteArray((const char *)&errorMessage, sizeof(errorMessage))); break; case RINPUT_EV_UTF8: break; default: qDebug("Warning: Remote capability type %hu unsupported", message.data.capability.type); errorMessage.data.error.type = RINPUT_CAPABILITY_TYPE_INVALID; hton_rinput(&errorMessage); connection->write(QByteArray((const char *)&errorMessage, sizeof(errorMessage))); break; } break; case RINPUT_SET_ABS_PARAM: qDebug("Warning: Remote absolute capabilities are unsupported"); errorMessage.data.error.type = RINPUT_ABS_AXIS_INVALID; errorMessage.data.error.code1 = message.data.abs_param.axis; hton_rinput(&errorMessage); connection->write(QByteArray((const char *)&errorMessage, sizeof(errorMessage))); break; // Echo create message back to signify successful creation case RINPUT_CREATE: if (created) { qWarning("Warning: Input device create message received more than once"); errorMessage.data.error.type = RINPUT_INPUT_DEVICE_CREATE_FAILED; hton_rinput(&errorMessage); connection->write(QByteArray((const char *)&errorMessage, sizeof(errorMessage))); break; } // Not really an error message, but the struct is already there for us to use errorMessage.type = RINPUT_CREATE; hton_rinput(&errorMessage); connection->write(QByteArray((const char *)&errorMessage, sizeof(errorMessage))); created = TRUE; break; case RINPUT_EVENT: { errorMessage.data.error.type = RINPUT_INPUT_EVENTS_FAILED; errorMessage.data.error.code1 = message.data.event.type; errorMessage.data.error.code2 = message.data.event.code; switch (message.data.event.type) { case RINPUT_EV_SYN: break; case RINPUT_EV_REL: if (!handleRelativeMessage(message.data.event.code, message.data.event.value)) { hton_rinput(&errorMessage); connection->write(QByteArray((const char *)&errorMessage, sizeof(errorMessage))); qWarning("Error: Remote relative code %hu invalid", message.data.event.code); } break; case RINPUT_EV_KEY: if (!handleKeyMessage(message.data.event.code, message.data.event.value)) { hton_rinput(&errorMessage); connection->write(QByteArray((const char *)&errorMessage, sizeof(errorMessage))); qWarning("Error: Remote key code %hu invalid", message.data.event.code); } break; case RINPUT_EV_UTF8: if (!handleUTF8Message(message.data.utf8.character, message.data.utf8.value)) { hton_rinput(&errorMessage); connection->write(QByteArray((const char *)&errorMessage, sizeof(errorMessage))); qWarning("Error: Remote UTF8 character (%hhX, %hhX, %hhX, %hhX) invalid", message.data.utf8.character[0], message.data.utf8.character[1], message.data.utf8.character[2], message.data.utf8.character[3]); } break; default: hton_rinput(&errorMessage); connection->write(QByteArray((const char *)&errorMessage, sizeof(errorMessage))); qWarning("Error: Remote event type %hu invalid", message.data.event.type); } break; } default: qWarning("Error: Remote message type invalid"); errorMessage.data.error.type = RINPUT_MESSAGE_TYPE_INVALID; errorMessage.data.error.code1 = message.type; hton_rinput(&errorMessage); connection->write(QByteArray((const char *)&errorMessage, sizeof(errorMessage))); break; } } bool MacInputDevice::handleRelativeMessage(uint16_t code, int32_t value) { CGEventRef event; switch (code) { case RINPUT_REL_X: { CGPoint position = cursorPosition(value, 0); if (buttonState.leftButton) { event = CGEventCreateMouseEvent(eventSource, kCGEventLeftMouseDragged, position, 0); dragLock = TRUE; } else if (buttonState.rightButton) { event = CGEventCreateMouseEvent(eventSource, kCGEventRightMouseDragged, position, 0); dragLock = TRUE; } else if (buttonState.middleButton) { event = CGEventCreateMouseEvent(eventSource, kCGEventOtherMouseDragged, position, kCGMouseButtonCenter); dragLock = TRUE; } else { event = CGEventCreateMouseEvent(eventSource, kCGEventMouseMoved, position, 0); } break; } case RINPUT_REL_Y: { CGPoint position = cursorPosition(0, value); if (buttonState.leftButton) { event = CGEventCreateMouseEvent(eventSource, kCGEventLeftMouseDragged, position, 0); dragLock = TRUE; } else if (buttonState.rightButton) { event = CGEventCreateMouseEvent(eventSource, kCGEventRightMouseDragged, position, 0); dragLock = TRUE; } else if (buttonState.middleButton) { event = CGEventCreateMouseEvent(eventSource, kCGEventOtherMouseDragged, position, kCGMouseButtonCenter); dragLock = TRUE; } else { event = CGEventCreateMouseEvent(eventSource, kCGEventMouseMoved, position, 0); } break; } case RINPUT_REL_WHEEL: { event = CGEventCreateScrollWheelEvent(eventSource, kCGScrollEventUnitLine, 2, value, 0); break; } case RINPUT_REL_HWHEEL: { event = CGEventCreateScrollWheelEvent(eventSource, kCGScrollEventUnitLine, 2, 0, -value); break; } default: return FALSE; } CGEventPost(kCGHIDEventTap, event); CFRelease(event); return TRUE; } bool MacInputDevice::handleKeyMessage(uint16_t code, int32_t value) { QQueue events; CGEventRef event; if (dragLock && (code == RINPUT_BTN_LEFT || code == RINPUT_BTN_RIGHT || code == RINPUT_BTN_MIDDLE)) { if (value) { dragLock = FALSE; switch (code) { case RINPUT_BTN_LEFT: buttonState.leftButton = (value && value != 256); break; case RINPUT_BTN_RIGHT: buttonState.rightButton = (value && value != 256); break; case RINPUT_BTN_MIDDLE: buttonState.middleButton = (value && value != 256); break; } } else { return TRUE; } } if ((code == RINPUT_BTN_LEFT || code == RINPUT_BTN_RIGHT || code == RINPUT_BTN_MIDDLE) && value) { if (!multiTapTimer.isActive()) { multiTapTimer.start([NSEvent doubleClickInterval] * 1000); multiTapCount = 1; } else { multiTapCount++; } } switch (code) { case RINPUT_BTN_LEFT: { CGPoint position = cursorPosition(0, 0); if (value == 256) { event = CGEventCreateMouseEvent(eventSource, kCGEventLeftMouseDown, position, 0); CGEventSetIntegerValueField(event, kCGMouseEventClickState, multiTapCount); events.enqueue(event); event = CGEventCreateMouseEvent(eventSource, kCGEventLeftMouseUp, position, 0); events.enqueue(event); buttonState.leftButton = FALSE; } else if (value) { event = CGEventCreateMouseEvent(eventSource, kCGEventLeftMouseDown, position, 0); CGEventSetIntegerValueField(event, kCGMouseEventClickState, multiTapCount); events.enqueue(event); buttonState.leftButton = TRUE; } else { event = CGEventCreateMouseEvent(eventSource, kCGEventLeftMouseUp, position, 0); events.enqueue(event); buttonState.leftButton = FALSE; } break; } case RINPUT_BTN_RIGHT: { CGPoint position = cursorPosition(0, 0); if (value == 256) { event = CGEventCreateMouseEvent(eventSource, kCGEventRightMouseDown, position, 0); CGEventSetIntegerValueField(event, kCGMouseEventClickState, multiTapCount); events.enqueue(event); event = CGEventCreateMouseEvent(eventSource, kCGEventRightMouseUp, position, 0); events.enqueue(event); buttonState.rightButton = FALSE; } else if (value) { event = CGEventCreateMouseEvent(eventSource, kCGEventRightMouseDown, position, 0); CGEventSetIntegerValueField(event, kCGMouseEventClickState, multiTapCount); events.enqueue(event); buttonState.rightButton = TRUE; } else { event = CGEventCreateMouseEvent(eventSource, kCGEventRightMouseUp, position, 0); buttonState.rightButton = FALSE; } break; } case RINPUT_BTN_MIDDLE: { CGPoint position = cursorPosition(0, 0); if (value == 256) { event = CGEventCreateMouseEvent(eventSource, kCGEventOtherMouseDown, position, kCGMouseButtonCenter); CGEventSetIntegerValueField(event, kCGMouseEventClickState, multiTapCount); events.enqueue(event); event = CGEventCreateMouseEvent(eventSource, kCGEventOtherMouseUp, position, kCGMouseButtonCenter); events.enqueue(event); buttonState.middleButton = FALSE; } else if (value) { event = CGEventCreateMouseEvent(eventSource, kCGEventOtherMouseDown, position, kCGMouseButtonCenter); CGEventSetIntegerValueField(event, kCGMouseEventClickState, multiTapCount); events.enqueue(event); buttonState.middleButton = TRUE; } else { event = CGEventCreateMouseEvent(eventSource, kCGEventOtherMouseUp, position, kCGMouseButtonCenter); events.enqueue(event); buttonState.middleButton = FALSE; } break; } default: { // WARNING: I have no clue how well all this will work if used on a machine with a non-ANSI keyboard! if (handleUniversalKeyMessage(code, value)) { break; } if (handleANSIKbKeyMessage(code, value)) { break; } if (handleMediaKeyMessage(code, value)) { break; } // Unrecognized key code return FALSE; } } while (!events.isEmpty()) { event = events.dequeue(); CGEventPost(kCGHIDEventTap, event); CFRelease(event); } return TRUE; } #define TRANSLATE(a, b) case RINPUT_KEY_##a: \ return kVK_##b; static inline CGKeyCode translateUniversalKey(uint16_t code) { switch (code) { TRANSLATE(ENTER, Return); TRANSLATE(TAB, Tab); TRANSLATE(SPACE, Space); TRANSLATE(BACKSPACE, Delete); TRANSLATE(ESC, Escape); TRANSLATE(LEFTMETA, Command); TRANSLATE(RIGHTMETA, Command); TRANSLATE(LEFTSHIFT, Shift); TRANSLATE(CAPSLOCK, CapsLock); TRANSLATE(LEFTALT, Option); TRANSLATE(OPTION, Option); TRANSLATE(LEFTCTRL, Control); TRANSLATE(RIGHTSHIFT, RightShift); TRANSLATE(RIGHTALT, RightOption); TRANSLATE(RIGHTCTRL, RightControl); TRANSLATE(FN, Function); TRANSLATE(F17, F17); TRANSLATE(F18, F18); TRANSLATE(F19, F19); TRANSLATE(F20, F20); TRANSLATE(F5, F5); TRANSLATE(F6, F6); TRANSLATE(F7, F7); TRANSLATE(F3, F3); TRANSLATE(F8, F8); TRANSLATE(F9, F9); TRANSLATE(F11, F11); TRANSLATE(F13, F13); TRANSLATE(F16, F16); TRANSLATE(F14, F14); TRANSLATE(F10, F10); TRANSLATE(F12, F12); TRANSLATE(F15, F15); TRANSLATE(HELP, Help); TRANSLATE(HOME, Home); TRANSLATE(PAGEUP, PageUp); TRANSLATE(DELETE, ForwardDelete); TRANSLATE(F4, F4); TRANSLATE(END, End); TRANSLATE(F2, F2); TRANSLATE(PAGEDOWN, PageDown); TRANSLATE(F1, F1); TRANSLATE(LEFT, LeftArrow); TRANSLATE(RIGHT, RightArrow); TRANSLATE(DOWN, DownArrow); TRANSLATE(UP, UpArrow); default: return 0xff; // Invalid key code } } #undef TRANSLATE bool MacInputDevice::handleUniversalKeyMessage(uint16_t code, int32_t value) { CGKeyCode key = translateUniversalKey(code); if (key == 0xFF) { return FALSE; } CGEventRef event = CGEventCreateKeyboardEvent(eventSource, key, value); CGEventPost(kCGHIDEventTap, event); CFRelease(event); if (value == 256) { event = CGEventCreateKeyboardEvent(eventSource, key, FALSE); CGEventPost(kCGHIDEventTap, event); CFRelease(event); } return TRUE; } #define TRANSLATE(a, b) if (code == RINPUT_KEY_##a) return kVK_ANSI_##b #define TRANSLATE_ALPHANUM(a) if (code == RINPUT_KEY_##a) return kVK_ANSI_##a static inline CGKeyCode translateANSIKbKey(uint16_t code) { TRANSLATE(GRAVE, Grave); TRANSLATE_ALPHANUM(1); TRANSLATE_ALPHANUM(2); TRANSLATE_ALPHANUM(3); TRANSLATE_ALPHANUM(4); TRANSLATE_ALPHANUM(5); TRANSLATE_ALPHANUM(6); TRANSLATE_ALPHANUM(7); TRANSLATE_ALPHANUM(8); TRANSLATE_ALPHANUM(9); TRANSLATE_ALPHANUM(0); TRANSLATE(MINUS, Minus); TRANSLATE(EQUAL, Equal); TRANSLATE_ALPHANUM(Q); TRANSLATE_ALPHANUM(W); TRANSLATE_ALPHANUM(E); TRANSLATE_ALPHANUM(R); TRANSLATE_ALPHANUM(T); TRANSLATE_ALPHANUM(Y); TRANSLATE_ALPHANUM(U); TRANSLATE_ALPHANUM(I); TRANSLATE_ALPHANUM(O); TRANSLATE_ALPHANUM(P); TRANSLATE(LEFTBRACE, LeftBracket); TRANSLATE(RIGHTBRACE, RightBracket); TRANSLATE(BACKSLASH, Backslash); TRANSLATE_ALPHANUM(A); TRANSLATE_ALPHANUM(S); TRANSLATE_ALPHANUM(D); TRANSLATE_ALPHANUM(F); TRANSLATE_ALPHANUM(G); TRANSLATE_ALPHANUM(H); TRANSLATE_ALPHANUM(J); TRANSLATE_ALPHANUM(K); TRANSLATE_ALPHANUM(L); TRANSLATE(SEMICOLON, Semicolon); TRANSLATE(APOSTROPHE, Quote); TRANSLATE_ALPHANUM(Z); TRANSLATE_ALPHANUM(X); TRANSLATE_ALPHANUM(C); TRANSLATE_ALPHANUM(V); TRANSLATE_ALPHANUM(B); TRANSLATE_ALPHANUM(N); TRANSLATE_ALPHANUM(M); TRANSLATE(KPASTERISK, KeypadMultiply); TRANSLATE(COMMA, Comma); TRANSLATE(DOT, Period); TRANSLATE(SLASH, Slash); TRANSLATE(KP7, Keypad7); TRANSLATE(KP8, Keypad7); TRANSLATE(KP9, Keypad7); TRANSLATE(KPMINUS, KeypadMinus); TRANSLATE(KP4, Keypad7); TRANSLATE(KP5, Keypad7); TRANSLATE(KP6, Keypad7); TRANSLATE(KPPLUS, KeypadPlus); TRANSLATE(KP1, Keypad7); TRANSLATE(KP2, Keypad7); TRANSLATE(KP3, Keypad7); TRANSLATE(KP0, Keypad7); TRANSLATE(KPDOT, KeypadDecimal); TRANSLATE(KPENTER, KeypadEnter); TRANSLATE(KPSLASH, KeypadDivide); TRANSLATE(KPEQUAL, KeypadEquals); TRANSLATE(KPPLUSMINUS, KeypadPlus); return 0xFF; // Invalid key code } #undef TRANSLATE #undef TRANSLATE_ALPHANUM bool MacInputDevice::handleANSIKbKeyMessage(uint16_t code, int32_t value) { CGKeyCode key = translateANSIKbKey(code); if (key == 0xFF) { return FALSE; } CGEventRef event = CGEventCreateKeyboardEvent(eventSource, key, value); CGEventPost(kCGHIDEventTap, event); CFRelease(event); if (value == 256) { CGEventRef event = CGEventCreateKeyboardEvent(eventSource, key, FALSE); CGEventPost(kCGHIDEventTap, event); CFRelease(event); } return TRUE; } static inline Float32 systemVolume(AudioDeviceID device) { Float32 volume[2]; UInt32 size = sizeof(Float32); AudioObjectPropertyAddress address = { kAudioDevicePropertyVolumeScalar, kAudioDevicePropertyScopeOutput, kAudioObjectPropertyElementMaster }; if (AudioObjectGetPropertyData(device, &address, 0, NULL, &size, volume) == noErr) { return volume[0]; } address.mSelector = kAudioDevicePropertyPreferredChannelsForStereo; UInt32 channels[2]; size = sizeof(channels); if (AudioObjectGetPropertyData(device, &address, 0, NULL, &size, channels) != noErr) { qWarning("Warning: Failed to get master volume or get stereo channels"); return -1; } address.mSelector = kAudioDevicePropertyVolumeScalar; address.mElement = channels[0]; size = sizeof(Float32); if (AudioObjectGetPropertyData(device, &address, 0, NULL, &size, volume) != noErr) { qWarning("Warning: Failed to get master or stereo volumes"); return -1; } address.mElement = channels[1]; size = sizeof(Float32); if (AudioObjectGetPropertyData(device, &address, 0, NULL, &size, volume + 1) != noErr) { qWarning("Warning: Failed to get master or stereo volumes"); return -1; } return (volume[0] + volume[1]) / 2; } static inline void setSystemVolume(AudioDeviceID device, Float32 volume) { UInt32 size = sizeof(volume); AudioObjectPropertyAddress address = { kAudioDevicePropertyVolumeScalar, kAudioDevicePropertyScopeOutput, kAudioObjectPropertyElementMaster }; if (AudioObjectSetPropertyData(device, &address, 0, NULL, size, &volume) == noErr) { return; } address.mSelector = kAudioDevicePropertyPreferredChannelsForStereo; UInt32 channels[2]; size = sizeof(channels); if (AudioObjectGetPropertyData(device, &address, 0, NULL, &size, channels) != noErr) { qWarning("Warning: Failed to set master volume or get stereo channels"); return; } address.mSelector = kAudioDevicePropertyVolumeScalar; address.mElement = channels[0]; size = sizeof(volume); if (AudioObjectSetPropertyData(device, &address, 0, NULL, size, &volume) != noErr) { qWarning("Warning: Failed to set master or stereo volumes"); return; } address.mElement = channels[1]; size = sizeof(volume); if (AudioObjectSetPropertyData(device, &address, 0, NULL, size, &volume) != noErr) { qWarning("Warning: Failed to set master or stereo volumes"); return; } } bool MacInputDevice::handleMediaKeyMessage(uint16_t code, int32_t value) { if (code == RINPUT_KEY_MUTE || code == RINPUT_KEY_VOLUMEDOWN || code == RINPUT_KEY_VOLUMEUP) { AudioDeviceID device = kAudioObjectUnknown; UInt32 size = sizeof(device); AudioObjectPropertyAddress address = { kAudioHardwarePropertyDefaultOutputDevice, kAudioObjectPropertyScopeGlobal, kAudioObjectPropertyElementMaster }; if (AudioObjectGetPropertyData(kAudioObjectSystemObject, &address, 0, NULL, &size, &device) != noErr || device == kAudioObjectUnknown) { qWarning("Warning: Failed to get default audio output device"); return TRUE; } if (code == RINPUT_KEY_MUTE) { UInt32 mute; size = sizeof(mute); address.mSelector = kAudioDevicePropertyMute; address.mScope = kAudioDevicePropertyScopeOutput; if (AudioObjectGetPropertyData(device, &address, 0, NULL, &size, &mute) != noErr) { qWarning("Warning: Failed to get audio output master mute value"); return TRUE; } mute = !mute; size = sizeof(mute); if (AudioObjectSetPropertyData(device, &address, 0, NULL, size, &mute) != noErr) { qWarning("Warning: Failed to set audio output master mute value"); return TRUE; } } else if (code == RINPUT_KEY_VOLUMEDOWN || code == RINPUT_KEY_VOLUMEUP) { Float32 volume = systemVolume(device); if (volume < 0 || volume > 1) { return TRUE; } volume += (Float32)(code == RINPUT_KEY_VOLUMEUP ? 1 : -1) / 16; if (volume > 1) { volume = 1; } else if (volume < 0) { volume = 0; } setSystemVolume(device, volume); } return TRUE; } return FALSE; } bool MacInputDevice::handleUTF8Message(unsigned char character[4], int16_t value) { NSUInteger length = 1; if (character[0] >= 0xC2 && character[0] <= 0xDF) { length = 2; } else if (character[0] >= 0xE0 && character[0] <= 0xEF) { length = 3; } else if (character[0] >= 0xF0 && character[0] <= 0xF4) { length = 4; } NSString *unicodeString = [[NSString alloc] initWithBytesNoCopy:character length:length encoding:NSUTF8StringEncoding freeWhenDone:NO]; if (unicodeString.length != 1) { [unicodeString release]; return FALSE; } unichar unicode[2]; [unicodeString getCharacters:unicode range:NSMakeRange(0, 1)]; [unicodeString release]; CGEventRef event = CGEventCreateKeyboardEvent(eventSource, kVK_ISO_Section, value); CGEventKeyboardSetUnicodeString(event, 1, unicode); CGEventPost(kCGHIDEventTap, event); CFRelease(event); if (value == 256) { CGEventRef event = CGEventCreateKeyboardEvent(eventSource, kVK_ISO_Section, FALSE); CGEventKeyboardSetUnicodeString(event, 1, unicode); CGEventPost(kCGHIDEventTap, event); CFRelease(event); } return TRUE; } // Fuzzy logic needed for float comparisons #define EPSILON 0.1 static inline BOOL CGRectContainsPointFuzzy(CGRect rect, CGPoint point) { if (point.x > rect.origin.x - EPSILON && point.x < rect.origin.x + rect.size.width + EPSILON && point.y > rect.origin.y - EPSILON && point.y < rect.origin.y + rect.size.height + EPSILON) { return YES; } else { return NO; } } enum Direction { UP, DOWN, LEFT, RIGHT }; // Only one of the arguments will be inequal to 0 CGPoint MacInputDevice::cursorPosition(CGFloat dx, CGFloat dy) { CGPoint position = NSPointToCGPoint([NSEvent mouseLocation]); NSArray *screens = [NSScreen screens]; NSScreen *screen; Direction direction = RIGHT; if (dx < 0) direction = LEFT; else if (dy > 0) direction = UP; else if (dy < 0) direction = DOWN; CGFloat maxScreenHeight = 0; for (screen in screens) { if (screen.frame.size.height > maxScreenHeight) { maxScreenHeight = screen.frame.size.height; } } // Flip y-axis position.y = maxScreenHeight - position.y; // Keep moving to the edge of the screen the position is in until we reach the end of the screens or the desired position forever { CGRect frame; for (screen in screens) { frame = NSRectToCGRect(screen.frame); frame.origin.y = maxScreenHeight - frame.size.height; frame.size.width--; frame.size.height--; if (CGRectContainsPointFuzzy(frame, position)) { break; } } // We've reached the end of a screen and there aren't any more screens next to it if (!screen) { // Backtrack so we aren't off screen if (direction == RIGHT) position.x--; else if (direction == LEFT) position.x++; else if (direction == UP) position.y--; else if (direction == DOWN) position.y++; return position; } // If our intended point is in the screen, go to it if (CGRectContainsPointFuzzy(frame, CGPointMake(position.x + dx, position.y + dy))) { position.x += dx; position.y += dy; return position; } // Go to a pixel past the edge of this screen // We rely on the fact that only one of dx or dy is inequal to 0 if (dx > 0) { dx -= CGRectGetMaxX(frame) + 1 - position.x; position.x = CGRectGetMaxX(frame) + 1; } else if (dx < 0) { dx -= CGRectGetMinX(frame) - 1 - position.x; position.x = CGRectGetMinX(frame) - 1; } else if (dy > 0) { dy -= CGRectGetMaxY(frame) + 1 - position.y; position.y = CGRectGetMaxY(frame) + 1; } else if (dy < 0) { dy -= CGRectGetMinY(frame) - 1 - position.y; position.y = CGRectGetMinY(frame) - 1; } } } MacInputDevice::~MacInputDevice() { if (eventSource) { CFRelease(eventSource); } } rinputd_1.0.5/rinputd/Server.h0000664000175000017500000000427611736727464016576 0ustar cndouglacndougla/* * Copyright (C) 2009 Chase Douglas * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 as published * by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License along * with this program; if not, write to the Free Software Foundation, Inc., * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the * OpenSSL library under certain conditions as described in each * individual source file, and distribute linked combinations * including the two. * You must obey the GNU General Public License in all respects * for all of the code used other than OpenSSL. If you modify * file(s) with this exception, you may extend this exception to your * version of the file(s), but you are not obligated to do so. If you * do not wish to do so, delete this exception statement from your * version. */ #ifndef SERVER_H #define SERVER_H #include #include #ifndef __APPLE__ #include #endif #include "config.h" #ifdef __APPLE__ #include "MacBroadcaster.h" #elif defined USE_AVAHI #include "AvahiBroadcaster.h" #endif class QSslCertificate; class QSslKey; class Connection; class Server : public QTcpServer { Q_OBJECT public: Server(quint16 _port, QString &_realm, QSslCertificate &cert, QSslKey &key, bool broadcast); private slots: void connectionEncrypted(); void connectionAuthenticated(); void checkPass(const QByteArray &user, const QByteArray &pass); private: void incomingConnection(int sock); QSslConfiguration config; #ifdef __APPLE__ MacBroadcaster *broadcaster; #elif defined USE_AVAHI AvahiBroadcaster *broadcaster; #endif #ifndef __APPLE__ sasl_conn_t *sasl; #endif }; #endif // SERVER_H rinputd_1.0.5/rinputd/InputDevice.h0000664000175000017500000000335111736727464017540 0ustar cndouglacndougla/* * Copyright (C) 2009 Chase Douglas * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 as published * by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License along * with this program; if not, write to the Free Software Foundation, Inc., * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the * OpenSSL library under certain conditions as described in each * individual source file, and distribute linked combinations * including the two. * You must obey the GNU General Public License in all respects * for all of the code used other than OpenSSL. If you modify * file(s) with this exception, you may extend this exception to your * version of the file(s), but you are not obligated to do so. If you * do not wish to do so, delete this exception statement from your * version. */ #ifndef INPUTDEVICE_H #define INPUTDEVICE_H #include #include "rinput.h" class Connection; class InputDevice : public QObject { Q_OBJECT public: InputDevice(Connection *_connection); virtual bool create(); protected: Connection *connection; bool created; private slots: void connectionReadyRead(); private: virtual void handleMessage(rinput_message_t &message); }; #endif // INPUTDEVICE_H rinputd_1.0.5/rinputd/MacAuthThread.h0000664000175000017500000000434011736727464017772 0ustar cndouglacndougla/* * Copyright (C) 2009 Chase Douglas * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 as published * by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License along * with this program; if not, write to the Free Software Foundation, Inc., * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the * OpenSSL library under certain conditions as described in each * individual source file, and distribute linked combinations * including the two. * You must obey the GNU General Public License in all respects * for all of the code used other than OpenSSL. If you modify * file(s) with this exception, you may extend this exception to your * version of the file(s), but you are not obligated to do so. If you * do not wish to do so, delete this exception statement from your * version. */ #ifndef MACAUTHTHREAD_H #define MACAUTHTHREAD_H #include #include #include #import class Connection; class MacAuthThread : public QThread { Q_OBJECT public: MacAuthThread(); ~MacAuthThread(); bool setup(); static bool authorized(Connection &connection, const QByteArray &user, const QByteArray &pass); void consoleUserChanged(); private: void run(); bool _authorized(Connection &connection, const QByteArray &user, const QByteArray &pass); AuthorizationRef auth; AuthorizationRights rights; AuthorizationEnvironment environment; AuthorizationItem rightItem; AuthorizationItem environmentItems[2]; SCDynamicStoreRef dynamicStore; CFRunLoopSourceRef storeRunLoopSource; CFRunLoopRef runLoop; QVector connections; QMutex mutex; }; #endif // MACAUTHTHREAD_H rinputd_1.0.5/rinputd/MacInputDevice.h0000664000175000017500000000462311736727464020164 0ustar cndouglacndougla/* * Copyright (C) 2009 Chase Douglas * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 as published * by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License along * with this program; if not, write to the Free Software Foundation, Inc., * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the * OpenSSL library under certain conditions as described in each * individual source file, and distribute linked combinations * including the two. * You must obey the GNU General Public License in all respects * for all of the code used other than OpenSSL. If you modify * file(s) with this exception, you may extend this exception to your * version of the file(s), but you are not obligated to do so. If you * do not wish to do so, delete this exception statement from your * version. */ #ifndef MACINPUTDEVICE_H #define MACINPUTDEVICE_H #include #include #include #import #include "InputDevice.h" class Connection; class MacInputDevice : public InputDevice { Q_OBJECT public: MacInputDevice(Connection *_connection); ~MacInputDevice(); bool create(); private: void handleMessage(rinput_message_t &message); bool handleRelativeMessage(uint16_t code, int32_t value); bool handleKeyMessage(uint16_t code, int32_t value); bool handleUniversalKeyMessage(uint16_t code, int32_t value); bool handleANSIKbKeyMessage(uint16_t code, int32_t value); bool handleMediaKeyMessage(uint16_t code, int32_t value); bool handleUTF8Message(unsigned char character[4], int16_t value); CGPoint cursorPosition(CGFloat dx, CGFloat dy); bool created; struct { bool leftButton; bool rightButton; bool middleButton; } buttonState; CGEventSourceRef eventSource; bool dragLock; QTimer multiTapTimer; int64_t multiTapCount; }; #endif // MACINPUTDEVICE_H rinputd_1.0.5/rinputd/AvahiBroadcaster.cpp0000664000175000017500000001302711736727464021057 0ustar cndouglacndougla/* * Copyright (C) 2009 Chase Douglas * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 as published * by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License along * with this program; if not, write to the Free Software Foundation, Inc., * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the * OpenSSL library under certain conditions as described in each * individual source file, and distribute linked combinations * including the two. * You must obey the GNU General Public License in all respects * for all of the code used other than OpenSSL. If you modify * file(s) with this exception, you may extend this exception to your * version of the file(s), but you are not obligated to do so. If you * do not wish to do so, delete this exception statement from your * version. */ #include #include #include #include #include #include "AvahiBroadcaster.h" static void avahiClientCallback(AvahiClient *client, AvahiClientState state, void *userData); static void avahiEntryGroupCallback(AvahiEntryGroup *group, AvahiEntryGroupState state, void *userData); static void avahiClientCallback(AvahiClient *client, AvahiClientState state, void *userData) { AvahiBroadcaster *broadcaster = static_cast(userData); broadcaster->_avahiClientCallback(client, state); } static void avahiEntryGroupCallback(AvahiEntryGroup *group, AvahiEntryGroupState state, void *userData) { AvahiBroadcaster *broadcaster = static_cast(userData); broadcaster->_avahiEntryGroupCallback(state); } AvahiBroadcaster::AvahiBroadcaster(quint16 _port) : avahiClient(NULL), avahiGroup(NULL), port(_port) { avahiName = QHostInfo::localHostName() + " Remote Input"; avahiClient = avahi_client_new(avahi_qt_poll_get(), AVAHI_CLIENT_NO_FAIL, avahiClientCallback, this, NULL); if (!avahiClient) { qWarning("Warning: Could not create avahi client, will not publish rinputd on network"); } } void AvahiBroadcaster::_avahiClientCallback(AvahiClient *client, AvahiClientState state) { switch (state) { case AVAHI_CLIENT_FAILURE: qWarning("Warning: Avahi client error: %s", avahi_strerror(avahi_client_errno(avahiClient))); if (avahiGroup) { avahi_entry_group_free(avahiGroup); avahiGroup = NULL; } break; case AVAHI_CLIENT_S_COLLISION: case AVAHI_CLIENT_S_REGISTERING: if (avahiGroup) { avahi_entry_group_reset(avahiGroup); } break; case AVAHI_CLIENT_S_RUNNING: createService(client); break; case AVAHI_CLIENT_CONNECTING: break; } } void AvahiBroadcaster::createService(AvahiClient *client) { if (!avahiGroup) { avahiGroup = avahi_entry_group_new(client, avahiEntryGroupCallback, this); if (!avahiGroup) { qWarning("Warning: Failed to create new Avahi group %s", avahi_strerror(avahi_client_errno(client))); return; } } if (avahi_entry_group_is_empty(avahiGroup)) { retry: int err = avahi_entry_group_add_service(avahiGroup, AVAHI_IF_UNSPEC, AVAHI_PROTO_UNSPEC, (AvahiPublishFlags)0, avahiName.toUtf8().data(), "_rinput._tcp", NULL, NULL, port, NULL); if (err < 0) { if (err == AVAHI_ERR_COLLISION) { alternativeServiceName(); goto retry; } else { qWarning("Warning: Failed to add _rinput._tcp service to Avahi: %s", avahi_strerror(err)); return; } } err = avahi_entry_group_commit(avahiGroup); if (err < 0) { qWarning("Warning: Failed to commit Avahi group entry: %s", avahi_strerror(err)); } } } void AvahiBroadcaster::alternativeServiceName() { avahiName = avahi_alternative_service_name(avahiName.toUtf8().data()); qDebug("Previous Avahi service name collided, renaming servive to %s", qPrintable(avahiName)); avahi_entry_group_reset(avahiGroup); } void AvahiBroadcaster::_avahiEntryGroupCallback(AvahiEntryGroupState state) { switch (state) { case AVAHI_ENTRY_GROUP_COLLISION: alternativeServiceName(); createService(avahiClient); break; case AVAHI_ENTRY_GROUP_FAILURE: qWarning("Warning: Avahi entry group error: %s", avahi_strerror(avahi_client_errno(avahi_entry_group_get_client(avahiGroup)))); break; case AVAHI_ENTRY_GROUP_ESTABLISHED: qDebug("Avahi service _rinput._tcp with name '%s' established", qPrintable(avahiName)); break; case AVAHI_ENTRY_GROUP_UNCOMMITED: case AVAHI_ENTRY_GROUP_REGISTERING: break; } } AvahiBroadcaster::~AvahiBroadcaster() { if (avahiGroup) { avahi_entry_group_free(avahiGroup); } if (avahiClient) { avahi_client_free(avahiClient); } } rinputd_1.0.5/rinputd/CMakeLists.txt0000664000175000017500000001047311736727464017713 0ustar cndouglacndouglaset(QT_DONT_USE_QTGUI TRUE) set(QT_USE_QTNETWORK TRUE) include(${QT_USE_FILE}) set(rinputd_SRCS main.cpp InputDevice.cpp Server.cpp ) set(rinputd_MOC_HDRS InputDevice.h Server.h ) if (${CMAKE_SYSTEM_NAME} MATCHES "Linux") set(rinputd_SRCS ${rinputd_SRCS} LinuxInputDevice.cpp) set(rinputd_MOC_HDRS ${rinputd_MOC_HDRS} LinuxInputDevice.h) elseif (APPLE) set(rinputd_SRCS ${rinputd_SRCS} MacBroadcaster.mm MacInputDevice.mm MacAuthThread.mm) set(rinputd_MOC_HDRS ${rinputd_MOC_HDRS} MacBroadcaster.h MacInputDevice.h MacAuthThread.h) find_library(CORE_AUDIO_FRAMEWORK CoreAudio) find_library(SECURITY_FRAMEWORK Security) find_library(SYSTEM_CONFIGURATION_FRAMEWORK SystemConfiguration) find_library(FOUNDATION_FRAMEWORK Foundation) find_library(APP_KIT_FRAMEWORK AppKit) set(EXTRA_LIBS ${CORE_AUDIO_FRAMEWORK} ${SECURITY_FRAMEWORK} ${SYSTEM_CONFIGURATION_FRAMEWORK} ${FOUNDATION_FRAMEWORK} ${APP_KIT_FRAMEWORK}) endif () if (USE_AVAHI) set(rinputd_SRCS ${rinputd_SRCS} AvahiBroadcaster.cpp) set(rinputd_MOC_HDRS ${rinputd_MOC_HDRS} AvahiBroadcaster.h) include_directories(${AVAHI_CLIENT_INCLUDE_DIRS} ${AVAHI_QT4_INCLUDE_DIRS}) link_directories(${AVAHI_CLIENT_LIBRARY_DIRS} ${AVAHI_QT4_LIBRARY_DIRS}) endif () qt4_automoc(${rinputd_SRCS}) qt4_wrap_cpp(rinputd_MOC_SRCS ${rinputd_MOC_HDRS}) include_directories(${rinput_SOURCE_DIR}/common) link_directories(${rinput_SOURCE_DIR}/common) if (APPLE) add_executable(rinputd MACOSX_BUNDLE ${rinputd_SRCS} ${rinputd_MOC_HDRS} ${rinputd_MOC_SRCS}) target_link_libraries(rinputd common ${QT_LIBRARIES} ${EXTRA_LIBS}) set(BUNDLE_PATH "${CMAKE_CURRENT_BINARY_DIR}/rinputd.app") set(FRAMEWORKS_PATH "${BUNDLE_PATH}/Contents/Frameworks") set(INSTALL_PATH "/Library/Remote Input/rinputd.app") if (${CMAKE_GENERATOR} MATCHES "Xcode") add_custom_command(TARGET rinputd POST_BUILD COMMAND rm -rf "${BUNDLE_PATH}" COMMAND cp -R "${CMAKE_CURRENT_BINARY_DIR}/$(CONFIGURATION)/rinputd.app" "${CMAKE_CURRENT_BINARY_DIR}/" VERBATIM) endif () add_custom_target(package ALL COMMAND rm -rf "${FRAMEWORKS_PATH}" COMMAND mkdir -p "${FRAMEWORKS_PATH}" COMMAND cp -R "${QT_QTNETWORK_LIBRARY_RELEASE}" "${FRAMEWORKS_PATH}/" COMMAND cp -R "${QT_QTCORE_LIBRARY_RELEASE}" "${FRAMEWORKS_PATH}/" COMMAND rm -rf "${FRAMEWORKS_PATH}/QtCore.framework/{,Versions/4/}Headers" COMMAND rm -rf "${FRAMEWORKS_PATH}/QtNetwork.framework/{,Versions/4/}Headers" COMMAND find "${FRAMEWORKS_PATH}" -name "*_debug*" -print0 | xargs -0 rm COMMAND install_name_tool -id "${INSTALL_PATH}/Contents/Frameworks/QtNetwork.framework/Versions/4/QtNetwork" "${FRAMEWORKS_PATH}/QtNetwork.framework/Versions/4/QtNetwork" COMMAND install_name_tool -id "${INSTALL_PATH}/Contents/Frameworks/QtCore.framework/Versions/4/QtCore" "${FRAMEWORKS_PATH}/QtCore.framework/Versions/4/QtCore" COMMAND install_name_tool -change "QtNetwork.framework/Versions/4/QtNetwork" "${INSTALL_PATH}/Contents/Frameworks/QtNetwork.framework/Versions/4/QtNetwork" ${BUNDLE_PATH}/Contents/MacOS/rinputd COMMAND install_name_tool -change "QtCore.framework/Versions/4/QtCore" "${INSTALL_PATH}/Contents/Frameworks/QtCore.framework/Versions/4/QtCore" "${BUNDLE_PATH}/Contents/MacOS/rinputd" COMMAND install_name_tool -change "QtCore.framework/Versions/4/QtCore" "${INSTALL_PATH}/Contents/Frameworks/QtCore.framework/Versions/4/QtCore" "${BUNDLE_PATH}/Contents/Frameworks/QtNetwork.framework/Versions/4/QtNetwork" COMMAND packagemaker --doc "${CMAKE_SOURCE_DIR}/mac/Remote Input Server.pmdoc" -o "${CMAKE_CURRENT_BINARY_DIR}/Remote Input Server.pkg" VERBATIM) add_dependencies(package rinputd rinputd-man) else () add_executable(rinputd ${rinputd_SRCS} ${rinputd_MOC_SRCS}) target_link_libraries(rinputd common ${QT_LIBRARIES} ${EXTRA_LIBS} sasl2) endif () if (USE_AVAHI) target_link_libraries(rinputd ${AVAHI_CLIENT_LIBRARIES} ${AVAHI_QT4_LIBRARIES}) endif () add_custom_target(rinputd-man ALL gzip -c --best ${rinput_SOURCE_DIR}/rinputd/rinputd.8 > rinputd.8.gz) if (NOT APPLE) install(TARGETS rinputd RUNTIME DESTINATION sbin COMPONENT rinputd) install(FILES ${CMAKE_CURRENT_BINARY_DIR}/rinputd.8.gz DESTINATION share/man/man8 COMPONENT man) install(DIRECTORY DESTINATION /etc/rinput) endif () rinputd_1.0.5/rinputd/AvahiBroadcaster.h0000664000175000017500000000362111736727464020523 0ustar cndouglacndougla/* * Copyright (C) 2009 Chase Douglas * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 as published * by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License along * with this program; if not, write to the Free Software Foundation, Inc., * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the * OpenSSL library under certain conditions as described in each * individual source file, and distribute linked combinations * including the two. * You must obey the GNU General Public License in all respects * for all of the code used other than OpenSSL. If you modify * file(s) with this exception, you may extend this exception to your * version of the file(s), but you are not obligated to do so. If you * do not wish to do so, delete this exception statement from your * version. */ #ifndef AVAHIBROADCASTER_H #define AVAHIBROADCASTER_H #include #include class AvahiBroadcaster : public QObject { Q_OBJECT public: AvahiBroadcaster(quint16 _port); ~AvahiBroadcaster(); void _avahiClientCallback(AvahiClient *client, AvahiClientState state); void _avahiEntryGroupCallback(AvahiEntryGroupState state); private: void createService(AvahiClient *client); void alternativeServiceName(); AvahiClient *avahiClient; AvahiEntryGroup *avahiGroup; QString avahiName; quint16 port; }; #endif // AVAHIBROADCASTER_H rinputd_1.0.5/rinputd/Server.cpp0000664000175000017500000001142111736727464017117 0ustar cndouglacndougla/* * Copyright (C) 2009 Chase Douglas * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 as published * by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License along * with this program; if not, write to the Free Software Foundation, Inc., * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the * OpenSSL library under certain conditions as described in each * individual source file, and distribute linked combinations * including the two. * You must obey the GNU General Public License in all respects * for all of the code used other than OpenSSL. If you modify * file(s) with this exception, you may extend this exception to your * version of the file(s), but you are not obligated to do so. If you * do not wish to do so, delete this exception statement from your * version. */ #include #include #include #include #include "config.h" #include "Connection.h" #include "Server.h" #include "macros.h" #include "rinput.h" #ifdef linux #include "LinuxInputDevice.h" #elif __APPLE__ #include "MacAuthThread.h" #include "MacInputDevice.h" #endif Server::Server(quint16 port, QString &realm, QSslCertificate &cert, QSslKey &key, bool broadcast) : config(QSslConfiguration::defaultConfiguration()) { #if defined __APPLE__ || defined USE_AVAHI broadcaster = NULL; #else broadcast = FALSE; #endif #ifndef __APPLE__ int result = sasl_server_init(NULL, "rinput"); if (result != SASL_OK) { qCritical("Error: Failed to initialize SASL interface (%d)", result); return; } result = sasl_server_new("rinput", NULL, realm.toAscii().data(), NULL, NULL, NULL, 0, &sasl); if (result != SASL_OK) { qCritical("Error: Failed to create SASL interface (%d)", result); return; } #endif config.setLocalCertificate(cert); config.setPrivateKey(key); if (!listen(QHostAddress::Any, port)) { qCritical("Error: Unable to bind to port %hu", port); return; } qWarning("Listening on port %hu", serverPort()); if (broadcast) { #ifdef __APPLE__ broadcaster = new MacBroadcaster(serverPort()); broadcaster->start(); broadcaster->setParent(this); #elif defined USE_AVAHI broadcaster = new AvahiBroadcaster(serverPort()); broadcaster->setParent(this); #endif } } void Server::incomingConnection(int sock) { Connection *connection = new Connection(sock, config); connection->setParent(this); connect(connection, SIGNAL(encrypted()), SLOT(connectionEncrypted())); connect(connection, SIGNAL(checkPass(const QByteArray &, const QByteArray &)), SLOT(checkPass(const QByteArray &, const QByteArray &))); connect(connection, SIGNAL(authenticated()), SLOT(connectionAuthenticated())); #ifndef NO_ENCRYPTION connection->startEncryption(); #else #ifndef NO_AUTHENTICATION connection->startAuthentication(); #else connection->startCommunication(); #endif #endif } void Server::connectionEncrypted() { Connection *connection = static_cast(sender()); #ifndef NO_AUTHENTICATION connection->startAuthentication(); #else connection->startCommunication(); #endif } void Server::checkPass(const QByteArray &user, const QByteArray &pass) { Connection *connection = static_cast(sender()); bool ok = FALSE; #ifdef __APPLE__ ok = MacAuthThread::authorized(*connection, user, pass); #else ok = (sasl_checkpass(sasl, user.data(), user.length(), pass.data(), pass.length()) == SASL_OK); #endif connection->checkPassResult(ok); } void Server::connectionAuthenticated() { Connection *connection = static_cast(sender()); connection->startCommunication(); rinput_message_t message = { RINPUT_VERSION, { RINPUT_PROTOCOL_VERSION } }; hton_rinput(&message); if (!connection->write(QByteArray((char *)&message, sizeof(message)))) { qWarning("Error: Failed to send protocol version message to client %s", qPrintable(connection->peerAddress().toString())); connection->disconnect(); return; } #ifdef linux LinuxInputDevice *device = new LinuxInputDevice(connection); #elif __APPLE__ MacInputDevice *device = new MacInputDevice(connection); #endif if (!device->create()) { delete device; } } rinputd_1.0.5/rinputd/InputDevice.cpp0000664000175000017500000000531011736727464020070 0ustar cndouglacndougla/* * Copyright (C) 2009 Chase Douglas * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 as published * by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License along * with this program; if not, write to the Free Software Foundation, Inc., * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the * OpenSSL library under certain conditions as described in each * individual source file, and distribute linked combinations * including the two. * You must obey the GNU General Public License in all respects * for all of the code used other than OpenSSL. If you modify * file(s) with this exception, you may extend this exception to your * version of the file(s), but you are not obligated to do so. If you * do not wish to do so, delete this exception statement from your * version. */ #include "Connection.h" #include "InputDevice.h" InputDevice::InputDevice(Connection *_connection) : connection(_connection), created(false) { connection->setParent(this); connect(connection, SIGNAL(readyRead()), SLOT(connectionReadyRead())); connect(connection, SIGNAL(disconnected()), SLOT(deleteLater())); } // This must be overridden in a subclass bool InputDevice::create() { return FALSE; } void InputDevice::connectionReadyRead() { while (connection->bytesAvailable() >= (signed)sizeof(rinput_message_t)) { rinput_message_t message; qint64 len; len = connection->read((char *)&message, sizeof(message)); if (len < 0) { qWarning("Warning: Received error while reading a message"); return; } if (len < (signed)sizeof(message)) { qCritical("Error: Failed to read entire message from client"); rinput_message_t errorMessage = { RINPUT_ERROR, { RINPUT_INTERNAL_ERROR } }; hton_rinput(&errorMessage); connection->write(QByteArray((const char *)&errorMessage, sizeof(errorMessage))); connection->disconnect(); return; } qDebug("Read message from client"); ntoh_rinput(&message); handleMessage(message); } } // This must be overridden in a subclass void InputDevice::handleMessage(rinput_message_t &message) {} rinputd_1.0.5/rinputd/MacBroadcaster.h0000664000175000017500000000323411736727464020173 0ustar cndouglacndougla/* * Copyright (C) 2009 Chase Douglas * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 as published * by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License along * with this program; if not, write to the Free Software Foundation, Inc., * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the * OpenSSL library under certain conditions as described in each * individual source file, and distribute linked combinations * including the two. * You must obey the GNU General Public License in all respects * for all of the code used other than OpenSSL. If you modify * file(s) with this exception, you may extend this exception to your * version of the file(s), but you are not obligated to do so. If you * do not wish to do so, delete this exception statement from your * version. */ #ifndef MACBROADCASTER_H #define MACBROADCASTER_H #include class NSNetService; class NSRunLoop; class MacBroadcaster : public QThread { Q_OBJECT public: MacBroadcaster(quint16 port); ~MacBroadcaster(); private: void run(); NSNetService *netService; NSRunLoop *runLoop; bool stop; }; #endif // MACBROADCASTER_H rinputd_1.0.5/rinputd/MacBroadcaster.mm0000664000175000017500000000532511736727464020360 0ustar cndouglacndougla/* * Copyright (C) 2009 Chase Douglas * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 as published * by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License along * with this program; if not, write to the Free Software Foundation, Inc., * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the * OpenSSL library under certain conditions as described in each * individual source file, and distribute linked combinations * including the two. * You must obey the GNU General Public License in all respects * for all of the code used other than OpenSSL. If you modify * file(s) with this exception, you may extend this exception to your * version of the file(s), but you are not obligated to do so. If you * do not wish to do so, delete this exception statement from your * version. */ #include #import #import #include "MacBroadcaster.h" @interface broadcasterDelegate : NSObject {} @end @implementation broadcasterDelegate - (void)netService:(NSNetService *)sender didNotPublish:(NSDictionary *)errorDict { qWarning("Failed to publish service over bonjour (domain: %d, error: %d)", [[errorDict objectForKey:NSNetServicesErrorDomain] intValue], [[errorDict objectForKey:NSNetServicesErrorCode] intValue]); } @end MacBroadcaster::MacBroadcaster(quint16 port) : stop(FALSE) { NSString *name = [[NSString alloc] initWithFormat:@"%@'s desktop on %s", NSFullUserName(), QHostInfo::localHostName().toAscii().data()]; netService = [[NSNetService alloc] initWithDomain:@"" type:@"_rinput._tcp" name:name port:port]; [name release]; netService.delegate = [[broadcasterDelegate alloc] init]; } void MacBroadcaster::run() { runLoop = [NSRunLoop currentRunLoop]; [netService scheduleInRunLoop:runLoop forMode:NSDefaultRunLoopMode]; [netService publish]; while (!stop && [runLoop runMode:NSDefaultRunLoopMode beforeDate:[NSDate distantFuture]]); } MacBroadcaster::~MacBroadcaster() { stop = TRUE; [netService stop]; [netService removeFromRunLoop:runLoop forMode:NSDefaultRunLoopMode]; [netService.delegate release]; [netService release]; } rinputd_1.0.5/LICENSE0000664000175000017500000004423311736727464014474 0ustar cndouglacndougla GNU GENERAL PUBLIC LICENSE Version 2, June 1991 Copyright (C) 1989, 1991 Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. Preamble The licenses for most software are designed to take away your freedom to share and change it. By contrast, the GNU General Public License is intended to guarantee your freedom to share and change free software--to make sure the software is free for all its users. This General Public License applies to most of the Free Software Foundation's software and to any other program whose authors commit to using it. (Some other Free Software Foundation software is covered by the GNU Lesser General Public License instead.) You can apply it to your programs, too. When we speak of free software, we are referring to freedom, not price. Our General Public Licenses are designed to make sure that you have the freedom to distribute copies of free software (and charge for this service if you wish), that you receive source code or can get it if you want it, that you can change the software or use pieces of it in new free programs; and that you know you can do these things. To protect your rights, we need to make restrictions that forbid anyone to deny you these rights or to ask you to surrender the rights. These restrictions translate to certain responsibilities for you if you distribute copies of the software, or if you modify it. For example, if you distribute copies of such a program, whether gratis or for a fee, you must give the recipients all the rights that you have. You must make sure that they, too, receive or can get the source code. And you must show them these terms so they know their rights. We protect your rights with two steps: (1) copyright the software, and (2) offer you this license which gives you legal permission to copy, distribute and/or modify the software. Also, for each author's protection and ours, we want to make certain that everyone understands that there is no warranty for this free software. If the software is modified by someone else and passed on, we want its recipients to know that what they have is not the original, so that any problems introduced by others will not reflect on the original authors' reputations. Finally, any free program is threatened constantly by software patents. We wish to avoid the danger that redistributors of a free program will individually obtain patent licenses, in effect making the program proprietary. To prevent this, we have made it clear that any patent must be licensed for everyone's free use or not licensed at all. The precise terms and conditions for copying, distribution and modification follow. GNU GENERAL PUBLIC LICENSE TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION 0. This License applies to any program or other work which contains a notice placed by the copyright holder saying it may be distributed under the terms of this General Public License. The "Program", below, refers to any such program or work, and a "work based on the Program" means either the Program or any derivative work under copyright law: that is to say, a work containing the Program or a portion of it, either verbatim or with modifications and/or translated into another language. (Hereinafter, translation is included without limitation in the term "modification".) Each licensee is addressed as "you". Activities other than copying, distribution and modification are not covered by this License; they are outside its scope. The act of running the Program is not restricted, and the output from the Program is covered only if its contents constitute a work based on the Program (independent of having been made by running the Program). Whether that is true depends on what the Program does. 1. You may copy and distribute verbatim copies of the Program's source code as you receive it, in any medium, provided that you conspicuously and appropriately publish on each copy an appropriate copyright notice and disclaimer of warranty; keep intact all the notices that refer to this License and to the absence of any warranty; and give any other recipients of the Program a copy of this License along with the Program. You may charge a fee for the physical act of transferring a copy, and you may at your option offer warranty protection in exchange for a fee. 2. You may modify your copy or copies of the Program or any portion of it, thus forming a work based on the Program, and copy and distribute such modifications or work under the terms of Section 1 above, provided that you also meet all of these conditions: a) You must cause the modified files to carry prominent notices stating that you changed the files and the date of any change. b) You must cause any work that you distribute or publish, that in whole or in part contains or is derived from the Program or any part thereof, to be licensed as a whole at no charge to all third parties under the terms of this License. c) If the modified program normally reads commands interactively when run, you must cause it, when started running for such interactive use in the most ordinary way, to print or display an announcement including an appropriate copyright notice and a notice that there is no warranty (or else, saying that you provide a warranty) and that users may redistribute the program under these conditions, and telling the user how to view a copy of this License. (Exception: if the Program itself is interactive but does not normally print such an announcement, your work based on the Program is not required to print an announcement.) These requirements apply to the modified work as a whole. If identifiable sections of that work are not derived from the Program, and can be reasonably considered independent and separate works in themselves, then this License, and its terms, do not apply to those sections when you distribute them as separate works. But when you distribute the same sections as part of a whole which is a work based on the Program, the distribution of the whole must be on the terms of this License, whose permissions for other licensees extend to the entire whole, and thus to each and every part regardless of who wrote it. Thus, it is not the intent of this section to claim rights or contest your rights to work written entirely by you; rather, the intent is to exercise the right to control the distribution of derivative or collective works based on the Program. In addition, mere aggregation of another work not based on the Program with the Program (or with a work based on the Program) on a volume of a storage or distribution medium does not bring the other work under the scope of this License. 3. You may copy and distribute the Program (or a work based on it, under Section 2) in object code or executable form under the terms of Sections 1 and 2 above provided that you also do one of the following: a) Accompany it with the complete corresponding machine-readable source code, which must be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange; or, b) Accompany it with a written offer, valid for at least three years, to give any third party, for a charge no more than your cost of physically performing source distribution, a complete machine-readable copy of the corresponding source code, to be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange; or, c) Accompany it with the information you received as to the offer to distribute corresponding source code. (This alternative is allowed only for noncommercial distribution and only if you received the program in object code or executable form with such an offer, in accord with Subsection b above.) The source code for a work means the preferred form of the work for making modifications to it. For an executable work, complete source code means all the source code for all modules it contains, plus any associated interface definition files, plus the scripts used to control compilation and installation of the executable. However, as a special exception, the source code distributed need not include anything that is normally distributed (in either source or binary form) with the major components (compiler, kernel, and so on) of the operating system on which the executable runs, unless that component itself accompanies the executable. If distribution of executable or object code is made by offering access to copy from a designated place, then offering equivalent access to copy the source code from the same place counts as distribution of the source code, even though third parties are not compelled to copy the source along with the object code. 4. You may not copy, modify, sublicense, or distribute the Program except as expressly provided under this License. Any attempt otherwise to copy, modify, sublicense or distribute the Program is void, and will automatically terminate your rights under this License. However, parties who have received copies, or rights, from you under this License will not have their licenses terminated so long as such parties remain in full compliance. 5. You are not required to accept this License, since you have not signed it. However, nothing else grants you permission to modify or distribute the Program or its derivative works. These actions are prohibited by law if you do not accept this License. Therefore, by modifying or distributing the Program (or any work based on the Program), you indicate your acceptance of this License to do so, and all its terms and conditions for copying, distributing or modifying the Program or works based on it. 6. Each time you redistribute the Program (or any work based on the Program), the recipient automatically receives a license from the original licensor to copy, distribute or modify the Program subject to these terms and conditions. You may not impose any further restrictions on the recipients' exercise of the rights granted herein. You are not responsible for enforcing compliance by third parties to this License. 7. If, as a consequence of a court judgment or allegation of patent infringement or for any other reason (not limited to patent issues), conditions are imposed on you (whether by court order, agreement or otherwise) that contradict the conditions of this License, they do not excuse you from the conditions of this License. If you cannot distribute so as to satisfy simultaneously your obligations under this License and any other pertinent obligations, then as a consequence you may not distribute the Program at all. For example, if a patent license would not permit royalty-free redistribution of the Program by all those who receive copies directly or indirectly through you, then the only way you could satisfy both it and this License would be to refrain entirely from distribution of the Program. If any portion of this section is held invalid or unenforceable under any particular circumstance, the balance of the section is intended to apply and the section as a whole is intended to apply in other circumstances. It is not the purpose of this section to induce you to infringe any patents or other property right claims or to contest validity of any such claims; this section has the sole purpose of protecting the integrity of the free software distribution system, which is implemented by public license practices. Many people have made generous contributions to the wide range of software distributed through that system in reliance on consistent application of that system; it is up to the author/donor to decide if he or she is willing to distribute software through any other system and a licensee cannot impose that choice. This section is intended to make thoroughly clear what is believed to be a consequence of the rest of this License. 8. If the distribution and/or use of the Program is restricted in certain countries either by patents or by copyrighted interfaces, the original copyright holder who places the Program under this License may add an explicit geographical distribution limitation excluding those countries, so that distribution is permitted only in or among countries not thus excluded. In such case, this License incorporates the limitation as if written in the body of this License. 9. The Free Software Foundation may publish revised and/or new versions of the General Public License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns. Each version is given a distinguishing version number. If the Program specifies a version number of this License which applies to it and "any later version", you have the option of following the terms and conditions either of that version or of any later version published by the Free Software Foundation. If the Program does not specify a version number of this License, you may choose any version ever published by the Free Software Foundation. 10. If you wish to incorporate parts of the Program into other free programs whose distribution conditions are different, write to the author to ask for permission. For software which is copyrighted by the Free Software Foundation, write to the Free Software Foundation; we sometimes make exceptions for this. Our decision will be guided by the two goals of preserving the free status of all derivatives of our free software and of promoting the sharing and reuse of software generally. NO WARRANTY 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. END OF TERMS AND CONDITIONS How to Apply These Terms to Your New Programs If you develop a new program, and you want it to be of the greatest possible use to the public, the best way to achieve this is to make it free software which everyone can redistribute and change under these terms. To do so, attach the following notices to the program. It is safest to attach them to the start of each source file to most effectively convey the exclusion of warranty; and each file should have at least the "copyright" line and a pointer to where the full notice is found. Copyright (C) This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. Also add information on how to contact you by electronic and paper mail. If the program is interactive, make it output a short notice like this when it starts in an interactive mode: Gnomovision version 69, Copyright (C) year name of author Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. This is free software, and you are welcome to redistribute it under certain conditions; type `show c' for details. The hypothetical commands `show w' and `show c' should show the appropriate parts of the General Public License. Of course, the commands you use may be called something other than `show w' and `show c'; they could even be mouse-clicks or menu items--whatever suits your program. You should also get your employer (if you work as a programmer) or your school, if any, to sign a "copyright disclaimer" for the program, if necessary. Here is a sample; alter the names: Yoyodyne, Inc., hereby disclaims all copyright interest in the program `Gnomovision' (which makes passes at compilers) written by James Hacker. , 1 April 1989 Ty Coon, President of Vice This General Public License does not permit incorporating your program into proprietary programs. If your program is a subroutine library, you may consider it more useful to permit linking proprietary applications with the library. If this is what you want to do, use the GNU Lesser General Public License instead of this License. In addition, as a special exception, the copyright holders give permission to link the code of portions of this program with the OpenSSL library under certain conditions as described in each individual source file, and distribute linked combinations including the two. You must obey the GNU General Public License in all respects for all of the code used other than OpenSSL. If you modify file(s) with this exception, you may extend this exception to your version of the file(s), but you are not obligated to do so. If you do not wish to do so, delete this exception statement from your version. rinputd_1.0.5/LICENSE.openssl0000664000175000017500000001547011736727464016157 0ustar cndouglacndouglaCertain source files in this program permit linking with the OpenSSL library (http://www.openssl.org), which otherwise wouldn't be allowed under the GPL. For purposes of identifying OpenSSL, most source files giving this permission limit it to versions of OpenSSL having a license identical to that listed in this file (LICENSE.OpenSSL). It is not necessary for the copyright years to match between this file and the OpenSSL version in question. However, note that because this file is an extension of the license statements of these source files, this file may not be changed except with permission from all copyright holders of source files in this program which reference this file. LICENSE ISSUES ============== The OpenSSL toolkit stays under a dual license, i.e. both the conditions of the OpenSSL License and the original SSLeay license apply to the toolkit. See below for the actual license texts. Actually both licenses are BSD-style Open Source licenses. In case of any license issues related to OpenSSL please contact openssl-core@openssl.org. OpenSSL License --------------- /* ==================================================================== * Copyright (c) 1998-2002 The OpenSSL Project. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in * the documentation and/or other materials provided with the * distribution. * * 3. All advertising materials mentioning features or use of this * software must display the following acknowledgment: * "This product includes software developed by the OpenSSL Project * for use in the OpenSSL Toolkit. (http://www.openssl.org/)" * * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to * endorse or promote products derived from this software without * prior written permission. For written permission, please contact * openssl-core@openssl.org. * * 5. Products derived from this software may not be called "OpenSSL" * nor may "OpenSSL" appear in their names without prior written * permission of the OpenSSL Project. * * 6. Redistributions of any form whatsoever must retain the following * acknowledgment: * "This product includes software developed by the OpenSSL Project * for use in the OpenSSL Toolkit (http://www.openssl.org/)" * * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED * OF THE POSSIBILITY OF SUCH DAMAGE. * ==================================================================== * * This product includes cryptographic software written by Eric Young * (eay@cryptsoft.com). This product includes software written by Tim * Hudson (tjh@cryptsoft.com). * */ Original SSLeay License ----------------------- /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * * This package is an SSL implementation written * by Eric Young (eay@cryptsoft.com). * The implementation was written so as to conform with Netscapes SSL. * * This library is free for commercial and non-commercial use as long as * the following conditions are aheared to. The following conditions * apply to all code found in this distribution, be it the RC4, RSA, * lhash, DES, etc., code; not just the SSL code. The SSL documentation * included with this distribution is covered by the same copyright terms * except that the holder is Tim Hudson (tjh@cryptsoft.com). * * Copyright remains Eric Young's, and as such any Copyright notices in * the code are not to be removed. * If this package is used in a product, Eric Young should be given attribution * as the author of the parts of the library used. * This can be in the form of a textual message at program startup or * in documentation (online or textual) provided with the package. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 3. All advertising materials mentioning features or use of this software * must display the following acknowledgement: * "This product includes cryptographic software written by * Eric Young (eay@cryptsoft.com)" * The word 'cryptographic' can be left out if the rouines from the library * being used are not cryptographic related :-). * 4. If you include any Windows specific code (or a derivative thereof) from * the apps directory (application code) you must include an acknowledgement: * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" * * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * * The licence and distribution terms for any publically available version or * derivative of this code cannot be changed. i.e. this code cannot simply be * copied and put under another distribution licence * [including the GNU Public Licence.] */ rinputd_1.0.5/CMakeLists.txt0000664000175000017500000000343011736727464016221 0ustar cndouglacndouglaif (DEFINED CMAKE_BUILD_TYPE) set(CMAKE_BUILD_TYPE ${CMAKE_BUILD_TYPE} CACHE STRING "Choose the type of build: None (CMAKE_CXX_FLAGS or CMAKE_C_FLAGS used) Debug Release RelWithDebInfo MinSizeRel") else () SET(CMAKE_BUILD_TYPE RelWithDebInfo CACHE STRING "Choose the type of build: None (CMAKE_CXX_FLAGS or CMAKE_C_FLAGS used) Debug Release RelWithDebInfo MinSizeRel") endif () set(CMAKE_CXX_FLAGS ${CMAKE_CXX_FLAGS} -pipe) if (APPLE) set(CMAKE_OSX_ARCHITECTURES i386;x86_64 CACHE STRING "Architecture") endif () if (NOT APPLE) option(USE_AVAHI "Use Avahi for multicast DNS service publishing" ON) else () set(USE_AVAHI OFF) endif () project(rinput) cmake_minimum_required(VERSION 2.6) include(CheckIncludeFiles) include(CheckLibraryExists) if (USE_AVAHI) include(FindPkgConfig) endif () configure_file(config.h.in config.h) include_directories(${CMAKE_BINARY_DIR}) find_package(Qt4 REQUIRED) if (NOT APPLE) check_include_files(sasl/sasl.h HAVE_SASL_H) check_library_exists(sasl2 sasl_checkpass "" HAVE_LIBSASL2) if (NOT HAVE_SASL_H) message(FATAL_ERROR "Could not find cyrus-sasl headers") endif () if (NOT HAVE_LIBSASL2) message(FATAL_ERROR "Could not find libsasl2 library") endif () endif () if (USE_AVAHI) pkg_check_modules(AVAHI_CLIENT avahi-client) pkg_check_modules(AVAHI_QT4 avahi-qt4) if (NOT ${AVAHI_CLIENT_FOUND} OR NOT ${AVAHI_QT4_FOUND}) message(FATAL_ERROR "Could not find Avahi client and/or Avahi Qt4 development packages. Install them or turn off USE_AVAHI in cmake") endif () endif () option(BUILD_TEST "Build rinput-test test client" NO) add_subdirectory(common) add_subdirectory(rinputd) if (BUILD_TEST) add_subdirectory(rinput-test) endif () rinputd_1.0.5/init.d/0000775000175000017500000000000011736727464014646 5ustar cndouglacndouglarinputd_1.0.5/init.d/rinputd.init.fedora0000775000175000017500000000400211736727464020456 0ustar cndouglacndougla#! /bin/sh # the following is the LSB init header see # http://www.linux-foundation.org/spec//booksets/LSB-Core-generic/LSB-Core-generic.html#INITSCRCOMCONV # ### BEGIN INIT INFO # Provides: rinputd # Should-Start: $saslauthd $network # Default-Start: 2 3 4 5 # Short-Description: rinputd remote input server daemon # Description: Listens for remote input clients that send input events # like key presses or mouse movements. ### END INIT INFO # the following is the chkconfig init header # # rinputd: rinputd remote input server daemon # # chkconfig: - 70 99 # description: Listens for remote input clients that send input events # like key presses or mouse movements. # # Author: Chase Douglas # Modified for Fedora by Jarod Wilson DESC="Remote Input Daemon" prog=rinputd DAEMON=/usr/sbin/$prog PIDFILE=/var/run/$prog.pid # Exit if the package is not installed [ -x "$DAEMON" ] || exit 0 # Read configuration variable file if it is present [ -r /etc/rinput/$prog.conf ] && . /etc/rinput/$prog.conf # Source function library . /etc/init.d/functions # # Function that starts the daemon/service # do_start() { # We have a hard dependency on uinput to deliver events, # so make damned sure the uinput driver is loaded. /sbin/modprobe uinput >/dev/null 2>&1 echo -n $"Starting $DESC: " # hack alert: $prog has no native daemonizing... (daemon $prog $RINPUTD_ARGS &) 2>/dev/null status $prog >/dev/null 2>&1 retval=$? if [ $retval -eq 0 ]; then success echo else failure echo fi return $retval } # # Function that stops the daemon/service # do_stop() { echo -n $"Stopping $DESC: " killproc $prog echo return $? } case "$1" in start) do_start ;; stop) do_stop ;; restart|reload|force-reload) do_stop do_start ;; status) status $prog exit $? ;; *) echo "Usage: $0 {start|stop|restart|force-reload|status}" >&2 exit 2 ;; esac : rinputd_1.0.5/init.d/rinputd.init.debian0000775000175000017500000000464511736727464020455 0ustar cndouglacndougla#! /bin/sh ### BEGIN INIT INFO # Provides: rinputd # Required-Start: $remote_fs $network # Required-Stop: $remote_fs $network # Default-Start: 2 3 4 5 # Default-Stop: 0 1 6 # Short-Description: rinputd remote input server daemon # Description: Listens for remote input clients that send input events # like key presses or mouse movements. ### END INIT INFO # Author: Chase Douglas PATH=/sbin:/usr/sbin:/bin:/usr/bin DESC="Remote Input Daemon" NAME=rinputd DAEMON=/usr/sbin/$NAME SCRIPTNAME=/etc/init.d/$NAME # Exit if the package is not installed [ -x "$DAEMON" ] || exit 0 # Read configuration variable file if it is present [ -r /etc/default/$NAME ] && . /etc/default/$NAME # Load the VERBOSE setting and other rcS variables . /lib/init/vars.sh # Define LSB log_* functions. # Depend on lsb-base (>= 3.0-6) to ensure that this file is present. . /lib/lsb/init-functions # # Function that starts the daemon/service # do_start() { modprobe uinput >/dev/null 2>&1 # Return # 0 if daemon has been started # 1 if daemon was already running # 2 if daemon could not be started start-stop-daemon --start --quiet --exec $DAEMON --test > /dev/null \ || return 1 start-stop-daemon --start --quiet --exec $DAEMON --background -- \ $RINPUTD_ARGS \ || return 2 } # # Function that stops the daemon/service # do_stop() { # Return # 0 if daemon has been stopped # 1 if daemon was already stopped # 2 if daemon could not be stopped # other if a failure occurred start-stop-daemon --stop --quiet --retry=TERM/30/KILL/5 --exec $DAEMON return $? } case "$1" in start) [ "$VERBOSE" != no ] && log_daemon_msg "Starting $DESC" "$NAME" do_start case "$?" in 0|1) [ "$VERBOSE" != no ] && log_end_msg 0 ;; 2) [ "$VERBOSE" != no ] && log_end_msg 1 ;; esac ;; stop) [ "$VERBOSE" != no ] && log_daemon_msg "Stopping $DESC" "$NAME" do_stop case "$?" in 0|1) [ "$VERBOSE" != no ] && log_end_msg 0 ;; 2) [ "$VERBOSE" != no ] && log_end_msg 1 ;; esac ;; restart|force-reload) log_daemon_msg "Restarting $DESC" "$NAME" do_stop case "$?" in 0|1) do_start case "$?" in 0) log_end_msg 0 ;; 1) log_end_msg 1 ;; # Old process is still running *) log_end_msg 1 ;; # Failed to start esac ;; *) # Failed to stop log_end_msg 1 ;; esac ;; *) echo "Usage: $SCRIPTNAME {start|stop|restart|force-reload}" >&2 exit 3 ;; esac : rinputd_1.0.5/.bzrignore0000664000175000017500000000040011736727464015455 0ustar cndouglacndouglaMakefile moc_* ./rinputd/rinputd ./rinputd/rinputd.8.gz CMakeFiles CMakeScripts CMakeCache.txt cmake_install.cmake install_manifest.txt ./config.h *.asc rinputd_*.tar.gz # Mac Xcode Files *.xcodeproj build *.build Debug Release RelWithDebInfo *.app *.pkg rinputd_1.0.5/mac/0000775000175000017500000000000011736727464014221 5ustar cndouglacndouglarinputd_1.0.5/mac/Remote Input Server.pmdoc/0000775000175000017500000000000011736727464021064 5ustar cndouglacndouglarinputd_1.0.5/mac/Remote Input Server.pmdoc/03rinputd.xml0000664000175000017500000000232111736727464023434 0ustar cndouglacndouglacom.rinputd.remoteInputServer.rinputd.pkg0.1../rinputd/rinputd.app/Library/Remote Input/installToscripts.postinstall.pathscripts.preinstall.isRelativeTypeidentifierparentversioninstallTo.pathinstallFrom.isRelativeTypescripts.postinstall.isRelativeTyperinputd.preinstrinputd.postinst03rinputd-contents.xmlisRelocatable/CVS$/\.svn$/\.cvsignore$/\.cvspass$/\.DS_Store$rinputd_1.0.5/mac/Remote Input Server.pmdoc/02com-contents.xml0000664000175000017500000000031611736727464024361 0ustar cndouglacndouglagroupownerrinputd_1.0.5/mac/Remote Input Server.pmdoc/03rinputd-contents.xml0000664000175000017500000000343711736727464025300 0ustar cndouglacndouglamodemodemodemodemodemodemodemodemodemodemodemodemodemodemodemodemodemodemodemodemodemodemodemodemodemodegroupownerrinputd_1.0.5/mac/Remote Input Server.pmdoc/01rinputd-contents.xml0000664000175000017500000000031011736727464025261 0ustar cndouglacndouglagroupownerrinputd_1.0.5/mac/Remote Input Server.pmdoc/02com.xml0000664000175000017500000000140111736727464022522 0ustar cndouglacndouglacom.rinputd.remoteInputServer.com.rinputd.pkg0.1com.rinputd.plist/Library/LaunchAgents/installTo.pathinstallFrom.isRelativeTypeparentinstallToversion02com-contents.xml/CVS$/\.svn$/\.cvsignore$/\.cvspass$/\.DS_Store$rinputd_1.0.5/mac/Remote Input Server.pmdoc/01rinputd.xml0000664000175000017500000000140711736727464023436 0ustar cndouglacndouglacom.rinputd.remoteInputServer.rinputd.8.pkg0.1../rinputd/rinputd.8.gz/usr/share/man/man8/installTo.pathinstallFrom.isRelativeTypeparentinstallToversion01rinputd-contents.xml/CVS$/\.svn$/\.cvsignore$/\.cvspass$/\.DS_Store$rinputd_1.0.5/mac/Remote Input Server.pmdoc/index.xml0000664000175000017500000000332211736727464022715 0ustar cndouglacndouglaRemote Input Server/Users/cndougla/devel/rinput/mac/Remote Input Server.pkgcom.rinputdRemote Input Server../LICENSEIncompatible OS X VersionOS X 10.6 or later is required.01rinputd.xml02com.xml03rinputd.xmlproperties.systemDomainproperties.titleproperties.customizeOptiondescriptionproperties.anywhereDomainextraFiles rinputd_1.0.5/mac/rinputd.postinst0000775000175000017500000000373411736727464017525 0ustar cndouglacndougla#!/bin/bash -x exec 3>>/tmp/rinput-install.log exec 2<&3 set -e chown root:admin "/Library/Remote Input" chmod 775 "/Library/Remote Input" if [ -e /etc/rinput/rinput.key -o -e /etc/rinput/rinput.crt ]; then # Assume that the com.rinputd group already exists chgrp com.rinputd "/Library/Remote Input/rinputd.app/Contents/MacOS/rinputd" chmod g+s "/Library/Remote Input/rinputd.app/Contents/MacOS/rinputd" # Load launch agents for all logged in users for proc in `ps ax | grep loginwindow | grep -v grep | cut -c 1-5`; do user=`ps -o user -p ${proc} | awk 'NR==1{next} {print $1}'` launchctl bsexec ${proc} sudo -u ${user} launchctl load -S Aqua /Library/LaunchAgents/com.rinputd.plist done rm -f /tmp/rinput-install.log exit 0; fi if ! dscl . list /groups | grep -q "com\.rinputd"; then # Find an unused group ID gid="25" while true; do name=`dscl . search /groups PrimaryGroupID $gid | cut -f1 -s` if [ -z "$name" ] ; then break fi gid=$[$gid + 1] done dscl . -create /groups/com.rinputd gid $gid fi chgrp com.rinputd "/Library/Remote Input/rinputd.app/Contents/MacOS/rinputd" chmod g+s "/Library/Remote Input/rinputd.app/Contents/MacOS/rinputd" mkdir -p /etc/rinput echo -n "Generating SSL key for rinputd... " openssl genrsa -out /etc/rinput/rinput.key 1024 > /dev/null 2>&1 echo "Done" chgrp com.rinputd /etc/rinput/rinput.key chmod 640 /etc/rinput/rinput.key echo -n "Generating SSL certificate for rinputd... " echo " `hostname` " | openssl req -new -x509 -key /etc/rinput/rinput.key -out /etc/rinput/rinput.crt -days 1095 > /dev/null 2>&1 echo "Done" # Load launch agents for all logged in users for proc in `ps ax | grep loginwindow | grep -v grep | cut -c 1-5`; do user=`ps -o user -p ${proc} | awk 'NR==1{next} {print $1}'` launchctl bsexec ${proc} sudo -u ${user} launchctl load -S Aqua /Library/LaunchAgents/com.rinputd.plist done rm -f /tmp/rinput-install.log rinputd_1.0.5/mac/com.rinputd.plist0000664000175000017500000000072111736727464017540 0ustar cndouglacndougla Label com.rinputd ProgramArguments /Library/Remote Input/rinputd.app/Contents/MacOS/rinputd -p 0 KeepAlive RunAtLoad rinputd_1.0.5/mac/rinputd.preinst0000775000175000017500000000053011736727464017315 0ustar cndouglacndougla#!/bin/bash -x exec 3>/tmp/rinput-install.log exec 2<&3 # Remove launch agents for all logged in users for proc in `ps ax | grep loginwindow | grep -v grep | cut -c 1-5`; do user=`ps -o user -p ${proc} | awk 'NR==1{next} {print $1}'` launchctl bsexec ${proc} sudo -u ${user} launchctl remove com.rinputd > /dev/null 2>&1 done exit 0 rinputd_1.0.5/config.h.in0000664000175000017500000000251411736727464015506 0ustar cndouglacndougla/* * Copyright (C) 2009 Chase Douglas * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 as published * by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License along * with this program; if not, write to the Free Software Foundation, Inc., * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the * OpenSSL library under certain conditions as described in each * individual source file, and distribute linked combinations * including the two. * You must obey the GNU General Public License in all respects * for all of the code used other than OpenSSL. If you modify * file(s) with this exception, you may extend this exception to your * version of the file(s), but you are not obligated to do so. If you * do not wish to do so, delete this exception statement from your * version. */ #cmakedefine USE_AVAHI