Skip to content

Commit

Permalink
More cleanups, still no luck on ignoring motion when there are scroll…
Browse files Browse the repository at this point in the history
… events

 on a two-finger-scroll trackpad.
  • Loading branch information
icculus committed Aug 3, 2006
1 parent 5a58042 commit dfeb43e
Showing 1 changed file with 29 additions and 8 deletions.
37 changes: 29 additions & 8 deletions macosx_hidmanager.c
Expand Up @@ -139,6 +139,7 @@ struct recDevice
long wheels; // number of wheels (calculated, not reported by device)
recElement* pListElements; // head of linked list of elements
DisconnectState disconnect; // (ryan added this.)
AbsoluteTime lastScrollTime; // (ryan added this.)
struct recDevice* pNext; // next device
};
typedef struct recDevice recDevice;
Expand Down Expand Up @@ -1458,6 +1459,17 @@ static int available_mice = 0;
static pRecDevice *devices = NULL;


/* returns non-zero if (a <= b). */
typedef unsigned long long ui64;
static inline int oldEvent(const AbsoluteTime *a, const AbsoluteTime *b)
{
#if 0 // !!! FIXME: doesn't work, timestamps aren't reliable.
const ui64 a64 = (((unsigned long long) a->hi) << 32) | a->lo;
const ui64 b64 = (((unsigned long long) b->hi) << 32) | b->lo;
#endif
return 0;
} /* oldEvent */

static int poll_mouse(pRecDevice mouse, ManyMouseEvent *outevent)
{
int unhandled = 1;
Expand Down Expand Up @@ -1486,28 +1498,37 @@ static int poll_mouse(pRecDevice mouse, ManyMouseEvent *outevent)
{
/*
* some devices (two-finger-scroll trackpads?) seem to give
* values of zero where we want non-events. Throw these out.
* a flood of events with values of zero for every legitimate
* event. Throw these zero events out.
*/
if (outevent->value == 0)
unhandled = 1;
else
{
/* !!! FIXME: absolute motion? */
switch (recelem->usage)
{
case kHIDUsage_GD_X:
outevent->type = MANYMOUSE_EVENT_RELMOTION;
outevent->item = 0;
break;
case kHIDUsage_GD_Y:
outevent->type = MANYMOUSE_EVENT_RELMOTION;
outevent->item = 1;
if (oldEvent(&event.timestamp, &mouse->lastScrollTime))
unhandled = 1;
else
{
outevent->type = MANYMOUSE_EVENT_RELMOTION;
if (recelem->usage == kHIDUsage_GD_X)
outevent->item = 0;
else
outevent->item = 1;
} /* else */
break;

case kHIDUsage_GD_Wheel:
memcpy(&mouse->lastScrollTime, &event.timestamp,
sizeof (AbsoluteTime));
outevent->type = MANYMOUSE_EVENT_SCROLL;
outevent->item = 0; /* !!! FIXME: horiz scroll? */
break;
default:

default: /* !!! FIXME: absolute motion? */
unhandled = 1;
} /* switch */
} /* else */
Expand Down

0 comments on commit dfeb43e

Please sign in to comment.