コード例 #1
0
ファイル: main.c プロジェクト: EtchedPixels/FUZIX
void platform_interrupt(void)
{
 tty_pollirq();
 tty_polluart();
 timer_interrupt();
 poll_input();
 if (timer_wait)
   wakeup(&timer_interrupt);
}
コード例 #2
0
ファイル: game.c プロジェクト: Wuerfel21/pigs-game
int logic_loop() {
    poll_input();
    //much logic, so complicated, wow
    if (levl->bgtype == 2) update_fire(); //Very firey
    for (int ei=levl->entitycnt-1;ei>=0;ei--) {
        ENTITY *e = levl->entities+ei;
        //printf("\nstart collide %d\n",ei);
        collide(e);
        switch (e->type) {
        default:
            printf("Unknown entity type in logic loop! type: %d id: %d",e->type,ei);
        case ENTITY_TYPE_NULL:
            break;
        case ENTITY_TYPE_PLAYER:
            //e->accely += 1/128.0;
            //if (e->accely > 1/16.0) e->accely = 1/16.0;
            if (pkeys & PIG_KEY_BUTTON) e->health -= 1;
            if ((pkeys & PIG_KEY_UP) && (e->data1 & 0x0001)) e->accely = -1/6.0;
            e->accelx = 0;
            if ((pkeys & PIG_KEY_LEFT) && !(e->data1 & 0x0001)) e->accelx = -1/16.0;
            if ((pkeys & PIG_KEY_RIGHT) && !(e->data1 & 0x0001)) e->accelx = 1/16.0;
            if ((pkeys & (PIG_KEY_LEFT | PIG_KEY_RIGHT)) == (PIG_KEY_LEFT | PIG_KEY_RIGHT) && !(e->data1 & 0x0001)) e->accelx = 0;
            //printf("1 %f %f %f %f %d\n",e->y,e->accely,e->x,e->accelx,e->data1);
            do_accel(e,0,1/256.0,1/8.0);
            //printf("2 %f %f %f %f %d\n",e->y,e->accely,e->x,e->accelx,e->data1);
            /*if (pkeys & PIG_KEY_UP) e->y -= 1/16.0;
            if (pkeys & PIG_KEY_DOWN) e->y += 1/16.0;
            if (pkeys & PIG_KEY_LEFT) e->x -= 1/16.0;
            if (pkeys & PIG_KEY_RIGHT) e->x += 1/16.0;*/
            if (e->health <= 0) return 1;
            break;
        case ENTITY_TYPE_COLLECTABLE:
            for (int ci=0;ci<levl->entitycnt;ci++) {
                //printf("entity %d coll list %d ",ci,coll_list[ci]);
                if (coll_list[ci] == 0xFFFFFFFF) break;
                ENTITY* ce = levl->entities+coll_list[ci];
                //printf("entity %d coll %d\n",ei,coll_list[ci]);
                if (ce->type == ENTITY_TYPE_PLAYER) {
                    ce->data4 += (e->data2 & 0x00FF) == 7 ? -13 : (int)pow(2,(e->data2 & 0x00FF));
                    e->type = 0;
                    break;
                }
            }
            break;
        }
        //sanity chacks
        //prevent stuff from escaping the map
        if(e->x<0)e->x=0;if(e->y<0)e->y=0;if(e->x>levl->sizex-1)e->x=levl->sizex-1;if(e->y>levl->sizey-1)e->y=levl->sizey-1;
    }
    //printf("0-1 %X\t%X\n",do_collide(levl->entities+0,levl->entities+1),is_intersection(21.4545,15.584254,1,1,20,10,1,1));
    return 0;
}
コード例 #3
0
ファイル: devtty.c プロジェクト: EtchedPixels/FUZIX
/* Polled 40 times a second */
void kbd_interrupt(void)
{
	newkey = 0;
	keyproc();
	if (keysdown && keysdown < 3) {
		if (newkey) {
			keydecode();
			kbd_timer = keyrepeat.first;
		} else if (!--kbd_timer) {
			keydecode();
			kbd_timer = keyrepeat.continual;
		}
	}
	poll_input();
}
コード例 #4
0
ファイル: main.c プロジェクト: PatroxGaurab/wine
static DWORD WINAPI ff_input_thread(void *param)
{
    struct JoystickData *data = param;
    DIJOYSTATE state;

    ZeroMemory(&state, sizeof(state));

    while (!data->stop)
    {
        int i;
        struct Joystick *joy = &data->joysticks[data->chosen_joystick];
        int chosen_effect = joy->chosen_effect;
        DIEFFECT *dieffect;
        DWORD flags = DIEP_AXES | DIEP_DIRECTION | DIEP_NORESTART;
        RECT r;

        /* Skip this if we have no effects */
        if (joy->num_effects == 0 || chosen_effect < 0) continue;

        poll_input(joy, &state);

        /* Set ff parameters and draw the axis */
        dieffect = &joy->effects[chosen_effect].params;
        dieffect->rgdwAxes[0] = state.lX;
        dieffect->rgdwAxes[1] = state.lY;

        r.left = FF_AXIS_X + state.lX;
        r.top = FF_AXIS_Y + state.lY;
        r.right = r.bottom = 0; /* unused */
        MapDialogRect(data->graphics.hwnd, &r);

        SetWindowPos(data->graphics.ff_axis, 0, r.left, r.top, 0, 0, SWP_NOZORDER | SWP_NOSIZE);

        for (i=0; i < joy->num_buttons; i++)
            if (state.rgbButtons[i])
            {
                IDirectInputEffect_SetParameters(joy->effects[chosen_effect].effect, dieffect, flags);
                IDirectInputEffect_Start(joy->effects[chosen_effect].effect, 1, 0);
                break;
            }

        Sleep(TEST_POLL_TIME);
    }

    return 0;
}
コード例 #5
0
ファイル: a4_aux.c プロジェクト: sesc4mt/mvcdecoder
/* emulate readkey(), except this version never blocks */
int readkey()
{
   int c = 0;

   poll_input();

   al_lock_mutex(keybuf_mutex);

   if (keybuf_len > 0) {
      c = keybuf[0];
      keybuf_len--;
      memmove(keybuf, keybuf + 1, sizeof(keybuf[0]) * keybuf_len);
   }

   al_unlock_mutex(keybuf_mutex);

   return c;
}
コード例 #6
0
ファイル: event.c プロジェクト: MrAlert/megazeux
static void *wii_poll_thread(void *dud)
{
  WPAD_Init();
  WPAD_SetDataFormat(WPAD_CHAN_ALL, WPAD_FMT_BTNS);
  WPAD_SetDataFormat(0, WPAD_FMT_BTNS_ACC_IR);
  WPAD_SetVRes(0, 640 + PTR_BORDER_W * 2, 350 + PTR_BORDER_H * 2);

  PAD_Init();

  KEYBOARD_Init(NULL);
  MOUSE_Init();

  while(1)
  {
    VIDEO_WaitVSync();
    poll_input();
  }

  return 0;
}
コード例 #7
0
void windows_osd_interface::update(bool skip_redraw)
{
	osd_common_t::update(skip_redraw);

	// if we're not skipping this redraw, update all windows
	if (!skip_redraw)
	{
//      profiler_mark(PROFILER_BLIT);
		for (auto window : osd_common_t::s_window_list)
			window->update();
//      profiler_mark(PROFILER_END);
	}

	// poll the joystick values here
	winwindow_process_events(machine(), TRUE, FALSE);
	poll_input(machine());
	check_osd_inputs();
	// if we're running, disable some parts of the debugger
	if ((machine().debug_flags & DEBUG_FLAG_OSD_ENABLED) != 0)
		debugger_update();
}
コード例 #8
0
ファイル: video.cpp プロジェクト: ccmurray/mame
void windows_osd_interface::update(bool skip_redraw)
{
	// ping the watchdog on each update
	winmain_watchdog_ping();

	update_slider_list();

	// if we're not skipping this redraw, update all windows
	if (!skip_redraw)
	{
//      profiler_mark(PROFILER_BLIT);
		for (win_window_info *window = win_window_list; window != NULL; window = window->m_next)
			window->update();
//      profiler_mark(PROFILER_END);
	}

	// poll the joystick values here
	winwindow_process_events(machine(), TRUE, FALSE);
	poll_input(machine());
	check_osd_inputs(machine());
	// if we're running, disable some parts of the debugger
	if ((machine().debug_flags & DEBUG_FLAG_OSD_ENABLED) != 0)
		debugger_update();
}
コード例 #9
0
ファイル: netplay.c プロジェクト: KitoHo/RetroArch
/**
 * netplay_poll:
 * @netplay              : pointer to netplay object
 *
 * Polls network to see if we have anything new. If our 
 * network buffer is full, we simply have to block 
 * for new input data.
 *
 * Returns: true (1) if successful, otherwise false (0).
 **/
