Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 12 additions & 4 deletions arch/sim/src/sim/sim_keyboard.c
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,7 @@ static uint32_t translate_x11_key(uint32_t code)
return KEYCODE_F24;

default:
return code;
return KEYCODE_NORMAL;
}
}

Expand Down Expand Up @@ -246,10 +246,16 @@ int sim_kbd_initialize(void)
void sim_kbdevent(uint32_t key, bool is_press)
{
uint32_t trans_key;
bool is_special;
struct sim_dev_s *priv = (struct sim_dev_s *) &g_simkeyboard;
uint32_t types[2] =
static const uint32_t types[2][2] =
{
KEYBOARD_RELEASE, KEYBOARD_PRESS
{
KEYBOARD_RELEASE, KEYBOARD_PRESS
},
{
KBD_SPECREL, KBD_SPECPRESS
}
};

if (priv->eventloop == 0)
Expand All @@ -258,9 +264,11 @@ void sim_kbdevent(uint32_t key, bool is_press)
}

trans_key = translate_x11_key(key);
is_special = trans_key != KEYCODE_NORMAL;
trans_key = is_special ? trans_key : key;
iinfo("key=%04x\n", key);

/* Report data changes */

keyboard_event(&priv->lower, trans_key, types[is_press]);
keyboard_event(&priv->lower, trans_key, types[is_special][is_press]);
}
1 change: 1 addition & 0 deletions drivers/input/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,7 @@ if(CONFIG_INPUT)

if(CONFIG_INPUT_KEYBOARD)
list(APPEND SRCS keyboard_upper.c)
list(APPEND SRCS virtio_key_decode.c)
endif()

if(CONFIG_INPUT_KMATRIX)
Expand Down
1 change: 1 addition & 0 deletions drivers/input/Make.defs
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,7 @@ endif

ifeq ($(CONFIG_INPUT_KEYBOARD),y)
CSRCS += keyboard_upper.c
CSRCS += virtio_key_decode.c
endif

ifeq ($(CONFIG_INPUT_DJOYSTICK),y)
Expand Down
17 changes: 15 additions & 2 deletions drivers/input/goldfish_events.c
Original file line number Diff line number Diff line change
Expand Up @@ -108,11 +108,24 @@ static bool
goldfish_events_send_keyboard_event(FAR struct goldfish_events_s *events,
FAR struct goldfish_input_event *evt)
{
uint32_t trans_key;
bool is_special;
static const uint32_t types[2][2] =
{
{
KEYBOARD_RELEASE, KEYBOARD_PRESS
},
{
KBD_SPECREL, KBD_SPECPRESS
}
};

if (evt->type == EV_KEY)
{
trans_key = keyboard_translate_virtio_code(evt->code, &is_special);
keyboard_event(&(events->keyboardlower),
keyboard_translate_virtio_code(evt->code),
!evt->value);
trans_key,
types[is_special][evt->value & 1]);
return true;
}

Expand Down
92 changes: 0 additions & 92 deletions drivers/input/keyboard_upper.c
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@

#include <nuttx/input/keyboard.h>
#include <nuttx/input/kbd_codec.h>
#include <nuttx/input/virtio-input-event-codes.h>
#include <nuttx/kmalloc.h>
#include <nuttx/list.h>
#include <nuttx/circbuf.h>
Expand Down Expand Up @@ -423,94 +422,3 @@ void keyboard_event(FAR struct keyboard_lowerhalf_s *lower, uint32_t keycode,

nxmutex_unlock(&upper->lock);
}

/****************************************************************************
* keyboard_translate_virtio_code
****************************************************************************/

uint32_t keyboard_translate_virtio_code(uint16_t keycode)
{
switch (keycode)
{
case KEY_DELETE:
return KEYCODE_FWDDEL;
case KEY_BACKSPACE:
return KEYCODE_BACKDEL;
case KEY_HOME:
return KEYCODE_HOME;
case KEY_END:
return KEYCODE_END;
case KEY_LEFT:
return KEYCODE_LEFT;
case KEY_RIGHT:
return KEYCODE_RIGHT;
case KEY_UP:
return KEYCODE_UP;
case KEY_DOWN:
return KEYCODE_DOWN;
case KEY_PAGEUP:
return KEYCODE_PAGEUP;
case KEY_PAGEDOWN:
return KEYCODE_PAGEDOWN;
case KEY_ENTER:
return KEYCODE_ENTER;
case KEY_CAPSLOCK:
return KEYCODE_CAPSLOCK;
case KEY_SCROLLLOCK:
return KEYCODE_SCROLLLOCK;
case KEY_NUMLOCK:
return KEYCODE_NUMLOCK;
case KEY_SYSRQ:
return KEYCODE_PRTSCRN;
case KEY_F1:
return KEYCODE_F1;
case KEY_F2:
return KEYCODE_F2;
case KEY_F3:
return KEYCODE_F3;
case KEY_F4:
return KEYCODE_F4;
case KEY_F5:
return KEYCODE_F5;
case KEY_F6:
return KEYCODE_F6;
case KEY_F7:
return KEYCODE_F7;
case KEY_F8:
return KEYCODE_F8;
case KEY_F9:
return KEYCODE_F9;
case KEY_F10:
return KEYCODE_F10;
case KEY_F11:
return KEYCODE_F11;
case KEY_F12:
return KEYCODE_F12;
case KEY_F13:
return KEYCODE_F13;
case KEY_F14:
return KEYCODE_F14;
case KEY_F15:
return KEYCODE_F15;
case KEY_F16:
return KEYCODE_F16;
case KEY_F17:
return KEYCODE_F17;
case KEY_F18:
return KEYCODE_F18;
case KEY_F19:
return KEYCODE_F19;
case KEY_F20:
return KEYCODE_F20;
case KEY_F21:
return KEYCODE_F21;
case KEY_F22:
return KEYCODE_F22;
case KEY_F23:
return KEYCODE_F23;
case KEY_F24:
return KEYCODE_F24;
default:
return keycode;
}
}
Loading
Loading