Hooray! I'm getting events! BUT...

Community Forums/General Help/Hooray! I'm getting events! BUT...

sswift(Posted 2009) [#1]



I'm not getting the WM_INPUT event at all!

Why?!


Btw, that's working example code that will compile.


N(Posted 2009) [#2]
Really ought to keep these in the forums for their respective programming languages and topics...


Brucey(Posted 2009) [#3]
tut tut :-p


sswift(Posted 2009) [#4]
Brucey:
I didn't notice that post before.


Adam Novagen(Posted 2009) [#5]
Yeah, unless I'm mistaken, this belongs in the BMax forum.

Oh, and DUDE!!! Use CODEBOX, not CODE!!! You've exploded my screen! @_@


sswift(Posted 2009) [#6]
I stil can't figure this out. I can't believe I spent three days on this and now I can't figure out why I'm not getting any WM_INPUT messages. I'm getting lots of other messages, so I know the event handler code is working. But I'm not getting the WM_INPUT messages.

I've double checked the constants. They're correct.

I double checked the size reported for the RAWINPUTDEVICE array. 12 bytes, as expected.

I tried VarPtr Rid[0] when registering the device in case the pointer was pointing to the wrong place. I tried Byte Ptr(Rid) too. No dice.


sswift(Posted 2009) [#7]
I think I know what the problem is, I don't know how to fix it yet though.

The RegisterRawinputdevice function requires a pointer to the data for the device.

In C, this is an array of structs. But types in Blitzmax work differently. When I make an array of RAWINPUTDEVICE, all I'm really doing is creating an array of pointers to my data, not an array of the data itself.

So I need to somehow point the function at my data. This should be possible, but it occurs to me that if I cannot create an array of types which contains the actual data in the type format, then I cannot pass more than one device to the function because the data will not be contiguous.

In my case that should be okay because I just want to read the mouse, but if one needed to read more than one device, I think you'd be stuck using banks or arrays or something instead of types.


sswift(Posted 2009) [#8]


Hooray! Finally! I'm getting WM_INPUT events!

And it looks like I'm getting the mouse data too!

And it ONLY TOOK THREE DAYS.

Or was that four? I've lost track of time. :-(


sswift(Posted 2009) [#9]
If someone on a laptop could test that code and tell me what kind of values it returns for lastmousex when using a trackpad, that would be most helpful.

If the numbers are large, like 1000-30000, then that means it's returning absolute coordinates, which would need to be converted to relative. (tossing out changes which are too big I suppose)

With my mouse I'm getting pretty small numbers. Like no more than +-10.


Floyd(Posted 2009) [#10]
In C a struct is really just a block of memory. Then you have names for little pieces of that memory, which you can use like ordinary variables such as int, short, pointers etc.

BlitzMax is managed ( garbage collected ) and has an extra level of indirection. Once you have an instance of a BlitzMax Type object memory occupied by the various Fields corresponds the the C struct. The address of the first field corresponds to the address of the struct.

Your next adventure will be padding and memory alignment. The address of a four-byte value will typically be a multiple of four, the address of an eight-byte value a multiple of eight etc. Suppose you have consective fields, an integer and a double. If the address of the integer happens to be a multiple of eight then it will be followed by four bytes of unused space so that the address of the double will also be a multiple of eight.


EOF(Posted 2009) [#11]
I tested the code on an EeePC 901 and am seeing values within -/+34 range


sswift(Posted 2009) [#12]
Your next adventure will be padding and memory alignment. The address of a four-byte value will typically be a multiple of four, the address of an eight-byte value a multiple of eight etc. Suppose you have consective fields, an integer and a double. If the address of the integer happens to be a multiple of eight then it will be followed by four bytes of unused space so that the address of the double will also be a multiple of eight.


But even so... if I set up my type the same way as the struct is set up, won't they both end up having the data in the same places?

(The app seems to be reading he data just fine too, so this must be the case.)


sswift(Posted 2009) [#13]
"I tested the code on an EeePC 901 and am seeing values within -/+34 range"

Hm. Well, that's good that it's not absolute. I tried it with my wacon tablet and it was absolute, but I didn't know if a trackpad would be the same.

And the +-34 makes sense I guess. Your pad may be set up to be fairly sensitive so you can scross the screen in one swipe.

It is a bit problematic though, having numbers so much higher. I really don't want to have to implement mouse sensitivity code in the game.


Floyd(Posted 2009) [#14]
if I set up my type the same way as the struct is set up, won't they both end up having the data in the same places?

Probably yes. I once checked 4-byte and 8-byte values and found that BlitzMax handled alignment the same as MingW. But I never got around to checking byte or short.