-1

There have 2 Qt program.

One is a normal program have QComboBox it isn't I design.

I design another, after startup it hide and if keep press KEY_POWER 2 sec it show, you can press KEY_TAB/KEY_LEFT/KEY_DOWN move focus between two buttons.

By the way. For get keyboard input on hiding, my method is read from /dev/input/event0 on thread if read KEY_POWER 2 sec show it.

void *ThreadMinitorKey(void *arg)
{
    struct input_event key_event;

    fd = open("/dev/input/event0", O_RDONLY);

    while(1) {
        len = read(fd, &key_event, sizeof(key_event));
        if (len != -1 && key_event.type == EV_KEY) {
            if (press_KEW_POWER_2_sec()) {
                g_dialog->show();
            }
        }
    }
}

Run well

enter image description here focus on the QComoBox

enter image description here press keyboard KEY_POWER 2 second my window show,the focus on left button. Attention to the QComboBox, it background from blue to white.

enter image description here press KEY_LEFT/KEY_TAB/KEY_RIGHT focus move to other button.

Run error

enter image description here QComboBox on popup

enter image description here press keyboard KEY_POWER 2 second my window show,the focus on left button. The QComboBox background still blue.

enter image description here press KEY_DOWN the effect on the QComobox

acraig5075
  • 10,588
  • 3
  • 31
  • 50
笼笼鸽
  • 1
  • 1

1 Answers1

0

pseudo touch input device

I find a rule, when QComoBox is popup, if press KEY_ENTER or touch screen any where the window will disappear.

So simulation touch input click screen any where before window show.

void pseudo_touch(int fd)
{
    struct input_event event;
    int len;

    event.type = EV_ABS;                        // touch press down
    event.code = ABS_PRESSURE;
    event.value = 1;
    gettimeofday(&event.time, NULL);
    len = write(fd, &event, sizeof(event));


    event.type = EV_ABS;                       // post coordinate X,Y make sure don't press any control box
    event.code = ABS_X;                        // ADC range is from 0 to 4095
    event.value = 0x9000;                      // ADC X = 0x9000
    gettimeofday(&event.time, NULL);
    len = write(fd, &event, sizeof(event));
    event.type = EV_ABS;
    event.code = ABS_Y;                        // ADC Y = 0xA000
    event.value = 0xa000;
    gettimeofday(&event.time, NULL);
    len = write(fd, &event, sizeof(event));

    event.type = EV_SYN;                       // synchronous one event
    event.code = SYN_REPORT;
    event.value = 0;
    gettimeofday(&event.time, NULL);
    len = write(fd, &event, sizeof(event));

    event.type = EV_ABS;                       // touch press up
    event.code = ABS_PRESSURE;
    event.value = 0;
    gettimeofday(&event.time, NULL);
    len = write(fd, &event, sizeof(event));

    event.type = EV_SYN;                       // synchronous one event
    event.code = SYN_REPORT;
    event.value = 0;
    gettimeofday(&event.time, NULL);
    len = write(fd, &event, sizeof(event));
}

void *ThreadMinitorKey(void *arg)
{
    struct input_event key_event;

    fd       = open("/dev/input/event0", O_RDONLY);   // Keyboard   
    fd_touch = open("/dev/input/event2", O_RDWR);     // Touch

    while(1) {
        len = read(fd, &key_event, sizeof(key_event));
        if (len != -1 && key_event.type == EV_KEY) {
            if (press_KEW_POWER_2_sec()) {
                pseudo_touch(fd_touch);
                g_dialog->show();
            }
        }
    }
}


void DlgShutdown::focusInEvent(QFocusEvent *event)
{
    pBtnCanel->setFocus();
}
笼笼鸽
  • 1
  • 1