yashsingh1/xdaforums huggingface dataset:
[XPERIA X1 General] JKingDev:
X1BH beta

X1 Button Hook

Jan 3, 2010

By Jonathan King

GUI/Updater by DOCIOHN​

Special thanks to DOCIOHN who not only created the settings GUI and updater, he is providing the server space to make updating possible.

Description

X1BH is a successor of X1BC and the (kinda) released X1BC2. The program gives you the capability to assign different functions to the panel, ok, soft, and volume keys. Another feature is the capability to disable screen rotate when the keyboard slides. You can assign a button to toggle this feature. X1BC also supported adding fn functions to the keys on the keyboard that had none as well as making 'tab' or 'win' a ctrl key. This feature is not yet added to X1BH but will be in future versions. A new feature not seen in any previous program is a fix for the X1 keyboard repeat problem. While this is a hardware problem, X1BH can prevent key repeats that appear too rapid. Credit for the idea for this feature goes to J-Pro. Unlike the previous programs, X1BH runs as a service therefore not counting toward the 32 process limit. This was something suggested by Dandie.

Download

See the second post for the current version.

Background

You may have noticed that my enthusiasm for the X1BC and X1BC2 projects dropped for a while. The reason for this is that I was frustrated with the methods for trapping the keys. X1BC used SetWindowsHook to set a low level keyboard hook. The problem with this method is that many programs like to use this function as a means for trapping keys and only one program is allowed to have a low level keyboard hook at a time. Having X1BC running in the background all the time prevented some applications from working and just annoyed others. Most importantly, I found that it was not possible to send volume up/down keys. Next came X1BC2. Instead of a hook I used hotkeys. There were some things better but some things worse. The biggest problem was that 3rd party programs liked to use hotkeys too. And when they did, they robbed X1BC2 of its hotkeys. There was no way I know of to detect my hotkeys were taken. The only way to restore would be to restart the program.

Enter X1BH. It started by me thinking what would it take to rewrite the button driver. I disovered keypad.dll. It runs a service responsible for detecting keyboard interrupts and broadcasting the key event using keybd_event(). It seemed that keypad.dll had much responsibility though. I could not feasibly rewrite it. So I had a better idea. Leave keypad.dll to do all the grunt work and just hook the keybd_event() routine. By modifying the import address table at runtime I redirect keybd_event() calls to my own routine that gets to decide what really gets sent out. The result is total and exclusive access to keys before everything else. The possibilities are wide. While I do not modify keypad.dll in any way, I will probably release a CAB installer that includes it just because my hooking routine will only work with a certain version of the dll.
[XPERIA X1 General] JKingDev:
Download Current Version

More details will be added later. To use, install the CAB and soft reset. Use the settings program to change options.

Current issues/work needed:

- Capturing the panel button will not prevent the panel manager from opening. To stop this you must delete the panel manager reg key

- Ctrl key still to be added
[XPERIA X1 General] JKingDev:
Could use this one too.
[XPERIA X1 General] pdamouse:
Sounds great :) - I'd love to have any easy way to do all these things + CTRL is extremely useful imho and being able to decide which key to make CTRL would be awesome :)

Thanks,

Peter
[XPERIA X1 General] palmwangja:
Lovely, JKingDev.

I just hope put ctrl/tab alloc functions on the first priority to-do of X1BH release :)
[XPERIA X1 General] pdamouse:
I agree :) - I was considering installing another app that would add CTRL functionality, but that one was hard coded to the TAB key, but I use that for other functions, such as filling in forms - being able to set the Windows key for CTRL though would be perfect since I already have that duped as my XPanel key. So being able to decide which you want to make Ctrl, either TAB or Windows Key or something else would be great :)

Peter
[XPERIA X1 General] JKingDev:
Ctrl key is next on the todo list. :) It will support tab or win key. Maybe even sym or "au". The original functionality of the key can be preserved though. It can be something like if you hold the key while pressing a letter it is ctrl. If you just press it, it acts normal.
[XPERIA X1 General] J-Pro:
Quite nice work, JKingDev! Thanks for doing that!

P.S.: Thanks for the credit ;)
[XPERIA X1 General] LazyFunker:
Who will get to try this? I'd be glad to do it :)
[XPERIA X1 General] JKingDev:
Sure, just send me a PM with your email address. Though one tester has already indicated that they have not have any problems, so perhaps a public release is very soon.
[XPERIA X1 General] pdamouse:
Sounds great :) - I use the Tab and Win keys daily, the Sym key weekly - and the au key never. So I'd be quite happy making that a permanent CTRL key, even if I lost all the au functionality. I'd be happy if I had to hit a key with the au to make it do it's original function, rather than having to hit a key with the au to make it CTRL :).

