| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
proc get_pluggable_for_connector {connector} { |
| 7 |
set t [plug $connector] |
| 8 |
return [string range $t [string first ": " $t]+2 end] |
| 9 |
} |
| 10 |
|
| 11 |
namespace eval autoplug { |
| 12 |
|
| 13 |
proc plug_if_empty {connector pluggable} { |
| 14 |
set plugged [get_pluggable_for_connector $connector] |
| 15 |
if {$plugged eq ""} { |
| 16 |
|
| 17 |
plug $connector $pluggable |
| 18 |
} |
| 19 |
} |
| 20 |
|
| 21 |
proc do_autoplug {} { |
| 22 |
|
| 23 |
|
| 24 |
|
| 25 |
if {[dict get [reverse status] status] ne "replaying"} { |
| 26 |
set connectors [list] |
| 27 |
catch { |
| 28 |
|
| 29 |
set connectors [machine_info connector] |
| 30 |
} |
| 31 |
set pluggables [list] |
| 32 |
catch { |
| 33 |
|
| 34 |
set pluggables [machine_info pluggable] |
| 35 |
} |
| 36 |
|
| 37 |
|
| 38 |
if {"cassetteport" in $connectors} { |
| 39 |
plug_if_empty cassetteport cassetteplayer |
| 40 |
} |
| 41 |
|
| 42 |
|
| 43 |
if {"joyporta" in $connectors} { |
| 44 |
plug_if_empty joyporta msxjoystick1 |
| 45 |
} |
| 46 |
if {"joyportb" in $connectors} { |
| 47 |
plug_if_empty joyportb msxjoystick2 |
| 48 |
} |
| 49 |
} |
| 50 |
after boot [namespace code do_autoplug] |
| 51 |
} |
| 52 |
|
| 53 |
}; |
| 54 |
|
| 55 |
after boot autoplug::do_autoplug |