Example #1
0
void			output_buffer(int fd, char *buf, int size, int tl)
{
	static time_t	clock = 0;
	struct timeval	now;
	static char		obuf[OUTPUT_BUFFER];
	static int		osize = 0;

	gettimeofday(&now, NULL);
	if (clock == 0)
		clock = now.tv_sec;
	if (osize + size > OUTPUT_BUFFER || size > OUTPUT_BUFFER)
	{
		put_buf(fd, obuf, &osize);
		if (size > OUTPUT_BUFFER)
		{
			write(fd, buf, size);
			return ;
		}
	}
	bufcat(obuf, buf, &osize, size);
	if (now.tv_sec - clock >= tl)
	{
		put_buf(fd, obuf, &osize);
		clock = now.tv_sec;
	}
}
int phantom_console_window_putc(int c)
{
#if TIMED_FLUSH
    phantom_undo_timed_call( &cons_timer );
#endif

#if NET_TIMED_FLUSH
    cancel_net_timer(&cons_upd_timer);
#endif

    switch(c)
    {
    case '\b':
        if(cbufpos > 0) cbufpos--;
        goto noflush;
        //return c;

    case '\t':
        while(cbufpos % 8)
        {
            if(cbufpos >= BUFS)
                break;
            put_buf(' ');
        }
        goto noflush;
        //return c;

    case '\n':
    case '\r':
        put_buf( c );
        goto flush;

    default:
        put_buf( c );
        if( cbufpos >= BUFS )
            goto flush;

noflush:
#if TIMED_FLUSH
        phantom_request_timed_call( &cons_timer, 0 );
#endif

#if NET_TIMED_FLUSH
        set_net_timer(&cons_upd_timer, 100, flush_stdout, 0, 0 );
#endif

        return c;
    }

flush:
    flush_stdout(0);
    return c;
}
Example #3
0
/* Handles the keyboard interrupt */
void keyboard_handler(struct regs *r)
{
    unsigned char scancode;

    /* Read from the keyboard's data buffer */
    scancode = inb(0x60);

    /* If the top bit of the byte we read from the keyboard is
    *  set, that means that a key has just been released */
    if (scancode & 0x80)
    {
        /* You can use this one to see if the user released the
        *  shift, alt, or control keys... */
    }
    else
    {
        /* Here, a key was just pressed. Please note that if you
        *  hold a key down, you will get repeated key press
        *  interrupts. */

        /* Just to show you how this works, we simply translate
        *  the keyboard scancode into an ASCII value, and then
        *  display it to the screen. You can get creative and
        *  use some flags to see if a shift is pressed and use a
        *  different layout, or you can add another 128 entries
        *  to the above layout to correspond to 'shift' being
        *  held. If shift is held using the larger lookup table,
        *  you would add 128 to the scancode when you look for it */
        //console_putc(kbdus[scancode]);
		put_buf(kbdus[scancode]);
    }
}
Example #4
0
void ps2_insert_mouse_event( int x, int y, int buttons )
{
    if(NULL == video_drv)
        return;

    video_drv->mouse_x = x;
    video_drv->mouse_y = y;

    struct ui_event e;
    ev_make_mouse_event( &e, x, y, buttons );
    /*
    memset( &e, 0, sizeof(e) );

    e.type = UI_EVENT_TYPE_MOUSE;
    e.time = fast_time();
    e.focus= 0;

    e.m.buttons = buttons;
    e.abs_x = x;
    e.abs_y = y;
    e.extra = 0;
    */
    put_buf(&e);
    hal_sem_release( &mouse_sem );

}
Example #5
0
static int
rs_lookup_out(struct trace_proc * proc, const message * m_out)
{

    put_buf(proc, "label", PF_STRING, (vir_bytes)m_out->m_rs_req.name,
            m_out->m_rs_req.name_len);

    return CT_DONE;
}
Example #6
0
/*
 * This function is shared between rs_down, rs_refresh, rs_restart, and
 * rs_clone.
 */
