vmmouse_detect.c revision d075918c
1d075918cSmrg/* 2d075918cSmrg * Copyright 2007 by VMware, Inc. 3d075918cSmrg * 4d075918cSmrg * Permission is hereby granted, free of charge, to any person obtaining a 5d075918cSmrg * copy of this software and associated documentation files (the "Software"), 6d075918cSmrg * to deal in the Software without restriction, including without limitation 7d075918cSmrg * the rights to use, copy, modify, merge, publish, distribute, sublicense, 8d075918cSmrg * and/or sell copies of the Software, and to permit persons to whom the 9d075918cSmrg * Software is furnished to do so, subject to the following conditions: 10d075918cSmrg * 11d075918cSmrg * The above copyright notice and this permission notice shall be included in 12d075918cSmrg * all copies or substantial portions of the Software. 13d075918cSmrg * 14d075918cSmrg * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15d075918cSmrg * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16d075918cSmrg * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 17d075918cSmrg * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR 18d075918cSmrg * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, 19d075918cSmrg * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 20d075918cSmrg * OTHER DEALINGS IN THE SOFTWARE. 21d075918cSmrg * 22d075918cSmrg * Except as contained in this notice, the name of the copyright holder(s) 23d075918cSmrg * and author(s) shall not be used in advertising or otherwise to promote 24d075918cSmrg * the sale, use or other dealings in this Software without prior written 25d075918cSmrg * authorization from the copyright holder(s) and author(s). 26d075918cSmrg */ 27d075918cSmrg 28d075918cSmrg 29d075918cSmrg#include <stdlib.h> 30d075918cSmrg#include <signal.h> 31d075918cSmrg#include "vmmouse_client.h" 32d075918cSmrg 33d075918cSmrg#ifdef HAVE_CONFIG_H 34d075918cSmrg#include "config.h" 35d075918cSmrg#endif 36d075918cSmrg 37d075918cSmrgvoid 38d075918cSmrgsegvCB(int sig) 39d075918cSmrg{ 40d075918cSmrg#if defined HAVE_XORG_SERVER_1_1_0 41d075918cSmrg exit(1); 42d075918cSmrg#endif 43d075918cSmrg} 44d075918cSmrg 45d075918cSmrg 46d075918cSmrgint 47d075918cSmrgmain(void) 48d075918cSmrg{ 49d075918cSmrg /* 50d075918cSmrg * If the vmmouse test is not run in a VMware virtual machine, it 51d075918cSmrg * will segfault instead of successfully accessing the port. 52d075918cSmrg */ 53d075918cSmrg signal(SIGSEGV, segvCB); 54d075918cSmrg 55d075918cSmrg#if defined __i386__ || defined __x86_64__ 56d075918cSmrg if (VMMouseClient_Enable()) { 57d075918cSmrg VMMouseClient_Disable(); 58d075918cSmrg return 0; 59d075918cSmrg } else { 60d075918cSmrg /* 61d075918cSmrg * We get here if we are running in a VM and the vmmouse 62d075918cSmrg * device is disabled. 63d075918cSmrg */ 64d075918cSmrg return 1; 65d075918cSmrg } 66d075918cSmrg#endif 67d075918cSmrg return 1; 68d075918cSmrg} 69