Commit 4c188679 authored by abmyii's avatar abmyii
Browse files

Calculate scale factor automatically

parent 80a38062
......@@ -73,6 +73,8 @@ thread_local int dummy_tls[2];
struct libevdev *dev;
struct libevdev_uinput *uidev;
float scale_factor;
bool lmb;
bool rmb;
bool mmb;
......@@ -145,6 +147,7 @@ MirScreencastParameters get_screencast_params(MirConnection* connection,
uint32_t output_id)
{
MirScreencastParameters params;
if (requested_region.size() == 4)
{
/* TODO: the region should probably be validated
......@@ -469,9 +472,9 @@ static void doptr(int buttonMask, int x, int y, rfbClientPtr cl)
int middle_down = buttonMask & 0x2;
/* printf("%d %d %d %d\n", buttonMask, left_down, right_down, right_down >> 2); */
libevdev_uinput_write_event(uidev, EV_ABS, ABS_X, x*2.5);
libevdev_uinput_write_event(uidev, EV_ABS, ABS_Y, y*2.5);
libevdev_uinput_write_event(uidev, EV_SYN, SYN_REPORT, 0);
/* libevdev_uinput_write_event(uidev, EV_ABS, ABS_X, x*scale_factor); */
/* libevdev_uinput_write_event(uidev, EV_ABS, ABS_Y, y*scale_factor); */
/* libevdev_uinput_write_event(uidev, EV_SYN, SYN_REPORT, 0); */
if (left_down) {
libevdev_uinput_write_event(uidev, EV_KEY, BTN_LEFT, 1);
......@@ -480,8 +483,8 @@ static void doptr(int buttonMask, int x, int y, rfbClientPtr cl)
libevdev_uinput_write_event(uidev, EV_ABS, ABS_MT_TRACKING_ID, 10);
libevdev_uinput_write_event(uidev, EV_KEY, BTN_TOUCH, 1);
libevdev_uinput_write_event(uidev, EV_KEY, BTN_TOOL_FINGER, 1);
libevdev_uinput_write_event(uidev, EV_ABS, ABS_MT_POSITION_X, x*2.5);
libevdev_uinput_write_event(uidev, EV_ABS, ABS_MT_POSITION_Y, y*2.5);
libevdev_uinput_write_event(uidev, EV_ABS, ABS_MT_POSITION_X, x*scale_factor);
libevdev_uinput_write_event(uidev, EV_ABS, ABS_MT_POSITION_Y, y*scale_factor);
libevdev_uinput_write_event(uidev, EV_SYN, SYN_REPORT, 0);
lmb = true;
}
......@@ -530,6 +533,7 @@ void do_screencast(EGLSetup const& egl_setup,
int bpp=4;
int maxx = size.width.as_uint32_t();
int maxy = size.height.as_uint32_t();
rfbScreenInfoPtr rfbScreen = rfbGetScreen(NULL,NULL,maxx,maxy,8,3,bpp);
rfbScreen->desktopName = "MIR Screen";
// rfbScreen->frameBuffer = (char*)malloc(maxx*maxy*bpp);
......@@ -710,6 +714,10 @@ try
MirScreencastParameters params =
get_screencast_params(connection.get(), *display_config, requested_size, screen_region, output_id);
// Calculate scale factor (NOTE: assumes scale ratio is equivalent on both axes)
scale_factor = (float)params.region.width / (float)params.width;
printf("%d %d %f\n", params.width, params.region.width, scale_factor);
double capture_rate_limit = get_capture_rate_limit(*display_config, params);
double capture_fps = capture_rate_limit/capture_interval;
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment