2002-07-09 16:24:59 +04:00
|
|
|
/*****************************************************************************/
|
|
|
|
// OpenBeOS input_server Backend Application
|
|
|
|
//
|
|
|
|
// This is the primary application class for the OpenBeOS input_server.
|
|
|
|
//
|
|
|
|
//
|
|
|
|
// Copyright (c) 2001 OpenBeOS Project
|
|
|
|
//
|
|
|
|
// Permission is hereby granted, free of charge, to any person obtaining a
|
|
|
|
// copy of this software and associated documentation files (the "Software"),
|
|
|
|
// to deal in the Software without restriction, including without limitation
|
|
|
|
// the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
|
|
|
// and/or sell copies of the Software, and to permit persons to whom the
|
|
|
|
// Software is furnished to do so, subject to the following conditions:
|
|
|
|
//
|
|
|
|
// The above copyright notice and this permission notice shall be included
|
|
|
|
// in all copies or substantial portions of the Software.
|
|
|
|
//
|
|
|
|
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
|
|
|
// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
|
|
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
|
|
|
// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
|
|
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
|
|
|
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
|
|
|
// DEALINGS IN THE SOFTWARE.
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
|
|
|
|
|
|
#ifndef INPUTSERVERAPP_H
|
|
|
|
#define INPUTSERVERAPP_H
|
|
|
|
|
|
|
|
// BeAPI Headers
|
|
|
|
#include <Application.h>
|
|
|
|
#include "InputServerDevice.h"
|
2002-07-18 06:12:24 +04:00
|
|
|
#include "InputServerFilter.h"
|
|
|
|
#include "InputServerMethod.h"
|
2004-08-19 20:00:09 +04:00
|
|
|
#include "AddOnManager.h"
|
2002-07-18 06:12:24 +04:00
|
|
|
|
2002-07-09 16:24:59 +04:00
|
|
|
#include <stdlib.h>
|
|
|
|
#include <string.h>
|
|
|
|
#include <unistd.h>
|
2002-07-18 06:12:24 +04:00
|
|
|
#include <Locker.h>
|
2002-07-09 16:24:59 +04:00
|
|
|
|
|
|
|
#include <Debug.h>
|
|
|
|
#include <FindDirectory.h>
|
|
|
|
#include <InterfaceDefs.h>
|
|
|
|
#include <Message.h>
|
|
|
|
#include <OS.h>
|
|
|
|
#include <SupportDefs.h>
|
|
|
|
|
2004-08-12 16:43:36 +04:00
|
|
|
class BPortLink;
|
2002-07-18 06:12:24 +04:00
|
|
|
|
|
|
|
class InputDeviceListItem
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
BInputServerDevice* mIsd;
|
|
|
|
input_device_ref* mDev;
|
|
|
|
|
|
|
|
InputDeviceListItem(BInputServerDevice* isd, input_device_ref* dev):
|
|
|
|
mIsd(isd), mDev(dev) {};
|
|
|
|
};
|
2002-07-09 16:24:59 +04:00
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
// InputServer
|
|
|
|
//
|
|
|
|
// Application class for input_server.
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
|
|
class InputServer : public BApplication
|
|
|
|
{
|
|
|
|
typedef BApplication Inherited;
|
|
|
|
public:
|
|
|
|
InputServer(void);
|
2004-04-01 12:57:07 +04:00
|
|
|
virtual ~InputServer(void);
|
2002-07-09 16:24:59 +04:00
|
|
|
|
2004-04-01 12:57:07 +04:00
|
|
|
virtual void ArgvReceived(long, char**);
|
2002-07-09 16:24:59 +04:00
|
|
|
|
|
|
|
void InitKeyboardMouseStates(void);
|
|
|
|
|
|
|
|
void InitDevices(void);
|
|
|
|
void InitFilters(void);
|
|
|
|
void InitMethods(void);
|
|
|
|
|
2004-04-01 12:57:07 +04:00
|
|
|
virtual bool QuitRequested(void);
|
|
|
|
virtual void ReadyToRun(void);
|
2002-07-09 16:24:59 +04:00
|
|
|
//thread_id Run(void);
|
2004-04-01 12:57:07 +04:00
|
|
|
virtual void MessageReceived(BMessage*);
|
2002-07-09 16:24:59 +04:00
|
|
|
|
|
|
|
void HandleSetMethod(BMessage*);
|
2004-08-18 19:38:30 +04:00
|
|
|
void HandleGetSetMouseType(BMessage*, BMessage*);
|
|
|
|
void HandleGetSetMouseAcceleration(BMessage*, BMessage*);
|
|
|
|
void HandleGetSetKeyRepeatDelay(BMessage*, BMessage*);
|
2002-07-09 16:24:59 +04:00
|
|
|
void HandleGetKeyInfo(BMessage*, BMessage*);
|
|
|
|
void HandleGetModifiers(BMessage*, BMessage*);
|
|
|
|
void HandleSetModifierKey(BMessage*, BMessage*);
|
|
|
|
void HandleSetKeyboardLocks(BMessage*, BMessage*);
|
2004-08-18 19:38:30 +04:00
|
|
|
void HandleGetSetMouseSpeed(BMessage*, BMessage*);
|
2002-07-09 16:24:59 +04:00
|
|
|
void HandleSetMousePosition(BMessage*, BMessage*);
|
2004-08-18 19:38:30 +04:00
|
|
|
void HandleGetSetMouseMap(BMessage*, BMessage*);
|
2002-07-09 16:24:59 +04:00
|
|
|
void HandleGetKeyboardID(BMessage*, BMessage*);
|
2002-09-30 21:52:57 +04:00
|
|
|
void HandleGetClickSpeed(BMessage*, BMessage*);
|
|
|
|
void HandleSetClickSpeed(BMessage*, BMessage*);
|
2004-08-18 19:38:30 +04:00
|
|
|
void HandleGetSetKeyRepeatRate(BMessage*, BMessage*);
|
2002-07-09 16:24:59 +04:00
|
|
|
void HandleGetSetKeyMap(BMessage*, BMessage*);
|
|
|
|
void HandleFocusUnfocusIMAwareView(BMessage*, BMessage*);
|
|
|
|
|
2004-08-18 19:38:30 +04:00
|
|
|
void HandleFindDevices(BMessage*, BMessage*);
|
|
|
|
void HandleWatchDevices(BMessage*, BMessage*);
|
|
|
|
void HandleIsDeviceRunning(BMessage*, BMessage*);
|
|
|
|
void HandleStartStopDevices(BMessage*, BMessage*);
|
|
|
|
void HandleControlDevices(BMessage*, BMessage*);
|
|
|
|
void HandleSystemShuttingDown(BMessage*, BMessage*);
|
|
|
|
void HandleNodeMonitor(BMessage*);
|
|
|
|
|
2002-07-09 16:24:59 +04:00
|
|
|
status_t EnqueueDeviceMessage(BMessage*);
|
|
|
|
status_t EnqueueMethodMessage(BMessage*);
|
|
|
|
status_t UnlockMethodQueue(void);
|
|
|
|
status_t LockMethodQueue(void);
|
|
|
|
status_t SetNextMethod(bool);
|
|
|
|
//SetActiveMethod(_BMethodAddOn_*);
|
|
|
|
const BMessenger* MethodReplicant(void);
|
|
|
|
|
|
|
|
status_t EventLoop(void*);
|
2002-07-18 06:12:24 +04:00
|
|
|
static bool EventLoopRunning(void);
|
2002-07-09 16:24:59 +04:00
|
|
|
|
|
|
|
bool DispatchEvents(BList*);
|
2002-07-18 06:12:24 +04:00
|
|
|
int DispatchEvent(BMessage*);
|
2002-07-09 16:24:59 +04:00
|
|
|
bool CacheEvents(BList*);
|
|
|
|
const BList* GetNextEvents(BList*);
|
|
|
|
bool FilterEvents(BList*);
|
|
|
|
bool SanitizeEvents(BList*);
|
|
|
|
bool MethodizeEvents(BList*, bool);
|
|
|
|
|
2002-07-18 06:12:24 +04:00
|
|
|
static status_t StartStopDevices(const char *, input_device_type, bool);
|
2002-07-09 16:24:59 +04:00
|
|
|
status_t ControlDevices(const char *, input_device_type, unsigned long, BMessage*);
|
|
|
|
|
|
|
|
bool DoMouseAcceleration(long*, long*);
|
|
|
|
bool SetMousePos(long*, long*, long, long);
|
|
|
|
bool SetMousePos(long*, long*, BPoint);
|
|
|
|
bool SetMousePos(long*, long*, float, float);
|
|
|
|
|
|
|
|
bool SafeMode(void);
|
|
|
|
|
2002-07-18 06:12:24 +04:00
|
|
|
static BList gInputDeviceList;
|
|
|
|
static BLocker gInputDeviceListLocker;
|
|
|
|
|
2002-07-09 16:24:59 +04:00
|
|
|
private:
|
2002-07-18 06:12:24 +04:00
|
|
|
void InitTestDevice();
|
|
|
|
|
2002-07-09 16:24:59 +04:00
|
|
|
status_t AddInputServerDevice(const char* path);
|
2002-07-18 06:12:24 +04:00
|
|
|
status_t AddInputServerFilter(const char* path);
|
|
|
|
status_t AddInputServerMethod(const char* path);
|
2002-07-09 16:24:59 +04:00
|
|
|
|
2002-07-18 06:12:24 +04:00
|
|
|
bool sEventLoopRunning;
|
|
|
|
bool sSafeMode;
|
|
|
|
port_id sEventPort;
|
|
|
|
BPoint sMousePos;
|
2002-09-30 21:52:57 +04:00
|
|
|
int32 sMouseType;
|
|
|
|
int32 sMouseSpeed;
|
|
|
|
int32 sMouseAcceleration;
|
|
|
|
bigtime_t sMouseClickSpeed;
|
|
|
|
int32 sKeyRepeatRate;
|
|
|
|
bigtime_t sKeyRepeatDelay;
|
|
|
|
mouse_map sMouseMap;
|
2002-07-09 16:24:59 +04:00
|
|
|
|
2002-07-18 06:12:24 +04:00
|
|
|
port_id ISPort;
|
|
|
|
port_id EventLooperPort;
|
|
|
|
thread_id ISPortThread;
|
|
|
|
static int32 ISPortWatcher(void *arg);
|
2002-07-09 16:24:59 +04:00
|
|
|
void WatchPort();
|
2002-07-18 06:12:24 +04:00
|
|
|
|
|
|
|
static bool doStartStopDevice(void*, void*);
|
|
|
|
|
|
|
|
static BList mInputServerDeviceList;
|
|
|
|
static BList mInputServerFilterList;
|
|
|
|
static BList mInputServerMethodList;
|
|
|
|
|
|
|
|
// added this to communicate via portlink
|
|
|
|
|
2004-08-12 16:43:36 +04:00
|
|
|
BPortLink *serverlink;
|
2004-08-19 20:00:09 +04:00
|
|
|
AddOnManager *fAddOnManager;
|
2002-07-18 06:12:24 +04:00
|
|
|
|
2002-07-09 16:24:59 +04:00
|
|
|
//fMouseState;
|
|
|
|
};
|
|
|
|
|
2002-07-18 06:12:24 +04:00
|
|
|
|
2002-09-28 14:43:52 +04:00
|
|
|
#endif
|