If you have even some of these options that would make this program awesome imho :).

Thank you,

Peter
[XPERIA X1 General] JKingDev:
Hmm. How about au key is ctrl. Fn+au is regular au. There are so many possibilities. Should I really make all these options or maybe just the best 3 so that it doesnt become confusing.
[XPERIA X1 General] pdamouse:
That option, Fn+au for au would be perfect imho :) - It's up to you though how many options you put in, maybe you could have an advanced mode and a simple mode - with the 3 basic options in simple and then the option for users to set more advanced functions elsewhere.

My problem with the other software was that it was hard coded and had no other option - no matter what other options you selected in that program, TAB was always CTRL and that just didn't work for me. Having 3 options already puts you ahead of the game - allowing people to customize is great, but if you are making multiple releases I'd say stick with the options you've mentioned for now and add others as they are requested.

To me I can't think of any better combo than au = Fn+au & Ctrl = au :)

Peter
[XPERIA X1 General] onaj:
I am very pleased that the investigation of Keyboard System DLL has brought such results ... Can not wait for the official version, which will be need to compliment any Xperia X1 ;)
[XPERIA X1 General] Angelusz:
Wooooo! I've been waiting so long for this Jking! Finally! PM'ing right away. :)
[XPERIA X1 General] ulysse84:
Hey, I copy keypad.dll to Windows and I lost control of all buttons :(

I've just figured out the reason. I don't have keypad.dll in windows folder. I use Untamed 1.1 Rom (MrRush)
[XPERIA X1 General] JKingDev:
Sorry for the lack of updates in the past few days. PMs are being answered. I am on the Hybrid Electric Vehicle Team at Virginia Tech. We are participating in the EcoCAR Challenge (add us on facebook/follow on twitter!) and this past week I have been in Daytona Florida participating in the Winter Workshop event. It has been hard work and I had to take a break from X1BH but I think we did well.

Some new developments, there will be a UI setting app. Thats one reason I am holding back the release. Another XDA member is writing the program. They have chosen to remain anonymous. It will even have an updater built in. That same user is graciously granting some server space. I am very grateful for their effort and contribution. Version 1 will come soon.
[XPERIA X1 General] kevintamhk:
It is great to hear that you are contributing to the earth! Looking forward to the release of X1BH~
[XPERIA X1 General] govnovic:
great job!!!

great job man!!! greetengs to you and to Dandie! i must say i enjoyed reading posts and threads written one year ago. it is amazing how much passion you guys put in solving these problems. small problems for geeks but big problems for humanity :) can't wait to try cab. once again, big thanks!!!

P.S. If only Tesla was alive today we all wouldn't need petrol cars. :) sorry for offtopic.
[XPERIA X1 General] nosedive:
x1bh

looks very compromsing and a very nice idea to hook keypad.dll directly ..

x1bc is still a great program to customize xperia keys but x1bh looks even better ... i would appreciate, if there was an easy way to create oem like using no hardcoded paths or paths read out from registry ..

i use x1bc and cook it into my roms .. btw, x1bc is great as it does not work only for x1 :)
[XPERIA X1 General] paul c:
reading through the comments, it seems we all use the keyboard keys differently :)

I write quite a lot in Spanish, so use the au key heavily to access the accents, the sym key every once in a while, normally for the $ sign, and the Windows key quite a lot too.

So, would it be possible not to hard-code the "function" keys to certain actions, letting each user choose his own config?

If that does not complicate the application exponentially, from a user perspective it should be OK, since anyone who is going to use the application should be prepared for a bit of deep-down configuration.
[XPERIA X1 General] JKingDev:
I can create an OEM package. But there are not really many requirements on paths. X1BH.dll must be in the windows folder.

I will release X1BC, X1BC2, and X1BH source for them to be adapted easily to other devices. Right now the source is available upon request, but I might post it.

Everything will be configurable. I will make a few options for the ctrl key.

