diff --git a/CMakeLists.txt b/CMakeLists.txt new file mode 100644 index 0000000..8365e6d --- /dev/null +++ b/CMakeLists.txt @@ -0,0 +1,41 @@ +# Configure with [fxsdk build-fx] or [fxsdk build-cg], which provide the +# toolchain file and module path of the fxSDK + +cmake_minimum_required(VERSION 3.15) +project(MyAddin) + +include(GenerateG1A) +include(GenerateG3A) +include(Fxconv) +find_package(Gint 2.9 REQUIRED) + +set(SOURCES + src/main.c + # ... +) +# Shared assets, fx-9860G-only assets and fx-CG-50-only assets +set(ASSETS + # ... +) +set(ASSETS_fx + assets-fx/example.png + # ... +) +set(ASSETS_cg + assets-cg/example.png + # ... +) + +fxconv_declare_assets(${ASSETS} ${ASSETS_fx} ${ASSETS_cg} WITH_METADATA) + +add_executable(myaddin ${SOURCES} ${ASSETS} ${ASSETS_${FXSDK_PLATFORM}}) +target_compile_options(myaddin PRIVATE -Wall -Wextra -Os) +target_link_libraries(myaddin Gint::Gint) + +if("${FXSDK_PLATFORM_LONG}" STREQUAL fx9860G) + generate_g1a(TARGET myaddin OUTPUT "Keydemo.g1a" + NAME "Keydemo" ICON assets-fx/icon.png) +elseif("${FXSDK_PLATFORM_LONG}" STREQUAL fxCG50) + generate_g3a(TARGET myaddin OUTPUT "Keydemo.g3a" + NAME "Keydemo" ICONS assets-cg/icon-uns.png assets-cg/icon-sel.png) +endif() diff --git a/assets-cg/example.png b/assets-cg/example.png new file mode 100644 index 0000000..8826800 Binary files /dev/null and b/assets-cg/example.png differ diff --git a/assets-cg/fxconv-metadata.txt b/assets-cg/fxconv-metadata.txt new file mode 100644 index 0000000..d435d5f --- /dev/null +++ b/assets-cg/fxconv-metadata.txt @@ -0,0 +1,3 @@ +example.png: + type: bopti-image + name: img_example diff --git a/assets-cg/icon-sel.png b/assets-cg/icon-sel.png new file mode 100644 index 0000000..7137b50 Binary files /dev/null and b/assets-cg/icon-sel.png differ diff --git a/assets-cg/icon-uns.png b/assets-cg/icon-uns.png new file mode 100644 index 0000000..3c99f62 Binary files /dev/null and b/assets-cg/icon-uns.png differ diff --git a/assets-fx/example.png b/assets-fx/example.png new file mode 100644 index 0000000..b26ba9a Binary files /dev/null and b/assets-fx/example.png differ diff --git a/assets-fx/fxconv-metadata.txt b/assets-fx/fxconv-metadata.txt new file mode 100644 index 0000000..d435d5f --- /dev/null +++ b/assets-fx/fxconv-metadata.txt @@ -0,0 +1,3 @@ +example.png: + type: bopti-image + name: img_example diff --git a/assets-fx/icon.png b/assets-fx/icon.png new file mode 100644 index 0000000..c92f12a Binary files /dev/null and b/assets-fx/icon.png differ diff --git a/src/main.c b/src/main.c new file mode 100644 index 0000000..3e56686 --- /dev/null +++ b/src/main.c @@ -0,0 +1,301 @@ +/* + * SuperInput demo - A new way to type text on casio fx calculators ! + * Copyright (C) 2022 Mibi88 + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see https://www.gnu.org/licenses/. + */ + +#include +#include + +#define INSZ 20 +#define INSZS1 (INSZ-1) + +unsigned char input[INSZ], keyc; +int pos, lenght, shift, alpha, inchar, key; + +void shiftstrpartright(int start){ + unsigned char c; + unsigned char copy[INSZ]; + for(int i=0;i 0){ + pos--; + }else if(key == KEY_RIGHT && pos < lenght){ + pos++; + } + if(key == KEY_SHIFT){ + shift = !shift; + }else if(key == KEY_ALPHA){ + alpha = !alpha; + }else if(key == KEY_DEL && pos > 0){ + shiftstrpartleft(pos-1); + lenght--; + pos--; + } + dclear(C_WHITE); + dtext(1, 1, C_BLACK, (char*)input); + dline(pos*6, 1, pos*6, 7, C_BLACK); + dupdate(); + clearevents(); + } + return 1; +}