2 Skelton for retropc emulator
4 Author : Takeda.Toshiya
13 //#include "emu_thread.h"
17 //BOOL WINAPI ctrl_c_handler(DWORD type)
22 void OSD_BASE::do_write_inputdata(QString s)
24 //emit sig_console_input_string(s);
27 void OSD_BASE::do_set_input_string(QString s)
30 console_cmd_str.append(s);
31 console_cmd_str.append(QString::fromUtf8("\n"));
35 _TCHAR *OSD_BASE::console_input_string(void)
37 //DebugSemaphore->acquire(1);
38 if(console_cmd_str.isEmpty()) {
39 //DebugSemaphore->release(1);
42 _TCHAR *p = (_TCHAR *)console_cmd_str.toUtf8().constData();
43 //DebugSemaphore->release();
47 void OSD_BASE::clear_console_input_string(void)
49 //DebugSemaphore->acquire(1);
50 console_cmd_str.clear();
51 //DebugSemaphore->release();
54 void OSD_BASE::open_console(_TCHAR* title)
56 if(osd_console_opened) return;
57 //DebugSemaphore->acquire(1);
58 console_cmd_str.clear();
59 osd_console_opened = true;
60 //DebugSemaphore->release();
64 void OSD_BASE::close_console()
66 //DebugSemaphore->release(DebugSemaphore->available());
67 console_cmd_str.clear();
68 osd_console_opened = false;
69 emit sig_close_console();
72 unsigned int OSD_BASE::get_console_code_page()
74 //return GetConsoleCP();
78 bool OSD_BASE::is_console_active()
80 return osd_console_opened;
83 void OSD_BASE::set_console_text_attribute(unsigned short attr)
85 //SetConsoleTextAttribute(hStdOut, attr);
88 void OSD_BASE::write_console(_TCHAR* buffer, unsigned int length)
90 QString s = QString::fromLocal8Bit((const char *)buffer, length);
91 emit sig_put_string_debugger(s);
94 int OSD_BASE::read_console_input(_TCHAR* buffer, int length)
98 //DebugSemaphore->acquire(1);
99 tmps = console_cmd_str.left(16);
100 //DebugSemaphore->release(1);
101 if(buffer == NULL) return 0;
102 memset(buffer, 0x00, 16);
106 int locallen = tmps.indexOf(QString::fromUtf8("\n"));
107 if(locallen >= 16) locallen = 15;
109 tmps = tmps.left(locallen + 1);
110 locallen = locallen + 1;
113 count = tmps.length();
114 if(tmps.isEmpty() || (count <= 0)) return 0;
115 if(count > 16) count = 16;
116 if(count > length) count = length;
117 //DebugSemaphore->acquire(1);
118 int l = console_cmd_str.length();
120 console_cmd_str = console_cmd_str.right(l - count);
121 strncpy((char *)buffer, tmps.toLocal8Bit().constData(), count);
122 //DebugSemaphore->release(1);
127 // This is not recognise char code.
128 bool OSD_BASE::is_console_key_pressed(uint32_t ch)
131 if(read_console_input(buf, 16) > 0) return true;
135 void OSD_BASE::close_debugger_console()
137 emit sig_debugger_finished(); // It's dirty...
140 void OSD_BASE::do_close_debugger_thread()
142 emit sig_debugger_finished();