The current holdup is that I am making X1BH work no matter what keypad driver version you have, rather than hard-coding it to work with just one. This would mean it will also work with other devices (though some modification would be needed since right now it is tailored for the X1). The hook itself will be universal. You would just need to change what keys are captured for devices with different key codes. Also, I want to wait for the UI to be complete.
[XPERIA X1 General] JKingDev:
Sorry for so much delay but there were problems getting the hook working on different devices. I think it is finally working though. It will now work regardless of your keypad dll or perhaps even if you have no keypad dll at all. I am just awaiting feedback from testers to make sure.

Some screen shots of the new settings app are in the first post. It will allow you to change settings without needing to restart your device. It also has a check for updates feature allowing you to update the software straight off the server. The app was written by DOCIOHN. He has also graciously provided the server space for updating.

Its almost ready!
[XPERIA X1 General] kevintamhk:
Great, can't wait 1min more!
[XPERIA X1 General] kevintamhk:
I keep checking this thread regular but still no news until now:(

Hope it will not be forgotten
[XPERIA X1 General] JKingDev:
Sorry, not forgotten. I just had a tough week at school. I'll try to get version 1 out this weekend.
[XPERIA X1 General] Angelusz:
Will the panelbutton be fixed in that version? I've e-mailed you about this issue, but I never got a response. :)
[XPERIA X1 General] JKingDev:
Sorry that I forgot to reply to your email. I think it would be a better idea to get this version out without the panel button just to have it sooner. The panel button can be fixed with an update. Updating is easy. Just go the the settings app and check for updates.

For those that do not know, the issue with the panel button is that even if X1BH captures it, the panel manager still opens. The only way to prevent this is to delete the panel manager registry key, which completely disables the panel manager. I will try to fix this so that X1BH suppresses this behavior and will also allow you to assign panel manager to a key.
[XPERIA X1 General] JKingDev:
First version is up. I'll add some more details later but I just wanted to get it out. To those who PM'ed me and requested the beta I apologize if I did not get a chance to respond.
[XPERIA X1 General] fnorling:
Coul I map keys with this software

On my X1 I have problems getting @, !"#*&/() to work Could these keys be mapped using this software?
[XPERIA X1 General] fnorling:
The update function doesn't work on my phone

it fails when updating the dll file in the windows directory
[XPERIA X1 General] DOCIOHN:
The update function doesn't work on my phone

Sorry for my late respond;

There are a lot of possible reasons; can you supply more information to determine the problem?

Do you see on the display something like “applying Windows/X1BH.dll” and then you get the error message "Couldn't replace the old files!" ???

Or do you see on the Display something like "downloading Windows/X1BH.dll” and then you get the error message "update failed,\ntry again later" ???

.....

Further can you post the version numbers of your components (you can find this information in the GUI under “About”)!

And did you start the updater by the GUI or direct?

(PS: Regarding “doesn't work on my phone” The updater should work device independent (.NET Framework)- maybe the problem isn’t the updater???)
[XPERIA X1 General] :
That's exactly what I see when the updater fails on my X1 (well, there is an additional "/" before "Windows" to me most exact ;) )

Also, I cannot get the X1BH to work at all it seems, it's constantly in the "Not Running" state :(

I hope you can help me cause this great app is exactly what I need :-)

My version information: GUI 0.91, Updater 0.1, the same thing happens wether I run the updater from GUI or manually through the exe file.

I have a non-english ROM, by the way -- can this be a problem? (I'm using the official Generic Poland R3AA009 Software Update from SE).
[XPERIA X1 General] pyth27:
I have the same problems mstrz described. The update fails at "downloading /Windows/X1BH.dll" and it always shows "X1BH: Not Running" in the settings. Also, the X1BH service isn't working at all. I use the german stock rom R3A.

Another small bug you could fix: the "X1BH Settings" shortcut is placed in a folder "Programs" in the start menu. So the path is "\Windows\Startmenü\Programme\Programs\X1BH Settings.lnk". I hope you know what I mean :)
[XPERIA X1 General] DOCIOHN:
Regarding the updater problem: I will look into it asap. (I will wait for X1BH.dll before I do useless work- the service must start to tell the actual version number, so updating is useless until the service starts)

The software shows "X1BH: Not Running" because the service doesn’t auto start on some devices (at device startup). (You can start it manually with FdcSoft’s Task Manager; there is also an advanced service managing feature in the GUI- you can activate it by setting the value of “Service

Handler” to “True” in config.ini. But it will only tell you that it couldn’t connect to the service (because the service configuration or rights or something like that isn’t correct))

Let’s see what the future brings..

Edit:

@mstrz & @pyth27

Thanks for the detailed report. (I also think that the non english rom could be the problem (I must reinstall my default german stock rom for warranty in the next days- maybe I take this chance to fix the updater bug))

(The current version numbers are GUI: 0.95; Updater: 0.5; DLL: 2)

Edit 2:

I think I have just found the problem: The easiest way is too share the latest updater.. I will upload it (so i don't need to redefine the updater protocol)
[XPERIA X1 General] DOCIOHN:
Edit: I removed the download link to the updater. Will try to update JKing's cabinet file asap.. (the better way)
[XPERIA X1 General] pjpeter:
Second poster, just wanted to check in, sounds like there've been a few small issues but definitely the GUI looks good :). I'm definitely looking forward to using this software especially the CTRL feature in particular. With the new 6.5.x builds lacking the standard keyboard not only does the Numpad require an extra couple of clicks both ways, but there's sometimes just no way to Paste without it.

Thanks :),

Peter
[XPERIA X1 General] DOCIOHN:
Hey,

Following cabinet file is up to date (should solve some problems): X1BH.cab (GUI: v0.95; Updater: v0.5; DLL: v2)

(Please report if there are any problems (I modified the existing cab file :D))

(Link to the old cab file: X1BH_old.cab (GUI: v0.91; Updater: v0.1; DLL: v2))
[XPERIA X1 General] :
Thanx! I have it up and running and I love the duplicated keys correction -- it really annoyed me :)

