I’ve recently starting looking into this, but thought I’d ask here to see if anyone has already found a way to do this.
Max provides some methods to do this already, but the way it tests for a right-click of the mouse is completely unreliable. So I’d thought I’d turn to dotNet for an alternative way of testing the mouse. Also, Max doesn’t have a way of testing just any keyboard input, only the shift/alt/control keys.
Any help would be appreciated, and I’ll post any information/solutions I find also.
I recently ran into this limitation as well - only being about to use ctrl, alt, or shift as inputs in my mini app. I’d love to hear about making this work.
I know you can do this using XNA and WPF, but don’t know how to get those libraries recognized by Max. I know you can hack WPF into Max, but don’t want to go there right now.
[QUOTE=bcloward;793]I recently ran into this limitation as well - only being about to use ctrl, alt, or shift as inputs in my mini app. I’d love to hear about making this work.[/QUOTE]
Light looked into this at my behest:
http://tech-artists.org/forum/showpost.php?p=690&postcount=5
It doesn’t appear possible to do what you want, JHaywood. If the mouse/key press is inside a dotnet control, doing this is pretty easy. Basically:
on theControl KeyDown arg do
(
local keyCode = arg.keyCode
local virtKeys = DotNetClass "System.Windows.Forms.Keys"
if (keyCode == virtKeys.T) then print "T pressed"
)
You probably knew that already but I figured it can’t hurt posting.
But if you just want to test all the time/outside of a control, or want it for controls without the MouseDown/KeyDown event handler, I think you’re out of luck.
I’ve been thinking that this thread over at cgtalk along with the good old windows message pump might have a few clues as to how we can deal with this, but haven’t had any chances to do any real experimenting as yet.
On looking again, thats completely useless It only helps with SENDKING keypresses not with intercepting them.
There are a couple more threads that might help:
DotNET+DirectInput(Joystick) Help needed!
Timeslider controlled with the Mouse wheel
Using DirectInput looks promising.
And then there’s some info I got from one or our engineers on GetKeyboardState/GetKeyState/GetAsyncKeyState, GetMouseMovePointsEx, and using PInvoke to access them.
I want to dive into this more when I get some free time. For now, I’ve created a function I can call for getting user input. It just uses the built in Max methods currrently, but I want to change those out for dotNet methods eventually.
fn getUserInput =
(
local userInput, ui
struct userInput
(
escape,
shift,
control,
alt,
mLeft,
mMiddle,
mRight
)
mb = mouse.buttonStates
ui = userInput()
ui.escape = keyboard.escPressed
ui.shift = keyboard.shiftPressed
ui.control = keyboard.controlPressed
ui.alt = keyboard.altPressed
ui.mLeft = mb[1]
ui.mMiddle = mb[2]
ui.mRight = mb[3]
ui
)