[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [tyndur-devel] [PATCH 2/3] vterm: Tastaturbelegung aenderbar machen



On Sat, Sep 05 13:21, Kevin Wolf wrote:
> + vterm: Ueber die Datei vterm:/keymap kann die Tastaturbelegung
>   veraendert werden
> 
> Signed-off-by: Kevin Wolf <kevin@xxxxxxxxxx>
> ---
>  src/modules/vterm/include/keymap.h |   18 +++++++++++++
>  src/modules/vterm/keymap.c         |   50 ++++++++++++++++++++++++++++++++++++
>  src/modules/vterm/lostio.c         |   10 +++++++
>  src/modules/vterm/vterm.c          |    4 +++
>  src/modules/vterm/vterm.h          |    1 +
>  5 files changed, 83 insertions(+), 0 deletions(-)
> 
> diff --git a/src/modules/vterm/include/keymap.h b/src/modules/vterm/include/keymap.h
> index 668067e..dcbc0ba 100644
> --- a/src/modules/vterm/include/keymap.h
> +++ b/src/modules/vterm/include/keymap.h
> @@ -37,6 +37,7 @@
>  #define _KEYMAP_H_
>  #include <stdint.h>
>  #include <stddef.h>
> +#include <lostio.h>
>  
>  /**
>   * Eintrag in der Keymap
> @@ -55,5 +56,22 @@ typedef struct keymap_entry {
>   */
>  keymap_entry_t* keymap_get(uint8_t keycode);
>  
> +/**
> + * Legt die vterm:/keymap im Verzeichnisbaum an
> + */
> +void keymap_init(void);
> +
> +/**
> + * LostIO-Handller um die Tastaturbelegung zu lesen
> + */
> +size_t keymap_read(lostio_filehandle_t* file, void* buf,
> +    size_t blocksize, size_t blockcount);
> +
> +/**
> + * LostIO-Handler um die Tastaturbelegung zu aendern
> + */
> +size_t keymap_write(lostio_filehandle_t* file, size_t blocksize,
> +    size_t blockcount, void* data);
> +
>  #endif // ifndef _KEYMAP_H_
>  
> diff --git a/src/modules/vterm/keymap.c b/src/modules/vterm/keymap.c
> index 4b5846f..c1881bd 100644
> --- a/src/modules/vterm/keymap.c
> +++ b/src/modules/vterm/keymap.c
> @@ -33,6 +33,10 @@
>   * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
>   */
>  
> +#include <io.h>
> +#include <string.h>
> +
> +#include "vterm.h"
>  #include "keymap.h"
>  
>  keymap_entry_t keymap[] = {
> @@ -176,3 +180,49 @@ keymap_entry_t* keymap_get(uint8_t keycode)
>      return &keymap[keycode];
>  }
>  
> +/**
> + * Legt die vterm:/keymap im Verzeichnisbaum an
> + */
> +void keymap_init(void)
> +{
> +    stdout = NULL;

Hm, das musst du mir aber erklären. ;-)

> +    vfstree_create_node("/keymap", LOSTIO_TYPES_KEYMAP, 0, NULL, 0);
> +}
> +
> +/**
> + * LostIO-Handller um die Tastaturbelegung zu lesen
> + */
> +size_t keymap_read(lostio_filehandle_t* file, void* buf,
> +    size_t blocksize, size_t blockcount)
> +{
> +    size_t size = blocksize * blockcount;
> +
> +    if (file->pos + size >= sizeof(keymap)) {
> +        size = sizeof(keymap) - file->pos;
> +        file->flags |= LOSTIO_FLAG_EOF;
> +    }
> +
> +    memcpy(buf, ((uint8_t*) keymap) + file->pos, size);
> +    file->pos += size;
> +
> +    return size;
> +}
> +
> +/**
> + * LostIO-Handler um die Tastaturbelegung zu aendern
> + */
> +size_t keymap_write(lostio_filehandle_t* file, size_t blocksize,
> +    size_t blockcount, void* buf)
> +{
> +    size_t size = blocksize * blockcount;
> +
> +    if (file->pos + size >= sizeof(keymap)) {
> +        size = sizeof(keymap) - file->pos;
> +        file->flags |= LOSTIO_FLAG_EOF;
> +    }
> +
> +    memcpy(((uint8_t*) keymap) + file->pos, buf, size);
> +    file->pos += size;
> +
> +    return size;
> +}
> diff --git a/src/modules/vterm/lostio.c b/src/modules/vterm/lostio.c
> index a835d6a..1470fa7 100644
> --- a/src/modules/vterm/lostio.c
> +++ b/src/modules/vterm/lostio.c
> @@ -35,8 +35,11 @@
>  #include <stdlib.h>
>  #include <syscall.h>
>  #include <string.h>
> +
>  #include "vterm.h"
>  #include "lostio.h"
> +#include "keymap.h"
> +
>  /// Handler fuer Lesen aus in
>  size_t terminal_read(lostio_filehandle_t* handle, void* buf,
>      size_t blocksize, size_t blockcount);
> @@ -83,6 +86,13 @@ void init_lostio_interface()
>      typehandle->link        = NULL;
>      typehandle->unlink      = NULL;
>      lostio_register_typehandle(typehandle);
> +
> +    // Typehandle fuer Keymaps
> +    typehandle = calloc(1, sizeof(typehandle_t));
> +    typehandle->id          = LOSTIO_TYPES_KEYMAP;
> +    typehandle->read        = &keymap_read;
> +    typehandle->write       = &keymap_write;
> +    lostio_register_typehandle(typehandle);
>  }
>  
>  /**
> diff --git a/src/modules/vterm/vterm.c b/src/modules/vterm/vterm.c
> index d3fcd7f..d27fbc6 100644
> --- a/src/modules/vterm/vterm.c
> +++ b/src/modules/vterm/vterm.c
> @@ -41,6 +41,7 @@
>  #include "vterm.h"
>  #include "sleep.h"
>  #include "init.h"
> +#include "keymap.h"
>  
>  
>  /// Hier kommen die Eingaben fuer all die virtuellen Terminals her
> @@ -67,6 +68,9 @@ int main(int argc, char* argv[])
>          return -1;
>      }
>  
> +    // Tastaturbelegung konfigurierbar machen
> +    keymap_init();
> +
>      // Auf Anfragen warten
>      while(TRUE) {
>          wait_for_rpc();
> diff --git a/src/modules/vterm/vterm.h b/src/modules/vterm/vterm.h
> index d5149da..0871db9 100644
> --- a/src/modules/vterm/vterm.h
> +++ b/src/modules/vterm/vterm.h
> @@ -39,6 +39,7 @@
>  
>  #define LOSTIO_TYPES_OUT 255
>  #define LOSTIO_TYPES_IN 254
> +#define LOSTIO_TYPES_KEYMAP 253
>  
>  #define SCREEN_WIDTH_MAX 80
>  #define SCREEN_HEIGHT_MAX 25

Sonst sieht das glaub ich vernünftig aus. ;-)

Acked-by: Antoine Kaufmann <toni@xxxxxxxxxx>

-- 
Antoine Kaufmann
<toni@xxxxxxxxxxxxxxxx>

Attachment: pgpHRJPMAdkSP.pgp
Description: PGP signature