diff --git a/client/X11/CMakeLists.txt b/client/X11/CMakeLists.txt index 7d08ea670..ded2c86d8 100644 --- a/client/X11/CMakeLists.txt +++ b/client/X11/CMakeLists.txt @@ -124,6 +124,15 @@ if(WITH_XV) set(${MODULE_PREFIX}_LIBS ${${MODULE_PREFIX}_LIBS} ${XV_LIBRARIES}) endif() +#Corey hacked this here for testing +#include_directories(${XINPUT2_INCLUDE_DIRS}) +#set(${MODULE_PREFIX}_LIBS ${${MODULE_PREFIX}_LIBS} ${XINPUT2_LIBRARIES}) + +include_directories(X11/extensions/XInput2.h) +set(${MODULE_PREFIX}_LIBS ${${MODULE_PREFIX}_LIBS} Xi) + + + include_directories(${CMAKE_SOURCE_DIR}/resources) set(${MODULE_PREFIX}_LIBS ${${MODULE_PREFIX}_LIBS} freerdp-client) diff --git a/client/X11/xf_interface.c b/client/X11/xf_interface.c index 6677223e6..66c5a1a54 100644 --- a/client/X11/xf_interface.c +++ b/client/X11/xf_interface.c @@ -25,6 +25,7 @@ #include #include #include +#include #ifdef WITH_XCURSOR #include @@ -81,6 +82,119 @@ static int run = 0; static long xv_port = 0; static const size_t password_size = 512; +/* Upscaling the image uses simple bilinear interpolation */ +int up_scale_image( + const unsigned char* const orig, + int width, int height, int channels, + unsigned char* resampled, + int resampled_width, int resampled_height + ) +{ + float dx, dy; + int x, y, c; + + /* error(s) check */ + if ( (width < 1) || (height < 1) || + (resampled_width < 2) || (resampled_height < 2) || + (channels < 1) || + (NULL == orig) || (NULL == resampled) ) + { + /* signify badness */ + return 0; + } + /* + for each given pixel in the new map, find the exact location + from the original map which would contribute to this guy + */ + dx = (width - 1.0f) / (resampled_width - 1.0f); + dy = (height - 1.0f) / (resampled_height - 1.0f); + for ( y = 0; y < resampled_height; ++y ) + { + /* find the base y index and fractional offset from that */ + float sampley = y * dy; + int inty = (int)sampley; + /* if( inty < 0 ) { inty = 0; } else */ + if( inty > height - 2 ) { inty = height - 2; } + sampley -= inty; + for ( x = 0; x < resampled_width; ++x ) + { + float samplex = x * dx; + int intx = (int)samplex; + int base_index; + /* find the base x index and fractional offset from that */ + /* if( intx < 0 ) { intx = 0; } else */ + if( intx > width - 2 ) { intx = width - 2; } + samplex -= intx; + /* base index into the original image */ + base_index = (inty * width + intx) * channels; + for ( c = 0; c < channels; ++c ) + { + /* do the sampling */ + float value = 0.5f; + value += orig[base_index] + *(1.0f-samplex)*(1.0f-sampley); + value += orig[base_index+channels] + *(samplex)*(1.0f-sampley); + value += orig[base_index+width*channels] + *(1.0f-samplex)*(sampley); + value += orig[base_index+width*channels+channels] + *(samplex)*(sampley); + /* move to the next channel */ + ++base_index; + /* save the new value */ + resampled[y*resampled_width*channels+x*channels+c] = + (unsigned char)(value); + } + } + } + /* done */ + return 1; +} + +void testXI(rdpContext* context) +{ + int major = 2, minor = 2; + xfInfo* xfi; + + XIDeviceInfo *info; + int ndevices, i, j; + + xfi = ((xfContext*) context)->xfi; + + + XIQueryVersion(xfi->display, &major, &minor); + if (major * 1000 + minor < 2002) + { + printf("Server does not support XI 2.2\n"); + return; + } + + printf("XI supported\n"); + + + + info = XIQueryDevice(xfi->display, XIAllDevices, &ndevices); + + for (i = 0; i < ndevices; i++) + { + XIDeviceInfo *dev = &info[i]; + printf("Device name %s\n", dev->name); + for (j = 0; j < dev->num_classes; j++) + { + XIAnyClassInfo *class = dev->classes[j]; + XITouchClassInfo *t = (XITouchClassInfo*)class; + + if (class->type != XITouchClass) + continue; + + printf("%s touch device, supporting %d touches.\n", + (t->mode == XIDirectTouch) ? "direct" : "dependent", + t->num_touches); + } + } + +} + void testXV(rdpContext* context) { xfInfo* xfi; @@ -392,7 +506,9 @@ void xf_hw_end_paint(rdpContext* context) if (run == 0) { run++; - testXV(context); + //testXV(context); + testXI(context); + } }