CHDK_DE Vorschauversion  Trunk Rev. 5300
 Alle Datenstrukturen Dateien Funktionen Variablen Typdefinitionen Aufzählungen Aufzählungswerte Makrodefinitionen
kbd.c-Dateireferenz
#include "stdlib.h"
#include "lolevel.h"
#include "platform.h"
#include "core.h"
#include "conf.h"
#include "kbd_common.h"
#include "touchscreen.h"
#include "levent.h"
#include "gui.h"
#include "gui_draw.h"
#include "gui_osd.h"
#include "font.h"
+ Include-Abhängigkeitsdiagramm für kbd.c:

gehe zum Quellcode dieser Datei

Makrodefinitionen

#define TS_KEY_TOGGLE_RAW   200
 
#define TS_KEY_TOGGLE_ZEBRA   201
 
#define TS_KEY_TOGGLE_HISTO   202
 
#define TS_KEY_TOGGLE_OSD   203
 
#define TS_KEY_TOGGLE_OVRD   204
 
#define TS_KEY_TOGGLE_EDGE   205
 
#define TS_KEY_PLAYBACK   214
 
#define TS_KEY_POWER   215
 
#define TS_XL   0
 
#define TS_XR   422
 
#define TS_W   58
 
#define TS_YT   0
 
#define TS_H   48
 
#define LB(x, n, s)   TS_XL+x*TS_W, TS_YT+n*TS_H, TS_XL+(x+1)*TS_W-1, TS_YT+n*TS_H+TS_H-1, s
 
#define RB(x, n, s)   TS_XR-x*TS_W, TS_YT+n*TS_H, TS_XR-(x-1)*TS_W-1, TS_YT+n*TS_H+TS_H-1, s
 
#define MODE_VID   0x400
 

Funktionen

void _GetKbdState (long *)
 
const char * gui_on_off_enum (int change, int arg)
 
const char * gui_histo_show_enum (int change, int arg)
 
const char * gui_override_disable_enum (int change, int arg)
 
static int is_button_displayed (int b, int guiMode, int camMode)
 
static int is_button_active (int b, int guiMode, int camMode)
 
int show_virtual_buttons ()
 
int chdk_process_touch ()
 
static int draw_test_pixel (coord x, coord y, color c)
 
void virtual_buttons ()
 
int ts_process_touch ()
 
int get_usb_bit ()
 
void kbd_fetch_data (long *dst)
 
void my_kbd_read_keys ()
 
long __attribute__ ((naked, noinline))
 *-------------------------------------------------------------------— Mehr ...
 

Variablen

long kbd_new_state [4] = { 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF }
 
long kbd_prev_state [4] = { 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF }
 
long kbd_mod_state [4] = { 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF }
 
static long touch_panel_state
 
KeyMap keymap []
 
int redraw_buttons = 1
 

Makro-Dokumentation

#define LB (   x,
  n,
  s 
)    TS_XL+x*TS_W, TS_YT+n*TS_H, TS_XL+(x+1)*TS_W-1, TS_YT+n*TS_H+TS_H-1, s

Definiert in Zeile 57 der Datei kbd.c.

#define MODE_VID   0x400

Definiert in Zeile 64 der Datei kbd.c.

#define RB (   x,
  n,
  s 
)    TS_XR-x*TS_W, TS_YT+n*TS_H, TS_XR-(x-1)*TS_W-1, TS_YT+n*TS_H+TS_H-1, s

Definiert in Zeile 58 der Datei kbd.c.

#define TS_H   48

Definiert in Zeile 56 der Datei kbd.c.

#define TS_KEY_PLAYBACK   214

Definiert in Zeile 49 der Datei kbd.c.

#define TS_KEY_POWER   215

Definiert in Zeile 50 der Datei kbd.c.

#define TS_KEY_TOGGLE_EDGE   205

Definiert in Zeile 48 der Datei kbd.c.

#define TS_KEY_TOGGLE_HISTO   202

Definiert in Zeile 45 der Datei kbd.c.

#define TS_KEY_TOGGLE_OSD   203

Definiert in Zeile 46 der Datei kbd.c.

#define TS_KEY_TOGGLE_OVRD   204

Definiert in Zeile 47 der Datei kbd.c.

#define TS_KEY_TOGGLE_RAW   200

Definiert in Zeile 43 der Datei kbd.c.

#define TS_KEY_TOGGLE_ZEBRA   201

Definiert in Zeile 44 der Datei kbd.c.

#define TS_W   58

Definiert in Zeile 54 der Datei kbd.c.

#define TS_XL   0

Definiert in Zeile 52 der Datei kbd.c.

#define TS_XR   422

