コード例 #1
0
ファイル: ioport.c プロジェクト: bhase/garage
position_t position(void)
{
	/* evaluate position */
	if (get_key_state(END_UP) && get_key_state(END_DOWN)) {
		return UNKNOWN;
	} else if (!get_key_state(END_DOWN)) {
		return CLOSE;
	} else if (!get_key_state(END_UP)) {
		return OPEN;
	}
	return UNKNOWN;
}
コード例 #2
0
ファイル: key_data_ext.c プロジェクト: eest/opendnssec
key_state_t* key_data_get_cached_ds(key_data_t* key_data) {
    if (!key_data) {
        return NULL;
    }

    return key_state_new_copy(get_key_state(key_data, KEY_STATE_TYPE_DS));
}
コード例 #3
0
ファイル: key_data_ext.c プロジェクト: eest/opendnssec
key_state_t* key_data_get_cached_rrsigdnskey(key_data_t* key_data) {
    if (!key_data) {
        return NULL;
    }

    return key_state_new_copy(get_key_state(key_data, KEY_STATE_TYPE_RRSIGDNSKEY));
}
コード例 #4
0
ファイル: xkeymap.c プロジェクト: z0x010/rdesktop
void
reset_modifier_keys(unsigned int state)
{
	/* reset keys */
	uint32 ev_time;
	ev_time = time(NULL);

	if (MASK_HAS_BITS(remote_modifier_state, MapLeftShiftMask)
	    && !get_key_state(state, XK_Shift_L))
		rdp_send_scancode(ev_time, RDP_KEYRELEASE, SCANCODE_CHAR_LSHIFT);

	if (MASK_HAS_BITS(remote_modifier_state, MapRightShiftMask)
	    && !get_key_state(state, XK_Shift_R))
		rdp_send_scancode(ev_time, RDP_KEYRELEASE, SCANCODE_CHAR_RSHIFT);

	if (MASK_HAS_BITS(remote_modifier_state, MapLeftCtrlMask)
	    && !get_key_state(state, XK_Control_L))
		rdp_send_scancode(ev_time, RDP_KEYRELEASE, SCANCODE_CHAR_LCTRL);

	if (MASK_HAS_BITS(remote_modifier_state, MapRightCtrlMask)
	    && !get_key_state(state, XK_Control_R))
		rdp_send_scancode(ev_time, RDP_KEYRELEASE, SCANCODE_CHAR_RCTRL);

	if (MASK_HAS_BITS(remote_modifier_state, MapLeftAltMask) && !get_key_state(state, XK_Alt_L))
		rdp_send_scancode(ev_time, RDP_KEYRELEASE, SCANCODE_CHAR_LALT);

	if (MASK_HAS_BITS(remote_modifier_state, MapRightAltMask) &&
	    !get_key_state(state, XK_Alt_R) && !get_key_state(state, XK_Mode_switch))
		rdp_send_scancode(ev_time, RDP_KEYRELEASE, SCANCODE_CHAR_RALT);
}
コード例 #5
0
ファイル: xkeymap.c プロジェクト: AmesianX/rdesktop-fuzzer
uint16
ui_get_numlock_state(unsigned int state)
{
	uint16 numlock_state = 0;

	if (get_key_state(state, XK_Num_Lock))
		numlock_state = KBD_FLAG_NUMLOCK;

	return numlock_state;
}
コード例 #6
0
ファイル: camera.c プロジェクト: 314piman/botball
int main()
{
	camera_open();
	camera_update();
	graphics_open(get_camera_width(), get_camera_height());
	
	while(!get_key_state('Q'))
	{
		camera_update();
		graphics_blit_enc(get_camera_frame(), BGR, 0, 0, get_camera_width(), get_camera_height());
		graphics_circle_fill(get_camera_width() / 2, get_camera_height() / 2, get_camera_height() / 20, 255, 0, 0);
		graphics_update();
	}
	
	camera_close();
	graphics_close();
	
	return 0;
}
コード例 #7
0
void
reset_modifier_keys()
{
	unsigned int state = read_keyboard_state();

	/* reset keys */
	uint32 ev_time;
	ev_time = time(NULL);

	printf("remote_modifier_state: %.8X\n", remote_modifier_state);

	if (MASK_HAS_BITS(remote_modifier_state, MapLeftShiftMask)
	    && !get_key_state(state, XK_Shift_L))
		rdp_send_scancode(ev_time, RDP_KEYRELEASE, SCANCODE_CHAR_LSHIFT);

	if (MASK_HAS_BITS(remote_modifier_state, MapRightShiftMask)
	    && !get_key_state(state, XK_Shift_R))
		rdp_send_scancode(ev_time, RDP_KEYRELEASE, SCANCODE_CHAR_RSHIFT);

	if (MASK_HAS_BITS(remote_modifier_state, MapLeftCtrlMask)
	    && !get_key_state(state, XK_Control_L))
		rdp_send_scancode(ev_time, RDP_KEYRELEASE, SCANCODE_CHAR_LCTRL);

	if (MASK_HAS_BITS(remote_modifier_state, MapRightCtrlMask)
	    && !get_key_state(state, XK_Control_R))
		rdp_send_scancode(ev_time, RDP_KEYRELEASE, SCANCODE_CHAR_RCTRL);

	if (MASK_HAS_BITS(remote_modifier_state, MapLeftAltMask) && !get_key_state(state, XK_Alt_L))
		rdp_send_scancode(ev_time, RDP_KEYRELEASE, SCANCODE_CHAR_LALT);

	if (MASK_HAS_BITS(remote_modifier_state, MapRightAltMask) &&
	    !get_key_state(state, XK_Alt_R) && !get_key_state(state, XK_Mode_switch)
	    && !get_key_state(state, XK_ISO_Level3_Shift))
		rdp_send_scancode(ev_time, RDP_KEYRELEASE, SCANCODE_CHAR_RALT);

	reset_winkey(ev_time);

	if (g_numlock_sync)
		rdp_send_input(ev_time, RDP_INPUT_SYNCHRONIZE, 0, ui_get_numlock_state(state), 0);
}
コード例 #8
0
ファイル: line_edit_control.cpp プロジェクト: 2asoft/xray
void line_edit_control::on_key_press( int dik )
{
	if ( DIK_COUNT <= dik )
	{
		return;
	}
	if ( !m_hold_mode )
	{
		m_last_key_time = 0.0f;
		m_accel = 1.0f;
	}
	m_mark = true;

	clamp_cur_pos();
	clear_inserted();
	compute_positions();

	if ( m_actions[dik] )
	{
		m_actions[dik]->on_key_press( this );
	}
	// ===========
	if ( dik == DIK_LCONTROL || dik == DIK_RCONTROL )
	{
		m_mark = false;	
	}
	
	m_edit_str[m_buffer_size-1] = 0;
	clamp_cur_pos();

	add_inserted_text();
	if ( m_mark && (!get_key_state( ks_Shift ) || !empty_inserted() ) )
	{
		m_select_start = m_cur_pos;
	}
	compute_positions();

	m_repeat_mode = false;
	m_rep_time    = 0.0f;
	
	update_bufs();
}
コード例 #9
0
ファイル: game.c プロジェクト: shiftky/GBA
void game_step(void)
{
  switch ( game_get_state() ) {
    case START:
      current_stage = 0;
      draw_string("Press START key to start.", 23, 85, COLOR_WHITE);
      if ( get_key_state(KEY_START) ) {
        draw_string("Press START key to start.", 23, 85, COLOR_BLACK);
        game_set_state(REMAINING);
      }
      break;

    case NEXTSTAGE:
      game_set_state(REMAINING);
      break;

    case REMAINING:
      draw_string("stage ", 95, 75, COLOR_WHITE);
      draw_num(current_stage+1, 140, 75, COLOR_WHITE);
      draw_string("ball x", 90, 85, COLOR_YELLOW);
      draw_num(ball_get_remaining(), 145, 85, COLOR_YELLOW);
      delay(30000);
      draw_string("stage ", 95, 75, COLOR_BLACK);
      draw_num(current_stage+1, 140, 75, COLOR_BLACK);
      draw_string("ball x", 90, 85, COLOR_BLACK);
      draw_num(ball_get_remaining(), 145, 85, COLOR_BLACK);
      game_set_state(RUNNING);
      break;

    case RUNNING:
      // for Debug
      if ( get_key_state(KEY_SELECT) ) {
        game_set_state(CLEAR);
      }
      break;

    case DEAD:
      draw_string("GAME OVER", 85, 70, COLOR_RED);
      draw_string("Press START key to restart.", 16, 85, COLOR_WHITE);
      if ( get_key_state(KEY_START) ) {
        init_screen();
        game_set_state(RESTART);
      }
      break;

    case CLEAR:
      if ( current_stage < 2 ) {
        draw_string("CLEAR!!", 95, 70, COLOR_ITF);
        draw_string("Press A key to", 65, 85, COLOR_WHITE);
        draw_string("next stage!", 80, 95, COLOR_WHITE);
        if ( get_key_state(KEY_A) ) {
          init_screen();
          current_stage++;
          game_set_state(NEXTSTAGE);
        }
      } else {
        draw_string("CLEAR!!", 95, 70, COLOR_ITF);
        draw_string("Press START key to restart.", 16, 85, COLOR_WHITE);
        if ( get_key_state(KEY_START) ) {
          init_screen();
          game_set_state(RESTART);
        }
      }
      break;

    case RESTART:
      current_stage = 0;
      game_set_state(START);
      break;
  }
}
コード例 #10
0
ファイル: Game.cpp プロジェクト: awinslow/Awesome-Game
  void Game::run() {
#ifdef TEST_NASTY_CONDITIONS
    Random random;
    const float time_scale = NASTY_MIN_RATE + (NASTY_MAX_RATE - NASTY_MIN_RATE) * random.frand_lte();
    Time::Second_Type time_used = Time::Second_Type();
    Time start_time;
#endif

    Sound_Source_Pool &sspr = get_Sound_Source_Pool();
    Time time_processed;

    for(;;) {
      const Time time_passed;
      float time_step = time_passed.get_seconds_since(time_processed);
      time_processed = time_passed;

#ifdef ENABLE_XINPUT
      get_Joysticks().poll();
#endif

      if(joy_mouse.enabled && (joy_mouse.velocity.x != 0 || joy_mouse.velocity.y != 0)) {
        Point2f adjusted_vel(joy_mouse.velocity.x + 0.5f, joy_mouse.velocity.y + 0.5f);
        if(adjusted_vel.x < 0.0f)
          adjusted_vel.x = std::min(0.0f, adjusted_vel.x + joy_mouse.noise_zone.x);
        else
          adjusted_vel.x = std::max(0.0f, adjusted_vel.x - joy_mouse.noise_zone.x);
        if(adjusted_vel.y < 0.0f)
          adjusted_vel.y = std::min(0.0f, adjusted_vel.y + joy_mouse.noise_zone.y);
        else
          adjusted_vel.y = std::max(0.0f, adjusted_vel.y - joy_mouse.noise_zone.y);
        adjusted_vel.x /= 32767.5f - joy_mouse.noise_zone.x;
        adjusted_vel.y /= 32767.5f - joy_mouse.noise_zone.y;

        int xrel = int(adjusted_vel.x * joy_mouse.pixels_per_second.x * time_step);
        int yrel = int(adjusted_vel.y * joy_mouse.pixels_per_second.y * time_step);

        if(xrel || yrel) {
          int x, y;
          SDL_GetMouseState(&x, &y);

          x += xrel;
          y += yrel;
          if(x < 0)
            x = 0;
          else if(x >= get_Window().get_width())
            x = get_Window().get_width() - 1;
          if(y < 0)
            y = 0;
          else if(y >= get_Window().get_width())
            y = get_Window().get_height() - 1;

          SDL_WarpMouse(Uint16(x), Uint16(y));
        }
      }

      for(SDL_Event event; SDL_PollEvent(&event);) {
        if(event.type == SDL_KEYDOWN ||
           event.type == SDL_KEYUP)
        {
          const SDL_keysym &s = event.key.keysym;
          const bool alt = get_key_state(SDLK_LALT) || get_key_state(SDLK_RALT);
          const bool ctrl = get_key_state(SDLK_LCTRL) || get_key_state(SDLK_RCTRL);
          const bool shift = get_key_state(SDLK_LSHIFT) || get_key_state(SDLK_RSHIFT);
          const bool gui = 
#if SDL_VERSION_ATLEAST(1,3,0)
                           get_key_state(SDLK_LGUI) || get_key_state(SDLK_RGUI);
#else
                           get_key_state(SDLK_LMETA) || get_key_state(SDLK_RMETA) || get_key_state(SDLK_LSUPER) || get_key_state(SDLK_RSUPER);
#endif

#ifndef NDEBUG
          if(s.sym == SDLK_BACKQUOTE && alt && !ctrl && !gui && !shift) {
            if(event.type == SDL_KEYDOWN) {
              if(m_console_active)
                deactivate_console();
              else
                activate_console();
            }

            continue;
          }
#endif

          on_event(event);

          if(event.type == SDL_KEYDOWN && (
#if defined(_MACOSX)
              (!alt && !ctrl &&  gui && !shift && s.sym == SDLK_q) ||
#endif
              (!alt &&  ctrl && !gui && !shift && s.sym == SDLK_q) ||
              ( alt && !ctrl && !gui && !shift && s.sym == SDLK_F4)))
          {
            throw Quit_Event();
          }
        }
#if SDL_VERSION_ATLEAST(1,3,0)
        else if(event.type == SDL_WINDOWEVENT && event.window.event == SDL_WINDOWEVENT_CLOSE) {
          on_event(event);

          if(event.window.windowID == SDL_GetWindowID(get_Window().get_window())) {
            get_Window().alert_window_destroyed();
            throw Quit_Event();
          }
        }
#endif
        else if(event.type == SDL_JOYAXISMOTION) {
          if(joy_mouse.enabled && (joy_mouse.joy_axes.x == event.jaxis.axis || joy_mouse.joy_axes.y == event.jaxis.axis)) {
            if(joy_mouse.joy_axes.x == event.jaxis.axis)
              joy_mouse.velocity.x = event.jaxis.value;
            else
              joy_mouse.velocity.y = event.jaxis.value;
          }
          else
            on_event(event);
        }
        else if(event.type == SDL_JOYBUTTONDOWN || event.type == SDL_JOYBUTTONUP) {
#ifdef _MACOSX
          if(event.jbutton.which < 4 && event.jbutton.button < 4) {
            static bool values[4][4] = {{false, false, false, false},
                                        {false, false, false, false},
                                        {false, false, false, false},
                                        {false, false, false, false}};
            values[event.jbutton.which][event.jbutton.button] = event.jbutton.state == SDL_PRESSED;

            SDL_Event e;

            e.type = Uint8(SDL_JOYHATMOTION);
            e.jhat.which = event.jbutton.which;
            e.jhat.hat = 0;

            if(values[event.jbutton.which][0]) {
              if(values[event.jbutton.which][2])
                e.jhat.value = SDL_HAT_LEFTUP;
              else if(values[event.jbutton.which][3])
                e.jhat.value = SDL_HAT_RIGHTUP;
              else
                e.jhat.value = SDL_HAT_UP;
            }
            else if(values[event.jbutton.which][1]) {
              if(values[event.jbutton.which][2])
                e.jhat.value = SDL_HAT_LEFTDOWN;
              else if(values[event.jbutton.which][3])
                e.jhat.value = SDL_HAT_RIGHTDOWN;
              else
                e.jhat.value = SDL_HAT_DOWN;
            }
            else {
              if(values[event.jbutton.which][2])
                e.jhat.value = SDL_HAT_LEFT;
              else if(values[event.jbutton.which][3])
                e.jhat.value = SDL_HAT_RIGHT;
              else
                e.jhat.value = SDL_HAT_CENTERED;
            }

            SDL_PushEvent(&e);
          }
          else
#endif

          if(joy_mouse.enabled && joy_mouse.left_click == event.jbutton.button) {
            SDL_Event e;

            e.type = Uint8(event.type == SDL_JOYBUTTONDOWN ? SDL_MOUSEBUTTONDOWN : SDL_MOUSEBUTTONUP);
            e.button.which = Uint8(event.jbutton.which + 1);
            e.button.state = event.jbutton.state;
            e.button.button = SDL_BUTTON_LEFT;

            int x, y;
            SDL_GetMouseState(&x, &y);
            e.button.x = Uint16(x);
            e.button.y = Uint16(y);

            on_event(e);
          }
          else if(joy_mouse.enabled && joy_mouse.escape == event.jbutton.button) {
            SDL_Event e;

            e.type = Uint8(event.type == SDL_JOYBUTTONDOWN ? SDL_KEYDOWN : SDL_KEYUP);
            e.key.which = Uint8(event.jbutton.which + 1);
            e.key.state = event.jbutton.state;
            e.key.keysym.mod = SDL_GetModState();
            e.key.keysym.scancode = 0;
            e.key.keysym.sym = SDLK_ESCAPE;
            e.key.keysym.unicode = 0;

            on_event(e);
          }
          else
            on_event(event);
        }
        else if(event.type == SDL_JOYHATMOTION) {
          if(joy_mouse.enabled && joy_mouse.scroll_hat == event.jhat.hat && (event.jhat.value == SDL_HAT_DOWN || event.jhat.value == SDL_HAT_UP)) {
            SDL_Event e;

            e.type = SDL_MOUSEBUTTONDOWN;
            e.button.which = Uint8(event.jhat.which + 1);
            e.button.state = SDL_PRESSED;
            e.button.button = Uint8(event.jhat.value == SDL_HAT_DOWN ? SDL_BUTTON_WHEELDOWN : SDL_BUTTON_WHEELUP);

            int x, y;
            SDL_GetMouseState(&x, &y);
            e.button.x = Uint16(x);
            e.button.y = Uint16(y);

            on_event(e);

            e.type = SDL_MOUSEBUTTONUP;
            e.button.state = SDL_RELEASED;

            on_event(e);
          }
          else
            on_event(event);
        }
        else {
          on_event(event);

          if(event.type == SDL_QUIT)
            throw Quit_Event();
        }
      }

#ifdef TEST_NASTY_CONDITIONS
      {
        const Time current_time;
        const Time::Second_Type time_passed = time_scale * current_time.get_seconds_since(start_time);
        size_t step_count = 0u;
        while(time_used + (1 / 60.0f) < time_passed) {
          time_used += (1 / 60.0f);
          perform_logic();
          if(++step_count == NASTY_RATE_CUTOFF)
            time_used = time_passed;
        }
        if(!random.rand_lt(NASTY_ZERO_STEP_FREQUENCY))
          perform_logic();
      }
#else
      perform_logic();
#endif

      sspr.update();

      if(Window::is_enabled()) {
        Video &vr = get_Video();

        if(vr.begin_prerender()) {
          prerender();

          if(vr.begin_render()) {
            try {
              render();
            }
            catch(...) {
              vr.end_render();
              throw;
            }

            vr.end_render();
          }
        }
      }
    }
  }