Thanx for posting the updated GUI version as well!
[XPERIA X1 General] djglenn1337:
wait a minute......if I install this it can fix the HW KB issue for which it gives like 2/3 times the letter for 1 press?

If so you could just become my new hero.

Edit: Ok, decided to try it out.

Installed fine, however it seems to be in a constant "XBBH: Not Running" state.

Followed DOCIOHN's instructions of using task manager, and was able to manually start it there.

Upon a restart of phone it is defaulted back to Not Running, therefore have to manually start it again.

However, this is exactly what I was looking for.

Finally I dont get text messages looking like this: "Hello are annny of you commming innn?"

Thanks very much to both JKingDev & DOCIOHN for the work. Great Stuff.

Is there any way to get it to start automatically on startup? Not working for me on MrRush's Touch X 10.9
[XPERIA X1 General] DOCIOHN:
Of course; the easiest way is to use “FdcSoft’s Task Manager”. The Task Manager has a command line option called “/startsvc servicename”. (It starts a service given its name)

Just create a shortcut in the startup folder of your PPC which runs the Task Manager with the desired parameters.

Just tried it and it works!

Step by Step:

Changed the registry value “FriendlyName” to X1BH (under HKLM\Services\X1BH)

Created the program shortcut under “\Windows\StratUp” (it’s just a text file with the ending .lnk)

The content is:

26#"\windows\TaskManager.exe" /startsvc X1BH

(“\windows\TaskManager.exe” is the location of “FdcSoft’s Task Manager”.)
[XPERIA X1 General] pyth27:
Thank you very much for this workaround! The service starts automatically now. I hope you find the bug causing this problem, though. :)
[XPERIA X1 General] Phat7:
Excellent piece of software! I'd say a must have for X1 owners :) Thanks a lot guys!

A suggestion: How about including the Send and End keys? I mean the Answer and Reject keys. Any thoughts/plans?

Keep up the great work!
[XPERIA X1 General] Phat7:
Hmm, for me the app stops working after couple presses. The same happens after device restart. The device vibrates when I long press a button, but nothing happens.

Assigned Panel and OK keys. Panel long press rotates the screen, short press shows today. OK long press runs the Torch app, short is default to closing windows.

Any ideas?
[XPERIA X1 General] Jive Turkey:
I have the same problem that the service doesn't automatically start up. The FdcSoft Task Manager shortcut worked though :)

I wonder how is the service set to start? I have AEBPlus installed, maybe that's causing a conflict? I don't have time to troubleshoot it right now, but I thought it would be worth raising the question.
[XPERIA X1 General] Phat7:
Figured out OK long press seems to be the problem, or the Torch app that is assigned to it. Removed the OK button and everything seems to work fine. Interesting :confused:
[XPERIA X1 General] jery2000:
Hi KingJ, it can't download now

anyone can please email to me?

chen_8888@yahoo.com

thanks in advance
[XPERIA X1 General] Jung Hae Woon:
Alt Key and Volume Down Key Conflict

Alt button is assigned to Korean/English toggle button in korean version xperia x1.

