xquartz: created darwinTablet, to represent tablet events

(cherry picked from commit 50641bce730ee03738fa0c4beb8125b34fda556f)
This commit is contained in:
Ben Byer 2008-04-29 23:37:58 -07:00 committed by Jeremy Huddleston
parent 519581b0ba
commit b71b51c982
3 changed files with 51 additions and 18 deletions

View File

@ -1,10 +1,9 @@
/************************************************************** /**************************************************************
* *
* Shared code for the Darwin X Server * Xquartz initialization code
* running with Quartz or IOKit display mode
* *
* Copyright (c) 2007-2008 Apple Inc.
* Copyright (c) 2001-2004 Torrey T. Lyons. All Rights Reserved. * 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 * Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"), * copy of this software and associated documentation files (the "Software"),
@ -112,6 +111,7 @@ int darwinFakeMouse3Mask = NX_COMMANDMASK;
// devices // devices
DeviceIntPtr darwinPointer = NULL; DeviceIntPtr darwinPointer = NULL;
DeviceIntPtr darwinTablet = NULL;
DeviceIntPtr darwinKeyboard = NULL; DeviceIntPtr darwinKeyboard = NULL;
// Common pixmap formats // Common pixmap formats
@ -332,14 +332,13 @@ static void DarwinChangePointerControl(
#endif #endif
/* /*
* DarwinMouseProc * DarwinMouseProc: Handle the initialization, etc. of a mouse
* Handle the initialization, etc. of a mouse
*/ */
static int DarwinMouseProc(DeviceIntPtr pPointer, int what) { 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}; CARD8 map[8] = {0, 1, 2, 3, 4, 5, 6, 7};
switch (what) { switch (what) {
case DEVICE_INIT: case DEVICE_INIT:
pPointer->public.on = FALSE; pPointer->public.on = FALSE;
@ -347,15 +346,13 @@ static int DarwinMouseProc(DeviceIntPtr pPointer, int what) {
InitPointerDeviceStruct((DevicePtr)pPointer, map, 7, InitPointerDeviceStruct((DevicePtr)pPointer, map, 7,
GetMotionHistory, GetMotionHistory,
(PtrCtrlProcPtr)NoopDDA, (PtrCtrlProcPtr)NoopDDA,
GetMotionHistorySize(), 7); GetMotionHistorySize(), 2);
InitProximityClassDeviceStruct(pPointer); pPointer->name = strdup("Quartz Pointing Device");
break; break;
case DEVICE_ON: case DEVICE_ON:
pPointer->public.on = TRUE; pPointer->public.on = TRUE;
AddEnabledDevice( darwinEventReadFD ); AddEnabledDevice( darwinEventReadFD );
return Success; return Success;
case DEVICE_CLOSE: case DEVICE_CLOSE:
case DEVICE_OFF: case DEVICE_OFF:
pPointer->public.on = FALSE; pPointer->public.on = FALSE;
@ -366,6 +363,34 @@ static int DarwinMouseProc(DeviceIntPtr pPointer, int what) {
return Success; 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 * DarwinKeybdProc
@ -376,6 +401,7 @@ static int DarwinKeybdProc( DeviceIntPtr pDev, int onoff )
switch ( onoff ) { switch ( onoff ) {
case DEVICE_INIT: case DEVICE_INIT:
DarwinKeyboardInit( pDev ); DarwinKeyboardInit( pDev );
pDev->name = strdup("Quartz Keyboard");
break; break;
case DEVICE_ON: case DEVICE_ON:
pDev->public.on = TRUE; pDev->public.on = TRUE;
@ -499,9 +525,11 @@ int DarwinParseModifierList(
void InitInput( int argc, char **argv ) void InitInput( int argc, char **argv )
{ {
darwinPointer = AddInputDevice(DarwinMouseProc, TRUE); darwinPointer = AddInputDevice(DarwinMouseProc, TRUE);
darwinPointer->name = strdup("tablet");
RegisterPointerDevice( darwinPointer ); RegisterPointerDevice( darwinPointer );
darwinTablet = AddInputDevice(DarwinTabletProc, TRUE);
RegisterPointerDevice( darwinTablet );
darwinKeyboard = AddInputDevice(DarwinKeybdProc, TRUE); darwinKeyboard = AddInputDevice(DarwinKeybdProc, TRUE);
RegisterKeyboardDevice( darwinKeyboard ); RegisterKeyboardDevice( darwinKeyboard );

View File

@ -71,6 +71,7 @@ extern io_connect_t darwinParamConnect;
extern int darwinEventReadFD; extern int darwinEventReadFD;
extern int darwinEventWriteFD; extern int darwinEventWriteFD;
extern DeviceIntPtr darwinPointer; extern DeviceIntPtr darwinPointer;
extern DeviceIntPtr darwinTablet;
extern DeviceIntPtr darwinKeyboard; extern DeviceIntPtr darwinKeyboard;
// User preferences // User preferences

View File

@ -365,6 +365,7 @@ void DarwinSendPointerEvents(int ev_type, int ev_button, int pointer_x, int poin
static int darwinFakeMouseButtonDown = 0; static int darwinFakeMouseButtonDown = 0;
static int darwinFakeMouseButtonMask = 0; static int darwinFakeMouseButtonMask = 0;
int i, num_events; 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); // DEBUG_LOG("x=%d, y=%d, p=%f, tx=%f, ty=%f\n", pointer_x, pointer_y, pressure, tilt_x, tilt_y);
@ -376,6 +377,9 @@ void DarwinSendPointerEvents(int ev_type, int ev_button, int pointer_x, int poin
int valuators[5] = {pointer_x, pointer_y, pressure * SCALEFACTOR_PRESSURE, int valuators[5] = {pointer_x, pointer_y, pressure * SCALEFACTOR_PRESSURE,
tilt_x * SCALEFACTOR_TILT, tilt_y * SCALEFACTOR_TILT}; tilt_x * SCALEFACTOR_TILT, tilt_y * SCALEFACTOR_TILT};
if (pressure == 0 && tilt_x == 0 && tilt_y == 0) dev = darwinPointer;
else dev = darwinTablet;
DEBUG_LOG("Valuators: {%d,%d,%d,%d,%d}\n", DEBUG_LOG("Valuators: {%d,%d,%d,%d,%d}\n",
valuators[0], valuators[1], valuators[2], valuators[3], valuators[4]); valuators[0], valuators[1], valuators[2], valuators[3], valuators[4]);
if (ev_type == ButtonPress && darwinFakeButtons && ev_button == 1) { if (ev_type == ButtonPress && darwinFakeButtons && ev_button == 1) {
@ -410,9 +414,9 @@ void DarwinSendPointerEvents(int ev_type, int ev_button, int pointer_x, int poin
} }
mieqEnqueue_lock(); { mieqEnqueue_lock(); {
num_events = GetPointerEvents(darwinEvents, darwinPointer, ev_type, ev_button, num_events = GetPointerEvents(darwinEvents, dev, ev_type, ev_button,
POINTER_ABSOLUTE, 0, 5, valuators); POINTER_ABSOLUTE, 0, dev==darwinTablet?5:2, valuators);
for(i=0; i<num_events; i++) mieqEnqueue (darwinPointer,&darwinEvents[i]); for(i=0; i<num_events; i++) mieqEnqueue (dev,&darwinEvents[i]);
DarwinPokeEQ(); DarwinPokeEQ();
} mieqEnqueue_unlock(); } mieqEnqueue_unlock();
@ -460,9 +464,9 @@ void DarwinSendProximityEvents(int ev_type, int pointer_x, int pointer_y) {
} }
mieqEnqueue_lock(); { mieqEnqueue_lock(); {
num_events = GetProximityEvents(darwinEvents, darwinPointer, ev_type, num_events = GetProximityEvents(darwinEvents, darwinTablet, ev_type,
0, 5, valuators); 0, 5, valuators);
for(i=0; i<num_events; i++) mieqEnqueue (darwinPointer,&darwinEvents[i]); for(i=0; i<num_events; i++) mieqEnqueue (darwinTablet,&darwinEvents[i]);
DarwinPokeEQ(); DarwinPokeEQ();
} mieqEnqueue_unlock(); } mieqEnqueue_unlock();
} }