add support for horizontal scrolling (buttons 6 and 7)
This commit is contained in:
parent
ab662c736e
commit
f525a4a432
|
@ -903,7 +903,7 @@ static void send_nsevent (NSEventType type, NSEvent *e) {
|
|||
break;
|
||||
|
||||
case NSScrollWheel:
|
||||
DarwinSendScrollEvents([e deltaY], pointer_x, pointer_y,
|
||||
DarwinSendScrollEvents([e deltaX], [e deltaY], pointer_x, pointer_y,
|
||||
pressure, tilt_x, tilt_y);
|
||||
break;
|
||||
|
||||
|
|
|
@ -337,7 +337,7 @@ static int DarwinMouseProc(
|
|||
DeviceIntPtr pPointer,
|
||||
int what )
|
||||
{
|
||||
CARD8 map[6];
|
||||
CARD8 map[8] = {0, 1, 2, 3, 4, 5, 6, 7};
|
||||
|
||||
switch (what) {
|
||||
|
||||
|
@ -345,15 +345,10 @@ static int DarwinMouseProc(
|
|||
pPointer->public.on = FALSE;
|
||||
|
||||
// Set button map.
|
||||
map[1] = 1;
|
||||
map[2] = 2;
|
||||
map[3] = 3;
|
||||
map[4] = 4;
|
||||
map[5] = 5;
|
||||
InitPointerDeviceStruct( (DevicePtr)pPointer, map, 5,
|
||||
InitPointerDeviceStruct( (DevicePtr)pPointer, map, 7,
|
||||
GetMotionHistory,
|
||||
(PtrCtrlProcPtr)NoopDDA,
|
||||
GetMotionHistorySize(), 5);
|
||||
GetMotionHistorySize(), 7);
|
||||
InitProximityClassDeviceStruct( (DevicePtr)pPointer);
|
||||
break;
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
/*
|
||||
Darwin event queue and event handling
|
||||
|
||||
Copyright 2007 Apple Inc.
|
||||
Copyright 2007-2008 Apple Inc.
|
||||
Copyright 2004 Kaleb S. KEITHLEY. All Rights Reserved.
|
||||
Copyright (c) 2002-2004 Torrey T. Lyons. All Rights Reserved.
|
||||
|
||||
|
@ -56,6 +56,12 @@ in this Software without prior written authorization from The Open Group.
|
|||
#include <unistd.h>
|
||||
#include <IOKit/hidsystem/IOLLEvent.h>
|
||||
|
||||
/* Fake button press/release for scroll wheel move. */
|
||||
#define SCROLLWHEELUPFAKE 4
|
||||
#define SCROLLWHEELDOWNFAKE 5
|
||||
#define SCROLLWHEELLEFTFAKE 6
|
||||
#define SCROLLWHEELRIGHTFAKE 7
|
||||
|
||||
#define _APPLEWM_SERVER_
|
||||
#include "applewmExt.h"
|
||||
#include <X11/extensions/applewm.h>
|
||||
|
@ -65,10 +71,6 @@ in this Software without prior written authorization from The Open Group.
|
|||
#include "rootlessWindow.h"
|
||||
WindowPtr xprGetXWindow(xp_window_id wid);
|
||||
|
||||
/* Fake button press/release for scroll wheel move. */
|
||||
#define SCROLLWHEELUPFAKE 4
|
||||
#define SCROLLWHEELDOWNFAKE 5
|
||||
|
||||
int input_check_zero, input_check_flag;
|
||||
|
||||
static int old_flags = 0; // last known modifier state
|
||||
|
@ -452,30 +454,32 @@ void DarwinSendProximityEvents(int ev_type, int pointer_x, int pointer_y,
|
|||
}
|
||||
|
||||
|
||||
/* Send the appropriate number of button 4 / 5 clicks to emulate scroll wheel */
|
||||
void DarwinSendScrollEvents(float count, int pointer_x, int pointer_y,
|
||||
/* Send the appropriate number of button clicks to emulate scroll wheel */
|
||||
void DarwinSendScrollEvents(float count_x, float count_y,
|
||||
int pointer_x, int pointer_y,
|
||||
float pressure, float tilt_x, float tilt_y) {
|
||||
int i;
|
||||
int ev_button = count > 0.0f ? 4 : 5;
|
||||
int valuators[5] = {pointer_x, pointer_y,
|
||||
pressure * INT32_MAX * 1.0f,
|
||||
tilt_x * INT32_MAX * 1.0f,
|
||||
tilt_y * INT32_MAX * 1.0f};
|
||||
|
||||
if(!darwinEvents) {
|
||||
ErrorF("DarwinSendScrollEvents called before darwinEvents was initialized\n");
|
||||
return;
|
||||
}
|
||||
ErrorF("scroll(%f, %f)\n", count_x, count_y);
|
||||
int sign_x = count_x > 0.0f ? SCROLLWHEELLEFTFAKE : SCROLLWHEELRIGHTFAKE;
|
||||
int sign_y = count_y > 0.0f ? SCROLLWHEELUPFAKE : SCROLLWHEELDOWNFAKE;
|
||||
count_x = fabs(count_x);
|
||||
count_y = fabs(count_y);
|
||||
|
||||
for (count = fabs(count); count > 0.0; count = count - 1.0f) {
|
||||
int num_events = GetPointerEvents(darwinEvents, darwinPointer, ButtonPress, ev_button,
|
||||
POINTER_ABSOLUTE, 0, 5, valuators);
|
||||
for(i=0; i<num_events; i++) mieqEnqueue(darwinPointer,&darwinEvents[i]);
|
||||
num_events = GetPointerEvents(darwinEvents, darwinPointer, ButtonRelease, ev_button,
|
||||
POINTER_ABSOLUTE, 0, 5, valuators);
|
||||
for(i=0; i<num_events; i++) mieqEnqueue(darwinPointer,&darwinEvents[i]);
|
||||
while ((count_x > 0.0f) || (count_y > 0.0f)) {
|
||||
if (count_x > 0.0f) {
|
||||
DarwinSendPointerEvents(ButtonPress, sign_x, pointer_x, pointer_y, pressure, tilt_x, tilt_y);
|
||||
DarwinSendPointerEvents(ButtonRelease, sign_x, pointer_x, pointer_y, pressure, tilt_x, tilt_y);
|
||||
count_x = count_x - 1.0f;
|
||||
}
|
||||
if (count_y > 0.0f) {
|
||||
DarwinSendPointerEvents(ButtonPress, sign_y, pointer_x, pointer_y, pressure, tilt_x, tilt_y);
|
||||
DarwinSendPointerEvents(ButtonRelease, sign_y, pointer_x, pointer_y, pressure, tilt_x, tilt_y);
|
||||
count_y = count_y - 1.0f;
|
||||
}
|
||||
}
|
||||
DarwinPokeEQ();
|
||||
}
|
||||
|
||||
/* Send the appropriate KeyPress/KeyRelease events to GetKeyboardEvents to
|
||||
|
|
|
@ -38,7 +38,7 @@ void DarwinSendPointerEvents(int ev_type, int ev_button, int pointer_x, int poin
|
|||
void DarwinSendProximityEvents(int ev_type, int pointer_x, int pointer_y,
|
||||
float pressure, float tilt_x, float tilt_y);
|
||||
void DarwinSendKeyboardEvents(int ev_type, int keycode);
|
||||
void DarwinSendScrollEvents(float count, int pointer_x, int pointer_y,
|
||||
void DarwinSendScrollEvents(float count_x, float count_y, int pointer_x, int pointer_y,
|
||||
float pressure, float tilt_x, float tilt_y);
|
||||
void DarwinUpdateModKeys(int flags);
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user