Пример #1
0
void
MouseSettings::_RetrieveSettings()
{
	// retrieve current values

	if (get_mouse_map(&fSettings.map) != B_OK)
		fprintf(stderr, "error when get_mouse_map\n");
	if (get_click_speed(&fSettings.click_speed) != B_OK)
		fprintf(stderr, "error when get_click_speed\n");
	if (get_mouse_speed(&fSettings.accel.speed) != B_OK)
		fprintf(stderr, "error when get_mouse_speed\n");
	if (get_mouse_acceleration(&fSettings.accel.accel_factor) != B_OK)
		fprintf(stderr, "error when get_mouse_acceleration\n");
	if (get_mouse_type(&fSettings.type) != B_OK)
		fprintf(stderr, "error when get_mouse_type\n");

	fMode = mouse_mode();
	fFocusFollowsMouseMode = focus_follows_mouse_mode();
	fAcceptFirstClick = accept_first_click();

	// also try to load the window position from disk

	BPath path;
	if (_GetSettingsPath(path) < B_OK)
		return;

	BFile file(path.Path(), B_READ_ONLY);
	if (file.InitCheck() < B_OK)
		return;

#if R5_COMPATIBLE
	const off_t kOffset = sizeof(mouse_settings) - sizeof(mouse_map)
		+ sizeof(int32) * 3;
		// we have to do this because mouse_map counts 16 buttons in OBOS
#else
	const off_t kOffset = sizeof(mouse_settings);
#endif

	if (file.ReadAt(kOffset, &fWindowPosition, sizeof(BPoint))
		!= sizeof(BPoint)) {
		// set default window position (invalid positions will be
		// corrected by the application; the window will be centered
		// in this case)
		fWindowPosition.x = -1;
		fWindowPosition.y = -1;
	}

#ifdef DEBUG
	Dump();
#endif
}
Пример #2
0
extern "C" int be_mouse_init(void)
{
   sem_id mouse_started;
   int32  num_buttons;

   mouse_started = create_sem(0, "starting mouse driver...");

   if (mouse_started < 0) {
      goto cleanup;
   }

   mouse_thread_id = spawn_thread(mouse_thread, MOUSE_THREAD_NAME,
                        MOUSE_THREAD_PRIORITY, &mouse_started); 

   if (mouse_thread_id < 0) {
      goto cleanup;
   }

   mouse_thread_running = true;
   resume_thread(mouse_thread_id);
   acquire_sem(mouse_started);
   delete_sem(mouse_started);

   be_mickey_x = 0;
   be_mickey_y = 0;

   be_mouse_x = 0;
   be_mouse_y = 0;
   be_mouse_b = 0;

   limit_up     = 0;
   limit_down   = 0;
   limit_left   = 0;
   limit_right  = 0;

   get_mouse_type(&num_buttons);

   return num_buttons;

   cleanup: {
      if (mouse_started > 0) {
         delete_sem(mouse_started);
      }

      be_mouse_exit();
      return 0;
   }
}
Пример #3
0
/*************************************************************************
 * AM-ACTIVE-TOOL-VIEW
 *************************************************************************/
AmActiveToolView::AmActiveToolView(	BPoint origin, float leftOverhang,
										float topOverhang, float rightOverhang)
		: inherited(BRect(origin, origin), "active_tools", B_FOLLOW_LEFT | B_FOLLOW_TOP, B_WILL_DRAW),
		  mMouseType(1), mMouseBitmap(NULL), mPrimaryTool(NULL), mSecondaryTool(NULL),
		  mTertiaryTool(NULL), mLeftOverhang(leftOverhang),
		  mRightOverhang(rightOverhang), mTopOverhang(topOverhang)
{
	if (get_mouse_type(&mMouseType) != B_OK) mMouseType = 1;
	/* Get my mouse image based on the mouse type.
	 */	
	if (mMouseType == 1) {
		mMouseBitmap = ImageManager().FindBitmap("Mouse 1");
	} else if (mMouseType == 2) {
		mMouseBitmap = ImageManager().FindBitmap("Mouse 2");
	} else if (mMouseType == 3) {
		mMouseBitmap = ImageManager().FindBitmap("Mouse 3");
	}
}