示例#1
0
static int PD_Open(MOUSEDEVICE *pmd)
{
	char *tsdevice = NULL;

	if ((tsdevice = getenv("TSLIB_TSDEVICE")) != NULL) {
		ts = ts_open(tsdevice, 1);
	} else {
		ts = ts_open("/dev/input/event0", 1);
	}

	if (!ts) {
		EPRINTF("Error opening touchscreen device [%s]: %s\n",
			tsdevice, strerror(errno));
		return -1;
	}

	if (ts_config(ts)) {
		EPRINTF("Error configuring touchscreen device: %s\n",
			strerror(errno));
		ts_close(ts);
		return -1;
	}

	GdHideCursor(&scrdev);
	return ts_fd(ts);
}
示例#2
0
/*
 * Initialize the mouse.
 * This sets its position to (0, 0) with no boundaries and no buttons pressed.
 * Returns < 0 on error, or mouse fd on success
 */
int
GdOpenMouse(void)
{
	int fd;

	/* init mouse position info*/
	buttons = 0;
	xpos = 0;
	ypos = 0;
	minx = MIN_MWCOORD;
	miny = MIN_MWCOORD;
	maxx = MAX_MWCOORD;
	maxy = MAX_MWCOORD;
	changed = TRUE;

	/* init cursor position and size info*/
	curvisible = 0;
	curneedsrestore = FALSE;
	curminx = minx;
	curminy = miny;
	curmaxx = curminx + MWMAX_CURSOR_SIZE - 1;
	curmaxy = curminy + MWMAX_CURSOR_SIZE - 1;

	if ((fd = mousedev.Open(&mousedev)) == -1)
		return -1;

	/* get default acceleration settings*/
	mousedev.GetDefaultAccel(&scale, &thresh);

	/* handle null mouse driver by hiding cursor*/
	if(fd == -2)
		GdHideCursor(&scrdev);
	return fd;
}
示例#3
0
/*
 * Open up the mouse device.
 * Returns the fd if successful, or negative if unsuccessful.
 */
static int PD_Open(MOUSEDEVICE *pmd)
{
   if(!init_touch(398,3720,3550,500,0))
   {
      printf("error init touch\n");
      return -1;
   }
   else
   {
      GdHideCursor(&scrdev);
   	return 1;
   }
}
示例#4
0
static int PD_Open(MOUSEDEVICE *pmd)
{
 	/*
	 * open up the touch-panel device.
	 * Return the fd if successful, or negative if unsuccessful.
	 */

	pd_fd = open(TOUCHDEVICE, O_NONBLOCK);
	if (pd_fd < 0) {
		EPRINTF("Error %d opening touch panel\n", errno);
		return -1;
	}

	GdHideCursor(&scrdev);
	return pd_fd;
}
示例#5
0
/*
 * Set the cursor size and bitmaps.
 */
void
GdSetCursor(PMWCURSOR pcursor)
{
	int	bytes;

	GdHideCursor(&scrdev);
	curmaxx = curminx + pcursor->width - 1;
	curmaxy = curminy + pcursor->height - 1;

	curfg = GdFindColor(pcursor->fgcolor);
	curbg = GdFindColor(pcursor->bgcolor);
	bytes = MWIMAGE_WORDS(pcursor->width) * pcursor->height
			* sizeof(MWIMAGEBITS);
	memcpy(cursorcolor, pcursor->image, bytes);
	memcpy(cursormask, pcursor->mask, bytes);

	GdShowCursor(&scrdev);
}
示例#6
0
/**
 * Set the cursor position.
 *
 * @param newx New X co-ordinate.
 * @param newy New Y co-ordinate.
 */
void
GdMoveCursor(MWCOORD newx, MWCOORD newy)
{
	MWCOORD shiftx;
	MWCOORD shifty;

	shiftx = newx - curminx;
	shifty = newy - curminy;
	if(shiftx == 0 && shifty == 0)
		return;
	curminx += shiftx;
	curmaxx += shiftx;
	curminy += shifty;
	curmaxy += shifty;

	/* Restore the screen under the mouse pointer*/
	GdHideCursor(&scrdev);

	/* Draw the new pointer*/
	GdShowCursor(&scrdev);
}
示例#7
0
static int DE2TS_Open(MOUSEDEVICE *pmd)
{
	struct de2ts_cal_params drv_params;

#if EEPROM_STORED_CALDATA
	if (read_eeprom_param() == 0) {
		drv_params = eep_stored_prm.prm;
	} else
#endif
	{
		/* use reasonnable default */
		drv_params.version = DE2TS_VERSION;
		drv_params.xoff = 500;
		drv_params.xden = 2840;
		drv_params.yoff = 3484;
		drv_params.yden = -3129;
		drv_params.xrng = 320;
		drv_params.yrng = 240;
	}

 	/*
	 * open up the touch-panel device.
	 * Return the fd if successful, or negative if unsuccessful.
	 */

	de2ts_fd = open("/dev/ts", O_NONBLOCK | O_RDWR);
	if (de2ts_fd < 0) {
		EPRINTF("Error %d opening touch panel\n", errno);
		return -1;
	}

	if (ioctl(de2ts_fd, DE2TS_CAL_PARAMS_SET, &drv_params) < 0) {
		EPRINTF("Unable to set touchscreen information\n");
		DE2TS_Close();
		return -1;
	}

	GdHideCursor(&scrdev);
	return de2ts_fd;
}
示例#8
0
/**
 * Check to see if the mouse pointer is about to be overwritten.
 * If so, then remove the cursor so that the graphics operation
 * works correctly.  If the cursor is removed, then this fact will
 * be remembered and a later call to GdFixCursor will restore it.
 *
 * @param psd Drawing surface.  If it is not onscreen, this call has
 * no effect.
 * @param x1 Left edge of rectangle to check.
 * @param y1 Top edge of rectangle to check.
 * @param x2 Right edge of rectangle to check.
 * @param y2 Bottom edge of rectangle to check.
 */
