[directfb-dev] df_input: mouse reported/used as joystick ?
Denis Oliver Kropp
dok at directfb.org
Sun Sep 25 20:30:56 CEST 2005
Quoting Stefan Lucke:
> Handling this touchscreen as joystick is a combination of driver code
> and directfb code.
>
> When setting supported mouse keys with:
> set_bit(BTN_MOUSE,psmouse->dev.keybit);
> or
> set_bit(BTN_TOUCH,psmouse->dev.keybit);
> only additional bits are set.
>
> So in directfb code it is checked with:
> (touchkitPS/2 eGalax Touchscreen) num_rels = 0, num_abs = 2, num_buttons = 3
>
> /* Mouse or Touchscreen? */
> if ((num_rels >= 2 && num_buttons) || (num_abs == 2 && (num_buttons == 1)))
> info->desc.type |= DIDTF_MOUSE;
> else if (num_abs && num_buttons) /* Or a Joystick? */
> info->desc.type |= DIDTF_JOYSTICK;
AFAIK there's no explicit classification in the Linux Input Architecture to
distinguish between mouse/touchscreen and joystick :-(
> When setting key with:
> psmouse->dev.keybit[LONG(BTN_MOUSE)] = BIT(BTN_LEFT);
> it is reported with num_bottons = 1 hand handled as mouse/touchscreen.
>
> But it should be always handled as touchscreen.
> So I think directfb code has to be changed, as to my opinion button
> counting is wrong. Only buttons up to BTN_JOYSTICK are counted.
> #define BTN_JOYSTICK 0x120
> #define BTN_TOOL_FINGER 0x145
> #define BTN_TOUCH 0x14a
>
> Attached patch fixes the recognition for me and maps
> BTN_TOUCH and BTN_TOOL_FINGER to BTN_MOUSE.
Ok, looks like BTN_TOUCH implies that it's a touch screen...
> What would be the right place to specify coordinate translation
> for touchscreen devices ? At the moment I use the following in
> df_input to get correct coordinates:
>
> static int llx = 1777, lly = 1727, urx = 276, ury = 328;
> static int scale_x(int val)
> {
> return /*screen_width -*/
> (screen_width / 8 +
> (((screen_width * 6) / 8) * (val - llx)) / (urx - llx));
> return ((val - llx) / (urx - llx)) * ((screen_width * 6) / 8) + screen_width / 8 ;
> return ((val - llx) / (urx - llx)) * 1536 + 256;
> }
>
> static int scale_y(int val)
> {
> return screen_height -
> (screen_height / 8 +
> (((screen_height * 6) / 8) * (val - lly)) / (ury - lly));
> return ((val - lly) / (ury - lly)) * ((screen_height * 6) / 8) + screen_height / 8 ;
> return ((val - lly) / (ury - lly)) * 1536 + 256;
> }
Generic support for input device calibration and scaling like this is missing.
The input core would be the best place, with an extension to the driver API.
> - /* Mouse or Touchscreen? */
> - if ((num_rels >= 2 && num_buttons) || (num_abs == 2 && (num_buttons == 1)))
> + /* Mouse, Touchscreen or Smartpad ? */
> + if ((test_bit( EV_KEY, evbit ) &&
> + (test_bit( BTN_TOUCH, keybit ) || test_bit( BTN_TOOL_FINGER, keybit ))) ||
> + ((num_rels >= 2 && num_buttons) || (num_abs == 2 && (num_buttons == 1))))
> info->desc.type |= DIDTF_MOUSE;
> else if (num_abs && num_buttons) /* Or a Joystick? */
> info->desc.type |= DIDTF_JOYSTICK;
I'll apply your patch. In the long term the linux_input driver should
be cleaned up or rewritten.
--
Best regards,
Denis Oliver Kropp
.------------------------------------------.
| DirectFB - Hardware accelerated graphics |
| http://www.directfb.org/ |
"------------------------------------------"
More information about the directfb-dev
mailing list