summaryrefslogtreecommitdiffstats
path: root/tools/ddcprobe/README
blob: bdba8f378cfe4da007d570078a416cbebe652ba4 (plain)
1
2
3
4
5
6
7
8
This is some VBE/DDC stuff.  It makes calls to the VESA extensions in the BIOS
using a slightly modified version of Josh Vanderhoof's LRMI 0.6, and generally
requires a 2.2 or newer kernel.  The idea for reading EDID data from the BIOS
came from Matt Wilson <msw@gimp.org>, as well as several ideas about better ways
to lay out data structure declarations.

Nalin Dahyabhai
bigfun@pobox.com
> 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
package interactive::stdio; # $Id$

use diagnostics;
use strict;
use vars qw(@ISA);

@ISA = qw(interactive);

use interactive;
use common;

$| = 1;

sub readln() {
    my $l = <STDIN>;
    chomp $l;
    $l;
}

sub check_it {
    my ($i, $n) = @_;
    $i =~ /^\s*\d+\s*$/ && 1 <= $i && $i <= $n;
}

sub good_choice {
    my ($def_s, $max) = @_;
    my $i;
    do {
	defined $i and print N("Bad choice, try again\n");
	print N("Your choice? (default %s) ", $def_s);
	$i = readln();
    } until !$i || check_it($i, $max);
    $i;
}

sub ask_fromW {
    my ($_o, $common, $l, $_l2) = @_;

    add2hash_($common, { ok => N("Ok"), cancel => N("Cancel") }) if !exists $common->{ok};

ask_fromW_begin:

    my $already_entries = 0;
    my $predo_widget = sub {
	my ($e) = @_;

	$e->{type} = 'list' if $e->{type} =~ /(icon|tree)list/;
	#- combo does not exist, fallback to a sensible default
	$e->{type} = $e->{not_edit} ? 'list' : 'entry' if $e->{type} eq 'combo';

	if ($e->{type} eq 'entry') {
	    my $t = "\t$e->{label} $e->{text}\n";
	    if ($already_entries) {
		length($already_entries) > 1 and print N("Entries you'll have to fill:\n%s", $already_entries);
		$already_entries = 1;
		print $t;
	    } else {
		$already_entries = $t;
	    }
	}
    };

    my @labels;
    my $format_label = sub { my ($e) = @_; return sprintf("`%s' %s %s\n", ${$e->{val}}, $e->{label}, $e->{text}) };
    my $do_widget = sub {
	my ($e, $ind) = @_;

	if ($e->{type} eq 'bool') {
	    print "$e->{text} $e->{label}\n";
	    print N("Your choice? (0/1, default `%s') ", ${$e->{val}} || '0');
	    my $i = readln();
	    if ($i) {
		to_bool($i) != to_bool(${$e->{val}}) && $e->{changed} and $e->{changed}->();
		${$e->{val}} = $i;
	    }
	} elsif ($e->{type} =~ /list/) {
	    $e->{text} || $e->{label} and print "=> $e->{label} $e->{text}\n";
	    my $n = 0; my $size = 0;
	    foreach (@{$e->{list}}) {
		$n++;
		my $t = "$n: " . may_apply($e->{format}, $_) . "\t";
		if ($size + length($t) >= 80) {
		    print "\n";
		    $size = 0;
		}
		print $t;
		$size += length($t);
	    }
	    print "\n";
	    my $i = good_choice(may_apply($e->{format}, ${$e->{val}}), $n);
	    print "Setting to <", $i ? ${$e->{list}}[$i-1] : ${$e->{val}}, ">\n";
	    if ($i) { 
		${$e->{val}} = ${$e->{list}}[$i-1];
		$e->{changed} and $e->{changed}->();
	    }
	} elsif ($e->{type} eq 'button') {
	    print N("Button `%s': %s", $e->{label}, may_apply($e->{format}, ${$e->{val}})), " $e->{text}\n";
	    print N("Do you want to click on this button?");
	    my $i = readln();
	    if ($i && $i !~ /^n/i) {
		$e->{clicked_may_quit}();
		$e->{changed} and $e->{changed}->();
	    }
	} elsif ($e->{type} eq 'label') {
	    my $t = $format_label->($e);
	    push @labels, $t;
	    print $t;
	} elsif ($e->{type} eq 'entry') {
	    print "$e->{label} $e->{text}\n";