root/platform/g7/kbd.c

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

DEFINITIONS

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

   1 #include "lolevel.h"
   2 #include "platform.h"
   3 #include "keyboard.h"
   4 #include "kbd_common.h"
   5 
   6 long kbd_new_state[3] = { 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF };
   7 long kbd_prev_state[3] = { 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF };
   8 long kbd_mod_state[3] = { 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF };
   9 
  10 KeyMap keymap[] = {
  11     /* tiny bug: key order matters. see kbd_get_pressed_key()
  12      * for example
  13      */
  14     { 1, KEY_UP,                0x00100000 },
  15     { 1, KEY_DOWN,              0x00080000 },
  16     { 1, KEY_LEFT,              0x00010000 },
  17     { 1, KEY_RIGHT,             0x00040000 },
  18     { 1, KEY_SET,               0x00020000 },
  19     { 0, KEY_SHOOT_FULL,        0xC0000000 },
  20     { 0, KEY_SHOOT_FULL_ONLY,   0x80000000 },
  21     { 0, KEY_SHOOT_HALF,        0x40000000 },
  22     { 1, KEY_ZOOM_IN,           0x00000010 },
  23     { 1, KEY_ZOOM_OUT,          0x00000008 },
  24     { 1, KEY_MENU,              0x08000000 },
  25     { 1, KEY_DISPLAY,           0x04000000 },
  26     { 1, KEY_PRINT,             0x00001000 },
  27     { 1, KEY_ERASE,             0x01000000 },
  28     { 1, KEY_EXPO_CORR,         0x02000000 },
  29     { 1, KEY_MICROPHONE,        0x10000000 },
  30     { 0, 0, 0 }
  31 };
  32 
  33 static int new_jogdial=0, old_jogdial=0;
  34 
  35 #define NEW_SS (0x2000)
  36 
  37 int get_usb_bit() 
  38 {
  39         long usb_physw[3];
  40         usb_physw[USB_IDX] = 0;
  41         _kbd_read_keys_r2(usb_physw);
  42         return(( usb_physw[USB_IDX] & USB_MASK)==USB_MASK) ; 
  43 }
  44 
  45 static char kbd_stack[NEW_SS];
  46 
  47 extern void _platformsub_kbd_fetch_data(long*);
  48 long __attribute__((naked)) wrap_kbd_p1_f();
  49 
  50 static void __attribute__((noinline)) mykbd_task_proceed()
  51 {
  52     while (physw_run){
  53         _SleepTask(10);
  54 
  55         if (wrap_kbd_p1_f() == 1){ // autorepeat ?
  56             _kbd_p2_f();
  57         }
  58     }
  59 }
  60 
  61 void __attribute__((naked,noinline))
  62 mykbd_task(long ua, long ub, long uc, long ud, long ue, long uf)
  63 {
  64     /* WARNING
  65      * Stack pointer manipulation performed here!
  66      * This means (but not limited to):
  67      *  function arguments destroyed;
  68      *  function CAN NOT return properly;
  69      *  MUST NOT call or use stack variables before stack
  70      *  is setup properly;
  71      *
  72      */
  73 
  74     register int i;
  75     register long *newstack;
  76 
  77     newstack = (void*)kbd_stack;
  78 
  79     for (i=0;i<NEW_SS/4;i++)
  80         newstack[i]=0xdededede;
  81 
  82     asm volatile (
  83         "MOV    SP, %0"
  84         :: "r"(((char*)newstack)+NEW_SS)
  85         : "memory"
  86     );
  87 
  88     mykbd_task_proceed();
  89 
  90     /* function can be modified to restore SP here...
  91      */
  92 
  93     _ExitTask();
  94 }
  95 
  96 
  97 long __attribute__((naked,noinline)) wrap_kbd_p1_f()
  98 {
  99 
 100     asm volatile(
 101                 "STMFD   SP!, {R4-R7,LR}\n"
 102                 "SUB     SP, SP, #0xC\n"
 103                 "BL      my_kbd_read_keys\n"
 104                 "B       _kbd_p1_f_cont\n"
 105     );
 106     return 0; // shut up the compiler
 107 }
 108 
 109 static int handle_taskTouchW = 0;
 110 
 111 int jogdial_stopped=0;
 112 
 113 void jogdial_control(int n) {
 114     // assumes jogdial task is started by the time this gets called
 115     if (handle_taskTouchW == 0) {
 116         handle_taskTouchW = _taskNameToId("tJogDial");
 117     }
 118 
 119     if (jogdial_stopped) {
 120         if(!n) {
 121             // if stopped and un-stopping, resume TouchW task
 122             _taskResume(handle_taskTouchW);
 123         }
 124     } else {
 125         if(n) {
 126             // if not stopped and stopping, halt TouchW task
 127                     _taskSuspend(handle_taskTouchW);
 128         }
 129     }
 130     jogdial_stopped = n;
 131 }
 132 
 133 
 134 void my_kbd_read_keys()
 135 {
 136     // not called in original port
 137     //_kbd_pwr_on();
 138 
 139     kbd_update_key_state();
 140 
 141     _kbd_read_keys_r2(physw_status);
 142 
 143     kbd_update_physw_bits();
 144 
 145     _kbd_pwr_off();
 146 }
 147 
 148 void kbd_fetch_data(long *dst)
 149 {
 150     _platformsub_kbd_fetch_data(dst);
 151 }
 152 
 153 
 154 
 155 int Get_JogDial(void){
 156  return (*(int*)0xC0240304)>>16;
 157 }
 158 
 159 long get_jogdial_direction(void) { 
 160  old_jogdial=new_jogdial;
 161  new_jogdial=Get_JogDial();
 162  if (old_jogdial<new_jogdial) return JOGDIAL_LEFT; 
 163  else if (old_jogdial>new_jogdial) return JOGDIAL_RIGHT;
 164  else return 0;
 165 }
 166 

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