@@ -63,7 +63,7 @@ bool UIKit_InitPen(SDL_VideoDevice *_this)
6363// we only have one Apple Pencil at a time, and it must be paired to the iOS device.
6464// We only know about its existence when it first sends an event, so add an single SDL pen
6565// device here if we haven't already.
66- static SDL_PenID UIKit_AddPenIfNecesary ()
66+ static SDL_PenID UIKit_AddPenIfNecesary (SDL_Window *window )
6767{
6868 if (!apple_pencil_id) {
6969 SDL_PenInfo info;
@@ -86,7 +86,7 @@ static SDL_PenID UIKit_AddPenIfNecesary()
8686 // so we can't use it for tangential pressure.
8787
8888 // There's only ever one Apple Pencil at most, so we just pass a non-zero value for the handle.
89- apple_pencil_id = SDL_AddPenDevice (0 , " Apple Pencil" , &info, (void *) (size_t ) 0x1 );
89+ apple_pencil_id = SDL_AddPenDevice (0 , " Apple Pencil" , window, &info, (void *) (size_t ) 0x1 );
9090 }
9191
9292 return apple_pencil_id;
@@ -95,7 +95,7 @@ static SDL_PenID UIKit_AddPenIfNecesary()
9595static void UIKit_HandlePenAxes (SDL_Window *window, NSTimeInterval nstimestamp, float zOffset, const CGPoint *point, float force,
9696 float maximumPossibleForce, float azimuthAngleInView, float altitudeAngle, float rollAngle)
9797{
98- const SDL_PenID penId = UIKit_AddPenIfNecesary ();
98+ const SDL_PenID penId = UIKit_AddPenIfNecesary (window );
9999 if (penId) {
100100 const Uint64 timestamp = UIKit_GetEventTimestamp (nstimestamp);
101101 const float radians_to_degrees = 180 .0f / SDL_PI_F;
@@ -188,26 +188,28 @@ void UIKit_HandlePenMotion(SDL_uikitview *view, UITouch *pencil)
188188
189189void UIKit_HandlePenPress (SDL_uikitview *view, UITouch *pencil)
190190{
191- const SDL_PenID penId = UIKit_AddPenIfNecesary ();
191+ SDL_Window *window = [view getSDLWindow ];
192+ const SDL_PenID penId = UIKit_AddPenIfNecesary (window);
192193 if (penId) {
193194 UIKit_HandlePenAxesFromUITouch (view, pencil);
194- SDL_SendPenTouch (UIKit_GetEventTimestamp ([pencil timestamp ]), penId, [view getSDLWindow ] , false , true );
195+ SDL_SendPenTouch (UIKit_GetEventTimestamp ([pencil timestamp ]), penId, window , false , true );
195196 }
196197}
197198
198199void UIKit_HandlePenRelease (SDL_uikitview *view, UITouch *pencil)
199200{
200- const SDL_PenID penId = UIKit_AddPenIfNecesary ();
201+ SDL_Window *window = [view getSDLWindow ];
202+ const SDL_PenID penId = UIKit_AddPenIfNecesary (window);
201203 if (penId) {
202- SDL_SendPenTouch (UIKit_GetEventTimestamp ([pencil timestamp ]), penId, [view getSDLWindow ] , false , false );
204+ SDL_SendPenTouch (UIKit_GetEventTimestamp ([pencil timestamp ]), penId, window , false , false );
203205 UIKit_HandlePenAxesFromUITouch (view, pencil);
204206 }
205207}
206208
207209void UIKit_QuitPen (SDL_VideoDevice *_this)
208210{
209211 if (apple_pencil_id) {
210- SDL_RemovePenDevice (0 , apple_pencil_id);
212+ SDL_RemovePenDevice (0 , NULL , apple_pencil_id);
211213 apple_pencil_id = 0 ;
212214 }
213215}
0 commit comments