Comments (6)
Thanks for reporting.
From looking at fyne-io/fyne#1024, which is from 2020, I tried pressing the Fn key on macOS in an events test program (which uses the glfw API as is, without recovers), and it printed:
000001e4 to 1 at 3.736: Key 0x-001 Scancode 0x003f (UNKNOWN) (with no mods) was released
000001e5 to 1 at 4.209: Key 0x-001 Scancode 0x003f (UNKNOWN) (with no mods) was released
Notably, there wasn't a panic.
Are you able to reproduce this issue with the latest version of v3.3/glfw?
from glfw.
I don't have easy access to any macOS so can't confirm how it behaves. However, there are very recent comments on the issue that they can replicate the invalid scancode issues (with multiple keys): fyne-io/fyne#1024 (comment)
from glfw.
Thanks. I'm able to reproduce it now with the following program on macOS:
package main
import (
"runtime"
"github.com/go-gl/glfw/v3.3/glfw"
)
func init() { runtime.LockOSThread() }
func main() {
if err := glfw.Init(); err != nil {
panic(err)
}
defer glfw.Terminate()
// The key callback handler reports the key glfw.KeyUnknown and scancode 0x003f
// when the 'Fn' key is pressed on macOS.
//
// Upstream docs for glfwGetKeyName (https://www.glfw.org/docs/3.3/group__input.html#gaeaed62e69c3bd62b7ff8f7b19913ce4f)
// say:
//
// If the key is GLFW_KEY_UNKNOWN, the scancode is used to identify the key, otherwise the scancode is ignored. If you specify a non-printable key, or GLFW_KEY_UNKNOWN and a scancode that maps to a non-printable key, this function returns NULL but does not emit an error.
//
// This behavior allows you to always pass in the arguments in the key callback without modification.
//
// So the next line should be okay.
_ = glfw.GetKeyName(glfw.KeyUnknown, 0x003f)
// Output:
// panic: InvalidValue: Invalid scancode 63
//
// goroutine 1 [running, locked to thread]:
// github.com/go-gl/glfw/v3.3/glfw.acceptError({0x0, 0x0, 0x1400004e738?})
// $GOMODCACHE/github.com/go-gl/glfw/v3.3/[email protected]/error.go:173 +0x204
// github.com/go-gl/glfw/v3.3/glfw.panicError(...)
// $GOMODCACHE/github.com/go-gl/glfw/v3.3/[email protected]/error.go:184
// github.com/go-gl/glfw/v3.3/glfw.GetKeyName(0x14000065f38?, 0x1005c43b0?)
// $GOMODCACHE/github.com/go-gl/glfw/v3.3/[email protected]/input.go:445 +0x40
// main.main()
// /tmp/pErjaJJXDo/main.go:27 +0x48
// exit status 2
}
My earlier attempt to reproduce this involved only the key callback, but it turns out this happens when GetKeyName
is also involved.
Based on the upstream GLFW docs, it seems the problem is upstream and tracked in glfw/glfw#1785 and will be fixed in elmindreda/glfw@01631b9. (I tested it locally and it indeed causes GetKeyName
to return the empty string instead of panicking.)
from glfw.
Related Issues (20)
- Axis not recognized with Street Fighter "Mad Catz" Fightpad.
- v3.3/glfw: Warnings when building using -tags wayland HOT 2
- unaligned pointer(s) for architecture arm64 HOT 7
- v3.3/glfw: warning: 'GLAPIENTRY' macro redefined HOT 2
- I can't run the case project properly HOT 2
- -
- No error handling in v3.3 HOT 5
- Old module name in README installation instructions HOT 3
- IME support HOT 6
- Build fail on macOS ventura 13.2.1 HOT 3
- How to use in windows? HOT 2
- v3.4 and supporting GLFW_MOUSE_PASSTHROUGH HOT 7
- Converting to execution character set: Illegal byte sequence
- can not build on macos 13.3.1 HOT 5
- Any way to try the glfw master branch to use libdecor ? HOT 1
- `(*glfw.Window).SetIcon` doesn't consider strides
- Unused import of image/draw after latest changes HOT 1
- Panic when creating cursor after latest changes HOT 1
- v3.3/glfw: CreateWindow can run into GLFW_NO_WINDOW_CONTEXT but doesn't accept it HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from glfw.