Permalink
Browse files

Remap ^M to ^J

OS X's Terminal.app emits ^M from return, but dcpu programs expect ^J.
  • Loading branch information...
1 parent 8303cca commit d1e613073a6e6a44390845594833b52041d8bae7 @kballard committed Apr 18, 2012
Showing with 9 additions and 4 deletions.
  1. +9 −0 dcpu/keyboard.go
  2. +0 −4 main.go
View
@@ -62,7 +62,16 @@ func (k *Keyboard) UnmapFromMachine(offset core.Word, m *Machine) error {
return nil
}
+var remapMap map[rune]rune = map[rune]rune{
+ '\x7F': '\x08', // fix delete on OS X
+ '\x0D': '\x0A', // fix return on OS X
+}
+
func (k *Keyboard) RegisterKey(key rune) {
+ // process any remappings first
+ if k2, ok := remapMap[key]; ok {
+ key = k2
+ }
select {
case k.input <- key:
default:
View
@@ -72,11 +72,7 @@ func main() {
// else pass it to the keyboard
if evt.Ch == 0 {
// it's a key constant
- // We need to fold Backspace2 down into Backspace
key := evt.Key
- if key == termbox.KeyBackspace2 {
- key = termbox.KeyBackspace
- }
machine.Keyboard.RegisterKey(rune(key))
} else {
machine.Keyboard.RegisterKey(evt.Ch)

0 comments on commit d1e6130

Please sign in to comment.