Skip to content

Commit

Permalink
Initial import
Browse files Browse the repository at this point in the history
  • Loading branch information
threedeyes committed Dec 15, 2021
0 parents commit 5e08cf6
Show file tree
Hide file tree
Showing 23 changed files with 1,581 additions and 0 deletions.
33 changes: 33 additions & 0 deletions KeyCursor Installer.sh
@@ -0,0 +1,33 @@
#!/bin/sh
# Installer for the KeyCursor input_server add-on & preflet.

BASE_DIR=$(dirname "$0")
SETTINGS_FILE="KeyCursor"
SETTINGS_DIR="/boot/home/config/settings"
PREFS_DIR="/boot/preferences"
FILTER_ADDON_DIR="/boot/home/config/add-ons/input_server/filters"
DEVICE_ADDON_DIR="/boot/home/config/add-ons/input_server/devices"

cd "$BASE_DIR"

rm "$SETTINGS_DIR/$SETTINGS_FILE"
copyattr --data ./preflet/KeyCursor "$PREFS_DIR"
copyattr --data ./src/KeyCursor "$FILTER_ADDON_DIR"
ln -s "$FILTER_ADDON_DIR"/KeyCursor "$DEVICE_ADDON_DIR"

/system/servers/input_server -q
snooze 3s

/boot/home/config/be/Preferences
copyattr --data "$PREFS_DIR"/KeyCursor
ln -s "$PREFS_DIR"/KeyCursor /boot/home/config/be/Preferences

sync

ANWSER=$(alert --info "KeyCursor has been installed.
Do you want to configure KeyCursor now?." "Yes" "No")

if [ "$ANWSER" = "Yes" ]
then
"$PREFS_DIR"/KeyCursor &
fi
17 changes: 17 additions & 0 deletions KeyCursor Uninstaller.sh
@@ -0,0 +1,17 @@
#!/bin/sh

ANSWER=$(alert --info --modal "Uninstall KeyCursor? Sure?" "Yes" "No")
if [ "$ANSWER" == "Yes" ]
then
rm /boot/home/config/add-ons/input_server/filters/KeyCursor
rm /boot/home/config/add-ons/input_server/devices/KeyCursor

/system/servers/input_server -q

rm /boot/home/config/settings/KeyCursor
rm /boot/preferencess/KeyCursor
rm /boot/home/config/be/Preferences/KeyCursor

sleep 3s
alert "KeyCursor was removed."
fi
53 changes: 53 additions & 0 deletions Readme.txt
@@ -0,0 +1,53 @@
KeyCursor version 1.1
(original version) by Nathan Schrenk,
originally posted on BeBits by Eugenia Loli-Queru.
(this version) by Oscar Lesta <bipolar@softhome.net>.

What is this?
It's just an update to Nathan Schrenk's mighty KeyCursor input_server add-on.
Read his BeNewsLetter article to find more (included as article.txt).

This one does all what the original version did (let you simulate a mouse using the keyboard) plus:

- Now you have a little preferences app that allows you to:
- choose which keys will toggle KeyCursor On/Off
- configure the acceleration factor
- disable KeyCursor usage, so you don't turn it on by accident.

- PageUp and PageDown act as a vertical mouse wheel when KeyCursor its active.
Just try it on Net+, it gives you a smooth scroll effect, kinda. I find it very useful to read the BeBook, mouseless :-)

Basic usage:
Hit and release the toggle key(s) to activate KeyCursor, then use the arrow keys to move the cursor.

The space bar key acts as the primary button, and if you press SHIFT while "clicking" with the space key, you get a secondary button event.

Hit again the toggle key(s) to deactivate it.

How to (un) install it?
Use the provided installer/uninstaller.

What else do I need to know?
The Preflet only allows you to configure the "toggle-keys" and not the "click" or "move" keys. That's because the laters are just fine for me. The source code it's included, just in case you want to make it more complete.

Interaction with other input filters: works OK with InstantClick and TwoWheels (the ones I use). Your milleage will vary.

To build from sources, just type make at the shell, then use the install scripts.

As requested by previous mantainer, I'll let you know where to get the older versions:
Eugenia's version:
http://bezip.de/app/777/

Nathan's (original) version:
http://chaosdna.com/mirror/ftp.be.com/samples/input_server/KeyCursor.zip

Thanks to:
Nathan Schrenk - for the original version, quite handy when things go wrong with your input_server device hacking efforts.
Thomas Thiriez - I used part of his EasyMove input_server filter addon and prefs app.
OBOS devs - I used some bytes from their cvs too.
Eugenia - for transfering the app to me.

Newer versions, if any, will be available here: http://www.bebits.com/apps/1941/

