Merge in Mouse Wheel support from Basilisk II.

This commit is contained in:
gbeauche 2003-12-27 10:37:30 +00:00
parent b9b0b5248b
commit 7f6078a591
5 changed files with 74 additions and 7 deletions

View File

@ -702,11 +702,13 @@ static void create_graphics_pane(GtkWidget *top)
*/
static GtkWidget *w_keycode_file;
static GtkWidget *w_mouse_wheel_lines;
// Set sensitivity of widgets
static void set_input_sensitive(void)
{
gtk_widget_set_sensitive(w_keycode_file, PrefsFindBool("keycodes"));
gtk_widget_set_sensitive(w_mouse_wheel_lines, PrefsFindInt32("mousewheelmode") == 1);
}
// "Use Raw Keycodes" button toggled
@ -716,6 +718,10 @@ static void tb_keycodes(GtkWidget *widget)
set_input_sensitive();
}
// "Mouse Wheel Mode" selected
static void mn_wheel_page(...) {PrefsReplaceInt32("mousewheelmode", 0); set_input_sensitive();}
static void mn_wheel_cursor(...) {PrefsReplaceInt32("mousewheelmode", 1); set_input_sensitive();}
// Read settings from widgets and set preferences
static void read_input_settings(void)
{
@ -724,6 +730,8 @@ static void read_input_settings(void)
PrefsReplaceString("keycodefile", str);
else
PrefsRemoveItem("keycodefile");
PrefsReplaceInt32("mousewheellines", gtk_spin_button_get_value_as_int(GTK_SPIN_BUTTON(w_mouse_wheel_lines)));
}
// Create "Input" pane
@ -737,6 +745,33 @@ static void create_input_pane(GtkWidget *top)
make_checkbox(box, STR_KEYCODES_CTRL, "keycodes", GTK_SIGNAL_FUNC(tb_keycodes));
w_keycode_file = make_entry(box, STR_KEYCODE_FILE_CTRL, "keycodefile");
make_separator(box);
static const opt_desc options[] = {
{STR_MOUSEWHEELMODE_PAGE_LAB, GTK_SIGNAL_FUNC(mn_wheel_page)},
{STR_MOUSEWHEELMODE_CURSOR_LAB, GTK_SIGNAL_FUNC(mn_wheel_cursor)},
{0, NULL}
};
int wheelmode = PrefsFindInt32("mousewheelmode"), active = 0;
switch (wheelmode) {
case 0: active = 0; break;
case 1: active = 1; break;
}
menu = make_option_menu(box, STR_MOUSEWHEELMODE_CTRL, options, active);
hbox = gtk_hbox_new(FALSE, 4);
gtk_widget_show(hbox);
gtk_box_pack_start(GTK_BOX(box), hbox, FALSE, FALSE, 0);
label = gtk_label_new(GetString(STR_MOUSEWHEELLINES_CTRL));
gtk_widget_show(label);
gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 0);
adj = gtk_adjustment_new(PrefsFindInt32("mousewheellines"), 1, 1000, 1, 5, 0);
w_mouse_wheel_lines = gtk_spin_button_new(GTK_ADJUSTMENT(adj), 0.0, 0);
gtk_widget_show(w_mouse_wheel_lines);
gtk_box_pack_start(GTK_BOX(hbox), w_mouse_wheel_lines, FALSE, FALSE, 0);
set_input_sensitive();
}

View File

