Jump to content
  • Advertisement

SpaceCadet.Steve

Member
  • Content Count

    4
  • Joined

  • Last visited

Community Reputation

0 Neutral

About SpaceCadet.Steve

  • Rank
    Newbie

Personal Information

  • Interests
    Programming
    QA
  1. SpaceCadet.Steve

    WinAPI Raw Input confusion

    About Raw Input 05/30/2018 4 minutes to read There are many user-input devices beside the traditional keyboard and mouse. For example, user input can come from a joystick, a touch screen, a microphone, or other devices that allow great flexibility in user input. These devices are collectively known as Human Interface Devices (HIDs). The raw input API provides a stable and robust way for applications to accept raw input from any HID, including the keyboard and mouse. https://docs.microsoft.com/en-us/windows/desktop/inputdev/about-raw-input It's what microsoft is recommending and promoting. The functions of xinput and directinput have been re-written and added to the windows header. Also for communicating with other user devices besides joysticks keyboards and mice. Which is my purposes. I brought this into question here with game developers as it would be the "modern" way to do things and figured to find it more commonly used. Also necessary for writing drivers for new input devices communicating through the usb bus, such as a keyboard controller or similar ascii coming into the decoder. How does one receive and translate messages received by the decoder? Take that message, // do stuff with it. (Figurative question, though I'm sure there's a great answer)
  2. SpaceCadet.Steve

    WinAPI Raw Input confusion

    Indeed. Being new to windows programming -- my world is in electronics, gnu/linux is usually the go-to. It's extremely overwhelming to sift through 20 years of API differences for the most up-to-date and compatible practices. Many many thanks Shaarigan. That's a lot for me to go through but the best explanation I've gotten. I followed the MSDN method to no-avail as noted in the original post.
  3. SpaceCadet.Steve

    WinAPI Raw Input confusion

    Thanks for the reply trill41. As I'm finding over the last week of trying to puzzle this method together. I will need raw input for talking to my applications with other tools besides standard peripherals -- such as an oscilloscope program with accompanying hardware. For standard HID mouse keyboard default messages are looking the way to stick. and a lot less headache. Thanks again.
  4. SpaceCadet.Steve

    WinAPI Raw Input confusion

    I'm quite new to the windows api and raw input is for lack of better terms kicking my tail. I've initialized it in my program, called and defined in the window proc with WM_INPUT, and I'm definitely receiving inputs. However that pesky key repeat delay is still there... First question would be is this direction I should be going programming an input framework in windows? Or is there a more recommended method in modern windows coding when needing on the fly and latency free response? Here is my window proc: LRESULT CALLBACK WindowProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam) { switch (uMsg) { case WM_CLOSE: PostQuitMessage(0); break; case WM_DESTROY: return 0; case WM_INPUT: { char keyBuffer[sizeof(RAWINPUT)] = {}; UINT KBsize = sizeof(RAWINPUT); GetRawInputData(reinterpret_cast<HRAWINPUT>(lParam), RID_INPUT, keyBuffer, &KBsize, sizeof(RAWINPUTHEADER)); RAWINPUT *raw = (RAWINPUT*)keyBuffer; if (raw->header.dwType == RIM_TYPEMOUSE) { // read the mouse data } if (raw->header.dwType == RIM_TYPEKEYBOARD) { // Get key value from the keyboard member (of type RAWKEYBOARD) USHORT keyCode = raw->data.keyboard.VKey; switch (keyCode) { case VK_ESCAPE: PostQuitMessage(0); break; case 0x41: theta += 1.0f; // Rotate left when A is pressed. break; case 0x44: theta -= 1.0f; // Rotate right when D is pressed. break; } } } return 0; default: return DefWindowProc(hwnd, uMsg, wParam, lParam); } return 0; } I understand that I should be defining the buffer to a hard array size, but this isn't my issue in the current case. I simply want the application to react to the key state, and not delay key repeats at the OS setting. Kind of silly to claim low level and I'm being code blocked by the OS. I've tested in this application with dwFlags at 0 (virtual key assign) and no legacy, to no avail. I'm sure this has probably been asked before, but I could not find an article or post here younger than 11 years on the subject. And what was found not what I was looking for. I've tried to watch my language -- retired sailor -- if I missed a few let me know for edit.
  • Advertisement
×

Important Information

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

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!