From 8693ae1bd880a758eb2efec4fccd32f89593855d Mon Sep 17 00:00:00 2001 From: Nebuleon Fumika Date: Sun, 3 Feb 2013 04:19:11 -0500 Subject: Add SDK modifications by BassAceGold as of 2011-04-14, as well as modified DMA functions as of 2013-01-29. --- sdk-modifications/libsrc/key/key.c | 145 ++++++++++++++++++++++++++++++++++++ sdk-modifications/libsrc/key/key.h | 31 ++++++++ sdk-modifications/libsrc/key/key.mk | 10 +++ 3 files changed, 186 insertions(+) create mode 100644 sdk-modifications/libsrc/key/key.c create mode 100644 sdk-modifications/libsrc/key/key.h create mode 100644 sdk-modifications/libsrc/key/key.mk (limited to 'sdk-modifications/libsrc/key') diff --git a/sdk-modifications/libsrc/key/key.c b/sdk-modifications/libsrc/key/key.c new file mode 100644 index 0000000..8a6ad5f --- /dev/null +++ b/sdk-modifications/libsrc/key/key.c @@ -0,0 +1,145 @@ +#include "ds2_timer.h" +#include "ds2io.h" + +#define KEY_REPEAT_TIME 200 //5 times/second +#define KEY_REPEAT_TIME_N (KEY_REPEAT_TIME*1000000/SYSTIME_UNIT) + +#define INPUT_REPEAT_TIME 100 +#define INPUT_REPEAT_TIME_N (INPUT_REPEAT_TIME*1000000/SYSTIME_UNIT) + +static unsigned int _last_key = 0; +static unsigned int _last_key_timestamp = 0; + +/* +* Function: only detect the key pressed or not +*/ +unsigned int getKey(void) +{ + struct key_buf input; + unsigned int new_key, hold_key, ret_key, timestamp; + int flag; + + ds2_getrawInput(&input); + timestamp = getSysTime(); + flag = ((timestamp - _last_key_timestamp) >= KEY_REPEAT_TIME_N) ? 1 : 0; + + input.key &= 0x3FFF; + new_key = (_last_key ^ input.key) & input.key; + hold_key = _last_key & input.key; + + ret_key = 0; + if(hold_key) { + if(flag) + { + ret_key = hold_key; + _last_key_timestamp = timestamp; + } + } + + if(new_key) + { + ret_key |= new_key; + _last_key_timestamp = timestamp; + + _last_key = input.key; + } + + return ret_key; +} + +/* +* Function: can get the detail information about key pressed, hold, or release +*/ +unsigned int getKey1(void) +{ + struct key_buf input; + unsigned int new_key, hold_key, ret_key, timestamp; + int flag; + + ds2_getrawInput(&input); + timestamp = getSysTime(); + flag = ((timestamp - _last_key_timestamp) >= KEY_REPEAT_TIME_N) ? 1 : 0; + + input.key &= 0x3FFF; + new_key = _last_key ^ input.key; + hold_key = _last_key & input.key; + //ret_key[31:16] = last key; + //ret_key[15:0] = new key; + + ret_key = 0; + if(hold_key) { + if(flag) + { + ret_key = (hold_key << 16) | hold_key; + _last_key_timestamp = timestamp; + } + } + + if(new_key) + { + unsigned int tmp_key; + + //have new key pressed + if(new_key & input.key) + { + ret_key |= new_key & input.key; + _last_key_timestamp = timestamp; + } + else + { + ret_key |= (new_key & ~input.key) << 16; + } + + _last_key = input.key; + } + + return ret_key; +} + +static unsigned int _last_input = 0; +static unsigned int _last_input_timestamp = 0; + +/* +* Function: only detect the key pressed or not and touch position +*/ +unsigned int getInput(struct key_buf *input) { + struct key_buf rawin; + unsigned int timestamp, new, hold; + int flag, ret; + + ds2_getrawInput(&rawin); + timestamp = getSysTime(); + flag = ((timestamp - _last_input_timestamp) >= INPUT_REPEAT_TIME_N) ? 1 : 0; + + rawin.key &= 0x3FFF; + new = (rawin.key ^ _last_input) & rawin.key; + hold = rawin.key & _last_input; + + ret = 0; + if(hold && flag) + { + ret = hold; + input->x = rawin.x; + input->y = rawin.y; + + _last_input_timestamp = timestamp; + } + + if(new) + { + ret |= new; + input->x = rawin.x; + input->y = rawin.y; + + _last_input_timestamp = timestamp; + _last_input = rawin.key; + } + + input->key = ret; + return ret > 0; +} + + + + + diff --git a/sdk-modifications/libsrc/key/key.h b/sdk-modifications/libsrc/key/key.h new file mode 100644 index 0000000..21674ec --- /dev/null +++ b/sdk-modifications/libsrc/key/key.h @@ -0,0 +1,31 @@ +#ifndef __KEY_H__ +#define __KEY_H__ + +#ifdef __cplusplus +extern "C" { +#endif + +#define KEY_PRESS(key, key_id) (!(key & (key_id<<16)) && (key & key_id)) +#define KEY_HOLD(key, key_id) ((key & (key_id<<16)) && (key & key_id)) +#define KEY_RELEASE(key, key_id) ((key & (key_id<<16)) && !(key & key_id)) + +/* +* Function: only detect the key pressed or not +*/ +unsigned int getKey(void); + +/* +* Function: can get the detail information about key pressed, hold, or release +*/ +unsigned int getKey1(void); + +/* +* Function: detect the key pressed or not and touched position +*/ +extern unsigned int getInput(struct key_buf *input); + +#ifdef __cplusplus +} +#endif + +#endif //__KEY_H__ diff --git a/sdk-modifications/libsrc/key/key.mk b/sdk-modifications/libsrc/key/key.mk new file mode 100644 index 0000000..fa08d7c --- /dev/null +++ b/sdk-modifications/libsrc/key/key.mk @@ -0,0 +1,10 @@ +#key.mk + +SRC += $(KEY_DIR)/key.c + +SSRC += + +INC += -I$(KEY_DIR) + +CFLAGS += + -- cgit v1.2.3 From d1a7bf5eb558e7db4a1a27e15ebedb02e6b7f804 Mon Sep 17 00:00:00 2001 From: Nebuleon Fumika Date: Mon, 4 Feb 2013 23:45:44 -0500 Subject: Fully integrate BassAceGold's libraries, finally. The README still states that 1.2 is required to overwrite 0.13's stuff; really, 0.13 is needed only for `gcc`. So the sequence goes 0.13's `gcc` -> 1.2 -> BassAceGold's libraries -> make `libds2a.a`. DMA function names changed to match BassAceGold's. --- sdk-modifications/libsrc/key/key.c | 0 sdk-modifications/libsrc/key/key.h | 0 sdk-modifications/libsrc/key/key.mk | 0 3 files changed, 0 insertions(+), 0 deletions(-) mode change 100644 => 100755 sdk-modifications/libsrc/key/key.c mode change 100644 => 100755 sdk-modifications/libsrc/key/key.h mode change 100644 => 100755 sdk-modifications/libsrc/key/key.mk (limited to 'sdk-modifications/libsrc/key') diff --git a/sdk-modifications/libsrc/key/key.c b/sdk-modifications/libsrc/key/key.c old mode 100644 new mode 100755 diff --git a/sdk-modifications/libsrc/key/key.h b/sdk-modifications/libsrc/key/key.h old mode 100644 new mode 100755 diff --git a/sdk-modifications/libsrc/key/key.mk b/sdk-modifications/libsrc/key/key.mk old mode 100644 new mode 100755 -- cgit v1.2.3