Skip to content

Commit fdc5d76

Browse files
committed
Fixed support for multiple mice also on Windows
1 parent 2e00f3f commit fdc5d76

File tree

3 files changed

+33
-3
lines changed

3 files changed

+33
-3
lines changed

Diff for: ChangeLog

+4
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
Version 2.9.11dev:
2+
3+
* Fixed support for multiple mice also on Windows.
4+
15
Version 2.9.9dev:
26

37
* Added 8BitDo controller configurations, updated dualshock 3 for Linux.

Diff for: libfsemu/src/ml/mouse.c

-2
Original file line numberDiff line numberDiff line change
@@ -72,9 +72,7 @@ static void *manymouse_thread(void* data)
7272
ManyMouseEvent event;
7373
fs_ml_event *new_event;
7474
while (!fs_ml_is_quitting()) {
75-
// printf("..\n");
7675
while (ManyMouse_PollEvent(&event)) {
77-
// printf(" -- event type %d -- \n", event.type);
7876
if (event.type == MANYMOUSE_EVENT_RELMOTION) {
7977
// printf("MANYMOUSE_EVENT_RELMOTION\n");
8078
new_event = fs_ml_alloc_event();

Diff for: manymouse/windows_wminput.c

+29-1
Original file line numberDiff line numberDiff line change
@@ -345,6 +345,23 @@ static LRESULT CALLBACK RawWndProc(HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lP
345345
return pDefWindowProcA(hWnd, Msg, wParam, lParam);
346346
} /* RawWndProc */
347347

348+
#ifdef FSUAE
349+
350+
#include <SDL.h>
351+
#include <SDL_syswm.h>
352+
353+
extern SDL_Window *g_fs_ml_window;
354+
static WNDPROC OldWndProc;
355+
356+
static LRESULT CALLBACK NewWndProc(HWND hwnd, UINT Msg, WPARAM wParam, LPARAM lParam)
357+
{
358+
if (Msg == WM_INPUT)
359+
wminput_handler(wParam, lParam);
360+
361+
return CallWindowProc(OldWndProc, hwnd, Msg, wParam, lParam);
362+
}
363+
364+
#endif
348365

349366
static int init_event_queue(void)
350367
{
@@ -378,6 +395,18 @@ static int init_event_queue(void)
378395
rid.usUsage = 2; /* GeneralDestop Mouse usage. */
379396
rid.dwFlags = RIDEV_INPUTSINK;
380397
rid.hwndTarget = raw_hwnd;
398+
399+
#ifdef FSUAE
400+
if (g_fs_ml_window) {
401+
SDL_SysWMinfo wmInfo;
402+
SDL_VERSION(&wmInfo.version);
403+
SDL_GetWindowWMInfo(g_fs_ml_window, &wmInfo);
404+
HWND hwnd = wmInfo.info.win.window;
405+
rid.hwndTarget = hwnd;
406+
OldWndProc = (WNDPROC) SetWindowLongPtr(hwnd, GWLP_WNDPROC, (LONG_PTR)&NewWndProc);
407+
}
408+
#endif
409+
381410
if (!pRegisterRawInputDevices(&rid, 1, sizeof (rid)))
382411
{
383412
pDeleteCriticalSection(&mutex);
@@ -558,7 +587,6 @@ static void init_mouse(const RAWINPUTDEVICELIST *dev)
558587
available_mice++;
559588
} /* init_mouse */
560589

561-
562590
static int windows_wminput_init(void)
563591
{
564592
RAWINPUTDEVICELIST *devlist = NULL;

0 commit comments

Comments
 (0)