root/platform/sx280hs/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. get_jogdial_counter
  6. get_jogdial_direction
  7. handle_jogdial
  8. jogdial_control
  9. my_kbd_read_keys
  10. kbd_fetch_data

   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 
  13 int get_usb_bit() {
  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     { 0, KEY_PLAYBACK        ,0x00000002 },
  22     { 0, KEY_SHOOT_FULL      ,0x0000000c },
  23     { 0, KEY_SHOOT_FULL_ONLY ,0x00000008 },
  24     { 0, KEY_SHOOT_HALF      ,0x00000004 },
  25     { 1, KEY_ZOOM_OUT        ,0x00000008 }, // full speed
  26     { 1, KEY_ZOOM_OUT        ,0x00000018 }, // middle speed
  27     { 1, KEY_ZOOM_OUT        ,0x00000010 }, // low speed
  28     { 1, KEY_ZOOM_IN         ,0x00000002 }, // full speed
  29     { 1, KEY_ZOOM_IN         ,0x00000006 }, // middle speed
  30     { 1, KEY_ZOOM_IN         ,0x00000004 }, // low speed
  31     { 0, KEY_VIDEO           ,0x00000100 },
  32     { 0, KEY_MENU            ,0x00000200 },
  33     { 0, KEY_DISPLAY         ,0x00002000 },
  34     { 0, KEY_UP              ,0x00004000 },
  35     { 0, KEY_DOWN            ,0x00008000 },
  36     { 0, KEY_RIGHT           ,0x00010000 },
  37     { 0, KEY_LEFT            ,0x00020000 },
  38     { 0, KEY_SET             ,0x00040000 },
  39     { 0, 0, 0 }
  40 };
  41 
  42 long __attribute__((naked,noinline)) wrap_kbd_p1_f() {
  43 
  44     asm volatile(
  45         "push    {r1-r7, lr}\n"
  46         "movs    r4, #0\n"
  47         "bl      my_kbd_read_keys\n"
  48         "b       _kbd_p1_f_cont\n"
  49     );
  50 
  51     return 0;
  52 }
  53 
  54 static void __attribute__((noinline)) mykbd_task_proceed() {
  55 
  56     extern void kbd_p2_f_my();
  57 
  58     while (physw_run) {
  59         _SleepTask(physw_sleep_delay);
  60 
  61         if (wrap_kbd_p1_f() == 1) {             // autorepeat ?
  62             kbd_p2_f_my();                      // replacement of _kbd_p2_f (in sub/<fwver>/boot.c)
  63         }
  64     }
  65 }
  66 
  67 // no stack manipulation needed here, since we create the task directly
  68 void __attribute__((naked,noinline)) mykbd_task() {
  69     mykbd_task_proceed();
  70 
  71     _ExitTask();
  72 }
  73 
  74 // sx280 jogdial hw counter (19 bits) 0xd9854004
  75 // 0x7fff8 .. 0x7fffc .. 0 (start pos) .. 4
  76 // intermediate positions are also available, but they are ignored by the fw for a good reason
  77 
  78 int jogdial_stopped=0;
  79 
  80 extern long jog_position[2];
  81 extern long jog_hw_pos;
  82 
  83 int get_jogdial_counter() {
  84     int p;
  85     p = jog_hw_pos & 0x7fffc;
  86     if (p > 0x3fffc) {
  87         p |= 0xfff80000;
  88     }
  89     return p;
  90 }
  91 
  92 long get_jogdial_direction(void) {
  93     static int new_jogdial=0, old_jogdial=0;
  94     
  95     old_jogdial=new_jogdial;
  96     new_jogdial=get_jogdial_counter();
  97     if (old_jogdial>new_jogdial) return JOGDIAL_LEFT; 
  98     else if (old_jogdial<new_jogdial) return JOGDIAL_RIGHT;
  99     else return 0;
 100 }
 101 
 102 int handle_jogdial() {
 103     // return 0 to prevent fw jogdial handler
 104     if (jogdial_stopped) {
 105         // update jog position in RAM
 106         jog_position[0] = jog_position[1] = get_jogdial_counter();
 107         return 0;
 108     }
 109     return 1;
 110 }
 111 
 112 void jogdial_control(int c) {
 113     jogdial_stopped = c;
 114 }
 115 
 116 void my_kbd_read_keys() {
 117     kbd_update_key_state();
 118     kbd_update_physw_bits();
 119 }
 120 
 121 void kbd_fetch_data(long *dst)
 122 {
 123     _GetKbdState(dst);
 124     _kbd_read_keys_r2(dst);
 125 }

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