VirtualBox

source: vbox/trunk/src/VBox/Additions/common/VBoxGuest/lib/VBoxGuestR0LibMouse.cpp@ 74526

Last change on this file since 74526 was 72627, checked in by vboxsync, 6 years ago

Additions: relicence components needed for Linux shared folders to MIT.
bugref:9109: Shared folders: update to match in-kernel code more closely
This change makes the code on which the Linux kernel shared folder patch is
based MIT-licenced, so that the version in the Linux kernel can be too. This
would make it easier to move code back and forth.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 4.6 KB
Line 
1/* $Id: VBoxGuestR0LibMouse.cpp 72627 2018-06-20 13:53:28Z vboxsync $ */
2/** @file
3 * VBoxGuestLibR0 - Mouse Integration.
4 */
5
6/*
7 * Copyright (C) 2012-2018 Oracle Corporation
8 *
9 * Permission is hereby granted, free of charge, to any person
10 * obtaining a copy of this software and associated documentation
11 * files (the "Software"), to deal in the Software without
12 * restriction, including without limitation the rights to use,
13 * copy, modify, merge, publish, distribute, sublicense, and/or sell
14 * copies of the Software, and to permit persons to whom the
15 * Software is furnished to do so, subject to the following
16 * conditions:
17 *
18 * The above copyright notice and this permission notice shall be
19 * included in all copies or substantial portions of the Software.
20 *
21 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
22 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
23 * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
24 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
25 * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
26 * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
27 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
28 * OTHER DEALINGS IN THE SOFTWARE.
29 */
30
31
32/*********************************************************************************************************************************
33* Header Files *
34*********************************************************************************************************************************/
35#include "VBoxGuestR0LibInternal.h"
36#ifdef VBGL_VBOXGUEST
37# error "This file shouldn't be part of the VBoxGuestR0LibBase library that is linked into VBoxGuest. It's client code."
38#endif
39
40
41/**
42 * Sets the function which is called back on each mouse pointer event. Only
43 * one callback can be active at once, so if you need several for any reason
44 * you must multiplex yourself. Call backs can be disabled by passing NULL
45 * as the function pointer.
46 *
47 * @remarks Ring-0.
48 * @returns iprt status code.
49 * @returns VERR_TRY_AGAIN if the main guest driver hasn't finished
50 * initialising.
51 *
52 * @param pfnNotify the function to call back. NULL to disable call backs.
53 * @param pvUser user supplied data/cookie to be passed to the function.
54 */
55DECLR0VBGL(int) VbglR0SetMouseNotifyCallback(PFNVBOXGUESTMOUSENOTIFY pfnNotify, void *pvUser)
56{
57 PVBGLIDCHANDLE pIdcHandle;
58 int rc = vbglR0QueryIdcHandle(&pIdcHandle);
59 if (RT_SUCCESS(rc))
60 {
61 VBGLIOCSETMOUSENOTIFYCALLBACK NotifyCallback;
62 VBGLREQHDR_INIT(&NotifyCallback.Hdr, SET_MOUSE_NOTIFY_CALLBACK);
63 NotifyCallback.u.In.pfnNotify = pfnNotify;
64 NotifyCallback.u.In.pvUser = pvUser;
65 rc = VbglR0IdcCall(pIdcHandle, VBGL_IOCTL_SET_MOUSE_NOTIFY_CALLBACK, &NotifyCallback.Hdr, sizeof(NotifyCallback));
66 }
67 return rc;
68}
69
70
71/**
72 * Retrieve mouse coordinates and features from the host.
73 *
74 * @remarks Ring-0.
75 * @returns VBox status code.
76 *
77 * @param pfFeatures Where to store the mouse features.
78 * @param px Where to store the X co-ordinate.
79 * @param py Where to store the Y co-ordinate.
80 */
81DECLR0VBGL(int) VbglR0GetMouseStatus(uint32_t *pfFeatures, uint32_t *px, uint32_t *py)
82{
83 PVBGLIDCHANDLE pIdcHandle;
84 int rc = vbglR0QueryIdcHandle(&pIdcHandle);
85 if (RT_SUCCESS(rc))
86 {
87 VMMDevReqMouseStatus Req;
88 VMMDEV_REQ_HDR_INIT(&Req.header, sizeof(Req), VMMDevReq_GetMouseStatus);
89 Req.mouseFeatures = 0;
90 Req.pointerXPos = 0;
91 Req.pointerYPos = 0;
92 rc = VbglR0IdcCall(pIdcHandle, VBGL_IOCTL_VMMDEV_REQUEST(sizeof(Req)), (PVBGLREQHDR)&Req.header, sizeof(Req));
93 if (RT_SUCCESS(rc))
94 {
95 if (pfFeatures)
96 *pfFeatures = Req.mouseFeatures;
97 if (px)
98 *px = Req.pointerXPos;
99 if (py)
100 *py = Req.pointerYPos;
101 }
102 }
103 return rc;
104}
105
106
107/**
108 * Send mouse features to the host.
109 *
110 * @remarks Ring-0.
111 * @returns VBox status code.
112 *
113 * @param fFeatures Supported mouse pointer features. The main guest driver
114 * will mediate different callers and show the host any
115 * feature enabled by any guest caller.
116 */
117DECLR0VBGL(int) VbglR0SetMouseStatus(uint32_t fFeatures)
118{
119 PVBGLIDCHANDLE pIdcHandle;
120 int rc = vbglR0QueryIdcHandle(&pIdcHandle);
121 if (RT_SUCCESS(rc))
122 {
123 VBGLIOCSETMOUSESTATUS Req;
124 VBGLREQHDR_INIT(&Req.Hdr, SET_MOUSE_STATUS);
125 Req.u.In.fStatus = fFeatures;
126 rc = VbglR0IdcCall(pIdcHandle, VBGL_IOCTL_SET_MOUSE_STATUS, &Req.Hdr, sizeof(Req));
127 }
128 return rc;
129}
130
Note: See TracBrowser for help on using the repository browser.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette