CHDK - virtual keyboard - testers needed! - page 5 - General Discussion and Assistance - CHDK Forum
supplierdeeply

CHDK - virtual keyboard - testers needed!

  • 150 Replies
  • 31453 Views
Re: CHDK - typing / virtual keyboard / editor-style typing
« Reply #40 on: 04 / January / 2012, 13:10:01 »
Advertisements
- two modes (unfortunately)
- MOVE mode is obvious (arrows and zooms moves cursor, SET leaves MOVE and goes to WRITE)
- in WRITE mode we could have:
* arrows for typing
* FUNC to use another letter from the same arrow / go to MOVE (as in EDI)
* MENU to cancel
* zooms for space/backspace
* shoot_full / DISP for OK
* shoot_half changes chars
In my experience too easy make shoot_full instead of shoot_half. No nuclear rocket starts, but probably I need reenter something from start again and again something just because I need different character set in the string.

I like how it works right now: DISP (MENU) switch between three modes. If make obvious which one is active, then no problem with it. Switching between modes is relatively rare event and this surely prevent any unexpected finalization. Just like MBOX - we can't say ok/cancel with "hotkey". Only select and "Enter".

Quote
Special characters should contain a space (for cameras without zoom).

And I have no idea how to implement backspace...
shoot_half in MOVE mode. not very comfortable, but relatively obvious.
Anyway most of cameras are unaffected. Just few of them (6 + probably 2 with touch screen) have no zoom. For camera with touch volunteer owner could write own cool touch keyboard. :)

Re: CHDK - typing / virtual keyboard / editor-style typing
« Reply #41 on: 04 / January / 2012, 13:18:14 »
Ok, you're right. But at the moment I don't know how to use these buttons below the text... How can I select them? I mean "OK" and "CANCEL"
if (2*b || !2*b) {
    cout<<question
}

Compile error: poor Yorick

Re: CHDK - typing / virtual keyboard / editor-style typing
« Reply #42 on: 04 / January / 2012, 13:30:14 »
I have now read all your post and think there should be two modes (as tvstar says). One for typing and one for the buttons.

My idea is to use the keys so:
arrows + ok = typing
MENU = change mode (typing / buttons)
zoom (or jogdial)  = text navigation
disp = space
shoot_half = change chars

For backspace erase or video button if present. But I don't know if there are cameras that haven't one of them and whether there are other buttons.
« Last Edit: 04 / January / 2012, 13:31:50 by TobiMarg »

Re: CHDK - typing / virtual keyboard / editor-style typing
« Reply #43 on: 04 / January / 2012, 14:28:51 »
I'm sure that tsvstar said about three modes;) It was also said, that only few cameras have ERASE button unfortunately...

After reading all these proposals I have some idea.

Ok, give me one or two days and I prepare a little bit rewritten code and we will discuss concrete solution;)
if (2*b || !2*b) {
    cout<<question
}

Compile error: poor Yorick


Re: CHDK - typing / virtual keyboard / editor-style typing
« Reply #44 on: 04 / January / 2012, 14:41:37 »
Oh yes tvstar writes about three modes.  :)
Then we can use zoom as in my first Idea:
  • To delete a character zoom out.
  • To insert a space zoom in.
and move in text/move mode with the arrow keys.


Quote
Ok, give me one or two days and I prepare a little bit rewritten code and we will discuss concrete solution;)
If yours is a better idea please write it and we'll wait.
« Last Edit: 04 / January / 2012, 14:45:43 by TobiMarg »

Re: CHDK - typing / virtual keyboard / editor-style typing
« Reply #45 on: 04 / January / 2012, 14:52:05 »
Quote
If yours is a better idea please write it and we'll wait.
I just like to change some things in your code and merge all these things together... :)
if (2*b || !2*b) {
    cout<<question
}

Compile error: poor Yorick

Re: CHDK - typing / virtual keyboard / editor-style typing
« Reply #46 on: 04 / January / 2012, 15:02:21 »
Ok, I'll wait. (or make a few improvements on my own  :))
But do you know how to fix that:
2. Current version is wrongly fill up on init string. Often strange symbols are exists.
If yes, please fix it and say what the problem was.

Re: CHDK - typing / virtual keyboard / editor-style typing
« Reply #47 on: 04 / January / 2012, 16:10:06 »
I have no idea, what's the problem. But I can't see, wheter c array is somewhere filled with zeros? Maybe this array is not zeroed at start and just contain random bits from memory?

About my changes - I like to for example replace tbox_chars with three-dimensional array, just like it is done in EDI. This way we don't need to place separators into this variable and use it in simpler way.

Code: [Select]
{
  {"a", "b", "c","d", "e"},{"f", "g", "h","i", "j"},{"k", "l", "m"...}...,
  {"A", "B", "C","D", "E"},{"F", "G", "H","I", "J"},{"K", "L", "M"...}...,
  {"1", "2", "3"},{"4", "5", "6"},{"7", "8", "9"...}...
}

One of my ideas is also to change a little bit draw statement. I hope I'll not get lost;)
if (2*b || !2*b) {
    cout<<question
}

Compile error: poor Yorick


Re: CHDK - typing / virtual keyboard / editor-style typing
« Reply #48 on: 04 / January / 2012, 19:25:51 »
Ok, I have a little bit changed the pattern. It was to little time to work on typing stuff, but I hope TobiMarg code could be introduced here with only minor changes. Some things with new letters array have to be changed. Of course, if you like this idea ;)

Other change is to add conditional drawing of the keyboard/buttons/something below the text field. Buttons are useless outside the 'B' as well as keyboard is useless in 'M' and 'B'. So only one of these things should be visible at the time.

I made this pattern and I would try to do something more, but it is 1:25 am o'clock here and I very like to go sleep...

Code: [Select]
#include "stdlib.h"
#include "keyboard.h"
#include "platform.h"
#include "core.h"
#include "conf.h"
#include "lang.h"
#include "gui.h"
#include "gui_draw.h"
#include "gui_lang.h"
#include "gui_tbox.h"

#include "module_load.h"
void gui_tbox_menu_kbd_process();

gui_handler GUI_MODE_TBOX =
    /*GUI_MODE_TBOX*/       { GUI_MODE_MODULE,   gui_tbox_draw,    gui_tbox_kbd_process,   gui_tbox_menu_kbd_process, 0, GUI_MODE_MAGICNUM };


static int need_redraw;
static int vkbd_txtfield_width=200;
static int vkbd_txtfield_height=75;




// static const char*  tbox_title;
// static const char*  tbox_msg;
// static char         tbox_to_draw;
// static char         text_to_draw;
// static char         key_to_draw;
// static char         cursor_to_draw;
// static int cl_greygrey;
// #define MAX_LINES       6
// #define MAX_WIDTH       35
// #define SPACING_TITLE   4
// #define SPACING_BTN     4
// #define BUTTON_SEP      18
// #define BUTTON_SIZE     6

#define TBOX_WIDTH 30 /*how many letters?*/
#define TBOX_BORDER 20 /*border in pixels*/
#define TBOX_TITLE_HEIGHT FONT_HEIGHT+4

static void     (*tbox_on_select)(unsigned int btn, char* newstr);
static coord    tbox_buttons_x, tbox_buttons_y;

const char *tbox_chars[][4] = {
    {"abcdef","ghijkl","mnopqrst","uvwxyz"},
    {"ABCDEF","GHIJKL","MNOPQRST","UVWXYZ"},
    {"123","456","788","0/*+-="},
    {" !@#$%","@#$%^","@@##","$"}
};


static const char*  tbox_title;
static const char*  tbox_msg;

char Mode; // T - Typing, M - Move, B - Buttons
char *text;
int current_letter; //number of current letter - e.g. "a" is 1, "W" is 3, "j" is 4.
char current_key; //which typing key was the last? values: U, D, L, R, N (N=none)

int basic_module_init() {

// // cl_greygrey = MAKE_COLOR(COLOR_GREY, COLOR_GREY);
    gui_set_mode( &GUI_MODE_TBOX );
    //TO BE CHANGED, NOT_HARDCODED!!!
//     gui_tbox_init(137, 137, 20, (NULL, "test"));
    gui_tbox_init(137, 137, 20, gui_tbox_menu_kbd_process );

return 1;
}

void gui_tbox_init(int title, int msg, unsigned int maxsize, void (*on_select)(unsigned int btn, char* newstr)) {
   
    Mode='T';
    current_letter=1;
    current_key='N';
    tbox_title = lang_str(title);
    tbox_msg = lang_str(msg);

}


void gui_tbox_draw(int enforce_redraw) {
   
    //TODO : do not redraw each time!

    //Window - the same in all modes

    int tbox_width=FONT_WIDTH*TBOX_WIDTH+TBOX_BORDER;
    int tbox_x1=(camera_screen.width-tbox_width)>>1;
    int tbox_x2=tbox_x1+tbox_width;
    int tbox_y1=30;
    int tbox_y2=120;
    int title_text_width=strlen(tbox_title)*FONT_WIDTH;
    int msg_height = 50; //TODO: should be calculated, not hardcoded
   
    draw_rect_shadow(tbox_x1, tbox_y1, tbox_x2, tbox_y2, COLOR_BLACK, 3); //shadow
    draw_filled_rect_thick(tbox_x1, tbox_y1, tbox_x2, tbox_y2, MAKE_COLOR(COLOR_GREY, COLOR_WHITE), 3); //whole box
   
    draw_filled_rect_thick(tbox_x1, tbox_y1, tbox_x2, tbox_y1+TBOX_TITLE_HEIGHT, MAKE_COLOR(COLOR_BLACK, COLOR_WHITE), 3); //title box
    draw_string(tbox_x1+((tbox_width-title_text_width)>>1), tbox_y1+3, tbox_title, MAKE_COLOR(COLOR_BLACK, COLOR_WHITE)); //title text

    //TODO: message draw
   
    //TODO: string  draw
   
   
    //********************************************
    //Below the string appropriate thing should be draw. It should depend on the Mode:
    //********************************************
   
    if (Mode == 'T') {}
//draw_keyboard
    if (Mode == 'M') {}
//draw "MOVE" message or something
    if (Mode == 'B') {}
//draw buttons

}



void gui_tbox_kbd_process() {
   
   
   
    if (Mode == 'T') {
        switch (kbd_get_autoclicked_key()) {
            case KEY_SHOOT_HALF: {}
                break;
            case KEY_UP: {}
                break;
            case KEY_DOWN: {}
                break;
            case KEY_LEFT: {}
                break;
            case KEY_RIGHT: {}
                break;
            case KEY_SET: {}
                break;
            case KEY_ZOOM_IN: {}
                break;
            case KEY_ZOOM_OUT: {}
                break;
            case KEY_DISPLAY: {}
                break;
        }
    }
    else if (Mode == 'M') {
        switch (kbd_get_autoclicked_key()) {
            case KEY_SHOOT_HALF: {}
                break;
            case KEY_UP: {}
                break;
            case KEY_DOWN: {}
                break;
            case KEY_LEFT: {}
                break;
            case KEY_RIGHT: {}
                break;
            case KEY_SET: {}
                break;
            case KEY_ZOOM_IN: {}
                break;
            case KEY_ZOOM_OUT: {}
                break;
            case KEY_DISPLAY: {}
                break;
        }
    }
    else if (Mode == 'B') {
        switch (kbd_get_autoclicked_key()) {
            case KEY_SHOOT_HALF: {}
                break;
            case KEY_UP: {}
                break;
            case KEY_DOWN: {}
                break;
            case KEY_LEFT: {}
                break;
            case KEY_RIGHT: {}
                break;
            case KEY_SET: {}
                break;
            case KEY_ZOOM_IN: {}
                break;
            case KEY_ZOOM_OUT: {}
                break;
            case KEY_DISPLAY: {}
                break;
        }
    }
}


extern int module_idx;

void gui_tbox_menu_kbd_process() {
gui_default_kbd_process_menu_btn();
  module_async_unload(module_idx);
}


/******************** Module Information structure ******************/

struct ModuleInfo _module_info = { MODULEINFO_V1_MAGICNUM,
sizeof(struct ModuleInfo),

ANY_CHDK_BRANCH, 0, // Requirements of CHDK version
ANY_PLATFORM_ALLOWED, // Specify platform dependency
0, // flag
(int32_t)"Virtual keyboard", // Module name
0, 2, // Module version
0
};


I also just tried to make code more understandable. I think, that the size of the tbox (I mean whole window) can be fixed, it might a little bit simplify the code.

Tobi - I would like to ask you to write your magic stuff that writes the msg in the window, since I don't understand this code correctly ;) I'll try to provide general idea of usage of buttons with the new array.

PS. Many thanks to all of you!
if (2*b || !2*b) {
    cout<<question
}

Compile error: poor Yorick

Re: CHDK - typing / virtual keyboard / editor-style typing
« Reply #49 on: 05 / January / 2012, 01:16:04 »
outslider,
Previous version is better. In new version keymap is hardcoded and couldn't be replaced.
In EDI no problem what is internal organization of keymap, because it is script and easily could be edited at any moment.

What is benefit of previous version and why TobiMarg (?) make this in this way. Because it was my request.
It easy to load such version from regular text file, which could be choosed or edited.
I could prefer different special symbols, I could add more sets to file (for example national characterset).

It will be module interface task to prepare this thing, because I plan to include into this keymap also module name (to give possibility to user change not only keymap but even input method).

Now keyboard lost big piece of its flexbility.

 

Related Topics