comparison src/com/five_ten_sg/connectbot/transport/TN5250.java @ 50:2cd3d8091e37 tn5250

start tn5250 integration
author Carl Byington <carl@five-ten-sg.com>
date Wed, 11 Jun 2014 11:50:25 -0700
parents 8887bff45dee
children 8c6de858bb73
comparison
equal deleted inserted replaced
49:8887bff45dee 50:2cd3d8091e37
36 import com.five_ten_sg.connectbot.bean.PortForwardBean; 36 import com.five_ten_sg.connectbot.bean.PortForwardBean;
37 import com.five_ten_sg.connectbot.service.TerminalBridge; 37 import com.five_ten_sg.connectbot.service.TerminalBridge;
38 import com.five_ten_sg.connectbot.service.TerminalKeyListener; 38 import com.five_ten_sg.connectbot.service.TerminalKeyListener;
39 import com.five_ten_sg.connectbot.service.TerminalManager; 39 import com.five_ten_sg.connectbot.service.TerminalManager;
40 import com.five_ten_sg.connectbot.util.HostDatabase; 40 import com.five_ten_sg.connectbot.util.HostDatabase;
41 import com.five_ten_sg.connectbot.util.PreferenceConstants;
41 import android.content.Context; 42 import android.content.Context;
42 import android.net.Uri; 43 import android.net.Uri;
43 import android.util.Log; 44 import android.util.Log;
45 import android.view.KeyEvent;
46 import android.view.View;
44 import de.mud.terminal.vt320; 47 import de.mud.terminal.vt320;
45 48
46 49
47 /** 50 /**
48 * @author Carl Byington 51 * @author Carl Byington
73 public void write(byte[] b) { 76 public void write(byte[] b) {
74 screen52.sendKeys(new String(b)); 77 screen52.sendKeys(new String(b));
75 } 78 }
76 @Override 79 @Override
77 public void write(int b) { 80 public void write(int b) {
78 screen52.sendKeys(new String(new byte[] {b})); 81 screen52.sendKeys(new String(new byte[] {(byte)b}));
79 } 82 }
80 // bridge.monitor placement of new characters 83 // bridge.monitor placement of new characters
81 @Override 84 @Override
82 public void putChar(int c, int l, char ch, int attributes) { 85 public void putChar(int c, int l, char ch, int attributes) {
83 if (bridge.monitor != null) bridge.monitor.screenChanged(l, c); 86 if (bridge.monitor != null) bridge.monitor.screenChanged(l, c);
104 * Modify the keys to make more sense to a host then pass it to the 5250. 107 * Modify the keys to make more sense to a host then pass it to the 5250.
105 */ 108 */
106 public boolean onKey(View v, int keyCode, KeyEvent event) { 109 public boolean onKey(View v, int keyCode, KeyEvent event) {
107 try { 110 try {
108 // skip keys if we aren't connected yet or have been disconnected 111 // skip keys if we aren't connected yet or have been disconnected
109 if (bridge.isDisconnected() || bridge.transport == null) 112 if (bridge.isDisconnected()) return false;
110 return false;
111
112 final boolean hardKeyboardHidden = manager.hardKeyboardHidden;
113 113
114 // Ignore all key-up events except for the special keys 114 // Ignore all key-up events except for the special keys
115 if (event.getAction() == KeyEvent.ACTION_UP) { 115 if (event.getAction() == KeyEvent.ACTION_UP) {
116 // There's nothing here for virtual keyboard users. 116 // There's nothing here for virtual keyboard users.
117 if (!hardKeyboard || (hardKeyboard && hardKeyboardHidden)) 117 if (!hardKeyboard || hardKeyboardHidden) return false;
118 return false;
119 118
120 // if keycode debugging enabled, log and print the pressed key 119 // if keycode debugging enabled, log and print the pressed key
121 if (prefs.getBoolean(PreferenceConstants.DEBUG_KEYCODES, false)) { 120 if (prefs.getBoolean(PreferenceConstants.DEBUG_KEYCODES, false)) {
122 String keyCodeString = String.format(": %d", keyCode); 121 String keyCodeString = String.format(": %d", keyCode);
123 String toastText = v.getContext().getString(R.string.keycode_pressed) + keyCodeString; 122 String toastText = v.getContext().getString(R.string.keycode_pressed) + keyCodeString;
253 metaState &= ~META_CTRL_ON; 252 metaState &= ~META_CTRL_ON;
254 bridge.redraw(); 253 bridge.redraw();
255 254
256 // If there is no hard keyboard or there is a hard keyboard currently hidden, 255 // If there is no hard keyboard or there is a hard keyboard currently hidden,
257 // CTRL-1 through CTRL-9 will send F1 through F9 256 // CTRL-1 through CTRL-9 will send F1 through F9
258 if ((!hardKeyboard || (hardKeyboard && hardKeyboardHidden)) 257 if ((!hardKeyboard || hardKeyboardHidden) && sendFunctionKey(keyCode))
259 && sendFunctionKey(keyCode))
260 return true; 258 return true;
261 259
262 uchar = keyAsControl(uchar); 260 uchar = keyAsControl(uchar);
263 } 261 }
264 262