root/platform/sx220hs/kbd.c

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

DEFINITIONS

This source file includes following definitions.
  1. get_usb_bit
  2. my_blinkk
  3. mykbd_task
  4. wrap_kbd_p1_f
  5. jogdial_control
  6. my_kbd_read_keys
  7. kbd_fetch_data
  8. Get_JogDial
  9. 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 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     /* tiny bug: key order matters. see kbd_get_pressed_key()
  23     * for example*/
  24 
  25     { 0, KEY_ZOOM_OUT        , 0x00000003 },
  26     { 0, KEY_ZOOM_OUT        , 0x00000001 },
  27     { 0, KEY_ZOOM_OUT        , 0x00000002 },
  28     { 0, KEY_ZOOM_IN         , 0x0000000C },
  29     { 0, KEY_ZOOM_IN         , 0x00000004 },
  30     { 0, KEY_ZOOM_IN         , 0x00000008 },
  31     { 0, KEY_DISPLAY         , 0x00000800 },
  32     { 0, KEY_UP              , 0x00001000 },
  33     { 0, KEY_RIGHT           , 0x00006000 },
  34     { 0, KEY_SET             , 0x00010000 },
  35     { 0, KEY_DOWN            , 0x00020000 },
  36     { 0, KEY_MENU            , 0x00040000 },
  37     { 0, KEY_VIDEO           , 0x00080000 },
  38  //   { 0, KEY_RIGHT_SOFT      , 0x00002000 },  //soft keys commented out but still counted in the keymasks, seems to disable them like we want.
  39  //   { 0, KEY_UP_SOFT         , 0x00000400 },  //if enabled can cause unintentional button presses in alt menu when rotating the jogdial really fast.
  40  //   { 0, KEY_DOWN_SOFT       , 0x00008000 },
  41 
  42     { 1, KEY_PRINT           , 0x00200000 }, // playback = alt button
  43     { 1, KEY_PLAYBACK        , 0x00200000 },
  44 
  45  //   { 2, KEY_LEFT_SOFT       , 0x00000080 },
  46     { 2, KEY_LEFT            , 0x00000100 },
  47     { 2, KEY_SHOOT_FULL      , 0x00002002 },
  48     { 2, KEY_SHOOT_FULL_ONLY , 0x00000002 },
  49     { 2, KEY_SHOOT_HALF      , 0x00002000 },
  50 
  51     { 0, 0, 0 }
  52 };
  53 
  54 
  55 #if 0
  56 void my_blinkk(void) {
  57     int i;
  58     while(1) {
  59         *((volatile int *) 0xC0220130) = 0x46; // Turn on LED
  60         for (i=0; i<0x200000; i++) { asm volatile ( "nop\n" ); }
  61 
  62         *((volatile int *) 0xC0220130) = 0x44; // Turn off LED
  63         for (i=0; i<0x200000; i++) { asm volatile ( "nop\n" ); }
  64 
  65         *((volatile int *) 0xC0220130) = 0x46; // Turn on LED
  66         for (i=0; i<0x200000; i++) { asm volatile ( "nop\n" ); }
  67 
  68         *((volatile int *) 0xC0220130) = 0x44; // Turn off LED
  69         for (i=0; i<0x900000; i++) { asm volatile ( "nop\n" ); }
  70     }
  71 }
  72 #endif
  73 
  74 // Set to 1 to disable jogdial events from being processed in firmware
  75 int jogdial_stopped=0;
  76 
  77 long __attribute__((naked)) wrap_kbd_p1_f();
  78 
  79 // no stack manipulation needed here, since we create the task directly
  80 void __attribute__((noinline)) mykbd_task() {
  81     while (physw_run) {
  82         _SleepTask(physw_sleep_delay);
  83 
  84         if (wrap_kbd_p1_f() == 1) {   // autorepeat ?
  85             _kbd_p2_f();
  86         }
  87     }
  88 
  89     _ExitTask();
  90 }
  91 
  92 // 
  93 long __attribute__((naked,noinline)) wrap_kbd_p1_f() {
  94     asm volatile(
  95                 "STMFD   SP!, {R1-R7,LR}\n"       //SX220 modified
  96                 "MOV     R5, #0\n"
  97             //    "BL      _kbd_read_keys\n"       // replaces kbd_fetch_data()
  98                 "BL      my_kbd_read_keys\n"     // +
  99                 "B       _kbd_p1_f_cont\n"       // continue
 100     );
 101 
 102     return 0;   // shut up the compiler
 103 }
 104 
 105 // copied from g12 and sx30, thx to philmoz
 106 // Pointer to stack location where jogdial task records previous and current
 107 // jogdial positions
 108 extern short* jog_position;
 109 
 110 void jogdial_control(int n)
 111 {
 112     if (jogdial_stopped && !n)
 113     {
 114         // If re-enabling jogdial set the task code current & previous positions to the actual
 115         // dial positions so that the change won't get processed by the firmware
 116         jog_position[0] = jog_position[2] = (*(short*)0xC0240106);  // Rear dial
 117     }
 118     jogdial_stopped = n;
 119 }
 120 
 121 // like SX30 and g12
 122 void my_kbd_read_keys() {
 123     kbd_update_key_state();
 124     kbd_update_physw_bits();
 125 }
 126 
 127 void kbd_fetch_data(long *dst)
 128 {
 129     _GetKbdState(dst);
 130     _kbd_read_keys_r2(dst);
 131 }
 132 
 133 int Get_JogDial(void) {
 134     return (*(int*)0xC0240104)>>16;     // 0xC0240000 + 0x104
 135 }
 136 
 137 static int new_jogdial=0, old_jogdial=0;
 138 
 139 long get_jogdial_direction(void) {
 140     old_jogdial=new_jogdial;
 141     new_jogdial=Get_JogDial();
 142 
 143     if (old_jogdial<new_jogdial) {
 144         return JOGDIAL_RIGHT;
 145     } else if (old_jogdial>new_jogdial) {
 146         return JOGDIAL_LEFT;
 147     } else {
 148         return 0;
 149     }
 150 }

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