Mercurial > sdl-ios-xcode
comparison src/video/ataricommon/SDL_xbiosmouseevents.c @ 281:c5010ab8ba35
Added initial support for Atari (thanks Patrice!)
author | Sam Lantinga <slouken@libsdl.org> |
---|---|
date | Sun, 17 Feb 2002 19:54:28 +0000 |
parents | |
children | f6ffac90895c |
comparison
equal
deleted
inserted
replaced
280:0ddcea45d829 | 281:c5010ab8ba35 |
---|---|
1 /* | |
2 SDL - Simple DirectMedia Layer | |
3 Copyright (C) 1997, 1998, 1999, 2000, 2001 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 * IKBD 6301 mouse vector | |
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_xbiosmouseinterrupt_s.h" | |
40 | |
41 static _KBDVECS *kbdvecs; /* Pointer to access vectors */ | |
42 static _KBDVECS sys_kbdvecs; /* Backup of system vectors */ | |
43 | |
44 /* Variables */ | |
45 | |
46 static Uint16 atari_prevmouseb; /* buttons */ | |
47 | |
48 void AtariXbios_InstallMouseVector(void) | |
49 { | |
50 void *oldpile; | |
51 | |
52 /* Read IKBD vectors base */ | |
53 kbdvecs=Kbdvbase(); | |
54 | |
55 /* Go to supervisor mode */ | |
56 oldpile=(void *)Super(0); | |
57 | |
58 /* Backup system vectors */ | |
59 memcpy(&sys_kbdvecs, kbdvecs, sizeof(_KBDVECS)); | |
60 | |
61 /* Install our vector */ | |
62 SDL_AtariXbiosMouseInstall(kbdvecs,SDL_AtariXbiosMouseVector); | |
63 | |
64 /* Back to user mode */ | |
65 Super(oldpile); | |
66 | |
67 /* Clear variables */ | |
68 SDL_AtariXbios_mouseb = SDL_AtariXbios_mousex = SDL_AtariXbios_mousey = 0; | |
69 atari_prevmouseb = 0; | |
70 } | |
71 | |
72 void AtariXbios_RestoreMouseVector(void) | |
73 { | |
74 void *oldpile; | |
75 | |
76 /* Go to supervisor mode */ | |
77 oldpile=(void *)Super(NULL); | |
78 | |
79 /* Reinstall system vector */ | |
80 SDL_AtariXbiosMouseInstall(kbdvecs,sys_kbdvecs.mousevec); | |
81 | |
82 /* Back to user mode */ | |
83 Super(oldpile); | |
84 } | |
85 | |
86 static int atari_GetButton(int button) | |
87 { | |
88 switch(button) | |
89 { | |
90 case 0: | |
91 return SDL_BUTTON_RIGHT; | |
92 break; | |
93 case 1: | |
94 default: | |
95 return SDL_BUTTON_LEFT; | |
96 break; | |
97 } | |
98 } | |
99 | |
100 void AtariXbios_PostMouseEvents(_THIS) | |
101 { | |
102 /* Mouse motion ? */ | |
103 if (SDL_AtariXbios_mousex || SDL_AtariXbios_mousey) { | |
104 SDL_PrivateMouseMotion(0, 1, SDL_AtariXbios_mousex, SDL_AtariXbios_mousey); | |
105 SDL_AtariXbios_mousex = SDL_AtariXbios_mousey = 0; | |
106 } | |
107 | |
108 /* Mouse button ? */ | |
109 if (SDL_AtariXbios_mouseb != atari_prevmouseb) { | |
110 int i; | |
111 | |
112 for (i=0;i<2;i++) { | |
113 int curbutton, prevbutton; | |
114 | |
115 curbutton = SDL_AtariXbios_mouseb & (1<<i); | |
116 prevbutton = atari_prevmouseb & (1<<i); | |
117 | |
118 if (curbutton & !prevbutton) { | |
119 SDL_PrivateMouseButton(SDL_PRESSED, atari_GetButton(i), 0, 0); | |
120 } | |
121 if (!curbutton & prevbutton) { | |
122 SDL_PrivateMouseButton(SDL_RELEASED, atari_GetButton(i), 0, 0); | |
123 } | |
124 } | |
125 atari_prevmouseb = SDL_AtariXbios_mouseb; | |
126 } | |
127 } |