root/platform/ixus1000_sd4500/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
  6. kbd_fetch_data
  7. jogdial_control
  8. Get_JogDial
  9. 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 KeyMap keymap[] = {
  11     { 2, KEY_SHOOT_FULL      ,0x00002002 }, // Found @0xffb8d554, levent 0x01
  12     { 2, KEY_SHOOT_HALF      ,0x00002000 }, // Found @0xffb8d56c, levent 0x00
  13     { 2, KEY_SHOOT_FULL_ONLY ,0x00000002 }, // Found @0xffb8d554, levent 0x01
  14     { 2, KEY_POWER           ,0x00000008 }, // Found @0xffb8d55c, levent 0x600
  15     { 2, KEY_PLAYBACK        ,0x00000100 }, // Found @0xffb8d564, levent 0x601
  16 
  17     { 1, KEY_VIDEO           ,0x00000080 }, // Found @0xffb8d4e4, levent 0x12
  18     { 1, KEY_UP              ,0x00000400 }, // Found @0xffb8d4fc, levent 0x04
  19     { 1, KEY_RIGHT           ,0x00000800 }, // Found @0xffb8d504, levent 0x07
  20     { 1, KEY_SET             ,0x00001000 }, // Found @0xffb8d50c, levent 0x08
  21     { 1, KEY_UP_SOFT         ,0x00002000 },
  22     { 1, KEY_RIGHT_SOFT      ,0x00004000 },
  23     { 1, KEY_LEFT            ,0x00008000 }, // Found @0xffb8d524, levent 0x06
  24     { 1, KEY_MENU            ,0x00010000 }, // Found @0xffb8d52c, levent 0x09
  25     { 1, KEY_DOWN            ,0x00020000 }, // Found @0xffb8d534, levent 0x05
  26     { 1, KEY_LEFT_SOFT       ,0x00040000 },
  27     { 1, KEY_DOWN_SOFT       ,0x00080000 },
  28 
  29     // 2 bits used and 4 values per direction, like sx30
  30     { 1, KEY_ZOOM_IN         , 0x00000004 }, // 0->4->c->8
  31     { 1, KEY_ZOOM_IN         , 0x00000008 },
  32     { 1, KEY_ZOOM_OUT        , 0x00000001 }, // 0->1->3->2
  33     { 1, KEY_ZOOM_OUT        , 0x00000002 },
  34 
  35     { 0, 0, 0 }
  36 };
  37 
  38 #define NEW_SS (0x2000)
  39 
  40 int get_usb_bit() 
  41 {
  42         long usb_physw[3];
  43         usb_physw[USB_IDX] = 0;
  44         _kbd_read_keys_r2(usb_physw);
  45         return(( usb_physw[USB_IDX] & USB_MASK)==USB_MASK) ; 
  46 }
  47 
  48 static char kbd_stack[NEW_SS];
  49 
  50 extern void _GetKbdState(long *dst);
  51 
  52 int jogdial_stopped=0;
  53 
  54 long __attribute__((naked)) wrap_kbd_p1_f();
  55 
  56 static void __attribute__((noinline)) mykbd_task_proceed() {
  57     while (physw_run) {
  58         _SleepTask(physw_sleep_delay);
  59 
  60         if (wrap_kbd_p1_f() == 1) {   // autorepeat ?
  61             _kbd_p2_f();
  62         }
  63     }
  64 }
  65 
  66 void __attribute__((naked,noinline)) mykbd_task() {
  67         register int i;
  68         register long *newstack;
  69 
  70         newstack = (void*)kbd_stack;
  71 
  72         for (i=0;i<NEW_SS/4;i++)
  73                 newstack[i]=0xdededede;
  74 
  75         asm volatile (
  76                 "MOV    SP, %0"
  77                 :: "r"(((char*)newstack)+NEW_SS)
  78                 : "memory"
  79         );
  80 
  81 
  82 
  83         mykbd_task_proceed();
  84 
  85 /* function can be modified to restore SP here...
  86          */
  87 
  88         _ExitTask();
  89 }
  90 
  91 // ROM:FF83484C, like SX110
  92 long __attribute__((naked,noinline)) wrap_kbd_p1_f() {
  93     asm volatile(
  94                 "STMFD   SP!, {R1-R5,LR}\n"
  95                 "MOV     R4, #0\n"
  96 //                "BL      _kbd_read_keys\n"
  97                 "BL      my_kbd_read_keys\n"     // +
  98                 "B       _kbd_p1_f_cont\n"       // continue at ROM:FF834858
  99     );
 100     return 0;   // shut up the compiler
 101 }
 102 
 103 void my_kbd_read_keys() {
 104     kbd_update_key_state();
 105     kbd_update_physw_bits();
 106 }
 107 
 108 void kbd_fetch_data(long *dst)
 109 {
 110     _GetKbdState(dst);
 111     _kbd_read_keys_r2(dst);
 112 }
 113 
 114 
 115 
 116 void jogdial_control(int n) {
 117     // this camera did not have jog_position defined
 118     /*
 119     if (jogdial_stopped && !n) {
 120         // If re-enabling jogdial set the task code current & previous positions to the actual
 121         // dial positions so that the change won't get processed by the firmware
 122         jog_position[0] = jog_position[2] = rear_dial_position;   // Rear dial
 123     }
 124     */
 125     jogdial_stopped = n;
 126 }
 127 
 128 int Get_JogDial(void) {
 129     return (*(int*)0xC0240104)>>16;     // 0xC0240000 + 0x104
 130 }
 131 
 132 static int new_jogdial=0, old_jogdial=0;
 133 
 134 long get_jogdial_direction(void) {
 135     old_jogdial=new_jogdial;
 136     new_jogdial=Get_JogDial();
 137 
 138     if (old_jogdial<new_jogdial) {
 139         return JOGDIAL_LEFT;
 140     } else if (old_jogdial>new_jogdial) {
 141         return JOGDIAL_RIGHT;
 142     } else {
 143         return 0;
 144     }
 145 }

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