root/platform/sx130is/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
  8. 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         // Order IS important. kbd_get_pressed_key will walk down this table  
  12         // and take the first matching mask. Notice that KEY_SHOOT_HALF is  
  13         // always pressed if KEY_SHOOT_FULL is. --MarcusSt
  14         //{ 0, KEY_FLASH     , 0x80000000 },
  15         { 2, KEY_MENU      , 0x00002000 },
  16         { 2, KEY_UP        , 0x00000100 },
  17         { 2, KEY_DOWN      , 0x00000200 },
  18         { 2, KEY_LEFT      , 0x00000800 },
  19         { 2, KEY_RIGHT     , 0x00000400 },
  20         { 2, KEY_SET       , 0x00001000 },
  21         // { 1, KEY_FACE      , 0x10000000 },
  22         { 1, KEY_PRINT     , 0x10000000 }, // Face -> Print
  23         { 2, KEY_ERASE     , 0x00008000 },
  24         { 2, KEY_DISPLAY   , 0x00004000 },
  25         { 2, KEY_ZOOM_IN   , 0x00000010 },
  26         { 2, KEY_ZOOM_OUT  , 0x00000020 },
  27         { 2, KEY_SHOOT_FULL, 0x0000000C },
  28     { 2, KEY_SHOOT_FULL_ONLY, 0x00000008 },
  29         { 2, KEY_SHOOT_HALF, 0x00000004 },
  30         { 0, 0, 0 }
  31 };
  32 
  33 int jogdial_stopped=0;
  34 
  35 int get_usb_bit() 
  36 {
  37         long usb_physw[3];
  38         usb_physw[USB_IDX] = 0;
  39         _kbd_read_keys_r2(usb_physw);
  40         return(( usb_physw[USB_IDX] & USB_MASK)==USB_MASK) ; 
  41 }
  42 
  43 extern void _GetKbdState(long* buffer);
  44 
  45 long __attribute__((naked)) wrap_kbd_p1_f();
  46 
  47 void __attribute__((noinline))
  48 mykbd_task(long ua, long ub, long uc, long ud, long ue, long uf)
  49 {
  50     (void)ua; (void)ub; (void)uc; (void)ud; (void)ue; (void)uf;
  51         /* Initialize our own kbd_new_state[] array with the
  52            current physical status.
  53            */
  54         kbd_new_state[0] = physw_status[0];
  55         kbd_new_state[1] = physw_status[1];
  56         kbd_new_state[2] = physw_status[2];
  57 
  58         while (physw_run){
  59                 _SleepTask(10);
  60                 if (wrap_kbd_p1_f() == 1){ // autorepeat ?
  61                         _kbd_p2_f();
  62                 }
  63     }
  64     _ExitTask();
  65 }
  66 
  67 
  68 long __attribute__((naked,noinline)) wrap_kbd_p1_f()
  69 {
  70     asm volatile(
  71                 "STMFD   SP!, {R1-R5,LR}\n"
  72                 "MOV     R4, #0\n"
  73                 "BL      my_kbd_read_keys\n"
  74                 "B       _kbd_p1_f_cont\n"
  75     );
  76  return 0; // shut up the compiler
  77 }
  78 
  79 
  80 void my_kbd_read_keys()
  81 {
  82     kbd_update_key_state();
  83 
  84     _kbd_read_keys_r2(physw_status);
  85 
  86     kbd_update_physw_bits();
  87 }
  88 
  89 void kbd_fetch_data(long *dst)
  90 {
  91     _GetKbdState(dst);
  92 }
  93 
  94 void jogdial_control(int n) {
  95     // this camera did not have jog_position defined
  96     /*
  97     if (jogdial_stopped && !n) {
  98         // If re-enabling jogdial set the task code current & previous positions to the actual
  99         // dial positions so that the change won't get processed by the firmware
 100         jog_position[0] = jog_position[2] = rear_dial_position;   // Rear dial
 101     }
 102     */
 103     jogdial_stopped = n;
 104 }
 105 
 106 
 107 int Get_JogDial(void) {
 108  return (*(int*)0xC0240104)>>16;
 109 }
 110 
 111 long get_jogdial_direction(void) {
 112         static int new_jogdial = 0;
 113         int old_jogdial = 0;
 114 
 115         old_jogdial = new_jogdial;
 116         new_jogdial = Get_JogDial();
 117 
 118         if (old_jogdial < new_jogdial)
 119                 return JOGDIAL_LEFT;
 120         else if (old_jogdial > new_jogdial)
 121                 return JOGDIAL_RIGHT;
 122         else
 123                 return 0;
 124 }

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