Main Page   Data Structures   File List   Data Fields   Globals  

hapi.c File Reference

#include "lapi.h"
#include "hapi.h"

Go to the source code of this file.

Data Structures

struct  MouseData

Defines

#define eSuspend   1
#define eUnSuspend   2
#define eCleanup   3
#define SPI_GETMOUSESPEED   112
#define abs(x)   (max((x),-(x)))

Typedefs

typedef MouseData MouseData

Functions

void __cdecl thehCallback (int number, signed int dx, signed int dy, unsigned int buttons, int suspended)
void __cdecl hLockCanvas ()
void __cdecl hUpdateCursors (int useCache)
DWORD WINAPI MainThread (LPVOID lpParameter)
int __cdecl hInitialise (int count, HWND window, HDC getscreen, unsigned int getevents)
void __cdecl hSuspendMouse (int number)
void __cdecl hUnSuspendMouse (int number)
void __cdecl hCleanup (void)
void __cdecl hGetRelativePosition (int number, hPOINT *p)
void __cdecl hGetAbsolutePosition (int number, hPOINT *p)
void __cdecl hSetAbsolutePosition (int number, hPOINT p)
void __cdecl hSetCursor (int number, hPOINT p, HBITMAP cursor, BYTE r, BYTE g, BYTE b)
int __cdecl hGetLastSuspended (void)
int __cdecl hGetLastUnSuspended (void)
int __cdecl hGetLastMoved (void)

Variables

MouseDatamicedata = NULL
int nummice = -1
HANDLE child = NULL
volatile int mousecount
volatile HWND mousewindow
DWORD dwThreadId
HANDLE datamutex = NULL
HANDLE canvas = NULL
HANDLE mutex = NULL
HANDLE event = NULL
HANDLE reply = NULL
int lastsuspended
int lastunsuspended
int lastmoved
unsigned int events
volatile int call
volatile int parameter
int accel [3]
int speed
int rx
int ry
HDC tmp = NULL
int mleft
int mright
int mtop
int mbottom
HDC screen


Define Documentation

#define abs      (max((x),-(x)))
 

Definition at line 55 of file hapi.c.

Referenced by hUpdateCursors(), and thehCallback().

#define eCleanup   3
 

Definition at line 7 of file hapi.c.

Referenced by hCleanup(), and MainThread().

#define eSuspend   1
 

Definition at line 5 of file hapi.c.

Referenced by hSuspendMouse(), and MainThread().

#define eUnSuspend   2
 

Definition at line 6 of file hapi.c.

Referenced by hUnSuspendMouse(), and MainThread().

#define SPI_GETMOUSESPEED   112
 

Definition at line 10 of file hapi.c.

Referenced by hInitialise().


Typedef Documentation

typedef struct MouseData MouseData
 


Function Documentation

void __cdecl hCleanup void   
 

Shutdown the API. Takes care of deallocating allocated ressources, including killing listener thread. It also UnGets all acquired mice.

Definition at line 345 of file hapi.c.

References call, child, eCleanup, event, mutex, and reply.

void __cdecl hGetAbsolutePosition int    number,
hPOINT   p
 

Get the absolute position of the specified mouse. This is affected by the CLIP flag (ie. the position is always within the DC given to hInitialise).

Parameters:
number  - The mouse for which to get the position
p  - a pointer to a hPOINT to store the position in

Definition at line 371 of file hapi.c.

References datamutex, MouseData::X, hPOINT::x, MouseData::Y, and hPOINT::y.

int __cdecl hGetLastMoved void   
 

Definition at line 450 of file hapi.c.

References lastmoved.

int __cdecl hGetLastSuspended void   
 

Definition at line 438 of file hapi.c.

References lastsuspended.

int __cdecl hGetLastUnSuspended void   
 

Definition at line 444 of file hapi.c.

References lastunsuspended.

void __cdecl hGetRelativePosition int    number,
hPOINT   p
 

Get the relative movement of the specified mouse since the last call. This is not affected by the CLIP flag.

Parameters:
number  - The mouse for which to get the relative position
p  - a pointer to a hPOINT to store the position in

Definition at line 359 of file hapi.c.

References datamutex, MouseData::dx, MouseData::dy, hPOINT::x, and hPOINT::y.

int __cdecl hInitialise int    count,
HWND    window,
HDC    screen,
unsigned int    flags
 

Initialise the API. This must be called or all the other functions will return abnormally. After this returns from the first call, it is thread-safe.

