summaryrefslogtreecommitdiffhomepage
path: root/src/debug
diff options
context:
space:
mode:
authormidipix <writeonce@midipix.org>2016-07-08 01:03:08 -0400
committermidipix <writeonce@midipix.org>2016-07-21 03:47:26 -0400
commit0e0975a453a7cacee3e1baf95042ef151fc94720 (patch)
tree87a9b5eb05a1f3c1630932be512caf838e467f88 /src/debug
parent1bab02981629876bc6059d9ba685b11ebd01374e (diff)
downloadptycon-0e0975a453a7cacee3e1baf95042ef151fc94720.tar.bz2
ptycon-0e0975a453a7cacee3e1baf95042ef151fc94720.tar.xz
debug: ptyc_dbg_event(): initial implementation.
Diffstat (limited to 'src/debug')
-rw-r--r--src/debug/ptyc_dbg_event.c101
1 files changed, 99 insertions, 2 deletions
diff --git a/src/debug/ptyc_dbg_event.c b/src/debug/ptyc_dbg_event.c
index 45cea3e..1398408 100644
--- a/src/debug/ptyc_dbg_event.c
+++ b/src/debug/ptyc_dbg_event.c
@@ -12,8 +12,105 @@
#include <ptycon/ptycon.h>
#include "ptycon_driver_impl.h"
+static int ptyc_dbg_input_record(void * hout, nt_input_record * rec)
+{
+ char * ch;
+ uintptr_t buffer[512/sizeof(uintptr_t)];
+ uint32_t nwritten;
+
+ ntapi->tt_aligned_block_memset(
+ buffer,0,sizeof(buffer));
+
+ ch = (char *)buffer;
+
+ switch (rec->event_type) {
+ case NT_KEY_EVENT:
+ ntapi->snprintf(ch,sizeof(buffer),
+ "key event. "
+ "key down: %d; "
+ "repeat count: %d; "
+ "virtual key code: 0x%04x; "
+ "virtual scan code: 0x%04x; "
+ "unicode char: 0x%04x; "
+ "control key: 0x%04x.\n",
+ rec->key_event.key_down,
+ rec->key_event.repeat_count,
+ rec->key_event.virtual_key_code,
+ rec->key_event.virtual_scan_code,
+ rec->key_event.unicode_char,
+ rec->key_event.control_key_state);
+ break;
+
+ case NT_MOUSE_EVENT:
+ ntapi->snprintf(ch,sizeof(buffer),
+ "mouse event. "
+ "pos.x: %d; "
+ "pos.y: %d; "
+ "button state: 0x%04x; "
+ "ctrl key state: 0x%04x; "
+ "event flags: 0x%04x.\n",
+ rec->mouse_event.mouse_position.x,
+ rec->mouse_event.mouse_position.y,
+ rec->mouse_event.button_state,
+ rec->mouse_event.control_key_state,
+ rec->mouse_event.event_flags);
+ break;
+
+ case NT_WINDOW_BUFFER_SIZE_EVENT:
+ ntapi->snprintf(ch,sizeof(buffer),
+ "window event. "
+ "size.x: %d; "
+ "size.y: %d.\n",
+ rec->window_event.size.x,
+ rec->window_event.size.y);
+
+ break;
+
+ case NT_MENU_EVENT:
+ ntapi->snprintf(ch,sizeof(buffer),
+ "menu event. "
+ "command id: %d.\n",
+ rec->menu_event.command_id);
+ break;
+
+ case NT_FOCUS_EVENT:
+ ntapi->snprintf(ch,sizeof(buffer),
+ "focus event. "
+ "set focus: %d.\n",
+ rec->focus_event.set_focus);
+ break;
+
+ default:
+ return NT_STATUS_INTERNAL_ERROR;
+ }
+
+ return ntcon->write_console_ansi(
+ hout,
+ ch,
+ ntapi->tt_string_null_offset_multibyte(ch),
+ &nwritten,0);
+}
+
+
int ptyc_dbg_event(struct ptyc_driver_ctx_impl * ictx)
{
- (void)ictx;
- return ntapi->tt_wait_for_dummy_event();
+ nt_input_record conevt[64];
+ uint32_t nread;
+ unsigned i;
+
+ do {
+ if (!(ntcon->read_console_input_utf16(
+ ictx->tctx.hin,
+ conevt,64,
+ &nread)))
+ return -1;
+
+ for (i=0; i<nread; i++)
+ if (!(ptyc_dbg_input_record(
+ ictx->tctx.hout,
+ &conevt[i])))
+ return -2;
+ } while (1);
+
+ return -3;
}