blob: 0fd26806e29898c61558e2d54ec578347c522889 [file] [log] [blame]
From 099fb457585e4e4b4ed0e290255ea3ea3abbcfa6 Mon Sep 17 00:00:00 2001
From: Dave Mielke <dave@mielke.cc>
Date: Mon, 31 Oct 2016 20:57:02 -0400
Subject: [PATCH 6/7] A bit of retain chords code cleanup. (dm)
---
Programs/ktb_translate.c | 18 ++++++++----------
1 file changed, 8 insertions(+), 10 deletions(-)
diff --git a/Programs/ktb_translate.c b/Programs/ktb_translate.c
index 52de1ca..1ed58c3 100644
--- a/Programs/ktb_translate.c
+++ b/Programs/ktb_translate.c
@@ -206,33 +206,31 @@ makeKeyboardCommand (KeyTable *table, unsigned char context, int allowChords) {
const KeyContext *ctx;
if ((ctx = getKeyContext(table, context))) {
- int keyboardCommand = 0;
+ int bits = 0;
for (unsigned int pressedIndex=0; pressedIndex<table->pressedKeys.count; pressedIndex+=1) {
const KeyValue *keyValue = &table->pressedKeys.table[pressedIndex];
const MappedKeyEntry *map = findMappedKeyEntry(ctx, keyValue);
if (!map) return EOF;
- keyboardCommand |= map->keyboardFunction->bit;
+ bits |= map->keyboardFunction->bit;
}
{
- int space = keyboardCommand & BRL_DOTC;
- int dots = keyboardCommand & (
+ int space = bits & BRL_DOTC;
+ int dots = bits & (
BRL_DOT1 | BRL_DOT2 | BRL_DOT3 | BRL_DOT4 |
BRL_DOT5 | BRL_DOT6 | BRL_DOT7 | BRL_DOT8
);
- if (!(allowChords && ((space | dots) == keyboardCommand))) {
+ if (!(allowChords && ((space | dots) == bits))) {
if (!space == !dots) return EOF;
- if (dots) keyboardCommand |= ctx->mappedKeys.superimpose;
- keyboardCommand &= ~BRL_DOTC;
+ if (dots) bits |= ctx->mappedKeys.superimpose;
+ bits &= ~BRL_DOTC;
}
-
- keyboardCommand |= BRL_CMD_BLK(PASSDOTS);
}
- return keyboardCommand;
+ return BRL_CMD_BLK(PASSDOTS) | bits;
}
return EOF;
--
2.8.0.rc3.226.g39d4020