src/video/cocoa/SDL_cocoawindow.m
changeset 4676 99b4560b7aa1
parent 4675 641c13b0ce5f
child 4678 f8431f66613d
equal deleted inserted replaced
4675:641c13b0ce5f 4676:99b4560b7aa1
    25 #include "../SDL_sysvideo.h"
    25 #include "../SDL_sysvideo.h"
    26 #include "../../events/SDL_keyboard_c.h"
    26 #include "../../events/SDL_keyboard_c.h"
    27 #include "../../events/SDL_mouse_c.h"
    27 #include "../../events/SDL_mouse_c.h"
    28 #include "../../events/SDL_touch_c.h"
    28 #include "../../events/SDL_touch_c.h"
    29 #include "../../events/SDL_windowevents_c.h"
    29 #include "../../events/SDL_windowevents_c.h"
    30 
       
    31 #include "SDL_cocoavideo.h"
    30 #include "SDL_cocoavideo.h"
    32 
    31 
    33 static __inline__ void ConvertNSRect(NSRect *r)
    32 static __inline__ void ConvertNSRect(NSRect *r)
    34 {
    33 {
    35     r->origin.y = CGDisplayPixelsHigh(kCGDirectMainDisplay) - r->origin.y - r->size.height;
    34     r->origin.y = CGDisplayPixelsHigh(kCGDirectMainDisplay) - r->origin.y - r->size.height;
   297     NSEnumerator *enumerator = [touches objectEnumerator];
   296     NSEnumerator *enumerator = [touches objectEnumerator];
   298     NSTouch *touch = (NSTouch*)[enumerator nextObject];
   297     NSTouch *touch = (NSTouch*)[enumerator nextObject];
   299     while (touch) {
   298     while (touch) {
   300         long touchId = (long)[touch device];
   299         long touchId = (long)[touch device];
   301         if (!SDL_GetTouch(touchId)) {
   300         if (!SDL_GetTouch(touchId)) {
   302 	  printf("Adding touch: %i\n",touchId)
   301 	  printf("Adding touch: %li\n",touchId);
   303             SDL_Touch touch;
   302             SDL_Touch touch;
   304 
   303 
   305             touch.id = touchId;
   304             touch.id = touchId;
   306             touch.x_min = 0;
   305             touch.x_min = 0;
   307             touch.x_max = 1;
   306             touch.x_max = 1;
   314             touch.pressureres = touch.pressure_max - touch.pressure_min;
   313             touch.pressureres = touch.pressure_max - touch.pressure_min;
   315             
   314             
   316             if (SDL_AddTouch(&touch, "") < 0) {
   315             if (SDL_AddTouch(&touch, "") < 0) {
   317                 continue;
   316                 continue;
   318             }
   317             }
   319 	    printf("Success, added touch: %i\n",touchId)
   318 	    printf("Success, added touch: %lin",touchId);
   320         } 
   319         } 
   321         float x = [touch normalizedPosition].x;
   320         float x = [touch normalizedPosition].x;
   322         float y = [touch normalizedPosition].y;
   321         float y = [touch normalizedPosition].y;
   323         long fingerId = (long)[touch identity];
   322         long fingerId = (long)[touch identity];
   324         switch (type) {
   323         switch (type) {