diff --git a/src/doompanning.cc b/src/doompanning.cc index 64520f4..e3f7f88 100644 --- a/src/doompanning.cc +++ b/src/doompanning.cc @@ -609,7 +609,15 @@ int doom_controller_loop(ControllerContext &ctx) } if (ImGui::IsKeyPressed(ImGuiKey_F10, false)) + { ctx.uiVisible = !ctx.uiVisible; + // FIXME: sadly this has issues: after toggling the ui off and + // on again the mouse cursor is invisible. Even using + // SDL_ShowCursor() unconditionally did not fix it. I suspect + // it's caused by some interaction between SLD and ImGui. + //if (SDL_SetRelativeMouseMode(ctx.uiVisible ? SDL_TRUE : SDL_FALSE) < 0) + // log_warn("SDL_SetRelativeMouseMode: %s", SDL_GetError()); + } } static ImVec2 panStartPos; @@ -707,7 +715,7 @@ int main(int argc, char *argv[]) dp_sdl_fatal("SDL_CreateRenderer"); IMGUI_CHECKVERSION(); - auto imgui = ImGui::CreateContext(); + /*auto imgui = */ImGui::CreateContext(); ImGui::GetIO().IniFilename = "doompanning_ui.ini"; ImGui::StyleColorsDark(); ImGui_ImplSDL2_InitForSDLRenderer(window, renderer); diff --git a/src/dp_common.h b/src/dp_common.h index b825b14..e79f925 100644 --- a/src/dp_common.h +++ b/src/dp_common.h @@ -82,9 +82,29 @@ typedef struct __attribute__((packed, aligned(4))) DP_DoomCommand cmd; } MsgMcstCommand; +// Doom input event types (from d_event.h). +typedef enum doom_evtype_t +{ + DP_ev_keydown, + DP_ev_keyup, + DP_ev_mouse, + DP_ev_joystick +} dp_doom_evtype_t; + +// Doom event structure (from d_event.h). +typedef struct +{ + dp_doom_evtype_t type; + int data1; // keys / mouse/joystick buttons + int data2; // mouse/joystick x move + int data3; // mouse/joystick y move +} dp_doom_event_t; + typedef struct __attribute__((packed, aligned(4))) { MessageBase head; + u8 eventCount; + dp_doom_event_t events[1]; } MsgInputs; void dp_errno_fatal(const char *const msg); diff --git a/src/dp_doom/linuxdoom-1.10/ib_video/ib_video_nng.c b/src/dp_doom/linuxdoom-1.10/ib_video/ib_video_nng.c index 892fc55..adc52aa 100644 --- a/src/dp_doom/linuxdoom-1.10/ib_video/ib_video_nng.c +++ b/src/dp_doom/linuxdoom-1.10/ib_video/ib_video_nng.c @@ -55,6 +55,8 @@ struct DoomContext nng_socket sub; doomid_t id; DP_DoomState state; + u8 eventCount; + dp_doom_event_t events[MAXEVENTS]; DoomStateFunc *f; }; @@ -206,6 +208,11 @@ void IB_StartTic (void) event.data1 = xlatekey(sdl_event.key.keysym.sym); D_PostEvent(&event); */ + _Static_assert(sizeof(event_t) == sizeof(dp_doom_event_t), + "Size mismatch between dooms event_t and doompannings dp_doom_event_t. Packing?"); + event_t event; + static int button_state; + //SDL_Event sdl_event; } void IB_GetFramebuffer(unsigned char **pixels, size_t *pitch)