1 | /*--------------------------------------------------------------------------------- |
---|
2 | $Id$ |
---|
3 | |
---|
4 | key input code -- provides slightly higher level input forming |
---|
5 | |
---|
6 | Copyright (C) 2005 |
---|
7 | Michael Noland (joat) |
---|
8 | Jason Rogers (dovoto) |
---|
9 | Christian Auby (DesktopMan) |
---|
10 | Dave Murphy (WinterMute) |
---|
11 | |
---|
12 | This software is provided 'as-is', without any express or implied |
---|
13 | warranty. In no event will the authors be held liable for any |
---|
14 | damages arising from the use of this software. |
---|
15 | |
---|
16 | Permission is granted to anyone to use this software for any |
---|
17 | purpose, including commercial applications, and to alter it and |
---|
18 | redistribute it freely, subject to the following restrictions: |
---|
19 | |
---|
20 | 1. The origin of this software must not be misrepresented; you |
---|
21 | must not claim that you wrote the original software. If you use |
---|
22 | this software in a product, an acknowledgment in the product |
---|
23 | documentation would be appreciated but is not required. |
---|
24 | 2. Altered source versions must be plainly marked as such, and |
---|
25 | must not be misrepresented as being the original software. |
---|
26 | 3. This notice may not be removed or altered from any source |
---|
27 | distribution. |
---|
28 | |
---|
29 | $Log$ |
---|
30 | Revision 1.1 2008/04/16 18:37:32 joel |
---|
31 | 2008-04-16 Matthieu Bucchianeri <mbucchia@gmail.com> |
---|
32 | |
---|
33 | * ChangeLog, Makefile.am, README, bsp_specs, configure.ac, |
---|
34 | mk_libnds.sh, patch.libnds, preinstall.am, block/block.c, |
---|
35 | clock/clock.c, console/console.c, coproc/coproc.S, coproc/coproc.c, |
---|
36 | coproc/coproc.ld, dswifi/dswifi_license.txt, dswifi/makefile, |
---|
37 | dswifi/arm7/makefile, dswifi/arm7/source/wifi_arm7.c, |
---|
38 | dswifi/arm7/source/wifi_arm7.h, dswifi/arm9/makefile, |
---|
39 | dswifi/arm9/source/sgIP.c, dswifi/arm9/source/sgIP.h, |
---|
40 | dswifi/arm9/source/sgIP_ARP.c, dswifi/arm9/source/sgIP_ARP.h, |
---|
41 | dswifi/arm9/source/sgIP_Config.h, dswifi/arm9/source/sgIP_DHCP.c, |
---|
42 | dswifi/arm9/source/sgIP_DHCP.h, dswifi/arm9/source/sgIP_DNS.c, |
---|
43 | dswifi/arm9/source/sgIP_DNS.h, dswifi/arm9/source/sgIP_Hub.c, |
---|
44 | dswifi/arm9/source/sgIP_Hub.h, dswifi/arm9/source/sgIP_ICMP.c, |
---|
45 | dswifi/arm9/source/sgIP_ICMP.h, dswifi/arm9/source/sgIP_IP.c, |
---|
46 | dswifi/arm9/source/sgIP_IP.h, dswifi/arm9/source/sgIP_TCP.c, |
---|
47 | dswifi/arm9/source/sgIP_TCP.h, dswifi/arm9/source/sgIP_UDP.c, |
---|
48 | dswifi/arm9/source/sgIP_UDP.h, dswifi/arm9/source/sgIP_memblock.c, |
---|
49 | dswifi/arm9/source/sgIP_memblock.h, |
---|
50 | dswifi/arm9/source/sgIP_sockets.c, dswifi/arm9/source/sgIP_sockets.h, |
---|
51 | dswifi/arm9/source/wifi_arm9.c, dswifi/arm9/source/wifi_arm9.h, |
---|
52 | dswifi/common/source/dsregs.h, dswifi/common/source/spinlock.h, |
---|
53 | dswifi/common/source/spinlock.s, dswifi/common/source/wifi_shared.h, |
---|
54 | dswifi/include/dswifi7.h, dswifi/include/dswifi9.h, |
---|
55 | dswifi/include/dswifi_version.h, dswifi/include/netdb.h, |
---|
56 | dswifi/include/sgIP_errno.h, dswifi/include/netinet/in.h, fb/fb.c, |
---|
57 | fb/fb.h, include/bsp.h, include/my_ipc.h, include/tm27.h, |
---|
58 | include/types.h, include/sys/iosupport.h, irq/irq.c, irq/irq.h, |
---|
59 | libfat/gba/include/fat.h, libfat/include/fat.h, |
---|
60 | libfat/nds/include/fat.h, libfat/source/bit_ops.h, |
---|
61 | libfat/source/cache.c, libfat/source/cache.h, libfat/source/common.h, |
---|
62 | libfat/source/directory.c, libfat/source/directory.h, |
---|
63 | libfat/source/fatdir.c, libfat/source/fatdir.h, |
---|
64 | libfat/source/fatfile.c, libfat/source/fatfile.h, |
---|
65 | libfat/source/file_allocation_table.c, |
---|
66 | libfat/source/file_allocation_table.h, libfat/source/filetime.c, |
---|
67 | libfat/source/filetime.h, libfat/source/libfat.c, |
---|
68 | libfat/source/mem_allocate.h, libfat/source/partition.c, |
---|
69 | libfat/source/partition.h, libfat/source/disc_io/disc.c, |
---|
70 | libfat/source/disc_io/disc.h, libfat/source/disc_io/disc_io.h, |
---|
71 | libfat/source/disc_io/io_cf_common.c, |
---|
72 | libfat/source/disc_io/io_cf_common.h, |
---|
73 | libfat/source/disc_io/io_dldi.h, libfat/source/disc_io/io_dldi.s, |
---|
74 | libfat/source/disc_io/io_efa2.c, libfat/source/disc_io/io_efa2.h, |
---|
75 | libfat/source/disc_io/io_fcsr.c, libfat/source/disc_io/io_fcsr.h, |
---|
76 | libfat/source/disc_io/io_m3_common.c, |
---|
77 | libfat/source/disc_io/io_m3_common.h, |
---|
78 | libfat/source/disc_io/io_m3cf.c, libfat/source/disc_io/io_m3cf.h, |
---|
79 | libfat/source/disc_io/io_m3sd.c, libfat/source/disc_io/io_m3sd.h, |
---|
80 | libfat/source/disc_io/io_mpcf.c, libfat/source/disc_io/io_mpcf.h, |
---|
81 | libfat/source/disc_io/io_njsd.c, libfat/source/disc_io/io_njsd.h, |
---|
82 | libfat/source/disc_io/io_nmmc.c, libfat/source/disc_io/io_nmmc.h, |
---|
83 | libfat/source/disc_io/io_sc_common.c, |
---|
84 | libfat/source/disc_io/io_sc_common.h, |
---|
85 | libfat/source/disc_io/io_sccf.c, libfat/source/disc_io/io_sccf.h, |
---|
86 | libfat/source/disc_io/io_scsd.c, libfat/source/disc_io/io_scsd.h, |
---|
87 | libfat/source/disc_io/io_scsd_s.s, |
---|
88 | libfat/source/disc_io/io_sd_common.c, |
---|
89 | libfat/source/disc_io/io_sd_common.h, libnds/Makefile.arm7, |
---|
90 | libnds/Makefile.arm9, libnds/libnds_license.txt, |
---|
91 | libnds/basicARM7/source/defaultARM7.c, |
---|
92 | libnds/include/default_font_bin.h, libnds/include/gbfs.h, |
---|
93 | libnds/include/nds.h, libnds/include/nds/bios.h, |
---|
94 | libnds/include/nds/card.h, libnds/include/nds/dma.h, |
---|
95 | libnds/include/nds/interrupts.h, libnds/include/nds/ipc.h, |
---|
96 | libnds/include/nds/jtypes.h, libnds/include/nds/memory.h, |
---|
97 | libnds/include/nds/registers_alt.h, libnds/include/nds/reload.h, |
---|
98 | libnds/include/nds/system.h, libnds/include/nds/timers.h, |
---|
99 | libnds/include/nds/arm7/audio.h, libnds/include/nds/arm7/clock.h, |
---|
100 | libnds/include/nds/arm7/serial.h, libnds/include/nds/arm7/touch.h, |
---|
101 | libnds/include/nds/arm9/background.h, |
---|
102 | libnds/include/nds/arm9/boxtest.h, libnds/include/nds/arm9/cache.h, |
---|
103 | libnds/include/nds/arm9/console.h, |
---|
104 | libnds/include/nds/arm9/exceptions.h, |
---|
105 | libnds/include/nds/arm9/image.h, libnds/include/nds/arm9/input.h, |
---|
106 | libnds/include/nds/arm9/math.h, libnds/include/nds/arm9/ndsmotion.h, |
---|
107 | libnds/include/nds/arm9/pcx.h, libnds/include/nds/arm9/postest.h, |
---|
108 | libnds/include/nds/arm9/rumble.h, libnds/include/nds/arm9/sound.h, |
---|
109 | libnds/include/nds/arm9/sprite.h, libnds/include/nds/arm9/trig_lut.h, |
---|
110 | libnds/include/nds/arm9/video.h, libnds/include/nds/arm9/videoGL.h, |
---|
111 | libnds/source/arm7/audio.c, libnds/source/arm7/clock.c, |
---|
112 | libnds/source/arm7/microphone.c, libnds/source/arm7/spi.c, |
---|
113 | libnds/source/arm7/touch.c, libnds/source/arm7/userSettings.c, |
---|
114 | libnds/source/arm9/COS.bin, libnds/source/arm9/COS.s, |
---|
115 | libnds/source/arm9/SIN.bin, libnds/source/arm9/SIN.s, |
---|
116 | libnds/source/arm9/TAN.bin, libnds/source/arm9/TAN.s, |
---|
117 | libnds/source/arm9/boxtest.c, libnds/source/arm9/console.c, |
---|
118 | libnds/source/arm9/dcache.s, libnds/source/arm9/default_font.bin, |
---|
119 | libnds/source/arm9/default_font.s, |
---|
120 | libnds/source/arm9/exceptionHandler.S, |
---|
121 | libnds/source/arm9/exceptionHandler.s, |
---|
122 | libnds/source/arm9/exceptions.c, libnds/source/arm9/gurumeditation.c, |
---|
123 | libnds/source/arm9/icache.s, libnds/source/arm9/image.c, |
---|
124 | libnds/source/arm9/initSystem.c, libnds/source/arm9/keys.c, |
---|
125 | libnds/source/arm9/ndsmotion.c, libnds/source/arm9/pcx.c, |
---|
126 | libnds/source/arm9/rumble.c, libnds/source/arm9/sound.c, |
---|
127 | libnds/source/arm9/system.c, libnds/source/arm9/touch.c, |
---|
128 | libnds/source/arm9/video.c, libnds/source/arm9/videoGL.c, |
---|
129 | libnds/source/common/biosCalls.s, libnds/source/common/card.c, |
---|
130 | libnds/source/common/gbfs.c, |
---|
131 | libnds/source/common/interruptDispatcher.s, |
---|
132 | libnds/source/common/interrupts.c, rtc/rtc.c, sound/sound.c, |
---|
133 | sound/sound.h, start/start.S, startup/linkcmds, startup/start.c, |
---|
134 | timer/timer.c, tools/Makefile.am, tools/bin2s, tools/bin2s.c, |
---|
135 | tools/configure.ac, tools/runtest, |
---|
136 | tools/ndstool/include/arm7_sha1_homebrew.h, |
---|
137 | tools/ndstool/include/arm7_sha1_nintendo.h, |
---|
138 | tools/ndstool/include/banner.h, tools/ndstool/include/bigint.h, |
---|
139 | tools/ndstool/include/crc.h, tools/ndstool/include/default_icon.h, |
---|
140 | tools/ndstool/include/encryption.h, tools/ndstool/include/header.h, |
---|
141 | tools/ndstool/include/hook.h, tools/ndstool/include/little.h, |
---|
142 | tools/ndstool/include/loadme.h, tools/ndstool/include/logo.h, |
---|
143 | tools/ndstool/include/ndscreate.h, |
---|
144 | tools/ndstool/include/ndsextract.h, tools/ndstool/include/ndstool.h, |
---|
145 | tools/ndstool/include/ndstree.h, tools/ndstool/include/overlay.h, |
---|
146 | tools/ndstool/include/passme.h, tools/ndstool/include/passme_sram.h, |
---|
147 | tools/ndstool/include/passme_vhd1.h, |
---|
148 | tools/ndstool/include/passme_vhd2.h, tools/ndstool/include/raster.h, |
---|
149 | tools/ndstool/include/sha1.h, tools/ndstool/include/types.h, |
---|
150 | tools/ndstool/source/arm7_sha1_homebrew.c, |
---|
151 | tools/ndstool/source/arm7_sha1_nintendo.c, |
---|
152 | tools/ndstool/source/banner.cpp, tools/ndstool/source/bigint.cpp, |
---|
153 | tools/ndstool/source/compile_date.c, tools/ndstool/source/crc.cpp, |
---|
154 | tools/ndstool/source/default_icon.c, |
---|
155 | tools/ndstool/source/encryption.cpp, tools/ndstool/source/header.cpp, |
---|
156 | tools/ndstool/source/hook.cpp, tools/ndstool/source/loadme.c, |
---|
157 | tools/ndstool/source/logo.cpp, tools/ndstool/source/ndscodes.cpp, |
---|
158 | tools/ndstool/source/ndscreate.cpp, |
---|
159 | tools/ndstool/source/ndsextract.cpp, |
---|
160 | tools/ndstool/source/ndstool.cpp, tools/ndstool/source/ndstree.cpp, |
---|
161 | tools/ndstool/source/passme.cpp, tools/ndstool/source/passme_sram.c, |
---|
162 | tools/ndstool/source/raster.cpp, tools/ndstool/source/sha1.cpp, |
---|
163 | touchscreen/README.reco, touchscreen/parser.c, touchscreen/reco.c, |
---|
164 | touchscreen/reco.h, touchscreen/touchscreen.c, |
---|
165 | touchscreen/touchscreen.h, wifi/compat.c, wifi/compat.h, wifi/wifi.c: |
---|
166 | New files. |
---|
167 | |
---|
168 | Revision 1.14 2006/02/25 02:18:53 wntrmute |
---|
169 | doxygenation updates |
---|
170 | |
---|
171 | Revision 1.13 2006/01/12 09:10:47 wntrmute |
---|
172 | Added key repeat as suggested by pepsiman |
---|
173 | |
---|
174 | Revision 1.12 2006/01/10 05:50:24 dovoto |
---|
175 | uhmm...about that KEY_R vs KEY_L thing...lets pretend that never happened |
---|
176 | |
---|
177 | Revision 1.11 2006/01/10 05:45:24 dovoto |
---|
178 | KEY_L and KEY_R were swapped |
---|
179 | |
---|
180 | Revision 1.10 2005/11/27 07:55:14 joatski |
---|
181 | Fixed my mistake in the changelogs |
---|
182 | |
---|
183 | Revision 1.9 2005/11/27 07:48:45 joatski |
---|
184 | Changed function returns to uint32 |
---|
185 | |
---|
186 | Revision 1.8 2005/11/14 11:59:49 wntrmute |
---|
187 | reformat for consistency |
---|
188 | |
---|
189 | Revision 1.7 2005/11/03 23:38:49 wntrmute |
---|
190 | don't use enum for key function returns |
---|
191 | |
---|
192 | Revision 1.6 2005/10/18 04:17:04 wntrmute |
---|
193 | doxygenation |
---|
194 | |
---|
195 | Revision 1.5 2005/10/13 16:30:11 dovoto |
---|
196 | Changed KEYPAD_BITS to a typedef enum, this resolved some issues with multiple redefinition of KEYPAD_BITS (although this error did not allways occur). |
---|
197 | |
---|
198 | Revision 1.4 2005/10/03 21:21:21 wntrmute |
---|
199 | doxygenation |
---|
200 | |
---|
201 | Revision 1.3 2005/09/07 18:03:36 wntrmute |
---|
202 | renamed key input registers |
---|
203 | moved key bit definitions to input.h |
---|
204 | |
---|
205 | Revision 1.2 2005/08/23 17:06:10 wntrmute |
---|
206 | converted all endings to unix |
---|
207 | |
---|
208 | Revision 1.1 2005/08/03 17:37:28 wntrmute |
---|
209 | moved to input.h |
---|
210 | |
---|
211 | Revision 1.5 2005/08/01 23:18:22 wntrmute |
---|
212 | adjusted headers for logging |
---|
213 | |
---|
214 | Revision 1.4 2005/07/25 02:31:07 wntrmute |
---|
215 | made local variables static |
---|
216 | added proper header to keys.h |
---|
217 | |
---|
218 | Revision 1.3 2005/07/25 02:19:01 desktopman |
---|
219 | Added support for KEY_LID in keys.c. |
---|
220 | Moved KEYS_CUR from header to source file. |
---|
221 | Changed from the custom abs() to stdlib.h's abs(). |
---|
222 | |
---|
223 | Revision 1.2 2005/07/14 08:00:57 wntrmute |
---|
224 | resynchronise with ndslib |
---|
225 | |
---|
226 | |
---|
227 | ---------------------------------------------------------------------------------*/ |
---|
228 | //! NDS input support. |
---|
229 | /*! \file input.h |
---|
230 | */ |
---|
231 | |
---|
232 | //--------------------------------------------------------------------------------- |
---|
233 | #ifndef INPUT_HEADER_INCLUDE |
---|
234 | #define INPUT_HEADER_INCLUDE |
---|
235 | //--------------------------------------------------------------------------------- |
---|
236 | |
---|
237 | #include <nds/jtypes.h> |
---|
238 | |
---|
239 | // Keyboard |
---|
240 | |
---|
241 | //! Bit values for the keypad buttons. |
---|
242 | typedef enum KEYPAD_BITS { |
---|
243 | KEY_A = BIT(0), //!< Keypad A button. |
---|
244 | KEY_B = BIT(1), //!< Keypad B button. |
---|
245 | KEY_SELECT = BIT(2), //!< Keypad SELECT button. |
---|
246 | KEY_START = BIT(3), //!< Keypad START button. |
---|
247 | KEY_RIGHT = BIT(4), //!< Keypad RIGHT button. |
---|
248 | KEY_LEFT = BIT(5), //!< Keypad LEFT button. |
---|
249 | KEY_UP = BIT(6), //!< Keypad UP button. |
---|
250 | KEY_DOWN = BIT(7), //!< Keypad DOWN button. |
---|
251 | KEY_R = BIT(8), //!< Right shoulder button. |
---|
252 | KEY_L = BIT(9), //!< Left shoulder button. |
---|
253 | KEY_X = BIT(10), //!< Keypad X button. |
---|
254 | KEY_Y = BIT(11), //!< Keypad Y button. |
---|
255 | KEY_TOUCH = BIT(12), //!< Touchscreen pendown. |
---|
256 | KEY_LID = BIT(13) //!< Lid state. |
---|
257 | } KEYPAD_BITS; |
---|
258 | |
---|
259 | #ifdef __cplusplus |
---|
260 | extern "C" { |
---|
261 | #endif |
---|
262 | |
---|
263 | //! Obtains the current keypad state. |
---|
264 | /*! Call this function once per main loop in order to use the keypad functions. |
---|
265 | */ |
---|
266 | void scanKeys(void); |
---|
267 | |
---|
268 | //! Obtains the current keypad held state. |
---|
269 | uint32 keysHeld(void); |
---|
270 | |
---|
271 | //! Obtains the current keypad pressed state. |
---|
272 | uint32 keysDown(void); |
---|
273 | |
---|
274 | //! Obtains the current keypad pressed or repeating state. |
---|
275 | uint32 keysDownRepeat(void); |
---|
276 | |
---|
277 | //! Sets the key repeat parameters. |
---|
278 | /*! \param setDelay Number of %scanKeys calls before keys start to repeat. |
---|
279 | \param setRepeat Number of %scanKeys calls before keys repeat. |
---|
280 | */ |
---|
281 | void keysSetRepeat( u8 setDelay, u8 setRepeat ); |
---|
282 | |
---|
283 | //! Obtains the current keypad released state. |
---|
284 | uint32 keysUp(void); |
---|
285 | |
---|
286 | //! Obtains the current touchscreen co-ordinates. |
---|
287 | touchPosition touchReadXY(void); |
---|
288 | |
---|
289 | #ifdef __cplusplus |
---|
290 | } |
---|
291 | #endif |
---|
292 | |
---|
293 | //--------------------------------------------------------------------------------- |
---|
294 | #endif // INPUT_HEADER_INCLUDE |
---|
295 | //--------------------------------------------------------------------------------- |
---|