static bool netplay_poll(void)
{
   int res;

   if (!netplay_data->has_connection)
      return false;

   netplay_data->can_poll = false;

   get_self_input_state(netplay_data);

   /* No network side in spectate mode */
   if (netplay_is_server(netplay_data) && netplay_data->spectate.enabled)
      return true;

   /* Read Netplay input, block if we're configured to stall for input every
    * frame */
   if (netplay_data->stall_frames == 0 &&
       netplay_data->read_frame_count <= netplay_data->self_frame_count)
      res = poll_input(netplay_data, true);
   else
      res = poll_input(netplay_data, false);
   if (res == -1)
   {
      hangup(netplay_data);
      return false;
   }

   /* Simulate the input if we don't have real input */
   if (!netplay_data->buffer[netplay_data->self_ptr].have_remote)
      netplay_simulate_input(netplay_data, netplay_data->self_ptr);

   /* Consider stalling */
   switch (netplay_data->stall)
   {
      case RARCH_NETPLAY_STALL_RUNNING_FAST:
         if (netplay_data->read_frame_count >= netplay_data->self_frame_count)
            netplay_data->stall = RARCH_NETPLAY_STALL_NONE;
         break;

      default: /* not stalling */
         if (netplay_data->read_frame_count + netplay_data->stall_frames 
               <= netplay_data->self_frame_count)
         {
            netplay_data->stall      = RARCH_NETPLAY_STALL_RUNNING_FAST;
            netplay_data->stall_time = cpu_features_get_time_usec();
         }
   }

   /* If we're stalling, consider disconnection */
   if (netplay_data->stall)
   {
      retro_time_t now = cpu_features_get_time_usec();

      /* Don't stall out while they're paused */
      if (netplay_data->remote_paused)
         netplay_data->stall_time = now;
      else if (now - netplay_data->stall_time >= MAX_STALL_TIME_USEC)
      {
         /* Stalled out! */
         hangup(netplay_data);
         return false;
      }
   }

   return true;
}
コード例 #10
0
ファイル: main.c プロジェクト: PatroxGaurab/wine
static DWORD WINAPI input_thread(void *param)
{
    int axes_pos[TEST_MAX_AXES][2];
    DIJOYSTATE state;
    struct JoystickData *data = param;

    /* Setup POV as clock positions
     *         0
     *   31500    4500
     * 27000  -1    9000
     *   22500   13500
     *       18000
     */
    int ma = TEST_AXIS_MAX;
    int pov_val[9] = {0, 4500, 9000, 13500,
                      18000, 22500, 27000, 31500, -1};
    int pov_pos[9][2] = { {0, -ma}, {ma/2, -ma/2}, {ma, 0}, {ma/2, ma/2},
                          {0, ma}, {-ma/2, ma/2}, {-ma, 0}, {-ma/2, -ma/2}, {0, 0} };

    ZeroMemory(&state, sizeof(state));

    while (!data->stop)
    {
        int i;
        unsigned int j;

        poll_input(&data->joysticks[data->chosen_joystick], &state);

        dump_joy_state(&state, data->joysticks[data->chosen_joystick].num_buttons);

        /* Indicate pressed buttons */
        for (i = 0; i < data->joysticks[data->chosen_joystick].num_buttons; i++)
            if (state.rgbButtons[i])
                SendMessageW(data->graphics.buttons[i], BM_SETSTATE, TRUE, 0);

        /* Indicate axis positions, axes showing are hardcoded for now */
        axes_pos[0][0] = state.lX;
        axes_pos[0][1] = state.lY;
        axes_pos[1][0] = state.lRx;
        axes_pos[1][1] = state.lRy;
        axes_pos[2][0] = state.lZ;
        axes_pos[2][1] = state.lRz;

        /* Set pov values */
        for (j = 0; j < sizeof(pov_val)/sizeof(pov_val[0]); j++)
        {
            if (state.rgdwPOV[0] == pov_val[j])
            {
                axes_pos[3][0] = pov_pos[j][0];
                axes_pos[3][1] = pov_pos[j][1];
            }
        }

        for (i = 0; i < TEST_MAX_AXES; i++)
        {
            RECT r;

            r.left = (TEST_AXIS_X + TEST_NEXT_AXIS_X*i + axes_pos[i][0]);
            r.top = (TEST_AXIS_Y + axes_pos[i][1]);
            r.bottom = r.right = 0; /* unused */
            MapDialogRect(data->graphics.hwnd, &r);

            SetWindowPos(data->graphics.axes[i], 0, r.left, r.top, 0, 0, SWP_NOZORDER | SWP_NOSIZE);
        }

        Sleep(TEST_POLL_TIME);

        /* Reset button state */
        for (i = 0; i < data->joysticks[data->chosen_joystick].num_buttons; i++)
            SendMessageW(data->graphics.buttons[i], BM_SETSTATE, FALSE, 0);
    }

    return 0;
}
コード例 #11
0
ファイル: a4_aux.c プロジェクト: sesc4mt/mvcdecoder
/* emulate keypressed() */
int keypressed()
{
   poll_input();

   return keybuf_len > 0;
}
コード例 #12
0
ファイル: netplay.c プロジェクト: carriercomm/RetroArch
/**
 * netplay_poll:
 * @netplay              : pointer to netplay object
 *
 * Polls network to see if we have anything new. If our
 * network buffer is full, we simply have to block
 * for new input data.
 *
 * Returns: true (1) if successful, otherwise false (0).
 **/
