[d3b6d5e] | 1 | /*
|
---|
| 2 | * Copyright (c) 2011 Lubos Slovak
|
---|
| 3 | * All rights reserved.
|
---|
| 4 | *
|
---|
| 5 | * Redistribution and use in source and binary forms, with or without
|
---|
| 6 | * modification, are permitted provided that the following conditions
|
---|
| 7 | * are met:
|
---|
| 8 | *
|
---|
| 9 | * - Redistributions of source code must retain the above copyright
|
---|
| 10 | * notice, this list of conditions and the following disclaimer.
|
---|
| 11 | * - Redistributions in binary form must reproduce the above copyright
|
---|
| 12 | * notice, this list of conditions and the following disclaimer in the
|
---|
| 13 | * documentation and/or other materials provided with the distribution.
|
---|
| 14 | * - The name of the author may not be used to endorse or promote products
|
---|
| 15 | * derived from this software without specific prior written permission.
|
---|
| 16 | *
|
---|
| 17 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
|
---|
| 18 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
---|
| 19 | * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
---|
| 20 | * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
|
---|
| 21 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
---|
| 22 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
---|
| 23 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
---|
| 24 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
---|
| 25 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
---|
| 26 | * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
---|
| 27 | */
|
---|
| 28 |
|
---|
| 29 | /** @addtogroup drvusbhid
|
---|
| 30 | * @{
|
---|
| 31 | */
|
---|
| 32 | /** @file
|
---|
| 33 | * UUSB multimedia key to keycode mapping.
|
---|
| 34 | */
|
---|
| 35 |
|
---|
| 36 | #include <io/keycode.h>
|
---|
| 37 | #include <stdint.h>
|
---|
| 38 | #include <stdio.h>
|
---|
| 39 | #include <usb/debug.h>
|
---|
| 40 | #include "keymap.h"
|
---|
| 41 |
|
---|
| 42 | /**
|
---|
[1b20da0] | 43 | * Mapping between USB HID multimedia usages (from HID Usage Tables) and
|
---|
[d3b6d5e] | 44 | * corresponding HelenOS key codes.
|
---|
| 45 | *
|
---|
| 46 | * Currently only Usages used by Logitech UltraX keyboard are present. All other
|
---|
| 47 | * should result in 0.
|
---|
| 48 | */
|
---|
| 49 | static int usb_hid_keymap_consumer[0x29c] = {
|
---|
| 50 | [0xb5] = 0, /* Scan Next Track */
|
---|
| 51 | [0xb6] = 0, /* Scan Previous Track */
|
---|
| 52 | [0xb7] = 0, /* Stop */
|
---|
| 53 | [0xb8] = 0, /* Eject */
|
---|
[3c9eb46] | 54 | [0xcd] = 0/*KC_F2*/, /* Play/Pause */
|
---|
| 55 | [0xe2] = 0/*KC_F3*/, /* Mute */
|
---|
| 56 | [0xe9] = 0/*KC_F5*/, /* Volume Increment */
|
---|
| 57 | [0xea] = 0/*KC_F4*/, /* Volume Decrement */
|
---|
| 58 | [0x183] = 0/*KC_F1*/, /* AL Consumer Control Configuration */
|
---|
[d3b6d5e] | 59 | [0x18a] = 0, /* AL Email Reader */
|
---|
| 60 | [0x192] = 0, /* AL Calculator */
|
---|
| 61 | [0x221] = 0, /* AC Search */
|
---|
[3c9eb46] | 62 | [0x223] = 0/*KC_F6*/, /* AC Home */
|
---|
[d3b6d5e] | 63 | [0x224] = 0, /* AC Back */
|
---|
| 64 | [0x225] = 0, /* AC Forward */
|
---|
| 65 | [0x226] = 0, /* AC Stop */
|
---|
[6fe0beeb] | 66 | [0x227] = 0, /* AC Refresh */
|
---|
| 67 | [0x22a] = 0 /* AC Bookmarks */
|
---|
[d3b6d5e] | 68 | };
|
---|
| 69 |
|
---|
| 70 | /**
|
---|
| 71 | * Translates USB HID Usages from the Consumer Page into HelenOS keycodes.
|
---|
| 72 | *
|
---|
| 73 | * @param usage USB HID Consumer Page Usage number.
|
---|
[1b20da0] | 74 | *
|
---|
[d3b6d5e] | 75 | * @retval HelenOS key code corresponding to the given USB Consumer Page Usage.
|
---|
| 76 | */
|
---|
| 77 | unsigned int usb_multimedia_map_usage(int usage)
|
---|
| 78 | {
|
---|
| 79 | unsigned int key;
|
---|
| 80 | int *map = usb_hid_keymap_consumer;
|
---|
| 81 | size_t map_length = sizeof(usb_hid_keymap_consumer) / sizeof(int);
|
---|
| 82 |
|
---|
| 83 | if ((usage < 0) || ((size_t)usage >= map_length))
|
---|
| 84 | return -1;
|
---|
| 85 |
|
---|
| 86 | /*! @todo What if the usage is not in the table? */
|
---|
| 87 | key = map[usage];
|
---|
[a35b458] | 88 |
|
---|
[d3b6d5e] | 89 | return key;
|
---|
| 90 | }
|
---|
| 91 |
|
---|
| 92 | /**
|
---|
| 93 | * @}
|
---|
| 94 | */
|
---|