Skip to content

Commit 3179b15

Browse files
committed
Properly iterate over SDL displays and modes
1 parent b0bd935 commit 3179b15

File tree

6 files changed

+40
-28
lines changed

6 files changed

+40
-28
lines changed

.gitignore

+2-1
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ core
3333
/data/
3434
*.dbg
3535
/*.deb
36-
/demos
36+
/demos/
3737
/depcomp
3838
.deps
3939
/desktop/
@@ -58,6 +58,7 @@ fs-uae-device-helper
5858
/FS-UAE.geany
5959
fs-uae.rc
6060
fs-uae-with-dat
61+
/games/
6162
*.gcda
6263
/gen
6364
genblitter

debian/changelog

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,4 @@ fs-uae (0.0.0-0) unstable; urgency=low
22

33
* Dummy changelog entry.
44

5-
-- Frode Solheim <[email protected]> Sun, 10 Oct 2021 09:03:58 +00:00
5+
-- Frode Solheim <[email protected]> Sun, 10 Oct 2021 09:03:58 +0000

docs/mouse.md

+12-3
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,9 @@
99
FS-UAE supports multiple mice on many platforms through the ManyMouse library
1010
by Ryan C. Gordon.
1111

12+
**Note: FS-UAE 4 does not support multiple mice yet.** The rest of the this
13+
section applies to FS-UAE 3 only, for now.
14+
1215
The old `Mouse` host device is still present and works like before - this
1316
is basically the system cursor, and most likely, all connected mice will
1417
affect this host device in FS-UAE.
@@ -35,9 +38,15 @@ there is less input lag with the new mouse devices.
3538
## Windows
3639

3740
Support for multiple mice seems to work just fine on Windows out of the box.
41+
Note that with FS-UAE on modern Windows version, all devices seem to be named
42+
"HID-compliant mouse" instead of the actual device name, which makes a bit
43+
awkward to select the desired mouse device.
3844

3945
## macOS
4046

47+
**Note: Multiple mice are currently disabled on macOS**. This is due to
48+
annoying security warnings that I need to find a workaround for.
49+
4150
Support for multiple mice seems to work just fine on macOS out of the box
4251
on older macOS versions.
4352

@@ -86,13 +95,13 @@ reconnect them for the changes to work.
8695
To verify that it works, reconnect your mouse/mice if you haven't already
8796
and type:
8897

89-
ls -l /dev/input/mouse*
98+
ls -l /dev/input/event*
9099

91100
All files listed should now have read permissions for all users, something
92101
like this:
93102

94-
crw-r--r-- 1 root root 13, 32 aug. 20 17:30 /dev/input/mouse0
95-
crw-r--r-- 1 root root 13, 33 aug. 20 17:30 /dev/input/mouse1
103+
crw-rw-r-- 1 root input 13, 64 aug. 20 17:30 /dev/input/event0
104+
crw-rw-r-- 1 root input 13, 65 aug. 20 17:30 /dev/input/event1
96105

97106
If it did not work, you have to do additional steps to activate the rules.
98107
Perhaps a command to reinitialize udev, such as as `sudo udevstart`,

fsbuild/version.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,7 @@ def update_debian_changelog(version):
152152
# Only update date if version was changed
153153
author, date = line.split(" ")
154154
date = datetime.datetime.utcnow().strftime(
155-
"%a, %e %b %Y %H:%M:%S +00:00"
155+
"%a, %d %b %Y %H:%M:%S +0000"
156156
)
157157
lines.append("{} {}\n".format(author, date))
158158
else:

fsemu/src/fsemu-monitor.c

+8-9
Original file line numberDiff line numberDiff line change
@@ -158,22 +158,22 @@ void fsemu_monitor_init(void)
158158

159159
// FIXME: Move SDL-specific code to sdlwindow module (later)
160160

161-
int display_index = 0;
162-
while (true) {
161+
int num_displays = SDL_GetNumVideoDisplays();
162+
for (int i = 0; i < num_displays; i++) {
163163
SDL_DisplayMode mode;
164-
int error = SDL_GetDesktopDisplayMode(display_index, &mode);
164+
int error = SDL_GetDesktopDisplayMode(i, &mode);
165165
if (error) {
166166
break;
167167
}
168168

169169
fsemu_monitor_t monitor;
170-
monitor.index = display_index;
170+
monitor.index = i;
171171
SDL_Rect rect;
172-
error = SDL_GetDisplayBounds(display_index, &rect);
172+
error = SDL_GetDisplayBounds(i, &rect);
173173
if (error) {
174174
fsemu_monitor_log(
175175
"Error retrieving display bounds for display %d: %s\n",
176-
display_index,
176+
i,
177177
SDL_GetError());
178178
monitor.rect.x = 0;
179179
monitor.rect.y = 0;
@@ -214,17 +214,16 @@ void fsemu_monitor_init(void)
214214
#endif
215215

216216
fsemu_monitor_log("%d: %dx%d+%d+%d %d Hz Scale %0.2f\n",
217-
display_index,
217+
i,
218218
monitor.rect.w,
219219
monitor.rect.h,
220220
monitor.rect.x,
221221
monitor.rect.y,
222222
monitor.refresh_rate,
223223
monitor.scale);
224224
g_array_append_val(fsemu_monitor.list, monitor);
225-
display_index += 1;
226225
}
227-
fsemu_monitor.count = display_index;
226+
fsemu_monitor.count = num_displays;
228227

229228
g_array_sort(fsemu_monitor.list, fsemu_monitor_compare);
230229
for (int i = 0; i < fsemu_monitor.count; i++) {

fsemu/src/fsemu-sdlwindow.c

+16-13
Original file line numberDiff line numberDiff line change
@@ -330,26 +330,29 @@ static SDL_HitTestResult fsemu_sdlwindow_hit_test(SDL_Window *window,
330330
static void fsemu_sdlwindow_find_mode(int display_index, SDL_DisplayMode *mode)
331331
{
332332
fsemu_window_log("Finding suitable mode for display %d:\n", display_index);
333-
// int display_count = 0;
334-
// int display_index = 0;
335-
int mode_index = 0;
336333
SDL_DisplayMode m = {SDL_PIXELFORMAT_UNKNOWN, 0, 0, 0, 0};
337-
while (true) {
338-
int error = SDL_GetDisplayMode(display_index, mode_index, &m);
334+
int num_display_modes = SDL_GetNumDisplayModes(display_index);
335+
// Hack - Try to find an 1080p@50 and use that
336+
for (int i = 0; i < num_display_modes; i++) {
337+
int error = SDL_GetDisplayMode(display_index, i, &m);
339338
if (error) {
340339
break;
341340
}
342-
// fsemu_window_log("Mode %d: %d %d %d\n",
343-
// mode_index,
344-
// m.w,
345-
// m.h,
346-
// m.refresh_rate);
347-
// FIXME: FSEMU needs to now the desired refresh rate...
348-
// FIXME: float vs int (refresh rate)?
349341
if (m.w == 1920 && m.h == 1080 && m.refresh_rate == 50) {
350342
*mode = m;
343+
return;
344+
}
345+
}
346+
// Hack (2) - fallback to 720p@50 if found
347+
for (int i = 0; i < num_display_modes; i++) {
348+
int error = SDL_GetDisplayMode(display_index, i, &m);
349+
if (error) {
350+
break;
351+
}
352+
if (m.w == 1280 && m.h == 720 && m.refresh_rate == 50) {
353+
*mode = m;
354+
return;
351355
}
352-
mode_index += 1;
353356
}
354357
}
355358

0 commit comments

Comments
 (0)