diff --git a/Changes.md b/Changes.md index 25b36e8..cb0da46 100644 --- a/Changes.md +++ b/Changes.md @@ -44,6 +44,11 @@ Some minor changes: * The game window maximizes on startup to fill the screen. * Fixed a few places where the old "Load Level" menu was being called instead of the fancy new one with the listbox. +* Fixed a touch screen detection bug that was causing the mouse cursor to hide + on Macbooks when using their touchpad. +* Add a `--touch` command line flag to the game binary, which forces touch screen + mode to always be on (which hides the mouse cursor), in case of touch screen + detection errors or annoyances. Some code cleanup and architecture changes: diff --git a/cmd/doodle/main.go b/cmd/doodle/main.go index 5434ad2..cafb580 100644 --- a/cmd/doodle/main.go +++ b/cmd/doodle/main.go @@ -19,6 +19,7 @@ import ( "git.kirsle.net/SketchyMaze/doodle/pkg/chatbot" "git.kirsle.net/SketchyMaze/doodle/pkg/gamepad" "git.kirsle.net/SketchyMaze/doodle/pkg/log" + "git.kirsle.net/SketchyMaze/doodle/pkg/native" "git.kirsle.net/SketchyMaze/doodle/pkg/plus/bootstrap" "git.kirsle.net/SketchyMaze/doodle/pkg/plus/dpp" "git.kirsle.net/SketchyMaze/doodle/pkg/shmem" @@ -101,6 +102,11 @@ func main() { Aliases: []string{"w"}, Usage: "set the window size (e.g. -w 1024x768) or special value: desktop, mobile, landscape, maximized", }, + &cli.BoolFlag{ + Name: "touch", + Aliases: []string{"t"}, + Usage: "force TouchScreenMode to be on at all times, which hides the mouse cursor", + }, &cli.BoolFlag{ Name: "guitest", Usage: "enter the GUI Test scene on startup", @@ -167,10 +173,9 @@ func main() { balance.FeaturesOn() } - // Offline mode? - if c.Bool("offline") { - shmem.OfflineMode = true - } + // Set other program flags. + shmem.OfflineMode = c.Bool("offline") + native.ForceTouchScreenModeAlwaysOn = c.Bool("touch") // SDL engine. engine := sdl.New( diff --git a/pkg/balance/numbers.go b/pkg/balance/numbers.go index 436814e..df31a17 100644 --- a/pkg/balance/numbers.go +++ b/pkg/balance/numbers.go @@ -31,6 +31,10 @@ var ( Y: 60, } + // Threshold of how many ticks should pass between the last Fingers Up + // event and a mouse movement, to indicate that TouchScreenMode should end. + TouchScreenModeLastFingerDownTicks uint64 = 10 + // Player speeds, gravity and movement physics. PlayerMaxVelocity float64 = 7 PlayerJumpVelocity float64 = -15 diff --git a/pkg/native/touch_screen.go b/pkg/native/touch_screen.go index 6b0f899..b41316e 100644 --- a/pkg/native/touch_screen.go +++ b/pkg/native/touch_screen.go @@ -1,6 +1,7 @@ package native import ( + "git.kirsle.net/SketchyMaze/doodle/pkg/balance" "git.kirsle.net/SketchyMaze/doodle/pkg/log" "git.kirsle.net/SketchyMaze/doodle/pkg/shmem" "git.kirsle.net/go/render/event" @@ -9,13 +10,16 @@ import ( // Common code to handle basic touch screen detection. var ( + // Force the TouchScreenMode to always be enabled. + ForceTouchScreenModeAlwaysOn bool + isTouchScreenMode bool lastFingerDownTick uint64 ) // IsTouchScreenMode is activated when the user has touched the screen, and false when the mouse is moved. func IsTouchScreenMode() bool { - return isTouchScreenMode + return ForceTouchScreenModeAlwaysOn || isTouchScreenMode } /* @@ -51,7 +55,7 @@ func UpdateTouchScreenMode(ev *event.State) { // If we have registered a mouse event a few ticks after the finger was // removed, it is a real mouse cursor and we exit touch screen mode. - if ev.IsMouseEvent && shmem.Tick-lastFingerDownTick > 5 { + if ev.IsMouseEvent && shmem.Tick-lastFingerDownTick > balance.TouchScreenModeLastFingerDownTicks { log.Info("TouchScreenMode OFF") isTouchScreenMode = false }