Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

IsKeyPressed / IsKeyReleased Sending False Values #13

Closed
SolarLune opened this issue Sep 17, 2017 · 7 comments
Closed

IsKeyPressed / IsKeyReleased Sending False Values #13

SolarLune opened this issue Sep 17, 2017 · 7 comments

Comments

@SolarLune
Copy link
Contributor

Hello!

So basically, IsKeyPressed() and IsKeyReleased() seem to be sending false values if you hold the key down for about a second or longer. Here's a quick example:

package main

import (
	"github.com/gen2brain/raylib-go/raylib"
)

func main() {

	raylib.SetConfigFlags(raylib.FlagWindowResizable)
	raylib.InitWindow(640, 480, "Test Game")
	raylib.SetTargetFPS(30)

	for !raylib.WindowShouldClose() {

		// Update

		if raylib.IsKeyPressed(raylib.KeyA) {
			println("A pressed")
		}
		if raylib.IsKeyReleased(raylib.KeyB) {
			println("B released")
		}

		// Draw

		raylib.BeginDrawing()

		raylib.ClearBackground(raylib.Black)

		raylib.DrawFPS(10, 10)

		raylib.EndDrawing()

	}

}

If you tap the A key, "A pressed" will be printed to the console (which is fine). If you press and hold it, and then release the key after about a second, "A pressed" will be printed to the console twice. A similar thing for the B key - tapping "B" will print "B released" to the console, but pressing, holding for about a second, and releasing the B key will print "B released" twice.

I'm running Solus 3 (Linux) 64-bit.

@raysan5
Copy link

raysan5 commented Sep 17, 2017

Just tested it in the C version of the library and it works fine, maybe it's related to Go binding...

@gen2brain
Copy link
Owner

I just tried in Go and I cannot reproduce it. Works as expected for me.

@SolarLune
Copy link
Contributor Author

SolarLune commented Sep 18, 2017

Dang, that's not good. I'm running Go 1.9, as well, so it's not a version issue. Not sure what it could be.

@SolarLune
Copy link
Contributor Author

I notice that it seems like it might be tied to the framerate (and perhaps also to how often keyboard events are updated)? At higher framerates (like >= 120), I can't reproduce it, while at typical framerates (30, 60), it's easy to reproduce.

@raysan5
Copy link

raysan5 commented Sep 18, 2017

Could you try in another computer and another keyboard?

@gen2brain
Copy link
Owner

@SolarLune There were some changes in library. Can you update and try now?

@gen2brain
Copy link
Owner

I will close this one, please file a new issue if you still have problems.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants