Commit d69187bc authored by Ben Avison's avatar Ben Avison
Browse files

Initial commit of Configure plug-in '!MousSetup' to CVS.

parents
| Copyright 1998 Acorn Computers Ltd
|
| Licensed under the Apache License, Version 2.0 (the "License");
| you may not use this file except in compliance with the License.
| You may obtain a copy of the License at
|
| http://www.apache.org/licenses/LICENSE-2.0
|
| Unless required by applicable law or agreed to in writing, software
| distributed under the License is distributed on an "AS IS" BASIS,
| WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
| See the License for the specific language governing permissions and
| limitations under the License.
|
Dir <Obey$Dir>
amu_machine clean
| Copyright 1998 Acorn Computers Ltd
|
| Licensed under the Apache License, Version 2.0 (the "License");
| you may not use this file except in compliance with the License.
| You may obtain a copy of the License at
|
| http://www.apache.org/licenses/LICENSE-2.0
|
| Unless required by applicable law or agreed to in writing, software
| distributed under the License is distributed on an "AS IS" BASIS,
| WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
| See the License for the specific language governing permissions and
| limitations under the License.
|
Dir <Obey$Dir>
Remove Resources.!RunImage
amu_machine install INSTDIR=<Boot$Dir>.RO380Hook.Res.Configure LDFLAGS=-Debug
| Copyright 1998 Acorn Computers Ltd
|
| Licensed under the Apache License, Version 2.0 (the "License");
| you may not use this file except in compliance with the License.
| You may obtain a copy of the License at
|
| http://www.apache.org/licenses/LICENSE-2.0
|
| Unless required by applicable law or agreed to in writing, software
| distributed under the License is distributed on an "AS IS" BASIS,
| WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
| See the License for the specific language governing permissions and
| limitations under the License.
|
Dir <Obey$Dir>
Remove Resources.!RunImage
amu_machine install INSTDIR=<Boot$Dir>.RO380Hook.Res.Configure
c/** gitlab-language=c linguist-language=c linguist-detectable=true
h/** gitlab-language=c linguist-language=c linguist-detectable=true
**************
* !MousSetup *
**************
Version Date Who Change
-------------------------------------------------------------------------------
<= 0.04 BJGA Early versions
0.05 09/12/1997 BJGA Reorganised into larger number of source files
0.06 11/12/1997 BJGA Updated help messages
0.07 16/01/1998 BJGA Minor tweaks to !Boot/!Run
and adapted to use stored cmos defaults
0.08 11/05/1998 BJGA Adapted for new Wimp CMOS usage
Added autoscroll pause time option
Apache License
Version 2.0, January 2004
http://www.apache.org/licenses/
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
1. Definitions.
"License" shall mean the terms and conditions for use, reproduction,
and distribution as defined by Sections 1 through 9 of this document.
"Licensor" shall mean the copyright owner or entity authorized by
the copyright owner that is granting the License.
"Legal Entity" shall mean the union of the acting entity and all
other entities that control, are controlled by, or are under common
control with that entity. For the purposes of this definition,
"control" means (i) the power, direct or indirect, to cause the
direction or management of such entity, whether by contract or
otherwise, or (ii) ownership of fifty percent (50%) or more of the
outstanding shares, or (iii) beneficial ownership of such entity.
"You" (or "Your") shall mean an individual or Legal Entity
exercising permissions granted by this License.
"Source" form shall mean the preferred form for making modifications,
including but not limited to software source code, documentation
source, and configuration files.
"Object" form shall mean any form resulting from mechanical
transformation or translation of a Source form, including but
not limited to compiled object code, generated documentation,
and conversions to other media types.
"Work" shall mean the work of authorship, whether in Source or
Object form, made available under the License, as indicated by a
copyright notice that is included in or attached to the work
(an example is provided in the Appendix below).
"Derivative Works" shall mean any work, whether in Source or Object
form, that is based on (or derived from) the Work and for which the
editorial revisions, annotations, elaborations, or other modifications
represent, as a whole, an original work of authorship. For the purposes
of this License, Derivative Works shall not include works that remain
separable from, or merely link (or bind by name) to the interfaces of,
the Work and Derivative Works thereof.
"Contribution" shall mean any work of authorship, including
the original version of the Work and any modifications or additions
to that Work or Derivative Works thereof, that is intentionally
submitted to Licensor for inclusion in the Work by the copyright owner
or by an individual or Legal Entity authorized to submit on behalf of
the copyright owner. For the purposes of this definition, "submitted"
means any form of electronic, verbal, or written communication sent
to the Licensor or its representatives, including but not limited to
communication on electronic mailing lists, source code control systems,
and issue tracking systems that are managed by, or on behalf of, the
Licensor for the purpose of discussing and improving the Work, but
excluding communication that is conspicuously marked or otherwise
designated in writing by the copyright owner as "Not a Contribution."
"Contributor" shall mean Licensor and any individual or Legal Entity
on behalf of whom a Contribution has been received by Licensor and
subsequently incorporated within the Work.
2. Grant of Copyright License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
copyright license to reproduce, prepare Derivative Works of,
publicly display, publicly perform, sublicense, and distribute the
Work and such Derivative Works in Source or Object form.
3. Grant of Patent License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
(except as stated in this section) patent license to make, have made,
use, offer to sell, sell, import, and otherwise transfer the Work,
where such license applies only to those patent claims licensable
by such Contributor that are necessarily infringed by their
Contribution(s) alone or by combination of their Contribution(s)
with the Work to which such Contribution(s) was submitted. If You
institute patent litigation against any entity (including a
cross-claim or counterclaim in a lawsuit) alleging that the Work
or a Contribution incorporated within the Work constitutes direct
or contributory patent infringement, then any patent licenses
granted to You under this License for that Work shall terminate
as of the date such litigation is filed.
4. Redistribution. You may reproduce and distribute copies of the
Work or Derivative Works thereof in any medium, with or without
modifications, and in Source or Object form, provided that You
meet the following conditions:
(a) You must give any other recipients of the Work or
Derivative Works a copy of this License; and
(b) You must cause any modified files to carry prominent notices
stating that You changed the files; and
(c) You must retain, in the Source form of any Derivative Works
that You distribute, all copyright, patent, trademark, and
attribution notices from the Source form of the Work,
excluding those notices that do not pertain to any part of
the Derivative Works; and
(d) If the Work includes a "NOTICE" text file as part of its
distribution, then any Derivative Works that You distribute must
include a readable copy of the attribution notices contained
within such NOTICE file, excluding those notices that do not
pertain to any part of the Derivative Works, in at least one
of the following places: within a NOTICE text file distributed
as part of the Derivative Works; within the Source form or
documentation, if provided along with the Derivative Works; or,
within a display generated by the Derivative Works, if and
wherever such third-party notices normally appear. The contents
of the NOTICE file are for informational purposes only and
do not modify the License. You may add Your own attribution
notices within Derivative Works that You distribute, alongside
or as an addendum to the NOTICE text from the Work, provided
that such additional attribution notices cannot be construed
as modifying the License.
You may add Your own copyright statement to Your modifications and
may provide additional or different license terms and conditions
for use, reproduction, or distribution of Your modifications, or
for any such Derivative Works as a whole, provided Your use,
reproduction, and distribution of the Work otherwise complies with
the conditions stated in this License.
5. Submission of Contributions. Unless You explicitly state otherwise,
any Contribution intentionally submitted for inclusion in the Work
by You to the Licensor shall be under the terms and conditions of
this License, without any additional terms or conditions.
Notwithstanding the above, nothing herein shall supersede or modify
the terms of any separate license agreement you may have executed
with Licensor regarding such Contributions.
6. Trademarks. This License does not grant permission to use the trade
names, trademarks, service marks, or product names of the Licensor,
except as required for reasonable and customary use in describing the
origin of the Work and reproducing the content of the NOTICE file.
7. Disclaimer of Warranty. Unless required by applicable law or
agreed to in writing, Licensor provides the Work (and each
Contributor provides its Contributions) on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
implied, including, without limitation, any warranties or conditions
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
PARTICULAR PURPOSE. You are solely responsible for determining the
appropriateness of using or redistributing the Work and assume any
risks associated with Your exercise of permissions under this License.
8. Limitation of Liability. In no event and under no legal theory,
whether in tort (including negligence), contract, or otherwise,
unless required by applicable law (such as deliberate and grossly
negligent acts) or agreed to in writing, shall any Contributor be
liable to You for damages, including any direct, indirect, special,
incidental, or consequential damages of any character arising as a
result of this License or out of the use or inability to use the
Work (including but not limited to damages for loss of goodwill,
work stoppage, computer failure or malfunction, or any and all
other commercial damages or losses), even if such Contributor
has been advised of the possibility of such damages.
9. Accepting Warranty or Additional Liability. While redistributing
the Work or Derivative Works thereof, You may choose to offer,
and charge a fee for, acceptance of support, warranty, indemnity,
or other liability obligations and/or rights consistent with this
License. However, in accepting such obligations, You may act only
on Your own behalf and on Your sole responsibility, not on behalf
of any other Contributor, and only if You agree to indemnify,
defend, and hold each Contributor harmless for any liability
incurred by, or claims asserted against, such Contributor by reason
of your accepting any such warranty or additional liability.
END OF TERMS AND CONDITIONS
APPENDIX: How to apply the Apache License to your work.
To apply the Apache License to your work, attach the following
boilerplate notice, with the fields enclosed by brackets "[]"
replaced with your own identifying information. (Don't include
the brackets!) The text should be enclosed in the appropriate
comment syntax for the file format. We also recommend that a
file or class name and description of purpose be included on the
same "printed page" as the copyright notice for easier
identification within third-party archives.
Copyright [yyyy] [name of copyright owner]
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
# Copyright 1998 Acorn Computers Ltd
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
# Makefile for MousSetup
#
# ***********************************
# *** C h a n g e L i s t ***
# ***********************************
# Date Name Description
# ---- ---- -----------
# 17-Oct-97 BJGA Derived from InetSetup makefiles
# 28-Oct-97 BJGA No longer uses OSLib
# 10-Nov-97 BJGA Modified to use shared Common directory
# 09-Dec-97 BJGA Split Main.c, and modified to use shared Common library
# 17-Dec-97 BJGA Tidied up
# 11-May-98 BJGA Replaced Common directory with ConfigLib
#
#
# Program specific options:
#
COMPONENT = MousSetup
APP = !${COMPONENT}
RDIR = Resources
LDIR = ${RDIR}.${LOCALE}
INSTDIR = ${INSTDIR}.${APP}
#
# Generic options:
#
MKDIR = cdir
CC = cc
ATTR = -attr
CP = copy
LD = link
RM = remove
SQUEEZE = squeeze
WIPE = -wipe
CFLAGS = -c -depend !Depend -ffa -gflv ${INCLUDES} -throwback
CPFLAGS = ~cfr~v
WFLAGS = ~c~v
#
# Libraries
#
CLIB = C:o.stubs
ELIB = Tbox:o.eventlib
TLIB = Tbox:o.toolboxlib
WLIB = Tbox:o.wimplib
CONLIB = <Lib$Dir>.ConfigLib.o.ConfigLib
#
# Include files
#
INCLUDES = -ITbox:,C:,<Lib$Dir>.ConfigLib.
FILES=\
${LDIR}.!Help\
${RDIR}.!Boot\
${LDIR}.!Run\
${RDIR}.!RunImage\
${RDIR}.!Sprites22\
${RDIR}.CoSprite22\
${LDIR}.Messages\
${LDIR}.Res\
OBJS = Main.o MouseType.o Settings.o ToolboxE.o WimpE.o WimpM.o
#
# Rule patterns
#
.c.o:; ${CC} ${CFLAGS} -o $@ $<
#
# Main rules:
#
# Application
#
all: ${FILES}
@echo ${COMPONENT}: All built (Disc)
install: ${FILES}
${MKDIR} ${INSTDIR}
|
${CP} ${RDIR}.!Boot ${INSTDIR}.!Boot ${CPFLAGS}
${CP} ${LDIR}.!Help ${INSTDIR}.!Help ${CPFLAGS}
${CP} ${LDIR}.!Run ${INSTDIR}.!Run ${CPFLAGS}
${CP} ${RDIR}.!RunImage ${INSTDIR}.!RunImage ${CPFLAGS}
${CP} ${RDIR}.!Sprites22 ${INSTDIR}.!Sprites22 ${CPFLAGS}
${CP} ${RDIR}.CoSprite22 ${INSTDIR}.CoSprite22 ${CPFLAGS}
${CP} ${LDIR}.Messages ${INSTDIR}.Messages ${CPFLAGS}
${CP} ${LDIR}.Res ${INSTDIR}.Res ${CPFLAGS}
|
${ATTR} -directories +wr -ww ${INSTDIR}
${ATTR} -files +or +ow +wr -ww ${INSTDIR}
|
@echo ${COMPONENT}: All installed (Disc)
clean:
${WIPE} o.* ${WFLAGS}
${RM} ${RDIR}.!RunImage
@echo ${COMPONENT}: cleaned
#
# Static dependencies:
#
${RDIR}.!RunImage: ${OBJS} ${CONLIB} ${ELIB} ${TLIB} ${WLIB} ${CLIB}
${LD} ${LDFLAGS} -o $@ ${OBJS} ${CONLIB} ${ELIB} ${TLIB} ${WLIB} ${CLIB}
${SQUEEZE} $@
#---------------------------------------------------------------------------
# Dynamic dependencies:
If "<MousSetup$Dir>" = "" then Set MousSetup$Dir <Obey$Dir>
IconSprites <MousSetup$Dir>.!Sprites
File added
File added
Mouse Setup
===========
MousSetup is used to configure mouse-related behaviour. You should not need to
run it separately - it integrates into !Configure.
Interactive help is available - load !Help from Apps.
RMEnsure UtilityModule 3.80 Error MousSetup requires RISC OS 3.80 or later
IF "<Choices$Write>" = "" OR "<Boot$Path>" = "" THEN Error No Boot application appears to have been run.
Set MousSetup$Dir <Obey$Dir>
IconSprites <MousSetup$Dir>.!Sprites
RMEnsure Toolbox 1.41 RMLoad System:Modules.Toolbox.Toolbox
RMEnsure Toolbox 1.41 Error You need Toolbox 1.36 or later to run MousSetup
RMEnsure Window 1.47 RMLoad System:Modules.Toolbox.Window
RMEnsure Window 1.47 Error You need Window Object 1.47 or later to run MousSetup
RMEnsure Menu 0.29 RMLoad System:Modules.Toolbox.Menu
RMEnsure Menu 0.29 Error You need Menu 0.29 or later to run MousSetup
WimpSlot 32k 32k
Run <MousSetup$Dir>.!RunImage %*0
_TaskName:Mouse Setup
_Purpose:Configuring the mouse
_Author: Acorn Computers Ltd, 1998
_Version:0.08 (11-May-98)
_ConfigText:Mouse
_ConfigHelp:Click SELECT to open the mouse configuration window.
_ConfigSprite:co_mouse
Mystery:Unrecognised
NoneAvail:No mouse drivers are available
NewType:You are about to change the mouse type to '%s'. If you do not have this sort of mouse connected the pointer will stop working. Do you want to continue with the reconfiguration?
Err_NoDefCMOS:Cannot find default CMOS file
File added
/* Copyright 1998 Acorn Computers Ltd
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/****** Main.c ************************************************************\
Project: Ursula (RISC OS for Risc PC II)
Component: Mouse configuration plug-in
This file: Overall control
History:
Date Who Change
----------------------------------------------------------------------------
09/12/1997 BJGA Split into Main, Settings, ToolboxE, WimpE & WimpM
Added these headers
\**************************************************************************/
/* CLib */
#include <stdlib.h>
/* Toolbox */
#include "event.h"
#include "toolbox.h"
/* Common */
#include "error.h"
#include "misc.h"
/* Local headers */
#include "Main.h" /* includes prototypes for this file */
#include "ToolboxE.h"
#include "WimpE.h"
#include "WimpM.h"
#define WimpVersion ((int) 310)
/* Global variables */
BOOL quit = FALSE;
ObjectId mainwindow_id;
MessagesFD messages;
/* Static global variables */
static WimpPollBlock poll_block;
static IdBlock id_block;
/****** main() ************************************************************\
In: Command line option:
-openat x y
specifies initial position to open window at
\**************************************************************************/
int main (int argc, char *argv[])
{
error_initialise ();
throw (toolbox_initialise (0, WimpVersion, wimpm_messages, toolboxe_events,
"<MousSetup$Dir>", &messages, &id_block, NULL, NULL, NULL));
misc_parsearguments (argc, argv);
throw (event_initialise (&id_block));
throw (event_set_mask (wimpe_mask));
//
wimpm_register ();
wimpe_register ();
toolboxe_register ();
//
error_recover_point();
while (!quit) {
throw (event_poll (NULL, &poll_block, NULL));
}
exit (EXIT_SUCCESS);
}
/* Copyright 1998 Acorn Computers Ltd
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/****** MouseType.c *******************************************************\
Project: Ursula (RISC OS for Risc PC II)
Component: Mouse configuration plug-in
This file: Mouse driver routines
History:
Date Who Change
----------------------------------------------------------------------------
09/12/1997 BJGA Added these headers
\**************************************************************************/
/* Clib */
#include <stdio.h>
#include <string.h>
#include "swis.h"
/* Toolbox */
#include "wimplib.h"
/* Common */
#include "cmos.h"
#include "message.h"
/* Local headers */
#include "Main.h"
#include "MouseType.h" /* includes prototypes for this file */
#include "Settings.h"
/* Statics */
typedef struct pvr { struct pvr *next;
unsigned int flags;
unsigned char pointer_type;
char name [30]; } pointerv_record;
static pointerv_record *pointer_list = NULL;
static pointerv_record *get_pointer_list (void);
static void free_pointer_list (void);
/****** get_pointer_list() ************************************************\
Purpose: Tells each mouse driver to add a record to the PointerV
linked list; records are allocated from RMA
Out: Pointer to most recently-added record
\**************************************************************************/
static pointerv_record *get_pointer_list (void)
{
if (pointer_list != NULL) free_pointer_list ();
return pointer_list = (pointerv_record *) _swi (OS_CallAVector, _INR(0,1)|_IN(9)|_RETURN(1), 1, 0, 0x26);
}
/****** free_pointer_list() ***********************************************\
Purpose: Frees each record in the PointerV linked list from RMA
\**************************************************************************/
static void free_pointer_list (void)
{
while (pointer_list != NULL) {
pointerv_record *next = pointer_list->next;
_swi (OS_Module, _IN(0)|_IN(2), 7, (int) pointer_list);
pointer_list = next;
}
}
/* Externs */
/****** mousetype_getavailable() ******************************************\
Purpose: Builds a comma-separated list of available mouse drivers
In: Buffer to place result in (assumed large enough)
Out: CRC of result
\**************************************************************************/
int mousetype_getavailable (char *buffer)
{
pointerv_record *p = get_pointer_list ();
if (p == NULL) strcpy (buffer, message_lookup_direct(messages,"NoneAvail"));
while (p) {
strcat (buffer, p->name);
p = p->next;
if (p) strcat (buffer, ",");
}
free_pointer_list ();
return _swi (OS_CRC, _INR(0,3)|_RETURN(0), 0, (int) buffer, (int) buffer + strlen (buffer), 1);
}
/****** mousetype_get() ***************************************************\
Purpose: Reads the current / default mouse driver
In: Function to use to determine CMOS value
(cmos_get or cmos_default)
Out: Pointer to string from RMA
(has just been deallocated, so this is potentially dodgy)
or "Mystery" message token, if none match
\**************************************************************************/
char *mousetype_get (int(get)(cmos item, void *messages))
{
char *result = message_lookup_direct(messages,"Mystery");
pointerv_record *p = get_pointer_list ();
unsigned char cmosvalue = (unsigned char) get (MouseType, &messages);
while (p) {
if (p->pointer_type == cmosvalue) result = p->name;
p = p->next;
}
free_pointer_list ();
return result;
}
/****** mousetype_set() ***************************************************\
Purpose: Sets the current and configured mouse driver,
generating an warning if necessary
In: Pointer to string
Out: Pointer to string from RMA
(has just been deallocated, so this is potentially dodgy)
or "Mystery" message token, if none match
\**************************************************************************/
int mousetype_set (char *value)
{
pointerv_record *p = get_pointer_list ();
unsigned char newcmosvalue = 0xFF, oldcmosvalue = (unsigned char) cmos_read (MouseType, NULL);
while (p) {
if (strcmp (p->name, value) == 0) newcmosvalue = p->pointer_type;
p = p->next;
}
free_pointer_list ();
if ((newcmosvalue != oldcmosvalue) && (newcmosvalue != 0xFF)) {
_kernel_oserror e = { 0, "" };
int button;
sprintf (e.errmess, message_lookup_direct(messages,"NewType"), value);
button = wimp_report_error (&e,
Wimp_ReportError_OK | Wimp_ReportError_Cancel | 1u << 8 | 4u << 9,
message_lookup_direct(messages,"_TaskName"),
message_lookup_direct(messages,"_ConfigSprite"), (void *) 1, NULL);
if (button != 1) return 2; /* "Cancel" was clicked on error box */
cmos_write (MouseType, newcmosvalue);
}
_swi (OS_Pointer, _INR(0,1), 1, (int) newcmosvalue);
/* Performed unconditionally to compensate for OS_Pointer possibly having been called independently */
return 1; /* As though "Continue" were clicked on error box */
}
/* Copyright 1998 Acorn Computers Ltd
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/****** Settings.c ********************************************************\
Project: Ursula (RISC OS for Risc PC II)
Component: Mouse configuration plug-in
This file: GUI <-> settings routines
History:
Date Who Change
----------------------------------------------------------------------------
09/12/1997 BJGA Split from Main
Added these headers
15/01/1998 BJGA Adapted to use stored CMOS defaults
11/05/1998 BJGA Adapted for use with new Wimp CMOS usage
Activated autofronting on/off and time options
Added autoscroll pause time support
\**************************************************************************/
/* CLib */
#include <string.h>
#include "swis.h"
/* Toolbox */
#include "toolbox.h"
#include "window.h"
#include "gadgets.h"
/* Common */
#include "cmos.h"
#include "misc.h"
/* local headers */
#include "Main.h"
#include "MouseType.h"
#include "Settings.h" /* includes prototypes for this file */
#define mousespeed_slider_upperbound ((int) 9)
const cmos cmos_details [18] = { { 0xC2, 0, 8 }, /* MouseMultiplier */
{ 0x1D, 0, 8 }, /* MouseType */
{ 0xDD, 0, 4 }, /* (WimpDragDelay EOR 5) */
{ 0xDD, 4, 4 }, /* (WimpAutoScrollDelay EOR 5) */
{ 0xDE, 0, 1 }, /* WimpDragDelayUnit */
{ 0xDE, 1, 1 }, /* WimpAutoScrollDelayUnit */
{ 0xDE, 2, 5 }, /* (WimpDragMove/4 EOR 8) */
{ 0xDF, 0, 4 }, /* (WimpDoubleClickDelay EOR 10) */
{ 0xDF, 4, 4 }, /* (WimpAutoFrontDelay EOR 5) */
{ 0x16, 0, 1 }, /* WimpDoubleClickDelayUnit */
{ 0x16, 1, 1 }, /* WimpAutoFrontDelayUnit */
{ 0x16, 2, 5 }, /* (WimpDoubleClickMove/4 EOR 8) */
{ 0x16, 7, 1 }, /* WimpAutoFrontIconBar */
{ 0xC5, 7, 1 }, /* WimpFlagsSubMenus */
{ 0x17, 0, 4 }, /* (WimpAutoMenuDelay EOR 10) */
{ 0x17, 4, 1 }, /* WimpAutoMenuDelayUnit */
{ 0x1B, 0, 4 }, /* (WimpMenuDragDelay EOR 10) */
{ 0x1B, 4, 1 } }; /* WimpMenuDragDelayUnit */
/****** settings_read() ***************************************************\
Purpose: Reads current / default settings, reflect them in GUI
In: Routine to determine settings (cmos_read or cmos_default)
\**************************************************************************/
void settings_read (int(*get)(cmos item, void *messages))
{
int value;
//
value = get (MouseMultiplier, &messages);
if (value >= 0x80) value = 0x100-value; /* force positive */
value = max(value, 1); /* force in range */
value = min(value, mousespeed_slider_upperbound);
throw (slider_set_value (0, mainwindow_id, mainwindow_mousespeed, value));
//
throw (stringset_set_selected (0, mainwindow_id, mainwindow_mousetype, mousetype_get (get)));
//
value = get (WimpDragDelay, &messages) ^ 5;
if (1 == get (WimpDragDelayUnit, &messages)) value *= 10;
throw (numberrange_set_value (0, mainwindow_id, mainwindow_dragdelay, value));
//
value = (get (WimpDragMove, &messages) ^ 8) * 4;
throw (numberrange_set_value (0, mainwindow_id, mainwindow_dragdist, value));
//
value = get (WimpDoubleClickDelay, &messages) ^ 10;
if (1 == get (WimpDoubleClickDelayUnit, &messages)) value *= 10;
throw (numberrange_set_value (0, mainwindow_id, mainwindow_dclickdelay, value));
//
value = (get (WimpDoubleClickMove, &messages) ^ 8) * 4;
throw (numberrange_set_value (0, mainwindow_id, mainwindow_dclickdist, value));
//
value = get (WimpAutoScrollDelay, &messages) ^ 5;
if (1 == get (WimpAutoScrollDelayUnit, &messages)) value *= 10;
throw (numberrange_set_value (0, mainwindow_id, mainwindow_autoscr, value));
//
throw (optionbutton_set_state (0, mainwindow_id, mainwindow_openmenu, value = get (WimpFlagsSubMenus, &messages)));
misc_shadecomponents (!value, mainwindow_id, mainwindow_openmenu_shademin, mainwindow_openmenu_shademax);
value = get (WimpAutoMenuDelay, &messages) ^ 10;
if (1 == get (WimpAutoMenuDelayUnit, &messages)) value *= 10;
throw (numberrange_set_value (0, mainwindow_id, mainwindow_openmenudelay, value));
value = get (WimpMenuDragDelay, &messages) ^ 10;
if (1 == get (WimpMenuDragDelayUnit, &messages)) value *= 10;
throw (numberrange_set_value (0, mainwindow_id, mainwindow_closemenudelay, value));
//
throw (optionbutton_set_state (0, mainwindow_id, mainwindow_autofront, value = !get (WimpAutoFrontIconBar, &messages)));
misc_shadecomponents (!value, mainwindow_id, mainwindow_autofront_shademin, mainwindow_autofront_shademax);
value = get (WimpAutoFrontDelay, &messages) ^ 5;
if (1 == get (WimpAutoFrontDelayUnit, &messages)) value *= 10;
throw (numberrange_set_value (0, mainwindow_id, mainwindow_autofrontdelay, value));
//
}
/****** settings_write() **************************************************\
Purpose: Reads GUI, reflect in current and configured settings
Out: TRUE => operation performed successfully
(if user backs out of changing the mouse driver,
no other settings are made either)
\**************************************************************************/
BOOL settings_write (void)
{
int value;
char string [256];
unsigned char step [3];
//
throw (stringset_get_selected (0, mainwindow_id, mainwindow_mousetype, string, 256, NULL));
if (mousetype_set (string) == 2) return FALSE;
//
throw (slider_get_value (0, mainwindow_id, mainwindow_mousespeed, &value));
cmos_write (MouseMultiplier, value);
step[0] = 0x2u;
step[1] = (unsigned char) value;
step[2] = (unsigned char) value;
_swi (OS_Word, _INR(0,1), 21, step);
//
throw (numberrange_get_value (0, mainwindow_id, mainwindow_dragdelay, &value));
sprintf (string, "Configure WimpDragDelay %i", value);
_swi (OS_CLI, _IN(0), string);
throw (numberrange_get_value (0, mainwindow_id, mainwindow_dragdist, &value));
sprintf (string, "Configure WimpDragMove %i", value);
_swi (OS_CLI, _IN(0), string);
throw (numberrange_get_value (0, mainwindow_id, mainwindow_dclickdelay, &value));
sprintf (string, "Configure WimpDoubleClickDelay %i", value);
_swi (OS_CLI, _IN(0), string);
throw (numberrange_get_value (0, mainwindow_id, mainwindow_dclickdist, &value));
sprintf (string, "Configure WimpDoubleClickMove %i", value);
_swi (OS_CLI, _IN(0), string);
throw (numberrange_get_value (0, mainwindow_id, mainwindow_autoscr, &value));
sprintf (string, "Configure WimpAutoScrollDelay %i", value);
_swi (OS_CLI, _IN(0), string);
//
throw (optionbutton_get_state (0, mainwindow_id, mainwindow_openmenu, &value));
if (value) {
cmos_write (WimpFlagsSubMenus, TRUE);
misc_applywimpflags ();
throw (numberrange_get_value (0, mainwindow_id, mainwindow_openmenudelay, &value));
sprintf (string, "Configure WimpAutoMenuDelay %i", value);
_swi (OS_CLI, _IN(0), string);
throw (numberrange_get_value (0, mainwindow_id, mainwindow_closemenudelay, &value));
sprintf (string, "Configure WimpMenuDragDelay %i", value);
_swi (OS_CLI, _IN(0), string);
}
else {
cmos_write (WimpFlagsSubMenus, FALSE);
misc_applywimpflags ();
}
//
throw (optionbutton_get_state (0, mainwindow_id, mainwindow_autofront, &value));
if (value) {
_swi (OS_CLI, _IN(0), "Configure WimpAutoFrontIconBar On");
throw (numberrange_get_value (0, mainwindow_id, mainwindow_autofrontdelay, &value));
sprintf (string, "Configure WimpAutoFrontDelay %i", value);
_swi (OS_CLI, _IN(0), string);
}
else {
_swi (OS_CLI, _IN(0), "Configure WimpAutoFrontIconBar Off");
}
return TRUE;
}
/* Copyright 1998 Acorn Computers Ltd
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/****** ToolboxE.c ********************************************************\
Project: Ursula (RISC OS for Risc PC II)
Component: Mouse configuration plug-in
This file: Toolbox event code
History:
Date Who Change
----------------------------------------------------------------------------
09/12/1997 BJGA Split from Main
Added these headers
10/12/1997 BJGA Made handler routines static
\**************************************************************************/
/* Toolbox */
#include "event.h"
#include "toolbox.h"
#include "gadgets.h"
/* Common */
#include "cmos.h"
#include "misc.h"
/* local headers */
#include "Main.h"
#include "MouseType.h"
#include "Settings.h"
#include "ToolboxE.h" /* includes prototypes for this file */
static int toolboxe_actionbuttonselected (int event_code, ToolboxEvent *event, IdBlock *id_block, void *handle);
static int toolboxe_objectautocreated (int event_code, ToolboxEvent *event, IdBlock *id_block, void *handle);
static int toolboxe_optionbuttonstatechanged (int event_code, ToolboxEvent *event, IdBlock *id_block, void *handle);
static int toolboxe_stringsetabouttobeshown (int event_code, ToolboxEvent *event, IdBlock *id_block, void *handle);
int toolboxe_events [5] = { ActionButton_Selected,
Toolbox_ObjectAutoCreated,
OptionButton_StateChanged,
StringSet_AboutToBeShown,
0 };
void toolboxe_register (void)
{
throw (event_register_toolbox_handler (-1, ActionButton_Selected, toolboxe_actionbuttonselected, NULL));
throw (event_register_toolbox_handler (-1, Toolbox_ObjectAutoCreated, toolboxe_objectautocreated, NULL));
throw (event_register_toolbox_handler (-1, OptionButton_StateChanged, toolboxe_optionbuttonstatechanged, NULL));
throw (event_register_toolbox_handler (-1, StringSet_AboutToBeShown, toolboxe_stringsetabouttobeshown, NULL));
}
/****** toolboxe_actionbuttonselected() ***********************************\
Purpose: Handles ActionButton_Selected event
\**************************************************************************/
static int toolboxe_actionbuttonselected (int event_code, ToolboxEvent *event, IdBlock *id_block, void *handle)
{
switch (id_block->self_component) {
case mainwindow_default:
settings_read (cmos_default);
break;
case mainwindow_cancel:
if (!(event->hdr.flags & 1)) quit = TRUE;
else settings_read (cmos_read);
break;
case mainwindow_set:
if (settings_write ()) if (!(event->hdr.flags & 1)) quit = TRUE;
break;
}
return 1;
}
/****** toolboxe_objectautocreated() **************************************\
Purpose: Handles Toolbox_ObjectAutoCreated event
\**************************************************************************/
static int toolboxe_objectautocreated (int event_code, ToolboxEvent *event, IdBlock *id_block, void *handle)
{
mainwindow_id = id_block->self_id;
misc_openwindow (mainwindow_id, TRUE);
settings_read (cmos_read);
return 1;
}
/****** toolboxe_optionbuttonstatechanged() *******************************\
Purpose: Handles OptionButton_StateChanged event
\**************************************************************************/
static int toolboxe_optionbuttonstatechanged (int event_code, ToolboxEvent *event, IdBlock *id_block, void *handle)
{
if (id_block->self_component == mainwindow_openmenu)
misc_shadecomponents (!((OptionButtonStateChangedEvent *) event)->new_state,
mainwindow_id, mainwindow_openmenu_shademin, mainwindow_openmenu_shademax);
if (id_block->self_component == mainwindow_autofront)
misc_shadecomponents (!((OptionButtonStateChangedEvent *) event)->new_state,
mainwindow_id, mainwindow_autofront_shademin, mainwindow_autofront_shademax);
return 1;
}
/****** toolboxe_stringsetabouttobeshown() ********************************\
Purpose: Handles StringSet_AboutToBeShown event
\**************************************************************************/
static int toolboxe_stringsetabouttobeshown (int event_code, ToolboxEvent *event, IdBlock *id_block, void *handle)
{
static int crc = 0; /* crc stuff is to alleviate a memory leak in the toolbox when new available list is set */
int newcrc;
char buffer [256] = "";
if ((newcrc = mousetype_getavailable (buffer)) != crc) {
crc = newcrc;
throw (stringset_set_available (0, mainwindow_id, mainwindow_mousetype, buffer));
}
return 1;
}
/* Copyright 1998 Acorn Computers Ltd
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/****** WimpE.c ***********************************************************\
Project: Ursula (RISC OS for Risc PC II)
Component: Mouse configuration plug-in
This file: Wimp event code
History:
Date Who Change
----------------------------------------------------------------------------
09/12/1997 BJGA Split from Main
Added these headers
10/12/1997 BJGA Made handler routines static
\**************************************************************************/
/* Toolbox */
#include "event.h"
#include "wimplib.h"
#include "toolbox.h"
/* Common */
#include "misc.h"
/* local headers */
#include "WimpE.h" /* includes prototypes for this file */
static int wimpe_keypressed (int event_code, WimpPollBlock *event, IdBlock *id_block, void *handle);
int wimpe_mask = Wimp_Poll_NullMask +
Wimp_Poll_PointerLeavingWindowMask +
Wimp_Poll_PointerEnteringWindowMask +
Wimp_Poll_LoseCaretMask +
Wimp_Poll_GainCaretMask +
Wimp_Poll_PollWordNonZeroMask ;
void wimpe_register (void)
{
throw (event_register_wimp_handler (-1, Wimp_EKeyPressed, wimpe_keypressed, NULL));
}
/****** wimpe_keypressed() ************************************************\
Purpose: Handles Key_Pressed event
\**************************************************************************/
static int wimpe_keypressed (int event_code, WimpPollBlock *event, IdBlock *id_block, void *handle)
{
throw (wimp_process_key (event->key_pressed.key_code));
return 1;
}
/* Copyright 1998 Acorn Computers Ltd
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/****** WimpM.c ***********************************************************\
Project: Ursula (RISC OS for Risc PC II)
Component: Mouse configuration plug-in
This file: Wimp message code
History:
Date Who Change
----------------------------------------------------------------------------
09/12/1997 BJGA Split from Main
Added these headers
10/12/1997 BJGA Made handler routines static
\**************************************************************************/
/* Toolbox */
#include "event.h"
#include "toolbox.h"
/* Common */
#include "misc.h"
/* local headers */
#include "Main.h"
#include "WimpM.h" /* includes prototypes for this file */
static int wimpm_quit (WimpMessage *message, void *handle);
static int wimpm_openconfigwindow (WimpMessage *message, void *handle);
int wimpm_messages [2] = { Wimp_MOpenConfigWindow,
0 };
void wimpm_register (void)
{
throw (event_register_message_handler (Wimp_MQuit, wimpm_quit, NULL));
throw (event_register_message_handler (Wimp_MOpenConfigWindow, wimpm_openconfigwindow, NULL));
}
/****** wimpm_quit() ******************************************************\
Purpose: Handles Message_Quit
\**************************************************************************/
static int wimpm_quit (WimpMessage *message, void *handle)
{
quit = TRUE;
return 1;
}
/****** wimpm_openconfigwindow() ******************************************\
Purpose: Handles Message_OpenConfigWindow
\**************************************************************************/
static int wimpm_openconfigwindow (WimpMessage *message, void *handle)
{
misc_openwindow (mainwindow_id, FALSE);
return 1;
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment