summaryrefslogtreecommitdiffstatshomepage
path: root/src/emu/natkeyboard.cpp
diff options
context:
space:
mode:
author AJR <ajrhacker@users.noreply.github.com>2020-01-10 12:06:08 -0500
committer AJR <ajrhacker@users.noreply.github.com>2020-01-10 12:09:15 -0500
commit197c94ceacbc05a8fc9785592a6ccfbb7f585047 (patch)
treee6b40959f3f3f219eadedbf249da196f4a1841ec /src/emu/natkeyboard.cpp
parent2b4c203d88e672e7c117d6266c5bb6ed7ef5bd00 (diff)
input_sdl: Process control characters so that the natural keyboard can see them (SDL normally strips these out)
Don't strip linefeed characters (Ctrl-J) from natural keyboard input except when pasting strings
Diffstat (limited to 'src/emu/natkeyboard.cpp')
-rw-r--r--src/emu/natkeyboard.cpp37
1 files changed, 20 insertions, 17 deletions
diff --git a/src/emu/natkeyboard.cpp b/src/emu/natkeyboard.cpp
index 7d154787c0c..5f6ede1edf3 100644
--- a/src/emu/natkeyboard.cpp
+++ b/src/emu/natkeyboard.cpp
@@ -17,7 +17,7 @@
// DEBUGGING
//**************************************************************************
-#define LOG_NATURAL_KEYBOARD 0
+#define LOG_NATURAL_KEYBOARD 1
@@ -385,29 +385,32 @@ void natural_keyboard::set_in_use(bool usage)
//-------------------------------------------------
-// post - post a single character
+// post_char - post a single character
//-------------------------------------------------
-void natural_keyboard::post(char32_t ch)
+void natural_keyboard::post_char(char32_t ch, bool normalize_crlf)
{
- // ignore any \n that are preceded by \r
- if (m_last_cr && ch == '\n')
+ if (normalize_crlf)
{
- m_last_cr = false;
- return;
- }
+ // ignore any \n that are preceded by \r
+ if (m_last_cr && ch == '\n')
+ {
+ m_last_cr = false;
+ return;
+ }
- // change all eolns to '\r'
- if (ch == '\n')
- ch = '\r';
- else
- m_last_cr = (ch == '\r');
+ // change all eolns to '\r'
+ if (ch == '\n')
+ ch = '\r';
+ else
+ m_last_cr = (ch == '\r');
+ }
// logging
if (LOG_NATURAL_KEYBOARD)
{
const keycode_map_entry *code = find_code(ch);
- machine().logerror("natural_keyboard::post(): code=%i (%s) field.name='%s'\n", int(ch), unicode_to_string(ch).c_str(), (code != nullptr && code->field[0] != nullptr) ? code->field[0]->name() : "<null>");
+ machine().logerror("natural_keyboard::post_char(): code=%i (%s) field.name='%s'\n", int(ch), unicode_to_string(ch).c_str(), (code != nullptr && code->field[0] != nullptr) ? code->field[0]->name() : "<null>");
}
// can we post this key in the queue directly?
@@ -447,7 +450,7 @@ void natural_keyboard::post(const char32_t *text, size_t length, const attotime
while (length > 0 && !full())
{
// fetch next character
- post(*text++);
+ post_char(*text++, true);
length--;
}
}
@@ -479,7 +482,7 @@ void natural_keyboard::post_utf8(const char *text, size_t length, const attotime
}
// append to the buffer
- post(uc);
+ post_char(uc, true);
text += count;
length -= count;
}
@@ -565,7 +568,7 @@ void natural_keyboard::post_coded(const char *text, size_t length, const attotim
// if we got a code, post it
if (ch != 0)
- post(ch);
+ post_char(ch);
curpos += increment;
}
}