-
Notifications
You must be signed in to change notification settings - Fork 0
/
keyb_handler.rb
executable file
·46 lines (38 loc) · 961 Bytes
/
keyb_handler.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
class KeyboardHandler
def initialize(io)
@io = io
end
def read_data
multi_bytes = @io.bytes.each do |i|
i.to_s(16)
end
end
def run
loop do
character = @io.getbytes.to_s(16)
#multi_bytes = @io.bytes.each {|i| i.to_s(16) }
case character
when "11" #C-q KeyCombo
@io.print "\x8\x8"
@io.print "\nShorel 'aran\n"
$monkserver.stop
when "41" #"A" Character
@io.print "\x8"
@io.print "B"
#@io.print "\x1b\x238" #Repeat E on screen
when "8" #"C-h" combination keypress
@io.print "\x8\x8"
@io.puts "Help commands : blah..blah.."
@io.print "\n~> "
when "7f" #Backspace
@io.print "\x8\x8\x8"
else
#character = @io.bytes.each {|i| i.to_s(16) }
#case multi_character
# when "1b5b337e"
#@io.print read_data
@io.print character + "-"
end
end
end
end