root/platform/a495/kbd.c

/* [<][>][^][v][top][bottom][index][help] */

DEFINITIONS

This source file includes following definitions.
  1. get_usb_bit
  2. mykbd_task_proceed
  3. mykbd_task
  4. wrap_kbd_p1_f
  5. my_kbd_read_keys

   1 #include "lolevel.h"
   2 #include "platform.h"
   3 #include "core.h"
   4 #include "conf.h"
   5 #include "keyboard.h"
   6 #include "kbd_common.h"
   7 
   8 long kbd_new_state[3] = { 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF };
   9 long kbd_prev_state[3] = { 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF };
  10 long kbd_mod_state[3] = { 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF };
  11 
  12 int get_usb_bit() 
  13 {
  14         long usb_physw[3];
  15         usb_physw[USB_IDX] = 0;
  16         _kbd_read_keys_r2(usb_physw);
  17         return(( usb_physw[USB_IDX] & USB_MASK)==USB_MASK) ; 
  18 }
  19 
  20 KeyMap keymap[] = {
  21     /* tiny bug: key order matters. see kbd_get_pressed_key()
  22     * for example
  23     */
  24 //    { 0, KEY_POWER           ,0x00800000 }, // Found @0xffe84ed4, levent 0x600
  25     { 0, KEY_PLAYBACK        ,0x00020000 }, // Found @0xffe84ebc, levent 0x601
  26     { 2, KEY_MENU            ,0x01000000 }, // Found @0xffe84f88, levent 0x09 (uses inverted logic in physw_status)
  27     { 2, KEY_MODE            ,0x00800000 }, // mode select                    (uses inverted logic in physw_status)
  28     { 2, KEY_LEFT            ,0x00400000 }, // Found @0xffe84f70, levent 0x06 (uses inverted logic in physw_status)
  29     { 2, KEY_DOWN            ,0x00200000 }, // Found @0xffe84f64, levent 0x05 (uses inverted logic in physw_status)
  30     { 2, KEY_UP              ,0x00100000 }, // Found @0xffe84f58, levent 0x04 (uses inverted logic in physw_status)
  31     { 2, KEY_SET             ,0x00000100 }, // Found @0xffe84f1c, levent 0x08
  32     { 2, KEY_ZOOM_IN         ,0x00000080 }, // Found @0xffe84f10, levent 0x02
  33     { 2, KEY_ZOOM_OUT        ,0x00000040 }, // Found @0xffe84f04, levent 0x03
  34     { 2, KEY_SHOOT_FULL      ,0x00000030 }, // Found @0xffe84ef8, levent 0x01
  35     { 2, KEY_SHOOT_FULL_ONLY ,0x00000020 }, // Found @0xffe84ef8, levent 0x01
  36     { 2, KEY_SHOOT_HALF      ,0x00000010 }, // Found @0xffe84eec, levent 0x00
  37     { 2, KEY_RIGHT           ,0x00000004 }, // Found @0xffe84ee0, levent 0x07
  38     { 0, 0, 0 }
  39 };
  40 
  41 
  42 long __attribute__((naked)) wrap_kbd_p1_f() ;
  43 
  44 
  45 static void __attribute__((noinline)) mykbd_task_proceed()
  46 {
  47         /* Initialize our own kbd_new_state[] array with the
  48            current physical status. (inspired by the S90 port)
  49            */
  50         kbd_new_state[0] = physw_status[0];
  51         kbd_new_state[1] = physw_status[1];
  52         kbd_new_state[2] = physw_status[2] ^ KEYS_INV2;
  53         while (physw_run){
  54                 _SleepTask(physw_sleep_delay);
  55                 
  56                 if (wrap_kbd_p1_f() == 1){ // autorepeat ?
  57                         _kbd_p2_f();
  58                 }
  59         }
  60 }
  61 
  62 // no stack manipulation needed here, since we create the task directly
  63 void __attribute__((naked,noinline)) mykbd_task()
  64 {
  65         mykbd_task_proceed();
  66         _ExitTask();
  67 }
  68 
  69 
  70 long __attribute__((naked,noinline)) wrap_kbd_p1_f()
  71 {
  72         asm volatile(
  73                         "STMFD   SP!, {R1-R5,LR}\n"
  74                         "MOV     R4, #0\n"
  75                         //"BL      _kbd_read_keys\n"       // replaces kbd_fetch_data()
  76                         "BL      my_kbd_read_keys\n"     // +
  77                         "B       _kbd_p1_f_cont\n"       // continue
  78         );
  79         return 0; // shut up the compiler
  80 }
  81 
  82 void my_kbd_read_keys()
  83 {
  84     // TODO currently does not use common kbd_update_key_state, because read into physw and need to xor
  85         kbd_prev_state[0] = kbd_new_state[0];
  86         kbd_prev_state[1] = kbd_new_state[1];
  87         kbd_prev_state[2] = kbd_new_state[2];
  88         
  89     extern void _kbd_read_keys(void);
  90     _kbd_read_keys();
  91         
  92         //_platformsub_kbd_fetch_data(kbd_new_state);
  93         kbd_new_state[0] = physw_status[0];
  94         kbd_new_state[1] = physw_status[1];
  95         kbd_new_state[2] = physw_status[2] ^ KEYS_INV2;
  96         
  97         if (kbd_process() == 0){
  98                 // leave it alone...
  99         } else {
 100         // override keys
 101         physw_status[0] = (kbd_new_state[0] | KEYS_MASK0) & (~KEYS_MASK0 | kbd_mod_state[0]);
 102         physw_status[1] = (kbd_new_state[1] | KEYS_MASK1) & (~KEYS_MASK1 | kbd_mod_state[1]);
 103         physw_status[2] = ((kbd_new_state[2] | KEYS_MASK2) & (~KEYS_MASK2 | kbd_mod_state[2])) ^ KEYS_INV2;
 104         }
 105         
 106     // usb and SD read-only are standard
 107     kbd_update_physw_bits();
 108 }

/* [<][>][^][v][top][bottom][index][help] */