mirror of
https://github.com/ClassiCube/ClassiCube.git
synced 2025-09-12 09:06:55 -04:00
DS: Slightly better touch input, still needs work though
This commit is contained in:
parent
d54cf921c4
commit
e86d57f4f6
@ -346,6 +346,7 @@ typedef cc_uint8 cc_bool;
|
|||||||
#define CC_BUILD_COOPTHREADED
|
#define CC_BUILD_COOPTHREADED
|
||||||
#define CC_BUILD_LOWMEM
|
#define CC_BUILD_LOWMEM
|
||||||
#define CC_BUILD_CONSOLE
|
#define CC_BUILD_CONSOLE
|
||||||
|
#define CC_BUILD_TOUCH
|
||||||
#undef CC_BUILD_FREETYPE
|
#undef CC_BUILD_FREETYPE
|
||||||
#undef CC_BUILD_RESOURCES
|
#undef CC_BUILD_RESOURCES
|
||||||
#elif defined __WIIU__
|
#elif defined __WIIU__
|
||||||
|
@ -15,7 +15,6 @@
|
|||||||
#include <nds/arm9/console.h>
|
#include <nds/arm9/console.h>
|
||||||
#include <nds/arm9/keyboard.h>
|
#include <nds/arm9/keyboard.h>
|
||||||
|
|
||||||
static int touchActive, touchBegX, touchBegY;
|
|
||||||
static cc_bool launcherMode, keyboardOpen;
|
static cc_bool launcherMode, keyboardOpen;
|
||||||
static int bg_id;
|
static int bg_id;
|
||||||
static u16* bg_ptr;
|
static u16* bg_ptr;
|
||||||
@ -24,9 +23,8 @@ struct _DisplayData DisplayInfo;
|
|||||||
struct _WindowData WindowInfo;
|
struct _WindowData WindowInfo;
|
||||||
|
|
||||||
void Window_Init(void) {
|
void Window_Init(void) {
|
||||||
|
DisplayInfo.Width = SCREEN_WIDTH;
|
||||||
DisplayInfo.Width = 256;
|
DisplayInfo.Height = SCREEN_HEIGHT;
|
||||||
DisplayInfo.Height = 192;
|
|
||||||
DisplayInfo.Depth = 4; // 32 bit
|
DisplayInfo.Depth = 4; // 32 bit
|
||||||
DisplayInfo.ScaleX = 0.5f;
|
DisplayInfo.ScaleX = 0.5f;
|
||||||
DisplayInfo.ScaleY = 0.5f;
|
DisplayInfo.ScaleY = 0.5f;
|
||||||
@ -36,11 +34,10 @@ void Window_Init(void) {
|
|||||||
Window_Main.Focused = true;
|
Window_Main.Focused = true;
|
||||||
Window_Main.Exists = true;
|
Window_Main.Exists = true;
|
||||||
|
|
||||||
|
//Input_SetTouchMode(true); TODO not UI
|
||||||
Input.Sources = INPUT_SOURCE_GAMEPAD;
|
Input.Sources = INPUT_SOURCE_GAMEPAD;
|
||||||
|
|
||||||
consoleDemoInit();
|
consoleDemoInit();
|
||||||
consoleDebugInit(DebugDevice_NOCASH);
|
|
||||||
|
|
||||||
videoSetMode(MODE_5_2D);
|
videoSetMode(MODE_5_2D);
|
||||||
vramSetBankA(VRAM_A_MAIN_BG);
|
vramSetBankA(VRAM_A_MAIN_BG);
|
||||||
|
|
||||||
@ -91,19 +88,22 @@ static void HandleButtons(int mods) {
|
|||||||
Input_SetNonRepeatable(CCPAD_DOWN, mods & KEY_DOWN);
|
Input_SetNonRepeatable(CCPAD_DOWN, mods & KEY_DOWN);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Copied from Window_3DS.c
|
||||||
static void ProcessTouchInput(int mods) {
|
static void ProcessTouchInput(int mods) {
|
||||||
touchPosition pos;
|
static int curX, curY; // current touch position
|
||||||
touchRead(&pos);
|
touchPosition touch;
|
||||||
|
touchRead(&touch);
|
||||||
|
|
||||||
// Set starting position for camera movement
|
if (keysDown() & KEY_TOUCH) { // stylus went down
|
||||||
if (!touchActive && (mods & KEY_TOUCH)) {
|
curX = touch.px;
|
||||||
touchBegX = pos.px;
|
curY = touch.py;
|
||||||
touchBegY = pos.py;
|
Input_AddTouch(0, curX, curY);
|
||||||
}
|
} else if (mods & KEY_TOUCH) { // stylus is down
|
||||||
|
curX = touch.px;
|
||||||
touchActive = mods & KEY_TOUCH;
|
curY = touch.py;
|
||||||
if (touchActive) {
|
Input_UpdateTouch(0, curX, curY);
|
||||||
Pointer_SetPosition(0, pos.px, pos.py);
|
} else if (keysUp() & KEY_TOUCH) { // stylus was lifted
|
||||||
|
Input_RemoveTouch(0, curX, curY);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -115,7 +115,6 @@ void Window_ProcessEvents(double delta) {
|
|||||||
if (keyboardOpen) {
|
if (keyboardOpen) {
|
||||||
keyboardUpdate();
|
keyboardUpdate();
|
||||||
} else {
|
} else {
|
||||||
Input_SetNonRepeatable(CCMOUSE_L, keys & KEY_TOUCH);
|
|
||||||
ProcessTouchInput(keys);
|
ProcessTouchInput(keys);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -124,17 +123,7 @@ void Cursor_SetPosition(int x, int y) { } // Makes no sense for PSP
|
|||||||
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;
|
|
||||||
touchRead(&touch);
|
|
||||||
|
|
||||||
Event_RaiseRawMove(&PointerEvents.RawMoved,
|
|
||||||
touch.px - touchBegX, touch.py - touchBegY);
|
|
||||||
touchBegX = touch.px;
|
|
||||||
touchBegY = touch.py;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/*########################################################################################################################*
|
/*########################################################################################################################*
|
||||||
|
Loading…
x
Reference in New Issue
Block a user