root/platform/g16/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_proceed
  4. mykbd_task
  5. my_kbd_read_keys
  6. kbd_fetch_data
  7. get_dial_hw_position
  8. get_jogdial_direction
  9. handle_jogdial
  10. jogdial_control

   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 extern void _GetKbdState(long*);
  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 {
  22     { 0, KEY_ZOOM_OUT        ,0x00000002 }, // Found @0xfc571a18, levent 0x04
  23     { 0, KEY_ZOOM_IN         ,0x00000004 }, // Found @0xfc571a20, levent 0x03
  24     { 0, KEY_VIDEO           ,0x00000008 }, // Found @0xfc571a28, levent 0x02
  25     { 0, KEY_MENU            ,0x00000010 }, // Found @0xfc571a30, levent 0x0b
  26     { 0, KEY_UP              ,0x00000020 }, // Found @0xfc571a38, levent 0x06
  27     { 0, KEY_DOWN            ,0x00000040 }, // Found @0xfc571a40, levent 0x07
  28 //  { 0, KEY_DISPLAY         ,0x00000040 }, // KEY_DISPLAY is also KEY_DOWN
  29     { 0, KEY_RIGHT           ,0x00000080 }, // Found @0xfc571a48, levent 0x09
  30     { 0, KEY_LEFT            ,0x00000100 }, // Found @0xfc571a50, levent 0x08
  31     { 0, KEY_SET             ,0x00000200 }, // Found @0xfc571a58, levent 0x0a
  32     { 0, KEY_PLAYBACK        ,0x00010000 }, // Found @0xfc571a80, levent 0x101
  33     { 0, KEY_POWER           ,0x00020000 }, // Found @0xfc571a88, levent 0x100
  34     { 0, KEY_SHOOT_FULL      ,0x000c0000 }, // Found @0xfc571a98, levent 0x01
  35     { 0, KEY_SHOOT_FULL_ONLY ,0x00080000 }, // Found @0xfc571a98, levent 0x01
  36     { 0, KEY_SHOOT_HALF      ,0x00040000 }, // Found @0xfc571a90, levent 0x00
  37     { 0, KEY_PRINT           ,0x00002000 }, // G16 shortcut key
  38     { 0, KEY_ERASE           ,0x00001000 }, // G16 erase or ISO key
  39     { 0, KEY_AE_LOCK         ,0x00000800 }, // G16 * or AE Lock
  40     { 0, KEY_WIFI            ,0x00000400 }, // G16 WiFI or AF frame select
  41     { 0, 0, 0 }
  42 };
  43 
  44 
  45 long __attribute__((naked,noinline)) wrap_kbd_p1_f()
  46 {
  47     asm volatile(
  48         "push    {r1-r7, lr}\n"
  49         "movs    r4, #0\n"
  50         "bl      my_kbd_read_keys\n"
  51         "b       _kbd_p1_f_cont\n"
  52     );
  53     return 0;
  54 }
  55 
  56 static void __attribute__((noinline)) mykbd_task_proceed()
  57 {
  58     extern void kbd_p2_f_my();
  59 
  60     while (physw_run) {
  61         _SleepTask(physw_sleep_delay);
  62         if (wrap_kbd_p1_f() == 1) {             // autorepeat ?
  63             kbd_p2_f_my();                      // replacement of _kbd_p2_f (in sub/<fwver>/boot.c)
  64         }
  65     }
  66 }
  67 
  68 void __attribute__((naked,noinline)) mykbd_task()
  69 {
  70     mykbd_task_proceed();
  71     _ExitTask();
  72 }
  73 
  74 void my_kbd_read_keys()
  75 {
  76       kbd_update_key_state();
  77       kbd_update_physw_bits();
  78 }
  79 
  80 void kbd_fetch_data(long *dst)
  81 {
  82     _GetKbdState(dst);
  83     _kbd_read_keys_r2(dst);
  84 }
  85 
  86 #define DIAL_HW_REAR  4
  87 #define DIAL_HW_FRONT 5
  88 
  89 extern int _get_dial_hw_position(int dial);
  90 extern long dial_positions[4];
  91 
  92 int jogdial_stopped=0;
  93 
  94 int get_dial_hw_position(int dial)
  95 {
  96     return _get_dial_hw_position(dial)&~3;     // note : mask low bits
  97 }
  98 
  99 long get_jogdial_direction(void)
 100 {
 101     static int new_jogdial=0, old_jogdial=0, new_frontdial=0, old_frontdial=0;
 102 
 103     old_jogdial=new_jogdial;
 104     new_jogdial=get_dial_hw_position(DIAL_HW_REAR);
 105     old_frontdial=new_frontdial;
 106     new_frontdial=get_dial_hw_position(DIAL_HW_FRONT);
 107 
 108     if (old_jogdial>new_jogdial)          return JOGDIAL_LEFT;
 109     else if (old_jogdial<new_jogdial)     return JOGDIAL_RIGHT;
 110     if (old_frontdial>new_frontdial)      return FRONTDIAL_RIGHT;
 111     else if (old_frontdial<new_frontdial) return FRONTDIAL_LEFT;
 112     else                                  return 0;
 113 }
 114 
 115 int handle_jogdial()
 116 {
 117     if (jogdial_stopped) {
 118         // update positions in RAM
 119         dial_positions[0] = dial_positions[2] = get_dial_hw_position(DIAL_HW_REAR);
 120         dial_positions[1] = dial_positions[3] = get_dial_hw_position(DIAL_HW_FRONT);
 121         return 0;      // return 0 to disable fw's dial handler
 122     }
 123     return 1;
 124 }
 125 
 126 void jogdial_control(int c)
 127 {
 128     jogdial_stopped = c;
 129 }

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