Parameters:
count  - Number of mice to try to acquire
window  - Window to send events to. Only required if either of BUTTON or MOVEMENT are specified
screen  - The display context to draw cursors to. Only required if either of CURSOR or CLIP are specified
flags  - Specifies flags as described above
Returns:
the number of mice actually acquired

Definition at line 237 of file hapi.c.

References accel, MouseData::cache, canvas, child, MouseData::cursor, CURSOR, datamutex, dwThreadId, MouseData::dx, MouseData::dy, event, events, MouseData::hx, MouseData::hy, MainThread(), mbottom, mleft, mousecount, mousewindow, mright, mtop, mutex, nummice, parameter, reply, rx, ry, screen, speed, SPI_GETMOUSESPEED, MouseData::suspended, MouseData::X, and MouseData::Y.

void __cdecl hLockCanvas  
 

Lock the canvas on which cursors are drawn. No cursors will be updated when this is called until hUpdateCursors is called manually from within the same thread.

Definition at line 146 of file hapi.c.

References canvas.

void __cdecl hSetAbsolutePosition int    number,
hPOINT    p
 

Set the relative position of the specified mouse. This is clipped to the DC given to hInitialise is the CLIP flag was specified. If the CURSOR flag was specified, the cursors are redrawn.

Parameters:
number  - The mouse to set the position for
p  - Where to move the mouse

Definition at line 380 of file hapi.c.

References datamutex, mbottom, mleft, mright, mtop, hPOINT::x, MouseData::X, hPOINT::y, and MouseData::Y.

void __cdecl hSetCursor int    number,
hPOINT    p,
HBITMAP    cursor,
BYTE    r,
BYTE    g,
BYTE    b
 

Set a cursor for a given mouse. If the CURSOR flag is not given this only stores the cursor, but does not display it.

Parameters:
number  - The mouse to set the cursor for
p  - The hotspot of the cursor
cursor  -a bitmap describing the cursor. Set to null to hide the cursor. Areas with color (255, 0, 205) are transparent, areas with color (255, 0, 204) are replaced by the colour specified
r, g, b  - RGB values of color to place instead of pixels with index 1

Definition at line 390 of file hapi.c.

References MouseData::cache, MouseData::cachebitmap, MouseData::cursor, MouseData::cursorbitmap, MouseData::cx, MouseData::cy, datamutex, hUpdateCursors(), MouseData::hx, MouseData::hy, screen, MouseData::theSize, tmp, hPOINT::x, and hPOINT::y.

void __cdecl hSuspendMouse int    number
 

Suspend the specified mouse

Parameters:
number  - The mouse to suspend

Definition at line 313 of file hapi.c.

References call, child, eSuspend, event, lastmoved, lastsuspended, lastunsuspended, mutex, parameter, reply, and MouseData::suspended.

void __cdecl hUnSuspendMouse int    number
 

UnSuspend the specified mouse

Parameters:
number  - The mouse to unsuspend

Definition at line 329 of file hapi.c.

References call, child, eUnSuspend, event, lastmoved, lastsuspended, lastunsuspended, mutex, parameter, reply, and MouseData::suspended.

void __cdecl hUpdateCursors int    useCache
 

Redisplay all cursors (only if the CURSOR flag is given)

Parameters:
useCache  - Swap the cache of the background in before redrawing cursors. Normally you want this, but if you know that you have redrawn the DC on which the cursors are drawn, this can corrupt the image.

Definition at line 150 of file hapi.c.

References abs, MouseData::cache, canvas, MouseData::cursor, CURSOR, MouseData::cx, MouseData::cy, datamutex, events, MouseData::hx, MouseData::hy, nummice, screen, MouseData::suspended, MouseData::theSize, tmp, MouseData::tx, MouseData::ty, MouseData::wh, MouseData::ww, MouseData::wx, MouseData::wy, MouseData::X, and MouseData::Y.

Referenced by hSetCursor(), MainThread(), and thehCallback().

DWORD WINAPI MainThread LPVOID    lpParameter
 

Definition at line 205 of file hapi.c.

References eCleanup, eSuspend, eUnSuspend, event, hUpdateCursors(), lGetMice(), lRegisterCallback(), lSuspendMouse(), lUnGetAllMice(), lUnRegisterCallback(), lUnSuspendMouse(), mousecount, parameter, reply, and thehCallback().

Referenced by hInitialise().

void __cdecl thehCallback int    number,
signed int    dx,
signed int    dy,
unsigned int    buttons,
int    suspended
 

Definition at line 57 of file hapi.c.