static bool netplay_poll(netplay_t *netplay)
{
    int res;

    if (!netplay->has_connection)
        return false;

    netplay->can_poll = false;

    if (!get_self_input_state(netplay))
        return false;

    /* We skip reading the first frame so the host has a chance to grab
     * our host info so we don't block forever :') */
    if (netplay->frame_count == 0)
    {
        netplay->buffer[0].used_real        = true;
        netplay->buffer[0].is_simulated     = false;

        memset(netplay->buffer[0].real_input_state,
               0, sizeof(netplay->buffer[0].real_input_state));

        netplay->read_ptr                   = NEXT_PTR(netplay->read_ptr);
        netplay->read_frame_count++;
        return true;
    }

    /* We might have reached the end of the buffer, where we
     * simply have to block. */
    res = poll_input(netplay, netplay->other_ptr == netplay->self_ptr);
    if (res == -1)
    {
        netplay->has_connection = false;
        warn_hangup();
        return false;
    }

    if (res == 1)
    {
        uint32_t first_read = netplay->read_frame_count;
        do
        {
            uint32_t buffer[UDP_FRAME_PACKETS * UDP_WORDS_PER_FRAME];
            if (!receive_data(netplay, buffer, sizeof(buffer)))
            {
                warn_hangup();
                netplay->has_connection = false;
                return false;
            }
            parse_packet(netplay, buffer, UDP_FRAME_PACKETS);

        } while ((netplay->read_frame_count <= netplay->frame_count) &&
                 poll_input(netplay, (netplay->other_ptr == netplay->self_ptr) &&
                            (first_read == netplay->read_frame_count)) == 1);
    }
    else
    {
        /* Cannot allow this. Should not happen though. */
        if (netplay->self_ptr == netplay->other_ptr)
        {
            warn_hangup();
            return false;
        }
    }

    if (netplay->read_ptr != netplay->self_ptr)
        simulate_input(netplay);
    else
        netplay->buffer[PREV_PTR(netplay->self_ptr)].used_real = true;

    return true;
}
コード例 #13
0
ファイル: ps2.c プロジェクト: TRex22/setedit
//#define PROFILE
int main(int argc, char *argv[])
{
 int i,Frames=0;
 unsigned long t1=0,t2,t3,t4;
 float Time;
 double k=18.334;
 int ForceGeneric=0;
 int Surface=1,UnoMas;

 for (i=1; i<argc; i++)
    {
     UnoMas=i<argc-1;
     if (argv[i][0]=='-')
       {
        switch (argv[i][1])
          {
           case 's':
                WaitSync=0;
                break;
           case 'g':
                ForceGeneric=1;
                break;
           case 'h':
                PrintHelp();
                return 1;
           case 'i':
                ShowInfo();
                return 2;
           case 'n':
                printf("Plasma mixsurf 1\n");
                return 3;
           case 'F':
                Surface=0;
                break;
           case 'k':
                if (UnoMas)
                   k=atof(argv[++i]);
                break;
          }
       }
    }

 AllegroInit();
 CalcuInit();

 // Virtual screen
 BMPAuxScreen=create_bitmap(w,h);
 screen_buffer=BMPAuxScreen->line[0];

 RPF_MakeBlueGreen_RedBars(temp2);

 if (!ForceGeneric)
   {
    t3=rawclock();
    PLA2_InitPlasmaTables();
    t4=rawclock();
    AllegroSetMode();

    RPF_RGBBarsWithCos(temp);
    RPF_SetAllPal(temp);
    t1=rawclock();
    while (!poll_input())
      {
       for (i=0; i<1000 && !poll_input(); i++)
          {
           PLA2_Step2(screen_buffer);
           RPF_RGBBarsWithCos(temp);
           if (WaitSync)
              vsync();
           PS_FullBlitLinear(BMPAuxScreen,screen);
           Frames++;
           RPF_SetAllPal(temp);
          }
       if (i<1000) break;
       RPF_SetAllPal(temp2);
       for (i=0; i<1000 && !poll_input(); i++)
          {
           PLA2_Step2(screen_buffer);
           if (WaitSync)
              vsync();
           PS_FullBlitLinear(BMPAuxScreen,screen);
           Frames++;
          }
       if (i<1000) break;
      }
   }
 else
   {
    t3=rawclock();
    PLA2G_InitPlasmaTables(w,h,screen_buffer,k,Surface,w*2,h*2,CalcuCallBack);
    t4=rawclock();
    AllegroSetMode();
    RPF_RGBBarsWithCos(temp);
    RPF_SetAllPal(temp);
    t1=rawclock();
    while (!poll_input())
      {
       for (i=0; i<1000 && !poll_input(); i++)
          {
           MVS_4SurfSC();
           RPF_RGBBarsWithCos(temp);
           Blit();
           RPF_SetAllPal(temp);
          }
       if (i<1000) break;
       RPF_SetAllPal(temp2);
       for (i=0; i<1000 && !poll_input(); i++)
          {
           MVS_4SurfSC();
           Blit();
          }
       if (i<1000) break;
      }
   }
 t2=rawclock();
 PLA2G_DeInit();
 allegro_exit();

 Time=(t2-t1)/18.2;
 printf("Time: %f Frames: %d => %f fps.\n",Time,Frames,Frames/Time);
 Time=(t4-t3)/18.2;
 printf("Initialization time: %f.\n",Time);

 terminate();
 return 0;
}
コード例 #14
0
ファイル: ps2.c プロジェクト: TRex22/setedit
int end_if_user_ready(void)
{
 if (poll_input())
    terminate();
 return 0;
}
コード例 #15
0
ファイル: player.c プロジェクト: sesc4mt/mvcdecoder
/* updates the player position */
int update_player()
{
   poll_input();

   /* quit game? */ 
   if (key[ALLEGRO_KEY_ESCAPE])
      return -1;

   /* safe period while initing */
   if (init_time)
      init_time--;

   /* blown up? */
   if (die_time) {
      die_time--;

      if (!die_time) {
	 lives--;
	 if (!lives)
	    return 1;

	 init_time = 128;
	 pos = 0.5;
	 vel = 0;

	 if (lives == 1)
	    message("This Is Your Final Life");
	 else
	    message("One Life Remaining");
      }
   }

   /* handle user left/right input */
   if (!die_time) {
      if ((joy_left) || (key[ALLEGRO_KEY_LEFT]))
	 vel -= 0.005;

      if ((joy_right) || (key[ALLEGRO_KEY_RIGHT]))
	 vel += 0.005;
   }

   /* move left and right */
   pos += vel;

   if (pos >= 1.0)
      pos -= 1.0;

   if (pos < 0.0)
      pos += 1.0;

   vel *= 0.67;

   /* fire bullets */
   if ((!die_time) && (!init_time) && (!fire_time)) {
      if ((key[ALLEGRO_KEY_SPACE]) || (joy_b1)) {
	 fire_bullet();
	 fire_time = 24;
      }
   }

   if (fire_time)
      fire_time--;

   return 0;
}
コード例 #16
0
ファイル: netplay.c プロジェクト: AbelFlos/RetroArch
// Poll network to see if we have anything new. If our network buffer is full, we simply have to block for new input data.
static bool netplay_poll(netplay_t *handle)
{
   if (!handle->has_connection)
      return false;

   handle->can_poll = false;

   if (!get_self_input_state(handle))
      return false;

   // We skip reading the first frame so the host has a chance to grab our host info so we don't block forever :')
   if (handle->frame_count == 0)
   {
      handle->buffer[0].used_real = true;
      handle->buffer[0].is_simulated = false;
      handle->buffer[0].real_input_state = 0;
      handle->read_ptr = NEXT_PTR(handle->read_ptr);
      handle->read_frame_count++;
      return true;
   }

   // We might have reached the end of the buffer, where we simply have to block.
   int res = poll_input(handle, handle->other_ptr == handle->self_ptr);
   if (res == -1)
   {
      handle->has_connection = false;
      warn_hangup();
      return false;
   }

   if (res == 1)
   {
      uint32_t first_read = handle->read_frame_count;
      do 
      {
         uint32_t buffer[UDP_FRAME_PACKETS * 2];
         if (!receive_data(handle, buffer, sizeof(buffer)))
         {
            warn_hangup();
            handle->has_connection = false;
            return false;
         }
         parse_packet(handle, buffer, UDP_FRAME_PACKETS);

      } while ((handle->read_frame_count <= handle->frame_count) && 
            poll_input(handle, (handle->other_ptr == handle->self_ptr) && 
               (first_read == handle->read_frame_count)) == 1);
   }
   else
   {
      // Cannot allow this. Should not happen though.
      if (handle->self_ptr == handle->other_ptr)
      {
         warn_hangup();
         return false;
      }
   }

   if (handle->read_ptr != handle->self_ptr)
      simulate_input(handle);
   else
      handle->buffer[PREV_PTR(handle->self_ptr)].used_real = true;

   return true;
}
コード例 #17
0
ファイル: dmabuf.c プロジェクト: 325116067/semc-qsd8x50
unsigned int DMAbuf_poll(struct file * file, int dev, poll_table *wait)
{
	struct audio_operations *adev = audio_devs[dev];
	poll_wait(file, &adev->poll_sleeper, wait);
	return poll_input(file, dev, wait) | poll_output(file, dev, wait);
}
コード例 #18
0
ファイル: a4_aux.c プロジェクト: sesc4mt/mvcdecoder
/* blocking version of poll_input(), also wakes on retrace_count */
void poll_input_wait()
{
   al_wait_for_event(input_queue, NULL);
   poll_input();
}