Mouse.cpp revision 1b9094e9e0e2b6dc15ba937a7d4b14736aea339e
eb90548e8e40e597d65cdcc16ec958a3e09c1d73vboxsync/* $Revision$ */
eb90548e8e40e597d65cdcc16ec958a3e09c1d73vboxsync/** @file
eb90548e8e40e597d65cdcc16ec958a3e09c1d73vboxsync * VBoxGuestLibR0 - Mouse Integration.
eb90548e8e40e597d65cdcc16ec958a3e09c1d73vboxsync */
eb90548e8e40e597d65cdcc16ec958a3e09c1d73vboxsync
eb90548e8e40e597d65cdcc16ec958a3e09c1d73vboxsync/*
c58f1213e628a545081c70e26c6b67a841cff880vboxsync * Copyright (C) 2012 Oracle Corporation
eb90548e8e40e597d65cdcc16ec958a3e09c1d73vboxsync *
eb90548e8e40e597d65cdcc16ec958a3e09c1d73vboxsync * This file is part of VirtualBox Open Source Edition (OSE), as
eb90548e8e40e597d65cdcc16ec958a3e09c1d73vboxsync * available from http://www.virtualbox.org. This file is free software;
eb90548e8e40e597d65cdcc16ec958a3e09c1d73vboxsync * you can redistribute it and/or modify it under the terms of the GNU
eb90548e8e40e597d65cdcc16ec958a3e09c1d73vboxsync * General Public License (GPL) as published by the Free Software
eb90548e8e40e597d65cdcc16ec958a3e09c1d73vboxsync * Foundation, in version 2 as it comes in the "COPYING" file of the
eb90548e8e40e597d65cdcc16ec958a3e09c1d73vboxsync * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
eb90548e8e40e597d65cdcc16ec958a3e09c1d73vboxsync * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
eb90548e8e40e597d65cdcc16ec958a3e09c1d73vboxsync *
eb90548e8e40e597d65cdcc16ec958a3e09c1d73vboxsync * The contents of this file may alternatively be used under the terms
eb90548e8e40e597d65cdcc16ec958a3e09c1d73vboxsync * of the Common Development and Distribution License Version 1.0
eb90548e8e40e597d65cdcc16ec958a3e09c1d73vboxsync * (CDDL) only, as it comes in the "COPYING.CDDL" file of the
eb90548e8e40e597d65cdcc16ec958a3e09c1d73vboxsync * VirtualBox OSE distribution, in which case the provisions of the
eb90548e8e40e597d65cdcc16ec958a3e09c1d73vboxsync * CDDL are applicable instead of those of the GPL.
eb90548e8e40e597d65cdcc16ec958a3e09c1d73vboxsync *
43747b1f0bc8302a238fb35e55857a5e9aa1933dvboxsync * You may elect to license modified versions of this file under the
eb90548e8e40e597d65cdcc16ec958a3e09c1d73vboxsync * terms and conditions of either the GPL or the CDDL or both.
eb90548e8e40e597d65cdcc16ec958a3e09c1d73vboxsync */
eb90548e8e40e597d65cdcc16ec958a3e09c1d73vboxsync
ee4d840f54fd2dcea8a73b1b86d5ec0db370b05dvboxsync#include "VBGLInternal.h"
eb90548e8e40e597d65cdcc16ec958a3e09c1d73vboxsync
f5e53763b0a581b0299e98028c6c52192eb06785vboxsyncDECLVBGL(int) VbglSetMouseNotifyCallback(PFNVBOXGUESTMOUSENOTIFY pfnNotify,
eb90548e8e40e597d65cdcc16ec958a3e09c1d73vboxsync void *pvUser)
ee4d840f54fd2dcea8a73b1b86d5ec0db370b05dvboxsync{
eb90548e8e40e597d65cdcc16ec958a3e09c1d73vboxsync VBoxGuestMouseSetNotifyCallback NotifyCallback;
ee4d840f54fd2dcea8a73b1b86d5ec0db370b05dvboxsync VBGLDRIVER *pDriver;
eb90548e8e40e597d65cdcc16ec958a3e09c1d73vboxsync int rc;
ee4d840f54fd2dcea8a73b1b86d5ec0db370b05dvboxsync
eb90548e8e40e597d65cdcc16ec958a3e09c1d73vboxsync rc = vbglGetDriver(&pDriver);
eb90548e8e40e597d65cdcc16ec958a3e09c1d73vboxsync if (RT_FAILURE(rc))
a39ea3668b7019c23a68936259545f9b71bce1aavboxsync return rc;
ee4d840f54fd2dcea8a73b1b86d5ec0db370b05dvboxsync NotifyCallback.pfnNotify = pfnNotify;
eb90548e8e40e597d65cdcc16ec958a3e09c1d73vboxsync NotifyCallback.pvUser = pvUser;
eb90548e8e40e597d65cdcc16ec958a3e09c1d73vboxsync return vbglDriverIOCtl(pDriver, VBOXGUEST_IOCTL_SET_MOUSE_NOTIFY_CALLBACK,
eb90548e8e40e597d65cdcc16ec958a3e09c1d73vboxsync &NotifyCallback, sizeof(NotifyCallback));
eb90548e8e40e597d65cdcc16ec958a3e09c1d73vboxsync}
eb90548e8e40e597d65cdcc16ec958a3e09c1d73vboxsync
eb90548e8e40e597d65cdcc16ec958a3e09c1d73vboxsyncDECLVBGL(int) VbglGetMouseStatus(uint32_t *pfFeatures, uint32_t *px,
eb90548e8e40e597d65cdcc16ec958a3e09c1d73vboxsync uint32_t *py)
eb90548e8e40e597d65cdcc16ec958a3e09c1d73vboxsync{
eb90548e8e40e597d65cdcc16ec958a3e09c1d73vboxsync VMMDevReqMouseStatus Req;
eb90548e8e40e597d65cdcc16ec958a3e09c1d73vboxsync VBGLDRIVER *pDriver;
eb90548e8e40e597d65cdcc16ec958a3e09c1d73vboxsync int rc;
eb90548e8e40e597d65cdcc16ec958a3e09c1d73vboxsync
eb90548e8e40e597d65cdcc16ec958a3e09c1d73vboxsync rc = vbglGetDriver(&pDriver);
e74eef731a813e4e06680c587a6759b9974b29c9vboxsync if (RT_FAILURE(rc))
eb90548e8e40e597d65cdcc16ec958a3e09c1d73vboxsync return rc;
eb90548e8e40e597d65cdcc16ec958a3e09c1d73vboxsync vmmdevInitRequest(&Req.header, VMMDevReq_GetMouseStatus);
eb90548e8e40e597d65cdcc16ec958a3e09c1d73vboxsync Req.mouseFeatures = 0;
eb90548e8e40e597d65cdcc16ec958a3e09c1d73vboxsync Req.pointerXPos = 0;
eb90548e8e40e597d65cdcc16ec958a3e09c1d73vboxsync Req.pointerYPos = 0;
eb90548e8e40e597d65cdcc16ec958a3e09c1d73vboxsync rc = vbglDriverIOCtl(pDriver, VBOXGUEST_IOCTL_VMMREQUEST(sizeof(Req)),
eb90548e8e40e597d65cdcc16ec958a3e09c1d73vboxsync &Req.header, sizeof(Req));
c28fa006ba669ad8f26ae31d00a338379c04ea1bvboxsync if (RT_FAILURE(rc))
eb90548e8e40e597d65cdcc16ec958a3e09c1d73vboxsync return rc;
e74eef731a813e4e06680c587a6759b9974b29c9vboxsync if (pfFeatures)
e74eef731a813e4e06680c587a6759b9974b29c9vboxsync *pfFeatures = Req.mouseFeatures;
eb90548e8e40e597d65cdcc16ec958a3e09c1d73vboxsync if (px)
eb90548e8e40e597d65cdcc16ec958a3e09c1d73vboxsync *px = Req.pointerXPos;
eb90548e8e40e597d65cdcc16ec958a3e09c1d73vboxsync if (py)
eb90548e8e40e597d65cdcc16ec958a3e09c1d73vboxsync *py = Req.pointerYPos;
eb90548e8e40e597d65cdcc16ec958a3e09c1d73vboxsync return VINF_SUCCESS;
eb90548e8e40e597d65cdcc16ec958a3e09c1d73vboxsync}
eb90548e8e40e597d65cdcc16ec958a3e09c1d73vboxsync
eb90548e8e40e597d65cdcc16ec958a3e09c1d73vboxsyncDECLVBGL(int) VbglSetMouseStatus(uint32_t fFeatures)
eb90548e8e40e597d65cdcc16ec958a3e09c1d73vboxsync{
c28fa006ba669ad8f26ae31d00a338379c04ea1bvboxsync VBGLDRIVER *pDriver;
eb90548e8e40e597d65cdcc16ec958a3e09c1d73vboxsync int rc;
eb90548e8e40e597d65cdcc16ec958a3e09c1d73vboxsync
eb90548e8e40e597d65cdcc16ec958a3e09c1d73vboxsync rc = vbglGetDriver(&pDriver);
eb90548e8e40e597d65cdcc16ec958a3e09c1d73vboxsync if (RT_FAILURE(rc))
eb90548e8e40e597d65cdcc16ec958a3e09c1d73vboxsync return rc;
ad77e3ec3cde24263bc7537575f5cae442bee3b1vboxsync return vbglDriverIOCtl(pDriver, VBOXGUEST_IOCTL_SET_MOUSE_STATUS,
eb90548e8e40e597d65cdcc16ec958a3e09c1d73vboxsync &fFeatures, sizeof(fFeatures));
eb90548e8e40e597d65cdcc16ec958a3e09c1d73vboxsync}
eb90548e8e40e597d65cdcc16ec958a3e09c1d73vboxsync