}
}
} else if (mouse.enabled) {
- // TODO Review this
mouse.x = x;
mouse.y = y;
- if (Config.xsp) {
- mouse.x /= 2;
- mouse.y /= 2;
+
+ if (mouse.x < GUI.RenderX) mouse.x = 0;
+ else {
+ mouse.x -= GUI.RenderX;
+ if (mouse.x > GUI.RenderW) mouse.x = GUI.RenderW;
+ }
+
+ if (mouse.y < GUI.RenderY) mouse.y = 0;
+ else {
+ mouse.y -= GUI.RenderY;
+ if (mouse.y > GUI.RenderH) mouse.y = GUI.RenderH;
}
+
+ // Take care of scaling
+ mouse.x /= GUI.Scale;
+ mouse.y /= GUI.Scale;
+
if (pressed > 0)
mouse.pressed = true;
else if (pressed < 0)
void S9xInputScreenChanged()
{
- unsigned int i = 0, w = 0, h = 0;
- S9xVideoGetWindowSize(&w, &h);
+ unsigned int i = 0;
+ const unsigned int w = GUI.Width, h = GUI.Height;
for (i = 0; i < sizeof(touchbuttons)/sizeof(TouchButton); i++) {
touchbuttons[i].x = (unsigned)round(touchbuttons[i].fx * w);
touchbuttons[i].y = (unsigned)round(touchbuttons[i].fy * h);
}
}
+template <typename T>
+static void drawControls(T * buffer, const int pitch)
+{
+ unsigned int i = 0;
+ int x, y;
+ T* temp;
+
+ for (i = 0; i < sizeof(touchbuttons)/sizeof(TouchButton); i++) {
+ temp = buffer + touchbuttons[i].y * pitch + touchbuttons[i].x;
+ for (x = touchbuttons[i].x; x < touchbuttons[i].x2; x++) {
+ *temp = -1UL; // Black
+ temp++;
+ }
+ temp = buffer + touchbuttons[i].y2 * pitch + touchbuttons[i].x;
+ for (x = touchbuttons[i].x; x < touchbuttons[i].x2; x++) {
+ *temp = -1UL; // Black
+ temp++;
+ }
+ temp = buffer + touchbuttons[i].y * pitch + touchbuttons[i].x;
+ for (y = touchbuttons[i].y; y < touchbuttons[i].y2; y++) {
+ *temp = -1UL; // Black
+ temp+=pitch;
+ }
+ temp = buffer + touchbuttons[i].y * pitch + touchbuttons[i].x2;
+ for (y = touchbuttons[i].y; y < touchbuttons[i].y2; y++) {
+ *temp = -1UL; // Black
+ temp+=pitch;
+ }
+ }
+}
+
+void S9xInputScreenDraw(int pixelSize, 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;
+ }
+}
+