Mercurial > sdl-ios-xcode
comparison src/video/gem/SDL_gemevents.c @ 4564:5002d6aeb85c SDL-1.2
Use proper GEM API to handle mouse button events
author | Patrice Mandin <patmandin@gmail.com> |
---|---|
date | Fri, 09 Jul 2010 17:19:18 +0200 |
parents | a1b03ba2fcd0 |
children |
comparison
equal
deleted
inserted
replaced
4557:4aa31b9207f2 | 4564:5002d6aeb85c |
---|---|
65 SDL_Atari_InitInternalKeymap(this); | 65 SDL_Atari_InitInternalKeymap(this); |
66 } | 66 } |
67 | 67 |
68 void GEM_PumpEvents(_THIS) | 68 void GEM_PumpEvents(_THIS) |
69 { | 69 { |
70 short mousex, mousey, mouseb, dummy; | 70 short prevkc, prevks; |
71 short kstate, prevkc, prevks; | 71 static short maskmouseb=0; |
72 int i; | 72 int i; |
73 SDL_keysym keysym; | 73 SDL_keysym keysym; |
74 | 74 |
75 SDL_memset(gem_currentkeyboard,0,sizeof(gem_currentkeyboard)); | 75 SDL_memset(gem_currentkeyboard,0,sizeof(gem_currentkeyboard)); |
76 prevkc = prevks = 0; | 76 prevkc = prevks = 0; |
77 | 77 |
78 for (;;) | 78 for (;;) |
79 { | 79 { |
80 int quit, resultat, event_mask, mouse_event; | 80 int quit, resultat, event_mask, mouse_event; |
81 short buffer[8], kc; | 81 short buffer[8], kc; |
82 short x2,y2,w2,h2; | 82 short x2,y2,w2,h2; |
83 short mousex, mousey, mouseb, dummy; | |
84 short kstate; | |
83 | 85 |
84 quit = | 86 quit = |
85 mouse_event = | 87 mouse_event = |
86 x2=y2=w2=h2 = 0; | 88 x2=y2=w2=h2 = 0; |
87 | 89 |
88 event_mask = MU_MESAG|MU_TIMER|MU_KEYBD; | 90 event_mask = MU_MESAG|MU_TIMER|MU_KEYBD|MU_BUTTON; |
89 if (!GEM_fullscreen && (GEM_handle>=0)) { | 91 if (!GEM_fullscreen && (GEM_handle>=0)) { |
90 wind_get (GEM_handle, WF_WORKXYWH, &x2, &y2, &w2, &h2); | 92 wind_get (GEM_handle, WF_WORKXYWH, &x2, &y2, &w2, &h2); |
91 event_mask |= MU_M1; | 93 event_mask |= MU_M1; |
92 mouse_event = ( (SDL_GetAppState() & SDL_APPMOUSEFOCUS) | 94 mouse_event = ( (SDL_GetAppState() & SDL_APPMOUSEFOCUS) |
93 == SDL_APPMOUSEFOCUS) ? MO_LEAVE : MO_ENTER; | 95 == SDL_APPMOUSEFOCUS) ? MO_LEAVE : MO_ENTER; |
94 } | 96 } |
95 | 97 |
96 resultat = evnt_multi( | 98 resultat = evnt_multi( |
97 event_mask, | 99 event_mask, |
98 0,0,0, | 100 0x101,7,maskmouseb, |
99 mouse_event,x2,y2,w2,h2, | 101 mouse_event,x2,y2,w2,h2, |
100 0,0,0,0,0, | 102 0,0,0,0,0, |
101 buffer, | 103 buffer, |
102 10, | 104 10, |
103 &dummy,&dummy,&dummy,&kstate,&kc,&dummy | 105 &mousex,&mousey,&mouseb,&kstate,&kc,&dummy |
104 ); | 106 ); |
105 | 107 |
106 /* Message event ? */ | 108 /* Message event ? */ |
107 if (resultat & MU_MESAG) | 109 if (resultat & MU_MESAG) |
108 quit = do_messages(this, buffer); | 110 quit = do_messages(this, buffer); |
125 SDL_APPMOUSEFOCUS); | 127 SDL_APPMOUSEFOCUS); |
126 } | 128 } |
127 GEM_CheckMouseMode(this); | 129 GEM_CheckMouseMode(this); |
128 } | 130 } |
129 | 131 |
132 /* Mouse button event ? */ | |
133 if (resultat & MU_BUTTON) { | |
134 do_mouse(this, mousex, mousey, mouseb, kstate); | |
135 maskmouseb = mouseb & 7; | |
136 } | |
137 | |
130 /* Timer event ? */ | 138 /* Timer event ? */ |
131 if ((resultat & MU_TIMER) || quit) | 139 if ((resultat & MU_TIMER) || quit) |
132 break; | 140 break; |
133 } | 141 } |
134 | |
135 /* Update mouse */ | |
136 graf_mkstate(&mousex, &mousey, &mouseb, &kstate); | |
137 do_mouse(this, mousex, mousey, mouseb, kstate); | |
138 | 142 |
139 /* Now generate keyboard events */ | 143 /* Now generate keyboard events */ |
140 for (i=0; i<ATARIBIOS_MAXKEYS; i++) { | 144 for (i=0; i<ATARIBIOS_MAXKEYS; i++) { |
141 /* Key pressed ? */ | 145 /* Key pressed ? */ |
142 if (gem_currentkeyboard[i] && !gem_previouskeyboard[i]) | 146 if (gem_currentkeyboard[i] && !gem_previouskeyboard[i]) |
340 | 344 |
341 /* Mouse button ? */ | 345 /* Mouse button ? */ |
342 if (prevmouseb!=mb) { | 346 if (prevmouseb!=mb) { |
343 int i; | 347 int i; |
344 | 348 |
345 for (i=0;i<2;i++) { | 349 for (i=0;i<3;i++) { |
346 int curbutton, prevbutton; | 350 int curbutton, prevbutton; |
347 | 351 |
348 curbutton = mb & (1<<i); | 352 curbutton = mb & (1<<i); |
349 prevbutton = prevmouseb & (1<<i); | 353 prevbutton = prevmouseb & (1<<i); |
350 | 354 |