diff options
| author | StapleButter <thetotalworm@gmail.com> | 2017-09-17 23:36:28 +0200 | 
|---|---|---|
| committer | StapleButter <thetotalworm@gmail.com> | 2017-09-17 23:36:28 +0200 | 
| commit | f30e19a2ec8dff11180a7a101a1368eb4a2d6d08 (patch) | |
| tree | ec619fecd1989e7d7eea10a81537cde02ae9232c /src | |
| parent | 8e7d46e717cc189681608adceeec84bb483b8f70 (diff) | |
touchscreen input
Diffstat (limited to 'src')
| -rw-r--r-- | src/libui_sdl/main.cpp | 32 | 
1 files changed, 31 insertions, 1 deletions
| diff --git a/src/libui_sdl/main.cpp b/src/libui_sdl/main.cpp index 52c8117..5cbe750 100644 --- a/src/libui_sdl/main.cpp +++ b/src/libui_sdl/main.cpp @@ -41,6 +41,8 @@ int EmuRunning;  SDL_mutex* ScreenMutex;  uiDrawBitmap* ScreenBitmap = NULL; +bool Touching = false; +  void AudioCallback(void* data, Uint8* stream, int len)  { @@ -51,6 +53,8 @@ int EmuThreadFunc(void* burp)  {      NDS::Init(); +    Touching = false; +      // DS:      // 547.060546875 samples per frame      // 32823.6328125 samples per second @@ -173,7 +177,33 @@ void OnAreaMouseEvent(uiAreaHandler* handler, uiArea* area, uiAreaMouseEvent* ev  {      int x = (int)evt->X;      int y = (int)evt->Y; -    printf("mouse: %08X %d,%d\n", (u32)evt->Held1To64, x, y); + +    if (Touching && (evt->Up == 1)) +    { +        Touching = false; +        NDS::ReleaseKey(16+6); +        NDS::ReleaseScreen(); +    } +    else if (!Touching && (evt->Down == 1) && (y >= 192)) +    { +        Touching = true; +        NDS::PressKey(16+6); +        // TODO: scaling/offset as needed +    } + +    if (Touching) +    { +        // TODO: scaling, here too +        y -= 192; + +        // clamp +        if (x < 0) x = 0; +        else if (x > 255) x = 255; +        if (y < 0) y = 0; +        else if (y > 191) y = 191; + +        NDS::TouchScreen(x, y); +    }  }  void OnAreaMouseCrossed(uiAreaHandler* handler, uiArea* area, int left) |