Mouse Support without Engine Funcs

On viernes, 24 de septiembre de 2010 0 comentarios

Credits go to:
Crusader, LanceVorgin, Xnient

Well, after being unsatisfied with my previous mouse making crap, I decided to find a new way to do a mouse in my Tool...
My friend(Xnient) kinda also wanted a mouse in his Tool, so that just made me want to make a new style of mouse, that will work with an opengl hook, I'm not sure about wrapper though, it might...
Without further adu, lets get started...

For making a mouse, we have to know what Half-Life(or any other game for that matter) uses to do a mouse. I figured out that it uses SetCursorPos, and GetCursorPos.

So, add hooks to these, so my_GetCursorPos and my_SetCursorPos for simplicity's sake...

        

That's a mighty fine looking hook if you ask me :)...

Now, some theory:
-Half-Life calls SetCursorPos at least once a frame to set cursor in middle.
-Half-Life reads where the mouse is by GetCursorPos.
-We do not want Half-Life to move the cursor around when were using it
-We want HL to believe its still in the middle to make your character not changes its view

So, what I have is a bool to say when my menu is open (cvar.menu), should be easy to understand...

        

Plz note, Viewport[4] is the variable that changes depending on how big your screen is, its OpenGL so it shouldn't be that hard to find out...
int Viewport[4] = {0, 0, 1024, 768}; My res is at 1024x768
int mousepos[2] = Saved crap for where we want to save the mouse's info

Ok, so that blocks HL from changing the mouse, and makes HL think its still in the middle of the screen, now we have to make a menu toggler...
This is my code in glViewPort:

        

That just toggles my friggin menu when I press F1... When the menu is un activated, it will send the mouse back to the middle of the screen, it isn't really important, just at the end your characters view will move for 1 frame... I just did that so I didn't get seizures, you can fuck around with it and not mess it up I suppose...

Now, it came to my attention that HL still reads mouse clicks, and if your in the menu you don't want to start shooting wildly do you?
So, Crusader pretty much gave me all of this (/me thanks).
It is just a keyboard/mouse hook, it prevents the key info being sent to HL, but our Tool will still be able to read it.

        

And, whenever you initialize stuff in your Tool, like for glPrint or something, just call HookKBD(); and it should work, if not then PM me on irc.rizenet.org #cheat-network

So, what's a good mouse when you cannot see it, Ill give you this mouse drawing code if you are really stupid and cannot figure out to do with it
(btw, its just a crosshair mouse, you can figure out how to draw a good mouse)

        

Now in glEnable, call DrawMouse(mousepos[0], mousepos[1]); to draw your mouse crosshair...


That is the end, my only friend the end...
«Azorbix»

Copyright© 2003 Azorbix

This may not appear elsewhere without permission(but may be linked to)

BTW:
Get the song Ordinary by the The Buzzhorn

0 comentarios:

Publicar un comentario