Re: [PATCH] new driver for ITM Touch touchscreen

Paulo Marques
2005-03-08T18:25:18Z

Hans-Christian Egtvedt wrote:
> [...]
> Any tips are welcome. Is this done before with a touchscreen?

Just a minor nitpick, not really related to the mouse problem. More of
coding style problem.

IMHO the UCP and UCOM macros just obfuscate the code. If you do not want
to write "((unsigned char *) urb->transfer_buffer)[0]" every time (I can
perfectly understand that), maybe using a local "u8 *" var would do the
trick.

Something like this:

> static void itmtouch_irq(struct urb *urb, struct pt_regs *regs)
> {
> struct itmtouch_dev * itmtouch = urb->context;
> int retval;
> u8 *tbuf;
>
> ....
>
> input_regs(&itmtouch->inputdev, regs);
>
> tbuf = (u8 *)(urb->transfer_buffer);
>
> /* if pressure has been released, then don't report X/Y */
> if (!(tbuf[7] & 0x20)) {
> input_report_abs(&itmtouch->inputdev, ABS_X,
> (tbuf[0] & 0x1F) << 7 | (tbuf[3] & 0x7F));
> input_report_abs(&itmtouch->inputdev, ABS_Y,
> (tbuf[1] & 0x1F) << 7 | (tbuf[4] & 0x7F));
> }
>
> input_report_abs(&itmtouch->inputdev, ABS_PRESSURE,
> (tbuf[2] & 0x1) << 7 | (tbuf[5] & 0x7F));
> input_report_key(&itmtouch->inputdev, BTN_TOUCH, !(tbuf[7] & 0x20));
> /* TODO: Do we need to use input_sync() ? */
> /* input_sync(&itmtouch->inputdev); */
>
> ......

This is perfectly readable without one having to find out what those
macros mean, and it is even easier for the compiler to optimize (even
though gcc will probably optimize both versions just fine).

--
Paulo Marques - www.grupopie.com

All that is necessary for the triumph of evil is that good men do nothing.
Edmund Burke (1729 - 1797)