2 SDL - Simple DirectMedia Layer
3 Copyright (C) 1997-2012 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 * Atari keyboard events manager, using hardware IKBD
31 #include <mint/osbind.h>
33 #include "../../events/SDL_sysevents.h"
34 #include "../../events/SDL_events_c.h"
36 #include "SDL_atarikeys.h"
37 #include "SDL_atarievents_c.h"
38 #include "SDL_ikbdinterrupt_s.h"
40 #define KEY_PRESSED 0xff
41 #define KEY_UNDEFINED 0x80
42 #define KEY_RELEASED 0x00
44 static Uint16 atari_prevmouseb; /* save state of mouse buttons */
46 void AtariIkbd_InitOSKeymap(_THIS)
48 SDL_memset((void *) SDL_AtariIkbd_keyboard, KEY_UNDEFINED, sizeof(SDL_AtariIkbd_keyboard));
50 /* Now install our handler */
51 SDL_AtariIkbd_mouseb = SDL_AtariIkbd_mousex = SDL_AtariIkbd_mousey = 0;
54 Supexec(SDL_AtariIkbdInstall);
57 static int atari_GetButton(int button)
62 return SDL_BUTTON_RIGHT;
66 return SDL_BUTTON_LEFT;
71 void AtariIkbd_PumpEvents(_THIS)
76 /*--- Send keyboard events ---*/
78 for (i=0; i<ATARIBIOS_MAXKEYS; i++) {
80 if (SDL_AtariIkbd_keyboard[i]==KEY_PRESSED) {
81 SDL_PrivateKeyboard(SDL_PRESSED,
82 SDL_Atari_TranslateKey(i, &keysym, SDL_TRUE));
83 SDL_AtariIkbd_keyboard[i]=KEY_UNDEFINED;
87 if (SDL_AtariIkbd_keyboard[i]==KEY_RELEASED) {
88 SDL_PrivateKeyboard(SDL_RELEASED,
89 SDL_Atari_TranslateKey(i, &keysym, SDL_FALSE));
90 SDL_AtariIkbd_keyboard[i]=KEY_UNDEFINED;
94 /*--- Send mouse events ---*/
97 if (SDL_AtariIkbd_mousex || SDL_AtariIkbd_mousey) {
98 SDL_PrivateMouseMotion(0, 1, SDL_AtariIkbd_mousex, SDL_AtariIkbd_mousey);
99 SDL_AtariIkbd_mousex = SDL_AtariIkbd_mousey = 0;
103 if (SDL_AtariIkbd_mouseb != atari_prevmouseb) {
105 int curbutton, prevbutton;
107 curbutton = SDL_AtariIkbd_mouseb & (1<<i);
108 prevbutton = atari_prevmouseb & (1<<i);
110 if (curbutton && !prevbutton) {
111 SDL_PrivateMouseButton(SDL_PRESSED, atari_GetButton(i), 0, 0);
113 if (!curbutton && prevbutton) {
114 SDL_PrivateMouseButton(SDL_RELEASED, atari_GetButton(i), 0, 0);
117 atari_prevmouseb = SDL_AtariIkbd_mouseb;
121 void AtariIkbd_ShutdownEvents(void)
123 Supexec(SDL_AtariIkbdUninstall);