root/platform/sx30/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 
  14 //void my_blinkk(void) {
  15 //      int i;
  16 ////    while(1) {
  17 //              *((volatile int *) 0xC0220134) = 0x46; // Turn on LED
  18 //              for (i=0; i<0x200000; i++) { asm volatile ( "nop\n" ); }
  19 //
  20 //              *((volatile int *) 0xC0220134) = 0x44; // Turn off LED
  21 //              for (i=0; i<0x200000; i++) { asm volatile ( "nop\n" ); }
  22 //
  23 //              *((volatile int *) 0xC0220134) = 0x46; // Turn on LED
  24 //              for (i=0; i<0x200000; i++) { asm volatile ( "nop\n" ); }
  25 //
  26 //              *((volatile int *) 0xC0220134) = 0x44; // Turn off LED
  27 //              for (i=0; i<0x900000; i++) { asm volatile ( "nop\n" ); }
  28 ////    }
  29 //}
  30 
  31 
  32 int get_usb_bit() 
  33 {
  34         long usb_physw[3];
  35         usb_physw[USB_IDX] = 0;
  36         _kbd_read_keys_r2(usb_physw);
  37         return(( usb_physw[USB_IDX] & USB_MASK)==USB_MASK) ; 
  38 }
  39 
  40 KeyMap keymap[] = {
  41         { 0, KEY_ZOOM_IN                ,0x00000060 }, // 2 bits used, 4 values (0x00000060)
  42         { 0, KEY_ZOOM_IN                ,0x00000020 }, // 2 bits used, 4 values (0x00000060)
  43         { 0, KEY_ZOOM_IN                ,0x00000040 }, // 2 bits used, 4 values (0x00000060)
  44         { 0, KEY_ZOOM_OUT               ,0x00000180 }, // 2 bits used, 4 values (0x00000180)
  45         { 0, KEY_ZOOM_OUT               ,0x00000080 }, // 2 bits used, 4 values (0x00000180)
  46         { 0, KEY_ZOOM_OUT               ,0x00000100 }, // 2 bits used, 4 values (0x00000180)
  47         { 0, KEY_UP                             ,0x00000400 },
  48         { 0, KEY_DOWN                   ,0x00000800 },
  49         { 0, KEY_LEFT                   ,0x00001000 },
  50         { 0, KEY_RIGHT                  ,0x00002000 },
  51         { 0, KEY_SET                    ,0x00004000 },
  52         { 0, KEY_VIDEO              ,0x00008000 },
  53         { 0, KEY_ZOOM_ASSIST        ,0x00010000 },
  54         { 0, KEY_DISPLAY                ,0x00020000 },
  55         { 0, KEY_MENU                   ,0x00040000 },
  56         { 0, KEY_ERASE                  ,0x00080000 },
  57         { 0, KEY_FLASH              ,0x00400000 },
  58         { 0, KEY_PRINT                  ,0x00800000 },
  59 
  60         { 2, KEY_SHOOT_FULL             ,0x00000300 },
  61     { 2, KEY_SHOOT_FULL_ONLY    ,0x00000200 },   // http://chdk.setepontos.com/index.php?topic=1444.msg70223#msg70223
  62         { 2, KEY_SHOOT_HALF             ,0x00000100 },
  63     { 2, KEY_POWER              ,0x00000400 }, // Found @0xffb979fc, levent 0x600
  64     { 2, KEY_PLAYBACK           ,0x00000800 }, // Found @0xffb97a04, levent 0x601
  65 
  66         { 0, 0, 0 } 
  67 };
  68 
  69 
  70 long __attribute__((naked)) wrap_kbd_p1_f();
  71 
  72 
  73 // no stack manipulation needed here, since we create the task directly
  74 void __attribute__((noinline))
  75 mykbd_task()
  76 {
  77         while (physw_run){
  78                 _SleepTask(physw_sleep_delay);
  79 
  80                 if (wrap_kbd_p1_f() == 1){ // autorepeat ?
  81                         _kbd_p2_f();
  82                 }
  83         }
  84 
  85     _ExitTask();
  86 }
  87 
  88 long __attribute__((naked,noinline)) wrap_kbd_p1_f()
  89 {
  90         asm volatile(
  91                 "STMFD   SP!, {R1-R5,LR}\n"
  92                 "MOV     R4, #0\n"
  93                 //"BL      _kbd_read_keys \n"
  94                 "BL             my_kbd_read_keys\n"
  95                 "B       _kbd_p1_f_cont\n"
  96         );
  97         return 0; // shut up the compiler
  98 }
  99 
 100 // Set to 1 to disable jogdial events from being processed in firmware
 101 int jogdial_stopped=0;
 102 
 103 // Pointer to stack location where jogdial task records previous and current
 104 // jogdial positions
 105 extern short* jog_position;
 106 extern short rear_dial_position;
 107 
 108 void jogdial_control(int n)
 109 {
 110     if (jogdial_stopped && !n)
 111     {
 112         // If re-enabling jogdial set the task code current & previous positions to the actual
 113         // dial positions so that the change won't get processed by the firmware
 114         jog_position[0] = jog_position[2] = rear_dial_position;   // Rear dial
 115     }
 116     jogdial_stopped = n;
 117 }
 118 
 119 void my_kbd_read_keys()
 120 {
 121     kbd_update_key_state();
 122     kbd_update_physw_bits();
 123 
 124     // Disable Zoom Assist button
 125     if (conf.zoom_assist_button_disable)
 126         physw_status[0] |= 0x00010000;
 127 }
 128 
 129 void kbd_fetch_data(long *dst)
 130 {
 131         _GetKbdState(dst);
 132         _kbd_read_keys_r2(dst);
 133 }
 134 
 135 
 136 static short new_jogdial=0, old_jogdial=0;
 137 
 138 long get_jogdial_direction(void)
 139 {
 140     old_jogdial = new_jogdial;
 141     new_jogdial = rear_dial_position;
 142     if (old_jogdial < new_jogdial) return JOGDIAL_LEFT;
 143     else if (old_jogdial > new_jogdial) return JOGDIAL_RIGHT;
 144     else return 0;
 145 }

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