Keyboard control refactoring.
This commit is contained in:
@@ -55,7 +55,6 @@
|
||||
<ClCompile Include="mist_cfg.c" />
|
||||
<ClCompile Include="osd.c" />
|
||||
<ClCompile Include="spi.c" />
|
||||
<ClCompile Include="state.c" />
|
||||
<ClCompile Include="tos.c" />
|
||||
<ClCompile Include="user_io.c" />
|
||||
</ItemGroup>
|
||||
@@ -85,7 +84,6 @@
|
||||
<ClInclude Include="mist_cfg.h" />
|
||||
<ClInclude Include="osd.h" />
|
||||
<ClInclude Include="spi.h" />
|
||||
<ClInclude Include="state.h" />
|
||||
<ClInclude Include="tos.h" />
|
||||
<ClInclude Include="user_io.h" />
|
||||
</ItemGroup>
|
||||
|
||||
@@ -56,9 +56,6 @@
|
||||
<ClCompile Include="spi.c">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="state.c">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="tos.c">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
@@ -142,9 +139,6 @@
|
||||
<ClInclude Include="spi.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="state.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="tos.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
|
||||
@@ -689,7 +689,7 @@ int ScanDirectory(char* path, int mode, char *extension, int options)
|
||||
}
|
||||
else
|
||||
{
|
||||
printf("dir scan for key: %x/%c\n", mode, mode);
|
||||
//printf("dir scan for key: %x/%c\n", mode, mode);
|
||||
mode = toupper(mode);
|
||||
if ((mode >= '0' && mode <= '9') || (mode >= 'A' && mode <= 'Z'))
|
||||
{
|
||||
|
||||
158
input.c
158
input.c
@@ -12,6 +12,9 @@
|
||||
#include "user_io.h"
|
||||
#include "menu.h"
|
||||
#include "hardware.h"
|
||||
#include "mist_cfg.h"
|
||||
#include "fpga_io.h"
|
||||
#include "osd.h"
|
||||
|
||||
#define NUMDEV 10
|
||||
|
||||
@@ -516,6 +519,111 @@ uint16_t get_map_pid()
|
||||
return input[mapping_dev].pid;
|
||||
}
|
||||
|
||||
static char kr_fn_table[] =
|
||||
{
|
||||
0x54, 0x48, // pause/break
|
||||
0x55, 0x46, // prnscr
|
||||
0x50, 0x4a, // home
|
||||
0x4f, 0x4d, // end
|
||||
0x52, 0x4b, // pgup
|
||||
0x51, 0x4e, // pgdown
|
||||
0x3a, 0x44, // f11
|
||||
0x3b, 0x45, // f12
|
||||
|
||||
0x3c, 0x6c, // EMU_MOUSE
|
||||
0x3d, 0x6d, // EMU_JOY0
|
||||
0x3e, 0x6e, // EMU_JOY1
|
||||
0x3f, 0x6f, // EMU_NONE
|
||||
|
||||
//Emulate keypad for A600
|
||||
0x1E, 0x59, //KP1
|
||||
0x1F, 0x5A, //KP2
|
||||
0x20, 0x5B, //KP3
|
||||
0x21, 0x5C, //KP4
|
||||
0x22, 0x5D, //KP5
|
||||
0x23, 0x5E, //KP6
|
||||
0x24, 0x5F, //KP7
|
||||
0x25, 0x60, //KP8
|
||||
0x26, 0x61, //KP9
|
||||
0x27, 0x62, //KP0
|
||||
0x2D, 0x56, //KP-
|
||||
0x2E, 0x57, //KP+
|
||||
0x31, 0x55, //KP*
|
||||
0x2F, 0x68, //KP(
|
||||
0x30, 0x69, //KP)
|
||||
0x37, 0x63, //KP.
|
||||
0x28, 0x58 //KP Enter
|
||||
};
|
||||
/*
|
||||
static void keyrah_trans(unsigned char *m, unsigned char *k)
|
||||
{
|
||||
static char keyrah_fn_state = 0;
|
||||
char fn = 0;
|
||||
char empty = 1;
|
||||
char rctrl = 0;
|
||||
int i = 0;
|
||||
while (i<6)
|
||||
{
|
||||
if ((k[i] == 0x64) || (k[i] == 0x32))
|
||||
{
|
||||
if (k[i] == 0x64) fn = 1;
|
||||
if (k[i] == 0x32) rctrl = 1;
|
||||
for (int n = i; n<5; n++) k[n] = k[n + 1];
|
||||
k[5] = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (k[i]) empty = 0;
|
||||
i++;
|
||||
}
|
||||
}
|
||||
|
||||
if (fn)
|
||||
{
|
||||
for (i = 0; i<6; i++)
|
||||
{
|
||||
for (int n = 0; n<(sizeof(kr_fn_table) / (2 * sizeof(kr_fn_table[0]))); n++)
|
||||
{
|
||||
if (k[i] == kr_fn_table[n * 2]) k[i] = kr_fn_table[(n * 2) + 1];
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// free these keys for core usage
|
||||
for (i = 0; i<6; i++)
|
||||
{
|
||||
if (k[i] == 0x53) k[i] = 0x68;
|
||||
if (k[i] == 0x47) k[i] = 0x69;
|
||||
if (k[i] == 0x49) k[i] = 0x6b; // workaround!
|
||||
}
|
||||
}
|
||||
|
||||
*m = rctrl ? (*m) | 0x10 : (*m) & ~0x10;
|
||||
if (fn)
|
||||
{
|
||||
keyrah_fn_state |= 1;
|
||||
if (*m || !empty) keyrah_fn_state |= 2;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (keyrah_fn_state == 1)
|
||||
{
|
||||
if (core_type == CORE_TYPE_MINIMIG2)
|
||||
{
|
||||
send_keycode(KEY_MENU);
|
||||
send_keycode(BREAK | KEY_MENU);
|
||||
}
|
||||
else
|
||||
{
|
||||
OsdKeySet(KEY_MENU);
|
||||
}
|
||||
}
|
||||
keyrah_fn_state = 0;
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
||||
#define KEY_EMU_LEFT (KEY_MAX+1)
|
||||
#define KEY_EMU_RIGHT (KEY_MAX+2)
|
||||
#define KEY_EMU_UP (KEY_MAX+3)
|
||||
@@ -985,40 +1093,26 @@ static void input_cb(struct input_event *ev, int dev)
|
||||
key = (key < (sizeof(ev2usb) / sizeof(ev2usb[0]))) ? ev2usb[key] : NONE;
|
||||
if(key != NONE)
|
||||
{
|
||||
static uint16_t mod = 0;
|
||||
|
||||
//Keyrah v2: USB\VID_18D8&PID_0002\A600/A1200_MULTIMEDIA_EXTENSION_VERSION
|
||||
int keyrah = (mist_cfg.keyrah_mode && (((((uint32_t)input[dev].vid) << 16) | input[dev].pid) == mist_cfg.keyrah_mode));
|
||||
|
||||
//if (keyrah) keyrah_trans(&m, k);
|
||||
|
||||
unsigned short reset_m = mod >> 8;
|
||||
if (key == 0x4c) reset_m |= 0x100;
|
||||
user_io_check_reset(reset_m, keyrah ? 1 : mist_cfg.reset_combo);
|
||||
|
||||
if (key & MODMASK)
|
||||
{
|
||||
modifiers = (ev->value) ? modifiers | (uint8_t)(key >> 8) : modifiers & ~(uint8_t)(key >> 8);
|
||||
if (ev->value) mod |= key;
|
||||
else mod &= ~key;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (ev->value)
|
||||
{
|
||||
int found = 0;
|
||||
for (int i = 0; i < (sizeof(keys) / sizeof(keys[0])); i++) if (keys[i] == (uint8_t)key) found = 1;
|
||||
key = (mod & MODMASK) | (key & ~MODMASK);
|
||||
|
||||
if (!found)
|
||||
{
|
||||
for (int i = 0; i < (sizeof(keys) / sizeof(keys[0])); i++)
|
||||
{
|
||||
if (!keys[i])
|
||||
{
|
||||
keys[i] = (uint8_t)key;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
for (int i = 0; i < (sizeof(keys) / sizeof(keys[0])); i++) if (keys[i] == (uint8_t)key) keys[i] = 0;
|
||||
}
|
||||
|
||||
int j = 0;
|
||||
for (int i = 0; i < (sizeof(keys) / sizeof(keys[0])); i++) if (keys[i]) keys[j++] = keys[i];
|
||||
while (j < (sizeof(keys) / sizeof(keys[0]))) keys[j++] = 0;
|
||||
}
|
||||
|
||||
user_io_kbd(modifiers, keys, input[dev].vid, input[dev].pid);
|
||||
menu_mod_set(mod >> 8);
|
||||
user_io_kbd((uint16_t)key, ev->value);
|
||||
return;
|
||||
}
|
||||
}
|
||||
@@ -1181,7 +1275,7 @@ int input_test(int getchar)
|
||||
{
|
||||
//keyboard, buttons
|
||||
case EV_KEY:
|
||||
printf("Input event: type=EV_KEY, code=%d(%x), value=%d\n", ev.code, ev.code, ev.value);
|
||||
if(ev.value<=1) printf("Input event: type=EV_KEY, code=%d(0x%x), value=%d\n", ev.code, ev.code, ev.value);
|
||||
break;
|
||||
|
||||
//mouse
|
||||
@@ -1210,7 +1304,7 @@ int input_test(int getchar)
|
||||
break;
|
||||
|
||||
default:
|
||||
printf("Input event: type=%d, code=%d(%x), value=%d(%x)\n", ev.type, ev.code, ev.code, ev.value, ev.value);
|
||||
printf("Input event: type=%d, code=%d(0x%x), value=%d(0x%x)\n", ev.type, ev.code, ev.code, ev.value, ev.value);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -3,6 +3,9 @@
|
||||
|
||||
#include "osd.h"
|
||||
|
||||
#ifndef KEYCODES_H
|
||||
#define KEYCODES_H
|
||||
|
||||
#define MISS 0xff
|
||||
#define KEYCODE_MAX (0x6f)
|
||||
|
||||
@@ -128,7 +131,7 @@ const unsigned short usb2ami[] = {
|
||||
0x0f, // 62: KP 0
|
||||
0x3c, // 63: KP .
|
||||
0x30, // 64: Europe 2
|
||||
KEY_MENU | OSD, // 65: App
|
||||
0x69 | OSD, // 65: App
|
||||
MISS, // 66: Power
|
||||
MISS, // 67: KP =
|
||||
0x5a, // 68: KP (
|
||||
@@ -502,3 +505,5 @@ const unsigned short usb2archie[] = {
|
||||
MISS, // 6e: F19
|
||||
MISS, // 6f: F20
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
201
menu.c
201
menu.c
@@ -32,7 +32,6 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
#include "string.h"
|
||||
#include "file_io.h"
|
||||
#include "osd.h"
|
||||
#include "state.h"
|
||||
#include "fdd.h"
|
||||
#include "hdd.h"
|
||||
#include "hardware.h"
|
||||
@@ -130,9 +129,7 @@ enum MENU
|
||||
MENU_8BIT_SYSTEM1,
|
||||
MENU_8BIT_SYSTEM2,
|
||||
MENU_8BIT_ABOUT1,
|
||||
MENU_8BIT_ABOUT2,
|
||||
MENU_8BIT_KEYTEST1,
|
||||
MENU_8BIT_KEYTEST2
|
||||
MENU_8BIT_ABOUT2
|
||||
};
|
||||
|
||||
unsigned char menustate = MENU_NONE1;
|
||||
@@ -405,6 +402,86 @@ char* get_keycode_table()
|
||||
return " PS/2";
|
||||
}
|
||||
|
||||
// conversion table of Amiga keyboard scan codes to ASCII codes
|
||||
const uint8_t keycode_table[128] =
|
||||
{
|
||||
0,'1','2','3','4','5','6','7','8','9','0', 0, 0, 0, 0, 0,
|
||||
'Q','W','E','R','T','Y','U','I','O','P', 0, 0, 0, 0, 0, 0,
|
||||
'A','S','D','F','G','H','J','K','L', 0, 0, 0, 0, 0, 0, 0,
|
||||
0,'Z','X','C','V','B','N','M', 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1,
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
|
||||
};
|
||||
|
||||
static uint8_t GetASCIIKey(unsigned char keycode)
|
||||
{
|
||||
if (keycode & KEY_AMI_UPSTROKE)
|
||||
return 0;
|
||||
|
||||
return keycode_table[keycode & 0x7F];
|
||||
}
|
||||
|
||||
/* the Atari core handles OSD keys competely inside the core */
|
||||
static unsigned char menu_key = 0;
|
||||
static unsigned char menu_mod = 0;
|
||||
|
||||
void menu_key_set(unsigned char c)
|
||||
{
|
||||
//iprintf("OSD enqueue: %x\n", c);
|
||||
menu_key = c;
|
||||
}
|
||||
|
||||
void menu_mod_set(uint8_t m)
|
||||
{
|
||||
menu_mod = m;
|
||||
}
|
||||
|
||||
// get key status
|
||||
static uint8_t menu_key_get(void)
|
||||
{
|
||||
static unsigned char c2;
|
||||
static unsigned long delay;
|
||||
static unsigned long repeat;
|
||||
static unsigned char repeat2;
|
||||
unsigned char c1, c;
|
||||
|
||||
c1 = menu_key;
|
||||
|
||||
// OsdKeyGet permanently returns the last key event.
|
||||
|
||||
// generate normal "key-pressed" event
|
||||
c = 0;
|
||||
if (c1 != c2) c = c1;
|
||||
c2 = c1;
|
||||
|
||||
// inject a fake "MENU_KEY" if no menu is visible and the menu key is loaded
|
||||
if (!user_io_osd_is_visible() && is_menu_core()) c = KEY_AMI_MENU;
|
||||
|
||||
// generate repeat "key-pressed" events
|
||||
if ((c1 & KEY_AMI_UPSTROKE) || (!c1))
|
||||
{
|
||||
repeat = GetTimer(REPEATDELAY);
|
||||
}
|
||||
else if (CheckTimer(repeat))
|
||||
{
|
||||
repeat = GetTimer(REPEATRATE);
|
||||
if (GetASCIIKey(c1)) c = c1;
|
||||
}
|
||||
|
||||
// currently no key pressed
|
||||
if (!c)
|
||||
{
|
||||
static unsigned char last_but = 0;
|
||||
unsigned char but = user_io_menu_button();
|
||||
if (!but && last_but) c = KEY_AMI_MENU;
|
||||
last_but = but;
|
||||
}
|
||||
|
||||
return(c);
|
||||
}
|
||||
|
||||
void HandleUI(void)
|
||||
{
|
||||
char *p;
|
||||
@@ -413,8 +490,6 @@ void HandleUI(void)
|
||||
uint8_t mod;
|
||||
unsigned long len;
|
||||
static hardfileTYPE t_hardfile[2]; // temporary copy of former hardfile configuration
|
||||
static unsigned char ctrl = false;
|
||||
static unsigned char lalt = false;
|
||||
char enable;
|
||||
static long helptext_timer;
|
||||
static const char *helptext;
|
||||
@@ -424,19 +499,10 @@ void HandleUI(void)
|
||||
uint8_t keys[6] = { 0,0,0,0,0,0 };
|
||||
uint16_t keys_ps2[6] = { 0,0,0,0,0,0 };
|
||||
|
||||
mist_joystick_t joy0, joy1;
|
||||
|
||||
/* check joystick status */
|
||||
char joy_string[32];
|
||||
char joy_string2[32];
|
||||
char usb_id[64];
|
||||
|
||||
// update turbo status for joysticks
|
||||
//StateTurboUpdate(0);
|
||||
//StateTurboUpdate(1);
|
||||
|
||||
// get user control codes
|
||||
c = OsdGetCtrl();
|
||||
c = menu_key_get();
|
||||
|
||||
// decode and set events
|
||||
menu = false;
|
||||
@@ -450,21 +516,9 @@ void HandleUI(void)
|
||||
|
||||
switch (c)
|
||||
{
|
||||
case KEY_CTRL:
|
||||
ctrl = true;
|
||||
break;
|
||||
case KEY_CTRL | KEY_UPSTROKE:
|
||||
ctrl = false;
|
||||
break;
|
||||
case KEY_LALT:
|
||||
lalt = true;
|
||||
break;
|
||||
case KEY_LALT | KEY_UPSTROKE:
|
||||
lalt = false;
|
||||
break;
|
||||
case KEY_MENU:
|
||||
case KEY_AMI_MENU:
|
||||
menu = true;
|
||||
OsdKeySet(KEY_MENU | KEY_UPSTROKE);
|
||||
menu_key_set(KEY_AMI_MENU | KEY_AMI_UPSTROKE);
|
||||
break;
|
||||
|
||||
// Within the menu the esc key acts as the menu key. problem:
|
||||
@@ -472,31 +526,31 @@ void HandleUI(void)
|
||||
// break code for the ESC key when the key is released will
|
||||
// reach the core which never saw the make code. Simple solution:
|
||||
// react on break code instead of make code
|
||||
case KEY_ESC | KEY_UPSTROKE:
|
||||
case KEY_AMI_ESC | KEY_AMI_UPSTROKE:
|
||||
if (menustate != MENU_NONE2)
|
||||
menu = true;
|
||||
break;
|
||||
case KEY_ENTER:
|
||||
case KEY_SPACE:
|
||||
case KEY_AMI_ENTER:
|
||||
case KEY_AMI_SPACE:
|
||||
select = true;
|
||||
break;
|
||||
case KEY_UP:
|
||||
case KEY_AMI_UP:
|
||||
up = true;
|
||||
break;
|
||||
case KEY_DOWN:
|
||||
case KEY_AMI_DOWN:
|
||||
down = true;
|
||||
break;
|
||||
case KEY_LEFT:
|
||||
case KEY_AMI_LEFT:
|
||||
left = true;
|
||||
break;
|
||||
case KEY_RIGHT:
|
||||
case KEY_AMI_RIGHT:
|
||||
right = true;
|
||||
break;
|
||||
case KEY_KPPLUS:
|
||||
case KEY_AMI_KPPLUS:
|
||||
case 0x0c: // =/+
|
||||
plus = true;
|
||||
break;
|
||||
case KEY_KPMINUS:
|
||||
case KEY_AMI_KPMINUS:
|
||||
case 0x0b: // -/_
|
||||
minus = true;
|
||||
break;
|
||||
@@ -579,7 +633,7 @@ void HandleUI(void)
|
||||
case MENU_NONE2:
|
||||
if (menu)
|
||||
{
|
||||
if (StateKeyboardModifiers() & 0x44) //Alt+Menu
|
||||
if (menu_mod & 0x44) //Alt+Menu
|
||||
{
|
||||
OsdSetSize(16);
|
||||
SelectFile("RBF", 0, MENU_FIRMWARE_CORE_FILE_SELECTED, MENU_NONE1, 0);
|
||||
@@ -955,7 +1009,7 @@ void HandleUI(void)
|
||||
helptext = helptexts[HELPTEXT_MAIN];
|
||||
m = 0;
|
||||
if (user_io_core_type() == CORE_TYPE_MINIMIG2) m = 1;
|
||||
menumask = m ? 0x7f : 0xff;
|
||||
menumask = m ? 0x7b : 0xfb;
|
||||
OsdSetTitle("System", OSD_ARROW_LEFT);
|
||||
menustate = MENU_8BIT_SYSTEM2;
|
||||
parentstate = MENU_8BIT_SYSTEM1;
|
||||
@@ -963,7 +1017,7 @@ void HandleUI(void)
|
||||
OsdWrite(OsdIsBig ? 1 : 0, " Firmware & Core \x16", menusub == 0, 0);
|
||||
if(OsdIsBig) OsdWrite(2, "", 0, 0);
|
||||
OsdWrite(OsdIsBig ? 3 : 1, " Define joystick buttons", menusub == 1, 0);
|
||||
OsdWrite(OsdIsBig ? 4 : 2, " Keyboard Test", menusub == 2, 0);
|
||||
OsdWrite(OsdIsBig ? 4 : 2, "", 0, 0);
|
||||
if (OsdIsBig) OsdWrite(5, "", 0, 0);
|
||||
OsdWrite(OsdIsBig ? 6 : 3, m ? " Reset" : " Reset settings", menusub == 3, 0);
|
||||
if (m)
|
||||
@@ -1008,9 +1062,6 @@ void HandleUI(void)
|
||||
menusub = 0;
|
||||
break;
|
||||
case 2:
|
||||
// Keyboard test
|
||||
menustate = MENU_8BIT_KEYTEST1;
|
||||
menusub = 0;
|
||||
break;
|
||||
case 3:
|
||||
menustate = MENU_RESET1;
|
||||
@@ -1175,42 +1226,6 @@ void HandleUI(void)
|
||||
break;
|
||||
|
||||
|
||||
case MENU_8BIT_KEYTEST1:
|
||||
helptext = helptexts[HELPTEXT_NONE];
|
||||
menumask = 1;
|
||||
OsdSetTitle("Keyboard", 0);
|
||||
menustate = MENU_8BIT_KEYTEST2;
|
||||
parentstate = MENU_8BIT_KEYTEST1;
|
||||
for (int i = 0; i < OsdGetSize() - 1; i++) OsdWrite(i, "", 0, 0);
|
||||
OsdWrite(OsdGetSize() - 1, STD_COMBO_EXIT, menusub == 0, 0);
|
||||
break;
|
||||
|
||||
case MENU_8BIT_KEYTEST2:
|
||||
m = OsdIsBig ? 4 : 0;
|
||||
StateKeyboardPressed(keys);
|
||||
OsdWrite(m++, " USB scancodes", 0, 0);
|
||||
siprintf(s, " %2x %2x %2x %2x", keys[0], keys[1], keys[2], keys[3]); // keys[4], keys[5]);
|
||||
OsdWrite(m++, s, 0, 0);
|
||||
mod = StateKeyboardModifiers();
|
||||
strcpy(usb_id, " ");
|
||||
siprintbinary(usb_id, sizeof(mod), &mod);
|
||||
siprintf(s, " mod keys - %s ", usb_id);
|
||||
OsdWrite(m++, s, 0, 0);
|
||||
m++;
|
||||
uint16_t keys_ps2[6] = { 0,0,0,0,0,0 };
|
||||
StateKeyboardPressedPS2(keys_ps2);
|
||||
add_modifiers(mod, keys_ps2);
|
||||
siprintf(s, " %s scancodes", get_keycode_table());
|
||||
OsdWrite(m++, s, 0, 0);
|
||||
siprintf(s, " %4x %4x %4x %4x ", keys_ps2[0], keys_ps2[1], keys_ps2[2], keys_ps2[3]);// keys_ps2[4], keys_ps2[5]);
|
||||
OsdWrite(m++, s, 0, 0);
|
||||
if ((mod & 0x11) && menu) // Ctrl+ESC
|
||||
{
|
||||
menustate = MENU_8BIT_SYSTEM1;
|
||||
menusub = 2;
|
||||
}
|
||||
break;
|
||||
|
||||
/******************************************************************/
|
||||
/* mist main menu */
|
||||
/******************************************************************/
|
||||
@@ -1817,7 +1832,7 @@ void HandleUI(void)
|
||||
else if (menusub == 11)
|
||||
menustate = MENU_NONE1;
|
||||
}
|
||||
else if (c == KEY_BACK) // eject all floppies
|
||||
else if (c == KEY_AMI_BACK) // eject all floppies
|
||||
{
|
||||
for (i = 0; i <= drives; i++)
|
||||
df[i].status = 0;
|
||||
@@ -1913,25 +1928,25 @@ void HandleUI(void)
|
||||
|
||||
ScrollLongName(); // scrolls file name if longer than display line
|
||||
|
||||
if (c == KEY_HOME)
|
||||
if (c == KEY_AMI_HOME)
|
||||
{
|
||||
ScanDirectory(SelectedPath, SCAN_INIT, fs_pFileExt, fs_Options);
|
||||
menustate = MENU_FILE_SELECT1;
|
||||
}
|
||||
|
||||
if (c == KEY_BACK)
|
||||
if (c == KEY_AMI_BACK)
|
||||
{
|
||||
changeDir("..");
|
||||
menustate = MENU_FILE_SELECT1;
|
||||
}
|
||||
|
||||
if ((c == KEY_PGUP) || (c == KEY_LEFT))
|
||||
if ((c == KEY_AMI_PGUP) || (c == KEY_AMI_LEFT))
|
||||
{
|
||||
ScanDirectory(SelectedPath, SCAN_PREV_PAGE, fs_pFileExt, fs_Options);
|
||||
menustate = MENU_FILE_SELECT1;
|
||||
}
|
||||
|
||||
if ((c == KEY_PGDN) || (c == KEY_RIGHT))
|
||||
if ((c == KEY_AMI_PGDN) || (c == KEY_AMI_RIGHT))
|
||||
{
|
||||
ScanDirectory(SelectedPath, SCAN_NEXT_PAGE, fs_pFileExt, fs_Options);
|
||||
menustate = MENU_FILE_SELECT1;
|
||||
@@ -1949,7 +1964,7 @@ void HandleUI(void)
|
||||
menustate = MENU_FILE_SELECT1;
|
||||
}
|
||||
|
||||
if ((i = GetASCIIKey(c)))
|
||||
if ((i = GetASCIIKey(c))>1)
|
||||
{
|
||||
// find an entry beginning with given character
|
||||
ScanDirectory(SelectedPath, i, fs_pFileExt, fs_Options);
|
||||
@@ -2011,11 +2026,13 @@ void HandleUI(void)
|
||||
|
||||
if (select && menusub == 0)
|
||||
{
|
||||
if (m) {
|
||||
if (m)
|
||||
{
|
||||
menustate = MENU_NONE1;
|
||||
OsdReset(RESET_NORMAL);
|
||||
OsdReset();
|
||||
}
|
||||
else {
|
||||
else
|
||||
{
|
||||
char *filename = user_io_create_config_name();
|
||||
unsigned long status = user_io_8bit_set_status(0, 0xffffffff);
|
||||
iprintf("Saving config to %s\n", filename);
|
||||
@@ -2569,9 +2586,7 @@ void HandleUI(void)
|
||||
|
||||
if (menustate == MENU_HARDFILE_CHANGED2)
|
||||
{
|
||||
ConfigIDE(config.enable_ide, config.hardfile[0].present && config.hardfile[0].enabled, config.hardfile[1].present && config.hardfile[1].enabled);
|
||||
OsdReset(RESET_NORMAL);
|
||||
|
||||
OsdReset();
|
||||
menustate = MENU_NONE1;
|
||||
}
|
||||
}
|
||||
|
||||
20
menu.h
20
menu.h
@@ -3,6 +3,23 @@
|
||||
|
||||
#include "fdd.h" // for adfTYPE definition
|
||||
|
||||
#define KEY_AMI_UPSTROKE 0x80
|
||||
#define KEY_AMI_MENU 0x69
|
||||
#define KEY_AMI_PGUP 0x6C
|
||||
#define KEY_AMI_PGDN 0x6D
|
||||
#define KEY_AMI_HOME 0x6A
|
||||
#define KEY_AMI_ESC 0x45
|
||||
#define KEY_AMI_KPENTER 0x43
|
||||
#define KEY_AMI_ENTER 0x44
|
||||
#define KEY_AMI_BACK 0x41
|
||||
#define KEY_AMI_SPACE 0x40
|
||||
#define KEY_AMI_UP 0x4C
|
||||
#define KEY_AMI_DOWN 0x4D
|
||||
#define KEY_AMI_LEFT 0x4F
|
||||
#define KEY_AMI_RIGHT 0x4E
|
||||
#define KEY_AMI_KPPLUS 0x5E
|
||||
#define KEY_AMI_KPMINUS 0x4A
|
||||
|
||||
// UI strings, used by boot messages
|
||||
extern const char *config_filter_msg[];
|
||||
extern const char *config_memory_chip_msg[];
|
||||
@@ -22,5 +39,8 @@ void InfoMessage(char *message);
|
||||
void ShowSplash();
|
||||
void HideSplash();
|
||||
void EjectAllFloppies();
|
||||
|
||||
void menu_key_set(unsigned char c);
|
||||
void menu_mod_set(uint8_t m);
|
||||
|
||||
#endif
|
||||
|
||||
106
osd.c
106
osd.c
@@ -45,20 +45,7 @@ as rotated copies of the first 128 entries. -- AMR
|
||||
#include "logo.h"
|
||||
#include "user_io.h"
|
||||
#include "hardware.h"
|
||||
|
||||
|
||||
// conversion table of Amiga keyboard scan codes to ASCII codes
|
||||
const char keycode_table[128] =
|
||||
{
|
||||
0,'1','2','3','4','5','6','7','8','9','0', 0, 0, 0, 0, 0,
|
||||
'Q','W','E','R','T','Y','U','I','O','P', 0, 0, 0, 0, 0, 0,
|
||||
'A','S','D','F','G','H','J','K','L', 0, 0, 0, 0, 0, 0, 0,
|
||||
0,'Z','X','C','V','B','N','M', 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
|
||||
};
|
||||
#include "config.h"
|
||||
|
||||
static int osd_size = 8;
|
||||
|
||||
@@ -509,9 +496,12 @@ void OsdDisable(void)
|
||||
spi_osd_cmd8(OSD_CMD_OSD, 0x00);
|
||||
}
|
||||
|
||||
void OsdReset(unsigned char boot)
|
||||
void OsdReset()
|
||||
{
|
||||
spi_osd_cmd8(OSD_CMD_RST, 0x01);
|
||||
|
||||
ConfigIDE(config.enable_ide, config.hardfile[0].present && config.hardfile[0].enabled, config.hardfile[1].present && config.hardfile[1].enabled);
|
||||
|
||||
spi_osd_cmd8(OSD_CMD_RST, 0x00);
|
||||
}
|
||||
|
||||
@@ -561,79 +551,6 @@ void ConfigAutofire(unsigned char autofire, unsigned char mask)
|
||||
spi_osd_cmd16(OSD_CMD_JOY, param);
|
||||
}
|
||||
|
||||
static unsigned char disable_menu = 0;
|
||||
|
||||
// get key status
|
||||
unsigned char OsdGetCtrl(void)
|
||||
{
|
||||
static unsigned char c2;
|
||||
static unsigned long delay;
|
||||
static unsigned long repeat;
|
||||
static unsigned char repeat2;
|
||||
unsigned char c1, c;
|
||||
|
||||
c1 = OsdKeyGet();
|
||||
|
||||
// OsdKeyGet permanently returns the last key event.
|
||||
|
||||
// generate normal "key-pressed" event
|
||||
c = 0;
|
||||
if (c1 != c2)
|
||||
c = c1;
|
||||
|
||||
c2 = c1;
|
||||
// inject a fake "MENU_KEY" if no menu is visible and the menu key is loaded
|
||||
if (!user_io_osd_is_visible() && is_menu_core())
|
||||
c = KEY_MENU;
|
||||
|
||||
// generate repeat "key-pressed" events
|
||||
if ((c1 & KEY_UPSTROKE) || (!c1))
|
||||
repeat = GetTimer(REPEATDELAY);
|
||||
else if (CheckTimer(repeat)) {
|
||||
repeat = GetTimer(REPEATRATE);
|
||||
if (c1 == KEY_UP || c1 == KEY_DOWN)
|
||||
c = c1;
|
||||
repeat2++;
|
||||
if (repeat2 == 2)
|
||||
{
|
||||
repeat2 = 0;
|
||||
if (c1 == KEY_PGUP || c1 == KEY_PGDN || c1 == KEY_LEFT || c1 == KEY_RIGHT || GetASCIIKey(c1))
|
||||
c = c1;
|
||||
}
|
||||
}
|
||||
|
||||
// currently no key pressed
|
||||
if (!c)
|
||||
{
|
||||
static unsigned char last_but = 0;
|
||||
if (!disable_menu)
|
||||
{
|
||||
unsigned char but = user_io_menu_button();
|
||||
if (!but && last_but) c = KEY_MENU;
|
||||
last_but = but;
|
||||
}
|
||||
else
|
||||
{
|
||||
last_but = 0;
|
||||
}
|
||||
}
|
||||
|
||||
return(c);
|
||||
}
|
||||
|
||||
void OsdDisableMenuButton(unsigned char disable)
|
||||
{
|
||||
disable_menu = disable;
|
||||
}
|
||||
|
||||
unsigned char GetASCIIKey(unsigned char keycode)
|
||||
{
|
||||
if (keycode & KEY_UPSTROKE)
|
||||
return 0;
|
||||
|
||||
return keycode_table[keycode & 0x7F];
|
||||
}
|
||||
|
||||
void ScrollText(char n, const char *str, int off, int len, int max_len, unsigned char invert)
|
||||
{
|
||||
// this function is called periodically when a string longer than the window is displayed.
|
||||
@@ -679,19 +596,6 @@ void ScrollReset()
|
||||
scroll_offset = 0; // start scrolling from the start
|
||||
}
|
||||
|
||||
/* the Atari core handles OSD keys competely inside the core */
|
||||
static unsigned char osd_key;
|
||||
|
||||
void OsdKeySet(unsigned char c) {
|
||||
// iprintf("OSD enqueue: %x\n", c);
|
||||
osd_key = c;
|
||||
}
|
||||
|
||||
unsigned char OsdKeyGet() {
|
||||
return osd_key;
|
||||
}
|
||||
|
||||
|
||||
/* core currently loaded */
|
||||
static char lastcorename[261 + 10] = "CORE";
|
||||
void OsdCoreNameSet(const char* str) {
|
||||
|
||||
43
osd.h
43
osd.h
@@ -50,36 +50,6 @@
|
||||
#define REPEATRATE 50 // repeat rate in 1ms units
|
||||
#define BUTTONDELAY 20 // repeat rate in 1ms units
|
||||
|
||||
#define KEY_UPSTROKE 0x80
|
||||
#define KEY_MENU 0x69
|
||||
#define KEY_PGUP 0x6C
|
||||
#define KEY_PGDN 0x6D
|
||||
#define KEY_HOME 0x6A
|
||||
#define KEY_ESC 0x45
|
||||
#define KEY_KPENTER 0x43
|
||||
#define KEY_ENTER 0x44
|
||||
#define KEY_BACK 0x41
|
||||
#define KEY_SPACE 0x40
|
||||
#define KEY_UP 0x4C
|
||||
#define KEY_DOWN 0x4D
|
||||
#define KEY_LEFT 0x4F
|
||||
#define KEY_RIGHT 0x4E
|
||||
#define KEY_F1 0x50
|
||||
#define KEY_F2 0x51
|
||||
#define KEY_F3 0x52
|
||||
#define KEY_F4 0x53
|
||||
#define KEY_F5 0x54
|
||||
#define KEY_F6 0x55
|
||||
#define KEY_F7 0x56
|
||||
#define KEY_F8 0x57
|
||||
#define KEY_F9 0x58
|
||||
#define KEY_F10 0x59
|
||||
#define KEY_CTRL 0x63
|
||||
#define KEY_LALT 0x64
|
||||
#define KEY_KPPLUS 0x5E
|
||||
#define KEY_KPMINUS 0x4A
|
||||
#define KEY_KP0 0x0F
|
||||
|
||||
#define CONFIG_TURBO 1
|
||||
#define CONFIG_NTSC 2
|
||||
#define CONFIG_A1000 4
|
||||
@@ -89,14 +59,9 @@
|
||||
#define CONFIG_FLOPPY1X 0
|
||||
#define CONFIG_FLOPPY2X 1
|
||||
|
||||
#define RESET_NORMAL 0
|
||||
#define RESET_BOOTLOADER 1
|
||||
|
||||
#define OSD_ARROW_LEFT 1
|
||||
#define OSD_ARROW_RIGHT 2
|
||||
|
||||
#define OSD_TURBO_STEP 50
|
||||
|
||||
#include <inttypes.h>
|
||||
|
||||
/*functions*/
|
||||
@@ -107,7 +72,7 @@ void OsdClear(void);
|
||||
void OsdEnable(unsigned char mode);
|
||||
void OsdDisable(void);
|
||||
void OsdWaitVBL(void);
|
||||
void OsdReset(unsigned char boot);
|
||||
void OsdReset();
|
||||
void ConfigFilter(unsigned char lores, unsigned char hires);
|
||||
void OsdReconfig(); // Reset to Chameleon core.
|
||||
// deprecated functions from Minimig 1
|
||||
@@ -120,9 +85,6 @@ void ConfigChipset(unsigned char chipset);
|
||||
void ConfigFloppy(unsigned char drives, unsigned char speed);
|
||||
void ConfigIDE(unsigned char gayle, unsigned char master, unsigned char slave);
|
||||
void ConfigAutofire(unsigned char autofire, unsigned char mask);
|
||||
unsigned char OsdGetCtrl(void);
|
||||
void OsdDisableMenuButton(unsigned char disable);
|
||||
unsigned char GetASCIIKey(unsigned char c);
|
||||
void OSD_PrintText(unsigned char line, char *text, unsigned long start, unsigned long width, unsigned long offset, unsigned char invert);
|
||||
void OsdWriteDoubleSize(unsigned char n, char *s, unsigned char pass);
|
||||
//void OsdDrawLogo(unsigned char n, char row);
|
||||
@@ -132,9 +94,6 @@ void ScrollReset();
|
||||
void StarsInit();
|
||||
void StarsUpdate();
|
||||
|
||||
void OsdKeySet(unsigned char);
|
||||
unsigned char OsdKeyGet();
|
||||
|
||||
// get/set core currently loaded
|
||||
void OsdCoreNameSet(const char* str);
|
||||
char* OsdCoreName();
|
||||
|
||||
365
state.c
365
state.c
@@ -1,365 +0,0 @@
|
||||
/*
|
||||
Copyright 2005, 2006, 2007 Dennis van Weeren
|
||||
Copyright 2008, 2009 Jakub Bednarski
|
||||
|
||||
This file is part of Minimig
|
||||
|
||||
Minimig 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 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
Minimig 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 <http://www.gnu.org/licenses/>.
|
||||
|
||||
This code keeps status of MiST state
|
||||
|
||||
*/
|
||||
|
||||
#include <string.h>
|
||||
#include "stdio.h"
|
||||
|
||||
#include "state.h"
|
||||
#include "osd.h"
|
||||
#include "hardware.h"
|
||||
|
||||
//#include "charrom.h"
|
||||
|
||||
|
||||
|
||||
// for I/O
|
||||
static mist_joystick_t mist_joystick_temp = {
|
||||
.vid = 0,
|
||||
.pid = 0,
|
||||
.num_buttons = 1, // DB9 has 1 button
|
||||
.state = 0,
|
||||
.state_extra = 0,
|
||||
.usb_state = 0,
|
||||
.usb_state_extra = 0,
|
||||
.turbo = 0,
|
||||
.turbo_counter = 0,
|
||||
.turbo_mask = 0x30, // A and B buttons
|
||||
.turbo_state = 0xFF // flip state (0 or 1)
|
||||
};
|
||||
|
||||
/* latest joystick state */
|
||||
static mist_joystick_t mist_joysticks[3] = { // 3rd one is dummy, used to store defaults
|
||||
{
|
||||
.vid = 0,
|
||||
.pid = 0,
|
||||
.num_buttons = 1, // DB9 has 1 button
|
||||
.state = 0,
|
||||
.state_extra = 0,
|
||||
.usb_state = 0,
|
||||
.usb_state_extra = 0,
|
||||
.turbo = 0,
|
||||
.turbo_counter = 0,
|
||||
.turbo_mask = 0x30, // A and B buttons
|
||||
.turbo_state = 0xFF // flip state (0 or 1)
|
||||
},
|
||||
{
|
||||
.vid = 0,
|
||||
.pid = 0,
|
||||
.num_buttons = 1, // DB9 has 1 button
|
||||
.state = 0,
|
||||
.state_extra = 0,
|
||||
.usb_state = 0,
|
||||
.usb_state_extra = 0,
|
||||
.turbo = 0,
|
||||
.turbo_counter = 0,
|
||||
.turbo_mask = 0x30, // A and B buttons
|
||||
.turbo_state = 0xFF // flip state (0 or 1)
|
||||
},
|
||||
{
|
||||
.vid = 0,
|
||||
.pid = 0,
|
||||
.num_buttons = 1, // DB9 has 1 button
|
||||
.state = 0,
|
||||
.state_extra = 0,
|
||||
.usb_state = 0,
|
||||
.usb_state_extra = 0,
|
||||
.turbo = 0,
|
||||
.turbo_counter = 0,
|
||||
.turbo_mask = 0x30, // A and B buttons
|
||||
.turbo_state = 0xFF // flip state (0 or 1)
|
||||
}
|
||||
};
|
||||
|
||||
void joy_reset(mist_joystick_t joy) {
|
||||
joy.vid = 0;
|
||||
joy.pid = 0;
|
||||
joy.num_buttons = 1; // DB9 has 1 button
|
||||
joy.state = 0;
|
||||
joy.state_extra = 0;
|
||||
joy.usb_state = 0;
|
||||
joy.usb_state_extra = 0;
|
||||
joy.turbo = 0;
|
||||
joy.turbo_counter = 0;
|
||||
joy.turbo_mask = 0x30; // A and B buttons
|
||||
joy.turbo_state = 0xFF; // flip state (0 or 1)
|
||||
}
|
||||
|
||||
// sets a joystick to input status
|
||||
void StateJoyCopy(uint8_t num_joy, mist_joystick_t* joy) {
|
||||
mist_joystick_t mine;
|
||||
if (num_joy>1) return;
|
||||
if (!joy) return;
|
||||
mine = mist_joysticks[num_joy];
|
||||
mine.vid = joy->vid;
|
||||
mine.pid = joy->pid;
|
||||
mine.num_buttons = joy->num_buttons;
|
||||
mine.state = joy->state;
|
||||
mine.state_extra = joy->state_extra;
|
||||
mine.usb_state = joy->usb_state;
|
||||
mine.usb_state_extra = joy->usb_state_extra;
|
||||
mine.turbo = joy->turbo;
|
||||
mine.turbo_counter = joy->turbo_counter;
|
||||
mine.turbo_mask = joy->turbo_mask;
|
||||
mine.turbo_state = joy->turbo_state;
|
||||
}
|
||||
|
||||
void StateJoyRead(uint8_t num_joy, mist_joystick_t* joy) {
|
||||
mist_joystick_t mine;
|
||||
if (num_joy>1) return;
|
||||
if (!joy) return;
|
||||
mine = mist_joysticks[num_joy];
|
||||
joy->vid = mine.vid;
|
||||
joy->pid = mine.pid;
|
||||
joy->num_buttons = mine.num_buttons;
|
||||
joy->state = mine.state;
|
||||
joy->state_extra = mine.state_extra;
|
||||
joy->usb_state = mine.usb_state;
|
||||
joy->usb_state_extra = mine.usb_state_extra;
|
||||
joy->turbo = mine.turbo;
|
||||
joy->turbo_counter = mine.turbo_counter;
|
||||
joy->turbo_mask = mine.turbo_mask;
|
||||
joy->turbo_state = mine.turbo_state;
|
||||
}
|
||||
|
||||
// returns a copy of a status structure
|
||||
mist_joystick_t StateJoyGetStructure(uint8_t num_joy) {
|
||||
StateJoyRead(num_joy, &mist_joystick_temp);
|
||||
return mist_joystick_temp;
|
||||
}
|
||||
|
||||
// applies the turbo to a given joystick
|
||||
mist_joystick_t StateJoyUpdateTurboStructure(uint8_t num_joy) {
|
||||
StateJoyRead(num_joy, &mist_joystick_temp);
|
||||
StateTurboUpdate(&mist_joystick_temp);
|
||||
//mist_joystick_t mine = mist_joystick_temp;
|
||||
StateJoyCopy(num_joy, &mist_joystick_temp);
|
||||
}
|
||||
|
||||
uint8_t StateJoyStructureState(uint8_t num_joy) {
|
||||
mist_joystick_t mine;
|
||||
mine = StateJoyGetStructure(num_joy);
|
||||
return mine.state;
|
||||
}
|
||||
|
||||
/* latest joystick state */
|
||||
static uint8_t osd_joy;
|
||||
static uint8_t osd_joy_extra;
|
||||
static uint8_t osd_joy2;
|
||||
static uint8_t osd_joy_extra2;
|
||||
void StateJoySet(uint8_t c, uint8_t joy_num) {
|
||||
//iprintf("OSD joy: %x\n", c);
|
||||
if (joy_num == 0)
|
||||
osd_joy = c;
|
||||
else
|
||||
osd_joy2 = c;
|
||||
}
|
||||
void StateJoySetExtra(uint8_t c, uint8_t joy_num) {
|
||||
if (joy_num == 0)
|
||||
osd_joy_extra = c;
|
||||
else
|
||||
osd_joy_extra2 = c;
|
||||
}
|
||||
uint8_t StateJoyGet(uint8_t joy_num) {
|
||||
return joy_num == 0 ? osd_joy : osd_joy2;
|
||||
}
|
||||
uint8_t StateJoyGetExtra(uint8_t joy_num) {
|
||||
return joy_num == 0 ? osd_joy_extra : osd_joy_extra2;
|
||||
}
|
||||
|
||||
static uint8_t raw_usb_joy; // four directions and 4 buttons
|
||||
static uint8_t raw_usb_joy_extra; // eight extra buttons
|
||||
static uint8_t raw_usb_joy_b; // four directions and 4 buttons
|
||||
static uint8_t raw_usb_joy_extra_b; // eight extra buttons
|
||||
void StateUsbJoySet(uint8_t usbjoy, uint8_t usbextra, uint8_t joy_num) {
|
||||
if (joy_num == 0) {
|
||||
raw_usb_joy = usbjoy;
|
||||
raw_usb_joy_extra = usbextra;
|
||||
}
|
||||
else {
|
||||
raw_usb_joy_b = usbjoy;
|
||||
raw_usb_joy_extra_b = usbextra;
|
||||
}
|
||||
}
|
||||
|
||||
uint8_t StateUsbJoyGet(uint8_t joy_num) {
|
||||
return (joy_num == 0) ? raw_usb_joy : raw_usb_joy_b;
|
||||
}
|
||||
uint8_t StateUsbJoyGetExtra(uint8_t joy_num) {
|
||||
return (joy_num == 0) ? raw_usb_joy_extra : raw_usb_joy_extra_b;
|
||||
}
|
||||
|
||||
static uint16_t usb_vid;
|
||||
static uint16_t usb_pid;
|
||||
static uint8_t num_buttons;
|
||||
static uint16_t usb_vid_b;
|
||||
static uint16_t usb_pid_b;
|
||||
static uint8_t num_buttons_b;
|
||||
void StateUsbIdSet(uint16_t vid, uint16_t pid, uint8_t num, uint8_t joy_num) {
|
||||
if (joy_num == 0) {
|
||||
usb_vid = vid;
|
||||
usb_pid = pid;
|
||||
num_buttons = num;
|
||||
}
|
||||
else {
|
||||
usb_vid_b = vid;
|
||||
usb_pid_b = pid;
|
||||
num_buttons_b = num;
|
||||
}
|
||||
}
|
||||
uint16_t StateUsbVidGet(uint8_t joy_num) {
|
||||
return joy_num == 0 ? usb_vid : usb_vid_b;
|
||||
}
|
||||
uint16_t StateUsbPidGet(uint8_t joy_num) {
|
||||
return joy_num == 0 ? usb_pid : usb_pid_b;
|
||||
}
|
||||
uint8_t StateUsbGetNumButtons(uint8_t joy_num) {
|
||||
return (joy_num == 0) ? num_buttons : num_buttons_b;
|
||||
}
|
||||
|
||||
// return joystick state take into account turbo settings
|
||||
void StateJoyState(uint8_t joy_num, mist_joystick_t* joy) {
|
||||
mist_joystick_t mine;
|
||||
if (joy_num>1) return;
|
||||
if (!joy) return;
|
||||
joy->vid = StateUsbVidGet(joy_num);
|
||||
joy->pid = StateUsbPidGet(joy_num);
|
||||
//joy.num_buttons=1; // DB9 has 1 button
|
||||
joy->state = StateUsbPidGet(joy_num);
|
||||
joy->state_extra = StateJoyGetExtra(joy_num);
|
||||
joy->usb_state = StateUsbJoyGet(joy_num);
|
||||
joy->usb_state_extra = (joy_num);
|
||||
//apply turbo status
|
||||
joy->state = StateUsbPidGet(joy_num);
|
||||
if (joy->turbo > 0) {
|
||||
joy->state &= joy->turbo_state;
|
||||
}
|
||||
// chache into current static scope
|
||||
StateJoyCopy(joy_num, joy);
|
||||
}
|
||||
|
||||
/* handle button's turbo timers */
|
||||
void StateTurboUpdate(mist_joystick_t* joy) {
|
||||
if (!joy) return;
|
||||
if (joy->turbo == 0) return; // nothing to do
|
||||
joy->turbo_counter += 1;
|
||||
if (joy->turbo_counter > joy->turbo) {
|
||||
joy->turbo_counter = 0;
|
||||
joy->turbo_state ^= joy->turbo_mask;
|
||||
}
|
||||
}
|
||||
/* reset all turbo timers and state */
|
||||
void StateTurboReset(mist_joystick_t* joy) {
|
||||
if (!joy) return;
|
||||
joy->turbo_counter = 0;
|
||||
joy->turbo_state = 0xFF;
|
||||
}
|
||||
/* set a specific turbo mask and timeout */
|
||||
void StateTurboSet(mist_joystick_t* joy, uint16_t turbo, uint16_t mask) {
|
||||
if (!joy) return;
|
||||
StateTurboReset(joy);
|
||||
joy->turbo = turbo;
|
||||
joy->turbo_mask = mask;
|
||||
}
|
||||
|
||||
// Keep track of connected sticks
|
||||
uint8_t joysticks = 0;
|
||||
uint8_t StateNumJoysticks() {
|
||||
return joysticks;
|
||||
}
|
||||
|
||||
void StateNumJoysticksSet(uint8_t num) {
|
||||
joysticks = num;
|
||||
}
|
||||
|
||||
/* keyboard data */
|
||||
static uint8_t key_modifier = 0;
|
||||
static uint8_t key_pressed[6] = { 0,0,0,0,0,0 };
|
||||
static uint16_t keys_ps2[6] = { 0,0,0,0,0,0 };
|
||||
|
||||
void StateKeyboardPressedPS2(uint16_t *keycodes) {
|
||||
unsigned i = 0;
|
||||
for (i = 0; i<6; i++) {
|
||||
keycodes[i] = keys_ps2[i];
|
||||
}
|
||||
}
|
||||
void StateKeyboardSet(uint8_t modifier, uint8_t* keycodes, uint16_t* keycodes_ps2) {
|
||||
unsigned i = 0, j = 0;
|
||||
key_modifier = modifier;
|
||||
for (i = 0; i<6; i++) {
|
||||
//iprintf("Key N=%d, USB=%x, PS2=%x\n", i, keycodes[i], keycodes_ps2[i]);
|
||||
if (((keycodes[i] & 0xFF) != 0xFF) && (keycodes[i] & 0xFF)) {
|
||||
key_pressed[j] = keycodes[i];
|
||||
if ((keycodes_ps2[i] & 0xFF) != 0xFF) {
|
||||
// translate EXT into 0E
|
||||
if (0x1000 & keycodes_ps2[i]) {
|
||||
keys_ps2[j++] = (keycodes_ps2[i] & 0xFF) | 0xE000;
|
||||
}
|
||||
else {
|
||||
keys_ps2[j++] = keycodes_ps2[i] & 0xFF;
|
||||
}
|
||||
}
|
||||
else {
|
||||
keys_ps2[j++] = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
while (j<6) {
|
||||
key_pressed[j] = 0;
|
||||
keys_ps2[j++] = 0;
|
||||
}
|
||||
}
|
||||
|
||||
uint8_t StateKeyboardModifiers() {
|
||||
return key_modifier;
|
||||
}
|
||||
void StateKeyboardPressed(uint8_t *keycodes) {
|
||||
uint8_t i = 0;
|
||||
for (i = 0; i<6; i++)
|
||||
keycodes[i] = key_pressed[i];
|
||||
}
|
||||
|
||||
|
||||
/* core currently loaded */
|
||||
static char lastcorename[261 + 10] = "CORE";
|
||||
void StateCoreNameSet(const char* str) {
|
||||
siprintf(lastcorename, "%s", str);
|
||||
}
|
||||
char* StateCoreName() {
|
||||
return lastcorename;
|
||||
}
|
||||
|
||||
// clear all states
|
||||
void StateReset() {
|
||||
strcpy(lastcorename, "CORE");
|
||||
//State_key = 0;
|
||||
//joysticks=0;
|
||||
key_modifier = 0;
|
||||
for (int i = 0; i<6; i++) {
|
||||
key_pressed[i] = 0;
|
||||
keys_ps2[i] = 0;
|
||||
}
|
||||
//joy_reset(mist_joy[0]);
|
||||
//joy_reset(mist_joy[1]);
|
||||
//joy_reset(mist_joy[2]);
|
||||
}
|
||||
82
state.h
82
state.h
@@ -1,82 +0,0 @@
|
||||
#ifndef STATE_H_INCLUDED
|
||||
#define STATE_H_INCLUDED
|
||||
|
||||
#include <inttypes.h>
|
||||
|
||||
void StateReset();
|
||||
|
||||
//// type definitions ////
|
||||
typedef struct {
|
||||
uint16_t vid; // USB vendor ID
|
||||
uint16_t pid; // USB product ID
|
||||
uint8_t num_buttons; // number of physical buttons reported by HID parsing
|
||||
uint8_t state; // virtual joystick: current state of 4 direction + 4 first buttons
|
||||
uint8_t state_extra; // current state of 8 more buttons
|
||||
uint8_t usb_state; // raw USB state of direction and buttons
|
||||
uint8_t usb_state_extra; // raw USB state of 8 more buttons
|
||||
uint16_t turbo; // 0 if disabled, otherwise max number to flip state
|
||||
uint16_t turbo_counter; // increased when using turbo, flips state when passing turbo
|
||||
uint8_t turbo_mask; // buttons subject to turbo
|
||||
uint8_t turbo_state; // current mask to apply
|
||||
|
||||
} mist_joystick_t;
|
||||
|
||||
|
||||
|
||||
/*****
|
||||
* Various functions to retrieve hardware state from the State
|
||||
*/
|
||||
|
||||
// USB raw data for joystick
|
||||
void StateUsbJoySet(uint8_t usbjoy, uint8_t usbextra, uint8_t joy_num);
|
||||
void StateUsbIdSet(uint16_t vid, uint16_t pid, uint8_t num_buttons, uint8_t joy_num);
|
||||
uint8_t StateUsbJoyGet(uint8_t joy_num);
|
||||
uint8_t StateUsbJoyGetExtra(uint8_t joy_num);
|
||||
uint8_t StateUsbGetNumButtons(uint8_t joy_num);
|
||||
uint16_t StateUsbVidGet(uint8_t joy_num);
|
||||
uint16_t StateUsbPidGet(uint8_t joy_num);
|
||||
|
||||
|
||||
// State of first (virtual) internal joystisk i.e. after mapping
|
||||
void StateJoySet(uint8_t c, uint8_t joy_num);
|
||||
void StateJoySetExtra(uint8_t c, uint8_t joy_num);
|
||||
uint8_t StateJoyGet(uint8_t joy_num);
|
||||
uint8_t StateJoyGetExtra(uint8_t joy_num);
|
||||
|
||||
// turbo button functions
|
||||
void StateTurboUpdate(mist_joystick_t* joy);
|
||||
void StateTurboReset(mist_joystick_t* joy);
|
||||
void StateTurboSet(mist_joystick_t* joy, uint16_t turbo, uint16_t mask);
|
||||
mist_joystick_t StateJoyUpdateTurboStructure(uint8_t num_joy);
|
||||
void StateJoyRead(uint8_t num_joy, mist_joystick_t* joy);
|
||||
void StateJoyCopy(uint8_t num_joy, mist_joystick_t* joy);
|
||||
uint8_t StateJoyStructureState(uint8_t num_joy);
|
||||
|
||||
|
||||
// Keep track of connected sticks
|
||||
uint8_t StateNumJoysticks();
|
||||
void StateNumJoysticksSet(uint8_t num);
|
||||
|
||||
// to get data
|
||||
void StateJoyState(uint8_t joy_num, mist_joystick_t* joy); // directions and 4 buttons, reflecting turbo settings
|
||||
|
||||
/*
|
||||
// turbo function
|
||||
void StateTurboUpdate(uint8_t joy_num);
|
||||
void StateTurboReset(uint8_t joy_num);
|
||||
void StateTurboSet ( uint16_t turbo, uint16_t mask, uint8_t joy_num );
|
||||
|
||||
*/
|
||||
|
||||
// keyboard status
|
||||
void StateKeyboardSet(uint8_t modifier, uint8_t* pressed, uint16_t* pressed_ps2); //get usb and ps2 codes
|
||||
uint8_t StateKeyboardModifiers();
|
||||
void StateKeyboardPressed(uint8_t *pressed);
|
||||
void StateKeyboardPressedPS2(uint16_t *keycodes);
|
||||
|
||||
// get/set core currently loaded
|
||||
void StateCoreNameSet(const char* str);
|
||||
char* StateCoreName();
|
||||
|
||||
#endif
|
||||
|
||||
242
user_io.c
242
user_io.c
@@ -7,8 +7,6 @@
|
||||
|
||||
#include "hardware.h"
|
||||
#include "osd.h"
|
||||
#include "state.h"
|
||||
#include "state.h"
|
||||
#include "user_io.h"
|
||||
#include "archie.h"
|
||||
#include "debug.h"
|
||||
@@ -21,6 +19,7 @@
|
||||
#include "fpga_io.h"
|
||||
#include "file_io.h"
|
||||
#include "config.h"
|
||||
#include "menu.h"
|
||||
|
||||
#define BREAK 0x8000
|
||||
|
||||
@@ -1298,7 +1297,7 @@ unsigned short keycode(unsigned char in)
|
||||
|
||||
extern configTYPE config;
|
||||
|
||||
void check_reset(unsigned short modifiers, char useKeys)
|
||||
void user_io_check_reset(unsigned short modifiers, char useKeys)
|
||||
{
|
||||
unsigned short combo[] =
|
||||
{
|
||||
@@ -1317,8 +1316,7 @@ void check_reset(unsigned short modifiers, char useKeys)
|
||||
switch (core_type)
|
||||
{
|
||||
case CORE_TYPE_MINIMIG2:
|
||||
ConfigIDE(config.enable_ide, config.hardfile[0].present && config.hardfile[0].enabled, config.hardfile[1].present && config.hardfile[1].enabled);
|
||||
OsdReset(RESET_NORMAL);
|
||||
OsdReset();
|
||||
break;
|
||||
|
||||
case CORE_TYPE_8BIT:
|
||||
@@ -1386,149 +1384,42 @@ static char key_used_by_osd(unsigned short s)
|
||||
return((core_type == CORE_TYPE_MIST) || (core_type == CORE_TYPE_ARCHIE) || (core_type == CORE_TYPE_8BIT));
|
||||
}
|
||||
|
||||
static char kr_fn_table[] =
|
||||
void user_io_kbd(uint16_t key, int press)
|
||||
{
|
||||
0x54, 0x48, // pause/break
|
||||
0x55, 0x46, // prnscr
|
||||
0x50, 0x4a, // home
|
||||
0x4f, 0x4d, // end
|
||||
0x52, 0x4b, // pgup
|
||||
0x51, 0x4e, // pgdown
|
||||
0x3a, 0x44, // f11
|
||||
0x3b, 0x45, // f12
|
||||
|
||||
0x3c, 0x6c, // EMU_MOUSE
|
||||
0x3d, 0x6d, // EMU_JOY0
|
||||
0x3e, 0x6e, // EMU_JOY1
|
||||
0x3f, 0x6f, // EMU_NONE
|
||||
|
||||
//Emulate keypad for A600
|
||||
0x1E, 0x59, //KP1
|
||||
0x1F, 0x5A, //KP2
|
||||
0x20, 0x5B, //KP3
|
||||
0x21, 0x5C, //KP4
|
||||
0x22, 0x5D, //KP5
|
||||
0x23, 0x5E, //KP6
|
||||
0x24, 0x5F, //KP7
|
||||
0x25, 0x60, //KP8
|
||||
0x26, 0x61, //KP9
|
||||
0x27, 0x62, //KP0
|
||||
0x2D, 0x56, //KP-
|
||||
0x2E, 0x57, //KP+
|
||||
0x31, 0x55, //KP*
|
||||
0x2F, 0x68, //KP(
|
||||
0x30, 0x69, //KP)
|
||||
0x37, 0x63, //KP.
|
||||
0x28, 0x58 //KP Enter
|
||||
};
|
||||
|
||||
static void keyrah_trans(unsigned char *m, unsigned char *k)
|
||||
{
|
||||
static char keyrah_fn_state = 0;
|
||||
char fn = 0;
|
||||
char empty = 1;
|
||||
char rctrl = 0;
|
||||
int i = 0;
|
||||
while (i<6)
|
||||
{
|
||||
if ((k[i] == 0x64) || (k[i] == 0x32))
|
||||
{
|
||||
if (k[i] == 0x64) fn = 1;
|
||||
if (k[i] == 0x32) rctrl = 1;
|
||||
for (int n = i; n<5; n++) k[n] = k[n + 1];
|
||||
k[5] = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (k[i]) empty = 0;
|
||||
i++;
|
||||
}
|
||||
}
|
||||
|
||||
if (fn)
|
||||
{
|
||||
for (i = 0; i<6; i++)
|
||||
{
|
||||
for (int n = 0; n<(sizeof(kr_fn_table) / (2 * sizeof(kr_fn_table[0]))); n++)
|
||||
{
|
||||
if (k[i] == kr_fn_table[n * 2]) k[i] = kr_fn_table[(n * 2) + 1];
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// free these keys for core usage
|
||||
for (i = 0; i<6; i++)
|
||||
{
|
||||
if (k[i] == 0x53) k[i] = 0x68;
|
||||
if (k[i] == 0x47) k[i] = 0x69;
|
||||
if (k[i] == 0x49) k[i] = 0x6b; // workaround!
|
||||
}
|
||||
}
|
||||
|
||||
*m = rctrl ? (*m) | 0x10 : (*m) & ~0x10;
|
||||
if (fn)
|
||||
{
|
||||
keyrah_fn_state |= 1;
|
||||
if (*m || !empty) keyrah_fn_state |= 2;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (keyrah_fn_state == 1)
|
||||
{
|
||||
if (core_type == CORE_TYPE_MINIMIG2)
|
||||
{
|
||||
send_keycode(KEY_MENU);
|
||||
send_keycode(BREAK | KEY_MENU);
|
||||
}
|
||||
else
|
||||
{
|
||||
OsdKeySet(KEY_MENU);
|
||||
}
|
||||
}
|
||||
keyrah_fn_state = 0;
|
||||
}
|
||||
}
|
||||
|
||||
//Keyrah v2: USB\VID_18D8&PID_0002\A600/A1200_MULTIMEDIA_EXTENSION_VERSION
|
||||
#define KEYRAH_ID (mist_cfg.keyrah_mode && (((((uint32_t)vid)<<16) | pid) == mist_cfg.keyrah_mode))
|
||||
|
||||
void user_io_kbd(unsigned char m, unsigned char *k, unsigned short vid, unsigned short pid)
|
||||
{
|
||||
char keyrah = KEYRAH_ID ? 1 : 0;
|
||||
if (keyrah) keyrah_trans(&m, k);
|
||||
|
||||
unsigned short reset_m = m;
|
||||
for (char i = 0; i<6; i++) if (k[i] == 0x4c) reset_m |= 0x100;
|
||||
check_reset(reset_m, keyrah ? 1 : mist_cfg.reset_combo);
|
||||
|
||||
if ((core_type == CORE_TYPE_MINIMIG2) ||
|
||||
(core_type == CORE_TYPE_MIST) ||
|
||||
(core_type == CORE_TYPE_ARCHIE) ||
|
||||
(core_type == CORE_TYPE_8BIT))
|
||||
{
|
||||
//iprintf("KBD: %d\n", m);
|
||||
//hexdump(k, 6, 0);
|
||||
uint8_t m = key >> 8;
|
||||
uint8_t k = key & 0xFF;
|
||||
|
||||
static unsigned char modifier = 0, pressed[6] = { 0,0,0,0,0,0 };
|
||||
char keycodes[6] = { 0,0,0,0,0,0 };
|
||||
uint16_t keycodes_ps2[6] = { 0,0,0,0,0,0 };
|
||||
char i, j;
|
||||
static unsigned char modifier = 0;
|
||||
|
||||
// handle modifier keys
|
||||
if (m != modifier && !osd_is_visible)
|
||||
if (m != modifier)
|
||||
{
|
||||
for (i = 0; i<8; i++)
|
||||
for (int i = 0; i<8; i++)
|
||||
{
|
||||
uint16_t code = modifier_keycode(i);
|
||||
|
||||
// Do we have a downstroke on a modifier key?
|
||||
if ((m & (1 << i)) && !(modifier & (1 << i)))
|
||||
{
|
||||
if (modifier_keycode(i) != MISS) send_keycode(modifier_keycode(i));
|
||||
if (code != MISS)
|
||||
{
|
||||
if (is_menu_core()) printf("keycode(make)%s for core: %d(0x%X)\n", (code & EXT) ? "(ext)" : "", code & 255, code & 255);
|
||||
if(!osd_is_visible) send_keycode(code);
|
||||
}
|
||||
}
|
||||
|
||||
if (!(m & (1 << i)) && (modifier & (1 << i)))
|
||||
{
|
||||
if (modifier_keycode(i) != MISS) send_keycode(BREAK | modifier_keycode(i));
|
||||
if (code != MISS)
|
||||
{
|
||||
if (is_menu_core()) printf("keycode(break)%s for core: %d(0x%X)\n", (code & EXT) ? "(ext)" : "", code & 255, code & 255);
|
||||
if (!osd_is_visible) send_keycode(BREAK | code);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1537,32 +1428,23 @@ void user_io_kbd(unsigned char m, unsigned char *k, unsigned short vid, unsigned
|
||||
|
||||
// check if there are keys in the pressed list which aren't
|
||||
// reported anymore
|
||||
for (i = 0; i<6; i++)
|
||||
if (k)
|
||||
{
|
||||
unsigned short code = keycode(pressed[i]);
|
||||
|
||||
if (pressed[i] && code != MISS)
|
||||
uint16_t code = keycode(k);
|
||||
if (!press)
|
||||
{
|
||||
//iprintf("key 0x%X break: 0x%X\n", pressed[i], code);
|
||||
if (is_menu_core()) printf("keycode(break)%s for core: %d(0x%X)\n", (code & EXT) ? "(ext)" : "", code & 255, code & 255);
|
||||
|
||||
for (j = 0; j<6 && pressed[i] != k[j]; j++);
|
||||
|
||||
// don't send break for caps lock
|
||||
if (j == 6)
|
||||
if (code != MISS)
|
||||
{
|
||||
// If OSD is visible, then all keys are sent into the OSD
|
||||
// using Amiga key codes since the OSD itself uses Amiga key codes
|
||||
// for historical reasons. If the OSD is invisble then only
|
||||
// those keys marked for OSD in the core specific table are
|
||||
// sent for OSD handling.
|
||||
if (code & OSD_OPEN)
|
||||
{
|
||||
OsdKeySet(0x80 | KEY_MENU);
|
||||
menu_key_set(KEY_AMI_UPSTROKE | KEY_AMI_MENU);
|
||||
}
|
||||
else
|
||||
{
|
||||
// special OSD key handled internally
|
||||
if (osd_is_visible) OsdKeySet(0x80 | usb2amiga(pressed[i]));
|
||||
if (osd_is_visible) menu_key_set(KEY_AMI_UPSTROKE | usb2amiga(k));
|
||||
}
|
||||
|
||||
if (!key_used_by_osd(code) && !(code & CAPS_LOCK_TOGGLE) && !(code & NUM_LOCK_TOGGLE))
|
||||
@@ -1571,21 +1453,12 @@ void user_io_kbd(unsigned char m, unsigned char *k, unsigned short vid, unsigned
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for (i = 0; i<6; i++)
|
||||
{
|
||||
unsigned short code = keycode(k[i]);
|
||||
|
||||
if (k[i] && (k[i] <= KEYCODE_MAX) && code != MISS)
|
||||
else
|
||||
{
|
||||
// check if this key is already in the list of pressed keys
|
||||
for (j = 0; j<6 && k[i] != pressed[j]; j++);
|
||||
if (is_menu_core()) printf("keycode(make)%s for core: %d(0x%X)\n", (code & EXT) ? "(ext)" : "", code & 255, code & 255);
|
||||
|
||||
if (j == 6)
|
||||
if ((k <= KEYCODE_MAX) && code != MISS)
|
||||
{
|
||||
//iprintf("key 0x%X make: 0x%X\n", k[i], code);
|
||||
|
||||
// If OSD is visible, then all keys are sent into the OSD
|
||||
// using Amiga key codes since the OSD itself uses Amiga key codes
|
||||
// for historical reasons. If the OSD is invisble then only
|
||||
@@ -1593,12 +1466,15 @@ void user_io_kbd(unsigned char m, unsigned char *k, unsigned short vid, unsigned
|
||||
// sent for OSD handling.
|
||||
if (code & OSD_OPEN)
|
||||
{
|
||||
OsdKeySet(KEY_MENU);
|
||||
menu_key_set(KEY_AMI_MENU);
|
||||
}
|
||||
else
|
||||
{
|
||||
// special OSD key handled internally
|
||||
if (osd_is_visible) OsdKeySet(usb2amiga(k[i]));
|
||||
if (osd_is_visible)
|
||||
{
|
||||
menu_key_set(usb2amiga(k));
|
||||
}
|
||||
}
|
||||
|
||||
// no further processing of any key that is currently
|
||||
@@ -1613,8 +1489,7 @@ void user_io_kbd(unsigned char m, unsigned char *k, unsigned short vid, unsigned
|
||||
|
||||
set_kbd_led(HID_LED_CAPS_LOCK, caps_lock_toggle);
|
||||
}
|
||||
else
|
||||
if (code & NUM_LOCK_TOGGLE)
|
||||
else if (code & NUM_LOCK_TOGGLE)
|
||||
{
|
||||
// num lock has four states indicated by leds:
|
||||
// all off: normal
|
||||
@@ -1625,7 +1500,7 @@ void user_io_kbd(unsigned char m, unsigned char *k, unsigned short vid, unsigned
|
||||
switch (code ^ NUM_LOCK_TOGGLE)
|
||||
{
|
||||
case 1:
|
||||
if(!joy_force) emu_mode = EMU_MOUSE;
|
||||
if (!joy_force) emu_mode = EMU_MOUSE;
|
||||
break;
|
||||
|
||||
case 2:
|
||||
@@ -1646,10 +1521,10 @@ void user_io_kbd(unsigned char m, unsigned char *k, unsigned short vid, unsigned
|
||||
break;
|
||||
}
|
||||
input_notify_mode();
|
||||
if(emu_mode == EMU_MOUSE || emu_mode == EMU_JOY0) set_kbd_led(HID_LED_NUM_LOCK, true);
|
||||
if (emu_mode == EMU_MOUSE || emu_mode == EMU_JOY0) set_kbd_led(HID_LED_NUM_LOCK, true);
|
||||
else set_kbd_led(HID_LED_NUM_LOCK, false);
|
||||
|
||||
if(emu_mode == EMU_MOUSE || emu_mode == EMU_JOY1) set_kbd_led(HID_LED_SCROLL_LOCK, true);
|
||||
if (emu_mode == EMU_MOUSE || emu_mode == EMU_JOY1) set_kbd_led(HID_LED_SCROLL_LOCK, true);
|
||||
else set_kbd_led(HID_LED_SCROLL_LOCK, false);
|
||||
}
|
||||
else
|
||||
@@ -1660,43 +1535,6 @@ void user_io_kbd(unsigned char m, unsigned char *k, unsigned short vid, unsigned
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for (i = 0; i<6; i++)
|
||||
{
|
||||
pressed[i] = k[i];
|
||||
keycodes[i] = pressed[i]; // send raw USB code, not amiga - keycode(pressed[i]);
|
||||
keycodes_ps2[i] = keycode(pressed[i]);
|
||||
}
|
||||
StateKeyboardSet(m, keycodes, keycodes_ps2);
|
||||
}
|
||||
}
|
||||
|
||||
/* translates a USB modifiers into scancodes */
|
||||
void add_modifiers(uint8_t mod, uint16_t* keys_ps2)
|
||||
{
|
||||
uint8_t i;
|
||||
uint8_t offset = 1;
|
||||
uint8_t index = 0;
|
||||
while (offset)
|
||||
{
|
||||
if (mod&offset)
|
||||
{
|
||||
uint16_t ps2_value = modifier_keycode(index);
|
||||
if (ps2_value != MISS)
|
||||
{
|
||||
if (ps2_value & EXT) ps2_value = (0xE000 | (ps2_value & 0xFF));
|
||||
for (i = 0; i<4; i++)
|
||||
{
|
||||
if (keys_ps2[i] == 0)
|
||||
{
|
||||
keys_ps2[i] = ps2_value;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
offset <<= 1;
|
||||
index++;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -179,7 +179,7 @@ void user_io_eth_receive_tx_frame(uint8_t *, uint16_t);
|
||||
|
||||
// hooks from the usb layer
|
||||
void user_io_mouse(unsigned char b, int16_t x, int16_t y);
|
||||
void user_io_kbd(unsigned char m, unsigned char *k, unsigned short vid, unsigned short pid);
|
||||
void user_io_kbd(uint16_t key, int press);
|
||||
char* user_io_create_config_name();
|
||||
void user_io_digital_joystick(unsigned char, uint16_t);
|
||||
void user_io_analog_joystick(unsigned char, char, char);
|
||||
@@ -191,4 +191,6 @@ void add_modifiers(uint8_t mod, uint16_t* keys_ps2);
|
||||
void user_io_set_index(unsigned char index);
|
||||
unsigned char user_io_ext_idx(char *, char*);
|
||||
|
||||
void user_io_check_reset(unsigned short modifiers, char useKeys);
|
||||
|
||||
#endif // USER_IO_H
|
||||
|
||||
Reference in New Issue
Block a user