@ -32,6 +32,8 @@ prefs_desc platform_prefs_items[] = {
{"ether", TYPE_STRING, false, "device name of Mac ethernet adapter"},
{"keycodes", TYPE_BOOLEAN, false, "use keycodes rather than keysyms to decode keyboard"},
{"keycodefile", TYPE_STRING, false, "path of keycode translation file"},
{"mousewheelmode", TYPE_INT32, false, "mouse wheel support mode (0=page up/down, 1=cursor up/down)"},
{"mousewheellines", TYPE_INT32, false, "number of lines to scroll in mouse wheel mode 1"},
{"dsp", TYPE_STRING, false, "audio output (dsp) device name"},
{"mixer", TYPE_STRING, false, "audio mixer device name"},
#ifdef HAVE_SIGSEGV_SKIP_INSTRUCTION
@ -100,6 +102,8 @@ void AddPlatformPrefsDefaults(void)
{
PrefsAddBool("keycodes", false);
PrefsReplaceString("extfs", "/");
PrefsReplaceInt32("mousewheelmode", 1);
PrefsReplaceInt32("mousewheellines", 3);
PrefsAddInt32("windowmodes", 3);
PrefsAddInt32("screenmodes", 0x3f);
#ifdef __linux__

View File

@ -66,9 +66,13 @@ user_string_def platform_strings[] = {
{STR_HELP_ITEM_ABOUT_GTK, "/Help/_About SheepShaver"},
{STR_DSPDEVICE_FILE_CTRL, "Audio Output Device"},
{STR_MIXERDEVICE_FILE_CTRL, "Audio Mixer Device"},
{STR_INPUT_PANE_TITLE, "Keyboard"},
{STR_INPUT_PANE_TITLE, "Mouse/Keyboard"},
{STR_KEYCODES_CTRL, "Use Raw Keycodes"},
{STR_KEYCODE_FILE_CTRL, "Keycode Translation File"},
{STR_MOUSEWHEELMODE_CTRL, "Mouse Wheel Function"},
{STR_MOUSEWHEELMODE_PAGE_LAB, "Page Up/Down"},
{STR_MOUSEWHEELMODE_CURSOR_LAB, "Cursor Up/Down"},
{STR_MOUSEWHEELLINES_CTRL, "Lines To Scroll"},
{STR_SUSPEND_WINDOW_TITLE, "SheepShaver suspended. Press Space to reactivate."},
{STR_VOSF_INIT_ERR, "Cannot initialize Video on SEGV signals."},

View File

@ -61,9 +61,14 @@ enum {
STR_SUSPEND_WINDOW_TITLE,
STR_DSPDEVICE_FILE_CTRL,
STR_MIXERDEVICE_FILE_CTRL,
STR_INPUT_PANE_TITLE,
STR_KEYCODES_CTRL,
STR_KEYCODE_FILE_CTRL
STR_KEYCODE_FILE_CTRL,
STR_MOUSEWHEELMODE_CTRL,
STR_MOUSEWHEELMODE_PAGE_LAB,
STR_MOUSEWHEELMODE_CURSOR_LAB,
STR_MOUSEWHEELLINES_CTRL,
};
#endif

View File

@ -54,6 +54,8 @@ const char KEYCODE_FILE_NAME[] = DATADIR "/keycodes";
// Global variables
static int32 frame_skip;
static int16 mouse_wheel_mode;
static int16 mouse_wheel_lines;
static bool redraw_thread_active = false; // Flag: Redraw thread installed
static pthread_t redraw_thread; // Redraw thread
@ -166,11 +168,6 @@ static bool open_window(int width, int height)
// Set absolute mouse mode
ADBSetRelMouseMode(false);
// Read frame skip prefs
frame_skip = PrefsFindInt32("frameskip");
if (frame_skip == 0)
frame_skip = 1;
// Create window
XSetWindowAttributes wattr;
wattr.event_mask = eventmask = win_eventmask;
@ -682,6 +679,15 @@ bool VideoInit(void)
// Init keycode translation
keycode_init();
// Read frame skip prefs
frame_skip = PrefsFindInt32("frameskip");
if (frame_skip == 0)
frame_skip = 1;
// Read mouse wheel prefs
mouse_wheel_mode = PrefsFindInt32("mousewheelmode");
mouse_wheel_lines = PrefsFindInt32("mousewheellines");
// Init variables
private_data = NULL;
cur_mode = 0; // Window 640x480
@ -1184,6 +1190,19 @@ static void handle_events(void)
unsigned int button = ((XButtonEvent *)&event)->button;
if (button < 4)
ADBMouseDown(button - 1);
else if (button < 6) { // Wheel mouse
if (mouse_wheel_mode == 0) {
int key = (button == 5) ? 0x79 : 0x74; // Page up/down
ADBKeyDown(key);
ADBKeyUp(key);
} else {
int key = (button == 5) ? 0x3d : 0x3e; // Cursor up/down
for(int i=0; i<mouse_wheel_lines; i++) {
ADBKeyDown(key);
ADBKeyUp(key);
}
}
}
break;
}
case ButtonRelease: {