#include "lolevel.h" #include "platform.h" #include "conf.h" #include "core.h" #include "keyboard.h" typedef struct { long hackkey; long canonkey; } KeyMap; static long kbd_new_state[3]; static long kbd_prev_state[3]; static long kbd_mod_state; static KeyMap keymap[]; static long last_kbd_key = 0; static int usb_power=0; static int remote_key, remote_count; #define NEW_SS (0x2000) #define SD_READONLY_FLAG (0x20000) #define USB_MASK 0x40 #define USB_REG 1 #ifndef MALLOCD_STACK static char kbd_stack[NEW_SS]; #endif extern void _platformsub_kbd_fetch_data(long*); long __attribute__((naked)) wrap_kbd_p1_f(); void __attribute__((naked,noinline)) mykbd_task_proceed_2(); extern void h_kbd_p2_f(); static void __attribute__((noinline)) mykbd_task_proceed() { asm volatile( "STMFD SP!, {R4,LR}\n" "B mykbd_task_proceed_2\n" ); } // function above aDerror0x02x0x0 void __attribute__((noinline)) mykbd_task_proceed_2() { asm volatile( "loc_FF828CCC:\n" "MOV R0, #0xA\n" "BL _SleepTask\n" "BL wrap_kbd_p1_f\n" "CMP R0, #1\n" "BNE loc_FF828CCC\n" "B h_kbd_p2_f\n" ); } void __attribute__((naked,noinline)) mykbd_task(long ua, long ub, long uc, long ud, long ue, long uf) { /* WARNING * Stack pointer manipulation performed here! * This means (but not limited to): * function arguments destroyed; * function CAN NOT return properly; * MUST NOT call or use stack variables before stack * is setup properly; * */ register int i; register long *newstack; #ifndef MALLOCD_STACK newstack = (void*)kbd_stack; #else newstack = malloc(NEW_SS); #endif for (i=0;i((press_count)?175:500)) { ++press_count; last_kbd_time = t; return last_kbd_key; } else { return 0; } } else { last_kbd_key = 0; return 0; } } } long kbd_use_zoom_as_mf() { return 0; } int usb_power_status_override(int status){ // for clear USB power flag - return status &~USB_MASK; // for get USB power flag read status & USB_MASK remote_key = (status & USB_MASK)==USB_MASK; if (remote_key) remote_count += 1; else if (remote_count) { usb_power = remote_count; remote_count = 0; } if (conf.remote_enable) { return status &~USB_MASK; } return status; } int get_usb_power(int edge) { int x; if (edge) return remote_key; x = usb_power; usb_power = 0; return x; } static KeyMap keymap[] = { /* tiny bug: key order matters. see kbd_get_pressed_key() * for example */ { KEY_UP , 0x00000020 }, { KEY_DOWN , 0x00000040 }, { KEY_LEFT , 0x00000080 }, { KEY_RIGHT , 0x00000100 }, { KEY_SET , 0x00000200 }, { KEY_SHOOT_FULL, 0x00000006 }, // note 6 here! { KEY_SHOOT_FULL_ONLY, 0x00000004 }, { KEY_SHOOT_HALF, 0x00000002 }, { KEY_ZOOM_IN , 0x00000008 }, { KEY_ZOOM_OUT , 0x00000010 }, { KEY_MENU , 0x00000400 }, { KEY_DISPLAY , 0x00000800 }, { KEY_PRINT , 0x00002000 }, // { KEY_ERASE , 0x00000800 }, // { KEY_DUMMY , 0x10000000 }, { 0, 0 } };