Mercurial > sdl-ios-xcode
comparison src/video/ataricommon/SDL_xbiosevents.c @ 305:9c6613983e85
Atari port cleanups from Patrice
author | Sam Lantinga <slouken@libsdl.org> |
---|---|
date | Sun, 10 Mar 2002 03:33:59 +0000 |
parents | |
children | e9278438fb3b |
comparison
equal
deleted
inserted
replaced
304:ec53caed9fb2 | 305:9c6613983e85 |
---|---|
1 /* | |
2 SDL - Simple DirectMedia Layer | |
3 Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002 Sam Lantinga | |
4 | |
5 This library is free software; you can redistribute it and/or | |
6 modify it under the terms of the GNU Library General Public | |
7 License as published by the Free Software Foundation; either | |
8 version 2 of the License, or (at your option) any later version. | |
9 | |
10 This library is distributed in the hope that it will be useful, | |
11 but WITHOUT ANY WARRANTY; without even the implied warranty of | |
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
13 Library General Public License for more details. | |
14 | |
15 You should have received a copy of the GNU Library General Public | |
16 License along with this library; if not, write to the Free | |
17 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | |
18 | |
19 Sam Lantinga | |
20 slouken@libsdl.org | |
21 */ | |
22 | |
23 #ifdef SAVE_RCSID | |
24 static char rcsid = | |
25 "@(#) $Id$"; | |
26 #endif | |
27 | |
28 /* | |
29 * XBIOS mouse & joystick vectors | |
30 * | |
31 * Patrice Mandin | |
32 */ | |
33 | |
34 #include <stdlib.h> | |
35 #include <string.h> | |
36 #include <mint/osbind.h> | |
37 | |
38 #include "SDL_events_c.h" | |
39 #include "SDL_xbiosevents_c.h" | |
40 #include "SDL_xbiosinterrupt_s.h" | |
41 | |
42 /* Variables */ | |
43 | |
44 int SDL_AtariXbios_enabled=0; | |
45 | |
46 static _KBDVECS *kbdvecs; /* Pointer to access vectors */ | |
47 static _KBDVECS sys_kbdvecs; /* Backup of system vectors */ | |
48 static Uint16 atari_prevmouseb; /* buttons */ | |
49 | |
50 void SDL_AtariXbios_InstallVectors(int vectors_mask) | |
51 { | |
52 void *oldpile; | |
53 | |
54 /* Clear variables */ | |
55 SDL_AtariXbios_mouseb = | |
56 SDL_AtariXbios_mousex = | |
57 SDL_AtariXbios_mousey = | |
58 SDL_AtariXbios_joystick = | |
59 atari_prevmouseb = 0; | |
60 | |
61 /* Read IKBD vectors base */ | |
62 kbdvecs=Kbdvbase(); | |
63 | |
64 /* Go to supervisor mode */ | |
65 oldpile=(void *)Super(0); | |
66 | |
67 /* Backup system vectors */ | |
68 memcpy(&sys_kbdvecs, kbdvecs, sizeof(_KBDVECS)); | |
69 | |
70 /* Install our vector */ | |
71 SDL_AtariXbios_Install( | |
72 kbdvecs, | |
73 (vectors_mask & ATARI_XBIOS_MOUSEEVENTS) ? SDL_AtariXbios_MouseVector : NULL, | |
74 (vectors_mask & ATARI_XBIOS_JOYSTICKEVENTS) ? SDL_AtariXbios_JoystickVector : NULL | |
75 ); | |
76 | |
77 /* Back to user mode */ | |
78 Super(oldpile); | |
79 | |
80 SDL_AtariXbios_enabled=1; | |
81 } | |
82 | |
83 void SDL_AtariXbios_RestoreVectors(void) | |
84 { | |
85 void *oldpile; | |
86 | |
87 /* Go to supervisor mode */ | |
88 oldpile=(void *)Super(NULL); | |
89 | |
90 /* Reinstall system vector */ | |
91 SDL_AtariXbios_Install(kbdvecs,sys_kbdvecs.mousevec,sys_kbdvecs.joyvec); | |
92 | |
93 /* Back to user mode */ | |
94 Super(oldpile); | |
95 } | |
96 | |
97 static int atari_GetButton(int button) | |
98 { | |
99 switch(button) | |
100 { | |
101 case 0: | |
102 return SDL_BUTTON_RIGHT; | |
103 break; | |
104 case 1: | |
105 default: | |
106 return SDL_BUTTON_LEFT; | |
107 break; | |
108 } | |
109 } | |
110 | |
111 void SDL_AtariXbios_PostMouseEvents(_THIS) | |
112 { | |
113 /* Mouse motion ? */ | |
114 if (SDL_AtariXbios_mousex || SDL_AtariXbios_mousey) { | |
115 SDL_PrivateMouseMotion(0, 1, SDL_AtariXbios_mousex, SDL_AtariXbios_mousey); | |
116 SDL_AtariXbios_mousex = SDL_AtariXbios_mousey = 0; | |
117 } | |
118 | |
119 /* Mouse button ? */ | |
120 if (SDL_AtariXbios_mouseb != atari_prevmouseb) { | |
121 int i; | |
122 | |
123 for (i=0;i<2;i++) { | |
124 int curbutton, prevbutton; | |
125 | |
126 curbutton = SDL_AtariXbios_mouseb & (1<<i); | |
127 prevbutton = atari_prevmouseb & (1<<i); | |
128 | |
129 if (curbutton & !prevbutton) { | |
130 SDL_PrivateMouseButton(SDL_PRESSED, atari_GetButton(i), 0, 0); | |
131 } | |
132 if (!curbutton & prevbutton) { | |
133 SDL_PrivateMouseButton(SDL_RELEASED, atari_GetButton(i), 0, 0); | |
134 } | |
135 } | |
136 atari_prevmouseb = SDL_AtariXbios_mouseb; | |
137 } | |
138 } |