Remap all T902 tablet/bezel buttons (and for other T90x, T73x etc maybe too)

Discussion in 'Fujitsu' started by stormi, Mar 25, 2014.

Thread Status:
Not open for further replies.
  1. stormi

    stormi Scribbler - Standard Member

    Messages:
    518
    Likes Received:
    318
    Trophy Points:
    76
    So I finally found a solution to remap the volume-buttons on my T902 without affecting other volume buttons/keys with multiple actions.
    Now I can remap the A, B, Rotation, Vol-Up & Vol-Down buttons to anything I want, including single, double and long press actions!
    Two more actions are possible using Windows-button + Vol-Up or Vol Down combination giving a total of 17 different actions (+ the windows-button) :)
    You can even let them behave different, depending on the program you are using.

    The tool that makes all this possible is AutoHotkey.
    You should check the website for documentation, faq's etc or simply the web-search of your liking. But I also want to help people here to get their tablet-buttons to do the things they want :)

    After installing AutoHotkey create a new script (right-click -> new AutoHotkey script), edit it and copy the example/s below into the script. You can copy everything into a single script if you want, except for the A & B buttons need it's own script (for a reason I don't understand).
    Then you need to replace all the 'Msgbox xyz' with the actions, key combinations, whatever to your preferences.
    For example 'Msgbox single-press ; single-press' --> 'Send {Volume_Mute} ; single-press'. You can find a quick-start guide about AHK here. At the bottom I'll also list some useful functions.

    If the remaps are not working for you double-click the tray icon of the script, then go to View --> Key history... and press the button you want to remap. Then refresh the window (View --> Refresh or F5) and check the keys it is sending.


    Below are the examples that are working on the T902 @Win8.1:

    • For the Vol-Up/Down buttons:
    Code:
    $Volume_Down::
    state := GetKeyState("Volume_Down", "P")
    if state=0
    	{
    	if voldown_presses > 0
    		{
    		voldown_presses += 1
    		return
    		}
    	voldown_presses = 1
    	SetTimer, VolDown, 550	; Time needed until the key has repeated itself min. 2 times (Volume_Down + Delay + Volume_Down + Volume Down = long button press). This is the time for default windows keyboard repeat delay and speed settings.
    	return
    	}
    else
    	Send {Volume_Down}	; Action for normal volume-down buttons
    return
    
    VolDown:	; Actions for the tablet/bezel volume-down button
    SetTimer, VolDown, off
    if voldown_presses = 1
    	{
    	Msgbox single-press	; single-press
    	}
    else if voldown_presses = 2
    	{
    	Msgbox double-press	; double-press
    	}
    else if voldown_presses > 2
    	{
    	Msgbox long-press	; long-press (or tripple-press)
    	Sleep 600	; Time from Settimer + a few ms
    	}
    voldown_presses = 0
    return
    
    
    $Volume_Up::
    state := GetKeyState("Volume_Up", "P")
    if state=0
    	{
    	if volup_presses > 0
    		{
    		volup_presses += 1
    		return
    		}
    	volup_presses = 1
    	SetTimer, VolUp, 550	; Time needed until the key has repeated itself min. 2 times (Volume_Down + Delay + Volume_Down + Volume Down = long button press). This is the time for default windows keyboard repeat delay and speed settings.
    	return
    	}
    else
    	Send {Volume_Up}	; Action for normal volume-down buttons
    return
    
    VolUp:	; Actions for the tablet/bezel volume-up button
    SetTimer, VolUp, off
    if volup_presses = 1
    	{
    	Msgbox single-press	; single-press
    	}
    else if volup_presses = 2
    	{
    	Msgbox double-press	; double-press
    	}
    else if volup_presses > 2
    	{
    	Msgbox long-press	; long-press (or tripple-press)
    	Sleep 600	; Time from Settimer + a few ms
    	}
    volup_presses = 0
    return
    
    • For the Win + Vol-Up/Down combinations (on Win8.1 'Win + Vol-Down' takes a screenshot and 'Win + Vol-Up' starts voice assistant resulting in these strange key-combinations seen by AHK. They'll probably don't work on Win7):
    Code:
    #F15::Msgbox Win + Vol-Down	; Win + Vol-Down
    #^F14::Msgbox Win + Vol-Up	; Win + Vol-Up
    
    • For the rotate button (on Win8.1 it locks the screen rotation resulting in this strange key-combination seen by AHK. This example will probably not work on Win7):
    Code:
    t=1
    
    #F14::	; rotate button
    if (t=1) {
    	t=0
    	KeyWait, F14, T0.4	; Time for long-press
    	if Errorlevel
    		{
    		Msgbox long-press	; Action for long-press
    		sleep 410	; Time for long-press + a few ms
    		t=1
    		return
    		}
    	KeyWait, F14, % "d T"0.3	; Time to wait between a double-press
    	if Errorlevel
    		{
    		Msgbox single-press	; Action for single-press
    		}
    	else {
    		Msgbox double-press	; Action for double-press
    		}
    	t=1
    	return
    	}
    else
    return
    
    • For the A & B button. They can already be remapped with Windows for short and long press but if you want 3 actions or shorten the annoying 2 sec delay for long-press you can remap them with Windows to some unneeded key combinations like 'Shift + F1' and 'Shift + F2' and then remap these with AHK:
    Code:
    t=1
    
    +F1::		; A button
       if (t=1) {
    	t=0
    	KeyWait, F1, T0.4	; Time for long-press
    	if Errorlevel {
    		Msgbox long-press	; Action for long-press
    		sleep 410	; Time for long-press + a few ms
    		t=1
    		return
    	}
    	KeyWait, F1, % "d T"0.3	; Time to wait between a double-press
    	if Errorlevel {
    		Msgbox single-press	; Action for single-press
    		}
    	else {
    		Msgbox double-press	; Action for double-press
    		}
    	t=1
    	return
    	}
       else
    return
    
    +F2::		; B button
       if (t=1) {
    	t=0
    	KeyWait, F2, T0.4	; Time for long-press
    	if Errorlevel {
    		Msgbox long-press	; Action for long-press
    		sleep 410	; Time for long-press + a few ms
    		t=1
    		return
    	}
    	KeyWait, F2, % "d T"0.3	; Time to wait between a double-press
    	if Errorlevel {
    		Msgbox single-press	; Action for single-press
    		}
    	else {
    		Msgbox double-press	; Action for double-press
    		}
    	t=1
    	return
    	}
       else
    return
    

    If you want to use the buttons as modifiers (for example ctrl or alt) you of course can't use the 'triple' functionality. Then you just do a simple remap:
    Code:
    $Volume_Down::
    state := GetKeyState("Volume_Down", "P")
    if state=0
    	Send {Ctrl}	; Actions for the tablet/bezel volume-down button
    else
    	Send {Volume_Down}	; Action for normal volume-down buttons
    return
    
    $Volume_Up::
    state := GetKeyState("Volume_Up", "P")
    if state=0
    	Send {Alt}	; Actions for the tablet/bezel volume-up button
    else
    	Send {Volume_Up}	; Action for normal volume-up buttons
    return
    
    #F14::Send {Shift}	; rotate button
    

    List of some useful functions:
    Code:
    Run, "explorer.exe" shell:::{3080F90E-D7AD-11D9-BD98-0000947B0257} ; shows the Alt+Tab task switcher (also working on Win8)
    Run, C:\Program Files\Common Files\microsoft shared\ink\TabTip.exe ; opens the Win8 touchscreen keyboard
    Run, "%ProgramFiles%\Fujitsu\Utils\FjRotBtn.exe" ; rotates the display, needs FujitsuDisplayManager to be installed
    Send #o ; Send the key-combo Win+O to lock auto-screen-rotation on Win8
    SendMessage, 0x112, 0xF170, 2,, Program Manager ; turns off the display
    
    Send {Volume_Down 1} ; lowers the volume by the amount of the number
    Send {Volume_Up 1} ; raises the volume by the amount of the number
    Send {Volume_Mute} ; mutes the volume
    Send {Media_Next} ; skips to next track on some media-players
    Send {Media_Prev} ; goes back to previous track on some media-players
    Send {Media_Pause} ; pause playback on some media-players
    
    to be continued...

    Please also test this on Win7 and other devices and report or ask questions here :)
     
    Last edited by a moderator: May 18, 2015
    Tamd, Tekn0 and luc like this.
Thread Status:
Not open for further replies.

Share This Page