And now with more buttons
Build and Test a3270 / Build Android APK (push) Successful in 7m2s

This commit is contained in:
2026-08-28 14:17:25 -04:00
parent 18c4203c0d
commit 600b626e94
3 changed files with 89 additions and 8 deletions
@@ -298,7 +298,12 @@ class MainActivity : ComponentActivity() {
return true return true
} }
KeyEvent.KEYCODE_ENTER, KeyEvent.KEYCODE_NUMPAD_ENTER -> { KeyEvent.KEYCODE_ENTER, KeyEvent.KEYCODE_NUMPAD_ENTER -> {
viewModel.sendAid(AID_ENTER) if (shift) {
viewModel.eraseEof()
isShiftPressedState.value = false
} else {
viewModel.sendAid(AID_ENTER)
}
return true return true
} }
KeyEvent.KEYCODE_TAB -> { KeyEvent.KEYCODE_TAB -> {
@@ -320,7 +325,7 @@ class MainActivity : ComponentActivity() {
} }
KeyEvent.KEYCODE_ESCAPE -> { KeyEvent.KEYCODE_ESCAPE -> {
if (shift) { if (shift) {
viewModel.sendAid(AID_CLEAR) viewModel.eraseInput()
isShiftPressedState.value = false isShiftPressedState.value = false
} else { } else {
viewModel.resetKeyboard() viewModel.resetKeyboard()
@@ -577,6 +582,10 @@ fun MainScreen(
viewModel.eraseInput() viewModel.eraseInput()
terminalInputViewRef?.showSoftKeyboard() terminalInputViewRef?.showSoftKeyboard()
}, },
onEraseEof = {
viewModel.eraseEof()
terminalInputViewRef?.showSoftKeyboard()
},
onAttn = { onAttn = {
viewModel.sendAid(AID_PA1) viewModel.sendAid(AID_PA1)
terminalInputViewRef?.showSoftKeyboard() terminalInputViewRef?.showSoftKeyboard()
@@ -40,6 +40,7 @@ fun TwoRowKeyBar(
onTab: () -> Unit, onTab: () -> Unit,
onBackTab: () -> Unit, onBackTab: () -> Unit,
onEraseInput: () -> Unit = {}, onEraseInput: () -> Unit = {},
onEraseEof: () -> Unit = {},
onAttn: () -> Unit = {}, onAttn: () -> Unit = {},
onSysReq: () -> Unit = {}, onSysReq: () -> Unit = {},
onCursorSelect: () -> Unit = {}, onCursorSelect: () -> Unit = {},
@@ -219,14 +220,59 @@ fun TwoRowKeyBar(
} }
) )
// 3. RESET // 3. RESET / ERASE (Erase Input) depending on Shift state
KeyButton("RESET", Color(0xFFE67700), modifier = Modifier.weight(1f), hapticFeedbackEnabled = hapticFeedbackEnabled, innerPaddingHorizontal = 0.dp, onClick = onReset) val resetLabel = if (isShiftPressed) "ERASE" else "RESET"
KeyButton(
label = resetLabel,
color = Color(0xFFE67700),
modifier = Modifier.weight(1f),
hapticFeedbackEnabled = hapticFeedbackEnabled,
innerPaddingHorizontal = 0.dp,
onClick = {
if (isShiftPressed) {
onEraseInput()
onClearShift()
} else {
onReset()
}
}
)
// 4. ENTER // 4. ENTER / EOF (Erase EOF) depending on Shift state
KeyButton("ENTER", Color(0xFF2B8A3E), modifier = Modifier.weight(1f), hapticFeedbackEnabled = hapticFeedbackEnabled, innerPaddingHorizontal = 0.dp, onClick = { onSendAid(AID_ENTER) }) val enterLabel = if (isShiftPressed) "EOF" else "ENTER"
KeyButton(
label = enterLabel,
color = Color(0xFF2B8A3E),
modifier = Modifier.weight(1f),
hapticFeedbackEnabled = hapticFeedbackEnabled,
innerPaddingHorizontal = 0.dp,
onClick = {
if (isShiftPressed) {
onEraseEof()
onClearShift()
} else {
onSendAid(AID_ENTER)
}
}
)
// 5. CLEAR // 5. CLEAR / ATTN (Attention) depending on Shift state
KeyButton("CLEAR", Color(0xFFC92A2A), modifier = Modifier.weight(1f), hapticFeedbackEnabled = hapticFeedbackEnabled, innerPaddingHorizontal = 0.dp, onClick = { onSendAid(AID_CLEAR) }) val clearLabel = if (isShiftPressed) "ATTN" else "CLEAR"
KeyButton(
label = clearLabel,
color = Color(0xFFC92A2A),
modifier = Modifier.weight(1f),
hapticFeedbackEnabled = hapticFeedbackEnabled,
innerPaddingHorizontal = 0.dp,
onClick = {
if (isShiftPressed) {
onAttn()
onClearShift()
} else {
onSendAid(AID_CLEAR)
}
}
)
// 6. PA1 // 6. PA1
KeyButton("PA1", Color(0xFF495057), modifier = Modifier.weight(1f), hapticFeedbackEnabled = hapticFeedbackEnabled, innerPaddingHorizontal = 0.dp, onClick = { onSendAid(AID_PA1) }) KeyButton("PA1", Color(0xFF495057), modifier = Modifier.weight(1f), hapticFeedbackEnabled = hapticFeedbackEnabled, innerPaddingHorizontal = 0.dp, onClick = { onSendAid(AID_PA1) })
@@ -212,4 +212,30 @@ class HardwareKeyboardInputTest {
assertTrue(result) assertTrue(result)
assertEquals(AID_ENTER, inputProcessor.lastAid) assertEquals(AID_ENTER, inputProcessor.lastAid)
} }
@Test
fun testEraseInputAndAttention() {
// Position 0: Unprotected FA
screenBuffer.setCellFA(0, (FA_PRINTABLE or FA_MODIFY).toByte())
// Position 10: Protected FA
screenBuffer.setCellFA(10, (FA_PRINTABLE or FA_PROTECT).toByte())
// Position 20: Unprotected FA
screenBuffer.setCellFA(20, (FA_PRINTABLE or FA_MODIFY).toByte())
screenBuffer.getCell(1).ucs4 = 'X'
screenBuffer.getCell(1).ec = translator.unicodeToEbcdic('X').toByte()
screenBuffer.getCell(21).ucs4 = 'Y'
screenBuffer.getCell(21).ec = translator.unicodeToEbcdic('Y').toByte()
inputProcessor.eraseInput()
// Unprotected fields should be cleared and reset
assertEquals(0, screenBuffer.getCell(1).ec.toInt())
assertEquals(0, screenBuffer.getCell(21).ec.toInt())
assertEquals(1, screenBuffer.cursorAddress)
// Attention AID
inputProcessor.sendAid(AID_PA1)
assertEquals(AID_PA1, inputProcessor.lastAid)
}
} }