summaryrefslogtreecommitdiff
Side-by-side diff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--inputmethods/multikey/keyboard.cpp148
-rw-r--r--inputmethods/multikey/keyboard.h6
2 files changed, 153 insertions, 1 deletions
diff --git a/inputmethods/multikey/keyboard.cpp b/inputmethods/multikey/keyboard.cpp
index 28d5cab..1dd8ca1 100644
--- a/inputmethods/multikey/keyboard.cpp
+++ b/inputmethods/multikey/keyboard.cpp
@@ -38,13 +38,13 @@
#include <sys/utsname.h>
/* Keyboard::Keyboard {{{1 */
Keyboard::Keyboard(QWidget* parent, const char* _name, WFlags f) :
QFrame(parent, _name, f), shift(0), lock(0), ctrl(0), alt(0),
- meta(0), circumflex(0), diaeresis(0),
+ meta(0), circumflex(0), diaeresis(0), baccent(0), accent(0),
useLargeKeys(TRUE), usePicks(0), useRepeat(0),
pressedKeyRow(-1), pressedKeyCol(-1),
unicode(-1), qkeycode(0), modifiers(0), schar(0), mchar(0), echar(0),
configdlg(0)
{
@@ -187,21 +187,29 @@ void Keyboard::drawKeyboard(QPainter &p, int row, int col)
if ((shift || lock) && keys->shift(c))
if (circumflex && keys->circumflex(keys->shift(c)))
c = keys->circumflex(keys->shift(c));
else if (diaeresis && keys->diaeresis(keys->shift(c)))
c = keys->diaeresis(keys->shift(c));
+ else if (baccent && keys->baccent(keys->shift(c)))
+ c = keys->baccent(keys->shift(c));
+ else if (accent && keys->accent(keys->shift(c)))
+ c = keys->accent(keys->shift(c));
else if (meta && keys->meta(keys->shift(c)))
c = keys->meta(keys->shift(c));
else
c = keys->shift(c);
else if (meta && keys->meta(c))
c = keys->meta(c);
else if (circumflex && keys->circumflex(c))
c = keys->circumflex(c);
+ else if (baccent && keys->baccent(c))
+ c = keys->baccent(c);
+ else if (accent && keys->accent(c))
+ c = keys->accent(c);
else if (diaeresis && (keys->diaeresis(c) || c == 0x2c6)) {
// the diaeresis key itself has to be in the diaeresisMap,
// or just do this to make it display the diaeresis char.
if (c == 0x2c6)
@@ -257,21 +265,29 @@ void Keyboard::drawKeyboard(QPainter &p, int row, int col)
if ((shift || lock) && keys->shift(c))
if (circumflex && keys->circumflex(keys->shift(c)))
c = keys->circumflex(keys->shift(c));
else if (diaeresis && keys->diaeresis(keys->shift(c)))
c = keys->diaeresis(keys->shift(c));
+ else if (baccent && keys->baccent(keys->shift(c)))
+ c = keys->baccent(keys->shift(c));
+ else if (accent && keys->accent(keys->shift(c)))
+ c = keys->accent(keys->shift(c));
else if (meta && keys->meta(keys->shift(c)))
c = keys->meta(keys->shift(c));
else
c = keys->shift(c);
else if (meta && keys->meta(c))
c = keys->meta(c);
else if (circumflex && keys->circumflex(c))
c = keys->circumflex(c);
+ else if (baccent && keys->baccent(c))
+ c = keys->baccent(c);
+ else if (accent && keys->accent(c))
+ c = keys->accent(c);
else if (diaeresis && (keys->diaeresis(c) || c == 0x2c6)) {
if (c == 0x2c6)
c = 0xa8;
else
c = keys->diaeresis(c);
@@ -343,12 +359,47 @@ void Keyboard::mousePressEvent(QMouseEvent *e)
// circumflex
qkeycode = 0x2000;
}
}
+ // Back accent character support
+
+ if (unicode == 0x60) {
+
+ unicode = 0;
+ if (shift || lock) {
+
+ // circumblex
+ qkeycode = 0x2000;
+ }
+ else {
+
+ // back accent
+ qkeycode = 0x2002;
+ }
+ }
+
+ // Accent character support
+
+ if (unicode == 0xb4) {
+
+ unicode = 0;
+ if (shift || lock) {
+
+ // diaeresis
+ qkeycode = 0x2001;
+ }
+ else {
+
+ // accent
+ qkeycode = 0x2003;
+ }
+ }
+
+
if (unicode == 0) { // either Qt char, or nothing
if (qkeycode == Qt::Key_F1) { // toggle the pickboard
if ( configdlg ) {
@@ -469,12 +520,14 @@ void Keyboard::mousePressEvent(QMouseEvent *e)
// reset all the other keys
if (shift) { *shift = 0; shift = 0; }
if (lock) { *lock = 0; lock = 0; }
if (circumflex) { *circumflex = 0; circumflex = 0; }
if (diaeresis) { *diaeresis = 0; diaeresis = 0; }
+ if (baccent) { *baccent = 0; baccent = 0; }
+ if (accent) { *accent = 0; accent = 0; }
// dont need to emit this key... acts same as alt
qkeycode = 0;
// circumflex
} else if (qkeycode == 0x2000) {
@@ -548,12 +601,56 @@ void Keyboard::mousePressEvent(QMouseEvent *e)
circumflex = 0;
}
qkeycode = 0;
+
+ // Back accent
+ } else if (qkeycode == 0x2002) {
+ need_repaint = TRUE;
+
+ if (baccent) {
+
+ *baccent = 0;
+ baccent = 0;
+
+ } else {
+
+ baccent = keys->pressedPtr(row, col);
+ *baccent = true;
+ }
+
+
+ if (shift) { *shift = 0; shift = 0; }
+ if (meta) { *meta = 0; meta = 0; }
+ if (accent) { *accent = 0; accent = 0; }
+
+ qkeycode = 0;
+
+ // Accent
+ } else if (qkeycode == 0x2003) {
+ need_repaint = TRUE;
+
+ if (accent) {
+
+ *accent = 0;
+ accent = 0;
+
+ } else {
+
+ accent = keys->pressedPtr(row, col);
+ *accent = true;
+ }
+
+
+ if (shift) { *shift = 0; shift = 0; }
+ if (meta) { *meta = 0; meta = 0; }
+ if (baccent) { *baccent = 0; }
+
+ qkeycode = 0;
}
}
else { // normal char
if ((shift || lock) && keys->shift(unicode)) {
@@ -561,12 +658,16 @@ void Keyboard::mousePressEvent(QMouseEvent *e)
// diaeresis/circumflex chars
if (circumflex && keys->circumflex(keys->shift(unicode)))
unicode = keys->circumflex(keys->shift(unicode));
else if (diaeresis && keys->diaeresis(keys->shift(unicode)))
unicode = keys->diaeresis(keys->shift(unicode));
+ else if (baccent && keys->baccent(keys->shift(unicode)))
+ unicode = keys->baccent(keys->shift(unicode));
+ else if (accent && keys->accent(keys->shift(unicode)))
+ unicode = keys->accent(keys->shift(unicode));
else if (meta && keys->meta(keys->shift(unicode)))
unicode = keys->meta(keys->shift(unicode));
else
unicode = keys->shift(unicode);
}
else if (meta && keys->meta(unicode)) {
@@ -576,12 +677,18 @@ void Keyboard::mousePressEvent(QMouseEvent *e)
unicode = keys->circumflex(unicode);
}
else if (diaeresis && keys->diaeresis(unicode)) {
unicode = keys->diaeresis(unicode);
}
+ else if (baccent && keys->baccent(unicode)) {
+ unicode = keys->baccent(unicode);
+ }
+ else if (accent && keys->accent(unicode)) {
+ unicode = keys->accent(unicode);
+ }
}
// korean parsing
if (keys->lang == "ko") {
unicode = parseKoreanInput(unicode);
@@ -730,12 +837,14 @@ void Keyboard::resetState()
{
if (shift) { *shift = 0; shift = 0; }
if (lock) {*lock = 0; lock = 0; }
if (meta) { *meta = 0; meta = 0; }
if (circumflex) { *circumflex = 0; circumflex = 0; }
if (diaeresis) { *diaeresis = 0; diaeresis = 0; }
+ if (baccent) { *baccent = 0; baccent = 0; }
+ if (accent) { *accent = 0; accent = 0; }
schar = mchar = echar = 0;
picks->resetState();
}
/* Keyboard::togglePickboard {{{1 */
@@ -1337,12 +1446,37 @@ void Keys::setKeysFromFile(const char * filename) {
tmp >> d >> lower >> shift;
diaeresisMap.insert(lower, shift);
buf = t.readLine();
}
+ // back accent
+ else if (buf.contains(QRegExp("^\\s*b\\s+[0-9a-fx]+\\s+[0-9a-fx]+\\s*$", FALSE, FALSE))) {
+
+ QTextStream tmp (buf, IO_ReadOnly);
+ ushort lower, shift;
+ QChar d;
+ tmp >> d >> lower >> shift;
+
+ baccentMap.insert(lower, shift);
+
+ qDebug ("Estoy añadiendo %i con %i", lower, shift);
+ buf = t.readLine();
+ }
+ // accent
+ else if (buf.contains(QRegExp("^\\s*a\\s+[0-9a-fx]+\\s+[0-9a-fx]+\\s*$", FALSE, FALSE))) {
+
+ QTextStream tmp (buf, IO_ReadOnly);
+ ushort lower, shift;
+ QChar d;
+ tmp >> d >> lower >> shift;
+
+ accentMap.insert(lower, shift);
+
+ buf = t.readLine();
+ }
// other variables like lang & title
else if (buf.contains(QRegExp("^\\s*[a-zA-Z]+\\s*=\\s*[a-zA-Z0-9/]+\\s*$", FALSE, FALSE))) {
QTextStream tmp (buf, IO_ReadOnly);
QString name, equals, value;
@@ -1486,10 +1620,22 @@ ushort Keys::circumflex(const ushort uni) {
ushort Keys::diaeresis(const ushort uni) {
if(diaeresisMap[uni]) return diaeresisMap[uni];
else return 0;
}
+ushort Keys::baccent(const ushort uni) {
+
+ if(baccentMap[uni]) return baccentMap[uni];
+ else return 0;
+}
+
+ushort Keys::accent(const ushort uni) {
+
+ if(accentMap[uni]) return accentMap[uni];
+ else return 0;
+}
+
bool *Keys::pressedPtr(const int row, const int col) {
return keys[row].at(col)->pressed;
}
diff --git a/inputmethods/multikey/keyboard.h b/inputmethods/multikey/keyboard.h
index 8af80d0..bc74e71 100644
--- a/inputmethods/multikey/keyboard.h
+++ b/inputmethods/multikey/keyboard.h
@@ -63,12 +63,14 @@ public:
bool pressed(const int row, const int col);
bool *pressedPtr(const int row, const int col);
ushort shift(const ushort);
ushort meta(const ushort);
ushort circumflex(const ushort);
ushort diaeresis(const ushort);
+ ushort baccent(const ushort);
+ ushort accent(const ushort);
QImage *pix(const int row, const int col);
int numKeys(const int row);
void setKeysFromFile(const char *filename);
void setKey(const int row, const int qcode, const ushort unicode,
const int width, QImage *pix);
void setPressed(const int row, const int col, const bool pressed);
@@ -89,12 +91,14 @@ private:
QList<Key> keys[6];
QMap<ushort,ushort> shiftMap;
QMap<ushort,ushort> metaMap;
QMap<ushort,ushort> circumflexMap;
QMap<ushort,ushort> diaeresisMap;
+ QMap<ushort,ushort> baccentMap;
+ QMap<ushort,ushort> accentMap;
};
class Keyboard : public QFrame
{
Q_OBJECT
@@ -135,12 +139,14 @@ private:
bool *lock;
bool *ctrl;
bool *alt;
bool *meta;
bool *circumflex;
bool *diaeresis;
+ bool *baccent;
+ bool *accent;
uint useLargeKeys:1;
uint usePicks:1;
uint useRepeat:1;
int pressedKeyRow;