mirror of
https://github.com/libretro/scummvm.git
synced 2025-01-10 20:01:25 +00:00
GLK: Beginnings of event handling
This commit is contained in:
parent
76bf2726f8
commit
7bbedcd099
@ -28,8 +28,36 @@ void Events::getEvent(event_t *event, bool polled) {
|
||||
// TODO
|
||||
}
|
||||
|
||||
void Events::eventStore(EvType type, Window *win, uint32 val1, uint32 val2) {
|
||||
// TODO
|
||||
void Events::store(EvType type, Window *win, uint32 val1, uint32 val2) {
|
||||
Event ev(type, win, val1, val2);
|
||||
|
||||
switch (type) {
|
||||
case evtype_Arrange:
|
||||
case evtype_Redraw:
|
||||
case evtype_SoundNotify:
|
||||
case evtype_Timer:
|
||||
_eventsPolled.push(ev);
|
||||
break;
|
||||
|
||||
default:
|
||||
_eventsLogged.push(ev);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void Events::dispatchEvent(Event &ev, bool polled) {
|
||||
Event dispatch;
|
||||
|
||||
if (!polled) {
|
||||
dispatch = _eventsLogged.retrieve();
|
||||
if (dispatch)
|
||||
dispatch = _eventsPolled.retrieve();
|
||||
} else {
|
||||
dispatch = _eventsPolled.retrieve();
|
||||
}
|
||||
|
||||
if (dispatch)
|
||||
ev = dispatch;
|
||||
}
|
||||
|
||||
} // End of namespace Gargoyle
|
||||
|
@ -100,7 +100,17 @@ struct Event {
|
||||
/**
|
||||
* Constructor
|
||||
*/
|
||||
Event() : type(evtype_None), window(nullptr), val1(0), val2(0) {}
|
||||
Event() { clear(); }
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*/
|
||||
Event(EvType evType, Window *evWindow, uint32 evVal1, uint32 evVal2) {
|
||||
type = evType;
|
||||
window = evWindow;
|
||||
val1 = evVal1;
|
||||
val2 = evVal2;
|
||||
}
|
||||
|
||||
/**
|
||||
* Clear
|
||||
@ -110,10 +120,30 @@ struct Event {
|
||||
window = nullptr;
|
||||
val1 = val2 = 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Boolean cast to allow checking whether event is filled out
|
||||
*/
|
||||
operator bool() const { return type != evtype_None; }
|
||||
};
|
||||
typedef Event event_t;
|
||||
|
||||
class EventQueue : public Common::Queue<Event> {
|
||||
public:
|
||||
/**
|
||||
* Retrieve a pending event, if any
|
||||
*/
|
||||
Event retrieve() {
|
||||
return empty() ? Event() : pop();
|
||||
}
|
||||
};
|
||||
|
||||
class Events {
|
||||
private:
|
||||
EventQueue _eventsPolled;
|
||||
EventQueue _eventsLogged;
|
||||
private:
|
||||
void dispatchEvent(Event &ev, bool polled);
|
||||
public:
|
||||
bool _forceClick;
|
||||
public:
|
||||
@ -130,7 +160,7 @@ public:
|
||||
/**
|
||||
* Store an event for retrieval
|
||||
*/
|
||||
void eventStore(EvType type, Window *win, uint32 val1 = 0, uint32 val2 = 0);
|
||||
void store(EvType type, Window *win, uint32 val1 = 0, uint32 val2 = 0);
|
||||
};
|
||||
|
||||
} // End of namespace Gargoyle
|
||||
|
@ -574,7 +574,7 @@ void TextBufferWindow::click(const Common::Point &newPos) {
|
||||
if (_hyperRequest) {
|
||||
glui32 linkval = g_vm->_windowMask->getHyperlink(newPos);
|
||||
if (linkval) {
|
||||
g_vm->_events->eventStore(evtype_Hyperlink, this, linkval, 0);
|
||||
g_vm->_events->store(evtype_Hyperlink, this, linkval, 0);
|
||||
_hyperRequest = false;
|
||||
if (g_conf->_safeClicks)
|
||||
g_vm->_events->_forceClick = 1;
|
||||
@ -1246,7 +1246,7 @@ void TextBufferWindow::acceptReadChar(glui32 arg) {
|
||||
|
||||
_charRequest = false;
|
||||
_charRequestUni = false;
|
||||
g_vm->_events->eventStore(evtype_CharInput, this, key, 0);
|
||||
g_vm->_events->store(evtype_CharInput, this, key, 0);
|
||||
}
|
||||
|
||||
void TextBufferWindow::acceptReadLine(glui32 arg) {
|
||||
@ -1479,11 +1479,11 @@ void TextBufferWindow::acceptLine(glui32 keycode) {
|
||||
glui32 val2 = keycode;
|
||||
if (val2 == keycode_Return)
|
||||
val2 = 0;
|
||||
g_vm->_events->eventStore(evtype_LineInput, this, len, val2);
|
||||
g_vm->_events->store(evtype_LineInput, this, len, val2);
|
||||
free(_lineTerminators);
|
||||
_lineTerminators = nullptr;
|
||||
} else {
|
||||
g_vm->_events->eventStore(evtype_LineInput, this, len, 0);
|
||||
g_vm->_events->store(evtype_LineInput, this, len, 0);
|
||||
}
|
||||
|
||||
_lineRequest = false;
|
||||
|
@ -198,7 +198,7 @@ void TextGridWindow::click(const Common::Point &newPos) {
|
||||
_windows->setFocus(this);
|
||||
|
||||
if (_mouseRequest) {
|
||||
g_vm->_events->eventStore(evtype_MouseInput, this, x / g_conf->_cellW, y / g_conf->_leading);
|
||||
g_vm->_events->store(evtype_MouseInput, this, x / g_conf->_cellW, y / g_conf->_leading);
|
||||
_mouseRequest = false;
|
||||
if (g_conf->_safeClicks)
|
||||
g_vm->_events->_forceClick = true;
|
||||
@ -208,7 +208,7 @@ void TextGridWindow::click(const Common::Point &newPos) {
|
||||
glui32 linkval = g_vm->_windowMask->getHyperlink(newPos);
|
||||
if (linkval)
|
||||
{
|
||||
g_vm->_events->eventStore(evtype_Hyperlink, this, linkval, 0);
|
||||
g_vm->_events->store(evtype_Hyperlink, this, linkval, 0);
|
||||
_hyperRequest = false;
|
||||
if (g_conf->_safeClicks)
|
||||
g_vm->_events->_forceClick = true;
|
||||
@ -405,7 +405,7 @@ void TextGridWindow::acceptReadChar(glui32 arg) {
|
||||
|
||||
_charRequest = false;
|
||||
_charRequestUni = false;
|
||||
g_vm->_events->eventStore(evtype_CharInput, this, key, 0);
|
||||
g_vm->_events->store(evtype_CharInput, this, key, 0);
|
||||
}
|
||||
|
||||
void TextGridWindow::acceptLine(glui32 keycode) {
|
||||
@ -444,11 +444,11 @@ void TextGridWindow::acceptLine(glui32 keycode) {
|
||||
glui32 val2 = keycode;
|
||||
if (val2 == keycode_Return)
|
||||
val2 = 0;
|
||||
g_vm->_events->eventStore(evtype_LineInput, this, _inLen, val2);
|
||||
g_vm->_events->store(evtype_LineInput, this, _inLen, val2);
|
||||
free(_lineTerminators);
|
||||
_lineTerminators = NULL;
|
||||
} else {
|
||||
g_vm->_events->eventStore(evtype_LineInput, this, _inLen, 0);
|
||||
g_vm->_events->store(evtype_LineInput, this, _inLen, 0);
|
||||
}
|
||||
_lineRequest = false;
|
||||
_lineRequestUni = false;
|
||||
|
Loading…
Reference in New Issue
Block a user