root/platform/g11/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. my_kbd_read_keys
  5. kbd_fetch_data
  6. Get_JogDial
  7. get_jogdial_direction
  8. jogdial_control

   1 #include "lolevel.h"
   2 #include "platform.h"
   3 #include "keyboard.h"
   4 #include "kbd_common.h"
   5 extern void _GetKbdState(long* buffer);
   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 int jogdial_stopped=0;
  12 
  13 KeyMap keymap[] = {
  14 //      { grp,       hackkey, canonkey  }
  15         { 0, KEY_UP                     , 0x00004000 }, // g11
  16         { 0, KEY_DOWN           , 0x00002000 }, // g11
  17         { 0, KEY_LEFT           , 0x00000400 }, // g11
  18         { 0, KEY_RIGHT          , 0x00001000 }, // g11
  19         { 0, KEY_SET            , 0x00000800 }, // g11
  20         { 2, KEY_SHOOT_FULL     , 0x00000003 }, // g11
  21     { 2, KEY_SHOOT_FULL_ONLY, 0x00000002 },
  22         { 2, KEY_SHOOT_HALF     , 0x00000001 }, // g11
  23         { 0, KEY_ZOOM_IN        , 0x00000010 }, // g11
  24         { 0, KEY_ZOOM_OUT       , 0x00000008 }, // g11
  25         { 0, KEY_MENU           , 0x00040000 }, // g11
  26         { 0, KEY_DISPLAY        , 0x00020000 }, // g11
  27         { 0, KEY_PRINT          , 0x00000200 }, // g11 - S Key
  28         { 0, KEY_ERASE          , 0x00010000 }, // g11
  29         { 0, KEY_EXPO_CORR  , 0x00008000 }, // g11
  30         { 0, KEY_MICROPHONE , 0x00080000 }, // g11
  31         { 0, 0, 0 }
  32 };
  33 
  34 int get_usb_bit()
  35 {
  36         long usb_physw[3];
  37         usb_physw[USB_IDX] = 0;
  38         _kbd_read_keys_r2(usb_physw);
  39         return(( usb_physw[USB_IDX] & USB_MASK)==USB_MASK) ; 
  40 }
  41 
  42 
  43 long __attribute__((naked)) wrap_kbd_p1_f();
  44 
  45 void __attribute__((naked,noinline))
  46 mykbd_task(long ua, long ub, long uc, long ud, long ue, long uf)
  47 {
  48         /* Initialize our own kbd_new_state[] array with the
  49            current physical status. If we dont do this here,
  50            the G11 will immediate switch off at the first call
  51        of _GetKbdState1/2 with a (uninitialized) array.
  52            */
  53         kbd_new_state[0] = physw_status[0];
  54         kbd_new_state[1] = physw_status[1];
  55         kbd_new_state[2] = physw_status[2];
  56 
  57         while (physw_run){ 
  58                 _SleepTask(10);
  59                 if (wrap_kbd_p1_f() == 1){ // autorepeat ?
  60                         _kbd_p2_f();
  61                 }
  62     }
  63 
  64     _ExitTask();
  65 }
  66 
  67 
  68 long __attribute__((naked,noinline)) wrap_kbd_p1_f()
  69 {
  70     asm volatile(
  71                 "STMFD   SP!, {R1-R5,LR}\n"
  72                 "MOV     R4, #0\n"
  73 //                              "BL _kbd_p1_sub\n"
  74                 "BL      my_kbd_read_keys\n"
  75                 "B       _kbd_p1_f_cont\n"      
  76 
  77     );
  78  return 0; // shut up the compiler
  79 }
  80 
  81 void my_kbd_read_keys()
  82 { 
  83     kbd_update_key_state();
  84     kbd_update_physw_bits();
  85 }
  86 
  87 void kbd_fetch_data(long *dst)
  88 {
  89     _GetKbdState(dst);
  90     _kbd_read_keys_r2(dst);
  91 }
  92 
  93 
  94 static int new_jogdial=0, old_jogdial=0;
  95 
  96 /* Baseadr 0xC0240000 @FF860940
  97    Offset 104 @FF860948 in Jogdial.c
  98 */
  99 int Get_JogDial(void){
 100  return (*(int*)0xC0240104)>>16;
 101 }
 102 
 103 long get_jogdial_direction(void) { 
 104  old_jogdial=new_jogdial;
 105  new_jogdial=Get_JogDial();
 106  if (old_jogdial<new_jogdial) return JOGDIAL_LEFT; 
 107  else if (old_jogdial>new_jogdial) return JOGDIAL_RIGHT;
 108  else return 0;
 109 }
 110 
 111 void jogdial_control(int n) {
 112     // TODO jog_position was not defined on this port
 113     /*
 114     if (jogdial_stopped && !n) {
 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     }
 119     */
 120     jogdial_stopped = n;
 121 }
 122 

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