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

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