Page 1 of 8 123 ... LastLast
Results 1 to 10 of 75

Thread: [HOWTO] Fix for Stuck Volume/Multimedia Keys

  1. #1
    Join Date
    Nov 2008
    Beans
    21
    Distro
    Ubuntu Studio 10.04 Lucid Lynx

    [HOWTO] Fix for Stuck Volume/Multimedia Keys

    (ADDED NOTE: This is for users using the 'evdev' driver only. This includes most of the users who have recently upgraded to Intrepid.)

    First off, this isn't a permanent fix for the volume/media key issues started in Intrepid. It's just a port of a small fix found in the 'kbd' driver present in Hardy to the 'evdev' driver present in Intrepid. Something similar, may eventually may work its way into future evdev releases, but for now, several developers are having deciding where the 'bug' should be handled.

    The issue is that on certain systems' PS/2 keyboards, the volume control keys (and certain media keys) report a KEY_DOWN when they're pressed, but not a KEY_UP when they're released. The result of this is that the system acts like they're stuck- and repeats them indefinitely, often preventing use of the keyboard and/or mouse.

    If your system seems to be affected by this bug, this is a detailed workaround. It requires for you to use the terminal, perform some file copy operations, and perform some compilations yourself. It also may require you to think a little, instead of following step by step instructions. If you're not comfortable with any of this, you can simply remap your volume controls to other keys using System->Preferences->Keyboard Shortcuts.

    A warning: you are modifying the primary keyboard input drivers for your graphical user interface. There is always the possibility that something can go wrong. You can take steps to recover from these, using one of the Virtual Terminals (CTRL+ALT+F2, for example), or a recovery mode prompt, but in the end all responsibility for your system's state is yours.

    That said, there are two basic methods:

    1) Download a pre-modified version of evdev-2.0.99, compile it, and install it. This method gives you the least customization, restricts you to evdev-2.0.99 in the event that a later stable version has been released, and only fixes the volume keys, but is easiest and doesn't require any mucking about with C code.

    2) Download the current version of the evdev source from the Ubuntu Package Repository. Customize it according to this How-To, then compile and install.

    Code:
    Text enclosed in these boxes are intended to be typed into the terminal.
    You will probably have to re-apply this patch using 'Method 2' below each time there's an evdev update, if you want to install the evdev update. Otherwise, simply choose not to install updates to evdev (not reccomended).

    Method 1

    1) Back up your current evdev driver, just in case. This line will back up to your home directory (~/), you can modify it if you want; just remember where you put it for later.

    Code:
     cp /usr/lib/xorg/modules/input/evdev_drv.so ~/
    2) Download my modified evdev-2.0.99 driver, if you're using intrepid:

    Code:
    wget http://labs.ktemkin.com/ubuntu/evdev_fix_2.0.99.tar.gz
    or my modified evdev-2.1.1 driver, if you're using jaunty;

    Code:
     wget http://www.ktemkin.com/content/ubuntu/evdev_fix_2.1.1.tar.gz
    or, if you're using jaunty and have a Toshiba model with a volume wheel:

    Code:
     wget http://www.ktemkin.com/content/ubuntu/evdev_fix_2.1.1-toshiba.tar.gz
    3) 'Unzip' it to the evdev_fix folder (you'll need to change this to 2.0.99 if you're using intrepid, or to 2.1.1-toshiba if you're using the Toshiba version.):

    Code:
     tar -zxvf evdev_fix_2.1.1.tar.gz
    4) Change the working directory to the evdev_fix folder:

    Code:
     cd evdev_fix
    5) You're ready to compile! Skip to the 'both methods' section.

    Method 2

    This method assumes a bit more technical knoweldge, so simple things like downloading and decompressing won't be explained.

    If you're more comfortable with the GUI:

    1) Download the newest version of the evdev driver from the Ubuntu Package Repository (Intrepid) or Ubuntu Package Repository (Jaunty).

    2) Untar it to a folder inside of your home directory.

    Or, if you're more comfortable with the terminal:

    1/2) This will download the current evdev source for you:

    Code:
    apt-get source xserver-xorg-input-evdev
    3) Inside the folder for the evdev version you just downloaded, you'll find a 'src' folder. Look for the block that contains:

    PHP Code:
        /* filter repeat events for chording keys */
        
    if (value == &&
            (
    ev->code == KEY_LEFTCTRL || ev->code == KEY_RIGHTCTRL ||
             
    ev->code == KEY_LEFTSHIFT || ev->code == KEY_RIGHTSHIFT ||
             
    ev->code == KEY_LEFTALT || ev->code == KEY_RIGHTALT ||
             
    ev->code == KEY_LEFTMETA || ev->code == KEY_RIGHTMETA ||
             
    ev->code == KEY_CAPSLOCK || ev->code == KEY_NUMLOCK ||
             
    ev->code == KEY_SCROLLLOCK)) /* XXX windows keys? */
            
    return; 
    After it, on a new line, copy and paste the following code:

    PHP Code:
        /* fix events for volume keys */
        
    if(ev->code == KEY_VOLUMEDOWN || ev->code == KEY_VOLUMEUP//MODIFY THIS LINE
        

        
    //post a keydown and then a keyup, as media keys have no automatic key-up
        
    xf86PostKeyboardEvent(pInfo->devcode1);
        
    xf86PostKeyboardEvent(pInfo->devcode0);
        return;
        } 
    4) Customize. At this point, you'll be customizing the line that preceeds the "Modify this line" comment. You can add additional keycodes by adding "ev->code == YOUR_KEYCODE", seperating each instance with a pair of double bars. "||". You can find additional keycodes using either the 'evtest' utility in the console, or in <linux/input.h>.

    For example, if you needed to fix the mute key on your keyboard as well, your block would look like:

    PHP Code:
        /* fix events for volume keys */
        
    if(ev->code == KEY_VOLUMEDOWN || ev->code == KEY_VOLUMEUP ||  ev->code == KEY_MUTE//MODIFY THIS LINE
        

        
    //post a keydown and then a keyup, as media keys have no automatic key-up
        
    xf86PostKeyboardEvent(pInfo->devcode1);
        
    xf86PostKeyboardEvent(pInfo->devcode0);
        return;
        } 
    5) Continue on to 'Both Methods' below.

    Both Methods

    1) Compile. Firstly, we'll need to make sure you have everything set up to compile. Install anything this step requires, or just continue if it tells you you're 'already newest version'. You'll need to type in your password to give yourself installation rights.

    Code:
     sudo apt-get install build-essential libtool automake gcc xorg-dev xutils-dev
    This should be the same as:

    Code:
     sudo apt-get build-dep xserver-xorg-input-evdev
    but for safety, especially if you're using method 1, I recommend executing both.

    Next, we have to generate our 'Makefile'. This tells the computer how to compile. It will probably generate a lot of text output.

    Code:
    ./autogen.sh
    Once it generates succesfully, it's time to perform the compilation itself.

    Code:
    make
    2) Install. First, tell make to install the file:

    Code:
    sudo make install
    Now, copy it to the correct location. There's a strong possibility this will restart your x-server (GUI), so make sure you've saved everything you want to save, as if you were restarting your computer. When it restarts, your volume keys should work!

    Code:
    sudo cp /usr/local/lib/xorg/modules/input/evdev_drv.so /usr/lib/xorg/modules/input/
    If your x-server didn't restart you can restart it by pressing CTRL+ALT+BACKSPACE, or by restarting your computer.


    Recovery

    If your keyboard/mouse stopped working, don't panic! Instead, switch to one of your virtual terminals by pressing CTRL+ALT+F2. Then, execute the following command:

    Code:
    sudo cp ~/evdev_drv.so /usr/lib/xorg/modules/input/
    That will restore your original driver. Then, restart the computer with the following commands.

    Code:
    sudo shutdown -r 0
    Last edited by ktemkin; June 8th, 2009 at 10:33 PM. Reason: jaunty fixes, toshiba version

  2. #2
    Join Date
    May 2008
    Location
    Shanghai
    Beans
    110

    Re: [HOWTO] Fix for Stuck Volume/Multimedia Keys

    Thanks for this workaround. While trying the easy method 1 autogen.sh stops with the following error:

    Code:
    ./configure: line 11656: syntax error near unexpected token `RANDR,'
    ./configure: line 11656: `XORG_DRIVER_CHECK_EXT(RANDR, randrproto)'
    I will try method 2 now...


    EDIT:
    okay, that's the same with method 2. I'm probably just missing some development libraries.

    EDIT 2:
    configuration works with the xorg-dev metapackage installed. How could I miss that... hehe!
    Last edited by rekado; November 9th, 2008 at 10:49 PM.

  3. #3
    Join Date
    Nov 2008
    Beans
    21
    Distro
    Ubuntu Studio 10.04 Lucid Lynx

    Re: [HOWTO] Fix for Stuck Volume/Multimedia Keys

    Oops. I missed a dependency. I'll add that above. Thank you.

  4. #4
    Join Date
    May 2008
    Location
    Shanghai
    Beans
    110

    Re: [HOWTO] Fix for Stuck Volume/Multimedia Keys

    It didn't work for me. After typing in the line to replace the driver the X server crashed (of course) and I was asked to re-login. However, input from the keyboard was not recognized any more. I could switch to tty1 but there was just some purple pattern. So I decided to just press the power button to restart. I go to the login screen again but still no input was accepted. This time switching to tty1 worked, I logged in and tried the recovery procedure.
    For me it only worked when changing the recovery line to:

    Code:
    sudo cp ~/evdev_drv.so /usr/lib/xorg/modules/input/
    i.e. copying to the same pathe where we took the backup from. I think this needs to be changed as the original line (with the "local" in between) didn't work.

    Sad to say it didn't work. Did I do something obvious wrong?

  5. #5
    Join Date
    Nov 2008
    Beans
    21
    Distro
    Ubuntu Studio 10.04 Lucid Lynx

    Re: [HOWTO] Fix for Stuck Volume/Multimedia Keys

    Yes, the backup line was a typo. It has been corrected. Did you use Method 2 the time that it didn't work? If so, please try Method 1 and tell me if your results differ. Any additional information you can give me about your procedure would help immensely.

    If you did use Method 2, please post your modified code.
    Last edited by ktemkin; November 9th, 2008 at 11:30 PM.

  6. #6
    Join Date
    May 2008
    Location
    Shanghai
    Beans
    110

    Re: [HOWTO] Fix for Stuck Volume/Multimedia Keys

    I used method 2 but I just entered wrong key codes. So just now I performed method 1 again and it worked like a charm! Now I can adjust my volume without locking up the X-session.

    Thanks a lot! More people should read this.

  7. #7
    Join Date
    Oct 2008
    Beans
    8

    Thumbs down Re: [HOWTO] Fix for Stuck Volume/Multimedia Keys

    Worked like a charm - fixed my volume control issues described in http://ubuntuforums.org/showthread.php?t=964870. Thanks for your work!

  8. #8
    Join Date
    Jan 2008
    Beans
    135

    Re: [HOWTO] Fix for Stuck Volume/Multimedia Keys

    Also method 1 worked like a charm, thank you very much. Just one question, wont it prevent me from getting it fixed whenever the official patch arives?
    Using Ubuntu 11.04 Fully updated, Toshiba U305 S5107 Intel Core 2 duo 4096 RAM.
    Sorry for my bad english...
    Did I helped you? Better try helping someone else than thanking me.

  9. #9
    Join Date
    Sep 2006
    Beans
    Hidden!

    Re: [HOWTO] Fix for Stuck Volume/Multimedia Keys

    Thank you for the fix.

  10. #10
    Join Date
    Jul 2007
    Beans
    8

    Talking Re: [HOWTO] Fix for Stuck Volume/Multimedia Keys

    Thanks ktemkin, I used method 1 and it worked great

    I got a email from the bug on LaunchPad https://bugs.launchpad.net/ubuntu/+bug/278781 , I will thank you over there too.

    thank you.
    Last edited by lolo67; November 16th, 2008 at 01:15 PM.

Page 1 of 8 123 ... LastLast

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •