diff options
author | Franklin Wei <git@fwei.tk> | 2017-01-21 15:18:31 -0500 |
---|---|---|
committer | Franklin Wei <git@fwei.tk> | 2017-12-23 21:01:26 -0500 |
commit | a855d6202536ff28e5aae4f22a0f31d8f5b325d0 (patch) | |
tree | 8c75f224dd64ed360505afa8843d016b0d75000b /apps/plugins/sdl/src/video/ataricommon/SDL_ikbdevents.c | |
parent | 01c6dcf6c7b9bb1ad2fa0450f99bacc5f3d3e04b (diff) | |
download | rockbox-a855d6202536ff28e5aae4f22a0f31d8f5b325d0.tar.gz rockbox-a855d6202536ff28e5aae4f22a0f31d8f5b325d0.zip |
Port of Duke Nukem 3D
This ports Fabien Sanglard's Chocolate Duke to run on a version of SDL
for Rockbox.
Change-Id: I8f2c4c78af19de10c1633ed7bb7a997b43256dd9
Diffstat (limited to 'apps/plugins/sdl/src/video/ataricommon/SDL_ikbdevents.c')
-rw-r--r-- | apps/plugins/sdl/src/video/ataricommon/SDL_ikbdevents.c | 124 |
1 files changed, 124 insertions, 0 deletions
diff --git a/apps/plugins/sdl/src/video/ataricommon/SDL_ikbdevents.c b/apps/plugins/sdl/src/video/ataricommon/SDL_ikbdevents.c new file mode 100644 index 0000000000..35fc5cb71a --- /dev/null +++ b/apps/plugins/sdl/src/video/ataricommon/SDL_ikbdevents.c | |||
@@ -0,0 +1,124 @@ | |||
1 | /* | ||
2 | SDL - Simple DirectMedia Layer | ||
3 | Copyright (C) 1997-2012 Sam Lantinga | ||
4 | |||
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. | ||
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 | Lesser General Public License for more details. | ||
14 | |||
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 | ||
18 | |||
19 | Sam Lantinga | ||
20 | slouken@libsdl.org | ||
21 | */ | ||
22 | #include "SDL_config.h" | ||
23 | |||
24 | /* | ||
25 | * Atari keyboard events manager, using hardware IKBD | ||
26 | * | ||
27 | * Patrice Mandin | ||
28 | */ | ||
29 | |||
30 | /* Mint includes */ | ||
31 | #include <mint/osbind.h> | ||
32 | |||
33 | #include "../../events/SDL_sysevents.h" | ||
34 | #include "../../events/SDL_events_c.h" | ||
35 | |||
36 | #include "SDL_atarikeys.h" | ||
37 | #include "SDL_atarievents_c.h" | ||
38 | #include "SDL_ikbdinterrupt_s.h" | ||
39 | |||
40 | #define KEY_PRESSED 0xff | ||
41 | #define KEY_UNDEFINED 0x80 | ||
42 | #define KEY_RELEASED 0x00 | ||
43 | |||
44 | static Uint16 atari_prevmouseb; /* save state of mouse buttons */ | ||
45 | |||
46 | void AtariIkbd_InitOSKeymap(_THIS) | ||
47 | { | ||
48 | SDL_memset((void *) SDL_AtariIkbd_keyboard, KEY_UNDEFINED, sizeof(SDL_AtariIkbd_keyboard)); | ||
49 | |||
50 | /* Now install our handler */ | ||
51 | SDL_AtariIkbd_mouseb = SDL_AtariIkbd_mousex = SDL_AtariIkbd_mousey = 0; | ||
52 | atari_prevmouseb = 0; | ||
53 | |||
54 | Supexec(SDL_AtariIkbdInstall); | ||
55 | } | ||
56 | |||
57 | static int atari_GetButton(int button) | ||
58 | { | ||
59 | switch(button) | ||
60 | { | ||
61 | case 0: | ||
62 | return SDL_BUTTON_RIGHT; | ||
63 | break; | ||
64 | case 1: | ||
65 | default: | ||
66 | return SDL_BUTTON_LEFT; | ||
67 | break; | ||
68 | } | ||
69 | } | ||
70 | |||
71 | void AtariIkbd_PumpEvents(_THIS) | ||
72 | { | ||
73 | int i; | ||
74 | SDL_keysym keysym; | ||
75 | |||
76 | /*--- Send keyboard events ---*/ | ||
77 | |||
78 | for (i=0; i<ATARIBIOS_MAXKEYS; i++) { | ||
79 | /* Key pressed ? */ | ||
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; | ||
84 | } | ||
85 | |||
86 | /* Key released ? */ | ||
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; | ||
91 | } | ||
92 | } | ||
93 | |||
94 | /*--- Send mouse events ---*/ | ||
95 | |||
96 | /* Mouse motion ? */ | ||
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; | ||
100 | } | ||
101 | |||
102 | /* Mouse button ? */ | ||
103 | if (SDL_AtariIkbd_mouseb != atari_prevmouseb) { | ||
104 | for (i=0;i<2;i++) { | ||
105 | int curbutton, prevbutton; | ||
106 | |||
107 | curbutton = SDL_AtariIkbd_mouseb & (1<<i); | ||
108 | prevbutton = atari_prevmouseb & (1<<i); | ||
109 | |||
110 | if (curbutton && !prevbutton) { | ||
111 | SDL_PrivateMouseButton(SDL_PRESSED, atari_GetButton(i), 0, 0); | ||
112 | } | ||
113 | if (!curbutton && prevbutton) { | ||
114 | SDL_PrivateMouseButton(SDL_RELEASED, atari_GetButton(i), 0, 0); | ||
115 | } | ||
116 | } | ||
117 | atari_prevmouseb = SDL_AtariIkbd_mouseb; | ||
118 | } | ||
119 | } | ||
120 | |||
121 | void AtariIkbd_ShutdownEvents(void) | ||
122 | { | ||
123 | Supexec(SDL_AtariIkbdUninstall); | ||
124 | } | ||