15f5aed22Saliguori /* 25f5aed22Saliguori * QEMU keysym to keycode conversion using rdesktop keymaps 35f5aed22Saliguori * 45f5aed22Saliguori * Copyright (c) 2004 Johannes Schindelin 55f5aed22Saliguori * 65f5aed22Saliguori * Permission is hereby granted, free of charge, to any person obtaining a copy 75f5aed22Saliguori * of this software and associated documentation files (the "Software"), to deal 85f5aed22Saliguori * in the Software without restriction, including without limitation the rights 95f5aed22Saliguori * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 105f5aed22Saliguori * copies of the Software, and to permit persons to whom the Software is 115f5aed22Saliguori * furnished to do so, subject to the following conditions: 125f5aed22Saliguori * 135f5aed22Saliguori * The above copyright notice and this permission notice shall be included in 145f5aed22Saliguori * all copies or substantial portions of the Software. 155f5aed22Saliguori * 165f5aed22Saliguori * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 175f5aed22Saliguori * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 185f5aed22Saliguori * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 195f5aed22Saliguori * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 205f5aed22Saliguori * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 215f5aed22Saliguori * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 225f5aed22Saliguori * THE SOFTWARE. 235f5aed22Saliguori */ 245f5aed22Saliguori 252a6a4076SMarkus Armbruster #ifndef QEMU_KEYMAPS_H 262a6a4076SMarkus Armbruster #define QEMU_KEYMAPS_H 275f5aed22Saliguori 285f5aed22Saliguori #include "qemu-common.h" 295f5aed22Saliguori 305f5aed22Saliguori typedef struct { 315f5aed22Saliguori const char* name; 325f5aed22Saliguori int keysym; 33c227f099SAnthony Liguori } name2keysym_t; 345f5aed22Saliguori 3544bb61c8SSamuel Thibault /* scancode without modifiers */ 3644bb61c8SSamuel Thibault #define SCANCODE_KEYMASK 0xff 3744bb61c8SSamuel Thibault /* scancode without grey or up bit */ 3844bb61c8SSamuel Thibault #define SCANCODE_KEYCODEMASK 0x7f 3944bb61c8SSamuel Thibault 4044bb61c8SSamuel Thibault /* "grey" keys will usually need a 0xe0 prefix */ 4144bb61c8SSamuel Thibault #define SCANCODE_GREY 0x80 4244bb61c8SSamuel Thibault #define SCANCODE_EMUL0 0xE0 437c388dbdSDaniel P. Berrange #define SCANCODE_EMUL1 0xE1 4444bb61c8SSamuel Thibault /* "up" flag */ 4544bb61c8SSamuel Thibault #define SCANCODE_UP 0x80 4644bb61c8SSamuel Thibault 4744bb61c8SSamuel Thibault /* Additional modifiers to use if not catched another way. */ 4844bb61c8SSamuel Thibault #define SCANCODE_SHIFT 0x100 4944bb61c8SSamuel Thibault #define SCANCODE_CTRL 0x200 5044bb61c8SSamuel Thibault #define SCANCODE_ALT 0x400 5144bb61c8SSamuel Thibault #define SCANCODE_ALTGR 0x800 5244bb61c8SSamuel Thibault 53fe5fca9aSGerd Hoffmann typedef struct kbd_layout_t kbd_layout_t; 545f5aed22Saliguori 55fe5fca9aSGerd Hoffmann kbd_layout_t *init_keyboard_layout(const name2keysym_t *table, 56fe5fca9aSGerd Hoffmann const char *language); 57*abb4f2c9SGerd Hoffmann int keysym2scancode(kbd_layout_t *k, int keysym, 58*abb4f2c9SGerd Hoffmann bool shift, bool altgr, bool ctrl); 59fe5fca9aSGerd Hoffmann int keycode_is_keypad(kbd_layout_t *k, int keycode); 60fe5fca9aSGerd Hoffmann int keysym_is_numlock(kbd_layout_t *k, int keysym); 615f5aed22Saliguori 622a6a4076SMarkus Armbruster #endif /* QEMU_KEYMAPS_H */ 63