root/platform/ixus300_sd4000/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
  5. kbd_fetch_data
  6. jogdial_control
  7. get_jogdial_direction

   1 #include "lolevel.h"
   2 #include "platform.h"
   3 #include "keyboard.h"
   4 #include "kbd_common.h"
   5 
   6 long kbd_new_state[3] = { 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF };
   7 long kbd_prev_state[3] = { 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF };
   8 long kbd_mod_state[3] = { 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF };
   9 
  10 // Base values in Play Mode
  11 // physw_status[0] = 0x800C91F      // 1
  12 // physw_status[1] = 0xFFE          // 2 (Mode Switch: Auto)
  13 // physw_status[2] = 0x400000       // 3
  14 // Mode Switch:
  15 // physw_status[1] 0x1 Auto Mode
  16 // physw_status[1] 0x0 Photo Mode
  17 // physw_status[1] 0x2 Video Mode
  18 // physw_status[2] 0x20000 SD-Card READONLY
  19 KeyMap keymap[] = {
  20     { 0, KEY_UP         , 0x00000004 },
  21     { 0, KEY_DOWN       , 0x00000001 },
  22     { 0, KEY_LEFT       , 0x00000008 },
  23     { 0, KEY_RIGHT      , 0x00000002 },
  24     { 0, KEY_POWER      , 0x00000010 },
  25     { 0, KEY_PLAYBACK   , 0x00004000 },    
  26     { 0, KEY_SHOOT_FULL , 0x00000900 },   // 0x00000800 (KEY_SHOOT_FULL_ONLY) + 0x00000100 (KEY_SHOOT_HALF)
  27     { 0, KEY_SHOOT_FULL_ONLY, 0x00000800 },
  28     { 0, KEY_SHOOT_HALF , 0x00000100 },
  29     { 1, KEY_SET        , 0x00000040 },
  30     { 1, KEY_ZOOM_IN    , 0x00000010 },
  31     { 1, KEY_ZOOM_OUT   , 0x00000020 },
  32     { 1, KEY_MENU       , 0x00000080 },
  33     { 0, 0, 0 }
  34 };
  35 
  36 extern void _GetKbdState(long *dst);
  37 
  38 int get_usb_bit() 
  39 {
  40         long usb_physw[3];
  41         usb_physw[USB_IDX] = 0;
  42         _kbd_read_keys_r2(usb_physw);
  43         return(( usb_physw[USB_IDX] & USB_MASK)==USB_MASK) ; 
  44 }
  45 
  46 long __attribute__((naked)) wrap_kbd_p1_f();
  47 
  48 // no stack manipulation needed here, since we create the task directly
  49 void __attribute__((noinline)) mykbd_task() {
  50     while (physw_run) {
  51         _SleepTask(physw_sleep_delay);
  52 
  53         if (wrap_kbd_p1_f() == 1) {   // autorepeat ?
  54             _kbd_p2_f();
  55         }
  56     }
  57     _ExitTask();
  58 }
  59 
  60 // ROM:FF83484C, like SX110
  61 long __attribute__((naked,noinline)) wrap_kbd_p1_f() {
  62     asm volatile(
  63         "STMFD   SP!, {R1-R5,LR}\n"
  64         "MOV     R4, #0\n"
  65 //        "BL      _kbd_read_keys\n"
  66         "BL      my_kbd_read_keys\n"     // +
  67         "B       _kbd_p1_f_cont\n"       // continue at ROM:FF834858
  68     );
  69     return 0;   // shut up the compiler
  70 }
  71 
  72 void my_kbd_read_keys() {
  73     kbd_update_key_state();
  74     kbd_update_physw_bits();
  75 }
  76 
  77 void kbd_fetch_data(long *dst)
  78 {
  79     _GetKbdState(dst);
  80     _kbd_read_keys_r2(dst);
  81 }
  82 
  83 int jogdial_stopped=0;
  84 extern short* jog_position;
  85 extern short rear_dial_position;
  86 
  87 void jogdial_control(int n) {
  88    
  89     if (jogdial_stopped && !n) {
  90         // If re-enabling jogdial set the task code current & previous positions to the actual
  91         // dial positions so that the change won't get processed by the firmware
  92         jog_position[2] = jog_position[4] = rear_dial_position;   // Rear dial
  93     }
  94     
  95     jogdial_stopped = n;
  96 }
  97 
  98 
  99 static int new_jogdial=0, old_jogdial=0;
 100 
 101 long get_jogdial_direction(void) {
 102     
 103     old_jogdial=new_jogdial;
 104     new_jogdial=rear_dial_position; // Get_JogDial();
 105 
 106     if (old_jogdial<new_jogdial) return JOGDIAL_RIGHT;
 107     if (old_jogdial>new_jogdial) return JOGDIAL_LEFT;
 108     return 0;
 109 }

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