Changeset a2afd8f in mainline for uspace/drv/hid/adb-kbd/ctl.c


Ignore:
Timestamp:
2017-11-13T18:07:46Z (6 years ago)
Author:
Jiri Svoboda <jiri@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
0dd4779
Parents:
56763a4
Message:

Move ADB keyboard and mouse support to separate drivers.

File:
1 moved

Legend:

Unmodified
Added
Removed
  • uspace/drv/hid/adb-kbd/ctl.c

    r56763a4 ra2afd8f  
    2727 */
    2828
    29 /** @addtogroup kbd_ctl
    30  * @ingroup input
    31  * @{
    32  */
    3329/**
    3430 * @file
    35  * @brief Apple ADB keyboard controller driver.
    36  */
    37 
     31 * @brief Apple ADB keyboard controller
     32 */
     33
     34#include <errno.h>
    3835#include <io/console.h>
    3936#include <io/keycode.h>
    40 #include "../kbd.h"
    41 #include "../kbd_ctl.h"
    42 #include "../kbd_port.h"
    43 
    44 static void apple_ctl_parse(sysarg_t);
    45 static int apple_ctl_init(kbd_dev_t *);
    46 static void apple_ctl_set_ind(kbd_dev_t *, unsigned int);
    47 
    48 kbd_ctl_ops_t apple_ctl = {
    49         .parse = apple_ctl_parse,
    50         .init = apple_ctl_init,
    51         .set_ind = apple_ctl_set_ind
    52 };
     37
     38#include "ctl.h"
    5339
    5440#define KBD_KEY_RELEASE  0x80
     
    185171};
    186172
    187 static kbd_dev_t *kbd_dev;
    188 
    189 static int apple_ctl_init(kbd_dev_t *kdev)
     173/** Translate ADB keyboard scancode into keyboard event.
     174 *
     175 * @param scancode Scancode
     176 * @param rtype Place to store type of keyboard event (press or release)
     177 * @param rkey Place to store key code
     178 *
     179 * @return EOK on success, ENOENT if no translation exists
     180 */
     181int adb_kbd_key_translate(sysarg_t scancode, kbd_event_type_t *rtype,
     182    unsigned int *rkey)
    190183{
    191         kbd_dev = kdev;
    192         return 0;
    193 }
    194 
    195 static void apple_ctl_parse(sysarg_t scancode)
    196 {
    197         kbd_event_type_t type;
    198        
     184        kbd_event_type_t etype;
     185        unsigned int key;
     186
    199187        if (scancode & KBD_KEY_RELEASE) {
    200188                scancode &= ~KBD_KEY_RELEASE;
    201                 type = KEY_RELEASE;
    202         } else
    203                 type = KEY_PRESS;
    204        
     189                etype = KEY_RELEASE;
     190        } else {
     191                etype = KEY_PRESS;
     192        }
     193
    205194        if (scancode >= sizeof(scanmap) / sizeof(unsigned int))
    206                 return;
    207        
    208         unsigned int key = scanmap[scancode];
    209         if (key != 0)
    210                 kbd_push_event(kbd_dev, type, key);
     195                return ENOENT;
     196
     197        key = scanmap[scancode];
     198        if (key == 0)
     199                return ENOENT;
     200
     201        *rtype = etype;
     202        *rkey = key;
     203        return EOK;
    211204}
    212205
    213 static void apple_ctl_set_ind(kbd_dev_t *kdev, unsigned mods)
    214 {
    215         (void) mods;
    216 }
    217 
    218206/** @}
    219207 */
Note: See TracChangeset for help on using the changeset viewer.