void
GdCheckCursor(PSD psd,MWCOORD x1,MWCOORD y1,MWCOORD x2,MWCOORD y2)
{
	MWCOORD temp;

	if (curvisible <= 0 || (psd->flags & PSF_SCREEN) == 0)
		return;

	if (x1 > x2) {
		temp = x1;
		x1 = x2;
		x2 = temp;
	}
	if (y1 > y2) {
		temp = y1;
		y1 = y2;
		y2 = temp;
	}
	if (x1 > curmaxx || x2 < curminx || y1 > curmaxy || y2 < curminy)
		return;

	GdHideCursor(psd);
	curneedsrestore = TRUE;
}
示例#9
0
static int PD_Open(MOUSEDEVICE *pmd)
{
	int err;
	struct ts_drv_params  drv_params;
	int mx1, mx2, my1, my2;
	int ux1, ux2, uy1, uy2;

 	/*
	 * open up the touch-panel device.
	 * Return the fd if successful, or negative if unsuccessful.
	 */

	pd_fd = open("/dev/ts", O_NONBLOCK | O_RDWR);
	if (pd_fd < 0) {
		EPRINTF("Error %d opening touch panel\n", errno);
		return -1;
	}

	err = ioctl(pd_fd, TS_PARAMS_GET, &drv_params);
	if (err == -1) {
		close(pd_fd);
		return(err);
	}

	drv_params.version_req    = MC68328DIGI_VERSION;
	drv_params.event_queue_on = 1;
	drv_params.deglitch_ms    = 0;
	drv_params.sample_ms      = 10;
	drv_params.follow_thrs    = 0;
	drv_params.mv_thrs        = 2;
	drv_params.y_max          = 159 + 66;  // to allow scribble area
	drv_params.y_min          = 0;
	drv_params.x_max          = 159;
	drv_params.x_min          = 0;
	drv_params.xy_swap        = 0;

	// according to mc68328digi.h 'How to calculate the parameters', we have
	// measured:
	mx1 = 508; ux1 =   0;
	my1 = 508; uy1 =   0;
	mx2 = 188; ux2 = 159;
	my2 = 188; uy2 = 159;

	// now calculate the params:
	drv_params.x_ratio_num    = ux1 - ux2;
	drv_params.x_ratio_den    = mx1 - mx2;
	drv_params.x_offset       =
	ux1 - mx1 * drv_params.x_ratio_num / drv_params.x_ratio_den;

	drv_params.y_ratio_num    = uy1 - uy2;
	drv_params.y_ratio_den    = my1 - my2;
	drv_params.y_offset       =
	uy1 - my1 * drv_params.y_ratio_num / drv_params.y_ratio_den;

	err = ioctl(pd_fd, TS_PARAMS_SET, &drv_params);
	if (err == -1) {
		close(pd_fd);
		return(err);
	}

	GdHideCursor(&scrdev);
	return pd_fd;
}
示例#10
0
static int
AM_Read(MWCOORD *dx, MWCOORD *dy, MWCOORD *dz, int *bp)
{
static int mz; 
static int hidingmouse;   

		int mickeyx = 0;
		int mickeyy = 0;
		int mickeyz = 0;
		int buttons = 0;

        poll_mouse();

if (ALLEGRO_SUB_VERSION >2){
//mouse_on_screen() not available on version 4.2 -> starting with 4.3
        if (mouse_on_screen()){ //mouse inside microwindows window
            if (hidingmouse == 1){ //already shown?
                GdShowCursor(&scrdev);
                hidingmouse == 0;
            }
        }else{
            if (hidingmouse == 0){ //already hidden?
                GdHideCursor(&scrdev);
                hidingmouse=1;
            }
        }
}
		/* microwindows reads the motion */
		get_mouse_mickeys(&mickeyx,&mickeyy);
#if 0
		*dx=mickeyx;
		*dy=mickeyy;
#else
        /* return position */
	    *dx=mouse_x;
        *dy=mouse_y; 
#endif
//calculate wheel button (up/down)
		if(mouse_z != mz)
		    mickeyz = mouse_z - mz;
		else
		    mickeyz = 0;
		mz = mouse_z;

        *dz = 0;
        *bp = 0;
		buttons = 0;
		//the buttons seem to be returned different than documented in allegro
		if (mouse_b & 1)
			buttons |= MWBUTTON_L;
		if (mouse_b & 2)
			buttons |= MWBUTTON_R;
		if (mouse_b & 4)
			buttons |= MWBUTTON_M;
		if (mickeyz > 0)
		    buttons |= MWBUTTON_SCROLLUP;  
		if (mickeyz < 0)
		    buttons |= MWBUTTON_SCROLLDN;  
			
		*bp = buttons;
        /* return absolute mouse position */
		return MOUSE_ABSPOS;
}
示例#11
0
static int MOS_Open(MOUSEDEVICE *pmd)
{
    GdHideCursor(&scrdev);
    return 0;
}