cscg24-guacamole

CSCG 2024 Challenge 'Guacamole Mashup'
git clone https://git.sinitax.com/sinitax/cscg24-guacamole
Log | Files | Refs | sfeed.txt

keymap.h (5370B)


      1/*
      2 * Licensed to the Apache Software Foundation (ASF) under one
      3 * or more contributor license agreements.  See the NOTICE file
      4 * distributed with this work for additional information
      5 * regarding copyright ownership.  The ASF licenses this file
      6 * to you under the Apache License, Version 2.0 (the
      7 * "License"); you may not use this file except in compliance
      8 * with the License.  You may obtain a copy of the License at
      9 *
     10 *   http://www.apache.org/licenses/LICENSE-2.0
     11 *
     12 * Unless required by applicable law or agreed to in writing,
     13 * software distributed under the License is distributed on an
     14 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
     15 * KIND, either express or implied.  See the License for the
     16 * specific language governing permissions and limitations
     17 * under the License.
     18 */
     19
     20#ifndef GUAC_RDP_KEYMAP_H
     21#define GUAC_RDP_KEYMAP_H
     22
     23#include <winpr/wtypes.h>
     24
     25/**
     26 * The X11 keysym for Num Lock.
     27 */
     28#define GUAC_RDP_KEYSYM_NUM_LOCK 0xFF7F
     29
     30/**
     31 * The X11 keysym for Scroll Lock.
     32 */
     33#define GUAC_RDP_KEYSYM_SCROLL_LOCK 0xFF14
     34
     35/**
     36 * The X11 keysym for Caps Lock.
     37 */
     38#define GUAC_RDP_KEYSYM_CAPS_LOCK 0xFFE5
     39
     40/**
     41 * The X11 keysym for Kana Lock.
     42 */
     43#define GUAC_RDP_KEYSYM_KANA_LOCK 0xFF2D
     44
     45/**
     46 * The X11 keysym for Left Shift.
     47 */
     48#define GUAC_RDP_KEYSYM_LSHIFT 0xFFE1
     49
     50/**
     51 * The X11 keysym for Right Shift.
     52 */
     53#define GUAC_RDP_KEYSYM_RSHIFT 0xFFE2
     54
     55/**
     56 * The X11 keysym for Left Ctrl.
     57 */
     58#define GUAC_RDP_KEYSYM_LCTRL 0xFFE3
     59
     60/**
     61 * The X11 keysym for Right Ctrl.
     62 */
     63#define GUAC_RDP_KEYSYM_RCTRL 0xFFE4
     64
     65/**
     66 * The X11 keysym for Left Alt.
     67 */
     68#define GUAC_RDP_KEYSYM_LALT 0xFFE9
     69
     70/**
     71 * The X11 keysym for Right Alt.
     72 */
     73#define GUAC_RDP_KEYSYM_RALT 0xFFEA
     74
     75/**
     76 * The X11 keysym for AltGr.
     77 */
     78#define GUAC_RDP_KEYSYM_ALTGR 0xFE03
     79
     80/**
     81 * Bitwise flag value representing the Shift modifier.
     82 */
     83#define GUAC_RDP_KEYMAP_MODIFIER_SHIFT 1
     84
     85/**
     86 * Bitwise flag value representing the AltGr modifier.
     87 */
     88#define GUAC_RDP_KEYMAP_MODIFIER_ALTGR 2
     89
     90/**
     91 * Represents a keysym-to-scancode mapping for RDP, with extra information
     92 * about the state of prerequisite keysyms.
     93 */
     94typedef struct guac_rdp_keysym_desc {
     95
     96    /**
     97     * The keysym being mapped.
     98     */
     99    int keysym;
    100
    101    /**
    102     * The scancode this keysym maps to.
    103     */
    104    int scancode;
    105
    106    /**
    107     * Required RDP-specific flags that must be sent along with the scancode.
    108     */
    109    int flags;
    110
    111    /**
    112     * Bitwise-OR of the flags of any modifiers that must be active for the
    113     * associated scancode to be interpreted as this keysym.
    114     *
    115     * If the associated keysym is pressed, and any of these modifiers are not
    116     * currently active, Guacamole's RDP support must send additional events to
    117     * activate these modifiers prior to sending the scancode for this keysym.
    118     *
    119     * @see GUAC_RDP_KEYMAP_MODIFIER_SHIFT
    120     * @see GUAC_RDP_KEYMAP_MODIFIER_ALTGR
    121     */
    122    const unsigned int set_modifiers;
    123
    124    /**
    125     * Bitwise-OR of the flags of any modifiers that must NOT be active for the
    126     * associated scancode to be interpreted as this keysym.
    127     *
    128     * If the associated keysym is pressed, and any of these modifiers are
    129     * currently active, Guacamole's RDP support must send additional events to
    130     * deactivate these modifiers prior to sending the scancode for this
    131     * keysym.
    132     *
    133     * @see GUAC_RDP_KEYMAP_MODIFIER_SHIFT
    134     * @see GUAC_RDP_KEYMAP_MODIFIER_ALTGR
    135     */
    136    const unsigned int clear_modifiers;
    137
    138    /**
    139     * Bitwise OR of the flags of all lock keys (ie: Caps lock, Num lock, etc.)
    140     * which must be active for this keysym to be properly typed. Legal flags
    141     * are KBD_SYNC_SCROLL_LOCK, KBD_SYNC_NUM_LOCK, KBD_SYNC_CAPS_LOCK, and
    142     * KBD_SYNC_KANA_LOCK.
    143      */
    144    const unsigned int set_locks;
    145
    146    /**
    147     * Bitwise OR of the flags of all lock keys (ie: Caps lock, Num lock, etc.)
    148     * which must be inactive for this keysym to be properly typed. Legal flags
    149     * are KBD_SYNC_SCROLL_LOCK, KBD_SYNC_NUM_LOCK, KBD_SYNC_CAPS_LOCK, and
    150     * KBD_SYNC_KANA_LOCK.
    151     */
    152    const unsigned int clear_locks;
    153
    154} guac_rdp_keysym_desc;
    155
    156/**
    157 * Hierarchical keysym mapping
    158 */
    159typedef struct guac_rdp_keymap guac_rdp_keymap;
    160struct guac_rdp_keymap {
    161
    162    /**
    163     * The parent mapping this map will inherit its initial mapping from.
    164     * Any other mapping information will add to or override the mapping
    165     * inherited from the parent.
    166     */
    167    const guac_rdp_keymap* parent;
    168
    169    /**
    170     * Descriptive name of this keymap
    171     */
    172    const char* name;
    173
    174    /**
    175     * Null-terminated array of scancode mappings.
    176     */
    177    const guac_rdp_keysym_desc* mapping;
    178
    179    /**
    180     * FreeRDP keyboard layout associated with this
    181     * keymap. If this keymap is selected, this layout
    182     * will be requested from the server.
    183     */
    184    const UINT32 freerdp_keyboard_layout;
    185
    186};
    187
    188/**
    189 * The name of the default keymap, which MUST exist.
    190 */
    191#define GUAC_DEFAULT_KEYMAP "en-us-qwerty"
    192
    193/**
    194 * NULL-terminated array of all keymaps.
    195 */
    196extern const guac_rdp_keymap* GUAC_KEYMAPS[];
    197
    198/**
    199 * Return the keymap having the given name, if any, or NULL otherwise.
    200 *
    201 * @param name
    202 *     The name of the keymap to find.
    203 *
    204 * @return
    205 *     The keymap having the given name, or NULL if no such keymap exists.
    206 */
    207const guac_rdp_keymap* guac_rdp_keymap_find(const char* name);
    208
    209#endif
    210