root/platform/g1x/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_DISPLAY         ,0x00000400 }, // Pretend the Metering button is the Disp button
  10 //  { 0, KEY_METERING        ,0x00000400 },
  11     { 0, KEY_SET             ,0x00000800 }, // Found @0xff464ca4, levent 0x08
  12     { 0, KEY_RIGHT           ,0x00001000 }, // Found @0xff464cac, levent 0x07
  13     { 0, KEY_DOWN            ,0x00002000 }, // Found @0xff464cb4, levent 0x05
  14 //  { 0, KEY_DISPLAY         ,0x00002000 }, 
  15     { 0, KEY_MENU            ,0x00004000 }, // Found @0xff464cbc, levent 0x09
  16     { 0, KEY_LEFT            ,0x00008000 }, // Found @0xff464cc4, levent 0x06
  17     { 0, KEY_ERASE           ,0x00010000 },
  18     { 0, KEY_AE_LOCK         ,0x00020000 },
  19     { 0, KEY_UP              ,0x00040000 }, // Found @0xff464cdc, levent 0x04
  20     { 0, KEY_VIDEO           ,0x00080000 },
  21     { 0, KEY_ZOOM_IN         ,0x00100000 }, // Found @0xff464cec, levent 0x02
  22     { 0, KEY_ZOOM_OUT        ,0x00200000 }, // Found @0xff464cf4, levent 0x03
  23     { 0, KEY_PRINT           ,0x01000000 },
  24 
  25     { 2, KEY_POWER           ,0x00000800 }, // Found @0xff464d34, levent 0x100
  26     { 2, KEY_PLAYBACK        ,0x00008000 }, // Found @0xff464d54, levent 0x101
  27     { 2, KEY_SHOOT_FULL      ,0x000c0000 }, // Found @0xff464d64, levent 0x01
  28     { 2, KEY_SHOOT_FULL_ONLY ,0x00080000 }, // Found @0xff464d64, levent 0x01
  29     { 2, KEY_SHOOT_HALF      ,0x00040000 }, // Found @0xff464d5c, levent 0x00
  30 
  31     { 0, 0, 0 }
  32 };
  33 
  34 long kbd_new_state[3] = { 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF };
  35 long kbd_prev_state[3] = { 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF };
  36 long kbd_mod_state[3] = { 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF };
  37 
  38 extern void _GetKbdState(long*);
  39 
  40 int get_usb_bit()
  41 {
  42         long usb_physw[3];
  43         usb_physw[USB_IDX] = 0;
  44         _kbd_read_keys_r2(usb_physw);
  45         return(( usb_physw[USB_IDX] & USB_MASK)==USB_MASK) ;
  46 }
  47 
  48 void kbd_fetch_data(long *dst)
  49 {
  50     _GetKbdState(dst);
  51     _kbd_read_keys_r2(dst);
  52 }
  53 
  54 void my_kbd_read_keys()
  55 {
  56     kbd_update_key_state();
  57     kbd_update_physw_bits();
  58 }
  59 
  60 long __attribute__((naked,noinline)) wrap_kbd_p1_f()
  61 {
  62     asm volatile(
  63         "STMFD   SP!, {R1-R7,LR}\n"
  64         "MOV     R5, #0\n"
  65         //"BL      _kbd_read_keys \n"
  66         "BL     my_kbd_read_keys\n"
  67         "B       _kbd_p1_f_cont\n"
  68     );
  69     return 0; // shut up the compiler
  70 }
  71 
  72 // no stack manipulation needed here, since we create the task directly
  73 void __attribute__((naked,noinline))
  74 mykbd_task()
  75 {
  76     while (physw_run){
  77         _SleepTask(physw_sleep_delay);
  78 
  79         if (wrap_kbd_p1_f() == 1){ // autorepeat ?
  80             _kbd_p2_f();
  81         }
  82     }
  83 
  84     _ExitTask();
  85 }
  86 
  87 // Set to 1 to disable jogdial events from being processed in firmware
  88 int jogdial_stopped=0;
  89 
  90 // Pointer to stack location where jogdial task records previous and current
  91 // jogdial positions
  92 extern short* jog_position;
  93 extern short rear_dial_position, front_dial_position;
  94 
  95 void jogdial_control(int n)
  96 {
  97     if (jogdial_stopped && !n)
  98     {
  99         // If re-enabling jogdial set the task code current & previous positions to the actual
 100         // dial positions so that the change won't get processed by the firmware
 101         jog_position[0] = jog_position[2] = rear_dial_position;   // Rear dial
 102         jog_position[1] = jog_position[3] = front_dial_position;  // Front dial
 103     }
 104     jogdial_stopped = n;
 105 }
 106 
 107 static short new_jogdial = 0, old_jogdial = 0, new_frontdial = 0, old_frontdial = 0;
 108 
 109 long get_jogdial_direction(void)
 110 {
 111     old_jogdial = new_jogdial;
 112     new_jogdial = rear_dial_position;
 113 
 114     old_frontdial = new_frontdial;
 115     new_frontdial = front_dial_position;
 116 
 117     if      (old_jogdial < new_jogdial)     return JOGDIAL_LEFT;
 118     else if (old_jogdial > new_jogdial)     return JOGDIAL_RIGHT;
 119     else if (old_frontdial > new_frontdial) return FRONTDIAL_LEFT;
 120     else if (old_frontdial < new_frontdial) return FRONTDIAL_RIGHT;
 121     else                                    return 0;
 122 }

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