xquartz: created darwinTablet, to represent tablet events

(cherry picked from commit 50641bce73)
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
* 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 );

View File

@ -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

View File

@ -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<num_events; i++) mieqEnqueue (darwinPointer,&darwinEvents[i]);
num_events = GetPointerEvents(darwinEvents, dev, ev_type, ev_button,
POINTER_ABSOLUTE, 0, dev==darwinTablet?5:2, valuators);
for(i=0; i<num_events; i++) mieqEnqueue (dev,&darwinEvents[i]);
DarwinPokeEQ();
} mieqEnqueue_unlock();
@ -460,9 +464,9 @@ void DarwinSendProximityEvents(int ev_type, int pointer_x, int pointer_y) {
}
mieqEnqueue_lock(); {
num_events = GetProximityEvents(darwinEvents, darwinPointer, ev_type,
num_events = GetProximityEvents(darwinEvents, darwinTablet, ev_type,
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();
} mieqEnqueue_unlock();
}