Connected Devices: Mouse, Touchpad and Keyboard
-Resolve some issues. -Added the connected devices code in the main window. -Replace BUTTON_DEFAULTS and BUTTON_REVERT with kMsgDefaults and kMsgRevert. Change-Id: I3b0c86fc581056859239df0fbf2c085b8d168136 Reviewed-on: https://review.haiku-os.org/c/haiku/+/1619 Reviewed-by: Adrien Destugues <[email protected]>
This commit is contained in:
committed by
Adrien Destugues
parent
262348afe7
commit
8272123ea5
@@ -61,6 +61,12 @@ InputApplication::MessageReceived(BMessage* message)
|
||||
fWindow->PostMessage(message);
|
||||
break;
|
||||
}
|
||||
case kMsgSliderrepeatrate:
|
||||
case kMsgSliderdelayrate:
|
||||
{
|
||||
fWindow->PostMessage(message);
|
||||
break;
|
||||
}
|
||||
default:
|
||||
BApplication::MessageReceived(message);
|
||||
}
|
||||
|
||||
@@ -25,9 +25,11 @@ const uint32 kMsgMouseType = 'PUmt';
|
||||
const uint32 kMsgMouseMap = 'PUmm';
|
||||
const uint32 kMsgMouseSpeed = 'SLms';
|
||||
const uint32 kMsgAccelerationFactor = 'SLma';
|
||||
const uint32 kMsgSelected = 'SMms';
|
||||
const uint32 kMsgAddToDeviceList = 'SAdl';
|
||||
const uint32 kMsgPointingDevices = 'MTss';
|
||||
const uint32 kMsgKeyboardButton = 'BKdr';
|
||||
const uint32 kMsgSliderrepeatrate = 'SLrr';
|
||||
const uint32 kMsgSliderdelayrate = 'SLdr';
|
||||
|
||||
const uint32 kMsgErrordetect = 'ERor';
|
||||
|
||||
const uint32 kBorderSpace = 10;
|
||||
const uint32 kItemSpace = 7;
|
||||
|
||||
@@ -12,6 +12,7 @@
|
||||
|
||||
#include <Catalog.h>
|
||||
#include <DateFormat.h>
|
||||
#include <Input.h>
|
||||
#include <LayoutBuilder.h>
|
||||
#include <ListView.h>
|
||||
#include <Locale.h>
|
||||
@@ -24,17 +25,6 @@
|
||||
#define B_TRANSLATION_CONTEXT "DeviceList"
|
||||
|
||||
|
||||
DeviceName::DeviceName(const char* item, int d)
|
||||
:
|
||||
BStringItem(item)
|
||||
{
|
||||
this->fDevice = d;
|
||||
}
|
||||
|
||||
DeviceName::~DeviceName()
|
||||
{
|
||||
}
|
||||
|
||||
DeviceListView::DeviceListView(const char* name)
|
||||
:
|
||||
BView(name, B_WILL_DRAW)
|
||||
@@ -47,8 +37,6 @@ DeviceListView::DeviceListView(const char* name)
|
||||
SetExplicitMinSize(BSize(160, B_SIZE_UNSET));
|
||||
SetExplicitMaxSize(BSize(B_SIZE_UNLIMITED, B_SIZE_UNSET));
|
||||
|
||||
fDeviceList->AddItem(new DeviceName("Mouse", 101));
|
||||
fDeviceList->AddItem(new DeviceName("Touchpad", 102));
|
||||
|
||||
BLayoutBuilder::Group<>(this, B_VERTICAL)
|
||||
.Add(fScrollView)
|
||||
|
||||
@@ -12,12 +12,12 @@
|
||||
|
||||
#include <ListView.h>
|
||||
#include <ListItem.h>
|
||||
#include <Message.h>
|
||||
#include <StringItem.h>
|
||||
#include <ScrollBar.h>
|
||||
#include <String.h>
|
||||
#include <ScrollView.h>
|
||||
#include <View.h>
|
||||
#include <Message.h>
|
||||
|
||||
#include "InputTouchpadPref.h"
|
||||
#include "MouseSettings.h"
|
||||
@@ -28,25 +28,15 @@ class TouchpadPref;
|
||||
class MouseSettings;
|
||||
|
||||
|
||||
class DeviceName : public BStringItem {
|
||||
public:
|
||||
DeviceName(const char* item, int d);
|
||||
virtual ~DeviceName();
|
||||
int WhichDevice() { return fDevice; };
|
||||
private:
|
||||
int fDevice;
|
||||
};
|
||||
|
||||
class DeviceListView: public BView {
|
||||
public:
|
||||
DeviceListView(const char *name);
|
||||
virtual ~DeviceListView();
|
||||
virtual void AttachedToWindow();
|
||||
BListView* fDeviceList;
|
||||
|
||||
private:
|
||||
BScrollView* fScrollView;
|
||||
BListView* fDeviceList;
|
||||
TouchpadPref fTouchpadPref;
|
||||
MouseSettings fMouseSettings;
|
||||
};
|
||||
|
||||
#endif // _INPUT_DEVICE_VIEW_H */
|
||||
|
||||
@@ -0,0 +1,152 @@
|
||||
/*
|
||||
* Copyright 2019, Haiku, Inc.
|
||||
* Distributed under the terms of the MIT License.
|
||||
*
|
||||
* Author:
|
||||
* Preetpal Kaur <[email protected]>
|
||||
*/
|
||||
|
||||
|
||||
#include "InputKeyboard.h"
|
||||
|
||||
#include <Box.h>
|
||||
#include <Button.h>
|
||||
#include <Catalog.h>
|
||||
#include <LayoutBuilder.h>
|
||||
#include <Locale.h>
|
||||
#include <Message.h>
|
||||
#include <SeparatorView.h>
|
||||
#include <Slider.h>
|
||||
#include <TextControl.h>
|
||||
|
||||
#include "InputConstants.h"
|
||||
#include "KeyboardView.h"
|
||||
|
||||
#undef B_TRANSLATION_CONTEXT
|
||||
#define B_TRANSLATION_CONTEXT "InputKeyboard"
|
||||
|
||||
InputKeyboard::InputKeyboard(BInputDevice* dev)
|
||||
:
|
||||
BView("InputKeyboard", B_WILL_DRAW)
|
||||
{
|
||||
// Add the main settings view
|
||||
fSettingsView = new KeyboardView();
|
||||
|
||||
// Add the "Default" button..
|
||||
fDefaultsButton = new BButton(B_TRANSLATE("Defaults"),
|
||||
new BMessage(kMsgDefaults));
|
||||
|
||||
// Add the "Revert" button...
|
||||
fRevertButton = new BButton(B_TRANSLATE("Revert"),
|
||||
new BMessage(kMsgRevert));
|
||||
fRevertButton->SetEnabled(false);
|
||||
|
||||
// Build the layout
|
||||
BLayoutBuilder::Group<>(this, B_VERTICAL)
|
||||
.AddGroup(B_HORIZONTAL)
|
||||
.SetInsets(B_USE_WINDOW_SPACING, B_USE_WINDOW_SPACING,
|
||||
B_USE_WINDOW_SPACING, 0)
|
||||
.Add(fSettingsView)
|
||||
.End()
|
||||
.Add(new BSeparatorView(B_HORIZONTAL))
|
||||
.AddGroup(B_HORIZONTAL)
|
||||
.SetInsets(B_USE_WINDOW_SPACING, 0, B_USE_WINDOW_SPACING,
|
||||
B_USE_WINDOW_SPACING)
|
||||
.Add(fDefaultsButton)
|
||||
.Add(fRevertButton)
|
||||
.End();
|
||||
|
||||
BSlider* slider = (BSlider* )FindView("key_repeat_rate");
|
||||
if (slider !=NULL)
|
||||
slider->SetValue(fSettings.KeyboardRepeatRate());
|
||||
|
||||
slider = (BSlider* )FindView("delay_until_key_repeat");
|
||||
if (slider !=NULL)
|
||||
slider->SetValue(fSettings.KeyboardRepeatDelay());
|
||||
|
||||
fDefaultsButton->SetEnabled(fSettings.IsDefaultable());
|
||||
}
|
||||
|
||||
void
|
||||
InputKeyboard::MessageReceived(BMessage* message)
|
||||
{
|
||||
BSlider* slider = NULL;
|
||||
|
||||
switch (message->what) {
|
||||
case kMsgDefaults:
|
||||
{
|
||||
fSettings.Defaults();
|
||||
|
||||
slider = (BSlider* )FindView("key_repeat_rate");
|
||||
if (slider !=NULL)
|
||||
slider->SetValue(fSettings.KeyboardRepeatRate());
|
||||
|
||||
slider = (BSlider* )FindView("delay_until_key_repeat");
|
||||
if (slider !=NULL)
|
||||
slider->SetValue(fSettings.KeyboardRepeatDelay());
|
||||
|
||||
fDefaultsButton->SetEnabled(false);
|
||||
|
||||
fRevertButton->SetEnabled(true);
|
||||
break;
|
||||
}
|
||||
case kMsgRevert:
|
||||
{
|
||||
fSettings.Revert();
|
||||
|
||||
slider = (BSlider* )FindView("key_repeat_rate");
|
||||
if (slider !=NULL)
|
||||
slider->SetValue(fSettings.KeyboardRepeatRate());
|
||||
|
||||
slider = (BSlider* )FindView("delay_until_key_repeat");
|
||||
if (slider !=NULL)
|
||||
slider->SetValue(fSettings.KeyboardRepeatDelay());
|
||||
|
||||
fDefaultsButton->SetEnabled(fSettings.IsDefaultable());
|
||||
|
||||
fRevertButton->SetEnabled(false);
|
||||
break;
|
||||
}
|
||||
case kMsgSliderrepeatrate:
|
||||
{
|
||||
int32 rate;
|
||||
if (message->FindInt32("be:value", &rate) != B_OK)
|
||||
break;
|
||||
fSettings.SetKeyboardRepeatRate(rate);
|
||||
|
||||
fDefaultsButton->SetEnabled(fSettings.IsDefaultable());
|
||||
|
||||
fRevertButton->SetEnabled(true);
|
||||
break;
|
||||
}
|
||||
case kMsgSliderdelayrate:
|
||||
{
|
||||
int32 delay;
|
||||
if (message->FindInt32("be:value", &delay) != B_OK)
|
||||
break;
|
||||
|
||||
// We need to look at the value from the slider and make it "jump"
|
||||
// to the next notch along. Setting the min and max values of the
|
||||
// slider to 1 and 4 doesn't work like the real Keyboard app.
|
||||
if (delay < 375000)
|
||||
delay = 250000;
|
||||
if (delay >= 375000 && delay < 625000)
|
||||
delay = 500000;
|
||||
if (delay >= 625000 && delay < 875000)
|
||||
delay = 750000;
|
||||
if (delay >= 875000)
|
||||
delay = 1000000;
|
||||
|
||||
fSettings.SetKeyboardRepeatDelay(delay);
|
||||
|
||||
slider = (BSlider* )FindView("delay_until_key_repeat");
|
||||
if (slider != NULL)
|
||||
slider->SetValue(delay);
|
||||
|
||||
fDefaultsButton->SetEnabled(fSettings.IsDefaultable());
|
||||
|
||||
fRevertButton->SetEnabled(true);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
/*
|
||||
* Copyright 2019, Haiku, Inc.
|
||||
* Distributed under the terms of the MIT License.
|
||||
*
|
||||
* Author:
|
||||
* Preetpal Kaur <[email protected]>
|
||||
*/
|
||||
|
||||
|
||||
#ifndef INPUT_KEYBOARD_H
|
||||
#define INPUT_KEYBOARD_H
|
||||
|
||||
#include <Button.h>
|
||||
#include <Window.h>
|
||||
|
||||
#include "InputDeviceView.h"
|
||||
#include "KeyboardSettings.h"
|
||||
#include "KeyboardView.h"
|
||||
|
||||
class DeviceListView;
|
||||
|
||||
class InputKeyboard : public BView
|
||||
{
|
||||
public:
|
||||
InputKeyboard(BInputDevice* dev);
|
||||
|
||||
void MessageReceived(BMessage* message);
|
||||
private:
|
||||
KeyboardView *fSettingsView;
|
||||
KeyboardSettings fSettings;
|
||||
BButton* fDefaultsButton;
|
||||
BButton* fRevertButton;
|
||||
};
|
||||
|
||||
#endif
|
||||
@@ -43,7 +43,7 @@ static const int32 kDefaultAccelerationFactor = 65536;
|
||||
static const bool kDefaultAcceptFirstClick = false;
|
||||
|
||||
|
||||
InputMouse::InputMouse()
|
||||
InputMouse::InputMouse(BInputDevice* dev)
|
||||
: BView("InputMouse", B_WILL_DRAW)
|
||||
{
|
||||
fSettingsView = new SettingsView(fSettings);
|
||||
|
||||
@@ -22,19 +22,19 @@
|
||||
#include <TabView.h>
|
||||
#include <View.h>
|
||||
|
||||
#include "InputWindow.h"
|
||||
#include "InputDeviceView.h"
|
||||
#include "MouseSettings.h"
|
||||
#include "MouseView.h"
|
||||
#include "SettingsView.h"
|
||||
|
||||
#define MOUSE_SETTINGS 'Mss'
|
||||
|
||||
class DeviceListView;
|
||||
|
||||
class BTabView;
|
||||
|
||||
class InputMouse : public BView {
|
||||
public:
|
||||
InputMouse();
|
||||
InputMouse(BInputDevice* dev);
|
||||
virtual ~InputMouse();
|
||||
void SetMouseType(int32 type);
|
||||
void MessageReceived(BMessage* message);
|
||||
|
||||
@@ -19,13 +19,10 @@
|
||||
|
||||
TouchpadPref::TouchpadPref()
|
||||
{
|
||||
fConnected = false;
|
||||
// default center position
|
||||
fWindowPosition.x = -1;
|
||||
fWindowPosition.y = -1;
|
||||
|
||||
ConnectToTouchPad();
|
||||
|
||||
if (LoadSettings() != B_OK)
|
||||
Defaults();
|
||||
|
||||
@@ -35,8 +32,7 @@ TouchpadPref::TouchpadPref()
|
||||
|
||||
TouchpadPref::~TouchpadPref()
|
||||
{
|
||||
if (fConnected)
|
||||
delete fTouchPad;
|
||||
delete fTouchPad;
|
||||
|
||||
SaveSettings();
|
||||
}
|
||||
@@ -52,11 +48,6 @@ TouchpadPref::Revert()
|
||||
status_t
|
||||
TouchpadPref::UpdateSettings()
|
||||
{
|
||||
if (!fConnected)
|
||||
return B_ERROR;
|
||||
|
||||
LOG("UpdateSettings of device %s\n", fTouchPad->Name());
|
||||
|
||||
BMessage msg;
|
||||
msg.AddBool("scroll_twofinger", fSettings.scroll_twofinger);
|
||||
msg.AddBool("scroll_twofinger_horizontal",
|
||||
@@ -145,42 +136,4 @@ TouchpadPref::SaveSettings()
|
||||
}
|
||||
|
||||
return B_OK;
|
||||
}
|
||||
|
||||
|
||||
status_t
|
||||
TouchpadPref::ConnectToTouchPad()
|
||||
{
|
||||
BList devList;
|
||||
status_t status = get_input_devices(&devList);
|
||||
if (status != B_OK)
|
||||
return status;
|
||||
|
||||
int32 i = 0;
|
||||
while (true) {
|
||||
BInputDevice* dev = (BInputDevice*)devList.ItemAt(i);
|
||||
if (dev == NULL)
|
||||
break;
|
||||
i++;
|
||||
|
||||
LOG("input device %s\n", dev->Name());
|
||||
|
||||
BString name = dev->Name();
|
||||
|
||||
if (name.FindFirst("Touchpad") >= 0
|
||||
&& dev->Type() == B_POINTING_DEVICE
|
||||
&& !fConnected) {
|
||||
fConnected = true;
|
||||
fTouchPad = dev;
|
||||
// Don't bail out here, since we need to delete the other devices
|
||||
// yet.
|
||||
} else {
|
||||
delete dev;
|
||||
}
|
||||
}
|
||||
if (fConnected)
|
||||
return B_OK;
|
||||
|
||||
LOG("touchpad input device NOT found\n");
|
||||
return B_ENTRY_NOT_FOUND;
|
||||
}
|
||||
@@ -17,6 +17,7 @@
|
||||
#include <Input.h>
|
||||
#include <Path.h>
|
||||
|
||||
|
||||
#if DEBUG
|
||||
# define LOG(text...) PRINT((text))
|
||||
#else
|
||||
@@ -27,7 +28,7 @@
|
||||
class TouchpadPref {
|
||||
public:
|
||||
TouchpadPref();
|
||||
~TouchpadPref();
|
||||
virtual ~TouchpadPref();
|
||||
|
||||
void Revert();
|
||||
void Defaults();
|
||||
@@ -39,8 +40,6 @@ public:
|
||||
|
||||
touchpad_settings& Settings()
|
||||
{ return fSettings; }
|
||||
bool IsTouchpadConnected()
|
||||
{ return fConnected; }
|
||||
status_t UpdateSettings();
|
||||
|
||||
private:
|
||||
@@ -48,9 +47,6 @@ private:
|
||||
status_t LoadSettings();
|
||||
status_t SaveSettings();
|
||||
|
||||
status_t ConnectToTouchPad();
|
||||
|
||||
bool fConnected;
|
||||
BInputDevice* fTouchPad;
|
||||
|
||||
touchpad_settings fSettings;
|
||||
@@ -59,4 +55,4 @@ private:
|
||||
};
|
||||
|
||||
|
||||
#endif // TOUCHPAD_PREF_H
|
||||
#endif // TOUCHPAD_PREF_H
|
||||
@@ -264,20 +264,13 @@ TouchpadView::DrawSliders()
|
||||
// #pragma mark - TouchpadPrefView
|
||||
|
||||
|
||||
TouchpadPrefView::TouchpadPrefView(const char* name)
|
||||
TouchpadPrefView::TouchpadPrefView(BInputDevice* dev)
|
||||
:
|
||||
BGroupView(name)
|
||||
BGroupView()
|
||||
{
|
||||
SetupView();
|
||||
// set view values
|
||||
SetValues(&fTouchpadPref.Settings());
|
||||
if (fTouchpadPref.IsTouchpadConnected() == false) {
|
||||
DisablePref();
|
||||
fShowWarning->SetText(B_TRANSLATE("No touchpad found, the settings "
|
||||
"will have no effect."));
|
||||
}
|
||||
else
|
||||
fShowWarning->Hide();
|
||||
}
|
||||
|
||||
|
||||
@@ -372,6 +365,7 @@ TouchpadPrefView::SetupView()
|
||||
BBox* scrollBox = new BBox("Touchpad");
|
||||
scrollBox->SetLabel(B_TRANSLATE("Scrolling"));
|
||||
|
||||
|
||||
fTouchpadView = new TouchpadView(BRect(0, 0, 130, 120));
|
||||
fTouchpadView->SetExplicitMaxSize(BSize(130, 120));
|
||||
|
||||
@@ -461,11 +455,9 @@ TouchpadPrefView::SetupView()
|
||||
new BMessage(REVERT_SETTINGS));
|
||||
fRevertButton->SetEnabled(false);
|
||||
|
||||
fShowWarning = new BStringView("warning", "");
|
||||
|
||||
BLayoutBuilder::Group<>(this, B_VERTICAL)
|
||||
.SetInsets(B_USE_WINDOW_SPACING)
|
||||
.Add(fShowWarning)
|
||||
.Add(scrollBox)
|
||||
.Add(tapBox)
|
||||
.Add(new BSeparatorView(B_HORIZONTAL))
|
||||
@@ -492,16 +484,4 @@ TouchpadPrefView::SetValues(touchpad_settings* settings)
|
||||
fScrollStepYSlider->SetValue(20 - settings->scroll_ystepsize / 2);
|
||||
fScrollAccelSlider->SetValue(settings->scroll_acceleration);
|
||||
fTapSlider->SetValue(settings->tapgesture_sensibility);
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
TouchpadPrefView::DisablePref()
|
||||
{
|
||||
fTwoFingerBox->SetEnabled(false);
|
||||
fTwoFingerHorizontalBox->SetEnabled(false);
|
||||
fTapSlider->SetEnabled(false);
|
||||
fScrollAccelSlider->SetEnabled(false);
|
||||
fScrollStepXSlider->SetEnabled(false);
|
||||
fScrollStepYSlider->SetEnabled(false);
|
||||
}
|
||||
@@ -36,6 +36,8 @@ const uint TAP_CONTROL_CHANGED = '&tcc';
|
||||
const uint DEFAULT_SETTINGS = '&dse';
|
||||
const uint REVERT_SETTINGS = '&rse';
|
||||
|
||||
class DeviceListView;
|
||||
|
||||
|
||||
//! Shows a touchpad
|
||||
class TouchpadView : public BView, public BInvoker {
|
||||
@@ -78,7 +80,7 @@ private:
|
||||
|
||||
class TouchpadPrefView : public BGroupView {
|
||||
public:
|
||||
TouchpadPrefView(const char* name);
|
||||
TouchpadPrefView(BInputDevice* dev);
|
||||
virtual ~TouchpadPrefView();
|
||||
virtual void MessageReceived(BMessage* message);
|
||||
virtual void AttachedToWindow();
|
||||
@@ -86,11 +88,8 @@ public:
|
||||
void SetupView();
|
||||
|
||||
void SetValues(touchpad_settings *settings);
|
||||
TouchpadPref fTouchpadPref;
|
||||
|
||||
private:
|
||||
void DisablePref();
|
||||
|
||||
TouchpadPref fTouchpadPref;
|
||||
TouchpadView* fTouchpadView;
|
||||
BCheckBox* fTwoFingerBox;
|
||||
BCheckBox* fTwoFingerHorizontalBox;
|
||||
@@ -100,7 +99,6 @@ private:
|
||||
BSlider* fTapSlider;
|
||||
BButton* fDefaultButton;
|
||||
BButton* fRevertButton;
|
||||
BStringView* fShowWarning;
|
||||
};
|
||||
|
||||
#endif // TOUCHPAD_PREF_VIEW_H
|
||||
@@ -19,16 +19,16 @@
|
||||
#include <LayoutBuilder.h>
|
||||
#include <SplitView.h>
|
||||
#include <Screen.h>
|
||||
#include <TabView.h>
|
||||
#include <stdio.h>
|
||||
|
||||
|
||||
#include "InputConstants.h"
|
||||
#include "InputDeviceView.h"
|
||||
#include "InputMouse.h"
|
||||
#include "InputTouchpadPref.h"
|
||||
#include "InputWindow.h"
|
||||
#include "MouseSettings.h"
|
||||
#include "InputMouse.h"
|
||||
#include "InputConstants.h"
|
||||
#include "SettingsView.h"
|
||||
#include "InputTouchpadPref.h"
|
||||
|
||||
#undef B_TRANSLATION_CONTEXT
|
||||
#define B_TRANSLATION_CONTEXT "InputWindow"
|
||||
@@ -40,13 +40,7 @@ InputWindow::InputWindow(BRect rect)
|
||||
B_NOT_RESIZABLE | B_NOT_ZOOMABLE | B_ASYNCHRONOUS_CONTROLS
|
||||
| B_AUTO_UPDATE_SIZE_LIMITS | B_QUIT_ON_WINDOW_CLOSE)
|
||||
{
|
||||
fInputMouse = new InputMouse();
|
||||
fTouchpadPrefView = new TouchpadPrefView(B_TRANSLATE("Touchpad"));
|
||||
fDeviceListView = new DeviceListView(B_TRANSLATE("Device List"));
|
||||
|
||||
fCardView = new BCardView();
|
||||
fCardView->AddChild(fInputMouse);
|
||||
fCardView->AddChild(fTouchpadPrefView);
|
||||
FindDevice();
|
||||
|
||||
BLayoutBuilder::Group<>(this, B_HORIZONTAL, 10)
|
||||
.SetInsets(B_USE_WINDOW_SPACING)
|
||||
@@ -78,7 +72,8 @@ InputWindow::MessageReceived(BMessage* message)
|
||||
case kMsgDefaults:
|
||||
case kMsgRevert:
|
||||
{
|
||||
PostMessage(message, fInputMouse);
|
||||
PostMessage(message,
|
||||
fCardView->CardLayout()->VisibleItem()->View());
|
||||
break;
|
||||
}
|
||||
case SCROLL_AREA_CHANGED:
|
||||
@@ -87,7 +82,15 @@ InputWindow::MessageReceived(BMessage* message)
|
||||
case DEFAULT_SETTINGS:
|
||||
case REVERT_SETTINGS:
|
||||
{
|
||||
PostMessage(message, fTouchpadPrefView);
|
||||
PostMessage(message,
|
||||
fCardView->CardLayout()->VisibleItem()->View());
|
||||
break;
|
||||
}
|
||||
case kMsgSliderrepeatrate:
|
||||
case kMsgSliderdelayrate:
|
||||
{
|
||||
PostMessage(message,
|
||||
fCardView->CardLayout()->VisibleItem()->View());
|
||||
break;
|
||||
}
|
||||
default:
|
||||
@@ -95,3 +98,51 @@ InputWindow::MessageReceived(BMessage* message)
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
status_t
|
||||
InputWindow::FindDevice()
|
||||
{
|
||||
BList devList;
|
||||
status_t status = get_input_devices(&devList);
|
||||
if (status != B_OK)
|
||||
return status;
|
||||
|
||||
int32 i = 0;
|
||||
|
||||
fDeviceListView = new DeviceListView(B_TRANSLATE("Device List"));
|
||||
fCardView = new BCardView();
|
||||
|
||||
while (true) {
|
||||
BInputDevice* dev = (BInputDevice*)devList.ItemAt(i);
|
||||
if (dev == NULL) {
|
||||
break;
|
||||
}
|
||||
i++;
|
||||
|
||||
BString name = dev->Name();
|
||||
|
||||
if (dev->Type() == B_POINTING_DEVICE
|
||||
&& name.FindFirst("Touchpad") >= 0) {
|
||||
|
||||
fTouchPad = dev;
|
||||
TouchpadPrefView* view = new TouchpadPrefView(dev);
|
||||
fCardView->AddChild(view);
|
||||
fDeviceListView->fDeviceList->AddItem(new BStringItem(name));
|
||||
} else if (dev->Type() == B_POINTING_DEVICE) {
|
||||
|
||||
fMouse = dev;
|
||||
InputMouse* view = new InputMouse(dev);
|
||||
fCardView->AddChild(view);
|
||||
fDeviceListView->fDeviceList->AddItem(new BStringItem(name));
|
||||
} else if (dev->Type() == B_KEYBOARD_DEVICE) {
|
||||
|
||||
fKeyboard = dev;
|
||||
InputKeyboard* view = new InputKeyboard(dev);
|
||||
fCardView->AddChild(view);
|
||||
fDeviceListView->fDeviceList->AddItem(new BStringItem(name));
|
||||
} else {
|
||||
delete dev;
|
||||
}
|
||||
}
|
||||
return B_ENTRY_NOT_FOUND;
|
||||
}
|
||||
|
||||
@@ -10,18 +10,21 @@
|
||||
#ifndef INPUT_WINDOW_H
|
||||
#define INPUT_WINDOW_H
|
||||
|
||||
#include <Window.h>
|
||||
#include <View.h>
|
||||
|
||||
#include <Box.h>
|
||||
#include <CardView.h>
|
||||
#include <Input.h>
|
||||
#include <ListItem.h>
|
||||
#include <ListView.h>
|
||||
#include <Message.h>
|
||||
#include <ScrollBar.h>
|
||||
#include <ScrollView.h>
|
||||
#include <SeparatorView.h>
|
||||
#include <Box.h>
|
||||
#include <CardView.h>
|
||||
#include <Message.h>
|
||||
#include <View.h>
|
||||
#include <Window.h>
|
||||
|
||||
#include "InputDeviceView.h"
|
||||
#include "InputKeyboard.h"
|
||||
#include "InputMouse.h"
|
||||
#include "InputTouchpadPrefView.h"
|
||||
#include "MouseSettings.h"
|
||||
@@ -34,11 +37,12 @@ class BCardLayout;
|
||||
|
||||
class SettingsView;
|
||||
class DeviceName;
|
||||
class InputDevices;
|
||||
class InputKeyboard;
|
||||
class InputMouse;
|
||||
class TouchpadPrefView;
|
||||
class TouchpadPref;
|
||||
class TouchpadView;
|
||||
class InputDevices;
|
||||
class InputMouse;
|
||||
|
||||
|
||||
class InputWindow : public BWindow
|
||||
@@ -46,14 +50,16 @@ class InputWindow : public BWindow
|
||||
public:
|
||||
InputWindow(BRect rect);
|
||||
void MessageReceived(BMessage* message);
|
||||
status_t FindDevice();
|
||||
private:
|
||||
|
||||
DeviceListView* fDeviceListView;
|
||||
BCardView* fCardView;
|
||||
MouseSettings fSettings;
|
||||
SettingsView* fSettingsView;
|
||||
InputMouse* fInputMouse;
|
||||
TouchpadPrefView* fTouchpadPrefView;
|
||||
TouchpadPref* fTouchpadPref;
|
||||
BInputDevice* fKeyboard;
|
||||
BInputDevice* fMouse;
|
||||
BInputDevice* fTouchPad;
|
||||
};
|
||||
|
||||
#endif /* INPUT_WINDOW_H */
|
||||
|
||||
@@ -5,10 +5,13 @@ UsePrivateHeaders input ;
|
||||
Preference Input :
|
||||
Input.cpp
|
||||
InputDeviceView.cpp
|
||||
InputKeyboard.cpp
|
||||
InputMouse.cpp
|
||||
InputTouchpadPref.cpp
|
||||
InputTouchpadPrefView.cpp
|
||||
InputWindow.cpp
|
||||
KeyboardSettings.cpp
|
||||
KeyboardView.cpp
|
||||
MouseView.cpp
|
||||
MouseSettings.cpp
|
||||
SettingsView.cpp
|
||||
@@ -23,6 +26,8 @@ DoCatalogs Input :
|
||||
InputTouchpadPref.cpp
|
||||
InputTouchpadPrefView.cpp
|
||||
InputWindow.cpp
|
||||
KeyboardSettings.cpp
|
||||
KeyboardView.cpp
|
||||
MouseView.cpp
|
||||
MouseSettings.cpp
|
||||
SettingsView.cpp
|
||||
|
||||
@@ -0,0 +1,97 @@
|
||||
/*
|
||||
* Copyright 2004-2006, the Haiku project. All rights reserved.
|
||||
* Distributed under the terms of the Haiku License.
|
||||
*
|
||||
* Authors in chronological order:
|
||||
* [email protected]
|
||||
* Jérôme Duval
|
||||
* Marcus Overhagen
|
||||
*/
|
||||
|
||||
|
||||
#include "KeyboardSettings.h"
|
||||
|
||||
#include <FindDirectory.h>
|
||||
#include <File.h>
|
||||
#include <Path.h>
|
||||
#include <stdio.h>
|
||||
|
||||
|
||||
KeyboardSettings::KeyboardSettings()
|
||||
{
|
||||
if (get_key_repeat_rate(&fSettings.key_repeat_rate) != B_OK)
|
||||
fSettings.key_repeat_rate = kb_default_key_repeat_rate;
|
||||
|
||||
if (get_key_repeat_delay(&fSettings.key_repeat_delay) != B_OK)
|
||||
fSettings.key_repeat_delay = kb_default_key_repeat_delay;
|
||||
|
||||
fOriginalSettings = fSettings;
|
||||
|
||||
BPath path;
|
||||
BFile file;
|
||||
|
||||
status_t status = find_directory(B_USER_SETTINGS_DIRECTORY, &path);
|
||||
if (status == B_OK) {
|
||||
status = path.Append(kb_settings_file);
|
||||
if (status == B_OK) {
|
||||
status = file.SetTo(path.Path(), B_READ_ONLY);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
KeyboardSettings::~KeyboardSettings()
|
||||
{
|
||||
BPath path;
|
||||
BFile file;
|
||||
|
||||
if (find_directory(B_USER_SETTINGS_DIRECTORY, &path) < B_OK)
|
||||
return;
|
||||
|
||||
if (path.Append(kb_settings_file) < B_OK)
|
||||
return;
|
||||
|
||||
// be careful: don't create the file if it doesn't already exist
|
||||
if (file.SetTo(path.Path(), B_WRITE_ONLY) < B_OK)
|
||||
return;
|
||||
}
|
||||
|
||||
void
|
||||
KeyboardSettings::SetKeyboardRepeatRate(int32 rate)
|
||||
{
|
||||
if (set_key_repeat_rate(rate) != B_OK)
|
||||
fprintf(stderr, "error while set_key_repeat_rate!\n");
|
||||
fSettings.key_repeat_rate = rate;
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
KeyboardSettings::SetKeyboardRepeatDelay(bigtime_t delay)
|
||||
{
|
||||
if (set_key_repeat_delay(delay) != B_OK)
|
||||
fprintf(stderr, "error while set_key_repeat_delay!\n");
|
||||
fSettings.key_repeat_delay = delay;
|
||||
}
|
||||
|
||||
void
|
||||
KeyboardSettings::Revert()
|
||||
{
|
||||
SetKeyboardRepeatDelay(fOriginalSettings.key_repeat_delay);
|
||||
SetKeyboardRepeatRate(fOriginalSettings.key_repeat_rate);
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
KeyboardSettings::Defaults()
|
||||
{
|
||||
SetKeyboardRepeatDelay(kb_default_key_repeat_delay);
|
||||
SetKeyboardRepeatRate(kb_default_key_repeat_rate);
|
||||
}
|
||||
|
||||
|
||||
bool
|
||||
KeyboardSettings::IsDefaultable()
|
||||
{
|
||||
return fSettings.key_repeat_delay != kb_default_key_repeat_delay
|
||||
|| fSettings.key_repeat_rate != kb_default_key_repeat_rate;
|
||||
}
|
||||
@@ -0,0 +1,40 @@
|
||||
/*
|
||||
* Copyright 2004-2006, the Haiku project. All rights reserved.
|
||||
* Distributed under the terms of the Haiku License.
|
||||
*
|
||||
* Authors in chronological order:
|
||||
* [email protected]
|
||||
* Jérôme Duval
|
||||
* Marcus Overhagen
|
||||
*/
|
||||
|
||||
|
||||
#ifndef KEYBOARD_SETTINGS_H_
|
||||
#define KEYBOARD_SETTINGS_H_
|
||||
|
||||
#include <SupportDefs.h>
|
||||
#include "kb_mouse_settings.h"
|
||||
|
||||
class KeyboardSettings{
|
||||
public :
|
||||
KeyboardSettings();
|
||||
~KeyboardSettings();
|
||||
|
||||
void Revert();
|
||||
void Defaults();
|
||||
bool IsDefaultable();
|
||||
|
||||
int32 KeyboardRepeatRate() const
|
||||
{ return fSettings.key_repeat_rate; }
|
||||
void SetKeyboardRepeatRate(int32 rate);
|
||||
|
||||
bigtime_t KeyboardRepeatDelay() const
|
||||
{ return fSettings.key_repeat_delay; }
|
||||
void SetKeyboardRepeatDelay(bigtime_t delay);
|
||||
|
||||
private:
|
||||
kb_settings fSettings;
|
||||
kb_settings fOriginalSettings;
|
||||
};
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,93 @@
|
||||
/*
|
||||
* Copyright 2004-2006, the Haiku project. All rights reserved.
|
||||
* Distributed under the terms of the Haiku License.
|
||||
*
|
||||
* Authors in chronological order:
|
||||
* [email protected]
|
||||
* Jérôme Duval
|
||||
* Marcus Overhagen
|
||||
*/
|
||||
|
||||
|
||||
#include "KeyboardView.h"
|
||||
|
||||
#include <InterfaceDefs.h>
|
||||
#include <Bitmap.h>
|
||||
#include <Button.h>
|
||||
#include <Catalog.h>
|
||||
#include <LayoutBuilder.h>
|
||||
#include <Locale.h>
|
||||
#include <Slider.h>
|
||||
#include <TextControl.h>
|
||||
#include <Window.h>
|
||||
|
||||
#include "InputConstants.h"
|
||||
#include "KeyboardSettings.h"
|
||||
|
||||
#undef B_TRANSLATION_CONTEXT
|
||||
#define B_TRANSLATION_CONTEXT "KeyboardView"
|
||||
|
||||
KeyboardView::KeyboardView()
|
||||
: BGroupView()
|
||||
{
|
||||
// Create the "Key repeat rate" slider...
|
||||
fRepeatSlider = new BSlider("key_repeat_rate",
|
||||
B_TRANSLATE("Key repeat rate"),
|
||||
new BMessage(kMsgSliderrepeatrate),
|
||||
20, 300, B_HORIZONTAL);
|
||||
fRepeatSlider->SetHashMarks(B_HASH_MARKS_BOTTOM);
|
||||
fRepeatSlider->SetHashMarkCount(5);
|
||||
fRepeatSlider->SetLimitLabels(B_TRANSLATE("Slow"),B_TRANSLATE("Fast"));
|
||||
fRepeatSlider->SetExplicitMinSize(BSize(200, B_SIZE_UNSET));
|
||||
|
||||
|
||||
// Create the "Delay until key repeat" slider...
|
||||
fDelaySlider = new BSlider("delay_until_key_repeat",
|
||||
B_TRANSLATE("Delay until key repeat"),
|
||||
new BMessage(kMsgSliderdelayrate),
|
||||
250000, 1000000, B_HORIZONTAL);
|
||||
fDelaySlider->SetHashMarks(B_HASH_MARKS_BOTTOM);
|
||||
fDelaySlider->SetHashMarkCount(4);
|
||||
fDelaySlider->SetLimitLabels(B_TRANSLATE("Short"),B_TRANSLATE("Long"));
|
||||
|
||||
// Create the "Typing test area" text box...
|
||||
BTextControl* textcontrol = new BTextControl(NULL,
|
||||
B_TRANSLATE("Typing test area"),
|
||||
new BMessage('TTEA'));
|
||||
textcontrol->SetAlignment(B_ALIGN_LEFT, B_ALIGN_CENTER);
|
||||
textcontrol->SetExplicitMinSize(BSize(
|
||||
textcontrol->StringWidth(B_TRANSLATE("Typing test area")), B_SIZE_UNSET));
|
||||
|
||||
// Build the layout
|
||||
BLayoutBuilder::Group<>(this, B_VERTICAL, B_USE_DEFAULT_SPACING)
|
||||
.Add(fRepeatSlider)
|
||||
.Add(fDelaySlider)
|
||||
.Add(textcontrol)
|
||||
.AddGlue();
|
||||
}
|
||||
|
||||
|
||||
KeyboardView::~KeyboardView()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
KeyboardView::Draw(BRect updateFrame)
|
||||
{
|
||||
BPoint pt;
|
||||
pt.x = fRepeatSlider->Frame().right + 10;
|
||||
|
||||
if (fIconBitmap != NULL) {
|
||||
pt.y = fRepeatSlider->Frame().bottom - 35
|
||||
- fIconBitmap->Bounds().Height() / 3;
|
||||
DrawBitmap(fIconBitmap, pt);
|
||||
}
|
||||
|
||||
if (fClockBitmap != NULL) {
|
||||
pt.y = fDelaySlider->Frame().bottom - 35
|
||||
- fClockBitmap->Bounds().Height() / 3;
|
||||
DrawBitmap(fClockBitmap, pt);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,37 @@
|
||||
/*
|
||||
* Copyright 2004-2006, the Haiku project. All rights reserved.
|
||||
* Distributed under the terms of the Haiku License.
|
||||
*
|
||||
* Authors in chronological order:
|
||||
* [email protected]
|
||||
* Jérôme Duval
|
||||
* Marcus Overhagen
|
||||
*/
|
||||
|
||||
|
||||
#ifndef KEYBOARD_VIEW_H
|
||||
#define KEYBOARD_VIEW_H
|
||||
|
||||
|
||||
#include <GroupView.h>
|
||||
#include <Slider.h>
|
||||
#include <SupportDefs.h>
|
||||
#include <InterfaceDefs.h>
|
||||
#include <Application.h>
|
||||
|
||||
|
||||
class KeyboardView : public BGroupView
|
||||
{
|
||||
public:
|
||||
KeyboardView();
|
||||
virtual ~KeyboardView();
|
||||
void Draw(BRect frame);
|
||||
|
||||
private:
|
||||
BBitmap *fIconBitmap;
|
||||
BBitmap *fClockBitmap;
|
||||
BSlider *fDelaySlider;
|
||||
BSlider *fRepeatSlider;
|
||||
};
|
||||
|
||||
#endif
|
||||
@@ -7,14 +7,16 @@
|
||||
*/
|
||||
|
||||
|
||||
#include "MouseSettings.h"
|
||||
|
||||
#include <FindDirectory.h>
|
||||
#include <File.h>
|
||||
#include <Path.h>
|
||||
#include <String.h>
|
||||
#include <View.h>
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
#include "MouseSettings.h"
|
||||
|
||||
// The R5 settings file differs from that of OpenBeOS;
|
||||
// the latter maps 16 different mouse buttons
|
||||
|
||||
@@ -11,6 +11,7 @@
|
||||
#define MOUSE_SETTINGS_H
|
||||
|
||||
|
||||
#include <Input.h>
|
||||
#include <InterfaceDefs.h>
|
||||
#include <Point.h>
|
||||
#include <SupportDefs.h>
|
||||
@@ -75,4 +76,4 @@ private:
|
||||
BPoint fWindowPosition;
|
||||
};
|
||||
|
||||
#endif // MOUSE_SETTINGS_H
|
||||
#endif // MOUSE_SETTINGS_H
|
||||
|
||||
@@ -29,7 +29,6 @@
|
||||
|
||||
#include "InputConstants.h"
|
||||
#include "MouseSettings.h"
|
||||
#include "InputWindow.h"
|
||||
|
||||
|
||||
static const int32 kButtonTop = 3;
|
||||
|
||||
@@ -60,4 +60,4 @@ private:
|
||||
};
|
||||
|
||||
|
||||
#endif /* MOUSE_VIEW_H */
|
||||
#endif /* MOUSE_VIEW_H */
|
||||
@@ -15,8 +15,8 @@
|
||||
#include <Bitmap.h>
|
||||
#include <Button.h>
|
||||
#include <CheckBox.h>
|
||||
#include <Slider.h>
|
||||
#include <PopUpMenu.h>
|
||||
#include <Slider.h>
|
||||
|
||||
|
||||
class MouseSettings;
|
||||
|
||||
Reference in New Issue
Block a user