Browse Source

Easy debugging for figuring out more keys.

Renamed config values to start upper cased, so I can access.
Steve Thielemann 3 years ago
parent
commit
90a78a1da2
3 changed files with 32 additions and 22 deletions
  1. 3 0
      .gitignore
  2. 16 16
      door/door.go
  3. 13 6
      door/input.go

+ 3 - 0
.gitignore

@@ -1 +1,4 @@
 testdoor/art.go
+testdoor/testdoor
+door32
+door32.sys

+ 16 - 16
door/door.go

@@ -57,16 +57,16 @@ g00r00                       Line 7 : User's handle/alias
 */
 
 type DropfileConfig struct {
-	comm_type      int
-	comm_handle    int
-	baudrate       int
+	Comm_type      int
+	Comm_handle    int
+	Baudrate       int
 	BBSID          string
 	User_number    int
 	Real_name      string
 	Handle         string
 	Security_level int
-	time_left      int
-	emulation      int
+	Time_left      int
+	Emulation      int
 	Node           int
 }
 
@@ -77,7 +77,7 @@ type Door struct {
 	Disconnected bool
 	TimeOut      time.Time // Fixed point in time, when time expires
 	StartTime    time.Time
-	pushback     *list.List
+	Pushback     *list.List
 }
 
 // Return the amount of time left as time.Duration
@@ -110,24 +110,24 @@ func (d *Door) ReadDropfile(filename string) {
 		lines = append(lines, line)
 	}
 
-	d.Config.comm_type, err = strconv.Atoi(lines[0])
-	d.Config.comm_handle, err = strconv.Atoi(lines[1])
-	d.Config.baudrate, err = strconv.Atoi(lines[2])
+	d.Config.Comm_type, err = strconv.Atoi(lines[0])
+	d.Config.Comm_handle, err = strconv.Atoi(lines[1])
+	d.Config.Baudrate, err = strconv.Atoi(lines[2])
 	d.Config.BBSID = lines[3]
 	d.Config.User_number, err = strconv.Atoi(lines[4])
 	d.Config.Real_name = lines[5]
 	d.Config.Handle = lines[6]
 	d.Config.Security_level, err = strconv.Atoi(lines[7])
-	d.Config.time_left, err = strconv.Atoi(lines[8])
-	d.Config.emulation, err = strconv.Atoi(lines[9])
+	d.Config.Time_left, err = strconv.Atoi(lines[8])
+	d.Config.Emulation, err = strconv.Atoi(lines[9])
 	d.Config.Node, err = strconv.Atoi(lines[10])
 
-	d.READFD = d.Config.comm_handle
-	d.WRITEFD = d.Config.comm_handle
+	d.READFD = d.Config.Comm_handle
+	d.WRITEFD = d.Config.Comm_handle
 
 	// Calculate the time when time expires.
 	d.StartTime = time.Now()
-	d.TimeOut = time.Now().Add(time.Duration(d.Config.time_left) * time.Minute)
+	d.TimeOut = time.Now().Add(time.Duration(d.Config.Time_left) * time.Minute)
 }
 
 // Detect client terminal capabilities, Unicode, CP437, Full_CP437,
@@ -204,7 +204,7 @@ func (d *Door) detect() {
 // detect terminal capabilities.
 func (d *Door) Init() {
 	var dropfile string
-	d.pushback = list.New()
+	d.Pushback = list.New()
 
 	flag.StringVar(&dropfile, "d", "", "Path to dropfile")
 	flag.Parse()
@@ -216,7 +216,7 @@ func (d *Door) Init() {
 
 	d.ReadDropfile(dropfile)
 
-	fmt.Printf("BBS %s, User %s / Handle %s / File %d\n", d.Config.BBSID, d.Config.Real_name, d.Config.Handle, d.Config.comm_handle)
+	fmt.Printf("BBS %s, User %s / Handle %s / File %d\n", d.Config.BBSID, d.Config.Real_name, d.Config.Handle, d.Config.Comm_handle)
 	d.detect()
 }
 

+ 13 - 6
door/input.go

@@ -110,12 +110,19 @@ func (d *Door) getch() int {
 }
 
 func (d *Door) getkey_or_pushback() int {
-	if d.pushback.Len() != 0 {
-		e := d.pushback.Front()
-		d.pushback.Remove(e)
+	if d.Pushback.Len() != 0 {
+		e := d.Pushback.Front()
+		d.Pushback.Remove(e)
 		return e.Value.(int)
 	}
-	return d.getch()
+
+	if false {
+		key := d.getch()
+		fmt.Printf("%d / %X\n", key, key)
+		return key
+	} else {
+		return d.getch()
+	}
 }
 
 // Return key received, or XKEY_* values.
@@ -145,7 +152,7 @@ func (d *Door) GetKey() int {
 			// wasn't an error
 			if c2 != 0x00 && c2 != 0x0a {
 				// wasn't 0x00 or 0x0a
-				d.pushback.PushFront(c2)
+				d.Pushback.PushFront(c2)
 			}
 		}
 		return c
@@ -228,7 +235,7 @@ func (d *Door) GetKey() int {
 		c2 = d.getkey_or_pushback()
 		for c2 > 0 {
 			if c2 == 0x1b {
-				d.pushback.PushBack(c2)
+				d.Pushback.PushBack(c2)
 				break
 			}
 			extended += string(c2)