cscg24-guacamole

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

rdpei.h (4942B)


      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_CHANNELS_RDPEI_H
     21#define GUAC_RDP_CHANNELS_RDPEI_H
     22
     23#include "settings.h"
     24
     25#include <freerdp/client/rdpei.h>
     26#include <freerdp/freerdp.h>
     27#include <guacamole/client.h>
     28#include <guacamole/timestamp.h>
     29
     30/**
     31 * The maximum number of simultaneously-tracked touches.
     32 */
     33#define GUAC_RDP_RDPEI_MAX_TOUCHES 10
     34
     35/**
     36 * A single, tracked touch contact.
     37 */
     38typedef struct guac_rdp_rdpei_touch {
     39
     40    /**
     41     * Whether this touch is active (1) or inactive (0). An active touch is
     42     * being tracked, while an inactive touch is simple an empty space awaiting
     43     * use by some future touch event.
     44     */
     45    int active;
     46
     47    /**
     48     * The unique ID representing this touch contact.
     49     */
     50    int id;
     51
     52    /**
     53     * The X-coordinate of this touch, in pixels.
     54     */
     55    int x;
     56
     57    /**
     58     * The Y-coordinate of this touch, in pixels.
     59     */
     60    int y;
     61
     62} guac_rdp_rdpei_touch;
     63
     64/**
     65 * Multi-touch input module.
     66 */
     67typedef struct guac_rdp_rdpei {
     68
     69    /**
     70     * The guac_client instance handling the relevant RDP connection.
     71     */
     72    guac_client* client;
     73
     74    /**
     75     * RDPEI control interface.
     76     */
     77    RdpeiClientContext* rdpei;
     78
     79    /**
     80     * All currently-tracked touches.
     81     */
     82    guac_rdp_rdpei_touch touch[GUAC_RDP_RDPEI_MAX_TOUCHES];
     83
     84} guac_rdp_rdpei;
     85
     86/**
     87 * Allocates a new RDPEI module, which will ultimately control the RDPEI
     88 * channel once connected. The RDPEI channel allows multi-touch input
     89 * events to be sent to the RDP server.
     90 *
     91 * @param client
     92 *     The guac_client instance handling the relevant RDP connection.
     93 *
     94 * @return
     95 *     A newly-allocated RDPEI module.
     96 */
     97guac_rdp_rdpei* guac_rdp_rdpei_alloc(guac_client* client);
     98
     99/**
    100 * Frees the resources associated with support for the RDPEI channel. Only
    101 * resources specific to Guacamole are freed. Resources specific to FreeRDP's
    102 * handling of the RDPEI channel will be freed by FreeRDP. If no resources are
    103 * currently allocated for RDPEI, this function has no effect.
    104 *
    105 * @param rdpei
    106 *     The RDPEI module to free.
    107 */
    108void guac_rdp_rdpei_free(guac_rdp_rdpei* rdpei);
    109
    110/**
    111 * Adds FreeRDP's "rdpei" plugin to the list of dynamic virtual channel plugins
    112 * to be loaded by FreeRDP's "drdynvc" plugin. The context of the plugin will
    113 * automatically be associated with the guac_rdp_rdpei instance pointed to by the
    114 * current guac_rdp_client. The plugin will only be loaded once the "drdynvc"
    115 * plugin is loaded. The "rdpei" plugin ultimately adds support for multi-touch
    116 * input via the RDPEI channel.
    117 *
    118 * If failures occur, messages noting the specifics of those failures will be
    119 * logged, and the RDP side of multi-touch support will not be functional.
    120 *
    121 * This MUST be called within the PreConnect callback of the freerdp instance
    122 * for multi-touch support to be loaded.
    123 *
    124 * @param context
    125 *     The rdpContext associated with the active RDP session.
    126 */
    127void guac_rdp_rdpei_load_plugin(rdpContext* context);
    128
    129/**
    130 * Reports to the RDP server that the status of a single touch contact has
    131 * changed. Depending on the amount of force associated with the touch and
    132 * whether the touch has been encountered before, this will result a new touch
    133 * contact, updates to an existing contact, or removal of an existing contact.
    134 * If the RDPEI channel has not yet been connected, touches will be ignored and
    135 * dropped until it is connected.
    136 *
    137 * @param rdpei
    138 *     The RDPEI module associated with the RDP session.
    139 *
    140 * @param id
    141 *     An arbitrary integer ID unique to the touch being updated.
    142 *
    143 * @param x
    144 *     The X-coordinate of the touch, in pixels.
    145 *
    146 * @param y
    147 *     The Y-coordinate of the touch, in pixels.
    148 *
    149 * @param force
    150 *     The amount of force currently being exerted on the device by the touch
    151 *     contact in question, where 1.0 is the maximum amount of force
    152 *     representable and 0.0 indicates the contact has been lifted.
    153 *
    154 * @return
    155 *     Zero if the touch event was successfully processed, non-zero if the
    156 *     touch event had to be dropped.
    157 */
    158int guac_rdp_rdpei_touch_update(guac_rdp_rdpei* rdpei, int id, int x, int y,
    159        double force);
    160
    161#endif
    162