When Alt key is pressed after 'Capture OK' or 'Capure Volume Up' is assigned in X1BH_Gui, volume down works.

Thanks to both JKingDev & DOCIOHN in advance.
[XPERIA X1 General] apinkel:
Earlier in the thread you mentioned that this cab could be used on more devices than just the X1, is that the case? I've got a Sprint Touch Diamond that I would love to have a reliable key mapper for the few hard keys it has (it does not have a qwerty keyboard... just send/end, vol up/down, power, home/back, and Dpad). Will your cab work on it?

If not would it be possible to get a copy of the source code to see if I could develop a driver for the diamond?

Also, the download links don't appear to be working. Could someone upload the cab?
[XPERIA X1 General] nelsonlye:
Hi the download link is not working...anyone hv the cab file able to email me? nelsonlye@gmail.com Thanks..
[XPERIA X1 General] cichy3000:
I tried to dl the Cab :/ but it doesnt work :/ ... could You reupload Beta ?
[XPERIA X1 General] DOCIOHN:
Alternative download

@cichy3000, @nelsonlye

Hi,

Sorry for that, but my hoster is down because of a DDoS- Attack:mad:.

You can download it here: X1BH.cab (link will work until my site is up again- hope soon/ fu**ing criminals)
[XPERIA X1 General] cichy3000:
thank You for providing link ! I'm happy to test the X1BH,

DDos ? wow... and is Your server still blocked ?
[XPERIA X1 General] nelsonlye:
Thanks lots....at last.....my KEYPAD work perfectly........
[XPERIA X1 General] palmwangja:
:)still no love for CTRL button?
[XPERIA X1 General] socrowd:
Real nice works! thanks
[XPERIA X1 General] VampiruX:
Not good for me...

Hi All,

Doesn't work for me: Error in X1BH_GUI.exe as soon as I start X1BH Setting.

Does someone know that ?

BR.
[XPERIA X1 General] jkkl:
weird issue

hi,

first of all thanks for this awesome app, its just what i needed (and even more when you get ctrl stuff working)

I get a weird thing on my xperia x1 in that the dll loads fine and starts working but after a while it stops doing the assigned things. i know its still in memory because the gui reports it as running and it still vibrates on holding the assigned buttons. it just doesnt execute the apps or send commands or anything else. the problem seems to be related to the ok button but i'm not sure.

the only way to get it to work is to restart the handset

system: xperia x1, raa3 uk generic rom

cheers,

update: on further research i found that assigning either left or right hardware keys makes the other also respond to the event but because its not assigned it doesn't do anything. after that the the previously described behaviour occurs again. the ok button dosn't seem to like long presses either: on long press it will execute the action but only once. after that it gets stucked (see original description)
[XPERIA X1 General] Lukebad:
I installed it, hoping it would solve my "aaaa" problem, but I can't get it to say "running" on status. It just says "not running"... How do I solve this? I installed the .cab and saved my preferences!
[XPERIA X1 General] ysherad:
hhhhhhhhhhhhhhhhhhhhhhhhhhhhh
[XPERIA X1 General] 3x4d:
how to start !?!

I have same problem !?!
[XPERIA X1 General] Lukebad:
I discovered how to start it! I read the entire thread, and there was a post that said to start the SERVICE with FdcSoft’s Task Manager, manually. This is due to X1BH not starting automatically on some devices.

It worked for me :)
[XPERIA X1 General] 3x4d:
Autostart x1bh

Thank you and you are right.

Now we should make AUTOSTART. Here is written => http://xdaforums.com/showpost.php?p=5814315&postcount=41
[XPERIA X1 General] chaoscreater:
download link dead..
[XPERIA X1 General] 3x4d:
You are right, but see this post #52

http://xdaforums.com/showpost.php?p=6261282&postcount=52
[XPERIA X1 General] MrLeche:
Hey all.

Got to read post #52 and downloaded it. Already cabling my ex-X1 to my wife PC to give it a try.

I replied coz I'm in web D business and I can provide a stable hosting for this. I'll give you devs an FTP account for it. Email me, pm me. I'm just a very busy man trying to earn money on this third world home of mine.

I'm serious. I pay host on American soil for all my clients. I can spare a hosting for X1BH to have it up until (free until I'm alive) XD.

I read the screenshot at first post. I don't actually understand the differences to the keyboard delays on what it actually does (except that I know what the meaning of the values underlined on the right).