Added 'Paste from Clipboard' with F5 key on Windows.

This commit is contained in:
Oliver Schmidt 2013-01-27 13:26:13 +00:00
parent 05fcad315e
commit 93eda21bae
6 changed files with 103 additions and 20 deletions

View File

@ -113,6 +113,7 @@ F1: Alias of Command
F2: Alias of Option
F3: Alias of ESC
F4: Configuration Panel
F5: Paste from clipboard (on Windows)
F6: Toggle through the 4 speeds: Unlimited, 1MHz, 2.8MHz, 8.0MHz
Shift-F6: Enter GSport debugger
F7: Toggle fast_disk_emul on/off

View File

@ -1562,7 +1562,13 @@ adb_read_c000()
word32 vbl_count;
if( ((g_kbd_buf[0] & 0x80) == 0) && (g_key_down == 0)) {
/* nothing happening, just get out */
/* nothing happening, check clipboard */
int c = clipboard_get_char();
if(c) {
/* inject clipboard char into keyboard buffer */
g_kbd_buf[0] = c;
}
/* just get out */
return g_kbd_buf[0];
}
if(g_kbd_buf[0] & 0x80) {
@ -1726,9 +1732,12 @@ adb_physical_key_update(int a2code, int is_up)
switch(special) {
// OG Disabled special keys (but warp)
#ifndef ACTIVEGS
case 0x04: /* F4 - Emulator config panel */
case 0x04: /* F4 - emulator config panel */
cfg_toggle_config_panel();
break;
case 0x05: /* F5 - emulator clipboard paste */
clipboard_paste();
break;
case 0x06: /* F6 - emulator speed */
if(SHIFT_DOWN) {
halt2_printf("Shift-F6 pressed\n");

View File

@ -504,3 +504,16 @@ int x_calc_ratio(float x,float y)
{
return 1;
}
void
clipboard_paste(void)
{
// TODO: Add clipboard support
}
int
clipboard_get_char(void)
{
// TODO: Add clipboard support
return 0;
}

View File

@ -42,6 +42,8 @@ void x_push_done();
void x_hide_pointer(int);
void x_get_kimage(Kimage *kimage_ptr);
void x_full_screen(int do_full);
void clipboard_paste(void);
int clipboard_get_char(void);
/* test65.c */
void do_gen_test(int got_num, int base_seed);

View File

@ -98,6 +98,9 @@ RECT g_main_window_saved_rect;
HMENU g_main_window_menu_saved;
int g_win_fullscreen_state = 0;
LPSTR g_clipboard;
size_t g_clipboard_pos;
/* this table is used to search for the Windows VK_* in col 1 or 2 */
/* flags bit 8 is or'ed into the VK, so we can distinguish keypad keys */
/* regardless of numlock */
@ -913,3 +916,45 @@ x_full_screen(int do_full)
}
return;
}
void
clipboard_paste(void)
{
if (!IsClipboardFormatAvailable(CF_TEXT))
return;
if (!OpenClipboard(g_hwnd_main))
return;
{
HGLOBAL hclipboard = GetClipboardData(CF_TEXT);
if (!hclipboard) {
CloseClipboard();
return;
}
{
LPSTR clipboard = (LPSTR)GlobalLock(hclipboard);
if (!clipboard) {
CloseClipboard();
return;
}
if (g_clipboard) {
free(g_clipboard);
g_clipboard_pos = 0;
}
g_clipboard = strdup(clipboard);
}
GlobalUnlock(hclipboard);
}
CloseClipboard();
}
int
clipboard_get_char(void)
{
if (!g_clipboard)
return 0;
if (g_clipboard[g_clipboard_pos] == '\n')
g_clipboard_pos++;
if (g_clipboard[g_clipboard_pos] == '\0')
return 0;
return g_clipboard[g_clipboard_pos++] | 0x80;
}

View File

@ -1360,3 +1360,16 @@ int x_calc_ratio(float x,float y)
{
return 1;
}
void
clipboard_paste(void)
{
// TODO: Add clipboard support
}
int
clipboard_get_char(void)
{
// TODO: Add clipboard support
return 0;
}