コード例 #11
0
ファイル: key_data_ext.c プロジェクト: eest/opendnssec
const key_state_t* key_data_cached_rrsigdnskey(key_data_t* key_data) {
    return get_key_state(key_data, KEY_STATE_TYPE_RRSIGDNSKEY);
}
コード例 #12
0
ファイル: key_data_ext.c プロジェクト: eest/opendnssec
const key_state_t* key_data_cached_ds(key_data_t* key_data) {
    return get_key_state(key_data, KEY_STATE_TYPE_DS);
}
コード例 #13
0
ファイル: SdlJoystick.cpp プロジェクト: TimSimpson/Lp3-Engine
 int find_pressed_key_code() override {
     for (int i = 0; i < get_key_count(); ++ i) {
         if (get_key_state(i)) { return i; }
     }
     return -1;
 }
コード例 #14
0
ファイル: input.cpp プロジェクト: piluke/BasicEventEngine
/*
* BEE::get_key_state() - Return whether the given keycode is pressed
* ! When the function is called with a SDL_Keycode, simply convert it into an SDL_Scancode and call the function again
* @k: the keycode to check
*/
bool BEE::get_key_state(SDL_Keycode k) const {
	return get_key_state(SDL_GetScancodeFromKey(k));
}
コード例 #15
0
int main(int argc, char** argv)
{
  if(!depth_open())
  {
    printf("Unable to open libkipr_link_depth_sensor\n");
    return 1;
  }

  int depth_image_height = -1;
  int depth_image_width = -1;

  int mouse_x;
  int mouse_y;

  int last_max_depth = 6000 /* mm */;
  int max_depth;

  if(set_depth_camera_resolution(DEPTH_CAMERA_RESOLUTION_640_480) == 0)
  {
    printf("Failed to set the depth camera resolution to 640 x 480\n");
    return 1;
  }
  
#ifdef CAMERA_IS_UPSIDE_DOWN
  if(set_depth_camera_orientation(DEPTH_CAMERA_ORIENTATION_UPSIDE_DOWN) == 0)
  {
    printf("Failed to set the depth camera orientation\n");
    return 1;
  }
#endif

  printf("Press 'Q' to stop\n");

  while(!get_key_state('Q'))
  {
    if(depth_update())
    {
      if(depth_image_height == -1)
      {
        // initialize the graphics output
        depth_image_height = depth_image_get_height();
        depth_image_width = depth_image_get_width();

        graphics_open(depth_image_width, depth_image_height);
      }

      get_mouse_position(&mouse_x, &mouse_y);
      max_depth = 0;

      // display depth image
      for(int y = 0; y < depth_image_height; y++)
      {
        for(int x = 0; x < depth_image_width; x++)
        {
          int depth = get_depth_value(x, y);

          // save max depth
          if(depth > max_depth)
          {
            max_depth = depth;
          }

          // color invalid depth pixel red
          if((depth != INVALID_COORDINATE) && last_max_depth)
          {
            int r;
            int g;
            int b;

            HSVtoRGB(360*0xFF*depth/last_max_depth, &r, &g, &b);

            graphics_pixel(x, y, r, g, b);
          }
          else
          {
            graphics_pixel(x, y, 0xFF, 0xFF, 0xFF);
          }

          #ifdef SHOW_DEPTH_UNDER_MOUSE
            if(mouse_x == x && mouse_y == y)
            {
              console_clear();
              if(depth != INVALID_COORDINATE)
              {
                printf("(%d, %d): Depth: %d mm; World coordinate: (%d, %d, %d)\n", x, y, depth, get_world_x(x, y), get_world_y(x, y), get_world_z(x, y));
              }
              else
              {
                printf("(%d, %d): No information available\n", x, y);
              }
            }
          #endif
        }
      }

      last_max_depth = max_depth;

      graphics_update();
    }
    else
    {
      printf("No depth image received yet\n");
      msleep(2000);
    }
  }

  graphics_close();
  depth_close();

  return 0;
}
コード例 #16
0
ファイル: eg_lp_printer.c プロジェクト: vaplv/lp
      (lp_printer, 50, 70, L">$ ",
       (float[]){0.f, 1.f, 0.f}, cur+0, cur+1));
    LP(printer_print_wstring
      (lp_printer, cur[0], cur[1], L"Hello",
       (float[]){1.f, 1.f, 1.f}, cur+0, cur+1));
    LP(printer_print_wstring
      (lp_printer, cur[0], cur[1], L" World",
       (float[]){1.f, 0.f, 0.f}, cur+0, cur+1));
    LP(printer_print_wstring
      (lp_printer, cur[0], cur[1], L"!",
       (float[]){0.f, 1.f, 0.f}, cur+0, cur+1));
    LP(printer_flush(lp_printer));

    WM(swap(window));
    WM(flush_events(device));
    WM(get_key_state(device, WM_KEY_ESC, &esc));
  } while(esc != WM_PRESS);

  /* Release data */
  for(i = 0; i < charset_len; ++i) {
    MEM_FREE(&mem_default_allocator, glyph_bitmap_list[i]);
  }
  LP(printer_ref_put(lp_printer));
  LP(font_ref_put(lp_font));
  LP(ref_put(lp));
  FONT(rsrc_ref_put(font_rsrc));
  FONT(system_ref_put(font_sys));
  RBI(&rbi, context_ref_put(rb_ctxt));
  CHECK(rbi_shutdown(&rbi), 0);
  WM(window_ref_put(window));
  WM(device_ref_put(device));
