annotate src/video/ataricommon/SDL_ikbdevents.c @ 1361:19418e4422cb

New configure-based build system. Still work in progress, but much improved
author Sam Lantinga <slouken@libsdl.org>
date Thu, 16 Feb 2006 10:11:48 +0000
parents c71e05b4dc2e
children d910939febfa
rev   line source
281
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1 /*
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2 SDL - Simple DirectMedia Layer
1312
c9b51268668f Updated copyright information and removed rcs id lines (problematic in branch merges)
Sam Lantinga <slouken@libsdl.org>
parents: 1221
diff changeset
3 Copyright (C) 1997-2006 Sam Lantinga
281
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
5 This library is free software; you can redistribute it and/or
1312
c9b51268668f Updated copyright information and removed rcs id lines (problematic in branch merges)
Sam Lantinga <slouken@libsdl.org>
parents: 1221
diff changeset
6 modify it under the terms of the GNU Lesser General Public
281
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
7 License as published by the Free Software Foundation; either
1312
c9b51268668f Updated copyright information and removed rcs id lines (problematic in branch merges)
Sam Lantinga <slouken@libsdl.org>
parents: 1221
diff changeset
8 version 2.1 of the License, or (at your option) any later version.
281
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
9
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
10 This library is distributed in the hope that it will be useful,
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
1312
c9b51268668f Updated copyright information and removed rcs id lines (problematic in branch merges)
Sam Lantinga <slouken@libsdl.org>
parents: 1221
diff changeset
13 Lesser General Public License for more details.
281
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
14
1312
c9b51268668f Updated copyright information and removed rcs id lines (problematic in branch merges)
Sam Lantinga <slouken@libsdl.org>
parents: 1221
diff changeset
15 You should have received a copy of the GNU Lesser General Public
c9b51268668f Updated copyright information and removed rcs id lines (problematic in branch merges)
Sam Lantinga <slouken@libsdl.org>
parents: 1221
diff changeset
16 License along with this library; if not, write to the Free Software
c9b51268668f Updated copyright information and removed rcs id lines (problematic in branch merges)
Sam Lantinga <slouken@libsdl.org>
parents: 1221
diff changeset
17 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
281
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
18
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
19 Sam Lantinga
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
20 slouken@libsdl.org
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
21 */
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
22
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
23 /*
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
24 * Atari keyboard events manager, using hardware IKBD
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
25 *
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
26 * Patrice Mandin
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
27 */
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
28
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
29 /* Mint includes */
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
30 #include <mint/osbind.h>
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
31
1361
19418e4422cb New configure-based build system. Still work in progress, but much improved
Sam Lantinga <slouken@libsdl.org>
parents: 1358
diff changeset
32 #include "../../events/SDL_sysevents.h"
19418e4422cb New configure-based build system. Still work in progress, but much improved
Sam Lantinga <slouken@libsdl.org>
parents: 1358
diff changeset
33 #include "../../events/SDL_events_c.h"
281
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
34
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
35 #include "SDL_atarikeys.h"
1209
a55ac374271c Added preliminary missingtranslation from Atari to Unicode charset
Patrice Mandin <patmandin@gmail.com>
parents: 1082
diff changeset
36 #include "SDL_atarievents_c.h"
281
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
37 #include "SDL_ikbdinterrupt_s.h"
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
38
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
39 /* Special keys state */
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
40 enum {
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
41 K_RSHIFT=0,
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
42 K_LSHIFT,
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
43 K_CTRL,
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
44 K_ALT,
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
45 K_CAPSLOCK,
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
46 K_CLRHOME,
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
47 K_INSERT
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
48 };
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
49
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
50 #define ATARIBIOS_MAXKEYS 128
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
51
1082
48436ffdf677 Avoid generating multiple key press/release messages for the same key
Patrice Mandin <patmandin@gmail.com>
parents: 769
diff changeset
52 #define KEY_PRESSED 0xff
48436ffdf677 Avoid generating multiple key press/release messages for the same key
Patrice Mandin <patmandin@gmail.com>
parents: 769
diff changeset
53 #define KEY_UNDEFINED 0x80
48436ffdf677 Avoid generating multiple key press/release messages for the same key
Patrice Mandin <patmandin@gmail.com>
parents: 769
diff changeset
54 #define KEY_RELEASED 0x00
281
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
55
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
56 /* The translation tables from a console scancode to a SDL keysym */
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
57 #define KT_NOCHANGE -1
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
58
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
59 enum {
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
60 KT_UNSHIFT=0,
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
61 KT_SHIFT=1,
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
62 KT_CAPS=2
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
63 };
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
64
1082
48436ffdf677 Avoid generating multiple key press/release messages for the same key
Patrice Mandin <patmandin@gmail.com>
parents: 769
diff changeset
65 static Uint16 atari_prevmouseb; /* save state of mouse buttons */
48436ffdf677 Avoid generating multiple key press/release messages for the same key
Patrice Mandin <patmandin@gmail.com>
parents: 769
diff changeset
66 static int caps_state; /* caps lock state */
281
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
67 _KEYTAB *curtables;
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
68 static unsigned char *tab_unshift, *tab_shift, *tab_caps;
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
69 static SDLKey keymap[ATARIBIOS_MAXKEYS];
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
70
1209
a55ac374271c Added preliminary missingtranslation from Atari to Unicode charset
Patrice Mandin <patmandin@gmail.com>
parents: 1082
diff changeset
71 static SDL_keysym *TranslateKey(int scancode, int numkeytable, SDL_keysym *keysym,
a55ac374271c Added preliminary missingtranslation from Atari to Unicode charset
Patrice Mandin <patmandin@gmail.com>
parents: 1082
diff changeset
72 SDL_bool pressed);
281
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
73
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
74 void AtariIkbd_InitOSKeymap(_THIS)
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
75 {
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
76 int i;
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
77
1336
3692456e7b0f Use SDL_ prefixed versions of C library functions.
Sam Lantinga <slouken@libsdl.org>
parents: 1312
diff changeset
78 SDL_memset(SDL_AtariIkbd_keyboard, KEY_UNDEFINED, ATARIBIOS_MAXKEYS);
281
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
79
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
80 /* Initialize keymap */
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
81 for ( i=0; i<sizeof(keymap); i++ )
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
82 keymap[i] = SDLK_UNKNOWN;
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
83
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
84 /* Functions keys */
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
85 for ( i = 0; i<10; i++ )
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
86 keymap[SCANCODE_F1 + i] = SDLK_F1+i;
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
87
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
88 /* Cursor keypad */
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
89 keymap[SCANCODE_HELP] = SDLK_HELP;
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
90 keymap[SCANCODE_UNDO] = SDLK_UNDO;
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
91 keymap[SCANCODE_INSERT] = SDLK_INSERT;
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
92 keymap[SCANCODE_CLRHOME] = SDLK_HOME;
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
93 keymap[SCANCODE_UP] = SDLK_UP;
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
94 keymap[SCANCODE_DOWN] = SDLK_DOWN;
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
95 keymap[SCANCODE_RIGHT] = SDLK_RIGHT;
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
96 keymap[SCANCODE_LEFT] = SDLK_LEFT;
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
97
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
98 /* Special keys */
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
99 keymap[SCANCODE_ESCAPE] = SDLK_ESCAPE;
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
100 keymap[SCANCODE_BACKSPACE] = SDLK_BACKSPACE;
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
101 keymap[SCANCODE_TAB] = SDLK_TAB;
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
102 keymap[SCANCODE_ENTER] = SDLK_RETURN;
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
103 keymap[SCANCODE_DELETE] = SDLK_DELETE;
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
104 keymap[SCANCODE_LEFTCONTROL] = SDLK_LCTRL;
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
105 keymap[SCANCODE_LEFTSHIFT] = SDLK_LSHIFT;
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
106 keymap[SCANCODE_RIGHTSHIFT] = SDLK_RSHIFT;
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
107 keymap[SCANCODE_LEFTALT] = SDLK_LALT;
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
108 keymap[SCANCODE_CAPSLOCK] = SDLK_CAPSLOCK;
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
109
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
110 /* Read XBIOS tables for scancode -> ascii translation */
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
111 curtables=Keytbl(KT_NOCHANGE, KT_NOCHANGE, KT_NOCHANGE);
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
112 tab_unshift=curtables->unshift;
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
113 tab_shift=curtables->shift;
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
114 tab_caps=curtables->caps;
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
115
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
116 /* Set Caps lock initial state */
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
117 caps_state=(Kbshift(-1) & (1<<K_CAPSLOCK));
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
118
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
119 /* Now install our handler */
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
120 SDL_AtariIkbd_mouseb = SDL_AtariIkbd_mousex = SDL_AtariIkbd_mousey = 0;
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
121 atari_prevmouseb = 0;
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
122
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
123 Supexec(SDL_AtariIkbdInstall);
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
124 }
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
125
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
126 static int atari_GetButton(int button)
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
127 {
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
128 switch(button)
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
129 {
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
130 case 0:
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
131 return SDL_BUTTON_RIGHT;
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
132 break;
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
133 case 1:
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
134 default:
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
135 return SDL_BUTTON_LEFT;
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
136 break;
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
137 }
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
138 }
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
139
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
140 void AtariIkbd_PumpEvents(_THIS)
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
141 {
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
142 int i;
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
143 SDL_keysym keysym;
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
144 int specialkeys;
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
145
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
146 /*--- Send keyboard events ---*/
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
147
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
148 /* Update caps lock state */
1082
48436ffdf677 Avoid generating multiple key press/release messages for the same key
Patrice Mandin <patmandin@gmail.com>
parents: 769
diff changeset
149 if (SDL_AtariIkbd_keyboard[SCANCODE_CAPSLOCK]==KEY_PRESSED) {
281
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
150 caps_state ^= 1;
1082
48436ffdf677 Avoid generating multiple key press/release messages for the same key
Patrice Mandin <patmandin@gmail.com>
parents: 769
diff changeset
151 }
281
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
152
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
153 /* Choose the translation table */
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
154 specialkeys=KT_UNSHIFT;
1082
48436ffdf677 Avoid generating multiple key press/release messages for the same key
Patrice Mandin <patmandin@gmail.com>
parents: 769
diff changeset
155 if ((SDL_AtariIkbd_keyboard[SCANCODE_LEFTSHIFT]==KEY_PRESSED)
48436ffdf677 Avoid generating multiple key press/release messages for the same key
Patrice Mandin <patmandin@gmail.com>
parents: 769
diff changeset
156 || (SDL_AtariIkbd_keyboard[SCANCODE_RIGHTSHIFT]==KEY_PRESSED))
48436ffdf677 Avoid generating multiple key press/release messages for the same key
Patrice Mandin <patmandin@gmail.com>
parents: 769
diff changeset
157 {
281
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
158 specialkeys = KT_SHIFT;
1082
48436ffdf677 Avoid generating multiple key press/release messages for the same key
Patrice Mandin <patmandin@gmail.com>
parents: 769
diff changeset
159 }
48436ffdf677 Avoid generating multiple key press/release messages for the same key
Patrice Mandin <patmandin@gmail.com>
parents: 769
diff changeset
160 if (caps_state) {
281
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
161 specialkeys = KT_CAPS;
1082
48436ffdf677 Avoid generating multiple key press/release messages for the same key
Patrice Mandin <patmandin@gmail.com>
parents: 769
diff changeset
162 }
281
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
163
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
164 /* Now generate events */
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
165 for (i=0; i<ATARIBIOS_MAXKEYS; i++) {
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
166 /* Key pressed ? */
1082
48436ffdf677 Avoid generating multiple key press/release messages for the same key
Patrice Mandin <patmandin@gmail.com>
parents: 769
diff changeset
167 if (SDL_AtariIkbd_keyboard[i]==KEY_PRESSED) {
1209
a55ac374271c Added preliminary missingtranslation from Atari to Unicode charset
Patrice Mandin <patmandin@gmail.com>
parents: 1082
diff changeset
168 SDL_PrivateKeyboard(SDL_PRESSED,
a55ac374271c Added preliminary missingtranslation from Atari to Unicode charset
Patrice Mandin <patmandin@gmail.com>
parents: 1082
diff changeset
169 TranslateKey(i, specialkeys, &keysym, SDL_TRUE));
1082
48436ffdf677 Avoid generating multiple key press/release messages for the same key
Patrice Mandin <patmandin@gmail.com>
parents: 769
diff changeset
170 SDL_AtariIkbd_keyboard[i]=KEY_UNDEFINED;
48436ffdf677 Avoid generating multiple key press/release messages for the same key
Patrice Mandin <patmandin@gmail.com>
parents: 769
diff changeset
171 }
281
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
172
1082
48436ffdf677 Avoid generating multiple key press/release messages for the same key
Patrice Mandin <patmandin@gmail.com>
parents: 769
diff changeset
173 /* Key released ? */
48436ffdf677 Avoid generating multiple key press/release messages for the same key
Patrice Mandin <patmandin@gmail.com>
parents: 769
diff changeset
174 if (SDL_AtariIkbd_keyboard[i]==KEY_RELEASED) {
1209
a55ac374271c Added preliminary missingtranslation from Atari to Unicode charset
Patrice Mandin <patmandin@gmail.com>
parents: 1082
diff changeset
175 SDL_PrivateKeyboard(SDL_RELEASED,
a55ac374271c Added preliminary missingtranslation from Atari to Unicode charset
Patrice Mandin <patmandin@gmail.com>
parents: 1082
diff changeset
176 TranslateKey(i, specialkeys, &keysym, SDL_FALSE));
1082
48436ffdf677 Avoid generating multiple key press/release messages for the same key
Patrice Mandin <patmandin@gmail.com>
parents: 769
diff changeset
177 SDL_AtariIkbd_keyboard[i]=KEY_UNDEFINED;
48436ffdf677 Avoid generating multiple key press/release messages for the same key
Patrice Mandin <patmandin@gmail.com>
parents: 769
diff changeset
178 }
281
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
179 }
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
180
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
181 /*--- Send mouse events ---*/
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
182
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
183 /* Mouse motion ? */
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
184 if (SDL_AtariIkbd_mousex || SDL_AtariIkbd_mousey) {
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
185 SDL_PrivateMouseMotion(0, 1, SDL_AtariIkbd_mousex, SDL_AtariIkbd_mousey);
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
186 SDL_AtariIkbd_mousex = SDL_AtariIkbd_mousey = 0;
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
187 }
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
188
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
189 /* Mouse button ? */
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
190 if (SDL_AtariIkbd_mouseb != atari_prevmouseb) {
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
191 for (i=0;i<2;i++) {
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
192 int curbutton, prevbutton;
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
193
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
194 curbutton = SDL_AtariIkbd_mouseb & (1<<i);
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
195 prevbutton = atari_prevmouseb & (1<<i);
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
196
331
e9278438fb3b Date: Thu, 04 Apr 2002 13:27:36 GMT+1
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
197 if (curbutton && !prevbutton) {
281
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
198 SDL_PrivateMouseButton(SDL_PRESSED, atari_GetButton(i), 0, 0);
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
199 }
331
e9278438fb3b Date: Thu, 04 Apr 2002 13:27:36 GMT+1
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
200 if (!curbutton && prevbutton) {
281
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
201 SDL_PrivateMouseButton(SDL_RELEASED, atari_GetButton(i), 0, 0);
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
202 }
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
203 }
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
204 atari_prevmouseb = SDL_AtariIkbd_mouseb;
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
205 }
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
206 }
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
207
1209
a55ac374271c Added preliminary missingtranslation from Atari to Unicode charset
Patrice Mandin <patmandin@gmail.com>
parents: 1082
diff changeset
208 static SDL_keysym *TranslateKey(int scancode, int numkeytable, SDL_keysym *keysym,
a55ac374271c Added preliminary missingtranslation from Atari to Unicode charset
Patrice Mandin <patmandin@gmail.com>
parents: 1082
diff changeset
209 SDL_bool pressed)
281
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
210 {
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
211 unsigned char asciicode;
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
212
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
213 /* Set the keysym information */
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
214 keysym->scancode = scancode;
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
215
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
216 asciicode=0;
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
217 switch(numkeytable) {
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
218 case KT_UNSHIFT:
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
219 asciicode=tab_unshift[scancode];
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
220 break;
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
221 case KT_SHIFT:
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
222 asciicode=tab_shift[scancode];
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
223 break;
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
224 case KT_CAPS:
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
225 asciicode=tab_caps[scancode];
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
226 break;
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
227 }
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
228
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
229 if (asciicode)
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
230 keysym->sym = asciicode;
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
231 else
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
232 keysym->sym = keymap[scancode];
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
233
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
234 keysym->mod = KMOD_NONE;
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
235 keysym->unicode = 0;
1221
8ef3e7e92a91 Use a simple table for Unicode translation
Patrice Mandin <patmandin@gmail.com>
parents: 1209
diff changeset
236 if (SDL_TranslateUNICODE && pressed) {
8ef3e7e92a91 Use a simple table for Unicode translation
Patrice Mandin <patmandin@gmail.com>
parents: 1209
diff changeset
237 keysym->unicode = SDL_AtariToUnicodeTable[asciicode];
1209
a55ac374271c Added preliminary missingtranslation from Atari to Unicode charset
Patrice Mandin <patmandin@gmail.com>
parents: 1082
diff changeset
238 }
281
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
239
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
240 return(keysym);
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
241 }
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
242
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
243 void AtariIkbd_ShutdownEvents(void)
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
244 {
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
245 Supexec(SDL_AtariIkbdUninstall);
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
246 }