@@ -28,6 +28,8 @@ import { useRevalidator } from "react-router-dom";
2828import { ShieldCheckIcon } from "@heroicons/react/20/solid" ;
2929import PluginList from "@components/PluginList" ;
3030import USBConfigDialog from "@components/USBConfigDialog" ;
31+ import { keyboardMappingsStore } from "@/keyboardMappings/KeyboardMappingStore" ;
32+ import { KeyboardLayout } from "@/keyboardMappings/KeyboardLayouts" ;
3133
3234export function SettingsItem ( {
3335 title,
@@ -80,6 +82,7 @@ export default function SettingsSidebar() {
8082 const setSidebarView = useUiStore ( state => state . setSidebarView ) ;
8183 const settings = useSettingsStore ( ) ;
8284 const [ send ] = useJsonRpc ( ) ;
85+ const [ keyboardLayout , setKeyboardLayout ] = useState ( "us" ) ;
8386 const [ streamQuality , setStreamQuality ] = useState ( "1" ) ;
8487 const [ autoUpdate , setAutoUpdate ] = useState ( true ) ;
8588 const [ devChannel , setDevChannel ] = useState ( false ) ;
@@ -150,6 +153,20 @@ export default function SettingsSidebar() {
150153 } ) ;
151154 } ;
152155
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+
153170 const handleStreamQualityChange = ( factor : string ) => {
154171 send ( "setStreamQualityFactor" , { factor : Number ( factor ) } , resp => {
155172 if ( "error" in resp ) {
@@ -300,6 +317,11 @@ export default function SettingsSidebar() {
300317 setDevChannel ( resp . result as boolean ) ;
301318 } ) ;
302319
320+ send ( "getKeyboardLayout" , { } , resp => {
321+ if ( "error" in resp ) return ;
322+ setKeyboardLayout ( String ( resp . result ) ) ;
323+ } ) ;
324+
303325 send ( "getStreamQualityFactor" , { } , resp => {
304326 if ( "error" in resp ) return ;
305327 setStreamQuality ( String ( resp . result ) ) ;
@@ -556,6 +578,33 @@ export default function SettingsSidebar() {
556578 </ div >
557579 </ div >
558580 < 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" />
559608 < div className = "pb-2 space-y-4" >
560609 < SectionHeader
561610 title = "Video"
0 commit comments