Changeset 67fecc3 in buchla-emu for emu/kbd.c


Ignore:
Timestamp:
09/09/2017 11:11:32 PM (7 years ago)
Author:
Thomas Lopatic <thomas@…>
Branches:
master
Children:
0d83ce8
Parents:
e26a632 (diff), 18cbd53 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent.
git-author:
Thomas Lopatic <thomas@…> (09/09/2017 11:11:27 PM)
git-committer:
Thomas Lopatic <thomas@…> (09/09/2017 11:11:32 PM)
Message:

Merge LCD emulation.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • emu/kbd.c

    re26a632 r67fecc3  
    104104}
    105105
     106static void slid(int32_t sig, bool on, int32_t val)
     107{
     108        out((uint8_t)(0x80 | sig));
     109        out(on ? 0x01 : 0x00);
     110        out((uint8_t)val);
     111}
     112
    106113#if defined NOT_YET
    107 static void pot_128(int32_t sig, int32_t val)
     114static void pot(int32_t sig, int32_t val)
    108115{
    109116        out((uint8_t)(0x80 | sig));
    110117        out((uint8_t)val);
    111118}
    112 
    113 static void pot_256(int32_t sig, int32_t val)
    114 {
    115         out((uint8_t)(0x80 | sig));
    116         out((uint8_t)((val >> 7) & 0x01));
    117         out((uint8_t)(val & 0x7f));
    118 }
    119119#endif
    120120
    121 void kbd_key(SDL_KeyboardEvent *ev, bool dn)
     121static void vid_key(SDL_KeyboardEvent *ev, bool dn)
    122122{
    123123        if ((ev->keysym.mod & KMOD_SHIFT) != 0 &&
     
    173173}
    174174
     175static void lcd_key(SDL_KeyboardEvent *ev, bool dn)
     176{
     177        if ((ev->keysym.mod & KMOD_CTRL) != 0 &&
     178                        ev->keysym.sym >= SDLK_a && ev->keysym.sym <= SDLK_n) {
     179                int32_t i = ev->keysym.sym - SDLK_a;
     180                ver2("kbd lcd %d %s", i, dn ? "dn" : "up");
     181
     182                if (dn) {
     183                        but_on(39 + i);
     184                }
     185                else {
     186                        but_off(39 + i);
     187                }
     188
     189                return;
     190        }
     191
     192        if (ev->keysym.sym >= SDLK_a && ev->keysym.sym <= SDLK_n) {
     193                static int32_t lev[14] = {
     194                        64, 0, 0, 0, 0, 64, 64, 64, 64, 0, 0, 0, 64, 0
     195                };
     196
     197                int32_t i = ev->keysym.sym - SDLK_a;
     198                int32_t val = lev[i];
     199
     200                if (!dn) {
     201                        if ((ev->keysym.mod & KMOD_SHIFT) != 0) {
     202                                val = val > 10 ? val - 10 : 0;
     203                        }
     204                        else {
     205                                val = val < 117 ? val + 10 : 127;
     206                        }
     207                }
     208
     209                ver2("kbd sli %d %s %d", i, dn ? "dn" : "up", val);
     210                slid(25 + i, dn, val);
     211
     212                lev[i] = val;
     213                return;
     214        }
     215}
     216
     217void kbd_key(SDL_KeyboardEvent *ev, bool vid, bool dn)
     218{
     219        if (vid) {
     220                vid_key(ev, dn);
     221        }
     222        else {
     223                lcd_key(ev, dn);
     224        }
     225}
     226
    175227void kbd_init(void)
    176228{
Note: See TracChangeset for help on using the changeset viewer.