mirror of
https://github.com/Oibaf66/frodo-wii.git
synced 2025-02-21 06:42:02 +01:00
Implement keyboard input handling
This commit is contained in:
parent
c7023f1210
commit
d3e4552174
@ -229,6 +229,7 @@ public:
|
|||||||
|
|
||||||
void startFakeKeySequence(const char *str);
|
void startFakeKeySequence(const char *str);
|
||||||
void run_fake_key_sequence();
|
void run_fake_key_sequence();
|
||||||
|
void pushKeyCode(int kc, bool up);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef WIN32
|
#ifdef WIN32
|
||||||
|
@ -84,6 +84,11 @@ void C64::c64_dtor(void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void C64::pushKeyCode(int kc, bool up)
|
||||||
|
{
|
||||||
|
TheDisplay->UpdateKeyMatrix(kc, up, TheCIA1->KeyMatrix, TheCIA1->RevMatrix, NULL);
|
||||||
|
}
|
||||||
|
|
||||||
/* From dreamcast port but heavily modified */
|
/* From dreamcast port but heavily modified */
|
||||||
void C64::run_fake_key_sequence()
|
void C64::run_fake_key_sequence()
|
||||||
{
|
{
|
||||||
|
@ -690,7 +690,7 @@ void C64Display::PollKeyboard(uint8 *key_matrix, uint8 *rev_matrix, uint8 *joyst
|
|||||||
Gui::gui->pushEvent(&event);
|
Gui::gui->pushEvent(&event);
|
||||||
|
|
||||||
/* Ignore keyboard input while the menu is active */
|
/* Ignore keyboard input while the menu is active */
|
||||||
if (Gui::gui->is_active)
|
if (Gui::gui->is_active || Gui::gui->kbd)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
switch (event.type) {
|
switch (event.type) {
|
||||||
|
@ -240,13 +240,13 @@ void Gui::runLogic(void)
|
|||||||
|
|
||||||
this->status_bar->runLogic();
|
this->status_bar->runLogic();
|
||||||
this->timerController->tick();
|
this->timerController->tick();
|
||||||
|
if (this->kbd)
|
||||||
|
this->kbd->runLogic();
|
||||||
|
|
||||||
if (!this->is_active || !cur_view)
|
if (!this->is_active || !cur_view)
|
||||||
return;
|
return;
|
||||||
if (this->dlg)
|
if (this->dlg)
|
||||||
this->dlg->runLogic();
|
this->dlg->runLogic();
|
||||||
else if (this->kbd)
|
|
||||||
this->kbd->runLogic();
|
|
||||||
else
|
else
|
||||||
cur_view->runLogic();
|
cur_view->runLogic();
|
||||||
}
|
}
|
||||||
@ -316,7 +316,11 @@ void Gui::pushEvent(SDL_Event *ev)
|
|||||||
GuiView *cur_view = this->peekView();
|
GuiView *cur_view = this->peekView();
|
||||||
|
|
||||||
if (!this->is_active || !cur_view)
|
if (!this->is_active || !cur_view)
|
||||||
|
{
|
||||||
|
if (this->kbd)
|
||||||
|
this->kbd->pushEvent(ev);
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
if (ev->type == SDL_QUIT)
|
if (ev->type == SDL_QUIT)
|
||||||
exit(0);
|
exit(0);
|
||||||
if (this->dlg)
|
if (this->dlg)
|
||||||
@ -334,6 +338,8 @@ void Gui::draw(SDL_Surface *where)
|
|||||||
if (!this->is_active || !cur_view)
|
if (!this->is_active || !cur_view)
|
||||||
{
|
{
|
||||||
this->status_bar->draw(where);
|
this->status_bar->draw(where);
|
||||||
|
if (this->kbd)
|
||||||
|
this->kbd->draw(where);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,19 +1,34 @@
|
|||||||
#include "menu.hh"
|
#include "menu.hh"
|
||||||
#include "dialogue_box.hh"
|
#include "dialogue_box.hh"
|
||||||
|
|
||||||
class KeyboardTypingListener : public KeyboardListener
|
class KeyboardTypingListener : public KeyboardListener, TimeoutHandler
|
||||||
{
|
{
|
||||||
|
public:
|
||||||
virtual void stringCallback(const char *str)
|
virtual void stringCallback(const char *str)
|
||||||
{
|
{
|
||||||
printf("string: %s\n", str);
|
|
||||||
/* Remove thyself! */
|
/* Remove thyself! */
|
||||||
delete this;
|
delete this;
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual void keyCallback(bool shift, const char *str)
|
virtual void keyCallback(bool shift, const char *str)
|
||||||
{
|
{
|
||||||
printf("Vobb: %d: %s\n", shift, str);
|
this->kc = VirtualKeyboard::kbd->stringToKeycode(str);
|
||||||
|
|
||||||
|
if (shift)
|
||||||
|
this->kc |= 0x80;
|
||||||
|
|
||||||
|
TheC64->pushKeyCode(this->kc, false);
|
||||||
|
/* Release it soon */
|
||||||
|
Gui::gui->timerController->arm(this, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
virtual void timeoutCallback()
|
||||||
|
{
|
||||||
|
TheC64->pushKeyCode(this->kc, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
private:
|
||||||
|
int kc;
|
||||||
};
|
};
|
||||||
|
|
||||||
class ExitListener : public DialogueListener
|
class ExitListener : public DialogueListener
|
||||||
@ -82,6 +97,7 @@ public:
|
|||||||
case 0:
|
case 0:
|
||||||
VirtualKeyboard::kbd->activate(false);
|
VirtualKeyboard::kbd->activate(false);
|
||||||
VirtualKeyboard::kbd->registerListener(new KeyboardTypingListener());
|
VirtualKeyboard::kbd->registerListener(new KeyboardTypingListener());
|
||||||
|
Gui::gui->exitMenu();
|
||||||
break;
|
break;
|
||||||
case 1:
|
case 1:
|
||||||
break;
|
break;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user