コード例 #17
0
ファイル: input.c プロジェクト: mikekap/wine
static void CALLBACK TrackMouseEventProc(HWND hwnd, UINT uMsg, UINT_PTR idEvent,
                                         DWORD dwTime)
{
    POINT pos;
    INT hoverwidth = 0, hoverheight = 0, hittest;

    TRACE("hwnd %p, msg %04x, id %04lx, time %u\n", hwnd, uMsg, idEvent, dwTime);

    GetCursorPos(&pos);
    hwnd = WINPOS_WindowFromPoint(hwnd, pos, &hittest);

    TRACE("point %s hwnd %p hittest %d\n", wine_dbgstr_point(&pos), hwnd, hittest);

    SystemParametersInfoW(SPI_GETMOUSEHOVERWIDTH, 0, &hoverwidth, 0);
    SystemParametersInfoW(SPI_GETMOUSEHOVERHEIGHT, 0, &hoverheight, 0);

    TRACE("tracked pos %s, current pos %s, hover width %d, hover height %d\n",
           wine_dbgstr_point(&tracking_info.pos), wine_dbgstr_point(&pos),
           hoverwidth, hoverheight);

    /* see if this tracking event is looking for TME_LEAVE and that the */
    /* mouse has left the window */
    if (tracking_info.tme.dwFlags & TME_LEAVE)
    {
        check_mouse_leave(hwnd, hittest);
    }

    if (tracking_info.tme.hwndTrack != hwnd)
    {
        /* mouse is gone, stop tracking mouse hover */
        tracking_info.tme.dwFlags &= ~TME_HOVER;
    }

    /* see if we are tracking hovering for this hwnd */
    if (tracking_info.tme.dwFlags & TME_HOVER)
    {
        /* has the cursor moved outside the rectangle centered around pos? */
        if ((abs(pos.x - tracking_info.pos.x) > (hoverwidth / 2)) ||
            (abs(pos.y - tracking_info.pos.y) > (hoverheight / 2)))
        {
            /* record this new position as the current position */
            tracking_info.pos = pos;
        }
        else
        {
            if (hittest == HTCLIENT)
            {
                ScreenToClient(hwnd, &pos);
                TRACE("client cursor pos %s\n", wine_dbgstr_point(&pos));

                PostMessageW(tracking_info.tme.hwndTrack, WM_MOUSEHOVER,
                             get_key_state(), MAKELPARAM( pos.x, pos.y ));
            }
            else
            {
                if (tracking_info.tme.dwFlags & TME_NONCLIENT)
                    PostMessageW(tracking_info.tme.hwndTrack, WM_NCMOUSEHOVER,
                                 hittest, MAKELPARAM( pos.x, pos.y ));
            }

            /* stop tracking mouse hover */
            tracking_info.tme.dwFlags &= ~TME_HOVER;
        }
    }

    /* stop the timer if the tracking list is empty */
    if (!(tracking_info.tme.dwFlags & (TME_HOVER | TME_LEAVE)))
    {
        KillSystemTimer(tracking_info.tme.hwndTrack, timer);
        timer = 0;
        tracking_info.tme.hwndTrack = 0;
        tracking_info.tme.dwFlags = 0;
        tracking_info.tme.dwHoverTime = 0;
    }
}
コード例 #18
0
ファイル: xkeymap.c プロジェクト: AmesianX/rdesktop-fuzzer
/* Handle special key combinations */
RD_BOOL
handle_special_keys(uint32 keysym, unsigned int state, uint32 ev_time, RD_BOOL pressed)
{
	switch (keysym)
	{
		case XK_Return:
			if ((get_key_state(state, XK_Alt_L) || get_key_state(state, XK_Alt_R))
			    && (get_key_state(state, XK_Control_L)
				|| get_key_state(state, XK_Control_R)))
			{
				/* Ctrl-Alt-Enter: toggle full screen */
				if (pressed)
					xwin_toggle_fullscreen();
				return True;
			}
			break;

		case XK_Break:
			/* Send Break sequence E0 46 E0 C6 */
			if (pressed)
			{
				rdp_send_scancode(ev_time, RDP_KEYPRESS,
						  (SCANCODE_EXTENDED | 0x46));
				rdp_send_scancode(ev_time, RDP_KEYPRESS,
						  (SCANCODE_EXTENDED | 0xc6));
			}
			/* No release sequence */
			return True;
			break;

		case XK_Pause:
			/* According to MS Keyboard Scan Code
			   Specification, pressing Pause should result
			   in E1 1D 45 E1 9D C5. I'm not exactly sure
			   of how this is supposed to be sent via
			   RDP. The code below seems to work, but with
			   the side effect that Left Ctrl stays
			   down. Therefore, we release it when Pause
			   is released. */
			if (pressed)
			{
				rdp_send_input(ev_time, RDP_INPUT_SCANCODE, RDP_KEYPRESS, 0xe1, 0);
				rdp_send_input(ev_time, RDP_INPUT_SCANCODE, RDP_KEYPRESS, 0x1d, 0);
				rdp_send_input(ev_time, RDP_INPUT_SCANCODE, RDP_KEYPRESS, 0x45, 0);
				rdp_send_input(ev_time, RDP_INPUT_SCANCODE, RDP_KEYPRESS, 0xe1, 0);
				rdp_send_input(ev_time, RDP_INPUT_SCANCODE, RDP_KEYPRESS, 0x9d, 0);
				rdp_send_input(ev_time, RDP_INPUT_SCANCODE, RDP_KEYPRESS, 0xc5, 0);
			}
			else
			{
				/* Release Left Ctrl */
				rdp_send_input(ev_time, RDP_INPUT_SCANCODE, RDP_KEYRELEASE,
					       0x1d, 0);
			}
			return True;
			break;

		case XK_Meta_L:	/* Windows keys */
		case XK_Super_L:
		case XK_Hyper_L:
			send_winkey(ev_time, pressed, True);
			return True;
			break;

		case XK_Meta_R:
		case XK_Super_R:
		case XK_Hyper_R:
			send_winkey(ev_time, pressed, False);
			return True;
			break;

		case XK_space:
			/* Prevent access to the Windows system menu in single app mode */
			if (g_win_button_size
			    && (get_key_state(state, XK_Alt_L) || get_key_state(state, XK_Alt_R)))
				return True;
			break;

		case XK_Num_Lock:
			/* Synchronize on key release */
			if (g_numlock_sync && !pressed)
				rdp_send_input(0, RDP_INPUT_SYNCHRONIZE, 0,
					       ui_get_numlock_state(read_keyboard_state()), 0);

			/* Inhibit */
			return True;
			break;
		case XK_Overlay1_Enable:
			/* Toggle SeamlessRDP */
			if (pressed)
				ui_seamless_toggle();
			break;

	}
	return False;
}
コード例 #19
0
ファイル: xkeymap.c プロジェクト: z0x010/rdesktop
/* Handles, for example, multi-scancode keypresses (which is not
   possible via keymap-files) */
