1 /** \file settings_mouse.c
2 * \brief Mouse settings widget
3 *
4 * \author Bas Wassink <b.wassink@ziggo.nl>
5 */
6
7 /*
8 * $VICERES ps2mouse x64dtv
9 * $VICERES SmartMouseRTCSave x64 x64sc xscpu64 x128 xvic xplus4 xcbm5x0
10 * $VICERES MouseSensitivity
11 * (appears to be Windows-specific)
12 */
13
14 /*
15 * This file is part of VICE, the Versatile Commodore Emulator.
16 * See README for copyright notice.
17 *
18 * This program is free software; you can redistribute it and/or modify
19 * it under the terms of the GNU General Public License as published by
20 * the Free Software Foundation; either version 2 of the License, or
21 * (at your option) any later version.
22 *
23 * This program is distributed in the hope that it will be useful,
24 * but WITHOUT ANY WARRANTY; without even the implied warranty of
25 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
26 * GNU General Public License for more details.
27 *
28 * You should have received a copy of the GNU General Public License
29 * along with this program; if not, write to the Free Software
30 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
31 * 02111-1307 USA.
32 *
33 */
34
35 #include "vice.h"
36
37 #include <gtk/gtk.h>
38
39 #include "resources.h"
40 #include "machine.h"
41 #include "vice_gtk3.h"
42
43 #include "settings_mouse.h"
44
45
46 #ifdef WIN32_COMPILE
47 /** \brief Create mouse sensitivity slider
48 *
49 * Appears to be Win32 only.
50 *
51 * \return GtkGrid
52 */
create_sensitivity_widget(void)53 static GtkWidget *create_sensitivity_widget(void)
54 {
55 GtkWidget * grid;
56 GtkWidget * scale;
57 GtkWidget * label;
58 int current;
59
60 if (resources_get_int("MouseSensitivity", ¤t) < 0) {
61 current = 20;
62 }
63
64 grid = gtk_grid_new();
65 gtk_grid_set_column_spacing(GTK_GRID(grid), 8);
66 gtk_grid_set_row_spacing(GTK_GRID(grid), 8);
67 g_object_set(grid, "margin", 16, NULL);
68
69 label = gtk_label_new("Mouse sensitivity");
70 gtk_widget_set_halign(label, GTK_ALIGN_START);
71 gtk_grid_attach(GTK_GRID(grid), label, 0, 0, 1, 1);
72
73 scale = gtk_scale_new_with_range(GTK_ORIENTATION_HORIZONTAL, 0.0, 40.0, 1.0);
74 gtk_range_set_value(GTK_RANGE(scale), (gdouble)current);
75 gtk_widget_set_hexpand(scale, TRUE);
76 gtk_grid_attach(GTK_GRID(grid), scale, 1, 0, 1, 1);
77
78 gtk_widget_show_all(grid);
79 return grid;
80 }
81 #endif
82
83
84 /** \brief Create mouse settings widget
85 *
86 * \param[in] parent parent widget
87 *
88 * \return GtkGrid
89 */
settings_mouse_widget_create(GtkWidget * parent)90 GtkWidget *settings_mouse_widget_create(GtkWidget *parent)
91 {
92 GtkWidget *layout;
93 GtkWidget *ps2_enable;
94 GtkWidget *mouse_save = NULL;
95 int row = 0;
96
97 layout = vice_gtk3_grid_new_spaced(VICE_GTK3_DEFAULT, VICE_GTK3_DEFAULT);
98 g_object_set(layout, "margin", 16, NULL);
99
100 if (machine_class == VICE_MACHINE_C64DTV) {
101 ps2_enable = vice_gtk3_resource_check_button_new("ps2mouse",
102 "Enable PS/2 mouse on Userport");
103 gtk_grid_attach(GTK_GRID(layout), ps2_enable, 0, row, 1, 1);
104 row++;
105 }
106
107 switch (machine_class) {
108 case VICE_MACHINE_C64: /* fall through */
109 case VICE_MACHINE_C64SC: /* fall through */
110 case VICE_MACHINE_SCPU64: /* fall through */
111 case VICE_MACHINE_C128: /* fall through */
112 case VICE_MACHINE_VIC20: /* fall through */
113 case VICE_MACHINE_PLUS4: /* fall through */
114 case VICE_MACHINE_CBM5x0:
115 mouse_save = vice_gtk3_resource_check_button_new(
116 "SmartMouseRTCSave", "Enable SmartMouse RTC Saving");
117 gtk_grid_attach(GTK_GRID(layout), mouse_save, 0, row, 1, 1);
118 row++;
119 break;
120 default:
121 /* No SmartMouse support */
122 break;
123 }
124
125 #ifdef WIN32_COMPILE
126 gtk_grid_attach(GTK_GRID(layout), create_sensitivity_widget(), 0, row, 1, 1);
127 #endif
128
129 gtk_widget_show_all(layout);
130 return layout;
131 }
132