Changeset 1087


Ignore:
Timestamp:
Nov 25, 2011, 12:30:26 AM (10 years ago)
Author:
sam
Message:

nacl: quick and dirty mouse support.

Location:
trunk
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/platform/nacl/nacl_instance.cpp

    r1084 r1087  
    1818#include <ppapi/cpp/module.h>
    1919#include <ppapi/cpp/completion_callback.h>
     20#include <ppapi/cpp/input_event.h>
    2021
    2122#include "core.h"
     
    3233      m_size(0, 0)
    3334{
    34     ;
     35    RequestInputEvents(PP_INPUTEVENT_CLASS_MOUSE);
    3536}
    3637
     
    102103}
    103104
     105bool NaClInstance::HandleInputEvent(const pp::InputEvent& event)
     106{
     107    switch (event.GetType())
     108    {
     109    case PP_INPUTEVENT_TYPE_MOUSEDOWN:
     110        Input::SetMouseButton(pp::MouseInputEvent(event).GetButton());
     111        break;
     112    case PP_INPUTEVENT_TYPE_MOUSEUP:
     113        Input::UnsetMouseButton(pp::MouseInputEvent(event).GetButton());
     114        break;
     115    case PP_INPUTEVENT_TYPE_MOUSEMOVE:
     116        Input::SetMousePos(ivec2(pp::MouseInputEvent(event).GetPosition().x(), opengl_context_->GetSize().height() - 1 - pp::MouseInputEvent(event).GetPosition().y()));
     117        break;
     118    default:
     119        break;
     120    }
     121    return true;
     122}
     123
    104124void NaClInstance::DrawSelf()
    105125{
  • trunk/src/platform/nacl/nacl_instance.h

    r1084 r1087  
    3737  //void InitializeMethods(ScriptingBridge* bridge);
    3838
     39
    3940  // Called to draw the contents of the module's browser area.
    40   void DrawSelf();
     41    virtual bool HandleInputEvent(const pp::InputEvent& event);
    4142
    42 // private:
    43   // Browser connectivity and scripting support.
    44 //  ScriptingBridge scripting_bridge_;
     43    void DrawSelf();
    4544
    46   SharedOpenGLContext opengl_context_;
     45    SharedOpenGLContext opengl_context_;
    4746
    4847    ivec2 m_size;
  • trunk/src/platform/nacl/opengl_context.h

    r1084 r1087  
    6262  void ResizeContext(const pp::Size& size);
    6363
     64  pp::Size const& GetSize() { return size_; }
     65
    6466  /// The OpenGL ES 2.0 interface.
    6567  const struct PPB_OpenGLES2* gles2() const {
  • trunk/test/tutorial/tut03.cpp

    r1086 r1087  
    8181            m_dirty[i] = 2;
    8282        }
    83 #if defined __CELLOS_LV2__ || defined __native_client__
     83#if defined __CELLOS_LV2__
    8484        //m_center = f64cmplx(-.22815528839841, -1.11514249704382);
    8585        //m_center = f64cmplx(0.001643721971153, 0.822467633298876);
     
    179179
    180180        ivec3 buttons = Input::GetMouseButtons();
    181 #if !defined __CELLOS_LV2__ && !defined __native_client__
     181#if !defined __CELLOS_LV2__
    182182        if ((buttons[0] || buttons[2]) && mousepos.x != -1)
    183183        {
     
    211211            }
    212212            m_radius *= zoom;
    213 #if !defined __CELLOS_LV2__ && !defined __native_client__
     213#if !defined __CELLOS_LV2__
    214214            m_center = (m_center - worldmouse) * zoom + worldmouse;
    215215            worldmouse = m_center + ScreenToWorldOffset(mousepos);
Note: See TracChangeset for help on using the changeset viewer.