Page 3 of 20 FirstFirst 1234513 ... LastLast
Results 21 to 30 of 194

Thread: HOWTO: Microsoft Natural Ergonomic Keyboard 4000 - enabling special keys

  1. #21
    Join Date
    Sep 2006
    Beans
    3

    Re: HOWTO: Microsoft Natural Ergonomic Keyboard 4000 - enabling special keys

    In order tho apply the patches you only need to cd /path/of/kernel_sources
    (cd /usr/src/linux for example) and then patch -p1 < /path/of/your/patch .

    P.S.

    The howto on gentoo-wiki is still a work in progress. I keep adding informations or notes. Several problems and possible solutions have come up, along with suggestions and questions. If you have any of these feel free to comment here: http://gentoo-wiki.com/Talk:HOWTO_Mi..._Keyboard_4000

  2. #22
    Join Date
    Aug 2006
    Beans
    18

    Re: HOWTO: Microsoft Natural Ergonomic Keyboard 4000 - enabling special keys

    Quote Originally Posted by trantorvega View Post
    I've some questions liyu. Not being a kernel hacker I've not understood how keycodes are actually generated and if their values are hardwired into the keyboard. Is differentiating the codes generated by Favorites/Down Arrow and One/Print (so that each key generates a different keycode) possible?
    You are welcome.

    No, as we want, these keycodes are not hardwired into this keyboard. they are defined in the ${KERNEL_SOURCE_TREE}/include/linux/input.h, I think they are a part of the Linux input interface. so, in principle, we can let one key generate more than one keycodes. Well, I am going to experiment with this.

    And, yes, as the guess in your email, I am chinese.

    Thanks.

  3. #23
    Join Date
    Aug 2006
    Beans
    18

    Re: HOWTO: Microsoft Natural Ergonomic Keyboard 4000 - enabling special keys

    This is you want to get. The My Favorites, Redo, and five custom keys can yield two keycodes, and one of both is less than 255, follow is the mapping:

    KEY_FAVORITES ==> KEY_F16 (186)
    KEY_REDO ==> KEY_F17 (187)
    KEY_CUSTOM1 ==> KEY_F18 (188)
    KEY_CUSTOM2 ==> KEY_F19 (189)
    KEY_CUSTOM3 ==> KEY_F20 (190)
    KEY_CUSTOM4 ==> KEY_F21 (191)
    KEY_CUSTOM5 ==> KEY_F22 (192)

    Here is the source, and I found there is a problem in the hid simple driver layer, I will release these sources/patches for 2.6.18 vanilla kernel later, however, I should go home now.

    /*
    * Microsoft Natural Ergonomic Keyboard 4000 Driver
    *
    * Version: 0.3.2
    *
    * Copyright (c) 2006 Li Yu <raise.sail@gmail.com>
    */

    /*
    * This program is free software; you can redistribute it and/or modify it
    * under the terms of the GNU General Public License as published by the Free
    * Software Foundation; either version 2 of the License, or (at your option)
    * any later version.
    */

    #include <linux/kernel.h>
    #include <linux/input.h>
    #include "hid.h"
    #include "hid-simple.h"

    #define USAGE_ZOOM_IN 0x22d
    #define USAGE_ZOOM_OUT 0x22e
    #define USAGE_HOME 0x223
    #define USAGE_SEARCH 0x221
    #define USAGE_EMAIL 0x18a
    #define USAGE_FAVORITES 0x182
    #define USAGE_MUTE 0xe2
    #define USAGE_VOLUME_DOWN 0xea
    #define USAGE_VOLUME_UP 0xe9
    #define USAGE_PLAY_PAUSE 0xcd
    #define USAGE_CALCULATOR 0x192
    #define USAGE_BACK 0x224
    #define USAGE_FORWARD 0x225
    #define USAGE_CUSTOM 0xff05

    #define USAGE_CUSTOM_RELEASE 0x0
    #define USAGE_CUSTOM_1 0x1
    #define USAGE_CUSTOM_2 0x2
    #define USAGE_CUSTOM_3 0x4
    #define USAGE_CUSTOM_4 0x8
    #define USAGE_CUSTOM_5 0x10

    #define USAGE_HELP 0x95
    #define USAGE_UNDO 0x21a
    #define USAGE_REDO 0x279
    #define USAGE_NEW 0x201
    #define USAGE_OPEN 0x202
    #define USAGE_CLOSE 0x203

    #define USAGE_REPLY 0x289
    #define USAGE_FWD 0x28b
    #define USAGE_SEND 0x28c
    #define USAGE_SPELL 0x1ab
    #define USAGE_SAVE 0x207
    #define USAGE_PRINT 0x208

    #define USAGE_KEYPAD_EQUAL 0x67
    #define USAGE_KEYPAD_LEFT_PAREN 0xb6
    #define USAGE_KEYPAD_RIGHT_PAREN 0xb7

    #define MSNEK4K_ID_VENDOR 0x045e
    #define MSNEK4K_ID_PRODUCT 0x00db

    static struct usb_device_id nek4k_id_table[] = {
    {
    USB_DEVICE(MSNEK4K_ID_VENDOR, MSNEK4K_ID_PRODUCT)
    },
    {}
    };

    MODULE_DEVICE_TABLE(usb, nek4k_id_table);

    static char driver_name[] = "Microsoft Natural Ergonomic Keyboard 4000";

    struct usage_block consumer_usage_block[] = {
    USAGE_BLOCK(USAGE_ZOOM_IN, 0, EV_KEY, KEY_F13, 0),
    USAGE_BLOCK(USAGE_ZOOM_OUT, 0, EV_KEY, KEY_F14, 0),
    USAGE_BLOCK(USAGE_HOME, 0, EV_KEY, KEY_HOMEPAGE, 0),
    USAGE_BLOCK(USAGE_SEARCH, 0, EV_KEY, KEY_SEARCH, 0),
    USAGE_BLOCK(USAGE_EMAIL, 0, EV_KEY, KEY_EMAIL, 0),
    USAGE_BLOCK(USAGE_FAVORITES, 0, EV_KEY, KEY_F16, 0),
    USAGE_BLOCK(USAGE_FAVORITES, 0, EV_KEY, KEY_FAVORITES, 0),
    USAGE_BLOCK(USAGE_MUTE, 0, EV_KEY, KEY_MUTE, 0),
    USAGE_BLOCK(USAGE_VOLUME_DOWN, 0, EV_KEY, KEY_VOLUMEDOWN, 0),
    USAGE_BLOCK(USAGE_VOLUME_UP, 0, EV_KEY, KEY_VOLUMEUP, 0),
    USAGE_BLOCK(USAGE_PLAY_PAUSE, 0, EV_KEY, KEY_PLAYPAUSE, 0),
    USAGE_BLOCK(USAGE_CALCULATOR, 0, EV_KEY, KEY_CALC, 0),
    USAGE_BLOCK(USAGE_BACK, 0, EV_KEY, KEY_BACK, 0),
    USAGE_BLOCK(USAGE_FORWARD, 0, EV_KEY, KEY_FORWARD, 0),
    USAGE_BLOCK(USAGE_HELP, 0, EV_KEY, KEY_HELP, 0),
    USAGE_BLOCK(USAGE_UNDO, 0, EV_KEY, KEY_UNDO, 0),
    USAGE_BLOCK(USAGE_REDO, 0, EV_KEY, KEY_F17, 0),
    USAGE_BLOCK(USAGE_REDO, 0, EV_KEY, KEY_REDO, 0),
    USAGE_BLOCK(USAGE_NEW, 0, EV_KEY, KEY_NEW, 0),
    USAGE_BLOCK(USAGE_OPEN, 0, EV_KEY, KEY_OPEN, 0),
    USAGE_BLOCK(USAGE_CLOSE, 0, EV_KEY, KEY_CLOSE, 0),
    USAGE_BLOCK(USAGE_REPLY, 0, EV_KEY, KEY_REPLY, 0),
    USAGE_BLOCK(USAGE_FWD, 0, EV_KEY, KEY_FORWARDMAIL, 0),
    USAGE_BLOCK(USAGE_SEND, 0, EV_KEY, KEY_SEND, 0),
    USAGE_BLOCK(USAGE_SPELL, 0, EV_KEY, KEY_F15, 0),
    USAGE_BLOCK(USAGE_SAVE, 0, EV_KEY, KEY_SAVE, 0),
    USAGE_BLOCK(USAGE_PRINT, 0, EV_KEY, KEY_PRINT, 0),
    USAGE_BLOCK_NULL
    };

    struct usage_block msvendor_usage_block[] = {
    USAGE_BLOCK(USAGE_CUSTOM, USAGE_CUSTOM_1, EV_KEY, KEY_FN_F1, 0),
    USAGE_BLOCK(USAGE_CUSTOM, USAGE_CUSTOM_2, EV_KEY, KEY_FN_F2, 0),
    USAGE_BLOCK(USAGE_CUSTOM, USAGE_CUSTOM_3, EV_KEY, KEY_FN_F3, 0),
    USAGE_BLOCK(USAGE_CUSTOM, USAGE_CUSTOM_4, EV_KEY, KEY_FN_F4, 0),
    USAGE_BLOCK(USAGE_CUSTOM, USAGE_CUSTOM_5, EV_KEY, KEY_FN_F5, 0),
    USAGE_BLOCK_NULL
    };

    struct usage_block keyboard_usage_block[] = {
    USAGE_BLOCK(USAGE_KEYPAD_EQUAL, 0, EV_KEY, KEY_KPEQUAL, 0),
    USAGE_BLOCK(USAGE_KEYPAD_LEFT_PAREN, 0, EV_KEY, KEY_KPLEFTPAREN, 0),
    USAGE_BLOCK(USAGE_KEYPAD_RIGHT_PAREN, 0, EV_KEY, KEY_KPRIGHTPAREN, 0),
    USAGE_BLOCK_NULL
    };

    struct usage_page_block nek4k_usage_page_blockes[] = {
    USAGE_PAGE_BLOCK(HID_UP_CONSUMER, consumer_usage_block),
    USAGE_PAGE_BLOCK(HID_UP_MSVENDOR, msvendor_usage_block),
    USAGE_PAGE_BLOCK(HID_UP_KEYBOARD, keyboard_usage_block),
    USAGE_PAGE_BLOCK_NULL
    };

    static int nek4k_pre_event(const struct hid_device *hid,
    const struct hid_field *field,
    const struct hid_usage *usage,
    const __s32 value,
    const struct pt_regs *regs)
    {
    struct hid_input *hidinput = field->hidinput;
    struct input_dev *input = hidinput->input;
    int code = 0, ascii_keycode = 0, ev_value;

    ev_value = value?1:0;

    switch (usage->hid&HID_USAGE) {
    case USAGE_FAVORITES:
    code = KEY_FAVORITES;
    ascii_keycode = KEY_F16;
    goto exit;
    case USAGE_REDO:
    code = KEY_REDO;
    ascii_keycode = KEY_F17;
    goto exit;
    };

    if ((usage->hid&HID_USAGE) != USAGE_CUSTOM)
    /* let hid core continue to process them */
    return (!0);

    switch (value) {
    case USAGE_CUSTOM_RELEASE:
    code = get_keycode(hidinput->private);
    ascii_keycode = KEY_F18+(code-KEY_FN_F1);
    break;
    case USAGE_CUSTOM_1:
    code = KEY_FN_F1;
    ascii_keycode = KEY_F18;
    break;
    case USAGE_CUSTOM_2:
    code = KEY_FN_F2;
    ascii_keycode = KEY_F19;
    break;
    case USAGE_CUSTOM_3:
    code = KEY_FN_F3;
    ascii_keycode = KEY_F20;
    break;
    case USAGE_CUSTOM_4:
    code = KEY_FN_F4;
    ascii_keycode = KEY_F21;
    break;
    case USAGE_CUSTOM_5:
    code = KEY_FN_F5;
    ascii_keycode = KEY_F22;
    break;
    }
    exit:
    if (code) {
    hidinput->private = (void*)code;
    input_event(input, EV_KEY, code, ev_value);
    input_sync(input);
    }
    if (ascii_keycode) {
    input_event(input, EV_KEY, ascii_keycode, ev_value);
    input_sync(input);
    }
    return 0;
    }

    static struct hidinput_simple_driver nek4k_driver = {
    .owner = THIS_MODULE,
    .name = driver_name,
    .pre_event = nek4k_pre_event,
    .id_table = nek4k_id_table,
    .usage_page_table = nek4k_usage_page_blockes,
    .private = NULL
    };

    static int __init nek4k_init(void)
    {
    return hidinput_register_simple_driver(&nek4k_driver);
    }

    static void __exit nek4k_exit(void)
    {
    hidinput_unregister_simple_driver(&nek4k_driver);
    }

    module_init(nek4k_init);
    module_exit(nek4k_exit);

    MODULE_LICENSE("GPL");
    Last edited by liyu; September 28th, 2006 at 01:52 PM.

  4. #24
    Join Date
    Jul 2005
    Beans
    24

    Re: HOWTO: Microsoft Natural Ergonomic Keyboard 4000 - enabling special keys

    Quote Originally Posted by trantorvega View Post
    The howto on gentoo-wiki is still a work in progress. I keep adding informations or notes. Several problems and possible solutions have come up, along with suggestions and questions. If you have any of these feel free to comment here: http://gentoo-wiki.com/Talk:HOWTO_Mi..._Keyboard_4000
    How weird. I'm not able to pull up anything from gentoo-wiki.com at the moment even though the site's pingable. Surprised there's no mirror.

  5. #25
    Join Date
    Feb 2006
    Beans
    66
    Distro
    Hardy Heron (Ubuntu Development)

    Re: HOWTO: Microsoft Natural Ergonomic Keyboard 4000 - enabling special keys

    The howto on gentoo-wiki is still a work in progress. I keep adding informations or notes. Several problems and possible solutions have come up, along with suggestions and questions. If you have any of these feel free to comment here: http://gentoo-wiki.com/Talk:HOWTO_Mi..._Keyboard_4000
    Thanks for putting that up there. I upgraded to Edgy the other day, and I was able to successfully apply those three patches to the ubuntu kernel sources. I did have to apply one patch manually (the one with the Makefile and Kconfig changes), but it was quite easy to do.

  6. #26
    Join Date
    Jul 2006
    Beans
    11

    Re: HOWTO: Microsoft Natural Ergonomic Keyboard 4000 - enabling special keys

    hello, i have a kernel newbie question (a bit off-topic),

    who and how one decides if a patch should be included in future releases?
    will this keybaord patch for example will be included?

    is it realy nessery to comipile all of the kerenl, souldn't modules allow you to add it dynamicly to a working kernel?

    thanks
    amit

  7. #27
    Join Date
    Apr 2005
    Beans
    3

    Exclamation Patches would not apply.

    I could not get the patches to apply, on 2.6.17.8 or 2.6.17.7

    I am running dapper drake with kernel 2.6.15-27-386, and some of the buttons do work. only the "My Favorites" and star buttons, and the zoom thing do not work.

  8. #28
    Join Date
    Nov 2006
    Beans
    Hidden!

    Re: HOWTO: Microsoft Natural Ergonomic Keyboard 4000 - enabling special keys

    I couldn't get usbnek4k.c 0.3.2 to work. When I modprobe it the kernel complains about get_keycode() not being found. I am missing a file or something?

    Chaz.

  9. #29
    Join Date
    Sep 2006
    Beans
    Hidden!

    Re: HOWTO: Microsoft Natural Ergonomic Keyboard 4000 - enabling special keys

    I had the same problem. It's because only part of the required patches were posted to this thread! I contacted the developer, and he told me that the most current version can be found here:

    http://lkml.org/lkml/2006/10/12/18

  10. #30
    Join Date
    Dec 2004
    Location
    Germany
    Beans
    155
    Distro
    Ubuntu 12.04 Precise Pangolin

    Re: HOWTO: Microsoft Natural Ergonomic Keyboard 4000 - enabling special keys

    I updated the instructions.

Page 3 of 20 FirstFirst 1234513 ... 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
  •