Revert "Remove manual adjustment of fps, automatically adjusted to the maximum already"
This commit is contained in:
parent
ffdfef0adc
commit
94f2751902
@ -1245,30 +1245,45 @@ void showConfirmSwitchSidesDialog(
|
|||||||
|
|
||||||
customImageQualityDialog(SessionID sessionId, String id, FFI ffi) async {
|
customImageQualityDialog(SessionID sessionId, String id, FFI ffi) async {
|
||||||
double qualityInitValue = 50;
|
double qualityInitValue = 50;
|
||||||
|
double fpsInitValue = 30;
|
||||||
bool qualitySet = false;
|
bool qualitySet = false;
|
||||||
|
bool fpsSet = false;
|
||||||
|
|
||||||
bool? direct;
|
bool? direct;
|
||||||
try {
|
try {
|
||||||
direct =
|
direct =
|
||||||
ConnectionTypeState.find(id).direct.value == ConnectionType.strDirect;
|
ConnectionTypeState.find(id).direct.value == ConnectionType.strDirect;
|
||||||
} catch (_) {}
|
} catch (_) {}
|
||||||
|
bool hideFps = (await bind.mainIsUsingPublicServer() && direct != true) ||
|
||||||
|
versionCmp(ffi.ffiModel.pi.version, '1.2.0') < 0;
|
||||||
bool hideMoreQuality =
|
bool hideMoreQuality =
|
||||||
(await bind.mainIsUsingPublicServer() && direct != true) ||
|
(await bind.mainIsUsingPublicServer() && direct != true) ||
|
||||||
versionCmp(ffi.ffiModel.pi.version, '1.2.2') < 0;
|
versionCmp(ffi.ffiModel.pi.version, '1.2.2') < 0;
|
||||||
|
|
||||||
setCustomValues({double? quality}) async {
|
setCustomValues({double? quality, double? fps}) async {
|
||||||
if (quality != null) {
|
if (quality != null) {
|
||||||
qualitySet = true;
|
qualitySet = true;
|
||||||
await bind.sessionSetCustomImageQuality(
|
await bind.sessionSetCustomImageQuality(
|
||||||
sessionId: sessionId, value: quality.toInt());
|
sessionId: sessionId, value: quality.toInt());
|
||||||
print("quality:$quality");
|
print("quality:$quality");
|
||||||
}
|
}
|
||||||
|
if (fps != null) {
|
||||||
|
fpsSet = true;
|
||||||
|
await bind.sessionSetCustomFps(sessionId: sessionId, fps: fps.toInt());
|
||||||
|
print("fps:$fps");
|
||||||
|
}
|
||||||
if (!qualitySet) {
|
if (!qualitySet) {
|
||||||
qualitySet = true;
|
qualitySet = true;
|
||||||
await bind.sessionSetCustomImageQuality(
|
await bind.sessionSetCustomImageQuality(
|
||||||
sessionId: sessionId, value: qualityInitValue.toInt());
|
sessionId: sessionId, value: qualityInitValue.toInt());
|
||||||
print("qualityInitValue:$qualityInitValue");
|
print("qualityInitValue:$qualityInitValue");
|
||||||
}
|
}
|
||||||
|
if (!hideFps && !fpsSet) {
|
||||||
|
fpsSet = true;
|
||||||
|
await bind.sessionSetCustomFps(
|
||||||
|
sessionId: sessionId, fps: fpsInitValue.toInt());
|
||||||
|
print("fpsInitValue:$fpsInitValue");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
final btnClose = dialogButton('Close', onPressed: () async {
|
final btnClose = dialogButton('Close', onPressed: () async {
|
||||||
@ -1280,10 +1295,25 @@ customImageQualityDialog(SessionID sessionId, String id, FFI ffi) async {
|
|||||||
final quality = await bind.sessionGetCustomImageQuality(sessionId: sessionId);
|
final quality = await bind.sessionGetCustomImageQuality(sessionId: sessionId);
|
||||||
qualityInitValue =
|
qualityInitValue =
|
||||||
quality != null && quality.isNotEmpty ? quality[0].toDouble() : 50.0;
|
quality != null && quality.isNotEmpty ? quality[0].toDouble() : 50.0;
|
||||||
|
if ((hideMoreQuality && qualityInitValue > 100) ||
|
||||||
|
qualityInitValue < 10 ||
|
||||||
|
qualityInitValue > 2000) {
|
||||||
|
qualityInitValue = 50;
|
||||||
|
}
|
||||||
|
// fps
|
||||||
|
final fpsOption =
|
||||||
|
await bind.sessionGetOption(sessionId: sessionId, arg: 'custom-fps');
|
||||||
|
fpsInitValue = fpsOption == null ? 30 : double.tryParse(fpsOption) ?? 30;
|
||||||
|
if (fpsInitValue < 5 || fpsInitValue > 120) {
|
||||||
|
fpsInitValue = 30;
|
||||||
|
}
|
||||||
|
|
||||||
final content = customImageQualityWidget(
|
final content = customImageQualityWidget(
|
||||||
initQuality: qualityInitValue,
|
initQuality: qualityInitValue,
|
||||||
|
initFps: fpsInitValue,
|
||||||
setQuality: (v) => setCustomValues(quality: v),
|
setQuality: (v) => setCustomValues(quality: v),
|
||||||
|
setFps: (v) => setCustomValues(fps: v),
|
||||||
|
showFps: !hideFps,
|
||||||
showMoreQuality: !hideMoreQuality);
|
showMoreQuality: !hideMoreQuality);
|
||||||
msgBoxCommon(ffi.dialogManager, 'Custom Image Quality', content, [btnClose]);
|
msgBoxCommon(ffi.dialogManager, 'Custom Image Quality', content, [btnClose]);
|
||||||
}
|
}
|
||||||
|
@ -7,13 +7,16 @@ import 'package:get/get.dart';
|
|||||||
|
|
||||||
customImageQualityWidget(
|
customImageQualityWidget(
|
||||||
{required double initQuality,
|
{required double initQuality,
|
||||||
|
required double initFps,
|
||||||
required Function(double) setQuality,
|
required Function(double) setQuality,
|
||||||
|
required Function(double) setFps,
|
||||||
|
required bool showFps,
|
||||||
required bool showMoreQuality}) {
|
required bool showMoreQuality}) {
|
||||||
final maxValue = showMoreQuality ? 2000 : 10;
|
if (!showMoreQuality && initQuality > 100) {
|
||||||
if (initQuality < 10 || initQuality > maxValue) {
|
|
||||||
initQuality = 50;
|
initQuality = 50;
|
||||||
}
|
}
|
||||||
final qualityValue = initQuality.obs;
|
final qualityValue = initQuality.obs;
|
||||||
|
final fpsValue = initFps.obs;
|
||||||
|
|
||||||
final RxBool moreQualityChecked = RxBool(qualityValue.value > 100);
|
final RxBool moreQualityChecked = RxBool(qualityValue.value > 100);
|
||||||
final debouncerQuality = Debouncer<double>(
|
final debouncerQuality = Debouncer<double>(
|
||||||
@ -23,6 +26,13 @@ customImageQualityWidget(
|
|||||||
},
|
},
|
||||||
initialValue: qualityValue.value,
|
initialValue: qualityValue.value,
|
||||||
);
|
);
|
||||||
|
final debouncerFps = Debouncer<double>(
|
||||||
|
Duration(milliseconds: 1000),
|
||||||
|
onChanged: (double v) {
|
||||||
|
setFps(v);
|
||||||
|
},
|
||||||
|
initialValue: fpsValue.value,
|
||||||
|
);
|
||||||
|
|
||||||
onMoreChanged(bool? value) {
|
onMoreChanged(bool? value) {
|
||||||
if (value == null) return;
|
if (value == null) return;
|
||||||
@ -96,21 +106,65 @@ customImageQualityWidget(
|
|||||||
)
|
)
|
||||||
],
|
],
|
||||||
)),
|
)),
|
||||||
|
if (showFps)
|
||||||
|
Obx(() => Row(
|
||||||
|
children: [
|
||||||
|
Expanded(
|
||||||
|
flex: 3,
|
||||||
|
child: Slider(
|
||||||
|
value: fpsValue.value,
|
||||||
|
min: 5.0,
|
||||||
|
max: 120.0,
|
||||||
|
divisions: 23,
|
||||||
|
onChanged: (double value) async {
|
||||||
|
fpsValue.value = value;
|
||||||
|
debouncerFps.value = value;
|
||||||
|
},
|
||||||
|
),
|
||||||
|
),
|
||||||
|
Expanded(
|
||||||
|
flex: 1,
|
||||||
|
child: Text(
|
||||||
|
'${fpsValue.value.round()}',
|
||||||
|
style: const TextStyle(fontSize: 15),
|
||||||
|
)),
|
||||||
|
Expanded(
|
||||||
|
flex: 2,
|
||||||
|
child: Text(
|
||||||
|
translate('FPS'),
|
||||||
|
style: const TextStyle(fontSize: 15),
|
||||||
|
))
|
||||||
|
],
|
||||||
|
)),
|
||||||
],
|
],
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
customImageQualitySetting() {
|
customImageQualitySetting() {
|
||||||
final qualityKey = 'custom_image_quality';
|
final qualityKey = 'custom_image_quality';
|
||||||
|
final fpsKey = 'custom-fps';
|
||||||
|
|
||||||
var initQuality =
|
var initQuality =
|
||||||
(double.tryParse(bind.mainGetUserDefaultOption(key: qualityKey)) ?? 50.0);
|
(double.tryParse(bind.mainGetUserDefaultOption(key: qualityKey)) ?? 50.0);
|
||||||
|
if (initQuality < 10 || initQuality > 2000) {
|
||||||
|
initQuality = 50;
|
||||||
|
}
|
||||||
|
var initFps =
|
||||||
|
(double.tryParse(bind.mainGetUserDefaultOption(key: fpsKey)) ?? 30.0);
|
||||||
|
if (initFps < 5 || initFps > 120) {
|
||||||
|
initFps = 30;
|
||||||
|
}
|
||||||
|
|
||||||
return customImageQualityWidget(
|
return customImageQualityWidget(
|
||||||
initQuality: initQuality,
|
initQuality: initQuality,
|
||||||
|
initFps: initFps,
|
||||||
setQuality: (v) {
|
setQuality: (v) {
|
||||||
bind.mainSetUserDefaultOption(key: qualityKey, value: v.toString());
|
bind.mainSetUserDefaultOption(key: qualityKey, value: v.toString());
|
||||||
},
|
},
|
||||||
|
setFps: (v) {
|
||||||
|
bind.mainSetUserDefaultOption(key: fpsKey, value: v.toString());
|
||||||
|
},
|
||||||
|
showFps: true,
|
||||||
showMoreQuality: true);
|
showMoreQuality: true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1218,6 +1218,10 @@ impl PeerConfig {
|
|||||||
if !mp.contains_key(key) {
|
if !mp.contains_key(key) {
|
||||||
mp.insert(key.to_owned(), UserDefaultConfig::read().get(key));
|
mp.insert(key.to_owned(), UserDefaultConfig::read().get(key));
|
||||||
}
|
}
|
||||||
|
key = "custom-fps";
|
||||||
|
if !mp.contains_key(key) {
|
||||||
|
mp.insert(key.to_owned(), UserDefaultConfig::read().get(key));
|
||||||
|
}
|
||||||
key = "zoom-cursor";
|
key = "zoom-cursor";
|
||||||
if !mp.contains_key(key) {
|
if !mp.contains_key(key) {
|
||||||
mp.insert(key.to_owned(), UserDefaultConfig::read().get(key));
|
mp.insert(key.to_owned(), UserDefaultConfig::read().get(key));
|
||||||
@ -1520,6 +1524,7 @@ impl UserDefaultConfig {
|
|||||||
self.get_string(key, "auto", vec!["vp8", "vp9", "av1", "h264", "h265"])
|
self.get_string(key, "auto", vec!["vp8", "vp9", "av1", "h264", "h265"])
|
||||||
}
|
}
|
||||||
"custom_image_quality" => self.get_double_string(key, 50.0, 10.0, 0xFFF as f64),
|
"custom_image_quality" => self.get_double_string(key, 50.0, 10.0, 0xFFF as f64),
|
||||||
|
"custom-fps" => self.get_double_string(key, 30.0, 5.0, 120.0),
|
||||||
_ => self
|
_ => self
|
||||||
.options
|
.options
|
||||||
.get(key)
|
.get(key)
|
||||||
|
@ -1483,6 +1483,10 @@ impl LoginConfigHandler {
|
|||||||
config.custom_image_quality[0]
|
config.custom_image_quality[0]
|
||||||
};
|
};
|
||||||
msg.custom_image_quality = quality << 8;
|
msg.custom_image_quality = quality << 8;
|
||||||
|
#[cfg(feature = "flutter")]
|
||||||
|
if let Some(custom_fps) = self.options.get("custom-fps") {
|
||||||
|
msg.custom_fps = custom_fps.parse().unwrap_or(30);
|
||||||
|
}
|
||||||
n += 1;
|
n += 1;
|
||||||
}
|
}
|
||||||
let view_only = self.get_toggle_option("view-only");
|
let view_only = self.get_toggle_option("view-only");
|
||||||
@ -1663,6 +1667,27 @@ impl LoginConfigHandler {
|
|||||||
res
|
res
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Create a [`Message`] for saving custom fps.
|
||||||
|
///
|
||||||
|
/// # Arguments
|
||||||
|
///
|
||||||
|
/// * `fps` - The given fps.
|
||||||
|
pub fn set_custom_fps(&mut self, fps: i32) -> Message {
|
||||||
|
let mut misc = Misc::new();
|
||||||
|
misc.set_option(OptionMessage {
|
||||||
|
custom_fps: fps,
|
||||||
|
..Default::default()
|
||||||
|
});
|
||||||
|
let mut msg_out = Message::new();
|
||||||
|
msg_out.set_misc(misc);
|
||||||
|
let mut config = self.load_config();
|
||||||
|
config
|
||||||
|
.options
|
||||||
|
.insert("custom-fps".to_owned(), fps.to_string());
|
||||||
|
self.save_config(config);
|
||||||
|
msg_out
|
||||||
|
}
|
||||||
|
|
||||||
pub fn get_option(&self, k: &str) -> String {
|
pub fn get_option(&self, k: &str) -> String {
|
||||||
if let Some(v) = self.config.options.get(k) {
|
if let Some(v) = self.config.options.get(k) {
|
||||||
v.clone()
|
v.clone()
|
||||||
@ -1770,11 +1795,7 @@ impl LoginConfigHandler {
|
|||||||
crate::flutter::push_global_event(crate::flutter::APP_TYPE_MAIN, evt);
|
crate::flutter::push_global_event(crate::flutter::APP_TYPE_MAIN, evt);
|
||||||
}
|
}
|
||||||
if config.keyboard_mode.is_empty() {
|
if config.keyboard_mode.is_empty() {
|
||||||
if is_keyboard_mode_supported(
|
if is_keyboard_mode_supported(&KeyboardMode::Map, get_version_number(&pi.version), &pi.platform) {
|
||||||
&KeyboardMode::Map,
|
|
||||||
get_version_number(&pi.version),
|
|
||||||
&pi.platform,
|
|
||||||
) {
|
|
||||||
config.keyboard_mode = KeyboardMode::Map.to_string();
|
config.keyboard_mode = KeyboardMode::Map.to_string();
|
||||||
} else {
|
} else {
|
||||||
config.keyboard_mode = KeyboardMode::Legacy.to_string();
|
config.keyboard_mode = KeyboardMode::Legacy.to_string();
|
||||||
|
@ -395,7 +395,7 @@ pub fn session_is_keyboard_mode_supported(session_id: SessionID, mode: String) -
|
|||||||
SyncReturn(is_keyboard_mode_supported(
|
SyncReturn(is_keyboard_mode_supported(
|
||||||
&mode,
|
&mode,
|
||||||
session.get_peer_version(),
|
session.get_peer_version(),
|
||||||
&session.peer_platform(),
|
&session.peer_platform()
|
||||||
))
|
))
|
||||||
} else {
|
} else {
|
||||||
SyncReturn(false)
|
SyncReturn(false)
|
||||||
@ -411,6 +411,12 @@ pub fn session_set_custom_image_quality(session_id: SessionID, value: i32) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn session_set_custom_fps(session_id: SessionID, fps: i32) {
|
||||||
|
if let Some(session) = sessions::get_session_by_session_id(&session_id) {
|
||||||
|
session.set_custom_fps(fps);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
pub fn session_lock_screen(session_id: SessionID) {
|
pub fn session_lock_screen(session_id: SessionID) {
|
||||||
if let Some(session) = sessions::get_session_by_session_id(&session_id) {
|
if let Some(session) = sessions::get_session_by_session_id(&session_id) {
|
||||||
session.lock_screen();
|
session.lock_screen();
|
||||||
|
@ -1,7 +1,4 @@
|
|||||||
use crate::{
|
use crate::{input::{MOUSE_BUTTON_LEFT, MOUSE_TYPE_DOWN, MOUSE_TYPE_UP, MOUSE_TYPE_WHEEL}, common::{is_keyboard_mode_supported, get_supported_keyboard_modes}};
|
||||||
common::{get_supported_keyboard_modes, is_keyboard_mode_supported},
|
|
||||||
input::{MOUSE_BUTTON_LEFT, MOUSE_TYPE_DOWN, MOUSE_TYPE_UP, MOUSE_TYPE_WHEEL},
|
|
||||||
};
|
|
||||||
use async_trait::async_trait;
|
use async_trait::async_trait;
|
||||||
use bytes::Bytes;
|
use bytes::Bytes;
|
||||||
use rdev::{Event, EventType::*, KeyCode};
|
use rdev::{Event, EventType::*, KeyCode};
|
||||||
@ -216,7 +213,7 @@ impl<T: InvokeUiSession> Session<T> {
|
|||||||
self.lc.read().unwrap().version.clone()
|
self.lc.read().unwrap().version.clone()
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn fallback_keyboard_mode(&self) -> String {
|
pub fn fallback_keyboard_mode(&self) -> String {
|
||||||
let peer_version = self.get_peer_version();
|
let peer_version = self.get_peer_version();
|
||||||
let platform = self.peer_platform();
|
let platform = self.peer_platform();
|
||||||
|
|
||||||
@ -395,6 +392,11 @@ impl<T: InvokeUiSession> Session<T> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn set_custom_fps(&self, custom_fps: i32) {
|
||||||
|
let msg = self.lc.write().unwrap().set_custom_fps(custom_fps);
|
||||||
|
self.send(Data::Message(msg));
|
||||||
|
}
|
||||||
|
|
||||||
pub fn get_remember(&self) -> bool {
|
pub fn get_remember(&self) -> bool {
|
||||||
self.lc.read().unwrap().remember
|
self.lc.read().unwrap().remember
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user