Skip to content

Commit

Permalink
SDL_vitatouch.c: Fixed the incorrect touch device IDs
Browse files Browse the repository at this point in the history
- Begining of device ID with 0 violates the SDL's specification that means the 0 is an error, invalid, failure, etc. But on Vita here it's an actual device...
- Replacing 0 and 1 with 1 and 2 to resolve this violation.

(cherry picked from commit dd6c663)
  • Loading branch information
Wohlstand authored and slouken committed Aug 14, 2024
1 parent 95aed34 commit 847a6cc
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/video/vita/SDL_vitatouch.c
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,8 @@ void VITA_InitTouch(void)
}

// Support passing both front and back touch devices in events
SDL_AddTouch((SDL_TouchID)0, SDL_TOUCH_DEVICE_DIRECT, "Front");
SDL_AddTouch((SDL_TouchID)1, SDL_TOUCH_DEVICE_INDIRECT_ABSOLUTE, "Back");
SDL_AddTouch((SDL_TouchID)1, SDL_TOUCH_DEVICE_DIRECT, "Front");
SDL_AddTouch((SDL_TouchID)2, SDL_TOUCH_DEVICE_INDIRECT_ABSOLUTE, "Back");
}

void VITA_QuitTouch(void)
Expand Down

3 comments on commit 847a6cc

@rsn8887
Copy link

@rsn8887 rsn8887 commented on 847a6cc Nov 10, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Did you test this at all?

It is not enough to make this change only. You also have to send the correct touch_ID:
SDL_SendTouchMotion((SDL_TouchID)port,...

Is wrong, it should be port + 1 there.

@Wohlstand
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Whoops, a good note, I tested the thing on my end, and it worked, but I guess, the thing wasn't properly tested in this case, thanks for this catch!

@xfangfang
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I encountered the same issue, and I think that this commit should not be merged into 2.30.x. After checking with other devices under 2.30.x (such as n3ds), the TouchID still starts from 0.

Is it possible that this is due to a change in SDL3 being mistakenly merged into SDL2?

Please sign in to comment.