S26recalboxsystem 4.63 KB
Newer Older
1 2
#!/bin/bash

3
systemsetting="recalbox_settings"
4
config_script=/recalbox/scripts/recalbox-config.sh
5

6 7 8
rb_volume_configure() {
    settingsVolume="`$systemsetting -command load -key audio.volume`"
    if [ "$settingsVolume" != "" ];then
9
        recallog "setting audio volume to $settingsVolume"
10
        eval $config_script "volume" "$settingsVolume" 2>&1 | recallog
11 12
    fi
}
13

14
rb_audio_configure() {
Bkg2k's avatar
Bkg2k committed
15
    recallog "Restoring audio configuration"
16 17 18 19 20
    settingsAudio="`$systemsetting -command load -key audio.device`"
    if [[ "$settingsAudio" == "" ]];then
        settingsAudio="auto"
    fi
    recallog "setting audio to $settingsAudio"
21
    eval $config_script "audio" "$settingsAudio" 2>&1 | recallog
22
}
23

24 25 26
rb_gpio_configure() {
    settings_gpio_mk="`$systemsetting -command load -key controllers.gpio.enabled`"
    if [ "$settings_gpio_mk" == "1" ];then
27 28 29
        settings_gpio_map="`$systemsetting -command load -key controllers.gpio.args`"
        [ "$settings_gpio_map" == "" ] && settings_gpio_map="map=1,2"
        recallog "enabling mk_arcade_joystick_rpi"
30
        eval $config_script "module" "load" mk_arcade_joystick_rpi "$settings_gpio_map" 2>&1 | recallog
31
    else
32 33 34 35 36 37 38 39
        # mk disabled let's check for db9
        settings_db9="`$systemsetting -command load -key controllers.db9.enabled`"
        if [ "$settings_db9" == "1" ];then
                settings_db9_map="`$systemsetting -command load -key controllers.db9.args`"
                recallog "enabling db9"
                eval $config_script "module" "load" db9_gpio_rpi "$settings_db9_map" 2>&1 | recallog
        else 
            # db9 and mk disabled let's check for gamecon
40 41 42 43
            settings_gamecon="`$systemsetting -command load -key controllers.gamecon.enabled`"
            if [ "$settings_gamecon" == "1" ];then
                settings_gamecon_map="`$systemsetting -command load -key controllers.gamecon.args`"
                recallog "enabling gamecon"
44
                eval $config_script "module" "load" gamecon_gpio_rpi "$settings_gamecon_map" 2>&1 | recallog
45 46
            fi
        fi
47 48
    fi
}
49

50 51 52 53 54
rb_keyboad_lang() {
    settings_lang="`$systemsetting -command load -key system.language`"
    settings_kb="`$systemsetting -command load -key system.kblayout`"
    if [[ "$settings_kb" != "" ]];then
        recallog "setting keyboard layout to ${settings_kb}"
55
        loadkeys "$settings_kb" 2>&1 | recallog
56 57
    else
        keyboardmap=`echo "$settings_lang" | cut -c1-2`
58
        if [[ "$keyboardmap" != "" ]]; then
59
            recallog "setting keyboard layout to ${keyboardmap}"
60
            loadkeys "$keyboardmap" 2>&1 | recallog
61
        fi
62 63
    fi
}
64

65 66
rb_timezone() {
    settings_timezone="`$systemsetting -command load -key system.timezone`"
Subs's avatar
Subs committed
67
    [[ -z $settings_timezone ]] && settings_timezone="Europe/Paris"
68 69
    if [[ "$settings_timezone" != "" && -f "/usr/share/zoneinfo/$settings_timezone" ]];then
        recallog "setting timezone to $settings_timezone"
Subs's avatar
Subs committed
70 71
        echo "$settings_timezone" > /var/timezone
        ln -sf "/usr/share/zoneinfo/$settings_timezone" /var/localtime
72 73 74 75 76 77 78 79 80 81 82
    fi
}

rb_hostname() {
    settings_hostname="`$systemsetting -command load -key system.hostname`"
    if [[ "$settings_hostname" != "" ]];then
        recallog "setting hostname to $settings_hostname"
        hostname "$settings_hostname"
    fi
}

Subs's avatar
Subs committed
83 84 85 86
rb_xarcade2jstick() {
    settings_xarcade="`$systemsetting -command load -key controllers.xarcade.enabled`"
    if [[ "$settings_xarcade" == "1" ]];then
        recallog "starting xarcade2jstick"
87 88 89 90 91 92 93 94 95 96 97 98
        # First try : suppose a real X-Arcade is plugged
        /usr/bin/xarcade2jstick -d
        if [ $? -ne "0" ]
        then
            # the user must have a keyboard encoder then
            recallog "xarcade2jstick : no official stick found, looking for keyboard encoder now ..."
            for dev in /recalbox/share_init/system/configs/xarcade2jstick/*
            do
                dev=$(basename "$dev")
                [ -h "/dev/input/by-id/$dev" ] && recallog "xarcade2jstick : Found $dev ! Starting xarcade2jstick ..." && /usr/bin/xarcade2jstick -d -e "/dev/input/by-id/$dev" && break
            done
        fi
Subs's avatar
Subs committed
99 100 101
    fi
}

102 103
case "$1" in
  start)
104
    recallog "starting new log"
105

106 107 108 109 110 111 112
    # Dos carriage return characters
    recallog "converting dos to unix carriage return characters"
    sed -i 's/\r//g' /recalbox/share/system/recalbox.conf
    
    # configure
    rb_gpio_configure&    # 0.9 start by the gpio while it's the longer
    rb_keyboad_lang&      # 0.7
OyyoDams's avatar
OyyoDams committed
113

114
#    ( rb_volume_configure ; rb_audio_configure ) &  # 1.0
115 116 117 118 119
    rb_timezone&          # 0.4
    rb_hostname&          # 0.4
    wait
    ( sleep 8 ; rb_xarcade2jstick ) &    # 0.1
    ;;
120
  stop)
121
    ;;
122
  restart|reload)
123
    ;;
124 125 126 127
  *)
esac

exit $?