1 registered members (AndrewAMD),
1,507
guests, and 12
spiders. |
Key:
Admin,
Global Mod,
Mod
|
|
|
Re: New, delete, and windows.h
[Re: the_mehmaster]
#350291
12/15/10 09:00
12/15/10 09:00
|
Joined: Feb 2008
Posts: 3,232 Australia
EvilSOB
Expert
|
Expert
Joined: Feb 2008
Posts: 3,232
Australia
|
Dude! What does this demo do when you run it, and what are you running it with? Im using A7.86.0 Comm and the mouse performs the little squares, but it also wanders off to the top-left of the screen... Did it do that for you?!? [EDIT] PS: I will be getting to your PM later tonite... [EDIT 2] For what it is worth, here is a savagely cut down version of meh_masters code.... windows.h no longer requires, ans structs over-simplified... (still has the drift problem on my machine...)
#include <acknex.h>
#include <default.c>
long __stdcall SendInput(long cInputs,long pInputs,long cbSize);
API(SendInput,user32)
typedef struct MOUSEINPUT
{
long type; //unused : always ZERO for mouse
long dx, dy; //move mouse by dx, dy pixels
long unused_0; //unused
long dwFlags; //static : always 0x1 for mouse-input
long unused_1[2]; //unused
} MOUSEINPUT;
void mouseMove(int dx, int dy)
{
static MOUSEINPUT* input = NULL;
if(!input) { input = sys_malloc(sizeof(MOUSEINPUT));
memset(input, 0, sizeof(MOUSEINPUT));
input.dwFlags = 0x1; }
//-----------------------------------------------------
input.dx = dx;
input.dy = dy;
SendInput(0x1, input, sizeof(MOUSEINPUT));
}
void main()
{
level_load("");
while(1)
{
mouseMove(40,0);
wait(1);
mouseMove(0,40);
wait(1);
mouseMove(-40,0);
wait(1);
mouseMove(0,-40);
wait(1);
}
}
Last edited by EvilSOB; 12/15/10 09:35. Reason: code added
"There is no fate but what WE make." - CEO Cyberdyne Systems Corp. A8.30.5 Commercial
|
|
|
Re: New, delete, and windows.h
[Re: EvilSOB]
#350301
12/15/10 10:22
12/15/10 10:22
|
Joined: Dec 2008
Posts: 528 Wagga, Australia
the_mehmaster
OP
User
|
OP
User
Joined: Dec 2008
Posts: 528
Wagga, Australia
|
Yeah the code does exactly the same thing for me But that doesn't really matter as that's all it was supposed to do anyway.. I have already integrated it with the IMU code that we had earlier, and it works perfectly.. Using the IMU to control crysis is pretty cool EDIT: I integrated your code.. looks a lot more efficient, and everything still works fine. Thanks!
Last edited by the_mehmaster; 12/15/10 10:29.
|
|
|
Re: New, delete, and windows.h
[Re: EvilSOB]
#350317
12/15/10 12:20
12/15/10 12:20
|
Joined: Apr 2007
Posts: 3,751 Canada
WretchedSid
Expert
|
Expert
Joined: Apr 2007
Posts: 3,751
Canada
|
Question: Why malloc at all? Thats a serious performance penalty when you call this multiple times as its dispatched in many other functions including a context switch to the kernel and memory mapping. The code from EvilSOB is better, but leaks the memory. In the end it could be done perfectly on the stack.
Shitlord by trade and passion. Graphics programmer at Laminar Research. I write blog posts at feresignum.com
|
|
|
|