Skip to content

Commit

Permalink
Merge pull request #5 from vgmoose/master
Browse files Browse the repository at this point in the history
Provide SDL touch info via InputManager
  • Loading branch information
xhp-creations authored Oct 12, 2019
2 parents 1ead920 + b9b068f commit f671b8b
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
9 changes: 9 additions & 0 deletions QuickSDL/InputManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -230,6 +230,10 @@ namespace QuickSDL {
return Vector2((float)mMouseXPos, (float)mMouseYPos);
}

Vector2 InputManager::TouchPos() {
return Vector2((float)mTouchXPos, (float)mTouchYPos);
}

bool InputManager::MouseButtonDown(MOUSE_BUTTON button) {

//mask to be using for bit wise operations
Expand Down Expand Up @@ -345,6 +349,11 @@ namespace QuickSDL {
//Updating the mouse state to get the key states of the current frame
mMouseState = SDL_GetMouseState(&mMouseXPos, &mMouseYPos);

SDL_Finger* touchState = SDL_GetTouchFinger(0, 0);
if (touchState != NULL) {
mTouchXPos = touchState->x;
mTouchYPos = touchState->y;
}

if (joy != NULL) {

Expand Down
4 changes: 4 additions & 0 deletions QuickSDL/InputManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,9 @@ namespace QuickSDL {
int mMouseXPos;
int mMouseYPos;

int mTouchXPos;
int mTouchYPos;

SDL_Joystick* joy;

Uint8* mPrevJoyButtonState;
Expand Down Expand Up @@ -148,6 +151,7 @@ namespace QuickSDL {
//Returns a Vector2 containing the current mouse position on screen
//------------------------------------------------------------------
Vector2 MousePos();
Vector2 TouchPos();

bool JoyButtonDown(int button);
bool JoyButtonPressed(int button);
Expand Down

0 comments on commit f671b8b

Please sign in to comment.