root/platform/sx40hs/kbd.c

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

DEFINITIONS

This source file includes following definitions.
  1. get_usb_bit
  2. kbd_fetch_data
  3. my_kbd_read_keys
  4. wrap_kbd_p1_f
  5. mykbd_task
  6. jogdial_control
  7. get_jogdial_direction

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

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