source: mainline/uspace/srv/hid/rfb/rfb.h@ bd0e6a1

lfn serial ticket/834-toolchain-update topic/msim-upgrade topic/simplify-dev-export
Last change on this file since bd0e6a1 was bd0e6a1, checked in by Martin Sucha <sucha14@…>, 12 years ago

Add a simple remote framebuffer (VNC) server

  • Property mode set to 100644
File size: 3.9 KB
Line 
1/*
2 * Copyright (c) 2013 Martin Sucha
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#ifndef RFB_H__
30#define RFB_H__
31
32#include <io/pixelmap.h>
33#include <fibril_synch.h>
34
35#define RFB_SECURITY_NONE 1
36#define RFB_SECURITY_HANDSHAKE_OK 0
37
38#define RFB_CMSG_SET_PIXEL_FORMAT 0
39#define RFB_CMSG_SET_ENCODINGS 2
40#define RFB_CMSG_FRAMEBUFFER_UPDATE_REQUEST 3
41#define RFB_CMSG_KEY_EVENT 4
42#define RFB_CMSG_POINTER_EVENT 5
43#define RFB_CMSG_CLIENT_CUT_TEXT 6
44
45#define RFB_SMSG_FRAMEBUFFER_UPDATE 0
46#define RFB_SMSG_SET_COLOR_MAP_ENTRIES 1
47#define RFB_SMSG_BELL 2
48#define RFB_SMSG_SERVER_CUT_TEXT 3
49
50#define RFB_ENCODING_RAW 0
51
52typedef struct {
53 uint8_t bpp;
54 uint8_t depth;
55 uint8_t big_endian;
56 uint8_t true_color;
57 uint16_t r_max;
58 uint16_t g_max;
59 uint16_t b_max;
60 uint8_t r_shift;
61 uint8_t g_shift;
62 uint8_t b_shift;
63 uint8_t pad[3];
64} __attribute__((packed)) rfb_pixel_format_t;
65
66typedef struct {
67 uint16_t width;
68 uint16_t height;
69 rfb_pixel_format_t pixel_format;
70 uint32_t name_length;
71 char name[0];
72} __attribute__((packed)) rfb_server_init_t;
73
74typedef struct {
75 uint8_t message_type;
76 uint8_t pad[3];
77 rfb_pixel_format_t pixel_format;
78} __attribute__((packed)) rfb_set_pixel_format_t;
79
80typedef struct {
81 uint8_t message_type;
82 uint8_t pad;
83 uint16_t count;
84} __attribute__((packed)) rfb_set_encodings_t;
85
86typedef struct {
87 uint8_t message_type;
88 uint8_t incremental;
89 uint16_t x;
90 uint16_t y;
91 uint16_t width;
92 uint16_t height;
93} __attribute__((packed)) rfb_framebuffer_update_request_t;
94
95typedef struct {
96 uint8_t message_type;
97 uint8_t down_flag;
98 uint8_t pad[2];
99 uint32_t key;
100} __attribute__((packed)) rfb_key_event_t;
101
102typedef struct {
103 uint8_t message_type;
104 uint8_t button_mask;
105 uint16_t x;
106 uint16_t y;
107} __attribute__((packed)) rfb_pointer_event_t;
108
109typedef struct {
110 uint8_t message_type;
111 uint8_t pad;
112 uint32_t length;
113 char text[0];
114} __attribute__((packed)) rfb_client_cut_text_t;
115
116typedef struct {
117 uint16_t x;
118 uint16_t y;
119 uint16_t width;
120 uint16_t height;
121 int32_t enctype;
122 uint8_t data[0];
123} __attribute__((packed)) rfb_rectangle_t;
124
125typedef struct {
126 uint8_t message_type;
127 uint8_t pad;
128 uint16_t rect_count;
129} __attribute__((packed)) rfb_framebuffer_update_t;
130
131typedef struct {
132 uint16_t width;
133 uint16_t height;
134 rfb_pixel_format_t pixel_format;
135 const char *name;
136 int listen_sd;
137 pixelmap_t framebuffer;
138 rfb_rectangle_t damage_rect;
139 bool damage_valid;
140 fibril_mutex_t lock;
141} rfb_t;
142
143
144extern int rfb_init(rfb_t *, uint16_t, uint16_t);
145extern int rfb_set_size(rfb_t *, uint16_t, uint16_t);
146extern int rfb_listen(rfb_t *, uint16_t);
147extern void rfb_accept(rfb_t *);
148
149#endif
Note: See TracBrowser for help on using the repository browser.