xorg driver, work on input
This commit is contained in:
parent
1f84c36ddd
commit
af8ca90784
@ -5,7 +5,7 @@ rdpPolyRectangle.o rdpPolyArc.o rdpFillPolygon.o rdpPolyFillRect.o \
|
|||||||
rdpPolyFillArc.o rdpPolyText8.o rdpPolyText16.o rdpImageText8.o \
|
rdpPolyFillArc.o rdpPolyText8.o rdpPolyText16.o rdpImageText8.o \
|
||||||
rdpImageText16.o rdpImageGlyphBlt.o rdpPolyGlyphBlt.o rdpPushPixels.o \
|
rdpImageText16.o rdpImageGlyphBlt.o rdpPolyGlyphBlt.o rdpPushPixels.o \
|
||||||
rdpCursor.o rdpMain.o rdpRandR.o rdpMisc.o rdpReg.o \
|
rdpCursor.o rdpMain.o rdpRandR.o rdpMisc.o rdpReg.o \
|
||||||
rdpComposite.o rdpGlyphs.o rdpPixmap.o
|
rdpComposite.o rdpGlyphs.o rdpPixmap.o rdpInput.o
|
||||||
|
|
||||||
CFLAGS = -g -O2 -Wall -fPIC -I/usr/include/xorg -I/usr/include/pixman-1
|
CFLAGS = -g -O2 -Wall -fPIC -I/usr/include/xorg -I/usr/include/pixman-1
|
||||||
|
|
||||||
|
@ -46,8 +46,8 @@ composite(alpha blending) calls
|
|||||||
static void
|
static void
|
||||||
rdpCompositeOrg(PictureScreenPtr ps, rdpPtr dev,
|
rdpCompositeOrg(PictureScreenPtr ps, rdpPtr dev,
|
||||||
CARD8 op, PicturePtr pSrc, PicturePtr pMask, PicturePtr pDst,
|
CARD8 op, PicturePtr pSrc, PicturePtr pMask, PicturePtr pDst,
|
||||||
INT16 xSrc, INT16 ySrc, INT16 xMask, INT16 yMask, INT16 xDst,
|
INT16 xSrc, INT16 ySrc, INT16 xMask, INT16 yMask,
|
||||||
INT16 yDst, CARD16 width, CARD16 height)
|
INT16 xDst, INT16 yDst, CARD16 width, CARD16 height)
|
||||||
{
|
{
|
||||||
ps->Composite = dev->Composite;
|
ps->Composite = dev->Composite;
|
||||||
ps->Composite(op, pSrc, pMask, pDst, xSrc, ySrc, xMask, yMask,
|
ps->Composite(op, pSrc, pMask, pDst, xSrc, ySrc, xMask, yMask,
|
||||||
@ -71,6 +71,6 @@ rdpComposite(CARD8 op, PicturePtr pSrc, PicturePtr pMask, PicturePtr pDst,
|
|||||||
pScrn = xf86Screens[pScreen->myNum];
|
pScrn = xf86Screens[pScreen->myNum];
|
||||||
dev = XRDPPTR(pScrn);
|
dev = XRDPPTR(pScrn);
|
||||||
ps = GetPictureScreen(pScreen);
|
ps = GetPictureScreen(pScreen);
|
||||||
rdpCompositeOrg(ps, dev, op, pSrc, pMask, pDst, xSrc, ySrc, xMask, yMask,
|
rdpCompositeOrg(ps, dev, op, pSrc, pMask, pDst, xSrc, ySrc,
|
||||||
xDst, yDst, width, height);
|
xMask, yMask, xDst, yDst, width, height);
|
||||||
}
|
}
|
||||||
|
@ -39,6 +39,10 @@ misc draw calls
|
|||||||
|
|
||||||
#include "rdp.h"
|
#include "rdp.h"
|
||||||
|
|
||||||
|
#define LOG_LEVEL 1
|
||||||
|
#define LLOGLN(_level, _args) \
|
||||||
|
do { if (_level < LOG_LEVEL) { ErrorF _args ; ErrorF("\n"); } } while (0)
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
void
|
void
|
||||||
rdpCopyWindow(WindowPtr pWin, DDXPointRec ptOldOrg, RegionPtr pOldRegion)
|
rdpCopyWindow(WindowPtr pWin, DDXPointRec ptOldOrg, RegionPtr pOldRegion)
|
||||||
|
@ -19,11 +19,20 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|||||||
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <string.h>
|
||||||
|
|
||||||
|
/* this should be before all X11 .h files */
|
||||||
|
#include <xorg-server.h>
|
||||||
|
|
||||||
|
/* all driver need this */
|
||||||
|
#include <xf86.h>
|
||||||
|
#include <xf86_OSproc.h>
|
||||||
|
|
||||||
#include "rdp.h"
|
#include "rdp.h"
|
||||||
#include "rdpDraw.h"
|
#include "rdpDraw.h"
|
||||||
|
|
||||||
#define LDEBUG 0
|
|
||||||
|
|
||||||
#define LOG_LEVEL 1
|
#define LOG_LEVEL 1
|
||||||
#define LLOGLN(_level, _args) \
|
#define LLOGLN(_level, _args) \
|
||||||
do { if (_level < LOG_LEVEL) { ErrorF _args ; ErrorF("\n"); } } while (0)
|
do { if (_level < LOG_LEVEL) { ErrorF _args ; ErrorF("\n"); } } while (0)
|
||||||
|
@ -19,6 +19,17 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|||||||
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <string.h>
|
||||||
|
|
||||||
|
/* this should be before all X11 .h files */
|
||||||
|
#include <xorg-server.h>
|
||||||
|
|
||||||
|
/* all driver need this */
|
||||||
|
#include <xf86.h>
|
||||||
|
#include <xf86_OSproc.h>
|
||||||
|
|
||||||
#include "rdp.h"
|
#include "rdp.h"
|
||||||
#include "rdpDraw.h"
|
#include "rdpDraw.h"
|
||||||
|
|
||||||
|
@ -19,6 +19,17 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|||||||
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <string.h>
|
||||||
|
|
||||||
|
/* this should be before all X11 .h files */
|
||||||
|
#include <xorg-server.h>
|
||||||
|
|
||||||
|
/* all driver need this */
|
||||||
|
#include <xf86.h>
|
||||||
|
#include <xf86_OSproc.h>
|
||||||
|
|
||||||
#include "rdp.h"
|
#include "rdp.h"
|
||||||
#include "rdpDraw.h"
|
#include "rdpDraw.h"
|
||||||
|
|
||||||
|
@ -19,6 +19,17 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|||||||
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <string.h>
|
||||||
|
|
||||||
|
/* this should be before all X11 .h files */
|
||||||
|
#include <xorg-server.h>
|
||||||
|
|
||||||
|
/* all driver need this */
|
||||||
|
#include <xf86.h>
|
||||||
|
#include <xf86_OSproc.h>
|
||||||
|
|
||||||
#include "rdp.h"
|
#include "rdp.h"
|
||||||
#include "rdpDraw.h"
|
#include "rdpDraw.h"
|
||||||
|
|
||||||
|
119
xorg/server/module/rdpInput.c
Normal file
119
xorg/server/module/rdpInput.c
Normal file
@ -0,0 +1,119 @@
|
|||||||
|
/*
|
||||||
|
Copyright 2013 Jay Sorg
|
||||||
|
|
||||||
|
Permission to use, copy, modify, distribute, and sell this software and its
|
||||||
|
documentation for any purpose is hereby granted without fee, provided that
|
||||||
|
the above copyright notice appear in all copies and that both that
|
||||||
|
copyright notice and this permission notice appear in supporting
|
||||||
|
documentation.
|
||||||
|
|
||||||
|
The above copyright notice and this permission notice shall be included in
|
||||||
|
all copies or substantial portions of the Software.
|
||||||
|
|
||||||
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
|
||||||
|
AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
||||||
|
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <string.h>
|
||||||
|
|
||||||
|
/* this should be before all X11 .h files */
|
||||||
|
#include <xorg-server.h>
|
||||||
|
|
||||||
|
/* all driver need this */
|
||||||
|
#include <xf86.h>
|
||||||
|
#include <xf86_OSproc.h>
|
||||||
|
|
||||||
|
#include "rdp.h"
|
||||||
|
#include "rdpDraw.h"
|
||||||
|
#include "rdpInput.h"
|
||||||
|
#include "rdpMisc.h"
|
||||||
|
|
||||||
|
#define LOG_LEVEL 1
|
||||||
|
#define LLOGLN(_level, _args) \
|
||||||
|
do { if (_level < LOG_LEVEL) { ErrorF _args ; ErrorF("\n"); } } while (0)
|
||||||
|
|
||||||
|
#define MAX_INPUT_PROC 4
|
||||||
|
|
||||||
|
struct input_proc_list
|
||||||
|
{
|
||||||
|
int type;
|
||||||
|
rdpInputEventProcPtr proc;
|
||||||
|
};
|
||||||
|
|
||||||
|
static struct input_proc_list g_input_proc[MAX_INPUT_PROC];
|
||||||
|
|
||||||
|
/******************************************************************************/
|
||||||
|
int
|
||||||
|
rdpRegisterInputCallback(int type, rdpInputEventProcPtr proc)
|
||||||
|
{
|
||||||
|
if (type == 0)
|
||||||
|
{
|
||||||
|
g_input_proc[0].proc = proc;
|
||||||
|
}
|
||||||
|
else if (type == 1)
|
||||||
|
{
|
||||||
|
g_input_proc[1].proc = proc;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/******************************************************************************/
|
||||||
|
int
|
||||||
|
rdpUnregisterInputCallback(rdpInputEventProcPtr proc)
|
||||||
|
{
|
||||||
|
int index;
|
||||||
|
|
||||||
|
for (index = 0; index < MAX_INPUT_PROC; index++)
|
||||||
|
{
|
||||||
|
if (g_input_proc[index].proc == proc)
|
||||||
|
{
|
||||||
|
g_input_proc[index].proc = 0;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
/******************************************************************************/
|
||||||
|
int
|
||||||
|
rdpInputKeyboardEvent(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 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/******************************************************************************/
|
||||||
|
int
|
||||||
|
rdpInputMouseEvent(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 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/******************************************************************************/
|
||||||
|
/* called when module loads */
|
||||||
|
int
|
||||||
|
rdpInputInit(void)
|
||||||
|
{
|
||||||
|
g_memset(g_input_proc, 0, sizeof(g_input_proc));
|
||||||
|
return 0;
|
||||||
|
}
|
41
xorg/server/module/rdpInput.h
Normal file
41
xorg/server/module/rdpInput.h
Normal file
@ -0,0 +1,41 @@
|
|||||||
|
/*
|
||||||
|
Copyright 2013 Jay Sorg
|
||||||
|
|
||||||
|
Permission to use, copy, modify, distribute, and sell this software and its
|
||||||
|
documentation for any purpose is hereby granted without fee, provided that
|
||||||
|
the above copyright notice appear in all copies and that both that
|
||||||
|
copyright notice and this permission notice appear in supporting
|
||||||
|
documentation.
|
||||||
|
|
||||||
|
The above copyright notice and this permission notice shall be included in
|
||||||
|
all copies or substantial portions of the Software.
|
||||||
|
|
||||||
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
|
||||||
|
AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
||||||
|
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
|
|
||||||
|
input
|
||||||
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef _RDPINPUT_H
|
||||||
|
#define _RDPINPUT_H
|
||||||
|
|
||||||
|
typedef int (*rdpInputEventProcPtr)(int msg, long param1, long param2,
|
||||||
|
long param3, long param4);
|
||||||
|
|
||||||
|
int
|
||||||
|
rdpRegisterInputCallback(int type, rdpInputEventProcPtr proc);
|
||||||
|
int
|
||||||
|
rdpUnregisterInputCallback(rdpInputEventProcPtr proc);
|
||||||
|
int
|
||||||
|
rdpInputKeyboardEvent(int msg, long param1, long param2,
|
||||||
|
long param3, long param4);
|
||||||
|
int
|
||||||
|
rdpInputMouseEvent(int msg, long param1, long param2,
|
||||||
|
long param3, long param4);
|
||||||
|
|
||||||
|
#endif
|
@ -63,6 +63,8 @@ xorgxrdpSetup(pointer Module, pointer Options, int *ErrorMajor, int *ErrorMinor)
|
|||||||
{
|
{
|
||||||
g_initialised = 1;
|
g_initialised = 1;
|
||||||
}
|
}
|
||||||
|
rdpInputInit();
|
||||||
|
rdpPrivateInit();
|
||||||
return (pointer) 1;
|
return (pointer) 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -19,6 +19,17 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|||||||
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <string.h>
|
||||||
|
|
||||||
|
/* this should be before all X11 .h files */
|
||||||
|
#include <xorg-server.h>
|
||||||
|
|
||||||
|
/* all driver need this */
|
||||||
|
#include <xf86.h>
|
||||||
|
#include <xf86_OSproc.h>
|
||||||
|
|
||||||
#include "rdp.h"
|
#include "rdp.h"
|
||||||
#include "rdpDraw.h"
|
#include "rdpDraw.h"
|
||||||
|
|
||||||
|
@ -19,6 +19,17 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|||||||
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <string.h>
|
||||||
|
|
||||||
|
/* this should be before all X11 .h files */
|
||||||
|
#include <xorg-server.h>
|
||||||
|
|
||||||
|
/* all driver need this */
|
||||||
|
#include <xf86.h>
|
||||||
|
#include <xf86_OSproc.h>
|
||||||
|
|
||||||
#include "rdp.h"
|
#include "rdp.h"
|
||||||
#include "rdpDraw.h"
|
#include "rdpDraw.h"
|
||||||
|
|
||||||
|
@ -20,6 +20,7 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|||||||
to deal with regions changing in xorg versions
|
to deal with regions changing in xorg versions
|
||||||
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
@ -153,8 +153,6 @@ rdpPreInit(ScrnInfoPtr pScrn, int flags)
|
|||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
rdpPrivateInit();
|
|
||||||
|
|
||||||
rdpAllocRec(pScrn);
|
rdpAllocRec(pScrn);
|
||||||
dev = XRDPPTR(pScrn);
|
dev = XRDPPTR(pScrn);
|
||||||
|
|
||||||
|
@ -39,13 +39,29 @@ xrdp keyboard module
|
|||||||
#include <micmap.h>
|
#include <micmap.h>
|
||||||
#include <mi.h>
|
#include <mi.h>
|
||||||
|
|
||||||
|
#include <xkbsrv.h>
|
||||||
|
|
||||||
#include "X11/keysym.h"
|
#include "X11/keysym.h"
|
||||||
|
|
||||||
#include "rdp.h"
|
#include "rdp.h"
|
||||||
|
#include "rdpInput.h"
|
||||||
|
|
||||||
|
static int g_pause_spe = 0;
|
||||||
|
static int g_ctrl_down = 0;
|
||||||
|
static int g_alt_down = 0;
|
||||||
|
static int g_shift_down = 0;
|
||||||
|
static int g_tab_down = 0;
|
||||||
|
/* this is toggled every time num lock key is released, not like the
|
||||||
|
above *_down vars */
|
||||||
|
static int g_scroll_lock_down = 0;
|
||||||
|
|
||||||
/* if 1, a keystroke is done every minute, down, then up */
|
/* if 1, a keystroke is done every minute, down, then up */
|
||||||
#define XRDPKB_TEST 0
|
#define XRDPKB_TEST 0
|
||||||
|
|
||||||
|
#if XRDPKB_TEST
|
||||||
|
static OsTimerPtr g_timer = 0;
|
||||||
|
#endif
|
||||||
|
|
||||||
/******************************************************************************/
|
/******************************************************************************/
|
||||||
#define LOG_LEVEL 1
|
#define LOG_LEVEL 1
|
||||||
#define LLOGLN(_level, _args) \
|
#define LLOGLN(_level, _args) \
|
||||||
@ -84,7 +100,6 @@ xrdp keyboard module
|
|||||||
(sizeof(g_kbdMap) / (sizeof(KeySym) * GLYPHS_PER_KEY))
|
(sizeof(g_kbdMap) / (sizeof(KeySym) * GLYPHS_PER_KEY))
|
||||||
|
|
||||||
static DeviceIntPtr g_keyboard = 0;
|
static DeviceIntPtr g_keyboard = 0;
|
||||||
static OsTimerPtr g_timer = 0;
|
|
||||||
|
|
||||||
static KeySym g_kbdMap[] =
|
static KeySym g_kbdMap[] =
|
||||||
{
|
{
|
||||||
@ -210,8 +225,6 @@ rdpEnqueueKey(int type, int scancode)
|
|||||||
{
|
{
|
||||||
if (type == KeyPress)
|
if (type == KeyPress)
|
||||||
{
|
{
|
||||||
/* need this cause rdp and X11 repeats are different */
|
|
||||||
xf86PostKeyboardEvent(g_keyboard, scancode, FALSE);
|
|
||||||
xf86PostKeyboardEvent(g_keyboard, scancode, TRUE);
|
xf86PostKeyboardEvent(g_keyboard, scancode, TRUE);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -220,6 +233,290 @@ rdpEnqueueKey(int type, int scancode)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/******************************************************************************/
|
||||||
|
static void
|
||||||
|
sendDownUpKeyEvent(int type, int x_scancode)
|
||||||
|
{
|
||||||
|
/* need this cause rdp and X11 repeats are different */
|
||||||
|
/* if type is keydown, send keyup + keydown */
|
||||||
|
if (type == KeyPress)
|
||||||
|
{
|
||||||
|
rdpEnqueueKey(KeyRelease, x_scancode);
|
||||||
|
rdpEnqueueKey(KeyPress, x_scancode);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
rdpEnqueueKey(KeyRelease, x_scancode);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/******************************************************************************/
|
||||||
|
static void
|
||||||
|
check_keysa(void)
|
||||||
|
{
|
||||||
|
if (g_ctrl_down != 0)
|
||||||
|
{
|
||||||
|
rdpEnqueueKey(KeyRelease, g_ctrl_down);
|
||||||
|
g_ctrl_down = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (g_alt_down != 0)
|
||||||
|
{
|
||||||
|
rdpEnqueueKey(KeyRelease, g_alt_down);
|
||||||
|
g_alt_down = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (g_shift_down != 0)
|
||||||
|
{
|
||||||
|
rdpEnqueueKey(KeyRelease, g_shift_down);
|
||||||
|
g_shift_down = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param down - true for KeyDown events, false otherwise
|
||||||
|
* @param param1 - ASCII code of pressed key
|
||||||
|
* @param param2 -
|
||||||
|
* @param param3 - scancode of pressed key
|
||||||
|
* @param param4 -
|
||||||
|
******************************************************************************/
|
||||||
|
static void
|
||||||
|
KbdAddEvent(int down, int param1, int param2, int param3, int param4)
|
||||||
|
{
|
||||||
|
int rdp_scancode;
|
||||||
|
int x_scancode;
|
||||||
|
int is_ext;
|
||||||
|
int is_spe;
|
||||||
|
int type;
|
||||||
|
|
||||||
|
type = down ? KeyPress : KeyRelease;
|
||||||
|
rdp_scancode = param3;
|
||||||
|
is_ext = param4 & 256; /* 0x100 */
|
||||||
|
is_spe = param4 & 512; /* 0x200 */
|
||||||
|
x_scancode = 0;
|
||||||
|
|
||||||
|
switch (rdp_scancode)
|
||||||
|
{
|
||||||
|
case 58: /* caps lock */
|
||||||
|
case 42: /* left shift */
|
||||||
|
case 54: /* right shift */
|
||||||
|
case 70: /* scroll lock */
|
||||||
|
x_scancode = rdp_scancode + MIN_KEY_CODE;
|
||||||
|
|
||||||
|
if (x_scancode > 0)
|
||||||
|
{
|
||||||
|
rdpEnqueueKey(type, x_scancode);
|
||||||
|
}
|
||||||
|
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 56: /* left - right alt button */
|
||||||
|
|
||||||
|
if (is_ext)
|
||||||
|
{
|
||||||
|
x_scancode = 113; /* right alt button */
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
x_scancode = 64; /* left alt button */
|
||||||
|
}
|
||||||
|
|
||||||
|
rdpEnqueueKey(type, x_scancode);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 15: /* tab */
|
||||||
|
|
||||||
|
if (!down && !g_tab_down)
|
||||||
|
{
|
||||||
|
check_keysa(); /* leave x_scancode 0 here, we don't want the tab key up */
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
sendDownUpKeyEvent(type, 23);
|
||||||
|
}
|
||||||
|
|
||||||
|
g_tab_down = down;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 29: /* left or right ctrl */
|
||||||
|
|
||||||
|
/* this is to handle special case with pause key sending control first */
|
||||||
|
if (is_spe)
|
||||||
|
{
|
||||||
|
if (down)
|
||||||
|
{
|
||||||
|
g_pause_spe = 1;
|
||||||
|
/* leave x_scancode 0 here, we don't want the control key down */
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
x_scancode = is_ext ? 109 : 37;
|
||||||
|
g_ctrl_down = down ? x_scancode : 0;
|
||||||
|
rdpEnqueueKey(type, x_scancode);
|
||||||
|
}
|
||||||
|
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 69: /* Pause or Num Lock */
|
||||||
|
|
||||||
|
if (g_pause_spe)
|
||||||
|
{
|
||||||
|
x_scancode = 110;
|
||||||
|
|
||||||
|
if (!down)
|
||||||
|
{
|
||||||
|
g_pause_spe = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
x_scancode = g_ctrl_down ? 110 : 77;
|
||||||
|
}
|
||||||
|
|
||||||
|
sendDownUpKeyEvent(type, x_scancode);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 28: /* Enter or Return */
|
||||||
|
x_scancode = is_ext ? 108 : 36;
|
||||||
|
sendDownUpKeyEvent(type, x_scancode);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 53: /* / */
|
||||||
|
x_scancode = is_ext ? 112 : 61;
|
||||||
|
sendDownUpKeyEvent(type, x_scancode);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 55: /* * on KP or Print Screen */
|
||||||
|
x_scancode = is_ext ? 111 : 63;
|
||||||
|
sendDownUpKeyEvent(type, x_scancode);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 71: /* 7 or Home */
|
||||||
|
x_scancode = is_ext ? 97 : 79;
|
||||||
|
sendDownUpKeyEvent(type, x_scancode);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 72: /* 8 or Up */
|
||||||
|
x_scancode = is_ext ? 98 : 80;
|
||||||
|
sendDownUpKeyEvent(type, x_scancode);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 73: /* 9 or PgUp */
|
||||||
|
x_scancode = is_ext ? 99 : 81;
|
||||||
|
sendDownUpKeyEvent(type, x_scancode);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 75: /* 4 or Left */
|
||||||
|
x_scancode = is_ext ? 100 : 83;
|
||||||
|
sendDownUpKeyEvent(type, x_scancode);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 77: /* 6 or Right */
|
||||||
|
x_scancode = is_ext ? 102 : 85;
|
||||||
|
sendDownUpKeyEvent(type, x_scancode);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 79: /* 1 or End */
|
||||||
|
x_scancode = is_ext ? 103 : 87;
|
||||||
|
sendDownUpKeyEvent(type, x_scancode);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 80: /* 2 or Down */
|
||||||
|
x_scancode = is_ext ? 104 : 88;
|
||||||
|
sendDownUpKeyEvent(type, x_scancode);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 81: /* 3 or PgDn */
|
||||||
|
x_scancode = is_ext ? 105 : 89;
|
||||||
|
sendDownUpKeyEvent(type, x_scancode);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 82: /* 0 or Insert */
|
||||||
|
x_scancode = is_ext ? 106 : 90;
|
||||||
|
sendDownUpKeyEvent(type, x_scancode);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 83: /* . or Delete */
|
||||||
|
x_scancode = is_ext ? 107 : 91;
|
||||||
|
sendDownUpKeyEvent(type, x_scancode);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 91: /* left win key */
|
||||||
|
rdpEnqueueKey(type, 115);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 92: /* right win key */
|
||||||
|
rdpEnqueueKey(type, 116);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 93: /* menu key */
|
||||||
|
rdpEnqueueKey(type, 117);
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
x_scancode = rdp_scancode + MIN_KEY_CODE;
|
||||||
|
|
||||||
|
if (x_scancode > 0)
|
||||||
|
{
|
||||||
|
sendDownUpKeyEvent(type, x_scancode);
|
||||||
|
}
|
||||||
|
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/******************************************************************************/
|
||||||
|
/* notes -
|
||||||
|
scroll lock doesn't seem to be a modifier in X
|
||||||
|
*/
|
||||||
|
static void
|
||||||
|
KbdSync(int param1)
|
||||||
|
{
|
||||||
|
int xkb_state;
|
||||||
|
|
||||||
|
xkb_state = XkbStateFieldFromRec(&(g_keyboard->key->xkbInfo->state));
|
||||||
|
|
||||||
|
if ((!(xkb_state & 0x02)) != (!(param1 & 4))) /* caps lock */
|
||||||
|
{
|
||||||
|
LLOGLN(0, ("KbdSync: toggling caps lock"));
|
||||||
|
KbdAddEvent(1, 58, 0, 58, 0);
|
||||||
|
KbdAddEvent(0, 58, 49152, 58, 49152);
|
||||||
|
}
|
||||||
|
|
||||||
|
if ((!(xkb_state & 0x10)) != (!(param1 & 2))) /* num lock */
|
||||||
|
{
|
||||||
|
LLOGLN(0, ("KbdSync: toggling num lock"));
|
||||||
|
KbdAddEvent(1, 69, 0, 69, 0);
|
||||||
|
KbdAddEvent(0, 69, 49152, 69, 49152);
|
||||||
|
}
|
||||||
|
|
||||||
|
if ((!(g_scroll_lock_down)) != (!(param1 & 1))) /* scroll lock */
|
||||||
|
{
|
||||||
|
LLOGLN(0, ("KbdSync: toggling scroll lock"));
|
||||||
|
KbdAddEvent(1, 70, 0, 70, 0);
|
||||||
|
KbdAddEvent(0, 70, 49152, 70, 49152);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/******************************************************************************/
|
||||||
|
static int
|
||||||
|
rdpInputKeyboard(int msg, long param1, long param2, long param3, long param4)
|
||||||
|
{
|
||||||
|
LLOGLN(0, ("rdpInputKeyboard:"));
|
||||||
|
switch (msg)
|
||||||
|
{
|
||||||
|
case 15: /* key down */
|
||||||
|
case 16: /* key up */
|
||||||
|
KbdAddEvent(msg == 15, param1, param2, param3, param4);
|
||||||
|
break;
|
||||||
|
case 17: /* from RDP_INPUT_SYNCHRONIZE */
|
||||||
|
KbdSync(param1);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
#if XRDPKB_TEST
|
#if XRDPKB_TEST
|
||||||
/******************************************************************************/
|
/******************************************************************************/
|
||||||
static CARD32
|
static CARD32
|
||||||
@ -339,6 +636,7 @@ rdpkeybControl(DeviceIntPtr device, int what)
|
|||||||
InitKeyboardDeviceStruct(device, &set, rdpkeybBell,
|
InitKeyboardDeviceStruct(device, &set, rdpkeybBell,
|
||||||
rdpkeybChangeKeyboardControl);
|
rdpkeybChangeKeyboardControl);
|
||||||
g_keyboard = device;
|
g_keyboard = device;
|
||||||
|
rdpRegisterInputCallback(0, rdpInputKeyboard);
|
||||||
#if XRDPKB_TEST
|
#if XRDPKB_TEST
|
||||||
g_timer = TimerSet(g_timer, 0, 1000, rdpDeferredUpdateCallback, 0);
|
g_timer = TimerSet(g_timer, 0, 1000, rdpDeferredUpdateCallback, 0);
|
||||||
#endif
|
#endif
|
||||||
|
Loading…
Reference in New Issue
Block a user