سؤال

I have a small TFT with touch control connected to a Raspberry Pi. The touchscreen works well within X windows.

I would like to be able to use the touchscreen outside of X windows. Something simple, like two buttons on the screen.

I have experience with C and writing to the framebuffer using SDL. Or directly to memory.

I have no idea how to detect the input of the touchscreen and I am hoping some one could point me in the right direction.

I see the touchscreen as /dev/input/event0

هل كانت مفيدة؟

المحلول

It seems that you are just seeing a regular event device. What have you done so far? You might try for example Using the Input Subsystem article on Linux Journal.

What you should try at first should probably be:

/* how many bytes were read */
size_t rb;
/* the events (up to 64 at once) */
struct input_event ev[64];

rb=read(fd,ev,sizeof(struct input_event)*64);

if (rb < (int) sizeof(struct input_event)) {
    perror("evtest: short read");
    exit (1);
}

for (yalv = 0;
     yalv < (int) (rb / sizeof(struct input_event));
     yalv++)
{
    //if (EV_KEY == ev[yalv].type)
        printf("%ld.%06ld ",
               ev[yalv].time.tv_sec,
               ev[yalv].time.tv_usec,
        printf("type %d code %d value %d\n",
               ev[yalv].type,
               ev[yalv].code, ev[yalv].value);
}

Then you should pay attention, what event types are being emitted, and then work with them further.

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top