maemo.org - Talk

maemo.org - Talk (https://talk.maemo.org/index.php)
-   Development (https://talk.maemo.org/forumdisplay.php?f=13)
-   -   Detect hw keyboard slide event (https://talk.maemo.org/showthread.php?t=62198)

Willem Liu 2010-09-13 07:51

Detect hw keyboard slide event
 
Is there a way to receive events from the hardware keyboard when it opens and closes?

Thanks for your answer!

rambo 2010-09-13 10:48

Re: Detect hw keyboard slide event
 
yes, use the search to see how.

Willem Liu 2010-09-13 10:54

Re: Detect hw keyboard slide event
 
Quote:

Originally Posted by rambo (Post 814790)
yes, use the search to see how.

Well rambo, if half the people here are like you and give me answers like that to all of my questions then I might as well stop trying to contribute to the community.

And it's not like I haven't searched. I wouldn't have asked if I could find it. I used the keyword "keyboard", "hardware keyboard", but I couldn't find anything useful in the results. I might have overlooked it.

Oh, and I forgot to mention I'm trying to do this in C++ with QtCreator.

MohammadAG 2010-09-13 11:02

Re: Detect hw keyboard slide event
 
Hmm, lockdaemon's source code will help, keyboard slides are GPIO events.

Willem Liu 2010-09-13 11:04

Re: Detect hw keyboard slide event
 
Quote:

Originally Posted by MohammadAG (Post 814800)
Hmm, lockdaemon's source code will help, keyboard slides are GPIO events.

Thank you, MohammadAG. I'll look into that one.

rambo 2010-09-13 11:37

Re: Detect hw keyboard slide event
 
Quote:

Originally Posted by Willem Liu (Post 814793)
Well rambo, if half the people here are like you and give me answers like that to all of my questions then I might as well stop trying to contribute to the community.

And it's not like I haven't searched. I wouldn't have asked if I could find it. I used the keyword "keyboard", "hardware keyboard", but I couldn't find anything useful in the results. I might have overlooked it.

Didn't really mean it to "sound" hostile, merely was in a hurry (and typing on the N900 itself) and didn't remember where the relevant documentation pages are.

Also the framing of the question could be better: like volunteering the "C++ with QtCreator" info from the start, also it would have helped to tell which search terms you used (and did you search the forum, or the API docs or general internet).

Sadly you're in the minority; the forum seems overrun with people who start new threads basically just demanding to be spoon-fed information they should be able to find with a quick search.

And to nitpick: you asked if it was possible, I answered the question.

giannoug 2010-09-13 11:41

Re: Detect hw keyboard slide event
 
Try this

Code:

cat /sys/devices/platform/gpio-switch/slide/state

Willem Liu 2010-09-13 11:44

Re: Detect hw keyboard slide event
 
Quote:

Originally Posted by rambo (Post 814828)
Didn't really mean it to "sound" hostile, merely was in a hurry (and typing on the N900 itself) and didn't remember where the relevant documentation pages are.

Also the framing of the question could be better: like volunteering the "C++ with QtCreator" info from the start, also it would have helped to tell which search terms you used (and did you search the forum, or the API docs or general internet).

Sadly you're in the minority; the forum seems overrun with people who start new threads basically just demanding to be spoon-fed information they should be able to find with a quick search.

And to nitpick: you asked if it was possible, I answered the question.

Well most questions are phrased like: "could someone tell me...", "Does anybody know how to...".
If we were all to answer those literally then there would only be Yes/No answers to all of them.

Anyway I did forget to add some initial and crucial information like what language/sdk I'm programming in/using. For that I'm sorry.
I've searched both uncle Google and the maemo.org forums with the keywords. And after a bit more searching it seems the answer might be more complicated than I initially thought it would be.

Willem Liu 2010-09-13 11:45

Re: Detect hw keyboard slide event
 
Quote:

Originally Posted by giannoug (Post 814834)
Try this

Code:

cat /sys/devices/platform/gpio-switch/slide/state

Thanks!

I'll look into that one.

MohammadAG 2010-09-13 11:53

Re: Detect hw keyboard slide event
 
Quote:

Originally Posted by giannoug (Post 814834)
Try this

Code:

cat /sys/devices/platform/gpio-switch/slide/state

That's not exactly an event though is it, it requires you to poll the file instead of listening to the keyboard slides.

Willem Liu 2010-09-13 11:56

Re: Detect hw keyboard slide event
 
Quote:

Originally Posted by MohammadAG (Post 814845)
That's not exactly an event though is it, it requires you to poll the file instead of listening to the keyboard slides.

MohammadAG, hmm yes that's quite a drawback. I'll have to study lockdaemons source code to see if there is any dbus calls used there which receives the signal from the keyboard.

lma 2010-09-13 11:57

Re: Detect hw keyboard slide event
 
There should also be a dbus signal (/org/freedesktop/Hal/devices/platform_slide on Diablo) so you don't need to poll /sys unnecessarily.

Willem Liu 2010-09-13 12:04

Re: Detect hw keyboard slide event
 
This is for informational purposes. To monitor dbus calls live:

Code:

dbus-monitor --profile --system
Just to have all the related information in one place.

nicolai 2010-09-13 12:09

Re: Detect hw keyboard slide event
 
Quote:

Originally Posted by Willem Liu (Post 814852)
MohammadAG, hmm yes that's quite a drawback. I'll have to study lockdaemons source code to see if there is any dbus calls used there which receives the signal from the keyboard.

You should listen for the dbus event, which only tells you the
state has changed. Than you read the value from
/sys/devices/platform/gpio-switch/slide/state
to see, if the slide is open or closed.

regards
Nicolai

Willem Liu 2010-09-13 12:14

Re: Detect hw keyboard slide event
 
Quote:

Originally Posted by nicolai (Post 814863)
You should listen for the dbus event, which only tells you the
state has changed. Than you read the value from
/sys/devices/platform/gpio-switch/slide/state
to see, if the slide is open or closed.

regards
Nicolai

Thanks! That's good to know. It would've been great if the dbus event would've carried that information with it, but I suppose I can't have it all.

pelago 2010-09-13 12:49

Re: Detect hw keyboard slide event
 
In case you haven't found it already, the initial thread for lockdaemon is http://talk.maemo.org/showthread.php?t=47439

Willem Liu 2010-09-13 12:58

Re: Detect hw keyboard slide event
 
Quote:

Originally Posted by pelago (Post 814880)
In case you haven't found it already, the initial thread for lockdaemon is http://talk.maemo.org/showthread.php?t=47439

Thanks. I did find it, but it's good to have that link here as well.

Willem Liu 2010-09-13 13:55

Re: Detect hw keyboard slide event
 
For informational purposes. Here is a quote from an answer to the same question from the qt-interest mailing list.

Quote:

You can try MCE Dbus Interface. Something like:

QDBusConnection::systemBus().connect(MCE_SERVICE, MCE_SIGNAL_PATH, MCE_SIGNAL_IF, MCE_TKLOCK_MODE_SIG, this, SLOT(onTKLockModeChanged(QString)));

Where onTKLockModeChanged is a simple slot method.

fsguru 2010-09-13 14:12

Re: Detect hw keyboard slide event
 
Quote:

Originally Posted by Willem Liu (Post 814886)
Thanks. I did find it, but it's good to have that link here as well.

You can use the "hal" infrastructure.

ssh into the phone or run in xterm:

lshal -m

You should be able to see the hal events if you now slide the keyboard.

You can use "libhal-dev" if you program in C.

This tuttorial should help you get going:

http://madison-project.wdfiles.com/l...l_Tutorial.pdf

Willem Liu 2010-09-13 14:15

Re: Detect hw keyboard slide event
 
@fsguru

That's great info. Thanks.

Willem Liu 2010-09-13 17:55

Re: Detect hw keyboard slide event
 
The code would look as follows:

Code:

QDBusConnection::systemBus().connect(QString("org.freedesktop.Hal"), QString("/org/freedesktop/Hal/devices/platform_slide"), QString("org.freedesktop.Hal.Device"), QString("PropertyModified"), this, SLOT(slotKeyboardSlide()));
You might also want to retrieve the value from the dbus event:
Code:

    QDBusInterface propertyInterface("org.freedesktop.Hal", QString("/org/freedesktop/Hal/devices/platform_slide"), "org.freedesktop.Hal.Device", QDBusConnection::systemBus());
    bool pressed = propertyInterface.call("GetProperty", "button.state.value").arguments().at(0).toBool();

Bool holds the value.

You'll also need the following line in the .pro file:
Code:

QT += dbus


All times are GMT. The time now is 22:10.

vBulletin® Version 3.8.8