示例#1
0
文件: wiiui.c 项目: twinaphex/sdcell
int
ui_event( void )
{
  keyboard_update();
  mouse_update();
  return 0;
}
示例#2
0
void XBOX_PumpEvents(_THIS)
{
	XInput_GetEvents();

	mouse_update();
	keyboard_update();
}
示例#3
0
/*-----------------------------------------------------------------
 * Desc: should do roughly what getchar() does, but in raw 
 * 	 (SLD) keyboard mode. 
 * 
 * Return: the (SDLKey) of the next key-pressed event cast to (int)
 *
 *-----------------------------------------------------------------*/
int
getchar_raw (void)
{
  SDL_Event event;
  int Returnkey;

  //  keyboard_update ();   /* treat all pending keyboard-events */

  while (1)
    {
      SDL_WaitEvent (&event);    /* wait for next event */
      
      if (event.type == SDL_KEYDOWN)
	{
	  /* 
	   * here we use the fact that, I cite from SDL_keyboard.h:
	   * "The keyboard syms have been cleverly chosen to map to ASCII"
	   * ... I hope that this design feature is portable, and durable ;)  
	   */
	  Returnkey = (int) event.key.keysym.sym;
	  if ( event.key.keysym.mod & KMOD_SHIFT ) Returnkey = toupper( (int)event.key.keysym.sym );
	  return ( Returnkey );
	}
      else
	{
	  SDL_PushEvent (&event);  /* put this event back into the queue */
	  keyboard_update ();  /* and treat it the usual way */
	  continue;
	}

    } /* while(1) */

} /* getchar_raw() */
示例#4
0
void _qdgdfv_input_poll(void)
{
    keyboard_update();

    _qdgdfv_key_up = keyboard_keypressed(0x48);
    _qdgdfv_key_down = keyboard_keypressed(0x50);
    _qdgdfv_key_left = keyboard_keypressed(0x4b);
    _qdgdfv_key_right = keyboard_keypressed(0x4d);
    _qdgdfv_key_escape = keyboard_keypressed(0x01);
    _qdgdfv_key_space = keyboard_keypressed(0x39);
    _qdgdfv_key_enter = keyboard_keypressed(0x1c);
    _qdgdfv_key_control = keyboard_keypressed(0x1d);
    _qdgdfv_key_shift_l = keyboard_keypressed(0x2a);
    _qdgdfv_key_shift_r = keyboard_keypressed(0x36);
    _qdgdfv_key_pgup = keyboard_keypressed(0x49);
    _qdgdfv_key_pgdn = keyboard_keypressed(0x51);
    _qdgdfv_key_home = keyboard_keypressed(0x47);
    _qdgdfv_key_end = keyboard_keypressed(0x4f);

    _qdgdfv_key_f1 = keyboard_keypressed(0x3b);
    _qdgdfv_key_f2 = keyboard_keypressed(0x3c);
    _qdgdfv_key_f3 = keyboard_keypressed(0x3d);
    _qdgdfv_key_f4 = keyboard_keypressed(0x3e);
    _qdgdfv_key_f5 = keyboard_keypressed(0x3f);
    _qdgdfv_key_f6 = keyboard_keypressed(0x40);
    _qdgdfv_key_f7 = keyboard_keypressed(0x41);
    _qdgdfv_key_f8 = keyboard_keypressed(0x42);
    _qdgdfv_key_f9 = keyboard_keypressed(0x43);
    _qdgdfv_key_f10 = keyboard_keypressed(0x44);
}
示例#5
0
文件: main.c 项目: segafan/yeti3d-pvr
void IdleFunc()
{
  static int MarkTime;
  
  if ((int)(MarkTime - timer_ms_gettime64()) < 0)
  {
    MarkTime = timer_ms_gettime64() + YETI_VIEWPORT_INTERVAL;

    keyboard_update(&yeti.keyboard);
    
    pvr_wait_ready();
    pvr_scene_begin();
    
   /* The cool thing here is that we don't have to worry about which display list
      to open/close, which display list is open, or any of that when using PVR DMA.
      We submit everything with pvr_list_prim instead of pvr_prim and things get
      submitted in the right order automatically. Just run your game loop in between
      "pvr_scene_begin();" and "pvr_scene_finish();" and the rest is taken care of. */    
    
    game_loop(&yeti);
    
    /* Done drawing! */
    pvr_scene_finish();
    
  }
}
示例#6
0
void d3d_flip(void)
{
  static unsigned MarkTime;

  if ((int)(MarkTime - timeGetTime()) < 0)
  {
    MarkTime = timeGetTime() + YETI_VIEWPORT_INTERVAL;   

    keyboard_update(&yeti.keyboard);
    game_loop(&yeti);

    ZeroMemory(&ddsd, sizeof(ddsd));
    ddsd.dwSize = sizeof(ddsd);

    if (lpDDSPrimary->Lock(NULL, &ddsd, DDLOCK_WAIT | DDLOCK_SURFACEMEMORYPTR, NULL) == DD_OK)
    {
      viewport_to_video(
        (u16*) ddsd.lpSurface,
        ddsd.lPitch,
        &yeti.viewport,
        ddpf.dwRBitMask,
        ddpf.dwGBitMask,
        ddpf.dwBBitMask);
                  
      lpDDSPrimary->Unlock(ddsd.lpSurface);
    }
  }
}
示例#7
0
static void
msg_loop()
{
    unsigned int previous_time;

    SDL_Event event;
    while( framework_running ) {
	SDL_PumpEvents();
	keyboard_update();
	mouse_update();
	while( SDL_PollEvent( &event ) ) {
	    switch( event.type ) {
		case SDL_MOUSEMOTION:
		    handle_mouse(&event.motion);
		    break;
		case SDL_VIDEORESIZE:
		    handle_resize(event.resize.w, event.resize.h);
		    break;
		default:
		    break;
	    }
	}
	previous_time = SDL_GetTicks();
	draw_frame(delta_time);
	SDL_GL_SwapBuffers();	
	delta_time = SDL_GetTicks() - previous_time;
	calc_fps();
    }
}
示例#8
0
bool
ModIsPressed (SDLMod mod)
{
  bool ret;
  keyboard_update();
  ret = ( (current_modifiers & mod) != 0) ;
  return (ret);
}
示例#9
0
bool
MouseLeftPressedR (void)
{
  bool ret;
  keyboard_update();
  ret = CurrentlyMouseLeftPressed;
  CurrentlyMouseLeftPressed = FALSE;
  return (ret);
}
示例#10
0
// does the same as KeyIsPressed, but automatically releases the key as well..
bool
KeyIsPressedR (SDLKey key)
{
  bool ret;
  keyboard_update();
  ret = key_pressed[key];
  ReleaseKey (key);
  return (ret);
}
示例#11
0
bool
WheelDownPressed (void)
{
  keyboard_update();
  if (WheelDownEvents)
    return (WheelDownEvents--);
  else
    return (FALSE);
}
示例#12
0
void
IN_SendKeyEvents ( void )
{
	if (!in_svgalib_inited) return;

	if (UseKeyboard) {
		while ((keyboard_update()));
	}
}
示例#13
0
void I_StartTic (void)
{
	keyboard_update();

	if (usemouse)
		mouse_update();

#ifdef USE_JOYSTICK
	if (usejoystick)
		joystick_events();
#endif
}
示例#14
0
static int wait_event (int which, fd_set *in, fd_set *out, fd_set *except, 
                struct timeval *timeout)
