xorg driver, mouse input

ulab-next
Jay Sorg 11 years ago
parent 17bf2abe30
commit 48aa165729

@ -14,3 +14,9 @@ allclean:
cd xrdpdev; $(MAKE) clean
cd xrdpkeyb; $(MAKE) clean
cd xrdpmouse; $(MAKE) clean
xinstall:
cp module/libxorgxrdp.so $(HOME)/xorg-modules/
cp xrdpdev/xrdpdev_drv.so $(HOME)/xorg-modules/drivers/
cp xrdpmouse/xrdpmouse_drv.so $(HOME)/xorg-modules/input/
cp xrdpkeyb/xrdpkeyb_drv.so $(HOME)/xorg-modules/input/

@ -87,24 +87,26 @@ rdpUnregisterInputCallback(rdpInputEventProcPtr proc)
/******************************************************************************/
int
rdpInputKeyboardEvent(int msg, long param1, long param2,
rdpInputKeyboardEvent(rdpPtr dev, int msg,
long param1, long param2,
long param3, long param4)
{
if (g_input_proc[0].proc != 0)
{
return g_input_proc[0].proc(msg, param1, param2, param3, param4);
return g_input_proc[0].proc(dev, msg, param1, param2, param3, param4);
}
return 0;
}
/******************************************************************************/
int
rdpInputMouseEvent(int msg, long param1, long param2,
rdpInputMouseEvent(rdpPtr dev, int msg,
long param1, long param2,
long param3, long param4)
{
if (g_input_proc[1].proc != 0)
{
return g_input_proc[1].proc(msg, param1, param2, param3, param4);
return g_input_proc[1].proc(dev, msg, param1, param2, param3, param4);
}
return 0;
}

@ -24,7 +24,8 @@ input
#ifndef _RDPINPUT_H
#define _RDPINPUT_H
typedef int (*rdpInputEventProcPtr)(int msg, long param1, long param2,
typedef int (*rdpInputEventProcPtr)(rdpPtr dev, int msg,
long param1, long param2,
long param3, long param4);
int
@ -32,10 +33,12 @@ rdpRegisterInputCallback(int type, rdpInputEventProcPtr proc);
int
rdpUnregisterInputCallback(rdpInputEventProcPtr proc);
int
rdpInputKeyboardEvent(int msg, long param1, long param2,
rdpInputKeyboardEvent(rdpPtr dev, int msg,
long param1, long param2,
long param3, long param4);
int
rdpInputMouseEvent(int msg, long param1, long param2,
rdpInputMouseEvent(rdpPtr dev, int msg,
long param1, long param2,
long param3, long param4);
int
rdpInputInit(void);

@ -304,7 +304,7 @@ rdpResizeSession(rdpPtr dev, int width, int height)
{
LLOGLN(0, (" calling RRScreenSizeSet"));
ok = RRScreenSizeSet(dev->pScreen, width, height, mmwidth, mmheight);
LLOGLN(0, (" RRScreenSizeSet ok=[%d]", ok));
LLOGLN(0, (" RRScreenSizeSet ok %d", ok));
}
return ok;
}

@ -494,7 +494,8 @@ KbdSync(int param1)
/******************************************************************************/
static int
rdpInputKeyboard(int msg, long param1, long param2, long param3, long param4)
rdpInputKeyboard(rdpPtr dev, int msg, long param1, long param2,
long param3, long param4)
{
LLOGLN(0, ("rdpInputKeyboard:"));
switch (msg)

@ -42,6 +42,7 @@ xrdp mouse module
#include <xserver-properties.h>
#include "rdp.h"
#include "rdpInput.h"
/******************************************************************************/
#define LOG_LEVEL 1
@ -56,6 +57,14 @@ xrdp mouse module
#define PACKAGE_VERSION_MINOR 0
#define PACKAGE_VERSION_PATCHLEVEL 0
static DeviceIntPtr g_pointer = 0;
static int g_cursor_x = 0;
static int g_cursor_y = 0;
static int g_old_button_mask = 0;
static int g_button_mask = 0;
/******************************************************************************/
static void
rdpmouseDeviceInit(void)
@ -84,6 +93,161 @@ rdpmouseCtrl(DeviceIntPtr pDevice, PtrCtrl *pCtrl)
LLOGLN(0, ("rdpmouseCtrl:"));
}
/******************************************************************************/
static int
l_bound_by(int val, int low, int high)
{
if (val > high)
{
val = high;
}
if (val < low)
{
val = low;
}
return val;
}
/******************************************************************************/
static void
rdpEnqueueMotion(int x, int y)
{
int i;
int n;
int valuators[2];
EventListPtr rdp_events;
xEvent *pev;
miPointerSetPosition(g_pointer, &x, &y);
valuators[0] = x;
valuators[1] = y;
GetEventList(&rdp_events);
n = GetPointerEvents(rdp_events, g_pointer, MotionNotify, 0,
POINTER_ABSOLUTE | POINTER_SCREEN,
0, 2, valuators);
for (i = 0; i < n; i++)
{
pev = (rdp_events + i)->event;
mieqEnqueue(g_pointer, (InternalEvent *)pev);
}
}
/******************************************************************************/
static void
rdpEnqueueButton(int type, int buttons)
{
int i;
int n;
EventListPtr rdp_events;
xEvent *pev;
i = GetEventList(&rdp_events);
n = GetPointerEvents(rdp_events, g_pointer, type, buttons, 0, 0, 0, 0);
for (i = 0; i < n; i++)
{
pev = (rdp_events + i)->event;
mieqEnqueue(g_pointer, (InternalEvent *)pev);
}
}
/******************************************************************************/
void
PtrAddEvent(int buttonMask, int x, int y)
{
int i;
int type;
int buttons;
rdpEnqueueMotion(x, y);
for (i = 0; i < 5; i++)
{
if ((buttonMask ^ g_old_button_mask) & (1 << i))
{
if (buttonMask & (1 << i))
{
type = ButtonPress;
buttons = i + 1;
rdpEnqueueButton(type, buttons);
}
else
{
type = ButtonRelease;
buttons = i + 1;
rdpEnqueueButton(type, buttons);
}
}
}
g_old_button_mask = buttonMask;
}
/******************************************************************************/
static int
rdpInputMouse(rdpPtr dev, int msg,
long param1, long param2,
long param3, long param4)
{
LLOGLN(0, ("rdpInputMouse:"));
switch (msg)
{
case 100:
/* without the minus 2, strange things happen when dragging
past the width or height */
g_cursor_x = l_bound_by(param1, 0, dev->width - 2);
g_cursor_y = l_bound_by(param2, 0, dev->height - 2);
PtrAddEvent(g_button_mask, g_cursor_x, g_cursor_y);
break;
case 101:
g_button_mask = g_button_mask & (~1);
PtrAddEvent(g_button_mask, g_cursor_x, g_cursor_y);
break;
case 102:
g_button_mask = g_button_mask | 1;
PtrAddEvent(g_button_mask, g_cursor_x, g_cursor_y);
break;
case 103:
g_button_mask = g_button_mask & (~4);
PtrAddEvent(g_button_mask, g_cursor_x, g_cursor_y);
break;
case 104:
g_button_mask = g_button_mask | 4;
PtrAddEvent(g_button_mask, g_cursor_x, g_cursor_y);
break;
case 105:
g_button_mask = g_button_mask & (~2);
PtrAddEvent(g_button_mask, g_cursor_x, g_cursor_y);
break;
case 106:
g_button_mask = g_button_mask | 2;
PtrAddEvent(g_button_mask, g_cursor_x, g_cursor_y);
break;
case 107:
g_button_mask = g_button_mask & (~8);
PtrAddEvent(g_button_mask, g_cursor_x, g_cursor_y);
break;
case 108:
g_button_mask = g_button_mask | 8;
PtrAddEvent(g_button_mask, g_cursor_x, g_cursor_y);
break;
case 109:
g_button_mask = g_button_mask & (~16);
PtrAddEvent(g_button_mask, g_cursor_x, g_cursor_y);
break;
case 110:
g_button_mask = g_button_mask | 16;
PtrAddEvent(g_button_mask, g_cursor_x, g_cursor_y);
break;
}
return 0;
}
/******************************************************************************/
static int
rdpmouseControl(DeviceIntPtr device, int what)
@ -118,7 +282,8 @@ rdpmouseControl(DeviceIntPtr device, int what)
InitPointerDeviceStruct(pDev, map, 5, btn_labels, rdpmouseCtrl,
GetMotionHistorySize(), 2, axes_labels);
g_pointer = device;
rdpRegisterInputCallback(1, rdpInputMouse);
break;
case DEVICE_ON:
pDev->on = 1;

Loading…
Cancel
Save