[directfb-dev] df_input: mouse reported/used as joystick ?
Stefan Lucke
stefan at lucke.in-berlin.de
Sun Sep 25 19:19:36 CEST 2005
On Samstag, 24. September 2005 11:44, Stefan Lucke wrote:
> Hi,
>
> I'm just writing an touchscreen kernel driver for an egalx device
> connected via PS/2.
>
> http://www.cartft.com/catalog/il/449
>
> In default kernel 2.6.13.2 there is only a driver which supports the
> USB version of this devoce.
>
> I noticed an odd behaviour when testing the driver with df_input.
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;
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.
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;
}
--
Stefan Lucke
-------------- next part --------------
A non-text attachment was scrubbed...
Name: touchscreen.02.diff
Type: text/x-diff
Size: 1586 bytes
Desc: not available
Url : http://mail.directfb.org/pipermail/directfb-dev/attachments/20050925/37cd5a50/touchscreen.02.bin
More information about the directfb-dev
mailing list