Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

main_loop_post_key_event() 有问题 #434

Open
21pages opened this issue Jun 29, 2020 · 1 comment
Open

main_loop_post_key_event() 有问题 #434

21pages opened this issue Jun 29, 2020 · 1 comment

Comments

@21pages
Copy link

21pages commented Jun 29, 2020

ret_t main_loop_post_key_event(main_loop_t* l, bool_t pressed, uint8_t key) {
  event_queue_req_t r;
  key_event_t event;
  main_loop_simple_t* loop = (main_loop_simple_t*)l;
  return_value_if_fail(loop != NULL, RET_BAD_PARAMS);

  loop->last_key = key;
  event.key = key;

  if (pressed) {
    loop->key_pressed = TRUE;
    event.e.type = EVT_KEY_DOWN;

    r.key_event = event;
    return main_loop_queue_event(l, &r);
  } else {
    if (loop->key_pressed) {
      loop->key_pressed = FALSE;
      event.e.type = EVT_KEY_UP;

      r.key_event = event;
      return main_loop_queue_event(l, &r);
    }
  }

可以多次按下, 却不能多次释放, 组合键 比如 Ctrl +Shift ,Ctrl按下Shift按下,Ctrl 释放Shift释放, 结果是Ctrl按下Shift按下Ctrl释放, Shift释放就丢了
loop->key_pressed, loop->last_key其它地方也没有引用

@xianjimli
Copy link
Member

好的。谢谢,我想想

@xianjimli xianjimli pinned this issue Jun 29, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants