Commit Graph

203 Commits

Author SHA1 Message Date
Hajime Hoshi
ef62f407d1 Clean up build tags 2021-10-24 15:05:36 +09:00
Hajime Hoshi
7c6f2fd799 ebiten: Vibrate takes time durations instead of the options
Android and browsers can specify only a time duration for vibration.

VibrateOptions is renamed to GamepadVibrateOptions for gamepads.

Updates #1452
2021-10-24 05:02:49 +09:00
Hajime Hoshi
b8a5ea7bd6 ebiten: Add Vibrate and VibrateOptions, and implement this on browsers
Updates #1452
2021-10-24 01:05:33 +09:00
Hajime Hoshi
6f29e57378 internal/uidriver/glfw: Wait for a FramebufferSize callback for the initial temporary window
Updates #1847
2021-10-13 00:16:18 +09:00
Hajime Hoshi
2f2ccbbe55 internal/uidriver/glfw: Bug fix: Wait for FramebufferSize callback after a window creation
Closes #1847
2021-10-13 00:04:14 +09:00
Hajime Hoshi
0eb6c846c7 internal/uidriver/glfw: Refactoring: Remove unused functions 2021-10-10 16:02:01 +09:00
Hajime Hoshi
4604a00e39 internal/uidriver/glfw: Refactoring: Rename functions 2021-10-10 15:50:12 +09:00
Hajime Hoshi
4580f9fa16 internal/uidriver/glfw: Refactring: Rename InDP -> InDIP
This change also renames some functions and variables.
2021-10-10 15:47:15 +09:00
Hajime Hoshi
da6b75bc6d internal/uidriver/glfw: Bug fix: Adjust the window size along with the device scale
After this change, UserInterface's windowWidth and windowHeight are
now windowWidthInDP and windowHeightInDP in device-independent pixels.

Closes #1844
2021-10-10 14:29:34 +09:00
Hajime Hoshi
fcd8a6c653 internal/uidriver/glfw: Bug fix: Get the correct initial monitor and its scale
Before this fix, Win32API is used to get the current monitor. This
might not work and return an unexpected monitor on some machines after
the runloop starts.

Instead, use the current window to get the current monitor correctly
instead of the Win32APIs. To get the initial monitor, the API
ForegroundWindow is still used.

Updates #1584
Updates #1844
2021-10-09 18:18:22 +09:00
Hajime Hoshi
77664ff057 internal/uidriver/glfw: Use the correct initial monitor on Linux/UNIX
Closes #1827
2021-09-25 02:48:13 +09:00
Hajime Hoshi
23566a7d2e internal/uidriver/glfw: Refactoring 2021-09-25 02:14:14 +09:00
Hajime Hoshi
8ed55ef42d internal/uidriver/glfw: Use the window size on a native fullscreen
Updates #1745
2021-09-19 00:35:18 +09:00
Hajime Hoshi
188e80d2f7 internal/uidriver/glfw: Bug fix: FPS is dropped when pressing the green button
Updates #1745
2021-09-18 22:16:21 +09:00
Hajime Hoshi
1a7cf7b3b8 internal/glfw/glfw: Modify GLFW for Windows to make the window non-floating
Closes #1506
2021-09-18 20:47:26 +09:00
Hajime Hoshi
428c079e52 internal/uidriver/glfw: Make a 'native' fullscreen on macOS
This is a breaking change. On macOS, `SetFullscreen` creates a new
independent space and maximize the size of the window there.

