diff --git a/hw/xquartz/darwin.c b/hw/xquartz/darwin.c index 6f4719453..f20cce127 100644 --- a/hw/xquartz/darwin.c +++ b/hw/xquartz/darwin.c @@ -1,10 +1,9 @@ /************************************************************** * - * Shared code for the Darwin X Server - * running with Quartz or IOKit display mode + * Xquartz initialization code * + * Copyright (c) 2007-2008 Apple Inc. * Copyright (c) 2001-2004 Torrey T. Lyons. All Rights Reserved. - * Copyright (c) 2007 Apple Inc. * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), @@ -112,6 +111,7 @@ int darwinFakeMouse3Mask = NX_COMMANDMASK; // devices DeviceIntPtr darwinPointer = NULL; +DeviceIntPtr darwinTablet = NULL; DeviceIntPtr darwinKeyboard = NULL; // Common pixmap formats @@ -332,14 +332,13 @@ static void DarwinChangePointerControl( #endif /* - * DarwinMouseProc - * Handle the initialization, etc. of a mouse + * DarwinMouseProc: Handle the initialization, etc. of a mouse */ static int DarwinMouseProc(DeviceIntPtr pPointer, int what) { + // 7 buttons: left, right, middle, then four scroll wheel "buttons" CARD8 map[8] = {0, 1, 2, 3, 4, 5, 6, 7}; switch (what) { - case DEVICE_INIT: pPointer->public.on = FALSE; @@ -347,15 +346,13 @@ static int DarwinMouseProc(DeviceIntPtr pPointer, int what) { InitPointerDeviceStruct((DevicePtr)pPointer, map, 7, GetMotionHistory, (PtrCtrlProcPtr)NoopDDA, - GetMotionHistorySize(), 7); - InitProximityClassDeviceStruct(pPointer); + GetMotionHistorySize(), 2); + pPointer->name = strdup("Quartz Pointing Device"); break; - case DEVICE_ON: pPointer->public.on = TRUE; AddEnabledDevice( darwinEventReadFD ); return Success; - case DEVICE_CLOSE: case DEVICE_OFF: pPointer->public.on = FALSE; @@ -366,6 +363,34 @@ static int DarwinMouseProc(DeviceIntPtr pPointer, int what) { return Success; } +static int DarwinTabletProc(DeviceIntPtr pPointer, int what) { + CARD8 map[4] = {0, 1, 2, 3}; + + switch (what) { + case DEVICE_INIT: + pPointer->public.on = FALSE; + + // Set button map. + InitPointerDeviceStruct((DevicePtr)pPointer, map, 3, + GetMotionHistory, + (PtrCtrlProcPtr)NoopDDA, + GetMotionHistorySize(), 7); + InitProximityClassDeviceStruct(pPointer); +// InitAbsoluteClassDeviceStruct(pPointer); + pPointer->name = strdup("pen"); + break; + case DEVICE_ON: + pPointer->public.on = TRUE; + AddEnabledDevice( darwinEventReadFD ); + return Success; + case DEVICE_CLOSE: + case DEVICE_OFF: + pPointer->public.on = FALSE; + RemoveEnabledDevice(darwinEventReadFD); + return Success; + } + return Success; +} /* * DarwinKeybdProc @@ -376,6 +401,7 @@ static int DarwinKeybdProc( DeviceIntPtr pDev, int onoff ) switch ( onoff ) { case DEVICE_INIT: DarwinKeyboardInit( pDev ); + pDev->name = strdup("Quartz Keyboard"); break; case DEVICE_ON: pDev->public.on = TRUE; @@ -499,9 +525,11 @@ int DarwinParseModifierList( void InitInput( int argc, char **argv ) { darwinPointer = AddInputDevice(DarwinMouseProc, TRUE); - darwinPointer->name = strdup("tablet"); RegisterPointerDevice( darwinPointer ); + darwinTablet = AddInputDevice(DarwinTabletProc, TRUE); + RegisterPointerDevice( darwinTablet ); + darwinKeyboard = AddInputDevice(DarwinKeybdProc, TRUE); RegisterKeyboardDevice( darwinKeyboard ); diff --git a/hw/xquartz/darwin.h b/hw/xquartz/darwin.h index 6d2fbd0e5..4300b9fc0 100644 --- a/hw/xquartz/darwin.h +++ b/hw/xquartz/darwin.h @@ -71,6 +71,7 @@ extern io_connect_t darwinParamConnect; extern int darwinEventReadFD; extern int darwinEventWriteFD; extern DeviceIntPtr darwinPointer; +extern DeviceIntPtr darwinTablet; extern DeviceIntPtr darwinKeyboard; // User preferences diff --git a/hw/xquartz/darwinEvents.c b/hw/xquartz/darwinEvents.c index e25ae84eb..7b3091d40 100644 --- a/hw/xquartz/darwinEvents.c +++ b/hw/xquartz/darwinEvents.c @@ -365,7 +365,8 @@ void DarwinSendPointerEvents(int ev_type, int ev_button, int pointer_x, int poin static int darwinFakeMouseButtonDown = 0; static int darwinFakeMouseButtonMask = 0; int i, num_events; - + DeviceIntPtr dev; + // DEBUG_LOG("x=%d, y=%d, p=%f, tx=%f, ty=%f\n", pointer_x, pointer_y, pressure, tilt_x, tilt_y); if(!darwinEvents) { @@ -376,7 +377,10 @@ void DarwinSendPointerEvents(int ev_type, int ev_button, int pointer_x, int poin int valuators[5] = {pointer_x, pointer_y, pressure * SCALEFACTOR_PRESSURE, tilt_x * SCALEFACTOR_TILT, tilt_y * SCALEFACTOR_TILT}; - DEBUG_LOG("Valuators: {%d,%d,%d,%d,%d}\n", + if (pressure == 0 && tilt_x == 0 && tilt_y == 0) dev = darwinPointer; + else dev = darwinTablet; + + DEBUG_LOG("Valuators: {%d,%d,%d,%d,%d}\n", valuators[0], valuators[1], valuators[2], valuators[3], valuators[4]); if (ev_type == ButtonPress && darwinFakeButtons && ev_button == 1) { // Mimic multi-button mouse with modifier-clicks @@ -410,9 +414,9 @@ void DarwinSendPointerEvents(int ev_type, int ev_button, int pointer_x, int poin } mieqEnqueue_lock(); { - num_events = GetPointerEvents(darwinEvents, darwinPointer, ev_type, ev_button, - POINTER_ABSOLUTE, 0, 5, valuators); - for(i=0; i