Commit 7aeb0054 authored by Arnaud Blanchard's avatar Arnaud Blanchard
Browse files

While starting, do not modify existing channel

parent 35a4c544
......@@ -16,7 +16,7 @@ project(i_keyboard)
find_package(blc_channel REQUIRED)
find_package(blc_program REQUIRED)
add_definitions(${BL_DEFINITIONS} -Wno-multichar)
add_definitions(${BL_DEFINITIONS} -std=c++14 -W -Wall)
include_directories(${BL_INCLUDE_DIRS})
add_executable(i_keyboard src/i_keyboard.cpp)
target_link_libraries(i_keyboard ${BL_LIBRARIES})
......
......@@ -218,8 +218,8 @@ static void loop_float(){
}
}
int main(int argc, char** argv){
bool created;
char *default_output=NULL;
char const *extension;
char const *channel_name, *type_str, *str_quitting_key, *str_neutral_key, *max_str, *min_str, *str_neutral_value, *toggle_mode, *step_size_str, *filename, *file_select_name;
......@@ -276,7 +276,7 @@ int main(int argc, char** argv){
if (type_str==NULL) type=channel_info.type;
else if (STRING_TO_UINT32(type_str)!=channel_info.type) EXIT_ON_CHANNEL_ERROR(&channel_info, "The requested type '%s' differ from the exisiting channel", type_str);
if (keys_nb==-1) keys_nb=channel_info.total_length;
else if (keys_nb!=channel_info.total_length) EXIT_ON_CHANNEL_ERROR(&channel_info, "number of keys(%d) differ from channel length (%d)", keys_nb, channel.total_length);
else if (keys_nb!=(int)channel_info.total_length) EXIT_ON_CHANNEL_ERROR(&channel_info, "number of keys(%d) differ from channel length (%d)", keys_nb, channel.total_length);
}
else {
if (type_str) type=STRING_TO_UINT32(type_str);
......@@ -301,20 +301,17 @@ int main(int argc, char** argv){
}
}
if (memchr(key_list, quitting_key, keys_nb)) EXIT_ON_ERROR("The quitting key '%c' is in your key list %.*s, you need to select an other one with --quitting_key=...", quitting_key, keys_nb, key_list);
if (memchr(key_list, neutral_key, keys_nb)) EXIT_ON_ERROR("The neutral key '%c' is in your key list %.*s, you need to select an other one with --neutral_key=...", neutral_key, keys_nb, key_list);
channel.create_or_open(channel_name, BLC_CHANNEL_WRITE, type, 'NDEF', 1, keys_nb);
created=channel.create_or_open(channel_name, BLC_CHANNEL_WRITE, type, 'NDEF', 1, keys_nb);
if (filename){
extension = blc_get_filename_extension(filename);
if(strcmp(extension, "blc")==0) channel.update_with_blc_file(filename);
else if (strcmp(extension, "tsv")==0) channel.update_with_tsv_file(filename);
else EXIT_ON_ERROR("'%s' is not a possible file type extension", extension);
}
else {
}else if (created){
switch (type){
case 'UIN8':
FOR(i, keys_nb) channel.uchars[i]=BLC_NORMED_FLOAT_TO_UCHAR(neutral_value);
......@@ -348,7 +345,7 @@ int main(int argc, char** argv){
}
table.allocate(max-min+1);
FOR(i, table.size){
FOR(i, (int)table.size){
pos=strchr(key_list, i+min);
if (pos) table.uchars[i]=pos-key_list;
else table.uchars[i]=keys_nb;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment