Misc style changes
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@14575 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -23,60 +23,22 @@
|
|||||||
// Author: Marc Flerackers ([email protected])
|
// Author: Marc Flerackers ([email protected])
|
||||||
// Description: Functions and class to manage input devices.
|
// Description: Functions and class to manage input devices.
|
||||||
//------------------------------------------------------------------------------
|
//------------------------------------------------------------------------------
|
||||||
|
|
||||||
// Standard Includes -----------------------------------------------------------
|
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
// System Includes -------------------------------------------------------------
|
|
||||||
#include <Input.h>
|
#include <Input.h>
|
||||||
#include <Message.h>
|
|
||||||
#include <Errors.h>
|
|
||||||
#include <List.h>
|
#include <List.h>
|
||||||
|
#include <Message.h>
|
||||||
|
|
||||||
// Project Includes ------------------------------------------------------------
|
#include <input_globals.h>
|
||||||
#include "InputServerTypes.h"
|
#include <InputServerTypes.h>
|
||||||
|
|
||||||
// Local Includes --------------------------------------------------------------
|
|
||||||
|
|
||||||
// Local Defines ---------------------------------------------------------------
|
static BMessenger *sInputServer = NULL;
|
||||||
|
|
||||||
// Globals ---------------------------------------------------------------------
|
|
||||||
|
|
||||||
BMessenger *input_server=NULL;
|
BInputDevice *
|
||||||
|
find_input_device(const char *name)
|
||||||
_IMPEXP_BE status_t _control_input_server_(BMessage *command, BMessage *reply);
|
|
||||||
|
|
||||||
/*static bool PrintNameAndDelete(void *ptr)
|
|
||||||
{
|
|
||||||
if(ptr)
|
|
||||||
{
|
|
||||||
BInputDevice *dev = (BInputDevice *)ptr;
|
|
||||||
printf("* %s : %s\n", dev->Name(), dev->IsRunning() ? "running" : "not running");
|
|
||||||
delete dev;
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
void PrintDevices()
|
|
||||||
{
|
|
||||||
BList devices;
|
|
||||||
|
|
||||||
status_t err = get_input_devices(&devices);
|
|
||||||
|
|
||||||
if(err != B_OK)
|
|
||||||
printf("Error while getting input devices\n");
|
|
||||||
else
|
|
||||||
{
|
|
||||||
devices.DoForEach(PrintNameAndDelete);
|
|
||||||
devices.MakeEmpty();
|
|
||||||
}
|
|
||||||
}*/
|
|
||||||
|
|
||||||
//------------------------------------------------------------------------------
|
|
||||||
BInputDevice *find_input_device(const char *name)
|
|
||||||
{
|
{
|
||||||
BMessage command(IS_FIND_DEVICES);
|
BMessage command(IS_FIND_DEVICES);
|
||||||
BMessage reply;
|
BMessage reply;
|
||||||
@@ -100,8 +62,10 @@ BInputDevice *find_input_device(const char *name)
|
|||||||
|
|
||||||
return dev;
|
return dev;
|
||||||
}
|
}
|
||||||
//------------------------------------------------------------------------------
|
|
||||||
status_t get_input_devices(BList *list)
|
|
||||||
|
status_t
|
||||||
|
get_input_devices(BList *list)
|
||||||
{
|
{
|
||||||
list->MakeEmpty();
|
list->MakeEmpty();
|
||||||
|
|
||||||
@@ -117,8 +81,7 @@ status_t get_input_devices(BList *list)
|
|||||||
int32 type;
|
int32 type;
|
||||||
int32 i = 0;
|
int32 i = 0;
|
||||||
|
|
||||||
while (reply.FindString("device", i, &name) == B_OK)
|
while (reply.FindString("device", i, &name) == B_OK) {
|
||||||
{
|
|
||||||
reply.FindInt32("type", i++, &type);
|
reply.FindInt32("type", i++, &type);
|
||||||
|
|
||||||
BInputDevice *dev = new BInputDevice;
|
BInputDevice *dev = new BInputDevice;
|
||||||
@@ -130,8 +93,10 @@ status_t get_input_devices(BList *list)
|
|||||||
|
|
||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
//------------------------------------------------------------------------------
|
|
||||||
status_t watch_input_devices(BMessenger target, bool start)
|
|
||||||
|
status_t
|
||||||
|
watch_input_devices(BMessenger target, bool start)
|
||||||
{
|
{
|
||||||
BMessage command(IS_WATCH_DEVICES);
|
BMessage command(IS_WATCH_DEVICES);
|
||||||
BMessage reply;
|
BMessage reply;
|
||||||
@@ -141,24 +106,30 @@ status_t watch_input_devices(BMessenger target, bool start)
|
|||||||
|
|
||||||
return _control_input_server_(&command, &reply);
|
return _control_input_server_(&command, &reply);
|
||||||
}
|
}
|
||||||
//------------------------------------------------------------------------------
|
|
||||||
|
|
||||||
BInputDevice::~BInputDevice()
|
BInputDevice::~BInputDevice()
|
||||||
{
|
{
|
||||||
if (fName)
|
free(fName);
|
||||||
free (fName);
|
|
||||||
}
|
}
|
||||||
//------------------------------------------------------------------------------
|
|
||||||
const char *BInputDevice::Name() const
|
|
||||||
|
const char *
|
||||||
|
BInputDevice::Name() const
|
||||||
{
|
{
|
||||||
return fName;
|
return fName;
|
||||||
}
|
}
|
||||||
//------------------------------------------------------------------------------
|
|
||||||
input_device_type BInputDevice::Type() const
|
|
||||||
|
input_device_type
|
||||||
|
BInputDevice::Type() const
|
||||||
{
|
{
|
||||||
return fType;
|
return fType;
|
||||||
}
|
}
|
||||||
//------------------------------------------------------------------------------
|
|
||||||
bool BInputDevice::IsRunning() const
|
|
||||||
|
bool
|
||||||
|
BInputDevice::IsRunning() const
|
||||||
{
|
{
|
||||||
if (!fName)
|
if (!fName)
|
||||||
return false;
|
return false;
|
||||||
@@ -170,8 +141,10 @@ bool BInputDevice::IsRunning() const
|
|||||||
|
|
||||||
return _control_input_server_(&command, &reply) == B_OK;
|
return _control_input_server_(&command, &reply) == B_OK;
|
||||||
}
|
}
|
||||||
//------------------------------------------------------------------------------
|
|
||||||
status_t BInputDevice::Start()
|
|
||||||
|
status_t
|
||||||
|
BInputDevice::Start()
|
||||||
{
|
{
|
||||||
if (!fName)
|
if (!fName)
|
||||||
return B_ERROR;
|
return B_ERROR;
|
||||||
@@ -183,8 +156,10 @@ status_t BInputDevice::Start()
|
|||||||
|
|
||||||
return _control_input_server_(&command, &reply);
|
return _control_input_server_(&command, &reply);
|
||||||
}
|
}
|
||||||
//------------------------------------------------------------------------------
|
|
||||||
status_t BInputDevice::Stop()
|
|
||||||
|
status_t
|
||||||
|
BInputDevice::Stop()
|
||||||
{
|
{
|
||||||
if (!fName)
|
if (!fName)
|
||||||
return B_ERROR;
|
return B_ERROR;
|
||||||
@@ -196,8 +171,10 @@ status_t BInputDevice::Stop()
|
|||||||
|
|
||||||
return _control_input_server_(&command, &reply);
|
return _control_input_server_(&command, &reply);
|
||||||
}
|
}
|
||||||
//------------------------------------------------------------------------------
|
|
||||||
status_t BInputDevice::Control(uint32 code, BMessage *message)
|
|
||||||
|
status_t
|
||||||
|
BInputDevice::Control(uint32 code, BMessage *message)
|
||||||
{
|
{
|
||||||
if (!fName)
|
if (!fName)
|
||||||
return B_ERROR;
|
return B_ERROR;
|
||||||
@@ -218,8 +195,10 @@ status_t BInputDevice::Control(uint32 code, BMessage *message)
|
|||||||
|
|
||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
//------------------------------------------------------------------------------
|
|
||||||
status_t BInputDevice::Start(input_device_type type)
|
|
||||||
|
status_t
|
||||||
|
BInputDevice::Start(input_device_type type)
|
||||||
{
|
{
|
||||||
BMessage command(IS_START_DEVICE);
|
BMessage command(IS_START_DEVICE);
|
||||||
BMessage reply;
|
BMessage reply;
|
||||||
@@ -228,8 +207,10 @@ status_t BInputDevice::Start(input_device_type type)
|
|||||||
|
|
||||||
return _control_input_server_(&command, &reply);
|
return _control_input_server_(&command, &reply);
|
||||||
}
|
}
|
||||||
//------------------------------------------------------------------------------
|
|
||||||
status_t BInputDevice::Stop(input_device_type type)
|
|
||||||
|
status_t
|
||||||
|
BInputDevice::Stop(input_device_type type)
|
||||||
{
|
{
|
||||||
BMessage command(IS_STOP_DEVICE);
|
BMessage command(IS_STOP_DEVICE);
|
||||||
BMessage reply;
|
BMessage reply;
|
||||||
@@ -238,8 +219,10 @@ status_t BInputDevice::Stop(input_device_type type)
|
|||||||
|
|
||||||
return _control_input_server_(&command, &reply);
|
return _control_input_server_(&command, &reply);
|
||||||
}
|
}
|
||||||
//------------------------------------------------------------------------------
|
|
||||||
status_t BInputDevice::Control(input_device_type type, uint32 code,
|
|
||||||
|
status_t
|
||||||
|
BInputDevice::Control(input_device_type type, uint32 code,
|
||||||
BMessage *message)
|
BMessage *message)
|
||||||
{
|
{
|
||||||
BMessage command(IS_CONTROL_DEVICES);
|
BMessage command(IS_CONTROL_DEVICES);
|
||||||
@@ -258,17 +241,19 @@ status_t BInputDevice::Control(input_device_type type, uint32 code,
|
|||||||
|
|
||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
//------------------------------------------------------------------------------
|
|
||||||
|
|
||||||
BInputDevice::BInputDevice()
|
BInputDevice::BInputDevice()
|
||||||
{
|
{
|
||||||
fName = NULL;
|
fName = NULL;
|
||||||
fType = B_UNDEFINED_DEVICE;
|
fType = B_UNDEFINED_DEVICE;
|
||||||
}
|
}
|
||||||
//------------------------------------------------------------------------------
|
|
||||||
void BInputDevice::set_name_and_type(const char *name, input_device_type type)
|
|
||||||
|
void
|
||||||
|
BInputDevice::set_name_and_type(const char *name, input_device_type type)
|
||||||
{
|
{
|
||||||
if (fName)
|
if (fName) {
|
||||||
{
|
|
||||||
free (fName);
|
free (fName);
|
||||||
fName = NULL;
|
fName = NULL;
|
||||||
}
|
}
|
||||||
@@ -278,17 +263,18 @@ void BInputDevice::set_name_and_type(const char *name, input_device_type type)
|
|||||||
|
|
||||||
fType = type;
|
fType = type;
|
||||||
}
|
}
|
||||||
//------------------------------------------------------------------------------
|
|
||||||
status_t _control_input_server_(BMessage *command, BMessage *reply)
|
|
||||||
|
status_t
|
||||||
|
_control_input_server_(BMessage *command, BMessage *reply)
|
||||||
{
|
{
|
||||||
if (!input_server)
|
if (!sInputServer)
|
||||||
input_server = new BMessenger;
|
sInputServer = new BMessenger;
|
||||||
|
|
||||||
if (!input_server->IsValid())
|
if (!sInputServer->IsValid())
|
||||||
*input_server = BMessenger("application/x-vnd.Be-input_server", -1, NULL);
|
*sInputServer = BMessenger("application/x-vnd.Be-input_server", -1, NULL);
|
||||||
//*input_server = BMessenger("application/x-vnd.OBOS-input_server", -1, NULL);
|
|
||||||
|
|
||||||
status_t err = input_server->SendMessage(command, reply);
|
status_t err = sInputServer->SendMessage(command, reply);
|
||||||
|
|
||||||
if (err != B_OK)
|
if (err != B_OK)
|
||||||
return err;
|
return err;
|
||||||
@@ -298,4 +284,3 @@ status_t _control_input_server_(BMessage *command, BMessage *reply)
|
|||||||
|
|
||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
//------------------------------------------------------------------------------
|
|
||||||
|
|||||||
@@ -3766,7 +3766,7 @@ BView::InitData(BRect frame, const char *name, uint32 resizingMode, uint32 flags
|
|||||||
fPermanentState = NULL;
|
fPermanentState = NULL;
|
||||||
fState = new BPrivate::ViewState;
|
fState = new BPrivate::ViewState;
|
||||||
|
|
||||||
fBounds = frame.OffsetToCopy(0.0, 0.0);
|
fBounds = frame.OffsetToCopy(B_ORIGIN);
|
||||||
fShelf = NULL;
|
fShelf = NULL;
|
||||||
pr_state = NULL;
|
pr_state = NULL;
|
||||||
|
|
||||||
|
|||||||
@@ -28,7 +28,6 @@
|
|||||||
// BMallocIO and BMemoryIO classes implement the protocol,
|
// BMallocIO and BMemoryIO classes implement the protocol,
|
||||||
// as does BFile in the Storage Kit.
|
// as does BFile in the Storage Kit.
|
||||||
//------------------------------------------------------------------------------
|
//------------------------------------------------------------------------------
|
||||||
#include <algorithm>
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
@@ -251,17 +250,15 @@ BMemoryIO::Position() const
|
|||||||
status_t
|
status_t
|
||||||
BMemoryIO::SetSize(off_t size)
|
BMemoryIO::SetSize(off_t size)
|
||||||
{
|
{
|
||||||
status_t err = B_ERROR;
|
|
||||||
|
|
||||||
if (fReadOnly)
|
if (fReadOnly)
|
||||||
return B_NOT_ALLOWED;
|
return B_NOT_ALLOWED;
|
||||||
|
|
||||||
if (size <= fPhys) {
|
if (size > fPhys)
|
||||||
err = B_OK;
|
return B_ERROR;
|
||||||
fLen = size;
|
|
||||||
}
|
|
||||||
|
|
||||||
return err;
|
fLen = size;
|
||||||
|
|
||||||
|
return B_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user