yashsingh1/xdaforums huggingface dataset:
[Xperia Play Android Development] Lordomn:
Hybrid ROM has its own fix...

http://xdaforums.com/showthread.php?p=31311433

Check this post.

R800x-unlocked/AOKP m6
[Xperia Play Android Development] farenheith:
I tried to flash this ROM to make a fix to it, regardless of what I said a few posts ago... but I got strange problems with the phone and give up.

This Secko ROM is not a "pure" AOKP port. The AOKP-ICS fix is for the AOKP ICS Rom ported by supervenom. The fix here need to be implemented on the Secko framework following the steps of post #2.

Edit: News about some tests I did on the Star Batalion. The touchpád is recognized. But is treated very wrong...

When I touched and hold the right touchpad and then touched the left touchpad, the game responds to it... it's like something changed on the touchpad events from GB to ICS. I'll make a test app that will produce a log with the touchpad events info, then I'll execute it on GB and on ICS to see if I found some difference...
[Xperia Play Android Development] farenheith:
Guys!

I did a new version of the touchpadactivator!

This version 1.2 have the option to activate the touchpad just to the app itself (like other apps do), to test this behavior. After you use this option, you don't have option to turn it off. You need to close the app with the back button and open again. Also, now when the app track the touchpad events, it write those events to the Logcat.

My intention with this is to make this app "work" on GB. Obviously the always activator behavior will do nothing, as the GB need to get the framework modded too to get this option, and there's no point on it. BUT, if you activate the touchpad to the app, then we'll get a logcat of the events of it, and I need it to do some analysis.

So... if anyone is using an stock GB ROM or stock GB ROM based, please, can install the new version, make some interaction with the touchpad and send me the logcat? If someone can, will save me some time.

To make the tests:

Install this version of the app

Do very quick interations with the touchpad because this device generate a flood of events and if you touch too long it the logcat will be giant.

I need to test three scenarios:

Just one finger

Two fingers, but the first finger touching the left side of the touchpad and the second the right one.

Two fingers, but the first finger touching the right side of the touchpad and the second the left one.

I'll do the tests on the CM9, and when I can I'll flash the stock GB and do this tests on it too, if no one can in the moment do this tests to me.
[Xperia Play Android Development] f3w1n:
http://www.mediafire.com/view/?opchxdrv17gal5u

Is that?

I dont see anything interesting there o_0

- f3w1n -
[Xperia Play Android Development] farenheith:
wow! Very quicly :)

You did the tests on GB?

Well, yes, almost it... but the logcat is incomplete... it not get the events since the beginning. Try to test just with one finger touching the left side of the touchpad, do a little swype, very quickly, and get the logcat of this.

Probably the logcat you got is incomplete for the amount of events generated....
[Xperia Play Android Development] f3w1n:
Yeah gb, give me a second

http://www.mediafire.com/file/4oye5io48g8vucy/alogcat.2012-10-24-21-33-23+0100.txt

- f3w1n -
[Xperia Play Android Development] farenheith:
Fine, please!

It's important to see the events from the beginning, but I already found something interesting... I just need to see the events from the beginning to make sure...

Some lines of your logcat, on GB:

I/TOUCHPADACTIVATOR( 4817): *******************BEGIN******************
I/TOUCHPADACTIVATOR( 4817): Action: 261
[B][COLOR="red"]I/TOUCHPADACTIVATOR( 4817): Device id: 65539[/COLOR][/B]
I/TOUCHPADACTIVATOR( 4817): Masked action: 5
I/TOUCHPADACTIVATOR( 4817): Action index: 1
I/TOUCHPADACTIVATOR( 4817): Action index: 0
I/TOUCHPADACTIVATOR( 4817): Pointer count: 2
I/TOUCHPADACTIVATOR( 4817): *********POINTERS*****************
[COLOR="red"][B]I/TOUCHPADACTIVATOR( 4817): Pointer id: 1[/B][/COLOR]
I/TOUCHPADACTIVATOR( 4817): Pointer X: 956.0
I/TOUCHPADACTIVATOR( 4817): Pointer Y: 162.0
[COLOR="red"][B]I/TOUCHPADACTIVATOR( 4817): Pointer id: 2[/B][/COLOR]
I/TOUCHPADACTIVATOR( 4817): Pointer X: 631.0
I/TOUCHPADACTIVATOR( 4817): Pointer Y: 149.0
I/TOUCHPADACTIVATOR( 4817): *********END POINTERS*****************
I/TOUCHPADACTIVATOR( 4817): *******************END******************

