summaryrefslogtreecommitdiff
path: root/uisimulator
diff options
context:
space:
mode:
authorDaniel Stenberg <daniel@haxx.se>2002-08-07 09:17:21 +0000
committerDaniel Stenberg <daniel@haxx.se>2002-08-07 09:17:21 +0000
commit4681e09aac67947787179829ed4b048f87a21784 (patch)
tree868fe4e4bd1b49ed43ea22b0023ecace285b2adf /uisimulator
parenta398aa49ddad0f53e305d87336f3015667fd0636 (diff)
Unix coder playing win32 programmer, added button_get_w_tmo() and it what
do you know, it might just work. There was no win32 programmer in sight. How hard can it be? ;-P git-svn-id: svn://svn.rockbox.org/rockbox/trunk@1580 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'uisimulator')
-rw-r--r--uisimulator/win32/button.c138
1 files changed, 83 insertions, 55 deletions
diff --git a/uisimulator/win32/button.c b/uisimulator/win32/button.c
index 3ecdca2b19..4fb4bd0612 100644
--- a/uisimulator/win32/button.c
+++ b/uisimulator/win32/button.c
@@ -50,61 +50,89 @@ int button_set_release(int newmask)
return oldmask;
}
+static int real_button_get(void)
+{
+ if (bActive)
+ {
+ if (KEY (VK_NUMPAD4) ||
+ KEY (VK_LEFT)) // left button
+ btn |= BUTTON_LEFT;
+
+ if (KEY (VK_NUMPAD6) ||
+ KEY (VK_RIGHT))
+ btn |= BUTTON_RIGHT; // right button
+
+ if (KEY (VK_NUMPAD8) ||
+ KEY (VK_UP))
+ btn |= BUTTON_UP; // up button
+
+ if (KEY (VK_NUMPAD2) ||
+ KEY (VK_DOWN))
+ btn |= BUTTON_DOWN; // down button
+
+ if (KEY (VK_ADD))
+ btn |= BUTTON_ON; // on button
+
+#ifdef HAVE_RECORDER_KEYPAD
+ if (KEY (VK_RETURN))
+ btn |= BUTTON_OFF; // off button
+
+ if (KEY (VK_DIVIDE) || KEY(VK_F1))
+ btn |= BUTTON_F1; // F1 button
+
+ if (KEY (VK_MULTIPLY) || KEY(VK_F2))
+ btn |= BUTTON_F2; // F2 button
+
+ if (KEY (VK_SUBTRACT) || KEY(VK_F3))
+ btn |= BUTTON_F3; // F3 button
+
+ if (KEY (VK_NUMPAD5) ||
+ KEY (VK_SPACE))
+ btn |= BUTTON_PLAY; // play button
+#else
+ if (KEY (VK_RETURN))
+ btn |= BUTTON_MENU; // menu button
+#endif
+
+ if (btn != 0) {
+ last_key = 0 ;
+ }
+ }
+
+ return btn;
+}
+
int button_get(bool block)
{
- int btn = 0;
- do
- {
- if (bActive)
- {
- if (KEY (VK_NUMPAD4) ||
- KEY (VK_LEFT)) // left button
- btn |= BUTTON_LEFT;
-
- if (KEY (VK_NUMPAD6) ||
- KEY (VK_RIGHT))
- btn |= BUTTON_RIGHT; // right button
-
- if (KEY (VK_NUMPAD8) ||
- KEY (VK_UP))
- btn |= BUTTON_UP; // up button
-
- if (KEY (VK_NUMPAD2) ||
- KEY (VK_DOWN))
- btn |= BUTTON_DOWN; // down button
-
- if (KEY (VK_ADD))
- btn |= BUTTON_ON; // on button
-
- #ifdef HAVE_RECORDER_KEYPAD
- if (KEY (VK_RETURN))
- btn |= BUTTON_OFF; // off button
-
- if (KEY (VK_DIVIDE) || KEY(VK_F1))
- btn |= BUTTON_F1; // F1 button
-
- if (KEY (VK_MULTIPLY) || KEY(VK_F2))
- btn |= BUTTON_F2; // F2 button
-
- if (KEY (VK_SUBTRACT) || KEY(VK_F3))
- btn |= BUTTON_F3; // F3 button
-
- if (KEY (VK_NUMPAD5) ||
- KEY (VK_SPACE))
- btn |= BUTTON_PLAY; // play button
- #else
- if (KEY (VK_RETURN))
- btn |= BUTTON_MENU; // menu button
- #endif
-
- if (btn != 0) {
- last_key = 0 ;
- }
- }
- }
- while (btn == 0 && block);
-
- Sleep (50);
-
- return btn;
+ int btn;
+ do {
+
+ btn = real_button_get();
+
+ if(!btn)
+ /* prevent busy-looping */
+ Sleep (50); /* ms */
+ else
+ break;
+
+ } while (block);
+
+ return btn;
+}
+
+int button_get_w_tmo(int ticks)
+{
+ int btn;
+ do {
+ btn = real_button_get();
+
+ if(!btn)
+ /* prevent busy-looping */
+ sleep(1); /* one tick! */
+ else
+ break;
+
+ } while (block);
+
+ return btn;
}