#endif
{
    ggi_event_mask mask = 0;
    int retval;

    if (which & IAL_MOUSEEVENT) {
        mask |= emKeyPress | emKeyRelease;
    }
    if (which & IAL_KEYEVENT) {
        mask |= emPointer;
    }

#ifdef _LITE_VERSION
    retval = ggiEventSelect(PHYSICALGC.visual, &mask, maxfd + 1, in, out, except,
                timeout);
#else
    /* GRR, this braindead vga_waitevent() doesn't take the n argument of
       select() */
    retval = ggiEventSelect(PHYSICALGC.visual, &mask, FD_SETSIZE, in, out, except,
                timeout);
#endif
    if (retval < 0) {
        return -1;
    }

    retval = 0;
    if (mask & emPointer) {
        retval |= IAL_MOUSEEVENT;

        mouse_update();
    }
    if (mask & (emKeyPress | emKeyRelease)) {
        retval |= IAL_KEYEVENT;
        keyboard_update();
    }

    return retval;
}
示例#15
0
文件: keyb.c 项目: yeqingyan/tos_tos
/*
 * keyb_notifier
 *
 * Notify keyboard_process, the keyboard was pressed.
 */
void keyb_notifier(PROCESS self, PARAM param) {
  volatile unsigned int cpsr_flag;
  Keyb_Message msg;
  BYTE key;
  //    kprintf("Keyb notifier start\n");
  assert(keyboard_address == 0);

  while (1) {
    SAVE_CPSR_DIS_IRQ(cpsr_flag);
    dmb();
    keyboard_update();
    key = keyboard_get_char();
    //        kprintf("Got new key %x\n", key);
    dmb();
    RESUME_CPSR(cpsr_flag);
    if (key != 0) {
      new_key = key;
      msg.key_buffer = (BYTE *)&new_key;
      message(keyb_port, &msg);
    }
  }
}
示例#16
0
文件: svga.c 项目: bernds/UAE
void handle_events (void)
{
    int button = mouse_getbutton ();

    gui_requested = 0;
    keyboard_update ();
    mouse_update ();
    lastmx += mouse_getx ();
    lastmy += mouse_gety ();
    mouse_setposition (0, 0);

    buttonstate[0] = button & 4;
    buttonstate[1] = button & 2;
    buttonstate[2] = button & 1;

#ifdef PICASSO96
    if (screen_is_picasso && !picasso_vidinfo.extra_mem) {
	int i;
	char *addr = gfxmemory + (picasso96_state.Address - gfxmem_start);
	for (i = 0; i < picasso_vidinfo.height; i++, addr += picasso96_state.BytesPerRow) {
	    if (!picasso_invalid_lines[i])
		continue;
	    picasso_invalid_lines[i] = 0;
	    vga_drawscanline (i, addr);
	}
    }
#endif

    if (!screen_is_picasso && gui_requested) {
	leave_graphics_mode ();
	gui_changesettings ();
	enter_graphics_mode (vgamode);
	if (linear_mem != NULL && !need_dither)
	    gfxvidinfo.bufmem = linear_mem;
	restore_vga_colors ();
	notice_screen_contents_lost ();
    }
}
示例#17
0
static void svgalib_key_update ()
{
	keyboard_update ();
}
示例#18
0
static void svgalib_key_flush ()
{
	keyboard_update ();
	keyboard_clearstate ();
	memset (key_state, 0, 128);
}
示例#19
0
void INL_Update()
{
	while (keyboard_update()) ; /* get all events */
}
int main(int argc, char* argv[])
{
	// our demo variables
	World* demoworld = 0;
	Camera* democamera = 0;
	Tileset* demotileset = 0;
	Renderer* demorenderer = 0;

	// init SDL
	if (SDL_Init(SDL_INIT_EVERYTHING) < 0)
	{
		fprintf(stderr, "SDL Library Initialization Failed!\n\tSDL Error: %s\n", SDL_GetError());
		exit(1);
	}
	atexit(SDL_Quit);

	// create the window
	if (!SDL_SetVideoMode(SCREEN_W, SCREEN_H, SCREEN_BPP, SDL_HWSURFACE | SDL_DOUBLEBUF))
	{
		fprintf(stderr, "SDL Screen Initialization Failed! %dx%d@%dbpp\nSDL Error: %s\n",
			SCREEN_W,
			SCREEN_H,
			SCREEN_BPP,
			SDL_GetError());
		exit(1);
	}

	// set the window caption
	SDL_WM_SetCaption("Basic SDL Map Editor Example Demo -- by Richard Marks <*****@*****.**>", 0);

	// create our keyboard handler
	Keyboard* keyboard = keyboard_create();

	// load the world
	demoworld = world_load("example_demo.map");
	if (!demoworld)
	{
		fprintf(stderr, "unable to load the world file!\n");
		exit(1);
	}

	// load the tileset
	demotileset = tileset_load("example_demo.png", 32, 32);
	if (!demotileset)
	{
		fprintf(stderr, "unable to load the tileset file!\n");
		exit(1);
	}

	// create the camera
	democamera = camera_create(
		// anchor position of the camera is at 32,32 on the screen
		32, 32,
		// the camera view is 30 x 22 tiles
		30, 22,
		// need to tell the camera the size of the tiles
		demotileset->width, demotileset->height);

	// create the renderer
	demorenderer = renderer_create(demoworld, demotileset, democamera);

	// pre-render the scene
	renderer_pre_render(demorenderer);

	fprintf(stderr, "\nstarting main loop...\n\n");
	// start the main loop
	SDL_Event event;
	bool running = true;
	int startticks = SDL_GetTicks();
	int mainlooptimer = SDL_GetTicks();
	while(running)
	{
		// check for our window being closed
		while(SDL_PollEvent(&event))
		{
			if (SDL_QUIT == event.type)
			{
				running = false;
			}
		}

		// update our keyboard handler
		keyboard_update(keyboard);

		// start timing our code
		startticks = SDL_GetTicks();

		// check for our controls

		// ESC and Q quits
		if (keyboard->key[SDLK_ESCAPE] || keyboard->key[SDLK_q])
		{
			running = false;
		}

		const unsigned int CAMERASPEED = 16;

		// W and up arrow
		if (keyboard->key[SDLK_w] || keyboard->key[SDLK_UP])
		{
			if (democamera->inpixels->y > 0)
			{
				democamera->inpixels->y -= CAMERASPEED;
			}
		}

		// S and down arrow
		if (keyboard->key[SDLK_s] || keyboard->key[SDLK_DOWN])
		{
			if (democamera->inpixels->y < demorenderer->scene->h - democamera->inpixels->h)
			{
				democamera->inpixels->y += CAMERASPEED;
			}
		}

		// A and left arrow
		if (keyboard->key[SDLK_a] || keyboard->key[SDLK_LEFT])
		{
			if (democamera->inpixels->x > 0)
			{
				democamera->inpixels->x -= CAMERASPEED;
			}
		}

		// D and right arrow
		if (keyboard->key[SDLK_d] || keyboard->key[SDLK_RIGHT])
		{
			if (democamera->inpixels->x < demorenderer->scene->w - democamera->inpixels->w)
			{
				democamera->inpixels->x += CAMERASPEED;
			}
		}

		// render our scene
		renderer_render(demorenderer);

		// flip our double buffer
		SDL_Flip(SDL_GetVideoSurface());

		// lock our framerate to roughly 30 FPS
		int tickdiff = SDL_GetTicks() - startticks;
		if (tickdiff < 33)
		{
			SDL_Delay(33 - tickdiff);
		}
	}

	int tickdiff = SDL_GetTicks() - mainlooptimer;

	fprintf(stderr, "finished after %d ticks!\n\n", tickdiff);

	// destroy our pointers
	tileset_destroy(demotileset);
	renderer_destroy(demorenderer);
	world_destroy(demoworld);
	camera_destroy(democamera);
	keyboard_destroy(keyboard);

	return 0;
}
示例#21
0
文件: event.c 项目: rxi/lovedos
void event_pump(void) {
  keyboard_update();
  mouse_update();
}
示例#22
0
bool
KeyIsPressed (SDLKey key)
{
  keyboard_update();
  return (key_pressed[key]);
}
示例#23
0
bool
MouseRightPressed(void)
{
  keyboard_update();
  return (CurrentlyMouseRightPressed);
}
示例#24
0
bool
MouseLeftPressed(void)
{
  keyboard_update();
  return CurrentlyMouseLeftPressed;
}
示例#25
0
void main(void)
{
    int vgamode, color, leftpressed;
    int x, y;
    vga_init();
    vgamode = vga_getdefaultmode();
    if ((vgamode == -1) || (vga_getmodeinfo(vgamode)->bytesperpixel != 1))
        vgamode = G320x200x256;

    if (!vga_hasmode(vgamode)) {
        printf("Mode not available.\n");
        exit(1);
    }
    printf("\nWARNING: This program will set the keyboard to RAW mode.\n"
           "The keyboard routines in svgalib have not been tested\n"
           "very much. There may be no recovery if something goes\n"
           "wrong.\n\n"
           "Press ctrl-c now to bail out, enter to continue.\n"
           "In the test itself, use 'q' or Escape to quit.\n"
           "It will also terminate after 60 seconds.\n"
           "Use any cursor keys to move, keypad 0 or enter to change color.\n");

    getchar();

    vga_setmode(vgamode);
    gl_setcontextvga(vgamode);
    gl_enableclipping();

    signal(SIGALRM, timeout);

    /* This installs the default handler, which is good enough for most */
    /* purposes. */
    if (keyboard_init()) {
        printf("Could not initialize keyboard.\n");
        exit(1);
    }
    /* Translate to 4 keypad cursor keys, and unify enter key. */
    keyboard_translatekeys(TRANSLATE_CURSORKEYS | TRANSLATE_KEYPADENTER |
                           TRANSLATE_DIAGONAL);
    /* (TRANSLATE_DIAGONAL seems to give problems.) Michael: No doesn't...
       but might not do what you expect.. */

    alarm(60);			/* Terminate after 60 seconds for safety. */

    x = WIDTH / 2;
    y = HEIGHT / 2;
    color = newcolor();
    leftpressed = 0;
    for (;;) {
        /* Draw moving box. */
        gl_fillbox(x, y, 5, 5, color);

        /* Draw key status bar at top of screen. */
        gl_putbox(0, 0, 128, 1, keyboard_getstate());

        /* Wait about 1/100th of a second. */
        /* Note that use of this function makes things less */
        /* smooth because of timer latency. */
        usleep(10000);

        keyboard_update();

        /* Move. */
        if (keyboard_keypressed(SCANCODE_CURSORLEFT))
            x--;
        if (keyboard_keypressed(SCANCODE_CURSORRIGHT))
            x++;
        if (keyboard_keypressed(SCANCODE_CURSORUP))
            y--;
        if (keyboard_keypressed(SCANCODE_CURSORDOWN))
            y++;

        /* Boundary checks. */
        if (x < 0)
            x = 0;
        if (x >= WIDTH)
            x = WIDTH - 1;
        if (y < 1)
            y = 1;
        if (y >= HEIGHT)
            y = HEIGHT - 1;

        /* Check for color change. */
        if (keyboard_keypressed(SCANCODE_KEYPAD0) ||
                keyboard_keypressed(SCANCODE_ENTER)) {
            if (!leftpressed) {
                color = newcolor();
                leftpressed = 1;
            }
        } else
            leftpressed = 0;

        if (keyboard_keypressed(SCANCODE_Q) ||
                keyboard_keypressed(SCANCODE_ESCAPE))
            break;
    }

    keyboard_close();		/* Don't forget this! */
    vga_setmode(TEXT);
    exit(0);
}
示例#26
0
Intent *read_input_devices(void)
{
     static Intent intent;


     intent.force_x = intent.force_y = intent.force_z = 0.0;
     intent.force_rotate = 0.0;
     intent.n_special = 0;

     keyboard_update();
     if (keyboard_keypressed(SCANCODE_CURSORBLOCKLEFT))
	  rotating_ccw = True;
     if (keyboard_keypressed(SCANCODE_CURSORBLOCKRIGHT))
	  rotating_cw = True;
     if (keyboard_keypressed(SCANCODE_CURSORBLOCKUP))
	  moving_forward = True;
     if (keyboard_keypressed(SCANCODE_CURSORBLOCKDOWN))
	  moving_backward= True;
     if (keyboard_keypressed(42) || keyboard_keypressed(54))
	  running= True;
     if (keyboard_keypressed(57))
	  add_special(&intent, INTENT_JUMP);
     if (keyboard_keypressed(56) || keyboard_keypressed(100))
	  strafing= True;

     if (!keyboard_keypressed(SCANCODE_CURSORBLOCKLEFT))
	  rotating_ccw = False;
     if (!keyboard_keypressed( SCANCODE_CURSORBLOCKRIGHT))
	  rotating_cw = False;
     if (!keyboard_keypressed(SCANCODE_CURSORBLOCKUP))
	  moving_forward = False;
     if (!keyboard_keypressed(SCANCODE_CURSORBLOCKDOWN))
	  moving_backward= False;
     if (!keyboard_keypressed(42) && !keyboard_keypressed(54))
	  running= False;
     if (!keyboard_keypressed(56) && !keyboard_keypressed(100))
	  strafing= False;
     if (keyboard_keypressed(SCANCODE_Q))
	  add_special(&intent, INTENT_END_GAME);

     if (rotating_cw) {
	  if (strafing)
	       intent.force_y -= 0.5;
	  else
	       intent.force_rotate -= 0.5;
     }
     if (rotating_ccw) {
	  if (strafing) {
	       intent.force_y += 0.5;
	  } else
	       intent.force_rotate += 0.5;
     }
     if (moving_forward)
	  intent.force_x += 0.5;
     if (moving_backward)
	  intent.force_x -= 0.5;
     if (running) {
	  intent.force_x *= 2.0;
	  intent.force_y *= 2.0;
	  intent.force_z *= 2.0;
	  intent.force_rotate *= 2.0;
     }

     return &intent;
}
示例#27
0
void KBD_Update(void)
{
	while (keyboard_update())
		;
}