yashsingh1/xdaforums huggingface dataset:
[Xperia Play Android Development] farenheith:
Look in the Turbo kernel thread for the Turbo r13 beta 1. It's the last version that dan put there and with this one, you'll have an option to switch the slot mod to ics-aosp or jb-aosp manually, is my last idea, dude. Did you tried the cm10 zip without the fix?

Well... regardless, with turbo r13 you can try to boot in the ics or jb mode to see what happens.

The last thing you can try is the fxp kernel. After these tests, if you keep in troubles, the better is if you look for help in the kernel threads, as it's going off topic here

Edit: just to be clear, look in the thread using search, not just in the first posts
[Xperia Play Android Development] K4maD3va:
Well, i'm just going to leave it like this. Thank you verry much for your support!

Have a great day!
[Xperia Play Android Development] CosmicDan:
Bard's Tale has no touchpad lag at all in JB. Nice. But the game itself lags a bit in Turbo UI (every second or so it has a small hitch). What are your clock/governor settings olokos?

Sent from Xperia Play (R800a) with Tapatalk
[Xperia Play Android Development] olokos:
Odp: [BETA][ICS][JB]Touchpad support improvement V 1.1

Clocks are 300/1600 intellidemand with sio governor. It lags for not even a second and you really have to pay attention to spot it
[Xperia Play Android Development] CosmicDan:
Hmm I must just have too many apps running, I also lower details and it lags a bit. Anyway, back on topic.

Sent from Xperia Play (R800a) with Tapatalk
[Xperia Play Android Development] olokos:
Odp: [BETA][ICS][JB]Touchpad support improvement V 1.1

I'm always using advanced task killer before starting any game :)

Could you take a look here?

http://xdaforums.com/showthread.php?t=2130890
[Xperia Play Android Development] farenheith:
I really want to know why some apps lag with the touchpad in JB and some others don't... The point here could be very useful :/
[Xperia Play Android Development] olokos:
Odp: [BETA][ICS][JB]Touchpad support improvement V 1.1

Maybe it's the drivers I mean maybe bards tale is another app using its own touch pads drivers like minecraft does :P

---------- Post added at 07:10 AM ---------- Previous post was at 06:32 AM ----------

Lol. I've just tested bards tale with ics aokplay! By supervenom + adreno drivers v3 which is without your patch i think and I was surprised! Touch pads and game pads are fully working! The performance is rough tho :P I had to o/c it to 1600 MHz to make it playable but it might be caused by multibooting ics because system is using the same sd-card as the game so it might be the sd-card which is just reaching its maximum speed (class 10 uhs1/I dunno is it 1 or I xd) so yeah you can add bards tale as working for ics too ^^
[Xperia Play Android Development] CosmicDan:
Yeah exactly, it probably just has better coding and is more native - Bards Tale is a very new game, it looks brilliant and - apart from the hitches I have every few seconds in Turbo UI - runs extremely well. It also has native support for Xbox 360 controllers and some other Bluetooth/USB controllers, so it must use some new low-level library for HID devices.

Don't misunderstand, I still get the horrible touchpad lag in Lara Croft and GTA3 - but in Minecraft and Bard's Tale, there is no lag causes by touchpads.

I like how Bard's Tale switches minimap mode by pressing the area between the two touch "sticks" - very cool :)
[Xperia Play Android Development] farenheith:
I just had a thought...

If the implementations of the touchpad in Minecraft Pocket Edition and Bard's tale is native, how is this implementation? They have a cpp code making pooling directly in the hardware, that is, without use the current event listener? If so and we get access to this code, maybe we can remove the current listener structure and replace it with one based on this code. I mean, something there, in the ROM code, we have the code of how to send the message of the event to the app, right? Maybe it's possible, idk.
[Xperia Play Android Development] CyberScopes:
i think ure getting somewhere...

hopefully u and some other devs can fix touchpads for jellybean!!!

:D

/==(CyberScopes)==\
[Xperia Play Android Development] CosmicDan:
You'd have to move the library into the package APK and rewrite the input code in smali o_O that'd be way too much work.

Sent from Xperia Play (R800a) with Tapatalk
[Xperia Play Android Development] farenheith:
Look this example.

