root/platform/a490/kbd.c

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

DEFINITIONS

This source file includes following definitions.
  1. get_usb_bit
  2. mykbd_task
  3. wrap_kbd_p1_f
  4. 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 
  25     { 0, KEY_PLAYBACK  , 0x00020000 }, // Playback
  26 
  27     { 2, KEY_SHOOT_FULL , 0x00000030 }, // 0x00000010 (KEY_SHOOT_HALF) + 0x00000020 (KEY_SHOOT_FULL_ONLY)
  28     { 2, KEY_SHOOT_FULL_ONLY, 0x00000020 },
  29     { 2, KEY_SHOOT_HALF , 0x00000010 },
  30     
  31     { 2, KEY_UP         , 0x00100000 },
  32     { 2, KEY_DOWN       , 0x00200000 },
  33     { 2, KEY_LEFT       , 0x00400000 },
  34     { 2, KEY_RIGHT      , 0x00000004 },
  35     { 2, KEY_SET        , 0x00000100 },
  36     { 2, KEY_ZOOM_IN    , 0x00000080 },
  37     { 2, KEY_ZOOM_OUT   , 0x00000040 },
  38     { 2, KEY_MENU       , 0x01000000 },
  39     { 0, 0, 0 }
  40 };
  41 
  42 
  43 long __attribute__((naked)) wrap_kbd_p1_f();
  44 
  45 void __attribute__((noinline)) mykbd_task()
  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(10);
  55                 
  56                 if (wrap_kbd_p1_f() == 1){ // autorepeat ?
  57                         _kbd_p2_f();
  58                 }
  59         }
  60         _ExitTask();
  61 }
  62 
  63 
  64 long __attribute__((naked,noinline)) wrap_kbd_p1_f()
  65 {
  66         asm volatile(
  67                         "STMFD   SP!, {R1-R5,LR}\n"
  68                         "MOV     R4, #0\n"
  69                         //"BL      _kbd_read_keys\n"       // replaces kbd_fetch_data()
  70                         "BL      my_kbd_read_keys\n"     // +
  71                         "B       _kbd_p1_f_cont\n"       // continue
  72         );
  73         
  74         return 0; // shut up the compiler
  75 }
  76 
  77 void my_kbd_read_keys()
  78 {
  79         kbd_prev_state[0] = kbd_new_state[0];
  80         //kbd_prev_state[1] = kbd_new_state[1];
  81         kbd_prev_state[2] = kbd_new_state[2];
  82 
  83     extern void _kbd_read_keys(void);
  84     _kbd_read_keys();
  85         
  86         kbd_new_state[0] = physw_status[0];
  87         kbd_new_state[1] = physw_status[1];
  88         kbd_new_state[2] = physw_status[2] ^ KEYS_INV2;
  89         
  90         if (kbd_process() == 0){
  91                 // leave it alone...
  92         } else {
  93         // override keys
  94         physw_status[0] = (kbd_new_state[0] | KEYS_MASK0) & (~KEYS_MASK0 | kbd_mod_state[0]);
  95         //physw_status[1] = (kbd_new_state[1] | KEYS_MASK1) & (~KEYS_MASK1 | kbd_mod_state[1]);
  96         physw_status[2] = ((kbd_new_state[2] | KEYS_MASK2) & (~KEYS_MASK2 | kbd_mod_state[2])) ^ KEYS_INV2;
  97         }
  98     // usb and SD read-only are standard
  99     kbd_update_physw_bits();
 100 }

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