root/platform/ixus110_sd960/kbd.c

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

DEFINITIONS

This source file includes following definitions.
  1. get_usb_bit
  2. wrap_kbd_p1_f
  3. mykbd_task
  4. kbd_fetch_data
  5. my_kbd_read_keys
  6. enable_extra_button
  7. kbd_set_extra_button
  8. jogdial_control
  9. Get_JogDial
  10. get_jogdial_direction

   1 #include "lolevel.h"
   2 #include "platform.h"
   3 #include "core.h"
   4 #include "keyboard.h"
   5 #include "conf.h"
   6 #include "kbd_common.h"
   7 
   8 KeyMap keymap[] = {
   9     /* tiny bug: key order matters. see kbd_get_pressed_key()
  10      * for example
  11      */
  12     { 1, KEY_POWER           ,0x00000001 }, // Found @0xffaeea90, levent 0x600
  13     { 1, KEY_ZOOM_OUT        ,0x00002000 }, // Found @0xffaeeab4, levent 0x03
  14     { 1, KEY_ZOOM_IN         ,0x00004000 }, // Found @0xffaeeac0, levent 0x02
  15     { 1, KEY_SHOOT_FULL      ,0x00009000 }, // Found @0xffaeeacc, levent 0x01
  16     { 1, KEY_SHOOT_FULL_ONLY ,0x00008000 }, // Found @0xffaeeacc, levent 0x01
  17     { 1, KEY_SHOOT_HALF      ,0x00001000 }, // Found @0xffaeeaa8, levent 0x00
  18     { 2, KEY_LEFT            ,0x00000020 }, // Found @0xffaeeb14, levent 0x06
  19     { 2, KEY_RIGHT           ,0x00000040 }, // Found @0xffaeeb20, levent 0x07
  20     { 2, KEY_DOWN            ,0x00000080 }, // Found @0xffaeeb2c, levent 0x05
  21     { 2, KEY_UP              ,0x00000200 }, // Found @0xffaeeb44, levent 0x04
  22     { 2, KEY_SET             ,0x00000400 }, // Found @0xffaeeb50, levent 0x08
  23     { 2, KEY_MENU            ,0x00000800 }, // Found @0xffaeeb5c, levent 0x09
  24     { 2, KEY_PLAYBACK        ,0x00004000 }, // Found @0xffaeeb68, levent 0x601
  25 //    { 2, KEY_LEFT_SOFT       ,0x00000001 },
  26 //    { 2, KEY_RIGHT_SOFT      ,0x00000002 },
  27 //    { 2, KEY_DOWN_SOFT       ,0x00000004 },
  28 //    { 2, KEY_UP_SOFT         ,0x00000008 },
  29     { 0, 0                   ,0x00000000 }, // placeholder for the fake key
  30     { 0, 0, 0 }
  31 };
  32 
  33 
  34 long kbd_new_state[3] = { 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF };
  35 long kbd_prev_state[3] = { 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF };
  36 long kbd_mod_state[3] = { 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF };
  37 
  38 int keys_mask1=0x0000F000;
  39 static int set_fake_key=0;
  40 
  41 int get_usb_bit() 
  42 {
  43     long usb_physw[3];
  44     usb_physw[USB_IDX] = 0;
  45     _kbd_read_keys_r2(usb_physw);
  46     return(( usb_physw[USB_IDX] & USB_MASK)==USB_MASK) ; 
  47 }
  48 
  49 long __attribute__((naked,noinline)) wrap_kbd_p1_f()
  50 {
  51 
  52     asm volatile(
  53                 "STMFD   SP!, {R1-R5,LR}\n"
  54                 "MOV     R4, #0\n"
  55                 "BL      my_kbd_read_keys\n"
  56                    "B     _kbd_p1_f_cont\n"
  57     );
  58     return 0; // shut up the compiler
  59 }
  60 
  61 void __attribute__((noinline)) mykbd_task()
  62 {
  63     while (physw_run){ 
  64         _SleepTask(10);
  65 
  66         if (wrap_kbd_p1_f() == 1){ // autorepeat ?
  67             _kbd_p2_f();
  68         }
  69     }
  70 
  71     _ExitTask();
  72 }
  73 
  74 extern void _GetKbdState(long*);
  75 long get_jogdial_direction();
  76 int jogdial_stopped=0;
  77 void enable_extra_button(short);
  78 
  79 void kbd_fetch_data(long *state) {
  80     _GetKbdState(state);
  81     _kbd_read_keys_r2(state);
  82 }
  83 
  84 void my_kbd_read_keys()
  85 {
  86     kbd_update_key_state();
  87     kbd_update_physw_bits();
  88 
  89     if (set_fake_key & 0x10000000) {
  90         enable_extra_button((short)(set_fake_key & 0xffff));
  91         set_fake_key=0;
  92     }
  93 }
  94 
  95 void enable_extra_button(short key) {
  96 /*
  97  * enable or disable the additional "fake" button
  98  * in this case, the power button will be re-mapped in ALT mode
  99  * called from the kbd task
 100  * beware: the "placeholder" in keymap[] is directly addressed here
 101  * the placeholder has to be the last entry before the terminating { 0, 0, 0 }, if it is ever set to { 0, 0, 0 }
 102  */
 103     if (key) {
 104         keys_mask1=0x0000F001;
 105         keymap[13].grp=1;
 106         keymap[13].canonkey=0x00000001;
 107         keymap[13].hackkey=key;
 108     }
 109     else {
 110         keys_mask1=0x0000F000;
 111         keymap[13].grp=0;
 112         keymap[13].canonkey=0;
 113         keymap[13].hackkey=0;
 114     }
 115 }
 116 
 117 void kbd_set_extra_button(short key) { // called by core
 118     set_fake_key=key|0x10000000;    
 119 }
 120 
 121 void jogdial_control(int n) {
 122     jogdial_stopped = n;
 123 }
 124 
 125 static int new_jogdial=0, old_jogdial=0;
 126 
 127 int Get_JogDial(void){
 128  return (*(int*)0xC0240104)>>16; // OK, ixus110
 129 }
 130 
 131 long get_jogdial_direction(void) { 
 132  old_jogdial=new_jogdial;
 133  new_jogdial=Get_JogDial();
 134  if (old_jogdial<new_jogdial) return JOGDIAL_RIGHT; 
 135  else if (old_jogdial>new_jogdial) return JOGDIAL_LEFT;
 136  else return 0;
 137 }

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