---
Oscar, 16 April 2004.
62 changes: 62 additions & 0 deletions article.txt
@@ -0,0 +1,62 @@
Using a Keyboard as a Pointing Device
By Nathan Schrenk -- <nschrenk@be.com>


Have you ever tried to use a computer and found the mouse
cursor frozen when you moved the mouse around? This has
happened to me many times, perhaps because I've been doing
some maintenance on my computer and have forgotten to plug
the mouse in, or because I was using a keyboard/mouse/video
switchbox to control multiple computers with one keyboard
and mouse and the switchbox scewed up the synchronization
between the PS/2 mouse and the computer.

In these situations, I'd like to be able to control the cursor
so that I can continue to use the machine. Unfortunately many
programs aren't very usable without a mouse, among them
applications and system components included with BeOS. So when
the mouse stops working, I can't use the computer productively.
One obvious solution is to enable the keyboard to emulate a
mouse. One day, annoyed that BeOS did not provide a way to
emulate a pointing device with the keyboard, I wrote an Input
Server add-on named KeyCursor to do just that. You can
download the source code at <ftp://ftp.be.com/pub/samples
/input_server/KeyCursor.zip>. I think it works pretty well.

KeyCursor has two parts:a BInputServerFilter subclass that
watches the stream of keyboard events for the key presses
that move the cursor around and generate mouse clicks, and
a BInputServerDevice subclass that simulates a pointing
device by generating movement and button events. For more
information about how the Input Server works in general,
and how the BInputServerFilter and BInputServerDevice
classes work in particular, consult the Be Book's chapter
on the Input Server. <http://www-classic.be.com/documentation
/be_book/The%20Input%20Server/index.html>.

If you examine the source code to KeyCursor, you'll find
that the keys used to move the cursor and to generate button
clicks are hardcoded. The arrow keys control the cursor
and the space bar is used to click. Pressing the space bar
while holding the shift key simulates clicking with the
second mouse button. You can turn KeyCursor on and off by
pressing and releasing the Option key (sometimes known as
the Windows key). You'll know that it is activating or
deactivating when you hear the system beep. If you don't
like the default keys, you'll have to edit the code.

I realize that this isn't very user friendly, but I haven't
gotten around to making KeyCursor more configurable and
writing a preference panel for it. If you feel like making
KeyCursor easier to customize, I'd love to find an improved
version on BeBits some day. As long as I'm dreaming, I'd
like to see a version with a preference panel that allows
the user to select which keys to use for activating KeyCursor,
moving the cursor, simulating various button clicks, and
changing cursor speed or acceleration.

As with all code that Be has released under the Be Sample
Code License, you can take the KeyCursor source code and
modify it and redistribute your modified version as long as
you honor the few requirements of the license. I hope you
find KeyCursor useful for situations when you need it.
10 changes: 10 additions & 0 deletions makefile
@@ -0,0 +1,10 @@
# makefile for KeyCursor input Add-On / KeyCursor Preflet

SUBDIRS = \
preflet \
src

default .DEFAULT :
-@for f in $(SUBDIRS) ; do \
$(MAKE) -C $$f -f makefile $@; \
done
Binary file added preflet/KeyCursor
Binary file not shown.
Binary file added preflet/KeyCursor.rsrc
Binary file not shown.
46 changes: 46 additions & 0 deletions preflet/KeyCursorSettings.cpp
@@ -0,0 +1,46 @@
#include <Application.h>

#include "SettingsWin.h"

////////////////////////////////////////////////////////////////////////////////

class SettingsWin;

class SettingsApp : public BApplication
{
public:
SettingsApp();
~SettingsApp();
virtual void ReadyToRun();

private:
SettingsWin* win;
};

////////////////////////////////////////////////////////////////////////////////

SettingsApp::SettingsApp()
: BApplication("application/x-vnd.OscarL-KeyCursorSettings")
{
}

SettingsApp::~SettingsApp()
{
}

void SettingsApp::ReadyToRun()
{
win = new SettingsWin;
win->Show();
}

////////////////////////////////////////////////////////////////////////////////

int main()
{
(new SettingsApp)->Run();

return 0;
}

////////////////////////////////////////////////////////////////////////////////
118 changes: 118 additions & 0 deletions preflet/ModifierBox.cpp
@@ -0,0 +1,118 @@
#include "ModifierBox.h"
#include "ModifierView.h"

////////////////////////////////////////////////////////////////////////////////

const ModifierBox::MaskListType ModifierBox::ModifierList[]=
{
{B_SHIFT_KEY, "Shift"},
{B_CONTROL_KEY, "Control"},
{B_COMMAND_KEY, "Command"},
{B_OPTION_KEY, "Option"},
{B_MENU_KEY, "Menu"}
};

