@@ -28,6 +28,8 @@ import { useRevalidator } from "react-router-dom";
28
28
import { ShieldCheckIcon } from "@heroicons/react/20/solid" ;
29
29
import PluginList from "@components/PluginList" ;
30
30
import USBConfigDialog from "@components/USBConfigDialog" ;
31
+ import { keyboardMappingsStore } from "@/keyboardMappings/KeyboardMappingStore" ;
32
+ import { KeyboardLayout } from "@/keyboardMappings/KeyboardLayouts" ;
31
33
32
34
export function SettingsItem ( {
33
35
title,
@@ -80,6 +82,7 @@ export default function SettingsSidebar() {
80
82
const setSidebarView = useUiStore ( state => state . setSidebarView ) ;
81
83
const settings = useSettingsStore ( ) ;
82
84
const [ send ] = useJsonRpc ( ) ;
85
+ const [ keyboardLayout , setKeyboardLayout ] = useState ( "us" ) ;
83
86
const [ streamQuality , setStreamQuality ] = useState ( "1" ) ;
84
87
const [ autoUpdate , setAutoUpdate ] = useState ( true ) ;
85
88
const [ devChannel , setDevChannel ] = useState ( false ) ;
@@ -150,6 +153,20 @@ export default function SettingsSidebar() {
150
153
} ) ;
151
154
} ;
152
155
156
+ const handleKeyboardLayoutChange = ( keyboardLayout : string ) => {
157
+ send ( "setKeyboardLayout" , { kbLayout : keyboardLayout } , resp => {
158
+ if ( "error" in resp ) {
159
+ notifications . error (
160
+ `Failed to set keyboard layout: ${ resp . error . data || "Unknown error" } ` ,
161
+ ) ;
162
+ return ;
163
+ }
164
+ // TODO set this to update to the actual layout chosen
165
+ keyboardMappingsStore . setLayout ( KeyboardLayout . UKApple )
166
+ setKeyboardLayout ( keyboardLayout ) ;
167
+ } ) ;
168
+ } ;
169
+
153
170
const handleStreamQualityChange = ( factor : string ) => {
154
171
send ( "setStreamQualityFactor" , { factor : Number ( factor ) } , resp => {
155
172
if ( "error" in resp ) {
@@ -300,6 +317,11 @@ export default function SettingsSidebar() {
300
317
setDevChannel ( resp . result as boolean ) ;
301
318
} ) ;
302
319
320
+ send ( "getKeyboardLayout" , { } , resp => {
321
+ if ( "error" in resp ) return ;
322
+ setKeyboardLayout ( String ( resp . result ) ) ;
323
+ } ) ;
324
+
303
325
send ( "getStreamQualityFactor" , { } , resp => {
304
326
if ( "error" in resp ) return ;
305
327
setStreamQuality ( String ( resp . result ) ) ;
@@ -556,6 +578,33 @@ export default function SettingsSidebar() {
556
578
</ div >
557
579
</ div >
558
580
< div className = "h-[1px] w-full bg-slate-800/10 dark:bg-slate-300/20" />
581
+ < div className = "pb-2 space-y-4" >
582
+ < SectionHeader
583
+ title = "Keyboard"
584
+ description = "Customize keyboard behaviour"
585
+ />
586
+ < div className = "space-y-4" >
587
+ < SettingsItem
588
+ title = "Keyboard Layout"
589
+ description = "Set keyboard layout (this should match the target machine)"
590
+ >
591
+ < SelectMenuBasic
592
+ size = "SM"
593
+ label = ""
594
+ // TODO figure out how to make this selector wider like the EDID one?
595
+ //fullWidth
596
+ value = { keyboardLayout }
597
+ options = { [
598
+ { value : "uk" , label : "GB" } ,
599
+ { value : "uk_apple" , label : "GB Apple" } ,
600
+ { value : "us" , label : "US" } ,
601
+ ] }
602
+ onChange = { e => handleKeyboardLayoutChange ( e . target . value ) }
603
+ />
604
+ </ SettingsItem >
605
+ </ div >
606
+ </ div >
607
+ < div className = "h-[1px] w-full bg-slate-800/10 dark:bg-slate-300/20" />
559
608
< div className = "pb-2 space-y-4" >
560
609
< SectionHeader
561
610
title = "Video"
0 commit comments