forked from alvr-org/ALVR
/
settings.rs
1560 lines (1391 loc) · 56.5 KB
/
settings.rs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
use alvr_common::{LogSeverity, LogSeverityDefault, LogSeverityDefaultVariant};
use bytemuck::{Pod, Zeroable};
use serde::{Deserialize, Serialize};
use settings_schema::{
ArrayDefault, DictionaryDefault, OptionalDefault, SettingsSchema, Switch, SwitchDefault,
VectorDefault,
};
include!(concat!(env!("OUT_DIR"), "/openvr_property_keys.rs"));
#[derive(SettingsSchema, Serialize, Deserialize, Clone)]
#[schema(gui = "button_group")]
pub enum FrameSize {
Scale(#[schema(gui(slider(min = 0.25, max = 2.0, step = 0.01)))] f32),
Absolute {
#[schema(gui(slider(min = 32, max = 0x1000, step = 32)))]
width: u32,
#[schema(gui(slider(min = 32, max = 0x1000, step = 32)))]
height: Option<u32>,
},
}
#[repr(u32)]
#[derive(SettingsSchema, Serialize, Deserialize, Clone)]
pub enum EncoderQualityPresetAmd {
Quality = 0,
Balanced = 1,
Speed = 2,
}
#[repr(u32)]
#[derive(SettingsSchema, Serialize, Deserialize, Clone)]
pub enum EncoderQualityPresetNvidia {
P1 = 1,
P2 = 2,
P3 = 3,
P4 = 4,
P5 = 5,
P6 = 6,
P7 = 7,
}
#[repr(u32)]
#[derive(SettingsSchema, Serialize, Deserialize, Clone)]
pub enum NvencTuningPreset {
HighQuality = 1,
LowLatency = 2,
UltraLowLatency = 3,
Lossless = 4,
}
#[repr(u32)]
#[derive(SettingsSchema, Serialize, Deserialize, Clone)]
pub enum NvencMultiPass {
Disabled = 0,
#[schema(strings(display_name = "1/4 resolution"))]
QuarterResolution = 1,
FullResolution = 2,
}
#[repr(u32)]
#[derive(SettingsSchema, Serialize, Deserialize, Clone)]
pub enum NvencAdaptiveQuantizationMode {
Disabled = 0,
Spatial = 1,
Temporal = 2,
}
#[repr(u8)]
#[derive(SettingsSchema, Serialize, Deserialize, Clone)]
#[schema(gui = "button_group")]
pub enum RateControlMode {
#[schema(strings(display_name = "CBR"))]
Cbr = 0,
#[schema(strings(display_name = "VBR"))]
Vbr = 1,
}
#[repr(u8)]
#[derive(SettingsSchema, Serialize, Deserialize, Clone)]
#[schema(gui = "button_group")]
pub enum EntropyCoding {
#[schema(strings(display_name = "CAVLC"))]
Cavlc = 1,
#[schema(strings(display_name = "CABAC"))]
Cabac = 0,
}
/// Except for preset, the value of these fields is not applied if == -1 (flag)
#[derive(SettingsSchema, Serialize, Deserialize, Clone)]
#[schema(collapsible)]
pub struct NvencConfig {
#[schema(strings(
help = "P1 is the fastest preset and P7 is the preset that produces better quality. P6 and P7 are too slow to be usable."
))]
#[schema(flag = "steamvr-restart")]
pub quality_preset: EncoderQualityPresetNvidia,
#[schema(flag = "steamvr-restart")]
pub tuning_preset: NvencTuningPreset,
#[schema(strings(
help = "Reduce compression artifacts at the cost of small performance penalty"
))]
#[schema(flag = "steamvr-restart")]
pub multi_pass: NvencMultiPass,
#[schema(strings(
help = r#"Spatial: Helps reduce color banding, but high-complexity scenes might look worse.
Temporal: Helps improve overall encoding quality, very small trade-off in speed."#
))]
#[schema(flag = "steamvr-restart")]
pub adaptive_quantization_mode: NvencAdaptiveQuantizationMode,
#[schema(flag = "steamvr-restart")]
pub low_delay_key_frame_scale: i64,
#[schema(flag = "steamvr-restart")]
pub refresh_rate: i64,
#[schema(flag = "steamvr-restart")]
pub enable_intra_refresh: bool,
#[schema(flag = "steamvr-restart")]
pub intra_refresh_period: i64,
#[schema(flag = "steamvr-restart")]
pub intra_refresh_count: i64,
#[schema(flag = "steamvr-restart")]
pub max_num_ref_frames: i64,
#[schema(flag = "steamvr-restart")]
pub gop_length: i64,
#[schema(flag = "steamvr-restart")]
pub p_frame_strategy: i64,
#[schema(flag = "steamvr-restart")]
pub rate_control_mode: i64,
#[schema(flag = "steamvr-restart")]
pub rc_buffer_size: i64,
#[schema(flag = "steamvr-restart")]
pub rc_initial_delay: i64,
#[schema(flag = "steamvr-restart")]
pub rc_max_bitrate: i64,
#[schema(flag = "steamvr-restart")]
pub rc_average_bitrate: i64,
#[schema(flag = "steamvr-restart")]
pub enable_weighted_prediction: bool,
}
#[derive(SettingsSchema, Serialize, Deserialize, Clone)]
#[schema(collapsible)]
pub struct AmfConfig {
#[schema(flag = "steamvr-restart")]
pub quality_preset: EncoderQualityPresetAmd,
#[schema(strings(display_name = "Enable VBAQ"), flag = "steamvr-restart")]
pub enable_vbaq: bool,
#[schema(flag = "steamvr-restart")]
pub use_preproc: bool,
#[schema(gui(slider(min = 0, max = 10)))]
#[schema(flag = "steamvr-restart")]
pub preproc_sigma: u32,
#[schema(gui(slider(min = 0, max = 10)))]
#[schema(flag = "steamvr-restart")]
pub preproc_tor: u32,
}
#[derive(SettingsSchema, Serialize, Deserialize, Clone)]
pub struct SoftwareEncodingConfig {
#[schema(strings(
display_name = "Force software encoding",
help = "Forces the encoder to use CPU instead of GPU"
))]
#[schema(flag = "steamvr-restart")]
pub force_software_encoding: bool,
#[schema(strings(display_name = "Encoder thread count"))]
#[schema(flag = "steamvr-restart")]
pub thread_count: u32,
}
#[derive(SettingsSchema, Serialize, Deserialize, Clone)]
#[schema(collapsible)]
pub struct EncoderConfig {
#[schema(strings(help = r#"CBR: Constant BitRate mode. This is recommended.
VBR: Variable BitRate mode. Not commended because it may throw off the adaptive bitrate algorithm. This is only supported on Windows and only with AMD/Nvidia GPUs"#))]
#[schema(flag = "steamvr-restart")]
pub rate_control_mode: RateControlMode,
#[schema(strings(
help = r#"In CBR mode, this makes sure the bitrate does not fall below the assigned value. This is mostly useful for debugging."#
))]
#[schema(flag = "steamvr-restart")]
pub filler_data: bool,
#[schema(strings(help = r#"CAVLC algorithm is recommended.
CABAC produces better compression but it's significantly slower and may lead to runaway latency"#))]
#[schema(flag = "steamvr-restart")]
pub entropy_coding: EntropyCoding,
#[schema(strings(
display_name = "Reduce color banding",
help = "Sets the encoder to use 10 bits per channel instead of 8. Does not work on Linux with Nvidia"
))]
#[schema(flag = "steamvr-restart")]
pub use_10bit: bool,
#[schema(strings(display_name = "NVENC"))]
#[schema(flag = "steamvr-restart")]
pub nvenc: NvencConfig,
#[schema(strings(display_name = "AMF"))]
#[schema(flag = "steamvr-restart")]
pub amf: AmfConfig,
pub software: SoftwareEncodingConfig,
}
#[derive(SettingsSchema, Serialize, Deserialize, Clone, Debug)]
pub enum MediacodecDataType {
Float(f32),
Int32(i32),
Int64(i64),
String(String),
}
#[derive(SettingsSchema, Serialize, Deserialize, Clone, PartialEq)]
pub struct EncoderLatencyLimiter {
#[schema(strings(
help = "Allowed percentage of frame interval to allocate for video encoding"
))]
#[schema(flag = "real-time")]
#[schema(gui(slider(min = 0.3, max = 1.0, step = 0.01)))]
pub max_saturation_multiplier: f32,
}
#[derive(SettingsSchema, Serialize, Deserialize, Clone, PartialEq)]
#[schema(collapsible)]
pub struct DecoderLatencyLimiter {
#[schema(strings(
display_name = "Maximum decoder latency",
help = "When the decoder latency goes above this threshold, the bitrate will be reduced"
))]
#[schema(flag = "real-time")]
#[schema(gui(slider(min = 1, max = 50)), suffix = "ms")]
pub max_decoder_latency_ms: u64,
#[schema(strings(
display_name = "latency overstep",
help = "Number of consecutive frames above the threshold to trigger a bitrate reduction"
))]
#[schema(flag = "real-time")]
#[schema(gui(slider(min = 1, max = 100)), suffix = " frames")]
pub latency_overstep_frames: usize,
#[schema(strings(
help = "Controls how much the bitrate is reduced when the decoder latency goes above the threshold"
))]
#[schema(flag = "real-time")]
#[schema(gui(slider(min = 0.5, max = 1.0)))]
pub latency_overstep_multiplier: f32,
}
#[derive(SettingsSchema, Serialize, Deserialize, Clone, PartialEq)]
#[schema(gui = "button_group")]
pub enum BitrateMode {
#[schema(strings(display_name = "Constant"))]
ConstantMbps(#[schema(gui(slider(min = 5, max = 1000, logarithmic)), suffix = "Mbps")] u64),
#[schema(collapsible)]
Adaptive {
#[schema(strings(
help = "Percentage of network bandwidth to allocate for video transmission"
))]
#[schema(flag = "real-time")]
#[schema(gui(slider(min = 0.5, max = 5.0, step = 0.01)))]
saturation_multiplier: f32,
#[schema(strings(display_name = "Maximum bitrate"))]
#[schema(flag = "real-time")]
#[schema(gui(slider(min = 1, max = 1000, logarithmic)), suffix = "Mbps")]
max_bitrate_mbps: Switch<u64>,
#[schema(strings(display_name = "Minimum bitrate"))]
#[schema(flag = "real-time")]
#[schema(gui(slider(min = 1, max = 100, logarithmic)), suffix = "Mbps")]
min_bitrate_mbps: Switch<u64>,
#[schema(strings(display_name = "Maximum network latency"))]
#[schema(flag = "real-time")]
#[schema(gui(slider(min = 1, max = 50)), suffix = "ms")]
max_network_latency_ms: Switch<u64>,
#[schema(flag = "real-time")]
encoder_latency_limiter: Switch<EncoderLatencyLimiter>,
#[schema(strings(
help = "Currently there is a bug where the decoder latency keeps rising when above a certain bitrate"
))]
#[schema(flag = "real-time")]
decoder_latency_limiter: Switch<DecoderLatencyLimiter>,
},
}
#[derive(SettingsSchema, Serialize, Deserialize, Clone, PartialEq)]
pub struct BitrateAdaptiveFramerateConfig {
#[schema(strings(
display_name = "FPS reset threshold multiplier",
help = "If the framerate changes more than this factor, trigger a parameters update",
))]
#[schema(flag = "real-time")]
#[schema(gui(slider(min = 1.0, max = 3.0, step = 0.1)))]
pub framerate_reset_threshold_multiplier: f32,
}
#[derive(SettingsSchema, Serialize, Deserialize, Clone, PartialEq)]
#[schema(collapsible)]
pub struct BitrateConfig {
#[schema(flag = "real-time")]
pub mode: BitrateMode,
#[schema(strings(
help = "Ensure that the specified bitrate value is respected regardless of the framerate"
))]
#[schema(flag = "real-time")]
pub adapt_to_framerate: Switch<BitrateAdaptiveFramerateConfig>,
#[schema(strings(help = "Controls the smoothness during calculations"))]
pub history_size: usize,
#[schema(strings(
help = "When this is enabled, an IDR frame is requested after the bitrate is changed.
This has an effect only on AMD GPUs."
))]
#[schema(flag = "steamvr-restart")]
pub image_corruption_fix: bool,
}
#[repr(u8)]
#[derive(SettingsSchema, Serialize, Deserialize, Copy, Clone, PartialEq)]
pub enum ClientsideFoveationLevel {
Low = 1,
Medium = 2,
High = 3,
}
#[derive(SettingsSchema, Serialize, Deserialize, Clone, PartialEq)]
pub enum ClientsideFoveationMode {
Static { level: ClientsideFoveationLevel },
Dynamic { max_level: ClientsideFoveationLevel },
}
#[derive(SettingsSchema, Serialize, Deserialize, Clone, PartialEq)]
#[schema(collapsible)]
pub struct ClientsideFoveationConfig {
pub mode: ClientsideFoveationMode,
#[schema(strings(display_name = "Foveation offset"))]
#[schema(gui(slider(min = -45.0, max = 45.0, step = 0.1)), suffix = "°")]
pub vertical_offset_deg: f32,
}
#[derive(SettingsSchema, Serialize, Deserialize, Clone, PartialEq)]
#[schema(collapsible)]
pub struct FoveatedEncodingConfig {
#[schema(strings(display_name = "Center region width"))]
#[schema(gui(slider(min = 0.0, max = 1.0, step = 0.01)))]
#[schema(flag = "steamvr-restart")]
pub center_size_x: f32,
#[schema(strings(display_name = "Center region height"))]
#[schema(gui(slider(min = 0.0, max = 1.0, step = 0.01)))]
#[schema(flag = "steamvr-restart")]
pub center_size_y: f32,
#[schema(strings(display_name = "Center shift X"))]
#[schema(gui(slider(min = -1.0, max = 1.0, step = 0.01)))]
#[schema(flag = "steamvr-restart")]
pub center_shift_x: f32,
#[schema(strings(display_name = "Center shift Y"))]
#[schema(gui(slider(min = -1.0, max = 1.0, step = 0.01)))]
#[schema(flag = "steamvr-restart")]
pub center_shift_y: f32,
#[schema(strings(display_name = "Horizontal edge ratio"))]
#[schema(gui(slider(min = 1.0, max = 10.0, step = 1.0)))]
#[schema(flag = "steamvr-restart")]
pub edge_ratio_x: f32,
#[schema(strings(display_name = "Vertical edge ratio"))]
#[schema(gui(slider(min = 1.0, max = 10.0, step = 1.0)))]
#[schema(flag = "steamvr-restart")]
pub edge_ratio_y: f32,
}
#[repr(C)]
#[derive(SettingsSchema, Clone, Copy, Serialize, Deserialize, Pod, Zeroable)]
#[schema(collapsible)]
pub struct ColorCorrectionConfig {
#[schema(gui(slider(min = -1.0, max = 1.0, step = 0.01)))]
#[schema(flag = "steamvr-restart")]
pub brightness: f32,
#[schema(gui(slider(min = -1.0, max = 1.0, step = 0.01)))]
#[schema(flag = "steamvr-restart")]
pub contrast: f32,
#[schema(gui(slider(min = -1.0, max = 1.0, step = 0.01)))]
#[schema(flag = "steamvr-restart")]
pub saturation: f32,
#[schema(gui(slider(min = 0.0, max = 5.0, step = 0.01)))]
#[schema(flag = "steamvr-restart")]
pub gamma: f32,
#[schema(gui(slider(min = -1.0, max = 5.0, step = 0.01)))]
#[schema(flag = "steamvr-restart")]
pub sharpening: f32,
}
#[repr(u8)]
#[derive(SettingsSchema, Serialize, Deserialize, Debug, Copy, Clone)]
#[schema(gui = "button_group")]
pub enum CodecType {
#[schema(strings(display_name = "h264"))]
H264 = 0,
#[schema(strings(display_name = "HEVC"))]
Hevc = 1,
}
#[derive(SettingsSchema, Serialize, Deserialize, Clone)]
#[schema(collapsible)]
pub struct VideoConfig {
#[schema(strings(help = "You probably don't want to change this"))]
#[schema(flag = "steamvr-restart")]
pub adapter_index: u32,
#[schema(strings(
help = "Resolution used for encoding and decoding. Relative to a single eye view."
))]
#[schema(flag = "steamvr-restart")]
pub transcoding_view_resolution: FrameSize,
#[schema(strings(
help = "This is the resolution that SteamVR will use as default for the game rendering. Relative to a single eye view."
))]
#[schema(flag = "steamvr-restart")]
pub emulated_headset_view_resolution: FrameSize,
#[schema(strings(display_name = "Preferred FPS"))]
#[schema(gui(slider(min = 60.0, max = 120.0)), suffix = "Hz")]
#[schema(flag = "steamvr-restart")]
pub preferred_fps: f32,
#[schema(
strings(
display_name = "Maximum buffering",
help = "Incresing this value will help reduce stutter but it will increase latency"
),
gui(slider(min = 1.0, max = 10.0, step = 0.1, logarithmic)),
suffix = " frames"
)]
pub max_buffering_frames: f32,
#[schema(gui(slider(min = 0.50, max = 0.99, step = 0.01)))]
pub buffering_history_weight: f32,
#[schema(strings(help = "This works only on Windows"))]
#[schema(flag = "real-time")]
pub optimize_game_render_latency: bool,
pub bitrate: BitrateConfig,
#[schema(strings(
help = "HEVC may provide better visual fidelity at the cost of increased encoder latency"
))]
#[schema(flag = "steamvr-restart")]
pub preferred_codec: CodecType,
#[schema(flag = "steamvr-restart")]
pub encoder_config: EncoderConfig,
pub mediacodec_extra_options: Vec<(String, MediacodecDataType)>,
#[schema(flag = "steamvr-restart")]
pub foveated_encoding: Switch<FoveatedEncodingConfig>,
pub clientside_foveation: Switch<ClientsideFoveationConfig>,
#[schema(strings(
help = "Attempts to use a software decoder on the device. Slow, but may work around broken codecs."
))]
pub force_software_decoder: bool,
#[schema(flag = "steamvr-restart")]
pub color_correction: Switch<ColorCorrectionConfig>,
}
#[derive(SettingsSchema, Serialize, Deserialize, Clone, Copy)]
#[schema(gui = "button_group")]
pub enum LinuxAudioBackend {
#[schema(strings(display_name = "ALSA"))]
Alsa,
Jack,
}
#[derive(SettingsSchema, Serialize, Deserialize, Clone)]
#[schema(gui = "button_group")]
pub enum CustomAudioDeviceConfig {
#[schema(strings(display_name = "By name (substring)"))]
NameSubstring(String),
#[schema(strings(display_name = "By index"))]
Index(usize),
}
#[derive(SettingsSchema, Serialize, Deserialize, Clone)]
#[schema(collapsible)]
pub struct AudioBufferingConfig {
#[schema(strings(display_name = "Average buffering"))]
#[schema(gui(slider(min = 0, max = 200)), suffix = "ms")]
pub average_buffering_ms: u64,
#[schema(strings(display_name = "Batch size"))]
#[schema(gui(slider(min = 1, max = 20)), suffix = "ms")]
pub batch_ms: u64,
}
#[derive(SettingsSchema, Serialize, Deserialize, Clone)]
#[schema(collapsible)]
pub struct GameAudioConfig {
pub device: Option<CustomAudioDeviceConfig>,
pub mute_when_streaming: bool,
pub buffering: AudioBufferingConfig,
}
#[derive(SettingsSchema, Serialize, Deserialize, Clone)]
pub enum MicrophoneDevicesConfig {
Automatic,
#[schema(strings(display_name = "VB Cable"))]
VBCable,
#[schema(strings(display_name = "VoiceMeeter"))]
VoiceMeeter,
#[schema(strings(display_name = "VoiceMeeter Aux"))]
VoiceMeeterAux,
#[schema(strings(display_name = "VoiceMeeter VAIO3"))]
VoiceMeeterVaio3,
Custom {
#[schema(strings(help = "This device is used by ALVR to output microphone audio"))]
sink: CustomAudioDeviceConfig,
#[schema(strings(help = "This device is set in SteamVR as the default microphone"))]
source: CustomAudioDeviceConfig,
},
}
// Note: sample rate is a free parameter for microphone, because both server and client supports
// resampling. In contrary, for game audio, the server does not support resampling.
#[derive(SettingsSchema, Serialize, Deserialize, Clone)]
#[schema(collapsible)]
pub struct MicrophoneConfig {
pub devices: MicrophoneDevicesConfig,
pub buffering: AudioBufferingConfig,
}
#[derive(SettingsSchema, Serialize, Deserialize, Clone)]
#[schema(collapsible)]
pub struct AudioConfig {
#[schema(strings(help = "ALSA is recommended for most PulseAudio or PipeWire-based setups"))]
pub linux_backend: LinuxAudioBackend,
pub game_audio: Switch<GameAudioConfig>,
pub microphone: Switch<MicrophoneConfig>,
}
#[derive(SettingsSchema, Serialize, Deserialize, Clone)]
pub enum HeadsetEmulationMode {
#[schema(strings(display_name = "Rift S"))]
RiftS,
#[schema(strings(display_name = "Quest 2"))]
Quest2,
Vive,
Custom {
serial_number: String,
},
}
#[derive(SettingsSchema, Serialize, Deserialize, Clone, PartialEq)]
pub struct FaceTrackingSourcesConfig {
pub combined_eye_gaze: bool,
pub eye_tracking_fb: bool,
pub face_tracking_fb: bool,
pub eye_expressions_htc: bool,
pub lip_expressions_htc: bool,
}
#[derive(SettingsSchema, Serialize, Deserialize, Clone)]
pub enum FaceTrackingSinkConfig {
#[schema(strings(display_name = "VRChat Eye OSC"))]
VrchatEyeOsc { port: u16 },
#[schema(strings(display_name = "VRCFaceTracking"))]
VrcFaceTracking,
}
#[derive(SettingsSchema, Serialize, Deserialize, Clone)]
#[schema(collapsible)]
pub struct FaceTrackingConfig {
pub sources: FaceTrackingSourcesConfig,
pub sink: FaceTrackingSinkConfig,
}
#[derive(SettingsSchema, Serialize, Deserialize, Clone, PartialEq, Eq)]
pub enum ControllersEmulationMode {
#[schema(strings(display_name = "Rift S Touch"))]
RiftSTouch,
#[schema(strings(display_name = "Quest 2 Touch"))]
Quest2Touch,
#[schema(strings(display_name = "Quest 3 Touch Plus"))]
Quest3Plus,
#[schema(strings(display_name = "Valve Index"))]
ValveIndex,
ViveWand,
ViveTracker,
Custom {
serial_number: String,
button_set: Vec<String>,
},
}
#[derive(SettingsSchema, Serialize, Deserialize, Clone, Copy)]
pub struct HysteresisThreshold {
#[schema(gui(slider(min = 0.0, max = 1.0, step = 0.01)))]
pub value: f32,
#[schema(gui(slider(min = 0.0, max = 1.0, step = 0.01)))]
pub deviation: f32,
}
#[derive(SettingsSchema, Serialize, Deserialize, Clone, Copy)]
pub struct BinaryToScalarStates {
#[schema(gui(slider(min = 0.0, max = 1.0, step = 0.01)))]
pub off: f32,
#[schema(gui(slider(min = 0.0, max = 1.0, step = 0.01)))]
pub on: f32,
}
// Remaps 0..1 to custom range
#[derive(SettingsSchema, Serialize, Deserialize, Clone, Copy)]
pub struct Range {
#[schema(gui(slider(min = 0.0, max = 1.0, step = 0.01)))]
pub min: f32,
#[schema(gui(slider(min = 0.0, max = 1.0, step = 0.01)))]
pub max: f32,
}
#[derive(SettingsSchema, Serialize, Deserialize, Clone)]
pub enum ButtonMappingType {
Passthrough,
HysteresisThreshold(HysteresisThreshold),
BinaryToScalar(BinaryToScalarStates),
Remap(Range),
}
#[derive(SettingsSchema, Serialize, Deserialize, Clone)]
pub struct ButtonBindingTarget {
pub destination: String,
pub mapping_type: ButtonMappingType,
pub binary_conditions: Vec<String>,
}
#[derive(SettingsSchema, Serialize, Deserialize, Clone)]
#[schema(collapsible)]
pub struct AutomaticButtonMappingConfig {
pub click_threshold: HysteresisThreshold,
pub touch_threshold: HysteresisThreshold,
pub force_threshold: f32,
}
#[derive(SettingsSchema, Serialize, Deserialize, Clone)]
#[schema(collapsible)]
pub struct HandGestureConfig {
#[schema(flag = "real-time")]
pub only_touch: bool,
#[schema(flag = "real-time")]
#[schema(strings(
help = "How close the tips of your fingers need to be to register a pinch click."
))]
#[schema(gui(slider(min = 0.0, max = 1.0, step = 0.01)), suffix = "cm")]
pub pinch_touch_distance: f32,
#[schema(flag = "real-time")]
#[schema(strings(
help = "How close together the tips of your fingers need to be to start registering a pinch trigger pull."
))]
#[schema(gui(slider(min = 0.0, max = 2.5, step = 0.025)), suffix = "cm")]
pub pinch_trigger_distance: f32,
#[schema(flag = "real-time")]
#[schema(strings(
help = "How close to your palm the tips of your fingers need to be to register a curl click."
))]
#[schema(gui(slider(min = 0.0, max = 5.0)), suffix = "cm")]
pub curl_touch_distance: f32,
#[schema(flag = "real-time")]
#[schema(strings(
help = "How close to your palm the tips of your fingers need to be to start registering a trigger pull."
))]
#[schema(gui(slider(min = 0.0, max = 10.0)), suffix = "cm")]
pub curl_trigger_distance: f32,
#[schema(flag = "real-time")]
#[schema(gui(slider(min = 0.0, max = 100.0)), suffix = "%")]
pub joystick_deadzone: f32,
#[schema(flag = "real-time")]
#[schema(gui(slider(min = -5.0, max = 5.0)), suffix = "cm")]
pub joystick_offset_horizontal: f32,
#[schema(flag = "real-time")]
#[schema(gui(slider(min = -5.0, max = 5.0)), suffix = "cm")]
pub joystick_offset_vertical: f32,
#[schema(flag = "real-time")]
#[schema(strings(
help = "The radius of motion of the joystick. The joystick can be controlled if the thumb is within 2x this range."
))]
#[schema(gui(slider(min = 0.0, max = 5.0)), suffix = "cm")]
pub joystick_range: f32,
#[schema(flag = "real-time")]
#[schema(strings(
help = "How long the gesture must be continuously held before it is activated."
))]
#[schema(gui(slider(min = 0, max = 1000)), suffix = "ms")]
pub activation_delay: u32,
#[schema(flag = "real-time")]
#[schema(strings(
help = "How long the gesture must be continuously released before it is deactivated."
))]
#[schema(gui(slider(min = 0, max = 1000)), suffix = "ms")]
pub deactivation_delay: u32,
#[schema(flag = "real-time")]
#[schema(strings(
help = "How long the after the gesture has been deactivated before it can be activated again."
))]
#[schema(gui(slider(min = 0, max = 1000)), suffix = "ms")]
pub repeat_delay: u32,
}
#[derive(SettingsSchema, Serialize, Deserialize, Clone)]
#[schema(collapsible)]
pub struct HapticsConfig {
#[schema(flag = "real-time")]
#[schema(gui(slider(min = 0.0, max = 5.0, step = 0.1)))]
pub intensity_multiplier: f32,
#[schema(flag = "real-time")]
#[schema(gui(slider(min = 0.0, max = 1.0, step = 0.01)))]
pub amplitude_curve: f32,
#[schema(strings(display_name = "Minimum duration"))]
#[schema(flag = "real-time")]
#[schema(gui(slider(min = 0.0, max = 0.1, step = 0.001)), suffix = "s")]
pub min_duration_s: f32,
}
#[derive(SettingsSchema, Serialize, Deserialize, Clone)]
#[schema(collapsible)]
pub struct ControllersConfig {
#[schema(strings(help = "Turning this off will make the controllers appear powered off."))]
#[schema(flag = "real-time")]
pub tracked: bool,
#[schema(flag = "real-time")]
#[schema(strings(
help = "Enabling this passes skeletal hand data (finger tracking) to SteamVR."
))]
pub enable_skeleton: bool,
#[schema(flag = "steamvr-restart")]
pub emulation_mode: ControllersEmulationMode,
#[schema(flag = "steamvr-restart")]
pub extra_openvr_props: Vec<OpenvrProperty>,
#[schema(strings(help = "List of OpenXR-syle paths"))]
pub button_mappings: Option<Vec<(String, Vec<ButtonBindingTarget>)>>,
pub button_mapping_config: AutomaticButtonMappingConfig,
#[schema(flag = "real-time")]
#[schema(strings(
help = "Enabling this allows using hand gestures to emulate controller inputs."
))]
pub gestures: Switch<HandGestureConfig>,
#[schema(strings(
display_name = "Prediction",
help = r"Higher values make the controllers track smoother.
Technically, this is the time (counted in frames) between pose submitted to SteamVR and the corresponding virtual vsync happens.
Currently this cannot be reliably estimated automatically. The correct value should be 2 but 3 is default for smoother tracking at the cost of slight lag."
))]
#[schema(gui(slider(min = 1.0, max = 10.0, logarithmic)), suffix = "frames")]
pub steamvr_pipeline_frames: f32,
#[schema(flag = "real-time")]
// note: logarithmic scale seems to be glitchy for this control
#[schema(gui(slider(min = 0.0, max = 1.0, step = 0.01)), suffix = "m/s")]
pub linear_velocity_cutoff: f32,
#[schema(flag = "real-time")]
// note: logarithmic scale seems to be glitchy for this control
#[schema(gui(slider(min = 0.0, max = 100.0, step = 1.0)), suffix = "°/s")]
pub angular_velocity_cutoff: f32,
#[schema(flag = "real-time")]
// note: logarithmic scale seems to be glitchy for this control
#[schema(gui(slider(min = -0.5, max = 0.5, step = 0.001)), suffix = "m")]
pub left_controller_position_offset: [f32; 3],
#[schema(flag = "real-time")]
#[schema(gui(slider(min = -180.0, max = 180.0, step = 1.0)), suffix = "°")]
pub left_controller_rotation_offset: [f32; 3],
#[schema(flag = "real-time")]
// note: logarithmic scale seems to be glitchy for this control
#[schema(gui(slider(min = -0.5, max = 0.5, step = 0.001)), suffix = "m")]
pub left_hand_tracking_position_offset: [f32; 3],
#[schema(flag = "real-time")]
#[schema(gui(slider(min = -180.0, max = 180.0, step = 1.0)), suffix = "°")]
pub left_hand_tracking_rotation_offset: [f32; 3],
#[schema(flag = "real-time")]
pub haptics: Switch<HapticsConfig>,
}
#[derive(SettingsSchema, Serialize, Deserialize, Clone, Copy)]
pub enum PositionRecenteringMode {
Disabled,
LocalFloor,
Local {
#[schema(gui(slider(min = 0.0, max = 3.0)), suffix = "m")]
view_height: f32,
},
}
#[derive(SettingsSchema, Serialize, Deserialize, Clone, Copy)]
pub enum RotationRecenteringMode {
Disabled,
Yaw,
Tilted,
}
#[derive(SettingsSchema, Serialize, Deserialize, Clone)]
#[schema(collapsible)]
pub struct HeadsetConfig {
#[schema(flag = "steamvr-restart")]
pub emulation_mode: HeadsetEmulationMode,
#[schema(flag = "steamvr-restart")]
pub extra_openvr_props: Vec<OpenvrProperty>,
#[schema(flag = "steamvr-restart")]
pub tracking_ref_only: bool,
#[schema(flag = "steamvr-restart")]
pub enable_vive_tracker_proxy: bool,
pub face_tracking: Switch<FaceTrackingConfig>,
#[schema(flag = "steamvr-restart")]
pub controllers: Switch<ControllersConfig>,
#[schema(strings(
help = r#"Disabled: the playspace origin is determined by the room-scale guardian setup.
Local floor: the origin is on the floor and resets when long pressing the oculus button.
Local: the origin resets when long pressing the oculus button, and is calculated as an offset from the current head position."#
))]
#[schema(flag = "real-time")]
pub position_recentering_mode: PositionRecenteringMode,
#[schema(strings(
help = r#"Disabled: the playspace orientation is determined by the room-scale guardian setup.
Yaw: the forward direction is reset when long pressing the oculus button.
Tilted: the world gets tilted when long pressing the oculus button. This is useful for using VR while laying down."#
))]
#[schema(flag = "real-time")]
pub rotation_recentering_mode: RotationRecenteringMode,
}
#[derive(SettingsSchema, Serialize, Deserialize, Clone)]
#[schema(gui = "button_group")]
pub enum SocketProtocol {
#[schema(strings(display_name = "UDP"))]
Udp,
#[schema(strings(display_name = "TCP"))]
Tcp,
}
#[derive(SettingsSchema, Serialize, Deserialize, Clone)]
pub struct DiscoveryConfig {
#[schema(strings(
help = "Allow untrusted clients to connect without confirmation. This is not recommended for security reasons."
))]
pub auto_trust_clients: bool,
}
#[derive(SettingsSchema, Serialize, Deserialize, Clone)]
pub enum SocketBufferSize {
Default,
Maximum,
Custom(#[schema(suffix = "B")] u32),
}
#[derive(SettingsSchema, Serialize, Deserialize, Clone)]
#[schema(collapsible)]
pub struct ConnectionConfig {
#[schema(strings(
help = r#"UDP: Faster, but less stable than TCP. Try this if your network is well optimized and free of interference.
TCP: Slower than UDP, but more stable. Pick this if you experience video or audio stutters with UDP."#
))]
pub stream_protocol: SocketProtocol,
pub client_discovery: Switch<DiscoveryConfig>,
pub stream_port: u16,
pub web_server_port: u16,
pub osc_local_port: u16,
#[schema(strings(display_name = "Streamer send buffer size"))]
pub server_send_buffer_bytes: SocketBufferSize,
#[schema(strings(display_name = "Streamer receive buffer size"))]
pub server_recv_buffer_bytes: SocketBufferSize,
#[schema(strings(display_name = "Client send buffer size"))]
pub client_send_buffer_bytes: SocketBufferSize,
#[schema(strings(display_name = "Client receive buffer size"))]
pub client_recv_buffer_bytes: SocketBufferSize,
#[schema(strings(
help = r#"The server discards video packets if it can't push them to the network.
This could happen on TCP. A IDR frame is requested in this case."#
))]
pub max_queued_server_video_frames: usize,
#[schema(strings(
help = r#"If the client, server or the network discarded one packet, discard packets until a IDR packet is found.
For now works only on Windows+Nvidia"#
))]
pub avoid_video_glitching: bool,
#[schema(strings(
help = "Reduce minimum delay between IDR keyframes from 100ms to 5ms. Use on networks with high packet loss."
))]
#[schema(flag = "steamvr-restart")]
pub aggressive_keyframe_resend: bool,
#[schema(strings(
help = "This script will be ran when the headset connects. Env var ACTION will be set to `connect`."
))]
pub on_connect_script: String,
#[schema(strings(
help = "This script will be ran when the headset disconnects, or when SteamVR shuts down. Env var ACTION will be set to `disconnect`."
))]
#[schema(flag = "real-time")]
pub on_disconnect_script: String,
#[schema(gui(slider(min = 1024, max = 65507, logarithmic)), suffix = "B")]
pub packet_size: i32,
#[schema(suffix = " frames")]
pub statistics_history_size: usize,
}
#[derive(SettingsSchema, Serialize, Deserialize, Clone)]
pub struct RawEventsConfig {
#[schema(flag = "real-time")]
pub hide_spammy_events: bool,
}
#[derive(SettingsSchema, Serialize, Deserialize, Clone)]
#[schema(collapsible)]
pub struct LoggingConfig {
pub client_log_report_level: Switch<LogSeverity>,
#[schema(strings(help = "Write logs into the session_log.txt file."))]
pub log_to_disk: bool,
#[schema(flag = "real-time")]
pub log_tracking: bool,
#[schema(flag = "real-time")]
pub log_button_presses: bool,
#[schema(flag = "real-time")]
pub log_haptics: bool,
#[schema(flag = "real-time")]
pub notification_level: LogSeverity,
#[schema(flag = "real-time")]