#include "platform.h"
#include "snes9x.h"
-#include "display.h"
#include "sdlv.h" // Dispatching video-related events
#if CONF_ZEEMOTE
#include "zeemote.h"
#endif
+#if !defined(SDL_MAXMOUSE)
+#define SDL_MAXMOUSE 1
+#endif
+
struct TouchButton {
unsigned short mask;
unsigned short x, y;
#undef TB
};
-static TouchButton* current = 0;
+static TouchButton* current[SDL_MAXMOUSE] = { 0 };
static uint32 joypads[2];
static struct {
joypads[Config.touchscreenInput - 1] |= b->mask;
}
-static void processMouse(unsigned int x, unsigned int y, int pressed = 0)
+static void processMouse(int which, unsigned int x, unsigned int y, int pressed = 0)
{
#if CONF_EXIT_BUTTON
/* no fullscreen escape button, we have to simulate one! */
if (Config.touchscreenInput) {
if (pressed < 0) {
// Button up.
- if (current) {
+ if (current[which]) {
// Leaving button
- unpress(current);
- current = 0;
+ unpress(current[which]);
+ current[which] = 0;
}
} else {
// Button down, or mouse motion.
TouchButton* b = getButtonFor(x, y);
- if (current && b && current != b) {
+ if (current[which] && b && current[which] != b) {
// Moving from button to button
- unpress(current);
- current = b;
- press(current);
- } else if (current && !b) {
+ unpress(current[which]);
+ current[which] = b;
+ press(current[which]);
+ } else if (current[which] && !b) {
// Leaving button
- unpress(current);
- current = 0;
- } else if (!current && b) {
+ unpress(current[which]);
+ current[which] = 0;
+ } else if (!current[which] && b) {
// Entering button
- current = b;
- press(current);
+ current[which] = b;
+ press(current[which]);
}
}
} else if (mouse.enabled) {
static void processEvent(const SDL_Event& event)
{
+ if (videoEventFilter(event)) return;
+
switch (event.type)
{
case SDL_KEYDOWN:
break;
case SDL_MOUSEBUTTONUP:
case SDL_MOUSEBUTTONDOWN:
- processMouse(event.button.x, event.button.y,
+ processMouse(event.button.which, event.button.x, event.button.y,
(event.button.state == SDL_PRESSED) ? 1 : - 1);
break;
case SDL_MOUSEMOTION:
- processMouse(event.motion.x, event.motion.y);
+ processMouse(event.button.which, event.motion.x, event.motion.y);
break;
case SDL_QUIT:
Config.quitting = true;
break;
- case SDL_ACTIVEEVENT:
- case SDL_SYSWMEVENT:
- processVideoEvent(event);
- break;
}
}
@param buttons The buttons return value is a bit-wise mask of the two SNES
mouse buttons, bit 0 for button 1 (left) and bit 1 for button 2 (right).
*/
-bool8 S9xReadMousePosition(int which1, int& x, int& y, uint32& buttons)
+bool8 S9xReadMousePosition(int which, int *x, int *y, uint32 *buttons)
{
- if (which1 != 0) return FALSE;
+ if (which != 0) return FALSE;
- x = mouse.x;
- y = mouse.y;
- buttons = mouse.pressed ? 1 : 0;
+ *x = mouse.x;
+ *y = mouse.y;
+ *buttons = mouse.pressed ? 1 : 0;
return TRUE;
}
-bool8 S9xReadSuperScopePosition(int& x, int& y, uint32& buttons)
+bool8 S9xReadSuperScopePosition(int *x, int *y, uint32 *buttons)
{
- x = mouse.x;
- y = mouse.y;
- buttons = mouse.pressed ? 8 : 0;
+ *x = mouse.x;
+ *y = mouse.y;
+ *buttons = mouse.pressed ? 8 : 0;
return TRUE;
}
mouse.enabled = false;
mouse.pressed = false;
+#if CONF_ZEEMOTE
+ ZeeInit();
+#endif
+
if (Config.joypad1Enabled) {
joypads[0] = 0x80000000UL;
}
}
printf("\n");
-#if CONF_ZEEMOTE
- ZeeInit();
-#endif
-
- // TODO Non-awful mouse support, Superscope
+ // TODO Non-awful mouse & superscope support
S9xInputScreenChanged();
}
void S9xDeinitInputDevices()
{
+#if CONF_ZEEMOTE
+ ZeeQuit();
+#endif
joypads[0] = 0;
joypads[1] = 0;
mouse.enabled = false;
mouse.pressed = false;
-#if CONF_ZEEMOTE
- ZeeQuit();
-#endif
}
void S9xInputScreenChanged()
}
}
-void S9xInputScreenDraw(int pixelSize, void * buffer, int pitch)
+void S9xInputScreenDraw(void * buffer, int pitch)
{
- switch (pixelSize)
- {
- case 1:
- drawControls(reinterpret_cast<uint8*>(buffer), pitch);
- break;
- case 2:
- drawControls(reinterpret_cast<uint16*>(buffer), pitch / 2);
- break;
- }
+ drawControls(reinterpret_cast<uint16*>(buffer), pitch / 2);
}