aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEugene Sandulenko2014-12-19 22:41:08 +0100
committerEugene Sandulenko2015-12-15 00:05:02 +0100
commit0dbcb7160c78ed8697afbdd87182f1a52b497824 (patch)
tree29610cea31bc4a2f9a8256f747aadd3d1ca69b6e
parentdfa0a1ef0b23e0343ddf98c545cdae2a51d85c77 (diff)
downloadscummvm-rg350-0dbcb7160c78ed8697afbdd87182f1a52b497824.tar.gz
scummvm-rg350-0dbcb7160c78ed8697afbdd87182f1a52b497824.tar.bz2
scummvm-rg350-0dbcb7160c78ed8697afbdd87182f1a52b497824.zip
LAB: Added input
-rw-r--r--engines/lab/engine.cpp3
-rw-r--r--engines/lab/interface.cpp4
-rw-r--r--engines/lab/machine.cpp2
-rw-r--r--engines/lab/mouse.h2
-rw-r--r--engines/lab/vga.cpp126
-rw-r--r--engines/lab/vga.h8
6 files changed, 139 insertions, 6 deletions
diff --git a/engines/lab/engine.cpp b/engines/lab/engine.cpp
index 3edf89631e..184b7e0669 100644
--- a/engines/lab/engine.cpp
+++ b/engines/lab/engine.cpp
@@ -860,8 +860,7 @@ static void process(void) {
if (result != 0) {
int x = 0, y = 0;
- warning("STUB: getMousePos()");
- //SDL_GetMousePos(&x, &y);
+ WSDL_GetMousePos(&x, &y);
Class = GADGETUP;
Qualifier = 0;
diff --git a/engines/lab/interface.cpp b/engines/lab/interface.cpp
index 91111ae949..acf7c8b13d 100644
--- a/engines/lab/interface.cpp
+++ b/engines/lab/interface.cpp
@@ -169,8 +169,8 @@ static struct Gadget *checkNumGadgetHit(struct Gadget *gadlist, uint16 key) {
/* Checks whether or not a key has been pressed. */
/*****************************************************************************/
static bool keyPress(uint16 *KeyCode) {
- if (_keyPressed.keycode) {
- *KeyCode = _keyPressed.keycode;
+ if (WSDL_HasNextChar()) {
+ *KeyCode = WSDL_GetNextChar();
return true;
}
diff --git a/engines/lab/machine.cpp b/engines/lab/machine.cpp
index ab46ce600e..da8744a9f5 100644
--- a/engines/lab/machine.cpp
+++ b/engines/lab/machine.cpp
@@ -248,7 +248,7 @@ uint16 swapUShort(uint16 value) {
b[1] = t;
return value;
}
-uint16 *swapUShortPtr(uint16 *ptr, int count) {
+uint16 *wapUShortPtsr(uint16 *ptr, int count) {
while (count-- > 0) {
char *b = (char *)ptr++;
char t = b[0];
diff --git a/engines/lab/mouse.h b/engines/lab/mouse.h
index e8bc7bfb7c..108afc219d 100644
--- a/engines/lab/mouse.h
+++ b/engines/lab/mouse.h
@@ -57,6 +57,8 @@ Gadget *mouseGadget(void);
void attachGadgetList(struct Gadget *GadList);
+void mouse_handler(int32 max, int32 mcx, int32 mdx);
+
} // End of namespace Lab
#endif /* LAB_MOUSE_H */
diff --git a/engines/lab/vga.cpp b/engines/lab/vga.cpp
index 8badc7072f..c8960a49fe 100644
--- a/engines/lab/vga.cpp
+++ b/engines/lab/vga.cpp
@@ -31,9 +31,12 @@
#include "lab/vga.h"
#include "lab/stddefines.h"
#include "lab/storage.h"
+#include "lab/mouse.h"
#include "graphics/palette.h"
+#include "common/events.h"
+
namespace Lab {
//static uint16 NotInRefresh = 0;
@@ -52,6 +55,13 @@ int g_ScreenWasLocked = 0;
int g_IgnoreUpdateDisplay = 0;
int g_LastWaitTOFTicks = 0;
+int g_MouseX = 0;
+int g_MouseY = 0;
+
+uint16 g_NextKeyIn = 0;
+uint16 g_KeyBuf[64];
+uint16 g_NextKeyOut = 0;
+bool g_MouseAtEdge = false;
/*****************************************************************************/
/* Sets the display mode. */
@@ -97,9 +107,123 @@ void VGARestorePage(void) {
// does nothing in SDL
}
-void WSDL_ProcessInput(int state) {
+void changeVolume(int delta) {
+ warning("STUB: changeVolume()");
+}
+
+uint16 WSDL_GetNextChar() {
+ uint16 c = 0;
+
+ WSDL_ProcessInput(0);
+ if (g_NextKeyIn != g_NextKeyOut) {
+ c = g_KeyBuf[g_NextKeyOut];
+ g_NextKeyOut = ((((unsigned int)((g_NextKeyOut + 1) >> 31) >> 26) + (byte)g_NextKeyOut + 1) & 0x3F)
+ - ((unsigned int)((g_NextKeyOut + 1) >> 31) >> 26);
+ }
+
+ return c;
+}
+
+bool WSDL_HasNextChar() {
+ WSDL_ProcessInput(0);
+ return g_NextKeyIn != g_NextKeyOut;
+}
+
+void WSDL_ProcessInput(bool can_delay) {
+ int n;
+ int lastMouseAtEdge;
+ int flags = 0;
+
+ Common::Event event;
+
+ if (1 /*!g_IgnoreProcessInput*/) {
+ while (g_system->getEventManager()->pollEvent(event)) {
+ switch (event.type) {
+ case Common::EVENT_RBUTTONDOWN:
+ flags |= 8;
+ mouse_handler(flags, g_MouseX, g_MouseY);
+ break;
+
+ case Common::EVENT_LBUTTONDOWN:
+ flags |= 2;
+ mouse_handler(flags, g_MouseX, g_MouseY);
+ break;
+
+ case Common::EVENT_MOUSEMOVE:
+ lastMouseAtEdge = g_MouseAtEdge;
+ g_MouseAtEdge = false;
+ g_MouseX = event.mouse.x;
+ if (event.mouse.x <= 0) {
+ g_MouseX = 0;
+ g_MouseAtEdge = true;
+ }
+ if (g_MouseX > 639) {
+ g_MouseX = 640;
+ g_MouseAtEdge = true;
+ }
+
+ g_MouseY = event.mouse.y;
+ if (event.mouse.y <= 0) {
+ g_MouseY = 0;
+ g_MouseAtEdge = true;
+ }
+ if (g_MouseY > 479) {
+ g_MouseY = 480;
+ g_MouseAtEdge = true;
+ }
+
+ if (!lastMouseAtEdge || !g_MouseAtEdge)
+ mouse_handler(1, g_MouseX, g_MouseY);
+
+ break;
+
+ case Common::EVENT_KEYDOWN:
+ switch (event.kbd.keycode) {
+ case Common::KEYCODE_LEFTBRACKET:
+ changeVolume(-1);
+ break;
+
+ case Common::KEYCODE_RIGHTBRACKET:
+ changeVolume(1);
+ break;
+
+ case Common::KEYCODE_z:
+ //saveSettings();
+ break;
+
+ default:
+ n = ((((unsigned int)((g_NextKeyIn + 1) >> 31) >> 26) + (byte)g_NextKeyIn + 1) & 0x3F)
+ - ((unsigned int)((g_NextKeyIn + 1) >> 31) >> 26);
+ if (n != g_NextKeyOut) {
+ g_KeyBuf[g_NextKeyIn] = event.kbd.keycode;
+ g_NextKeyIn = n;
+ }
+ }
+ break;
+
+ case Common::EVENT_QUIT:
+ case Common::EVENT_RTL:
+ default:
+ break;
+ }
+
+ g_system->copyRectToScreen(g_DisplayBuffer, VGAScreenWidth, 0, 0, VGAScreenWidth, VGAScreenHeight);
+ g_system->updateScreen();
+ }
+ }
+
+ if (can_delay)
+ g_system->delayMillis(10);
+}
+
+void WSDL_GetMousePos(int *x, int *y) {
+ WSDL_ProcessInput(0);
+
+ *x = g_MouseX;
+ *y = g_MouseY;
}
+
void waitTOF() {
int untilOutOfRefresh = 1;
diff --git a/engines/lab/vga.h b/engines/lab/vga.h
index fc5f981531..a0b2f6314d 100644
--- a/engines/lab/vga.h
+++ b/engines/lab/vga.h
@@ -99,6 +99,14 @@ void WSDL_UpdateScreen();
void WSDL_IgnoreUpdateDisplay(int state);
+void WSDL_GetMousePos(int *x, int *y);
+
+uint16 WSDL_GetNextChar();
+
+bool WSDL_HasNextChar();
+
+void WSDL_ProcessInput(bool can_delay);
+
} // End of namespace Lab
#endif /* LAB_VGA_H */