Thursday, October 16, 2014

Calibrating Wacom BAMBOO ONE CTE-660 to Particular portion of Screen

I was working on calibrating Wacom tablets (Wacom Bamboo One CTE-660) to particular portion of the desktop screen. Initially I implemented my own mechanism by editing wacom driver configuration files to calibrate but lately I found xsetwacom utility which is very useful to query or change properties on the devices loaded by the wacom driver. The modification of properties happens at runtime and is not persistent through X server restarts.
Wacom Bamboo One CTE-660
  To install xsetwacom, first of all download it from Here and extract the downloaded file & follow the instruction given in INSTALL file.

Once you install xsetwacom utility, to calibrate(map) wacom tablet to left top most portion of 500X500 area of your screen, run the following command.

xsetwacom set "Wacom Bamboo1 5x8 stylus" MapToOutput 500X500+0+0

To calibrate(map) wacom tablet to entire scree run the following command

xsetwacom set "Wacom Bamboo1 5x8 stylus" MapToOutput VGA1

 The following program creates a xwindow & by pressing 'm' key calibrates(map) Wacom Bamboo1 5x8 stylus to the created window and by pressing 'u' calibrates Wacom Bamboo1 5x8 stylus to entire screen.

#include <stdio.h>
#include <stdlib.h>
#include <X11/Xlib.h>
#include <X11/Xutil.h>
#include <X11/Xos.h>
#include <X11/Xatom.h>
#include <X11/keysym.h>
#include <X11/extensions/shape.h>
#define NIL (0)

int main()
  char *window_name = (char*)"gem input window";
  Display *dpy = XOpenDisplay(NIL);
  int whiteColor = WhitePixel(dpy, DefaultScreen(dpy));
  Window w = XCreateSimpleWindow(dpy, RootWindow(dpy, DefaultScreen(dpy)), 0, 0, 500, 500, 0, whiteColor, whiteColor);
  XSelectInput(dpy, w, ButtonPressMask| PointerMotionMask| LeaveWindowMask| EnterWindowMask| ButtonReleaseMask );
  XStoreName(dpy, w, window_name);
  XMapWindow(dpy, w);
  for(;;) {
   XEvent e;
   XNextEvent(dpy, &e);
   if(e.xany.window == w)
         case KeyPress: 

        if (e.xkey.keycode == XKeysymToKeycode(dpy, XK_m))
        printf("\n Calibration to 500X500 Done");
        system("xsetwacom set \"Wacom Bamboo1 5x8 stylus\" MapToOutput 500X500+0+0");
        if (e.xkey.keycode == XKeysymToKeycode(dpy, XK_u))
          printf("\n Calibrating to entire screen Done");
          system("xsetwacom set \"Wacom Bamboo1 5x8 stylus\" MapToOutput VGA1");
        if (e.xkey.keycode == XKeysymToKeycode(dpy, XK_e))
        XDestroyWindow(dpy, w);
  return 0;


No comments:

Post a Comment