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     (void)ua; (void)ub; (void)uc; (void)ud; (void)ue; (void)uf;
  49         /* Initialize our own kbd_new_state[] array with the
  50            current physical status. If we dont do this here,
  51            the G11 will immediate switch off at the first call
  52        of _GetKbdState1/2 with a (uninitialized) array.
  53            */
  54         kbd_new_state[0] = physw_status[0];
  55         kbd_new_state[1] = physw_status[1];
  56         kbd_new_state[2] = physw_status[2];
  57 
  58         while (physw_run){ 
  59                 _SleepTask(10);
  60                 if (wrap_kbd_p1_f() == 1){ // autorepeat ?
  61                         _kbd_p2_f();
  62                 }
  63     }
  64 
  65     _ExitTask();
  66 }
  67 
  68 
  69 long __attribute__((naked,noinline)) wrap_kbd_p1_f()
  70 {
  71     asm volatile(
  72                 "STMFD   SP!, {R1-R5,LR}\n"
  73                 "MOV     R4, #0\n"
  74 //                              "BL _kbd_p1_sub\n"
  75                 "BL      my_kbd_read_keys\n"
  76                 "B       _kbd_p1_f_cont\n"      
  77 
  78     );
  79  return 0; // shut up the compiler
  80 }
  81 
  82 void my_kbd_read_keys()
  83 { 
  84     kbd_update_key_state();
  85     kbd_update_physw_bits();
  86 }
  87 
  88 void kbd_fetch_data(long *dst)
  89 {
  90     _GetKbdState(dst);
  91     _kbd_read_keys_r2(dst);
  92 }
  93 
  94 
  95 static int new_jogdial=0, old_jogdial=0;
  96 
  97 /* Baseadr 0xC0240000 @FF860940
  98    Offset 104 @FF860948 in Jogdial.c
  99 */
 100 int Get_JogDial(void){
 101  return (*(int*)0xC0240104)>>16;
 102 }
 103 
 104 long get_jogdial_direction(void) { 
 105  old_jogdial=new_jogdial;
 106  new_jogdial=Get_JogDial();
 107  if (old_jogdial<new_jogdial) return JOGDIAL_LEFT; 
 108  else if (old_jogdial>new_jogdial) return JOGDIAL_RIGHT;
 109  else return 0;
 110 }
 111 
 112 void jogdial_control(int n) {
 113     // TODO jog_position was not defined on this port
 114     /*
 115     if (jogdial_stopped && !n) {
 116         // If re-enabling jogdial set the task code current & previous positions to the actual
 117         // dial positions so that the change won't get processed by the firmware
 118         jog_position[0] = jog_position[2] = rear_dial_position;   // Rear dial
 119     }
 120     */
 121     jogdial_stopped = n;
 122 }
 123 

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