[-]
[+]
|
Changed |
_service:tar_git:harbour-ambience-tohkbd2.changes
|
|
[-]
[+]
|
Changed |
_service:tar_git:harbour-ambience-tohkbd2.spec
^
|
|
[-]
[+]
|
Changed |
_service
^
|
@@ -6,7 +6,7 @@
<service name="tar_git">
<param name="url">https://github.com/kimmoli/tohkbd2.git</param>
<param name="branch">master</param>
- <param name="revision">b52b0318bc1e5c91f26d0dcd16eceea94b148fca</param>
+ <param name="revision">5c8edeaccf679db8357aa6fe665383aca6a167bb</param>
<param name="token"/>
<param name="debian">N</param>
<param name="dumb">N</param>
|
[-]
[+]
|
Changed |
_service:tar_git:harbour-ambience-tohkbd2-0.3.13.tar.bz2/daemon/daemon.pro
^
|
@@ -39,7 +39,8 @@
src/daemonAdaptor.cpp \
src/eepromdriver.cpp \
src/modifierhandler.cpp \
- ../user-daemon/src/userInterface.cpp
+ ../user-daemon/src/userInterface.cpp \
+ src/uinputevpoll.cpp
HEADERS += \
src/toh.h \
@@ -54,7 +55,8 @@
src/eepromdriver.h \
src/keymapping_lut.h \
src/modifierhandler.h \
- ../user-daemon/src/userInterface.h
+ ../user-daemon/src/userInterface.h \
+ src/uinputevpoll.h
OTHER_FILES += \
config/$${TARGET}.service \
|
[-]
[+]
|
Changed |
_service:tar_git:harbour-ambience-tohkbd2-0.3.13.tar.bz2/daemon/src/modifierhandler.cpp
^
|
@@ -97,7 +97,7 @@
void modifierHandler::clear(bool force)
{
- /* If tere is something to clear, clear */
+ /* If there is something to clear, clear */
if ((pressed && !down && !locked) || force)
{
locked = false;
|
[-]
[+]
|
Changed |
_service:tar_git:harbour-ambience-tohkbd2-0.3.13.tar.bz2/daemon/src/tohkeyboard.cpp
^
|
@@ -83,6 +83,19 @@
uinputif = new UinputIf();
uinputif->openUinputDevice();
+ uinputevpoll = new UinputEvPoll();
+ evpollThread = new QThread();
+
+ uinputevpoll->moveToThread(evpollThread);
+ connect(uinputevpoll, SIGNAL(capsLockLedChanged(bool)), this, SLOT(capsLockLedState(bool)));
+ connect(uinputevpoll, SIGNAL(pollingRequested()), evpollThread, SLOT(start()));
+ connect(evpollThread, SIGNAL(started()), uinputevpoll, SLOT(doPoll()));
+ connect(uinputevpoll, SIGNAL(finished()), evpollThread, SLOT(quit()), Qt::DirectConnection);
+
+ uinputevpoll->requestPolling(uinputif->getFd());
+
+ printf("uinputevpoll->requestPolling(uinputif->getFd());\n");
+
tca8424 = new tca8424driver(0x3b);
keymap = new keymapping();
@@ -726,26 +739,15 @@
checkDoWeNeedBacklight();
}
-
+/* Press caps-lock key once, toggles it state
+ * led state is controlled by system through EV_LED
+ */
void Tohkbd::toggleCapsLock()
{
uinputif->sendUinputKeyPress(KEY_CAPSLOCK, 1);
QThread::msleep(KEYREPEAT_RATE);
uinputif->sendUinputKeyPress(KEY_CAPSLOCK, 0);
uinputif->synUinputDevice();
-
- capsLock = !capsLock;
-
- if (capsLock)
- {
- tca8424->setLeds(LED_CAPSLOCK_ON);
- printf("CapsLock on\n");
- }
- else
- {
- tca8424->setLeds(LED_CAPSLOCK_OFF);
- printf("CapsLock off\n");
- }
}
@@ -1327,3 +1329,24 @@
return false;
}
}
+
+/* UinputEvPoll will emit signal if caps lock led state is seen in evdev
+ */
+void Tohkbd::capsLockLedState(bool state)
+{
+ if (state != capsLock)
+ {
+ printf("caps lock led state changed to %s\n", state ? "on" : "off");
+
+ capsLock = state;
+
+ if (capsLock)
+ {
+ tca8424->setLeds(LED_CAPSLOCK_ON);
+ }
+ else
+ {
+ tca8424->setLeds(LED_CAPSLOCK_OFF);
+ }
+ }
+}
|
[-]
[+]
|
Changed |
_service:tar_git:harbour-ambience-tohkbd2-0.3.13.tar.bz2/daemon/src/tohkeyboard.h
^
|
@@ -18,6 +18,7 @@
#include <QHash>
#include "uinputif.h"
+#include "uinputevpoll.h"
#include "tca8424driver.h"
#include "keymapping.h"
@@ -53,6 +54,7 @@
void handleKeyReleased();
void toggleCapsLock();
+ void capsLockLedState(bool state);
/* timer timeouts */
void backlightTimerTimeout();
@@ -100,6 +102,8 @@
QThread *thread;
Worker *worker;
UinputIf *uinputif;
+ UinputEvPoll *uinputevpoll;
+ QThread *evpollThread;
tca8424driver *tca8424;
keymapping *keymap;
|
[-]
[+]
|
Added |
_service:tar_git:harbour-ambience-tohkbd2-0.3.13.tar.bz2/daemon/src/uinputevpoll.cpp
^
|
@@ -0,0 +1,122 @@
+#include "uinputevpoll.h"
+#include <stdio.h>
+#include <sys/epoll.h>
+#include <unistd.h>
+#include <errno.h>
+#include <linux/input.h>
+
+UinputEvPoll::UinputEvPoll(QObject *parent) :
+ QObject(parent)
+{
+ _polling = false;
+ _abort = false;
+}
+
+void UinputEvPoll::abort()
+{
+ mutex.lock();
+ if (_polling)
+ {
+ _abort = true;
+ }
+ mutex.unlock();
+}
+
+void UinputEvPoll::requestPolling(int fd)
+{
+ mutex.lock();
+ _polling = true;
+ _abort = false;
+ _uinputfd = fd;
+ mutex.unlock();
+
+ emit pollingRequested();
+}
+
+void UinputEvPoll::doPoll()
+{
+ int epfd;
+ int ret;
+ int i;
+ struct epoll_event ev;
+ struct epoll_event evs[16];
+
+ epfd = epoll_create1(0);
+
+ if (epfd < 0)
+ {
+ printf("failed to create epoll instance\n");
+ return;
+ }
+
+ memset(&ev, 0, sizeof(ev));
+ ev.events = EPOLLIN;
+ ev.data.fd = _uinputfd;
+
+ ret = epoll_ctl(epfd, EPOLL_CTL_ADD, _uinputfd, &ev);
+ if (ret)
+ {
+ printf("Couldn't add to epoll\n");
+ close(epfd);
+ return;
+ }
+
+ printf("starting caps lock led polling.\n");
+
+ for (;;)
+ {
+ // Checks if the process should be aborted
+ mutex.lock();
+ bool abort = _abort;
+ mutex.unlock();
+
+ if (abort)
+ {
+ break;
+ }
+
+ ret = epoll_wait(epfd, evs, 16, -1);
+
+ if (ret < 0)
+ {
+ if (errno == EINTR)
+ continue;
+ else
+ break;
+ }
+
+ for (i = 0 ; i<ret ; i++)
+ {
+ readKeyboard(evs[i].data.fd);
+ }
+ }
+
+ close(epfd);
+
+ emit finished();
+}
+
+void UinputEvPoll::readKeyboard(int fd)
+{
+ ssize_t len;
+ struct input_event evs[16];
+
+ while ((len = read(fd, &evs, sizeof(evs))) > 0)
+ {
+ const size_t nevs = len / sizeof(struct input_event);
+ size_t i;
+ for (i = 0; i < nevs; i++)
+ {
+ if (evs[i].type == EV_LED && evs[i].code == LED_CAPSL)
+ {
+ emit capsLockLedChanged(evs[i].value == 1);
+ }
+ }
+ }
+
+ if (len < 0 && errno != EWOULDBLOCK)
+ {
+ printf("Couldn't read, %s\n", strerror(errno));
+ return;
+ }
+}
|
[-]
[+]
|
Added |
_service:tar_git:harbour-ambience-tohkbd2-0.3.13.tar.bz2/daemon/src/uinputevpoll.h
^
|
@@ -0,0 +1,35 @@
+#ifndef UINPUTEVPOLL_H
+#define UINPUTEVPOLL_H
+
+#include <QObject>
+#include <QMutex>
+
+class UinputEvPoll : public QObject
+{
+ Q_OBJECT
+public:
+ explicit UinputEvPoll(QObject *parent = 0);
+
+ void requestPolling(int fd);
+ void abort();
+
+signals:
+ void capsLockLedChanged(bool state);
+ void pollingRequested();
+ void finished();
+
+public slots:
+ void doPoll();
+
+private:
+ bool _polling;
+ bool _abort;
+ int _uinputfd;
+
+ QMutex mutex;
+
+ void readKeyboard(int fd);
+
+};
+
+#endif // UINPUTEVPOLL_H
|
[-]
[+]
|
Changed |
_service:tar_git:harbour-ambience-tohkbd2-0.3.13.tar.bz2/daemon/src/uinputif.cpp
^
|
@@ -24,7 +24,7 @@
int UinputIf::fd = -1;
-static const int eventsToRegister[] = { EV_KEY, EV_SW, EV_SYN,
+static const int eventsToRegister[] = { EV_KEY, EV_SW, EV_SYN, EV_LED,
-1 };
static const int keysToRegister[] = { KEY_UP, KEY_DOWN, KEY_LEFT, KEY_RIGHT,KEY_HOME, KEY_END, KEY_PAGEDOWN, KEY_PAGEUP,
@@ -44,6 +44,9 @@
static const int switchesToRegister[] = { SW_LID, SW_KEYPAD_SLIDE,
-1 };
+static const int ledsToRegister[] = { LED_CAPSL,
+ -1 };
+
UinputIf::UinputIf(QObject *parent) :
QObject(parent)
{
@@ -61,7 +64,7 @@
struct uinput_user_dev uidev;
- fd = open("/dev/uinput", O_WRONLY | O_NONBLOCK);
+ fd = open("/dev/uinput", O_RDWR | O_NONBLOCK);
if (fd < 0)
{
printf("uinput: error: open\n");
@@ -97,6 +100,16 @@
return false;
}
}
+
+ /* Enable selected LEDs */
+ for (i=0; ledsToRegister[i] != -1; i++)
+ {
+ if (ioctl(fd, UI_SET_LEDBIT, ledsToRegister[i]) < 0)
+ {
+ printf("uinput: error: ioctl UI_SET_LEDBIT %d\n", i);
+ return false;
+ }
+ }
memset(&uidev, 0, sizeof(uidev));
strncpy(uidev.name, conf_devname, UINPUT_MAX_NAME_SIZE);
|
[-]
[+]
|
Changed |
_service:tar_git:harbour-ambience-tohkbd2-0.3.13.tar.bz2/daemon/src/uinputif.h
^
|
@@ -20,6 +20,8 @@
int sendUinputKeyPress(unsigned int code, int val);
int sendUinputSwitch(unsigned int code, int val);
+ int getFd() { return fd; }
+
signals:
public slots:
|
[-]
[+]
|
Changed |
_service:tar_git:harbour-ambience-tohkbd2-0.3.13.tar.bz2/settings-ui/src/tohkbd2-settingsui.cpp
^
|
@@ -26,11 +26,11 @@
QScopedPointer<QGuiApplication> app(SailfishApp::application(argc, argv));
QTranslator engineeringTranslator;
- engineeringTranslator.load("engineering_en", "/usr/share/harbour-tohkbd2-settingsui/i18n");
+ engineeringTranslator.load("engineering_en", SailfishApp::pathTo("i18n").toLocalFile());
app->installTranslator(&engineeringTranslator);
QTranslator translator;
- translator.load(QLocale::system().name(), "/usr/share/harbour-tohkbd2-settingsui/i18n");
+ translator.load(QLocale::system().name(), SailfishApp::pathTo("i18n").toLocalFile());
app->installTranslator(&translator);
QScopedPointer<QQuickView> view(SailfishApp::createView());
|
[-]
[+]
|
Changed |
_service:tar_git:harbour-ambience-tohkbd2-0.3.13.tar.bz2/user-daemon/src/screenshot.cpp
^
|
@@ -11,7 +11,7 @@
void ScreenShot::takeScreenShot()
{
QString ssFilename = QString("%1/ss%2.png")
- .arg("/home/nemo/Pictures")
+ .arg(QStandardPaths::writableLocation(QStandardPaths::PicturesLocation))
.arg(QDateTime::currentDateTime().toString("yyyyMMdd-hhmmss-zzz"));
QDBusMessage m = QDBusMessage::createMethodCall("org.nemomobile.lipstick",
|
[-]
[+]
|
Changed |
_service:tar_git:harbour-ambience-tohkbd2-0.3.13.tar.bz2/user-daemon/src/tohkbd2user.cpp
^
|
@@ -46,11 +46,11 @@
view->setClearBeforeRendering(true);
QTranslator engineeringTranslator;
- engineeringTranslator.load("engineering_en", "/usr/share/harbour-tohkbd2-user/i18n");
+ engineeringTranslator.load("engineering_en", SailfishApp::pathTo("i18n").toLocalFile());
app->installTranslator(&engineeringTranslator);
QTranslator translator;
- translator.load(QLocale::system().name(), "/usr/share/harbour-tohkbd2-user/i18n");
+ translator.load(QLocale::system().name(), SailfishApp::pathTo("i18n").toLocalFile());
app->installTranslator(&translator);
view->setSource(SailfishApp::pathTo("qml/taskswitcher.qml"));
|