diff options
Diffstat (limited to 'src/lib')
-rw-r--r-- | src/lib/include/gip.h | 3 | ||||
-rw-r--r-- | src/lib/libkogata/gip.c | 4 | ||||
-rw-r--r-- | src/lib/libkogata/mainloop.c | 4 |
3 files changed, 10 insertions, 1 deletions
diff --git a/src/lib/include/gip.h b/src/lib/include/gip.h index c2167c4..9c66091 100644 --- a/src/lib/include/gip.h +++ b/src/lib/include/gip.h @@ -16,7 +16,8 @@ typedef struct { noarg_gip_callback_t reset, initiate, ok, failure, enable_features, disable_features, - query_mode, set_mode, switch_buffer; + query_mode, set_mode, switch_buffer, + key_down, key_up; void (*buffer_info)(gip_handler_t *s, gip_msg_header *m, gip_buffer_info_msg *i); void (*mode_info)(gip_handler_t *s, gip_msg_header *m, gip_mode_info_msg *i); void (*buffer_damage)(gip_handler_t *s, gip_msg_header *m, gip_buffer_damage_msg *i); diff --git a/src/lib/libkogata/gip.c b/src/lib/libkogata/gip.c index 7fa1cca..852cc05 100644 --- a/src/lib/libkogata/gip.c +++ b/src/lib/libkogata/gip.c @@ -167,6 +167,10 @@ void giph_msg_header(mainloop_fd_t *fd) { mainloop_expect(fd, &h->mode_info_msg_buf, sizeof(gip_mode_info_msg), giph_mode_info); } else if (code == GIPN_BUFFER_DAMAGE) { mainloop_expect(fd, &h->buffer_damage_msg_buf, sizeof(gip_buffer_damage_msg), giph_buffer_damage); + } else if (code == GIPN_KEY_DOWN) { + use_cb = h->cb->key_down; + } else if (code == GIPN_KEY_UP) { + use_cb = h->cb->key_up; } else { use_cb = h->cb->unknown_msg; } diff --git a/src/lib/libkogata/mainloop.c b/src/lib/libkogata/mainloop.c index d8890e7..e7fdfa4 100644 --- a/src/lib/libkogata/mainloop.c +++ b/src/lib/libkogata/mainloop.c @@ -88,12 +88,14 @@ void mainloop_run() { } // ---- Do the select + dbg_printf("(mainloop) begin select\n"); bool ok = select(sel_arg, nfds, -1); if (!ok) { dbg_printf("(mainloop) Failed to select.\n"); free(sel_arg); return; } + dbg_printf("(mainloop) end select\n"); { // Parse result int i = 0; @@ -105,6 +107,7 @@ void mainloop_run() { fd->rd_buf_filled += read(fd->fd, 0, fd->rd_buf_expect_size - fd->rd_buf_filled, fd->rd_buf + fd->rd_buf_filled); if (fd->rd_buf_filled == fd->rd_buf_expect_size) { + dbg_printf("(mainloop) finish read %d\n", fd->rd_buf_expect_size); fd->rd_buf_filled = 0; ASSERT(fd->rd_on_full != 0); fd->rd_on_full(fd); @@ -116,6 +119,7 @@ void mainloop_run() { fd->wr_bufs[0].written += write(fd->fd, 0, remain_size, write_ptr); if (fd->wr_bufs[0].written == fd->wr_bufs[0].size) { + dbg_printf("(mainloop) finish write %d\n", fd->wr_bufs[0].size); if (fd->wr_bufs[0].must_free) free(fd->wr_bufs[0].buf); for (int i = 1; i < MAINLOOP_MAX_WR_BUFS; i++) { fd->wr_bufs[i-1] = fd->wr_bufs[i]; |