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 }
// Resets the settings to the system defaults void MouseSettings::Defaults() { SetClickSpeed(kDefaultClickSpeed); SetMouseSpeed(kDefaultMouseSpeed); SetMouseType(kDefaultMouseType); SetAccelerationFactor(kDefaultAccelerationFactor); SetMouseMode(B_NORMAL_MOUSE); SetFocusFollowsMouseMode(B_NORMAL_FOCUS_FOLLOWS_MOUSE); SetAcceptFirstClick(kDefaultAcceptFirstClick); mouse_map map; if (get_mouse_map(&map) == B_OK) { map.button[0] = B_PRIMARY_MOUSE_BUTTON; map.button[1] = B_SECONDARY_MOUSE_BUTTON; map.button[2] = B_TERTIARY_MOUSE_BUTTON; SetMapping(map); } }