Jump to content
  • Advertisement
Sign in to follow this  

Handling Different Inputs

This topic is 1610 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

What is the best way to handle the mouse for an FPS game. That includes speed and the ability to read high DPI. Also how would I handle a keyboard, I assume that performance is not as big of a deal with the keyboard. BTW I am a new to game programming and would have no idea what you mean if you post code and don't explain it, thanks.

Share this post


Link to post
Share on other sites
Advertisement

Question: Are you new to Programming in general or really just to Game Programming?

 

If first true you should do this:

  • Choose a programming language of your choice
    • Learn your language
    • learn and exercise basic programming skills
      • algorythm
      • data structs
      • etc...
    • develop small minimalistic programms on your own to recive experience.
    • dependet how quick and which language you learn start think about gameprogramming 3-9 month later again

Otherwise:

 

  • Choose a programming language of your choice
  • Choose an Framework/library which fits to your project in mind best
    • SDL "very low level"
    • SFML
    • Allegro
    • Unity
    • etc. ...
    • Learn your choosen framework to use
  • develop small minimalistic programms on your own to recive experience

 

 

 


That includes speed and the ability to read high DPI.

Since when, perhaps i was all time wrong, you need to know the DPI,the only thing to know with a mouse is the deltaX and deltaY components( Framework/OS provides this information of course ). The rest makes the mouse for you and you don't have to care about it anymore

Edited by exOfde

Share this post


Link to post
Share on other sites

Question: Are you new to Programming in general or really just to Game Programming?

 

If first true you should do this:

  • Choose a programming language of your choice
    • Learn your language
    • learn and exercise basic programming skills
      • algorythm
      • data structs
      • etc...
    • develop small minimalistic programms on your own to recive experience.
    • dependet how quick and which language you learn start think about gameprogramming 3-9 month later again

Otherwise:

 

  • Choose a programming language of your choice
  • Choose an Framework/library which fits to your project in mind best
    • SDL "very low level"
    • SFML
    • Allegro
    • Unity
    • etc. ...
    • Learn your choosen framework to use
  • develop small minimalistic programms on your own to recive experience

 

 

 


That includes speed and the ability to read high DPI.

Since when, perhaps i was all time wrong, you need to know the DPI,the only thing to know with a mouse is the deltaX and deltaY components( Framework/OS provides this information of course ). The rest makes the mouse for you and you don't have to care about it anymore

 

 

Well no I have already made framework for rendering etc... I just don't know how to get inputs.

Share this post


Link to post
Share on other sites

Okay. They are two ways:

and last but not least learn your API's. read them. do experiments with them, collect experience.

Edited by exOfde

Share this post


Link to post
Share on other sites

Okay. They are two ways:

and last but not least learn your API's. read them. do experiments with them, collect experience.

 

 

 

Question: Are you new to Programming in general or really just to Game Programming?

 

If first true you should do this:

  • Choose a programming language of your choice
    • Learn your language
    • learn and exercise basic programming skills
      • algorythm
      • data structs
      • etc...
    • develop small minimalistic programms on your own to recive experience.
    • dependet how quick and which language you learn start think about gameprogramming 3-9 month later again

Otherwise:

 

  • Choose a programming language of your choice
  • Choose an Framework/library which fits to your project in mind best
    • SDL "very low level"
    • SFML
    • Allegro
    • Unity
    • etc. ...
    • Learn your choosen framework to use
  • develop small minimalistic programms on your own to recive experience

 

 

 


That includes speed and the ability to read high DPI.

Since when, perhaps i was all time wrong, you need to know the DPI,the only thing to know with a mouse is the deltaX and deltaY components( Framework/OS provides this information of course ). The rest makes the mouse for you and you don't have to care about it anymore

 

 

Well no I have already made framework for rendering etc... I just don't know how to get inputs.

 

Well I have looked into DirectInput but Microsoft recommends WM_INPUT but don't know how to use it.

Share this post


Link to post
Share on other sites

please don't qoute everything if don't use it.

Why don't you ask this question at the beginning?

 

But why you don't know how to use it? it's pretty well explained

in msdn: http://msdn.microsoft.com/en-us/library/windows/desktop/ee418998(v=vs.85).aspx

 

I would mention you should ask yourself what you don't understand and try then the problematic to explain first on your own. and after that process to forumlate your question with all information are needed.

Edited by exOfde

Share this post


Link to post
Share on other sites

please don't qoute everything if don't use it.

Why don't you ask this question at the beginning?

 

But why you don't know how to use it? it's pretty well explained

in msdn: http://msdn.microsoft.com/en-us/library/windows/desktop/ee418998(v=vs.85).aspx

 