With this code, every motion event (in our case touchscreen and touchpad) is accessed through NDK. That is, the common framework way is not followed even for touchscreen events, every touchscreen or touchpad event falls into the OnNativeMotion method, that you can found in TouchpadNAJava\src\com\sonyericsson\TouchpadNAJava\TouchpadNAActivity.java. I'm not pretty sure, but I think the code to the .so is in the TouchpadNA folder...

But well... looking into the code of the touchpadNA/jni, we can see that, in the method engine_handle_input, the code is returning 1 to every motion event, and 0 to any other... maybe we can make this code return 1 just for touchpad events, then the touchscreen events can start to follow the default framework process. Then, making a code based on it, we can make the framework use the .so, I don't know how yet, that will send the input to a special java method (like the OnNativeMotion). Finally, we can call directly the onGenericMotionEvent, probably on the root view...

Or, Maybe we can insert this code somehow in the jni part of the MotionEventListener (I don't remember exactly the class name) making this intercept the touchpad events, and changing the treatment of this input so far

Edit:

Correction: looks like the code for the lib is TouchpadNAJava\jni\main.c
[Xperia Play Android Development] CosmicDan:
Both JNI and .c files end up compiling into a static object (library). The jni is the "outer" layer code which exposes the native methods and such (so the Java > Smali code can access it), the .c code is where the real work is done.

So basically we would have to write our own jni code, then modify framework java to wrap motion events to new native methods that we write. This is too difficult for me!

On another note, Galaxy On Fire II is another game that has no touchpad lag on JB. Maybe you could mark these games with no touchpad lag as [JB OK] on the list? I never played it before, found out it was free, and I love these space sim games - I'm surprised i never tried it earlier lol. But yeah, the fact that gamepad doesn't work is annoying. I decompiled the game and, like I assumed, most of the game is compiled with native code. However there is a Wrapper java class, which has native methods like this:

.method public static native getGamePadClosed()I
.end method

.method public static native getGamePadFired()I
.end method

.method public static native getGamePadOpened()I
.end method

All of these are inside libgof2.so. But of course we can't see the code. I will try disassembling the .so file and maybe find some references to framwork classes/methods or some special files that it checks or needs, it's as if the game is "half" detecting it as Xperia Play.

It would be curious to know if GOF2 gamepad works on ICS stock based ROM's or the ICS Beta. Because when my Linux machine is back up, I plan to decompile the entire Sony framework and compare it with AOSP framework - and maybe find some missing methods that AOSP doesn't have.

EDIT: To dump an android static object, we use objdump (for ARM targets, not linux) in the Android AOSP tree (for those without e.g. IDA Pro).
[Xperia Play Android Development] farenheith:
Unfortunately Gamepads with GoF2 only works in stock GB :(

I never could find out what is wrong
[Xperia Play Android Development] farenheith:
By the way, cosmicDan, I always use virtual ten studio to edit the jars... Looks like now this app is capable of decompiling even odexed files!

I didn't test it yet... I just saw the changelog. It worth a try as it make simpler some default procedures
[Xperia Play Android Development] CosmicDan:
I just right-click the JAR and select Android > Decompile then after editing, right-click folder and select Android > Recompile, Push and Reboot ;)

I recompiled GOF2 after finding some smali code to enable debugging (Logcat output). The game detects keycodes from the system keys (Back, Menu, etc) but nothing on the gampad. Before taking a look at the disassembled shared object, I think it's a special case of the new KeyLayout and KeyCharacterMap files just being wrong (since they were changed in 3.0 and later).

One example - the keylayout file in all ICS/JB ROM's is wrong, it's a decompiled 2.3 source file. Format changed since Jellybean.

Another example - Android's sample template for a joystick layout:

[FONT=Verdana]# This is an example of a key layout file for a joystick.

# These are the buttons that the joystick supports, represented as keys.
key 304 BUTTON_A
key 305 BUTTON_B
key 307 BUTTON_X
key 308 BUTTON_Y
key 310 BUTTON_L1
key 311 BUTTON_R1
key 314 BUTTON_SELECT
key 315 BUTTON_START
key 316 BUTTON_MODE
key 317 BUTTON_THUMBL
key 318 BUTTON_THUMBR

# Left and right stick.
# The reported value for flat is 128 out of a range from -32767 to 32768, which is absurd.
# This confuses applications that rely on the flat value because the joystick actually
# settles in a flat range of +/- 4096 or so. We override it here.
axis 0x00 X flat 4096
axis 0x01 Y flat 4096
axis 0x03 Z flat 4096
axis 0x04 RZ flat 4096

# Triggers.
axis 0x02 LTRIGGER
axis 0x05 RTRIGGER

# Hat.
axis 0x10 HAT_X
axis 0x11 HAT_Y[/FONT]

Does GOF2 use the D-PAD or Triangle/Square buttons at all? I mean in original GB? Because on our controller, Cross and Circle are mapped as DPAD_CENTER and BACK_ALT, as you already know. But maybe they should be A and B?

EDIT: Here are the controls for GOF2:

[FONT=Verdana]L1: Autopilot
Cross: Fire
Square: Secondary Fire
Circle: Turret View
Triangle: Boost
Start and menu: Pause Menu
Select: Weapon Select[/FONT]

But because I am only early in game (tutorial I guess?) I am not sure if all these keys are enabled yet. Because START should work but doesn't. Hmm.

And also, maybe the axis statements (from sample above) can help with the touchpad in some Games. I am researching this, checking scancodes and referencing the keylayout code.... to see what I come up with.
[Xperia Play Android Development] farenheith:
X and Circle is mapped right, as you can see in this Sony's article. I tried to play with the map files with no luck... maybe you got something as you're more experienced.

If we only could decompile the so files, probably this mistery would be solved
[Xperia Play Android Development] CosmicDan:
This is true, but as I said - things regarding Input changed in Android 3.0. 4.0.x and again in 4.1.x.

Here are my current changes:

keypad-zeus.kcm

type SPECIAL_FUNCTION

key DPAD_CENTER {
base: fallback BUTTON_A
}

key BACK {
base: fallback BUTTON_B
}

key BUTTON_X {
base: none
}

key BUTTON_Y {
base: none
}

key BUTTON_L1 {
base: fallback FOCUS
}

key BUTTON_R1 {
base: fallback CAMERA
}

key BUTTON_SELECT {
base: none
alt: none
}

key BUTTON_START {
base: none
alt: none
}

The "fallback" actions are only done if the app/game does not handle them already. So with this change, if a certain game/app does not recognize the X/O button (e.g. maybe Emu's that are not coded right) they will instead go to BUTTON_A/BUTTON_B. Also, if the L/R triggers are not handled by app, they will focus/shoot camera. I tested this in game and with Camera, and the trigger buttons work great :) Bards' Tale controls are unchanged and GOF2 is still broken buttons though.

I need to test changing the keylayout for X/O to be BUTTON_A/B too, and make the fallback for O to be back alt. But I am not sure if that will break O button in native Xperia Play games, it would def. fix any Emu that goes "back" on O press (because it would recognize as BUTTON_B first). I will test tha another time.

Tomorrow I will setup for so disassembly, and if you like I can send a full dump to you via E-Mail or Mediafire and we can dig in manually. In particular I will disassemble GTA3, Lara Croft and (for gamepad) GOF2.
[Xperia Play Android Development] farenheith:
Tomorrow will be my first day of work (finally) but yeah, I'll appreciate to dig it too in my free time!
[Xperia Play Android Development] CosmicDan:
OK so I disassembled the libgof2.so file and I have no idea lol, I can't read assembly. I had a browse at the input related functions and I couldn't find any mention or reference to java methods. If you still want me to send you the dump in text form (it will be quite large), let me know and I'll upload it.

I think the best way is to find a way to do some deeper debugging. Or maybe we should open a thread on the GOF2 forum, I don't know.
[Xperia Play Android Development] olokos:
Odp: [BETA][ICS][JB]Touchpad support improvement V 1.1

Finally somebody is trying to get this game to work properly :D

I'm crazy for this game. I've passed it 3 times (even more on non touch devices) and every time I wanted to play it again I had to flash GB :(

Hope you will succeed :D
[Xperia Play Android Development] farenheith:
You can send me the files, I'll try to get something from it, dude
[Xperia Play Android Development] CosmicDan:
PM sent.
[Xperia Play Android Development] CriGiu:
@farenheith do you think it's possible to make a cm7 version of it? It would be nice :D
[Xperia Play Android Development] farenheith:
Probably, but it's a completely different work. While the fix is the same job on ICS or JB, in GB we need to study much more and do completely different changes. I don't know how, and never researched about it.

Particularly, I'll not make this one. I don't think it worth a try. We have good enough GB versions stock based, and is just too much work.
[Xperia Play Android Development] olokos:
Odp: [BETA][ICS][JB]Touchpad support improvement V 1.1

I agree. Just try nxt or dixperia 2
[Xperia Play Android Development] CosmicDan:
Faren,

If you can remember, let's go back to the original idea/work of this fix. Since I now have a Gingerbread MIUI build working with touchpads, I had to manually merge MIUI framework into stock GB framework. During this time I noticed some exclusive methods and calls for the Xperia framework - interceptMotionEventBeforeQueing rings a bell, as well as some changes and additions to pointer-device methods. There was only a tiny bit in the View code, most of it was in Input code or the WindowManagerService.

I will give you a diff of the original MIUI framework, and my new framework soon - all these changes that I have found might be a much better method than your current work.

From memory, I never touched the MotionEvent class, and I never saw any native declarations.

Maybe with this information, we can eliminate the lag on Jellybean by porting it forward with the help of Dex2Jar, and even remove the need for touchpad activator app. It seems that the original method of working with touchpad was done on the WindowManager service level, as opposed to the view or input services (which are above the WindowManager).
[Xperia Play Android Development] igor_anta:
I'd just like to ask here as well, seems that the fix is not working on the new CM9.1 builds. I'm not sure when this happened, but I'm running FXP208 and the fix breaks more stuff then it corrects, it causes some texture and framework glitches.
[Xperia Play Android Development] henk717:
Having the same issue on FXP205 it seems to be incompatible with the latest FXP's again.
[Xperia Play Android Development] CosmicDan:
Faren,

Regarding my last reply, there is one native method in stock GB firmware that no other ROM has. It is a simple one so could be possibly re-written, otherwise we would have to contact sony for native sourcecode.

.method public getExternalKeyboardState(III)I
.locals 1
.parameter "deviceId"
.parameter "sourceMask"
.parameter "code"

.prologue
.line 214
invoke-static {p1, p2, p3}, Lcom/android/server/InputManager;->nativeGetExternalKeyboardState(III)I

move-result v0

return v0
.end method

I'm sure we could check what type of value this returns with some test code, and maybe reproduce it. I imagine it returns 1 for open and 0 for closed/no gamepad, in which case we could completely remove the native call and make it always return 1 (or, again use a helper app that allows turning off so Xperia Games will use touchscreen instead).

When I get my linux machine back up I will try to do some work on it.
[Xperia Play Android Development] olokos:
Odp: [BETA][ICS][JB]Touchpad support improvement V 1.1

I've read somewhere here on xda that getting source code for touchpads is not an option because synaptics own the code which has closed source so Sony would have to pay to release this source. It was a dialogue on the Sony official board or by Sony email (I'm not sure which way, but you can try more and more to get it.

Good luck and thanks for all your work.
[Xperia Play Android Development] CosmicDan:
No, that's for the touchpad firmware which is preconpiled in the kernel. Synaptics have no hand in native Android code, that's all Sony. Unless that's part of the agreement which I highly doubt because it has nothing to do with synaptics driver, its a helper function for filtering source device events and is generic.

Besides, its for the gamepad - not the touchpad. Touchpad is a psuedo-mouse device on Gingerbread and is handled elsewhere.

My work on this should solve button issues in e.g. GOF2.

Regardless, I will be able to replicate the native code very easily - its about ten lines of C++, piece of cake.

Sent from Xperia Play (R800a) running Turbo UI Classic with Tapatalk
[Xperia Play Android Development] farenheith:
About the cm9 fix: when i get home I'll try to make the fix. But it's simple for cm9, really is. The last time I saw, the classes ViewRootImpl, View and MotionEvent was not modified. So, w only need to baksmali the framework.jar and replace this classes with the ones from the jar of the fix.

@CosmicDan: nice one, you did analyse the framework GB code, what is great. I think this can be a semi-fix for the touchpad in GB, as the solution still depends of the Sony core i think, ie, probably will not work with cm7 (before someone asks). I can take a look into it with you if you want. About the touchpad activator, the only game that need it so far is max Payne. The idea of the app is force the games that "refuse" to activate the touchpad to do it. Max Payne don't activate the touchpad for itself if the SDK is 13 or above.
[Xperia Play Android Development] farenheith:
Oh, and Dan. About the keyboard method you found, I think of you just make it returns always 1 is good enough.
[Xperia Play Android Development] vokal1992:
whats this lib for?

libtouchpadndk.so
[Xperia Play Android Development] CosmicDan:
Never heard of it. Probably included in games that use the NDK method for touchpad communication.
[Xperia Play Android Development] vokal1992:
found it on the Data partition on the 4.0.2.A.0.79 firmware, I was wondering if it was useful for you guys
[Xperia Play Android Development] CosmicDan:
If it was on the data partition thn that means it came from an app. Not useful.
[Xperia Play Android Development] farenheith:
Some posts ago i said how to mod the new cm9 framework easily. Sorry for not do it, I'm not in conditions right now...

If someone could make it, it would be very helpful
[Xperia Play Android Development] vokal1992:
yeah, extracted the userdata.sin and the lib was there
[Xperia Play Android Development] CosmicDan:
Again, no it won't help in any way. Has nothing to do with touchpad functions itself, it's only an interface for one of the preinstalled games on stock firmware.

The reason why it's only a 90% solution right now is because it's a custom implementation and not standard. The reason why we have touchpad lag in JB is because the framework is not filtering these events.

I am working on both of these things already (only for Jellybean), they are on my todo list.
[Xperia Play Android Development] RB_1980:
I have the slimbin installend on r800x so shoild i change from r800i to r800x where aplicable?
[Xperia Play Android Development] farenheith:
Exactly... I'll make it clear in the post ASAP

Thanks!
[Xperia Play Android Development] RB_1980:
can you suggest any apps that i can use to edit build prop. i downloaded build prop editor after making the changes it reverts back to original entry.
[Xperia Play Android Development] funnies7:
hello guys can someone please make the touchpads work for this firmware:http://xdaforums.com/showthread.php?t=2176936 its a neo l firmware but works very well on our play.

Thanks:fingers-crossed:
[Xperia Play Android Development] chery2k:
Not going to happen.
[Xperia Play Android Development] RB_1980:
is it possible to edit the build prop using my pc?
[Xperia Play Android Development] Lordomn:
yes...but apps like root browser or root explore should work as long as you have root access...

"We are the fire that will consume them, belly and bowel, head and heart, many flames of us, but one fire."
[Xperia Play Android Development] CosmicDan:
adb pull /system/build.prop
(edit the file with a unix line-ending-aware editor)
adb remount
adb push build.prop /system
adb shell chmod 644 /system/build.prop
adb reboot
[Xperia Play Android Development] farenheith:
The neo L core don't access the touchpad, so, to make the touchpad work with it you need a very different fix :/
[Xperia Play Android Development] CosmicDan:
Yep. The port from GB that I'm still working on should work, but that's nowhere near finished.
[Xperia Play Android Development] funnies7:
I see... anyway thanks, I will wait for your fix ;)
[Xperia Play Android Development] RoboticBuddy:
I have the latest FXP Rom with Turbo Kernel installed, but whenever I try to flash the FXP TouchPad Patch, it keeps giving me Status 2. Any suggestions?
[Xperia Play Android Development] farenheith:
Flash via cwm... but sorry, dude. I think the fxp fix is outdated too. If you flash it successfully probably will get bootloops.

I put some instructions some posts ago on how to mod easily the new framework, but I'm too sick right now and I need to rest almost all the time...

If anyone want to try to fix the new framework, I think will be easy
[Xperia Play Android Development] Dany XP:
Just to sum up: what is the last official fxp in wich farenheith fix is still functional?
[Xperia Play Android Development] chery2k:
Go 15 versions back.
[Xperia Play Android Development] Dany XP:
So since we are now in FXP 210, (-15) you mean FXP149? I think You are wrong because at least FXP 152 the Farenheith Fix was working fine, because i personally tested.

Maybe you are confusing kernel and roms?

EDIT: In second thoght, i'm pretty sure that even in FXP 202 fix was still working
[Xperia Play Android Development] RoboticBuddy:
Do you have a link for the FXP152 or 149?
[Xperia Play Android Development] Dany XP:
No but i have FXP202 wich i'm pretty sure fix was still working: https://www.box.com/s/v7c1xf0bldf7fg589pb5

So, no one can tell me when farenheith fix stop working on what FXP?
[Xperia Play Android Development] abdel12345:
Hello if I flash a neo l ROM on my play that is ICS will flashing this make touch pads work?

rom: cm9 official

2nd slot: turbo ui classic

kernel: Turbo v3.1
[Xperia Play Android Development] CosmicDan:
No it will break the ROM.

Sent from Xperia Play (R800a) running MIUI5 with Tapatalk