References abs, accel, ACCELERATE, BUTTON, CLIP, datamutex, MouseData::dx, MouseData::dy, events, hUpdateCursors(), lastmoved, lastsuspended, lastunsuspended, mbottom, mleft, mousewindow, MOVEMENT, mright, mtop, rx, ry, speed, SUSPEND, MouseData::X, and MouseData::Y.

Referenced by MainThread().


Variable Documentation

int accel[3]
 

Definition at line 42 of file hapi.c.

Referenced by hInitialise(), and thehCallback().

volatile int call
 

Definition at line 40 of file hapi.c.

Referenced by hCleanup(), hSuspendMouse(), and hUnSuspendMouse().

HANDLE canvas = NULL
 

Definition at line 32 of file hapi.c.

Referenced by hInitialise(), hLockCanvas(), and hUpdateCursors().

HANDLE child = NULL
 

Definition at line 27 of file hapi.c.

Referenced by hCleanup(), hInitialise(), hSuspendMouse(), and hUnSuspendMouse().

HANDLE datamutex = NULL
 

Definition at line 31 of file hapi.c.

Referenced by hGetAbsolutePosition(), hGetRelativePosition(), hInitialise(), hSetAbsolutePosition(), hSetCursor(), hUpdateCursors(), and thehCallback().

DWORD dwThreadId
 

Definition at line 30 of file hapi.c.

Referenced by hInitialise().

HANDLE event = NULL
 

Definition at line 34 of file hapi.c.

Referenced by hCleanup(), hInitialise(), hSuspendMouse(), hUnSuspendMouse(), and MainThread().

unsigned int events
 

Definition at line 39 of file hapi.c.

Referenced by hInitialise(), hUpdateCursors(), and thehCallback().

int lastmoved
 

Definition at line 37 of file hapi.c.

Referenced by hGetLastMoved(), hSuspendMouse(), hUnSuspendMouse(), and thehCallback().

int lastsuspended
 

Definition at line 37 of file hapi.c.

Referenced by hGetLastSuspended(), hSuspendMouse(), hUnSuspendMouse(), and thehCallback().

int lastunsuspended
 

Definition at line 37 of file hapi.c.

Referenced by hGetLastUnSuspended(), hSuspendMouse(), hUnSuspendMouse(), and thehCallback().

int mbottom
 

Definition at line 52 of file hapi.c.

Referenced by hInitialise(), hSetAbsolutePosition(), and thehCallback().

MouseData* micedata = NULL
 

Definition at line 24 of file hapi.c.

int mleft
 

Definition at line 52 of file hapi.c.

Referenced by hInitialise(), hSetAbsolutePosition(), and thehCallback().

volatile int mousecount
 

Definition at line 28 of file hapi.c.

Referenced by hInitialise(), and MainThread().

volatile HWND mousewindow
 

Definition at line 29 of file hapi.c.

Referenced by hInitialise(), and thehCallback().

int mright
 

Definition at line 52 of file hapi.c.

Referenced by hInitialise(), hSetAbsolutePosition(), and thehCallback().

int mtop
 

Definition at line 52 of file hapi.c.

Referenced by hInitialise(), hSetAbsolutePosition(), and thehCallback().

HANDLE mutex = NULL
 

Definition at line 33 of file hapi.c.

Referenced by hCleanup(), hInitialise(), hSuspendMouse(), and hUnSuspendMouse().

int nummice = -1
 

Definition at line 25 of file hapi.c.

Referenced by hInitialise(), and hUpdateCursors().

volatile int parameter
 

Definition at line 40 of file hapi.c.

Referenced by hInitialise(), hSuspendMouse(), hUnSuspendMouse(), and MainThread().

HANDLE reply = NULL
 

Definition at line 35 of file hapi.c.

Referenced by hCleanup(), hInitialise(), hSuspendMouse(), hUnSuspendMouse(), and MainThread().

int rx
 

Definition at line 44 of file hapi.c.

Referenced by hInitialise(), and thehCallback().

int ry
 

Definition at line 44 of file hapi.c.

Referenced by hInitialise(), and thehCallback().

HDC screen
 

Definition at line 53 of file hapi.c.

Referenced by hInitialise(), hSetCursor(), and hUpdateCursors().

int speed
 

Definition at line 43 of file hapi.c.

Referenced by hInitialise(), and thehCallback().

HDC tmp = NULL
 

Definition at line 46 of file hapi.c.

Referenced by hSetCursor(), and hUpdateCursors().


Generated on Mon Jan 12 21:47:21 2004 for CPNMouse by doxygen1.2.18