win32 solution to WM_NCLBUTTONUP
this stupid thing! a “convenient API for detecting mouse button release outside of client area”, only works when the window is maximised (and thus literally pointless). reason because once outside client, mouse is captured for dragging the window so the message is *never sent*. really good.
instead of messing with button messages, use this in your process to detect the button state:
if((GetKeyState(VK_LBUTTON) & 0x100) != 0)
EASY JOYSTICKS FOR WIN32!!!
JOYINFOEX joyinfo;
MMRESULT joygetpos_result = joyGetPosEx( JOYSTICKID1, &joyinfo );
should be a separate article but wordpress isn’t logging in today.
a few years ago, i picked up a cheap “standard” game controller with 2 thumbsticks to use with my programs… i don’t know xbox or whatever, i don’t play games, so i don’t know the things other people are apparently presumed to know. so after a couple weeks of trying ot figure it the fuck out from MS, i gave up. there’s so much pointless information, as usual, no insight into APIs, et c., bitchbitchbitch.
here’s how it works:
in the first place, a controller with two sticks on it is one controller, not two joysticks. when they talk about “six axis” for game controllers, its two per stick, so eg. six axis support can handle three sticks on one controller. that will save you trying to install two sticks, wondering where the second one is, et c.
that code above is all it takes. someone somewhere wrote, “developers usually petition the controller instead of handle it in the message loop”. no clue if its true, but helps me be satisfied with what i can do.
there’s more you need to know:
there is a JOYINFO and of course the EX expands upon it. i couldn’t get the 2nd stick gonig wiht basic JOYINFO but in hindsight, it could be because i eg. might not have figured out whatever hokey fucked up naming system they use for the second stick (z axis = horizontal, and “z roll” = vertical). hjesus bloody god decades of this shit and nobody can bloody write it simple.
its those two fucking lines up the top. all you need. two fuvking lines. no directx, just two lines.
the JOYINFOEX is to declare a structure to hold teh data. the MMRESULT thing (and the declared joygetpos_result) is only there because it doesn’t populate iwthout the mmresult line.
next, you can read the controller params as such (remember, my lowercase joyinfo is just my variable name)
something = joyinfo.dwXpos;
something = joyinfo.dwYpos;
the six available axes are X, Y, Z, R, U, V, so a two thumbstick controller is X, Y, Z, and R. they return 0-255, 127 centered. however, when your pointer goes out of the window, they return some really bogus values. haven’t sorted that yet.
the precedent, non-EX version doesn’t use “dw” in there, that’s only there because some fuckshite figured out adding a couple of extra characters to textually discriminate the EX API from the old API would cause millions of lines of code to have extra shite in it it doesn’t need, so they put that in there as a gift to us.
reading the buttons:
there are no separate APIs for the buttons in the EX version (non-EX limited to 4 buttons). there are two APIs:
something = joyinfo.dwButtons
something = joyinfo.dwButtonNumber
and amazingly they used a binary system to return the value of the button (unplugged my sticky, can’t see which val it is, you’ll figure it out) and all of the buttons were available on my cheapy controller, including stick press buttons.
what i called the “directional pad” which has four buttons on a disk that tilts, eg. ancient nintendo controllers, is called a “hat” and is not a button. to read it, use joyinfo.dwPOV … this returns 65535 when not pressed, and eight cardinal directions defined as degrees x 100. up is 0, right is 9000, top right is 4500, bottom is 18000, you get it.
when humans leanr to write stuf in the fuck plain language instead of tell you “oh go fuck with directx10”
that’s all you need
xoxosvst
July 13, 2018 at 8:20 pm
a few months later..
obscure-to-me point about teh joyGetPosEx API: “You must set the dwSize and dwFlags members or joyGetPosEx will fail.”
so:
JOYINFOEX joyinfo;
MMRESULT joygetpos_result = joyGetPosEx( JOYSTICKID1, &joyinfo );
joyinfo.dwSize = sizeof(joyinfo);
joyinfo.dwFlags = JOY_RETURNALL;
i was getting arbitrary results… plug controller in one time or port, range is 0-255, next time 0-65535… much better (now so far..) when set those two properties.
xoxosvst
October 1, 2018 at 3:25 am