2 SDL - Simple DirectMedia Layer
3 Copyright (C) 1997-2009 Sam Lantinga
5 This library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version.
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 Lesser General Public License for more details.
15 You should have received a copy of the GNU Lesser General Public
16 License along with this library; if not, write to the Free Software
17 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
22 #include "SDL_config.h"
25 * XBIOS mouse & joystick vectors
30 #include <mint/osbind.h>
32 #include "../../events/SDL_events_c.h"
33 #include "SDL_xbiosevents_c.h"
34 #include "SDL_xbiosinterrupt_s.h"
38 int SDL_AtariXbios_enabled=0;
42 static _KBDVECS *kbdvecs; /* Pointer to access system vectors */
43 static Uint16 atari_prevmouseb; /* buttons */
47 void SDL_AtariXbios_InstallVectors(int vectors_mask)
52 SDL_AtariXbios_mouselock =
53 SDL_AtariXbios_mouseb =
54 SDL_AtariXbios_mousex =
55 SDL_AtariXbios_mousey =
56 SDL_AtariXbios_joystick =
59 if (vectors_mask==0) {
60 SDL_AtariXbios_enabled=0;
64 /* Read IKBD vectors base */
67 /* Go to supervisor mode */
68 oldpile=(void *)Super(0);
70 /* Install our vectors */
71 SDL_AtariXbios_Install(
73 (vectors_mask & ATARI_XBIOS_MOUSEEVENTS) ? SDL_AtariXbios_MouseVector : NULL,
74 (vectors_mask & ATARI_XBIOS_JOYSTICKEVENTS) ? SDL_AtariXbios_JoystickVector : NULL
77 /* Back to user mode */
80 SDL_AtariXbios_enabled=1;
83 void SDL_AtariXbios_RestoreVectors(void)
87 if (SDL_AtariXbios_enabled==0) {
91 /* Read IKBD vectors base */
94 /* Go to supervisor mode */
95 oldpile=(void *)Super(NULL);
97 /* Reinstall system vector */
98 SDL_AtariXbios_Restore(kbdvecs);
100 /* Back to user mode */
104 static int atari_GetButton(int button)
109 return SDL_BUTTON_RIGHT;
113 return SDL_BUTTON_LEFT;
118 void SDL_AtariXbios_PostMouseEvents(_THIS, SDL_bool buttonEvents)
120 if (SDL_AtariXbios_enabled==0) {
125 if (SDL_AtariXbios_mousex || SDL_AtariXbios_mousey) {
126 SDL_PrivateMouseMotion(0, 1, SDL_AtariXbios_mousex, SDL_AtariXbios_mousey);
127 SDL_AtariXbios_mousex = SDL_AtariXbios_mousey = 0;
131 if (buttonEvents && (SDL_AtariXbios_mouseb != atari_prevmouseb)) {
135 int curbutton, prevbutton;
137 curbutton = SDL_AtariXbios_mouseb & (1<<i);
138 prevbutton = atari_prevmouseb & (1<<i);
140 if (curbutton && !prevbutton) {
141 SDL_PrivateMouseButton(SDL_PRESSED, atari_GetButton(i), 0, 0);
143 if (!curbutton && prevbutton) {
144 SDL_PrivateMouseButton(SDL_RELEASED, atari_GetButton(i), 0, 0);
147 atari_prevmouseb = SDL_AtariXbios_mouseb;
151 void SDL_AtariXbios_LockMousePosition(SDL_bool lockPosition)
153 SDL_AtariXbios_mouselock = lockPosition;