////////////////////////////////////////////////////////////////////////////////

ModifierBox::ModifierBox(BRect frame, const char* label, uint32 modifier,
uint32 button)
: BBox(frame),
fDefaultModifier(0)
{
if (label) SetLabel(label);

float right = 0;
float bottom;
BRect frame(10, 15, 10, 15);

fModifierViewList = new ModifierView*[5];

BFont f = be_plain_font;
float width = f.StringWidth("Command");
width += 20;

fModifierViewList[0] = new ModifierView(BRect(10, 15, 10 + width, 15), ModifierList[0].mask, ModifierList[0].label, ModifierList[0].mask & modifier, new BMessage(MODIFIER_CHANGED));
fModifierViewList[1] = new ModifierView(BRect(10, 35, 10 + width, 45), ModifierList[1].mask, ModifierList[1].label, ModifierList[1].mask & modifier, new BMessage(MODIFIER_CHANGED));
fModifierViewList[2] = new ModifierView(BRect(10, 55, 10 + width, 65), ModifierList[2].mask, ModifierList[2].label, ModifierList[2].mask & modifier, new BMessage(MODIFIER_CHANGED));
fModifierViewList[3] = new ModifierView(BRect(15 + width, 15, 75 + width, 15), ModifierList[3].mask, ModifierList[3].label, ModifierList[3].mask & modifier, new BMessage(MODIFIER_CHANGED));
fModifierViewList[4] = new ModifierView(BRect(15 + width, 35, 75 + width, 45), ModifierList[4].mask, ModifierList[4].label, ModifierList[4].mask & modifier, new BMessage(MODIFIER_CHANGED));

for (int32 i = 0; i < 5; i++)
{
fModifierViewList[i]->ResizeToPreferred();
AddChild(fModifierViewList[i]);

right = max_c(right, fModifierViewList[i]->Frame().right);
frame.OffsetTo(frame.left, fModifierViewList[i]->Frame().bottom + 5);
}

bottom = fModifierViewList[5 - 1]->Frame().bottom;
ResizeTo(right + 10, bottom + 30);
}

ModifierBox::~ModifierBox()
{
delete fModifierViewList;
}

void ModifierBox::MessageReceived(BMessage* message)
{
uint32 mask = 0;

switch(message->what)
{
case MODIFIER_CHANGED:
for (int32 i = 0; i < 5; i++)
mask |= fModifierViewList[i]->GetMask();
if (!mask)
{
mask = fDefaultModifier;
for (int32 i = 0; i < 5; i++)
fModifierViewList[i]->SetValue(ModifierList[i].mask & mask);
}
InvokeNotify(Message());
break;

default:
BBox::MessageReceived(message);
}
}

void ModifierBox::AttachedToWindow()
{
for (int32 i = 0; i < 5; i++)
fModifierViewList[i]->SetTarget(this);
}

////////////////////////////////////////////////////////////////////////////////

uint32 ModifierBox::GetModifierMask()
{
uint32 mask = 0;

for (int32 i = 0; i < 5; i++)
mask |= fModifierViewList[i]->GetMask();

return mask;
}

void ModifierBox::SetModifierMask(uint32 mask)
{
for (int32 i = 0; i < 5; i++)
fModifierViewList[i]->SetValue(ModifierList[i].mask & mask);
}

void ModifierBox::SetDefaultModifierMask(uint32 mask)
{
fDefaultModifier = mask;
}

void ModifierBox::SetEnabled(bool enabled)
{
for (int i = 0; i < 5; i++)
fModifierViewList[i]->SetEnabled(enabled);

fControlsEnabled = enabled;
}

////////////////////////////////////////////////////////////////////////////////
38 changes: 38 additions & 0 deletions preflet/ModifierBox.h
@@ -0,0 +1,38 @@
#include <Box.h>
#include <Invoker.h>

class ModifierView;

class ModifierBox : public BInvoker, public BBox
{
public:
ModifierBox(BRect frame, const char* label = 0, uint32 modifier = 0,
uint32 button = 0);
~ModifierBox();

virtual void MessageReceived(BMessage* message);
virtual void AttachedToWindow();

uint32 GetModifierMask();
void SetModifierMask(uint32 mask);
void SetDefaultModifierMask(uint32 mask);

bool IsEnabled() { return fControlsEnabled; };
void SetEnabled(bool enabled);
private:
struct MaskListType
{
uint32 mask;
char* label;
};

static const MaskListType ModifierList[];

ModifierView** fModifierViewList;

uint32 fDefaultModifier;

static const uint32 MODIFIER_CHANGED = 'modc';

bool fControlsEnabled;
};

0 comments on commit 5e08cf6

Please sign in to comment.