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

Author Topic: SFML and Raw Mouse  (Read 4808 times)

0 Members and 1 Guest are viewing this topic.

ZnakE

  • Newbie
  • *
  • Posts: 1
    • View Profile
SFML and Raw Mouse
« on: April 10, 2009, 06:15:22 pm »
Hi!
We are currently working on a game where we need several mice inputs, and we have planned to do this via rawmouse.
But we have encountered problems in getting the LPARAM needed for the function add_to_raw_mouse_x_and_y(HANDLE in_device_handle).
Code: [Select]
BOOL add_to_raw_mouse_x_and_y(HANDLE in_device_handle)
{
// When the WM_INPUT message is received, the lparam must be passed to this function to keep a running tally of
//     every mouse moves to maintain accurate results for get_raw_mouse_?_delta().
// This function will take the HANDLE of the device and find the device in the raw_mice arrayand add the
//      x and y mousemove values according to the information stored in the RAWINPUT structure.

LPBYTE lpb;
int dwSize;

if (/* GetRawInputData */(*_GRID)((HRAWINPUT)in_device_handle, RID_INPUT, NULL, &dwSize, sizeof(RAWINPUTHEADER)) == -1) {
fprintf(stderr, "ERROR: Unable to add to get size of raw input header.\n");
return 0;
}

lpb = (LPBYTE)malloc(sizeof(LPBYTE) * dwSize);
if (lpb == NULL) {
fprintf(stderr, "ERROR: Unable to allocate memory for raw input header.\n");
return 0;
}
 
if (/* GetRawInputData */(*_GRID)((HRAWINPUT)in_device_handle, RID_INPUT, lpb, &dwSize, sizeof(RAWINPUTHEADER)) != dwSize ) {
fprintf(stderr, "ERROR: Unable to add to get raw input header.\n");
return 0;
}

read_raw_input((RAWINPUT*)lpb);

free(lpb);

return 1;
}


We think that we need a device handle to pass to the function, we have tried the window handle and the LPARAM from the mouse event.

Does anybody know how to get it to work?

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
SFML and Raw Mouse
« Reply #1 on: April 10, 2009, 06:51:51 pm »
What is the relation with SFML?
Laurent Gomila - SFML developer

Hericage

  • Newbie
  • *
  • Posts: 4
    • View Profile
SFML and Raw Mouse
« Reply #2 on: April 11, 2009, 06:21:00 am »
The relation to SFML.. well we (yes, im working with Znake) are building the engine in SFML and Visual C++. It seems a regular Win32 project in Visual Studio 2008 has no problem passing through the correct LPARAM from the WM_INPUT message. How can we catch that event in SFML?

we figuered the GlobalOnEvent() function in the lib source would be the best way to catch it, but so far we've been unsuccesfull.

long story short: a normal Win32 app can properly catch the WM_INPUT message and pass through the LPARAM we need to Raw Mouse. Can we do this in SFML, as a console app with SFML windows, and if so how's the best way to do it?

thanks.

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
SFML and Raw Mouse
« Reply #3 on: April 11, 2009, 09:47:32 am »
You can create your window externally with your own event loop, then create a sf::Window with its handle.
Laurent Gomila - SFML developer

Hericage

  • Newbie
  • *
  • Posts: 4
    • View Profile
SFML and Raw Mouse
« Reply #4 on: April 11, 2009, 04:06:49 pm »
Im not sure I know what you mean. How would that help us getting the LPARAM sent along with the WM_INPUT message?

Code: [Select]
// When the WM_INPUT message is received, the lparam must be passed to this function

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
SFML and Raw Mouse
« Reply #5 on: April 11, 2009, 04:16:13 pm »
If you have your own event loop then you can do whatever you want with the received messages and their parameters.
Laurent Gomila - SFML developer

Hericage

  • Newbie
  • *
  • Posts: 4
    • View Profile
SFML and Raw Mouse
« Reply #6 on: April 11, 2009, 04:18:04 pm »
ah, I get it now.. will have to try it out monday :)

thanks!

 

anything