From 720751ae360bfbf16b1e11dcffc0e2d5cce4540b Mon Sep 17 00:00:00 2001 From: Jay Sorg Date: Sun, 14 Jul 2013 20:47:52 -0700 Subject: [PATCH] work on Xorg keyboard and mouse drivers --- xorg/server/xrdpdev/xorg.conf | 3 +- xorg/server/xrdpkeyb/rdpKeyboard.c | 114 ++++++++++++++ xorg/server/xrdpmouse/rdpMouse.c | 241 +++++++++++++++++++++++++++++ 3 files changed, 357 insertions(+), 1 deletion(-) diff --git a/xorg/server/xrdpdev/xorg.conf b/xorg/server/xrdpdev/xorg.conf index 2d6096fc..1c9d7cfc 100644 --- a/xorg/server/xrdpdev/xorg.conf +++ b/xorg/server/xrdpdev/xorg.conf @@ -7,7 +7,8 @@ Section "ServerLayout" EndSection Section "ServerFlags" - Option "DontVTSwitch" "off" + Option "DontVTSwitch" "on" + Option "AutoAddDevices" "off" EndSection Section "Files" diff --git a/xorg/server/xrdpkeyb/rdpKeyboard.c b/xorg/server/xrdpkeyb/rdpKeyboard.c index fbf4eb1c..88bcf680 100644 --- a/xorg/server/xrdpkeyb/rdpKeyboard.c +++ b/xorg/server/xrdpkeyb/rdpKeyboard.c @@ -20,3 +20,117 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. xrdp keyboard module */ + +#include +#include +#include + +/* this should be before all X11 .h files */ +#include + +/* all driver need this */ +#include +#include + +#include "xf86Xinput.h" + +#include +#include +#include +#include + +#include "rdp.h" + +/******************************************************************************/ +#define LOG_LEVEL 1 +#define LLOGLN(_level, _args) \ + do { if (_level < LOG_LEVEL) { ErrorF _args ; ErrorF("\n"); } } while (0) + +#define XRDP_DRIVER_NAME "XRDPKEYB" +#define XRDP_NAME "XRDPKEYB" +#define XRDP_VERSION 1000 + +#define PACKAGE_VERSION_MAJOR 1 +#define PACKAGE_VERSION_MINOR 0 +#define PACKAGE_VERSION_PATCHLEVEL 0 + +/******************************************************************************/ +static int +rdpKeybControl(DeviceIntPtr device, int what) +{ + LLOGLN(0, ("rdpKeybControl: what %d", what)); + return 0; +} + +/******************************************************************************/ +static int +rdpkeybPreInit(InputDriverPtr drv, InputInfoPtr info, int flags) +{ + LLOGLN(0, ("rdpkeybPreInit: drv %p info %p, flags 0x%x", + drv, info, flags)); + info->device_control = rdpKeybControl; + info->type_name = "Keyboard"; + + return 0; +} + +/******************************************************************************/ +static void +rdpkeybUnInit(InputDriverPtr drv, InputInfoPtr info, int flags) +{ + LLOGLN(0, ("rdpkeybUnInit: drv %p info %p, flags 0x%x", + drv, info, flags)); +} + +/******************************************************************************/ +static InputDriverRec rdpkeyb = +{ + PACKAGE_VERSION_MAJOR, /* version */ + XRDP_NAME, /* name */ + NULL, /* identify */ + rdpkeybPreInit, /* preinit */ + rdpkeybUnInit, /* uninit */ + NULL, /* module */ + 0 /* ref count */ +}; + +/******************************************************************************/ +static void +rdpkeybUnplug(pointer p) +{ + LLOGLN(0, ("rdpkeybUnplug:")); +} + +/******************************************************************************/ +static pointer +rdpkeybPlug(pointer module, pointer options, int *errmaj, int *errmin) +{ + LLOGLN(0, ("rdpkeybPlug:")); + xf86AddInputDriver(&rdpkeyb, module, 0); + return module; +} + +/******************************************************************************/ +static XF86ModuleVersionInfo rdpkeybVersionRec = +{ + XRDP_DRIVER_NAME, + MODULEVENDORSTRING, + MODINFOSTRING1, + MODINFOSTRING2, + XORG_VERSION_CURRENT, + PACKAGE_VERSION_MAJOR, + PACKAGE_VERSION_MINOR, + PACKAGE_VERSION_PATCHLEVEL, + ABI_CLASS_XINPUT, + ABI_XINPUT_VERSION, + MOD_CLASS_XINPUT, + { 0, 0, 0, 0 } +}; + +/******************************************************************************/ +XF86ModuleData xrdpkeybModuleData = +{ + &rdpkeybVersionRec, + rdpkeybPlug, + rdpkeybUnplug +}; diff --git a/xorg/server/xrdpmouse/rdpMouse.c b/xorg/server/xrdpmouse/rdpMouse.c index a6cbb0f2..a444ea55 100644 --- a/xorg/server/xrdpmouse/rdpMouse.c +++ b/xorg/server/xrdpmouse/rdpMouse.c @@ -20,3 +20,244 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. xrdp mouse module */ + +#include +#include +#include + +/* this should be before all X11 .h files */ +#include + +/* all driver need this */ +#include +#include + +#include "xf86Xinput.h" + +#include +#include +#include +#include +#include +#include + +#include "rdp.h" + +/******************************************************************************/ +#define LOG_LEVEL 1 +#define LLOGLN(_level, _args) \ + do { if (_level < LOG_LEVEL) { ErrorF _args ; ErrorF("\n"); } } while (0) + +#define XRDP_DRIVER_NAME "XRDPMOUSE" +#define XRDP_NAME "XRDPMOUSE" +#define XRDP_VERSION 1000 + +#define PACKAGE_VERSION_MAJOR 1 +#define PACKAGE_VERSION_MINOR 0 +#define PACKAGE_VERSION_PATCHLEVEL 0 + +/******************************************************************************/ +static void +rdpMouseDeviceInit(void) +{ + LLOGLN(0, ("rdpMouseDeviceInit:")); +} + +/******************************************************************************/ +static void +rdpMouseDeviceOn(DeviceIntPtr pDev) +{ + LLOGLN(0, ("rdpMouseDeviceOn:")); +} + +/******************************************************************************/ +static void +rdpMouseDeviceOff(void) +{ + LLOGLN(0, ("rdpMouseDeviceOff:")); +} + +/******************************************************************************/ +static void +rdpMouseCtrl(DeviceIntPtr pDevice, PtrCtrl *pCtrl) +{ + LLOGLN(0, ("rdpMouseCtrl:")); +} + +/******************************************************************************/ +static int +rdpMouseControl(DeviceIntPtr device, int what) +{ + BYTE map[6]; + DevicePtr pDev; + Atom btn_labels[6]; + Atom axes_labels[2]; + + LLOGLN(0, ("rdpMouseControl: what %d", what)); + pDev = (DevicePtr)device; + + switch (what) + { + case DEVICE_INIT: + rdpMouseDeviceInit(); + map[0] = 0; + map[1] = 1; + map[2] = 2; + map[3] = 3; + map[4] = 4; + map[5] = 5; + + btn_labels[0] = XIGetKnownProperty(BTN_LABEL_PROP_BTN_LEFT); + btn_labels[1] = XIGetKnownProperty(BTN_LABEL_PROP_BTN_MIDDLE); + btn_labels[2] = XIGetKnownProperty(BTN_LABEL_PROP_BTN_RIGHT); + btn_labels[3] = XIGetKnownProperty(BTN_LABEL_PROP_BTN_WHEEL_UP); + btn_labels[4] = XIGetKnownProperty(BTN_LABEL_PROP_BTN_WHEEL_DOWN); + + axes_labels[0] = XIGetKnownProperty(AXIS_LABEL_PROP_REL_X); + axes_labels[1] = XIGetKnownProperty(AXIS_LABEL_PROP_REL_Y); + + InitPointerDeviceStruct(pDev, map, 5, btn_labels, rdpMouseCtrl, + GetMotionHistorySize(), 2, axes_labels); + + break; + case DEVICE_ON: + pDev->on = 1; + rdpMouseDeviceOn(device); + break; + case DEVICE_OFF: + pDev->on = 0; + rdpMouseDeviceOff(); + break; + case DEVICE_CLOSE: + + if (pDev->on) + { + rdpMouseDeviceOff(); + } + + break; + } + + return Success; +} + +/******************************************************************************/ +static void +rdpMouseReadInput(struct _InputInfoRec *local) +{ + LLOGLN(0, ("rdpMouseReadInput:")); +} + +/******************************************************************************/ +static int +rdpMouseControlProc(struct _InputInfoRec *local, xDeviceCtl *control) +{ + LLOGLN(0, ("rdpMouseControlProc:")); + return 0; +} + +/******************************************************************************/ +static int +rdpMouseSwitchMode(ClientPtr client, DeviceIntPtr dev, int mode) +{ + LLOGLN(0, ("rdpMouseSwitchMode:")); + return 0; +} + +/******************************************************************************/ +static int +rdpMouseSetDeviceValuators(struct _InputInfoRec *local, + int *valuators, int first_valuator, + int num_valuators) +{ + LLOGLN(0, ("rdpMouseSetDeviceValuators:")); + return 0; +} + +/******************************************************************************/ +static int +rdpmousePreInit(InputDriverPtr drv, InputInfoPtr info, int flags) +{ + //MouseDevPtr pMse; + + LLOGLN(0, ("rdpmousePreInit: drv %p info %p, flags 0x%x", + drv, info, flags)); + info->device_control = rdpMouseControl; + info->read_input = rdpMouseReadInput; + info->control_proc = rdpMouseControlProc; + info->switch_mode = rdpMouseSwitchMode; + info->set_device_valuators = rdpMouseSetDeviceValuators; + //info->fd = -1; + //LLOGLN(0, ("%p", info->dev)); + //LLOGLN(0, ("rdpmousePreInit: info->flags 0x%x", info->flags)); + //info->flags |= 0x40 | 0x08 | 0x02 | 0x10;; + //LLOGLN(0, ("rdpmousePreInit: info->flags 0x%x", info->flags)); + //LLOGLN(0, ("rdpmousePreInit: %s %s %s", info->type_name, info->name, info->driver)); + info->type_name = "Mouse"; + //info->driver = "xrdpmouse"; + + //xf86AddEnabledDevice(info); + + return 0; +} + +/******************************************************************************/ +static void +rdpmouseUnInit(InputDriverPtr drv, InputInfoPtr info, int flags) +{ + LLOGLN(0, ("rdpmouseUnInit: drv %p info %p, flags 0x%x", + drv, info, flags)); +} + +/******************************************************************************/ +static InputDriverRec rdpmouse = +{ + PACKAGE_VERSION_MAJOR, /* version */ + XRDP_NAME, /* name */ + NULL, /* identify */ + rdpmousePreInit, /* preinit */ + rdpmouseUnInit, /* uninit */ + NULL, /* module */ + 0 /* ref count */ +}; + +/******************************************************************************/ +static void +rdpmouseUnplug(pointer p) +{ + LLOGLN(0, ("rdpmouseUnplug:")); +} + +/******************************************************************************/ +static pointer +rdpmousePlug(pointer module, pointer options, int *errmaj, int *errmin) +{ + LLOGLN(0, ("rdpmousePlug:")); + xf86AddInputDriver(&rdpmouse, module, 0); + return module; +} + +/******************************************************************************/ +static XF86ModuleVersionInfo rdpmouseVersionRec = +{ + XRDP_DRIVER_NAME, + MODULEVENDORSTRING, + MODINFOSTRING1, + MODINFOSTRING2, + XORG_VERSION_CURRENT, + PACKAGE_VERSION_MAJOR, + PACKAGE_VERSION_MINOR, + PACKAGE_VERSION_PATCHLEVEL, + ABI_CLASS_XINPUT, + ABI_XINPUT_VERSION, + MOD_CLASS_XINPUT, + { 0, 0, 0, 0 } +}; + +/******************************************************************************/ +XF86ModuleData xrdpmouseModuleData = +{ + &rdpmouseVersionRec, + rdpmousePlug, + rdpmouseUnplug +};