source: mainline/uspace/drv/usbhid/lgtch-ultrax/keymap.c@ 04c1524

lfn serial ticket/834-toolchain-update topic/msim-upgrade topic/simplify-dev-export
Last change on this file since 04c1524 was e67399e, checked in by Lubos Slovak <lubos.slovak@…>, 15 years ago

Minor changes

  • Property mode set to 100644
File size: 3.4 KB
Line 
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/**
43 * Mapping between USB HID multimedia usages (from HID Usage Tables) and
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 */
49static int usb_hid_keymap_consumer[0x29c] = {
50 [0xf] = KC_F1, /* Just for testing purposes */
51 [0x5] = KC_F1, /* Just for testing purposes */
52 [0x8] = KC_F3, /* Just for testing purposes */
53 [0x6] = KC_F4, /* Just for testing purposes */
54 [0x7] = KC_F5, /* Just for testing purposes */
55 [0xc] = KC_F6, /* Just for testing purposes */
56
57 [0xb5] = 0, /* Scan Next Track */
58 [0xb6] = 0, /* Scan Previous Track */
59 [0xb7] = 0, /* Stop */
60 [0xb8] = 0, /* Eject */
61 [0xcd] = KC_F2, /* Play/Pause */
62 [0xe2] = KC_F3, /* Mute */
63 [0xe9] = KC_F5, /* Volume Increment */
64 [0xea] = KC_F4, /* Volume Decrement */
65 [0x183] = 0, /* AL Consumer Control Configuration */
66 [0x18a] = 0, /* AL Email Reader */
67 [0x192] = 0, /* AL Calculator */
68 [0x221] = 0, /* AC Search */
69 [0x223] = 0, /* AC Home */
70 [0x224] = 0, /* AC Back */
71 [0x225] = 0, /* AC Forward */
72 [0x226] = 0, /* AC Stop */
73 [0x227] = KC_F1, /* AC Refresh */
74 [0x22a] = KC_F6 /* AC Bookmarks */
75};
76
77/**
78 * Translates USB HID Usages from the Consumer Page into HelenOS keycodes.
79 *
80 * @param usage USB HID Consumer Page Usage number.
81 *
82 * @retval HelenOS key code corresponding to the given USB Consumer Page Usage.
83 */
84unsigned int usb_lgtch_map_usage(int usage)
85{
86 unsigned int key;
87 int *map = usb_hid_keymap_consumer;
88 size_t map_length = sizeof(usb_hid_keymap_consumer) / sizeof(int);
89
90 if ((usage < 0) || ((size_t)usage >= map_length))
91 return -1;
92
93 /*! @todo What if the usage is not in the table? */
94 key = map[usage];
95
96 return key;
97}
98
99/**
100 * @}
101 */
Note: See TracBrowser for help on using the repository browser.