Add basic XTest functionality, clean up and refactor other sources

This commit is contained in:
Bradlee Speice
2012-06-26 14:07:03 -04:00
parent 62431b5a18
commit ca39bd90be
10 changed files with 699 additions and 44 deletions

View File

@ -1,7 +1,7 @@
/*
* =====================================================================================
*
* Filename: libcvautomation-x11.h
* Filename: libcvautomation-xlib.h
*
* Description: Function definitions for X11 operations
*
@ -16,8 +16,8 @@
* =====================================================================================
*/
#ifndef LIBCVAUTOMATION_X11_H
#define LIBCVAUTOMATION_X11_H
#ifndef LIBCVAUTOMATION_XLIB_H
#define LIBCVAUTOMATION_XLIB_H
#include <libcvautomation/libcvautomation.h>
@ -30,16 +30,22 @@
* CV_TM_CCOEFF_NORMED
*/
/* Custom wrapper for XOpenDisplay function */
Display* cvaOpenDisplay ( char *displayName );
/* Custom wrapper for XCloseDisplay funtion */
void cvaCloseDisplay ( Display *displayLocation );
/* Match a sub image using the X11 root window as root */
CvPoint matchSubImage_X11( char *displayLocation, IplImage *subImage, int searchMethod, int tolerance );
CvPoint matchSubImage_X11( Display *displayLocation, IplImage *subImage, int searchMethod, int tolerance );
/* Match a sub image using the X11 root window as root, return the center */
CvPoint matchSubImage_X11_center( char *displayLocation, IplImage *subImage, int searchMethod, int tolerance );
CvPoint matchSubImage_X11_center( Display *displayLocation, IplImage *subImage, int searchMethod, int tolerance );
/* Match a sub image using X11 as root, from filename */
CvPoint matchSubImage_X11_location( char *displayLocation, const char *subImage_location, int search_method, int tolerance );
CvPoint matchSubImage_X11_location( Display *displayLocation, const char *subImage_location, int search_method, int tolerance );
/* Match a sub image using X11 as root, from filename, return the center */
CvPoint matchSubImage_X11_location_center( char *displayLocation, const char *subImage_location, int search_method, int tolerance );
CvPoint matchSubImage_X11_location_center( Display *displayLocation, const char *subImage_location, int search_method, int tolerance );
#endif /* LIBCVAUTOMATION_X11_H */
#endif /* LIBCVAUTOMATION_XLIB_H */

View File

@ -0,0 +1,97 @@
/*
* =====================================================================================
*
* Filename: libcvautomation-xinput.h
*
* Description:
*
* Version: 1.0
* Created: 06/26/2012 09:08:41 AM
* Revision: none
* Compiler: gcc
*
* Author: Bradlee Speice (), bspeice.nc@gmail.com
* Organization:
*
* =====================================================================================
*/
#ifndef LIBCVAUTOMATION_XTEST_H
#define LIBCVAUTOMATION_XTEST_H
#include <libcvautomation/libcvautomation.h>
/* Make sure that the XTest extension is supported.
* If it's not, return 0 (false) */
int xte_xTestSupported ( Display *displayLocation );
/* Get the current location of the pointer */
cvaPoint xte_pointerLocation ( Display *displayLocation );
/* Click the mouse where it is currently at */
void xte_clickMouse ( Display *displayLocation, int mouseButton );
/* Click the mouse on an absolute screen location */
void xte_clickMouseXY ( Display *displayLocation, int xLocation, int yLocation, int mouseButton );
/* Click the mouse on a screen location relative to where it currently is */
void xte_clickMouseRXY ( Display *displayLocation, int xIncrement, int yIncrement, int mouseButton );
/* Click the mouse at the top-left corner of an image on the specified display */
void xte_clickMouseImage ( Display *displayLocation, IplImage *subImage, int mouseButton, int searchMethod, int tolerance );
/* Click the mouse at the top-left corner of an image on the specified display
* where the subImage is a file location */
void xte_clickMouseImage_location ( Display *displayLocation, const char *fileName, int mouseButton, int searchMethod, int tolerance );
/* Click the mouse at the center of an image on the specified display */
void xte_clickMouseImage_center ( Display *displayLocation, IplImage *subImage, int mouseButton, int searchMethod, int tolerance );
/* Click the mouse at the center of an image on the specified display
* where the subImage is a file location */
void xte_clickMouseImage_location_center ( Display *displayLocation, const char *fileName, int mouseButton, int searchMethod, int tolerance );
/* Move the mouse to a location and leave it there */
void xte_hoverMouseXY ( Display *displayLocation, int xLocation, int yLocation );
/* Move the mouse to a location relative to where it currently is and leave it there */
void xte_hoverMouseRXY ( Display *displayLocation, int xIncrement, int yIncrement );
/* Move the mouse to a location at the top-left corner of an image on the specified display
* but don't click the mouse */
void xte_hoverMouseImage ( Display *displayLocation, IplImage *subImage, int searchMethod, int tolerance );
/* Move the mouse to a location at the top-left corner of an image from file on the specified display
* but don't click the mouse */
void xte_hoverMouseImage_location ( Display *displayLocation, const char *filename, int searchMethod, int tolerance );
/* Move the mouse to a location at the center of an image on the specified display
* but don't click the mouse */
void xte_hoverMouseImage_center ( Display *displayLocation, IplImage *subImage, int searchMethod, int tolerance );
/* Move the mouse to a location at the center of an image from file on the specified display
* but don't click the mouse */
void xte_hoverMouseImage_location_center ( Display *displayLocation, const char *fileName, int searchMethod, int tolerance );
/* Push a mouse button down, but don't release it */
void xte_mouseDown ( Display *displayLocation, int mouseButton );
/* Let a mouse button up */
void xte_mouseUp ( Display *displayLocation, int mouseButton );
/* Move the mouse a little bit */
void xte_mouseJiggle ( Display *displayLocation );
/* Press and release a single key */
void xte_clickKey ( Display *displayLocation, char key );
/* Press and release keys in a string */
void xte_clickKeyStr ( Display *displayLocation, const char *string );
/* Press a key down */
void xte_keyDown ( Display *displayLocation, char key );
/* Release a key */
void xte_keyUp ( Display *displayLocation, char key );
#endif /* LIBCVAUTOMATION_XTEST_H */

View File

@ -37,6 +37,7 @@
/* X11 includes */
#include <X11/Xlib.h>
#include <X11/Xutil.h>
#include <X11/extensions/XTest.h>
/* Define a basic structure to help us with using multiple-picture arguments
* Yes, it's a hackish implementation, nobody said you had to use this one. */
@ -51,10 +52,16 @@ typedef struct {
} cvautomationList;
/* Define another basic structure for points */
typedef struct {
int x, y;
} cvaPoint;
/* Project component includes */
/* The includes come here to make sure all function prototypes have access
* to the cvautomationList struct */
#include <libcvautomation/libcvautomation-opencv.h>
#include <libcvautomation/libcvautomation-x11.h>
#include <libcvautomation/libcvautomation-xlib.h>
#include <libcvautomation/libcvautomation-xtest.h>
#endif /* LIBCVAUTOMATION_H */