Updates #1506
Closes #1579
2021-09-18 16:31:22 +09:00
Hajime Hoshi
2a390c18c1 internal/uidriver/glfw: Do not iconify the fullscreen window on Linux
Updates #1506
2021-09-18 00:52:04 +09:00
Hajime Hoshi
ec2f823420 internal/uidriver/glfw: Clear the device scale cache when monitors are changed 2021-09-15 13:04:38 +09:00
divVerent
5bc7b93e6f
Move VideoModeScaleAt into internal/uidriver/glfw. (#1812)
It's only used by GLFW, and has been in devicescale only to ease migration
to separate video mode vs content scaling.

Updates #1774
2021-09-15 12:47:04 +09:00
divVerent
923c84a3d6
Split the concept of device scale and screen scale (#1811)
We now set deviceScale to always the mapping from logical window system pixels
to device independent pixels (which is what Ebiten API users expect), and
introduce a new concept of videoModeScale that maps from video mode to logical
window system pixels.

videoModeScale is now only used for computing full-screen resolutions, while
deviceScale is used for any other conversion.

Fixes window sizes on X11, should be a NOP otherwise.

Closes #1774.
2021-09-15 01:03:04 +09:00
divVerent
60df512352
Switch out the devicescale implementation by one that relies on glfw/xrandr. (#1800)
This should fix fullscreen mode on Linux/X11 systems in general,
while not affecting other systems.

Note that this deletes a bunch of OS X specific and Windows specific code,
as GLFW already provides this functionality.

This change is not expected to cause regressions, however,
the current behavior is still wrong and leads to wrong/unintended window sizes.
To be fixed in further PRs.

Updates #1774
2021-09-14 12:35:02 +09:00
Hajime Hoshi
39e7f71ccb internal/uidriver/glfw: Bug fix: Forbide Maximize/MinimizeWindow on the native fullscreen on macOS
Closes #1810
2021-09-12 23:38:44 +09:00
Hajime Hoshi
f23dadb8ae
Add internal/gamepaddb (#1805)
This is basically a revert of 93a156a718.
This implements parsing the SDL gamepad mappings by Ebiten instead
of GLFW, so that Ebiten can handle parsing errors completely.

Closes #1802
2021-09-11 22:46:05 +09:00
Hajime Hoshi
37771717cc internal/uidriver: Bug fix: Potential memory leak by [:0]
Updates #1803
2021-09-10 02:17:29 +09:00
Hajime Hoshi
106ff7a84b internal/ui: Reduce calls of glfw.GetMonitors
Updates #1803
2021-09-09 11:14:08 +09:00
Hajime Hoshi
d5ce0dbd90 internal/uidriver/glfw: Bug fix: Disable the sticky mode on FPSModeVsyncOffMinimum
Closes #1791
2021-08-31 11:43:11 +09:00
Hajime Hoshi
40d2dd3ba7 internal/uidriver/glfw: Update comments
Updates #1787
2021-08-26 02:05:30 +09:00
Hajime Hoshi
15ac69b8d5 internal/graphicsdriver/metal: Bug fix: Disable presentsWithTransaction on fullscreen
Closes #1745
2021-08-08 17:40:37 +09:00
Hajime Hoshi
cc1accc32a internal/uidriver/glfw: Bug fix: Disable vsync when resizing the window
Closes #1740
2021-08-06 03:08:04 +09:00
Hajime Hoshi
0bc5166a36 driver: Refactoring: Rename functions 2021-08-05 01:29:45 +09:00
Hajime Hoshi
1706d9436a ebiten: Add FPSModeType, FPSMode, SetFPSMode, and ScheduleFrame
This change adds these APIs:

  * type FPSModeType
  * func FPSMode
  * func SetFPSMode
  * func ScheduleFrame

and deprecates these APIs:

  * func SetVsyncEnabled
  * func IsVsyncEnabled

Closes #1556
2021-07-24 16:09:13 +09:00
Hajime Hoshi
2503323557 internal/driver: Add FPSMode
Updates #1556
2021-07-23 00:47:09 +09:00
Hajime Hoshi
93a156a718 internal/uidriver/glfw: Use glfwGameGamepadState
This change replaces the usage of gamepaddb package with glfwGetGamepadState.

Updates #1557
2021-07-21 16:09:30 +09:00
Hajime Hoshi
49c3c30c79 ebiten: Add IsWindowBeingClosed / SetWindowClosingHandled / IsWindowClosingHandled
IsWindowBeingClosed reports whether the window is being closed by
the user.

SetWindowClosingHandled sets whether the window closing is handled
or not. If the state is true, the window is not closed immediately
by the user and the game can handle the closing state. In this case,
the Update function should return an error in order to end the game.

This change also adds examples/windowclosing.

Closes #1574
2021-06-14 02:29:11 +09:00
Hajime Hoshi
f989ce4e64 internal/uidriver/glfw: Rename variables 2021-06-13 23:25:24 +09:00
Hajime Hoshi
3c2d562967 internal/glfw: Bug fix: NewCallbackCDecl objects were leaked
Callbacks created by NewCallbackCDecl were never released and then
they are leaked, especially when the window size was changed by
SetWindowSize on Windows.

This change defines new callback ID types with uintptr, and reuse
the callbacks.

Closes #1672
2021-06-13 22:23:01 +09:00
Hajime Hoshi
b54ad73a2b Add go:build comments with go1.17beta1 fmt 2021-06-11 01:11:46 +09:00
Hajime Hoshi
58843b68f9 internal/hooks: Enable to return error at suspend/resume audio 2021-05-04 23:09:01 +09:00
Tom Lister
bea5ab3335
internal/uidriver/glfw: Native macOS implementation for setting cursor shape (#1624)
Updates #1624
2021-05-02 14:50:50 +09:00
Hajime Hoshi
091e51ae4c internal/uidriver/glfw: Avoid allocating a new slice 2021-04-25 00:57:06 +09:00
Hajime Hoshi
91f8347500 internal/uidriver/glfw: Avoid busy loop by sleeping
Updates #1580
2021-04-24 05:19:23 +09:00
Hajime Hoshi
3df31c0fce internal/uidriver/glfw: Bug fix: Deadlock at FramebufferSize callback
glfw.PollEvents might invoke multiple FramebufferSize callbacks in
theory, this is very rare though. In this case, the sending an object
to the channel never ends.

This change fixes this deadlock by using 'select'.

Closes #1618
2021-04-24 02:22:51 +09:00
Hajime Hoshi
ac9a18931c internal/uidriver/glfw: Fix comments
Updates #1618
2021-04-23 03:28:14 +09:00
Hajime Hoshi
d446aa39a9 internal/uidriver/glfw: Bug fix: Always wait for SetFramebuffer
In case when the callback is not called, let's use timeout.

Updates #1618
2021-04-23 03:02:12 +09:00
Hajime Hoshi
c4c331b0d5 Fix misspellings 2021-04-21 22:50:00 +09:00
Hajime Hoshi
4cb6cb9d6a internal/uidriver/glfw: Misspelling 2021-04-21 22:29:54 +09:00
Hajime Hoshi
1013ca9c66 internal/uidriver/glfw: Bug fix: A window can never be 'maximized' on fullscreen
When the window is fullscreen, calling MaximizeWindow never returned.
Apparently the attribute glfw.Maximized can never be true on the
fullscreen mode.

This change fixes the issue by checking the fullscreen state.
2021-04-21 22:25:14 +09:00
Hajime Hoshi
c7dd9a4107 internal/uidriver/glfw: Bug fix: Wait for Restore/Maximize/Iconify finishes explicitly
On Linux (and probably other UNIX OSes), glfwRestore, glfwMaximize,
and glfwIconify returns even though the window state has not changed.
Wait for its finish by a for loop and glfw.PollEvents.

Closes #1608
2021-04-21 00:52:06 +09:00
Hajime Hoshi
58572fb000 internal/uidriver/glfw: Bug fix: Unexpected small window size on Linux
At the initial phase, GLFW window's GetSize seems unreliable. Do not
call it on Linux. On the other hand, this is still necessary on macOS.

Updates #1606
Closes #1609
2021-04-20 23:38:34 +09:00
Hajime Hoshi
ec5b806241 Revert "internal/uidriver/glfw: Bug fix: Delay to enable SetSize callback"
This reverts commit fbe6961528.

Reason: This doesn't fix the issue unfortunately
2021-04-20 23:01:02 +09:00