I would mention you should ask yourself what you don't understand and try then the problematic to explain first on your own. and after that process to forumlate your question with all information are needed.

No it is transferring WM_INPUT to usable data.

Share this post


Link to post
Share on other sites

Since when, perhaps i was all time wrong, you need to know the DPI,the only thing to know with a mouse is the deltaX and deltaY components( Framework/OS provides this information of course ). The rest makes the mouse for you and you don't have to care about it anymore


The API you use may perform undesired filtering or only send updates at a low frequency or in low-resolution coordinates. FPS games need to deal with mouse sensitivity options, response curves, and optionally also smoothing. Input handling in a high-quality FPS is not exactly trivial, though the basic stuff works to get up and running.

Share this post


Link to post
Share on other sites

thanky you SeanMiddleditch and again learned something new biggrin.png

 

Perhaps you should a little bit scrolling and searching through msdn. because they explain it the how to use it:

 

 

Understanding DirectInput

This topic covers the underlying structure of Microsoft DirectInput and its relationship to the Microsoft Windows message system.

For practical information about how to implement the elements of DirectInput introduced here, see Using DirectInput.

DirectInput Objects

 

An input-only DirectInput implementation consists of the DirectInput object, which supportsIDirectInput8 Interface, a Component Object Model (COM) interface, and a DirectInputDevice object for each input device that provides data. Each DirectInputDevice object in turn has device objects, which are individual controls or switches, such as keys, buttons, or axes. Device objects are also called device object instances.

 

Each DirectInputDevice object represents one input device, such as a mouse, keyboard, or joystick. In the DirectInput API, the word joystick means any type of input device other than a mouse or keyboard. A piece of hardware that is really a combination of different types of input devices, such as a keyboard with a touchpad, can be represented by two or more DirectInputDevice objects. A force-feedback device is represented by a single joystick object that handles both input and output.

 

DirectInputDevice objects instantiate the IDirectInputDevice8 Interface. The application ascertains the number and type of device objects available by using theIDirectInputDevice8::EnumObjects method. Individual device objects are not encapsulated as code objects, but are described in DIDEVICEOBJECTINSTANCE structures.

All DirectInput interfaces are available in ANSI and Unicode versions. If "UNICODE" is defined during compilation, the Unicode versions are used.

Interaction with Windows

 

Because DirectInput works directly with the device drivers, it either suppresses or ignores Windows mouse and keyboard messages. It also ignores mouse and keyboard settings made by the user in Control Panel. It does, however, use the calibrations set for a joystick or other game controller.

DirectInput does not recognize keyboard character repeat settings. When using buffered data, DirectInput interprets each press and release as a single event with no repetition. When using immediate data, DirectInput is concerned only with the present physical state of the keys, not with keyboard events as interpreted by Windows.

DirectInput does not perform any character conversion or translation. For example, the SHIFT key is treated like any other key, not as a modifier of another keypress. Keys return the same identifiers regardless of the user's system language settings.

 

Under Windows 2000, acquiring the keyboard in exclusive mode prevents any applications that are subsequently launched from receiving keyboard data.

Because DirectInput works directly with the mouse driver, it bypasses the subsystem of Windows that interprets mouse data for windowed applications. Applications that rely on the Windows cursor for navigation should continue to use the standard Windows mouse messages and Microsoft Win32 functions.

 

When using the system mouse in exclusive mode, DirectInput suppresses mouse messages, and therefore Windows is unable to show the standard cursor.

DirectInput ignores Control Panel settings such as acceleration and swapped buttons. However, DirectInput recognizes settings in the driver itself. For example, if the user has a three-button mouse and uses the driver-utility software to make the middle button a double-click shortcut, DirectInput reports a click of the middle button as two clicks of the primary button. ---- http://msdn.microsoft.com/en-us/library/windows/desktop/ee418998(v=vs.85).aspx

 

 

 

 

By the way I wish all a Merry Christmas :D

Edited by exOfde

Share this post


Link to post
Share on other sites

Well with this code, the window instantly closes:

    case WM_INPUT:
    {
                     for (int i = 3000; i>0; i -= 10){
                         Beep(i, 100);
                     }
                     UINT dwSize = 40;
                     static BYTE lpb[40];

                     GetRawInputData((HRAWINPUT)lparam, RID_INPUT,
                         lpb, &dwSize, sizeof(RAWINPUTHEADER));

                     RAWINPUT* raw = (RAWINPUT*)lpb;

                     if (raw->header.dwType == RIM_TYPEMOUSE)
                     {
                         int xPosRelative = raw->data.mouse.lLastX;
                         int yPosRelative = raw->data.mouse.lLastY;
                         if (xPosRelative > 100 && yPosRelative > 100)
                         Beep(10, 1000);
                     }
                     break;
    }

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!