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

   1 #include "lolevel.h"
   2 #include "platform.h"
   3 #include "conf.h"
   4 #include "keyboard.h"
   5 #include "kbd_common.h"
   6 
   7 long kbd_new_state[3] = { 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF };
   8 long kbd_prev_state[3] = { 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF };
   9 long kbd_mod_state[3] = { 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF };
  10 
  11 extern void _GetKbdState(long*);
  12 
  13 int get_usb_bit() 
  14 {
  15         long usb_physw[3];
  16         usb_physw[USB_IDX] = 0;
  17         _kbd_read_keys_r2(usb_physw);
  18         return(( usb_physw[USB_IDX] & USB_MASK)==USB_MASK) ; 
  19 }
  20 
  21 KeyMap keymap[] = {
  22     { 0, KEY_SET             ,0x00000400 }, // Found @0xff49e55c, levent 0x08
  23     { 0, KEY_DISPLAY         ,0x00000800 }, // Found @0xff49e564, levent 0x0a
  24     { 0, KEY_DOWN            ,0x00001000 }, // Found @0xff49e56c, levent 0x05
  25     { 0, KEY_MENU            ,0x00002000 }, // Found @0xff49e574, levent 0x09
  26     { 0, KEY_LEFT            ,0x00004000 }, // Found @0xff49e57c, levent 0x06
  27     { 0, KEY_UP              ,0x00040000 }, // Found @0xff49e59c, levent 0x04
  28     { 0, KEY_RIGHT           ,0x00080000 }, // Found @0xff49e5a4, levent 0x07
  29     { 2, KEY_POWER           ,0x00000800 }, // Found @0xff49e5fc, levent 0x100
  30     { 2, KEY_PLAYBACK        ,0x00001000 }, // Found @0xff49e604, levent 0x101
  31     { 2, KEY_SHOOT_FULL      ,0x0000c000 }, // Found @0xff49e61c, levent 0x01
  32     { 2, KEY_SHOOT_FULL_ONLY ,0x00008000 }, // Found @0xff49e61c, levent 0x01
  33     { 2, KEY_SHOOT_HALF      ,0x00004000 }, // Found @0xff49e614, levent 0x00
  34         { 0, KEY_PRINT               ,0x00800000 },
  35         { 0, KEY_FLASH           ,0x00400000 },
  36         { 0, KEY_ERASE               ,0x00020000 },     
  37         { 0, KEY_VIDEO           ,0x00010000 },
  38         { 0, KEY_ZOOM_IN             ,0x00000060 }, // 2 bits used, 4 values (0x00000060)
  39         { 0, KEY_ZOOM_IN             ,0x00000020 }, // 2 bits used, 4 values (0x00000060)
  40         { 0, KEY_ZOOM_IN             ,0x00000040 }, // 2 bits used, 4 values (0x00000060)
  41         { 0, KEY_ZOOM_OUT            ,0x00000180 }, // 2 bits used, 4 values (0x00000180)
  42         { 0, KEY_ZOOM_OUT            ,0x00000080 }, // 2 bits used, 4 values (0x00000180)
  43         { 0, KEY_ZOOM_OUT            ,0x00000100 }, // 2 bits used, 4 values (0x00000180)
  44     { 0, 0, 0 }
  45 };
  46 
  47 
  48 long __attribute__((naked)) wrap_kbd_p1_f();
  49 
  50 
  51 // no stack manipulation needed here, since we create the task directly
  52 void __attribute__((noinline))
  53 mykbd_task()
  54 {
  55         while (physw_run){
  56                 _SleepTask(physw_sleep_delay);
  57 
  58                 if (wrap_kbd_p1_f() == 1){ // autorepeat ?
  59                         _kbd_p2_f();
  60                 }
  61         }
  62     _ExitTask();
  63 }
  64 
  65 long __attribute__((naked,noinline)) wrap_kbd_p1_f()
  66 {
  67         asm volatile(
  68                 "STMFD   SP!, {R1-R7,LR}\n"
  69                 "MOV     R5, #0\n"
  70                 //"BL      _kbd_read_keys \n"
  71                 "BL             my_kbd_read_keys\n"
  72                 "B       _kbd_p1_f_cont\n"
  73         );
  74         return 0; // shut up the compiler
  75 }
  76 
  77 // Set to 1 to disable jogdial events from being processed in firmware
  78 int jogdial_stopped=0;
  79 
  80 // Pointer to stack location where jogdial task records previous and current
  81 // jogdial positions
  82 extern short* jog_position;
  83 extern short rear_dial_position;
  84 
  85 void jogdial_control(int n)
  86 {
  87     if (jogdial_stopped && !n)
  88     {
  89         // If re-enabling jogdial set the task code current & previous positions to the actual
  90         // dial positions so that the change won't get processed by the firmware
  91         jog_position[0] = jog_position[2] = rear_dial_position;   // Rear dial
  92     }
  93     jogdial_stopped = n;
  94 }
  95 
  96 void my_kbd_read_keys()
  97 {
  98     kbd_update_key_state();
  99     kbd_update_physw_bits();
 100 
 101     // Disable Zoom Assist button
 102     if (conf.zoom_assist_button_disable)
 103         physw_status[0] |= 0x00010000;
 104 }
 105 
 106 void kbd_fetch_data(long *dst)
 107 {
 108     _GetKbdState(dst);
 109     _kbd_read_keys_r2(dst);
 110 }
 111 
 112 
 113 
 114 static short new_jogdial=0, old_jogdial=0;
 115 
 116 long get_jogdial_direction(void)
 117 {
 118     old_jogdial = new_jogdial;
 119     new_jogdial = rear_dial_position;
 120     if (old_jogdial < new_jogdial) return JOGDIAL_RIGHT;
 121     else if (old_jogdial > new_jogdial) return JOGDIAL_LEFT;
 122     else return 0;
 123 }

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