root/platform/sx160is/kbd.c

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

DEFINITIONS

This source file includes following definitions.
  1. get_usb_bit
  2. get_hdmi_hpd_bit
  3. get_analog_av_bit
  4. wrap_kbd_p1_f
  5. mykbd_task_proceed
  6. mykbd_task
  7. jogdial_control
  8. kbd_fetch_data
  9. my_kbd_read_keys
  10. get_jogdial_direction

   1 #include "lolevel.h"
   2 #include "platform.h"
   3 #include "core.h"
   4 #include "keyboard.h"
   5 #include "kbd_common.h"
   6 
   7 
   8 long kbd_new_state[3] = { 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF };
   9 long kbd_prev_state[3] = { 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF };
  10 long kbd_mod_state[3] = { 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF };
  11 
  12 extern void _GetKbdState(long*);
  13 
  14 int get_usb_bit() {
  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 int get_hdmi_hpd_bit() {
  22     long hpd_physw[3];
  23     hpd_physw[HDMI_HPD_IDX] = 0;
  24     _GetKbdState(hpd_physw);
  25     return( ((hpd_physw[HDMI_HPD_IDX] & HDMI_HPD_FLAG)==HDMI_HPD_FLAG)?0:1) ;
  26 }
  27 
  28 int get_analog_av_bit() {
  29     long av_physw[3];
  30     av_physw[ANALOG_AV_IDX] = 0;
  31     _GetKbdState(av_physw);
  32     return( ((av_physw[ANALOG_AV_IDX] & ANALOG_AV_FLAG)==ANALOG_AV_FLAG)?0:1) ;
  33 }
  34 
  35 KeyMap keymap[] = {
  36     // Order IS important. kbd_get_pressed_key will walk down this table
  37     // and take the first matching mask. Notice that KEY_SHOOT_HALF is
  38     // always pressed if KEY_SHOOT_FULL is. --MarcusSt
  39     { 0, KEY_DISPLAY         ,0x80000000 }, // Found @0xffba4ac4, levent 0x0a
  40     { 1, KEY_DOWN            ,0x80000000 }, // Found @0xffba4b0c, levent 0x05
  41     { 1, KEY_UP              ,0x40000000 }, // Found @0xffba4b04, levent 0x04
  42     { 1, KEY_SHOOT_FULL      ,0x30000000 }, // Found @0xffba4afc, levent 0x01
  43     { 1, KEY_SHOOT_FULL_ONLY ,0x20000000 }, // Found @0xffba4afc, levent 0x01
  44     { 1, KEY_SHOOT_HALF      ,0x10000000 }, // Found @0xffba4af4, levent 0x00
  45     { 1, KEY_ERASE           ,0x08000000 },
  46     { 1, KEY_MENU            ,0x00800000 }, // Found @0xffba4ae4, levent 0x09
  47     { 1, KEY_SET             ,0x00000001 }, // Found @0xffba4acc, levent 0x08
  48     { 2, KEY_LEFT            ,0x00002000 }, // Found @0xffba4b4c, levent 0x06
  49     { 2, KEY_RIGHT           ,0x00001000 }, // Found @0xffba4b44, levent 0x07
  50     { 2, KEY_ZOOM_IN         ,0x00000080 }, // Found @0xffba4b34, levent 0x02
  51     { 2, KEY_ZOOM_OUT        ,0x00000040 }, // Found @0xffba4b2c, levent 0x03
  52     { 2, KEY_POWER           ,0x00000020 }, // Found @0xffba4b24, levent 0x100
  53     { 2, KEY_PLAYBACK        ,0x00000008 }, // Found @0xffba4b1c, levent 0x101
  54     { 2, KEY_VIDEO           ,0x00000001 },
  55     { 0, 0, 0 }
  56 };
  57 
  58 //volatile int jogdial_stopped=0;
  59 int jogdial_stopped=0;
  60 
  61 long __attribute__((naked,noinline)) wrap_kbd_p1_f() {
  62 
  63     //sx160 100a @ 0xff829238
  64     asm volatile(
  65                 "STMFD   SP!, {R1-R7,LR}\n"
  66                 "MOV     R5, #0\n"
  67                 "BL      my_kbd_read_keys\n"
  68                 "B       _kbd_p1_f_cont\n"
  69     );
  70 
  71     return 0;
  72 }
  73 
  74 static void __attribute__((noinline)) mykbd_task_proceed() {
  75     while (physw_run) {
  76         _SleepTask(physw_sleep_delay);
  77 
  78         if (wrap_kbd_p1_f() == 1) {             // autorepeat ?
  79             _kbd_p2_f();
  80         }
  81     }
  82 }
  83 
  84 // no stack manipulation needed here, since we create the task directly
  85 void __attribute__((naked,noinline)) mykbd_task() {
  86     mykbd_task_proceed();
  87 
  88 // function can be modified to restore SP here...
  89     _ExitTask();
  90 }
  91 
  92 // Pointer to stack location where jogdial task records previous and current
  93 // jogdial positions
  94 extern short* jog_position;
  95 extern short rear_dial_position;
  96 
  97 void jogdial_control(int n) {
  98     if (jogdial_stopped && !n) {
  99         // If re-enabling jogdial set the task code current & previous positions to the actual
 100         // dial positions so that the change won't get processed by the firmware
 101         jog_position[0] = jog_position[2] = rear_dial_position;   // Rear dial
 102     }
 103     jogdial_stopped = n;
 104 }
 105 
 106 void kbd_fetch_data(long *state) {
 107     _GetKbdState(state);
 108     _kbd_read_keys_r2(state);
 109 }
 110 void my_kbd_read_keys()
 111 {
 112     kbd_update_key_state();
 113     kbd_update_physw_bits();
 114 }
 115 
 116 static short new_jogdial = 0, old_jogdial = 0;
 117 
 118 long get_jogdial_direction(void)
 119 {
 120     old_jogdial = new_jogdial;
 121     new_jogdial = rear_dial_position;
 122 
 123     if      (old_jogdial > new_jogdial)     return JOGDIAL_RIGHT;
 124     else if (old_jogdial < new_jogdial)     return JOGDIAL_LEFT;
 125     else                                    return 0;
 126 }

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