Some lines of my logcat, on CM9:

I/TOUCHPADACTIVATOR(3(31568): : *******************BEGIN******************
I/TOUCHPADACTIVATOR(3(31568): : Action: 261
[B][COLOR="red"]I/TOUCHPADACTIVATOR(3(31568): : Device id: 8[/COLOR][/B]
I/TOUCHPADACTIVATOR(3(31568): : Masked action: 5
I/TOUCHPADACTIVATOR(3(31568): : Action index: 1
I/TOUCHPADACTIVATOR(3(31568): : Action index: 0
I/TOUCHPADACTIVATOR(3(31568): : Pointer count: 2
I/TOUCHPADACTIVATOR(3(31568): : *********POINTERS*****************
[B][COLOR="red"]I/TOUCHPADACTIVATOR(3(31568): : Pointer id: 0[/COLOR][/B]
I/TOUCHPADACTIVATOR(3(31568): : Pointer X: 211.0
I/TOUCHPADACTIVATOR(3(31568): : Pointer Y: 185.0
[B][COLOR="red"]I/TOUCHPADACTIVATOR(3(31568): : Pointer id: 1[/COLOR][/B]
I/TOUCHPADACTIVATOR(3(31568): : Pointer X: 802.0
I/TOUCHPADACTIVATOR(3(31568): : Pointer Y: 334.0
I/TOUCHPADACTIVATOR(3(31568): : *********END POINTERS*****************
I/TOUCHPADACTIVATOR(3(31568): : *******************END******************

The lines in red show very important difference, that can create mistakes from the android devs when implementing the touchpads:

First: the device id... This ID maybe is constant on the GB (65539), but there's no guarantee of it according to the android official help. On CM9, on my tests it's always 8, but it's not a trustworthy reference. If the devs look to this to know if the device is a touchpad, then the touchpad will not work on CM9 and potentially on any ICS/JB ROM.

Now, the pointer ID...

On the CM9, the first finger is always ID 0. Apparently, on GB, the first finger is ID 1... This can be a problem, again, if the devs do some validation on this field like, consider the point invalid if the ID is 0. This can explain my tests on Star Batalion (the game was answering to the touchpad commands, with bugs, only if I first touch the right side of the touchpad and hold, then the left one). I was suspecting of that, now I'm sure...
[Xperia Play Android Development] cj360:
Are you thinking that they changed the device identifiers between gb and ics?
[Xperia Play Android Development] farenheith:
I don't know... I'm using CM9 right now... We need to know, for example, what is the device identifier on the Markphyton ROM, that is sony Based. BUT, this device identifier is kind of a irrelevant information. In theory, this is only an index to a list of devices of the phone. If, for any reason, the loading order of this devices change, then the device id is changed too. Then, you can't use this info to identify the touchpad.

The problem is: in AOSP GB, there's no a real support to touchpad devices on the framework, then, the Sony did what they need to do to make it work, and maybe the Sony GB id is so higher because they put it constant and don't want any conflict with other devices on the phone.

But I analysed the Smalis of the game 'Star batalion, and I can confirm: the problem is the pointer ids!... F*ck...

The ontouchevent is implemented on java, but it's calling an C++ native function implemented on the game .so. The problem is, the device id is been passed to the library like this: pointerID - 1. Probably because, on GB, it's start on 1, but the DLL is waiting a ID starting on 0.

Then, the problem: on CM9, the id start in 0. Then, this "pointerID - 1" just make the first pointer id be "-1", and the dll do some unexpected behavior. I modded the apk making this part of the code just pass the original pointerID and, with this change, the touchpad start to work.

There's a little bug yet. When i'm controlling the ship with the left touchpad and touch the right one, the ship start to go to right... I don't know why it's happening and don't know if it's happening on GB.... but now I know the next step on the touchpad fixes: we need to make the touchpads events be exactly like it is on GB.

Well... maybe the device id we can't change, otherwise this can cause bugs on the framework, but the pointer ID I think we need... well... time to more researchs...
[Xperia Play Android Development] farenheith:
Ooooookkkaaaaaayyyyy....

I did a change on the framework that, in our country we call of... "gambiarra"... a near translation to it is workaround, but I think this word isn't shameful as gambiarra is... so...

Well.... we have a big chance of this change break some games, but the touchpad is working now with the Star Batalion.

I want someone to test if the touchpad will work now with the OnLive app. I can't test it because the service is unavailable where I live...

Also, preview games must be tested with this changes too, to know if it'll still work.

If I get a good feedback about this change, I'll update the version.

You can get the new framework here. It's for CM9. To test it, you'll have to replace manually the file on the folder /system/framework

The new changes is on the MotionEvent class, on the android/view.

If anyone want to implement it on another frameworks, here is the changes:

.method public final getPointerId(I)I
.locals 2
.parameter "pointerIndex"

.prologue
.line 1927
iget v0, p0, Landroid/view/MotionEvent;->mNativePtr:I

invoke-static {v0, p1}, Landroid/view/MotionEvent;->nativeGetPointerId(II)I

move-result v0

[B][COLOR="Red"] sget v1, Landroid/view/InputDevice;->SOURCE_TOUCHPAD:I

invoke-virtual {p0}, Landroid/view/MotionEvent;->getSource()I

move-result v2

if-ne v1, v2, :cond_1

const/4 v1, 0x1

add-int/2addr v0, v1

:cond_1[/COLOR][/B]
return v0
.end method

.method public final getX(I)F
.locals 4
.parameter "pointerIndex"

.prologue
.line 1974
[B][COLOR="red"]const/4 v1, 0x0
add-int v3, p1, v1

if-eqz v3, :cond_1

sget v1, Landroid/view/InputDevice;->SOURCE_TOUCHPAD:I

invoke-virtual {p0}, Landroid/view/MotionEvent;->getSource()I

move-result v2

if-ne v1, v2, :cond_1

const/4 v1, 0x1

sub-int v3, v3, v1

:cond_1[/COLOR][/B]
iget v0, p0, Landroid/view/MotionEvent;->mNativePtr:I

const/4 v1, 0x0

const/high16 v2, -0x8000

invoke-static {v0, v1, [B][COLOR="red"]v3[/COLOR][/B], v2}, Landroid/view/MotionEvent;->nativeGetAxisValue(IIII)F

move-result v0

return v0
.end method

.method public final getY(I)F
.locals 4
.parameter "pointerIndex"

.prologue
.line 1989
[COLOR="red"][B] const/4 v1, 0x0
add-int v3, p1, v1

if-eqz v3, :cond_1

sget v1, Landroid/view/InputDevice;->SOURCE_TOUCHPAD:I

invoke-virtual {p0}, Landroid/view/MotionEvent;->getSource()I

move-result v2

if-ne v1, v2, :cond_1

const/4 v1, 0x1
sub-int v3, v3, v1

:cond_1
[/B][/COLOR] iget v0, p0, Landroid/view/MotionEvent;->mNativePtr:I

const/4 v1, 0x1

const/high16 v2, -0x8000

invoke-static {v0, v1, [B][COLOR="red"]v3[/COLOR][/B], v2}, Landroid/view/MotionEvent;->nativeGetAxisValue(IIII)F

move-result v0

return v0
.end method

PS: If you implement this change (for now it's just for test purposes), don't forget the line of the nativeGetAxisValue, at the final of getX and getY method, where you need to change p1 to v3

EDIT: It's done.... The touchpad is broke on Lara croft xD.... But I still want to know if it'll work on the Onlive
[Xperia Play Android Development] jimmyvau:
The touchpads work with Onlive, however none of the other controller buttons do.
[Xperia Play Android Development] farenheith:
Sorry,

But the touchpads is working with the framework from my last post or with the last fix? Also, send me your build.prop so I can take a look.
[Xperia Play Android Development] jimmyvau:
I'm using the framework from your previous post. My build.prop has the edits from the front page but I used R800x instead of R800i. I'll upload it later when I'm back at my PC
[Xperia Play Android Development] farenheith:
Thanks...

I also did a better change to the MotionEvent. The touchpad worked with Lara Croft, Star Batalion, Dead Space and Brothers in Arms 2 (news! But a little buggy... I'll give more detail later), but not with Rise of Glory :/... I'll keep investigating, but if anyone want to try

Here is the new modified framework for CM9

Here is the new code changes

.method public final getPointerId(I)I
.locals 2
.parameter "pointerIndex"

.prologue
.line 1927
iget v0, p0, Landroid/view/MotionEvent;->mNativePtr:I

invoke-static {v0, p1}, Landroid/view/MotionEvent;->nativeGetPointerId(II)I

move-result v0

[B][COLOR="Red"] sget v1, Landroid/view/InputDevice;->SOURCE_TOUCHPAD:I

invoke-virtual {p0}, Landroid/view/MotionEvent;->getSource()I

move-result v2

if-ne v1, v2, :cond_1

const/4 v1, 0x1

add-int/2addr v0, v1

:cond_1[/COLOR][/B]
return v0
.end method

.method public final getX(I)F
.locals 4
.parameter "pointerIndex"

.prologue
.line 1974
[B][COLOR="red"]const/4 v1, 0x0
add-int v3, p1, v1

sget v1, Landroid/view/InputDevice;->SOURCE_TOUCHPAD:I

invoke-virtual {p0}, Landroid/view/MotionEvent;->getSource()I

move-result v2

if-ne v1, v2, :cond_1

invoke-virtual {p0}, Landroid/view/MotionEvent;->getPointerCount()I

move-result v2

if-lt v3, v2, :cond_1

const/4 v3, 0x0

:cond_1[/COLOR][/B]
iget v0, p0, Landroid/view/MotionEvent;->mNativePtr:I

const/4 v1, 0x0

const/high16 v2, -0x8000

invoke-static {v0, v1, [B][COLOR="red"]v3[/COLOR][/B], v2}, Landroid/view/MotionEvent;->nativeGetAxisValue(IIII)F

move-result v0

return v0
.end method

.method public final getY(I)F
.locals 4
.parameter "pointerIndex"

.prologue
.line 1989
[COLOR="red"][B] const/4 v1, 0x0
add-int v3, p1, v1

sget v1, Landroid/view/InputDevice;->SOURCE_TOUCHPAD:I

invoke-virtual {p0}, Landroid/view/MotionEvent;->getSource()I

move-result v2

if-ne v1, v2, :cond_1

invoke-virtual {p0}, Landroid/view/MotionEvent;->getPointerCount()I

move-result v2

if-lt v3, v2, :cond_1

const/4 v3, 0x0

:cond_1
[/B][/COLOR] iget v0, p0, Landroid/view/MotionEvent;->mNativePtr:I

const/4 v1, 0x1

const/high16 v2, -0x8000

invoke-static {v0, v1, [B][COLOR="red"]v3[/COLOR][/B], v2}, Landroid/view/MotionEvent;->nativeGetAxisValue(IIII)F

move-result v0

return v0
.end method
[Xperia Play Android Development] CosmicDan:
Heya faren,

doing that test on my latest MIUI ROM (not yet released) gives these results:

I/TOUCHPADACTIVATOR( 1684): *******************BEGIN******************
I/TOUCHPADACTIVATOR( 1684): Action: 6
I/TOUCHPADACTIVATOR( 1684): Device id: 8
I/TOUCHPADACTIVATOR( 1684): Masked action: 6
I/TOUCHPADACTIVATOR( 1684): Action index: 0
I/TOUCHPADACTIVATOR( 1684): Action index: 0
I/TOUCHPADACTIVATOR( 1684): Pointer count: 2
I/TOUCHPADACTIVATOR( 1684): *********POINTERS*****************
I/TOUCHPADACTIVATOR( 1684): Pointer id: 0
I/TOUCHPADACTIVATOR( 1684): Pointer X: 0.0
I/TOUCHPADACTIVATOR( 1684): Pointer Y: 160.0
I/TOUCHPADACTIVATOR( 1684): Pointer id: 1
I/TOUCHPADACTIVATOR( 1684): Pointer X: 923.0
I/TOUCHPADACTIVATOR( 1684): Pointer Y: 149.0
I/TOUCHPADACTIVATOR( 1684): *********END POINTERS*****************
I/TOUCHPADACTIVATOR( 1684): *******************END******************
I/TOUCHPADACTIVATOR( 1684): *******************BEGIN******************
I/TOUCHPADACTIVATOR( 1684): Action: 2
I/TOUCHPADACTIVATOR( 1684): Device id: 8
I/TOUCHPADACTIVATOR( 1684): Masked action: 2
I/TOUCHPADACTIVATOR( 1684): Action index: 0
I/TOUCHPADACTIVATOR( 1684): Action index: 0
I/TOUCHPADACTIVATOR( 1684): Pointer count: 1
I/TOUCHPADACTIVATOR( 1684): *********POINTERS*****************
I/TOUCHPADACTIVATOR( 1684): Pointer id: 1
I/TOUCHPADACTIVATOR( 1684): Pointer X: 915.0
I/TOUCHPADACTIVATOR( 1684): Pointer Y: 124.0
I/TOUCHPADACTIVATOR( 1684): *********END POINTERS*****************
I/TOUCHPADACTIVATOR( 1684): *******************END******************

Pointer ID is still 0,1 but Device id seems right..... some users have reported that some games have axis inverted, I guess this is the pointer id issue?
[Xperia Play Android Development] mehdi.moha:
oh my god

nice to see to god of developing here !

Mr.Farenheith

i've put my comment on " miui Australia " treat , i also sent mail to GemRB developer ...

the problem is : touchpad left and right works like charm on mentioned miui , but up and down work inverse ! when i touch up , the courser goes down ! when i touch down , the courser goes up !

please let us know what it your opinion ?

thanks in advance :) special thanks to Dan ;)
[Xperia Play Android Development] farenheith:
Unfortunately, I don't think it's for the pointer ID. The pointer ID is more like to identify the order of the fingers, to know which is the first finger that touched the touchpad.

But I know what you're talking about. The touchpad looks inverted on pewpew (the only game I found with this issue), but this specific title implement the touchpads via C++, so... I'm unable to investigate the reason because I can't decompile it.

Tell us what games you're experiencing that issue.

@CosmicDan, this pointer ID issue I tried to fix changing the method MotionEvent.getPointerID, making it return the value + 1 when the device is a touchpad, The game Star Batalion is implementing the touchpads wrong... the devs are getting the getX and getY passing the pointerID, but they must pass the pointerIndex (always from 0 to PointerCount - 1), so, I changed the getX and getY to change the passed ID to 0 always when the this value is out of bound and this solved the touchpad on this game. Probably the Sony Framework on GB is doing this too... I need to check later because I lost my deodexed one :P.

Well, I tested some games (Lara Croft and Dead Space, actually) that was previously working and they don't looks to have problem with this. But, in Rise of Glory the touchpads broken :/. It's so strange as the touchpads of this game is working on GB...
[Xperia Play Android Development] CosmicDan:
So is this pointerIndex change possible to fix the GemRB or whatever it is too? Maybe you will need to add a new option, "Legacy Mode (Enable if axis are wrong)" and user can manually toggle it.

I think there was another game I tested that had touchpad all messed up, like up was right and right was down or something but I can't remember what it was.
[Xperia Play Android Development] farenheith:
No... the pointerID will not solve inverted axis... Will solve the recognition on some games... Also, is different... I put that option because Max Payne checks the android SDK to activate the touchpad, but this one... well, the Sony Framework is working with the pointerID starting from 1 and rise of glory works well on GB, so, there's must to be a way to treat well, I just didn't found yet.

Also... we have two things: the pointerID and the pointerIndex.

The pointerID is a unique identifier of the finger touching the touchpad.

The pointerIndex is the index of the pointer inside the pointer's array, because every MotionEvent have a pointer array. In C, C++ and Java, the indexes of an array always start from 0.

What I found on Star Batalion, and this is an error, is that they are calling the methods getX and getY passing the pointerID as the parameter. But this is wrong. They must pass the pointerIndex, but I think Sony did some treatment on they framework to avoid this problem
[Xperia Play Android Development] CosmicDan:
Ah, I see. Damn that's a shame.

I still think the solution for axis, and maybe more, is in the idc (Input device configuration) files. GB didn't use these, they are new to ICS (honeycomb actually). I think the one from Sony beta is incomplete. Take a look:

# touchpad

touch.deviceType = touchPad
touch.orientationAware = 1

That's the stock one from ICS beta (usr\idc\synaptics_touchpad.idc). This article on Android developers explains the many possible values that can be in here. I think on GB, this was all handled with libhardware_legacy.so but on ICS this is no longer possible.

Here is an example of what I think it might look like - this is not right of course, it needs more research:

###
# touchpad
#
touch.deviceType = touchPad
touch.orientationAware = 1

###
# The following expressions denote the raw values reported by the touch device driver as EV_ABS events.
#
raw.x = 0
raw.y = 1
raw.tiltX = 2
raw.tiltY = 3
raw.orientation = 1

###
# Specifies the kind of measurement used by the touch driver to report the touch size and tool size.
# If the value is default, the system uses the geometric calibration if the raw.touchMajor or
# raw.toolMajor axis is available, otherwise it uses the none calibration.
#
touch.size.calibration = geometric

This section describes specifically what the touch input driver must provide. I do not know if this is in the kernel or not, but I hope so. Because when I have time I may compare the ICS kernel to GB kernel. If this is the case, I have a feeling that the ICS (and JB) kernels do not have a properly updated synaptics driver.

EDIT: By the way, it's clear to us kernel/ROM dev's that Sony has completely abandoned the Xperia Play. The Xperia Neo L is 100% identical to the Play, just without a touchpad. My new kernel based on Sony 4.1.A.0.562 sources uses a modified phoenix config (phoenix = Neo L) which, as I said, identical to the play - because official kernel source did not even have a zeus config.

New MIUI ROM is 99.9% based on 4.1.A.0.562 Firmware for Neo L, I only had to add some new files from ICS Beta (mostly in bin) to get touchpad to detect.
[Xperia Play Android Development] farenheith:
Hey Dan,

I think I got it. The right thing is change the drivers or stuff to make the pointerID start in 1 for real. As I can't compile CM9 from source on Windows (I'll install Ubuntu on my notebook as soon as I can), and also I don't have any idea where I need to change on this giant source xD... well... I changed the framework to "pretend" that the pointerId start on 1. I just needed to change on a few more places to everything works ok

Now the touchpad is working on Star Batalion and Brothers in arms 2, without breaking the touchpads on Rise of Glory :)

I'll finish to update the OP with the news
[Xperia Play Android Development] CosmicDan:
That is great to hear :) So does this fix detection on every game you know of? The only thing left is to fix axies being inverted, but I'm still not sure about that.
[Xperia Play Android Development] farenheith:
OP Updated!

Version V 1.1. of the fix with a new option to get the touchpad closer of the GB behavior! For more details, look for the new questions on the FAQ about PointerID.

Make sure that you'll install the touchpadactivater V 1.3 so you can change the pointerID behavior!

This version is very important because two games I couldn't make work until now is working with the new option: Star Batalion and Brothers in arms 2!

So, I need reports, tests and feedback about the other games to know if they're still working!

Also, if you tried some other game and the touchpad isn't recognized or you get some FC when you touch the touchpad, try it again with the pointerID starting at 1, to see if it will solve the problem!

And, be kind and try your current working titles with this option too, so we can confirm that it will not broke the touchpad on any game!

Thanks f3w1n for the tests on GB so I could see the different behavior of the pointerID! And for CosmicDan for confirm that the pointerID starts at 0 is happening on Sony based ROMs too
[Xperia Play Android Development] game_guy:
I haven't had a chance to thank you for your work farenheith. Mostly because I haven't used your work until recently (running Cosmic's MIUI). Been on stock GB for the past few months now. I'll be sure to test out some games and get back to you.
[Xperia Play Android Development] mehdi.moha:
i've tried on " Baldur's Gate series and Icewind Dale series, Planescape:Torment "

those are really big games !

thank you
[Xperia Play Android Development] farenheith:
For the post you quoted, I wonder what framework.jar did you used to test those games: the one I shared on a post a few previously of that one, or with the new one, released with the version v 1.1 of the fix. And you tried this games and their worked? If yes, did you need to use pointerID starting at 1 or you just used starting at 0?
[Xperia Play Android Development] mehdi.moha:
i'm using Dan's " miui Australia " , a touch pad activator is already installed on that