oNaiPs / droidVncServer

VNC server for Android devices.
GNU General Public License v3.0
899 stars 477 forks source link

[SGS II] Keybinding only work when followed by a left click #42

Open OphyTe opened 11 years ago

OphyTe commented 11 years ago

Hi,

I use this VNC server for a few days now and I found this anoying bug which force me to always make a left click after any key I press (page up for menu for instance) !

hyhjcjy commented 11 years ago

Me too!!

For the HTC Hero, things are all very well. But for the HTC sensation XE, the bug happened. They both open uinput at the path /dev/uinput. But with different reactions. Why?

agronick commented 11 years ago

Are the permissions set to read and write?

On Tue, May 7, 2013 at 2:48 AM, hyhjcjy notifications@github.com wrote:

Me too!!

For the HTC Hero, things are all very well. But for the HTC sensation XE, the bug happened. They both open uinput at the path /dev/uinput. But with different reactions. Why?

— Reply to this email directly or view it on GitHubhttps://github.com/oNaiPs/droid-VNC-server/issues/42#issuecomment-17526070 .

hyhjcjy commented 11 years ago

How to check?

But I don't think it's the problem of permissions, it can send key, but binding with a left click...

alvin777 commented 11 years ago

Reproduces on my HTC Desire C, OS: 4.0.3

alvin777 commented 11 years ago

Calling suinput_write(inputfd, EV_SYN, SYN_REPORT, 0); after ret=suinput_press(inputfd,code); and ret=suinput_release(inputfd,code); fixes the issue for me

hyhjcjy commented 11 years ago

Thanks so much to alvin777 !!! You really fix the problem!!!! :+1:

HTC Sensetion XE, OS:4.0.3

hyhjcjy commented 11 years ago

BTW, do you have the following situation?

For my HTC Sens, the touch screen control: there's a "spot" to be drag to the right place if I want to do click. But for my HTC Hero, it is "touch-and-play".

Why they are different??

(Hope you can understand my question, sorry for poor English.)

alvin777 commented 11 years ago

The build I installed from Google Play was "touch and play", but the one I built myself has that spot. I'm going to investigate that next weekend.

hyhjcjy commented 11 years ago

I see, thank you for your kindly reply :)

alvin777 commented 11 years ago

Ok, this one was tougher. According to http://source.android.com/tech/input/touch-devices.html propbit INPUT_PROP_DIRECT should be set explicitly. This could be done in suinput_open with:

if (ioctl(uinput_fd, UI_SET_PROPBIT, INPUT_PROP_DIRECT) == -1)
    goto err;    

The catch is that neither UI_SET_PROPBIT nor INPUT_PROP_DIRECT defined in Android NDK. It could be copypasted from https://github.com/quarck/csetup/blob/master/csetup/jni/input.h

#define UI_SET_PROPBIT      _IOW(UINPUT_IOCTL_BASE, 110, int)
#define EVIOCGPROP(len)     _IOC(_IOC_READ, 'E', 0x09, len)
#define INPUT_PROP_POINTER      0x00
#define INPUT_PROP_DIRECT       0x01
#define INPUT_PROP_BUTTONPAD    0x02
#define INPUT_PROP_SEMI_MT      0x03
#define INPUT_PROP_MAX          0x1f
#define INPUT_PROP_CNT          (INPUT_PROP_MAX + 1)

This fix works for me.

hyhjcjy commented 11 years ago

Yes! It works for me, too!! Thank you sooooooo much :smile:

hyhjcjy commented 11 years ago

Oops! But the HTC Hero (OS: 2.x) becomes view only.

alvin777 commented 11 years ago

Most likely ioctl line returns error. I think you can safely remove return value check here.

hyhjcjy commented 11 years ago

It seems that Adroid change the input control from 4.x, but the EVIOCGPROP ioctl only support by kernel 3.x. My HTC hero is the kernel of 2.6. So this

if (ioctl(uinput_fd, UI_SET_PROPBIT, INPUT_PROP_DIRECT) == -1) goto err;

would return error.

But if I remove the return value, the Android 4.0 phone becomes view only. @@

ghost commented 11 years ago

Guys try to pull the changes from the forked master https://github.com/rbrune/droid-VNC-server/commit/b7db761f13297f00f060a4d3e714c93e8794594b

That should fix the "touch and play" issue

hyhjcjy commented 11 years ago

Sorry, my fault. I cannot just remove the return line. It should leave a semicolon for the if statement.

if (ioctl(uinput_fd, UI_SET_PROPBIT, INPUT_PROP_DIRECT) == -1) ;

Then the two phones both work! (HTC Sensation XE ,4.0.3 & HTC hero, 2.x) Thanks to alvin777 again! You really help a lot!

alvin777 commented 11 years ago

I'd leave just:

ioctl(uinput_fd, UI_SET_PROPBIT, INPUT_PROP_DIRECT)

You are welcome :)