2 Skelton for retropc emulator
4 Author : Takeda.Toshiya
12 //#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 //DebugSemaphore->acquire(1);
31 console_cmd_str.append(s);
32 console_cmd_str.append(QString::fromUtf8("\n"));
33 //DebugSemaphore->release();
36 _TCHAR *OSD_BASE::console_input_string(void)
38 //DebugSemaphore->acquire(1);
39 if(console_cmd_str.isEmpty()) {
40 //DebugSemaphore->release(1);
43 _TCHAR *p = (_TCHAR *)console_cmd_str.toUtf8().constData();
44 //DebugSemaphore->release();
48 void OSD_BASE::clear_console_input_string(void)
50 //DebugSemaphore->acquire(1);
51 console_cmd_str.clear();
52 //DebugSemaphore->release();
55 void OSD_BASE::open_console(_TCHAR* title)
57 if(osd_console_opened) return;
58 //DebugSemaphore->acquire(1);
59 console_cmd_str.clear();
60 osd_console_opened = true;
61 //DebugSemaphore->release();
65 void OSD_BASE::close_console()
67 //DebugSemaphore->release(DebugSemaphore->available());
68 console_cmd_str.clear();
69 osd_console_opened = false;
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)
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 //DebugSemaphore->acquire(1);
117 int l = console_cmd_str.length();
119 console_cmd_str = console_cmd_str.right(l - count);
120 strncpy((char *)buffer, tmps.toLocal8Bit().constData(), count);
121 //DebugSemaphore->release(1);
126 // This is not recognise char code.
127 bool OSD_BASE::is_console_key_pressed(uint32_t ch)
130 if(read_console_input(buf) > 0) return true;
134 void OSD_BASE::close_debugger_console()
136 emit sig_debugger_finished(); // It's dirty...
139 void OSD_BASE::do_close_debugger_thread()
141 emit sig_debugger_finished();