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

Author Topic: Event-Handling ONLY in Console  (Read 3808 times)

0 Members and 1 Guest are viewing this topic.

Savvas

  • Newbie
  • *
  • Posts: 3
    • View Profile
Event-Handling ONLY in Console
« on: December 09, 2011, 02:05:41 am »
Hi guys,
           This is my first thread here.

All i want to ask is, if there is a way to add event handling in console, in case someone wants to test a game for example in console first and then create the graphics of this game in SFML windows etc..
I know that event-handling works with drawn windows.(read the smfl tutorials but they only refer to windows).

Thx for your time in advance and if u think that my question needs clarification please tell me to do so.

nitrix

  • Newbie
  • *
  • Posts: 27
    • View Profile
Event-Handling ONLY in Console
« Reply #1 on: December 09, 2011, 03:35:55 am »
Well, your event handling on the console will be fairly limited. The only input a console has is the keyboard. You can't poll the mouse position, nor get minimize/resize events, etc.

Thus are born windows, you need them.

Savvas

  • Newbie
  • *
  • Posts: 3
    • View Profile
Event-Handling ONLY in Console
« Reply #2 on: December 09, 2011, 10:01:39 am »
Yes i know. But i want unbuffered input in my console(before i do the graphics for my game). I just want to know if there is a way to use the event-handling for winows in console and if there is i would like someone to tell me how do it if it is not a big deal. That's all i am asking. I know that windows offer way more things than console.

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32504
    • View Profile
    • SFML's website
    • Email
Event-Handling ONLY in Console
« Reply #3 on: December 09, 2011, 10:06:53 am »
It is not possible with SFML.
Laurent Gomila - SFML developer

nitrix

  • Newbie
  • *
  • Posts: 27
    • View Profile
Event-Handling ONLY in Console
« Reply #4 on: December 09, 2011, 06:48:15 pm »
I beleive you have ncurses and others for that but its Linux only.

MorleyDev

  • Full Member
  • ***
  • Posts: 219
  • "It is not enough for code to work."
    • View Profile
    • http://www.morleydev.co.uk/
Event-Handling ONLY in Console
« Reply #5 on: December 10, 2011, 04:34:54 pm »
You can do this with the Windows API too either by hooking up using the window handle (GetConsoleWindow and SetWindowsHookEx) which let's you treat the console window exactly like any other or using Console Input Buffer.

GetConsoleWindow: http://msdn.microsoft.com/en-us/library/ms683175(VS.85).aspx
SetWindowsHookEx: http://msdn.microsoft.com/en-us/library/ms644990(VS.85).aspx

Console Input Buffer: http://msdn.microsoft.com/en-us/library/ms682079(VS.85).aspx

I did once create an abstract window system that had implementations that worked using ncurses, the windows API or SFML to create/simulate a console window with events and such but that a few years ago and I doubt I still have the code lying around...
UnitTest11 - A unit testing library in C++ written to take advantage of C++11.

All code is guilty until proven innocent, unworthy until tested, and pointless without singular and well-defined purpose.

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32504
    • View Profile
    • SFML's website
    • Email
Event-Handling ONLY in Console
« Reply #6 on: December 10, 2011, 04:56:03 pm »
If you're just interested in global keyboard/mouse/joystick states, and not events, you can use the sf::Keyboard/sf::Mouse/sf::Joystick classes in SFML 2
Laurent Gomila - SFML developer