我需要知道如何使用KeySym
,xcb
或xtest
将xlib
注入X服务器。我可以注入密钥代码,也可以获得键盘映射,在那里搜索keysym并按下相应的密钥代码,但是当它没有映射到当前布局时,我无法注入KeySym(例如XKB_KEY_Arabic_0
)。
我有办法做到吗?
我想到的是找到一个空键码并将其重新映射到所需的键盘。问题:我的代码没有找到空键。这是我的代码:
uint32_t find_empty_key_for_remapping()
{
int keycode_low;
int keycode_high;
KeySym * keysyms = 0;
int empty_key = 0;
int num_keysym;
XDisplayKeycodes(display_, &keycode_low, &keycode_high);
keysyms = XGetKeyboardMapping(display_, keycode_low, keycode_high - keycode_low, &num_keysym);
for (int i = keycode_low; i <= keycode_high && !empty_key; ++i)
{
bool key_is_empty = true;
for (int j = 0; j < num_keysym; ++j)
{
int symindex = ((i - keycode_low) * num_keysym) + j;
if (keysyms[symindex] != 0)
{
key_is_empty = false;
}
}
if (key_is_empty)
{
return i;
}
}
return 0;
}
任何帮助将不胜感激!
答案 0 :(得分:-1)
使用 model = Sequential([Conv2D(filters=8, kernel_size=(3, 3),
activation='relu', input_shape=(32, 32,3),
name='conv_1'),
BatchNormalization(),
Conv2D(filters=8, kernel_size=(3, 3),
activation='relu', padding= 'SAME',
name='conv_2'),
BatchNormalization(),
MaxPooling2D(pool_size=(8, 8), name='pool_1'),
Flatten(),
Dense(64, kernel_regularizer =
regularizers.l2(0.5), bias_initializer='ones',
activation='relu' , name='dense_1'),
Dropout(0.3),
Dense(64,kernel_regularizer =
regularizers.l2(0.5) , activation='relu',
name='dense_2'),
Dense(64, kernel_regularizer =
regularizers.l2(0.5) , activation='relu',
name='dense_3'),
Dense(10, activation='softmax',
name='dense_4')
])
model.compile(
optimizer = 'adam',
loss = 'sparse_categorical_crossentropy',
metrics= ['accuracy' ])
history = model.fit(train_images,train_labels , epochs = 30)
来注入keyyms。要插入xdotool
,请使用
XKB_KEY_Arabic_0
独立于键盘映射。