Definiert in Zeile 53 der Datei kbd.c.

#define TS_YT   0

Definiert in Zeile 55 der Datei kbd.c.

Dokumentation der Funktionen

long __attribute__ ( (naked, noinline)  )

*-------------------------------------------------------------------—

!!

IS_ERROR( hSoundHandle )

IS_ERROR( RetCode )

IS_ERROR( RetCode )

IS_ERROR( RetCode )

IS_ERROR( RetCode )

Definiert in Zeile 342 der Datei kbd.c.

343 {
344  asm volatile(
345  "STMFD SP!, {R1-R7,LR}\n"
346  "MOV R5, #0\n"
347  //"BL _kbd_read_keys \n"
348  "BL my_kbd_read_keys\n"
349  "B _kbd_p1_f_cont\n"
350  );
351  return 0; // shut up the compiler
352 }
void _GetKbdState ( long *  )
int chdk_process_touch ( )

Definiert in Zeile 153 der Datei kbd.c.

154 {
155  //ts_check_cnt++;
156 
157  // If in canon menu, let the firmware have all the touch events.
158  if (!show_virtual_buttons()) return 0;
159 
161 
162  // Touch co-ordinate
163  unsigned int tx = ((touch_screen_x & 0x7FFF) >> 5) ^ 0x3FF;
164  unsigned int ty = ((touch_screen_y & 0x7FFF) >> 5) ^ 0x3FF;
165  // Screen co-ordinate
166  int sx = ((tx - 40) * 480) / 954;
167  int sy = ((ty - 60) * 240) / 900;
168  if (conf.rotate_osd)
169  {
170  sx = 480 - sx;
171  sy = 240 - sy;
172  }
173 
174  // Search for CHDK on screen buttons matching co-ordinate
175  int i;
176  for (i=0; keymap[i].hackkey; i++)
177  {
178  if ((sx >= keymap[i].x1) && (sx < keymap[i].x2) && (sy >= keymap[i].y1) && (sy < keymap[i].y2) && is_button_active(i,camera_info.state.gui_mode,camMode))
179  {
181  }
182  }
183 
184  // Check if menu touched
185  int mk = gui_touch_process(sx, sy);
186  if (mk != 0)
187  {
188  for (i=0; keymap[i].hackkey; i++)
189  {
190  if ((keymap[i].hackkey == mk) && is_button_active(i,camera_info.state.gui_mode,camMode))
191  {
193  }
194  }
195  }
196 
197  // If in alt mode (or about to enter alt mode) block event from firmware
198  return !camera_info.state.gui_mode_none || (((touch_panel_state & 1) == 0) && ((kbd_mod_state[3] & 1) != 0));
199 }
static int draw_test_pixel ( coord  x,
coord  y,
color  c 
)
static

Definiert in Zeile 204 der Datei kbd.c.

205 {
206  extern char* bitmap_buffer[];
207  extern int active_bitmap_buffer;
208  if (conf.rotate_osd)
209  return (bitmap_buffer[active_bitmap_buffer][(240-y) * camera_screen.buffer_width + ASPECT_XCORRECTION(480-x) - 1] == c);
210  else
211  return (bitmap_buffer[active_bitmap_buffer][y * camera_screen.buffer_width + ASPECT_XCORRECTION(x)] == c);
212 }
int get_usb_bit ( )

Definiert in Zeile 306 der Datei kbd.c.

307 {
308  long usb_physw[3];
309  usb_physw[USB_IDX] = 0;
310  _kbd_read_keys_r2(usb_physw);
311  return(( usb_physw[USB_IDX] & USB_MASK)==USB_MASK) ;
312 }
const char* gui_histo_show_enum ( int  change,
int  arg 
)
const char* gui_on_off_enum ( int  change,
int  arg 
)
const char* gui_override_disable_enum ( int  change,
int  arg 
)
static int is_button_active ( int  b,
int  guiMode,
int  camMode 
)
static

Definiert in Zeile 140 der Datei kbd.c.

141 {
142  return (is_button_displayed(b, guiMode, camMode) && keymap[b].canonkey);
143 }
static int is_button_displayed ( int  b,
int  guiMode,
int  camMode 
)
static

Definiert in Zeile 129 der Datei kbd.c.

130 {
131  return (
132  (keymap[b].grp == 3) &&
133  (guiMode >= keymap[b].min_gui_mode) &&
134  (guiMode <= keymap[b].max_gui_mode) &&
135  (camMode & keymap[b].cam_mode_mask) &&
136  ((keymap[b].conf_disable == 0) || (*keymap[b].conf_disable == 0))
137  );
138 }
void kbd_fetch_data ( long *  dst)

Definiert in Zeile 314 der Datei kbd.c.

