September 23, 2019, 03:09:17 PM

Author Topic: Getting Raw Mouse Input?  (Read 130 times)

Offline Kippykip

  • Jr. Member
  • **
  • Posts: 90
    • Kippykip Forums!
Getting Raw Mouse Input?
« on: August 14, 2019, 04:34:40 PM »
Alrighty so I'm trying to find a way of using Win32 WM_INPUT commands into BlitzMax.
The MouseX() and MouseY() are great for cursor stuff, but for games it's a bit tricky messing with mouse movement since most computers by default have "Enhance pointer precision" turned on and high DPI mouses have enough precision to be measured by raw input but not enough to move the cursor.

The closest thing I could find is this code archive:

But every Win32 Extern example relating to inputs I've come across so far isn't compatible with BlitzMax-NG, and I haven't had much luck porting code over and compiling successfully.
I remember a while ago running into a similar problem trying to set the Window Icon to what's set in the executable, but just involved encasing an old codearchive piece with LParam() or something.
Here's that code if you're interested:
Code: [Select]
'Windows only
Function SetIcon()
SendMessageW(GetActiveWindow(), WM_SETICON, 0, LParam(LoadIconW(GetModuleHandleW(Null), 101)))
End Function

I really would appreciate any help!

Offline markcwm

  • Sr. Member
  • ****
  • Posts: 400
Re: Getting Raw Mouse Input?
« Reply #1 on: August 16, 2019, 04:13:45 PM »
To make it 64-bit compatible you need to change Int to Byte Ptr when Int is a 32-bit handle or address, this is in Externs and in Types mirroring a structure. You have to be careful and look everything up. Another gotcha is Int Ptr, that will be cast to Long Ptr in 64-bit but it will be declared as Int Ptr in Externs. Also there is struct alignment, in 64-bit this is 8 bytes minimum so any Int field will actually occupy 8 bytes.