SFML community forums

General => Feature requests => Topic started by: achpile on April 18, 2016, 01:39:26 pm

Title: More Events
Post by: achpile on April 18, 2016, 01:39:26 pm
What about to add some more events? For example: DROPFILES and HOTKEY.
Title: Re: More Events
Post by: Laurent on April 18, 2016, 01:52:45 pm
If you want specific events (not just "some more" for fun), please explain in detail why you think they would be useful, give relevant use cases, etc. if you want your request to be considered.
Title: Re: More Events
Post by: achpile on April 18, 2016, 02:03:36 pm
Laurent, for example WM_HOTKEY. I can register hotkey with 'BOOL WINAPI RegisterHotKey', but can't get event. Or file drops (as was requested in http://en.sfml-dev.org/forums/index.php?topic=19096.0).

Yes, realization of functionality like that is kinda difficult. But what about to make just OS-specific event data and OS-specific event?

For example: there's a 'processEvent' function in window implementation.

    switch (message)
    {
....
        case WM_CLOSE:
        {
            Event event;
            event.type = Event::Closed;
            pushEvent(event);
            break;
        }
.....
        default:
        {
            Event event;
            event.type = Event::OSSpecific;
            event.data.message = message;
            event.data.wParam = wParam;
            event.data.lParam = lParam;
            pushEvent(event);
            break;
        }
 

Of course with X11, Android etc. there will be another data structures, that can be ruled by #ifdef's.
Title: Re: More Events
Post by: achpile on April 18, 2016, 03:33:49 pm
For example like this

https://github.com/achpile/SFML/commit/43fe3c454dc345221b38b2109e3fb6680bbde782
Title: Re: More Events
Post by: Mr_Blame on April 18, 2016, 04:02:12 pm
these events are not game-realted.
Title: Re: More Events
Post by: Hiura on April 18, 2016, 05:16:29 pm
The problem IMO is not that they are not game-related (because SF Multimedia L) but because they are low-level, OS-specific data structures that we try to abstract with SFML -- it would in fact defeat the whole purpose of a multi-platform library to do it at this scale.

As Laurent said, we can discussed adding more kind of events if you can show us some specific use cases for specific events.
Title: Re: More Events
Post by: achpile on April 18, 2016, 05:53:31 pm
Hiura, I know that it's too low-level... For now I'm writing timer for speedruns (http://en.sfml-dev.org/forums/index.php?topic=20182) and I want to make HotKey support to control timers without moving focus to timer window and I want to change profiles just by Drag&Drop profile files to application window.

Yeah, maybe easiest way to do it will be to fork repo and make changes for my own...
Title: Re: More Events
Post by: Laurent on April 18, 2016, 08:14:12 pm
I'm fine with forwarding OS specific events, to allow users to implement missing features instead of being stuck behind the SFML API. The same way we provide the window's native handle. But we'd have to find a nice API for this stuff ;)
Title: Re: More Events
Post by: eXpl0it3r on April 18, 2016, 08:48:15 pm
Yeah, I'd like to see the option to forward events as well. Because right now all you can do is fork SFML or move on if you want to use some event that SFML doesn't handle (and just swallows).
Title: Re: More Events
Post by: Hiura on April 18, 2016, 09:06:37 pm
I'm of course not against extending the event system but the first problem I see if we blindly forward un-handled events to the user is that later we might break some code by simply adding support for more events. We should probably have a clean one-to-one mapping between OS event and SFML event.

[Also, implementation-wise, this is tricky on OS X as we'd have to manage memory semi-manually, but that's another story.]
Title: Re: More Events
Post by: achpile on April 20, 2016, 09:32:17 am
Sorry about the hotkeys... It can be done simply by checking sf::Keyboard::isKeyPressed. But dropping files is a nice idea. At least it can be easily done for windows. Just change 'CreateWindowW' to 'CreateWindowExW' and add WS_EX_ACCEPTFILES as first param and on event fill std::vector<sf::String> with filenames. But for X - it is horrible  :D I spent two days to find out, how does Xdnd work and still can't get it...