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

scroll automap content with the mouse (proof of concept) #1809

Draft
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

fabiangreffrath
Copy link
Owner

Fixes #1729

@MrAlaux
Copy link
Collaborator

MrAlaux commented Aug 1, 2024

I tried this artifact (Win-64), but couldn't get the feature to work: I bound Mouse Shift to Z, Shift and Mouse2 and tried pressing and holding each and all of them then moving the mouse, to no avail.

@fabiangreffrath
Copy link
Owner Author

I can reproduce this, but I swear I had it working yesterday. Now it seems that mouse movement event aren't even passed to AM_Responder() anymore. Now what's that? Very strange.

@fabiangreffrath
Copy link
Owner Author

Can you confirm that it works with Uncapped Framerate disabled? What the... 🤔

@fabiangreffrath
Copy link
Owner Author

Can you confirm that it works with Uncapped Framerate disabled? What the... 🤔

I'm afraid I need some support from @ceski-1 here.

@rfomin
Copy link
Collaborator

rfomin commented Aug 1, 2024

Here is the culprit:

diff --git a/src/d_main.c b/src/d_main.c
index ead2b8ba..7f346438 100644
--- a/src/d_main.c
+++ b/src/d_main.c
@@ -191,7 +191,7 @@ void D_PostEvent(event_t *ev)
   switch (ev->type)
   {
     case ev_mouse:
-      if (uncapped && raw_input)
+      if (uncapped && raw_input && !automapactive)
       {
         G_MovementResponder(ev);
         G_PrepMouseTiccmd();

Still works awkwardly with uncapped == true

@fabiangreffrath
Copy link
Owner Author

There is a similar line in

if (!uncapped || !raw_input)

@rfomin
Copy link
Collaborator

rfomin commented Aug 1, 2024

I think the code in D_PostEvent just skips all mouse events in uncapped mode. We only use ev_mouse in gameplay, for the menus it's ev_mouse_state.

@ceski-1
Copy link
Collaborator

ceski-1 commented Aug 2, 2024

At a first glance, I don't think this will be trivial. The mouse input code doesn't consider this at all.

@MrAlaux
Copy link
Collaborator

MrAlaux commented Aug 2, 2024

Can you confirm that it works with Uncapped Framerate disabled? What the... 🤔

Late reply, but yes, it works with capped.

You might be aware, but I noticed that the scrolling speed isn't adjusted by zoom; I think it should be. Other than that, I like it!

@rfomin
Copy link
Collaborator

rfomin commented Aug 2, 2024

At a first glance, I don't think this will be trivial. The mouse input code doesn't consider this at all.

By adding another event type, we can avoid mouse input code:

diff --git a/src/am_map.c b/src/am_map.c
index f717f8a9..7950030b 100644
--- a/src/am_map.c
+++ b/src/am_map.c
@@ -977,7 +977,7 @@ boolean AM_Responder
   m_paninc.x = 0;
   m_paninc.y = 0;
 
-  if (mousepan && ev->type == ev_mouse)
+  if (mousepan && ev->type == ev_mouse_rel)
   {
     m_paninc.x -= (int)G_CalcMouseSide(ev->data1) * MAPUNIT;
     m_paninc.y += (int)G_CalcMouseVert(ev->data2) * MAPUNIT;
diff --git a/src/d_event.h b/src/d_event.h
index 18c9ee30..d0455000 100644
--- a/src/d_event.h
+++ b/src/d_event.h
@@ -34,6 +34,7 @@ typedef enum evtype_e
   ev_mouseb_up,
   ev_mouse,
   ev_mouse_state,
+  ev_mouse_rel,
   ev_joyb_down,
   ev_joyb_up,
   ev_joystick,
diff --git a/src/i_input.c b/src/i_input.c
index 5c1716ae..343b3989 100644
--- a/src/i_input.c
+++ b/src/i_input.c
@@ -19,11 +19,11 @@
 #include "d_event.h"
 #include "d_main.h"
 #include "doomkeys.h"
+#include "doomstat.h"
 #include "doomtype.h"
 #include "i_gamepad.h"
 #include "i_printf.h"
 #include "i_system.h"
-#include "m_config.h"
 
 #define AXIS_BUTTON_DEADZONE (SDL_JOYSTICK_AXIS_MAX / 3)
 
@@ -424,12 +424,19 @@ void I_DelayEvent(void)
 void I_ReadMouse(void)
 {
     static event_t ev = {.type = ev_mouse};
+    static int oldgametic;
 
     SDL_GetRelativeMouseState(&ev.data1, &ev.data2);
 
     if (ev.data1 || ev.data2)
     {
         D_PostEvent(&ev);
+        if (oldgametic != gametic)
+        {
+            oldgametic = gametic;
+            ev.type = ev_mouse_rel;
+            D_PostEvent(&ev);
+        }
         ev.data1 = ev.data2 = 0;
     }
 }

Still the interpolation is not working properly.

@ceski-1
Copy link
Collaborator

ceski-1 commented Aug 2, 2024

By adding another event type, we can avoid mouse input code:

I spent an hour on it and failed. My idea is a stripped down AM_Responder that accumulates mouse input.

diff.txt

@fabiangreffrath
Copy link
Owner Author

Wow, this is getting really complicated.

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

Successfully merging this pull request may close these issues.

[Feature] Mouse scrolls automap
4 participants