static int
rs_label_out(struct trace_proc * proc, const message * m_out)
{

    /*
     * We are not using PF_STRING here, because unlike in most places
     * (including rs_lookup), the string length does not include the
     * terminating NULL character.
     */
    put_buf(proc, "label", 0, (vir_bytes)m_out->m_rs_req.addr,
            m_out->m_rs_req.len);

    return CT_DONE;
}
Example #7
0
static void
put_struct_rs_start(struct trace_proc * proc, const char * name,
                    vir_bytes addr)
{
    struct rs_start buf;

    if (!put_open_struct(proc, name, 0, addr, &buf, sizeof(buf)))
        return;

    if (verbose > 0)
        put_flags(proc, "rss_flags", rss_flags, COUNT(rss_flags),
                  "0x%x", buf.rss_flags);
    put_buf(proc, "rss_cmd", 0, (vir_bytes)buf.rss_cmd, buf.rss_cmdlen);
    put_buf(proc, "rss_label", 0, (vir_bytes)buf.rss_label.l_addr,
            buf.rss_label.l_len);
    if (verbose > 0 || buf.rss_major != 0)
        put_value(proc, "rss_major", "%d", buf.rss_major);
    if (verbose > 0 || buf.devman_id != 0)
        put_value(proc, "devman_id", "%d", buf.devman_id);
    put_value(proc, "rss_uid", "%u", buf.rss_uid);
    if (verbose > 0) {
        put_endpoint(proc, "rss_sigmgr", buf.rss_sigmgr);
        put_endpoint(proc, "rss_scheduler", buf.rss_sigmgr);
    }
    if (verbose > 1) {
        put_value(proc, "rss_priority", "%d", buf.rss_priority);
        put_value(proc, "rss_quantum", "%d", buf.rss_quantum);
    }
    if (verbose > 0) {
        put_value(proc, "rss_period", "%ld", buf.rss_period);
        put_buf(proc, "rss_script", 0, (vir_bytes)buf.rss_script,
                buf.rss_scriptlen);
    }

    put_close_struct(proc, FALSE /*all*/); /* TODO: the remaining fields */
}
Example #8
0
int main(int argc, char* argv[])
{
	struct pipe p;
	void* h;
	void* h0, *h1, *h2;
	void* b;
	const void* b0, *b1, *b2;
	int s0, s1, s2;

	// init
	printf("%d\n", init_pipe(&p, 3, 2, 0x1));

#if 0
	//get and push
	h0 = get_buf(&p, &b);
	printf("%p %p\n", h0, b);
	printf("%d\n", push_buf(&p, h0, 1));

	print_pipe(&p);

	h0 = pull_buf(&p, 0, &b0, &s0);
	h1 = pull_buf(&p, 1, &b1, &s1);
	h2 = pull_buf(&p, 2, &b2, &s2);
	put_buf(&p, h0);
	put_buf(&p, h1);
	put_buf(&p, h2);

	print_pipe(&p);

	h0 = get_buf(&p, &b);
	printf("%p %p\n", h0, b);
	printf("%d\n", push_buf(&p, h0, 1));
#endif

	// src push 0 1 2
	h = get_buf(&p, &b); push_buf(&p, h, 1);
	// src push 0 1 2
	h = get_buf(&p, &b); push_buf(&p, h, 2);

	// dst pull 1 2
	h2 = pull_buf(&p, 2, &b2, &s2); put_buf(&p, h2);
	h1 = pull_buf(&p, 1, &b1, &s1); put_buf(&p, h1);
	//print_pipe(&p); exit(0);

	// src push 1 2 (0 is full)
	h = get_buf(&p, &b); push_buf(&p, h, 3);
	//print_pipe(&p); exit(0);

	// dst pull 1 2
	h2 = pull_buf(&p, 2, &b2, &s2); put_buf(&p, h2);
	h1 = pull_buf(&p, 1, &b1, &s1); put_buf(&p, h1);
	//print_pipe(&p); exit(0);

	// dst pull 1 2
	h2 = pull_buf(&p, 2, &b2, &s2); put_buf(&p, h2);
	h1 = pull_buf(&p, 1, &b1, &s1); put_buf(&p, h1);
	//print_pipe(&p); exit(0);

	// dst pull 0
	h0 = pull_buf(&p, 0, &b0, &s0); put_buf(&p, h0);

	// dst pull 0
	h0 = pull_buf(&p, 0, &b0, &s0); put_buf(&p, h0);
	//print_pipe(&p); exit(0);

	// src push 0 1 2
	h = get_buf(&p, &b); push_buf(&p, h, 4);
	// src push 0 1 2
	h = get_buf(&p, &b); push_buf(&p, h, 5);
	// src push 0 1 2
	h = get_buf(&p, &b); push_buf(&p, h, 6);
	// src push 0 1 2
	h = get_buf(&p, &b); push_buf(&p, h, 7);
	//print_pipe(&p); exit(0);

	// dst pull 0
	h0 = pull_buf(&p, 0, &b0, &s0); put_buf(&p, h0);
	// dst pull 0
	h0 = pull_buf(&p, 0, &b0, &s0); put_buf(&p, h0);
	h0 = pull_buf(&p, 0, &b0, &s0); 
	printf("%p\n", h0);

	print_pipe(&p); exit(0);
		//should be src(0), dst0(0), dst1(2), dst2(2)

#if 0
	struct queue q;
	void* p;
	init_queue(&q, 5);
	printf("%d\n", enqueue(&q, (void*)1));
	printf("%d\n", enqueue(&q, (void*)2));
	printf("%d\n", enqueue(&q, (void*)3));
	printf("%d\n", enqueue(&q, (void*)4));
	printf("%d\n", enqueue(&q, (void*)5));
	printf("%d\n", enqueue(&q, (void*)6));
	printf("\n");
	printf("%d ", dequeue(&q, &p)); printf("%p\n", p);
	printf("%d ", dequeue(&q, &p)); printf("%p\n", p);
	printf("%d ", dequeue(&q, &p)); printf("%p\n", p);
	printf("%d ", dequeue(&q, &p)); printf("%p\n", p);
	printf("%d ", dequeue(&q, &p)); printf("%p\n", p);
	printf("%d ", dequeue(&q, &p)); printf("%p\n", p);

	printf("\n\n");
	init_queue(&q, 7);
	printf("%d\n", enqueue(&q, (void*)1));
	printf("%d\n", enqueue(&q, (void*)2));
	printf("%d\n", enqueue(&q, (void*)3));
	printf("%d\n", enqueue(&q, (void*)4));
	printf("%d\n", enqueue(&q, (void*)5));
	printf("%d\n", enqueue(&q, (void*)6));
	printf("%d\n", enqueue(&q, (void*)7));
	printf("%d\n", enqueue(&q, (void*)8));
	printf("\n");
	printf("%d ", dequeue(&q, &p)); printf("%p\n", p);
	printf("%d ", dequeue(&q, &p)); printf("%p\n", p);
	printf("%d ", dequeue(&q, &p)); printf("%p\n", p);
	printf("%d ", dequeue(&q, &p)); printf("%p\n", p);
	printf("%d ", dequeue(&q, &p)); printf("%p\n", p);
	printf("%d ", dequeue(&q, &p)); printf("%p\n", p);
	printf("%d ", dequeue(&q, &p)); printf("%p\n", p);
	printf("%d ", dequeue(&q, &p)); printf("%p\n", p);
#endif

	return 0;
}
int
char_ioctl_arg(struct trace_proc * proc, unsigned long req, void * ptr,
	int dir)
{
	minix_i2c_ioctl_exec_t *iie;
	struct fb_var_screeninfo *fbvs;
	struct volume_level *level;
	struct inout_ctrl *inout;
	struct termios *tc;
	struct ptmget *pm;
	struct winsize *ws;
	struct kio_bell *bell;
	struct kio_leds *leds;
	struct pciio_cfgreg *pci_cfgreg;
	struct pciio_bdf_cfgreg *pci_bdf_cfgreg;
	struct pciio_businfo *pci_businfo;
	struct pciio_map *pci_iomap;
	struct pciio_acl *pci_acl;

	switch (req) {
	case MINIX_I2C_IOCTL_EXEC:
		if ((iie = (minix_i2c_ioctl_exec_t *)ptr) == NULL)
			return IF_OUT; /* we print only the request for now */

		put_i2c_op(proc, "iie_op", iie->iie_op);
		put_value(proc, "iie_addr", "0x%04x", iie->iie_addr);
		return 0; /* TODO: print command/data/result */

	case FBIOGET_VSCREENINFO:
		if ((fbvs = (struct fb_var_screeninfo *)ptr) == NULL)
			return IF_IN;

		put_value(proc, "xres", "%"PRIu32, fbvs->xres);
		put_value(proc, "yres", "%"PRIu32, fbvs->yres);
		put_value(proc, "xres_virtual", "%"PRIu32, fbvs->xres_virtual);
		put_value(proc, "yres_virtual", "%"PRIu32, fbvs->yres_virtual);
		put_value(proc, "xoffset", "%"PRIu32, fbvs->xoffset);
		put_value(proc, "yoffset", "%"PRIu32, fbvs->yoffset);
		put_value(proc, "bits_per_pixel", "%"PRIu32,
		    fbvs->bits_per_pixel);
		return 0;

	case FBIOPUT_VSCREENINFO:
	case FBIOPAN_DISPLAY:
		if ((fbvs = (struct fb_var_screeninfo *)ptr) == NULL)
			return IF_OUT;

		put_value(proc, "xoffset", "%"PRIu32, fbvs->xoffset);
		put_value(proc, "yoffset", "%"PRIu32, fbvs->yoffset);
		return 0;

	case DSPIORATE:
	case DSPIOSTEREO:
	case DSPIOSIZE:
	case DSPIOBITS:
	case DSPIOSIGN:
	case DSPIOMAX:
	case DSPIOFREEBUF:
	case DSPIOSAMPLESINBUF:
		if (ptr == NULL)
			return dir;

		put_value(proc, NULL, "%u", *(unsigned int *)ptr);
		return IF_ALL;

	case MIXIOGETVOLUME:
		if ((level = (struct volume_level *)ptr) == NULL)
			return dir;

		if (dir == IF_OUT)
			put_sound_device(proc, "device", level->device);
		else {
			put_value(proc, "left", "%d", level->left);
			put_value(proc, "right", "%d", level->right);
		}
		return IF_ALL;

	case MIXIOSETVOLUME:
		/* Print the corrected volume levels only with verbosity on. */
		if ((level = (struct volume_level *)ptr) == NULL)
			return IF_OUT | ((verbose > 0) ? IF_IN : 0);

		if (dir == IF_OUT)
			put_sound_device(proc, "device", level->device);
		put_value(proc, "left", "%d", level->left);
		put_value(proc, "right", "%d", level->right);
		return IF_ALL;

	case MIXIOGETINPUTLEFT:
	case MIXIOGETINPUTRIGHT:
	case MIXIOGETOUTPUT:
		if ((inout = (struct inout_ctrl *)ptr) == NULL)
			return dir;

		if (dir == IF_OUT)
			put_sound_device(proc, "device", inout->device);
		else {
			put_sound_state(proc, "left", inout->left);
			put_sound_state(proc, "right", inout->right);
		}
		return IF_ALL;

	case MIXIOSETINPUTLEFT:
	case MIXIOSETINPUTRIGHT:
	case MIXIOSETOUTPUT:
		if ((inout = (struct inout_ctrl *)ptr) == NULL)
			return IF_OUT;

		put_sound_device(proc, "device", inout->device);
		put_sound_state(proc, "left", inout->left);
		put_sound_state(proc, "right", inout->right);
		return IF_ALL;

	case TIOCFLUSH:
		if (ptr == NULL)
			return IF_OUT;

		put_flags(proc, NULL, flush_flags, COUNT(flush_flags), "0x%x",
		    *(int *)ptr);
		return IF_ALL;

	case TIOCGETA:
	case TIOCSETA:
	case TIOCSETAW:
	case TIOCSETAF:
		if ((tc = (struct termios *)ptr) == NULL)
			return dir;

		/*
		 * These are fairly common IOCTLs, so printing everything by
		 * default would create a lot of noise.  By default we limit
		 * ourselves to printing the field that contains what I
		 * consider to be the most important flag: ICANON.
		 * TODO: see if we can come up with a decent format for
		 * selectively printing (relatively important) flags.
		 */
		if (verbose > 0) {
			put_flags(proc, "c_iflag", tc_iflags, COUNT(tc_iflags),
			    "0x%x", tc->c_iflag);
			put_flags(proc, "c_oflag", tc_oflags, COUNT(tc_oflags),
			    "0x%x", tc->c_oflag);
			put_flags(proc, "c_cflag", tc_cflags, COUNT(tc_cflags),
			    "0x%x", tc->c_cflag);
		}
		put_flags(proc, "c_lflag", tc_lflags, COUNT(tc_lflags), "0x%x",
			tc->c_lflag);
		if (verbose > 0) {
			put_value(proc, "c_ispeed", "%d", tc->c_ispeed);
			put_value(proc, "c_ospeed", "%d", tc->c_ospeed);
		}
		return 0; /* TODO: print the c_cc fields */

	case TIOCGETD:
	case TIOCSETD:
		if (ptr == NULL)
			return dir;

		put_tty_disc(proc, NULL, *(int *)ptr);
		return IF_ALL;

	case TIOCGLINED:
	case TIOCSLINED:
		if (ptr == NULL)
			return dir;

		put_buf(proc, NULL, PF_LOCADDR | PF_STRING, (vir_bytes)ptr,
		    sizeof(linedn_t));
		return IF_ALL;

	case TIOCGPGRP:
	case TIOCSPGRP:
	case TIOCOUTQ:
	case TIOCPKT:
	case TIOCREMOTE:
	case TIOCUCNTL:
	case TIOCSTAT:		/* argument seems unused? */
	case TIOCGSID:
	case TIOCCONS:		/* argument seems unused? */
	case TIOCEXT:
	case TIOCSQSIZE:
	case TIOCGQSIZE:
		/* Print a simple integer. */
		if (ptr == NULL)
			return dir;

		put_value(proc, NULL, "%d", *(int *)ptr);
		return IF_ALL;

	case TIOCPTSNAME:
		if ((pm = (struct ptmget *)ptr) == NULL)
			return IF_IN;

		put_buf(proc, "sn", PF_LOCADDR | PF_STRING, (vir_bytes)pm->sn,
		    sizeof(pm->sn));
		return IF_ALL;

	case TIOCSTI:
		if (ptr == NULL)
			return dir;

		if (!valuesonly)
			put_value(proc, NULL, "'%s'",
			    get_escape(*(char *)ptr));
		else
			put_value(proc, NULL, "%u", *(char *)ptr);
		return IF_ALL;

	case TIOCGWINSZ:
	case TIOCSWINSZ:
		if ((ws = (struct winsize *)ptr) == NULL)
			return dir;

		/* This is a stupid order, but we follow the struct layout. */
		put_value(proc, "ws_row", "%u", ws->ws_row);
		put_value(proc, "ws_col", "%u", ws->ws_col);
		if (verbose > 0) {
			put_value(proc, "ws_xpixel", "%u", ws->ws_xpixel);
			put_value(proc, "ws_ypixel", "%u", ws->ws_ypixel);
		}
		return (verbose > 0) ? IF_ALL : 0;

	case KIOCBELL:
		if ((bell = (struct kio_bell *)ptr) == NULL)
			return IF_OUT;

		put_value(proc, "kb_pitch", "%u", bell->kb_pitch);
		put_value(proc, "kb_volume", "%lu", bell->kb_volume);
		put_struct_timeval(proc, "kb_duration", PF_LOCADDR,
		    (vir_bytes)&bell->kb_duration);

		return IF_ALL;

	case KIOCSLEDS:
		if ((leds = (struct kio_leds *)ptr) == NULL)
			return IF_OUT;

		put_flags(proc, "kl_bits", kbd_leds, COUNT(kbd_leds), "0x%x",
		    leds->kl_bits);
		return IF_ALL;

	case PCI_IOC_CFGREAD:
		if ((pci_cfgreg = (struct pciio_cfgreg *)ptr) == NULL)
			return IF_IN;

		put_ptr(proc, "reg", (vir_bytes)pci_cfgreg->reg);
		put_value(proc, "val", "%08x", pci_cfgreg->val);
		return IF_ALL;

	case PCI_IOC_CFGWRITE:
		if ((pci_cfgreg = (struct pciio_cfgreg *)ptr) == NULL)
			return IF_OUT;

		put_ptr(proc, "reg", (vir_bytes)pci_cfgreg->reg);
		put_value(proc, "val", "%08x", pci_cfgreg->val);
		return IF_ALL;

	case PCI_IOC_BDF_CFGREAD:
		if ((pci_bdf_cfgreg = (struct pciio_bdf_cfgreg *)ptr) == NULL)
			return IF_IN;

		put_value(proc, "bus", "%u", pci_bdf_cfgreg->bus);
		put_value(proc, "device", "%u", pci_bdf_cfgreg->device);
		put_value(proc, "function", "%u", pci_bdf_cfgreg->function);
		put_ptr(proc, "cfgreg.reg", (vir_bytes)pci_bdf_cfgreg->cfgreg.reg);
		put_value(proc, "cfgreg.val", "%08x", pci_bdf_cfgreg->cfgreg.val);
		return IF_ALL;

	case PCI_IOC_BDF_CFGWRITE:
		if ((pci_bdf_cfgreg = (struct pciio_bdf_cfgreg *)ptr) == NULL)
			return IF_OUT;

		put_value(proc, "bus", "%u", pci_bdf_cfgreg->bus);
		put_value(proc, "device", "%u", pci_bdf_cfgreg->device);
		put_value(proc, "function", "%u", pci_bdf_cfgreg->function);
		put_ptr(proc, "cfgreg.reg", (vir_bytes)pci_bdf_cfgreg->cfgreg.reg);
		put_value(proc, "cfgreg.val", "%08x", pci_bdf_cfgreg->cfgreg.val);
		return IF_ALL;

	case PCI_IOC_BUSINFO:
		if ((pci_businfo = (struct pciio_businfo *)ptr) == NULL)
			return IF_IN;

		put_value(proc, "busno", "%u", pci_businfo->busno);
		put_value(proc, "maxdevs", "%u", pci_businfo->maxdevs);
		return IF_ALL;

	case PCI_IOC_MAP:
		if ((pci_iomap = (struct pciio_map *)ptr) == NULL)
			return IF_OUT|IF_IN;

		put_value(proc, "flags", "%x", pci_iomap->flags);
		put_value(proc, "phys_offset", "%08x", pci_iomap->phys_offset);
		put_value(proc, "size", "%zu", pci_iomap->size);
		put_value(proc, "readonly", "%x", pci_iomap->readonly);

		if (IF_IN == dir)
			put_ptr(proc, "vaddr_ret", (vir_bytes)pci_iomap->vaddr_ret);

		return IF_ALL;

	case PCI_IOC_UNMAP:
		if ((pci_iomap = (struct pciio_map *)ptr) == NULL)
			return IF_OUT;

		put_ptr(proc, "vaddr", (vir_bytes)pci_iomap->vaddr);

		return IF_ALL;

	case PCI_IOC_RESERVE:
		if ((pci_acl = (struct pciio_acl *)ptr) == NULL)
			return IF_OUT;

		put_value(proc, "domain", "%u", pci_acl->domain);
		put_value(proc, "bus", "%u", pci_acl->bus);
		put_value(proc, "device", "%u", pci_acl->device);
		put_value(proc, "function", "%u", pci_acl->function);

		return IF_ALL;
	case PCI_IOC_RELEASE:
		if ((pci_acl = (struct pciio_acl *)ptr) == NULL)
			return IF_OUT;

		put_value(proc, "domain", "%u", pci_acl->domain);
		put_value(proc, "bus", "%u", pci_acl->bus);
		put_value(proc, "device", "%u", pci_acl->device);
		put_value(proc, "function", "%u", pci_acl->function);

		return IF_ALL;

	default:
		return 0;
	}
}
Example #10
0
static void ps2ms_int_handler( void *arg )
{
    (void) arg;

    static int inbytepos = 0;

    signed char mousedata = inb( PS2_DATA_ADDR );

    SHOW_FLOW( 10 ,"%2X ", mousedata & 0xFFu );

    switch(inbytepos)
    {
    case 0:

        // first byte has one in this pos
        if(1 && ! (0x8 & mousedata) )
        {
            //inbytepos = -1; break;
            inbytepos = 0; return;
        }

        ps2ms_state_buttons = 0x7 & mousedata;
        xsign = 0x10 & mousedata;
        ysign = 0x20 & mousedata;
        break;

    case 1:     xval = mousedata; break;
    case 2:     yval = mousedata; break;
    case 3:     break;
    case 4:     break;
    }

    inbytepos++;
    inbytepos %= 3;
    //inbytepos %= 4;

    if(inbytepos != 0)
        return;

    xval = insert_bit9( xval, xsign );
    yval = insert_bit9( yval, ysign );

    ps2ms_state_xpos += xval;
    ps2ms_state_ypos += yval;

    if( ps2ms_state_xpos < 0 ) ps2ms_state_xpos = 0;
    if( ps2ms_state_ypos < 0 ) ps2ms_state_ypos = 0;

    if( ps2ms_state_xpos > video_drv->xsize ) ps2ms_state_xpos = video_drv->xsize;
    if( ps2ms_state_ypos > video_drv->ysize ) ps2ms_state_ypos = video_drv->ysize;


    //printf("ms %d %d %x\n", ps2ms_state_xpos, ps2ms_state_ypos, ps2ms_state_buttons );

    if(NULL != video_drv)
    {
        video_drv->mouse_x = ps2ms_state_xpos;
        video_drv->mouse_y = ps2ms_state_ypos;

        struct ui_event e;
        e.type = UI_EVENT_TYPE_MOUSE;
        e.time = fast_time();
        e.focus= 0;

        e.m.buttons = ps2ms_state_buttons;
        e.abs_x = ps2ms_state_xpos;
        e.abs_y = ps2ms_state_ypos;

        put_buf(&e);
        hal_sem_release( &mouse_sem );
    }

}
Example #11
0
   bool output_stream::put_buf(const void* pBuf, int len)
   {
	   STARTWORKING
	   WIFISTREAM_DEBUG(Serial.print(F("input: ")));
	   WIFISTREAM_DEBUG(Serial.println(len,DEC));
	 if(len+buffer_usage > BUFFER_SIZE)
     {
		 WIFISTREAM_DEBUG(Serial.println(F("buffer voll!!")));

		 ledOn(LED_RED);
    	 int restlength = BUFFER_SIZE-buffer_usage;

    	 WIFISTREAM_DEBUG(Serial.print(F("letzter paket teil: ")));
    	 WIFISTREAM_DEBUG(Serial.println(restlength,DEC));

    	 memcpy((void*)(stream_buffer+buffer_usage),(const void*)(pBuf),restlength);
    	 buf_ofs += restlength;
#ifndef alternate
#ifdef usb
    	 for(int x = 0; x < BUFFER_SIZE;x++)
    		 Serial.write(stream_buffer[x]);
#else
    	 if(wifi_isready())
    	 {
      		 ledOff(LED_RED);
      		ERROR_MESSAGE("[wifistream] wifi is not ready breaking!!!\r\n\r\n");
    		 return false;
    	 }
		int ret = wifi_senddata((unsigned char*)stream_buffer,BUFFER_SIZE);
    	 while(ret==3)
    	 {
    		 ERROR_MESSAGE("[wifistream] watch out!!! xbee buffer error 3!!\r\n\r\n");
    		 delay(100);
    		 ret = wifi_senddata((unsigned char*)stream_buffer,BUFFER_SIZE);
    	 }
    	 WIFISTREAM_DEBUG(Serial.println(ret));
    	 if(ret!=0)
    	 {
				ledOff(LED_RED);
				ERROR_MESSAGE("[wifistream] some other return code: ");
				ERROR_MESSAGE(ret);
				ERROR_MESSAGE("\r\n\r\n");
    		 	return false;
    	 }
#endif
#endif
    	 init_buffer();
    	 put_buf((const void*)((int)pBuf+restlength),len-restlength);
    	 STARTWORKING;
  		 ledOff(LED_RED);
     }
     else
     {

    	 WIFISTREAM_DEBUG(Serial.print(F("moving memory ")));
    	 memcpy((void*)((int)stream_buffer+buffer_usage),(const void*)pBuf,len);
    	 buffer_usage+=len;
    	 buf_ofs += len;
     }
	 WIFISTREAM_DEBUG(Serial.print(F("new buffer_usage: ")));
	 WIFISTREAM_DEBUG(Serial.println(buffer_usage,DEC));
	 STOPWORKING;
     return true;
   }