315 {
316  _GetKbdState(dst);
318 
319  static int was_active = 0;
320 
321  if (touch_screen_active == 2) // Touch screen activated?
322  {
323  was_active = 1; // Record activated, wait until released
324  }
325  else if (was_active)
326  {
327  kbd_new_state[3] = touch_panel_state; // Use virtual button state
328  was_active = 0;
329  }
330  else
331  {
332  kbd_new_state[3] = touch_panel_state = 0xFFFFFFFF; // Clear out virtual button state
333  }
334 }
void my_kbd_read_keys ( )

Definiert in Zeile 336 der Datei kbd.c.

337 {
340 }
int show_virtual_buttons ( )

Definiert in Zeile 145 der Datei kbd.c.

146 {
147  extern char canon_play_menu_active;
148  return (canon_menu_active==(int)&canon_menu_active-4) && (canon_shoot_menu_active==0) && (canon_play_menu_active == 0);
149 }
int ts_process_touch ( )

Definiert in Zeile 274 der Datei kbd.c.

275 {
276  int rv = 0, i;
277 
278  if (touch_panel_state != 0xFFFFFFFF)
279  {
281 
282  //ts_proc_cnt++;
283 
284  for (i=0; keymap[i].hackkey; i++)
285  {
286  if (is_button_active(i, camera_info.state.gui_mode, camMode))
287  {
288  if (kbd_is_key_clicked(keymap[i].hackkey))
289  {
290  if (keymap[i].conf_val && keymap[i].chg_val)
291  {
292  keymap[i].chg_val(1,(int)keymap[i].conf_val);
293  rv = keymap[i].redraw & 1;
294  }
295  if (keymap[i].redraw & 2) redraw_buttons = 1;
296  }
297  }
298  }
299  }
300 
301  return rv;
302 }
void virtual_buttons ( )

Definiert in Zeile 214 der Datei kbd.c.

215 {
216  char buf[30];
217 
218  // If shooting or in any Canon menus then don't display any CHDK buttons
220 
221  // Check if border of CHDK button is corrupted, force redraw if so
223 
224  if (redraw_buttons)
225  {
226  //ts_redraw_cnt++;
227 
228  int i, x1, y1, x2, y2, ofst, sc, xo, yo;
230 
231  color c1 = MAKE_COLOR(COLOR_GREY_DK_TRANS, COLOR_WHITE);
233 
234  for (i=0; keymap[i].hackkey; i++)
235  {
236  if (is_button_displayed(i, camera_info.state.gui_mode, camMode) && keymap[i].nm)
237  {
238  x1 = keymap[i].x1;
239  x2 = keymap[i].x2;
240  y1 = keymap[i].y1;
241  y2 = keymap[i].y2;
242  sc = keymap[i].sc;
243  yo = (sc == 1) ? 16 : 8;
244 
245  twoColors cl = c1;
246  if (camera_info.state.gui_mode && (keymap[i].hackkey == KEY_PRINT)) cl = c2;
247  if (keymap[i].conf_val && *keymap[i].conf_val) cl = c2;
248 
250 
251  if (keymap[i].conf_val && keymap[i].chg_val)
252  {
253  yo -= 9;
254  strcpy(buf,(char*)keymap[i].chg_val(0,(int)keymap[i].conf_val));
255  buf[6] = 0;
256  xo = (58 - strlen(buf)*FONT_WIDTH*sc) / 2;
257  draw_string(x1+xo, y1+yo+18, buf, cl);
258  }
259  else if (keymap[i].nm2)
260  {
261  yo -= 9;
262  xo = (58 - strlen(keymap[i].nm2)*FONT_WIDTH*sc) / 2;
263  draw_string(x1+xo, y1+yo+18, keymap[i].nm2, cl);
264  }
265  xo = (58 - strlen(keymap[i].nm)*FONT_WIDTH*sc) / 2;
266  draw_string_scaled(x1+xo, y1+yo, keymap[i].nm, cl, sc, sc);
267  }
268  }
269  }
270 
271  redraw_buttons = 0;
272 }

Variablen-Dokumentation

long kbd_mod_state[4] = { 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF }

Definiert in Zeile 21 der Datei kbd.c.

long kbd_new_state[4] = { 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF }

Definiert in Zeile 19 der Datei kbd.c.

long kbd_prev_state[4] = { 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF }

Definiert in Zeile 20 der Datei kbd.c.

KeyMap keymap[]

Definiert in Zeile 83 der Datei kbd.c.

int redraw_buttons = 1

Definiert in Zeile 201 der Datei kbd.c.

long touch_panel_state
static

Definiert in Zeile 22 der Datei kbd.c.