Welcome, Guest. Please login or register. Did you miss your activation email?

Author Topic: More Events  (Read 7519 times)

0 Members and 1 Guest are viewing this topic.

achpile

  • Full Member
  • ***
  • Posts: 231
    • View Profile
    • Achpile's homepage
    • Email
More Events
« on: April 18, 2016, 01:39:26 pm »
What about to add some more events? For example: DROPFILES and HOTKEY.

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
Re: More Events
« Reply #1 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.
Laurent Gomila - SFML developer

achpile

  • Full Member
  • ***
  • Posts: 231
    • View Profile
    • Achpile's homepage
    • Email
Re: More Events
« Reply #2 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.


Mr_Blame

  • Full Member
  • ***
  • Posts: 192
    • View Profile
    • Email
Re: More Events
« Reply #4 on: April 18, 2016, 04:02:12 pm »
these events are not game-realted.

Hiura

  • SFML Team
  • Hero Member
  • *****
  • Posts: 4321
    • View Profile
    • Email
Re: More Events
« Reply #5 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.
SFML / OS X developer

achpile

  • Full Member
  • ***
  • Posts: 231
    • View Profile
    • Achpile's homepage
    • Email
Re: More Events
« Reply #6 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...

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
Re: More Events
« Reply #7 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 ;)
Laurent Gomila - SFML developer

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 11033
    • View Profile
    • development blog
    • Email
Re: More Events
« Reply #8 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).
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

Hiura

  • SFML Team
  • Hero Member
  • *****
  • Posts: 4321
    • View Profile
    • Email
Re: More Events
« Reply #9 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.]
SFML / OS X developer

achpile

  • Full Member
  • ***
  • Posts: 231
    • View Profile
    • Achpile's homepage
    • Email
Re: More Events
« Reply #10 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...

 

anything