pixel icon indicating copy to clipboard operation
pixel copied to clipboard

Add callback functionality for input events

Open trondhumbor opened this issue 4 years ago • 9 comments

Allows adding custom callback functions, which will be called when glfw fires an input event.

trondhumbor avatar Sep 01 '21 16:09 trondhumbor

Thanks for the PR! Can you explain a bit of your use-case/thought process behind this change please? I'm interested to see how this differs from using the existing pixel.Window input functions.

dusk125 avatar Sep 02 '21 01:09 dusk125

I was thinking this feature would be nice but came to the conclusion most things i would do with callbacks i could just do with checking an input loop. However, the best idea I had was for UI elements (checking every mouse click if you're over a button on the screen, etc.)

cebarks avatar Sep 02 '21 06:09 cebarks

The intention was to provide a way to make use of the callback methods already existing in glfw. Instead of exposing them raw, I wrapped them so that glfw elements won't leak into the pixel library. One of the main benefits with this change, as I see it, is that you can avoid using an input loop for something that is event-driven "under-the-hood".

trondhumbor avatar Sep 02 '21 07:09 trondhumbor

So the thing I'm struggling with here is that I don't know if this actually buys you anything. GLFW might be able to send events async, but OpenGL is still single threaded and basically all calls in Pixel that go touch OpenGL are forcibly done in the main thread.

The thing I'm not sure about (given my inexperience with GLFW) is if the callbacks are actually done async or if they're also called single threaded-ly; maybe you can speak to that? In Pixel, we call glfw.PollEvents (on the main thread) and then update our internal structure.

dusk125 avatar Sep 04 '21 14:09 dusk125

@trondhumbor what's your use case for this feature? i'm curious

cebarks avatar Sep 05 '21 00:09 cebarks

Related to https://github.com/dusk125/pixelui/issues ? If so, would be nice to get this merged so the others can also be.

Chillance avatar Sep 19 '21 00:09 Chillance

Related to https://github.com/dusk125/pixelui/issues ? If so, would be nice to get this merged so the others can also be.

Thanks for reminding me to go through the PixelUI issues :D All of those issues were waiting on PRs that have now been accepted into Pixel (they've now been closed); that is to say, this isn't related to the issues I was having in PixelUI.

dusk125 avatar Sep 19 '21 01:09 dusk125

Related to https://github.com/dusk125/pixelui/issues ? If so, would be nice to get this merged so the others can also be.

Thanks for reminding me to go through the PixelUI issues :D All of those issues were waiting on PRs that have now been accepted into Pixel (they've now been closed); that is to say, this isn't related to the issues I was having in PixelUI.

PixelUI is fantastic. Great addition to fantastic Pixel. Started to use PixelUI myself and noticed it needs to upgrade the underlying imgui-go (made an issue for it) Anyway, this is about Pixel so I hope this PR will be merged soon too.

Chillance avatar Sep 19 '21 03:09 Chillance

@dusk125

Is this PR still relevant?

duysqubix avatar Oct 02 '23 19:10 duysqubix