mirror of
https://github.com/ClassiCube/ClassiCube.git
synced 2025-09-15 10:35:11 -04:00
simplify 3DS touch handling and make it behave more like the Android port
This commit is contained in:
parent
e66e99c048
commit
c1adccb0aa
@ -12,7 +12,6 @@
|
|||||||
#include "ExtMath.h"
|
#include "ExtMath.h"
|
||||||
#include <3ds.h>
|
#include <3ds.h>
|
||||||
|
|
||||||
static int touchActive, touchBegX, touchBegY;
|
|
||||||
static cc_bool launcherMode;
|
static cc_bool launcherMode;
|
||||||
static Result irrst_result;
|
static Result irrst_result;
|
||||||
static enum Screen3DS renderScreen = TOP_SCREEN;
|
static enum Screen3DS renderScreen = TOP_SCREEN;
|
||||||
@ -132,35 +131,26 @@ static void ProcessJoystickInput(circlePosition* pos, double delta) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void ProcessTouchInput(int mods) {
|
static void ProcessTouchInput(int mods) {
|
||||||
|
static int currX, currY; // current touch position
|
||||||
touchPosition touch;
|
touchPosition touch;
|
||||||
hidTouchRead(&touch);
|
hidTouchRead(&touch);
|
||||||
touchActive = mods & KEY_TOUCH;
|
if (hidKeysDown() & KEY_TOUCH) { // stylus went down
|
||||||
|
currX = touch.px;
|
||||||
if (touchActive) {
|
currY = touch.py;
|
||||||
// rescale X from [0, bottom_FB_width) to [0, top_FB_width)
|
Input_AddTouch(0, currX, currY);
|
||||||
int x = touch.px * Window_Main.Width / GSP_SCREEN_HEIGHT_BOTTOM;
|
|
||||||
int y = touch.py;
|
|
||||||
Pointer_SetPosition(0, x, y);
|
|
||||||
}
|
}
|
||||||
int x = touch.px;
|
else if (mods & KEY_TOUCH) { // stylus is down
|
||||||
int y = touch.py;
|
currX = touch.px;
|
||||||
|
currY = touch.py;
|
||||||
// Set starting position for camera movement
|
Input_UpdateTouch(0, currX, currY);
|
||||||
if (hidKeysDown() & KEY_TOUCH) {
|
|
||||||
//Platform_Log2("touch down: %i,%i", &x, &y);
|
|
||||||
touchBegX = touch.px;
|
|
||||||
touchBegY = touch.py;
|
|
||||||
Input_AddTouch(1, touch.px, touch.py);
|
|
||||||
}
|
}
|
||||||
if (hidKeysUp() & KEY_TOUCH) {
|
else if (hidKeysUp() & KEY_TOUCH) { // stylus was lifted
|
||||||
//Platform_Log2("touch up: %i,%i", &x, &y);
|
Input_RemoveTouch(0, currX, currY);
|
||||||
Input_RemoveTouch(1, touch.px, touch.py); // TODO: coordinates are 0
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Window_ProcessEvents(double delta) {
|
void Window_ProcessEvents(double delta) {
|
||||||
hidScanInput();
|
hidScanInput();
|
||||||
/* TODO implement */
|
|
||||||
|
|
||||||
if (!aptMainLoop()) {
|
if (!aptMainLoop()) {
|
||||||
Window_Main.Exists = false;
|
Window_Main.Exists = false;
|
||||||
@ -191,18 +181,7 @@ void Cursor_SetPosition(int x, int y) { } // Makes no sense for 3DS
|
|||||||
void Window_EnableRawMouse(void) { Input.RawMode = true; }
|
void Window_EnableRawMouse(void) { Input.RawMode = true; }
|
||||||
void Window_DisableRawMouse(void) { Input.RawMode = false; }
|
void Window_DisableRawMouse(void) { Input.RawMode = false; }
|
||||||
|
|
||||||
void Window_UpdateRawMouse(void) {
|
void Window_UpdateRawMouse(void) { }
|
||||||
if (!touchActive) return;
|
|
||||||
|
|
||||||
touchPosition touch;
|
|
||||||
hidTouchRead(&touch);
|
|
||||||
|
|
||||||
Event_RaiseRawMove(&PointerEvents.RawMoved,
|
|
||||||
touch.px - touchBegX, touch.py - touchBegY);
|
|
||||||
touchBegX = touch.px;
|
|
||||||
touchBegY = touch.py;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/*########################################################################################################################*
|
/*########################################################################################################################*
|
||||||
*------------------------------------------------------Framebuffer--------------------------------------------------------*
|
*------------------------------------------------------Framebuffer--------------------------------------------------------*
|
||||||
|
Loading…
x
Reference in New Issue
Block a user