BOOL
handle_special_keys(uint32 keysym, unsigned int state, uint32 ev_time, BOOL pressed)
{
	switch (keysym)
	{
		case XK_Return:
			if ((get_key_state(state, XK_Alt_L) || get_key_state(state, XK_Alt_R))
			    && (get_key_state(state, XK_Control_L)
				|| get_key_state(state, XK_Control_R)))
			{
				/* Ctrl-Alt-Enter: toggle full screen */
				if (pressed)
					xwin_toggle_fullscreen();
				return True;
			}
			break;

		case XK_Break:
			/* Send Break sequence E0 46 E0 C6 */
			if (pressed)
			{
				rdp_send_scancode(ev_time, RDP_KEYPRESS,
						  (SCANCODE_EXTENDED | 0x46));
				rdp_send_scancode(ev_time, RDP_KEYPRESS,
						  (SCANCODE_EXTENDED | 0xc6));
			}
			/* No release sequence */
			return True;

		case XK_Pause:
			/* According to MS Keyboard Scan Code
			   Specification, pressing Pause should result
			   in E1 1D 45 E1 9D C5. I'm not exactly sure
			   of how this is supposed to be sent via
			   RDP. The code below seems to work, but with
			   the side effect that Left Ctrl stays
			   down. Therefore, we release it when Pause
			   is released. */
			if (pressed)
			{
				rdp_send_input(ev_time, RDP_INPUT_SCANCODE, RDP_KEYPRESS, 0xe1, 0);
				rdp_send_input(ev_time, RDP_INPUT_SCANCODE, RDP_KEYPRESS, 0x1d, 0);
				rdp_send_input(ev_time, RDP_INPUT_SCANCODE, RDP_KEYPRESS, 0x45, 0);
				rdp_send_input(ev_time, RDP_INPUT_SCANCODE, RDP_KEYPRESS, 0xe1, 0);
				rdp_send_input(ev_time, RDP_INPUT_SCANCODE, RDP_KEYPRESS, 0x9d, 0);
				rdp_send_input(ev_time, RDP_INPUT_SCANCODE, RDP_KEYPRESS, 0xc5, 0);
			}
			else
			{
				/* Release Left Ctrl */
				rdp_send_input(ev_time, RDP_INPUT_SCANCODE, RDP_KEYRELEASE,
					       0x1d, 0);
			}
			return True;

		case XK_Meta_L:	/* Windows keys */
		case XK_Super_L:
		case XK_Hyper_L:
		case XK_Meta_R:
		case XK_Super_R:
		case XK_Hyper_R:
			if (pressed)
			{
				rdp_send_scancode(ev_time, RDP_KEYPRESS, SCANCODE_CHAR_LCTRL);
				rdp_send_scancode(ev_time, RDP_KEYPRESS, SCANCODE_CHAR_ESC);
			}
			else
			{
				rdp_send_scancode(ev_time, RDP_KEYRELEASE, SCANCODE_CHAR_ESC);
				rdp_send_scancode(ev_time, RDP_KEYRELEASE, SCANCODE_CHAR_LCTRL);
			}
			return True;
	}
	return False;
}
コード例 #20
0
ファイル: zsk_rollover.c プロジェクト: gitter-badger/knot
static bool zsk_match(const dnssec_kasp_key_t *key, time_t now, key_state_t state)
{
	return dnssec_key_get_flags(key->key) == DNSKEY_FLAGS_ZSK &&
	       get_key_state(key, now) == state;
}
コード例 #21
0
ファイル: SAMPLING.CPP プロジェクト: wizest/wingwing
void ss_sampl_H()
{
	// Choose sampling method.
		//#define SAMP_METHOD_SWING
		#define SAMP_METHOD_SWING_S

	// SWING mm
	#if defined(SAMP_METHOD_SWING)

		#define toR2	24+1	//20
		#define toR3	12+2	//10
		#define toR1	23		//15
		#define toL1	23-2	//20
		#define toL3	23		//20
		#define toL2	12+3	//15
		#define toC1	24+3	//20

	#elif defined(SAMP_METHOD_SWING_S)

		#define toR2	40
		#define toR3	20
		#define toR1	40
		#define toL1	40
		#define toL3	40
		#define toL2	20
		#define toC1	40

	#else
	#error Choose Sampling Method
	#endif

	led_off(PIO_LED_ALL);
	led_on (PIO_LED_2 | PIO_LED_6 | PIO_LED_3);
//	sys_delay(1000);

	ss_on();
	// show LEDs to find the center of block
	int ss_diff;
	while( !( get_key_state()==(PORT_CANCEL) || get_key_state()==(PORT_SELECT) ) )
	{
		ss_diff = ((int)ss_value[SS_L45]) - ((int)ss_value[SS_R45]);

		led_off(PIO_LED_ALL);
		if 		( ss_diff > 10) 	led_on(PIO_LED_3);
		else if	( ss_diff > 5)		led_on(PIO_LED_4 | PIO_LED_1);
		else if ( ss_diff < -10)    led_on(PIO_LED_2);
		else if ( ss_diff < -5 ) 	led_on(PIO_LED_5 | PIO_LED_0);
		else						led_on(PIO_LED_6);
	}

//	wait_key();

	torque_on();
	wait_key();

//	ss_on();
	led_count_down( 5, 1000 );

	// debug
	//#define DEBUG_SAMPL

	disable_adj();
	reset_spd_ptr();

	// C1
	led_off( PIO_LED_0 |PIO_LED_1|PIO_LED_2|PIO_LED_3|PIO_LED_4|PIO_LED_5|PIO_LED_6);
	led_on ( PIO_LED_6 );
	sys_delay(100);	sampl_value( sC1 );
	motor_start();

	#ifdef	DEBUG_SAMPL
	motor_stop();	wait_key();	motor_start();
	#endif

	// R2
	led_off( PIO_LED_0|PIO_LED_1|PIO_LED_2|PIO_LED_3|PIO_LED_4|PIO_LED_5|PIO_LED_6);
	led_on ( PIO_LED_0|PIO_LED_5|PIO_LED_2 );

	#if defined(SAMP_METHOD_SWING)
	  swing(toR2);
	#elif defined(SAMP_METHOD_SWING_S)
	  swing_S(toR2);
	#else
	#error Choose Sampling Method
	#endif
	sampl_value( sR2 );

	#ifdef	DEBUG_SAMPL
	motor_stop();	wait_key();	motor_start();
	#endif

	// R3
	led_off( PIO_LED_0|PIO_LED_1|PIO_LED_2|PIO_LED_3|PIO_LED_4|PIO_LED_5|PIO_LED_6);
	led_on ( PIO_LED_2 );

	#if defined(SAMP_METHOD_SWING)
	  swing(toR3);
	#elif defined(SAMP_METHOD_SWING_S)
	  swing_S(toR3);
	#else
	#error Choose Sampling Method
	#endif
	sampl_value( sR3 );

	#ifdef	DEBUG_SAMPL
	motor_stop();	wait_key();	motor_start();
	#endif

	// R1
	led_off( PIO_LED_0 |PIO_LED_1|PIO_LED_2|PIO_LED_3|PIO_LED_4|PIO_LED_5|PIO_LED_6);
	led_on ( PIO_LED_0 | PIO_LED_5);

	#if defined(SAMP_METHOD_SWING)
	  swing(-toR1);
	#elif defined(SAMP_METHOD_SWING_S)
	  swing_S(-toR1);
	#else
	#error Choose Sampling Method
	#endif
	sampl_value( sR1 );

	#ifdef	DEBUG_SAMPL
	motor_stop();	wait_key();	motor_start();
	#endif

	// L1
	led_off( PIO_LED_0 |PIO_LED_1|PIO_LED_2|PIO_LED_3|PIO_LED_4|PIO_LED_5|PIO_LED_6);
	led_on ( PIO_LED_1 | PIO_LED_4);

	#if defined(SAMP_METHOD_SWING)
	  swing(-toL1);
	#elif defined(SAMP_METHOD_SWING_S)
	  swing_S(-toL1);
	#else
	#error Choose Sampling Method
	#endif
	sampl_value( sL1 );

	#ifdef	DEBUG_SAMPL
	motor_stop();	wait_key();	motor_start();
	#endif

	// L3
	led_off( PIO_LED_0 |PIO_LED_1|PIO_LED_2|PIO_LED_3|PIO_LED_4|PIO_LED_5|PIO_LED_6);
	led_on ( PIO_LED_3);

	#if defined(SAMP_METHOD_SWING)
	  swing(-toL3);
	#elif defined(SAMP_METHOD_SWING_S)
	  swing_S(-toL3);
	#else
	#error Choose Sampling Method
	#endif
	sampl_value( sL3 );

	#ifdef	DEBUG_SAMPL
	motor_stop();	wait_key();	motor_start();
	#endif

	// L2
	led_off( PIO_LED_0 |PIO_LED_1|PIO_LED_2|PIO_LED_3|PIO_LED_4|PIO_LED_5|PIO_LED_6);
	led_on ( PIO_LED_1|PIO_LED_3|PIO_LED_4 );

	#if defined(SAMP_METHOD_SWING)
	  swing(toL2);
	#elif defined(SAMP_METHOD_SWING_S)
	  swing_S(toL2);
	#else
	#error Choose Sampling Method
	#endif
	sampl_value( sL2 );

	#ifdef	DEBUG_SAMPL
	motor_stop();	wait_key();	motor_start();
	#endif

	// C1
	led_off( PIO_LED_0 |PIO_LED_1|PIO_LED_2|PIO_LED_3|PIO_LED_4|PIO_LED_5|PIO_LED_6);
	led_on ( PIO_LED_6 );

	#if defined(SAMP_METHOD_SWING)
	  swing(toC1);
	#elif defined(SAMP_METHOD_SWING_S)
	  swing_S(toC1);
	#else
	#error Choose Sampling Method
	#endif

	#ifdef	DEBUG_SAMPL
	motor_stop();	wait_key();	motor_start();
	#endif

	motor_stop();
	ss_off();

	torque_off();
}
コード例 #22
0
ファイル: timer.c プロジェクト: HBelusca/NasuTek-Odyssey
//
// Process win32k system timers.
//
VOID
CALLBACK
SystemTimerProc(HWND hwnd,
                UINT uMsg,
         UINT_PTR idEvent,
             DWORD dwTime)
{
  PDESKTOP pDesk;
  PWND pWnd = NULL;

  if (hwnd)
  {
     pWnd = UserGetWindowObject(hwnd);
     if (!pWnd)
     {
        ERR( "System Timer Proc has invalid window handle! 0x%x Id: %d\n", hwnd, idEvent);
        return;
     }
  }
  else
  {
     TRACE( "Windowless Timer Running!\n" );
     return;
  }

  switch (idEvent)
  {
/*
   Used in NtUserTrackMouseEvent.
 */
     case ID_EVENT_SYSTIMER_MOUSEHOVER:
       {
          POINT Point;
          UINT Msg;
          WPARAM wParam;

          pDesk = pWnd->head.rpdesk;
          if ( pDesk->dwDTFlags & DF_TME_HOVER &&
               pWnd == pDesk->spwndTrack )
          {
             Point = gpsi->ptCursor;
             if ( RECTL_bPointInRect(&pDesk->rcMouseHover, Point.x, Point.y) )
             {
                if (pDesk->htEx == HTCLIENT) // In a client area.
                {
                   wParam = get_key_state();
                   Msg = WM_MOUSEHOVER;

                   if (pWnd->ExStyle & WS_EX_LAYOUTRTL)
                   {
                      Point.x = pWnd->rcClient.right - Point.x - 1;
                   }
                   else
                      Point.x -= pWnd->rcClient.left;
                   Point.y -= pWnd->rcClient.top;
                }
                else
                {
                   wParam = pDesk->htEx; // Need to support all HTXYZ hits.
                   Msg = WM_NCMOUSEHOVER;
                }
                UserPostMessage(hwnd, Msg, wParam, MAKELPARAM(Point.x, Point.y));
                pDesk->dwDTFlags &= ~DF_TME_HOVER;
                break; // Kill this timer.
             }
          }
       }
       return; // Not this window so just return.

     default:
       ERR( "System Timer Proc invalid id %d!\n", idEvent );
       break;
  }
  IntKillTimer(pWnd, idEvent, TRUE);
}