@@ -43,11 +43,9 @@ void FXKeyboard::pleaseDraw(void) {
4343// Event calls
4444void FXKeyboard::penDown (u8 px, u8 py)
4545{
46- s16 tx, rx;
47- tx = ntxm_clamp ((px - x)/24 , 0 , 8 - 1 );
48- rx = (px - x) % 24 ;
49- bool r = rx > 11 ;
50- u8 bt_ind = (tx * 2 ) + (r ? 1 : 0 );
46+ if (px > FXBUTTON_WIDTH * NUM_FXKEYS) return ;
47+
48+ u8 bt_ind = ntxm_clamp (px / FXBUTTON_WIDTH, 0 , NUM_FXKEYS-1 );
5149
5250 if (fxkb_state[bt_ind] != FXBUTTON_DISABLED)
5351 fxkb_state[bt_ind] |= 0x1 ; // set pushed
@@ -120,6 +118,7 @@ void FXKeyboard::setCategory(u8 newcat) {
120118
121119 category = newcat;
122120
121+ useDarkTitle (false );
123122 memset (fxkb_state, FXBUTTON_NORMAL, NUM_FXKEYS);
124123 setCaption (category_captions[category]);
125124
@@ -150,9 +149,9 @@ u8 FXKeyboard::getCategory(void)
150149 return category;
151150}
152151
153- void FXKeyboard::setLastCmd (u8 _last_e_cmd )
152+ void FXKeyboard::setLastCmd (u8 _last_cmd )
154153{
155- last_cmd = _last_e_cmd ;
154+ last_cmd = _last_cmd ;
156155}
157156
158157u8 FXKeyboard::getLastCmd (void )
@@ -177,12 +176,12 @@ void FXKeyboard::drawCaption(void) {
177176
178177 drawFullBox (1 , 3 , width, 5 , bgcolor);
179178 u16 capcol = darken_title ? theme->col_fxkeyboard_cmd_desc_disabled : theme->col_fxkeyboard_cmd_desc ;
180- drawSmallString (caption, ((NUM_FXKEYS * FXBUTTON_WIDTH) / 2 ) - (2 * strlen (caption)), 3 , capcol); // width=(3px char+1px space) / 2
179+ drawSmallString (caption, ((NUM_FXKEYS * FXBUTTON_WIDTH) / 2 ) - (2 * strlen (caption)) + 4 , 3 , capcol); // width=(3px char+1px space) / 2
181180}
182181
183182void FXKeyboard::drawButtonLabel (u8 key, u8 cat, bool visible)
184183{
185- u8 xpos = key * 12 + 3 ;
184+ u8 xpos = key * FXBUTTON_WIDTH + 3 ;
186185 u16 col = theme->col_fxkeyboard_btn_label ;
187186 u16 smallcol1 = theme->col_fxkeyboard_minilabel_x ;
188187 u16 smallcol2 = theme->col_fxkeyboard_minilabel_y ;
@@ -200,7 +199,7 @@ void FXKeyboard::drawButtonLabel(u8 key, u8 cat, bool visible)
200199 char small_caption[3 ] = {0 }; // one wasted byte...noone will notice
201200
202201 if (cat == FX_CATEGORY_E)
203- snprintf (small_caption, 3 , " E%1X " , fxkb_vals[key]);
202+ snprintf (small_caption, 3 , " %1XX " , fxkb_vals[key]);
204203 else if (cat == FX_CATEGORY_NORMAL)
205204 sprintf (small_caption, " X%s" , ((labels_cat0 >> key) & 0x1 ) ? " Y" : " X" );
206205 else
@@ -226,7 +225,6 @@ void FXKeyboard::eraseButtonLabels(void)
226225void FXKeyboard::draw (void ) {
227226 if (!isExposed ()) return ;
228227
229- int row;
230228 u16 lstate, rstate;
231229
232230 /*
@@ -244,25 +242,28 @@ void FXKeyboard::draw(void) {
244242 basically this depends on the order of the tiles in
245243 effectinput.png, so dont rearrange them (˘︶˘)
246244 */
245+
246+ int row,col;
247+
247248 for (int pair=0 ;pair<NUM_FXKEYS/2 ;++pair)
248249 {
249250 lstate=fxkb_state[pair*2 ];
250251 rstate=fxkb_state[pair*2 +1 ];
251252
252- u16 buttontiles[15 ]={
253+ const u16 buttontiles[15 ]={
253254 TILE_BLANK, TILE_LCORNER+lstate, TILE_LEDGE+lstate, TILE_LEDGE+lstate, VFLIP (TILE_LCORNER+lstate),
254255 TILE_BLANK, TILE_MID_EDGE+(3 *rstate)+lstate, TILE_MID+(3 *rstate)+lstate, TILE_MID+(3 *rstate)+lstate, VFLIP (TILE_MID_EDGE+(3 *rstate)+lstate),
255256 TILE_BLANK, TILE_EVEN_END_EDGE+rstate, TILE_EVEN_END_MID+rstate, TILE_EVEN_END_MID+rstate, VFLIP (TILE_EVEN_END_EDGE+rstate), // btm edge=y flipped top edge
256257 };
257258
258- int abs_col =pair*3 ;
259+ int tile_pos_x =pair*3 ;
259260
260- for (int j =0 ;j <3 ;++j )
261+ for (col =0 ;col <3 ;++col )
261262 {
262- for (row=0 ;row<5 ;++row)
263+ for (row=0 ;row<FXKEYBOARD_HEIGHT_TILES ;++row)
263264 {
264- u8 pos = (row * 28 ) + abs_col + j ;
265- fxkb_map[pos]=buttontiles[row + (j* 5 )];
265+ u8 pos = (row * FXKEYBOARD_WIDTH_TILES ) + tile_pos_x + col ;
266+ fxkb_map[pos]=buttontiles[row + (col*FXKEYBOARD_HEIGHT_TILES )];
266267 }
267268 }
268269 }
@@ -271,24 +272,24 @@ void FXKeyboard::draw(void) {
271272 if (NUM_FXKEYS % 2 == 1 )
272273 {
273274 rstate=fxkb_state[NUM_FXKEYS-1 ];
274-
275- u16 oddend[10 ]={
275+
276+ const u16 oddend[10 ]={
276277 TILE_BLANK, TILE_LCORNER+rstate, TILE_LEDGE+rstate, TILE_LEDGE+rstate, VFLIP (TILE_LCORNER+rstate),
277278 TILE_BLANK, TILE_ODD_END_EDGE+rstate, TILE_ODD_END_MID+rstate, TILE_ODD_END_MID+rstate, VFLIP (TILE_ODD_END_EDGE+rstate)
278279 };
279280
280- for (int j =0 ;j <2 ;++j )
281+ for (col =0 ;col <2 ;++col )
281282 {
282- for (row=0 ;row<5 ;++row)
283+ for (row=0 ;row<FXKEYBOARD_HEIGHT_TILES ;++row)
283284 {
284- u8 pos = (row * 28 ) + ((NUM_FXKEYS/2 )*3 ) + j ;
285- fxkb_map[pos]=oddend[row + (j* 5 )];
285+ u8 pos = (row * FXKEYBOARD_WIDTH_TILES ) + ((NUM_FXKEYS/2 )*3 ) + col ;
286+ fxkb_map[pos]=oddend[row + (col*FXKEYBOARD_HEIGHT_TILES )];
286287 }
287288 }
288289 }
289290
290- for (int py=0 ; py<5 ; ++py)
291- memcpy (map_base + (32 *(py+y/8 )+(x/8 )), fxkb_map + (28 * py), 28 * 2 );
291+ for (int py=0 ; py<FXKEYBOARD_HEIGHT_TILES ; ++py)
292+ memcpy (map_base + (32 *(py+y/8 )+(x/8 )), fxkb_map + (FXKEYBOARD_WIDTH_TILES * py), FXKEYBOARD_WIDTH_TILES * 2 );
292293
293294 drawButtonLabels ();
294295 drawCaption ();
0 commit comments